All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] nvmem: Enable OTP access for Raspberry Pi
@ 2018-11-21 13:11 ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

The VC4 firmware exposes a mailbox interface that allows the ARM core
to access only the customer part (8 cells * 32 bits) of the OTP memory.
This version brings read-only support, but could also be extended to
write support. Beside the kernelspace support this is also a limited userspace
alternative to the vendor specific "vcgencmd otp_dump".

I think this driver could be helpful for vendors, which integrate the
Raspberry Pi Compute Module in their products need to store unique data
like a serial or additional MAC address in the OTP.

Note for testers: This series needs "firmware: raspberrypi: Fix firmware calls
with large buffers" from James Hughes to work properly.

Changes since RFC:
- implement improvements suggested by Rob Herring and Eric Anholt
- extend Kconfig description
- define nvmem type and read only
- make MODULE_LICENSE match license text
- add patches to enable driver in bcm2835 and multi_v7 defconfig
- rebased on current srini/nvmem.git/for-next

Stefan Wahren (5):
  dt-bindings: nvmem: add binding for Raspberry Pi OTP
  nvmem: add driver for Raspberry Pi OTP
  ARM: dts: bcm2835-rpi: Enable OTP access for Raspberry Pi
  ARM: bcm2835_defconfig: Enable Raspberry Pi OTP driver
  ARM: multi_v7_defconfig: Enable Raspberry Pi OTP driver

 .../nvmem/raspberrypi,bcm2835-customer-otp.txt     |  22 ++++
 arch/arm/boot/dts/bcm2835-rpi.dtsi                 |   4 +
 arch/arm/configs/bcm2835_defconfig                 |   2 +
 arch/arm/configs/multi_v7_defconfig                |   1 +
 drivers/nvmem/Kconfig                              |  10 ++
 drivers/nvmem/Makefile                             |   2 +
 drivers/nvmem/raspberrypi-otp.c                    | 113 +++++++++++++++++++++
 7 files changed, 154 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
 create mode 100644 drivers/nvmem/raspberrypi-otp.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 0/5] nvmem: Enable OTP access for Raspberry Pi
@ 2018-11-21 13:11 ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

The VC4 firmware exposes a mailbox interface that allows the ARM core
to access only the customer part (8 cells * 32 bits) of the OTP memory.
This version brings read-only support, but could also be extended to
write support. Beside the kernelspace support this is also a limited userspace
alternative to the vendor specific "vcgencmd otp_dump".

I think this driver could be helpful for vendors, which integrate the
Raspberry Pi Compute Module in their products need to store unique data
like a serial or additional MAC address in the OTP.

Note for testers: This series needs "firmware: raspberrypi: Fix firmware calls
with large buffers" from James Hughes to work properly.

Changes since RFC:
- implement improvements suggested by Rob Herring and Eric Anholt
- extend Kconfig description
- define nvmem type and read only
- make MODULE_LICENSE match license text
- add patches to enable driver in bcm2835 and multi_v7 defconfig
- rebased on current srini/nvmem.git/for-next

Stefan Wahren (5):
  dt-bindings: nvmem: add binding for Raspberry Pi OTP
  nvmem: add driver for Raspberry Pi OTP
  ARM: dts: bcm2835-rpi: Enable OTP access for Raspberry Pi
  ARM: bcm2835_defconfig: Enable Raspberry Pi OTP driver
  ARM: multi_v7_defconfig: Enable Raspberry Pi OTP driver

 .../nvmem/raspberrypi,bcm2835-customer-otp.txt     |  22 ++++
 arch/arm/boot/dts/bcm2835-rpi.dtsi                 |   4 +
 arch/arm/configs/bcm2835_defconfig                 |   2 +
 arch/arm/configs/multi_v7_defconfig                |   1 +
 drivers/nvmem/Kconfig                              |  10 ++
 drivers/nvmem/Makefile                             |   2 +
 drivers/nvmem/raspberrypi-otp.c                    | 113 +++++++++++++++++++++
 7 files changed, 154 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
 create mode 100644 drivers/nvmem/raspberrypi-otp.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
  2018-11-21 13:11 ` Stefan Wahren
@ 2018-11-21 13:11   ` Stefan Wahren
  -1 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

This patch adds the devicetree binding for Raspberry Pi customer OTP
driver.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt

diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
new file mode 100644
index 0000000..041ff17
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
@@ -0,0 +1,22 @@
+Customer OTP Memory for Raspberry Pi
+
+The VC4 firmware exposes a mailbox interface that allows the ARM core
+to access the customer part of the OTP memory.
+
+The OTP node must be a child node of the Raspberry Pi firmware node.
+
+Required properties :
+- compatible     : Should be "raspberrypi,bcm2835-customer-otp"
+
+See nvmem.txt for more information.
+
+Example:
+
+firmware: firmware-rpi {
+	compatible = "raspberrypi,bcm2835-firmware";
+	mboxes = <&mailbox>;
+
+	customer_otp: otp {
+		compatible = "raspberrypi,bcm2835-customer-otp";
+	};
+};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
@ 2018-11-21 13:11   ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds the devicetree binding for Raspberry Pi customer OTP
driver.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt

diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
new file mode 100644
index 0000000..041ff17
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
@@ -0,0 +1,22 @@
+Customer OTP Memory for Raspberry Pi
+
+The VC4 firmware exposes a mailbox interface that allows the ARM core
+to access the customer part of the OTP memory.
+
+The OTP node must be a child node of the Raspberry Pi firmware node.
+
+Required properties :
+- compatible     : Should be "raspberrypi,bcm2835-customer-otp"
+
+See nvmem.txt for more information.
+
+Example:
+
+firmware: firmware-rpi {
+	compatible = "raspberrypi,bcm2835-firmware";
+	mboxes = <&mailbox>;
+
+	customer_otp: otp {
+		compatible = "raspberrypi,bcm2835-customer-otp";
+	};
+};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/5] nvmem: add driver for Raspberry Pi OTP
  2018-11-21 13:11 ` Stefan Wahren
@ 2018-11-21 13:11   ` Stefan Wahren
  -1 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

This patch brings read-only support for the Raspberry Pi Customer OTP,
which consists of 8 cells a 32 bits. The driver accesses the OTP via
the mailbox property interface provided by the VPU firmware.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
---
 drivers/nvmem/Kconfig           |  10 ++++
 drivers/nvmem/Makefile          |   2 +
 drivers/nvmem/raspberrypi-otp.c | 113 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/nvmem/raspberrypi-otp.c

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 0a7a470e..12106fe 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -192,4 +192,14 @@ config SC27XX_EFUSE
 	  This driver can also be built as a module. If so, the module
 	  will be called nvmem-sc27xx-efuse.
 
+config NVMEM_RASPBERRYPI_OTP
+	tristate "Raspberry Pi Customer OTP support"
+	depends on (ARCH_BCM2835 && RASPBERRYPI_FIRMWARE) || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
+	help
+	  This is a driver for access to the Customer OTP block
+	  (8 cells * 32 bits) on the Raspberry Pi.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called nvmem-raspberrypi-otp.
+
 endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 4e8c616..dd043bd 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -41,3 +41,5 @@ obj-$(CONFIG_RAVE_SP_EEPROM)	+= nvmem-rave-sp-eeprom.o
 nvmem-rave-sp-eeprom-y		:= rave-sp-eeprom.o
 obj-$(CONFIG_SC27XX_EFUSE)	+= nvmem-sc27xx-efuse.o
 nvmem-sc27xx-efuse-y		:= sc27xx-efuse.o
