lib: optee: remove the duplicate CONFIG_OPTEE
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Thu, 2 Sep 2021 09:56:16 +0000 (11:56 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 5 Oct 2021 12:44:48 +0000 (08:44 -0400)
The configuration CONFIG_OPTEE is defined 2 times:
1- in lib/optee/Kconfig for support of OPTEE images loaded by bootm command
2- in drivers/tee/optee/Kconfig for support of OP-TEE driver.

It is abnormal to have the same CONFIG define for 2 purpose;
and it is difficult to managed correctly their dependencies.

Moreover CONFIG_SPL_OPTEE is defined in common/spl/Kconfig
to manage OPTEE image load in SPL.

This definition causes an issue with the macro CONFIG_IS_ENABLED(OPTEE)
to test the availability of the OP-TEE driver.

This patch cleans the configuration dependency with:
- CONFIG_OPTEE_IMAGE (renamed) => support of OP-TEE image in U-Boot
- CONFIG_SPL_OPTEE_IMAGE (renamed) => support of OP-TEE image in SPL
- CONFIG_OPTEE (same) => support of OP-TEE driver in U-Boot
- CONFIG_OPTEE_LIB (new) => support of OP-TEE library

After this patch, the macro have the correct behavior:
- CONFIG_IS_ENABLED(OPTEE_IMAGE) => Load of OP-TEE image is supported
- CONFIG_IS_ENABLED(OPTEE) => OP-TEE driver is supported

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
12 files changed:
arch/arm/mach-rockchip/sdram.c
common/spl/Kconfig
common/spl/Makefile
common/spl/spl.c
configs/evb-rk3229_defconfig
configs/evb-rk3288_defconfig
configs/odroid-go2_defconfig
include/tee/optee.h
lib/Makefile
lib/optee/Kconfig
lib/optee/Makefile
lib/optee/optee.c

index 28c379e..705ec7b 100644 (file)
@@ -45,7 +45,7 @@ int dram_init_banksize(void)
        gd->bd->bi_dram[0].start = 0x200000;
        gd->bd->bi_dram[0].size = top - gd->bd->bi_dram[0].start;
 #else
-#ifdef CONFIG_SPL_OPTEE
+#ifdef CONFIG_SPL_OPTEE_IMAGE
        struct tos_parameter_t *tos_parameter;
 
        tos_parameter = (struct tos_parameter_t *)(CONFIG_SYS_SDRAM_BASE +
index 34f6fc2..8a8a971 100644 (file)
@@ -1263,11 +1263,11 @@ config SPL_AM33XX_ENABLE_RTC32K_OSC
          Enable access to the AM33xx RTC and select the external 32kHz clock
          source.
 
-config SPL_OPTEE
-       bool "Support OP-TEE Trusted OS"
+config SPL_OPTEE_IMAGE
+       bool "Support OP-TEE Trusted OS image in SPL"
        depends on ARM
        help
-         OP-TEE is an open source Trusted OS  which is loaded by SPL.
+         OP-TEE is an open source Trusted OS which is loaded by SPL.
          More detail at: https://github.com/OP-TEE/optee_os
 
 config SPL_OPENSBI
index cb15c8e..db8fd36 100644 (file)
@@ -22,7 +22,7 @@ obj-$(CONFIG_$(SPL_TPL_)UBI) += spl_ubi.o
 obj-$(CONFIG_$(SPL_TPL_)NET) += spl_net.o
 obj-$(CONFIG_$(SPL_TPL_)MMC) += spl_mmc.o
 obj-$(CONFIG_$(SPL_TPL_)ATF) += spl_atf.o
-obj-$(CONFIG_$(SPL_TPL_)OPTEE) += spl_optee.o
+obj-$(CONFIG_$(SPL_TPL_)OPTEE_IMAGE) += spl_optee.o
 obj-$(CONFIG_$(SPL_TPL_)OPENSBI) += spl_opensbi.o
 obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o
 obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o
index ed94d51..a9304d4 100644 (file)
@@ -776,7 +776,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                spl_invoke_atf(&spl_image);
                break;
 #endif
-#if CONFIG_IS_ENABLED(OPTEE)
+#if CONFIG_IS_ENABLED(OPTEE_IMAGE)
        case IH_OS_TEE:
                debug("Jumping to U-Boot via OP-TEE\n");
                spl_board_prepare_for_optee(spl_image.fdt_addr);
index 0bf91d6..a8b1c42 100644 (file)
@@ -28,7 +28,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_SPL_OPTEE=y
+CONFIG_SPL_OPTEE_IMAGE=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB_MASS_STORAGE=y
index efb2a3e..eca9f5c 100644 (file)
@@ -25,7 +25,7 @@ CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
-CONFIG_SPL_OPTEE=y
+CONFIG_SPL_OPTEE_IMAGE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
index c744c3a..df64307 100644 (file)
@@ -98,7 +98,7 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_SOUND=y
 CONFIG_SYSRESET=y
-CONFIG_OPTEE=y
+CONFIG_OPTEE_LIB=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
index ebdfe5e..2928597 100644 (file)
@@ -43,7 +43,7 @@ optee_image_get_load_addr(const struct image_header *hdr)
        return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
 }
 
-#if defined(CONFIG_OPTEE)
+#if defined(CONFIG_OPTEE_IMAGE)
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
                       unsigned long tzdram_len, unsigned long image_len);
 #else
