[PATCH] mtd: spi-nor: xmc: add block protection support

XMC SPI-NOR Block Protection Support

Hi OpenWrt developers,

Problem

The XM25QH128A flash chip on Dragonglass DGR7 boards (and potentially other devices using XMC/XM25Q series SPI NOR) has block protection bits (BP0-BP3) set by the vendor U-Boot. The kernel's spi-nor driver currently lacks unlock support for XMC chips, causing Failed to erase block errors during sysupgrade and preventing flash write operations.

Fix

This patch adds SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB flags to all XMC (XM25Qx) parts in drivers/mtd/spi-nor/xmc.c. This enables the kernel to:

  • Detect the block protection status
  • Unlock the protected blocks before erase/write operations
  • Restore protection after completion

Testing

Verified on actual DGR7 (MT7621A, XM25QH128A) hardware. Before the patch, mtd erase firmware consistently failed. After the patch, erase and write operations work reliably.

Patch passes checkpatch.pl with 0 errors, 0 warnings.

Would appreciate any review. Thanks!

— Ivan Lee