1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-06-05 02:20:30 +00:00

arm-bsp/u-boot: Corstone1000: bump to v2022.10

Upgrade to v2022.10

This includes Corstone-1000 out of tree patches.

FF-A patches are the latest sent to U-Boot mailing list (v8).

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Abdellatif El Khlifi
2023-01-12 11:02:57 +00:00
committed by Jon Mason
parent 3f35573acb
commit a51d4704cc
40 changed files with 1370 additions and 6832 deletions
@@ -22,7 +22,7 @@ TFM_SIGN_PRIVATE_KEY = "${libdir}/tfm-scripts/root-RSA-3072_1.pem"
RE_IMAGE_OFFSET = "0x1000"
# u-boot
PREFERRED_VERSION_u-boot ?= "2022.07"
PREFERRED_VERSION_u-boot ?= "2022.10"
EXTRA_IMAGEDEPENDS += "u-boot"
UBOOT_CONFIG ??= "EFI"
@@ -1,7 +1,7 @@
From 7afe2370bc24b9003be8184fbd3169ebca03165a Mon Sep 17 00:00:00 2001
From 584e4952dca726c3dc9df319dffb37a518b65c14 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Fri, 29 Jul 2022 13:06:19 +0100
Subject: [PATCH 06/26] arm64: smccc: add support for SMCCCv1.2 x0-x17
Subject: [PATCH 01/25] arm64: smccc: add support for SMCCCv1.2 x0-x17
registers
add support for x0-x17 registers used by the SMC calls
@@ -16,13 +16,19 @@ arm64: smccc: Add support for SMCCCv1.2 extended input/output registers
[1]: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token=
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v7:
* improve indentation of ARM_SMCCC_1_2_REGS_Xn_OFFS
v4:
* rename the commit title and improve description
@@ -33,11 +39,11 @@ v3:
* port x0-x17 registers support from linux kernel as defined by SMCCCv1.2
commit title:
arm64: smccc: add Xn registers support used by SMC calls
---
arch/arm/cpu/armv8/smccc-call.S | 53 +++++++++++++++++++++++++++++++++
arch/arm/lib/asm-offsets.c | 13 ++++++++
arch/arm/lib/asm-offsets.c | 14 +++++++++
include/linux/arm-smccc.h | 43 ++++++++++++++++++++++++++
3 files changed, 109 insertions(+)
3 files changed, 110 insertions(+)
diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S
index dc92b28777..ec6f299bc9 100644
@@ -108,38 +114,39 @@ index dc92b28777..ec6f299bc9 100644
+
+#endif
diff --git a/arch/arm/lib/asm-offsets.c b/arch/arm/lib/asm-offsets.c
index 22fd541f9a..b6bd1b32b0 100644
index 22fd541f9a..db6d7ed234 100644
--- a/arch/arm/lib/asm-offsets.c
+++ b/arch/arm/lib/asm-offsets.c
@@ -9,6 +9,8 @@
@@ -9,6 +9,9 @@
* generate asm statements containing #defines,
* compile this file to assembler, and then extract the
* #defines from the assembly-language output.
+ *
+ * (C) Copyright 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#include <common.h>
@@ -117,6 +119,17 @@ int main(void)
@@ -117,6 +120,17 @@ int main(void)
DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id));
DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state));
+ #ifdef CONFIG_ARM64
+ DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS, offsetof(struct arm_smccc_1_2_regs, a0));
+ DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS, offsetof(struct arm_smccc_1_2_regs, a2));
+ DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS, offsetof(struct arm_smccc_1_2_regs, a4));
+ DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS, offsetof(struct arm_smccc_1_2_regs, a6));
+ DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS, offsetof(struct arm_smccc_1_2_regs, a8));
+ DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS, offsetof(struct arm_smccc_1_2_regs, a10));
+ DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS, offsetof(struct arm_smccc_1_2_regs, a12));
+ DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS, offsetof(struct arm_smccc_1_2_regs, a14));
+ DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS, offsetof(struct arm_smccc_1_2_regs, a16));
+ #endif
+#ifdef CONFIG_ARM64
+ DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS, offsetof(struct arm_smccc_1_2_regs, a0));
+ DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS, offsetof(struct arm_smccc_1_2_regs, a2));
+ DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS, offsetof(struct arm_smccc_1_2_regs, a4));
+ DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS, offsetof(struct arm_smccc_1_2_regs, a6));
+ DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS, offsetof(struct arm_smccc_1_2_regs, a8));
+ DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS, offsetof(struct arm_smccc_1_2_regs, a10));
+ DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS, offsetof(struct arm_smccc_1_2_regs, a12));
+ DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS, offsetof(struct arm_smccc_1_2_regs, a14));
+ DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS, offsetof(struct arm_smccc_1_2_regs, a16));
+#endif
#endif
return 0;
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 7f2be23394..dae58d3476 100644
index e1d09884a1..9105031d55 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -1,6 +1,8 @@
@@ -151,7 +158,7 @@ index 7f2be23394..dae58d3476 100644
*/
#ifndef __LINUX_ARM_SMCCC_H
#define __LINUX_ARM_SMCCC_H
@@ -66,6 +68,47 @@ struct arm_smccc_res {
@@ -70,6 +72,47 @@ struct arm_smccc_res {
unsigned long a3;
};
@@ -1,186 +0,0 @@
From 910760408430de32ad08b1e5ddf894cc9f2f3d0c Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Thu, 24 Jun 2021 09:25:00 +0100
Subject: [PATCH 01/26] cmd: load: add load command for memory mapped
cp.b is used a lot as a way to load binaries to memory and execute
them, however we may need to integrate this with the efi subsystem to
set it up as a bootdev.
So, introduce a loadm command that will be consistent with the other
loadX commands and will call the efi API's.
ex: loadm $kernel_addr $kernel_addr_r $kernel_size
with this a kernel with CONFIG_EFI_STUB enabled will be loaded and
then subsequently booted with bootefi command.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Accepted [2022.10-rc1]
---
README | 1 +
cmd/Kconfig | 6 ++++
cmd/bootefi.c | 12 ++++++++
cmd/load.c | 48 ++++++++++++++++++++++++++++++++
include/efi_loader.h | 2 ++
lib/efi_loader/efi_device_path.c | 9 ++++++
6 files changed, 78 insertions(+)
diff --git a/README b/README
index b7ab6e5070..cd76f95e74 100644
--- a/README
+++ b/README
@@ -2578,6 +2578,7 @@ rarpboot- boot image via network using RARP/TFTP protocol
diskboot- boot from IDE devicebootd - boot default, i.e., run 'bootcmd'
loads - load S-Record file over serial line
loadb - load binary file over serial line (kermit mode)
+loadm - load binary blob from source address to destination address
md - memory display
mm - memory modify (auto-incrementing)
nm - memory modify (constant address)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 09193b61b9..ba2f321ae9 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1143,6 +1143,12 @@ config CMD_LOADB
help
Load a binary file over serial line.
+config CMD_LOADM
+ bool "loadm"
+ default y
+ help
+ Load a binary over memory mapped.
+
config CMD_LOADS
bool "loads"
default y
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 827fcd97df..37ce659fa1 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -34,6 +34,18 @@ static struct efi_device_path *bootefi_device_path;
static void *image_addr;
static size_t image_size;
+/**
+ * efi_get_image_parameters() - return image parameters
+ *
+ * @img_addr: address of loaded image in memory
+ * @img_size: size of loaded image
+ */
+void efi_get_image_parameters(void **img_addr, size_t *img_size)
+{
+ *img_addr = image_addr;
+ *img_size = image_size;
+}
+
/**
* efi_clear_bootdev() - clear boot device
*/
diff --git a/cmd/load.c b/cmd/load.c
index 7e4a552d90..1224a7f85b 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -1063,6 +1063,44 @@ static ulong load_serial_ymodem(ulong offset, int mode)
#endif
+#if defined(CONFIG_CMD_LOADM)
+static int do_load_memory_bin(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong addr, dest, size;
+ void *src, *dst;
+
+ if (argc != 4)
+ return CMD_RET_USAGE;
+
+ addr = simple_strtoul(argv[1], NULL, 16);
+
+ dest = simple_strtoul(argv[2], NULL, 16);
+
+ size = simple_strtoul(argv[3], NULL, 16);
+
+ if (!size) {
+ printf("loadm: can not load zero bytes\n");
+ return 1;
+ }
+
+ src = map_sysmem(addr, size);
+ dst = map_sysmem(dest, size);
+
+ memcpy(dst, src, size);
+
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
+
+ if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
+ efi_set_bootdev("Mem", "", "", map_sysmem(dest, 0), size);
+
+ printf("loaded bin to memory: size: %lu\n", size);
+
+ return 0;
+}
+#endif
+
/* -------------------------------------------------------------------- */
#if defined(CONFIG_CMD_LOADS)
@@ -1137,3 +1175,13 @@ U_BOOT_CMD(
);
#endif /* CONFIG_CMD_LOADB */
+
+#if defined(CONFIG_CMD_LOADM)
+U_BOOT_CMD(
+ loadm, 4, 0, do_load_memory_bin,
+ "load binary blob from source address to destination address",
+ "[src_addr] [dst_addr] [size]\n"
+ " - load a binary blob from one memory location to other"
+ " from src_addr to dst_addr by size bytes"
+);
+#endif /* CONFIG_CMD_LOADM */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 11930fbea8..5b41985244 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -591,6 +591,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
void efi_save_gd(void);
/* Call this to relocate the runtime section to an address space */
void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
+/* Call this to get image parameters */
+void efi_get_image_parameters(void **img_addr, size_t *img_size);
/* Add a new object to the object list. */
void efi_add_handle(efi_handle_t obj);
/* Create handle */
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 171661b897..2493d74326 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -1158,6 +1158,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
{
struct blk_desc *desc = NULL;
struct disk_partition fs_partition;
+ size_t image_size;
+ void *image_addr;
int part = 0;
char *filename;
char *s;
@@ -1173,6 +1175,13 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
} else if (!strcmp(dev, "Uart")) {
if (device)
*device = efi_dp_from_uart();
+ } else if (!strcmp(dev, "Mem")) {
+ efi_get_image_parameters(&image_addr, &image_size);
+
+ if (device)
+ *device = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
+ (uintptr_t)image_addr,
+ image_size);
} else {
part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
1);
--
2.17.1
@@ -1,682 +0,0 @@
From 3523b1bac430f10f02a31f7d013ea369e29656be Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 15 Feb 2022 09:44:10 +0000
Subject: [PATCH 02/26] arm: add support to corstone1000 platform
Corstone1000 is a platform from arm, which includes pre
verified Corstone SSE710 sub-system that combines Cortex-A and
Cortex-M processors [0].
This code adds the support for the Cortex-A35 implementation
at host side, it contains also the necessary bits to support
the Corstone 1000 FVP (Fixed Virtual Platform) [1] and also the
FPGA MPS3 board implementation of this platform. [2]
0: https://documentation-service.arm.com/static/619e02b1f45f0b1fbf3a8f16
1: https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps
2: https://documentation-service.arm.com/static/61f3f4d7fa8173727a1b71bf
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Accepted [2022.10-rc1]
---
arch/arm/Kconfig | 8 ++
arch/arm/dts/Makefile | 3 +
arch/arm/dts/corstone1000-fvp.dts | 23 +++
arch/arm/dts/corstone1000-mps3.dts | 32 +++++
arch/arm/dts/corstone1000.dtsi | 169 +++++++++++++++++++++++
board/armltd/corstone1000/Kconfig | 12 ++
board/armltd/corstone1000/MAINTAINERS | 7 +
board/armltd/corstone1000/Makefile | 7 +
board/armltd/corstone1000/corstone1000.c | 125 +++++++++++++++++
configs/corstone1000_defconfig | 80 +++++++++++
include/configs/corstone1000.h | 86 ++++++++++++
11 files changed, 552 insertions(+)
create mode 100644 arch/arm/dts/corstone1000-fvp.dts
create mode 100644 arch/arm/dts/corstone1000-mps3.dts
create mode 100644 arch/arm/dts/corstone1000.dtsi
create mode 100644 board/armltd/corstone1000/Kconfig
create mode 100644 board/armltd/corstone1000/MAINTAINERS
create mode 100644 board/armltd/corstone1000/Makefile
create mode 100644 board/armltd/corstone1000/corstone1000.c
create mode 100644 configs/corstone1000_defconfig
create mode 100644 include/configs/corstone1000.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9898c7d68e..2fc2b7d20f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1347,6 +1347,12 @@ config ARCH_VEXPRESS64
select ENV_IS_IN_FLASH if MTD
imply DISTRO_DEFAULTS
+config TARGET_CORSTONE1000
+ bool "Support Corstone1000 Platform"
+ select ARM64
+ select PL01X_SERIAL
+ select DM
+
config TARGET_TOTAL_COMPUTE
bool "Support Total Compute Platform"
select ARM64
@@ -2295,6 +2301,8 @@ source "arch/arm/mach-npcm/Kconfig"
source "board/armltd/total_compute/Kconfig"
+source "board/armltd/corstone1000/Kconfig"
+
source "board/bosch/shc/Kconfig"
source "board/bosch/guardian/Kconfig"
source "board/Marvell/octeontx/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a7e0d9f6c0..8c8f15b6a8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1265,6 +1265,9 @@ dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
dtb-$(CONFIG_ARCH_QEMU) += qemu-arm.dtb qemu-arm64.dtb
+dtb-$(CONFIG_TARGET_CORSTONE1000) += corstone1000-mps3.dtb \
+ corstone1000-fvp.dtb
+
include $(srctree)/scripts/Makefile.dts
targets += $(dtb-y)
diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
new file mode 100644
index 0000000000..1fcc137a49
--- /dev/null
+++ b/arch/arm/dts/corstone1000-fvp.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
+ *
+ */
+
+/dts-v1/;
+
+#include "corstone1000.dtsi"
+
+/ {
+ model = "ARM Corstone1000 FVP (Fixed Virtual Platform)";
+ compatible = "arm,corstone1000-fvp";
+
+ smsc: ethernet@4010000 {
+ compatible = "smsc,lan91c111";
+ reg = <0x40100000 0x10000>;
+ phy-mode = "mii";
+ interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
+ reg-io-width = <2>;
+ };
+};
diff --git a/arch/arm/dts/corstone1000-mps3.dts b/arch/arm/dts/corstone1000-mps3.dts
new file mode 100644
index 0000000000..e3146747c2
--- /dev/null
+++ b/arch/arm/dts/corstone1000-mps3.dts
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
+ *
+ */
+
+/dts-v1/;
+
+#include "corstone1000.dtsi"
+
+/ {
+ model = "ARM Corstone1000 FPGA MPS3 board";
+ compatible = "arm,corstone1000-mps3";
+
+ smsc: ethernet@4010000 {
+ compatible = "smsc,lan9220", "smsc,lan9115";
+ reg = <0x40100000 0x10000>;
+ phy-mode = "mii";
+ interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
+ reg-io-width = <2>;
+ smsc,irq-push-pull;
+ };
+
+ usb_host: usb@40200000 {
+ compatible = "nxp,usb-isp1763";
+ reg = <0x40200000 0x100000>;
+ interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+ bus-width = <16>;
+ dr_mode = "host";
+ };
+};
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
new file mode 100644
index 0000000000..d0194aa893
--- /dev/null
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -0,0 +1,169 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
+ *
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+ interrupt-parent = <&gic>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ aliases {
+ serial0 = &uart0;
+ serial1 = &uart1;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ };
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu: cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a35";
+ reg = <0>;
+ next-level-cache = <&L2_0>;
+ };
+ };
+
+ memory@88200000 {
+ device_type = "memory";
+ reg = <0x88200000 0x77e00000>;
+ };
+
+ gic: interrupt-controller@1c000000 {
+ compatible = "arm,gic-400";
+ #interrupt-cells = <3>;
+ #address-cells = <0>;
+ interrupt-controller;
+ reg = <0x1c010000 0x1000>,
+ <0x1c02f000 0x2000>,
+ <0x1c04f000 0x1000>,
+ <0x1c06f000 0x2000>;
+ interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(1) |
+ IRQ_TYPE_LEVEL_LOW)>;
+ };
+
+ L2_0: l2-cache0 {
+ compatible = "cache";
+ cache-level = <2>;
+ cache-size = <0x80000>;
+ cache-line-size = <64>;
+ cache-sets = <1024>;
+ };
+
+ refclk100mhz: refclk100mhz {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <100000000>;
+ clock-output-names = "apb_pclk";
+ };
+
+ smbclk: refclk24mhzx2 {
+ /* Reference 24MHz clock x 2 */
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <48000000>;
+ clock-output-names = "smclk";
+ };
+
+ timer {
+ compatible = "arm,armv8-timer";
+ interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) |
+ IRQ_TYPE_LEVEL_LOW)>,
+ <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) |
+ IRQ_TYPE_LEVEL_LOW)>,
+ <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) |
+ IRQ_TYPE_LEVEL_LOW)>,
+ <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) |
+ IRQ_TYPE_LEVEL_LOW)>;
+ };
+
+ uartclk: uartclk {
+ /* UART clock - 50MHz */
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <50000000>;
+ clock-output-names = "uartclk";
+ };
+
+ psci {
+ compatible = "arm,psci-1.0", "arm,psci-0.2";
+ method = "smc";
+ };
+
+ soc {
+ compatible = "simple-bus";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ interrupt-parent = <&gic>;
+ ranges;
+
+ timer@1a220000 {
+ compatible = "arm,armv7-timer-mem";
+ reg = <0x1a220000 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ clock-frequency = <50000000>;
+ ranges;
+
+ frame@1a230000 {
+ frame-number = <0>;
+ interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
+ reg = <0x1a230000 0x1000>;
+ };
+ };
+
+ uart0: serial@1a510000 {
+ compatible = "arm,pl011", "arm,primecell";
+ reg = <0x1a510000 0x1000>;
+ interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&uartclk>, <&refclk100mhz>;
+ clock-names = "uartclk", "apb_pclk";
+ };
+
+ uart1: serial@1a520000 {
+ compatible = "arm,pl011", "arm,primecell";
+ reg = <0x1a520000 0x1000>;
+ interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&uartclk>, <&refclk100mhz>;
+ clock-names = "uartclk", "apb_pclk";
+ };
+
+ mhu_hse1: mailbox@1b820000 {
+ compatible = "arm,mhuv2-tx", "arm,primecell";
+ reg = <0x1b820000 0x1000>;
+ clocks = <&refclk100mhz>;
+ clock-names = "apb_pclk";
+ interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
+ #mbox-cells = <2>;
+ arm,mhuv2-protocols = <0 0>;
+ secure-status = "okay"; /* secure-world-only */
+ status = "disabled";
+ };
+
+ mhu_seh1: mailbox@1b830000 {
+ compatible = "arm,mhuv2-rx", "arm,primecell";
+ reg = <0x1b830000 0x1000>;
+ clocks = <&refclk100mhz>;
+ clock-names = "apb_pclk";
+ interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
+ #mbox-cells = <2>;
+ arm,mhuv2-protocols = <0 0>;
+ secure-status = "okay"; /* secure-world-only */
+ status = "disabled";
+ };
+ };
+
+ arm_ffa: arm_ffa {
+ compatible = "arm,ffa";
+ method = "smc";
+ };
+};
diff --git a/board/armltd/corstone1000/Kconfig b/board/armltd/corstone1000/Kconfig
new file mode 100644
index 0000000000..709674d4cf
--- /dev/null
+++ b/board/armltd/corstone1000/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_CORSTONE1000
+
+config SYS_BOARD
+ default "corstone1000"
+
+config SYS_VENDOR
+ default "armltd"
+
+config SYS_CONFIG_NAME
+ default "corstone1000"
+
+endif
diff --git a/board/armltd/corstone1000/MAINTAINERS b/board/armltd/corstone1000/MAINTAINERS
new file mode 100644
index 0000000000..8c905686de
--- /dev/null
+++ b/board/armltd/corstone1000/MAINTAINERS
@@ -0,0 +1,7 @@
+CORSTONE1000 BOARD
+M: Rui Miguel Silva <rui.silva@linaro.org>
+M: Vishnu Banavath <vishnu.banavath@arm.com>
+S: Maintained
+F: board/armltd/corstone1000/
+F: include/configs/corstone1000.h
+F: configs/corstone1000_defconfig
diff --git a/board/armltd/corstone1000/Makefile b/board/armltd/corstone1000/Makefile
new file mode 100644
index 0000000000..77a82c2892
--- /dev/null
+++ b/board/armltd/corstone1000/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2022 Arm Limited
+# (C) Copyright 2022 Linaro
+# Rui Miguel Silva <rui.silva@linaro.org>
+
+obj-y := corstone1000.o
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
new file mode 100644
index 0000000000..2fa485ff37
--- /dev/null
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022 ARM Limited
+ * (C) Copyright 2022 Linaro
+ * Rui Miguel Silva <rui.silva@linaro.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/platform_data/serial_pl01x.h>
+#include <asm/armv8/mmu.h>
+#include <asm/global_data.h>
+
+
+static const struct pl01x_serial_plat serial_plat = {
+ .base = V2M_UART0,
+ .type = TYPE_PL011,
+ .clock = CONFIG_PL011_CLOCK,
+};
+
+U_BOOT_DRVINFO(corstone1000_serials) = {
+ .name = "serial_pl01x",
+ .plat = &serial_plat,
+};
+
+static struct mm_region corstone1000_mem_map[] = {
+ {
+ /* CVM */
+ .virt = 0x02000000UL,
+ .phys = 0x02000000UL,
+ .size = 0x02000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* QSPI */
+ .virt = 0x08000000UL,
+ .phys = 0x08000000UL,
+ .size = 0x08000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* Host Peripherals */
+ .virt = 0x1A000000UL,
+ .phys = 0x1A000000UL,
+ .size = 0x26000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* USB */
+ .virt = 0x40200000UL,
+ .phys = 0x40200000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* ethernet */
+ .virt = 0x40100000UL,
+ .phys = 0x40100000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* OCVM */
+ .virt = 0x80000000UL,
+ .phys = 0x80000000UL,
+ .size = 0x80000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* List terminator */
+ 0,
+ }
+};
+
+struct mm_region *mem_map = corstone1000_mem_map;
+
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+}
+
+int board_init(void)
+{
+ return 0;
+}
+
+int dram_init(void)
+{
+ gd->ram_size = PHYS_SDRAM_1_SIZE;
+
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+
+ return 0;
+}
+
+/*
+ * Board specific ethernet initialization routine.
+ * */
+int board_eth_init(struct bd_info *bis)
+{
+ int rc = 0;
+
+#ifndef CONFIG_DM_ETH
+#ifdef CONFIG_SMC91111
+ rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
+#endif
+#ifdef CONFIG_SMC911X
+ rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
+#endif
+#endif
+
+ return rc;
+}
+
+void reset_cpu(ulong addr)
+{
+}
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
new file mode 100644
index 0000000000..02f931b0d4
--- /dev/null
+++ b/configs/corstone1000_defconfig
@@ -0,0 +1,80 @@
+CONFIG_ARM=y
+CONFIG_TARGET_CORSTONE1000=y
+CONFIG_SYS_TEXT_BASE=0x80000000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_MALLOC_LEN=0x2000000
+CONFIG_SYS_LOAD_ADDR=0x82100000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING=" corstone1000 aarch64 "
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
+CONFIG_LOGLEVEL=7
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="corstone1000# "
+# CONFIG_CMD_CONSOLE is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTM=y
+CONFIG_CMD_LOADM=y
+CONFIG_CMD_BOOTEFI=y
+CONFIG_EFI_LOADER=y
+CONFIG_EFI_PARTITION=y
+CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
+CONFIG_CMD_BOOTEFI_HELLO=y
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_ENV_EXISTS is not set
+CONFIG_CMD_NVEDIT_EFI=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_USB=y
+CONFIG_CMD_ITEST=y
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_MII=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EFIDEBUG=y
+CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_REGMAP=y
+# CONFIG_MMC is not set
+CONFIG_DM_SERIAL=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_STORAGE=y
+CONFIG_EFI_MM_COMM_TEE=y
+# CONFIG_OPTEE is not set
+# CONFIG_GENERATE_SMBIOS_TABLE is not set
+# CONFIG_HEXDUMP is not set
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+# CONFIG_EFI_CAPSULE_ON_DISK_EARLY is not set
+# CONFIG_EFI_CAPSULE_AUTHENTICATE is not set
+CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
+CONFIG_EFI_SECURE_BOOT=y
+CONFIG_DM_RTC=y
+CONFIG_CMD_RTC=y
+CONFIG_EFI_GET_TIME=y
+CONFIG_EFI_SET_TIME=y
+CONFIG_RTC_EMULATION=y
+CONFIG_PSCI_RESET=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_CMD_DHCP=y
+CONFIG_SMC911X=y
+CONFIG_SMC911X_BASE=0x40100000
+CONFIG_DM_ETH=y
+CONFIG_PHY_SMSC=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_GETTIME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_VERSION_VARIABLE=y
+CONFIG_PHYLIB=y
+CONFIG_PHY=y
+CONFIG_RAM=y
+CONFIG_ERRNO_STR=y
+CONFIG_CMD_EDITENV=y
+CONFIG_MISC=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
new file mode 100644
index 0000000000..cf166f107e
--- /dev/null
+++ b/include/configs/corstone1000.h
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2022 ARM Limited
+ * (C) Copyright 2022 Linaro
+ * Rui Miguel Silva <rui.silva@linaro.org>
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+ *
+ * Configuration for Corstone1000. Parts were derived from other ARM
+ * configurations.
+ */
+
+#ifndef __CORSTONE1000_H
+#define __CORSTONE1000_H
+
+#include <linux/sizes.h>
+
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+#define CONFIG_SYS_HZ 1000
+
+#define V2M_SRAM0 0x02000000
+#define V2M_QSPI 0x08000000
+
+#define V2M_DEBUG 0x10000000
+#define V2M_BASE_PERIPH 0x1A000000
+
+#define V2M_BASE 0x80000000
+
+#define V2M_PERIPH_OFFSET(x) (x << 16)
+
+#define V2M_SYSID (V2M_BASE_PERIPH)
+#define V2M_SYSCTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(1))
+
+#define V2M_COUNTER_CTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(32))
+#define V2M_COUNTER_READ (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(33))
+
+#define V2M_TIMER_CTL (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(34))
+#define V2M_TIMER_BASE0 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(35))
+
+#define V2M_UART0 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(81))
+#define V2M_UART1 (V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(82))
+
+#define CONFIG_PL011_CLOCK 50000000
+
+/* Physical Memory Map */
+#define PHYS_SDRAM_1 (V2M_BASE)
+#define PHYS_SDRAM_1_SIZE 0x80000000
+
+#define CONFIG_ENV_SECT_SIZE SZ_64K
+
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
+#define CONFIG_SYS_MAXARGS 64 /* max command args */
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "usb_pgood_delay=250\0" \
+ "boot_bank_flag=0x08002000\0" \
+ "kernel_addr_bank_0=0x083EE000\0" \
+ "kernel_addr_bank_1=0x0936E000\0" \
+ "retrieve_kernel_load_addr=" \
+ "if itest.l *${boot_bank_flag} == 0; then " \
+ "setenv kernel_addr $kernel_addr_bank_0;" \
+ "else " \
+ "setenv kernel_addr $kernel_addr_bank_1;" \
+ "fi;" \
+ "\0" \
+ "kernel_addr_r=0x88200000\0" \
+ "fdt_high=0xffffffff\0"
+
+/*
+ * config_distro_bootcmd define the boot command to distro_bootcmd, but we here
+ * want to first try to load a kernel if exists, override that config then
+ */
+#undef CONFIG_BOOTCOMMAND
+
+#define CONFIG_BOOTCOMMAND \
+ "run retrieve_kernel_load_addr;" \
+ "echo Loading kernel from $kernel_addr to memory ... ;" \
+ "loadm $kernel_addr $kernel_addr_r 0xc00000;" \
+ "usb start; usb reset;" \
+ "run distro_bootcmd;" \
+ "bootefi $kernel_addr_r $fdtcontroladdr;"
+#endif
--
2.17.1
@@ -0,0 +1,132 @@
From b226e6000de0b1f55d56c1193d1fde028d64abd3 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 4 Aug 2022 16:46:47 +0100
Subject: [PATCH 02/25] lib: uuid: introduce uuid_str_to_le_bin function
convert UUID string to little endian binary data
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8:
* use simple_strtoull() in uuid_str_to_le_bin() to support 32-bit platforms
v7:
* rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin()
* make uuid_str_to_le_bin() implementation similar to uuid_str_to_bin()
by using same APIs
v4:
* rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
a standalone commit (the current)
v3:
* introduce ffa_uuid_str_to_bin (provided by
arm_ffa: introduce Arm FF-A low-level driver)
---
include/uuid.h | 8 ++++++++
lib/uuid.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/include/uuid.h b/include/uuid.h
index 4a4883d3b5..293a8eb0a5 100644
--- a/include/uuid.h
+++ b/include/uuid.h
@@ -2,6 +2,8 @@
/*
* Copyright (C) 2014 Samsung Electronics
* Przemyslaw Marczak <p.marczak@samsung.com>
+ * (C) Copyright 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#ifndef __UUID_H__
#define __UUID_H__
@@ -44,4 +46,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
const char *uuid_guid_get_str(const unsigned char *guid_bin);
void gen_rand_uuid(unsigned char *uuid_bin);
void gen_rand_uuid_str(char *uuid_str, int str_format);
+
+/**
+ * uuid_str_to_le_bin - Converts a UUID string to little endian binary data
+ */
+int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
+
#endif
diff --git a/lib/uuid.c b/lib/uuid.c
index 465e1ac38f..d29f561a70 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2011 Calxeda, Inc.
+ * (C) Copyright 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#include <common.h>
@@ -346,6 +348,50 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
return 0;
}
+/**
+ * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
+ * @uuid_str: pointer to UUID string
+ * @uuid_bin: pointer to allocated array for little endian output [16B]
+ *
+ * UUID string is 36 characters (36 bytes):
+ *
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a little endian binary UUID, the string fields are reversed.
+ *
+ * Return:
+ *
+ * uuid_bin filled with little endian UUID data
+ * On success 0 is returned. Otherwise, failure code.
+ */
+int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
+{
+ u16 tmp16;
+ u32 tmp32;
+ u64 tmp64;
+
+ if (!uuid_str_valid(uuid_str) || !uuid_bin)
+ return -EINVAL;
+
+ tmp32 = cpu_to_le32(hextoul(uuid_str, NULL));
+ memcpy(uuid_bin, &tmp32, 4);
+
+ tmp16 = cpu_to_le16(hextoul(uuid_str + 9, NULL));
+ memcpy(uuid_bin + 4, &tmp16, 2);
+
+ tmp16 = cpu_to_le16(hextoul(uuid_str + 14, NULL));
+ memcpy(uuid_bin + 6, &tmp16, 2);
+
+ tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
+ memcpy(uuid_bin + 8, &tmp16, 2);
+
+ tmp64 = cpu_to_le64(simple_strtoull(uuid_str + 24, NULL, 16));
+ memcpy(uuid_bin + 10, &tmp64, 6);
+
+ return 0;
+}
+
/*
* uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
*
--
2.17.1
@@ -1,498 +0,0 @@
From 178da5bee196f44c4c10e9804674fe5ac0bc1176 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Mon, 28 Jun 2021 23:20:55 +0100
Subject: [PATCH 03/26] usb: common: move urb code to common
Move urb code from musb only use to a more common scope, so other
drivers in the future can use the handling of urb in usb.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Accepted [2022.10-rc1]
---
drivers/usb/common/Makefile | 2 +
drivers/usb/common/usb_urb.c | 160 ++++++++++++++++++
drivers/usb/host/r8a66597-hcd.c | 30 +---
drivers/usb/musb-new/musb_core.c | 2 +-
drivers/usb/musb-new/musb_host.c | 2 +-
drivers/usb/musb-new/musb_host.h | 2 +-
drivers/usb/musb-new/musb_uboot.c | 38 +----
drivers/usb/musb-new/musb_uboot.h | 2 +-
.../linux/usb/usb_urb_compat.h | 46 ++++-
include/usb_defs.h | 32 ++++
10 files changed, 240 insertions(+), 76 deletions(-)
create mode 100644 drivers/usb/common/usb_urb.c
rename drivers/usb/musb-new/usb-compat.h => include/linux/usb/usb_urb_compat.h (60%)
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 3bedbf213f..dc05cb0a50 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -4,5 +4,7 @@
#
obj-$(CONFIG_$(SPL_)DM_USB) += common.o
+obj-$(CONFIG_USB_MUSB_HCD) += usb_urb.o
+obj-$(CONFIG_USB_MUSB_UDC) += usb_urb.o
obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
diff --git a/drivers/usb/common/usb_urb.c b/drivers/usb/common/usb_urb.c
new file mode 100644
index 0000000000..be3b6b9f32
--- /dev/null
+++ b/drivers/usb/common/usb_urb.c
@@ -0,0 +1,160 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common code for usb urb handling, based on the musb-new code
+ *
+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
+ *
+ */
+
+#include <dm/device.h>
+#include <dm/device_compat.h>
+#include <linux/usb/usb_urb_compat.h>
+
+#include <time.h>
+#include <usb.h>
+
+#if CONFIG_IS_ENABLED(DM_USB)
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+ struct udevice *parent = udev->dev->parent;
+
+ /*
+ * When called from usb-uclass.c: usb_scan_device() udev->dev points
+ * to the parent udevice, not the actual udevice belonging to the
+ * udev as the device is not instantiated yet.
+ *
+ * If dev is an usb-bus, then we are called from usb_scan_device() for
+ * an usb-device plugged directly into the root port, return NULL.
+ */
+ if (device_get_uclass_id(udev->dev) == UCLASS_USB)
+ return NULL;
+
+ /*
+ * If these 2 are not the same we are being called from
+ * usb_scan_device() and udev itself is the parent.
+ */
+ if (dev_get_parent_priv(udev->dev) != udev)
+ return udev;
+
+ /* We are being called normally, use the parent pointer */
+ if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
+ return dev_get_parent_priv(parent);
+
+ return NULL;
+}
+#else
+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
+{
+ return udev->parent;
+}
+#endif
+
+static void usb_urb_complete(struct urb *urb)
+{
+ urb->dev->status &= ~USB_ST_NOT_PROC;
+ urb->dev->act_len = urb->actual_length;
+
+ if (urb->status == -EINPROGRESS)
+ urb->status = 0;
+}
+
+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
+ struct usb_device *dev, int endpoint_type,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup, int interval)
+{
+ int epnum = usb_pipeendpoint(pipe);
+ int is_in = usb_pipein(pipe);
+ u16 maxpacketsize = is_in ? dev->epmaxpacketin[epnum] :
+ dev->epmaxpacketout[epnum];
+
+ memset(urb, 0, sizeof(struct urb));
+ memset(hep, 0, sizeof(struct usb_host_endpoint));
+ INIT_LIST_HEAD(&hep->urb_list);
+ INIT_LIST_HEAD(&urb->urb_list);
+ urb->ep = hep;
+ urb->complete = usb_urb_complete;
+ urb->status = -EINPROGRESS;
+ urb->dev = dev;
+ urb->pipe = pipe;
+ urb->transfer_buffer = buffer;
+ urb->transfer_dma = (unsigned long)buffer;
+ urb->transfer_buffer_length = len;
+ urb->setup_packet = (unsigned char *)setup;
+
+ urb->ep->desc.wMaxPacketSize = __cpu_to_le16(maxpacketsize);
+ urb->ep->desc.bmAttributes = endpoint_type;
+ urb->ep->desc.bEndpointAddress = ((is_in ? USB_DIR_IN : USB_DIR_OUT) |
+ epnum);
+ urb->ep->desc.bInterval = interval;
+}
+
+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb)
+{
+ const struct usb_urb_ops *ops = hcd->urb_ops;
+ unsigned long timeout;
+ int ret;
+
+ if (!ops)
+ return -EINVAL;
+
+ ret = ops->urb_enqueue(hcd, urb, 0);
+ if (ret < 0) {
+ printf("Failed to enqueue URB to controller\n");
+ return ret;
+ }
+
+ timeout = get_timer(0) + USB_TIMEOUT_MS(urb->pipe);
+ do {
+ if (ctrlc())
+ return -EIO;
+ ops->isr(0, hcd);
+ } while (urb->status == -EINPROGRESS && get_timer(0) < timeout);
+
+ if (urb->status == -EINPROGRESS)
+ ops->urb_dequeue(hcd, urb, -ETIME);
+
+ return urb->status;
+}
+
+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep,
+ struct usb_device *dev, unsigned long pipe,
+ void *buffer, int len, struct devrequest *setup,
+ int interval, enum usb_device_speed speed)
+{
+ const struct usb_urb_ops *ops = hcd->urb_ops;
+
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_CONTROL, pipe, buffer,
+ len, setup, 0);
+
+ /* Fix speed for non hub-attached devices */
+ if (!usb_dev_get_parent(dev)) {
+ dev->speed = speed;
+ if (ops->hub_control)
+ return ops->hub_control(hcd, dev, pipe, buffer, len,
+ setup);
+ }
+
+ return usb_urb_submit(hcd, urb);
+}
+
+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len)
+{
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_BULK, pipe, buffer, len,
+ NULL, 0);
+
+ return usb_urb_submit(hcd, urb);
+}
+
+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len, int interval)
+{
+ usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_INT, pipe, buffer, len,
+ NULL, interval);
+
+ return usb_urb_submit(hcd, urb);
+}
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index f1fc93f3d4..3ccbc16da3 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -14,6 +14,7 @@
#include <dm/device_compat.h>
#include <linux/delay.h>
#include <linux/iopoll.h>
+#include <linux/usb/usb_urb_compat.h>
#include <power/regulator.h>
#include "r8a66597.h"
@@ -24,35 +25,6 @@
#define R8A66597_DPRINT(...)
#endif
-static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- struct udevice *parent = udev->dev->parent;
-
- /*
- * When called from usb-uclass.c: usb_scan_device() udev->dev points
- * to the parent udevice, not the actual udevice belonging to the
- * udev as the device is not instantiated yet.
- *
- * If dev is an usb-bus, then we are called from usb_scan_device() for
- * an usb-device plugged directly into the root port, return NULL.
- */
- if (device_get_uclass_id(udev->dev) == UCLASS_USB)
- return NULL;
-
- /*
- * If these 2 are not the same we are being called from
- * usb_scan_device() and udev itself is the parent.
- */
- if (dev_get_parent_priv(udev->dev) != udev)
- return udev;
-
- /* We are being called normally, use the parent pointer */
- if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
- return dev_get_parent_priv(parent);
-
- return NULL;
-}
-
static void get_hub_data(struct usb_device *dev, u16 *hub_devnum, u16 *hubport)
{
struct usb_device *parent = usb_dev_get_parent(dev);
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index 18d9bc805f..fc7af7484e 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -89,9 +89,9 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb/musb.h>
+#include <linux/usb/usb_urb_compat.h>
#include <asm/io.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#endif
#include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c
index acb2d40f3b..e5905d90d6 100644
--- a/drivers/usb/musb-new/musb_host.c
+++ b/drivers/usb/musb-new/musb_host.c
@@ -26,8 +26,8 @@
#include <dm/device_compat.h>
#include <usb.h>
#include <linux/bug.h>
+#include <linux/usb/usb_urb_compat.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#endif
#include "musb_core.h"
diff --git a/drivers/usb/musb-new/musb_host.h b/drivers/usb/musb-new/musb_host.h
index afc8fa35a7..5a604bdb0c 100644
--- a/drivers/usb/musb-new/musb_host.h
+++ b/drivers/usb/musb-new/musb_host.h
@@ -10,7 +10,7 @@
#ifndef _MUSB_HOST_H
#define _MUSB_HOST_H
#ifdef __UBOOT__
-#include "usb-compat.h"
+#include <linux/usb/usb_urb_compat.h>
#endif
static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 61ff68def2..d186facc7e 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -8,10 +8,10 @@
#include <linux/errno.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include <linux/usb/usb_urb_compat.h>
#include <usb.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#include "musb_core.h"
#include "musb_host.h"
#include "musb_gadget.h"
@@ -453,39 +453,3 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
return *musbp;
}
-
-#if CONFIG_IS_ENABLED(DM_USB)
-struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- struct udevice *parent = udev->dev->parent;
-
- /*
- * When called from usb-uclass.c: usb_scan_device() udev->dev points
- * to the parent udevice, not the actual udevice belonging to the
- * udev as the device is not instantiated yet.
- *
- * If dev is an usb-bus, then we are called from usb_scan_device() for
- * an usb-device plugged directly into the root port, return NULL.
- */
- if (device_get_uclass_id(udev->dev) == UCLASS_USB)
- return NULL;
-
- /*
- * If these 2 are not the same we are being called from
- * usb_scan_device() and udev itself is the parent.
- */
- if (dev_get_parent_priv(udev->dev) != udev)
- return udev;
-
- /* We are being called normally, use the parent pointer */
- if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
- return dev_get_parent_priv(parent);
-
- return NULL;
-}
-#else
-struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-{
- return udev->parent;
-}
-#endif
diff --git a/drivers/usb/musb-new/musb_uboot.h b/drivers/usb/musb-new/musb_uboot.h
index 18282efccc..6b162f03b1 100644
--- a/drivers/usb/musb-new/musb_uboot.h
+++ b/drivers/usb/musb-new/musb_uboot.h
@@ -8,8 +8,8 @@
#define __MUSB_UBOOT_H__
#include <usb.h>
+#include <linux/usb/usb_urb_compat.h>
#include "linux-compat.h"
-#include "usb-compat.h"
#include "musb_core.h"
struct musb_host_data {
diff --git a/drivers/usb/musb-new/usb-compat.h b/include/linux/usb/usb_urb_compat.h
similarity index 60%
rename from drivers/usb/musb-new/usb-compat.h
rename to include/linux/usb/usb_urb_compat.h
index df68c9220a..5ed96fa64e 100644
--- a/drivers/usb/musb-new/usb-compat.h
+++ b/include/linux/usb/usb_urb_compat.h
@@ -1,16 +1,31 @@
-#ifndef __USB_COMPAT_H__
-#define __USB_COMPAT_H__
+#ifndef __USB_URB_COMPAT_H__
+#define __USB_URB_COMPAT_H__
-#include "usb.h"
+#include <linux/compat.h>
+#include <usb.h>
struct udevice;
+struct urb;
+struct usb_hcd;
+
+
+struct usb_urb_ops {
+ int (*urb_enqueue)(struct usb_hcd *hcd, struct urb *urb,
+ gfp_t mem_flags);
+ int (*urb_dequeue)(struct usb_hcd *hcd, struct urb *urb, int status);
+ int (*hub_control)(struct usb_hcd *hcd, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup);
+ irqreturn_t (*isr)(int irq, void *priv);
+};
struct usb_hcd {
void *hcd_priv;
+ const struct usb_urb_ops *urb_ops;
};
struct usb_host_endpoint {
- struct usb_endpoint_descriptor desc;
+ struct usb_endpoint_descriptor desc;
struct list_head urb_list;
void *hcpriv;
};
@@ -23,8 +38,6 @@ struct usb_host_endpoint {
#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
-struct urb;
-
typedef void (*usb_complete_t)(struct urb *);
struct urb {
@@ -76,4 +89,25 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
*/
struct usb_device *usb_dev_get_parent(struct usb_device *udev);
+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep,
+ struct usb_device *dev, unsigned long pipe,
+ void *buffer, int len, struct devrequest *setup,
+ int interval, enum usb_device_speed speed);
+
+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len);
+
+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
+ struct usb_host_endpoint *hep, struct usb_device *dev,
+ unsigned long pipe, void *buffer, int len, int interval);
+
+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
+ struct usb_device *dev, int endpoint_type,
+ unsigned long pipe, void *buffer, int len,
+ struct devrequest *setup, int interval);
+
+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb);
+
#endif /* __USB_COMPAT_H__ */
diff --git a/include/usb_defs.h b/include/usb_defs.h
index 6dd2c997f9..ec00161710 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -81,6 +81,32 @@
#define EndpointOutRequest \
((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
+/* class requests from the USB 2.0 hub spec, table 11-15 */
+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
+/* GetBusState and SetHubDescriptor are optional, omitted */
+#define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
+ USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
+ USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
+ USB_REQ_GET_STATUS)
+#define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
+ USB_REQ_GET_STATUS)
+#define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
+ USB_REQ_SET_FEATURE)
+#define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ USB_REQ_SET_FEATURE)
+#define ClearTTBuffer HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_CLEAR_TT_BUFFER)
+#define ResetTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_RESET_TT)
+#define GetTTState HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
+ HUB_GET_TT_STATE)
+#define StopTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
+ HUB_STOP_TT)
+
/* Descriptor types */
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
@@ -289,10 +315,16 @@
#define USB_SS_PORT_STAT_C_CONFIG_ERROR 0x0080
/* wHubCharacteristics (masks) */
+#define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */
+#define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */
+#define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */
#define HUB_CHAR_LPSM 0x0003
#define HUB_CHAR_COMPOUND 0x0004
+#define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */
+#define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */
#define HUB_CHAR_OCPM 0x0018
#define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */
+#define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */
/*
* Hub Status & Hub Change bit masks
--
2.17.1
@@ -0,0 +1,73 @@
From 3035651bfc0dcdfd48d28acff6efe2f29bbe9439 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 6 Oct 2022 15:04:25 +0100
Subject: [PATCH 04/25] arm_ffa: efi: unmap RX/TX buffers
unmap RX/TX buffers at ExitBootServices()
Unmapping the RX/TX buffers created by u-boot is needed before EFI
runtime.
At EFI runtime the linux kernel takes care of allocating its own RX/TX
buffers and registering them with the secure world.
Secure world should be using the RX/TX buffers created by the kernel.
So, RX/TX buffers created by u-boot must be unmapped.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8: pass NULL device pointer to the FF-A bus operation
v7: replace debug() by log_err()
---
lib/efi_loader/efi_boottime.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 6f7333638a..caa64028be 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -3,6 +3,9 @@
* EFI application boot time services
*
* Copyright (c) 2016 Alexander Graf
+ *
+ * (C) Copyright 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#include <common.h>
@@ -23,6 +26,10 @@
#include <asm/setjmp.h>
#include <linux/libfdt_env.h>
+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
+#include <arm_ffa.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
/* Task priority level */
@@ -2178,6 +2185,12 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
}
+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
+ /* unmap FF-A RX/TX buffers */
+ if (ffa_bus_ops_get()->rxtx_unmap(NULL))
+ log_err("Can't unmap FF-A RX/TX buffers\n");
+#endif
+
/* Patch out unsupported runtime function */
efi_runtime_detach();
--
2.17.1
@@ -1,20 +1,35 @@
From a09ed2542f4d991fef61bd51f87d373f44ad1ff3 Mon Sep 17 00:00:00 2001
From e9ec690a3f0d34631729a17c1734d66111e768e1 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Jun 2022 12:46:38 +0100
Subject: [PATCH 10/26] arm_ffa: introduce armffa command
Subject: [PATCH 05/25] arm_ffa: introduce armffa command
Provide armffa command showcasing the use of the FF-A driver
The armffa command allows to query secure partitions data from
the secure world and exchanging messages with the partitions.
the secure world and exchanging messages with the partitions
using 64-bit FF-A direct messaging.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8:
* update partition_info_get() second argument to be an SP count
* pass NULL device pointer to the FF-A bus discovery and operations
v7:
* adapt do_ffa_dev_list() following the recent update on
uclass_first_device/uclass_next_device functions (they return void now)
* set armffa command to use 64-bit direct messaging
v4:
* remove pattern data in do_ffa_msg_send_direct_req
@@ -32,32 +47,32 @@ v2:
v1:
* introduce armffa command
---
MAINTAINERS | 1 +
cmd/Kconfig | 10 ++
cmd/Makefile | 2 +
cmd/armffa.c | 242 +++++++++++++++++++++++++++++++
cmd/armffa.c | 237 +++++++++++++++++++++++++++++++
drivers/firmware/arm-ffa/Kconfig | 1 +
5 files changed, 256 insertions(+)
5 files changed, 251 insertions(+)
create mode 100644 cmd/armffa.c
diff --git a/MAINTAINERS b/MAINTAINERS
index e760b4ca3a..9f0a1b7387 100644
index 734fcb10c4..d50bdddea8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -247,6 +247,7 @@ F: include/configs/turris_*.h
@@ -251,6 +251,7 @@ F: configs/cortina_presidio-asic-pnand_defconfig
ARM FF-A
M: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
S: Maintained
+F: cmd/armffa.c
F: doc/README.ffa.drv
F: doc/arch/arm64.ffa.rst
F: drivers/firmware/arm-ffa/
F: include/arm_ffa.h
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ba2f321ae9..090e668125 100644
index 0e0be94f41..013d4c3da7 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -873,6 +873,16 @@ endmenu
@@ -912,6 +912,16 @@ endmenu
menu "Device access commands"
@@ -75,7 +90,7 @@ index ba2f321ae9..090e668125 100644
#depends on FLASH_CFI_DRIVER
bool "armflash"
diff --git a/cmd/Makefile b/cmd/Makefile
index 5e43a1e022..e40f52f1e4 100644
index 6e87522b62..979c6d59df 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,8 @@ obj-y += panic.o
@@ -89,10 +104,10 @@ index 5e43a1e022..e40f52f1e4 100644
obj-$(CONFIG_CMD_AES) += aes.o
diff --git a/cmd/armffa.c b/cmd/armffa.c
new file mode 100644
index 0000000000..9b56e8a830
index 0000000000..d2e8687bfb
--- /dev/null
+++ b/cmd/armffa.c
@@ -0,0 +1,242 @@
@@ -0,0 +1,237 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022 ARM Limited
@@ -126,7 +141,7 @@ index 0000000000..9b56e8a830
+static int do_ffa_get_singular_partition_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ u32 count = 0, size = 0;
+ u32 count = 0;
+ int ret;
+ struct ffa_partition_info *parts_info;
+ u32 info_idx;
@@ -135,7 +150,7 @@ index 0000000000..9b56e8a830
+ return -EINVAL;
+
+ /* Mode 1: getting the number of secure partitions */
+ ret = ffa_bus_ops_get()->partition_info_get(argv[0], &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, NULL);
+ if (ret != 0) {
+ ffa_err("Failure in querying partitions count (error code: %d)", ret);
+ return ret;
@@ -157,13 +172,11 @@ index 0000000000..9b56e8a830
+ if (!parts_info)
+ return -EINVAL;
+
+ size = count * sizeof(struct ffa_partition_info);
+
+ /*
+ * ask the driver to fill the buffer with the SPs info
+ */
+
+ ret = ffa_bus_ops_get()->partition_info_get(argv[0], &size, parts_info);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, parts_info);
+ if (ret != 0) {
+ ffa_err("Failure in querying partition(s) info (error code: %d)", ret);
+ free(parts_info);
@@ -224,7 +237,7 @@ index 0000000000..9b56e8a830
+ return -EINVAL;
+ }
+
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
+ if (ret == 0) {
+ u8 cnt;
+
@@ -257,16 +270,13 @@ index 0000000000..9b56e8a830
+int do_ffa_dev_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct udevice *dev = NULL;
+ int i, ret;
+ int i;
+
+ ffa_info("arm_ffa uclass entries:");
+
+ for (i = 0, ret = uclass_first_device(UCLASS_FFA, &dev);
+ for (i = 0, uclass_first_device(UCLASS_FFA, &dev);
+ dev;
+ ret = uclass_next_device(&dev), i++) {
+ if (ret)
+ break;
+
+ uclass_next_device(&dev), i++) {
+ ffa_info("entry %d - instance %08x, ops %08x, plat %08x",
+ i,
+ (u32)map_to_sysmem(dev),
@@ -274,7 +284,7 @@ index 0000000000..9b56e8a830
+ (u32)map_to_sysmem(dev_get_plat(dev)));
+ }
+
+ return cmd_process_error(cmdtp, ret);
+ return 0;
+}
+
+static struct cmd_tbl armffa_commands[] = {
@@ -315,7 +325,7 @@ index 0000000000..9b56e8a830
+ if (!armffa_cmd || argc > armffa_cmd->maxargs)
+ return CMD_RET_USAGE;
+
+ ret = ffa_bus_discover();
+ ret = ffa_bus_discover(NULL);
+ if (ret != 0)
+ return cmd_process_error(cmdtp, ret);
+
@@ -336,7 +346,7 @@ index 0000000000..9b56e8a830
+ "devlist\n"
+ " - displays the arm_ffa device info\n");
diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig
index aceb61cf49..40b467b0a5 100644
index e4914b9bc7..be4df89d23 100644
--- a/drivers/firmware/arm-ffa/Kconfig
+++ b/drivers/firmware/arm-ffa/Kconfig
@@ -4,6 +4,7 @@ config ARM_FFA_TRANSPORT
@@ -1,49 +0,0 @@
From 8717357eff3f4172c74f0b10078c31cdff9bcc41 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Thu, 3 Mar 2022 16:52:02 +0000
Subject: [PATCH 05/26] corstone1000: enable isp1763 usb controller
MPS3 board have a ISP1763 usb controller, add the
correspondent mmio area and enable it to be used for mass
storage access for example.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Accepted [2022.10-rc1]
---
configs/corstone1000_defconfig | 1 +
include/configs/corstone1000.h | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 02f931b0d4..e573fe6fe6 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -42,6 +42,7 @@ CONFIG_REGMAP=y
CONFIG_DM_SERIAL=y
CONFIG_USB=y
CONFIG_DM_USB=y
+CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
CONFIG_EFI_MM_COMM_TEE=y
# CONFIG_OPTEE is not set
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index cf166f107e..8ba0effb0a 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -55,7 +55,13 @@
#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
#define CONFIG_SYS_MAXARGS 64 /* max command args */
+#define BOOT_TARGET_DEVICES(func) \
+ func(USB, usb, 0)
+
+#include <config_distro_bootcmd.h>
+
#define CONFIG_EXTRA_ENV_SETTINGS \
+ BOOTENV \
"usb_pgood_delay=250\0" \
"boot_bank_flag=0x08002000\0" \
"kernel_addr_bank_0=0x083EE000\0" \
--
2.17.1
@@ -1,7 +1,7 @@
From 553b57e39808ef04bc6aa54e0324f92b0175e476 Mon Sep 17 00:00:00 2001
From 6d28dcdc36ad87b6987c7f920e06165c74eca59d Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Jun 2022 12:55:08 +0100
Subject: [PATCH 11/26] arm_ffa: introduce the FF-A Sandbox driver
Date: Tue, 29 Nov 2022 14:44:36 +0000
Subject: [PATCH 06/25] arm_ffa: introduce the FF-A Sandbox driver
Provide a Sandbox driver to emulate the FF-A ABIs
@@ -12,67 +12,63 @@ The Sandbox driver provides operations allowing the test
application to read the status of all the inspected ABIs
and perform functional tests based on that.
sandbox driver supports only 64-bit direct messaging.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8: update ffa_bus_prvdata_get() to return a pointer rather than
a pointer address
v7: state that sandbox driver supports only 64-bit direct messaging
v4: align sandbox driver with the new FF-A driver interfaces
and new way of error handling
and new way of error handling
v1: introduce the sandbox driver
---
MAINTAINERS | 1 +
common/board_r.c | 2 +-
configs/sandbox64_defconfig | 2 +
configs/sandbox_defconfig | 2 +
doc/arch/sandbox.rst | 1 +
drivers/firmware/arm-ffa/Kconfig | 10 +-
drivers/firmware/arm-ffa/Kconfig | 9 +-
drivers/firmware/arm-ffa/Makefile | 1 +
drivers/firmware/arm-ffa/arm_ffa_prv.h | 15 +-
drivers/firmware/arm-ffa/core.c | 24 +-
drivers/firmware/arm-ffa/core.c | 22 +-
drivers/firmware/arm-ffa/sandbox.c | 659 ++++++++++++++++++
.../firmware/arm-ffa/sandbox_arm_ffa_prv.h | 144 ++++
include/arm_ffa.h | 2 +-
include/sandbox_arm_ffa.h | 91 +++
lib/efi_loader/efi_boottime.c | 2 +-
14 files changed, 941 insertions(+), 15 deletions(-)
13 files changed, 938 insertions(+), 13 deletions(-)
create mode 100644 drivers/firmware/arm-ffa/sandbox.c
create mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h
create mode 100644 include/sandbox_arm_ffa.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 9f0a1b7387..96157db6b6 100644
index d50bdddea8..23cebbd526 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -251,6 +251,7 @@ F: cmd/armffa.c
F: doc/README.ffa.drv
@@ -255,6 +255,7 @@ F: cmd/armffa.c
F: doc/arch/arm64.ffa.rst
F: drivers/firmware/arm-ffa/
F: include/arm_ffa.h
+F: include/sandbox_arm_ffa.h
ARM FREESCALE IMX
M: Stefano Babic <sbabic@denx.de>
diff --git a/common/board_r.c b/common/board_r.c
index c75634286b..f838cd5958 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -783,7 +783,7 @@ static init_fnc_t init_sequence_r[] = {
INIT_FUNC_WATCHDOG_RESET
initr_net,
#endif
-#ifdef CONFIG_ARM_FFA_TRANSPORT
+#if defined(CONFIG_ARM_FFA_TRANSPORT) && !defined(CONFIG_SANDBOX_FFA)
ffa_bus_discover,
#endif
#ifdef CONFIG_POST
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index d7f22b39ae..78bc5aaa96 100644
index 290d1506c2..36e6448968 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -250,3 +250,5 @@ CONFIG_TEST_FDTDEC=y
@@ -248,3 +248,5 @@ CONFIG_TEST_FDTDEC=y
CONFIG_UNIT_TEST=y
CONFIG_UT_TIME=y
CONFIG_UT_DM=y
@@ -80,10 +76,10 @@ index d7f22b39ae..78bc5aaa96 100644
+CONFIG_SANDBOX_FFA=y
\ No newline at end of file
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index c509a924e6..8942aa7157 100644
index ab5d3f19bf..8bf3848788 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -327,3 +327,5 @@ CONFIG_TEST_FDTDEC=y
@@ -328,3 +328,5 @@ CONFIG_TEST_FDTDEC=y
CONFIG_UNIT_TEST=y
CONFIG_UT_TIME=y
CONFIG_UT_DM=y
@@ -103,7 +99,7 @@ index 068d4a3be4..5d7e1b2c48 100644
- Chrome OS EC
- GPIO
diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig
index 40b467b0a5..263481de96 100644
index be4df89d23..b86f16d778 100644
--- a/drivers/firmware/arm-ffa/Kconfig
+++ b/drivers/firmware/arm-ffa/Kconfig
@@ -2,8 +2,8 @@
@@ -117,27 +113,26 @@ index 40b467b0a5..263481de96 100644
select CMD_ARMFFA
select LIB_UUID
select DEVRES
@@ -38,3 +38,9 @@ config ARM_FFA_EFI_RUNTIME_MODE
The driver Code needed at runtime is placed at EFI runtime code section.
Turning this on makes ffa_copy_runtime_data available for use and the driver
code placed at EFI runtime code section.
+
@@ -29,3 +29,8 @@ config ARM_FFA_TRANSPORT
For more details about the FF-A driver, please refer to doc/arch/arm64.ffa.rst
+config SANDBOX_FFA
+ bool "FF-A Sandbox driver"
+ depends on ARM_FFA_TRANSPORT && SANDBOX
+ help
+ This emulates the FF-A handling under Sandbox and allows to test the FF-A driver
diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile
index 0b9b0a61b4..d50060b836 100644
index 043a8915be..0d21d6b47a 100644
--- a/drivers/firmware/arm-ffa/Makefile
+++ b/drivers/firmware/arm-ffa/Makefile
@@ -5,3 +5,4 @@
@@ -4,3 +4,4 @@
# Abdellatif El Khlifi, Arm Limited, abdellatif.elkhlifi@arm.com.
obj-y += arm-ffa-uclass.o core.o
obj-$(CONFIG_ARM_FFA_EFI_RUNTIME_MODE) += efi_ffa_runtime_data_mgr.o
+obj-$(CONFIG_SANDBOX_FFA) += sandbox.o
diff --git a/drivers/firmware/arm-ffa/arm_ffa_prv.h b/drivers/firmware/arm-ffa/arm_ffa_prv.h
index 7bc90f7f66..3e0d4c112c 100644
index 4eea7dc036..bbc8b87069 100644
--- a/drivers/firmware/arm-ffa/arm_ffa_prv.h
+++ b/drivers/firmware/arm-ffa/arm_ffa_prv.h
@@ -19,6 +19,16 @@
@@ -157,7 +152,7 @@ index 7bc90f7f66..3e0d4c112c 100644
/* FF-A driver version definitions */
#define MAJOR_VERSION_MASK GENMASK(30, 16)
@@ -94,11 +104,6 @@ struct ffa_abi_errmap {
@@ -103,11 +113,6 @@ struct ffa_abi_errmap {
#define FFA_ERRMAP_COUNT (FFA_LAST_ID - FFA_FIRST_ID + 1)
#define FFA_ID_TO_ERRMAP_ID(ffa_id) ((ffa_id) - FFA_FIRST_ID)
@@ -170,10 +165,10 @@ index 7bc90f7f66..3e0d4c112c 100644
* struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET
* @a1-4: 32-bit words access to the UUID data
diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c
index 41c7b96e68..caba10caae 100644
index 0b1f8e6a07..560603b28b 100644
--- a/drivers/firmware/arm-ffa/core.c
+++ b/drivers/firmware/arm-ffa/core.c
@@ -1101,6 +1101,7 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
@@ -1072,6 +1072,7 @@ static int ffa_msg_send_direct_req(struct udevice *dev, u16 dst_part_id,
return ffa_to_std_errno(ffa_errno);
}
@@ -181,7 +176,7 @@ index 41c7b96e68..caba10caae 100644
/**
* __arm_ffa_fn_smc - SMC wrapper
* @args: FF-A ABI arguments to be copied to Xn registers
@@ -1114,6 +1115,7 @@ void __ffa_runtime __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
@@ -1085,6 +1086,7 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
{
arm_smccc_1_2_smc(&args, res);
}
@@ -189,7 +184,7 @@ index 41c7b96e68..caba10caae 100644
/**
* ffa_set_smc_conduit - Set the SMC conduit
@@ -1127,7 +1129,12 @@ void __ffa_runtime __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
@@ -1098,7 +1100,12 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
*/
static int ffa_set_smc_conduit(void)
{
@@ -203,19 +198,19 @@ index 41c7b96e68..caba10caae 100644
if (!ffa_priv_data->invoke_ffa_fn) {
ffa_err("failure to set the invoke function");
@@ -1304,17 +1311,18 @@ struct ffa_prvdata **ffa_bus_prvdata_get(void)
@@ -1275,17 +1282,18 @@ struct ffa_prvdata *ffa_bus_prvdata_get(void)
}
/**
- * ffa_bus_discover - discover FF-A bus and probe the arm_ffa device
- * ffa_bus_discover - discover FF-A bus and probe arm_ffa device
+ * ffa_bus_discover - discover FF-A bus and probe arm_ffa and sandbox_arm_ffa devices
* @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created
* successfully)
*
* This boot time function makes sure the FF-A bus is discoverable.
- * Then, the arm_ffa device is probed and ready to use.
+ * Then, the arm_ffa and sandbox_arm_ffa devices are ready to use.
+ *
* This function is called automatically at initcalls
* level (after u-boot relocation).
* This function makes sure the FF-A bus is discoverable.
- * When probing succeeds FF-A discovery is done. The arm_ffa device is ready to use.
+ * When probing succeeds FF-A discovery is done. The arm_ffa and sandbox_arm_ffa devices
+ * are ready to use.
*
* When the bus was already discovered successfully the discovery will not run again.
*
@@ -225,13 +220,9 @@ index 41c7b96e68..caba10caae 100644
* All FF-A clients should use the arm_ffa device to use the FF-A transport.
*
* Return:
@@ -1325,9 +1333,15 @@ int ffa_bus_discover(void)
{
int ret = 0;
- if (!ffa_priv_data)
+ if (!ffa_priv_data) {
ret = ffa_device_get();
@@ -1299,6 +1307,12 @@ int ffa_bus_discover(struct udevice **pdev)
if (!ffa_priv_data) {
ret = ffa_device_get(pdev);
+#if CONFIG_IS_ENABLED(SANDBOX_FFA)
+ if (ret == 0)
@@ -244,7 +235,7 @@ index 41c7b96e68..caba10caae 100644
diff --git a/drivers/firmware/arm-ffa/sandbox.c b/drivers/firmware/arm-ffa/sandbox.c
new file mode 100644
index 0000000000..16e1fdc809
index 0000000000..16f1ca926e
--- /dev/null
+++ b/drivers/firmware/arm-ffa/sandbox.c
@@ -0,0 +1,659 @@
@@ -680,7 +671,7 @@ index 0000000000..16e1fdc809
+ * @{a0-a7} , res: The SMC call arguments and return structure.
+ *
+ * This is the function that emulates FFA_MSG_SEND_DIRECT_{REQ,RESP}
+ * FF-A functions.
+ * FF-A functions. Only SMC 64-bit is supported in Sandbox.
+ *
+ * Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not supported.
+ * In case of success FFA_MSG_SEND_DIRECT_RESP is returned with default pattern data (0xff).
@@ -743,13 +734,13 @@ index 0000000000..16e1fdc809
+ if (!func_data)
+ return -EINVAL;
+
+ if (!func_data->data0 || func_data->data0_size != sizeof(struct ffa_prvdata **))
+ if (!func_data->data0 || func_data->data0_size != sizeof(struct ffa_prvdata *))
+ return -EINVAL;
+
+ if (!func_data->data1 || func_data->data1_size != sizeof(struct sandbox_ffa_prvdata **))
+ if (!func_data->data1 || func_data->data1_size != sizeof(struct sandbox_ffa_prvdata *))
+ return -EINVAL;
+
+ *((struct ffa_prvdata **)func_data->data0) = *(ffa_bus_prvdata_get());
+ *((struct ffa_prvdata **)func_data->data0) = ffa_bus_prvdata_get();
+ *((struct sandbox_ffa_prvdata **)func_data->data1) = &sandbox_ffa_priv_data;
+
+ return 0;
@@ -1058,17 +1049,17 @@ index 0000000000..4db57f5092
+
+#endif
diff --git a/include/arm_ffa.h b/include/arm_ffa.h
index f17b100497..665413a0c5 100644
index 74b16174c2..b88904fe50 100644
--- a/include/arm_ffa.h
+++ b/include/arm_ffa.h
@@ -111,7 +111,7 @@ struct ffa_bus_ops {
const struct ffa_bus_ops * __ffa_runtime ffa_bus_ops_get(void);
@@ -90,7 +90,7 @@ struct ffa_bus_ops {
const struct ffa_bus_ops *ffa_bus_ops_get(void);
/**
- * ffa_bus_discover - discover FF-A bus and probes the arm_ffa device
+ * ffa_bus_discover - discover FF-A bus and probes the arm_ffa and sandbox_arm_ffa devices
*/
int ffa_bus_discover(void);
int ffa_bus_discover(struct udevice **pdev);
diff --git a/include/sandbox_arm_ffa.h b/include/sandbox_arm_ffa.h
new file mode 100644
@@ -1168,18 +1159,18 @@ index 0000000000..d5df16f282
+
+#endif
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 0ec002ac8b..8fa9a58d76 100644
index caa64028be..1099ccc800 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2177,7 +2177,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
@@ -2185,7 +2185,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
}
-#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) && !CONFIG_IS_ENABLED(SANDBOX_FFA)
/* unmap FF-A RX/TX buffers */
if (ffa_bus_ops_get()->rxtx_unmap())
debug("[efi_boottime][ERROR]: can not unmap FF-A RX/TX buffers\n");
if (ffa_bus_ops_get()->rxtx_unmap(NULL))
log_err("Can't unmap FF-A RX/TX buffers\n");
--
2.17.1
@@ -1,59 +0,0 @@
From 83f9da30247c2d021658bc1b595c59ecc35eadf5 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Fri, 29 Jul 2022 13:07:43 +0100
Subject: [PATCH 07/26] arm64: smccc: clear the Xn registers after SMC calls
set to zero the x0-x17 registers
As per the SMCCC v1.2 spec, unused result and scratch registers can leak
information after an SMC call. We can mitigate against this risk by
returning zero in each register.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Changelog:
===============
v4:
* move the clearing code into a new macro: clear_gp_regs
v3:
* clear the Xn registers after SMC calls
arch/arm/cpu/armv8/smccc-call.S | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S
index ec6f299bc9..32f3eb8eeb 100644
--- a/arch/arm/cpu/armv8/smccc-call.S
+++ b/arch/arm/cpu/armv8/smccc-call.S
@@ -50,6 +50,12 @@ ENDPROC(__arm_smccc_hvc)
#ifdef CONFIG_ARM64
+ .macro clear_gp_regs
+ .irp n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
+ mov x\n, xzr
+ .endr
+ .endm
+
.macro SMCCC_1_2 instr
/* Save `res` and free a GPR that won't be clobbered */
stp x1, x19, [sp, #-16]!
@@ -84,6 +90,9 @@ ENDPROC(__arm_smccc_hvc)
stp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
stp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
+ /* x0-x17 registers can leak information after an SMC or HVC call. Let's clear them */
+ clear_gp_regs
+
/* Restore original x19 */
ldp xzr, x19, [sp], #16
ret
--
2.17.1
@@ -1,7 +1,7 @@
From dbc51066367481b5a45ce24f91571f83a022576e Mon Sep 17 00:00:00 2001
From de26427c9f9b450ab4a18352fa51f46b3b585bc1 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Jun 2022 17:26:06 +0100
Subject: [PATCH 12/26] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
Subject: [PATCH 07/25] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
Add functional test cases for the FF-A core driver
@@ -9,28 +9,38 @@ These tests rely on the FF-A Sandbox driver which helps in
inspecting the FF-A core driver.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8:
* update partition_info_get() second argument to be an SP count
* pass NULL device pointer to the FF-A bus discovery and operations
v7: set the tests to use 64-bit direct messaging
v4: align sandbox tests with the new FF-A driver interfaces
and new way of error handling
v1: introduce sandbox tests
---
MAINTAINERS | 1 +
test/dm/Makefile | 1 +
test/dm/ffa.c | 394 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 396 insertions(+)
test/dm/Makefile | 2 +
test/dm/ffa.c | 392 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 395 insertions(+)
create mode 100644 test/dm/ffa.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 96157db6b6..e5b71b0ade 100644
index 23cebbd526..e682db8d8f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -252,6 +252,7 @@ F: doc/README.ffa.drv
@@ -256,6 +256,7 @@ F: doc/arch/arm64.ffa.rst
F: drivers/firmware/arm-ffa/
F: include/arm_ffa.h
F: include/sandbox_arm_ffa.h
@@ -39,10 +49,18 @@ index 96157db6b6..e5b71b0ade 100644
ARM FREESCALE IMX
M: Stefano Babic <sbabic@denx.de>
diff --git a/test/dm/Makefile b/test/dm/Makefile
index f0a7c97e3d..f96f848046 100644
index 7543df8823..e5a791768e 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (c) 2013 Google, Inc
+# (C) Copyright 2022 ARM Limited
obj-$(CONFIG_UT_DM) += test-dm.o
@@ -81,6 +82,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
obj-$(CONFIG_ACPI_PMC) += pmc.o
obj-$(CONFIG_DM_PMIC) += pmic.o
obj-$(CONFIG_DM_PWM) += pwm.o
@@ -52,10 +70,10 @@ index f0a7c97e3d..f96f848046 100644
obj-y += regmap.o
diff --git a/test/dm/ffa.c b/test/dm/ffa.c
new file mode 100644
index 0000000000..052d5fc3f4
index 0000000000..128d8626a7
--- /dev/null
+++ b/test/dm/ffa.c
@@ -0,0 +1,394 @@
@@ -0,0 +1,392 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Functional tests for UCLASS_FFA class
@@ -228,7 +246,7 @@ index 0000000000..052d5fc3f4
+ struct ffa_send_direct_data msg = {0};
+ u8 cnt;
+
+ ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg));
+ ut_assertok(ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1));
+
+ for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++)
+ ut_assertok(((u64 *)&msg)[cnt] != 0xffffffffffffffff);
@@ -240,7 +258,7 @@ index 0000000000..052d5fc3f4
+ struct sandbox_ffa_prvdata *sdx_prvdata,
+ struct unit_test_state *uts)
+{
+ u32 count = 0, size = 0;
+ u32 count = 0;
+ struct ffa_partition_info *parts_info;
+ u32 info_idx, exp_info_idx;
+ int ret;
@@ -248,7 +266,7 @@ index 0000000000..052d5fc3f4
+ /*
+ * get from the driver the count of the SPs matching the UUID
+ */
+ ret = ffa_bus_ops_get()->partition_info_get(service_uuid, &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, NULL);
+ /* make sure partitions are detected */
+ ut_assertok(ret != 0);
+ ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
@@ -261,12 +279,10 @@ index 0000000000..052d5fc3f4
+ parts_info = calloc(count, sizeof(struct ffa_partition_info));
+ ut_assertok(!parts_info);
+
+ size = count * sizeof(struct ffa_partition_info);
+
+ /*
+ * ask the driver to fill the buffer with the SPs info
+ */
+ ret = ffa_bus_ops_get()->partition_info_get(service_uuid, &size, parts_info);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, parts_info);
+ if (ret != 0) {
+ free(parts_info);
+ ut_assertok(ret != 0);
@@ -317,7 +333,7 @@ index 0000000000..052d5fc3f4
+ int ret;
+
+ /* test probing FF-A devices */
+ ut_assertok(ffa_bus_discover());
+ ut_assertok(ffa_bus_discover(NULL));
+
+ /* get a pointer to the FF-A core and sandbox drivers private data */
+ func_data.data0 = &prvdata;
@@ -374,7 +390,7 @@ index 0000000000..052d5fc3f4
+ ut_assertok(check_rxbuf_release_flag(rxbuf_flag, uts));
+
+ /* test FFA_RXTX_UNMAP */
+ ut_assertok(ffa_bus_ops_get()->rxtx_unmap());
+ ut_assertok(ffa_bus_ops_get()->rxtx_unmap(NULL));
+
+ rxbuf_flag = 1;
+ ut_assertok(sandbox_ffa_query_core_state(FFA_RXTX_UNMAP, &func_data));
@@ -399,7 +415,7 @@ index 0000000000..052d5fc3f4
+ u16 part_id = 0;
+
+ /* test probing FF-A devices */
+ ut_assertok(ffa_bus_discover());
+ ut_assertok(ffa_bus_discover(NULL));
+
+ /* get a pointer to the FF-A core and sandbox drivers private data */
+ func_data.data0 = &prvdata;
@@ -418,32 +434,32 @@ index 0000000000..052d5fc3f4
+ ut_assertok(check_sandbox_dev(sdx_prvdata, uts));
+
+ /* query partitions count using invalid arguments */
+ ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid, NULL, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, NULL, NULL);
+ ut_assertok(ret != -EINVAL);
+
+ /* query partitions count using an invalid UUID string */
+ ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid_str, &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid_str, &count, NULL);
+ ut_assertok(ret != -EINVAL);
+
+ /* query partitions count using an invalid UUID (no matching SP) */
+ count = 0;
+ ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid, &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, &count, NULL);
+ ut_assertok(count != 0);
+
+ /* query partitions count using a valid UUID */
+ count = 0;
+ ret = ffa_bus_ops_get()->partition_info_get(valid_svc_uuid, &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, valid_svc_uuid, &count, NULL);
+ /* make sure partitions are detected */
+ ut_assertok(ret != 0);
+ ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
+
+ /* send data to an invalid partition */
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
+ ut_assertok(ret != -EINVAL);
+
+ /* send data to a valid partition */
+ part_id = prvdata->partitions.descs[0].info.id;
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
+ ut_assertok(ret != 0);
+
+ return CMD_RET_SUCCESS;
@@ -1,13 +1,16 @@
From 5be8c1d52045cbdc1adf79299792a6a49fef66c3 Mon Sep 17 00:00:00 2001
From 5507189fe37f1243d685c59ea52fa5643d3cc50c Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 6 Jun 2022 17:30:44 +0100
Subject: [PATCH 13/26] arm_ffa: introduce armffa command Sandbox test
Date: Tue, 29 Nov 2022 14:48:34 +0000
Subject: [PATCH 08/25] arm_ffa: introduce armffa command Sandbox test
Add Sandbox test for the armffa command
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
@@ -15,18 +18,18 @@ Changelog:
v4: drop use of helper APIs
v1: introduce armffa command sandbox test
---
MAINTAINERS | 1 +
test/cmd/Makefile | 1 +
test/cmd/armffa.c | 40 ++++++++++++++++++++++++++++++++++++++++
test/cmd/Makefile | 2 ++
test/cmd/armffa.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+)
create mode 100644 test/cmd/armffa.c
diff --git a/MAINTAINERS b/MAINTAINERS
index e5b71b0ade..505fffff14 100644
index e682db8d8f..72f01769c9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -252,6 +252,7 @@ F: doc/README.ffa.drv
@@ -256,6 +256,7 @@ F: doc/arch/arm64.ffa.rst
F: drivers/firmware/arm-ffa/
F: include/arm_ffa.h
F: include/sandbox_arm_ffa.h
@@ -35,20 +38,28 @@ index e5b71b0ade..505fffff14 100644
ARM FREESCALE IMX
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index a59adb1e6d..d9dc0809d6 100644
index c331757425..19e9d0a995 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (c) 2013 Google, Inc
+# (C) Copyright 2022 ARM Limited
ifdef CONFIG_HUSH_PARSER
obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
@@ -13,3 +14,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
+obj-$(CONFIG_SANDBOX_FFA) += armffa.o
diff --git a/test/cmd/armffa.c b/test/cmd/armffa.c
new file mode 100644
index 0000000000..531f82066e
index 0000000000..e04363ba63
--- /dev/null
+++ b/test/cmd/armffa.c
@@ -0,0 +1,40 @@
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for armffa command
@@ -58,7 +69,6 @@ index 0000000000..531f82066e
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <sandbox_arm_ffa.h>
+#include <string.h>
@@ -72,7 +82,7 @@ index 0000000000..531f82066e
+{
+ char ping_cmd[PING_CMD_SIZE] = {0};
+
+ ut_assertok(ffa_bus_discover());
+ ut_assertok(ffa_bus_discover(NULL));
+
+ /* armffa getpart <UUID> */
+ ut_assertok(run_command("armffa getpart " SANDBOX_SERVICE1_UUID, 0));
@@ -1,127 +0,0 @@
From af17d357674393565c8be15f21c86cba972963e7 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 4 Aug 2022 16:46:47 +0100
Subject: [PATCH 08/26] lib: uuid: introduce be_uuid_str_to_le_bin function
convert big endian UUID string to little endian buffer
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Changelog:
===============
v4:
* rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
a standalone commit (the current)
v3:
* introduce ffa_uuid_str_to_bin (provided by
arm_ffa: introduce Arm FF-A low-level driver)
include/uuid.h | 6 +++++
lib/uuid.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+)
diff --git a/include/uuid.h b/include/uuid.h
index 4a4883d3b5..5355230b5e 100644
--- a/include/uuid.h
+++ b/include/uuid.h
@@ -44,4 +44,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
const char *uuid_guid_get_str(const unsigned char *guid_bin);
void gen_rand_uuid(unsigned char *uuid_bin);
void gen_rand_uuid_str(char *uuid_str, int str_format);
+
+/**
+ * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little endian buffer
+ */
+int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
+
#endif
diff --git a/lib/uuid.c b/lib/uuid.c
index 284f8113ff..d0fa51d0bf 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2011 Calxeda, Inc.
+ * Copyright 2022 ARM Limited
*/
#include <common.h>
@@ -342,6 +343,68 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
return 0;
}
+/**
+ * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little endian buffer
+ * @uuid_str: UUID string in big endian format (36 bytes wide + '/0')
+ * @uuid_bin: preallocated 16 bytes UUID buffer in little endian format
+ *
+ * UUID string is 36 characters (36 bytes):
+ *
+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ * be be be be be
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a binary UUID, these endianness rules apply:
+ * be: means the field in the string is considered a big endian hex number
+ * and should be converted to little endian binary format
+ *
+ * Return:
+ *
+ * uuid_bin filled with little endian UUID data
+ * On success 0 is returned. Otherwise, failure code.
+ */
+int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
+{
+ u16 tmp16 = 0;
+ u32 tmp32 = 0;
+ u64 tmp64 = 0;
+
+ if (!uuid_str_valid(uuid_str) || !uuid_bin)
+ return -EINVAL;
+
+ /*
+ * reverse bytes from big to little endian
+ */
+ tmp32 = simple_strtoul(uuid_str, NULL, 16);
+ memcpy(uuid_bin, &tmp32, 4);
+
+ /*
+ * reverse bytes from big to little endian
+ */
+ tmp16 = simple_strtoul(uuid_str + 9, NULL, 16);
+ memcpy(uuid_bin + 4, &tmp16, 2);
+
+ /*
+ * reverse bytes from big to little endian
+ */
+ tmp16 = simple_strtoul(uuid_str + 14, NULL, 16);
+ memcpy(uuid_bin + 6, &tmp16, 2);
+
+ /*
+ * reverse bytes from big to little endian
+ */
+ tmp16 = simple_strtoul(uuid_str + 19, NULL, 16);
+ memcpy(uuid_bin + 8, &tmp16, 2);
+
+ /*
+ * reverse bytes from big to little endian
+ */
+ tmp64 = simple_strtoull(uuid_str + 24, NULL, 16);
+ memcpy(uuid_bin + 10, (char *)&tmp64, 6);
+
+ return 0;
+}
+
/*
* uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
*
--
2.17.1
@@ -1,12 +1,10 @@
From b3c7d84dcde6ee1cbc13e10664d24ffa220f5fb3 Mon Sep 17 00:00:00 2001
From cefc1d101c62e62e66f9cbf1775defde7d2c3d27 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 15 Aug 2022 15:12:49 +0100
Subject: [PATCH 14/26] arm_ffa: introduce FF-A MM communication
Subject: [PATCH 09/25] arm_ffa: efi: introduce FF-A MM communication
Add MM communication support using FF-A transport
Access an SP's service through EFI MM communication protocol.
This feature allows accessing MM partitions services through
EFI MM communication protocol. MM partitions such as StandAlonneMM
or smm-gateway secure partitions which reside in secure world.
@@ -26,18 +24,41 @@ buffer with the response data.
The response data is copied back to the communication buffer and
consumed by the EFI subsystem.
FF-A driver private data is copied to EFI runtime section at
ExitBootServices(). This garantees secure world partitions data are
available at EFI runtime level.
MM communication protocol supports FF-A 64-bit direct messaging.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8:
* isolate the compilation choices between FF-A and OP-TEE
* update partition_info_get() second argument to be an SP count
* pass NULL device pointer to the FF-A bus discovery and operations
v7:
* set the MM door bell event to use 64-bit direct messaging
* issue a compile time error when one of these macros are not found :
FFA_SHARED_MM_BUFFER_SIZE, FFA_SHARED_MM_BUFFER_OFFSET, FFA_SHARED_MM_BUFFER_ADDR
* make mm_sp_svc_uuid static
* replace EINVAL with ENOMEM in ffa_discover_mm_sp_id() when calloc() fails
* improve use of unmap_sysmem() in ffa_mm_communicate()
v6:
* add FF-A runtime discovery at MM communication level
* drop EFI runtime support for FF-A MM communication
* revert the changes in include/mm_communication.h for
efi_mm_communicate_header and smm_variable_access structures
v4:
* use the new FF-A driver interfaces
@@ -45,7 +66,7 @@ v4:
* copy FF-A driver private data to EFI runtime section at
ExitBootServices()
* drop use of FFA_ERR_STAT_SUCCESS error code
* replace EFI_BUFFER_TOO_SMALL by EFI_OUT_OF_RESOURCES
* replace EFI_BUFFER_TOO_SMALL with EFI_OUT_OF_RESOURCES
in ffa_mm_communicate(). No need for efi_memcpy_runtime() anymore
* revert the error log in mm_communicate() in case of failure
* remove packed attribute from efi_mm_communicate_header and
@@ -58,93 +79,26 @@ v2:
v1:
* introduce FF-A MM communication
arch/arm/cpu/armv8/cache.S | 16 ++
arch/arm/cpu/armv8/cache_v8.c | 3 +-
include/mm_communication.h | 7 +-
---
include/mm_communication.h | 5 +
lib/efi_loader/Kconfig | 14 +-
lib/efi_loader/efi_boottime.c | 7 +
lib/efi_loader/efi_variable_tee.c | 261 +++++++++++++++++++++++++++++-
6 files changed, 299 insertions(+), 9 deletions(-)
lib/efi_loader/efi_variable_tee.c | 294 +++++++++++++++++++++++++++++-
3 files changed, 307 insertions(+), 6 deletions(-)
diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S
index d1cee23437..f69ef64ed6 100644
--- a/arch/arm/cpu/armv8/cache.S
+++ b/arch/arm/cpu/armv8/cache.S
@@ -21,7 +21,11 @@
* x1: 0 clean & invalidate, 1 invalidate only
* x2~x9: clobbered
*/
+#ifdef CONFIG_EFI_LOADER
+.pushsection .text.efi_runtime, "ax"
+#else
.pushsection .text.__asm_dcache_level, "ax"
+#endif
ENTRY(__asm_dcache_level)
lsl x12, x0, #1
msr csselr_el1, x12 /* select cache level */
@@ -65,7 +69,11 @@ ENDPROC(__asm_dcache_level)
*
* flush or invalidate all data cache by SET/WAY.
*/
+#ifdef CONFIG_EFI_LOADER
+.pushsection .text.efi_runtime, "ax"
+#else
.pushsection .text.__asm_dcache_all, "ax"
+#endif
ENTRY(__asm_dcache_all)
mov x1, x0
dsb sy
@@ -109,7 +117,11 @@ ENTRY(__asm_flush_dcache_all)
ENDPROC(__asm_flush_dcache_all)
.popsection
+#ifdef CONFIG_EFI_LOADER
+.pushsection .text.efi_runtime, "ax"
+#else
.pushsection .text.__asm_invalidate_dcache_all, "ax"
+#endif
ENTRY(__asm_invalidate_dcache_all)
mov x0, #0x1
b __asm_dcache_all
@@ -182,7 +194,11 @@ ENTRY(__asm_invalidate_icache_all)
ENDPROC(__asm_invalidate_icache_all)
.popsection
+#ifdef CONFIG_EFI_LOADER
+.pushsection .text.efi_runtime, "ax"
+#else
.pushsection .text.__asm_invalidate_l3_dcache, "ax"
+#endif
WEAK(__asm_invalidate_l3_dcache)
mov x0, #0 /* return status as success */
ret
diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index e4736e5643..afbc487fa1 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <cpu_func.h>
+#include <efi_loader.h>
#include <hang.h>
#include <log.h>
#include <asm/cache.h>
@@ -445,7 +446,7 @@ __weak void mmu_setup(void)
/*
* Performs a invalidation of the entire data cache at all levels
*/
-void invalidate_dcache_all(void)
+void __efi_runtime invalidate_dcache_all(void)
{
__asm_invalidate_dcache_all();
__asm_invalidate_l3_dcache();
diff --git a/include/mm_communication.h b/include/mm_communication.h
index e65fbde60d..32dc5dbac8 100644
index e65fbde60d..d409bed777 100644
--- a/include/mm_communication.h
+++ b/include/mm_communication.h
@@ -13,6 +13,9 @@
@@ -6,6 +6,8 @@
* Copyright (c) 2017, Intel Corporation. All rights reserved.
* Copyright (C) 2020 Linaro Ltd. <sughosh.ganu@linaro.org>
* Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas@linaro.org>
+ * (C) Copyright 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#ifndef _MM_COMMUNICATION_H_
@@ -13,6 +15,9 @@
#include <part_efi.h>
@@ -154,29 +108,11 @@ index e65fbde60d..32dc5dbac8 100644
/*
* Interface to the pseudo Trusted Application (TA), which provides a
* communication channel with the Standalone MM (Management Mode)
@@ -43,7 +46,7 @@
* To avoid confusion in interpreting frames, the communication buffer should
* always begin with efi_mm_communicate_header.
*/
-struct __packed efi_mm_communicate_header {
+struct efi_mm_communicate_header {
efi_guid_t header_guid;
size_t message_len;
u8 data[];
@@ -145,7 +148,7 @@ struct smm_variable_communicate_header {
* Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
*
*/
-struct smm_variable_access {
+struct __packed smm_variable_access {
efi_guid_t guid;
efi_uintn_t data_size;
efi_uintn_t name_size;
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index e3f2402d0e..2a6d70f862 100644
index b8fb2701a7..d292f57244 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -60,13 +60,23 @@ config EFI_VARIABLE_FILE_STORE
@@ -61,13 +61,23 @@ config EFI_VARIABLE_FILE_STORE
stored as file /ubootefi.var on the EFI system partition.
config EFI_MM_COMM_TEE
@@ -202,29 +138,24 @@ index e3f2402d0e..2a6d70f862 100644
config EFI_VARIABLE_NO_STORE
bool "Don't persist non-volatile UEFI variables"
help
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 8fa9a58d76..cede7826bd 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2185,6 +2185,13 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
debug("[efi_boottime][INFO]: FF-A RX/TX buffers unmapped\n");
#endif
+#if CONFIG_IS_ENABLED(ARM_FFA_EFI_RUNTIME_MODE) && !CONFIG_IS_ENABLED(SANDBOX_FFA)
+ if (ffa_copy_runtime_data())
+ printf("ERROR: EFI: FFA: copying runtime data\n");
+ else
+ printf("INFO: EFI: FFA: runtime data copied\n");
+#endif
+
/* Patch out unsupported runtime function */
efi_runtime_detach();
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index dfef18435d..7d9d577281 100644
index dfef18435d..3933a24e8c 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -15,6 +15,36 @@
@@ -4,9 +4,12 @@
*
* Copyright (C) 2019 Linaro Ltd. <sughosh.ganu@linaro.org>
* Copyright (C) 2019 Linaro Ltd. <ilias.apalodimas@linaro.org>
+ * Copyright (C) 2022 ARM Limited
+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
*/
#include <common.h>
+#include <dm.h>
#include <efi.h>
#include <efi_api.h>
#include <efi_loader.h>
@@ -15,6 +18,36 @@
#include <malloc.h>
#include <mm_communication.h>
@@ -235,33 +166,33 @@ index dfef18435d..7d9d577281 100644
+#include <mapmem.h>
+
+#ifndef FFA_SHARED_MM_BUFFER_SIZE
+#warning "FFA_SHARED_MM_BUFFER_SIZE must be defined in include/configs/<board>.h"
+#error "FFA_SHARED_MM_BUFFER_SIZE must be defined in include/configs/<board>.h"
+#define FFA_SHARED_MM_BUFFER_SIZE 0
+#endif
+
+#ifndef FFA_SHARED_MM_BUFFER_OFFSET
+#warning "FFA_SHARED_MM_BUFFER_OFFSET must be defined in include/configs/<board>.h"
+#error "FFA_SHARED_MM_BUFFER_OFFSET must be defined in include/configs/<board>.h"
+#define FFA_SHARED_MM_BUFFER_OFFSET 0
+#endif
+
+#ifndef FFA_SHARED_MM_BUFFER_ADDR
+#warning "FFA_SHARED_MM_BUFFER_ADDR must be defined in include/configs/<board>.h"
+#error "FFA_SHARED_MM_BUFFER_ADDR must be defined in include/configs/<board>.h"
+#define FFA_SHARED_MM_BUFFER_ADDR 0
+#endif
+
+/* MM return codes */
+#define MM_SUCCESS (0)
+
+const char *mm_sp_svc_uuid = MM_SP_UUID;
+static const char *mm_sp_svc_uuid = MM_SP_UUID;
+
+static __efi_runtime_data u16 mm_sp_id;
+static u16 mm_sp_id;
+
+#endif
+
extern struct efi_var_file __efi_runtime_data *efi_var_buf;
static efi_uintn_t max_buffer_size; /* comm + var + func + data */
static efi_uintn_t max_payload_size; /* func + data */
@@ -24,6 +54,7 @@ struct mm_connection {
@@ -24,6 +57,7 @@ struct mm_connection {
u32 session;
};
@@ -269,7 +200,7 @@ index dfef18435d..7d9d577281 100644
/**
* get_connection() - Retrieve OP-TEE session for a specific UUID.
*
@@ -143,16 +174,227 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
@@ -143,13 +177,248 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
return ret;
}
@@ -290,7 +221,7 @@ index dfef18435d..7d9d577281 100644
+ *
+ * 0 on success
+ */
+static int __efi_runtime ffa_notify_mm_sp(void)
+static int ffa_notify_mm_sp(void)
+{
+ struct ffa_send_direct_data msg = {0};
+ int ret;
@@ -301,7 +232,7 @@ index dfef18435d..7d9d577281 100644
+
+ msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */
+
+ ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(NULL, mm_sp_id, &msg, 1);
+ if (ret != 0)
+ return ret;
+
@@ -330,7 +261,7 @@ index dfef18435d..7d9d577281 100644
+ */
+static int ffa_discover_mm_sp_id(void)
+{
+ u32 count = 0, size = 0;
+ u32 count = 0;
+ int ret;
+ struct ffa_partition_info *parts_info;
+
@@ -340,7 +271,7 @@ index dfef18435d..7d9d577281 100644
+ /*
+ * get from the driver the count of the SPs matching the UUID
+ */
+ ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &count, NULL);
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, NULL);
+ if (ret != 0) {
+ log_err("EFI: Failure in querying partitions count (error code: %d)\n", ret);
+ return ret;
@@ -358,18 +289,16 @@ index dfef18435d..7d9d577281 100644
+
+ log_info("EFI: Pre-allocating %d partition(s) info structures\n", count);
+
+ parts_info = calloc(count, sizeof(struct ffa_partition_info));
+ parts_info = calloc(count, sizeof(*parts_info));
+ if (!parts_info)
+ return -EINVAL;
+
+ size = count * sizeof(struct ffa_partition_info);
+ return -ENOMEM;
+
+ /*
+ * ask the driver to fill the
+ * buffer with the SPs info
+ */
+ ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &size, parts_info);
+ if (ret != 0) {
+ ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, parts_info);
+ if (ret) {
+ log_err("EFI: Failure in querying partition(s) info (error code: %d)\n", ret);
+ free(parts_info);
+ return ret;
@@ -404,10 +333,11 @@ index dfef18435d..7d9d577281 100644
+ *
+ * EFI status code
+ */
+static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
+static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
+{
+ ulong tx_data_size;
+ int ffa_ret;
+ efi_status_t efi_ret;
+ struct efi_mm_communicate_header *mm_hdr;
+ void *virt_shared_buf;
+
@@ -429,7 +359,7 @@ index dfef18435d..7d9d577281 100644
+ /* Copy the data to the shared buffer */
+
+ virt_shared_buf = (void *)map_sysmem((phys_addr_t)FFA_SHARED_MM_BUFFER_ADDR, 0);
+ efi_memcpy_runtime(virt_shared_buf, comm_buf, tx_data_size);
+ memcpy(virt_shared_buf, comm_buf, tx_data_size);
+
+ /*
+ * The secure world might have cache disabled for
@@ -444,8 +374,6 @@ index dfef18435d..7d9d577281 100644
+ /* Announce there is data in the shared buffer */
+
+ ffa_ret = ffa_notify_mm_sp();
+ if (ffa_ret)
+ unmap_sysmem(virt_shared_buf);
+
+ switch (ffa_ret) {
+ case 0:
@@ -457,30 +385,57 @@ index dfef18435d..7d9d577281 100644
+ sizeof(size_t);
+
+ if (rx_data_size > comm_buf_size) {
+ unmap_sysmem(virt_shared_buf);
+ return EFI_OUT_OF_RESOURCES;
+ efi_ret = EFI_OUT_OF_RESOURCES;
+ break;
+ }
+
+ efi_memcpy_runtime(comm_buf, virt_shared_buf, rx_data_size);
+ unmap_sysmem(virt_shared_buf);
+
+ return EFI_SUCCESS;
+ memcpy(comm_buf, virt_shared_buf, rx_data_size);
+ efi_ret = EFI_SUCCESS;
+ break;
+ }
+ case -EINVAL:
+ return EFI_DEVICE_ERROR;
+ efi_ret = EFI_DEVICE_ERROR;
+ break;
+ case -EPERM:
+ return EFI_INVALID_PARAMETER;
+ efi_ret = EFI_INVALID_PARAMETER;
+ break;
+ case -EACCES:
+ return EFI_ACCESS_DENIED;
+ efi_ret = EFI_ACCESS_DENIED;
+ break;
+ case -EBUSY:
+ return EFI_OUT_OF_RESOURCES;
+ efi_ret = EFI_OUT_OF_RESOURCES;
+ break;
+ default:
+ return EFI_ACCESS_DENIED;
+ efi_ret = EFI_ACCESS_DENIED;
+ }
+
+ unmap_sysmem(virt_shared_buf);
+ return efi_ret;
+}
+#endif
+
+/**
+ * select_ffa_mm_comms() - checks FF-A support availability
+ *
+ * Making sure FF-A is compiled in. If that's the case try to discover
+ * the FF-A bus.
+ *
+ * Return:
+ *
+ * 0: FF-A ready for use. Otherwise, failure
+ */
+static efi_status_t select_ffa_mm_comms(void)
+{
+ efi_status_t ret = EFI_UNSUPPORTED;
+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+ ret = ffa_bus_discover(NULL);
+ if (ret)
+ ret = EFI_NOT_READY;
+#endif
+ return ret;
+}
+
+/**
+ * mm_communicate() - Adjust the communication buffer to the MM SP and send
* it to OP-TEE
*
@@ -488,31 +443,34 @@ index dfef18435d..7d9d577281 100644
+ * @comm_buf: locally allocated communication buffer
* @dsize: buffer size
+ *
+ * The MM SP (also called partition) can be StandAlonneMM or smm-gateway.
+ * The SP (also called partition) can be any MM SP such as StandAlonneMM or smm-gateway.
+ * The comm_buf format is the same for both partitions.
+ * When using the u-boot OP-TEE driver, StandAlonneMM is supported.
+ * When using the u-boot FF-A driver, StandAlonneMM and smm-gateway are supported.
+ * When using the u-boot FF-A driver, any MM SP is supported.
+ *
* Return: status code
*/
-static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
+static efi_status_t __efi_runtime mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
{
efi_status_t ret;
struct efi_mm_communicate_header *mm_hdr;
@@ -162,7 +404,11 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
@@ -162,7 +431,17 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
mm_hdr = (struct efi_mm_communicate_header *)comm_buf;
var_hdr = (struct smm_variable_communicate_header *)mm_hdr->data;
+ #if (IS_ENABLED(CONFIG_OPTEE))
ret = optee_mm_communicate(comm_buf, dsize);
+ #elif (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+ ret = ffa_mm_communicate(comm_buf, dsize);
+ #endif
- ret = optee_mm_communicate(comm_buf, dsize);
+ ret = select_ffa_mm_comms();
+ if (ret != EFI_SUCCESS) {
+#if (IS_ENABLED(CONFIG_OPTEE))
+ ret = optee_mm_communicate(comm_buf, dsize);
+#endif
+ } else {
+#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
+ ret = ffa_mm_communicate(comm_buf, dsize);
+#endif
+ }
+
if (ret != EFI_SUCCESS) {
log_err("%s failed!\n", __func__);
return ret;
@@ -258,6 +504,13 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
@@ -258,6 +537,13 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
goto out;
}
*size = var_payload->size;
@@ -526,7 +484,7 @@ index dfef18435d..7d9d577281 100644
/*
* There seems to be a bug in EDK2 miscalculating the boundaries and
* size checks, so deduct 2 more bytes to fulfill this requirement. Fix
@@ -697,7 +950,7 @@ void efi_variables_boot_exit_notify(void)
@@ -697,7 +983,7 @@ void efi_variables_boot_exit_notify(void)
ret = EFI_NOT_FOUND;
if (ret != EFI_SUCCESS)
@@ -0,0 +1,76 @@
From 46cadb787a3b13da39419706fae7d1ba703f4b68 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Fri, 23 Sep 2022 15:17:21 +0100
Subject: [PATCH 10/25] arm_ffa: efi: corstone1000: enable MM communication
turn on EFI MM communication
On corstone1000 platform MM communication between u-boot
and the secure world (Optee) is done using the FF-A bus.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
Changelog:
===============
v8:
* drop OP-TEE configs from Corstone-1000 defconfig
v7:
* improve the definition of FFA_SHARED_MM_BUFFER_ADDR and
FFA_SHARED_MM_BUFFER_OFFSET
* update FFA_SHARED_MM_BUFFER_ADDR value
v6:
* corstone-1000: enable optee driver
* corstone-1000: remove CONFIG_ARM_FFA_EFI_RUNTIME_MODE from the defconfig
v4:
* corstone-1000: turn on EFI MM communication
---
configs/corstone1000_defconfig | 2 ++
include/configs/corstone1000.h | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index ed2e0fe70a..c26f99e7e5 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -52,3 +52,5 @@ CONFIG_DM_SERIAL=y
CONFIG_USB=y
CONFIG_USB_ISP1760=y
CONFIG_ERRNO_STR=y
+CONFIG_EFI_MM_COMM_TEE=y
+CONFIG_ARM_FFA_TRANSPORT=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 8e0230c135..0362d29ac2 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -14,6 +14,15 @@
#include <linux/sizes.h>
+#define FFA_SHARED_MM_BUFFER_SIZE SZ_4K /* 4 KB */
+
+/*
+ * shared buffer physical address used for communication between
+ * u-boot and the MM SP
+ */
+#define FFA_SHARED_MM_BUFFER_ADDR 0x02000000UL
+#define FFA_SHARED_MM_BUFFER_OFFSET 0
+
#define V2M_BASE 0x80000000
#define CONFIG_PL011_CLOCK 50000000
--
2.17.1
@@ -1,7 +1,7 @@
From 10e155a677192731481ebe7f302e2d9ad790346a Mon Sep 17 00:00:00 2001
From 7702c4aeda51011be95ecbaab0dc2e7373d04286 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 28 Jul 2022 15:01:55 +0100
Subject: [PATCH 16/26] efi: corstone1000: introduce EFI capsule update
Date: Tue, 29 Nov 2022 15:11:27 +0000
Subject: [PATCH 11/25] efi: corstone1000: introduce EFI capsule update
This commit provides capsule update feature for Corstone1000.
@@ -22,15 +22,43 @@ Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
include/configs/corstone1000.h | 18 +++++
include/efi_loader.h | 4 +-
lib/efi_loader/efi_boottime.c | 36 ++++++++++
lib/efi_loader/efi_capsule.c | 124 ++++++++++++++++++++++++++++++++-
lib/efi_loader/efi_setup.c | 15 ++++
5 files changed, 193 insertions(+), 4 deletions(-)
board/armltd/corstone1000/corstone1000.c | 4 +
configs/corstone1000_defconfig | 3 +
include/configs/corstone1000.h | 18 ++++
include/efi_loader.h | 4 +-
lib/efi_loader/efi_boottime.c | 36 +++++++
lib/efi_loader/efi_capsule.c | 124 ++++++++++++++++++++++-
lib/efi_loader/efi_setup.c | 15 +++
7 files changed, 200 insertions(+), 4 deletions(-)
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
index 4f4b96a095..76816f8f4e 100644
--- a/board/armltd/corstone1000/corstone1000.c
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -66,6 +66,10 @@ static struct mm_region corstone1000_mem_map[] = {
struct mm_region *mem_map = corstone1000_mem_map;
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+}
+
int board_init(void)
{
return 0;
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index c26f99e7e5..c72d027711 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -54,3 +54,6 @@ CONFIG_USB_ISP1760=y
CONFIG_ERRNO_STR=y
CONFIG_EFI_MM_COMM_TEE=y
CONFIG_ARM_FFA_TRANSPORT=y
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 5960c6b4be..fe5ec0adcd 100644
index 0362d29ac2..4d20090c9b 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -14,6 +14,24 @@
@@ -59,10 +87,10 @@ index 5960c6b4be..fe5ec0adcd 100644
/*
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5b41985244..796419b69b 100644
index 545ba06d94..773c4f6310 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -984,11 +984,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit;
@@ -993,11 +993,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit;
extern const struct efi_firmware_management_protocol efi_fmp_raw;
/* Capsule update */
@@ -77,10 +105,10 @@ index 5b41985244..796419b69b 100644
efi_uintn_t capsule_count,
u64 *maximum_capsule_size,
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index cede7826bd..9bf2596597 100644
index 1099ccc800..d9eed33ac8 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2095,6 +2095,33 @@ static void efi_exit_caches(void)
@@ -2103,6 +2103,33 @@ static void efi_exit_caches(void)
#endif
}
@@ -106,7 +134,7 @@ index cede7826bd..9bf2596597 100644
+ msg.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */
+ msg.data2 = CORSTONE1000_KERNEL_STARTED_EVT; /* x5 */
+
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
+}
+
+#endif
@@ -114,7 +142,7 @@ index cede7826bd..9bf2596597 100644
/**
* efi_exit_boot_services() - stop all boot services
* @image_handle: handle of the loaded image
@@ -2210,6 +2237,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
@@ -2209,6 +2236,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
/* Recalculate CRC32 */
efi_update_table_header_crc32(&systab.hdr);
@@ -131,7 +159,7 @@ index cede7826bd..9bf2596597 100644
efi_set_watchdog(0);
WATCHDOG_RESET();
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index a6b98f066a..c0f3427a60 100644
index a6b98f066a..636b61f0ad 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -25,6 +25,14 @@
@@ -221,7 +249,7 @@ index a6b98f066a..c0f3427a60 100644
+ msg.data1 = capsule_image_size; /* x4 */
+ msg.data2 = CORSTONE1000_BUFFER_READY_EVT; /* x5 */
+
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
+}
+#endif
+
@@ -301,7 +329,7 @@ index a6b98f066a..c0f3427a60 100644
efi_uintn_t capsule_count,
u64 *maximum_capsule_size,
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 492ecf4cb1..bfd4687e10 100644
index c633fcd91e..443f409906 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -16,6 +16,13 @@
@@ -1,7 +1,7 @@
From 3f8d35ccbb0d59d4820b81f7f939ada95b3cd92c Mon Sep 17 00:00:00 2001
From 71162273e8a6b28a6aaf8635cff752419d09a293 Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Fri, 4 Mar 2022 15:56:09 +0000
Subject: [PATCH 18/26] arm: corstone1000: fix unrecognized filesystem type
Subject: [PATCH 12/25] arm: corstone1000: fix unrecognized filesystem type
Some usb sticks are not recognized by usb, just add a
delay before checking status.
@@ -1,7 +1,7 @@
From 3bb5826af8e3891617d41a30419de0ce089f9fc3 Mon Sep 17 00:00:00 2001
From f8ccaf53dec63d57bab2f86b822f9fb3ed06d132 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 10 Dec 2021 20:03:35 +0000
Subject: [PATCH 19/26] efi_capsule: corstone1000: pass interface id and buffer
Subject: [PATCH 13/25] efi_capsule: corstone1000: pass interface id and buffer
event id using register w4
Initially the interface/event IDs are passed to the SP using register
@@ -23,7 +23,7 @@ Upstream-Status: Pending [Not submitted to upstream yet]
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 2d89a8966e..4637dd5d5d 100644
index 4d20090c9b..77f96e87a1 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -24,6 +24,12 @@
@@ -40,7 +40,7 @@ index 2d89a8966e..4637dd5d5d 100644
#define CORSTONE1000_CAPSULE_BUFFER_SIZE (8192) /* 32 MB */
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index c0f3427a60..bf8bd68256 100644
index 636b61f0ad..c22b9b5aa0 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -28,6 +28,8 @@
@@ -67,7 +67,7 @@ index c0f3427a60..bf8bd68256 100644
+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */
return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
}
--
2.17.1
@@ -1,7 +1,7 @@
From 668fe40ccb0db5542ef333cd4655511dbb8572f9 Mon Sep 17 00:00:00 2001
From e4e7ccc77a4e6930a768cc1c1f6daf8907ac16c3 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 10 Dec 2021 20:10:41 +0000
Subject: [PATCH 20/26] efi_boottime: corstone1000: pass interface id and
Subject: [PATCH 14/25] efi_boottime: corstone1000: pass interface id and
kernel event id using register w4
Initially the interface/event IDs are passed to the SP using register
@@ -22,10 +22,10 @@ Upstream-Status: Pending [Not submitted to upstream yet]
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 9bf2596597..de815484d2 100644
index d9eed33ac8..88f2d050be 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -27,6 +27,11 @@
@@ -30,6 +30,11 @@
#include <arm_ffa.h>
#endif
@@ -37,7 +37,7 @@ index 9bf2596597..de815484d2 100644
DECLARE_GLOBAL_DATA_PTR;
/* Task priority level */
@@ -2112,10 +2117,12 @@ static int efi_corstone1000_kernel_started_event(void)
@@ -2120,10 +2125,12 @@ static int efi_corstone1000_kernel_started_event(void)
log_debug("[%s]\n", __func__);
/*
@@ -51,7 +51,7 @@ index 9bf2596597..de815484d2 100644
+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
}
--
2.17.1
@@ -1,53 +0,0 @@
From 01d1487cebc37834e2a5d259e0417a610539a0f5 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Thu, 9 Jun 2022 12:47:35 +0100
Subject: [PATCH 15/26] arm_ffa: corstone1000: enable FF-A and MM support
This commit allows corstone1000 platform to perform
MM communication between u-boot and the secure world
using FF-A transport.
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
---
configs/corstone1000_defconfig | 2 ++
include/configs/corstone1000.h | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index e573fe6fe6..c299dda49f 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -44,6 +44,8 @@ CONFIG_USB=y
CONFIG_DM_USB=y
CONFIG_USB_ISP1760=y
CONFIG_USB_STORAGE=y
+CONFIG_ARM_FFA_TRANSPORT=y
+CONFIG_ARM_FFA_EFI_RUNTIME_MODE=y
CONFIG_EFI_MM_COMM_TEE=y
# CONFIG_OPTEE is not set
# CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 8ba0effb0a..5960c6b4be 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -14,6 +14,15 @@
#include <linux/sizes.h>
+#define FFA_SHARED_MM_BUFFER_SIZE SZ_4K /* 4 KB */
+
+/*
+ * shared buffer physical address used for communication between
+ * u-boot and the MM SP
+ */
+#define FFA_SHARED_MM_BUFFER_ADDR (0x023F8000)
+#define FFA_SHARED_MM_BUFFER_OFFSET (0)
+
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
#define CONFIG_SKIP_LOWLEVEL_INIT
--
2.17.1
@@ -1,7 +1,7 @@
From 4d7fd850347dbea10a73cd5cf6eb518607118414 Mon Sep 17 00:00:00 2001
From caf6c4ec65fd0a5e945dd790f2369acd163d1daf Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Sat, 11 Dec 2021 13:23:55 +0000
Subject: [PATCH 21/26] efi_loader: corstone1000: remove guid check from
Subject: [PATCH 15/25] efi_loader: corstone1000: remove guid check from
corstone1000 config option
Use generic fmp guid and no separte check is required for
@@ -15,7 +15,7 @@ Upstream-Status: Pending [Not submitted to upstream yet]
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index bf8bd68256..5db9d30d53 100644
index c22b9b5aa0..0eee3c2d4c 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -646,12 +646,6 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
@@ -1,7 +1,7 @@
From 720e5ada733b0f7b019baaec57d74603a9dff67e Mon Sep 17 00:00:00 2001
From 41a2c8bb23e587e9abe7b8bc62db1a93c0e5d841 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:49:02 +0000
Subject: [PATCH 22/26] efi_loader: populate ESRT table if EFI_ESRT config
Subject: [PATCH 16/25] efi_loader: populate ESRT table if EFI_ESRT config
option is set
This change is to call efi_esrt_populate function if CONFIG_EFI_ESRT
@@ -15,7 +15,7 @@ Upstream-Status: Pending [Not submitted to upstream yet]
1 file changed, 7 insertions(+)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 5db9d30d53..65e2fc8296 100644
index 0eee3c2d4c..94dc0dfe3d 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -668,6 +668,13 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
@@ -1,34 +0,0 @@
From a84f6be14f1bb31edea987fc02efd5a079a28db1 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Wed, 17 Nov 2021 15:28:06 +0000
Subject: [PATCH 17/26] corstone1000: Update FFA shared buffer address
FFA shared buffer address changed to 0x02000000.
The existing address 0x023F8000 is currently being used by
Optee so the virtual address returned to the SMM gateway is 0x0000.
So the buffer is moved to 0x02000000.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
include/configs/corstone1000.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index fe5ec0adcd..2d89a8966e 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -38,7 +38,7 @@
* shared buffer physical address used for communication between
* u-boot and the MM SP
*/
-#define FFA_SHARED_MM_BUFFER_ADDR (0x023F8000)
+#define FFA_SHARED_MM_BUFFER_ADDR (0x02000000)
#define FFA_SHARED_MM_BUFFER_OFFSET (0)
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
--
2.17.1
@@ -1,7 +1,7 @@
From 2cad562823976134f201d6e2ef187bf103e17d1e Mon Sep 17 00:00:00 2001
From 323df950c63af6d1a9ba5bd16f4f9d9348e9afc2 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:50:25 +0000
Subject: [PATCH 23/26] efi_firmware: add get_image_info for corstone1000
Subject: [PATCH 17/25] efi_firmware: add get_image_info for corstone1000
This change is to populate get_image_info which eventually
will be populated in ESRT table
@@ -1,7 +1,7 @@
From 709e5d8ff07474f840f1d34d3077135f77795452 Mon Sep 17 00:00:00 2001
From 7bf9c380c63726b7de8316e9c743cb06c9bc7842 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Mon, 15 Aug 2022 15:46:18 +0100
Subject: [PATCH 24/26] efi_loader: send bootcomplete message to secure enclave
Subject: [PATCH 18/25] efi_loader: send bootcomplete message to secure enclave
On corstone1000 platform, Secure Enclave will be expecting
an event from uboot when it performs capsule update. Previously,
@@ -21,7 +21,7 @@ Upstream-Status: Pending [Not submitted to upstream yet]
4 files changed, 41 insertions(+), 45 deletions(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 4637dd5d5d..333b1d93b6 100644
index 77f96e87a1..4cf1170ffb 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -22,7 +22,7 @@
@@ -34,10 +34,10 @@ index 4637dd5d5d..333b1d93b6 100644
#define PREP_SEPROXY_SVC_ID_MASK GENMASK(31, 16)
#define PREP_SEPROXY_SVC_ID(x) (FIELD_PREP(PREP_SEPROXY_SVC_ID_MASK, (x)))
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index de815484d2..cede7826bd 100644
index 88f2d050be..1099ccc800 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -27,11 +27,6 @@
@@ -30,11 +30,6 @@
#include <arm_ffa.h>
#endif
@@ -49,7 +49,7 @@ index de815484d2..cede7826bd 100644
DECLARE_GLOBAL_DATA_PTR;
/* Task priority level */
@@ -2100,35 +2095,6 @@ static void efi_exit_caches(void)
@@ -2108,35 +2103,6 @@ static void efi_exit_caches(void)
#endif
}
@@ -77,7 +77,7 @@ index de815484d2..cede7826bd 100644
- msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
- PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
-
- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
-}
-
-#endif
@@ -85,7 +85,7 @@ index de815484d2..cede7826bd 100644
/**
* efi_exit_boot_services() - stop all boot services
* @image_handle: handle of the loaded image
@@ -2244,15 +2210,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
@@ -2243,15 +2209,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
/* Recalculate CRC32 */
efi_update_table_header_crc32(&systab.hdr);
@@ -115,7 +115,7 @@ index af43d4502f..25f427b936 100644
}
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index bfd4687e10..6c9e14c37e 100644
index 443f409906..c154eb0e9d 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -17,6 +17,9 @@
@@ -156,7 +156,7 @@ index bfd4687e10..6c9e14c37e 100644
+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */
+
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
+}
+#endif
+
@@ -1,7 +1,7 @@
From 456e616401b02a579e9ea5ec3e5ab1d1c884b389 Mon Sep 17 00:00:00 2001
From 28e7a47c7021b7d321bb6e4dbe1bd7d2ceb8aa6d Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 14 Jan 2022 15:24:18 +0000
Subject: [PATCH 25/26] efi_loader: fix null pointer exception with
Subject: [PATCH 19/25] efi_loader: fix null pointer exception with
get_image_info
get_img_info API implemented for corstone1000 target does not
@@ -0,0 +1,99 @@
From d662633cb8e90144969790b8abf047a3f777e47a Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Wed, 30 Nov 2022 15:37:22 +0000
Subject: [PATCH 20/25] arm:corstone1000: add mmc for fvp
Enable support mmc/sdcard for the corstone1000 FVP.
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
board/armltd/corstone1000/corstone1000.c | 28 +++++++++++++++++++-----
configs/corstone1000_defconfig | 8 ++++++-
include/configs/corstone1000.h | 4 +++-
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
index 76816f8f4e..d6ca6e8961 100644
--- a/board/armltd/corstone1000/corstone1000.c
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -38,19 +38,35 @@ static struct mm_region corstone1000_mem_map[] = {
}, {
/* USB */
.virt = 0x40200000UL,
- .phys = 0x40200000UL,
+ .phys = 0x40200000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* MMC0 */
+ .virt = 0x40300000UL,
+ .phys = 0x40300000UL,
.size = 0x00100000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
- PTE_BLOCK_NON_SHARE |
- PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* ethernet */
.virt = 0x40100000UL,
- .phys = 0x40100000UL,
+ .phys = 0x40100000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* MMC1 */
+ .virt = 0x50000000UL,
+ .phys = 0x50000000UL,
.size = 0x00100000UL,
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
- PTE_BLOCK_NON_SHARE |
- PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* OCVM */
.virt = 0x80000000UL,
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index c72d027711..336da67a8d 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -40,7 +40,13 @@ CONFIG_VERSION_VARIABLE=y
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_REGMAP=y
CONFIG_MISC=y
-# CONFIG_MMC is not set
+CONFIG_CLK=y
+CONFIG_CMD_MMC=y
+CONFIG_DM_MMC=y
+CONFIG_ARM_PL180_MMCI=y
+CONFIG_MMC_SDHCI_ADMA_HELPERS=y
+CONFIG_MMC_WRITE=y
+CONFIG_DM_GPIO=y
CONFIG_PHYLIB=y
CONFIG_PHY_SMSC=y
CONFIG_SMC911X=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 4cf1170ffb..1f28a0f6c0 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -58,7 +58,9 @@
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
#define BOOT_TARGET_DEVICES(func) \
- func(USB, usb, 0)
+ func(USB, usb, 0) \
+ func(MMC, mmc, 0) \
+ func(MMC, mmc, 1)
#include <config_distro_bootcmd.h>
--
2.17.1
@@ -0,0 +1,33 @@
From 37ee9a07d168b43bde17b2ce3dbf637905af5bf2 Mon Sep 17 00:00:00 2001
From: Jon Mason <jon.mason@arm.com>
Date: Wed, 30 Nov 2022 18:59:59 +0000
Subject: [PATCH 21/25] corstone1000: add compressed kernel support
The corstone1000 kernel has become too large to fit in the available
storage. Swtiching to a compressed kernel avoids the problem, but
requires uncompressing it. Add this decompression to the default boot
instructions.
Signed-off-by: Jon Mason <jon.mason@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
configs/corstone1000_defconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 336da67a8d..eeb207aa5f 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -15,7 +15,7 @@ CONFIG_FIT=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
-CONFIG_BOOTCOMMAND="run retrieve_kernel_load_addr; echo Loading kernel from $kernel_addr to memory ... ; loadm $kernel_addr $kernel_addr_r 0xc00000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;"
+CONFIG_BOOTCOMMAND="run retrieve_kernel_load_addr; echo Loading kernel from $kernel_addr to memory ... ; unzip $kernel_addr 0x90000000; loadm 0x90000000 $kernel_addr_r 0xf00000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;"
CONFIG_CONSOLE_RECORD=y
CONFIG_LOGLEVEL=7
# CONFIG_DISPLAY_CPUINFO is not set
--
2.17.1
@@ -1,7 +1,7 @@
From 83f16fe96a86b00f7a4b7c4c4f7416119b80eddd Mon Sep 17 00:00:00 2001
From a3fae205de2fd6d2abdb8afca6475267c16e9e29 Mon Sep 17 00:00:00 2001
From: Emekcan <emekcan.aras@arm.com>
Date: Fri, 19 Aug 2022 16:04:48 +0100
Subject: [PATCH] Introduce external sys driver to device-tree
Date: Wed, 30 Nov 2022 19:02:26 +0000
Subject: [PATCH 22/25] Introduce external sys driver to device-tree
It adds external sys driver binding to u-boot
device tree.
@@ -13,10 +13,10 @@ Upstream-Status: Pending [Not submitted to upstream yet]
1 file changed, 7 insertions(+)
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index d0194aa893..19b6e3ea72 100644
index 4e46826f88..2c7185e139 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -160,6 +160,13 @@
@@ -160,5 +160,12 @@
secure-status = "okay"; /* secure-world-only */
status = "disabled";
};
@@ -28,8 +28,7 @@ index d0194aa893..19b6e3ea72 100644
+ reg-names = "rstreg", "streg";
+ };
};
arm_ffa: arm_ffa {
};
--
2.17.1
@@ -1,7 +1,7 @@
From a1b8b91a43cfa9dbaa2d907a6d9629da6f93fa3e Mon Sep 17 00:00:00 2001
From 55e2bc835be50b23ef04066b950bbe75c0065d19 Mon Sep 17 00:00:00 2001
From: Emekcan <emekcan.aras@arm.com>
Date: Mon, 12 Sep 2022 15:47:06 +0100
Subject: [PATCH] Add mhu and rpmsg client to u-boot device tree
Subject: [PATCH 23/25] Add mhu and rpmsg client to u-boot device tree
Adds external system controller and mhu driver to u-boot
device tree. This enables communication between host and
@@ -10,11 +10,11 @@ the external system.
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
arch/arm/dts/corstone1000.dtsi | 50 ++++++++++++++++++++++++++++++++
arch/arm/dts/corstone1000.dtsi | 50 ++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
index 19b6e3ea72..61dd6c432c 100644
index 2c7185e139..61e0c33247 100644
--- a/arch/arm/dts/corstone1000.dtsi
+++ b/arch/arm/dts/corstone1000.dtsi
@@ -161,6 +161,56 @@
@@ -1,7 +1,7 @@
From d8fca6ebd5917df9a12dbf1da6a97f99af06eee9 Mon Sep 17 00:00:00 2001
From 475f787ba7351282ca3ce0fcf9badc01821cd8a3 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Fri, 19 Aug 2022 09:18:33 +0100
Subject: [PATCH] arm/corstone1000: esrt support
Date: Wed, 30 Nov 2022 19:11:43 +0000
Subject: [PATCH 24/25] arm/corstone1000: esrt support
The implementation is platform specific and would require
change in future.
@@ -15,14 +15,14 @@ Upstream-Status: Inappropriate [Redesign of FMP protocol for ESRT and Capsule up
---
include/efi_api.h | 2 +-
lib/efi_loader/efi_firmware.c | 133 ++++++++++++++++++++++++++++++++++
lib/efi_loader/efi_setup.c | 16 ++--
3 files changed, 142 insertions(+), 9 deletions(-)
lib/efi_loader/efi_setup.c | 17 +++--
3 files changed, 143 insertions(+), 9 deletions(-)
diff --git a/include/efi_api.h b/include/efi_api.h
index 83c01085fd..26899afd01 100644
index 9bb0d44ac8..fcf2643e14 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -2014,7 +2014,7 @@ struct efi_firmware_image_descriptor {
@@ -2030,7 +2030,7 @@ struct efi_firmware_image_descriptor {
u32 last_attempt_status;
u64 hardware_instance;
efi_firmware_image_dep_t *dependencies;
@@ -185,13 +185,14 @@ index 28d9a19edb..aa4af8036b 100644
.set_image = efi_firmware_fit_set_image,
.check_image = efi_firmware_check_image_unsupported,
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 6c9e14c37e..6ccda175ff 100644
index c154eb0e9d..63329bbff8 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -168,13 +168,6 @@ static efi_status_t efi_init_capsule(void)
@@ -167,14 +167,6 @@ static efi_status_t efi_init_capsule(void)
efi_status_t ret = EFI_SUCCESS;
#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
int ffa_ret;
- int ffa_ret;
-
- ffa_ret = efi_corstone1000_uboot_efi_started_event();
- if (ffa_ret)
@@ -202,11 +203,10 @@ index 6c9e14c37e..6ccda175ff 100644
ret = efi_corstone1000_alloc_capsule_shared_buf();
if (ret != EFI_SUCCESS) {
printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n");
@@ -306,7 +299,14 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
}
-
@@ -308,6 +300,15 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ int ffa_ret;
+ ffa_ret = efi_corstone1000_uboot_efi_started_event();
@@ -215,9 +215,10 @@ index 6c9e14c37e..6ccda175ff 100644
+ else
+ debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
+#endif
+
/* Initialize variable services */
ret = efi_init_variables();
if (ret != EFI_SUCCESS)
--
2.25.1
2.17.1
@@ -0,0 +1,50 @@
From de5994cda7a35317f12dc1cedb28cae1b932283a Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Wed, 30 Nov 2022 19:14:52 +0000
Subject: [PATCH 25/25] efi_setup: discover FF-A bus before raising EFI started
event
add FF-A discovery to efi_corstone1000_uboot_efi_started_event()
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
lib/efi_loader/efi_setup.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 63329bbff8..cf8abe3af0 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -142,9 +142,16 @@ static efi_status_t efi_init_secure_boot(void)
static int efi_corstone1000_uboot_efi_started_event(void)
{
struct ffa_send_direct_data msg = {0};
+ int ret;
log_debug("[%s]\n", __func__);
+ ret = ffa_bus_discover(NULL);
+ if (ret != 0) {
+ log_err("failure to discover FF-A bus\n");
+ return ret;
+ }
+
/*
* setting the kernel started event arguments:
* setting capsule update interface ID(31:16)
@@ -304,9 +311,9 @@ efi_status_t efi_init_obj_list(void)
int ffa_ret;
ffa_ret = efi_corstone1000_uboot_efi_started_event();
if (ffa_ret)
- debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n");
+ log_err("Failure to notify SE Proxy FW update service\n");
else
- debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
+ debug("SE Proxy FW update service notified\n");
#endif
/* Initialize variable services */
--
2.17.1
@@ -1,149 +0,0 @@
From 5e4c819c7ab0841429016c098106615b33486c8b Mon Sep 17 00:00:00 2001
From: Rui Miguel Silva <rui.silva@linaro.org>
Date: Tue, 5 Apr 2022 10:24:38 +0100
Subject: [PATCH 26/26] arm:corstone1000: add mmc for fvp
Enable support mmc/sdcard for the corstone1000 FVP.
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Upstream-Status: Pending [Not submitted to upstream yet]
---
arch/arm/dts/corstone1000-fvp.dts | 28 +++++++++++++++
board/armltd/corstone1000/corstone1000.c | 46 ++++++++++++++++--------
configs/corstone1000_defconfig | 8 ++++-
include/configs/corstone1000.h | 4 ++-
4 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
index 1fcc137a49..26b0f1b3ce 100644
--- a/arch/arm/dts/corstone1000-fvp.dts
+++ b/arch/arm/dts/corstone1000-fvp.dts
@@ -20,4 +20,32 @@
interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <2>;
};
+
+ vmmc_v3_3d: fixed_v3_3d {
+ compatible = "regulator-fixed";
+ regulator-name = "vmmc_supply";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ sdmmc0: mmc@40300000 {
+ compatible = "arm,pl18x", "arm,primecell";
+ reg = <0x40300000 0x1000>;
+ interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
+ max-frequency = <12000000>;
+ vmmc-supply = <&vmmc_v3_3d>;
+ clocks = <&smbclk>, <&refclk100mhz>;
+ clock-names = "smclk", "apb_pclk";
+ };
+
+ sdmmc1: mmc@50000000 {
+ compatible = "arm,pl18x", "arm,primecell";
+ reg = <0x50000000 0x10000>;
+ interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
+ max-frequency = <12000000>;
+ vmmc-supply = <&vmmc_v3_3d>;
+ clocks = <&smbclk>, <&refclk100mhz>;
+ clock-names = "smclk", "apb_pclk";
+ };
};
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
index 2fa485ff37..3d537d7a90 100644
--- a/board/armltd/corstone1000/corstone1000.c
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -46,22 +46,38 @@ static struct mm_region corstone1000_mem_map[] = {
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE |
PTE_BLOCK_PXN | PTE_BLOCK_UXN
- }, {
- /* USB */
- .virt = 0x40200000UL,
- .phys = 0x40200000UL,
- .size = 0x00100000UL,
- .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
- PTE_BLOCK_NON_SHARE |
- PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
- /* ethernet */
- .virt = 0x40100000UL,
- .phys = 0x40100000UL,
- .size = 0x00100000UL,
- .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
- PTE_BLOCK_NON_SHARE |
- PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ /* USB */
+ .virt = 0x40200000UL,
+ .phys = 0x40200000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* MMC0 */
+ .virt = 0x40300000UL,
+ .phys = 0x40300000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* ethernet */
+ .virt = 0x40100000UL,
+ .phys = 0x40100000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* MMC1 */
+ .virt = 0x50000000UL,
+ .phys = 0x50000000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* OCVM */
.virt = 0x80000000UL,
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index c299dda49f..76e07fc20c 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -38,7 +38,13 @@ CONFIG_CMD_EFIDEBUG=y
CONFIG_CMD_FAT=y
CONFIG_OF_CONTROL=y
CONFIG_REGMAP=y
-# CONFIG_MMC is not set
+CONFIG_CLK=y
+CONFIG_CMD_MMC=y
+CONFIG_DM_MMC=y
+CONFIG_ARM_PL180_MMCI=y
+CONFIG_MMC_SDHCI_ADMA_HELPERS=y
+CONFIG_MMC_WRITE=y
+CONFIG_DM_GPIO=y
CONFIG_DM_SERIAL=y
CONFIG_USB=y
CONFIG_DM_USB=y
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 333b1d93b6..815239590e 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -89,7 +89,9 @@
#define CONFIG_SYS_MAXARGS 64 /* max command args */
#define BOOT_TARGET_DEVICES(func) \
- func(USB, usb, 0)
+ func(USB, usb, 0) \
+ func(MMC, mmc, 0) \
+ func(MMC, mmc, 1)
#include <config_distro_bootcmd.h>
--
2.17.1
@@ -0,0 +1,27 @@
From 15778524604652db60f704a772b6815d0f4305bf Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Mon, 5 Dec 2022 17:02:32 +0000
Subject: [PATCH] corstone1000: enable distro booting command
enable distro_bootcmd
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
include/configs/corstone1000.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 1f28a0f6c0..548856b970 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -64,5 +64,6 @@
#include <config_distro_bootcmd.h>
+#define CONFIG_EXTRA_ENV_SETTINGS BOOTENV
#endif
--
2.17.1
@@ -1,34 +0,0 @@
From 26c8a8528b794dbaba49bcf3e1bae8a1e15a8448 Mon Sep 17 00:00:00 2001
From: Jon Mason <jon.mason@arm.com>
Date: Thu, 25 Aug 2022 11:21:28 +0100
Subject: [PATCH] corstone1000: add compressed kernel support
The corstone1000 kernel has become too large to fit in the available
storage. Swtiching to a compressed kernel avoids the problem, but
requires uncompressing it. Add this decompression to the default boot
instructions.
Signed-off-by: Jon Mason <jon.mason@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
include/configs/corstone1000.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 815239590e..a8aa105fe6 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -120,7 +120,8 @@
#define CONFIG_BOOTCOMMAND \
"run retrieve_kernel_load_addr;" \
"echo Loading kernel from $kernel_addr to memory ... ;" \
- "loadm $kernel_addr $kernel_addr_r 0xc00000;" \
+ "unzip $kernel_addr 0x90000000;" \
+ "loadm 0x90000000 $kernel_addr_r 0xf00000;" \
"usb start; usb reset;" \
"run distro_bootcmd;" \
"bootefi $kernel_addr_r $fdtcontroladdr;"
--
2.17.1
@@ -1,182 +0,0 @@
From 6cb8e5f83d53357fbc6e58c2c5c5a3450654f9e6 Mon Sep 17 00:00:00 2001
From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Date: Wed, 19 Oct 2022 17:51:10 +0100
Subject: [PATCH] arm_ffa: add support for 32-bit direct messaging
add 32-bit mode for FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP
Tested-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Upstream-Status: Pending [Not submitted to upstream yet]
---
cmd/armffa.c | 2 +-
drivers/firmware/arm-ffa/core.c | 17 ++++++++++++++---
drivers/firmware/arm-ffa/sandbox.c | 2 +-
include/arm_ffa.h | 2 +-
lib/efi_loader/efi_capsule.c | 2 +-
lib/efi_loader/efi_setup.c | 2 +-
lib/efi_loader/efi_variable_tee.c | 2 +-
test/dm/ffa.c | 6 +++---
8 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/cmd/armffa.c b/cmd/armffa.c
index 9b56e8a830..9842b99181 100644
--- a/cmd/armffa.c
+++ b/cmd/armffa.c
@@ -129,7 +129,7 @@ int do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
return -EINVAL;
}
- ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
if (ret == 0) {
u8 cnt;
diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c
index caba10caae..ba1ba59937 100644
--- a/drivers/firmware/arm-ffa/core.c
+++ b/drivers/firmware/arm-ffa/core.c
@@ -1032,6 +1032,7 @@ static int ffa_cache_partitions_info(void)
* ffa_msg_send_direct_req - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function
* @dst_part_id: destination partition ID
* @msg: pointer to the message data preallocated by the client (in/out)
+ * @is_smc64: select 64-bit or 32-bit FF-A ABI
*
* This is the runtime function that implements FFA_MSG_SEND_DIRECT_{REQ,RESP}
* FF-A functions.
@@ -1048,10 +1049,12 @@ static int ffa_cache_partitions_info(void)
*
* 0 on success. Otherwise, failure
*/
-static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_send_direct_data *msg)
+static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_send_direct_data *msg,
+ u8 is_smc64)
{
ffa_value_t res = {0};
int ffa_errno;
+ u64 req_mode, resp_mode;
if (!ffa_priv_data || !ffa_priv_data->invoke_ffa_fn)
return -EINVAL;
@@ -1060,8 +1063,16 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs)
return -ENODEV;
+ if(is_smc64) {
+ req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ);
+ resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP);
+ } else {
+ req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ);
+ resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP);
+ }
+
ffa_priv_data->invoke_ffa_fn((ffa_value_t){
- .a0 = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ),
+ .a0 = req_mode,
.a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id) |
PREP_PART_ENDPOINT_ID(dst_part_id),
.a2 = 0,
@@ -1083,7 +1094,7 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
return 0;
}
- if (res.a0 == FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP)) {
+ if (res.a0 == resp_mode){
/*
* Message sent with response
* extract the return data
diff --git a/drivers/firmware/arm-ffa/sandbox.c b/drivers/firmware/arm-ffa/sandbox.c
index 16e1fdc809..8e8549441d 100644
--- a/drivers/firmware/arm-ffa/sandbox.c
+++ b/drivers/firmware/arm-ffa/sandbox.c
@@ -430,7 +430,7 @@ static int sandbox_ffa_sp_valid(u16 part_id)
* @{a0-a7} , res: The SMC call arguments and return structure.
*
* This is the function that emulates FFA_MSG_SEND_DIRECT_{REQ,RESP}
- * FF-A functions.
+ * FF-A functions. Only SMC 64-bit is supported in Sandbox.
*
* Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not supported.
* In case of success FFA_MSG_SEND_DIRECT_RESP is returned with default pattern data (0xff).
diff --git a/include/arm_ffa.h b/include/arm_ffa.h
index 665413a0c5..4a7c59ff28 100644
--- a/include/arm_ffa.h
+++ b/include/arm_ffa.h
@@ -97,7 +97,7 @@ struct __packed ffa_send_direct_data {
struct ffa_bus_ops {
int (*partition_info_get)(const char *uuid_str,
u32 *parts_size, struct ffa_partition_info *buffer);
- int (*sync_send_receive)(u16 dst_part_id, struct ffa_send_direct_data *msg);
+ int (*sync_send_receive)(u16 dst_part_id, struct ffa_send_direct_data *msg, u8 is_smc64);
int (*rxtx_unmap)(void);
};
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 65e2fc8296..c479c53d04 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -591,7 +591,7 @@ static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_s
msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */
- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
}
#endif
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 6ccda175ff..416af8d663 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -153,7 +153,7 @@ static int efi_corstone1000_uboot_efi_started_event(void)
msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */
- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
}
#endif
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 7d9d577281..05f3c02911 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -201,7 +201,7 @@ static int __efi_runtime ffa_notify_mm_sp(void)
msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */
- ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg, 1);
if (ret != 0)
return ret;
diff --git a/test/dm/ffa.c b/test/dm/ffa.c
index 052d5fc3f4..14b19cf71e 100644
--- a/test/dm/ffa.c
+++ b/test/dm/ffa.c
@@ -170,7 +170,7 @@ static int test_ffa_msg_send_direct_req(u16 part_id, struct unit_test_state *ut
struct ffa_send_direct_data msg = {0};
u8 cnt;
- ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg));
+ ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1));
for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++)
ut_assertok(((u64 *)&msg)[cnt] != 0xffffffffffffffff);
@@ -380,12 +380,12 @@ static int dm_test_ffa_nack(struct unit_test_state *uts)
ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
/* send data to an invalid partition */
- ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
ut_assertok(ret != -EINVAL);
/* send data to a valid partition */
part_id = prvdata->partitions.descs[0].info.id;
- ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
+ ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
ut_assertok(ret != 0);
return CMD_RET_SUCCESS;
--
2.17.1
@@ -18,37 +18,32 @@ EXTRA_OEMAKE:append:corstone1000 = ' DEVICE_TREE=${CORSTONE1000_DEVICE_TREE}'
SYSROOT_DIRS:append:corstone1000 = " /boot"
SRC_URI:append:corstone1000 = " \
file://0001-cmd-load-add-load-command-for-memory-mapped.patch \
file://0002-arm-add-support-to-corstone1000-platform.patch \
file://0003-usb-common-move-urb-code-to-common.patch \
file://0004-usb-add-isp1760-family-driver.patch \
file://0005-corstone1000-enable-isp1763-usb-controller.patch \
file://0006-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch \
file://0007-arm64-smccc-clear-the-Xn-registers-after-SMC-calls.patch \
file://0008-lib-uuid-introduce-be_uuid_str_to_le_bin-function.patch \
file://0009-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch \
file://0010-arm_ffa-introduce-armffa-command.patch \
file://0011-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch \
file://0012-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch \
file://0013-arm_ffa-introduce-armffa-command-Sandbox-test.patch \
file://0014-arm_ffa-introduce-FF-A-MM-communication.patch \
file://0015-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch \
file://0016-efi-corstone1000-introduce-EFI-capsule-update.patch \
file://0017-corstone1000-Update-FFA-shared-buffer-address.patch \
file://0018-arm-corstone1000-fix-unrecognized-filesystem-type.patch \
file://0019-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch \
file://0020-efi_boottime-corstone1000-pass-interface-id-and-kern.patch \
file://0021-efi_loader-corstone1000-remove-guid-check-from-corst.patch \
file://0022-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch \
file://0023-efi_firmware-add-get_image_info-for-corstone1000.patch \
file://0024-efi_loader-send-bootcomplete-message-to-secure-encla.patch \
file://0025-efi_loader-fix-null-pointer-exception-with-get_image.patch \
file://0026-arm-corstone1000-add-mmc-for-fvp.patch \
file://0027-corstone1000-use-a-compressed-kernel.patch \
file://0028-Introduce-external-sys-driver-to-device-tree.patch \
file://0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \
file://0030-arm-corstone1000-esrt-support.patch \
file://0031-ffa-add-support-for-32-bit-direct-messaging.patch \
file://0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch \
file://0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch \
file://0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch \
file://0004-arm_ffa-efi-unmap-RX-TX-buffers.patch \
file://0005-arm_ffa-introduce-armffa-command.patch \
file://0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch \
file://0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch \
file://0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch \
file://0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch \
file://0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch \
file://0011-efi-corstone1000-introduce-EFI-capsule-update.patch \
file://0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch \
file://0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch \
file://0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch \
file://0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch \
file://0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch \
file://0017-efi_firmware-add-get_image_info-for-corstone1000.patch \
file://0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch \
file://0019-efi_loader-fix-null-pointer-exception-with-get_image.patch \
file://0020-arm-corstone1000-add-mmc-for-fvp.patch \
file://0021-corstone1000-add-compressed-kernel-support.patch \
file://0022-Introduce-external-sys-driver-to-device-tree.patch \
file://0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \
file://0024-arm-corstone1000-esrt-support.patch \
file://0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch \
file://0026-corstone1000-enable-distro-booting-command.patch \
"
#