ARM: Realtek DHC SoC info
Subsystems (3)
v2 cover ARM: Realtek DHC SoC info
Hello,
This series adds a soc bus driver for Realtek Digital Home Center SoC families.
v2 is rebased on syscon and RTD1319, adjusts field widths and incorporates data additions from Stanley's monolithic patch.
The previous RFC's reg hack is superseded in v2 with a trivial read-only eFuse driver, along with an extension of the nvmem consumer API.
Reminder: For RTD1293 I had to invent my own detection logic, possibly flawed. Nor have the names of the magic register bits been disclosed.
We have no RTD1294 nor RTD1392 DT in mainline, so their detection is included mainly as proof of concept. No EVB names were visible in public BSP sources; Ligomedia seems the only vendor so far with publicly announced RTD1392 STBs, for RTD1294 I only find one all-Chinese page and some Russian forum posts - patches and testing welcome. Otherwise we can only test that the other models are not misdetected as RTD1392 or RTD1294.
DHC upstreaming progress is being tracked at:
https://en.opensuse.org/HCL:Realtek_DHC
Latest experimental patches at:
https://github.com/afaerber/linux/commits/rtd1295-next
Have a lot of fun!
Cheers,
Andreas
v1 -> v2:
* Cleaned up binding schema (Rob)
* Rebased onto syscon mfd refactoring of containing SB2, Iso, etc.
* Limit chip id and rev to 16 bits, as per old header files
* Include mentioned RTD1395, RTD1619 and RTD1319 patches
* Incorporate RTD1392 and RTD1319 bits from Stanley's API export patch
* Add eFuse nvmem driver and adopt and extend nvmem cell API
Andreas Färber (27):
dt-bindings: soc: Add Realtek RTD1195 chip info binding
soc: Add Realtek DHC chip info driver for RTD1195 and RTD1295
arm64: dts: realtek: rtd129x: Add chip info node
ARM: dts: rtd1195: Add chip info node
dt-bindings: soc: realtek: rtd1195-chip: Add iso-syscon property
soc: realtek: chip: Detect RTD1296
arm64: dts: realtek: rtd129x: Extend chip-info reg with CHIP_INFO1
soc: realtek: chip: Detect RTD1293
soc: realtek: chip: Add RTD1395 info
arm64: dts: realtek: rtd139x: Add chip info node
soc: realtek: chip: Add RTD1619 info
arm64: dts: realtek: rtd16xx: Add chip info node
soc: realtek: chip: Add RTD1319 info
arm64: dts: realtek: rtd13xx: Add chip info node
dt-bindings: nvmem: Add Realtek RTD1195 eFuse
nvmem: Add Realtek DHC eFuse driver
ARM: dts: rtd1195: Add eFuse node
arm64: dts: realtek: rtd129x: Add eFuse node
arm64: dts: realtek: rtd139x: Add eFuse node
arm64: dts: realtek: rtd16xx: Add eFuse node
arm64: dts: realtek: rtd13xx: Add eFuse node
dt-bindings: soc: realtek: rtd1195-chip: Allow nvmem-cells property
arm64: dts: realtek: rtd129x: Add eFuse package_id to chip-info
soc: realtek: chip: Detect RTD1294
nvmem: core: Grammar fixes for help text
nvmem: core: Add nvmem_cell_read_u8()
soc: realtek: chip: Adopt nvmem_cell_read_u8() helper
Stanley Chang (2):
soc: realtek: chip: Add RTD1319 revisions
soc: realtek: chip: Detect RTD1392
.../bindings/nvmem/realtek,rtd1195-efuse.yaml | 53 ++++ .../soc/realtek/realtek,rtd1195-chip.yaml | 55 ++++ MAINTAINERS | 4 + arch/arm/boot/dts/rtd1195.dtsi | 13 + arch/arm64/boot/dts/realtek/rtd129x.dtsi | 23 ++ arch/arm64/boot/dts/realtek/rtd139x.dtsi | 15 +- arch/arm64/boot/dts/realtek/rtd13xx.dtsi | 15 + arch/arm64/boot/dts/realtek/rtd16xx.dtsi | 15 + drivers/nvmem/Kconfig | 9 + drivers/nvmem/Makefile | 2 + drivers/nvmem/core.c | 27 +- drivers/nvmem/rtk-dhc-efuse.c | 86 ++++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/realtek/Kconfig | 13 + drivers/soc/realtek/Makefile | 2 + drivers/soc/realtek/chip.c | 269 ++++++++++++++++++ include/linux/nvmem-consumer.h | 1 + 18 files changed, 597 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml create mode 100644 Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml create mode 100644 drivers/nvmem/rtk-dhc-efuse.c create mode 100644 drivers/soc/realtek/Kconfig create mode 100644 drivers/soc/realtek/Makefile create mode 100644 drivers/soc/realtek/chip.c
Signature · 1 line
2.26.2
PATCH v2 1/29 dt-bindings: soc: Add Realtek RTD1195 chip info binding
Define a binding for RTD1195 and later DHC SoCs' chip info registers. Add the new directory to MAINTAINERS.
---
Note: The binding gets extended compatibly twice with additional properties. Could be squashed later if approved.
v1 -> v2:
* Dropped quotes for compatible (Rob)
* Added additionalProperties: false (Rob)
.../soc/realtek/realtek,rtd1195-chip.yaml | 34 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/realtek/realtek,rtd1195-chip.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Realtek Digital Home Center chip identification + +maintainers: + - Andreas Färber <[email protected]> + +description: | + The Realtek DHC SoCs have some registers to identify the chip and revision. + +properties: + compatible: + const: realtek,rtd1195-chip + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + chip-info@1801a200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x1801a200 0x8>; + }; +...
MAINTAINERS +1 -0
@@ -2307,6 +2307,7 @@ L: [email protected] (moderated for non-subscribers) L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/arm/realtek.yaml +F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/ F: arch/arm64/boot/dts/realtek/
Signature · 1 line
2.26.2
Re: [PATCH v2 01/29] dt-bindings: soc: Add Realtek RTD1195 chip info binding
Quoted 8 lines · Andreas Färber
Define a binding for RTD1195 and later DHC SoCs' chip info registers. Add the new directory to
MAINTAINERS.Signed-off-by Andreas Färber <[email protected]>---
Note: The binding gets extended compatibly twice with additional properties. Could be squashed later if approved.
Quoted 9 lines
v1 -> v2:
* Dropped quotes for compatible (Rob)
* Added additionalProperties: false (Rob).../soc/realtek/realtek,rtd1195-chip.yaml | 34 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
PATCH v2 2/29 soc: Add Realtek DHC chip info driver for RTD1195 and RTD1295
In reply to Andreas FärberAdd a soc bus driver to print chip model and revision details.
Revisions from downstream drivers/soc/realtek/rtd{119x,129x}/rtk_chip.c.
---
v1 -> v2:
* Added entry to MAINTAINERS
* Changed chip_id and chip_rev from u32 to u16, based on reg field definitions
* Added error return path for get_name for deferred probing, reordered code
MAINTAINERS | 1 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/realtek/Kconfig | 13 +++ drivers/soc/realtek/Makefile | 2 + drivers/soc/realtek/chip.c | 181 +++++++++++++++++++++++++++++++++++ 6 files changed, 199 insertions(+) create mode 100644 drivers/soc/realtek/Kconfig create mode 100644 drivers/soc/realtek/Makefile create mode 100644 drivers/soc/realtek/chip.c
MAINTAINERS +1 -0
@@ -2311,6 +2311,7 @@ F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/ F: arch/arm64/boot/dts/realtek/ +F: drivers/soc/realtek/ ARM/RENESAS ARM64 ARCHITECTURE M: Geert Uytterhoeven <[email protected]>
drivers/soc/Kconfig +1 -0
@@ -11,6 +11,7 @@ source "drivers/soc/imx/Kconfig" source "drivers/soc/ixp4xx/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" +source "drivers/soc/realtek/Kconfig" source "drivers/soc/renesas/Kconfig" source "drivers/soc/rockchip/Kconfig" source "drivers/soc/samsung/Kconfig"
drivers/soc/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-y += mediatek/ obj-y += amlogic/ obj-y += qcom/ +obj-y += realtek/ obj-y += renesas/ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_SOC_SAMSUNG) += samsung/
drivers/soc/realtek/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +if ARCH_REALTEK || COMPILE_TEST + +config REALTEK_SOC + tristate "Realtek chip info" + default ARCH_REALTEK + select SOC_BUS + help + Say 'y' here to enable support for SoC info on Realtek RTD1195 and + RTD1295 SoC families. + If unsure, say 'n'. + +endif
drivers/soc/realtek/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +obj-$(CONFIG_REALTEK_SOC) += chip.o
drivers/soc/realtek/chip.c new file +181 -0
181 lines not on this page · raw message
Signature · 1 line
2.26.2
RE: [PATCH v2 02/29] soc: Add Realtek DHC chip info driver for RTD1195 and RTD1295
Hi Andreas,
I have reviewed this patch and tested in my local platforms (RTD1319/RTD1619/RTD1395). And this patch is fine and it can work.
Quoted 22 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 02/29] soc: Add Realtek DHC chip info driver for RTD1195 and RTD1295Add a soc bus driver to print chip model and revision details.
Revisions from downstream
drivers/soc/realtek/rtd{119x,129x}/rtk_chip.c.Signed-off-by Andreas Färber <[email protected]>---
v1 -> v2:
* Added entry toMAINTAINERS
* Changedchip_idandchip_revfrom u32 to u16, based on reg field
definitions
* Added error return path forget_namefor deferred probing, reordered
code
Quoted 8 lines
MAINTAINERS | 1 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/realtek/Kconfig | 13 +++ drivers/soc/realtek/Makefile | 2 + drivers/soc/realtek/chip.c | 181 +++++++++++++++++++++++++++++++++++ 6 files changed, 199 insertions(+)
Thanks,
Stanley
PATCH v2 3/29 arm64: dts: realtek: rtd129x: Add chip info node
In reply to Andreas FärberAdd a DT node for chip identification.
---
v1 -> v2:
* Rebased onto SB2 syscon
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/realtek/rtd129x.dtsi +5 -0
@@ -201,6 +201,11 @@ sb2_hd_sem: hwspinlock@0 { #hwlock-cells = <0>; }; + chip-info@200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x200 0x8>; + }; + sb2_hd_sem_new: hwspinlock@620 { compatible = "realtek,rtd1195-sb2-sem"; reg = <0x620 0x20>;
Signature · 1 line
2.26.2
RE: [PATCH v2 03/29] arm64: dts: realtek: rtd129x: Add chip info node
Hi Andreas,
Quoted 9 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber; Rob Herring; [email protected]
Subject: [PATCH v2 03/29] arm64: dts: realtek: rtd129x: Add chip info node
Quoted 5 lines
Add a DT node for chip identification.
Acked-by James Tai <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
Thanks,
Stanley
PATCH v2 4/29 ARM: dts: rtd1195: Add chip info node
In reply to Andreas FärberAdd a DT node for chip identification.
---
v1 -> v2:
* Rebased onto SB2 syscon
arch/arm/boot/dts/rtd1195.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/rtd1195.dtsi +5 -0
@@ -223,6 +223,11 @@ sb2_hd_sem: hwspinlock@0 { #hwlock-cells = <0>; }; + chip-info@200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x200 0x8>; + }; + sb2_hd_sem_new: hwspinlock@620 { compatible = "realtek,rtd1195-sb2-sem"; reg = <0x620 0x20>;
Signature · 1 line
2.26.2
RE: [PATCH v2 04/29] ARM: dts: rtd1195: Add chip info node
Hi Andreas,
Quoted 9 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber; Rob Herring; [email protected]
Subject: [PATCH v2 04/29] ARM: dts: rtd1195: Add chip info node
Quoted 3 lines
Add a DT node for chip identification.
Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 5/29 dt-bindings: soc: realtek: rtd1195-chip: Add iso-syscon property
In reply to Andreas FärberAllow to optionally specify a phandle to iso syscon to identify the chip. RTD1295 family will want to check the ISO_CHIP_INFO1 register.
---
A SoC specific binding would defeat the purpose of the generic Linux driver detecting the SoC based on registers.
Simply allowing it all for SoC families seems the most flexible.
v1 -> v2:
* Instead of extending reg, allow optional iso-syscon property for RTD129x. Iso syscon currently does not have a compatible, and it may need to differ across SoC families.
.../bindings/soc/realtek/realtek,rtd1195-chip.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml +9 -0
@@ -11,6 +11,7 @@ maintainers: description: | The Realtek DHC SoCs have some registers to identify the chip and revision. + To identify the exact model within a family, further registers are needed. properties: compatible:
@@ -19,6 +20,8 @@ properties: reg: maxItems: 1 + iso-syscon: true + required: - compatible - reg
@@ -31,4 +34,10 @@ examples: compatible = "realtek,rtd1195-chip"; reg = <0x1801a200 0x8>; }; + - | + chip-info@9801a200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x9801a200 0x8>; + iso-syscon = <&iso>; + }; ...
Signature · 1 line
2.26.2
Rob Herring
maintainerRe: [PATCH v2 05/29] dt-bindings: soc: realtek: rtd1195-chip: Add iso-syscon property
Quoted 30 lines · Andreas Färber
Allow to optionally specify a phandle to iso syscon to identify the chip. RTD1295 family will want to check the
ISO_CHIP_INFO1register.Signed-off-by Andreas Färber <[email protected]>---
A SoC specific binding would defeat the purpose of the generic Linux driver detecting the SoC based on registers.
Simply allowing it all for SoC families seems the most flexible.v1 -> v2:
* Instead of extending reg, allow optional iso-syscon property for RTD129x. Iso syscon currently does not have a compatible, and it may need to differ across SoC families..../bindings/soc/realtek/realtek,rtd1195-chip.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml +1
-0@@ -11,6 +11,7 @@ maintainers: description: | The Realtek DHC SoCs have some registers to identify the chip and revision. + To identify the exact model within a family, further registers are needed. properties: compatible:
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml properties: · line 23
Quoted 4 lines
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml +1
-0@@ -19,6 +20,8 @@ properties: reg: maxItems: 1 + iso-syscon: true
Needs a type $ref (phandle).
Quoted 18 lines
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml +7
-0+ required: - compatible - reg@@ -31,4 +34,10 @@ examples: compatible = "realtek,rtd1195-chip"; reg = <0x1801a200 0x8>; }; + - | + chip-info@9801a200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x9801a200 0x8>; + iso-syscon = <&iso>; + };Signature · 1 line
2.26.2
PATCH v2 6/29 soc: realtek: chip: Detect RTD1296
In reply to Andreas FärberDetection logic from downstream drivers/soc/realtek/rtd129x/rtk_chip.c.
---
TODO: Name the bit in ISO_CHIP_INFO1:bound_opts.
v1 -> v2:
* Instead of direct iso register access use the new syscon regmap
drivers/soc/realtek/chip.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/soc/realtek/chip.c +26 -1
@@ -23,6 +23,8 @@#define SB2_CHIP_INFO_REVISE_ID GENMASK(31, 16) +#define REG_ISO_CHIP_INFO1 0x028 +struct dhc_soc_revision {const char *name;u16 chip_rev;
@@ -57,9 +59,32 @@ static const char *default_name(struct device *dev, const struct dhc_soc *s)return s->family; } +static const char *rtd1295_name (struct device *dev,const struct dhc_soc *s) +{ +struct regmap *regmap; +unsigned int val; +int ret; + + regmap =syscon_regmap_lookup_by_phandle (dev->of_node,"iso-syscon" ); +if (IS_ERR (regmap)) { + ret =PTR_ERR (regmap); +if (ret == -EPROBE_DEFER ) +return ERR_PTR (ret); +dev_warn (dev,"Could not check iso (%d)\n" , ret); + }else { + ret =regmap_read (regmap,REG_ISO_CHIP_INFO1 , &val); +if (ret) +dev_warn (dev,"Could not read chip_info1 (%d)\n" , ret); +else if (val &BIT (11 )) +return "RTD1296" ; + } + +return "RTD1295" ; +} +static const struct dhc_soc dhc_soc_families[] = { {0x6329 ,"RTD1195" , default_name, rtd1195_revisions,"Phoenix" }, - {0x6421 ,"RTD1295" , default_name, rtd1295_revisions,"Kylin" }, + {0x6421 ,"RTD1295" , rtd1295_name, rtd1295_revisions,"Kylin" }, };static const struct dhc_soc *dhc_soc_by_chip_id (u16 chip_id)
Signature · 1 line
2.26.2
RE: [PATCH v2 06/29] soc: realtek: chip: Detect RTD1296
Hi Andreas,
I have reviewed this patch and it is ok.
Quoted 8 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 06/29] soc: realtek: chip: Detect RTD1296
Quoted 4 lines
Detection logic from downstream
drivers/soc/realtek/rtd129x/rtk_chip.c.Acked-by James Tai <[email protected]>Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 7/29 arm64: dts: realtek: rtd129x: Extend chip-info reg with CHIP_INFO1
In reply to Andreas FärberThis additional register is needed to distinguish RTD1296 from RTD1295.
---
v1 -> v2:
* Switched from reg to new iso-syscon phandle
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/realtek/rtd129x.dtsi +1 -0
@@ -204,6 +204,7 @@ sb2_hd_sem: hwspinlock@0 { chip-info@200 { compatible = "realtek,rtd1195-chip"; reg = <0x200 0x8>; + iso-syscon = <&iso>; }; sb2_hd_sem_new: hwspinlock@620 {
Signature · 1 line
2.26.2
RE: [PATCH v2 07/29] arm64: dts: realtek: rtd129x: Extend chip-info reg with CHIP_INFO1
Hi Andreas,
Quoted 10 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber; Rob Herring; [email protected]
Subject: [PATCH v2 07/29] arm64: dts: realtek: rtd129x: Extend chip-info reg withCHIP_INFO1
Quoted 3 lines
This additional register is needed to distinguish RTD1296 from RTD1295.
Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 8/29 soc: realtek: chip: Detect RTD1293
In reply to Andreas FärberLogic self-determined by comparing DS418j and DS418 registers.
---
TODO: Identify the bit in ISO_CHIP_INFO1:bound_opts and what it really means.
v1 -> v2:
* Rebased onto iso syscon regmap
drivers/soc/realtek/chip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/realtek/chip.c +4 -1
@@ -75,8 +75,11 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s) ret =regmap_read (regmap,REG_ISO_CHIP_INFO1 , &val);if (ret)dev_warn (dev,"Could not read chip_info1 (%d)\n" , ret); -else if (val &BIT (11 )) +else if (val &BIT (11 )) { +if (val &BIT (4 )) +return "RTD1293" ;return "RTD1296" ; + } }return "RTD1295" ;
Signature · 1 line
2.26.2
PATCH v2 9/29 soc: realtek: chip: Add RTD1395 info
In reply to Andreas FärberChip ID from BPi-M4.
Revisions based on downstream drivers/soc/realtek/rtd139x/rtk_chip.c.
---
v2: New
drivers/soc/realtek/chip.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/soc/realtek/chip.c +8 -0
@@ -46,6 +46,13 @@ static const struct dhc_soc_revision rtd1295_revisions[] = { { } }; +static const struct dhc_soc_revision rtd1395_revisions[] = { + {"A00" ,0x0000 }, + {"A01" ,0x0001 }, + {"A02" ,0x0002 }, + { } +}; +struct dhc_soc {u16 chip_id;const char *family;
@@ -88,6 +95,7 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s)static const struct dhc_soc dhc_soc_families[] = { {0x6329 ,"RTD1195" , default_name, rtd1195_revisions,"Phoenix" }, {0x6421 ,"RTD1295" , rtd1295_name, rtd1295_revisions,"Kylin" }, + {0x6481 ,"RTD1395" , default_name, rtd1395_revisions,"Hercules" }, };static const struct dhc_soc *dhc_soc_by_chip_id (u16 chip_id)
Signature · 1 line
2.26.2
RE: [PATCH v2 09/29] soc: realtek: chip: Add RTD1395 info
Hi Andreas,
This patch is ok in my platform.
Quoted 8 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 09/29] soc: realtek: chip: Add RTD1395 info
Quoted 4 lines
Chip ID from BPi-M4.
Revisions based on downstreamdrivers/soc/realtek/rtd139x/rtk_chip.c.Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 10/29 arm64: dts: realtek: rtd139x: Add chip info node
In reply to Andreas FärberAdd a DT node for chip identification.
---
v2: New
arch/arm64/boot/dts/realtek/rtd139x.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/realtek/rtd139x.dtsi +5 -0
@@ -199,6 +199,11 @@ sb2_hd_sem: hwspinlock@0 { #hwlock-cells = <0>; }; + chip-info@200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x200 0x8>; + }; + sb2_hd_sem_new: hwspinlock@620 { compatible = "realtek,rtd1195-sb2-sem"; reg = <0x620 0x20>;
Signature · 1 line
2.26.2
RE: [PATCH v2 10/29] arm64: dts: realtek: rtd139x: Add chip info node
Hi Andreas,
Quoted 9 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber; Rob Herring; [email protected]
Subject: [PATCH v2 10/29] arm64: dts: realtek: rtd139x: Add chip info node
Quoted 3 lines
Add a DT node for chip identification.
Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 11/29 soc: realtek: chip: Add RTD1619 info
In reply to Andreas FärberRevisions based on downstream drivers/soc/realtek/rtd16xx/rtk_chip.c.
---
v2: New
drivers/soc/realtek/chip.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/soc/realtek/chip.c +7 -0
@@ -53,6 +53,12 @@ static const struct dhc_soc_revision rtd1395_revisions[] = { { } }; +static const struct dhc_soc_revision rtd1619_revisions[] = { + {"A00" ,0x0000 }, + {"A01" ,0x0001 }, + { } +}; +struct dhc_soc {u16 chip_id;const char *family;
@@ -96,6 +102,7 @@ static const struct dhc_soc dhc_soc_families[] = { { 0x6329, "RTD1195", default_name, rtd1195_revisions, "Phoenix" }, { 0x6421, "RTD1295", rtd1295_name, rtd1295_revisions, "Kylin" }, { 0x6481, "RTD1395", default_name, rtd1395_revisions, "Hercules" }, + { 0x6525, "RTD1619", default_name, rtd1619_revisions, "Thor" }, };static const struct dhc_soc *dhc_soc_by_chip_id (u16 chip_id)
Signature · 1 line
2.26.2
RE: [PATCH v2 11/29] soc: realtek: chip: Add RTD1619 info
Quoted 10 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 11/29] soc: realtek: chip: Add RTD1619 info
Quoted 3 lines
Revisions based on downstream
drivers/soc/realtek/rtd16xx/rtk_chip.c.Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 12/29 arm64: dts: realtek: rtd16xx: Add chip info node
In reply to Andreas FärberAdd a DT node for chip identification.
---
v2: New
arch/arm64/boot/dts/realtek/rtd16xx.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/realtek/rtd16xx.dtsi +7 -0
@@ -227,3 +227,10 @@ uart2: serial2@400 { status = "disabled"; }; }; + +&sb2 { + chip-info@200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x200 0x8>; + }; +};
Signature · 1 line
2.26.2
RE: [PATCH v2 12/29] arm64: dts: realtek: rtd16xx: Add chip info node
Hi Andreas,
Quoted 9 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber; Rob Herring; [email protected]
Subject: [PATCH v2 12/29] arm64: dts: realtek: rtd16xx: Add chip info node
Quoted 3 lines
Add a DT node for chip identification.
Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 13/29 soc: realtek: chip: Add RTD1319 info
In reply to Andreas FärberRevision based on downstream drivers/soc/realtek/rtd13xx/rtk_chip.c.
---
v2: New
* Filled in chip ID based on Stanley's v1
drivers/soc/realtek/chip.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/soc/realtek/chip.c +6 -0
@@ -59,6 +59,11 @@ static const struct dhc_soc_revision rtd1619_revisions[] = { { } }; +static const struct dhc_soc_revision rtd1319_revisions[] = { + {"A00" ,0x0000 }, + { } +}; +struct dhc_soc {u16 chip_id;const char *family;
@@ -103,6 +108,7 @@ static const struct dhc_soc dhc_soc_families[] = { { 0x6421, "RTD1295", rtd1295_name, rtd1295_revisions, "Kylin" }, { 0x6481, "RTD1395", default_name, rtd1395_revisions, "Hercules" }, { 0x6525, "RTD1619", default_name, rtd1619_revisions, "Thor" }, + { 0x6570, "RTD1319", default_name, rtd1319_revisions, "Hank" }, };static const struct dhc_soc *dhc_soc_by_chip_id (u16 chip_id)
Signature · 1 line
2.26.2
RE: [PATCH v2 13/29] soc: realtek: chip: Add RTD1319 info
Hi Andreas,
I have tested this patch, it is okay
Quoted 8 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 13/29] soc: realtek: chip: Add RTD1319 info
Quoted 4 lines
Revision based on downstream
drivers/soc/realtek/rtd13xx/rtk_chip.c.Signed-off-by Stanley Chang <[email protected]>Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 14/29 soc: realtek: chip: Add RTD1319 revisions
In reply to Andreas FärberFrom: Stanley Chang <[email protected]>
Identify RTD1319 SoC revisions B00 to B02.
---
v2: New
* Split out from Stanley's v1
drivers/soc/realtek/chip.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/soc/realtek/chip.c +4 -0
@@ -3,6 +3,7 @@* Realtek Digital Home Center System-on-Chip info * * Copyright (c) 2017-2020 Andreas Färber +* Copyright (c) 2019 Realtek Semiconductor Corp. */ #include <linux/bitfield.h>
@@ -61,6 +62,9 @@ static const struct dhc_soc_revision rtd1619_revisions[] = {static const struct dhc_soc_revision rtd1319_revisions[] = { {"A00" ,0x0000 }, + {"B00" ,0x0001 }, + {"B01" ,0x0002 }, + {"B02" ,0x0003 }, { } };
Signature · 1 line
2.26.2
RE: [PATCH v2 14/29] soc: realtek: chip: Add RTD1319 revisions
Hi Andreas,
Quoted 8 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 14/29] soc: realtek: chip: Add RTD1319 revisions
Quoted 6 lines
From: Stanley Chang <[email protected]>
Identify RTD1319 SoC revisions B00 to B02.
Signed-off-by Stanley Chang <[email protected]>Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 15/29 arm64: dts: realtek: rtd13xx: Add chip info node
In reply to Andreas FärberAdd a DT node for chip identification.
---
v2: New
arch/arm64/boot/dts/realtek/rtd13xx.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/realtek/rtd13xx.dtsi +7 -0
@@ -211,3 +211,10 @@ uart2: serial@400 { status = "disabled"; }; }; + +&sb2 { + chip-info@200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x200 0x8>; + }; +};
Signature · 1 line
2.26.2
RE: [PATCH v2 15/29] arm64: dts: realtek: rtd13xx: Add chip info node
Thanks,
Stanley
PATCH v2 16/29 soc: realtek: chip: Detect RTD1392
In reply to Andreas FärberFrom: Stanley Chang <[email protected]>
Distinguish RTD1392 from RTD1395 via ISO_CHIP_INFO1 register.
---
TODO: Name the bit in ISO_CHIP_INFO1:bound_opts.
Note: We don't have any RTD1392 .dtsi/.dts yet.
v2: New
* Split out from Stanley's v1
drivers/soc/realtek/chip.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/soc/realtek/chip.c +24 -1
@@ -107,10 +107,33 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s)return "RTD1295" ; } +static const char *rtd1395_name (struct device *dev,const struct dhc_soc *s) +{ +struct regmap *regmap; +unsigned int val; +int ret; + + regmap =syscon_regmap_lookup_by_phandle (dev->of_node,"iso-syscon" ); +if (IS_ERR (regmap)) { + ret =PTR_ERR (regmap); +if (ret == -EPROBE_DEFER ) +return ERR_PTR (ret); +dev_warn (dev,"Could not check iso (%d)\n" , ret); + }else { + ret =regmap_read (regmap,REG_ISO_CHIP_INFO1 , &val); +if (ret) +dev_warn (dev,"Could not read chip_info1 (%d)\n" , ret); +else if (val &BIT (12 )) +return "RTD1392" ; + } + +return "RTD1395" ; +} +static const struct dhc_soc dhc_soc_families[] = { {0x6329 ,"RTD1195" , default_name, rtd1195_revisions,"Phoenix" }, {0x6421 ,"RTD1295" , rtd1295_name, rtd1295_revisions,"Kylin" }, - {0x6481 ,"RTD1395" , default_name, rtd1395_revisions,"Hercules" }, + {0x6481 ,"RTD1395" , rtd1395_name, rtd1395_revisions,"Hercules" }, {0x6525 ,"RTD1619" , default_name, rtd1619_revisions,"Thor" }, {0x6570 ,"RTD1319" , default_name, rtd1319_revisions,"Hank" }, };
Signature · 1 line
2.26.2
RE: [PATCH v2 16/29] soc: realtek: chip: Detect RTD1392
Hi Andreas,
Quoted 8 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: Tuesday, June 23, 2020 10:51 AM
To: [email protected]
Cc: [email protected]; [email protected]; James Tai [戴志峰]; Stanley Chang[昌育德]; Edgar Lee [李承諭]; Andreas Färber
Subject: [PATCH v2 16/29] soc: realtek: chip: Detect RTD1392
Quoted 6 lines
From: Stanley Chang <[email protected]>
Distinguish RTD1392 from RTD1395 via
ISO_CHIP_INFO1register.Signed-off-by Stanley Chang <[email protected]>Signed-off-by Andreas Färber <[email protected]>
Thanks,
Stanley
PATCH v2 17/29 dt-bindings: nvmem: Add Realtek RTD1195 eFuse
In reply to Andreas FärberAdd a DT binding for eFuse on Realtek Digital Home Center SoCs.
---
v2: New
.../bindings/nvmem/realtek,rtd1195-efuse.yaml | 53 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml
Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml new file +53 -0
@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/nvmem/realtek,rtd1195-efuse.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Realtek Digital Home Center eFuse + +maintainers: + - Andreas Färber <[email protected]> + +description: | + The Realtek DHC SoCs have an eFuse block with non-volatile OTP memory. + +allOf: + - $ref: "nvmem.yaml#" + +properties: + compatible: + const: realtek,rtd1195-efuse + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + +required: + - compatible + - reg + +examples: + - | + efuse@18017000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x18017000 0x400>; + }; + - | + efuse@98017000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x98017000 0x400>; + #address-cells = <1>; + #size-cells = <1>; + + efuse_package_id: package-id@1d8 { + reg = <0x1d8 0x1>; + bits = <0 2>; + }; + }; +...
MAINTAINERS +1 -0
@@ -2307,6 +2307,7 @@ L: [email protected] (moderated for non-subscribers) L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/arm/realtek.yaml +F: Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/
Signature · 1 line
2.26.2
Re: [PATCH v2 17/29] dt-bindings: nvmem: Add Realtek RTD1195 eFuse
Quoted 11 lines · Andreas Färber
Add a DT binding for eFuse on Realtek Digital Home Center SoCs.
Signed-off-by Andreas Färber <[email protected]>---
v2: New.../bindings/nvmem/realtek,rtd1195-efuse.yaml | 53 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml
PATCH v2 18/29 nvmem: Add Realtek DHC eFuse driver
In reply to Andreas FärberImplement enough of a read-only nvmem driver to easily read efuse cells.
---
v2: New
MAINTAINERS | 1 + drivers/nvmem/Kconfig | 9 ++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/rtk-dhc-efuse.c | 86 +++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/nvmem/rtk-dhc-efuse.c
MAINTAINERS +1 -0
@@ -2312,6 +2312,7 @@ F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/ F: arch/arm64/boot/dts/realtek/ +F: drivers/nvmem/rtk-dhc-efuse.c F: drivers/soc/realtek/ ARM/RENESAS ARM64 ARCHITECTURE
drivers/nvmem/Kconfig +9 -0
@@ -129,6 +129,15 @@ config NVMEM_SPMI_SDAM Qualcomm Technologies, Inc. PMICs. It provides the clients an interface to read/write to the SDAM module's shared memory. +config REALTEK_DHC_EFUSE + tristate "Realtek DHC eFuse Support" + depends on ARCH_REALTEK || COMPILE_TEST + depends on HAS_IOMEM + help + Say y here to enable read-only access to the Realtek Digital Home + This driver can also be built as a module. If so, the module + will be called nvmem-rtk-dhc-efuse. + config ROCKCHIP_EFUSE tristate "Rockchip eFuse Support" depends on ARCH_ROCKCHIP || COMPILE_TEST
drivers/nvmem/Makefile +2 -0
@@ -33,6 +33,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += nvmem_rockchip_efuse.o nvmem_rockchip_efuse-y := rockchip-efuse.o obj-$(CONFIG_ROCKCHIP_OTP) += nvmem-rockchip-otp.o nvmem-rockchip-otp-y := rockchip-otp.o +obj-$(CONFIG_REALTEK_DHC_EFUSE) += nvmem-rtk-dhc-efuse.o +nvmem-rtk-dhc-efuse-y := rtk-dhc-efuse.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_stm32_romem-y := stm32-romem.o obj-$(CONFIG_NVMEM_STM32_ROMEM) += nvmem_stm32_romem.o
drivers/nvmem/rtk-dhc-efuse.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH v2 18/29] nvmem: Add Realtek DHC eFuse driver
Quoted 5 lines · Andreas Färber
Implement enough of a read-only nvmem driver to easily read efuse cells.
Cc Cheng-Yu Lee <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
This patch itself looks okay to me, I will apply this once DT patches are Reviewed/applied by DT maintainers!
--srini
Quoted 147 lines
v2: New
MAINTAINERS | 1 + drivers/nvmem/Kconfig | 9 ++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/rtk-dhc-efuse.c | 86 +++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)create mode 100644
drivers/nvmem/rtk-dhc-efuse.cMAINTAINERS +1
-0@@ -2312,6 +2312,7 @@ F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/ F: arch/arm64/boot/dts/realtek/ +F: drivers/nvmem/rtk-dhc-efuse.c F: drivers/soc/realtek/ ARM/RENESAS ARM64 ARCHITECTUREdrivers/nvmem/Kconfig +9
-0@@ -129,6 +129,15 @@ config NVMEM_SPMI_SDAM Qualcomm Technologies, Inc. PMICs. It provides the clients an interface to read/write to the SDAM module's shared memory. +config REALTEK_DHC_EFUSE + tristate "Realtek DHC eFuse Support" + depends on ARCH_REALTEK || COMPILE_TEST + depends on HAS_IOMEM + help + Say y here to enable read-only access to the Realtek Digital Home + This driver can also be built as a module. If so, the module + will be called nvmem-rtk-dhc-efuse. + config ROCKCHIP_EFUSE tristate "Rockchip eFuse Support" depends on ARCH_ROCKCHIP || COMPILE_TESTdrivers/nvmem/Makefile +2
-0@@ -33,6 +33,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += nvmem_rockchip_efuse.o nvmem_rockchip_efuse-y := rockchip-efuse.o obj-$(CONFIG_ROCKCHIP_OTP) += nvmem-rockchip-otp.o nvmem-rockchip-otp-y := rockchip-otp.o +obj-$(CONFIG_REALTEK_DHC_EFUSE) += nvmem-rtk-dhc-efuse.o +nvmem-rtk-dhc-efuse-y := rtk-dhc-efuse.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_stm32_romem-y := stm32-romem.o obj-$(CONFIG_NVMEM_STM32_ROMEM) += nvmem_stm32_romem.odrivers/nvmem/rtk-dhc-efuse.c new file +86
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Realtek Digital Home Center eFuse +* +* Copyright (c) 2020 Andreas Färber +*/ + +#include <linux/io.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +struct dhc_efuse { +struct device *dev; +void __iomem *base; +struct nvmem_device *nvmem; +}; + +static int dhc_efuse_reg_read (void *priv,unsigned int offset,void *val, +size_t bytes) +{ +struct dhc_efuse *efuse = priv; +u8 *buf = val; + +while (bytes--) + *buf++ =readb_relaxed (efuse->base + offset++); + +return 0 ; +} + +static int dhc_efuse_probe (struct platform_device *pdev) +{ +struct dhc_efuse *efuse; +struct nvmem_config config = {}; +struct resource *res; + + efuse =devm_kzalloc (&pdev->dev,sizeof (*efuse),GFP_KERNEL ); +if (!efuse) +return -ENOMEM ; + + efuse->base =devm_platform_get_and_ioremap_resource (pdev,0 , &res); +if (IS_ERR (efuse->base)) +return PTR_ERR (efuse->base); + + efuse->dev = &pdev->dev; + + config.dev = &pdev->dev; + config.name ="dhc-efuse" ; + config.owner =THIS_MODULE ; + config.type =NVMEM_TYPE_OTP ; + config.read_only = true, + config.word_size =4 ; + config.stride =1 ; + config.size =resource_size (res); + config.reg_read = dhc_efuse_reg_read; + config.priv = efuse; + + efuse->nvmem =devm_nvmem_register (&pdev->dev, &config); +if (IS_ERR (efuse->nvmem)) { +dev_err (&pdev->dev,"failed to register nvmem (%ld)\n" , +PTR_ERR (efuse->nvmem)); +return PTR_ERR (efuse->nvmem); + } + +return 0 ; +} + +static const struct of_device_id dhc_efuse_dt_ids[] = { + { .compatible ="realtek,rtd1195-efuse" }, + { } +}; + +static struct platform_driver dhc_efuse_driver = { + .probe = dhc_efuse_probe, + .driver = { + .name ="rtk-dhc-efuse" , + .of_match_table = dhc_efuse_dt_ids, + }, +}; +module_platform_driver (dhc_efuse_driver); + +MODULE_DESCRIPTION ("Realtek DHC eFuse driver" ); +MODULE_LICENSE ("GPL" );
Re: [PATCH v2 18/29] nvmem: Add Realtek DHC eFuse driver
Hi Srini,
Am 23.06.20 um 11:32 schrieb Srinivas Kandagatla:
Quoted 8 lines · Andreas Färber
Quoted 5 lines
Implement enough of a read-only nvmem driver to easily read efuse cells.
Cc Cheng-Yu Lee <[email protected]>Signed-off-by Andreas Färber <[email protected]>---
This patch itself looks okay to me, I will apply this once DT patches are Reviewed/applied by DT maintainers!
Thanks - let's give the Realtek engineers some time to review, too:
* Driver naming - new [rtk-]dhc (Stanley) vs. in-tree rtd1195 elsewhere.
* My other driver was previously reading u32-sized registers directly, whereas here I switched to byte-sized reads based on other in-tree nvmem drivers. Downstream driver seems inconsistent wrt .word_size:
https://github.com/BPI-SINOVOIP/BPI-M4-bsp/blob/master/linux-rtk/drivers/nvmem/rtk-efuse.c#L191
* RTD1619 (RTD1319, too?) may need special handling and therefore its own DT compatible: There's a magic OTP_CTRL register write downstream that I am lacking documentation w/ names&explanations and use case for.
https://github.com/BPI-SINOVOIP/BPI-M4-bsp/blob/master/linux-rtk/drivers/nvmem/rtk-efuse.c#L216
That might obviously affect the binding, too, requiring oneOf - could be changed in a later step though.
I would take the .dts patches through my linux-realtek.git once the binding is approved.
* The downstream DTs have nvmem-cells and nvmem-cell-names properties in the efuse node directly, which I regarded as unnecessary from reading the consumer binding, placing those properties into the consuming node.
* Downstream DTs have more eFuse fields declared than the one I use in this series [1]; they are also inconsistent in prefixing them efuse_ vs. otp_; in the RTD1295 datasheet the block is called eFuse, so I used efuse_ for consistency. I have enforced the dashes convention for nodes, as I didn't see the node name get used anywhere.
[1] https://patchwork.kernel.org/patch/11619643/
One more comment inline...
Quoted 8 lines
Quoted 8 lines
v2: New
MAINTAINERS | 1 +
drivers/nvmem/Kconfig | 9 ++++ drivers/nvmem/Makefile | 2 +drivers/nvmem/rtk-dhc-efuse.c| 86 +++++++++++++++++++++++++++++++++++4 files changed, 98 insertions(+)create mode 100644
drivers/nvmem/rtk-dhc-efuse.c
Quoted 12 lines
Quoted 5 lines
MAINTAINERS +0
-0@@ -2312,6 +2312,7 @@ F:Quoted 7 lines
Documentation/devicetree/bindings/soc/realtek/
F:arch/arm/boot/dts/rtd*
F:arch/arm/mach-realtek/
F:arch/arm64/boot/dts/realtek/
+F:drivers/nvmem/rtk-dhc-efuse.c
F:drivers/soc/realtek/
ARM/RENESAS ARM64 ARCHITECTURE
[snip]
This line addition will conflict with the next line, added earlier in this patchset. Same for the binding patch. Do you need a v3 reordering them? This driver seems easier to target for 5.9 than the rest of the series.
If you do not intend to take the dt-bindings patch (17/29) through your tree, I can queue it once ack'ed by Rob and you.
Thanks for the quick review,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)
Re: [PATCH v2 18/29] nvmem: Add Realtek DHC eFuse driver
In reply to Andreas FärberQuoted 4 lines · Andreas Färber
Implement enough of a read-only nvmem driver to easily read efuse cells.
Cc Cheng-Yu Lee <[email protected]>Signed-off-by Andreas Färber <[email protected]>
If you are expecting this to be applied, then please resend this patch splitting the MAINTAINER File changes separately!
--srini
Quoted 148 lines
---
v2: NewMAINTAINERS | 1 + drivers/nvmem/Kconfig | 9 ++++ drivers/nvmem/Makefile | 2 + drivers/nvmem/rtk-dhc-efuse.c | 86 +++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)create mode 100644
drivers/nvmem/rtk-dhc-efuse.cMAINTAINERS +1
-0@@ -2312,6 +2312,7 @@ F: Documentation/devicetree/bindings/soc/realtek/ F: arch/arm/boot/dts/rtd* F: arch/arm/mach-realtek/ F: arch/arm64/boot/dts/realtek/ +F: drivers/nvmem/rtk-dhc-efuse.c F: drivers/soc/realtek/ ARM/RENESAS ARM64 ARCHITECTUREdrivers/nvmem/Kconfig +9
-0@@ -129,6 +129,15 @@ config NVMEM_SPMI_SDAM Qualcomm Technologies, Inc. PMICs. It provides the clients an interface to read/write to the SDAM module's shared memory. +config REALTEK_DHC_EFUSE + tristate "Realtek DHC eFuse Support" + depends on ARCH_REALTEK || COMPILE_TEST + depends on HAS_IOMEM + help + Say y here to enable read-only access to the Realtek Digital Home + This driver can also be built as a module. If so, the module + will be called nvmem-rtk-dhc-efuse. + config ROCKCHIP_EFUSE tristate "Rockchip eFuse Support" depends on ARCH_ROCKCHIP || COMPILE_TESTdrivers/nvmem/Makefile +2
-0@@ -33,6 +33,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += nvmem_rockchip_efuse.o nvmem_rockchip_efuse-y := rockchip-efuse.o obj-$(CONFIG_ROCKCHIP_OTP) += nvmem-rockchip-otp.o nvmem-rockchip-otp-y := rockchip-otp.o +obj-$(CONFIG_REALTEK_DHC_EFUSE) += nvmem-rtk-dhc-efuse.o +nvmem-rtk-dhc-efuse-y := rtk-dhc-efuse.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_stm32_romem-y := stm32-romem.o obj-$(CONFIG_NVMEM_STM32_ROMEM) += nvmem_stm32_romem.odrivers/nvmem/rtk-dhc-efuse.c new file +86
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Realtek Digital Home Center eFuse +* +* Copyright (c) 2020 Andreas Färber +*/ + +#include <linux/io.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +struct dhc_efuse { +struct device *dev; +void __iomem *base; +struct nvmem_device *nvmem; +}; + +static int dhc_efuse_reg_read (void *priv,unsigned int offset,void *val, +size_t bytes) +{ +struct dhc_efuse *efuse = priv; +u8 *buf = val; + +while (bytes--) + *buf++ =readb_relaxed (efuse->base + offset++); + +return 0 ; +} + +static int dhc_efuse_probe (struct platform_device *pdev) +{ +struct dhc_efuse *efuse; +struct nvmem_config config = {}; +struct resource *res; + + efuse =devm_kzalloc (&pdev->dev,sizeof (*efuse),GFP_KERNEL ); +if (!efuse) +return -ENOMEM ; + + efuse->base =devm_platform_get_and_ioremap_resource (pdev,0 , &res); +if (IS_ERR (efuse->base)) +return PTR_ERR (efuse->base); + + efuse->dev = &pdev->dev; + + config.dev = &pdev->dev; + config.name ="dhc-efuse" ; + config.owner =THIS_MODULE ; + config.type =NVMEM_TYPE_OTP ; + config.read_only = true, + config.word_size =4 ; + config.stride =1 ; + config.size =resource_size (res); + config.reg_read = dhc_efuse_reg_read; + config.priv = efuse; + + efuse->nvmem =devm_nvmem_register (&pdev->dev, &config); +if (IS_ERR (efuse->nvmem)) { +dev_err (&pdev->dev,"failed to register nvmem (%ld)\n" , +PTR_ERR (efuse->nvmem)); +return PTR_ERR (efuse->nvmem); + } + +return 0 ; +} + +static const struct of_device_id dhc_efuse_dt_ids[] = { + { .compatible ="realtek,rtd1195-efuse" }, + { } +}; + +static struct platform_driver dhc_efuse_driver = { + .probe = dhc_efuse_probe, + .driver = { + .name ="rtk-dhc-efuse" , + .of_match_table = dhc_efuse_dt_ids, + }, +}; +module_platform_driver (dhc_efuse_driver); + +MODULE_DESCRIPTION ("Realtek DHC eFuse driver" ); +MODULE_LICENSE ("GPL" );
PATCH v2 19/29 ARM: dts: rtd1195: Add eFuse node
In reply to Andreas FärberAdd a DT node for eFuse.
---
v2: New
arch/arm/boot/dts/rtd1195.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/rtd1195.dtsi +8 -0
@@ -119,6 +119,14 @@ iso: syscon@7000 { ranges = <0x0 0x7000 0x1000>; }; + efuse: efuse@17000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x17000 0x400>; + read-only; + #address-cells = <1>; + #size-cells = <1>; + }; + sb2: syscon@1a000 { compatible = "syscon", "simple-mfd"; reg = <0x1a000 0x1000>;
Signature · 1 line
2.26.2
PATCH v2 20/29 arm64: dts: realtek: rtd129x: Add eFuse node
In reply to Andreas FärberAdd a DT node for eFuse.
---
v2: New
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/realtek/rtd129x.dtsi +15 -0
@@ -81,6 +81,14 @@ iso: syscon@7000 { ranges = <0x0 0x7000 0x1000>; }; + efuse: efuse@17000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x17000 0x400>; + read-only; + #address-cells = <1>; + #size-cells = <1>; + }; + sb2: syscon@1a000 { compatible = "syscon", "simple-mfd"; reg = <0x1a000 0x1000>;
@@ -194,6 +202,13 @@ uart2: serial@400 { }; }; +&otp { + otp_package_id: package-id@1d8 { + reg = <0x1d8 0x1>; + bits = <0 2>; + }; +}; + &sb2 { sb2_hd_sem: hwspinlock@0 { compatible = "realtek,rtd1195-sb2-sem";
Signature · 1 line
2.26.2
PATCH v2 21/29 arm64: dts: realtek: rtd139x: Add eFuse node
In reply to Andreas FärberAdd a DT node for eFuse.
---
v2: New
arch/arm64/boot/dts/realtek/rtd139x.dtsi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/realtek/rtd139x.dtsi +9 -1
@@ -2,7 +2,7 @@ /* * Realtek RTD1395 SoC family * - * Copyright (c) 2019 Andreas Färber + * Copyright (c) 2019-2020 Andreas Färber */ /memreserve/ 0x0000000000000000 0x000000000002f000;
@@ -79,6 +79,14 @@ iso: syscon@7000 { ranges = <0x0 0x7000 0x1000>; }; + efuse: efuse@17000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x17000 0x400>; + read-only; + #address-cells = <1>; + #size-cells = <1>; + }; + sb2: syscon@1a000 { compatible = "syscon", "simple-mfd"; reg = <0x1a000 0x1000>;
Signature · 1 line
2.26.2
PATCH v2 22/29 arm64: dts: realtek: rtd16xx: Add eFuse node
In reply to Andreas FärberAdd a DT node for eFuse.
---
v2: New
arch/arm64/boot/dts/realtek/rtd16xx.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/realtek/rtd16xx.dtsi +8 -0
@@ -155,6 +155,14 @@ iso: syscon@7000 { ranges = <0x0 0x7000 0x1000>; }; + efuse: efuse@17000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x17000 0x1000>; + read-only; + #address-cells = <1>; + #size-cells = <1>; + }; + sb2: syscon@1a000 { compatible = "syscon", "simple-mfd"; reg = <0x1a000 0x1000>;
Signature · 1 line
2.26.2
PATCH v2 23/29 arm64: dts: realtek: rtd13xx: Add eFuse node
In reply to Andreas FärberAdd a DT node for eFuse.
---
v2: New
arch/arm64/boot/dts/realtek/rtd13xx.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/realtek/rtd13xx.dtsi +8 -0
@@ -139,6 +139,14 @@ iso: syscon@7000 { ranges = <0x0 0x7000 0x1000>; }; + efuse: efuse@17000 { + compatible = "realtek,rtd1195-efuse"; + reg = <0x17000 0x1000>; + read-only; + #address-cells = <1>; + #size-cells = <1>; + }; + sb2: syscon@1a000 { compatible = "syscon", "simple-mfd"; reg = <0x1a000 0x1000>;
Signature · 1 line
2.26.2
PATCH v2 24/29 dt-bindings: soc: realtek: rtd1195-chip: Allow nvmem-cells property
In reply to Andreas FärberAllow to optionally specify nvmem cells to identify the chip. RTD1295 family will want the eFuse package_id cell.
---
v1 -> v2:
* Instead of extending reg, allow nvmem-cells reference for eFuse
.../bindings/soc/realtek/realtek,rtd1195-chip.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml +12 -0
@@ -22,6 +22,10 @@ properties: iso-syscon: true + nvmem-cells: true + + nvmem-cell-names: true + required: - compatible - reg
@@ -40,4 +44,12 @@ examples: reg = <0x9801a200 0x8>; iso-syscon = <&iso>; }; + - | + chip-info@9801a200 { + compatible = "realtek,rtd1195-chip"; + reg = <0x9801a200 0x8>; + iso-syscon = <&iso>; + nvmem-cells = <&efuse_package_id>; + nvmem-cell-names = "efuse_package_id"; + }; ...
Signature · 1 line
2.26.2
Re: [PATCH v2 24/29] dt-bindings: soc: realtek: rtd1195-chip: Allow nvmem-cells property
Quoted 11 lines · Andreas Färber
Allow to optionally specify nvmem cells to identify the chip. RTD1295 family will want the eFuse
package_idcell.Signed-off-by Andreas Färber <[email protected]>---
v1 -> v2:
* Instead of extending reg, allow nvmem-cells reference for eFuse.../bindings/soc/realtek/realtek,rtd1195-chip.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
PATCH v2 25/29 arm64: dts: realtek: rtd129x: Add eFuse package_id to chip-info
In reply to Andreas FärberAdd the package_id field as sub-node to eFuse and reference it for chip identification.
---
v1 -> v2:
* Instead of extending reg, use nvmem-cells reference for eFuse
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/arm64/boot/dts/realtek/rtd129x.dtsi +9 -7
@@ -156,6 +156,13 @@ reset4: reset-controller@50 { }; }; +&efuse { + efuse_package_id: package-id@1d8 { + reg = <0x1d8 0x1>; + bits = <0 2>; + }; +}; + &iso { iso_reset: reset-controller@88 { compatible = "snps,dw-low-reset";
@@ -202,13 +209,6 @@ uart2: serial@400 { }; }; -&otp { - otp_package_id: package-id@1d8 { - reg = <0x1d8 0x1>; - bits = <0 2>; - }; -}; - &sb2 { sb2_hd_sem: hwspinlock@0 { compatible = "realtek,rtd1195-sb2-sem";
@@ -220,6 +220,8 @@ chip-info@200 { compatible = "realtek,rtd1195-chip"; reg = <0x200 0x8>; iso-syscon = <&iso>; + nvmem-cells = <&efuse_package_id>; + nvmem-cell-names = "efuse_package_id"; }; sb2_hd_sem_new: hwspinlock@620 {
Signature · 1 line
2.26.2
PATCH v2 26/29 soc: realtek: chip: Detect RTD1294
In reply to Andreas FärberDetection logic from downstream include/soc/realtek/rtd129x_cpu.h.
---
Note: We don't have any RTD1294 .dtsi/.dts yet.
v1 -> v2:
* Instead of direct eFuse register access use nvmem cell API
* Warn on errors other than deferred probing
drivers/soc/realtek/chip.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/soc/realtek/chip.c +39 -0
@@ -10,6 +10,7 @@#include <linux/io.h> #include <linux/mfd/syscon.h> #include <linux/module.h> +#include <linux/nvmem-consumer.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/platform_device.h>
@@ -26,6 +27,8 @@#define REG_ISO_CHIP_INFO1 0x028 +#define REG_EFUSE_PACKAGE_ID 0x1d8 +struct dhc_soc_revision {const char *name;u16 chip_rev;
@@ -76,6 +79,33 @@ struct dhc_soc {const char *codename; }; +static int dhc_efuse_read_u8 (struct device *dev,const char *cell_id,u8 *val) +{ +struct nvmem_cell *cell; +void *buf; +size_t len; + + cell =nvmem_cell_get (dev, cell_id); +if (IS_ERR (cell)) +return PTR_ERR (cell); + + buf =nvmem_cell_read (cell, &len); +if (IS_ERR (buf)) { +nvmem_cell_put (cell); +return PTR_ERR (buf); + } +if (len !=sizeof (*val)) { +kfree (buf); +nvmem_cell_put (cell); +return -EINVAL ; + } +memcpy (val, buf,1 ); +kfree (buf); +nvmem_cell_put (cell); + +return 0 ; +} +static const char *default_name (struct device *dev,const struct dhc_soc *s) {return s->family;
@@ -86,6 +116,15 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s)struct regmap *regmap;unsigned int val;int ret; +u8 b; + + ret =dhc_efuse_read_u8 (dev,"efuse_package_id" , &b); +if (ret == -EPROBE_DEFER ) +return ERR_PTR (ret); +else if (ret) +dev_warn (dev,"Could not read efuse package_id (%d)\n" , ret); +else if (b ==0x1 ) +return "RTD1294" ; regmap =syscon_regmap_lookup_by_phandle (dev->of_node,"iso-syscon" );if (IS_ERR (regmap)) {
Signature · 1 line
2.26.2
RE: [PATCH v2 26/29] soc: realtek: chip: Detect RTD1294
Thanks,
Stanley
PATCH v2 27/29 nvmem: core: Grammar fixes for help text
In reply to Andreas FärberIt's "an unsigned" but "a U".
Similarly, "an entry" but "a binary entry".
While at it, also drop superfluous articles for negative and zero.
---
In theory, for clean backports this would need to be split into 5 pieces... Not sure whether anyone would actually do that for help text? Dropping the Fixes headers might be an alternative.
v2: New
drivers/nvmem/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvmem/core.c +6 -6
@@ -573,7 +573,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)/** * nvmem_register() - Register a nvmem device for given nvmem_config. -* Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem +* Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem * * @config: nvmem device configuration with which nvmem device is created. *
@@ -728,7 +728,7 @@ static void devm_nvmem_release(struct device *dev, void *res)/** * devm_nvmem_register() - Register a managed nvmem device for given * nvmem_config. -* Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem +* Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem * * @dev: Device that uses the nvmem device. * @config: nvmem device configuration with which nvmem device is created.
@@ -772,7 +772,7 @@ static int devm_nvmem_match(struct device *dev, void *res, void *data)* @dev: Device that uses the nvmem device. * @nvmem: Pointer to previously registered nvmem device. * -* Return: Will be an negative on error or a zero on success. +* Return: Will be negative on error or zero on success. */ int devm_nvmem_unregister (struct device *dev,struct nvmem_device *nvmem) {
@@ -1375,7 +1375,7 @@ static int nvmem_cell_read_common(struct device *dev, const char *cell_id, }/** -* nvmem_cell_read_u16() - Read a cell value as an u16 +* nvmem_cell_read_u16() - Read a cell value as a u16 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read.
@@ -1390,7 +1390,7 @@ int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val)EXPORT_SYMBOL_GPL (nvmem_cell_read_u16);/** -* nvmem_cell_read_u32() - Read a cell value as an u32 +* nvmem_cell_read_u32() - Read a cell value as a u32 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read.
@@ -1405,7 +1405,7 @@ int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val)EXPORT_SYMBOL_GPL (nvmem_cell_read_u32);/** -* nvmem_cell_read_u64() - Read a cell value as an u64 +* nvmem_cell_read_u64() - Read a cell value as a u64 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read.
Signature · 1 line
2.26.2
Re: [PATCH v2 27/29] nvmem: core: Grammar fixes for help text
Quoted 11 lines · Andreas Färber
It's "an unsigned" but "a U".
Similarly, "an entry" but "a binary entry".While at it, also drop superfluous articles for negative and zero.
Fixes 8b977c5498b8 ("nvmem: core: add nvmem_cell_read_u64")Fixes 0a9b2d1ce422 ("nvmem: core: add nvmem_cell_read_u16")Fixes d026d70a2e94 ("nvmem: core: Add nvmem_cell_read_u32")Fixes f1f50eca5f90 ("nvmem: Introduce devm_nvmem_(un)register()")Fixes eace75cfdcf7 ("nvmem: Add a simple NVMEM framework for nvmem providers")Signed-off-by Andreas Färber <[email protected]>
Quoted 4 lines
---
In theory, for clean backports this would need to be split into 5 pieces... Not sure whether anyone would actually do that for help text? Dropping the Fixes headers might be an alternative.
TBH, it adds lot of confusion while automatically back-porting these patches! For now I have removed these Fixes tags and applied.
As I do not feel this is going to add any value in back-porting this grammar fixes!!
--srini
Quoted 65 lines
v2: New
drivers/nvmem/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/nvmem/core.c +6
-6@@ -573,7 +573,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)/** * nvmem_register() - Register a nvmem device for given nvmem_config. -* Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem +* Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem * * @config: nvmem device configuration with which nvmem device is created. * @@ -728,7 +728,7 @@ static void devm_nvmem_release(struct device *dev, void *res)/** * devm_nvmem_register() - Register a managed nvmem device for given * nvmem_config. -* Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem +* Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem * * @dev: Device that uses the nvmem device. * @config: nvmem device configuration with which nvmem device is created. @@ -772,7 +772,7 @@ static int devm_nvmem_match(struct device *dev, void *res, void *data)* @dev: Device that uses the nvmem device. * @nvmem: Pointer to previously registered nvmem device. * -* Return: Will be an negative on error or a zero on success. +* Return: Will be negative on error or zero on success. */ int devm_nvmem_unregister (struct device *dev,struct nvmem_device *nvmem) {@@ -1375,7 +1375,7 @@ static int nvmem_cell_read_common(struct device *dev, const char *cell_id, }/** -* nvmem_cell_read_u16() - Read a cell value as an u16 +* nvmem_cell_read_u16() - Read a cell value as a u16 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read. @@ -1390,7 +1390,7 @@ int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val)EXPORT_SYMBOL_GPL (nvmem_cell_read_u16);/** -* nvmem_cell_read_u32() - Read a cell value as an u32 +* nvmem_cell_read_u32() - Read a cell value as a u32 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read. @@ -1405,7 +1405,7 @@ int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val)EXPORT_SYMBOL_GPL (nvmem_cell_read_u32);/** -* nvmem_cell_read_u64() - Read a cell value as an u64 +* nvmem_cell_read_u64() - Read a cell value as a u64 * * @dev: Device that requests the nvmem cell. * @cell_id: Name of nvmem cell to read.
PATCH v2 28/29 nvmem: core: Add nvmem_cell_read_u8()
In reply to Andreas FärberComplement the u16, u32 and u64 helpers with a u8 variant to ease accessing byte-sized values.
This helper will be useful for Realtek Digital Home Center platforms, which store some byte and sub-byte sized values in non-volatile memory.
---
v2: New
drivers/nvmem/core.c | 15 +++++++++++++++ include/linux/nvmem-consumer.h | 1 + 2 files changed, 16 insertions(+)
drivers/nvmem/core.c +15 -0
@@ -1374,6 +1374,21 @@ static int nvmem_cell_read_common(struct device *dev, const char *cell_id,return 0 ; } +/** +* nvmem_cell_read_u8() - Read a cell value as a u8 +* +* @dev: Device that requests the nvmem cell. +* @cell_id: Name of nvmem cell to read. +* @val: pointer to output value. +* +* Return: 0 on success or negative errno. +*/ +int nvmem_cell_read_u8 (struct device *dev,const char *cell_id,u8 *val) +{ +return nvmem_cell_read_common (dev, cell_id, val,sizeof (*val)); +} +EXPORT_SYMBOL_GPL (nvmem_cell_read_u8); +/** * nvmem_cell_read_u16() - Read a cell value as a u16 *
include/linux/nvmem-consumer.h +1 -0
@@ -61,6 +61,7 @@ void nvmem_cell_put(struct nvmem_cell *cell);void devm_nvmem_cell_put (struct device *dev,struct nvmem_cell *cell);void *nvmem_cell_read (struct nvmem_cell *cell,size_t *len);int nvmem_cell_write (struct nvmem_cell *cell,void *buf,size_t len); +int nvmem_cell_read_u8 (struct device *dev,const char *cell_id,u8 *val);int nvmem_cell_read_u16 (struct device *dev,const char *cell_id,u16 *val);int nvmem_cell_read_u32 (struct device *dev,const char *cell_id,u32 *val);int nvmem_cell_read_u64 (struct device *dev,const char *cell_id,u64 *val);
Signature · 1 line
2.26.2
Re: [PATCH v2 28/29] nvmem: core: Add nvmem_cell_read_u8()
Quoted 7 lines · Andreas Färber
Complement the u16, u32 and u64 helpers with a u8 variant to ease accessing byte-sized values.
This helper will be useful for Realtek Digital Home Center platforms, which store some byte and sub-byte sized values in non-volatile memory.
Signed-off-by Andreas Färber <[email protected]>
Applied thanks,
--srini
PATCH v2 29/29 soc: realtek: chip: Adopt nvmem_cell_read_u8() helper
In reply to Andreas FärberReplace the local helper with the newly introduced official one.
---
This could be squashed if the new API and this commit were to get merged in subsequent merge windows or with the help of a topic branch.
v2: New
drivers/soc/realtek/chip.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-)
drivers/soc/realtek/chip.c +1 -28
@@ -79,33 +79,6 @@ struct dhc_soc {const char *codename; }; -static int dhc_efuse_read_u8 (struct device *dev,const char *cell_id,u8 *val) -{ -struct nvmem_cell *cell; -void *buf; -size_t len; - - cell =nvmem_cell_get (dev, cell_id); -if (IS_ERR (cell)) -return PTR_ERR (cell); - - buf =nvmem_cell_read (cell, &len); -if (IS_ERR (buf)) { -nvmem_cell_put (cell); -return PTR_ERR (buf); - } -if (len !=sizeof (*val)) { -kfree (buf); -nvmem_cell_put (cell); -return -EINVAL ; - } -memcpy (val, buf,1 ); -kfree (buf); -nvmem_cell_put (cell); - -return 0 ; -} -static const char *default_name (struct device *dev,const struct dhc_soc *s) {return s->family;
@@ -118,7 +91,7 @@ static const char *rtd1295_name(struct device *dev, const struct dhc_soc *s)int ret;u8 b; - ret =dhc_efuse_read_u8 (dev,"efuse_package_id" , &b); + ret =nvmem_cell_read_u8 (dev,"efuse_package_id" , &b);if (ret == -EPROBE_DEFER )return ERR_PTR (ret);else if (ret)
Signature · 1 line
2.26.2