440-mtd-don-t-look-for-OTP-legacy-NVMEM-cells-if-proper-.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  2. Date: Wed, 27 Mar 2024 23:18:51 +0100
  3. Subject: [PATCH] mtd: don't look for OTP legacy NVMEM cells if proper node
  4. doesn't exist
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. If node with "user-otp" / "factory-otp" compatible doesn't exist it's
  9. important to prevent NVMEM core from looking for legacy NVMEM cells.
  10. Otherwise it would look for them in the device node.
  11. This fixes treating NAND controller attached chips as NVMEM cell.
  12. Problem example:
  13. [ 0.410107] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xdc
  14. [ 0.416531] nand: Macronix MX30LF4G18AC
  15. [ 0.420409] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
  16. [ 0.428022] iproc_nand 18028000.nand-controller: detected 512MiB total, 128KiB blocks, 2KiB pages, 16B OOB, 8-bit, BCH-8
  17. [ 0.438991] Scanning device for bad blocks
  18. (...)
  19. [ 2.848418] nvmem user-otp1: nvmem: invalid reg on /nand-controller@18028000/nand@0
  20. [ 2.856126] iproc_nand 18028000.nand-controller: error -EINVAL: Failed to register OTP NVMEM device
  21. This long standing issue was exposed by the support for Macronix OTP.
  22. Reported-by: Christian Marangi <[email protected]>
  23. Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
  24. Fixes: e87161321a40 ("mtd: rawnand: macronix: OTP access for MX30LFxG18AC")
  25. Signed-off-by: Rafał Miłecki <[email protected]>
  26. ---
  27. drivers/mtd/mtdcore.c | 2 +-
  28. 1 file changed, 1 insertion(+), 1 deletion(-)
  29. --- a/drivers/mtd/mtdcore.c
  30. +++ b/drivers/mtd/mtdcore.c
  31. @@ -931,7 +931,7 @@ static struct nvmem_device *mtd_otp_nvme
  32. config.name = compatible;
  33. config.id = NVMEM_DEVID_AUTO;
  34. config.owner = THIS_MODULE;
  35. - config.add_legacy_fixed_of_cells = true;
  36. + config.add_legacy_fixed_of_cells = !!np;
  37. config.type = NVMEM_TYPE_OTP;
  38. config.root_only = true;
  39. config.ignore_wp = true;