From d27f2b90df0b787859c2f5665feaecbe87e6b1ff Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Tue, 4 Jun 2019 16:22:22 +0100
Subject: [PATCH] arm: dts: Improve the bcm27xx inclusion hierarchy

1) The top-level .dts files now include parallel chains of bcm27xx.dtsi
   and bcm27xx-rpi.dtsi files, with no cross-inclusion between the two
   chains.

2) Move definitions and deletions to the point of maximum commonality
   to reduce redundancy.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
 arch/arm/boot/dts/bcm2708-rpi-b-plus.dts   |  1 +
 arch/arm/boot/dts/bcm2708-rpi-b.dts        |  1 +
 arch/arm/boot/dts/bcm2708-rpi-cm.dtsi      |  1 +
 arch/arm/boot/dts/bcm2708-rpi-zero-w.dts   |  1 +
 arch/arm/boot/dts/bcm2708-rpi-zero.dts     |  1 +
 arch/arm/boot/dts/bcm2708-rpi.dtsi         | 63 +++++++---------------
 arch/arm/boot/dts/bcm2708.dtsi             |  1 -
 arch/arm/boot/dts/bcm2709-rpi-2-b.dts      |  1 +
 arch/arm/boot/dts/bcm2709.dtsi             |  1 -
 arch/arm/boot/dts/bcm270x.dtsi             | 18 +------
 arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts |  1 +
 arch/arm/boot/dts/bcm2710-rpi-3-b.dts      |  1 +
 arch/arm/boot/dts/bcm2710-rpi-cm3.dts      |  1 +
 arch/arm/boot/dts/bcm2710.dtsi             |  1 -
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts      | 15 ++++--
 arch/arm/boot/dts/bcm2711-rpi.dtsi         |  7 +++
 arch/arm/boot/dts/bcm2711.dtsi             | 10 ----
 arch/arm/boot/dts/bcm2835-rpi.dtsi         | 16 ++++++
 arch/arm/boot/dts/bcm2838.dtsi             | 33 ++++++++----
 arch/arm/boot/dts/bcm283x.dtsi             |  2 +-
 20 files changed, 86 insertions(+), 90 deletions(-)
 create mode 100644 arch/arm/boot/dts/bcm2711-rpi.dtsi

--- a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2708.dtsi"
+#include "bcm2708-rpi.dtsi"
 #include "bcm283x-rpi-smsc9514.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2708.dtsi"
+#include "bcm2708-rpi.dtsi"
 #include "bcm283x-rpi-smsc9512.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2708-rpi-cm.dtsi
+++ b/arch/arm/boot/dts/bcm2708-rpi-cm.dtsi
@@ -1,4 +1,5 @@
 #include "bcm2708.dtsi"
