* [PATCH 1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:10 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 2/7] firmware: add missing include Sascha Hauer
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
CONFIG_FIRMWARE_IMX8MQ_OPTEE is used but not defined in Kconfig. Add the
missing symbol like existing for the other i.MX8M variants.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
firmware/Kconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/firmware/Kconfig b/firmware/Kconfig
index 38fbf85555..8babdb85a8 100644
--- a/firmware/Kconfig
+++ b/firmware/Kconfig
@@ -53,6 +53,10 @@ config FIRMWARE_IMX8MP_OPTEE
bool "install OP-TEE on i.MX8MP boards"
depends on FIRMWARE_IMX8MP_ATF && PBL_OPTEE
+config FIRMWARE_IMX8MQ_OPTEE
+ bool "install OP-TEE on i.MX8MQ boards"
+ depends on FIRMWARE_IMX8MQ_ATF && PBL_OPTEE
+
config FIRMWARE_CCBV2_OPTEE
bool
depends on MACH_WEBASTO_CCBV2 && PBL_OPTEE
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol
2024-01-19 14:24 ` [PATCH 1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol Sascha Hauer
@ 2024-01-19 15:10 ` Marco Felsch
0 siblings, 0 replies; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:10 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> CONFIG_FIRMWARE_IMX8MQ_OPTEE is used but not defined in Kconfig. Add the
> missing symbol like existing for the other i.MX8M variants.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> firmware/Kconfig | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/firmware/Kconfig b/firmware/Kconfig
> index 38fbf85555..8babdb85a8 100644
> --- a/firmware/Kconfig
> +++ b/firmware/Kconfig
> @@ -53,6 +53,10 @@ config FIRMWARE_IMX8MP_OPTEE
> bool "install OP-TEE on i.MX8MP boards"
> depends on FIRMWARE_IMX8MP_ATF && PBL_OPTEE
>
> +config FIRMWARE_IMX8MQ_OPTEE
> + bool "install OP-TEE on i.MX8MQ boards"
> + depends on FIRMWARE_IMX8MQ_ATF && PBL_OPTEE
> +
> config FIRMWARE_CCBV2_OPTEE
> bool
> depends on MACH_WEBASTO_CCBV2 && PBL_OPTEE
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/7] firmware: add missing include
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
2024-01-19 14:24 ` [PATCH 1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:11 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 3/7] firmware: i.MX OP-TEE: Add some Kconfig help Sascha Hauer
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
include/firmware.h uses _text and as such needs asm/sections.h. Add the
missing include.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/firmware.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/firmware.h b/include/firmware.h
index 93c800e11b..361ff2f8ae 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -12,6 +12,7 @@
#include <driver.h>
#include <debug_ll.h>
#include <linux/kernel.h>
+#include <asm/sections.h>
struct firmware {
size_t size;
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] firmware: add missing include
2024-01-19 14:24 ` [PATCH 2/7] firmware: add missing include Sascha Hauer
@ 2024-01-19 15:11 ` Marco Felsch
0 siblings, 0 replies; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:11 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> include/firmware.h uses _text and as such needs asm/sections.h. Add the
> missing include.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> include/firmware.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/firmware.h b/include/firmware.h
> index 93c800e11b..361ff2f8ae 100644
> --- a/include/firmware.h
> +++ b/include/firmware.h
> @@ -12,6 +12,7 @@
> #include <driver.h>
> #include <debug_ll.h>
> #include <linux/kernel.h>
> +#include <asm/sections.h>
>
> struct firmware {
> size_t size;
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] firmware: i.MX OP-TEE: Add some Kconfig help
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
2024-01-19 14:24 ` [PATCH 1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol Sascha Hauer
2024-01-19 14:24 ` [PATCH 2/7] firmware: add missing include Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:12 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry() Sascha Hauer
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
By enabling FIRMWARE_IMX8M*_OPTEE barebox will load and start OP-TEE
via the TF-A. Add some help text which explains where the OP-TEE
binaries are expected during barebox build.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
firmware/Kconfig | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/firmware/Kconfig b/firmware/Kconfig
index 8babdb85a8..c1731366c6 100644
--- a/firmware/Kconfig
+++ b/firmware/Kconfig
@@ -44,18 +44,34 @@ config FIRMWARE_IMX93_ATF
config FIRMWARE_IMX8MM_OPTEE
bool "install OP-TEE on i.MX8MM boards"
depends on FIRMWARE_IMX8MM_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MM. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl31.bin-optee.
config FIRMWARE_IMX8MN_OPTEE
bool "install OP-TEE on i.MX8MN boards"
depends on FIRMWARE_IMX8MN_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MN. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl31.bin-optee.
config FIRMWARE_IMX8MP_OPTEE
bool "install OP-TEE on i.MX8MP boards"
depends on FIRMWARE_IMX8MP_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MP. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl31.bin-optee.
config FIRMWARE_IMX8MQ_OPTEE
bool "install OP-TEE on i.MX8MQ boards"
depends on FIRMWARE_IMX8MQ_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MQ. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl31.bin-optee.
config FIRMWARE_CCBV2_OPTEE
bool
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] firmware: i.MX OP-TEE: Add some Kconfig help
2024-01-19 14:24 ` [PATCH 3/7] firmware: i.MX OP-TEE: Add some Kconfig help Sascha Hauer
@ 2024-01-19 15:12 ` Marco Felsch
0 siblings, 0 replies; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:12 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> By enabling FIRMWARE_IMX8M*_OPTEE barebox will load and start OP-TEE
> via the TF-A. Add some help text which explains where the OP-TEE
> binaries are expected during barebox build.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> firmware/Kconfig | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/firmware/Kconfig b/firmware/Kconfig
> index 8babdb85a8..c1731366c6 100644
> --- a/firmware/Kconfig
> +++ b/firmware/Kconfig
> @@ -44,18 +44,34 @@ config FIRMWARE_IMX93_ATF
> config FIRMWARE_IMX8MM_OPTEE
> bool "install OP-TEE on i.MX8MM boards"
> depends on FIRMWARE_IMX8MM_ATF && PBL_OPTEE
> + help
> + This enables OP-TEE loading and starting on i.MX8MM. Place the OP-TEE binary
> + in CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl32.bin. When this option is enabled then
> + the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mm-bl31.bin-optee.
>
> config FIRMWARE_IMX8MN_OPTEE
> bool "install OP-TEE on i.MX8MN boards"
> depends on FIRMWARE_IMX8MN_ATF && PBL_OPTEE
> + help
> + This enables OP-TEE loading and starting on i.MX8MN. Place the OP-TEE binary
> + in CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl32.bin. When this option is enabled then
> + the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mn-bl31.bin-optee.
>
> config FIRMWARE_IMX8MP_OPTEE
> bool "install OP-TEE on i.MX8MP boards"
> depends on FIRMWARE_IMX8MP_ATF && PBL_OPTEE
> + help
> + This enables OP-TEE loading and starting on i.MX8MP. Place the OP-TEE binary
> + in CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl32.bin. When this option is enabled then
> + the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mp-bl31.bin-optee.
>
> config FIRMWARE_IMX8MQ_OPTEE
> bool "install OP-TEE on i.MX8MQ boards"
> depends on FIRMWARE_IMX8MQ_ATF && PBL_OPTEE
> + help
> + This enables OP-TEE loading and starting on i.MX8MQ. Place the OP-TEE binary
> + in CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl32.bin. When this option is enabled then
> + the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl31.bin-optee.
>
> config FIRMWARE_CCBV2_OPTEE
> bool
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry()
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
` (2 preceding siblings ...)
2024-01-19 14:24 ` [PATCH 3/7] firmware: i.MX OP-TEE: Add some Kconfig help Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:21 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 5/7] ARM: i.MX: export imx9_ddrc_sdram_size() Sascha Hauer
` (3 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
We already have support for detecting the DDR size automatically on
i.MX93. Create imx93_barebox_entry() from it and use it instead of
the hardcoded DDR size in the tqmba9xxxca board.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/tqmba9xxxca/lowlevel.c | 4 +++-
arch/arm/mach-imx/esdctl.c | 15 ++++++++++++---
include/mach/imx/esdctl.h | 1 +
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boards/tqmba9xxxca/lowlevel.c b/arch/arm/boards/tqmba9xxxca/lowlevel.c
index 0a57d02451..64913b8de9 100644
--- a/arch/arm/boards/tqmba9xxxca/lowlevel.c
+++ b/arch/arm/boards/tqmba9xxxca/lowlevel.c
@@ -4,11 +4,13 @@
#include <debug_ll.h>
#include <mach/imx/debug_ll.h>
#include <mach/imx/generic.h>
+#include <mach/imx/xload.h>
#include <asm/barebox-arm.h>
#include <soc/imx9/ddr.h>
#include <mach/imx/atf.h>
#include <mach/imx/xload.h>
#include <mach/imx/romapi.h>
+#include <mach/imx/esdctl.h>
extern char __dtb_z_imx93_tqma9352_mba93xxca_start[];
extern struct dram_timing_info tqma93xxca_dram_timing;
@@ -29,7 +31,7 @@ static noinline void tqma9352_mba93xxca_continue(void)
imx93_load_and_start_image_via_tfa();
}
- barebox_arm_entry(0x80000000, 0x40000000, __dtb_z_imx93_tqma9352_mba93xxca_start);
+ imx93_barebox_entry(__dtb_z_imx93_tqma9352_mba93xxca_start);
}
ENTRY_FUNCTION(start_imx93_tqma9352_mba93xxca, r0, r1, r2)
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 1bd22cc6ef..2dc858c87f 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -563,7 +563,7 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
#define IMX9_DDRC_CS_COL_BITS GENMASK(2, 0)
#define IMX9_DDRC_CS_EN BIT(31)
-static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
{
int width = 2;
int banks = 8;
@@ -588,7 +588,12 @@ static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
mem += memory_sdram_size(cols, rows, banks, width);
}
- return arm_add_mem_device("ram0", data->base0, mem);
+ return mem;
+}
+
+static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+{
+ return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size(mmdcbase));
}
static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
@@ -1039,4 +1044,8 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
boarddata);
}
-
+void __noreturn imx93_barebox_entry(void *boarddata)
+{
+ barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
+ imx9_ddrc_sdram_size(IOMEM(MX9_DDR_CTL_BASE)), boarddata);
+}
diff --git a/include/mach/imx/esdctl.h b/include/mach/imx/esdctl.h
index 01533478cc..4898a3e682 100644
--- a/include/mach/imx/esdctl.h
+++ b/include/mach/imx/esdctl.h
@@ -148,6 +148,7 @@ void __noreturn imx8mn_barebox_entry(void *boarddata);
void __noreturn imx8mp_barebox_entry(void *boarddata);
void __noreturn imx8mq_barebox_entry(void *boarddata);
void __noreturn imx7d_barebox_entry(void *boarddata);
+void __noreturn imx93_barebox_entry(void *boarddata);
#define imx6sx_barebox_entry(boarddata) imx6ul_barebox_entry(boarddata)
void imx_esdctl_disable(void);
resource_size_t imx8m_barebox_earlymem_size(unsigned buswidth);
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry()
2024-01-19 14:24 ` [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry() Sascha Hauer
@ 2024-01-19 15:21 ` Marco Felsch
2024-01-22 10:20 ` Sascha Hauer
0 siblings, 1 reply; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:21 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> We already have support for detecting the DDR size automatically on
> i.MX93. Create imx93_barebox_entry() from it and use it instead of
> the hardcoded DDR size in the tqmba9xxxca board.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> arch/arm/boards/tqmba9xxxca/lowlevel.c | 4 +++-
> arch/arm/mach-imx/esdctl.c | 15 ++++++++++++---
> include/mach/imx/esdctl.h | 1 +
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/boards/tqmba9xxxca/lowlevel.c b/arch/arm/boards/tqmba9xxxca/lowlevel.c
> index 0a57d02451..64913b8de9 100644
> --- a/arch/arm/boards/tqmba9xxxca/lowlevel.c
> +++ b/arch/arm/boards/tqmba9xxxca/lowlevel.c
> @@ -4,11 +4,13 @@
> #include <debug_ll.h>
> #include <mach/imx/debug_ll.h>
> #include <mach/imx/generic.h>
> +#include <mach/imx/xload.h>
> #include <asm/barebox-arm.h>
> #include <soc/imx9/ddr.h>
> #include <mach/imx/atf.h>
> #include <mach/imx/xload.h>
> #include <mach/imx/romapi.h>
> +#include <mach/imx/esdctl.h>
>
> extern char __dtb_z_imx93_tqma9352_mba93xxca_start[];
> extern struct dram_timing_info tqma93xxca_dram_timing;
> @@ -29,7 +31,7 @@ static noinline void tqma9352_mba93xxca_continue(void)
> imx93_load_and_start_image_via_tfa();
> }
>
> - barebox_arm_entry(0x80000000, 0x40000000, __dtb_z_imx93_tqma9352_mba93xxca_start);
> + imx93_barebox_entry(__dtb_z_imx93_tqma9352_mba93xxca_start);
> }
>
> ENTRY_FUNCTION(start_imx93_tqma9352_mba93xxca, r0, r1, r2)
> diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
> index 1bd22cc6ef..2dc858c87f 100644
> --- a/arch/arm/mach-imx/esdctl.c
> +++ b/arch/arm/mach-imx/esdctl.c
> @@ -563,7 +563,7 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> #define IMX9_DDRC_CS_COL_BITS GENMASK(2, 0)
> #define IMX9_DDRC_CS_EN BIT(31)
>
> -static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> +static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
> {
> int width = 2;
> int banks = 8;
> @@ -588,7 +588,12 @@ static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> mem += memory_sdram_size(cols, rows, banks, width);
> }
>
> - return arm_add_mem_device("ram0", data->base0, mem);
> + return mem;
Nit: make mem typeof resource_size_t?
Regards,
Marco
> +}
> +
> +static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> +{
> + return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size(mmdcbase));
> }
>
> static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
> @@ -1039,4 +1044,8 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
> boarddata);
> }
>
> -
> +void __noreturn imx93_barebox_entry(void *boarddata)
> +{
> + barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
> + imx9_ddrc_sdram_size(IOMEM(MX9_DDR_CTL_BASE)), boarddata);
> +}
> diff --git a/include/mach/imx/esdctl.h b/include/mach/imx/esdctl.h
> index 01533478cc..4898a3e682 100644
> --- a/include/mach/imx/esdctl.h
> +++ b/include/mach/imx/esdctl.h
> @@ -148,6 +148,7 @@ void __noreturn imx8mn_barebox_entry(void *boarddata);
> void __noreturn imx8mp_barebox_entry(void *boarddata);
> void __noreturn imx8mq_barebox_entry(void *boarddata);
> void __noreturn imx7d_barebox_entry(void *boarddata);
> +void __noreturn imx93_barebox_entry(void *boarddata);
> #define imx6sx_barebox_entry(boarddata) imx6ul_barebox_entry(boarddata)
> void imx_esdctl_disable(void);
> resource_size_t imx8m_barebox_earlymem_size(unsigned buswidth);
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry()
2024-01-19 15:21 ` Marco Felsch
@ 2024-01-22 10:20 ` Sascha Hauer
0 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2024-01-22 10:20 UTC (permalink / raw)
To: Marco Felsch; +Cc: Barebox List
On Fri, Jan 19, 2024 at 04:21:03PM +0100, Marco Felsch wrote:
> On 24-01-19, Sascha Hauer wrote:
> > We already have support for detecting the DDR size automatically on
> > i.MX93. Create imx93_barebox_entry() from it and use it instead of
> > the hardcoded DDR size in the tqmba9xxxca board.
> >
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> > arch/arm/boards/tqmba9xxxca/lowlevel.c | 4 +++-
> > arch/arm/mach-imx/esdctl.c | 15 ++++++++++++---
> > include/mach/imx/esdctl.h | 1 +
> > 3 files changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/boards/tqmba9xxxca/lowlevel.c b/arch/arm/boards/tqmba9xxxca/lowlevel.c
> > index 0a57d02451..64913b8de9 100644
> > --- a/arch/arm/boards/tqmba9xxxca/lowlevel.c
> > +++ b/arch/arm/boards/tqmba9xxxca/lowlevel.c
> > @@ -4,11 +4,13 @@
> > #include <debug_ll.h>
> > #include <mach/imx/debug_ll.h>
> > #include <mach/imx/generic.h>
> > +#include <mach/imx/xload.h>
> > #include <asm/barebox-arm.h>
> > #include <soc/imx9/ddr.h>
> > #include <mach/imx/atf.h>
> > #include <mach/imx/xload.h>
> > #include <mach/imx/romapi.h>
> > +#include <mach/imx/esdctl.h>
> >
> > extern char __dtb_z_imx93_tqma9352_mba93xxca_start[];
> > extern struct dram_timing_info tqma93xxca_dram_timing;
> > @@ -29,7 +31,7 @@ static noinline void tqma9352_mba93xxca_continue(void)
> > imx93_load_and_start_image_via_tfa();
> > }
> >
> > - barebox_arm_entry(0x80000000, 0x40000000, __dtb_z_imx93_tqma9352_mba93xxca_start);
> > + imx93_barebox_entry(__dtb_z_imx93_tqma9352_mba93xxca_start);
> > }
> >
> > ENTRY_FUNCTION(start_imx93_tqma9352_mba93xxca, r0, r1, r2)
> > diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
> > index 1bd22cc6ef..2dc858c87f 100644
> > --- a/arch/arm/mach-imx/esdctl.c
> > +++ b/arch/arm/mach-imx/esdctl.c
> > @@ -563,7 +563,7 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> > #define IMX9_DDRC_CS_COL_BITS GENMASK(2, 0)
> > #define IMX9_DDRC_CS_EN BIT(31)
> >
> > -static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> > +static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
> > {
> > int width = 2;
> > int banks = 8;
> > @@ -588,7 +588,12 @@ static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> > mem += memory_sdram_size(cols, rows, banks, width);
> > }
> >
> > - return arm_add_mem_device("ram0", data->base0, mem);
> > + return mem;
>
> Nit: make mem typeof resource_size_t?
Yes. Added an extra patch for this.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/7] ARM: i.MX: export imx9_ddrc_sdram_size()
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
` (3 preceding siblings ...)
2024-01-19 14:24 ` [PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry() Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:21 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 6/7] ARM: i.MX93: add scratch space support Sascha Hauer
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
imx9_ddrc_sdram_size() will be needed by upcoming i.MX93 scratch space
support, so export it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/esdctl.c | 7 ++++---
include/mach/imx/esdctl.h | 1 +
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 2dc858c87f..9c2c4b105d 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -563,8 +563,9 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
#define IMX9_DDRC_CS_COL_BITS GENMASK(2, 0)
#define IMX9_DDRC_CS_EN BIT(31)
-static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
+resource_size_t imx9_ddrc_sdram_size(void)
{
+ void __iomem *mmdcbase = IOMEM(MX9_DDR_CTL_BASE);
int width = 2;
int banks = 8;
unsigned long mem = 0;
@@ -593,7 +594,7 @@ static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
{
- return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size(mmdcbase));
+ return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size());
}
static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
@@ -1047,5 +1048,5 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
void __noreturn imx93_barebox_entry(void *boarddata)
{
barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
- imx9_ddrc_sdram_size(IOMEM(MX9_DDR_CTL_BASE)), boarddata);
+ imx9_ddrc_sdram_size(), boarddata);
}
diff --git a/include/mach/imx/esdctl.h b/include/mach/imx/esdctl.h
index 4898a3e682..d79bf17959 100644
--- a/include/mach/imx/esdctl.h
+++ b/include/mach/imx/esdctl.h
@@ -152,6 +152,7 @@ void __noreturn imx93_barebox_entry(void *boarddata);
#define imx6sx_barebox_entry(boarddata) imx6ul_barebox_entry(boarddata)
void imx_esdctl_disable(void);
resource_size_t imx8m_barebox_earlymem_size(unsigned buswidth);
+resource_size_t imx9_ddrc_sdram_size(void);
#endif
#endif /* __MACH_ESDCTL_V2_H */
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] ARM: i.MX: export imx9_ddrc_sdram_size()
2024-01-19 14:24 ` [PATCH 5/7] ARM: i.MX: export imx9_ddrc_sdram_size() Sascha Hauer
@ 2024-01-19 15:21 ` Marco Felsch
0 siblings, 0 replies; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:21 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> imx9_ddrc_sdram_size() will be needed by upcoming i.MX93 scratch space
> support, so export it.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> arch/arm/mach-imx/esdctl.c | 7 ++++---
> include/mach/imx/esdctl.h | 1 +
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
> index 2dc858c87f..9c2c4b105d 100644
> --- a/arch/arm/mach-imx/esdctl.c
> +++ b/arch/arm/mach-imx/esdctl.c
> @@ -563,8 +563,9 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> #define IMX9_DDRC_CS_COL_BITS GENMASK(2, 0)
> #define IMX9_DDRC_CS_EN BIT(31)
>
> -static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
> +resource_size_t imx9_ddrc_sdram_size(void)
> {
> + void __iomem *mmdcbase = IOMEM(MX9_DDR_CTL_BASE);
> int width = 2;
> int banks = 8;
> unsigned long mem = 0;
> @@ -593,7 +594,7 @@ static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
>
> static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
> {
> - return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size(mmdcbase));
> + return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size());
> }
>
> static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
> @@ -1047,5 +1048,5 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
> void __noreturn imx93_barebox_entry(void *boarddata)
> {
> barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
> - imx9_ddrc_sdram_size(IOMEM(MX9_DDR_CTL_BASE)), boarddata);
> + imx9_ddrc_sdram_size(), boarddata);
> }
> diff --git a/include/mach/imx/esdctl.h b/include/mach/imx/esdctl.h
> index 4898a3e682..d79bf17959 100644
> --- a/include/mach/imx/esdctl.h
> +++ b/include/mach/imx/esdctl.h
> @@ -152,6 +152,7 @@ void __noreturn imx93_barebox_entry(void *boarddata);
> #define imx6sx_barebox_entry(boarddata) imx6ul_barebox_entry(boarddata)
> void imx_esdctl_disable(void);
> resource_size_t imx8m_barebox_earlymem_size(unsigned buswidth);
> +resource_size_t imx9_ddrc_sdram_size(void);
> #endif
>
> #endif /* __MACH_ESDCTL_V2_H */
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] ARM: i.MX93: add scratch space support
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
` (4 preceding siblings ...)
2024-01-19 14:24 ` [PATCH 5/7] ARM: i.MX: export imx9_ddrc_sdram_size() Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-19 15:23 ` Marco Felsch
2024-01-19 14:24 ` [PATCH 7/7] ARM: i.MX93: Add OP-TEE support Sascha Hauer
2024-01-22 10:15 ` [PATCH 0/7] ARM: Add i.MX93 " Sascha Hauer
7 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
With upcoming i.MX93 OP-TEE support we'll need to transport the OP-TEE
base address from PBL to barebox proper. Add scratch space support for
i.MX93 to accommodate this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/atf.c | 2 ++
arch/arm/mach-imx/esdctl.c | 2 ++
arch/arm/mach-imx/scratch.c | 11 +++++++++++
include/mach/imx/scratch.h | 1 +
4 files changed, 16 insertions(+)
diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index d334c902b2..148de8f448 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -384,6 +384,8 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
const void *tfa;
size_t tfa_size;
+ imx93_init_scratch_space(true);
+
/*
* On completion the TF-A will jump to MX93_ATF_BL33_BASE_ADDR
* in EL2. Copy the image there, but replace the PBL part of
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 9c2c4b105d..0dbf0f7242 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -1047,6 +1047,8 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
void __noreturn imx93_barebox_entry(void *boarddata)
{
+ imx93_init_scratch_space(false);
+
barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
imx9_ddrc_sdram_size(), boarddata);
}
diff --git a/arch/arm/mach-imx/scratch.c b/arch/arm/mach-imx/scratch.c
index 117b2eadbf..60d15a4f1a 100644
--- a/arch/arm/mach-imx/scratch.c
+++ b/arch/arm/mach-imx/scratch.c
@@ -5,6 +5,7 @@
#include <linux/err.h>
#include <linux/printk.h>
#include <mach/imx/imx8m-regs.h>
+#include <mach/imx/imx9-regs.h>
#include <mach/imx/esdctl.h>
#include <mach/imx/scratch.h>
#include <memory.h>
@@ -30,6 +31,16 @@ void imx8m_init_scratch_space(int ddr_buswidth, bool zero_init)
memset(scratch, 0, sizeof(*scratch));
}
+void imx93_init_scratch_space(bool zero_init)
+{
+ ulong endmem = MX9_DDR_CSD1_BASE_ADDR + imx9_ddrc_sdram_size();
+
+ scratch = (void *)arm_mem_scratch(endmem);
+
+ if (zero_init)
+ memset(scratch, 0, sizeof(*scratch));
+}
+
void imx8m_scratch_save_bootrom_log(const u32 *rom_log)
{
size_t sz = sizeof(scratch->bootrom_log);
diff --git a/include/mach/imx/scratch.h b/include/mach/imx/scratch.h
index b1bb2e446e..6c2cecabcd 100644
--- a/include/mach/imx/scratch.h
+++ b/include/mach/imx/scratch.h
@@ -4,6 +4,7 @@
#define __MACH_IMX_SCRATCH_H
void imx8m_init_scratch_space(int ddr_buswidth, bool zero_init);
+void imx93_init_scratch_space(bool zero_init);
const u32 *imx8m_scratch_get_bootrom_log(void);
void imx8m_scratch_save_bootrom_log(const u32 *rom_log);
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/7] ARM: i.MX93: add scratch space support
2024-01-19 14:24 ` [PATCH 6/7] ARM: i.MX93: add scratch space support Sascha Hauer
@ 2024-01-19 15:23 ` Marco Felsch
0 siblings, 0 replies; 16+ messages in thread
From: Marco Felsch @ 2024-01-19 15:23 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On 24-01-19, Sascha Hauer wrote:
> With upcoming i.MX93 OP-TEE support we'll need to transport the OP-TEE
> base address from PBL to barebox proper. Add scratch space support for
> i.MX93 to accommodate this.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> arch/arm/mach-imx/atf.c | 2 ++
> arch/arm/mach-imx/esdctl.c | 2 ++
> arch/arm/mach-imx/scratch.c | 11 +++++++++++
> include/mach/imx/scratch.h | 1 +
> 4 files changed, 16 insertions(+)
>
> diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
> index d334c902b2..148de8f448 100644
> --- a/arch/arm/mach-imx/atf.c
> +++ b/arch/arm/mach-imx/atf.c
> @@ -384,6 +384,8 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
> const void *tfa;
> size_t tfa_size;
>
> + imx93_init_scratch_space(true);
> +
> /*
> * On completion the TF-A will jump to MX93_ATF_BL33_BASE_ADDR
> * in EL2. Copy the image there, but replace the PBL part of
> diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
> index 9c2c4b105d..0dbf0f7242 100644
> --- a/arch/arm/mach-imx/esdctl.c
> +++ b/arch/arm/mach-imx/esdctl.c
> @@ -1047,6 +1047,8 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
>
> void __noreturn imx93_barebox_entry(void *boarddata)
> {
> + imx93_init_scratch_space(false);
> +
> barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
> imx9_ddrc_sdram_size(), boarddata);
> }
> diff --git a/arch/arm/mach-imx/scratch.c b/arch/arm/mach-imx/scratch.c
> index 117b2eadbf..60d15a4f1a 100644
> --- a/arch/arm/mach-imx/scratch.c
> +++ b/arch/arm/mach-imx/scratch.c
> @@ -5,6 +5,7 @@
> #include <linux/err.h>
> #include <linux/printk.h>
> #include <mach/imx/imx8m-regs.h>
> +#include <mach/imx/imx9-regs.h>
> #include <mach/imx/esdctl.h>
> #include <mach/imx/scratch.h>
> #include <memory.h>
> @@ -30,6 +31,16 @@ void imx8m_init_scratch_space(int ddr_buswidth, bool zero_init)
> memset(scratch, 0, sizeof(*scratch));
> }
>
> +void imx93_init_scratch_space(bool zero_init)
> +{
> + ulong endmem = MX9_DDR_CSD1_BASE_ADDR + imx9_ddrc_sdram_size();
> +
> + scratch = (void *)arm_mem_scratch(endmem);
> +
> + if (zero_init)
> + memset(scratch, 0, sizeof(*scratch));
> +}
> +
> void imx8m_scratch_save_bootrom_log(const u32 *rom_log)
> {
> size_t sz = sizeof(scratch->bootrom_log);
> diff --git a/include/mach/imx/scratch.h b/include/mach/imx/scratch.h
> index b1bb2e446e..6c2cecabcd 100644
> --- a/include/mach/imx/scratch.h
> +++ b/include/mach/imx/scratch.h
> @@ -4,6 +4,7 @@
> #define __MACH_IMX_SCRATCH_H
>
> void imx8m_init_scratch_space(int ddr_buswidth, bool zero_init);
> +void imx93_init_scratch_space(bool zero_init);
>
> const u32 *imx8m_scratch_get_bootrom_log(void);
> void imx8m_scratch_save_bootrom_log(const u32 *rom_log);
> --
> 2.39.2
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 7/7] ARM: i.MX93: Add OP-TEE support
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
` (5 preceding siblings ...)
2024-01-19 14:24 ` [PATCH 6/7] ARM: i.MX93: add scratch space support Sascha Hauer
@ 2024-01-19 14:24 ` Sascha Hauer
2024-01-22 10:15 ` [PATCH 0/7] ARM: Add i.MX93 " Sascha Hauer
7 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2024-01-19 14:24 UTC (permalink / raw)
To: Barebox List
This enables OP-TEE support for i.MX93. This is done in a way very
similar to how it's done on i.MX8M.
One major difference is that the i.MX93 needs a RAM firmware for the
EdgeLock secure enclave. Without it OP-TEE doesn't work properly.
The firmware can be integrated into the i.MX93 image where the ROM
picks it up automatically. The firmware image is SoC revision specific
though, so we load the firmware during runtime to avoid having to
create a barebox image for each SoC revision.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/atf.c | 23 ++++++++++++-
arch/arm/mach-imx/ele.c | 67 ++++++++++++++++++++++++++++++++++++++
arch/arm/mach-imx/esdctl.c | 1 +
arch/arm/mach-imx/imx9.c | 15 +++++++++
firmware/Kconfig | 12 +++++++
firmware/Makefile | 5 ++-
include/mach/imx/ele.h | 5 +++
7 files changed, 126 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index 148de8f448..fad9b7954f 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -14,6 +14,7 @@
#include <soc/fsl/fsl_udc.h>
#include <soc/fsl/caam.h>
#include <tee/optee.h>
+#include <mach/imx/ele.h>
/**
* imx8m_atf_load_bl31 - Load ATF BL31 blob and transfer control to it
@@ -383,6 +384,8 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
void __noreturn (*bl31)(void) = (void *)atf_dest;
const void *tfa;
size_t tfa_size;
+ void *bl33 = (void *)MX93_ATF_BL33_BASE_ADDR;
+ unsigned long endmem = MX9_DDR_CSD1_BASE_ADDR + imx9_ddrc_sdram_size();
imx93_init_scratch_space(true);
@@ -402,7 +405,25 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
*/
memcpy((void *)MX93_ATF_BL33_BASE_ADDR, __image_start, ALIGN(barebox_pbl_size, 1024));
- get_builtin_firmware(imx93_bl31_bin, &tfa, &tfa_size);
+ if (IS_ENABLED(CONFIG_FIRMWARE_IMX93_OPTEE)) {
+ void *bl32 = (void *)arm_mem_optee(endmem);
+ size_t bl32_size;
+ void *bl32_image;
+
+ imx93_ele_load_fw(bl33);
+
+ get_builtin_firmware_ext(imx93_bl32_bin,
+ bl33, &bl32_image,
+ &bl32_size);
+
+ imx_adjust_optee_memory(&bl32, &bl32_image, &bl32_size);
+
+ memcpy(bl32, bl32_image, bl32_size);
+
+ get_builtin_firmware(imx93_bl31_bin_optee, &tfa, &tfa_size);
+ } else {
+ get_builtin_firmware(imx93_bl31_bin, &tfa, &tfa_size);
+ }
memcpy(bl31, tfa, tfa_size);
diff --git a/arch/arm/mach-imx/ele.c b/arch/arm/mach-imx/ele.c
index 70cfc9ba81..eaae784c94 100644
--- a/arch/arm/mach-imx/ele.c
+++ b/arch/arm/mach-imx/ele.c
@@ -9,6 +9,8 @@
#include <mach/imx/ele.h>
#include <mach/imx/imx9-regs.h>
#include <linux/iopoll.h>
+#include <firmware.h>
+#include <linux/bitfield.h>
#define MU_SR_TE0_MASK BIT(0)
#define MU_SR_RF0_MASK BIT(0)
@@ -142,6 +144,71 @@ int ele_call(struct ele_msg *msg, bool get_response)
return imx9_s3mua_call(msg, get_response);
}
+int ele_get_info(struct ele_get_info_data *info)
+{
+ struct ele_msg msg = {
+ .version = ELE_VERSION,
+ .tag = ELE_CMD_TAG,
+ .size = 4,
+ .command = ELE_GET_INFO_REQ,
+ .data = {
+ upper_32_bits((unsigned long)info),
+ lower_32_bits((unsigned long)info),
+ sizeof(struct ele_get_info_data),
+ },
+ };
+ int ret;
+
+ ret = ele_call(&msg, true);
+ if (ret)
+ pr_err("Could not get ELE info: ret %d, response 0x%x\n",
+ ret, msg.data[0]);
+
+ return ret;
+}
+
+int imx93_ele_load_fw(void *bl33)
+{
+ struct ele_get_info_data info = {};
+ struct ele_msg msg = {
+ .version = ELE_VERSION,
+ .tag = ELE_CMD_TAG,
+ .size = 4,
+ .command = ELE_FW_AUTH_REQ,
+ };
+ void *firmware;
+ int size, ret;
+ int rev = 0;
+
+ ele_get_info(&info);
+
+ rev = FIELD_GET(ELE_INFO_SOC_REV, info.soc);
+
+ switch (rev) {
+ case 0xa0:
+ get_builtin_firmware_ext(mx93a0_ahab_container_img, bl33, &firmware, &size);
+ break;
+ case 0xa1:
+ get_builtin_firmware_ext(mx93a1_ahab_container_img, bl33, &firmware, &size);
+ break;
+ default:
+ pr_err("Unknown unhandled SoC revision %2x\n", rev);
+ return -EINVAL;
+ }
+
+ /* Address of the container header */
+ msg.data[0] = lower_32_bits((unsigned long)firmware);
+ /* Actual address of the container header */
+ msg.data[2] = lower_32_bits((unsigned long)firmware);
+
+ ret = ele_call(&msg, true);
+ if (ret)
+ pr_err("Could not start ELE firmware: ret %d, response 0x%x\n",
+ ret, msg.data[0]);
+
+ return 0;
+}
+
int ele_read_common_fuse(u16 fuse_id, u32 *fuse_word, u32 *response)
{
struct ele_msg msg;
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 0dbf0f7242..19b630c7e8 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -1048,6 +1048,7 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
void __noreturn imx93_barebox_entry(void *boarddata)
{
imx93_init_scratch_space(false);
+ optee_set_membase(imx_scratch_get_optee_hdr());
barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
imx9_ddrc_sdram_size(), boarddata);
diff --git a/arch/arm/mach-imx/imx9.c b/arch/arm/mach-imx/imx9.c
index 0df4824afd..bfc248aadf 100644
--- a/arch/arm/mach-imx/imx9.c
+++ b/arch/arm/mach-imx/imx9.c
@@ -7,6 +7,10 @@
#include <mach/imx/ele.h>
#include <linux/bitfield.h>
#include <mach/imx/imx9-regs.h>
+#include <tee/optee.h>
+#include <asm-generic/memory_layout.h>
+#include <asm/optee.h>
+#include <mach/imx/scratch.h>
#define SPEED_GRADING_MASK GENMASK(11, 6)
#define MARKETING_GRADING_MASK GENMASK(5, 4)
@@ -169,5 +173,16 @@ int imx93_init(void)
imx93_type();
imx93_set_arm_clock();
+ if (IS_ENABLED(CONFIG_PBL_OPTEE)) {
+ static struct of_optee_fixup_data optee_fixup_data = {
+ .shm_size = OPTEE_SHM_SIZE,
+ .method = "smc",
+ };
+
+ optee_set_membase(imx_scratch_get_optee_hdr());
+ of_optee_fixup(of_get_root_node(), &optee_fixup_data);
+ of_register_fixup(of_optee_fixup, &optee_fixup_data);
+ }
+
return 0;
}
diff --git a/firmware/Kconfig b/firmware/Kconfig
index c1731366c6..86a40a9dd1 100644
--- a/firmware/Kconfig
+++ b/firmware/Kconfig
@@ -73,6 +73,18 @@ config FIRMWARE_IMX8MQ_OPTEE
in CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl32.bin. When this option is enabled then
the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx8mq-bl31.bin-optee.
+config FIRMWARE_IMX93_OPTEE
+ bool "install OP-TEE on i.MX93 boards"
+ depends on FIRMWARE_IMX93_ATF && PBL_OPTEE
+ help
+ This enables OP-TEE loading and starting on i.MX8MQ. Place the OP-TEE binary
+ in CONFIG_EXTRA_FIRMWARE_DIR/imx93-bl32.bin. When this option is enabled then
+ the TF-A binary will be used from CONFIG_EXTRA_FIRMWARE_DIR/imx93-bl31.bin-optee.
+ Additionally OP-TEE requires a RAM firmware loaded into the ELE. This is expected
+ in CONFIG_EXTRA_FIRMWARE_DIR/mx93a0-ahab-container.img and
+ CONFIG_EXTRA_FIRMWARE_DIR/mx93a1-ahab-container.img. You can obtain it from
+ https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-ele-imx-0.1.0.bin
+
config FIRMWARE_CCBV2_OPTEE
bool
depends on MACH_WEBASTO_CCBV2 && PBL_OPTEE
diff --git a/firmware/Makefile b/firmware/Makefile
index 51d98d54bf..31dd68664e 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -16,10 +16,13 @@ pbl-firmware-$(CONFIG_FIRMWARE_IMX8MM_ATF) += imx8mm-bl31.bin$(if $(CONFIG_FIRMW
pbl-firmware-$(CONFIG_FIRMWARE_IMX8MN_ATF) += imx8mn-bl31.bin$(if $(CONFIG_FIRMWARE_IMX8MN_OPTEE),-optee,)
pbl-firmware-$(CONFIG_FIRMWARE_IMX8MP_ATF) += imx8mp-bl31.bin$(if $(CONFIG_FIRMWARE_IMX8MP_OPTEE),-optee,)
pbl-firmware-$(CONFIG_FIRMWARE_IMX8MQ_ATF) += imx8mq-bl31.bin
-pbl-firmware-$(CONFIG_FIRMWARE_IMX93_ATF) += imx93-bl31.bin
+pbl-firmware-$(CONFIG_FIRMWARE_IMX93_ATF) += imx93-bl31.bin$(if $(CONFIG_FIRMWARE_IMX93_OPTEE),-optee,)
fw-external-$(CONFIG_FIRMWARE_IMX8MM_OPTEE) += imx8mm-bl32.bin
fw-external-$(CONFIG_FIRMWARE_IMX8MN_OPTEE) += imx8mn-bl32.bin
fw-external-$(CONFIG_FIRMWARE_IMX8MP_OPTEE) += imx8mp-bl32.bin
+fw-external-$(CONFIG_FIRMWARE_IMX93_OPTEE) += imx93-bl32.bin \
+ mx93a0-ahab-container.img \
+ mx93a1-ahab-container.img
pbl-firmware-$(CONFIG_ARCH_RK3568) += rk3568-bl31.bin
pbl-firmware-$(CONFIG_ARCH_RK3568_OPTEE) += rk3568-op-tee.bin
pbl-firmware-$(CONFIG_ARCH_RK3588) += rk3588-bl31.bin
diff --git a/include/mach/imx/ele.h b/include/mach/imx/ele.h
index 5770878d7d..7e6896be3c 100644
--- a/include/mach/imx/ele.h
+++ b/include/mach/imx/ele.h
@@ -132,10 +132,15 @@ struct ele_get_info_data {
u32 state;
};
+#define ELE_INFO_SOC_REV GENMASK(31, 24)
+
int ele_call(struct ele_msg *msg, bool get_response);
int ele_read_common_fuse(u16 fuse_id, u32 *fuse_word, u32 *response);
int ele_release_rdc(u8 core_id, u8 xrdc, u32 *response);
int ele_read_shadow_fuse(u16 fuse_id, u32 *fuse_word, u32 *response);
+int ele_get_info(struct ele_get_info_data *info);
+
+int imx93_ele_load_fw(void *bl33);
#endif
--
2.39.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/7] ARM: Add i.MX93 OP-TEE support
2024-01-19 14:24 [PATCH 0/7] ARM: Add i.MX93 OP-TEE support Sascha Hauer
` (6 preceding siblings ...)
2024-01-19 14:24 ` [PATCH 7/7] ARM: i.MX93: Add OP-TEE support Sascha Hauer
@ 2024-01-22 10:15 ` Sascha Hauer
7 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2024-01-22 10:15 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Fri, 19 Jan 2024 15:24:06 +0100, Sascha Hauer wrote:
> This enables OP-TEE support for i.MX93. This is done in a way very
> similar to how it's done on i.MX8M.
> One major difference is that the i.MX93 needs a RAM firmware for the
> EdgeLock secure enclave. Without it OP-TEE doesn't work properly.
> The firmware can be integrated into the i.MX93 image where the ROM
> picks it up automatically. The firmware image is SoC revision specific
> though, so we load the firmware during runtime to avoid having to
> create a barebox image for each SoC revision.
>
> [...]
Applied, thanks!
[1/7] firmware: add missing FIRMWARE_IMX8MQ_OPTEE symbol
https://git.pengutronix.de/cgit/barebox/commit/?id=d52fd9bf6688 (link may not be stable)
[2/7] firmware: add missing include
https://git.pengutronix.de/cgit/barebox/commit/?id=e3e2b837d11c (link may not be stable)
[3/7] firmware: i.MX OP-TEE: Add some Kconfig help
https://git.pengutronix.de/cgit/barebox/commit/?id=75ad426aa1e8 (link may not be stable)
[4/7] ARM: i.MX93: add imx93_barebox_entry()
https://git.pengutronix.de/cgit/barebox/commit/?id=250e4d9efd85 (link may not be stable)
[5/7] ARM: i.MX: export imx9_ddrc_sdram_size()
https://git.pengutronix.de/cgit/barebox/commit/?id=79069811cd59 (link may not be stable)
[6/7] ARM: i.MX93: add scratch space support
https://git.pengutronix.de/cgit/barebox/commit/?id=585c8dc5df4d (link may not be stable)
[7/7] ARM: i.MX93: Add OP-TEE support
https://git.pengutronix.de/cgit/barebox/commit/?id=c678c3ff052c (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 16+ messages in thread