Browse Source

Platform/AMD/OverdriveBoard: build device tree from source

Instead of incorporating the prebuilt device tree binary as a
FREEFORM FFS file into the build, define a module that contains
the source so that the device tree compiler is invoked at build
time.

The original .dts file is moved into the new module, and cleaned
up a little so that explicit phandle properties are dropped, and
unused clocks and other redudant pieces are removed as well. The
existing prebuilt binary is deleted.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Ard Biesheuvel 5 years ago
parent
commit
006c241447

+ 42 - 102
Platform/AMD/OverdriveBoard/FdtBlob/styx-overdrive.dts → Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.dts

@@ -19,11 +19,11 @@
 / {
 	model = "AMD Seattle (Rev.B) Development Board (Overdrive)";
 	compatible = "amd,seattle-overdrive", "amd,seattle";
-	interrupt-parent = <0x1>;
+	interrupt-parent = <&gic>;
 	#address-cells = <0x2>;
 	#size-cells = <0x2>;
 
-	interrupt-controller@e1101000 {
+	gic: interrupt-controller@e1101000 {
 		compatible = "arm,gic-400", "arm,cortex-a15-gic";
 		interrupt-controller;
 		#interrupt-cells = <0x3>;
@@ -35,15 +35,11 @@
 		      <0x0 0xe1160000 0x0 0x2000>;
 		interrupts = <0x1 0x9 0xf04>;
 		ranges = <0x0 0x0 0x0 0xe1100000 0x0 0x100000>;
-		linux,phandle = <0x1>;
-		phandle = <0x1>;
 
-		v2m@e0080000 {
+		msi: v2m@e0080000 {
 			compatible = "arm,gic-v2m-frame";
 			msi-controller;
 			reg = <0x0 0x80000 0x0 0x1000>;
-			linux,phandle = <0x4>;
-			phandle = <0x4>;
 		};
 	};
 
@@ -67,59 +63,25 @@
 		 */
 		dma-ranges = <0x0 0x0 0x0 0x0 0x100 0x0>;
 
-		clk100mhz_0 {
-			compatible = "fixed-clock";
-			#clock-cells = <0x0>;
-			clock-frequency = <100000000>;
-			clock-output-names = "adl3clk_100mhz";
-		};
-
-		clk375mhz {
-			compatible = "fixed-clock";
-			#clock-cells = <0x0>;
-			clock-frequency = <375000000>;
-			clock-output-names = "ccpclk_375mhz";
-		};
-
-		clk333mhz {
+		sata_clk: clk333mhz {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <333000000>;
 			clock-output-names = "sataclk_333mhz";
-			linux,phandle = <0x2>;
-			phandle = <0x2>;
 		};
 
-		clk500mhz_0 {
-			compatible = "fixed-clock";
-			#clock-cells = <0x0>;
-			clock-frequency = <500000000>;
-			clock-output-names = "pcieclk_500mhz";
-		};
-
-		clk500mhz_1 {
-			compatible = "fixed-clock";
-			#clock-cells = <0x0>;
-			clock-frequency = <500000000>;
-			clock-output-names = "dmaclk_500mhz";
-		};
-
-		clk250mhz_4 {
+		i2c_clk: clk250mhz_4 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <250000000>;
 			clock-output-names = "miscclk_250mhz";
-			linux,phandle = <0xd>;
-			phandle = <0xd>;
 		};
 
-		clk100mhz_1 {
+		apb_clk: clk100mhz_1 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <100000000>;
 			clock-output-names = "uartspiclk_100mhz";
-			linux,phandle = <0x3>;
-			phandle = <0x3>;
 		};
 
 		sata0_smmu: smmu@e0200000 {
@@ -152,7 +114,7 @@
 			compatible = "snps,dwc-ahci";
 			reg = <0x0 0xe0300000 0x0 0xf0000>;
 			interrupts = <0x0 0x163 0x4>;
-			clocks = <0x2>;
+			clocks = <&sata_clk>;
 			dma-coherent;
 			iommus = <&sata0_smmu 0x00 0x1f>; /* 0-31 */
 		};
@@ -162,7 +124,7 @@
 			compatible = "snps,dwc-ahci";
 			reg = <0x0 0xe0d00000 0x0 0xf0000>;
 			interrupts = <0x0 0x162 0x4>;
-			clocks = <0x2>;
+			clocks = <&sata_clk>;
 			dma-coherent;
 			iommus = <&sata1_smmu 0x00 0x1f>; /* 0-31 */
 		};
@@ -171,21 +133,21 @@
 			compatible = "snps,designware-i2c";
 			reg = <0x0 0xe1000000 0x0 0x1000>;
 			interrupts = <0x0 0x165 0x4>;
-			clocks = <0xd>;
+			clocks = <&i2c_clk>;
 		};
 
 		i2c@e0050000 {
 			compatible = "snps,designware-i2c";
 			reg = <0x0 0xe0050000 0x0 0x1000>;
 			interrupts = <0x0 0x154 0x4>;
-			clocks = <0xd>;
+			clocks = <&i2c_clk>;
 		};
 
 		serial@e1010000 {
 			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x0 0xe1010000 0x0 0x1000>;
 			interrupts = <0x0 0x148 0x4>;
-			clocks = <0x3 0x3>;
+			clocks = <&apb_clk &apb_clk>;
 			clock-names = "uartclk", "apb_pclk";
 		};
 
@@ -194,7 +156,7 @@
 			reg = <0x0 0xe1020000 0x0 0x1000>;
 			spi-controller;
 			interrupts = <0x0 0x14a 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 		};
 
@@ -203,7 +165,7 @@
 			reg = <0x0 0xe1030000 0x0 0x1000>;
 			spi-controller;
 			interrupts = <0x0 0x149 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 			num-cs = <0x1>;
 			#address-cells = <0x1>;
@@ -230,7 +192,7 @@
 			interrupt-controller;
 			#interrupt-cells = <0x2>;
 			interrupts = <0x0 0x166 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 		};
 