+obj-$(CONFIG_NVMEM_RASPBERRYPI_OTP)	+= nvmem-raspberrypi-otp.o
+nvmem-raspberrypi-otp-y		:= raspberrypi-otp.o
diff --git a/drivers/nvmem/raspberrypi-otp.c b/drivers/nvmem/raspberrypi-otp.c
new file mode 100644
index 0000000..af6b228
--- /dev/null
+++ b/drivers/nvmem/raspberrypi-otp.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Raspberry Pi Customer OTP driver
+ *
+ * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com>
+ */
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+#define CUSTOMER_CELLS 8
+
+struct rpi_otp {
+	struct nvmem_device *nvmem;
+	struct rpi_firmware *fw;
+};
+
+/*
+ * Packet definition used by RPI_FIRMWARE_GET_CUSTOMER_OTP
+ */
+struct rpi_customer_otp_packet {
+	u32 index;
+	u32 length;
+	u8 cells[CUSTOMER_CELLS * 4];
+};
+
+static int rpi_otp_read(void *context, unsigned int offset, void *val,
+			size_t bytes)
+{
+	struct rpi_customer_otp_packet packet;
+	struct rpi_otp *otp = context;
+	int ret;
+
+	packet.index = 0;
+	packet.length = CUSTOMER_CELLS;
+	memset(packet.cells, 0xff, sizeof(packet.cells));
+
+	ret = rpi_firmware_property(otp->fw, RPI_FIRMWARE_GET_CUSTOMER_OTP,
+				    &packet, sizeof(packet));
+
+	if (ret)
+		return ret;
+
+	/* Request rejected by firmware */
+	if (packet.index)
+		return -EIO;
+
+	memcpy(val, &packet.cells[offset], bytes);
+
+	return 0;
+}
+
+static struct nvmem_config ocotp_config = {
+	.name = "rpi-customer-otp",
+	.read_only = true,
+	.type = NVMEM_TYPE_OTP,
+	.size = CUSTOMER_CELLS * 4,
+	.stride = 4,
+	.word_size = 4,
+	.reg_read = rpi_otp_read,
+};
+
+static int rpi_otp_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *fw_node;
+	struct rpi_otp *otp;
+
+	otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
+	if (!otp)
+		return -ENOMEM;
+
+	fw_node = of_get_parent(dev->of_node);
+	if (!fw_node) {
+		dev_err(dev, "Missing firmware node\n");
+		return -ENOENT;
+	}
+
+	otp->fw = rpi_firmware_get(fw_node);
+	of_node_put(fw_node);
+	if (!otp->fw)
+		return -EPROBE_DEFER;
+
+	ocotp_config.priv = otp;
+	ocotp_config.dev = dev;
+	otp->nvmem = devm_nvmem_register(dev, &ocotp_config);
+
+	return PTR_ERR_OR_ZERO(otp->nvmem);
+}
+
+static const struct of_device_id rpi_otp_of_match[] = {
+	{ .compatible = "raspberrypi,bcm2835-customer-otp", },
+	{ /* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, rpi_otp_of_match);
+
+static struct platform_driver rpi_otp_driver = {
+	.probe = rpi_otp_probe,
+	.driver = {
+		.name = "rpi-customer-otp",
+		.of_match_table = rpi_otp_of_match,
+	},
+};
+module_platform_driver(rpi_otp_driver);
+
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_DESCRIPTION("Raspberry Pi Customer OTP driver");
+MODULE_LICENSE("GPL");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/5] nvmem: add driver for Raspberry Pi OTP
@ 2018-11-21 13:11   ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch brings read-only support for the Raspberry Pi Customer OTP,
which consists of 8 cells a 32 bits. The driver accesses the OTP via
the mailbox property interface provided by the VPU firmware.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
---
 drivers/nvmem/Kconfig           |  10 ++++
 drivers/nvmem/Makefile          |   2 +
 drivers/nvmem/raspberrypi-otp.c | 113 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/nvmem/raspberrypi-otp.c

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 0a7a470e..12106fe 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -192,4 +192,14 @@ config SC27XX_EFUSE
 	  This driver can also be built as a module. If so, the module
 	  will be called nvmem-sc27xx-efuse.
 
+config NVMEM_RASPBERRYPI_OTP
+	tristate "Raspberry Pi Customer OTP support"
+	depends on (ARCH_BCM2835 && RASPBERRYPI_FIRMWARE) || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
+	help
+	  This is a driver for access to the Customer OTP block
+	  (8 cells * 32 bits) on the Raspberry Pi.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called nvmem-raspberrypi-otp.
+
 endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 4e8c616..dd043bd 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -41,3 +41,5 @@ obj-$(CONFIG_RAVE_SP_EEPROM)	+= nvmem-rave-sp-eeprom.o
 nvmem-rave-sp-eeprom-y		:= rave-sp-eeprom.o
 obj-$(CONFIG_SC27XX_EFUSE)	+= nvmem-sc27xx-efuse.o
 nvmem-sc27xx-efuse-y		:= sc27xx-efuse.o
+obj-$(CONFIG_NVMEM_RASPBERRYPI_OTP)	+= nvmem-raspberrypi-otp.o
+nvmem-raspberrypi-otp-y		:= raspberrypi-otp.o
diff --git a/drivers/nvmem/raspberrypi-otp.c b/drivers/nvmem/raspberrypi-otp.c
new file mode 100644
index 0000000..af6b228
--- /dev/null
+++ b/drivers/nvmem/raspberrypi-otp.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Raspberry Pi Customer OTP driver
+ *
+ * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com>
+ */
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <soc/bcm2835/raspberrypi-firmware.h>
+
+#define CUSTOMER_CELLS 8
+
+struct rpi_otp {
+	struct nvmem_device *nvmem;
+	struct rpi_firmware *fw;
+};
+
+/*
+ * Packet definition used by RPI_FIRMWARE_GET_CUSTOMER_OTP
+ */
+struct rpi_customer_otp_packet {
+	u32 index;
+	u32 length;
+	u8 cells[CUSTOMER_CELLS * 4];
+};
+
+static int rpi_otp_read(void *context, unsigned int offset, void *val,
+			size_t bytes)
+{
+	struct rpi_customer_otp_packet packet;
+	struct rpi_otp *otp = context;
+	int ret;
+
+	packet.index = 0;
+	packet.length = CUSTOMER_CELLS;
+	memset(packet.cells, 0xff, sizeof(packet.cells));
+
+	ret = rpi_firmware_property(otp->fw, RPI_FIRMWARE_GET_CUSTOMER_OTP,
+				    &packet, sizeof(packet));
+
+	if (ret)
+		return ret;
+
+	/* Request rejected by firmware */
+	if (packet.index)
+		return -EIO;
+
+	memcpy(val, &packet.cells[offset], bytes);
+
+	return 0;
+}
+
+static struct nvmem_config ocotp_config = {
+	.name = "rpi-customer-otp",
+	.read_only = true,
+	.type = NVMEM_TYPE_OTP,
+	.size = CUSTOMER_CELLS * 4,
+	.stride = 4,
+	.word_size = 4,
+	.reg_read = rpi_otp_read,
+};
+
+static int rpi_otp_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *fw_node;
+	struct rpi_otp *otp;
+
+	otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
+	if (!otp)
+		return -ENOMEM;
+
+	fw_node = of_get_parent(dev->of_node);
+	if (!fw_node) {
+		dev_err(dev, "Missing firmware node\n");
+		return -ENOENT;
+	}
+
+	otp->fw = rpi_firmware_get(fw_node);
+	of_node_put(fw_node);
+	if (!otp->fw)
+		return -EPROBE_DEFER;
+
+	ocotp_config.priv = otp;
+	ocotp_config.dev = dev;
+	otp->nvmem = devm_nvmem_register(dev, &ocotp_config);
+
+	return PTR_ERR_OR_ZERO(otp->nvmem);
+}
+
+static const struct of_device_id rpi_otp_of_match[] = {
+	{ .compatible = "raspberrypi,bcm2835-customer-otp", },
+	{ /* sentinel */},
+};
+MODULE_DEVICE_TABLE(of, rpi_otp_of_match);
+
+static struct platform_driver rpi_otp_driver = {
+	.probe = rpi_otp_probe,
+	.driver = {
+		.name = "rpi-customer-otp",
+		.of_match_table = rpi_otp_of_match,
+	},
+};
+module_platform_driver(rpi_otp_driver);
+
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_DESCRIPTION("Raspberry Pi Customer OTP driver");
+MODULE_LICENSE("GPL");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/5] ARM: dts: bcm2835-rpi: Enable OTP access for Raspberry Pi
  2018-11-21 13:11 ` Stefan Wahren
@ 2018-11-21 13:11   ` Stefan Wahren
  -1 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

