From a38d7464ca20e1c0aaa3ed77e03e1ea6af4bc557 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 31 Mar 2021 10:22:30 +0100
Subject: [PATCH] ARM: dts: update bcm2711-rpi-cm4.dts and -400

Neither CM4 nor Pi 400 have appeared upstream yet, and as a result
they have missed out on improvements to the Pi 4B platform.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

ARM: dts: Bring bcm2711-rpi-400.dts up-to-date

Pi 400 support has not appeared upstream yet, and as a result it has
missed out on improvements to the other Pi 4 platforms.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/bcm2711-rpi-400.dts | 17 +++++++
 arch/arm/boot/dts/bcm2711-rpi-cm4.dts | 73 +++++++++++++++++++++------
 2 files changed, 74 insertions(+), 16 deletions(-)

--- a/arch/arm/boot/dts/bcm2711-rpi-400.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-400.dts
@@ -24,6 +24,7 @@
 		emmc2bus = &emmc2bus;
 		ethernet0 = &genet;
 		pcie0 = &pcie0;
+		blconfig = &blconfig;
 	};
 
 	leds {
@@ -215,6 +216,22 @@
 	status = "okay";
 };
 
+&rmem {
+	/*
+	 * RPi4's co-processor will copy the board's bootloader configuration
+	 * into memory for the OS to consume. It'll also update this node with
+	 * its placement information.
+	 */
+	blconfig: nvram@0 {
+		compatible = "raspberrypi,bootloader-config", "nvmem-rmem";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x0 0x0 0x0>;
+		no-map;
+		status = "disabled";
+	};
+};
+
 /* SDHCI is used to control the SDIO for wireless */
 &sdhci {
 	#address-cells = <1>;
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
@@ -3,6 +3,8 @@
 #include "bcm2711.dtsi"
 #include "bcm2835-rpi.dtsi"
 
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
 / {
 	compatible = "raspberrypi,4-compute-module", "brcm,bcm2711";
 	model = "Raspberry Pi Compute Module 4";
@@ -22,6 +24,7 @@
 		emmc2bus = &emmc2bus;
 		ethernet0 = &genet;
 		pcie0 = &pcie0;
+		blconfig = &blconfig;
 	};
 
 	leds {
@@ -76,6 +79,11 @@
 };
 
 &firmware {
+	firmware_clocks: clocks {
+		compatible = "raspberrypi,firmware-clocks";
+		#clock-cells = <1>;
+	};
+
 	expgpio: gpio {
 		compatible = "raspberrypi,firmware-gpio";
 		gpio-controller;
@@ -102,6 +110,11 @@
 			output-low;
 		};
 	};
+
+	reset: reset {
+		compatible = "raspberrypi,firmware-reset";
+		#reset-cells = <1>;
+	};
 };
 
 &gpio {
@@ -209,20 +222,28 @@
 	status = "okay";
 };
 
-&vc4 {
-	status = "okay";
-};
-
-&vec {
-	status = "disabled";
-};
-
 &pwm1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pwm1_0_gpio40 &pwm1_1_gpio41>;
 	status = "okay";
 };
 
+&rmem {
+	/*
+	 * RPi4's co-processor will copy the board's bootloader configuration
+	 * into memory for the OS to consume. It'll also update this node with
+	 * its placement information.
+	 */
+	blconfig: nvram@0 {
+		compatible = "raspberrypi,bootloader-config", "nvmem-rmem";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x0 0x0 0x0>;
+		no-map;
+		status = "disabled";
+	};
+};
+
 /* SDHCI is used to control the SDIO for wireless */
 &sdhci {
 	#address-cells = <1>;
@@ -262,6 +283,21 @@
 	};
 };
 
+&pcie0 {
+	pci@1,0 {
+		#address-cells = <3>;
+		#size-cells = <2>;
+		ranges;
+
+		reg = <0 0 0 0 0>;
+
+		usb@1,0 {
+			reg = <0x10000 0 0 0 0>;
+			resets = <&reset RASPBERRYPI_FIRMWARE_RESET_ID_USB>;
+		};
+	};
+};
+
 /* uart0 communicates with the BT module */
 &uart0 {
 	pinctrl-names = "default";
@@ -287,6 +323,14 @@
 	interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
 };
 
+&vc4 {
+	status = "okay";
+};
+
+&vec {
+	status = "disabled";
+};
+
 // =============================================
 // Downstream rpi- changes
 
@@ -306,6 +350,7 @@
 #include "bcm283x-rpi-csi0-2lane.dtsi"
 #include "bcm283x-rpi-csi1-4lane.dtsi"
 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
+#include "bcm283x-rpi-cam1-regulator.dtsi"
 
 / {
 	chosen {
@@ -331,14 +376,6 @@
 	};
 
 	/delete-node/ wifi-pwrseq;
-
-	cam0_reg: cam1_reg: cam1_reg {
-		compatible = "regulator-fixed";
-		regulator-name = "cam1-reg";
-		gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
-		enable-active-high;
-		status = "disabled";
-	};
 };
 
 &mmcnr {
@@ -589,6 +626,10 @@
 	brcm,disable-headphones = <1>;
 };
 
+cam0_reg: &cam1_reg {
+	gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
+};
+
 / {
 	__overrides__ {
 		act_led_gpio = <&act_led>,"gpios:4";