mediatek: mt8183: pass platform parameters
authorkenny liang <kenny.liang@mediatek.com>
Fri, 3 May 2019 08:59:07 +0000 (16:59 +0800)
committerkenny liang <kenny.liang@mediatek.com>
Tue, 10 Sep 2019 03:25:29 +0000 (11:25 +0800)
Add plat parameter structs to support BL2 to pass
variable-length, variable-type parameters to BL31.
The parameters are structured as a link list.
During BL31 setup time, we traverse the list to process
each parameter.

Signed-off-by: kenny liang <kenny.liang@mediatek.com>
Change-Id: Ie84cfc9606656fb1d2780a68cadf27e09afa6628

include/export/plat/mediatek/common/plat_params_exp.h [new file with mode: 0644]
plat/mediatek/common/params_setup.c [new file with mode: 0644]
plat/mediatek/common/plat_params.h [new file with mode: 0644]
plat/mediatek/mt8183/bl31_plat_setup.c
plat/mediatek/mt8183/platform.mk

diff --git a/include/export/plat/mediatek/common/plat_params_exp.h b/include/export/plat/mediatek/common/plat_params_exp.h
new file mode 100644 (file)
index 0000000..d650030
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ARM_TRUSTED_FIRMWARE_EXPORT_PLAT_MEDIATEK_COMMON_PLAT_PARAMS_EXP_H
+#define ARM_TRUSTED_FIRMWARE_EXPORT_PLAT_MEDIATEK_COMMON_PLAT_PARAMS_EXP_H
+
+/* EXPORT HEADER -- See include/export/README for details! -- EXPORT HEADER */
+
+#include "../../../lib/bl_aux_params/bl_aux_params_exp.h"
+
+/* param type */
+enum bl_aux_mtk_param_type {
+       BL_AUX_PARAM_MTK_RESET_GPIO = BL_AUX_PARAM_VENDOR_SPECIFIC_FIRST,
+};
+
+#endif /* ARM_TRUSTED_FIRMWARE_EXPORT_PLAT_MEDIATEK_COMMON_PLAT_PARAMS_EXP_H */
diff --git a/plat/mediatek/common/params_setup.c b/plat/mediatek/common/params_setup.c
new file mode 100644 (file)
index 0000000..a9df13e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <lib/bl_aux_params/bl_aux_params.h>
+#include <common/debug.h>
+#include <plat_params.h>
+#include <string.h>
+
+static struct bl_aux_gpio_info rst_gpio;
+
+struct bl_aux_gpio_info *plat_get_mtk_gpio_reset(void)
+{
+       return &rst_gpio;
+}
+
+static bool mtk_aux_param_handler(struct bl_aux_param_header *param)
+{
+       /* Store platform parameters for later processing if needed. */
+       switch (param->type) {
+       case BL_AUX_PARAM_MTK_RESET_GPIO:
+               rst_gpio = ((struct bl_aux_param_gpio *)param)->gpio;
+               return true;
+       }
+
+       return false;
+}
+
+void params_early_setup(u_register_t plat_param_from_bl2)
+{
+       bl_aux_params_parse(plat_param_from_bl2, mtk_aux_param_handler);
+}
+
diff --git a/plat/mediatek/common/plat_params.h b/plat/mediatek/common/plat_params.h
new file mode 100644 (file)
index 0000000..828c3dc
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef PLAT_PARAMS_H
+#define PLAT_PARAMS_H
+
+#include <stdint.h>
+
+#include <export/plat/mediatek/common/plat_params_exp.h>
+
+struct bl_aux_gpio_info *plat_get_mtk_gpio_reset(void);
+void params_early_setup(u_register_t plat_param_from_bl2);
+
+#endif
index f20e8acdd3e4cbedeb21a3e01a459bd8f189dcc4..ea39ff6f63a8228ee36921487787a4d42c017e45 100644 (file)
@@ -18,6 +18,7 @@
 #include <mtk_plat_common.h>
 #include <mtspmc.h>
 #include <plat_debug.h>
+#include <plat_params.h>
 #include <plat_private.h>
 #include <platform_def.h>
 #include <scu.h>
@@ -74,6 +75,8 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
 {
        static console_16550_t console;
 
+       params_early_setup(arg1);
+
        console_16550_register(UART0_BASE, UART_CLOCK, UART_BAUDRATE, &console);
 
        NOTICE("MT8183 bl31_setup\n");
index 9c2b9645cc7f7803035bb00b85e982dda9f9e2c2..8fb015105163565a94aa55f148c30983c44c71e3 100644 (file)
@@ -31,6 +31,7 @@ BL31_SOURCES    += common/desc_image_load.c                              \
                    drivers/delay_timer/generic_delay_timer.c             \
                    drivers/gpio/gpio.c                                   \
                    drivers/ti/uart/aarch64/16550_console.S               \
+                   lib/bl_aux_params/bl_aux_params.c                     \
                    lib/cpus/aarch64/aem_generic.S                        \
                    lib/cpus/aarch64/cortex_a53.S                         \
                    lib/cpus/aarch64/cortex_a73.S                         \
@@ -38,6 +39,7 @@ BL31_SOURCES    += common/desc_image_load.c                              \
                    ${MTK_PLAT}/common/mtk_plat_common.c                  \
                    ${MTK_PLAT}/common/drivers/pmic_wrap/pmic_wrap_init.c \
                    ${MTK_PLAT}/common/drivers/rtc/rtc_common.c           \
+                   ${MTK_PLAT}/common/params_setup.c                     \
                    ${MTK_PLAT_SOC}/aarch64/plat_helpers.S                \
                    ${MTK_PLAT_SOC}/aarch64/platform_common.c             \
                    ${MTK_PLAT_SOC}/drivers/mcsi/mcsi.c                   \