Skip to contentSkip to conversation

nvmem: Add Nuvoton NPCM OTP driver

PATCH In review Kuan-Wei Chiu 3 participants 8 messages Mar 18 – Mar 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover nvmem: Add Nuvoton NPCM OTP driver

Add support for the OTP memory controllers found on Nuvoton NPCM7 SoCs.

This OTP is read-only and manages two independent arrays: Key Storage and Fuse Array, which contain cryptographic keys, hardware strapping, and calibration data. Each array provides 1024 bytes of storage.

You can use qemu-system-arm -M npcm750-evb to play around with it.

Kuan-Wei Chiu (3):
dt-bindings: nvmem: add nuvoton,npcm750-otp
nvmem: npcm-otp: Add Nuvoton NPCM OTP driver
ARM: dts: nuvoton: Add OTP nodes for NPCM7xx

 .../bindings/nvmem/nuvoton,npcm750-otp.yaml   |  35 +++++
 MAINTAINERS                                   |   7 +
 .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi   |  10 ++
 drivers/nvmem/Kconfig                         |  10 ++
 drivers/nvmem/Makefile                        |   2 +
 drivers/nvmem/npcm-otp.c                      | 129 ++++++++++++++++++
 6 files changed, 193 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml
 create mode 100644 drivers/nvmem/npcm-otp.c
Signature · 1 line
2.53.0.851.ga537e3e6e9-goog
#1 lore raw

PATCH 1/3 dt-bindings: nvmem: add nuvoton,npcm750-otp

Add device tree bindings for the OTP memory controllers found on Nuvoton NPCM7xx SoCs.

The NPCM7xx SoCs contain two independent OTP memory arrays:
- Key Storage (OTP1): used for cryptographic keys.
- Fuse Array (OTP2): used for hardware strapping, calibration data, and derivative definitions.

Each controller provides up to 1024 bytes of read-only storage.

---
 .../bindings/nvmem/nuvoton,npcm750-otp.yaml   | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml
Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml new file +35 -0
new file mode 100644
index 000000000000..45bcf72d7c78
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/nuvoton,npcm750-otp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NPCM7xx OTP (One-Time Programmable) Memory
+
+maintainers:
+  - Kuan-Wei Chiu <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,npcm750-key-storage
+      - nuvoton,npcm750-fuse-array
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    otp@f0189000 {
+        compatible = "nuvoton,npcm750-key-storage";
+        reg = <0xf0189000 0x1000>;
+    };
Signature · 1 line
2.53.0.851.ga537e3e6e9-goog
#2 lore raw

Re: [PATCH 1/3] dt-bindings: nvmem: add nuvoton,npcm750-otp

Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml line 19

Quoted 11 lines · Kuan-Wei Chiu
Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml new file +11 -0
+maintainers:
+  - Kuan-Wei Chiu <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,npcm750-key-storage
+      - nuvoton,npcm750-fuse-array

Your driver says these are exactly the same devices, so you got only one compatible. Otherwise explain in commit msg why these are different (current message speaks about purpose, but is not what is needed here).

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/3] dt-bindings: nvmem: add nuvoton,npcm750-otp

Hi Krzysztof,

Quoted 17 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml line 19

Quoted 11 lines · Kuan-Wei Chiu
Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml new file +11 -0
+maintainers:
+  - Kuan-Wei Chiu <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,npcm750-key-storage
+      - nuvoton,npcm750-fuse-array

Your driver says these are exactly the same devices, so you got only one compatible. Otherwise explain in commit msg why these are different (current message speaks about purpose, but is not what is needed here).

Thanks for the prompt review.

I will drop the content-specific compatible strings and unify them into a single "nuvoton,npcm750-otp" in the upcoming v2 series.

Regards,
Kuan-Wei

#4 lore raw

PATCH 2/3 nvmem: npcm-otp: Add Nuvoton NPCM OTP driver

In reply to Kuan-Wei Chiu

Add a new NVMEM driver for the OTP memory controllers found on Nuvoton NPCM SoCs.

