804-v5.14-0001-nvmem-core-allow-specifying-of_node.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 1333a6779501f4cc662ff5c8b36b0a22f3a7ddc6 Mon Sep 17 00:00:00 2001
  2. From: Michael Walle <[email protected]>
  3. Date: Sat, 24 Apr 2021 13:06:04 +0200
  4. Subject: [PATCH] nvmem: core: allow specifying of_node
  5. Until now, the of_node of the parent device is used. Some devices
  6. provide more than just the nvmem provider. To avoid name space clashes,
  7. add a way to allow specifying the nvmem cells in subnodes. Consider the
  8. following example:
  9. flash@0 {
  10. compatible = "jedec,spi-nor";
  11. partitions {
  12. compatible = "fixed-partitions";
  13. #address-cells = <1>;
  14. #size-cells = <1>;
  15. partition@0 {
  16. reg = <0x000000 0x010000>;
  17. };
  18. };
  19. otp {
  20. compatible = "user-otp";
  21. #address-cells = <1>;
  22. #size-cells = <1>;
  23. serial-number@0 {
  24. reg = <0x0 0x8>;
  25. };
  26. };
  27. };
  28. There the nvmem provider might be the MTD partition or the OTP region of
  29. the flash.
  30. Add a new config->of_node parameter, which if set, will be used instead
  31. of the parent's of_node.
  32. Signed-off-by: Michael Walle <[email protected]>
  33. Acked-by: Srinivas Kandagatla <[email protected]>
  34. Signed-off-by: Miquel Raynal <[email protected]>
  35. Link: https://lore.kernel.org/linux-mtd/[email protected]
  36. ---
  37. drivers/nvmem/core.c | 4 +++-
  38. include/linux/nvmem-provider.h | 2 ++
  39. 2 files changed, 5 insertions(+), 1 deletion(-)
  40. --- a/drivers/nvmem/core.c
  41. +++ b/drivers/nvmem/core.c
  42. @@ -795,7 +795,9 @@ struct nvmem_device *nvmem_register(cons
  43. nvmem->reg_write = config->reg_write;
  44. nvmem->keepout = config->keepout;
  45. nvmem->nkeepout = config->nkeepout;
  46. - if (!config->no_of_node)
  47. + if (config->of_node)
  48. + nvmem->dev.of_node = config->of_node;
  49. + else if (!config->no_of_node)
  50. nvmem->dev.of_node = config->dev->of_node;
  51. switch (config->id) {
  52. --- a/include/linux/nvmem-provider.h
  53. +++ b/include/linux/nvmem-provider.h
  54. @@ -57,6 +57,7 @@ struct nvmem_keepout {
  55. * @type: Type of the nvmem storage
  56. * @read_only: Device is read-only.
  57. * @root_only: Device is accessibly to root only.
  58. + * @of_node: If given, this will be used instead of the parent's of_node.
  59. * @no_of_node: Device should not use the parent's of_node even if it's !NULL.
  60. * @reg_read: Callback to read data.
  61. * @reg_write: Callback to write data.
  62. @@ -87,6 +88,7 @@ struct nvmem_config {
  63. enum nvmem_type type;
  64. bool read_only;
  65. bool root_only;
  66. + struct device_node *of_node;
  67. bool ignore_wp;
  68. bool no_of_node;
  69. nvmem_reg_read_t reg_read;