This patch enables OTP access for all Raspberry Pi variants.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index cb2d6d7..0fcd9da 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -22,6 +22,10 @@
 			#address-cells = <0>;
 			#size-cells = <0>;
 			mboxes = <&mailbox>;
+
+			customer_otp: otp {
+				compatible = "raspberrypi,bcm2835-customer-otp";
+			};
 		};
 
 		power: power {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/5] ARM: dts: bcm2835-rpi: Enable OTP access for Raspberry Pi
@ 2018-11-21 13:11   ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

This patch enables OTP access for all Raspberry Pi variants.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index cb2d6d7..0fcd9da 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -22,6 +22,10 @@
 			#address-cells = <0>;
 			#size-cells = <0>;
 			mboxes = <&mailbox>;
+
+			customer_otp: otp {
+				compatible = "raspberrypi,bcm2835-customer-otp";
+			};
 		};
 
 		power: power {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/5] ARM: bcm2835_defconfig: Enable Raspberry Pi OTP driver
  2018-11-21 13:11 ` Stefan Wahren
@ 2018-11-21 13:11   ` Stefan Wahren
  -1 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

Enable the Raspberry Pi OTP driver, which could be helpful for
custom Compute Module designs.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/configs/bcm2835_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/bcm2835_defconfig b/arch/arm/configs/bcm2835_defconfig
index bb6a35f..4c1405e 100644
--- a/arch/arm/configs/bcm2835_defconfig
+++ b/arch/arm/configs/bcm2835_defconfig
@@ -136,6 +136,8 @@ CONFIG_RASPBERRYPI_POWER=y
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=y
 CONFIG_RASPBERRYPI_FIRMWARE=y