This OTP is read-only and manages two independent arrays: Key Storage and Fuse Array, which contain cryptographic keys, hardware strapping, and calibration data.

Each array provides 1024 bytes of storage.

It can be accessed by writing the target address and a read command to the control registers, and then polling a status register until the data is ready. Concurrent accesses are protected by a mutex.

---
 MAINTAINERS              |   7 +++
 drivers/nvmem/Kconfig    |  10 +++
 drivers/nvmem/Makefile   |   2 +
 drivers/nvmem/npcm-otp.c | 129 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 drivers/nvmem/npcm-otp.c
MAINTAINERS +7 -0
index 61bf550fd37c..e391e2bcb5f6 100644
@@ -18894,6 +18894,13 @@ F:	drivers/nubus/
 F:	include/linux/nubus.h
 F:	include/uapi/linux/nubus.h
 
+NUVOTON NPCM OTP NVMEM DRIVER
+M:	Kuan-Wei Chiu <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml
+F:	drivers/nvmem/npcm-otp.c
+
 NUVOTON NCT6694 MFD DRIVER
 M:	Ming Yu <[email protected]>
 S:	Supported
drivers/nvmem/Kconfig +10 -0
index 74ddbd0f79b0..5d065b7448ff 100644
@@ -483,4 +483,14 @@ config NVMEM_QORIQ_EFUSE
 	  This driver can also be built as a module. If so, the module
 	  will be called nvmem_qoriq_efuse.
 
+config NVMEM_NPCM_OTP
+	tristate "Nuvoton NPCM7xx OTP Controller"
+	depends on ARCH_NPCM || COMPILE_TEST
+	help
+	  This option enables support for the OTP (One-Time Programmable)
+	  controller found on Nuvoton NPCM7xx BMCs.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called npcm-otp.
+
 endif
drivers/nvmem/Makefile +2 -0
index 7252b8ec88d4..63c23b304d64 100644
@@ -95,3 +95,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP)		+= nvmem_zynqmp_nvmem.o
 nvmem_zynqmp_nvmem-y			:= zynqmp_nvmem.o
 obj-$(CONFIG_NVMEM_QORIQ_EFUSE)		+= nvmem-qoriq-efuse.o
 nvmem-qoriq-efuse-y			:= qoriq-efuse.o
+obj-$(CONFIG_NVMEM_NPCM_OTP)		+= nvmem-npcm-otp.o
+nvmem-npcm-otp-y			:= npcm-otp.o
drivers/nvmem/npcm-otp.c new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
2.53.0.851.ga537e3e6e9-goog
maintainer
#5 lore raw

Re: [PATCH 2/3] nvmem: npcm-otp: Add Nuvoton NPCM OTP driver

Hi Kuan-Wei,

Thanks for the upstream Nuvoton OTP driver.

Quoted 157 lines · Kuan-Wei Chiu

Add a new NVMEM driver for the OTP memory controllers found on Nuvoton NPCM SoCs.

This OTP is read-only and manages two independent arrays: Key Storage and Fuse Array, which contain cryptographic keys, hardware strapping, and calibration data.

Each array provides 1024 bytes of storage.

It can be accessed by writing the target address and a read command to the control registers, and then polling a status register until the data is ready. Concurrent accesses are protected by a mutex.

---
 MAINTAINERS              |   7 +++
 drivers/nvmem/Kconfig    |  10 +++
 drivers/nvmem/Makefile   |   2 +
 drivers/nvmem/npcm-otp.c | 129 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 drivers/nvmem/npcm-otp.c
MAINTAINERS +7 -0
index 61bf550fd37c..e391e2bcb5f6 100644
@@ -18894,6 +18894,13 @@ F:     drivers/nubus/
 F:     include/linux/nubus.h
 F:     include/uapi/linux/nubus.h
 
