# Forked for adding rk3399 support and crust compatibility
pkgname=arm-trusted-firmware
_pkgver=crust-20210410
pkgver=9999
pkgrel=2
pkgdesc="ARM Trusted Firmware-A (TF-A)"
url="https://github.com/crust-firmware/arm-trusted-firmware/"
arch="aarch64"
license="BSD-3-Clause"
makedepends="dtc openssl-dev gcc-arm-none-eabi"
options="!check" # no tests
subpackages="$pkgname-sun50i $pkgname-rk3399"
source="
	$pkgname-$_pkgver.tar.gz::https://github.com/crust-firmware/arm-trusted-firmware/archive/refs/tags/$_pkgver.tar.gz
	rk3399-baudrate.patch
"
options="!check" # no testsuite
builddir="$srcdir/$pkgname-$_pkgver"

build() {
	LDFLAGS="" make PLAT=sun50i_a64 bl31
	LDFLAGS="" make PLAT=rk3399 bl31
}

package() {
	mkdir -p "$pkgdir"/usr/share/$pkgname
}

sun50i() {
	pkgdesc="ARM Trusted Firmware-A for sun50i"
	mkdir -p "$subpkgdir"/usr/share/$subpkgname
	install "$builddir"/build/sun50i_a64/release/bl31.bin "$subpkgdir"/usr/share/$subpkgname/
}

rk3399() {
	pkgdesc="ARM Trusted Firmware-A for rk3399"
	mkdir -p "$subpkgdir"/usr/share/$subpkgname
	install "$builddir"/build/rk3399/release/bl31/bl31.elf "$subpkgdir"/usr/share/$subpkgname/
}

sha512sums="
ecc69c60d35d5c116647c13067e425b75f46ce5753d0e518396a55dfa6e934ff16ccbc91349bcb6dbd55011e289afc8448e2b3da082e05a0fc757563e4605948  arm-trusted-firmware-crust-20210410.tar.gz
86d8c60157145ab05e9b870aad11d2acaf2137ba00bf71419f8a54a4fd2b1906c19bc8bfeccc735344d1dcf11ba81bd9396bfd8854cdb972a72503b632d1e900  rk3399-baudrate.patch
"