+CONFIG_NVMEM=y
+CONFIG_NVMEM_RASPBERRYPI_OTP=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT2_FS_POSIX_ACL=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/5] ARM: bcm2835_defconfig: Enable Raspberry Pi OTP driver
@ 2018-11-21 13:11   ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

Enable the Raspberry Pi OTP driver, which could be helpful for
custom Compute Module designs.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/configs/bcm2835_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/bcm2835_defconfig b/arch/arm/configs/bcm2835_defconfig
index bb6a35f..4c1405e 100644
--- a/arch/arm/configs/bcm2835_defconfig
+++ b/arch/arm/configs/bcm2835_defconfig
@@ -136,6 +136,8 @@ CONFIG_RASPBERRYPI_POWER=y
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=y
 CONFIG_RASPBERRYPI_FIRMWARE=y
+CONFIG_NVMEM=y
+CONFIG_NVMEM_RASPBERRYPI_OTP=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT2_FS_POSIX_ACL=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/5] ARM: multi_v7_defconfig: Enable Raspberry Pi OTP driver
  2018-11-21 13:11 ` Stefan Wahren
@ 2018-11-21 13:11   ` Stefan Wahren
  -1 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Mark Rutland, Florian Fainelli,
	Ray Jui, Scott Branden, Eric Anholt, Arnd Bergmann, gregkh
  Cc: Stefan Wahren, devicetree, bcm-kernel-feedback-list,
	linux-rpi-kernel, linux-arm-kernel

Enable the Raspberry Pi OTP driver, which could be helpful for
custom Compute Module 3 designs.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 1c76168..9b7ba43 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -964,6 +964,7 @@ CONFIG_NVMEM_IMX_OCOTP=y
 CONFIG_NVMEM_SUNXI_SID=y
 CONFIG_NVMEM_VF610_OCOTP=y
 CONFIG_RASPBERRYPI_FIRMWARE=y
+CONFIG_NVMEM_RASPBERRYPI_OTP=y
 CONFIG_BCM47XX_NVRAM=y
 CONFIG_BCM47XX_SPROM=y
 CONFIG_EFI_VARS=m
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/5] ARM: multi_v7_defconfig: Enable Raspberry Pi OTP driver
@ 2018-11-21 13:11   ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-11-21 13:11 UTC (permalink / raw)
  To: linux-arm-kernel

Enable the Raspberry Pi OTP driver, which could be helpful for
custom Compute Module 3 designs.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 1c76168..9b7ba43 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -964,6 +964,7 @@ CONFIG_NVMEM_IMX_OCOTP=y
 CONFIG_NVMEM_SUNXI_SID=y
 CONFIG_NVMEM_VF610_OCOTP=y
 CONFIG_RASPBERRYPI_FIRMWARE=y
+CONFIG_NVMEM_RASPBERRYPI_OTP=y
 CONFIG_BCM47XX_NVRAM=y
 CONFIG_BCM47XX_SPROM=y
 CONFIG_EFI_VARS=m
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
  2018-11-21 13:11   ` Stefan Wahren
@ 2018-12-06 23:49     ` Rob Herring
  -1 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2018-12-06 23:49 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, devicetree, Florian Fainelli, Arnd Bergmann,
	Scott Branden, Ray Jui, Eric Anholt, Srinivas Kandagatla,
	linux-rpi-kernel, gregkh, bcm-kernel-feedback-list,
	linux-arm-kernel

