* [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
@ 2023-05-08 11:46 Peng Fan (OSS)
2023-05-08 11:46 ` [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP Peng Fan (OSS)
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Peng Fan (OSS) @ 2023-05-08 11:46 UTC (permalink / raw)
To: srinivas.kandagatla, robh+dt, krzysztof.kozlowski+dt
Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, devicetree,
linux-arm-kernel, linux-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Add i.MX93 OCOTP support
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V2:
Reuse imx-ocotp.yaml
Based on https://lore.kernel.org/all/20230506064128.34005-1-krzysztof.kozlowski@linaro.org/
Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
index 0784d71ae8f9..99e60d713dac 100644
--- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
@@ -4,7 +4,7 @@
$id: http://devicetree.org/schemas/nvmem/imx-ocotp.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
-title: Freescale i.MX6 On-Chip OTP Controller (OCOTP)
+title: Freescale i.MX On-Chip OTP Controller (OCOTP)
maintainers:
- Anson Huang <Anson.Huang@nxp.com>
@@ -12,7 +12,7 @@ maintainers:
description: |
This binding represents the on-chip eFuse OTP controller found on
i.MX6Q/D, i.MX6DL/S, i.MX6SL, i.MX6SX, i.MX6UL, i.MX6ULL/ULZ, i.MX6SLL,
- i.MX7D/S, i.MX7ULP, i.MX8MQ, i.MX8MM, i.MX8MN and i.MX8MP SoCs.
+ i.MX7D/S, i.MX7ULP, i.MX8MQ, i.MX8MM, i.MX8MN i.MX8MP and i.MX93 SoCs.
allOf:
- $ref: nvmem.yaml#
@@ -32,6 +32,7 @@ properties:
- fsl,imx7ulp-ocotp
- fsl,imx8mq-ocotp
- fsl,imx8mm-ocotp
+ - fsl,imx93-ocotp
- const: syscon
- items:
- enum:
--
2.37.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP
2023-05-08 11:46 [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Peng Fan (OSS)
@ 2023-05-08 11:46 ` Peng Fan (OSS)
2023-05-17 8:46 ` Peng Fan
2023-05-08 12:27 ` [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Rob Herring
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Peng Fan (OSS) @ 2023-05-08 11:46 UTC (permalink / raw)
To: srinivas.kandagatla, robh+dt, krzysztof.kozlowski+dt
Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, devicetree,
linux-arm-kernel, linux-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Add i.MX93 OCOTP support. i.MX93 OCOTP has two parts: Fuse shadow
block(fsb) and fuse managed by ELE. The FSB part could be directly
accessed with MMIO, the ELE could only be accessed with ELE API.
Currently the ELE API is not ready, so NULL function callback is used,
but it was tested with downstream ELE API.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V2:
Merge ele & fsb compatible to use fsl,imx93-ocotp
drivers/nvmem/Kconfig | 9 ++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/imx-ocotp-ele.c | 175 ++++++++++++++++++++++++++++++++++
3 files changed, 186 insertions(+)
create mode 100644 drivers/nvmem/imx-ocotp-ele.c
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index b291b27048c7..e7093726b28e 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -82,6 +82,15 @@ config NVMEM_IMX_OCOTP
This driver can also be built as a module. If so, the module
will be called nvmem-imx-ocotp.
+config NVMEM_IMX_OCOTP_ELE
+ tristate "i.MX On-Chip OTP Controller support"
+ depends on ARCH_MXC || COMPILE_TEST
+ depends on HAS_IOMEM
+ depends on OF
+ help
+ This is a driver for the On-Chip OTP Controller (OCOTP)
+ available on i.MX SoCs which has ELE.
+
config NVMEM_IMX_OCOTP_SCU
tristate "i.MX8 SCU On-Chip OTP Controller support"
depends on IMX_SCU
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index f82431ec8aef..cc23ce4ffb1f 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -18,6 +18,8 @@ obj-$(CONFIG_NVMEM_IMX_IIM) += nvmem-imx-iim.o
nvmem-imx-iim-y := imx-iim.o
obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o
nvmem-imx-ocotp-y := imx-ocotp.o
+obj-$(CONFIG_NVMEM_IMX_OCOTP_ELE) += nvmem-imx-ocotp-ele.o
+nvmem-imx-ocotp-ele-y := imx-ocotp-ele.o
obj-$(CONFIG_NVMEM_IMX_OCOTP_SCU) += nvmem-imx-ocotp-scu.o
nvmem-imx-ocotp-scu-y := imx-ocotp-scu.o
obj-$(CONFIG_NVMEM_JZ4780_EFUSE) += nvmem_jz4780_efuse.o
diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c
new file mode 100644
index 000000000000..af9ce0ce4792
--- /dev/null
+++ b/drivers/nvmem/imx-ocotp-ele.c
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * i.MX9 OCOTP fusebox driver
+ *
+ * Copyright 2023 NXP
+ */
+
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum fuse_type {
+ FUSE_FSB = 1,
+ FUSE_ELE = 2,
+ FUSE_INVALID = -1
+};
+
+struct ocotp_map_entry {
+ u32 start; /* start word */
+ u32 num; /* num words */
+ enum fuse_type type;
+};
+
+struct ocotp_devtype_data {
+ u32 reg_off;
+ char *name;
+ u32 size;
+ u32 num_entry;
+ u32 flag;
+ nvmem_reg_read_t reg_read;
+ struct ocotp_map_entry entry[];
+};
+
+struct imx_ocotp_priv {
+ struct device *dev;
+ void __iomem *base;
+ struct nvmem_config config;
+ struct mutex lock;
+ const struct ocotp_devtype_data *data;
+};
+
+static enum fuse_type imx_ocotp_fuse_type(void *context, u32 index)
+{
+ struct imx_ocotp_priv *priv = context;
+ const struct ocotp_devtype_data *data = priv->data;
+ u32 start, end;
+ int i;
+
+ for (i = 0; i < data->num_entry; i++) {
+ start = data->entry[i].start;
+ end = data->entry[i].start + data->entry[i].num;
+
+ if (index >= start && index < end)
+ return data->entry[i].type;
+ }
+
+ return FUSE_INVALID;
+}
+
+static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, size_t bytes)
+{
+ struct imx_ocotp_priv *priv = context;
+ void __iomem *reg = priv->base + priv->data->reg_off;
+ u32 count, index, num_bytes;
+ enum fuse_type type;
+ u32 *buf;
+ void *p;
+ int i;
+
+ index = offset;
+ num_bytes = round_up(bytes, 4);
+ count = num_bytes >> 2;
+
+ if (count > ((priv->data->size >> 2) - index))
+ count = (priv->data->size >> 2) - index;
+
+ p = kzalloc(num_bytes, GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+
+ mutex_lock(&priv->lock);
+
+ buf = p;
+
+ for (i = index; i < (index + count); i++) {
+ type = imx_ocotp_fuse_type(context, i);
+ if (type == FUSE_INVALID || type == FUSE_ELE) {
+ *buf++ = 0;
+ continue;
+ }
+
+ *buf++ = readl_relaxed(reg + (i << 2));
+ }
+
+ memcpy(val, (u8 *)p, bytes);
+
+ mutex_unlock(&priv->lock);
+
+ kfree(p);
+
+ return 0;
+};
+
+static int imx_ele_ocotp_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct imx_ocotp_priv *priv;
+ struct nvmem_device *nvmem;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->data = of_device_get_match_data(dev);
+
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
+
+ priv->config.dev = dev;
+ priv->config.name = "ELE-OCOTP";
+ priv->config.id = NVMEM_DEVID_AUTO;
+ priv->config.owner = THIS_MODULE;
+ priv->config.size = priv->data->size;
+ priv->config.reg_read = priv->data->reg_read;
+ priv->config.word_size = 4;
+ priv->config.stride = 1;
+ priv->config.priv = priv;
+ priv->config.read_only = true;
+ mutex_init(&priv->lock);
+
+ nvmem = devm_nvmem_register(dev, &priv->config);
+ if (IS_ERR(nvmem))
+ return PTR_ERR(nvmem);
+
+ return 0;
+}
+
+static const struct ocotp_devtype_data imx93_ocotp_data = {
+ .reg_off = 0x8000,
+ .reg_read = imx_ocotp_reg_read,
+ .size = 2048,
+ .num_entry = 6,
+ .entry = {
+ { 0, 52, FUSE_FSB },
+ { 63, 1, FUSE_ELE},
+ { 128, 16, FUSE_ELE },
+ { 182, 1, FUSE_ELE },
+ { 188, 1, FUSE_ELE },
+ { 312, 200, FUSE_FSB }
+ },
+};
+
+static const struct of_device_id imx_ele_ocotp_dt_ids[] = {
+ { .compatible = "fsl,imx93-ocotp", .data = &imx93_ocotp_data, },
+ {},
+};
+MODULE_DEVICE_TABLE(of, imx_ele_ocotp_dt_ids);
+
+static struct platform_driver imx_ele_ocotp_driver = {
+ .driver = {
+ .name = "imx_ele_ocotp",
+ .of_match_table = imx_ele_ocotp_dt_ids,
+ },
+ .probe = imx_ele_ocotp_probe,
+};
+module_platform_driver(imx_ele_ocotp_driver);
+
+MODULE_DESCRIPTION("i.MX OCOTP/ELE driver");
+MODULE_AUTHOR("Peng Fan <peng.fan@nxp.com>");
+MODULE_LICENSE("GPL");
--
2.37.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
2023-05-08 11:46 [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Peng Fan (OSS)
2023-05-08 11:46 ` [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP Peng Fan (OSS)
@ 2023-05-08 12:27 ` Rob Herring
2023-05-09 0:49 ` Peng Fan
2023-05-09 6:45 ` Krzysztof Kozlowski
2023-05-31 13:41 ` Srinivas Kandagatla
3 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2023-05-08 12:27 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: robh+dt, linux-kernel, s.hauer, srinivas.kandagatla,
krzysztof.kozlowski+dt, kernel, devicetree, shawnguo,
linux-arm-kernel, linux-imx, festevam, Peng Fan
On Mon, 08 May 2023 19:46:38 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Add i.MX93 OCOTP support
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
> Reuse imx-ocotp.yaml
> Based on https://lore.kernel.org/all/20230506064128.34005-1-krzysztof.kozlowski@linaro.org/
>
> Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/rockchip-isp1.example.dtb: camera@3c: port:endpoint:data-lanes: [[1]] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.example.dtb: camera-sensor@3c: port:endpoint:data-lanes: [[1]] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.example.dtb: pcie-ep@33800000: Unevaluated properties are not allowed ('assigned-clock-parents', 'assigned-clock-rates', 'assigned-clocks' were unexpected)
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml
doc reference errors (make refcheckdocs):
Documentation/usb/gadget_uvc.rst: Documentation/userspace-api/media/v4l/pixfmt-packed.yuv.rst
MAINTAINERS: Documentation/devicetree/bindings/pwm/pwm-apple.yaml
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230508114639.1525521-1-peng.fan@oss.nxp.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
2023-05-08 12:27 ` [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Rob Herring
@ 2023-05-09 0:49 ` Peng Fan
2023-05-09 6:45 ` Krzysztof Kozlowski
0 siblings, 1 reply; 8+ messages in thread
From: Peng Fan @ 2023-05-09 0:49 UTC (permalink / raw)
To: Rob Herring, Peng Fan (OSS)
Cc: robh+dt@kernel.org, linux-kernel@vger.kernel.org,
s.hauer@pengutronix.de, srinivas.kandagatla@linaro.org,
krzysztof.kozlowski+dt@linaro.org, kernel@pengutronix.de,
devicetree@vger.kernel.org, shawnguo@kernel.org,
linux-arm-kernel@lists.infradead.org, dl-linux-imx,
festevam@gmail.com
Hi Rob,
> Subject: Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
>
>
> On Mon, 08 May 2023 19:46:38 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Add i.MX93 OCOTP support
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >
> > V2:
> > Reuse imx-ocotp.yaml
> > Based on
> >
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore
> > .kernel.org%2Fall%2F20230506064128.34005-1-
> krzysztof.kozlowski%40linar
> >
> o.org%2F&data=05%7C01%7Cpeng.fan%40nxp.com%7Ca420ce0c500d4c7e7
> 63a08db4
> >
> fbfa1d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638191456
> 69328409
> >
> 9%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzI
> iLCJBTiI6
> >
> Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=V7QDS9Ko3cvQ3q
> rR%2FzlHVVI
> > NImlIzkkqBmDHPFme5oI%3D&reserved=0
> >
> > Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
>
> My bot found errors running 'make DT_CHECKER_FLAGS=-m
> dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
>
> yamllint warnings/errors:
[Peng Fan]
I think the following errors are not related this patch. I not touch
pcie, camera in this patch.
Thanks,
Peng.
>
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/media/rockchip-
> isp1.example.dtb: camera@3c: port:endpoint:data-lanes: [[1]] is too short
> From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.exampl
> e.dtb: camera-sensor@3c: port:endpoint:data-lanes: [[1]] is too short
> From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/media/i2c/ovti,ov2685.yaml
> /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-
> ep.example.dtb: pcie-ep@33800000: Unevaluated properties are not
> allowed ('assigned-clock-parents', 'assigned-clock-rates', 'assigned-clocks'
> were unexpected)
> From schema: /builds/robherring/dt-review-
> ci/linux/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie-ep.yaml
>
> doc reference errors (make refcheckdocs):
> Documentation/usb/gadget_uvc.rst: Documentation/userspace-
> api/media/v4l/pixfmt-packed.yuv.rst
> MAINTAINERS: Documentation/devicetree/bindings/pwm/pwm-apple.yaml
>
> See
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc
> hwork.ozlabs.org%2Fproject%2Fdevicetree-
> bindings%2Fpatch%2F20230508114639.1525521-1-
> peng.fan%40oss.nxp.com&data=05%7C01%7Cpeng.fan%40nxp.com%7Ca42
> 0ce0c500d4c7e763a08db4fbfa1d7%7C686ea1d3bc2b4c6fa92cd99c5c301635
> %7C0%7C0%7C638191456693284099%7CUnknown%7CTWFpbGZsb3d8eyJW
> IjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7
> C3000%7C%7C%7C&sdata=BagDUtBuSrbiQNnFQkFSiXMUwzpdxZFwuyizKx%
> 2BnEhs%3D&reserved=0
>
> The base for the series is generally the latest rc1. A different dependency
> should be noted in *this* patch.
>
> If you already ran 'make dt_binding_check' and didn't see the above error(s),
> then make sure 'yamllint' is installed and dt-schema is up to
> date:
>
> pip3 install dtschema --upgrade
>
> Please check and re-submit after running the above command yourself.
> Note that DT_SCHEMA_FILES can be set to your schema file to speed up
> checking your schema. However, it must be unset to test all examples with
> your schema.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
2023-05-08 11:46 [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Peng Fan (OSS)
2023-05-08 11:46 ` [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP Peng Fan (OSS)
2023-05-08 12:27 ` [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Rob Herring
@ 2023-05-09 6:45 ` Krzysztof Kozlowski
2023-05-31 13:41 ` Srinivas Kandagatla
3 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-09 6:45 UTC (permalink / raw)
To: Peng Fan (OSS), srinivas.kandagatla, robh+dt,
krzysztof.kozlowski+dt
Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, devicetree,
linux-arm-kernel, linux-kernel, Peng Fan
On 08/05/2023 13:46, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Add i.MX93 OCOTP support
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
2023-05-09 0:49 ` Peng Fan
@ 2023-05-09 6:45 ` Krzysztof Kozlowski
0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-09 6:45 UTC (permalink / raw)
To: Peng Fan, Rob Herring, Peng Fan (OSS)
Cc: robh+dt@kernel.org, linux-kernel@vger.kernel.org,
s.hauer@pengutronix.de, srinivas.kandagatla@linaro.org,
krzysztof.kozlowski+dt@linaro.org, kernel@pengutronix.de,
devicetree@vger.kernel.org, shawnguo@kernel.org,
linux-arm-kernel@lists.infradead.org, dl-linux-imx,
festevam@gmail.com
On 09/05/2023 02:49, Peng Fan wrote:
> Hi Rob,
>
>> Subject: Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
>>
>>
>> On Mon, 08 May 2023 19:46:38 +0800, Peng Fan (OSS) wrote:
>>> From: Peng Fan <peng.fan@nxp.com>
>>>
>>> Add i.MX93 OCOTP support
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>> ---
>>>
>>> V2:
>>> Reuse imx-ocotp.yaml
>>> Based on
>>>
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore
>>> .kernel.org%2Fall%2F20230506064128.34005-1-
>> krzysztof.kozlowski%40linar
>>>
>> o.org%2F&data=05%7C01%7Cpeng.fan%40nxp.com%7Ca420ce0c500d4c7e7
>> 63a08db4
>>>
>> fbfa1d7%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638191456
>> 69328409
>>>
>> 9%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzI
>> iLCJBTiI6
>>>
>> Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=V7QDS9Ko3cvQ3q
>> rR%2FzlHVVI
>>> NImlIzkkqBmDHPFme5oI%3D&reserved=0
>>>
>>> Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>
>> My bot found errors running 'make DT_CHECKER_FLAGS=-m
>> dt_binding_check'
>> on your patch (DT_CHECKER_FLAGS is new in v5.13):
>>
>> yamllint warnings/errors:
> [Peng Fan]
>
> I think the following errors are not related this patch. I not touch
> pcie, camera in this patch.
Yes, these errors can be ignored.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP
2023-05-08 11:46 ` [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP Peng Fan (OSS)
@ 2023-05-17 8:46 ` Peng Fan
0 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2023-05-17 8:46 UTC (permalink / raw)
To: Peng Fan (OSS), srinivas.kandagatla@linaro.org,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org
Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, dl-linux-imx,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Hi Srinivas
> Subject: [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP
The patch v2 1/2 has got R-b from DT maintainers. Are you fine with
Patch v2 2/2?
Thanks,
Peng.
>
> From: Peng Fan <peng.fan@nxp.com>
>
> Add i.MX93 OCOTP support. i.MX93 OCOTP has two parts: Fuse shadow
> block(fsb) and fuse managed by ELE. The FSB part could be directly accessed
> with MMIO, the ELE could only be accessed with ELE API.
>
> Currently the ELE API is not ready, so NULL function callback is used, but it
> was tested with downstream ELE API.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
> Merge ele & fsb compatible to use fsl,imx93-ocotp
>
> drivers/nvmem/Kconfig | 9 ++
> drivers/nvmem/Makefile | 2 +
> drivers/nvmem/imx-ocotp-ele.c | 175
> ++++++++++++++++++++++++++++++++++
> 3 files changed, 186 insertions(+)
> create mode 100644 drivers/nvmem/imx-ocotp-ele.c
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index
> b291b27048c7..e7093726b28e 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -82,6 +82,15 @@ config NVMEM_IMX_OCOTP
> This driver can also be built as a module. If so, the module
> will be called nvmem-imx-ocotp.
>
> +config NVMEM_IMX_OCOTP_ELE
> + tristate "i.MX On-Chip OTP Controller support"
> + depends on ARCH_MXC || COMPILE_TEST
> + depends on HAS_IOMEM
> + depends on OF
> + help
> + This is a driver for the On-Chip OTP Controller (OCOTP)
> + available on i.MX SoCs which has ELE.
> +
> config NVMEM_IMX_OCOTP_SCU
> tristate "i.MX8 SCU On-Chip OTP Controller support"
> depends on IMX_SCU
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index
> f82431ec8aef..cc23ce4ffb1f 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -18,6 +18,8 @@ obj-$(CONFIG_NVMEM_IMX_IIM) +=
> nvmem-imx-iim.o
> nvmem-imx-iim-y := imx-iim.o
> obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o
> nvmem-imx-ocotp-y := imx-ocotp.o
> +obj-$(CONFIG_NVMEM_IMX_OCOTP_ELE) += nvmem-imx-ocotp-ele.o
> +nvmem-imx-ocotp-ele-y := imx-ocotp-ele.o
> obj-$(CONFIG_NVMEM_IMX_OCOTP_SCU) += nvmem-imx-ocotp-scu.o
> nvmem-imx-ocotp-scu-y := imx-ocotp-scu.o
> obj-$(CONFIG_NVMEM_JZ4780_EFUSE) += nvmem_jz4780_efuse.o
> diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-
> ele.c new file mode 100644 index 000000000000..af9ce0ce4792
> --- /dev/null
> +++ b/drivers/nvmem/imx-ocotp-ele.c
> @@ -0,0 +1,175 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * i.MX9 OCOTP fusebox driver
> + *
> + * Copyright 2023 NXP
> + */
> +
> +#include <linux/device.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +
> +enum fuse_type {
> + FUSE_FSB = 1,
> + FUSE_ELE = 2,
> + FUSE_INVALID = -1
> +};
> +
> +struct ocotp_map_entry {
> + u32 start; /* start word */
> + u32 num; /* num words */
> + enum fuse_type type;
> +};
> +
> +struct ocotp_devtype_data {
> + u32 reg_off;
> + char *name;
> + u32 size;
> + u32 num_entry;
> + u32 flag;
> + nvmem_reg_read_t reg_read;
> + struct ocotp_map_entry entry[];
> +};
> +
> +struct imx_ocotp_priv {
> + struct device *dev;
> + void __iomem *base;
> + struct nvmem_config config;
> + struct mutex lock;
> + const struct ocotp_devtype_data *data; };
> +
> +static enum fuse_type imx_ocotp_fuse_type(void *context, u32 index) {
> + struct imx_ocotp_priv *priv = context;
> + const struct ocotp_devtype_data *data = priv->data;
> + u32 start, end;
> + int i;
> +
> + for (i = 0; i < data->num_entry; i++) {
> + start = data->entry[i].start;
> + end = data->entry[i].start + data->entry[i].num;
> +
> + if (index >= start && index < end)
> + return data->entry[i].type;
> + }
> +
> + return FUSE_INVALID;
> +}
> +
> +static int imx_ocotp_reg_read(void *context, unsigned int offset, void
> +*val, size_t bytes) {
> + struct imx_ocotp_priv *priv = context;
> + void __iomem *reg = priv->base + priv->data->reg_off;
> + u32 count, index, num_bytes;
> + enum fuse_type type;
> + u32 *buf;
> + void *p;
> + int i;
> +
> + index = offset;
> + num_bytes = round_up(bytes, 4);
> + count = num_bytes >> 2;
> +
> + if (count > ((priv->data->size >> 2) - index))
> + count = (priv->data->size >> 2) - index;
> +
> + p = kzalloc(num_bytes, GFP_KERNEL);
> + if (!p)
> + return -ENOMEM;
> +
> + mutex_lock(&priv->lock);
> +
> + buf = p;
> +
> + for (i = index; i < (index + count); i++) {
> + type = imx_ocotp_fuse_type(context, i);
> + if (type == FUSE_INVALID || type == FUSE_ELE) {
> + *buf++ = 0;
> + continue;
> + }
> +
> + *buf++ = readl_relaxed(reg + (i << 2));
> + }
> +
> + memcpy(val, (u8 *)p, bytes);
> +
> + mutex_unlock(&priv->lock);
> +
> + kfree(p);
> +
> + return 0;
> +};
> +
> +static int imx_ele_ocotp_probe(struct platform_device *pdev) {
> + struct device *dev = &pdev->dev;
> + struct imx_ocotp_priv *priv;
> + struct nvmem_device *nvmem;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->data = of_device_get_match_data(dev);
> +
> + priv->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(priv->base))
> + return PTR_ERR(priv->base);
> +
> + priv->config.dev = dev;
> + priv->config.name = "ELE-OCOTP";
> + priv->config.id = NVMEM_DEVID_AUTO;
> + priv->config.owner = THIS_MODULE;
> + priv->config.size = priv->data->size;
> + priv->config.reg_read = priv->data->reg_read;
> + priv->config.word_size = 4;
> + priv->config.stride = 1;
> + priv->config.priv = priv;
> + priv->config.read_only = true;
> + mutex_init(&priv->lock);
> +
> + nvmem = devm_nvmem_register(dev, &priv->config);
> + if (IS_ERR(nvmem))
> + return PTR_ERR(nvmem);
> +
> + return 0;
> +}
> +
> +static const struct ocotp_devtype_data imx93_ocotp_data = {
> + .reg_off = 0x8000,
> + .reg_read = imx_ocotp_reg_read,
> + .size = 2048,
> + .num_entry = 6,
> + .entry = {
> + { 0, 52, FUSE_FSB },
> + { 63, 1, FUSE_ELE},
> + { 128, 16, FUSE_ELE },
> + { 182, 1, FUSE_ELE },
> + { 188, 1, FUSE_ELE },
> + { 312, 200, FUSE_FSB }
> + },
> +};
> +
> +static const struct of_device_id imx_ele_ocotp_dt_ids[] = {
> + { .compatible = "fsl,imx93-ocotp", .data = &imx93_ocotp_data, },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, imx_ele_ocotp_dt_ids);
> +
> +static struct platform_driver imx_ele_ocotp_driver = {
> + .driver = {
> + .name = "imx_ele_ocotp",
> + .of_match_table = imx_ele_ocotp_dt_ids,
> + },
> + .probe = imx_ele_ocotp_probe,
> +};
> +module_platform_driver(imx_ele_ocotp_driver);
> +
> +MODULE_DESCRIPTION("i.MX OCOTP/ELE driver");
> MODULE_AUTHOR("Peng Fan
> +<peng.fan@nxp.com>"); MODULE_LICENSE("GPL");
> --
> 2.37.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
2023-05-08 11:46 [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Peng Fan (OSS)
` (2 preceding siblings ...)
2023-05-09 6:45 ` Krzysztof Kozlowski
@ 2023-05-31 13:41 ` Srinivas Kandagatla
3 siblings, 0 replies; 8+ messages in thread
From: Srinivas Kandagatla @ 2023-05-31 13:41 UTC (permalink / raw)
To: robh+dt, krzysztof.kozlowski+dt, Peng Fan (OSS)
Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, devicetree,
linux-arm-kernel, linux-kernel, Peng Fan
On Mon, 08 May 2023 19:46:38 +0800, Peng Fan (OSS) wrote:
> Add i.MX93 OCOTP support
>
>
Applied, thanks!
[1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93
commit: 42d033c4e47b9490cd9351c0eacb0b7dedb179e4
[2/2] nvmem: imx: support i.MX93 OCOTP
commit: 4d47e9a76d5fd3008e69c91dccfb52ca02624c5a
Best regards,
--
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-05-31 13:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-08 11:46 [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Peng Fan (OSS)
2023-05-08 11:46 ` [PATCH V2 2/2] nvmem: imx: support i.MX93 OCOTP Peng Fan (OSS)
2023-05-17 8:46 ` Peng Fan
2023-05-08 12:27 ` [PATCH V2 1/2] dt-bindings: nvmem: imx-ocotp: support i.MX93 Rob Herring
2023-05-09 0:49 ` Peng Fan
2023-05-09 6:45 ` Krzysztof Kozlowski
2023-05-09 6:45 ` Krzysztof Kozlowski
2023-05-31 13:41 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).