+NUVOTON NPCM OTP NVMEM DRIVER
+M:     Kuan-Wei Chiu <[email protected]>
+L:     [email protected] (moderated for non-subscribers)
+S:     Maintained
+F:     Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml
+F:     drivers/nvmem/npcm-otp.c
+
 NUVOTON NCT6694 MFD DRIVER
 M:     Ming Yu <[email protected]>
 S:     Supported
drivers/nvmem/Kconfig +10 -0
index 74ddbd0f79b0..5d065b7448ff 100644
@@ -483,4 +483,14 @@ config NVMEM_QORIQ_EFUSE
          This driver can also be built as a module. If so, the module
          will be called nvmem_qoriq_efuse.
 
+config NVMEM_NPCM_OTP
+       tristate "Nuvoton NPCM7xx OTP Controller"
+       depends on ARCH_NPCM || COMPILE_TEST
+       help
+         This option enables support for the OTP (One-Time Programmable)
+         controller found on Nuvoton NPCM7xx BMCs.
+
+         This driver can also be built as a module. If so, the module
+         will be called npcm-otp.
+
 endif
drivers/nvmem/Makefile +2 -0
index 7252b8ec88d4..63c23b304d64 100644
@@ -95,3 +95,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP)            += nvmem_zynqmp_nvmem.o
 nvmem_zynqmp_nvmem-y                   := zynqmp_nvmem.o
 obj-$(CONFIG_NVMEM_QORIQ_EFUSE)                += nvmem-qoriq-efuse.o
 nvmem-qoriq-efuse-y                    := qoriq-efuse.o
+obj-$(CONFIG_NVMEM_NPCM_OTP)           += nvmem-npcm-otp.o
+nvmem-npcm-otp-y                       := npcm-otp.o
drivers/nvmem/npcm-otp.c new file +81 -0
new file mode 100644
index 000000000000..abe4bab66c06
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Nuvoton NPCM7xx OTP (One-Time Programmable) NVMEM driver
+ *
+ * Copyright (C) 2026 Kuan-Wei Chiu <[email protected]>
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+/* Register offsets and bitmasks */
+#define NPCM_OTP_FST           0x00
+#define NPCM_OTP_FADDR         0x04
+#define NPCM_OTP_FDATA         0x08
+#define NPCM_OTP_FCTL          0x14
+
+#define FST_RDY                        BIT(0)
+#define FST_RDST               BIT(1)
+#define FCTL_READ_CMD          0x02
+
+/* OTP total capacity is 8192 bits (1024 Bytes) */
+#define NPCM_OTP_SIZE          1024
+
+struct npcm_otp {
+       void __iomem *base;
+       struct mutex lock; /* protects concurrent OTP accesses */
+};
+
+static int npcm_otp_read_byte(struct npcm_otp *otp, unsigned int offset, u8 *val)
+{
+       u32 fst;
+       int ret;
+
+       writel(offset, otp->base + NPCM_OTP_FADDR);
+       writel(FCTL_READ_CMD, otp->base + NPCM_OTP_FCTL);
+
+       ret = readl_poll_timeout(otp->base + NPCM_OTP_FST, fst,
+                                (fst & FST_RDY), 10, 10000);
+       if (ret)
+               return ret;
+
+       *val = (u8)(readl(otp->base + NPCM_OTP_FDATA) & 0xFF);
+
+       /* Clear the status bit to prepare for the next read */
+       writel(FST_RDST, otp->base + NPCM_OTP_FST);
+
+       return 0;
+}
+
+static int npcm_otp_read(void *context, unsigned int offset,
+                        void *val, size_t bytes)
+{
+       struct npcm_otp *otp = context;
+       u8 *buf = val;
+       int ret = 0;
+       size_t i;
+
+       mutex_lock(&otp->lock);
+
+       for (i = 0; i < bytes; i++) {
+               ret = npcm_otp_read_byte(otp, offset + i, &buf[i]);
+               if (ret)
+                       break;
+       }
+
+       mutex_unlock(&otp->lock);
+
+       return ret;
+}
+
+static int npcm_otp_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct npcm_otp *otp;

drivers/nvmem/npcm-otp.c line 91

