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
Cc: [email protected]
Cc: Rob Herring <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: James Tai <[email protected]>
Cc: Stanley Chang [昌育德] <[email protected]>
Cc: Edgar Lee <[email protected]>
Cc: [email protected]
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
--
2.26.2
Add a DT node for chip identification.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd13xx.dtsi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd13xx.dtsi b/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
index e41be02f2e3a..e4271ef5cb1e 100644
--- a/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
@@ -211,3 +211,10 @@ uart2: serial@400 {
status = "disabled";
};
};
+
+&sb2 {
+ chip-info@200 {
+ compatible = "realtek,rtd1195-chip";
+ reg = <0x200 0x8>;
+ };
+};
--
2.26.2
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
diff --git a/Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml b/Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml
new file mode 100644
index 000000000000..a616cb22673e
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/realtek,rtd1195-efuse.yaml
@@ -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>;
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index ff0ee48fee6f..1d0d6ab20451 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
--
2.26.2
Add a DT node for eFuse.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
index 30a7782aa0d9..8f96d4e4c46b 100644
--- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
@@ -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";
--
2.26.2
Allow to optionally specify nvmem cells to identify the chip.
RTD1295 family will want the eFuse package_id cell.
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(+)
diff --git a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
index dfe33c95f68d..57a6e0df4494 100644
--- a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
+++ b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
@@ -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";
+ };
...
--
2.26.2
Add the package_id field as sub-node to eFuse and reference it for
chip identification.
Signed-off-by: Andreas Färber <[email protected]>
---
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(-)
diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
index 8f96d4e4c46b..c35955e915f4 100644
--- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
@@ -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 {
--
2.26.2
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]>
---
v2: New
drivers/nvmem/core.c | 15 +++++++++++++++
include/linux/nvmem-consumer.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 95bed31391cd..d6bacc878500 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -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
*
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 1b311d27c9b8..052293f4cbdb 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -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);
--
2.26.2
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]>
---
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(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fc480d636be2..95bed31391cd 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -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.
--
2.26.2
Revisions based on downstream drivers/soc/realtek/rtd16xx/rtk_chip.c.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
drivers/soc/realtek/chip.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index aa7ca6bb1e64..e3220187e336 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)
--
2.26.2
Replace the local helper with the newly introduced official one.
Cc: Srinivas Kandagatla <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
---
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(-)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index bed028ce1b16..46e0d9063b5d 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)
--
2.26.2
Detection logic from downstream include/soc/realtek/rtd129x_cpu.h.
Signed-off-by: Andreas Färber <[email protected]>
---
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(+)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index 9cee760bac35..bed028ce1b16 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)) {
--
2.26.2
Add a DT node for eFuse.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd13xx.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd13xx.dtsi b/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
index e4271ef5cb1e..ed5ee7cc6a44 100644
--- a/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd13xx.dtsi
@@ -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>;
--
2.26.2
Add a DT node for eFuse.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd16xx.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd16xx.dtsi b/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
index 04cb546142a0..3c955fc7450c 100644
--- a/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
@@ -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>;
--
2.26.2
Add a DT node for eFuse.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd139x.dtsi | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/realtek/rtd139x.dtsi b/arch/arm64/boot/dts/realtek/rtd139x.dtsi
index 3d4d2323294b..48746d432328 100644
--- a/arch/arm64/boot/dts/realtek/rtd139x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd139x.dtsi
@@ -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>;
--
2.26.2
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]>
---
v2: New
* Filled in chip ID based on Stanley's v1
drivers/soc/realtek/chip.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index e3220187e336..ae7c5322f338 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)
--
2.26.2
Add a DT node for chip identification.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd139x.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd139x.dtsi b/arch/arm64/boot/dts/realtek/rtd139x.dtsi
index 586b05350274..3d4d2323294b 100644
--- a/arch/arm64/boot/dts/realtek/rtd139x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd139x.dtsi
@@ -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>;
--
2.26.2
From: Stanley Chang <[email protected]>
Distinguish RTD1392 from RTD1395 via ISO_CHIP_INFO1 register.
Signed-off-by: Stanley Chang <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
---
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(-)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index 6b3d1f3d3816..9cee760bac35 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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" },
};
--
2.26.2
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]>
---
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
diff --git a/MAINTAINERS b/MAINTAINERS
index 1d0d6ab20451..02117fbf0e57 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index d7b7f6d688e7..75cf43b16cf9 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -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
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index a7c377218341..67cefdfa44e6 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -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
diff --git a/drivers/nvmem/rtk-dhc-efuse.c b/drivers/nvmem/rtk-dhc-efuse.c
new file mode 100644
index 000000000000..4672db2c2619
--- /dev/null
+++ b/drivers/nvmem/rtk-dhc-efuse.c
@@ -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");
--
2.26.2
This additional register is needed to distinguish RTD1296 from RTD1295.
Signed-off-by: Andreas Färber <[email protected]>
---
v1 -> v2:
* Switched from reg to new iso-syscon phandle
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
index b5be9df80dae..30a7782aa0d9 100644
--- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
@@ -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 {
--
2.26.2
Logic self-determined by comparing DS418j and DS418 registers.
Signed-off-by: Andreas Färber <[email protected]>
---
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(-)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index 103f564aad7f..32ed0e4a3646 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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";
--
2.26.2
Add 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 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
diff --git a/MAINTAINERS b/MAINTAINERS
index 78adbc3cc101..ff0ee48fee6f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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]>
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 425ab6f7e375..925647993119 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -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"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 36452bed86ef..cdcf00bbad10 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -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/
diff --git a/drivers/soc/realtek/Kconfig b/drivers/soc/realtek/Kconfig
new file mode 100644
index 000000000000..be75c1889c61
--- /dev/null
+++ b/drivers/soc/realtek/Kconfig
@@ -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
diff --git a/drivers/soc/realtek/Makefile b/drivers/soc/realtek/Makefile
new file mode 100644
index 000000000000..49900273905b
--- /dev/null
+++ b/drivers/soc/realtek/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+obj-$(CONFIG_REALTEK_SOC) += chip.o
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
new file mode 100644
index 000000000000..c4650d512c91
--- /dev/null
+++ b/drivers/soc/realtek/chip.c
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Realtek Digital Home Center System-on-Chip info
+ *
+ * Copyright (c) 2017-2020 Andreas Färber
+ */
+
+#include <linux/bitfield.h>
+#include <linux/io.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
+
+#define REG_SB2_CHIP_ID 0x200
+#define REG_SB2_CHIP_INFO 0x204
+
+#define SB2_CHIP_ID_CHIP_ID GENMASK(15, 0)
+
+#define SB2_CHIP_INFO_REVISE_ID GENMASK(31, 16)
+
+struct dhc_soc_revision {
+ const char *name;
+ u16 chip_rev;
+};
+
+static const struct dhc_soc_revision rtd1195_revisions[] = {
+ { "A", 0x0000 },
+ { "B", 0x0001 },
+ { "C", 0x0002 },
+ { "D", 0x0003 },
+ { }
+};
+
+static const struct dhc_soc_revision rtd1295_revisions[] = {
+ { "A00", 0x0000 },
+ { "A01", 0x0001 },
+ { "B00", 0x0002 },
+ { "B01", 0x0003 },
+ { }
+};
+
+struct dhc_soc {
+ u16 chip_id;
+ const char *family;
+ const char *(*get_name)(struct device *dev, const struct dhc_soc *s);
+ const struct dhc_soc_revision *revisions;
+ const char *codename;
+};
+
+static const char *default_name(struct device *dev, const struct dhc_soc *s)
+{
+ return s->family;
+}
+
+static const struct dhc_soc dhc_soc_families[] = {
+ { 0x6329, "RTD1195", default_name, rtd1195_revisions, "Phoenix" },
+ { 0x6421, "RTD1295", default_name, rtd1295_revisions, "Kylin" },
+};
+
+static const struct dhc_soc *dhc_soc_by_chip_id(u16 chip_id)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(dhc_soc_families); i++) {
+ const struct dhc_soc *family = &dhc_soc_families[i];
+
+ if (family->chip_id == chip_id)
+ return family;
+ }
+ return NULL;
+}
+
+static const char *dhc_soc_rev(const struct dhc_soc *family, u16 chip_rev)
+{
+ if (family) {
+ const struct dhc_soc_revision *rev = family->revisions;
+
+ while (rev && rev->name) {
+ if (rev->chip_rev == chip_rev)
+ return rev->name;
+ rev++;
+ }
+ }
+ return "unknown";
+}
+
+static int dhc_soc_probe(struct platform_device *pdev)
+{
+ const struct dhc_soc *s;
+ struct soc_device_attribute *soc_dev_attr;
+ struct soc_device *soc_dev;
+ struct device_node *node;
+ struct regmap *regmap;
+ u16 chip_id, chip_rev;
+ unsigned int val;
+ int ret;
+
+ regmap = syscon_node_to_regmap(pdev->dev.of_node->parent);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ ret = regmap_read(regmap, REG_SB2_CHIP_ID, &val);
+ if (ret)
+ return ret;
+ chip_id = FIELD_GET(SB2_CHIP_ID_CHIP_ID, val);
+
+ ret = regmap_read(regmap, REG_SB2_CHIP_INFO, &val);
+ if (ret)
+ return ret;
+ chip_rev = FIELD_GET(SB2_CHIP_INFO_REVISE_ID, val);
+
+ soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+ if (!soc_dev_attr)
+ return -ENOMEM;
+
+ node = of_find_node_by_path("/");
+ of_property_read_string(node, "model", &soc_dev_attr->machine);
+ of_node_put(node);
+
+ s = dhc_soc_by_chip_id(chip_id);
+
+ if (likely(s && s->get_name)) {
+ soc_dev_attr->soc_id = s->get_name(&pdev->dev, s);
+ if (IS_ERR(soc_dev_attr->soc_id))
+ return PTR_ERR(soc_dev_attr->soc_id);
+ } else
+ soc_dev_attr->soc_id = "unknown";
+
+ soc_dev_attr->revision = dhc_soc_rev(s, chip_rev);
+
+ soc_dev_attr->family = kasprintf(GFP_KERNEL, "Realtek %s",
+ (s && s->codename) ? s->codename :
+ ((s && s->family) ? s->family : "Digital Home Center"));
+
+ soc_dev = soc_device_register(soc_dev_attr);
+ if (IS_ERR(soc_dev)) {
+ kfree(soc_dev_attr->family);
+ kfree(soc_dev_attr);
+ return PTR_ERR(soc_dev);
+ }
+
+ platform_set_drvdata(pdev, soc_dev);
+
+ pr_info("%s %s (0x%04x) rev %s (0x%04x) detected\n",
+ soc_dev_attr->family, soc_dev_attr->soc_id, (u32)chip_id,
+ soc_dev_attr->revision, (u32)chip_rev);
+
+ return 0;
+}
+
+static int dhc_soc_remove(struct platform_device *pdev)
+{
+ struct soc_device *soc_dev = platform_get_drvdata(pdev);
+
+ soc_device_unregister(soc_dev);
+
+ return 0;
+}
+
+static const struct of_device_id dhc_soc_dt_ids[] = {
+ { .compatible = "realtek,rtd1195-chip" },
+ { }
+};
+
+static struct platform_driver dhc_soc_driver = {
+ .probe = dhc_soc_probe,
+ .remove = dhc_soc_remove,
+ .driver = {
+ .name = "dhc-soc",
+ .of_match_table = dhc_soc_dt_ids,
+ },
+};
+module_platform_driver(dhc_soc_driver);
+
+MODULE_DESCRIPTION("Realtek DHC SoC identification driver");
+MODULE_LICENSE("GPL");
--
2.26.2
Add a DT node for chip identification.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm64/boot/dts/realtek/rtd16xx.dtsi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd16xx.dtsi b/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
index afba5f04c8ec..04cb546142a0 100644
--- a/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd16xx.dtsi
@@ -227,3 +227,10 @@ uart2: serial2@400 {
status = "disabled";
};
};
+
+&sb2 {
+ chip-info@200 {
+ compatible = "realtek,rtd1195-chip";
+ reg = <0x200 0x8>;
+ };
+};
--
2.26.2
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.
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
diff --git a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
new file mode 100644
index 000000000000..86a1de214782
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
@@ -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>;
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index d282ee3492e0..78adbc3cc101 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
--
2.26.2
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]>
---
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(-)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index c4650d512c91..103f564aad7f 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)
--
2.26.2
Chip ID from BPi-M4.
Revisions based on downstream drivers/soc/realtek/rtd139x/rtk_chip.c.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
drivers/soc/realtek/chip.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index 32ed0e4a3646..aa7ca6bb1e64 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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)
--
2.26.2
Add a DT node for chip identification.
Acked-by: James Tai <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
---
v1 -> v2:
* Rebased onto SB2 syscon
arch/arm64/boot/dts/realtek/rtd129x.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
index 93ab6fdd03d4..b5be9df80dae 100644
--- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi
@@ -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>;
--
2.26.2
Add a DT node for eFuse.
Signed-off-by: Andreas Färber <[email protected]>
---
v2: New
arch/arm/boot/dts/rtd1195.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/boot/dts/rtd1195.dtsi b/arch/arm/boot/dts/rtd1195.dtsi
index 5ad0e81c37af..2ae08f6da9e8 100644
--- a/arch/arm/boot/dts/rtd1195.dtsi
+++ b/arch/arm/boot/dts/rtd1195.dtsi
@@ -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>;
--
2.26.2
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]>
---
v2: New
* Split out from Stanley's v1
drivers/soc/realtek/chip.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/soc/realtek/chip.c b/drivers/soc/realtek/chip.c
index ae7c5322f338..6b3d1f3d3816 100644
--- a/drivers/soc/realtek/chip.c
+++ b/drivers/soc/realtek/chip.c
@@ -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 },
{ }
};
--
2.26.2
Allow to optionally specify a phandle to iso syscon to identify the chip.
RTD1295 family will want to check the ISO_CHIP_INFO1 register.
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(+)
diff --git a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
index 86a1de214782..dfe33c95f68d 100644
--- a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
+++ b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
@@ -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>;
+ };
...
--
2.26.2
On 23/06/2020 03:51, Andreas Färber wrote:
> 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]>
> ---
> 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
>
> v2: New
>
> drivers/nvmem/core.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index fc480d636be2..95bed31391cd 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -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.
>
On 23/06/2020 03:51, Andreas Färber wrote:
> 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
On 23/06/2020 03:50, Andreas Färber wrote:
> 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
> 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
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1d0d6ab20451..02117fbf0e57 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index d7b7f6d688e7..75cf43b16cf9 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -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
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index a7c377218341..67cefdfa44e6 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -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
> diff --git a/drivers/nvmem/rtk-dhc-efuse.c b/drivers/nvmem/rtk-dhc-efuse.c
> new file mode 100644
> index 000000000000..4672db2c2619
> --- /dev/null
> +++ b/drivers/nvmem/rtk-dhc-efuse.c
> @@ -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");
>
Hi Srini,
Am 23.06.20 um 11:32 schrieb Srinivas Kandagatla:
> On 23/06/2020 03:50, Andreas Färber wrote:
>> 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...
>> 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
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 1d0d6ab20451..02117fbf0e57 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -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
[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
--
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer
HRB 36809 (AG Nürnberg)
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.
> -----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 RTD1295
>
> Add 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 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(+)
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
>
> Add a DT node for chip identification.
>
> Acked-by: James Tai <[email protected]>
> Signed-off-by: Andreas Färber <[email protected]>
> ---
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
I have reviewed this patch and it is ok.
> -----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
>
> 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]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
> with CHIP_INFO1
>
> This additional register is needed to distinguish RTD1296 from RTD1295.
>
> Signed-off-by: Andreas Färber <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
>
> Add a DT node for chip identification.
>
> Signed-off-by: Andreas Färber <[email protected]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
>
> Add a DT node for chip identification.
>
> Signed-off-by: Andreas Färber <[email protected]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
This patch is ok in my platform.
> -----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
>
> Chip ID from BPi-M4.
> Revisions based on downstream drivers/soc/realtek/rtd139x/rtk_chip.c.
>
> Signed-off-by: Andreas Färber <[email protected]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
I have tested this patch, it is okay
> -----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
>
> 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]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
> -----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
>
> Revisions based on downstream drivers/soc/realtek/rtd16xx/rtk_chip.c.
>
> Signed-off-by: Andreas Färber <[email protected]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
>
> 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]>
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Hi Andreas,
> -----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
>
> From: Stanley Chang <[email protected]>
>
> Distinguish RTD1392 from RTD1395 via ISO_CHIP_INFO1 register.
>
> Signed-off-by: Stanley Chang <[email protected]>
> Signed-off-by: Andreas Färber <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Tested-by: Stanley Chang <[email protected]>
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
Reviewed-by: Stanley Chang <[email protected]>
Thanks,
Stanley
On Tue, 23 Jun 2020 04:50:38 +0200, Andreas F?rber wrote:
> 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.
>
> 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
>
Reviewed-by: Rob Herring <[email protected]>
On Tue, Jun 23, 2020 at 04:50:42AM +0200, Andreas F?rber wrote:
> Allow to optionally specify a phandle to iso syscon to identify the chip.
> RTD1295 family will want to check the ISO_CHIP_INFO1 register.
>
> 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(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
> index 86a1de214782..dfe33c95f68d 100644
> --- a/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
> +++ b/Documentation/devicetree/bindings/soc/realtek/realtek,rtd1195-chip.yaml
> @@ -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
Needs a type $ref (phandle).
> +
> 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>;
> + };
> ...
> --
> 2.26.2
>
On Tue, 23 Jun 2020 04:51:01 +0200, Andreas F?rber wrote:
> Allow to optionally specify nvmem cells to identify the chip.
> RTD1295 family will want the eFuse package_id cell.
>
> 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(+)
>
Reviewed-by: Rob Herring <[email protected]>
On Tue, 23 Jun 2020 04:50:54 +0200, Andreas F?rber wrote:
> 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
>
Reviewed-by: Rob Herring <[email protected]>
On 23/06/2020 03:50, Andreas Färber wrote:
> 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
> ---
> 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
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1d0d6ab20451..02117fbf0e57 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index d7b7f6d688e7..75cf43b16cf9 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -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
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index a7c377218341..67cefdfa44e6 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -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
> diff --git a/drivers/nvmem/rtk-dhc-efuse.c b/drivers/nvmem/rtk-dhc-efuse.c
> new file mode 100644
> index 000000000000..4672db2c2619
> --- /dev/null
> +++ b/drivers/nvmem/rtk-dhc-efuse.c
> @@ -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");
>