Skip to contentSkip to conversation

nvmem: sunxi-sid: add SID controller support for H5 and H6

PATCH Superseded Yangtao Li 4 participants 16 messages Feb 17, 2019 – Feb 28, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

cover nvmem: sunxi-sid: add SID controller support for H5 and H6

Add SID controller support for H5 and H6, and do some cleanup without functional changes.

Yangtao Li (5):
nvmem: sunxi-sid: fix wrong description in kernel doc
nvmem: sunxi-sid: add support for H5's SID controller
nvmem: sunxi-sid: add binding for H6's SID controller
nvmem: sunxi-sid: add support for H6's SID controller
nvmem: sunxi-sid: convert to SPDX license tags

 .../bindings/nvmem/allwinner,sunxi-sid.txt    |  3 ++-
 drivers/nvmem/sunxi_sid.c                     | 23 +++++++++++--------
 2 files changed, 15 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.0
author
#1 lore raw

PATCH 1/5 nvmem: sunxi-sid: fix wrong description in kernel doc

qfprom->sunxi-sid

---
 Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt +1 -1
index 99c4ba6a3f61..d37017e343b1 100644
@@ -12,7 +12,7 @@ Required properties:
 - reg: Should contain registers location and length
 
 = Data cells =
-Are child nodes of qfprom, bindings of which as described in
+Are child nodes of sunxi-sid, bindings of which as described in
 bindings/nvmem/nvmem.txt
 
 Example for sun4i:
Signature · 1 line
2.17.0
author
#4 lore raw

PATCH 2/5 nvmem: sunxi-sid: add support for H5's SID controller

In reply to Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +6 -0
index 570a2e354f30..036029e90921 100644
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
 	.size = 0x100,
 };
 
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+	.value_offset = 0x200,
+	.size = 0x100,
+};
+
 static const struct of_device_id sunxi_sid_of_match[] = {
 	{ .compatible = "allwinner,sun4i-a10-sid", .data = &sun4i_a10_cfg },
 	{ .compatible = "allwinner,sun7i-a20-sid", .data = &sun7i_a20_cfg },
 	{ .compatible = "allwinner,sun8i-h3-sid", .data = &sun8i_h3_cfg },
 	{ .compatible = "allwinner,sun50i-a64-sid", .data = &sun50i_a64_cfg },
+	{ .compatible = "allwinner,sun50i-h5-sid", .data = &sun50i_h5_cfg },
 	{/* sentinel */},
 };
 MODULE_DEVICE_TABLE(of, sunxi_sid_of_match);
Signature · 1 line
2.17.0
author
#10 lore raw

PATCH 3/5 nvmem: sunxi-sid: add binding for H6's SID controller

In reply to Yangtao Li

Add a binding for H6's SID controller.

---
 Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt +1 -0
index d37017e343b1..cfb18b4ef8f7 100644
@@ -8,6 +8,7 @@ Required properties:
   "allwinner,sun8i-h3-sid"
   "allwinner,sun50i-a64-sid"
   "allwinner,sun50i-h5-sid"
+  "allwinner,sun50i-h6-sid"
 
 - reg: Should contain registers location and length
 
Signature · 1 line
2.17.0
author
#13 lore raw

PATCH 4/5 nvmem: sunxi-sid: add support for H6's SID controller

In reply to Yangtao Li

Add support for H6's SID controller. It supports 4K-bit EFUSE, bigger than before.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +6 -0
index 036029e90921..8692b58d76ce 100644
@@ -224,12 +224,18 @@ static const struct sunxi_sid_cfg sun50i_h5_cfg = {
 	.size = 0x100,
 };
 