Quoted 10 lines
drivers/nvmem/npcm-otp.c new file +10 -0
+       struct nvmem_config config = { 0 };
+       struct nvmem_device *nvmem;
+
+       otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
+       if (!otp)
+               return -ENOMEM;
+
+       otp->base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(otp->base))
+               return PTR_ERR(otp->base);

Since the driver already opens and manages the OTP registers, it should also be responsible for handling the OTP index.
The NPCM AES driver can make use of keys stored in OTP.
We would be happy to help add support for OTP‑stored keys to the upstream driver.
If you’d like, we can set up a meeting to discuss how this can be implemented.

drivers/nvmem/npcm-otp.c line 102

Quoted 11 lines
drivers/nvmem/npcm-otp.c new file +11 -0
+
+       mutex_init(&otp->lock);
+
+       config.dev = dev;
+       config.name = dev_name(dev);
+       config.read_only = true;
+       config.word_size = 1;
+       config.stride = 1;
+       config.reg_read = npcm_otp_read;
+       config.priv = otp;
+       config.size = NPCM_OTP_SIZE;

Suggest setting the size according to the BMC SoC, The NPCM7xx has 2 8Kbyte OTP, and the NPCM8xx 64KB size.OPT

Quoted 28 lines
drivers/nvmem/npcm-otp.c new file +27 -1
+
+       nvmem = devm_nvmem_register(dev, &config);
+       if (IS_ERR(nvmem))
+               return dev_err_probe(dev, PTR_ERR(nvmem), "Failed to register nvmem\n");
+
+       return 0;
+}
+
+static const struct of_device_id npcm_otp_dt_ids[] = {
+       { .compatible = "nuvoton,npcm750-key-storage" },
+       { .compatible = "nuvoton,npcm750-fuse-array" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, npcm_otp_dt_ids);
+
+static struct platform_driver npcm_otp_driver = {
+       .probe          = npcm_otp_probe,
+       .driver         = {
+               .name   = "npcm-otp",
+               .of_match_table = npcm_otp_dt_ids,
+       },
+};
+module_platform_driver(npcm_otp_driver);
+
+MODULE_AUTHOR("Kuan-Wei Chiu <[email protected]>");
+MODULE_DESCRIPTION("Nuvoton NPCM7xx OTP NVMEM driver");
+MODULE_LICENSE("GPL");
--
Quoted 2 lines

2.53.0.851.ga537e3e6e9-goog

Thanks,

Tomer

#6 lore raw

Re: [PATCH 2/3] nvmem: npcm-otp: Add Nuvoton NPCM OTP driver

Hi Tomer,

Quoted 170 lines · Tomer Maimon

Hi Kuan-Wei,

Thanks for the upstream Nuvoton OTP driver.

Quoted 165 lines · Kuan-Wei Chiu

Add a new NVMEM driver for the OTP memory controllers found on Nuvoton NPCM SoCs.

This OTP is read-only and manages two independent arrays: Key Storage and Fuse Array, which contain cryptographic keys, hardware strapping, and calibration data.

Each array provides 1024 bytes of storage.

It can be accessed by writing the target address and a read command to the control registers, and then polling a status register until the data is ready. Concurrent accesses are protected by a mutex.

---
 MAINTAINERS              |   7 +++
 drivers/nvmem/Kconfig    |  10 +++
 drivers/nvmem/Makefile   |   2 +
 drivers/nvmem/npcm-otp.c | 129 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 drivers/nvmem/npcm-otp.c
MAINTAINERS +7 -0
index 61bf550fd37c..e391e2bcb5f6 100644
@@ -18894,6 +18894,13 @@ F:     drivers/nubus/
 F:     include/linux/nubus.h
 F:     include/uapi/linux/nubus.h
 
+NUVOTON NPCM OTP NVMEM DRIVER
+M:     Kuan-Wei Chiu <[email protected]>
+L:     [email protected] (moderated for non-subscribers)
+S:     Maintained
+F:     Documentation/devicetree/bindings/nvmem/nuvoton,npcm750-otp.yaml
+F:     drivers/nvmem/npcm-otp.c
+
 NUVOTON NCT6694 MFD DRIVER
 M:     Ming Yu <[email protected]>
 S:     Supported
drivers/nvmem/Kconfig +10 -0
index 74ddbd0f79b0..5d065b7448ff 100644
@@ -483,4 +483,14 @@ config NVMEM_QORIQ_EFUSE
          This driver can also be built as a module. If so, the module
          will be called nvmem_qoriq_efuse.
 
+config NVMEM_NPCM_OTP
+       tristate "Nuvoton NPCM7xx OTP Controller"
+       depends on ARCH_NPCM || COMPILE_TEST
+       help
+         This option enables support for the OTP (One-Time Programmable)
+         controller found on Nuvoton NPCM7xx BMCs.
+
+         This driver can also be built as a module. If so, the module
+         will be called npcm-otp.
+
 endif
drivers/nvmem/Makefile +2 -0
index 7252b8ec88d4..63c23b304d64 100644
@@ -95,3 +95,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP)            += nvmem_zynqmp_nvmem.o
 nvmem_zynqmp_nvmem-y                   := zynqmp_nvmem.o
 obj-$(CONFIG_NVMEM_QORIQ_EFUSE)                += nvmem-qoriq-efuse.o
 nvmem-qoriq-efuse-y                    := qoriq-efuse.o
