Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/67359 )
Change subject: soc/mediatek: a common implementation to register BL31 reset ......................................................................
soc/mediatek: a common implementation to register BL31 reset
WIP - we should provide a weak/stub if ATF config is not selected.
BUG=None TEST=None
Change-Id: I297ea2e18a6d7e92236cf415844b166523616bdf Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/cherry/mainboard.c A src/soc/mediatek/common/bl31.c A src/soc/mediatek/common/include/soc/bl31.h M src/soc/mediatek/mt8183/Makefile.inc M src/soc/mediatek/mt8186/Makefile.inc M src/soc/mediatek/mt8188/Makefile.inc M src/soc/mediatek/mt8192/Makefile.inc M src/soc/mediatek/mt8195/Makefile.inc 8 files changed, 62 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/59/67359/1
diff --git a/src/mainboard/google/cherry/mainboard.c b/src/mainboard/google/cherry/mainboard.c index b69403e..a4f76bb 100644 --- a/src/mainboard/google/cherry/mainboard.c +++ b/src/mainboard/google/cherry/mainboard.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#include <bl31.h> #include <boardid.h> #include <bootmode.h> #include <console/console.h> @@ -10,6 +9,7 @@ #include <edid.h> #include <framebuffer_info.h> #include <gpio.h> +#include <soc/bl31.h> #include <soc/ddp.h> #include <soc/dpm.h> #include <soc/dptx.h> @@ -23,8 +23,6 @@
#include "gpio.h"
-#include <arm-trusted-firmware/include/export/plat/mediatek/common/plat_params_exp.h> - /* GPIO to schematics names */ #define GPIO_AP_EDP_BKLTEN GPIO(DGI_D5) #define GPIO_BL_PWM_1V8 GPIO(DISP_PWM0) @@ -57,17 +55,6 @@ } }
-static void register_reset_to_bl31(void) -{ - static struct bl_aux_param_gpio param_reset = { - .h = { .type = BL_AUX_PARAM_MTK_RESET_GPIO }, - .gpio = { .polarity = ARM_TF_GPIO_LEVEL_HIGH }, - }; - - param_reset.gpio.index = GPIO_RESET.id; - register_bl31_aux_param(¶m_reset.h); -} - /* Set up backlight control pins as output pin and power-off by default */ static void configure_panel_backlight(void) { @@ -160,7 +147,8 @@ if (spm_init()) printk(BIOS_ERR, "spm init failed, system suspend may not work\n");
- register_reset_to_bl31(); + if (CONFIG(ARM64_USE_ARM_TRUSTED_FIRMWARE)) + register_reset_to_bl31(GPIO_RESET.id, ACTIVE_HIGH); }
static void mainboard_enable(struct device *dev) diff --git a/src/soc/mediatek/common/bl31.c b/src/soc/mediatek/common/bl31.c new file mode 100644 index 0000000..d89ce1a --- /dev/null +++ b/src/soc/mediatek/common/bl31.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <assert.h> + +#include <bl31.h> +#include <soc/bl31.h> +#include <boot/coreboot_tables.h> +#include <gpio.h> +#include <arm-trusted-firmware/include/export/plat/mediatek/common/plat_params_exp.h> + +void register_reset_to_bl31(int gpio_index, int gpio_polarity) +{ + static struct bl_aux_param_gpio param_reset = { + .h = { .type = BL_AUX_PARAM_MTK_RESET_GPIO }, + }; + + switch (gpio_polarity) { + case ACTIVE_HIGH: + param_reset.gpio.polarity = ARM_TF_GPIO_LEVEL_HIGH; + break; + + case ACTIVE_LOW: + param_reset.gpio.polarity = ARM_TF_GPIO_LEVEL_LOW; + break; + + default: + assert(0); + } + + param_reset.gpio.index = gpio_index; + register_bl31_aux_param(¶m_reset.h); +} diff --git a/src/soc/mediatek/common/include/soc/bl31.h b/src/soc/mediatek/common/include/soc/bl31.h new file mode 100644 index 0000000..0c61ed3 --- /dev/null +++ b/src/soc/mediatek/common/include/soc/bl31.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +#ifndef _SOC_BL31_H_ +#define _SOC_BL31_H_ + +void register_reset_to_bl31(int gpio_index, int gpio_polarity); + +#endif /* _SOC_BL31_H_ */ diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc index 2cf8133..1624421 100644 --- a/src/soc/mediatek/mt8183/Makefile.inc +++ b/src/soc/mediatek/mt8183/Makefile.inc @@ -25,6 +25,7 @@ verstage-y += ../common/wdt.c
romstage-y += ../common/auxadc.c +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += ../common/bl31.c romstage-y += ../common/cbmem.c emi.c romstage-y += dramc_init_setting.c romstage-y += dramc_param.c diff --git a/src/soc/mediatek/mt8186/Makefile.inc b/src/soc/mediatek/mt8186/Makefile.inc index 892c809..bd1e560 100644 --- a/src/soc/mediatek/mt8186/Makefile.inc +++ b/src/soc/mediatek/mt8186/Makefile.inc @@ -27,6 +27,7 @@ romstage-y += ../common/rtc.c ../common/rtc_osc_init.c rtc.c
ramstage-y += ../common/auxadc.c +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += ../common/bl31.c ramstage-y += ../common/ddp.c ddp.c ramstage-y += ../common/devapc.c devapc.c ramstage-y += ../common/dfd.c diff --git a/src/soc/mediatek/mt8188/Makefile.inc b/src/soc/mediatek/mt8188/Makefile.inc index 70ec42a..3f83cbc 100644 --- a/src/soc/mediatek/mt8188/Makefile.inc +++ b/src/soc/mediatek/mt8188/Makefile.inc @@ -29,6 +29,7 @@ romstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c
ramstage-y += ../common/auxadc.c +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += ../common/bl31.c ramstage-y += ../common/devapc.c devapc.c ramstage-y += ../common/dfd.c ramstage-y += ../common/dpm.c diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index 3e3f59ae..cd3f473 100644 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -32,6 +32,7 @@
ramstage-y += apusys.c ramstage-y += ../common/auxadc.c +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += ../common/bl31.c ramstage-y += ../common/ddp.c ddp.c ramstage-y += devapc.c ramstage-y += ../common/dfd.c diff --git a/src/soc/mediatek/mt8195/Makefile.inc b/src/soc/mediatek/mt8195/Makefile.inc index a09cb9c..2d50506 100644 --- a/src/soc/mediatek/mt8195/Makefile.inc +++ b/src/soc/mediatek/mt8195/Makefile.inc @@ -39,6 +39,7 @@ ramstage-y += apusys.c ramstage-y += apusys_devapc.c ramstage-y += ../common/auxadc.c +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += ../common/bl31.c ramstage-y += ../common/early_init.c ramstage-y += ../common/ddp.c ddp.c ramstage-y += ../common/devapc.c devapc.c