@@ -243,7 +205,7 @@
 			interrupt-controller;
 			#interrupt-cells = <0x2>;
 			interrupts = <0x0 0x16e 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 		};
 
@@ -256,7 +218,7 @@
 			interrupt-controller;
 			#interrupt-cells = <0x2>;
 			interrupts = <0x0 0x16d 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 		};
 
@@ -268,7 +230,7 @@
 			interrupt-controller;
 			#interrupt-cells = <0x2>;
 			interrupts = <0x0 0x169 0x4>;
-			clocks = <0x3>;
+			clocks = <&apb_clk>;
 			clock-names = "apb_pclk";
 		};
 
@@ -288,23 +250,23 @@
 			iommu-map = <0x0 &pcie_smmu 0x0 0x10000>;
 			device_type = "pci";
 			bus-range = <0x0 0x7f>;
-			msi-parent = <0x4>;
+			msi-parent = <&msi>;
 			reg = <0x0 0xf0000000 0x0 0x10000000>;
 			interrupt-map-mask = <0xff00 0x0 0x0 0x7>;
-			interrupt-map = <0x1100 0x0 0x0 0x1 0x1 0x0 0x0 0x0 0x120 0x1>,
-					<0x1100 0x0 0x0 0x2 0x1 0x0 0x0 0x0 0x121 0x1>,
-					<0x1100 0x0 0x0 0x3 0x1 0x0 0x0 0x0 0x122 0x1>,
-					<0x1100 0x0 0x0 0x4 0x1 0x0 0x0 0x0 0x123 0x1>,
-
-					<0x1200 0x0 0x0 0x1 0x1 0x0 0x0 0x0 0x124 0x1>,
-					<0x1200 0x0 0x0 0x2 0x1 0x0 0x0 0x0 0x125 0x1>,
-					<0x1200 0x0 0x0 0x3 0x1 0x0 0x0 0x0 0x126 0x1>,
-					<0x1200 0x0 0x0 0x4 0x1 0x0 0x0 0x0 0x127 0x1>,
-
-					<0x1300 0x0 0x0 0x1 0x1 0x0 0x0 0x0 0x128 0x1>,
-					<0x1300 0x0 0x0 0x2 0x1 0x0 0x0 0x0 0x129 0x1>,
-					<0x1300 0x0 0x0 0x3 0x1 0x0 0x0 0x0 0x12a 0x1>,
-					<0x1300 0x0 0x0 0x4 0x1 0x0 0x0 0x0 0x12b 0x1>;
+			interrupt-map = <0x1100 0x0 0x0 0x1 &gic 0x0 0x0 0x0 0x120 0x1>,
+					<0x1100 0x0 0x0 0x2 &gic 0x0 0x0 0x0 0x121 0x1>,
+					<0x1100 0x0 0x0 0x3 &gic 0x0 0x0 0x0 0x122 0x1>,
+					<0x1100 0x0 0x0 0x4 &gic 0x0 0x0 0x0 0x123 0x1>,
+
+					<0x1200 0x0 0x0 0x1 &gic 0x0 0x0 0x0 0x124 0x1>,
+					<0x1200 0x0 0x0 0x2 &gic 0x0 0x0 0x0 0x125 0x1>,
+					<0x1200 0x0 0x0 0x3 &gic 0x0 0x0 0x0 0x126 0x1>,
+					<0x1200 0x0 0x0 0x4 &gic 0x0 0x0 0x0 0x127 0x1>,
+
+					<0x1300 0x0 0x0 0x1 &gic 0x0 0x0 0x0 0x128 0x1>,
+					<0x1300 0x0 0x0 0x2 &gic 0x0 0x0 0x0 0x129 0x1>,
+					<0x1300 0x0 0x0 0x3 &gic 0x0 0x0 0x0 0x12a 0x1>,
+					<0x1300 0x0 0x0 0x4 &gic 0x0 0x0 0x0 0x12b 0x1>;
 			dma-coherent;
 			dma-ranges = <0x43000000 0x0 0x0 0x0 0x0 0x100 0x0>;
 			ranges = <0x1000000 0x0 0x00000000 0x0 0xefff0000 0x00 0x00010000>, /* I/O Memory (size=64K) */