+#include "bcm2708-rpi.dtsi"
 
 &leds {
 	act_led: act {
--- a/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2708.dtsi"
+#include "bcm2708-rpi.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
 / {
--- a/arch/arm/boot/dts/bcm2708-rpi-zero.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-zero.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2708.dtsi"
+#include "bcm2708-rpi.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
 / {
--- a/arch/arm/boot/dts/bcm2708-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2708-rpi.dtsi
@@ -1,6 +1,6 @@
-/* Downstream version of bcm2835-rpi.dtsi */
+/* Downstream modifications to bcm2835-rpi.dtsi */
 
-#include <dt-bindings/power/raspberrypi-power.h>
+#include "bcm2835-rpi.dtsi"
 
 / {
 	memory {
@@ -49,29 +49,10 @@
 			reg = <0x7e200000 0x1000>;
 		};
 
-		firmware: firmware {
-			compatible = "raspberrypi,bcm2835-firmware", "simple-bus";
-			#address-cells = <0>;
-			#size-cells = <0>;
-			mboxes = <&mailbox>;
-		};
-
-		power: power {
-			compatible = "raspberrypi,bcm2835-power";
-			firmware = <&firmware>;
-			#power-domain-cells = <1>;
-		};
-
 		fb: fb {
 			compatible = "brcm,bcm2708-fb";
 			firmware = <&firmware>;
-			status = "disabled";
-		};
-
-		vchiq: mailbox@7e00b840 {
-			compatible = "brcm,bcm2835-vchiq";
-			reg = <0x7e00b840 0x3c>;
-			interrupts = <0 2>;
+			status = "okay";
 		};
 
 		vcsm: vcsm {
@@ -91,10 +72,6 @@
 		sound: sound {
 			status = "disabled";
 		};
-
-		txp: txp@7e004000 {
-			status = "disabled";
-		};
 	};
 
 	__overrides__ {
@@ -125,11 +102,23 @@
 };
 
 &hdmi {
-	power-domains = <&power RPI_POWER_DOMAIN_HDMI>;
+	status = "disabled";
 };
 
-&usb {
-	power-domains = <&power RPI_POWER_DOMAIN_USB>;
+&txp {
+	status = "disabled";
+};
+
+&i2c0 {
+	status = "disabled";
+};
+
+&i2c1 {
+	status = "disabled";
+};
+
+&i2c2 {
+	status = "disabled";
 };
 
 &clocks {
@@ -141,16 +130,8 @@ sdhost_pins: &sdhost_gpio48 {
 };
 
 &sdhost {
-	pinctrl-names = "default";
-	pinctrl-0 = <&sdhost_gpio48>;
-	bus-width = <4>;
 	brcm,overclock-50 = <0>;
 	brcm,pio-limit = <1>;
-	status = "okay";
-};
-
-&fb {
-	status = "okay";
 };
 
 &cpu_thermal {
@@ -160,11 +141,3 @@ sdhost_pins: &sdhost_gpio48 {
 &vec {
 	status = "disabled";
 };
-
-&csi0 {
-	power-domains = <&power RPI_POWER_DOMAIN_UNICAM0>;
-};
-
-&csi1 {
-	power-domains = <&power RPI_POWER_DOMAIN_UNICAM1>;
-};
--- a/arch/arm/boot/dts/bcm2708.dtsi
+++ b/arch/arm/boot/dts/bcm2708.dtsi
@@ -1,6 +1,5 @@
 #include "bcm2835.dtsi"
 #include "bcm270x.dtsi"
-#include "bcm2708-rpi.dtsi"
 
 / {
 	/delete-node/ cpus;
--- a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
+++ b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2709.dtsi"
+#include "bcm2709-rpi.dtsi"
 #include "bcm283x-rpi-smsc9514.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2709.dtsi
+++ b/arch/arm/boot/dts/bcm2709.dtsi
@@ -1,6 +1,5 @@
 #include "bcm2836.dtsi"
 #include "bcm270x.dtsi"
-#include "bcm2709-rpi.dtsi"
 
 / {
 	soc {
--- a/arch/arm/boot/dts/bcm270x.dtsi
+++ b/arch/arm/boot/dts/bcm270x.dtsi
@@ -68,7 +68,7 @@
 
 		/delete-node/ sdhci@7e300000;
 
-		mmc: mmc@7e300000 {
+		sdhci: mmc: mmc@7e300000 {
 			compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
 			reg = <0x7e300000 0x100>;
 			interrupts = <2 30>;
@@ -152,22 +152,6 @@
 		};
 	};
 
-	vdd_5v0_reg: fixedregulator_5v0 {
-		compatible = "regulator-fixed";
-		regulator-name = "5v0";
-		regulator-min-microvolt = <5000000>;
-		regulator-max-microvolt = <5000000>;
-		regulator-always-on;
-	};
-
-	vdd_3v3_reg: fixedregulator_3v3 {
-		compatible = "regulator-fixed";
-		regulator-name = "3v3";
-		regulator-min-microvolt = <3300000>;
-		regulator-max-microvolt = <3300000>;
-		regulator-always-on;
-	};
-
 	__overrides__ {
 		cam0-pwdn-ctrl;
 		cam0-pwdn;
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2710.dtsi"
+#include "bcm2709-rpi.dtsi"
 #include "bcm283x-rpi-lan7515.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2710.dtsi"
+#include "bcm2709-rpi.dtsi"
 #include "bcm283x-rpi-smsc9514.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 #include "bcm2710.dtsi"
+#include "bcm2709-rpi.dtsi"
 #include "bcm283x-rpi-csi0-2lane.dtsi"
 #include "bcm283x-rpi-csi1-4lane.dtsi"
 
--- a/arch/arm/boot/dts/bcm2710.dtsi
+++ b/arch/arm/boot/dts/bcm2710.dtsi
@@ -1,6 +1,5 @@
 #include "bcm2837.dtsi"
 #include "bcm270x.dtsi"
-#include "bcm2709-rpi.dtsi"
 
 / {
 	compatible = "brcm,bcm2837", "brcm,bcm2836";
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -1,13 +1,12 @@
 /dts-v1/;
 
 #include "bcm2711.dtsi"
+#include "bcm2711-rpi.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 
 / {
-	compatible = "raspberrypi,4-model-b", "brcm,bcm2838", "brcm,bcm2837";
+	compatible = "raspberrypi,4-model-b", "brcm,bcm2838";
 	model = "Raspberry Pi 4 Model B";
-	#address-cells = <2>;
-	#size-cells = <1>;
 
 	memory {
 		device_type = "memory";
@@ -48,10 +47,18 @@
 };
 
 &firmware {
-	expgpio: expgpio {
+	expgpio: gpio {
 		compatible = "raspberrypi,firmware-gpio";
 		gpio-controller;
 		#gpio-cells = <2>;
+		gpio-line-names = "BT_ON",
+				  "WL_ON",
+				  "PWR_LED_OFF",
+				  "GLOBAL_RESET",
+				  "VDD_SD_IO_SEL",
+				  "CAM_GPIO",
+				  "",
+				  "";
 		status = "okay";
 	};
 };
--- /dev/null
+++ b/arch/arm/boot/dts/bcm2711-rpi.dtsi
@@ -0,0 +1,7 @@
+#include "bcm2708-rpi.dtsi"
+#include "bcm2838-rpi.dtsi"
+
+&v3d {
+     /* Undo the overwriting by bcm270x.dtsi */
+     power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>;
+};
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -1,10 +1,8 @@
 #include "bcm2838.dtsi"
 #include "bcm270x.dtsi"
-#include "bcm2708-rpi.dtsi"
 
 / {
 	soc {
-		/delete-node/ mailbox@7e00b840;
 		/delete-node/ v3d@7ec00000;
 	};
 
@@ -17,14 +15,6 @@
 	status = "disabled";
 };
 
-&dma {
-	brcm,dma-channel-mask = <0x7ef5>;
-};
-
-&txp {
-	interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
-};
-
 &firmwarekms {
 	interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
 };
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -36,6 +36,22 @@
 			interrupts = <0 2>;
 		};
 	};
+
+	vdd_3v3_reg: fixedregulator_3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-always-on;
+	};
+
+	vdd_5v0_reg: fixedregulator_5v0 {
+		compatible = "regulator-fixed";
+		regulator-name = "5v0";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+	};
 };
 
 &gpio {
--- a/arch/arm/boot/dts/bcm2838.dtsi
+++ b/arch/arm/boot/dts/bcm2838.dtsi
@@ -5,7 +5,10 @@
 #include <dt-bindings/soc/bcm2835-pm.h>
 
 / {
-	compatible = "brcm,bcm2838", "brcm,bcm2837";
+	compatible = "brcm,bcm2838";
+
+	#address-cells = <2>;
+	#size-cells = <1>;
 
 	interrupt-parent = <&gicv2>;
 
@@ -16,8 +19,8 @@
 		/* Emulate a contiguous 30-bit address range for DMA */
 		dma-ranges = <0xc0000000  0x0 0x00000000  0x3c000000>;
 
-		/delete-node/ mailbox@7e00b840;
 		/delete-node/ interrupt-controller@7e00f300;
+		/delete-node/ v3d@7ec00000;
 
 		local_intc: local_intc@40000000 {
 			compatible = "brcm,bcm2836-l1-intc";
@@ -191,6 +194,16 @@
 			interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
+		pwm1: pwm@7e20c800 {
+			compatible = "brcm,bcm2835-pwm";
+			reg = <0x7e20c800 0x28>;
+			clocks = <&clocks BCM2835_CLOCK_PWM>;
+			assigned-clocks = <&clocks BCM2835_CLOCK_PWM>;
+			assigned-clock-rates = <10000000>;
+			#pwm-cells = <2>;
+			status = "disabled";
+		};
+
 		emmc2: emmc2@7e340000 {
 			compatible = "brcm,bcm2711-emmc2";
 			status = "okay";
@@ -385,7 +398,7 @@
 				"dma13",
 				"dma14";
 			#dma-cells = <1>;
-			brcm,dma-channel-mask = <0x7000>;
+			brcm,dma-channel-mask = <0x7800>;
 		};
 		/* DMA4 - 40 bit DMA engines */
 
@@ -396,12 +409,6 @@
 			interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
-		vchiq: mailbox@7e00b840 {
-			compatible = "brcm,bcm2838-vchiq";
-			reg = <0 0x7e00b840 0x3c>;
-			interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
-		};
-
 		hevc-decoder@7eb00000 {
 			compatible = "raspberrypi,argon-hevc-decoder";
 			reg = <0x0 0x7eb00000 0x10000>;
@@ -450,6 +457,8 @@
 };
 
 &gpio {
+	compatible = "brcm,bcm2838-gpio", "brcm,bcm2835-gpio";
+
 	gpclk0_gpio49: gpclk0_gpio49 {
 		brcm,pins = <49>;
 		brcm,function = <BCM2835_FSEL_ALT1>;
@@ -729,5 +738,9 @@
 			  "dma8",
 			  "dma9",
 			  "dma10";
-	brcm,dma-channel-mask = <0x01f5>;
+	brcm,dma-channel-mask = <0x07f5>;
+};
+
+&txp {
+	interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
 };
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -55,7 +55,7 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
-		txp@7e004000 {
+		txp: txp@7e004000 {
 			compatible = "brcm,bcm2835-txp";
 			reg = <0x7e004000 0x20>;
 			interrupts = <1 11>;
