* [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp
2025-10-31 12:45 [PATCH 0/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
@ 2025-10-31 12:45 ` Tudor Ambarus
2025-10-31 15:02 ` Conor Dooley
2025-10-31 12:45 ` [PATCH 2/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 12:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel, Tudor Ambarus
Add binding for the OTP controller found on Google GS101.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
.../bindings/nvmem/google,gs101-otp.yaml | 68 ++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..2144911297beb89337b0389b30fe6609db4156ea
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/google,gs101-otp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Google GS101 OTP Controller
+
+maintainers:
+ - Tudor Ambarus <tudor.ambarus@linaro.org>
+
+description: |
+ OTP controller drives a NVMEM memory where system or user specific data
+ can be stored. The OTP controller register space if of interest as well
+ because it contains dedicated registers where it stores the Product ID
+ and the Chip ID (apart other things like TMU or ASV info).
+
+allOf:
+ - $ref: nvmem.yaml#
+ - $ref: nvmem-deprecated-cells.yaml
+
+properties:
+ compatible:
+ items:
+ - const: google,gs101-otp
+
+ clocks:
+ maxItems: 1
+
+ clock-names:
+ const: pclk
+
+ reg:
+ maxItems: 1
+
+ power-domains:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - "#address-cells"
+ - "#size-cells"
+ - clock-names
+ - clocks
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/google,gs101.h>
+
+ otp: efuse@10000000 {
+ compatible = "google,gs101-otp";
+ reg = <0x10000000 0xf084>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ clocks = <&cmu_misc CLK_GOUT_MISC_OTP_CON_TOP_PCLK>;
+ clock-names = "pclk";
+
+ product_id: product_id@0 {
+ reg = <0x0 0x4>;
+ };
+
+ chip_id: chip-id@4 {
+ reg = <0x4 0x10>;
+ };
+ };
--
2.51.1.930.gacf6e81ea2-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp
2025-10-31 12:45 ` [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp Tudor Ambarus
@ 2025-10-31 15:02 ` Conor Dooley
2025-10-31 16:06 ` Tudor Ambarus
0 siblings, 1 reply; 10+ messages in thread
From: Conor Dooley @ 2025-10-31 15:02 UTC (permalink / raw)
To: Tudor Ambarus
Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik, semen.protsenko, willmcvicker, kernel-team,
linux-kernel, linux-samsung-soc, devicetree, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 2937 bytes --]
On Fri, Oct 31, 2025 at 12:45:09PM +0000, Tudor Ambarus wrote:
> Add binding for the OTP controller found on Google GS101.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> ---
> .../bindings/nvmem/google,gs101-otp.yaml | 68 ++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..2144911297beb89337b0389b30fe6609db4156ea
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
> @@ -0,0 +1,68 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/nvmem/google,gs101-otp.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Google GS101 OTP Controller
> +
> +maintainers:
> + - Tudor Ambarus <tudor.ambarus@linaro.org>
> +
> +description: |
> + OTP controller drives a NVMEM memory where system or user specific data
> + can be stored. The OTP controller register space if of interest as well
> + because it contains dedicated registers where it stores the Product ID
> + and the Chip ID (apart other things like TMU or ASV info).
> +
> +allOf:
> + - $ref: nvmem.yaml#
> + - $ref: nvmem-deprecated-cells.yaml
Why are the deprecated cells needed here?
| Before introducing NVMEM layouts all NVMEM (fixed) cells were defined
| as direct device subnodes. That syntax was replaced by "fixed-layout"
| and is deprecated now. No new bindings should use it.
> +
> +properties:
> + compatible:
> + items:
> + - const: google,gs101-otp
> +
> + clocks:
> + maxItems: 1
> +
> + clock-names:
> + const: pclk
Why bother with clock-names when you only have one clock? Are you
anticipating a variant with more?
> +
> + reg:
> + maxItems: 1
> +
> + power-domains:
> + maxItems: 1
> +
> +required:
> + - compatible
> + - reg
> + - "#address-cells"
> + - "#size-cells"
> + - clock-names
> + - clocks
> +
> +unevaluatedProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/clock/google,gs101.h>
> +
> + otp: efuse@10000000 {
> + compatible = "google,gs101-otp";
> + reg = <0x10000000 0xf084>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + clocks = <&cmu_misc CLK_GOUT_MISC_OTP_CON_TOP_PCLK>;
> + clock-names = "pclk";
> +
> + product_id: product_id@0 {
Why does this node name have an underscore?
Additionally, all nodes here should lose their labels.
pw-bot: changes-requested
> + reg = <0x0 0x4>;
> + };
> +
> + chip_id: chip-id@4 {
> + reg = <0x4 0x10>;
> + };
> + };
>
> --
> 2.51.1.930.gacf6e81ea2-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp
2025-10-31 15:02 ` Conor Dooley
@ 2025-10-31 16:06 ` Tudor Ambarus
0 siblings, 0 replies; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 16:06 UTC (permalink / raw)
To: Conor Dooley, Srinivas Kandagatla
Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik, semen.protsenko, willmcvicker, kernel-team,
linux-kernel, linux-samsung-soc, devicetree, linux-arm-kernel
On 10/31/25 5:02 PM, Conor Dooley wrote:
> On Fri, Oct 31, 2025 at 12:45:09PM +0000, Tudor Ambarus wrote:
>> Add binding for the OTP controller found on Google GS101.
>>
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
>> ---
>> .../bindings/nvmem/google,gs101-otp.yaml | 68 ++++++++++++++++++++++
>> 1 file changed, 68 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..2144911297beb89337b0389b30fe6609db4156ea
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
>> @@ -0,0 +1,68 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/nvmem/google,gs101-otp.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Google GS101 OTP Controller
>> +
>> +maintainers:
>> + - Tudor Ambarus <tudor.ambarus@linaro.org>
>> +
>> +description: |
>> + OTP controller drives a NVMEM memory where system or user specific data
>> + can be stored. The OTP controller register space if of interest as well
>> + because it contains dedicated registers where it stores the Product ID
>> + and the Chip ID (apart other things like TMU or ASV info).
>> +
>> +allOf:
>> + - $ref: nvmem.yaml#
>> + - $ref: nvmem-deprecated-cells.yaml
>
> Why are the deprecated cells needed here?
> | Before introducing NVMEM layouts all NVMEM (fixed) cells were defined
> | as direct device subnodes. That syntax was replaced by "fixed-layout"
> | and is deprecated now. No new bindings should use it.
>
This OTP controller has an OTP memory space that can be read/program/lock
using specific OTP commands /register pokes (I'm not adding support for
this in this patch set).
The OTP controller register space contains dedicated registers for the
Product ID and Chip ID, which I'd like to expose as nvmem cells so that
a client can parse them and register as a soc device (see [1]).
Right now I need to expose the OTP controller register space, but I
expect that the OTP memory space will need to be exposed as nvmem cells
in the future as well.
Thus I need to be able to expose both the OTP register space and the
OTP memory space as nvmem cells in DT. I thought of using the deprecated
(fixed) cells for the OTP register space and the fixed-layout syntax
for the OTP memory space.
What is the recommended way to expose the OTP register space? I guess
an alternative is to add empty nodes as direct device subnodes, and
define and add the cells to the nvmem device from the driver using
config->cells.
[1] https://lore.kernel.org/linux-samsung-soc/20251031-gs101-chipid-v1-0-d78d1076b210@linaro.org/T/>> +
>> +properties:
>> + compatible:
>> + items:
>> + - const: google,gs101-otp
>> +
>> + clocks:
>> + maxItems: 1
>> +
>> + clock-names:
>> + const: pclk
>
> Why bother with clock-names when you only have one clock? Are you
> anticipating a variant with more?
>
Likely, but I'll drop the name. We can add it later on.>> +
>> + reg:
>> + maxItems: 1
>> +
>> + power-domains:
>> + maxItems: 1
>> +
>> +required:
>> + - compatible
>> + - reg
>> + - "#address-cells"
>> + - "#size-cells"
>> + - clock-names
>> + - clocks
>> +
>> +unevaluatedProperties: false
>> +
>> +examples:
>> + - |
>> + #include <dt-bindings/clock/google,gs101.h>
>> +
>> + otp: efuse@10000000 {
>> + compatible = "google,gs101-otp";
>> + reg = <0x10000000 0xf084>;
>> + #address-cells = <1>;
>> + #size-cells = <1>;
>> + clocks = <&cmu_misc CLK_GOUT_MISC_OTP_CON_TOP_PCLK>;
>> + clock-names = "pclk";
>> +
>> + product_id: product_id@0 {
>
> Why does this node name have an underscore?
I forgot to update, will use product-id for the name>
> Additionally, all nodes here should lose their labels.
and drop the labels from the examples.
Thanks!
ta
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/5] nvmem: add Samsung Exynos OTP support
2025-10-31 12:45 [PATCH 0/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
2025-10-31 12:45 ` [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp Tudor Ambarus
@ 2025-10-31 12:45 ` Tudor Ambarus
2025-11-04 7:19 ` Krzysztof Kozlowski
2025-10-31 12:45 ` [PATCH 3/5] arm64: dts: exynos: gs101: add OTP node Tudor Ambarus
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 12:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel, Tudor Ambarus
Add support for the Samsung Exynos OTP controller. On the Google GS101
SoC, this controller provides 32 Kbit of OTP memory space that can be
read/program/lock using a specific sequence of register accesses.
The OTP controller register space is of interest as well because it
contains dedicated registers for the Product ID and the Chip ID (apart
other things like TMU or ASV info). Register the OTP controller
register space as a nvmem device so that other drivers can access its
contents using nvmem cells.
Support for the OTP memory space can follow and be modeled as a
dedicated nvmem device.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/nvmem/Kconfig | 10 +++++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/exynos-otp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 110 insertions(+)
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index e0d88d3199c11a3b71cc274b2114e9554ac486fc..f973e009737f2fbdc8511e50f1aa9e6003286065 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -84,6 +84,16 @@ config NVMEM_BRCM_NVRAM
This driver provides support for Broadcom's NVRAM that can be accessed
using I/O mapping.
+config NVMEM_EXYNOS_OTP
+ tristate "Samsung Exynos OTP support"
+ depends on ARCH_EXYNOS || COMPILE_TEST
+ help
+ This driver provides support for the OTP controller found on some
+ Samsung Exynos SoCs.
+
+ This driver can also be built as a module. If so, the module
+ will be called exynos-otp.
+
config NVMEM_IMX_IIM
tristate "i.MX IC Identification Module support"
depends on ARCH_MXC || COMPILE_TEST
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 70a4464dcb1e25cf9116280a32f4a0f4f9941a75..920a536fc359a5a7d8f3aabba6a712e85c277ee7 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -20,6 +20,8 @@ obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o
nvmem-bcm-ocotp-y := bcm-ocotp.o
obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
nvmem_brcm_nvram-y := brcm_nvram.o
+obj-$(CONFIG_NVMEM_EXYNOS_OTP) += nvmem-exynos-otp.o
+nvmem-exynos-otp-y := exynos-otp.o
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
diff --git a/drivers/nvmem/exynos-otp.c b/drivers/nvmem/exynos-otp.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bff9421e6f2b80a8f20533b490a289687d117e8
--- /dev/null
+++ b/drivers/nvmem/exynos-otp.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2025 Linaro Ltd.
+ *
+ * Samsung Exynos OTP driver.
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mod_devicetable.h>
+
+struct exynos_otp {
+ struct clk *pclk;
+ struct regmap *regmap;
+};
+
+static int exynos_otp_read(void *context, unsigned int offset, void *val,
+ size_t bytes)
+{
+ struct exynos_otp *eotp = context;
+
+ return regmap_bulk_read(eotp->regmap, offset, val, bytes / 4);
+}
+
+static struct nvmem_config exynos_otp_nvmem_config = {
+ .name = "exynos-otp-reg",
+ .add_legacy_fixed_of_cells = true,
+ .reg_read = exynos_otp_read,
+ .word_size = 4,
+ .stride = 4,
+};
+
+static int exynos_otp_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct nvmem_device *nvmem;
+ struct exynos_otp *eotp;
+ struct resource *res;
+ void __iomem *base;
+
+ eotp = devm_kzalloc(dev, sizeof(*eotp), GFP_KERNEL);
+ if (!eotp)
+ return -ENOMEM;
+
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ const struct regmap_config reg_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+ .use_relaxed_mmio = true,
+ .max_register = (resource_size(res) - reg_config.reg_stride),
+ };
+
+ eotp->regmap = devm_regmap_init_mmio(dev, base, ®_config);
+ if (IS_ERR(eotp->regmap))
+ return PTR_ERR(eotp->regmap);
+
+ eotp->pclk = devm_clk_get_enabled(dev, "pclk");
+ if (IS_ERR(eotp->pclk))
+ return dev_err_probe(dev, PTR_ERR(eotp->pclk),
+ "Could not get pclk\n");
+
+ exynos_otp_nvmem_config.size = resource_size(res);
+ exynos_otp_nvmem_config.dev = dev;
+ exynos_otp_nvmem_config.priv = eotp;
+
+ nvmem = devm_nvmem_register(dev, &exynos_otp_nvmem_config);
+
+ return PTR_ERR_OR_ZERO(nvmem);
+}
+
+static const struct of_device_id exynos_otp_dt_ids[] = {
+ { .compatible = "google,gs101-otp" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, exynos_otp_dt_ids);
+
+static struct platform_driver exynos_otp_driver = {
+ .probe = exynos_otp_probe,
+ .driver = {
+ .name = "exynos-otp",
+ .of_match_table = exynos_otp_dt_ids,
+ },
+};
+module_platform_driver(exynos_otp_driver);
+
+MODULE_AUTHOR("Tudor Ambarus <tudor.ambarus@linaro.org>");
+MODULE_DESCRIPTION("Samsung Exynos OTP driver");
+MODULE_LICENSE("GPL");
--
2.51.1.930.gacf6e81ea2-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 2/5] nvmem: add Samsung Exynos OTP support
2025-10-31 12:45 ` [PATCH 2/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
@ 2025-11-04 7:19 ` Krzysztof Kozlowski
2025-11-10 9:52 ` Tudor Ambarus
0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-04 7:19 UTC (permalink / raw)
To: Tudor Ambarus, Srinivas Kandagatla, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel
On 31/10/2025 13:45, Tudor Ambarus wrote:
> Add support for the Samsung Exynos OTP controller. On the Google GS101
> SoC, this controller provides 32 Kbit of OTP memory space that can be
> read/program/lock using a specific sequence of register accesses.
>
> The OTP controller register space is of interest as well because it
> contains dedicated registers for the Product ID and the Chip ID (apart
> other things like TMU or ASV info). Register the OTP controller
> register space as a nvmem device so that other drivers can access its
> contents using nvmem cells.
>
> Support for the OTP memory space can follow and be modeled as a
> dedicated nvmem device.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> ---
> drivers/nvmem/Kconfig | 10 +++++
> drivers/nvmem/Makefile | 2 +
> drivers/nvmem/exynos-otp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 110 insertions(+)
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index e0d88d3199c11a3b71cc274b2114e9554ac486fc..f973e009737f2fbdc8511e50f1aa9e6003286065 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -84,6 +84,16 @@ config NVMEM_BRCM_NVRAM
> This driver provides support for Broadcom's NVRAM that can be accessed
> using I/O mapping.
>
> +config NVMEM_EXYNOS_OTP
> + tristate "Samsung Exynos OTP support"
> + depends on ARCH_EXYNOS || COMPILE_TEST
> + help
> + This driver provides support for the OTP controller found on some
> + Samsung Exynos SoCs.
> +
> + This driver can also be built as a module. If so, the module
> + will be called exynos-otp.
> +
> config NVMEM_IMX_IIM
> tristate "i.MX IC Identification Module support"
> depends on ARCH_MXC || COMPILE_TEST
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index 70a4464dcb1e25cf9116280a32f4a0f4f9941a75..920a536fc359a5a7d8f3aabba6a712e85c277ee7 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -20,6 +20,8 @@ obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o
> nvmem-bcm-ocotp-y := bcm-ocotp.o
> obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
> nvmem_brcm_nvram-y := brcm_nvram.o
> +obj-$(CONFIG_NVMEM_EXYNOS_OTP) += nvmem-exynos-otp.o
> +nvmem-exynos-otp-y := exynos-otp.o
> 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
> diff --git a/drivers/nvmem/exynos-otp.c b/drivers/nvmem/exynos-otp.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..3bff9421e6f2b80a8f20533b490a289687d117e8
> --- /dev/null
> +++ b/drivers/nvmem/exynos-otp.c
> @@ -0,0 +1,98 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright 2025 Linaro Ltd.
> + *
> + * Samsung Exynos OTP driver.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/ioport.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/mod_devicetable.h>
> +
> +struct exynos_otp {
> + struct clk *pclk;
> + struct regmap *regmap;
> +};
> +
> +static int exynos_otp_read(void *context, unsigned int offset, void *val,
> + size_t bytes)
> +{
> + struct exynos_otp *eotp = context;
> +
> + return regmap_bulk_read(eotp->regmap, offset, val, bytes / 4);
So you are just reading MMIO and pretending this is NVMEM?
Is it possible to actually do the other actions from your commit msg
"read/program/lock"? If not, then you just created NVMEM abstraction
over existing chipid completely duplicating the driver (with more
translation layers).
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 2/5] nvmem: add Samsung Exynos OTP support
2025-11-04 7:19 ` Krzysztof Kozlowski
@ 2025-11-10 9:52 ` Tudor Ambarus
0 siblings, 0 replies; 10+ messages in thread
From: Tudor Ambarus @ 2025-11-10 9:52 UTC (permalink / raw)
To: Krzysztof Kozlowski, Srinivas Kandagatla, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel
On 11/4/25 9:19 AM, Krzysztof Kozlowski wrote:
> On 31/10/2025 13:45, Tudor Ambarus wrote:
>> Add support for the Samsung Exynos OTP controller. On the Google GS101
>> SoC, this controller provides 32 Kbit of OTP memory space that can be
>> read/program/lock using a specific sequence of register accesses.
>>
>> The OTP controller register space is of interest as well because it
>> contains dedicated registers for the Product ID and the Chip ID (apart
>> other things like TMU or ASV info). Register the OTP controller
>> register space as a nvmem device so that other drivers can access its
>> contents using nvmem cells.
>>
>> Support for the OTP memory space can follow and be modeled as a
>> dedicated nvmem device.
>>
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
>> ---
>> drivers/nvmem/Kconfig | 10 +++++
>> drivers/nvmem/Makefile | 2 +
>> drivers/nvmem/exynos-otp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 110 insertions(+)
>>
>> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
>> index e0d88d3199c11a3b71cc274b2114e9554ac486fc..f973e009737f2fbdc8511e50f1aa9e6003286065 100644
>> --- a/drivers/nvmem/Kconfig
>> +++ b/drivers/nvmem/Kconfig
>> @@ -84,6 +84,16 @@ config NVMEM_BRCM_NVRAM
>> This driver provides support for Broadcom's NVRAM that can be accessed
>> using I/O mapping.
>>
>> +config NVMEM_EXYNOS_OTP
>> + tristate "Samsung Exynos OTP support"
>> + depends on ARCH_EXYNOS || COMPILE_TEST
>> + help
>> + This driver provides support for the OTP controller found on some
>> + Samsung Exynos SoCs.
>> +
>> + This driver can also be built as a module. If so, the module
>> + will be called exynos-otp.
>> +
>> config NVMEM_IMX_IIM
>> tristate "i.MX IC Identification Module support"
>> depends on ARCH_MXC || COMPILE_TEST
>> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
>> index 70a4464dcb1e25cf9116280a32f4a0f4f9941a75..920a536fc359a5a7d8f3aabba6a712e85c277ee7 100644
>> --- a/drivers/nvmem/Makefile
>> +++ b/drivers/nvmem/Makefile
>> @@ -20,6 +20,8 @@ obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o
>> nvmem-bcm-ocotp-y := bcm-ocotp.o
>> obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
>> nvmem_brcm_nvram-y := brcm_nvram.o
>> +obj-$(CONFIG_NVMEM_EXYNOS_OTP) += nvmem-exynos-otp.o
>> +nvmem-exynos-otp-y := exynos-otp.o
>> 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
>> diff --git a/drivers/nvmem/exynos-otp.c b/drivers/nvmem/exynos-otp.c
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..3bff9421e6f2b80a8f20533b490a289687d117e8
>> --- /dev/null
>> +++ b/drivers/nvmem/exynos-otp.c
>> @@ -0,0 +1,98 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Copyright 2025 Linaro Ltd.
>> + *
>> + * Samsung Exynos OTP driver.
>> + */
>> +
>> +#include <linux/clk.h>
>> +#include <linux/device.h>
>> +#include <linux/err.h>
>> +#include <linux/ioport.h>
>> +#include <linux/module.h>
>> +#include <linux/nvmem-provider.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/regmap.h>
>> +#include <linux/mod_devicetable.h>
>> +
>> +struct exynos_otp {
>> + struct clk *pclk;
>> + struct regmap *regmap;
>> +};
>> +
>> +static int exynos_otp_read(void *context, unsigned int offset, void *val,
>> + size_t bytes)
>> +{
>> + struct exynos_otp *eotp = context;
>> +
>> + return regmap_bulk_read(eotp->regmap, offset, val, bytes / 4);
>
>
> So you are just reading MMIO and pretending this is NVMEM?
Right. I thought of registering the OTP register space as a nvmem
device, so that consumers can read it. The OTP memory space (32Kbit,
the one accessed via OTP commands) can then be registered as another
nvmem device.
>
> Is it possible to actually do the other actions from your commit msg
> "read/program/lock"? If not, then you just created NVMEM abstraction
It is possible to add support for the OTP memory space (32Kbit) and model
it as a nvmem device, but I don't really care about it because downstream
does not use the OTP memory space in the kernel.
I now think that the correct way to handle the chipid for gs101 is to
register to the SoC interface directly from the efuse driver. Support
for the OTP memory space can come later on if needed, I don't really need
to register any nvmem space for now.
Thanks,
ta
> over existing chipid completely duplicating the driver (with more
> translation layers).
>
> Best regards,
> Krzysztof
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/5] arm64: dts: exynos: gs101: add OTP node
2025-10-31 12:45 [PATCH 0/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
2025-10-31 12:45 ` [PATCH 1/5] dt-bindings: nvmem: add google,gs101-otp Tudor Ambarus
2025-10-31 12:45 ` [PATCH 2/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
@ 2025-10-31 12:45 ` Tudor Ambarus
2025-10-31 12:45 ` [PATCH 4/5] arm64: defconfig: enable Samsung Exynos OTP controller Tudor Ambarus
2025-10-31 12:45 ` [PATCH 5/5] MAINTAINERS: add entry for the Samsung Exynos OTP controller driver Tudor Ambarus
4 siblings, 0 replies; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 12:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel, Tudor Ambarus
Add the OTP controller node.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
arch/arm64/boot/dts/exynos/google/gs101.dtsi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
index d06d1d05f36408137a8acd98e43d48ea7d4f4292..3cd5675c094c0774b0efba1b5f76f8916cff3fc4 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
+++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
@@ -571,6 +571,23 @@ soc: soc@0 {
#size-cells = <1>;
ranges = <0x0 0x0 0x0 0x40000000>;
+ otp: efuse@10000000 {
+ compatible = "google,gs101-otp";
+ reg = <0x10000000 0xf084>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ clocks = <&cmu_misc CLK_GOUT_MISC_OTP_CON_TOP_PCLK>;
+ clock-names = "pclk";
+
+ product_id: product-id@0 {
+ reg = <0x0 0x4>;
+ };
+
+ chip_id: chip-id@4 {
+ reg = <0x4 0x10>;
+ };
+ };
+
cmu_misc: clock-controller@10010000 {
compatible = "google,gs101-cmu-misc";
reg = <0x10010000 0x10000>;
--
2.51.1.930.gacf6e81ea2-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 4/5] arm64: defconfig: enable Samsung Exynos OTP controller
2025-10-31 12:45 [PATCH 0/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
` (2 preceding siblings ...)
2025-10-31 12:45 ` [PATCH 3/5] arm64: dts: exynos: gs101: add OTP node Tudor Ambarus
@ 2025-10-31 12:45 ` Tudor Ambarus
2025-10-31 12:45 ` [PATCH 5/5] MAINTAINERS: add entry for the Samsung Exynos OTP controller driver Tudor Ambarus
4 siblings, 0 replies; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 12:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel, Tudor Ambarus
Enable the exynos-otp nvmem driver for fuse access on the Samsung Exynos
SoCs. The fuse block stores various system information (Product ID,
Chip ID, TMU, ASV, etc.) which will be accessed by client drivers.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
arch/arm64/configs/defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 646097e94efe7f1a18fb59d5b6dfc6268be91383..6433e3c0f88b892ce6f2ee190f866a6ab4889771 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1682,6 +1682,7 @@ CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU=m
CONFIG_NVIDIA_CORESIGHT_PMU_ARCH_SYSTEM_PMU=m
CONFIG_MESON_DDR_PMU=m
CONFIG_NVMEM_LAYOUT_SL28_VPD=m
+CONFIG_NVMEM_EXYNOS_OTP=m
CONFIG_NVMEM_IMX_OCOTP=y
CONFIG_NVMEM_IMX_OCOTP_ELE=m
CONFIG_NVMEM_IMX_OCOTP_SCU=y
--
2.51.1.930.gacf6e81ea2-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/5] MAINTAINERS: add entry for the Samsung Exynos OTP controller driver
2025-10-31 12:45 [PATCH 0/5] nvmem: add Samsung Exynos OTP support Tudor Ambarus
` (3 preceding siblings ...)
2025-10-31 12:45 ` [PATCH 4/5] arm64: defconfig: enable Samsung Exynos OTP controller Tudor Ambarus
@ 2025-10-31 12:45 ` Tudor Ambarus
4 siblings, 0 replies; 10+ messages in thread
From: Tudor Ambarus @ 2025-10-31 12:45 UTC (permalink / raw)
To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Krzysztof Kozlowski, Alim Akhtar, Peter Griffin,
André Draszik
Cc: semen.protsenko, willmcvicker, kernel-team, linux-kernel,
linux-samsung-soc, devicetree, linux-arm-kernel, Tudor Ambarus
Add an entry for the Samsung Exynos OTP controller driver.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index ab00eca640e02d40dd80949986d6cd6216ee6194..813a098475ab7d5371c811020ea022f63d1acb35 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22775,6 +22775,14 @@ F: Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml
F: drivers/mailbox/exynos-mailbox.c
F: include/linux/mailbox/exynos-message.h
+SAMSUNG EXYNOS OTP DRIVER
+M: Tudor Ambarus <tudor.ambarus@linaro.org>
+L: linux-kernel@vger.kernel.org
+L: linux-samsung-soc@vger.kernel.org
+S: Supported
+F: Documentation/devicetree/bindings/nvmem/google,gs101-otp.yaml
+F: drivers/nvmem/exynos-otp.c
+
SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
M: Krzysztof Kozlowski <krzk@kernel.org>
L: linux-crypto@vger.kernel.org
--
2.51.1.930.gacf6e81ea2-goog
^ permalink raw reply related [flat|nested] 10+ messages in thread