Add SG2044 eFUSE driver
Inochi Amaoto
maintainerv2 cover Add SG2044 eFUSE driver
Add SG2044 eFUSE driver, The eFUSE contains factory-programmed data, and it will be auto loaded into shadow registers while startup. So only MMIO read is needed.
Change from v1:
- https://lore.kernel.org/all/[email protected]/
patch 1:
1. Remove clock-names minItems.
patch 2:
1. Fix wrong buffer size in sg2044_efuses_read().
2. Fix return type of sg2044_efuses_read_strip
3. Fix some style error on the driver.
Inochi Amaoto (3):
dt-bindings: nvmem: Add SG2044 eFuse controller
nvmem: Add Sophgo SG2044 eFuse driver
riscv: dts: sophgo: sg2044: Add eFUSE device
.../bindings/nvmem/sophgo,sg2044-efuse.yaml | 59 ++++++ .../boot/dts/sophgo/sg2044-sophgo-srd3-10.dts | 4 + arch/riscv/boot/dts/sophgo/sg2044.dtsi | 12 ++ drivers/nvmem/Kconfig | 12 ++ drivers/nvmem/Makefile | 2 + drivers/nvmem/sophgo-efuse.c | 176 ++++++++++++++++++ 6 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,sg2044-efuse.yaml create mode 100644 drivers/nvmem/sophgo-efuse.c
--
2.56.1
Inochi Amaoto
maintainerPATCH v2 1/3 dt-bindings: nvmem: Add SG2044 eFuse controller
Sophgo SG2044 uses eFuses used to store factory-programmed data such as ROM patch, public keys and other factory information.
--- .../bindings/nvmem/sophgo,sg2044-efuse.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/sophgo,sg2044-efuse.yaml
Documentation/devicetree/bindings/nvmem/sophgo,sg2044-efuse.yaml new file +59 -0
@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/sophgo,sg2044-efuse.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo SG2044 SoC eFuse-based NVMEM + +description: + Sophgo SoCs contain factory-programmed eFuses used to store ROM patch, + public key and other factory information. + +maintainers: + - Inochi Amaoto <[email protected]> + +allOf: + - $ref: nvmem.yaml# + +properties: + compatible: + enum: + - sophgo,sg2044-efuse + + reg: + maxItems: 1 + + clocks: + items: + - description: Core clock + - description: APB clock + + clock-names: + items: + - const: core + - const: apb + + resets: + maxItems: 1 + +required: + - compatible + - reg + - clocks + +unevaluatedProperties: false + +examples: + - | + efuse@40000000 { + compatible = "sophgo,sg2044-efuse"; + reg = <0x40000000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&clk 0>, + <&clk 1>; + clock-names = "core", "apb"; + }; + +...
Signature · 1 line
2.56.1
Inochi Amaoto
maintainerPATCH v2 2/3 nvmem: Add Sophgo SG2044 eFuse driver
In reply to Inochi AmaotoSophgo SoCs such as SG2044 contain eFuses used to store factory-programmed data.
As for SG2044, HW automatically loads the eFuse content into shadow registers which are organized as 32bit values exposed as MMIO.
--- drivers/nvmem/Kconfig | 12 +++ drivers/nvmem/Makefile | 2 + drivers/nvmem/sophgo-efuse.c | 176 +++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 drivers/nvmem/sophgo-efuse.c
drivers/nvmem/Kconfig +12 -0
@@ -476,6 +476,18 @@ 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 SG2044. These are e.g. used to store factory programmed + required data for internal device like ROM patch. + + 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
@@ -81,6 +81,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 +176 -0
176 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 2/3] nvmem: Add Sophgo SG2044 eFuse driver
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] nvmem: sophgo-efuse: unnecessary add_legacy_fixed_of_cells in probe - [Low] nvmem: sophgo-efuse…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] nvmem: sophgo-efuse: unnecessary add_legacy_fixed_of_cells in probe
- [Low] nvmem: sophgo-efuse: commit message misdescribes indirect register read
--
commit 35eaad0514f43d8079e979919f4e2f5fc25d9f4a
Author: Inochi Amaoto <[email protected]>
nvmem: Add Sophgo SG2044 eFuse driver
This commit adds an NVMEM provider driver for the eFuse controller on Sophgo SG2044 SoCs.
Quoted 3 lines
As for SG2044, HW automatically loads the eFuse content into shadow registers which are organized as 32bit values exposed as MMIO.
[Severity: Low]
Does the commit message match how the driver accesses the hardware? Instead of reading a bank of MMIO shadow registers directly, sg2044_efuses_read_strip() writes the word address to SG2044_EFUSE_ADR, triggers a read command in SG2044_EFUSE_MD, polls for completion, and reads the result from SG2044_EFUSE_RD_DATA.
Quoted 5 lines
drivers/nvmem/sophgo-efuse.c new file +0
-0
[ ... ]
drivers/nvmem/sophgo-efuse.c line 130
Quoted 8 lines
drivers/nvmem/sophgo-efuse.c new file +8
-0+static int sophgo_efuses_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct sophgo_efuses *efuse; +struct nvmem_config config = { + .dev = &pdev->dev, + .add_legacy_fixed_of_cells = true, + .read_only = true,
[Severity: Low]
Should a new driver set add_legacy_fixed_of_cells = true? That option was introduced in 2cc3b37f5b6d ("nvmem: add explicit config option to read old syntax fixed OF cells") for legacy bindings that reference nvmem-deprecated-cells.yaml#, whereas the sophgo,sg2044-efuse.yaml binding only allows nvmem-layout cells via nvmem.yaml#.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Inochi Amaoto
maintainerPATCH v2 3/3 riscv: dts: sophgo: sg2044: Add eFUSE device
In reply to Inochi AmaotoAdd eFUSE controller node for SG2044.
--- arch/riscv/boot/dts/sophgo/sg2044-sophgo-srd3-10.dts | 4 ++++ arch/riscv/boot/dts/sophgo/sg2044.dtsi | 12 ++++++++++++ 2 files changed, 16 insertions(+)
arch/riscv/boot/dts/sophgo/sg2044-sophgo-srd3-10.dts +4 -0
@@ -36,6 +36,10 @@ &emmc { status = "okay"; }; +&efuse0 { + status = "okay"; +}; + &gmac0 { phy-handle = <&phy0>; phy-mode = "rgmii-id";
arch/riscv/boot/dts/sophgo/sg2044.dtsi +12 -0
@@ -408,6 +408,18 @@ sd: mmc@703000b000 { status = "disabled"; }; + efuse0: efuse@7040000000 { + compatible = "sophgo,sg2044-efuse"; + reg = <0x70 0x40000000 0x0 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&clk CLK_GATE_EFUSE>, + <&clk CLK_GATE_APB_EFUSE>; + clock-names = "core", "apb"; + resets = <&rst RST_EFUSE0>; + status = "disabled"; + }; + i2c0: i2c@7040005000 { compatible = "sophgo,sg2044-i2c", "snps,designware-i2c"; reg = <0x70 0x40005000 0x0 0x1000>;
Signature · 1 line
2.56.1