+obj-$(CONFIG_NVMEM_NPCM_OTP)           += nvmem-npcm-otp.o
+nvmem-npcm-otp-y                       := npcm-otp.o
drivers/nvmem/npcm-otp.c new file +89 -0
new file mode 100644
index 000000000000..abe4bab66c06
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Nuvoton NPCM7xx OTP (One-Time Programmable) NVMEM driver
+ *
+ * Copyright (C) 2026 Kuan-Wei Chiu <[email protected]>
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+/* Register offsets and bitmasks */
+#define NPCM_OTP_FST           0x00
+#define NPCM_OTP_FADDR         0x04
+#define NPCM_OTP_FDATA         0x08
+#define NPCM_OTP_FCTL          0x14
+
+#define FST_RDY                        BIT(0)
+#define FST_RDST               BIT(1)
+#define FCTL_READ_CMD          0x02
+
+/* OTP total capacity is 8192 bits (1024 Bytes) */
+#define NPCM_OTP_SIZE          1024
+
+struct npcm_otp {
+       void __iomem *base;
+       struct mutex lock; /* protects concurrent OTP accesses */
+};
+
+static int npcm_otp_read_byte(struct npcm_otp *otp, unsigned int offset, u8 *val)
+{
+       u32 fst;
+       int ret;
+
+       writel(offset, otp->base + NPCM_OTP_FADDR);
+       writel(FCTL_READ_CMD, otp->base + NPCM_OTP_FCTL);
+
+       ret = readl_poll_timeout(otp->base + NPCM_OTP_FST, fst,
+                                (fst & FST_RDY), 10, 10000);
+       if (ret)
+               return ret;
+
+       *val = (u8)(readl(otp->base + NPCM_OTP_FDATA) & 0xFF);
+
+       /* Clear the status bit to prepare for the next read */
+       writel(FST_RDST, otp->base + NPCM_OTP_FST);
+
+       return 0;
+}
+
+static int npcm_otp_read(void *context, unsigned int offset,
+                        void *val, size_t bytes)
+{
+       struct npcm_otp *otp = context;
+       u8 *buf = val;
+       int ret = 0;
+       size_t i;
+
+       mutex_lock(&otp->lock);
+
+       for (i = 0; i < bytes; i++) {
+               ret = npcm_otp_read_byte(otp, offset + i, &buf[i]);
+               if (ret)
+                       break;
+       }
+
+       mutex_unlock(&otp->lock);
+
+       return ret;
+}
+
+static int npcm_otp_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct npcm_otp *otp;
+       struct nvmem_config config = { 0 };
+       struct nvmem_device *nvmem;
+
+       otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
+       if (!otp)
+               return -ENOMEM;
+
+       otp->base = devm_platform_ioremap_resource(pdev, 0);
Quoted 8 lines

