From: Rafał Miłecki Date: Wed, 27 Mar 2024 23:03:34 +0000 (+0100) Subject: kernel: fix NVMEM looking for OTP NVMEM cells in wrong DT node X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=dd78a59cd7b029560b33cb3ac0e1aa8b747bd807;p=openwrt%2Fstaging%2Fblocktrron.git kernel: fix NVMEM looking for OTP NVMEM cells in wrong DT node It was breaking NAND controllers drivers. Signed-off-by: Rafał Miłecki --- diff --git a/target/linux/generic/pending-6.6/440-mtd-don-t-look-for-OTP-legacy-NVMEM-cells-if-proper-.patch b/target/linux/generic/pending-6.6/440-mtd-don-t-look-for-OTP-legacy-NVMEM-cells-if-proper-.patch new file mode 100644 index 0000000000..d9d15a4048 --- /dev/null +++ b/target/linux/generic/pending-6.6/440-mtd-don-t-look-for-OTP-legacy-NVMEM-cells-if-proper-.patch @@ -0,0 +1,44 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Wed, 27 Mar 2024 23:18:51 +0100 +Subject: [PATCH] mtd: don't look for OTP legacy NVMEM cells if proper node + doesn't exist +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If node with "user-otp" / "factory-otp" compatible doesn't exist it's +important to prevent NVMEM core from looking for legacy NVMEM cells. +Otherwise it would look for them in the device node. + +This fixes treating NAND controller attached chips as NVMEM cell. +Problem example: +[ 0.410107] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xdc +[ 0.416531] nand: Macronix MX30LF4G18AC +[ 0.420409] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 +[ 0.428022] iproc_nand 18028000.nand-controller: detected 512MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-8 +[ 0.438991] Scanning device for bad blocks +(...) +[ 2.848418] nvmem user-otp1: nvmem: invalid reg on /nand-controller@18028000/nand@0 +[ 2.856126] iproc_nand 18028000.nand-controller: error -EINVAL: Failed to register OTP NVMEM device + +This long standing issue was exposed by the support for Macronix OTP. + +Reported-by: Christian Marangi +Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support") +Fixes: e87161321a40 ("mtd: rawnand: macronix: OTP access for MX30LFxG18AC") +Signed-off-by: Rafał Miłecki +--- + drivers/mtd/mtdcore.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/mtdcore.c ++++ b/drivers/mtd/mtdcore.c +@@ -931,7 +931,7 @@ static struct nvmem_device *mtd_otp_nvme + config.name = compatible; + config.id = NVMEM_DEVID_AUTO; + config.owner = THIS_MODULE; +- config.add_legacy_fixed_of_cells = true; ++ config.add_legacy_fixed_of_cells = !!np; + config.type = NVMEM_TYPE_OTP; + config.root_only = true; + config.ignore_wp = true;