+static const struct sunxi_sid_cfg sun50i_h6_cfg = {
+	.value_offset = 0x200,
+	.size = 0x200,
+};
+
 static const struct of_device_id sunxi_sid_of_match[] = {
 	{ .compatible = "allwinner,sun4i-a10-sid", .data = &sun4i_a10_cfg },
 	{ .compatible = "allwinner,sun7i-a20-sid", .data = &sun7i_a20_cfg },
 	{ .compatible = "allwinner,sun8i-h3-sid", .data = &sun8i_h3_cfg },
 	{ .compatible = "allwinner,sun50i-a64-sid", .data = &sun50i_a64_cfg },
 	{ .compatible = "allwinner,sun50i-h5-sid", .data = &sun50i_h5_cfg },
+	{ .compatible = "allwinner,sun50i-h6-sid", .data = &sun50i_h6_cfg },
 	{/* sentinel */},
 };
 MODULE_DEVICE_TABLE(of, sunxi_sid_of_match);
Signature · 1 line
2.17.0
author
#14 lore raw

PATCH 5/5 nvmem: sunxi-sid: convert to SPDX license tags

In reply to Yangtao Li

Updates license to use SPDX-License-Identifier.

---
 drivers/nvmem/sunxi_sid.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/nvmem/sunxi_sid.c +1 -10
index 8692b58d76ce..f56c9f713cb4 100644
@@ -1,18 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Allwinner sunXi SoCs Security ID support.
  *
  * Copyright (c) 2013 Oliver Schinagl <[email protected]>
  * Copyright (C) 2014 Maxime Ripard <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include <linux/device.h>
Signature · 1 line
2.17.0
#5 lore raw

Re: [PATCH 2/5] nvmem: sunxi-sid: add support for H5's SID controller

In reply to Yangtao Li
Quoted 12 lines · Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +0 -0
index 570a2e354f30..036029e90921 100644

drivers/nvmem/sunxi_sid.c static const struct sunxi_sid_cfg sun50i_a64_cfg = { · line 225

Quoted 7 lines
drivers/nvmem/sunxi_sid.c +4 -0
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
 	.size = 0x100,
 };
 
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+	.value_offset = 0x200,
+	.size = 0x100,
+};

IIRC, there was an endianness issue on the newer SoCs, with the driver converting the data from big endian to little endian, while it's actually stored little endian in the SID.

Have you checked the SID content?

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

Re: [PATCH 2/5] nvmem: sunxi-sid: add support for H5's SID controller

In reply to Maxime Ripard
Quoted 17 lines · Maxime Ripard
Quoted 15 lines · Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +0 -0
index 570a2e354f30..036029e90921 100644
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
      .size = 0x100,
 };
 
Quoted 8 lines

drivers/nvmem/sunxi_sid.c static const struct sunxi_sid_cfg sun50i_a64_cfg = { · line 225

Quoted 4 lines
drivers/nvmem/sunxi_sid.c +4 -0
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+     .value_offset = 0x200,
+     .size = 0x100,
+};

IIRC, there was an endianness issue on the newer SoCs, with the driver converting the data from big endian to little endian, while it's actually stored little endian in the SID.

About that, it seems the internals are either little endian or native (same as the bus). Either way the nvmem the driver currently exposes is wrong.

My idea is to keep the current one with the current name, but have it not associate itself with the DT node. We then register an extra one, called "sunxi-sid-native" which uses the native endian. This one will be associated with the DT node, so the THS driver can consume nvmem cells.

What do you think?

Quoted 1 line

Have you checked the SID content?

On the A64 and H5, directly dumping the SID registers (not using the H3 read method) shows the contents are little or native endian.

ChenYu

#7 lore raw

Re: [PATCH 2/5] nvmem: sunxi-sid: add support for H5's SID controller

Hi,

Quoted 27 lines · Chen-Yu Tsai
Quoted 17 lines · Maxime Ripard
Quoted 15 lines · Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +0 -0
index 570a2e354f30..036029e90921 100644
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
      .size = 0x100,
 };
 
Quoted 8 lines

drivers/nvmem/sunxi_sid.c static const struct sunxi_sid_cfg sun50i_a64_cfg = { · line 225

Quoted 4 lines
drivers/nvmem/sunxi_sid.c +4 -0
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+     .value_offset = 0x200,
+     .size = 0x100,
+};

IIRC, there was an endianness issue on the newer SoCs, with the driver converting the data from big endian to little endian, while it's actually stored little endian in the SID.

