rk3399: Add generic rk3399 support

Adds support for the rk3399 SoC. Notably:
 *) Split out the default kernel config and image type from
    rockchip-defaults.inc now that not all support chips are ARMv7
 *) Apply a patch to Arm Trusted Firmware to fix a compile issue
 *) Arm Trusted Firmware requires the arm-none-eabi-native compiler to
    compile the M0 firmware.
 *) Modify u-boot to pull in the ATF files when compiling
 *) The rk3399 is support by the panfrost driver in mesa, so enable it

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
This commit is contained in:
Joshua Watt 2020-01-23 13:46:44 -06:00 committed by Trevor Woerner
parent 1035b5d734
commit 01467664da
10 changed files with 170 additions and 3 deletions

View File

@ -6,3 +6,6 @@ SOC_FAMILY = "rk3066"
require conf/machine/include/tune-cortexa9.inc
require conf/machine/include/soc-family.inc
require conf/machine/include/rockchip-defaults.inc
KBUILD_DEFCONFIG = "multi_v7_defconfig"
KERNEL_IMAGETYPE = "zImage"

View File

@ -6,3 +6,6 @@ SOC_FAMILY = "rk3188"
require conf/machine/include/tune-cortexa9.inc
require conf/machine/include/soc-family.inc
require conf/machine/include/rockchip-defaults.inc
KBUILD_DEFCONFIG = "multi_v7_defconfig"
KERNEL_IMAGETYPE = "zImage"

View File

@ -7,6 +7,9 @@ require conf/machine/include/tune-cortexa17.inc
require conf/machine/include/soc-family.inc
require conf/machine/include/rockchip-defaults.inc
KBUILD_DEFCONFIG = "multi_v7_defconfig"
KERNEL_IMAGETYPE = "zImage"
SERIAL_CONSOLES = "115200;ttyS2"
PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"

View File

@ -0,0 +1,27 @@
# Copyright (C) 2020 Garmin Ltd. or its subsidaries
# Released under the MIT license (see COPYING.MIT for the terms)
SOC_FAMILY = "rk3399"
DEFAULTTUNE ?= "cortexa72-cortexa53-crypto"
require conf/machine/include/tune-cortexa72-cortexa53.inc
require conf/machine/include/soc-family.inc
require conf/machine/include/rockchip-defaults.inc
KBUILD_DEFCONFIG ?= "defconfig"
KERNEL_CLASSES = "kernel-fitimage"
KERNEL_IMAGETYPE = "fitImage"
ATF_PLATFORM ?= "rk3399"
ATF_TARGET ?= "bl31"
ATF_SUFFIX ?= "elf"
UBOOT_SUFFIX ?= "itb"
UBOOT_ENTRYPOINT ?= "0x06000000"
SERIAL_CONSOLES = "115200;ttyS2"
PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
SPL_BINARY ?= "idbloader.img"

View File

@ -3,8 +3,6 @@
# kernel
PREFERRED_PROVIDER_virtual/kernel ?= "linux-stable"
LINUX_VERSION_EXTENSION ?= "-rockchip"
KBUILD_DEFCONFIG = "multi_v7_defconfig"
KERNEL_IMAGETYPE = "zImage"
# xserver
PREFERRED_PROVIDER_virtual/xserver = "xserver-xorg"

View File