On Wed, Nov 21, 2018 at 02:11:40PM +0100, Stefan Wahren wrote:
> This patch adds the devicetree binding for Raspberry Pi customer OTP
> driver.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> 
> diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> new file mode 100644
> index 0000000..041ff17
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> @@ -0,0 +1,22 @@
> +Customer OTP Memory for Raspberry Pi
> +
> +The VC4 firmware exposes a mailbox interface that allows the ARM core
> +to access the customer part of the OTP memory.
> +
> +The OTP node must be a child node of the Raspberry Pi firmware node.
> +
> +Required properties :
> +- compatible     : Should be "raspberrypi,bcm2835-customer-otp"

Why do we need this child node? Can't the parent instantiate this?

Are there OTP fields you want to expose in DT?

> +
> +See nvmem.txt for more information.
> +
> +Example:
> +
> +firmware: firmware-rpi {
> +	compatible = "raspberrypi,bcm2835-firmware";
> +	mboxes = <&mailbox>;
> +
> +	customer_otp: otp {
> +		compatible = "raspberrypi,bcm2835-customer-otp";
> +	};
> +};
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
@ 2018-12-06 23:49     ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2018-12-06 23:49 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, devicetree, Florian Fainelli, Arnd Bergmann,
	Scott Branden, Ray Jui, Eric Anholt, Srinivas Kandagatla,
	linux-rpi-kernel, gregkh, bcm-kernel-feedback-list,
	linux-arm-kernel

On Wed, Nov 21, 2018 at 02:11:40PM +0100, Stefan Wahren wrote:
> This patch adds the devicetree binding for Raspberry Pi customer OTP
> driver.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> 
> diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> new file mode 100644
> index 0000000..041ff17
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> @@ -0,0 +1,22 @@
> +Customer OTP Memory for Raspberry Pi
> +
> +The VC4 firmware exposes a mailbox interface that allows the ARM core
> +to access the customer part of the OTP memory.
> +
> +The OTP node must be a child node of the Raspberry Pi firmware node.
> +
> +Required properties :
> +- compatible     : Should be "raspberrypi,bcm2835-customer-otp"

Why do we need this child node? Can't the parent instantiate this?

Are there OTP fields you want to expose in DT?

> +
> +See nvmem.txt for more information.
> +
> +Example:
> +
> +firmware: firmware-rpi {
> +	compatible = "raspberrypi,bcm2835-firmware";
> +	mboxes = <&mailbox>;
> +
> +	customer_otp: otp {
> +		compatible = "raspberrypi,bcm2835-customer-otp";
> +	};
> +};
> -- 
> 2.7.4
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
  2018-12-06 23:49     ` Rob Herring
  (?)
@ 2018-12-07  8:10     ` Stefan Wahren
  2018-12-28 15:46       ` Stefan Wahren
  -1 siblings, 1 reply; 16+ messages in thread
From: Stefan Wahren @ 2018-12-07  8:10 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Florian Fainelli, Arnd Bergmann,
	Scott Branden, Ray Jui, Eric Anholt, Srinivas Kandagatla,
	linux-rpi-kernel, gregkh, bcm-kernel-feedback-list,
	linux-arm-kernel

Hi Rob,

Am 07.12.18 um 00:49 schrieb Rob Herring:
> On Wed, Nov 21, 2018 at 02:11:40PM +0100, Stefan Wahren wrote:
>> This patch adds the devicetree binding for Raspberry Pi customer OTP
>> driver.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>  .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
>>
>> diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
>> new file mode 100644
>> index 0000000..041ff17
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
>> @@ -0,0 +1,22 @@
>> +Customer OTP Memory for Raspberry Pi
>> +
>> +The VC4 firmware exposes a mailbox interface that allows the ARM core
>> +to access the customer part of the OTP memory.
>> +
>> +The OTP node must be a child node of the Raspberry Pi firmware node.
>> +
>> +Required properties :
>> +- compatible     : Should be "raspberrypi,bcm2835-customer-otp"
> Why do we need this child node? Can't the parent instantiate this?
>
> Are there OTP fields you want to expose in DT?

the customer part of the OTP is reserved (initialized with zero) for
user who wants to use the Raspberry Pi (mostly the Compute Module) in
their custom designs. So i cannot provide any nvmem cells yet because it
is up to the user to define them (e.g. hardware related values like
serial numbers, MAC addresses for additional network interfaces or
calibration values). But yes i consider the binding and the ability to
define nvmem cells via devicetree as a great feature.

Currently the Foundation suggests to use the mailbox interface from
userspace [1], but i prefer a more common way like nvmem.

[1] - 
https://www.raspberrypi.org/documentation/hardware/industrial/README.md


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP
  2018-12-07  8:10     ` Stefan Wahren
