From 815aac9f7e9a23babdc52c035d02a12222c9200b Mon Sep 17 00:00:00 2001
From: "Andrew F. Davis" <afd@ti.com>
Date: Sun, 2 Apr 2017 18:22:53 -0500
Subject: [PATCH] am43xx: Initial support for TI AM43xx

Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org>
---
 README.md              |  2 ++
 am43xx.mk              | 36 ++++++++++++++++++++++++
 ti/fitImage-am43xx.its | 62 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+)
 create mode 100644 am43xx.mk
 create mode 100644 ti/fitImage-am43xx.its

diff --git a/README.md b/README.md
index b922f77..9c55432 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,7 @@ information.
 | [QEMUv8](http://wiki.qemu.org/Main_Page) |`PLATFORM=vexpress-qemu_armv8a`| Yes |
 | [Raspberry Pi 3](https://www.raspberrypi.org/products/raspberry-pi-3-model-b) |`PLATFORM=rpi3`| Yes |
 | [Texas Instruments DRA7xx](http://www.ti.com/product/DRA746)|`PLATFORM=ti-dra7xx`| Yes |
+| [Texas Instruments AM43xx](http://www.ti.com/product/AM4379)|`PLATFORM=ti-am43xx`| Yes |
 
 # 6. Manifests
 Here is a list of manifests for the devices currently supported.
@@ -103,6 +104,7 @@ Here is a list of manifests for the devices currently supported.
 | ARM Juno board| `juno.xml` | `juno_stable.xml` |
 | Raspberry Pi 3 | `rpi3.xml` | `rpi3_stable.xml` |
 | DRA7xx | `dra7xx.xml` | `dra7xx_stable.xml` |
+| AM43xx | `am43xx.xml` | `am43xx_stable.xml` |
 
 # 7. Get and build the solution
 Below we will describe the general way of getting the source, building the
diff --git a/am43xx.mk b/am43xx.mk
new file mode 100644
index 0000000..2bd9eb3
--- /dev/null
+++ b/am43xx.mk
@@ -0,0 +1,36 @@
+###############################################################################
+# Following variables defines how the NS_USER (Non Secure User - Client
+# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and
+# S_USER (Secure User - TA) are compiled
+###############################################################################
+override COMPILE_NS_USER   := 32
+override COMPILE_NS_KERNEL := 32
+override COMPILE_S_USER    := 32
+override COMPILE_S_KERNEL  := 32
+
+###############################################################################
+# Includes
+###############################################################################
+-include common.mk
+
+###############################################################################
+# Paths to git projects and various binaries
+###############################################################################
+STAGING_AREA    ?= $(ROOT)/out
+U-BOOT_PATH     ?= $(ROOT)/u-boot
+UBOOT_SPL       ?= $(U-BOOT_PATH)/u-boot-spl_HS_ISSW
+UBOOT_IMG       ?= $(U-BOOT_PATH)/u-boot_HS.img
+UBOOT_ENV       ?= $(BUILD_PATH)/ti/uEnv.txt
+LINUX_IMAGE     ?= $(LINUX_PATH)/arch/arm/boot/zImage
+LINUX_DTBS      ?= $(wildcard $(LINUX_PATH)/arch/arm/boot/dts/am43*.dtb)
+FIT_SOURCE      ?= $(BUILD_PATH)/ti/fitImage-am43xx.its
+FIT_MAKEFILE    ?= $(BUILD_PATH)/ti/Makefile
+OPTEE_PLATFORM  ?= ti-am43xx
+U-BOOT_CONFIG   ?= am43xx_hs_evm_defconfig
+CONFIG_TYPE     ?= ti_sdk_am4x_debug
+BUSYBOX_TARGET  ?= am43xx
+
+###############################################################################
+# Include common to TI builds
+###############################################################################
+include ti/ti-common.mk
diff --git a/ti/fitImage-am43xx.its b/ti/fitImage-am43xx.its
new file mode 100644
index 0000000..ee88b76
--- /dev/null
+++ b/ti/fitImage-am43xx.its
@@ -0,0 +1,62 @@
+/dts-v1/;
+
+/ {
+	description = "U-Boot fitImage";
+	#address-cells = <1>;
+
+	images {
+		kernel@1 {
+			description = "Linux kernel";
+			data = /incbin/("zImage.sec");
+			type = "kernel";
+			arch = "arm";
+			os = "linux";
+			compression = "none";
+			load = <0x82000000>;
+			entry = <0x82000000>;
+		};
+
+		am437x-gp-evm.dtb {
+			description = "Flattened Device Tree blob";
+			data = /incbin/("am437x-gp-evm.dtb.sec");
+			type = "flat_dt";
+			arch = "arm";
+			compression = "none";
+		};
+
+		am43x-epos-evm.dtb {
+			description = "Flattened Device Tree blob";
+			data = /incbin/("am43x-epos-evm.dtb.sec");
+			type = "flat_dt";
+			arch = "arm";
+			compression = "none";
+		};
+
+		optee {
+			description = "OPTEE OS Image";
+			data = /incbin/("tee.bin.sec");
+			type = "tee";
+			arch = "arm";
+			compression = "none";
+			load = <0xbdb000e4>;
+		};
+	};
+
+	configurations {
+		default = "am437x-gp-evm.dtb";
+
+		am437x-gp-evm.dtb {
+			description = "Linux kernel, FDT blob, OPTEE OS";
+			kernel = "kernel@1";
+			fdt = "am437x-gp-evm.dtb";
+			loadables = "optee";
+		};
+
+		am43x-epos-evm.dtb {
+			description = "Linux kernel, FDT blob, OPTEE OS";
+			kernel = "kernel@1";
+			fdt = "am43x-epos-evm.dtb";
+			loadables = "optee";
+		};
+	};
+};
-- 
GitLab