@ -0,0 +1,94 @@
From 39a97dce61aca9f618e28e26c6e441c8976f3172 Mon Sep 17 00:00:00 2001
From: Joshua Watt <JPEWhacker@gmail.com>
Date: Fri, 13 Dec 2019 13:44:55 -0600
Subject: [PATCH] rockchip: Prevent macro expansion in paths
Instead of stringizing the paths to binary files, add them as string
defines on the command line (e.g. -DFOO=\"BAR\" instead of -DFOO=BAR).
This prevents macros from being expanded inside the string value itself.
For example, -DFOO=/path/with-linux-in-it would have been expanded to
"/path/with-1-in-it" because `linux=1` is one of the standard GCC
defines.
Upstream-Status: Accepted [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/2813]
Change-Id: I7b65df3c9930faed4f1aff75ad726982ae3671e6
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
plat/rockchip/rk3399/drivers/dp/cdn_dp.c | 2 +-
plat/rockchip/rk3399/drivers/pmu/pmu_fw.c | 24 +++++++++++------------
plat/rockchip/rk3399/platform.mk | 6 +++---
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
index aa71fdea..a8773f4f 100644
--- a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
+++ b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
@@ -18,7 +18,7 @@ __asm__(
".global hdcp_handler\n"
".balign 4\n"
"hdcp_handler:\n"
- ".incbin \"" __XSTRING(HDCPFW) "\"\n"
+ ".incbin \"" HDCPFW "\"\n"
".type hdcp_handler, %function\n"
".size hdcp_handler, .- hdcp_handler\n"
".popsection\n"
diff --git a/plat/rockchip/rk3399/drivers/pmu/pmu_fw.c b/plat/rockchip/rk3399/drivers/pmu/pmu_fw.c
index a09ad21e..25596b18 100644
--- a/plat/rockchip/rk3399/drivers/pmu/pmu_fw.c
+++ b/plat/rockchip/rk3399/drivers/pmu/pmu_fw.c
@@ -5,20 +5,18 @@
*/
/* convoluted way to make sure that the define is pasted just the right way */
-#define _INCBIN(file, sym, sec) \
+#define INCBIN(file, sym, sec) \
__asm__( \
- ".section " #sec "\n" \
- ".global " #sym "\n" \
- ".type " #sym ", %object\n" \
+ ".section " sec "\n" \
+ ".global " sym "\n" \
+ ".type " sym ", %object\n" \
".align 4\n" \
- #sym ":\n" \
- ".incbin \"" #file "\"\n" \
- ".size " #sym ", .-" #sym "\n" \
- ".global " #sym "_end\n" \
- #sym "_end:\n" \
+ sym ":\n" \
+ ".incbin \"" file "\"\n" \
+ ".size " sym ", .-" sym "\n" \
+ ".global " sym "_end\n" \
+ sym "_end:\n" \
)
-#define INCBIN(file, sym, sec) _INCBIN(file, sym, sec)
-
-INCBIN(RK3399M0FW, rk3399m0_bin, ".sram.incbin");
-INCBIN(RK3399M0PMUFW, rk3399m0pmu_bin, ".pmusram.incbin");
+INCBIN(RK3399M0FW, "rk3399m0_bin", ".sram.incbin");
+INCBIN(RK3399M0PMUFW, "rk3399m0pmu_bin", ".pmusram.incbin");
diff --git a/plat/rockchip/rk3399/platform.mk b/plat/rockchip/rk3399/platform.mk
index cfc48e8f..643c24f5 100644
--- a/plat/rockchip/rk3399/platform.mk
+++ b/plat/rockchip/rk3399/platform.mk
@@ -82,13 +82,13 @@ PLAT_M0 := ${PLAT}m0
BUILD_M0 := ${BUILD_PLAT}/m0
RK3399M0FW=${BUILD_M0}/${PLAT_M0}.bin
-$(eval $(call add_define,RK3399M0FW))
+$(eval $(call add_define_val,RK3399M0FW,\"$(RK3399M0FW)\"))
RK3399M0PMUFW=${BUILD_M0}/${PLAT_M0}pmu.bin
-$(eval $(call add_define,RK3399M0PMUFW))
+$(eval $(call add_define_val,RK3399M0PMUFW,\"$(RK3399M0PMUFW)\"))
HDCPFW=${RK_PLAT_SOC}/drivers/dp/hdcp.bin
-$(eval $(call add_define,HDCPFW))
+$(eval $(call add_define_val,HDCPFW,\"$(HDCPFW)\"))
# CCACHE_EXTRAFILES is needed because ccache doesn't handle .incbin
export CCACHE_EXTRAFILES
--
2.23.0

View File

@ -6,10 +6,16 @@ HOMEPAGE = "https://developer.trustedfirmware.org/"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://docs/license.rst;md5=189505435dbcdcc8caa63c46fe93fa89"
# Rockchip RK3399 compiles some M0 firmware which requires an arm-none-eabi GCC
# toolchain
DEPENDS_rk3399 = "virtual/arm-none-eabi-gcc"
PROVIDES = "virtual/atf"
BRANCH = "master"
SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=http;branch=${BRANCH}"
SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=http;branch=${BRANCH} \
file://0001-rockchip-Prevent-macro-expansion-in-paths.patch \
"
SRCREV = "a04808c16cfc126d9fe572ae7c4b5a3d39de5796"
S = "${WORKDIR}/git"

View File

@ -4,3 +4,11 @@ do_compile_append_rock2-square () {
cp ${B}/spl/${SPL_BINARY} ${B}
fi
}
ATF_DEPENDS ??= ""
EXTRA_OEMAKE_append_rk3399 = " BL31=${DEPLOY_DIR_IMAGE}/bl31.elf"
ATF_DEPENDS_rk3399 = "virtual/atf:do_deploy"
do_compile[depends] += "${ATF_DEPENDS}"

View File

@ -1 +1,2 @@
PACKAGECONFIG_append_rk3288 = " kmsro panfrost"
PACKAGECONFIG_append_rk3399 = " kmsro panfrost"

24
wic/rk3399-boot.wks Normal file
View File

@ -0,0 +1,24 @@
# Copyright (C) 2020 Garmin Ltd. or its subsidiaries
# Released under the MIT license (see COPYING.MIT for the terms)
#
# Disk layout
# Note that the reference documentation refers to 512 byte disk sectors, but
# wic uses 1KB blocks
#
# Partition Start Sector Number of Sectors
# loader1 64 8000
# reserved1 8064 128
# reserved2 8192 8192
# loader2 16384 8192
# atf 24576 8192
# boot 32768 229376
# root 262144 -
#
part loader1 --align 32 --size 4000K --source rawcopy --sourceparams="file=idbloader.img"
part reserved1 --align 4032 --size 64K
part reserved2 --align 4096 --size 4096K
part loader2 --align 8192 --size 4096K --source rawcopy --sourceparams="file=u-boot.itb"
part atf --align 12288 --size 4096K
part /boot --align 16384 --size=114688K --active --source bootimg-partition --fstype=vfat --label boot --sourceparams="loader=u-boot"