@ 2018-12-28 15:46       ` Stefan Wahren
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Wahren @ 2018-12-28 15:46 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Florian Fainelli, Arnd Bergmann,
	Scott Branden, Ray Jui, Eric Anholt, Srinivas Kandagatla,
	linux-rpi-kernel, gregkh, bcm-kernel-feedback-list,
	linux-arm-kernel

Hi Rob,

> Stefan Wahren <stefan.wahren@i2se.com> hat am 7. Dezember 2018 um 09:10 geschrieben:
> 
> 
> Hi Rob,
> 
> Am 07.12.18 um 00:49 schrieb Rob Herring:
> > On Wed, Nov 21, 2018 at 02:11:40PM +0100, Stefan Wahren wrote:
> >> This patch adds the devicetree binding for Raspberry Pi customer OTP
> >> driver.
> >>
> >> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >> ---
> >>  .../nvmem/raspberrypi,bcm2835-customer-otp.txt     | 22 ++++++++++++++++++++++
> >>  1 file changed, 22 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> >> new file mode 100644
> >> index 0000000..041ff17
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/nvmem/raspberrypi,bcm2835-customer-otp.txt
> >> @@ -0,0 +1,22 @@
> >> +Customer OTP Memory for Raspberry Pi
> >> +
> >> +The VC4 firmware exposes a mailbox interface that allows the ARM core
> >> +to access the customer part of the OTP memory.
> >> +
> >> +The OTP node must be a child node of the Raspberry Pi firmware node.
> >> +
> >> +Required properties :
> >> +- compatible     : Should be "raspberrypi,bcm2835-customer-otp"
> > Why do we need this child node? Can't the parent instantiate this?
> >
> > Are there OTP fields you want to expose in DT?
> 
> the customer part of the OTP is reserved (initialized with zero) for
> user who wants to use the Raspberry Pi (mostly the Compute Module) in
> their custom designs. So i cannot provide any nvmem cells yet because it
> is up to the user to define them (e.g. hardware related values like
> serial numbers, MAC addresses for additional network interfaces or
> calibration values). But yes i consider the binding and the ability to
> define nvmem cells via devicetree as a great feature.
> 
> Currently the Foundation suggests to use the mailbox interface from
> userspace [1], but i prefer a more common way like nvmem.
> 
> [1] - 
> https://www.raspberrypi.org/documentation/hardware/industrial/README.md
>

did it answer your questions?

Stefan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-12-28 15:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-21 13:11 [PATCH 0/5] nvmem: Enable OTP access for Raspberry Pi Stefan Wahren
2018-11-21 13:11 ` Stefan Wahren
2018-11-21 13:11 ` [PATCH 1/5] dt-bindings: nvmem: add binding for Raspberry Pi OTP Stefan Wahren
2018-11-21 13:11   ` Stefan Wahren
2018-12-06 23:49   ` Rob Herring
2018-12-06 23:49     ` Rob Herring
2018-12-07  8:10     ` Stefan Wahren
2018-12-28 15:46       ` Stefan Wahren
2018-11-21 13:11 ` [PATCH 2/5] nvmem: add driver " Stefan Wahren
2018-11-21 13:11   ` Stefan Wahren
2018-11-21 13:11 ` [PATCH 3/5] ARM: dts: bcm2835-rpi: Enable OTP access for Raspberry Pi Stefan Wahren
2018-11-21 13:11   ` Stefan Wahren
2018-11-21 13:11 ` [PATCH 4/5] ARM: bcm2835_defconfig: Enable Raspberry Pi OTP driver Stefan Wahren
2018-11-21 13:11   ` Stefan Wahren
2018-11-21 13:11 ` [PATCH 5/5] ARM: multi_v7_defconfig: " Stefan Wahren
2018-11-21 13:11   ` Stefan Wahren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.