@@ -352,43 +314,35 @@
 			reg-spacing = <4>;
 		};
 
-		clk250mhz_0 {
+		xgmacclk0_dma: clk250mhz_0 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <250000000>;
 			clock-output-names = "xgmacclk0_dma_250mhz";
-			linux,phandle = <0x5>;
-			phandle = <0x5>;
 		};
 
-		clk250mhz_1 {
+		xgmacclk0_ptp: clk250mhz_1 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <250000000>;
 			clock-output-names = "xgmacclk0_ptp_250mhz";
-			linux,phandle = <0x6>;
-			phandle = <0x6>;
 		};
 
-		clk250mhz_2 {
+		xgmacclk1_dma: clk250mhz_2 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <250000000>;
 			clock-output-names = "xgmacclk1_dma_250mhz";
-			linux,phandle = <0x7>;
-			phandle = <0x7>;
 		};
 
-		clk250mhz_3 {
+		xgmacclk1_ptp: clk250mhz_3 {
 			compatible = "fixed-clock";
 			#clock-cells = <0x0>;
 			clock-frequency = <250000000>;
 			clock-output-names = "xgmacclk1_ptp_250mhz";
-			linux,phandle = <0x8>;
-			phandle = <0x8>;
 		};
 
-		phy@e1240800 {
+		xgmac0_phy: phy@e1240800 {
 			status = "disabled";
 			compatible = "amd,xgbe-phy-seattle-v1a";
 			reg = <0x0 0xe1240800 0x0 0x0400>, /* SERDES RX/TX0 */
@@ -402,11 +356,9 @@
 			amd,serdes-tx-amp = <0xf 0xf 0xa>;
 			amd,serdes-dfe-tap-config = <0x3 0x3 0x1>;
 			amd,serdes-dfe-tap-enable = <0x0 0x0 0x7f>;
-			linux,phandle = <0x9>;
-			phandle = <0x9>;
 		};
 
-		phy@e1240c00 {
+		xgmac1_phy: phy@e1240c00 {
 			status = "disabled";
 			compatible = "amd,xgbe-phy-seattle-v1a";
 			reg = <0x0 0xe1240c00 0x0 0x0400>, /* SERDES RX/TX0 */
@@ -420,8 +372,6 @@
 			amd,serdes-tx-amp = <0xf 0xf 0xa>;
 			amd,serdes-dfe-tap-config = <0x3 0x3 0x1>;
 			amd,serdes-dfe-tap-enable = <0x0 0x0 0x7f>;
-			linux,phandle = <0xa>;
-			phandle = <0xa>;
 		};
 
 		xgmac0_smmu: smmu@e0600000 {
@@ -461,14 +411,12 @@
 				     <0x0 0x15d 0x1>;
 			amd,per-channel-interrupt;
 			mac-address = [02 a1 a2 a3 a4 a5];
-			clocks = <0x5 0x6>;
+			clocks = <&xgmacclk0_dma &xgmacclk0_ptp>;
 			clock-names = "dma_clk", "ptp_clk";
-			phy-handle = <0x9>;
+			phy-handle = <&xgmac0_phy>;
 			phy-mode = "xgmii";
 			dma-coherent;
 			iommus = <&xgmac0_smmu 0x00 0x1f>; /* 0-31 */
-			linux,phandle = <0xb>;
-			phandle = <0xb>;
 		};
 
 		xgmac@e0900000 {
@@ -482,25 +430,17 @@
 				     <0x0 0x158 0x1>;
 			amd,per-channel-interrupt;
 			mac-address = [02 b1 b2 b3 b4 b5];
-			clocks = <0x7 0x8>;
+			clocks = <&xgmacclk1_dma &xgmacclk1_ptp>;
 			clock-names = "dma_clk", "ptp_clk";
-			phy-handle = <0xa>;
+			phy-handle = <&xgmac1_phy>;
 			phy-mode = "xgmii";
 			dma-coherent;
 			iommus = <&xgmac1_smmu 0x00 0x1f>; /* 0-31 */
-			linux,phandle = <0xc>;
-			phandle = <0xc>;
 		};
 	};
 
 	chosen {
 		stdout-path = "/smb/serial@e1010000";
-		/* Note:
-		 * Linux support for pci-probe-only DT is not
-		 * stable. Disable this for now and let Linux
-		 * take care of the resource assignment.
-		 */
-		// linux,pci-probe-only;
 	};
 
 	psci {

+ 28 - 0
Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.inf

@@ -0,0 +1,28 @@
+## @file
+#
+#  Device tree description of the AMD Overdrive platform
+#
+#  Copyright (c) 2018, Linaro Ltd. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION    = 0x0001001A
+  BASE_NAME      = OverdriveBoardDeviceTree
+  FILE_GUID      = 25462CDA-221F-47DF-AC1D-259CFAA4E326 # gDtPlatformDefaultDtbFileGuid
+  MODULE_TYPE    = USER_DEFINED
+  VERSION_STRING = 1.0
+
+[Sources]
+  OverdriveBoard.dts
+
+[Packages]
+  MdePkg/MdePkg.dec

BIN
Platform/AMD/OverdriveBoard/FdtBlob/styx-overdrive.dtb


+ 1 - 0
Platform/AMD/OverdriveBoard/OverdriveBoard.dsc

@@ -622,6 +622,7 @@ DEFINE DO_CAPSULE   = FALSE
       FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
       DtPlatformDtbLoaderLib|Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.inf
   }
+  Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.inf
 
   #
   # PCI support

+ 6 - 4
Platform/AMD/OverdriveBoard/OverdriveBoard.fdf

@@ -149,10 +149,7 @@ READ_LOCK_STATUS   = TRUE
   # FDT support
   #
   INF EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
-
-  FILE FREEFORM = 25462CDA-221F-47DF-AC1D-259CFAA4E326 {
-    SECTION RAW = Platform/AMD/OverdriveBoard/FdtBlob/styx-overdrive.dtb
-  }
+  INF RuleOverride = DTB Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.inf
 
   #
   # PCI support
@@ -514,3 +511,8 @@ CAPSULE_HEADER_INIT_VERSION = 0x1
      UI       STRING="$(MODULE_NAME)" Optional
      VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
+
+[Rule.Common.USER_DEFINED.DTB]
+  FILE FREEFORM = $(NAMED_GUID) {
+    RAW BIN                |.dtb
+  }

+ 1 - 0
Platform/LeMaker/CelloBoard/CelloBoard.dsc

@@ -562,6 +562,7 @@ DEFINE DO_FLASHER   = FALSE
       FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
       DtPlatformDtbLoaderLib|Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.inf
   }
+  Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.inf
 
   #
   # PCI support

+ 5 - 4
Platform/LeMaker/CelloBoard/CelloBoard.fdf

@@ -145,10 +145,7 @@ READ_LOCK_STATUS   = TRUE
   # FDT support
   #
   INF EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
-
-  FILE FREEFORM = 25462CDA-221F-47DF-AC1D-259CFAA4E326 {
-    SECTION RAW = Platform/AMD/OverdriveBoard/FdtBlob/styx-overdrive.dtb
-  }
+  INF RuleOverride = DTB Platform/AMD/OverdriveBoard/DeviceTree/OverdriveBoard.inf
 
   #
   # PCI support
@@ -408,3 +405,7 @@ READ_LOCK_STATUS   = TRUE
     RAW ASL                |.aml
   }
 
+[Rule.Common.USER_DEFINED.DTB]
+  FILE FREEFORM = $(NAMED_GUID) {
+    RAW BIN                |.dtb
+  }