Re: [Linux-stm32] [PATCH V4] nvmem: add explicit config option to read old syntax fixed OF cells

From: Rafał Miłecki
Date: Tue Jul 18 2023 - 05:57:20 EST


Hi Ahmad,

On 2023-07-18 11:08, Ahmad Fatoum wrote:
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 60670b2f70b9..334adbae3690 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -522,6 +522,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
config.dev = &mtd->dev;
config.name = dev_name(&mtd->dev);
config.owner = THIS_MODULE;
+ config.add_legacy_fixed_of_cells = of_device_is_compatible(node, "nvmem-cells");

How does the new binding look like in this situation?

Before it was:

&{flash/partitions} {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
compatible = "nvmem-cells";
reg = <0 0x100>;
#address-cells = <1>;
#size-cells = <1>;

calib@1 {
reg = <1 1>;
};
}
};

It it now the same, but s/"nvmem-cells"/"fixed-layout"/ ?

Please take a look at those commits and examples:

bd912c991d2e ("dt-bindings: nvmem: layouts: add fixed-layout")
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bd912c991d2ef079a32558f057b8663bcf1fb6fc

fa7fbe53ecdc ("dt-bindings: nvmem: convert base example to use NVMEM fixed cells layout")
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fa7fbe53ecdc4e7d549a9f73a40e257b0046b4b9


Basically you need a "nvmem-layout" node with:
compatible = "fixed-layout";

So in your case that would be:

&{flash/partitions} {
compatible = "fixed-partitions";

partition@0 {
reg = <0 0x100>;

nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

calib@1 {
reg = <1 1>;
};
};
}
};