@@ -57,7 +57,7 @@ static inline int optee_verify_image(struct optee_header *hdr,
 
 #endif
 
-#if defined(CONFIG_OPTEE)
+#if defined(CONFIG_OPTEE_IMAGE)
 int optee_verify_bootm_image(unsigned long image_addr,
                             unsigned long image_load_addr,
                             unsigned long image_len);
@@ -70,7 +70,7 @@ static inline int optee_verify_bootm_image(unsigned long image_addr,
 }
 #endif
 
-#if defined(CONFIG_OPTEE) && defined(CONFIG_OF_LIBFDT)
+#if defined(CONFIG_OPTEE_LIB) && defined(CONFIG_OF_LIBFDT)
 int optee_copy_fdt_nodes(void *new_blob);
 #else
 static inline int optee_copy_fdt_nodes(void *new_blob)
index 09e380e..962470f 100644 (file)
@@ -16,7 +16,7 @@ obj-$(CONFIG_FIT) += libfdt/
 obj-$(CONFIG_OF_LIVE) += of_live.o
 obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
-obj-$(CONFIG_OPTEE) += optee/
+obj-$(CONFIG_OPTEE_LIB) += optee/
 obj-$(CONFIG_ASN1_DECODER) += asn1_decoder.o
 obj-y += crypto/
 
index 3290b66..3072c28 100644 (file)
@@ -1,23 +1,27 @@
-config OPTEE
+config OPTEE_LIB
+       bool "Support OPTEE library"
+       default y if OPTEE || OPTEE_IMAGE
+       help
+         Selecting this option will enable the shared OPTEE library code.
+
+config OPTEE_IMAGE
        bool "Support OPTEE images"
        help
-         U-Boot can be configured to boot OPTEE images.
-         Selecting this option will enable shared OPTEE library code and
-          enable an OPTEE specific bootm command that will perform additional
-          OPTEE specific checks before booting an OPTEE image created with
-          mkimage.
+         Selecting this option to boot OPTEE images.
+         This option enable the OPTEE specific checks done before booting
+         an OPTEE image created with mkimage
 
 config OPTEE_LOAD_ADDR
        hex "OPTEE load address"
        default 0x00000000
-       depends on OPTEE
+       depends on OPTEE_LIB
        help
          The load address of the bootable OPTEE binary.
 
 config OPTEE_TZDRAM_SIZE
        hex "Amount of Trust-Zone RAM for the OPTEE image"
        default 0x0000000
-       depends on OPTEE
+       depends on OPTEE_LIB
        help
          The size of pre-allocated Trust Zone DRAM to allocate for the OPTEE
          runtime.
@@ -25,7 +29,7 @@ config OPTEE_TZDRAM_SIZE
 config OPTEE_TZDRAM_BASE
        hex "Base address of Trust-Zone RAM for the OPTEE image"
        default 0x00000000
-       depends on OPTEE
+       depends on OPTEE_LIB
        help
          The base address of pre-allocated Trust Zone DRAM for
          the OPTEE runtime.
@@ -33,7 +37,7 @@ config OPTEE_TZDRAM_BASE
 config BOOTM_OPTEE
        bool "Support OPTEE bootm command"
        select BOOTM_LINUX
-       depends on OPTEE
+       select OPTEE_IMAGE
        help
          Select this command to enable chain-loading of a Linux kernel
          via an OPTEE firmware.
index b692311..9befe60 100644 (file)
@@ -2,4 +2,4 @@
 #
 # (C) Copyright 2017 Linaro
 
-obj-$(CONFIG_OPTEE) += optee.o
+obj-y += optee.o
index 672690d..5676785 100644 (file)
@@ -20,6 +20,7 @@
        "\n\theader lo=0x%08x hi=0x%08x size=0x%08lx arch=0x%08x" \
        "\n\tuimage params 0x%08lx-0x%08lx\n"
 
+#if defined(CONFIG_OPTEE_IMAGE)
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
                       unsigned long tzdram_len, unsigned long image_len)
 {
@@ -70,6 +71,7 @@ error:
 
        return ret;
 }
+#endif
 
 #if defined(CONFIG_OF_LIBFDT)
 static int optee_copy_firmware_node(ofnode node, void *fdt_blob)