nvmem: add explicit config option to read old syntax fixed OF cells
Subsystems (18)
PATCH v4 1/1 nvmem: add explicit config option to read old syntax fixed OF cells
From: Rafał Miłecki <[email protected]>
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
---
This is based on top of them
[PATCH V6 3/3] nvmem: core: add support for fixed cells *layout*
V2: Fix stm32-romem.c typo breaking its compilation
Pick Martin's Acked-by
Add paragraph about layouts deprecating add_legacy_fixed_of_cells
V3: Update commit description:
1. Make it clear we're NOT dropping fixed cells support
2. Use nicer words (s/made sense/was totally safe/)
3. Explain fixed cells layout thing
4. Add paragraph with purpose of this commit
V4: Completely rewrite commit message.
Rename config option to "add_legacy_fixed_of_cells".
--- drivers/mtd/mtdcore.c | 2 ++ drivers/nvmem/apple-efuses.c | 1 + drivers/nvmem/core.c | 8 +++++--- drivers/nvmem/imx-ocotp-scu.c | 1 + drivers/nvmem/imx-ocotp.c | 1 + drivers/nvmem/meson-efuse.c | 1 + drivers/nvmem/meson-mx-efuse.c | 1 + drivers/nvmem/microchip-otpc.c | 1 + drivers/nvmem/mtk-efuse.c | 1 + drivers/nvmem/qcom-spmi-sdam.c | 1 + drivers/nvmem/qfprom.c | 1 + drivers/nvmem/rave-sp-eeprom.c | 1 + drivers/nvmem/rockchip-efuse.c | 1 + drivers/nvmem/sc27xx-efuse.c | 1 + drivers/nvmem/sprd-efuse.c | 1 + drivers/nvmem/stm32-romem.c | 1 + drivers/nvmem/sunplus-ocotp.c | 1 + drivers/nvmem/sunxi_sid.c | 1 + drivers/nvmem/uniphier-efuse.c | 1 + drivers/nvmem/zynqmp_nvmem.c | 1 + drivers/rtc/nvmem.c | 1 + drivers/w1/slaves/w1_ds250x.c | 1 + include/linux/nvmem-provider.h | 2 ++ 23 files changed, 29 insertions(+), 3 deletions(-)
drivers/mtd/mtdcore.c +2 -0
@@ -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" ); config.reg_read = mtd_nvmem_reg_read; config.size = mtd->size; config.word_size =1 ;
@@ -889,6 +890,7 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, config.name = compatible; config.id =NVMEM_DEVID_AUTO ; config.owner =THIS_MODULE ; + config.add_legacy_fixed_of_cells = true; config.type =NVMEM_TYPE_OTP ; config.root_only = true; config.ignore_wp = true;
drivers/nvmem/apple-efuses.c +1 -0
@@ -36,6 +36,7 @@ static int apple_efuses_probe(struct platform_device *pdev)struct resource *res;struct nvmem_config config = { .dev = &pdev->dev, + .add_legacy_fixed_of_cells = true, .read_only = true, .reg_read = apple_efuses_read, .stride =sizeof (u32),
drivers/nvmem/core.c +5 -3
@@ -994,9 +994,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)if (rval) goto err_remove_cells; - rval =nvmem_add_cells_from_legacy_of (nvmem); -if (rval) - goto err_remove_cells; +if (config->add_legacy_fixed_of_cells) { + rval =nvmem_add_cells_from_legacy_of (nvmem); +if (rval) + goto err_remove_cells; + }dev_dbg (&nvmem->dev,"Registering nvmem device %s\n" , config->name);
drivers/nvmem/imx-ocotp-scu.c +1 -0
@@ -220,6 +220,7 @@ static int imx_scu_ocotp_write(void *context, unsigned int offset,static struct nvmem_config imx_scu_ocotp_nvmem_config = { .name ="imx-scu-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = false, .word_size =4 , .stride =1 ,
drivers/nvmem/imx-ocotp.c +1 -0
@@ -621,6 +621,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)return PTR_ERR (priv->clk); priv->params =of_device_get_match_data (&pdev->dev); + imx_ocotp_nvmem_config.add_legacy_fixed_of_cells = true; imx_ocotp_nvmem_config.size =4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv;
drivers/nvmem/meson-efuse.c +1 -0
@@ -93,6 +93,7 @@ static int meson_efuse_probe(struct platform_device *pdev) econfig->dev = dev; econfig->name =dev_name (dev); + econfig->add_legacy_fixed_of_cells = true; econfig->stride =1 ; econfig->word_size =1 ; econfig->reg_read = meson_efuse_read;
drivers/nvmem/meson-mx-efuse.c +1 -0
@@ -213,6 +213,7 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) efuse->config.owner =THIS_MODULE ; efuse->config.dev = &pdev->dev; efuse->config.priv = efuse; + efuse->config.add_legacy_fixed_of_cells = true; efuse->config.stride = drvdata->word_size; efuse->config.word_size = drvdata->word_size; efuse->config.size =SZ_512 ;
drivers/nvmem/microchip-otpc.c +1 -0
@@ -261,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev)return ret; mchp_nvmem_config.dev = otpc->dev; + mchp_nvmem_config.add_legacy_fixed_of_cells = true; mchp_nvmem_config.size = size; mchp_nvmem_config.priv = otpc; nvmem =devm_nvmem_register (&pdev->dev, &mchp_nvmem_config);
drivers/nvmem/mtk-efuse.c +1 -0
@@ -83,6 +83,7 @@ static int mtk_efuse_probe(struct platform_device *pdev)return PTR_ERR (priv->base); pdata =device_get_match_data (dev); + econfig.add_legacy_fixed_of_cells = true; econfig.stride =1 ; econfig.word_size =1 ; econfig.reg_read = mtk_reg_read;
drivers/nvmem/qcom-spmi-sdam.c +1 -0
@@ -142,6 +142,7 @@ static int sdam_probe(struct platform_device *pdev) sdam->sdam_config.name ="spmi_sdam" ; sdam->sdam_config.id =NVMEM_DEVID_AUTO ; sdam->sdam_config.owner =THIS_MODULE ; + sdam->sdam_config.add_legacy_fixed_of_cells = true; sdam->sdam_config.stride =1 ; sdam->sdam_config.word_size =1 ; sdam->sdam_config.reg_read = sdam_read;
drivers/nvmem/qfprom.c +1 -0
@@ -357,6 +357,7 @@ static int qfprom_probe(struct platform_device *pdev) {struct nvmem_config econfig = { .name ="qfprom" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .id =NVMEM_DEVID_AUTO ,
drivers/nvmem/rave-sp-eeprom.c +1 -0
@@ -328,6 +328,7 @@ static int rave_sp_eeprom_probe(struct platform_device *pdev)of_property_read_string (np,"zii,eeprom-name" , &config.name); config.priv = eeprom; config.dev = dev; + config.add_legacy_fixed_of_cells = true; config.size = size; config.reg_read = rave_sp_eeprom_reg_read; config.reg_write = rave_sp_eeprom_reg_write;
drivers/nvmem/rockchip-efuse.c +1 -0
@@ -205,6 +205,7 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset,static struct nvmem_config econfig = { .name ="rockchip-efuse" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .read_only = true,
drivers/nvmem/sc27xx-efuse.c +1 -0
@@ -248,6 +248,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev) econfig.reg_read = sc27xx_efuse_read; econfig.priv = efuse; econfig.dev = &pdev->dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (&pdev->dev, &econfig);if (IS_ERR (nvmem)) {dev_err (&pdev->dev,"failed to register nvmem config\n" );
drivers/nvmem/sprd-efuse.c +1 -0
@@ -408,6 +408,7 @@ static int sprd_efuse_probe(struct platform_device *pdev) econfig.read_only = false; econfig.name ="sprd-efuse" ; econfig.size = efuse->data->blk_nums *SPRD_EFUSE_BLOCK_WIDTH ; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = sprd_efuse_read; econfig.reg_write = sprd_efuse_write; econfig.priv = efuse;
drivers/nvmem/stm32-romem.c +1 -0
@@ -208,6 +208,7 @@ static int stm32_romem_probe(struct platform_device *pdev) priv->cfg.priv = priv; priv->cfg.owner =THIS_MODULE ; priv->cfg.type =NVMEM_TYPE_OTP ; + priv->cfg.add_legacy_fixed_of_cells = true; priv->lower =0 ;
drivers/nvmem/sunplus-ocotp.c +1 -0
@@ -145,6 +145,7 @@ static int sp_ocotp_read(void *priv, unsigned int offset, void *value, size_t bystatic struct nvmem_config sp_ocotp_nvmem_config = { .name ="sp-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = true, .word_size =1 , .size =QAC628_OTP_SIZE ,
drivers/nvmem/sunxi_sid.c +1 -0
@@ -156,6 +156,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) nvmem_cfg->dev = dev; nvmem_cfg->name ="sunxi-sid" ; nvmem_cfg->type =NVMEM_TYPE_OTP ; + nvmem_cfg->add_legacy_fixed_of_cells = true; nvmem_cfg->read_only = true; nvmem_cfg->size = cfg->size; nvmem_cfg->word_size =1 ;
drivers/nvmem/uniphier-efuse.c +1 -0
@@ -53,6 +53,7 @@ static int uniphier_efuse_probe(struct platform_device *pdev) econfig.size =resource_size (res); econfig.priv = priv; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, &econfig);return PTR_ERR_OR_ZERO (nvmem);
drivers/nvmem/zynqmp_nvmem.c +1 -0
@@ -58,6 +58,7 @@ static int zynqmp_nvmem_probe(struct platform_device *pdev) priv->dev = dev; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = zynqmp_nvmem_read; econfig.priv = priv;
drivers/rtc/nvmem.c +1 -0
@@ -21,6 +21,7 @@ int devm_rtc_nvmem_register(struct rtc_device *rtc, nvmem_config->dev = dev; nvmem_config->owner = rtc->owner; + nvmem_config->add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, nvmem_config);if (IS_ERR (nvmem))dev_err (dev,"failed to register nvmem device for RTC\n" );
drivers/w1/slaves/w1_ds250x.c +1 -0
@@ -168,6 +168,7 @@ static int w1_eprom_add_slave(struct w1_slave *sl)struct nvmem_device *nvmem;struct nvmem_config nvmem_cfg = { .dev = &sl->dev, + .add_legacy_fixed_of_cells = true, .reg_read = w1_nvmem_read, .type =NVMEM_TYPE_OTP , .read_only = true,
include/linux/nvmem-provider.h +2 -0
@@ -82,6 +82,7 @@ struct nvmem_cell_info {* @owner: Pointer to exporter module. Used for refcounting. * @cells: Optional array of pre-defined NVMEM cells. * @ncells: Number of elements in cells. +* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax. * @keepout: Optional array of keepout ranges (sorted ascending by start). * @nkeepout: Number of elements in the keepout array. * @type: Type of the nvmem storage
@@ -112,6 +113,7 @@ struct nvmem_config {struct module *owner;const struct nvmem_cell_info *cells;int ncells; +bool add_legacy_fixed_of_cells;const struct nvmem_keepout *keepout;unsigned int nkeepout;enum nvmem_type type;
Signature · 1 line
2.34.1
Dne torek, 04. april 2023 ob 00:55:40 CEST je Rafał Miłecki napisal(a):
Quoted 54 lines
From: Rafał Miłecki <[email protected]>
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
Signed-off-by Rafał Miłecki <[email protected]>[for meson-{efuse,mx-efuse}.c][for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]Reviewed-by AngeloGioacchino Del Regno<[email protected]> [MT8192, MT8195 Chromebooks]
Tested-by: AngeloGioacchino Del Regno <[email protected]> [formicrochip-otpc.c]Reviewed-by Claudiu Beznea <[email protected]>[SAMA7G5-EK]Tested-by Claudiu Beznea <[email protected]>---
This is based on top of them
[PATCH V6 3/3] nvmem: core: add support for fixed cells *layout*V2: Fix
stm32-romem.ctypo breaking its compilation
Pick Martin's Acked-by
Add paragraph about layouts deprecatingadd_legacy_fixed_of_cells
V3: Update commit description:
1. Make it clear we're NOT dropping fixed cells support
2. Use nicer words (s/made sense/was totally safe/)
3. Explain fixed cells layout thing
4. Add paragraph with purpose of this commit
V4: Completely rewrite commit message.
Rename config option to "add_legacy_fixed_of_cells".--- drivers/mtd/mtdcore.c | 2 ++ drivers/nvmem/apple-efuses.c | 1 + drivers/nvmem/core.c | 8 +++++--- drivers/nvmem/imx-ocotp-scu.c | 1 + drivers/nvmem/imx-ocotp.c | 1 + drivers/nvmem/meson-efuse.c | 1 + drivers/nvmem/meson-mx-efuse.c | 1 + drivers/nvmem/microchip-otpc.c | 1 + drivers/nvmem/mtk-efuse.c | 1 + drivers/nvmem/qcom-spmi-sdam.c | 1 +
Quoted 8 lines
drivers/nvmem/qfprom.c | 1 + drivers/nvmem/rave-sp-eeprom.c | 1 + drivers/nvmem/rockchip-efuse.c | 1 + drivers/nvmem/sc27xx-efuse.c | 1 + drivers/nvmem/sprd-efuse.c | 1 + drivers/nvmem/stm32-romem.c | 1 + drivers/nvmem/sunplus-ocotp.c | 1 + drivers/nvmem/sunxi_sid.c | 1 +
For sunxi_sid:
Best regards,
Jernej
Quoted 6 lines
drivers/nvmem/uniphier-efuse.c | 1 + drivers/nvmem/zynqmp_nvmem.c | 1 + drivers/rtc/nvmem.c | 1 + drivers/w1/slaves/w1_ds250x.c | 1 + include/linux/nvmem-provider.h | 2 ++ 23 files changed, 29 insertions(+), 3 deletions(-)
Am Dienstag, 4. April 2023, 00:55:40 CEST schrieb Rafał Miłecki:
Quoted 35 lines
From: Rafał Miłecki <[email protected]>
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
Signed-off-by Rafał Miłecki <[email protected]>[for meson-{efuse,mx-efuse}.c][for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]Reviewed-by AngeloGioacchino Del Regno <[email protected]>[MT8192, MT8195 Chromebooks][for microchip-otpc.c]Reviewed-by Claudiu Beznea <[email protected]>[SAMA7G5-EK]Tested-by Claudiu Beznea <[email protected]>drivers/nvmem/rockchip-efuse.c +0
-0
drivers/nvmem/rockchip-efuse.c static int rockchip_rk3399_efuse_read(void *context, unsigned int offset, · line 211
Quoted 7 lines
drivers/nvmem/rockchip-efuse.c +1
-0@@ -205,6 +205,7 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset,static struct nvmem_config econfig = { .name ="rockchip-efuse" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .read_only = true,
for rockchip-efuse.c
Hi,
Quoted 7 lines · Rafał Miłecki
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
Quoted 8 lines
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
is there any chance I can have this accepted / pushed, please?
It's a tiny optimization and it makes sure people don't use deprecated syntax with new drivers.
I also noticed this will probably let me drop an unclear and non-intuitive no_of_node config option.
Hello Rafał,
Quoted 18 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
Quoted 11 lines
Signed-off-by Rafał Miłecki <[email protected]>[for meson-{efuse,mx-efuse}.c][for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]Reviewed-by AngeloGioacchino Del Regno <[email protected]>[MT8192, MT8195 Chromebooks][for microchip-otpc.c]Reviewed-by Claudiu Beznea <[email protected]>[SAMA7G5-EK]Tested-by Claudiu Beznea <[email protected]>
but small question below:
drivers/mtd/mtdcore.c static int mtd_nvmem_add(struct mtd_info *mtd) · line 525
Quoted 11 lines
---
drivers/mtd/mtdcore.c +1
-0@@ -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"/ ?
Quoted 290 lines
drivers/mtd/mtdcore.c +1
-0config.reg_read = mtd_nvmem_reg_read; config.size = mtd->size; config.word_size =1 ;@@ -889,6 +890,7 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, config.name = compatible; config.id =NVMEM_DEVID_AUTO ; config.owner =THIS_MODULE ; + config.add_legacy_fixed_of_cells = true; config.type =NVMEM_TYPE_OTP ; config.root_only = true; config.ignore_wp = true;drivers/nvmem/apple-efuses.c +1
-0@@ -36,6 +36,7 @@ static int apple_efuses_probe(struct platform_device *pdev)struct resource *res;struct nvmem_config config = { .dev = &pdev->dev, + .add_legacy_fixed_of_cells = true, .read_only = true, .reg_read = apple_efuses_read, .stride =sizeof (u32),drivers/nvmem/core.c +5
-3@@ -994,9 +994,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)if (rval) goto err_remove_cells; - rval =nvmem_add_cells_from_legacy_of (nvmem); -if (rval) - goto err_remove_cells; +if (config->add_legacy_fixed_of_cells) { + rval =nvmem_add_cells_from_legacy_of (nvmem); +if (rval) + goto err_remove_cells; + }dev_dbg (&nvmem->dev,"Registering nvmem device %s\n" , config->name);drivers/nvmem/imx-ocotp-scu.c +1
-0@@ -220,6 +220,7 @@ static int imx_scu_ocotp_write(void *context, unsigned int offset,static struct nvmem_config imx_scu_ocotp_nvmem_config = { .name ="imx-scu-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = false, .word_size =4 , .stride =1 ,drivers/nvmem/imx-ocotp.c +1
-0@@ -621,6 +621,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)return PTR_ERR (priv->clk); priv->params =of_device_get_match_data (&pdev->dev); + imx_ocotp_nvmem_config.add_legacy_fixed_of_cells = true; imx_ocotp_nvmem_config.size =4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv;drivers/nvmem/meson-efuse.c +1
-0@@ -93,6 +93,7 @@ static int meson_efuse_probe(struct platform_device *pdev) econfig->dev = dev; econfig->name =dev_name (dev); + econfig->add_legacy_fixed_of_cells = true; econfig->stride =1 ; econfig->word_size =1 ; econfig->reg_read = meson_efuse_read;drivers/nvmem/meson-mx-efuse.c +1
-0@@ -213,6 +213,7 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) efuse->config.owner =THIS_MODULE ; efuse->config.dev = &pdev->dev; efuse->config.priv = efuse; + efuse->config.add_legacy_fixed_of_cells = true; efuse->config.stride = drvdata->word_size; efuse->config.word_size = drvdata->word_size; efuse->config.size =SZ_512 ;drivers/nvmem/microchip-otpc.c +1
-0@@ -261,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev)return ret; mchp_nvmem_config.dev = otpc->dev; + mchp_nvmem_config.add_legacy_fixed_of_cells = true; mchp_nvmem_config.size = size; mchp_nvmem_config.priv = otpc; nvmem =devm_nvmem_register (&pdev->dev, &mchp_nvmem_config);drivers/nvmem/mtk-efuse.c +1
-0@@ -83,6 +83,7 @@ static int mtk_efuse_probe(struct platform_device *pdev)return PTR_ERR (priv->base); pdata =device_get_match_data (dev); + econfig.add_legacy_fixed_of_cells = true; econfig.stride =1 ; econfig.word_size =1 ; econfig.reg_read = mtk_reg_read;drivers/nvmem/qcom-spmi-sdam.c +1
-0@@ -142,6 +142,7 @@ static int sdam_probe(struct platform_device *pdev) sdam->sdam_config.name ="spmi_sdam" ; sdam->sdam_config.id =NVMEM_DEVID_AUTO ; sdam->sdam_config.owner =THIS_MODULE ; + sdam->sdam_config.add_legacy_fixed_of_cells = true; sdam->sdam_config.stride =1 ; sdam->sdam_config.word_size =1 ; sdam->sdam_config.reg_read = sdam_read;drivers/nvmem/qfprom.c +1
-0@@ -357,6 +357,7 @@ static int qfprom_probe(struct platform_device *pdev) {struct nvmem_config econfig = { .name ="qfprom" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .id =NVMEM_DEVID_AUTO ,drivers/nvmem/rave-sp-eeprom.c +1
-0@@ -328,6 +328,7 @@ static int rave_sp_eeprom_probe(struct platform_device *pdev)of_property_read_string (np,"zii,eeprom-name" , &config.name); config.priv = eeprom; config.dev = dev; + config.add_legacy_fixed_of_cells = true; config.size = size; config.reg_read = rave_sp_eeprom_reg_read; config.reg_write = rave_sp_eeprom_reg_write;drivers/nvmem/rockchip-efuse.c +1
-0@@ -205,6 +205,7 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset,static struct nvmem_config econfig = { .name ="rockchip-efuse" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .read_only = true,drivers/nvmem/sc27xx-efuse.c +1
-0@@ -248,6 +248,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev) econfig.reg_read = sc27xx_efuse_read; econfig.priv = efuse; econfig.dev = &pdev->dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (&pdev->dev, &econfig);if (IS_ERR (nvmem)) {dev_err (&pdev->dev,"failed to register nvmem config\n" );drivers/nvmem/sprd-efuse.c +1
-0@@ -408,6 +408,7 @@ static int sprd_efuse_probe(struct platform_device *pdev) econfig.read_only = false; econfig.name ="sprd-efuse" ; econfig.size = efuse->data->blk_nums *SPRD_EFUSE_BLOCK_WIDTH ; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = sprd_efuse_read; econfig.reg_write = sprd_efuse_write; econfig.priv = efuse;drivers/nvmem/stm32-romem.c +1
-0@@ -208,6 +208,7 @@ static int stm32_romem_probe(struct platform_device *pdev) priv->cfg.priv = priv; priv->cfg.owner =THIS_MODULE ; priv->cfg.type =NVMEM_TYPE_OTP ; + priv->cfg.add_legacy_fixed_of_cells = true; priv->lower =0 ;drivers/nvmem/sunplus-ocotp.c +1
-0@@ -145,6 +145,7 @@ static int sp_ocotp_read(void *priv, unsigned int offset, void *value, size_t bystatic struct nvmem_config sp_ocotp_nvmem_config = { .name ="sp-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = true, .word_size =1 , .size =QAC628_OTP_SIZE ,drivers/nvmem/sunxi_sid.c +1
-0@@ -156,6 +156,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) nvmem_cfg->dev = dev; nvmem_cfg->name ="sunxi-sid" ; nvmem_cfg->type =NVMEM_TYPE_OTP ; + nvmem_cfg->add_legacy_fixed_of_cells = true; nvmem_cfg->read_only = true; nvmem_cfg->size = cfg->size; nvmem_cfg->word_size =1 ;drivers/nvmem/uniphier-efuse.c +1
-0@@ -53,6 +53,7 @@ static int uniphier_efuse_probe(struct platform_device *pdev) econfig.size =resource_size (res); econfig.priv = priv; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, &econfig);return PTR_ERR_OR_ZERO (nvmem);drivers/nvmem/zynqmp_nvmem.c +1
-0@@ -58,6 +58,7 @@ static int zynqmp_nvmem_probe(struct platform_device *pdev) priv->dev = dev; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = zynqmp_nvmem_read; econfig.priv = priv;drivers/rtc/nvmem.c +1
-0@@ -21,6 +21,7 @@ int devm_rtc_nvmem_register(struct rtc_device *rtc, nvmem_config->dev = dev; nvmem_config->owner = rtc->owner; + nvmem_config->add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, nvmem_config);if (IS_ERR (nvmem))dev_err (dev,"failed to register nvmem device for RTC\n" );drivers/w1/slaves/w1_ds250x.c +1
-0@@ -168,6 +168,7 @@ static int w1_eprom_add_slave(struct w1_slave *sl)struct nvmem_device *nvmem;struct nvmem_config nvmem_cfg = { .dev = &sl->dev, + .add_legacy_fixed_of_cells = true, .reg_read = w1_nvmem_read, .type =NVMEM_TYPE_OTP , .read_only = true,include/linux/nvmem-provider.h +2
-0@@ -82,6 +82,7 @@ struct nvmem_cell_info {* @owner: Pointer to exporter module. Used for refcounting. * @cells: Optional array of pre-defined NVMEM cells. * @ncells: Number of elements in cells. +* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax. * @keepout: Optional array of keepout ranges (sorted ascending by start). * @nkeepout: Number of elements in the keepout array. * @type: Type of the nvmem storage @@ -112,6 +113,7 @@ struct nvmem_config {struct module *owner;const struct nvmem_cell_info *cells;int ncells; +bool add_legacy_fixed_of_cells;const struct nvmem_keepout *keepout;unsigned int nkeepout;enum nvmem_type type;
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Ahmad,
Quoted 32 lines · Ahmad Fatoum
drivers/mtd/mtdcore.c static int mtd_nvmem_add(struct mtd_info *mtd) · line 526
Quoted 10 lines
drivers/mtd/mtdcore.c +1
-0@@ -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>; }; } };
Quoted 1 line
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>;
};
};
}
};Hi Rafal,
thankyou for the patch and having patience.
Patch, does not apply on rc1.
Can you rebase this and if possible include drivers/nvmem/sec-qfprom.c
thanks,
Srini
Quoted 368 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes has been deprecated. It has been replaced by the "fixed-layout" NVMEM layout binding.
New syntax is meant to be clearer and should help avoiding imprecise bindings.
NVMEM subsystem already supports the new binding. It should be a good idea to limit support for old syntax to existing drivers that actually support & use it (we can't break backward compatibility!). That way we additionally encourage new bindings & drivers to ignore deprecated binding.
It wasn't clear (to me) if rtc and w1 code actually uses old syntax fixed cells. I enabled them to don't risk any breakage.
Signed-off-by Rafał Miłecki <[email protected]>[for meson-{efuse,mx-efuse}.c][for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]Reviewed-by AngeloGioacchino Del Regno <[email protected]>[MT8192, MT8195 Chromebooks][for microchip-otpc.c]Reviewed-by Claudiu Beznea <[email protected]>[SAMA7G5-EK]Tested-by Claudiu Beznea <[email protected]>---
This is based on top of them
[PATCH V6 3/3] nvmem: core: add support for fixed cells *layout*V2: Fix
stm32-romem.ctypo breaking its compilation
Pick Martin's Acked-by
Add paragraph about layouts deprecatingadd_legacy_fixed_of_cells
V3: Update commit description:
1. Make it clear we're NOT dropping fixed cells support
2. Use nicer words (s/made sense/was totally safe/)
3. Explain fixed cells layout thing
4. Add paragraph with purpose of this commit
V4: Completely rewrite commit message.
Rename config option to "add_legacy_fixed_of_cells".--- drivers/mtd/mtdcore.c | 2 ++ drivers/nvmem/apple-efuses.c | 1 + drivers/nvmem/core.c | 8 +++++--- drivers/nvmem/imx-ocotp-scu.c | 1 + drivers/nvmem/imx-ocotp.c | 1 + drivers/nvmem/meson-efuse.c | 1 + drivers/nvmem/meson-mx-efuse.c | 1 + drivers/nvmem/microchip-otpc.c | 1 + drivers/nvmem/mtk-efuse.c | 1 + drivers/nvmem/qcom-spmi-sdam.c | 1 + drivers/nvmem/qfprom.c | 1 + drivers/nvmem/rave-sp-eeprom.c | 1 + drivers/nvmem/rockchip-efuse.c | 1 + drivers/nvmem/sc27xx-efuse.c | 1 + drivers/nvmem/sprd-efuse.c | 1 + drivers/nvmem/stm32-romem.c | 1 + drivers/nvmem/sunplus-ocotp.c | 1 + drivers/nvmem/sunxi_sid.c | 1 + drivers/nvmem/uniphier-efuse.c | 1 + drivers/nvmem/zynqmp_nvmem.c | 1 + drivers/rtc/nvmem.c | 1 + drivers/w1/slaves/w1_ds250x.c | 1 + include/linux/nvmem-provider.h | 2 ++ 23 files changed, 29 insertions(+), 3 deletions(-)drivers/mtd/mtdcore.c +2
-0@@ -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" ); config.reg_read = mtd_nvmem_reg_read; config.size = mtd->size; config.word_size =1 ;@@ -889,6 +890,7 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, config.name = compatible; config.id =NVMEM_DEVID_AUTO ; config.owner =THIS_MODULE ; + config.add_legacy_fixed_of_cells = true; config.type =NVMEM_TYPE_OTP ; config.root_only = true; config.ignore_wp = true;drivers/nvmem/apple-efuses.c +1
-0@@ -36,6 +36,7 @@ static int apple_efuses_probe(struct platform_device *pdev)struct resource *res;struct nvmem_config config = { .dev = &pdev->dev, + .add_legacy_fixed_of_cells = true, .read_only = true, .reg_read = apple_efuses_read, .stride =sizeof (u32),drivers/nvmem/core.c +5
-3@@ -994,9 +994,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)if (rval) goto err_remove_cells; - rval =nvmem_add_cells_from_legacy_of (nvmem); -if (rval) - goto err_remove_cells; +if (config->add_legacy_fixed_of_cells) { + rval =nvmem_add_cells_from_legacy_of (nvmem); +if (rval) + goto err_remove_cells; + }dev_dbg (&nvmem->dev,"Registering nvmem device %s\n" , config->name);drivers/nvmem/imx-ocotp-scu.c +1
-0@@ -220,6 +220,7 @@ static int imx_scu_ocotp_write(void *context, unsigned int offset,static struct nvmem_config imx_scu_ocotp_nvmem_config = { .name ="imx-scu-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = false, .word_size =4 , .stride =1 ,drivers/nvmem/imx-ocotp.c +1
-0@@ -621,6 +621,7 @@ static int imx_ocotp_probe(struct platform_device *pdev)return PTR_ERR (priv->clk); priv->params =of_device_get_match_data (&pdev->dev); + imx_ocotp_nvmem_config.add_legacy_fixed_of_cells = true; imx_ocotp_nvmem_config.size =4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv;drivers/nvmem/meson-efuse.c +1
-0@@ -93,6 +93,7 @@ static int meson_efuse_probe(struct platform_device *pdev) econfig->dev = dev; econfig->name =dev_name (dev); + econfig->add_legacy_fixed_of_cells = true; econfig->stride =1 ; econfig->word_size =1 ; econfig->reg_read = meson_efuse_read;drivers/nvmem/meson-mx-efuse.c +1
-0@@ -213,6 +213,7 @@ static int meson_mx_efuse_probe(struct platform_device *pdev) efuse->config.owner =THIS_MODULE ; efuse->config.dev = &pdev->dev; efuse->config.priv = efuse; + efuse->config.add_legacy_fixed_of_cells = true; efuse->config.stride = drvdata->word_size; efuse->config.word_size = drvdata->word_size; efuse->config.size =SZ_512 ;drivers/nvmem/microchip-otpc.c +1
-0@@ -261,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev)return ret; mchp_nvmem_config.dev = otpc->dev; + mchp_nvmem_config.add_legacy_fixed_of_cells = true; mchp_nvmem_config.size = size; mchp_nvmem_config.priv = otpc; nvmem =devm_nvmem_register (&pdev->dev, &mchp_nvmem_config);drivers/nvmem/mtk-efuse.c +1
-0@@ -83,6 +83,7 @@ static int mtk_efuse_probe(struct platform_device *pdev)return PTR_ERR (priv->base); pdata =device_get_match_data (dev); + econfig.add_legacy_fixed_of_cells = true; econfig.stride =1 ; econfig.word_size =1 ; econfig.reg_read = mtk_reg_read;drivers/nvmem/qcom-spmi-sdam.c +1
-0@@ -142,6 +142,7 @@ static int sdam_probe(struct platform_device *pdev) sdam->sdam_config.name ="spmi_sdam" ; sdam->sdam_config.id =NVMEM_DEVID_AUTO ; sdam->sdam_config.owner =THIS_MODULE ; + sdam->sdam_config.add_legacy_fixed_of_cells = true; sdam->sdam_config.stride =1 ; sdam->sdam_config.word_size =1 ; sdam->sdam_config.reg_read = sdam_read;drivers/nvmem/qfprom.c +1
-0@@ -357,6 +357,7 @@ static int qfprom_probe(struct platform_device *pdev) {struct nvmem_config econfig = { .name ="qfprom" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .id =NVMEM_DEVID_AUTO ,drivers/nvmem/rave-sp-eeprom.c +1
-0@@ -328,6 +328,7 @@ static int rave_sp_eeprom_probe(struct platform_device *pdev)of_property_read_string (np,"zii,eeprom-name" , &config.name); config.priv = eeprom; config.dev = dev; + config.add_legacy_fixed_of_cells = true; config.size = size; config.reg_read = rave_sp_eeprom_reg_read; config.reg_write = rave_sp_eeprom_reg_write;drivers/nvmem/rockchip-efuse.c +1
-0@@ -205,6 +205,7 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset,static struct nvmem_config econfig = { .name ="rockchip-efuse" , + .add_legacy_fixed_of_cells = true, .stride =1 , .word_size =1 , .read_only = true,drivers/nvmem/sc27xx-efuse.c +1
-0@@ -248,6 +248,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev) econfig.reg_read = sc27xx_efuse_read; econfig.priv = efuse; econfig.dev = &pdev->dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (&pdev->dev, &econfig);if (IS_ERR (nvmem)) {dev_err (&pdev->dev,"failed to register nvmem config\n" );drivers/nvmem/sprd-efuse.c +1
-0@@ -408,6 +408,7 @@ static int sprd_efuse_probe(struct platform_device *pdev) econfig.read_only = false; econfig.name ="sprd-efuse" ; econfig.size = efuse->data->blk_nums *SPRD_EFUSE_BLOCK_WIDTH ; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = sprd_efuse_read; econfig.reg_write = sprd_efuse_write; econfig.priv = efuse;drivers/nvmem/stm32-romem.c +1
-0@@ -208,6 +208,7 @@ static int stm32_romem_probe(struct platform_device *pdev) priv->cfg.priv = priv; priv->cfg.owner =THIS_MODULE ; priv->cfg.type =NVMEM_TYPE_OTP ; + priv->cfg.add_legacy_fixed_of_cells = true; priv->lower =0 ;drivers/nvmem/sunplus-ocotp.c +1
-0@@ -145,6 +145,7 @@ static int sp_ocotp_read(void *priv, unsigned int offset, void *value, size_t bystatic struct nvmem_config sp_ocotp_nvmem_config = { .name ="sp-ocotp" , + .add_legacy_fixed_of_cells = true, .read_only = true, .word_size =1 , .size =QAC628_OTP_SIZE ,drivers/nvmem/sunxi_sid.c +1
-0@@ -156,6 +156,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) nvmem_cfg->dev = dev; nvmem_cfg->name ="sunxi-sid" ; nvmem_cfg->type =NVMEM_TYPE_OTP ; + nvmem_cfg->add_legacy_fixed_of_cells = true; nvmem_cfg->read_only = true; nvmem_cfg->size = cfg->size; nvmem_cfg->word_size =1 ;drivers/nvmem/uniphier-efuse.c +1
-0@@ -53,6 +53,7 @@ static int uniphier_efuse_probe(struct platform_device *pdev) econfig.size =resource_size (res); econfig.priv = priv; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, &econfig);return PTR_ERR_OR_ZERO (nvmem);drivers/nvmem/zynqmp_nvmem.c +1
-0@@ -58,6 +58,7 @@ static int zynqmp_nvmem_probe(struct platform_device *pdev) priv->dev = dev; econfig.dev = dev; + econfig.add_legacy_fixed_of_cells = true; econfig.reg_read = zynqmp_nvmem_read; econfig.priv = priv;drivers/rtc/nvmem.c +1
-0@@ -21,6 +21,7 @@ int devm_rtc_nvmem_register(struct rtc_device *rtc, nvmem_config->dev = dev; nvmem_config->owner = rtc->owner; + nvmem_config->add_legacy_fixed_of_cells = true; nvmem =devm_nvmem_register (dev, nvmem_config);if (IS_ERR (nvmem))dev_err (dev,"failed to register nvmem device for RTC\n" );drivers/w1/slaves/w1_ds250x.c +1
-0@@ -168,6 +168,7 @@ static int w1_eprom_add_slave(struct w1_slave *sl)struct nvmem_device *nvmem;struct nvmem_config nvmem_cfg = { .dev = &sl->dev, + .add_legacy_fixed_of_cells = true, .reg_read = w1_nvmem_read, .type =NVMEM_TYPE_OTP , .read_only = true,include/linux/nvmem-provider.h +2
-0@@ -82,6 +82,7 @@ struct nvmem_cell_info {* @owner: Pointer to exporter module. Used for refcounting. * @cells: Optional array of pre-defined NVMEM cells. * @ncells: Number of elements in cells. +* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax. * @keepout: Optional array of keepout ranges (sorted ascending by start). * @nkeepout: Number of elements in the keepout array. * @type: Type of the nvmem storage @@ -112,6 +113,7 @@ struct nvmem_config {struct module *owner;const struct nvmem_cell_info *cells;int ncells; +bool add_legacy_fixed_of_cells;const struct nvmem_keepout *keepout;unsigned int nkeepout;enum nvmem_type type;