linux icon indicating copy to clipboard operation
linux copied to clipboard

nvmem: raspberrypi: Add nvmem driver for reading customer OTP

Open popcornmix opened this issue 1 year ago • 1 comments

This supports reading and writing OTP using the firmware mailbox interface.

It needs supporting firmware to run.

popcornmix avatar Mar 05 '24 18:03 popcornmix

@timg236 updated with:

dtparam=nvmem_customer_writeable

Allow write access to customer otp through nvmem driver (I suspect we will want to change names, and probably where these entries are places in DT files).

popcornmix avatar Mar 06 '24 19:03 popcornmix

@pelwell @timg236 I think this is ready for review.

popcornmix avatar Apr 03 '24 17:04 popcornmix

@pelwell @timg236 I think this is ready for review.

Thanks I’ll try this out tomorrow

timg236 avatar Apr 03 '24 18:04 timg236

I think you can cover all downstream dtbs by putting the changes in bcm2708-rpi.dtsi, bcm2711-rpi-ds.dtsi and bcm2712-rpi.dtsi. If we want to change upstream as well, move them to bcm2835-common.dtsi and bcm2711-rpi.dtsi.

pelwell avatar Apr 05 '24 10:04 pelwell

I also notice that the 2712 nvmem entries are in /soc, whereas the others are in /.

pelwell avatar Apr 05 '24 11:04 pelwell

See https://github.com/pelwell/linux/tree/nvmem - the output is identical. Also consider moving the 2712 nvmem nodes to /

pelwell avatar Apr 05 '24 11:04 pelwell

Updated.

popcornmix avatar Apr 05 '24 11:04 popcornmix

diff --git a/arch/arm/boot/dts/broadcom/bcm2708-rpi.dtsi b/arch/arm/boot/dts/broadcom/bcm2708-rpi.dtsi
index 4302f55f57b4d..f4949a07272b6 100644
--- a/arch/arm/boot/dts/broadcom/bcm2708-rpi.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2708-rpi.dtsi
@@ -15,6 +15,17 @@ aliases {
                i2c2 = &i2c2;
        };
 
+       __overrides__ {
+               hdmi = <&hdmi>,"status";
+               i2c2_iknowwhatimdoing = <&i2c2>,"status";
+               i2c2_baudrate = <&i2c2>,"clock-frequency:0";
+               nvmem_cust_rw = <&nvmem_cust>,"rw?";
+               sd = <&sdhost>,"status";
+               sd_poll_once = <&sdhost>,"non-removable?";
+       };
+};
+
+&soc {
        nvmem_otp: nvmem_otp {
                compatible = "raspberrypi,rpi-otp";
                firmware = <&firmware>;
@@ -28,15 +39,6 @@ nvmem_cust: nvmem_cust {
                reg = <1 8>;
                status = "okay";
        };
-
-       __overrides__ {
-               hdmi = <&hdmi>,"status";
-               i2c2_iknowwhatimdoing = <&i2c2>,"status";
-               i2c2_baudrate = <&i2c2>,"clock-frequency:0";
-               nvmem_cust_rw = <&nvmem_cust>,"rw?";
-               sd = <&sdhost>,"status";
-               sd_poll_once = <&sdhost>,"non-removable?";
-       };
 };
 
 &sdhost {
diff --git a/arch/arm/boot/dts/broadcom/bcm2711-rpi-ds.dtsi b/arch/arm/boot/dts/broadcom/bcm2711-rpi-ds.dtsi
index daa3b5dfa0bf3..b298cd8bb71ce 100644
--- a/arch/arm/boot/dts/broadcom/bcm2711-rpi-ds.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2711-rpi-ds.dtsi
@@ -75,6 +75,21 @@ zone_dma {
                #size-cells = <1>;
                dma-ranges = <0x0  0x0 0x0  0x40000000>;
        };
+};
+
+&vc4 {
+       raspberrypi,firmware = <&firmware>;
+};
+
+&cma {
+       /* Limit cma to the lower 768MB to allow room for HIGHMEM on 32-bit */
+       alloc-ranges = <0x0 0x00000000 0x30000000>;
+};
+
+&soc {
+       /* Add the physical <-> DMA mapping for the I/O space */
+       dma-ranges = <0xc0000000  0x0 0x00000000  0x40000000>,
+                    <0x7c000000  0x0 0xfc000000  0x03800000>;
 
        nvmem_otp: nvmem_otp {
                compatible = "raspberrypi,rpi-otp";
@@ -98,21 +113,6 @@ nvmem_priv: nvmem_priv {
        };
 };
 
-&vc4 {
-       raspberrypi,firmware = <&firmware>;
-};
-
-&cma {
-       /* Limit cma to the lower 768MB to allow room for HIGHMEM on 32-bit */
-       alloc-ranges = <0x0 0x00000000 0x30000000>;
-};
-
-&soc {
-       /* Add the physical <-> DMA mapping for the I/O space */
-       dma-ranges = <0xc0000000  0x0 0x00000000  0x40000000>,
-                    <0x7c000000  0x0 0xfc000000  0x03800000>;
-};
-
 &scb {
        #size-cells = <2>;
 

pelwell avatar Apr 05 '24 11:04 pelwell

Updated

popcornmix avatar Apr 05 '24 12:04 popcornmix