mach-snapdragon: Enable OP-TEE support
Subsystems (4)
Sumit Garg
reviewerv3 cover mach-snapdragon: Enable OP-TEE support
From: Sumit Garg <[email protected]>
Introduce TF-A and OP-TEE config fragment
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
$ ./scripts/kconfig/merge_config.sh \
configs/qcom_defconfig \
board/qualcomm/tfa-optee.config
$ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2---
Changes in v3:
- Incorporated misc. comments on patch #2.
Changes in v2:
- Add new patch #1 to export OP-TEE message UID check API
- Use OP-TEE message UID check API in order to perform the DT fixup for OP-TEE.
- Switch from new defconfig to a config fragment instead.
Sumit Garg (3):
tee: optee: Export OP-TEE message UID check API
mach-snapdragon: of_fixup: Add OP-TEE DT fixup support board/qualcomm: Introduce TF-A and OP-TEE config fragment
arch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ board/qualcomm/tfa-optee.config | 4 ++++ drivers/tee/optee/core.c | 5 +++++ include/tee/optee.h | 9 ++++++++ 4 files changed, 53 insertions(+) create mode 100644 board/qualcomm/tfa-optee.config
Signature · 1 line
2.51.0
Sumit Garg
reviewerPATCH v3 1/3 tee: optee: Export OP-TEE message UID check API
From: Sumit Garg <[email protected]>
OP-TEE message UID check API can be useful to know whether OP-TEE is enabled on not assuming the corresponding SMC call is properly handled if OP-TEE is not supported.
This API can be used by platform code to know OP-TEE presence and on that basis OP-TEE DT node can be added as part of DT fixups for the OP-TEE driver probe to happen for both U-Boot and Linux.
--- drivers/tee/optee/core.c | 5 +++++ include/tee/optee.h | 9 +++++++++ 2 files changed, 14 insertions(+)
drivers/tee/optee/core.c +5 -0
@@ -795,6 +795,11 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)return ERR_PTR (-EINVAL ); } +bool is_optee_smc_api (void ) +{ +return is_optee_api (optee_smccc_smc); +} +static int optee_of_to_plat (struct udevice *dev) {struct optee_pdata *pdata =dev_get_plat (dev);
include/tee/optee.h +9 -0
@@ -65,4 +65,13 @@ static inline int optee_copy_fdt_nodes(void *new_blob) }#endif +#if defined(CONFIG_OPTEE ) +bool is_optee_smc_api (void ); +#else +static inline bool is_optee_smc_api (void ) +{ +return false; +} +#endif +#endif /* _OPTEE_H */
Signature · 1 line
2.51.0
Sumit Garg
reviewerPATCH v3 2/3 mach-snapdragon: of_fixup: Add OP-TEE DT fixup support
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Add support for OP-TEE live tree DT fixup support which enables U-Boot OP-TEE driver to be probed. As well as the EFI DT fixup protocol allows the live tree fixup to be carried over to the OS for the OP-TEE driver in the OS to probe as well.
Note that this fixup only gets applied if OP-TEE support is detected via checking for OP-TEE message UID.
--- arch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/arm/mach-snapdragon/of_fixup.c +35 -0
@@ -25,6 +25,7 @@#include <fdt_support.h> #include <linux/errno.h> #include <stdlib.h> +#include <tee/optee.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3
@@ -164,6 +165,37 @@ static void fixup_power_domains(struct device_node *root) } } +static void add_optee_node (struct device_node *root) +{ +struct device_node *fw =NULL , *optee =NULL ; +int ret; + + fw =of_find_node_by_path ("/firmware" ); +if (!fw) { +log_err ("Failed to find /firmware node\n" ); +return ; + } + + ret =of_add_subnode (fw,"optee" ,strlen ("optee" ) +1 , &optee); +if (ret) { +log_err ("Failed to add 'optee' subnode: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"compatible" ,strlen ("linaro,optee-tz" ) +1 , +"linaro,optee-tz" ); +if (ret) { +log_err ("Failed to add optee 'compatible' property: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"method" ,strlen ("smc" ) +1 ,"smc" ); +if (ret) { +log_err ("Failed to add optee 'method' property: %d\n" , ret); +return ; + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \
@@ -178,6 +210,9 @@ static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)time_call (fixup_usb_nodes, root);time_call (fixup_power_domains, root); +if (IS_ENABLED (CONFIG_OPTEE ) &&is_optee_smc_api ()) +time_call (add_optee_node, root); +return 0 ; }
Signature · 1 line
2.51.0
Sumit Garg
reviewerPATCH v3 3/3 board/qualcomm: Introduce TF-A and OP-TEE config fragment
In reply to Sumit GargFrom: Sumit Garg <[email protected]>
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
$ ./scripts/kconfig/merge_config.sh \
configs/qcom_defconfig \
board/qualcomm/tfa-optee.config
$ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2For more information refer here:
https://trustedfirmware-a.readthedocs.io/en/latest/plat/qti/rb3gen2.html
--- board/qualcomm/tfa-optee.config | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 board/qualcomm/tfa-optee.config
board/qualcomm/tfa-optee.config new file +4 -0
@@ -0,0 +1,4 @@ +# Enables support for TF-A based OP-TEE as the open +# source TrustZone stack on Qcom platforms +CONFIG_TEE=y +CONFIG_OPTEE=y
Signature · 1 line
2.51.0
Re: [PATCH v3 2/3] mach-snapdragon: of_fixup: Add OP-TEE DT fixup support
In reply to Sumit GargHi Sumit,
Thanks for respinning this.
Quoted 6 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Add support for OP-TEE live tree DT fixup support which enables U-Boot OP-TEE driver to be probed. As well as the EFI DT fixup protocol allows the live tree fixup to be carried over to the OS for the OP-TEE driver in the OS to probe as well.
The EFI DT fixup protocol hook seems to be missing here?
Quoted 69 lines
Note that this fixup only gets applied if OP-TEE support is detected via checking for OP-TEE message UID.
Signed-off-by Sumit Garg <[email protected]>--- arch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)arch/arm/mach-snapdragon/of_fixup.c +35
-0@@ -25,6 +25,7 @@#include <fdt_support.h> #include <linux/errno.h> #include <stdlib.h> +#include <tee/optee.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 @@ -164,6 +165,37 @@ static void fixup_power_domains(struct device_node *root) } } +static void add_optee_node (struct device_node *root) +{ +struct device_node *fw =NULL , *optee =NULL ; +int ret; + + fw =of_find_node_by_path ("/firmware" ); +if (!fw) { +log_err ("Failed to find /firmware node\n" ); +return ; + } + + ret =of_add_subnode (fw,"optee" ,strlen ("optee" ) +1 , &optee); +if (ret) { +log_err ("Failed to add 'optee' subnode: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"compatible" ,strlen ("linaro,optee-tz" ) +1 , +"linaro,optee-tz" ); +if (ret) { +log_err ("Failed to add optee 'compatible' property: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"method" ,strlen ("smc" ) +1 ,"smc" ); +if (ret) { +log_err ("Failed to add optee 'method' property: %d\n" , ret); +return ; + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \@@ -178,6 +210,9 @@ static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)time_call (fixup_usb_nodes, root);time_call (fixup_power_domains, root); +if (IS_ENABLED (CONFIG_OPTEE ) &&is_optee_smc_api ()) +time_call (add_optee_node, root); +return 0 ; }
Signature · 1 line
// Casey (she/her)
Re: [PATCH v3 1/3] tee: optee: Export OP-TEE message UID check API
In reply to Sumit GargQuoted 11 lines · Sumit Garg
From: Sumit Garg <[email protected]>
OP-TEE message UID check API can be useful to know whether OP-TEE is enabled on not assuming the corresponding SMC call is properly handled if OP-TEE is not supported.
This API can be used by platform code to know OP-TEE presence and on that basis OP-TEE DT node can be added as part of DT fixups for the OP-TEE driver probe to happen for both U-Boot and Linux.
Signed-off-by Sumit Garg <[email protected]>
Quoted 39 lines
--- drivers/tee/optee/core.c | 5 +++++ include/tee/optee.h | 9 +++++++++ 2 files changed, 14 insertions(+)drivers/tee/optee/core.c +5
-0@@ -795,6 +795,11 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev)return ERR_PTR (-EINVAL ); } +bool is_optee_smc_api (void ) +{ +return is_optee_api (optee_smccc_smc); +} +static int optee_of_to_plat (struct udevice *dev) {struct optee_pdata *pdata =dev_get_plat (dev);include/tee/optee.h +9
-0@@ -65,4 +65,13 @@ static inline int optee_copy_fdt_nodes(void *new_blob) }#endif +#if defined(CONFIG_OPTEE ) +bool is_optee_smc_api (void ); +#else +static inline bool is_optee_smc_api (void ) +{ +return false; +} +#endif +#endif /* _OPTEE_H */
Signature · 1 line
// Casey (she/her)
Re: [PATCH v3 3/3] board/qualcomm: Introduce TF-A and OP-TEE config fragment
In reply to Sumit GargQuoted 14 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
$ ./scripts/kconfig/merge_config.sh \ configs/qcom_defconfig \ board/qualcomm/tfa-optee.config $ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2
Quoted 4 lines
For more information refer here:
https://trustedfirmware-a.readthedocs.io/en/latest/plat/qti/rb3gen2.htmlSigned-off-by Sumit Garg <[email protected]>
Quoted 15 lines
--- board/qualcomm/tfa-optee.config | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 board/qualcomm/tfa-optee.configboard/qualcomm/tfa-optee.config new file +4
-0@@ -0,0 +1,4 @@ +# Enables support for TF-A based OP-TEE as the open +# source TrustZone stack on Qcom platforms +CONFIG_TEE=y +CONFIG_OPTEE=y
Signature · 1 line
// Casey (she/her)
Sumit Garg
reviewerRe: [PATCH v3 2/3] mach-snapdragon: of_fixup: Add OP-TEE DT fixup support
In reply to Casey ConnollyHi Casey,
Quoted 5 lines · Casey Connolly
Hi Sumit,
Thanks for respinning this.
On 27/01/2026 07:23, Sumit Garg wrote:
Quoted 8 lines
Quoted 6 lines
From: Sumit Garg <[email protected]>
Add support for OP-TEE live tree DT fixup support which enables U-Boot OP-TEE driver to be probed. As well as the EFI DT fixup protocol allows the live tree fixup to be carried over to the OS for the OP-TEE driver in the OS to probe as well.
The EFI DT fixup protocol hook seems to be missing here?
The EFI DT fixup for OP-TEE node is already taken care of by the common OP-TEE library as part of this code path:
efi_dt_fixup() ->
image_setup_libfdt() ->
optee_copy_fdt_nodes()
-Sumit
Quoted 73 lines
Quoted 69 lines
Note that this fixup only gets applied if OP-TEE support is detected via checking for OP-TEE message UID.
Signed-off-by Sumit Garg <[email protected]>--- arch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)arch/arm/mach-snapdragon/of_fixup.c +35
-0@@ -25,6 +25,7 @@#include <fdt_support.h> #include <linux/errno.h> #include <stdlib.h> +#include <tee/optee.h> #include <time.h> /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3 @@ -164,6 +165,37 @@ static void fixup_power_domains(struct device_node *root) } } +static void add_optee_node (struct device_node *root) +{ +struct device_node *fw =NULL , *optee =NULL ; +int ret; + + fw =of_find_node_by_path ("/firmware" ); +if (!fw) { +log_err ("Failed to find /firmware node\n" ); +return ; + } + + ret =of_add_subnode (fw,"optee" ,strlen ("optee" ) +1 , &optee); +if (ret) { +log_err ("Failed to add 'optee' subnode: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"compatible" ,strlen ("linaro,optee-tz" ) +1 , +"linaro,optee-tz" ); +if (ret) { +log_err ("Failed to add optee 'compatible' property: %d\n" , ret); +return ; + } + + ret =of_write_prop (optee,"method" ,strlen ("smc" ) +1 ,"smc" ); +if (ret) { +log_err ("Failed to add optee 'method' property: %d\n" , ret); +return ; + } +} +#define time_call (func, ...) \ do { \ u64 start = timer_get_us(); \@@ -178,6 +210,9 @@ static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)time_call (fixup_usb_nodes, root);time_call (fixup_power_domains, root); +if (IS_ENABLED (CONFIG_OPTEE ) &&is_optee_smc_api ()) +time_call (add_optee_node, root); +return 0 ; }Signature · 1 line
// Casey (she/her)
Sumit Garg
reviewerHey Casey,
Quoted 11 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Introduce TF-A and OP-TEE config fragment
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
Quoted 9 lines
$ ./scripts/kconfig/merge_config.sh \ configs/qcom_defconfig \ board/qualcomm/tfa-optee.config $ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2---
Changes in v3:
- Incorporated misc. comments on patch #2.
Can we get this patch-set applied as well? Have been waiting on the list for approx. 2 months.
-Sumit
Quoted 21 lines
Changes in v2:
- Add new patch #1 to export OP-TEE message UID check API
- Use OP-TEE message UID check API in order to perform the DT fixup for OP-TEE.
- Switch from new defconfig to a config fragment instead.Sumit Garg (3):
tee: optee: Export OP-TEE message UID check API
mach-snapdragon:of_fixup: Add OP-TEE DT fixup support board/qualcomm: Introduce TF-A and OP-TEE config fragmentarch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ board/qualcomm/tfa-optee.config | 4 ++++ drivers/tee/optee/core.c | 5 +++++ include/tee/optee.h | 9 ++++++++ 4 files changed, 53 insertions(+) create mode 100644 board/qualcomm/tfa-optee.configSignature · 1 line
2.51.0
Hi Sumit,
Quoted 19 lines · Sumit Garg
Hey Casey,
Quoted 16 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Introduce TF-A and OP-TEE config fragment
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
$ ./scripts/kconfig/merge_config.sh \ configs/qcom_defconfig \ board/qualcomm/tfa-optee.config $ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2
Quoted 7 lines
Quoted 4 lines
---
Changes in v3:
- Incorporated misc. comments on patch #2.Can we get this patch-set applied as well? Have been waiting on the list for approx. 2 months.
Yeah, I'll get this into -next soon, apologies for the wait.
Kind regards,
Quoted 24 lines
-Sumit
Quoted 21 lines
Changes in v2:
- Add new patch #1 to export OP-TEE message UID check API
- Use OP-TEE message UID check API in order to perform the DT fixup for OP-TEE.
- Switch from new defconfig to a config fragment instead.Sumit Garg (3):
tee: optee: Export OP-TEE message UID check API
mach-snapdragon:of_fixup: Add OP-TEE DT fixup support board/qualcomm: Introduce TF-A and OP-TEE config fragmentarch/arm/mach-snapdragon/of_fixup.c | 35 +++++++++++++++++++++++++++++ board/qualcomm/tfa-optee.config | 4 ++++ drivers/tee/optee/core.c | 5 +++++ include/tee/optee.h | 9 ++++++++ 4 files changed, 53 insertions(+) create mode 100644 board/qualcomm/tfa-optee.configSignature · 1 line
2.51.0
Signature · 1 line
// Casey (she/her)
Sumit Garg
reviewerQuoted 27 lines · Casey Connolly
Hi Sumit,
Quoted 24 lines · Sumit Garg
Hey Casey,
Quoted 20 lines · Sumit Garg
From: Sumit Garg <[email protected]>
Introduce TF-A and OP-TEE config fragment
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
So, lets add a generic U-Boot config fragment for Qcom platforms to support TF-A/OP-TEE based TrustZone stack. Build command:
$ ./scripts/kconfig/merge_config.sh \ configs/qcom_defconfig \ board/qualcomm/tfa-optee.config $ make -j`nproc` DEVICE_TREE=qcom/qcs6490-rb3gen2---
Changes in v3:
- Incorporated misc. comments on patch #2.
Quoted 5 lines
Quoted 2 lines
Can we get this patch-set applied as well? Have been waiting on the list for approx. 2 months.
Yeah, I'll get this into -next soon, apologies for the wait.
Still haven't seen any of your PR for this cycle. I see a lot of patches reviewed but not applied on patchworks here [1].
-Sumit
Casey Connolly
AppliedQuoted 11 lines · Sumit Garg
mach-snapdragon: Enable OP-TEE support
From: Sumit Garg <[email protected]>
Introduce TF-A and OP-TEE config fragment
Recently upstream TF-A/OP-TEE has started gaining support for Qcom platforms. RB3Gen2 being the first one and more to come. U-Boot in corresponding boot flow is packaged as a position independent executable.
[...]
Applied, thanks!
First and last time I use b4 review, the commit shas are wrong but you can find the patches in https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commits/casey/qcom-main-13Apr2026?ref_type=heads
Apologies
[1/3] tee: optee: Export OP-TEE message UID check API
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/145a2bcea9c8 [2/3] mach-snapdragon: of_fixup: Add OP-TEE DT fixup support https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/43ade570091d [3/3] board/qualcomm: Introduce TF-A and OP-TEE config fragment https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/845a1750c973
Best regards,
Signature · 1 line
// Casey (she/they)