Skip to contentSkip to conversation

nvmem: Add Sophgo eFuse driver

PATCH In review Jisheng Zhang 3 participants 5 messages Nov 19, 2023 – Nov 27, 2023

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

cover nvmem: Add Sophgo eFuse driver

Sophgo SoCs such as CV1800B contain eFuses used to store factory-programmed data such as calibration values for the built-in ethernet PHY.

As for CV1800B, HW automatically loads the eFuse content into CONTENT base registers which are organized as 32bit values exposed as MMIO.

Currently, add read support for the eFuse. This is a preparation step for supporting the built-in ethernet phy.

Since the clk support isn't mainlined, so cv1800b DT patches are not included.

Jisheng Zhang (2):
dt-bindings: nvmem: Add sophgo,efuses
nvmem: Add Sophgo eFuse driver

 .../bindings/nvmem/sophgo,efuse.yaml          | 54 +++++++++++
 drivers/nvmem/Kconfig                         | 13 +++
 drivers/nvmem/Makefile                        |  2 +
 drivers/nvmem/sophgo-efuse.c                  | 97 +++++++++++++++++++
 4 files changed, 166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml
 create mode 100644 drivers/nvmem/sophgo-efuse.c
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/2 dt-bindings: nvmem: Add sophgo,efuses

Sophgo SoCs such as CV1800B come with eFuses used to store factory-programmed data such as calibration settings for the built-in ethernet PHY.

---
 .../bindings/nvmem/sophgo,efuse.yaml          | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +54 -0
new file mode 100644
index 000000000000..e4ae81a1742a
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/sophgo,efuse.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SoC eFuse-based NVMEM
+
+description: |
+  Sophgo SoCs such as the CV1800B contain factory-programmed eFuses used to e.g. store
+  calibration data for the built-in ethernet PHY.
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+  - $ref: nvmem-deprecated-cells.yaml#
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - sophgo,cv1800b-efuse
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description:
+      eFuse clock id.
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    efuse@3050000 {
+        compatible = "sophgo,cv1800b-efuse";
+        reg = <0x3050000 0x1000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        clocks = <&clk 1>;
+
+        ephy_txitune: ephy-txitune@24 {
+            reg = <0x24 0x4>;
+        };
+    };
+
+...
Signature · 1 line
2.42.0
#2 lore raw

Re: [PATCH 1/2] dt-bindings: nvmem: Add sophgo,efuses

Quoted 5 lines · Jisheng Zhang

Sophgo SoCs such as CV1800B come with eFuses used to store factory-programmed data such as calibration settings for the built-in ethernet PHY.

Thank you for your patch. There is something to discuss/improve.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml

Quoted 10 lines
---
 .../bindings/nvmem/sophgo,efuse.yaml          | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +0 -0
new file mode 100644
index 000000000000..e4ae81a1742a

Filename should match the compatible, unless you already have other devices coming.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 9

Quoted 10 lines
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +9 -0
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/sophgo,efuse.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SoC eFuse-based NVMEM
+
+description: |

Do not need '|' unless you need to preserve formatting.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 10

Quoted 1 line
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +1 -0
+  Sophgo SoCs such as the CV1800B contain factory-programmed eFuses used to e.g. store

Please wrap at Linux coding style (so 80).

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 11

Quoted 1 line
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +1 -0
+  calibration data for the built-in ethernet PHY.

Blank line here.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 21

Quoted 10 lines
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +10 -0
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+  - $ref: nvmem-deprecated-cells.yaml#
+
+properties:
+  compatible:
+    items:

Drop items, we keep just enum directly for such cases.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 30

Quoted 9 lines
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +9 -0
+      - enum:
+          - sophgo,cv1800b-efuse
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description:
+      eFuse clock id.

Drop description, quite obvious.

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 54

Quoted 9 lines
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +9 -0
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+unevaluatedProperties: false
+...

Best regards,
Krzysztof

maintainer
#3 lore raw

Re: [PATCH 1/2] dt-bindings: nvmem: Add sophgo,efuses

In reply to Jisheng Zhang
Quoted 23 lines · Jisheng Zhang

Sophgo SoCs such as CV1800B come with eFuses used to store factory-programmed data such as calibration settings for the built-in ethernet PHY.

---
 .../bindings/nvmem/sophgo,efuse.yaml          | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +7 -0
new file mode 100644
index 000000000000..e4ae81a1742a
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/sophgo,efuse.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sophgo SoC eFuse-based NVMEM

Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/nvmem/sophgo,efuse.yaml new file +10 -0
+
+description: |
+  Sophgo SoCs such as the CV1800B contain factory-programmed eFuses used to e.g. store
+  calibration data for the built-in ethernet PHY.
+maintainers:
+  - Jisheng Zhang <[email protected]>
+
+allOf:
+  - $ref: nvmem.yaml#
+  - $ref: nvmem-deprecated-cells.yaml#

Why does a new binding need to use the deprecated form?

Rob

#4 lore raw

PATCH 2/2 nvmem: Add Sophgo eFuse driver

In reply to Jisheng Zhang

Sophgo SoCs such as CV1800B contain eFuses used to store factory-programmed data such as calibration values for the built-in ethernet PHY.

As for CV1800B, HW automatically loads the eFuse content into CONTENT base registers which are organized as 32bit values exposed as MMIO.

Currently, add read support for the eFuse. This is a preparation step for supporting the built-in ethernet phy.

---
 drivers/nvmem/Kconfig        | 13 +++++
 drivers/nvmem/Makefile       |  2 +
 drivers/nvmem/sophgo-efuse.c | 97 ++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 drivers/nvmem/sophgo-efuse.c
drivers/nvmem/Kconfig +13 -0
index 5bc9c4874fe3..f2de7338c6e9 100644
@@ -298,6 +298,19 @@ config NVMEM_SNVS_LPGPR
 	  This driver can also be built as a module. If so, the module
 	  will be called nvmem-snvs-lpgpr.
 
+config NVMEM_SOPHGO_EFUSE
+	tristate "Sophgo eFuse support"
+	depends on ARCH_SOPHGO || COMPILE_TEST
+	default ARCH_SOPHGO
+	help
+	  Say y here to enable support for reading eFuses on Sophgo SoCs
+	  such as the CV1800B. These are e.g. used to store factory programmed
+	  calibration data required for the builtin ethernet PHY.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called nvmem-sophgo-efuse.
+
+
 config NVMEM_SPMI_SDAM
 	tristate "SPMI SDAM Support"
 	depends on SPMI
drivers/nvmem/Makefile +2 -0
index 423baf089515..f3602bb16efc 100644
@@ -60,6 +60,8 @@ obj-$(CONFIG_NVMEM_SC27XX_EFUSE)	+= nvmem-sc27xx-efuse.o
 nvmem-sc27xx-efuse-y			:= sc27xx-efuse.o
 obj-$(CONFIG_NVMEM_SNVS_LPGPR)		+= nvmem_snvs_lpgpr.o
 nvmem_snvs_lpgpr-y			:= snvs_lpgpr.o
+obj-$(CONFIG_NVMEM_SOPHGO_EFUSE)	+= nvmem-sophgo-efuse.o
+nvmem-sophgo-efuse-y			:= sophgo-efuse.o
 obj-$(CONFIG_NVMEM_SPMI_SDAM)		+= nvmem_qcom-spmi-sdam.o
 nvmem_qcom-spmi-sdam-y			+= qcom-spmi-sdam.o
 obj-$(CONFIG_NVMEM_SPRD_EFUSE)		+= nvmem_sprd_efuse.o
drivers/nvmem/sophgo-efuse.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.42.0