drivers/nvmem/npcm-otp.c line 91

Quoted 2 lines
drivers/nvmem/npcm-otp.c new file +2 -0
+       if (IS_ERR(otp->base))
+               return PTR_ERR(otp->base);

Since the driver already opens and manages the OTP registers, it should also be responsible for handling the OTP index.
The NPCM AES driver can make use of keys stored in OTP.
We would be happy to help add support for OTP‑stored keys to the upstream driver.
If you’d like, we can set up a meeting to discuss how this can be implemented.

I would be very happy to collaborate. :)

Regarding scheduling a meeting, I will be traveling abroad from 03/22 to 04/01 with very limited and unstable network access, so I would prefer to avoid that window. We can coordinate the exact date and time off-list.

Regards,
Kuan-Wei

Quoted 47 lines

drivers/nvmem/npcm-otp.c line 102

Quoted 11 lines
drivers/nvmem/npcm-otp.c new file +11 -0
+
+       mutex_init(&otp->lock);
+
+       config.dev = dev;
+       config.name = dev_name(dev);
+       config.read_only = true;
+       config.word_size = 1;
+       config.stride = 1;
+       config.reg_read = npcm_otp_read;
+       config.priv = otp;
+       config.size = NPCM_OTP_SIZE;

Suggest setting the size according to the BMC SoC, The NPCM7xx has 2 8Kbyte OTP, and the NPCM8xx 64KB size.OPT

Quoted 28 lines
drivers/nvmem/npcm-otp.c new file +27 -1
+
+       nvmem = devm_nvmem_register(dev, &config);
+       if (IS_ERR(nvmem))
+               return dev_err_probe(dev, PTR_ERR(nvmem), "Failed to register nvmem\n");
+
+       return 0;
+}
+
+static const struct of_device_id npcm_otp_dt_ids[] = {
+       { .compatible = "nuvoton,npcm750-key-storage" },
+       { .compatible = "nuvoton,npcm750-fuse-array" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, npcm_otp_dt_ids);
+
+static struct platform_driver npcm_otp_driver = {
+       .probe          = npcm_otp_probe,
+       .driver         = {
+               .name   = "npcm-otp",
+               .of_match_table = npcm_otp_dt_ids,
+       },
+};
+module_platform_driver(npcm_otp_driver);
+
+MODULE_AUTHOR("Kuan-Wei Chiu <[email protected]>");
+MODULE_DESCRIPTION("Nuvoton NPCM7xx OTP NVMEM driver");
+MODULE_LICENSE("GPL");
--
Quoted 2 lines

2.53.0.851.ga537e3e6e9-goog

Thanks,

Tomer

#7 lore raw

PATCH 3/3 ARM: dts: nuvoton: Add OTP nodes for NPCM7xx

In reply to Kuan-Wei Chiu

Add device tree nodes for the OTP memory controllers found on Nuvoton NPCM7xx SoCs.

The controllers (Key Storage and Fuse Array) are attached to the APB bus. Since they are internal SoC components with no board-level dependencies, they are enabled by default.

---
 arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi +10 -0
index ab3c3c5713ae..8a28b1f8a4fd 100644
@@ -480,6 +480,16 @@ &fanin12_pins &fanin13_pins
 				status = "disabled";
 			};
 
+			otp1: otp@189000 {
+				compatible = "nuvoton,npcm750-key-storage";
+				reg = <0x189000 0x1000>;
+			};
+
+			otp2: otp@18a000 {
+				compatible = "nuvoton,npcm750-fuse-array";
+				reg = <0x18a000 0x1000>;
+			};
+
 			i2c0: i2c@80000 {
 				reg = <0x80000 0x1000>;
 				compatible = "nuvoton,npcm750-i2c";
Signature · 1 line
2.53.0.851.ga537e3e6e9-goog