Quoted 2 lines

About that, it seems the internals are either little endian or native (same as the bus). Either way the nvmem the driver currently exposes is wrong.

Do you mean that it can be configured either way, or it's little endian and since you are running a little endian system you can't tell?

Quoted 6 lines

My idea is to keep the current one with the current name, but have it not associate itself with the DT node. We then register an extra one, called "sunxi-sid-native" which uses the native endian. This one will be associated with the DT node, so the THS driver can consume nvmem cells.

What do you think?

I thought about this some more, and I don't think anyone really has used the sysfs interface for it. Since the data are in an unusable order (without an additional conversion at least), we would have had a bug report by now (just like we had when someone tried to use it for the thermal calibration).

So maybe the easy way out is just to disable the conversion on the affected SoCs, and see if anyone complains?

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw

Re: [PATCH 2/5] nvmem: sunxi-sid: add support for H5's SID controller

Quoted 31 lines · Maxime Ripard

Hi,

Quoted 27 lines · Chen-Yu Tsai
Quoted 25 lines · Maxime Ripard
Quoted 12 lines · Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +0 -0
index 570a2e354f30..036029e90921 100644

drivers/nvmem/sunxi_sid.c static const struct sunxi_sid_cfg sun50i_a64_cfg = { · line 225

Quoted 7 lines
drivers/nvmem/sunxi_sid.c +4 -0
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
      .size = 0x100,
 };
 
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+     .value_offset = 0x200,
+     .size = 0x100,
+};

IIRC, there was an endianness issue on the newer SoCs, with the driver converting the data from big endian to little endian, while it's actually stored little endian in the SID.

Quoted 6 lines
Quoted 2 lines

About that, it seems the internals are either little endian or native (same as the bus). Either way the nvmem the driver currently exposes is wrong.

Do you mean that it can be configured either way, or it's little endian and since you are running a little endian system you can't tell?

I can't tell. There doesn't seem to be a toggle for endianess though.

Quoted 7 lines
Quoted 6 lines

My idea is to keep the current one with the current name, but have it not associate itself with the DT node. We then register an extra one, called "sunxi-sid-native" which uses the native endian. This one will be associated with the DT node, so the THS driver can consume nvmem cells.

What do you think?

Quoted 8 lines

I thought about this some more, and I don't think anyone really has used the sysfs interface for it. Since the data are in an unusable order (without an additional conversion at least), we would have had a bug report by now (just like we had when someone tried to use it for the thermal calibration).

So maybe the easy way out is just to disable the conversion on the affected SoCs, and see if anyone complains?

That works. And please see my other mail about the DT nvmem cell arrangement.

ChenYu

author
#9 lore raw

Re: [PATCH 2/5] nvmem: sunxi-sid: add support for H5's SID controller

In reply to Maxime Ripard

HI Maxime and ChenYu,

Quoted 26 lines · Maxime Ripard
Quoted 12 lines · Yangtao Li

Add support for H5's SID controller.

---
 drivers/nvmem/sunxi_sid.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvmem/sunxi_sid.c +0 -0
index 570a2e354f30..036029e90921 100644

drivers/nvmem/sunxi_sid.c static const struct sunxi_sid_cfg sun50i_a64_cfg = { · line 225

Quoted 7 lines
drivers/nvmem/sunxi_sid.c +4 -0
@@ -219,11 +219,17 @@ static const struct sunxi_sid_cfg sun50i_a64_cfg = {
      .size = 0x100,
 };
 
+static const struct sunxi_sid_cfg sun50i_h5_cfg = {
+     .value_offset = 0x200,
+     .size = 0x100,
+};

IIRC, there was an endianness issue on the newer SoCs, with the driver converting the data from big endian to little endian, while it's actually stored little endian in the SID.

Quoted 1 line

Have you checked the SID content?

It seems that data by hexdump /sys/bus/nvmem/devices/sunxi_sid/nvmem or by md command in uboot , the data is different in some soc.

Sorry, I replied a bit late.
Any suggestions to solve it?

Yangtao

Quoted 7 lines

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com