Commit 76eac186 authored by Soby Mathew's avatar Soby Mathew Committed by TrustedFirmware Code Review
Browse files

Merge changes I08cf22df,I535ee414,Ie84cfc96,I8c35ce4e,If7649764, ... into integration

* changes:
  mediatek: mt8183: Support coreboot configuration
  mediatek: mt8183: support system reset
  mediatek: mt8183: pass platform parameters
  mediatek: mt8183: add GPIO driver
  mediatek: mt8183: support system off
  mediatek: mt8183: support CPU hotplug
  mediatek: mt8183: refine GIC driver
parents 5f7956c0 0d8cb493
/*
* Copyright (c) 2019, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PLAT_DCM_H
#define PLAT_DCM_H
#define MP2_SYNC_DCM (MCUCFG_BASE + 0x2274)
#define MP2_SYNC_DCM_MASK (0x1 << 0)
#define MP2_SYNC_DCM_ON (0x1 << 0)
#define MP2_SYNC_DCM_OFF (0x0 << 0)
extern uint64_t plat_dcm_mcsi_a_addr;
extern uint32_t plat_dcm_mcsi_a_val;
extern int plat_dcm_initiated;
extern void plat_dcm_mcsi_a_backup(void);
extern void plat_dcm_mcsi_a_restore(void);
extern void plat_dcm_rgu_enable(void);
extern void plat_dcm_restore_cluster_on(unsigned long mpidr);
extern void plat_dcm_msg_handler(uint64_t x1);
extern unsigned long plat_dcm_get_enabled_cnt(uint64_t type);
extern void plat_dcm_init(void);
#define ALL_DCM_TYPE (ARMCORE_DCM_TYPE | MCUSYS_DCM_TYPE \
| STALL_DCM_TYPE | BIG_CORE_DCM_TYPE \
| GIC_SYNC_DCM_TYPE | RGU_DCM_TYPE \
| INFRA_DCM_TYPE \
| DDRPHY_DCM_TYPE | EMI_DCM_TYPE | DRAMC_DCM_TYPE \
| MCSI_DCM_TYPE)
enum {
ARMCORE_DCM_TYPE = (1U << 0),
MCUSYS_DCM_TYPE = (1U << 1),
INFRA_DCM_TYPE = (1U << 2),
PERI_DCM_TYPE = (1U << 3),
EMI_DCM_TYPE = (1U << 4),
DRAMC_DCM_TYPE = (1U << 5),
DDRPHY_DCM_TYPE = (1U << 6),
STALL_DCM_TYPE = (1U << 7),
BIG_CORE_DCM_TYPE = (1U << 8),
GIC_SYNC_DCM_TYPE = (1U << 9),
LAST_CORE_DCM_TYPE = (1U << 10),
RGU_DCM_TYPE = (1U << 11),
TOPCKG_DCM_TYPE = (1U << 12),
LPDMA_DCM_TYPE = (1U << 13),
MCSI_DCM_TYPE = (1U << 14),
NR_DCM_TYPE = 15,
};
#endif /* PLAT_DCM_H */
\ No newline at end of file
...@@ -273,7 +273,7 @@ INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \ ...@@ -273,7 +273,7 @@ INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
******************************************************************************/ ******************************************************************************/
#define TZRAM_BASE 0x54600000 #define TZRAM_BASE 0x54600000
#define TZRAM_SIZE 0x00020000 #define TZRAM_SIZE 0x00030000
/******************************************************************************* /*******************************************************************************
* BL31 specific defines. * BL31 specific defines.
...@@ -291,7 +291,7 @@ INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \ ...@@ -291,7 +291,7 @@ INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
******************************************************************************/ ******************************************************************************/
#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32) #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32) #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
#define MAX_XLAT_TABLES 4 #define MAX_XLAT_TABLES 16
#define MAX_MMAP_REGIONS 16 #define MAX_MMAP_REGIONS 16
/******************************************************************************* /*******************************************************************************
......
This diff is collapsed.
/*
* Copyright (c) 2019, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <lib/bakery_lock.h>
#include <drivers/console.h>
#include <common/debug.h>
#include <lib/mmio.h>
#include <plat_dcm.h>
#include <plat_private.h>
#include <plat_dcm.h>
#include <plat/common/platform.h>
#include <platform_def.h>
#include <mtk_plat_common.h>
#define PWR_STATUS (SPM_BASE + 0x180)
uint64_t plat_dcm_mcsi_a_addr;
uint32_t plat_dcm_mcsi_a_val;
static int plat_dcm_init_type;
static unsigned int dcm_big_core_cnt;
int plat_dcm_initiated;
#define PWR_STA_BIG_MP_MASK (0x1 << 15)
DEFINE_BAKERY_LOCK(dcm_lock);
void dcm_lock_init(void)
{
bakery_lock_init(&dcm_lock);
}
void dcm_lock_get(void)
{
bakery_lock_get(&dcm_lock);
}
void dcm_lock_release(void)
{
bakery_lock_release(&dcm_lock);
}
void plat_dcm_mcsi_a_backup(void)
{
}
void plat_dcm_mcsi_a_restore(void)
{
}
void plat_dcm_rgu_enable(void)
{
}
void plat_dcm_big_core_sync(short on)
{
/* Check if Big cluster power is existed */
if (!(mmio_read_32(PWR_STATUS) & PWR_STA_BIG_MP_MASK))
return;
if (on) {
mmio_write_32(MP2_SYNC_DCM,
(mmio_read_32(MP2_SYNC_DCM) & ~MP2_SYNC_DCM_MASK)
| MP2_SYNC_DCM_ON);
dcm_big_core_cnt++;
} else
mmio_write_32(MP2_SYNC_DCM,
(mmio_read_32(MP2_SYNC_DCM) & ~MP2_SYNC_DCM_MASK)
| MP2_SYNC_DCM_OFF);
}
void plat_dcm_restore_cluster_on(unsigned long mpidr)
{
unsigned long cluster_id =
(mpidr & MPIDR_CLUSTER_MASK) >> MPIDR_AFFINITY_BITS;
switch (cluster_id) {
case 0x1:
dcm_lock_get();
if (plat_dcm_init_type & BIG_CORE_DCM_TYPE)
plat_dcm_big_core_sync(1);
else
plat_dcm_big_core_sync(0);
dcm_lock_release();
break;
default:
break;
}
}
void plat_dcm_msg_handler(uint64_t x1)
{
plat_dcm_init_type = x1 & ALL_DCM_TYPE;
}
unsigned long plat_dcm_get_enabled_cnt(uint64_t type)
{
switch (type) {
case BIG_CORE_DCM_TYPE:
return dcm_big_core_cnt;
default:
return 0;
}
}
void plat_dcm_init(void)
{
dcm_lock_init();
}
/* /*
* Copyright (c) 2019, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2019, MediaTek Inc. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <assert.h>
#include <common/bl_common.h> #include <common/bl_common.h>
#include <common/debug.h> #include <common/debug.h>
#include <drivers/arm/gicv3.h> #include <drivers/arm/gicv3.h>
#include <bl31/interrupt_mgmt.h> #include <bl31/interrupt_mgmt.h>
#include <../drivers/arm/gic/v3/gicv3_private.h>
#include <mt_gic_v3.h> #include <mt_gic_v3.h>
#include <mtk_plat_common.h> #include <mtk_plat_common.h>
#include "plat_private.h" #include "plat_private.h"
...@@ -21,13 +21,9 @@ ...@@ -21,13 +21,9 @@
uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT]; uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
/* /* we save and restore the GICv3 context on system suspend */
* We save and restore the GICv3 context on system suspend. Allocate the gicv3_redist_ctx_t rdist_ctx;
* data in the designated EL3 Secure carve-out memory gicv3_dist_ctx_t dist_ctx;
*/
gicv3_redist_ctx_t rdist_ctx __section("arm_el3_tzc_dram");
gicv3_dist_ctx_t dist_ctx __section("arm_el3_tzc_dram");
static unsigned int mt_mpidr_to_core_pos(u_register_t mpidr) static unsigned int mt_mpidr_to_core_pos(u_register_t mpidr)
{ {
...@@ -42,27 +38,6 @@ gicv3_driver_data_t mt_gicv3_data = { ...@@ -42,27 +38,6 @@ gicv3_driver_data_t mt_gicv3_data = {
.mpidr_to_core_pos = mt_mpidr_to_core_pos, .mpidr_to_core_pos = mt_mpidr_to_core_pos,
}; };
void setup_int_schedule_mode(enum irq_schedule_mode mode,
unsigned int active_cpu)
{
assert(mode <= HW_MODE);
assert(active_cpu <= 0xFF);
if (mode == HW_MODE) {
mmio_write_32(GIC_INT_MASK,
(mmio_read_32(GIC_INT_MASK) & ~(GIC500_ACTIVE_SEL_MASK))
| (0x1 << GIC500_ACTIVE_SEL_SHIFT));
} else if (mode == SW_MODE) {
mmio_write_32(GIC_INT_MASK,
(mmio_read_32(GIC_INT_MASK) & ~(GIC500_ACTIVE_SEL_MASK)));
}
mmio_write_32(GIC_INT_MASK,
(mmio_read_32(GIC_INT_MASK) & ~(GIC500_ACTIVE_CPU_MASK))
| (active_cpu << GIC500_ACTIVE_CPU_SHIFT));
return;
}
void clear_sec_pol_ctl_en(void) void clear_sec_pol_ctl_en(void)
{ {
unsigned int i; unsigned int i;
...@@ -85,7 +60,6 @@ void mt_gic_init(void) ...@@ -85,7 +60,6 @@ void mt_gic_init(void)
gicv3_rdistif_init(plat_my_core_pos()); gicv3_rdistif_init(plat_my_core_pos());
gicv3_cpuif_enable(plat_my_core_pos()); gicv3_cpuif_enable(plat_my_core_pos());
setup_int_schedule_mode(SW_MODE, 0xf);
clear_sec_pol_ctl_en(); clear_sec_pol_ctl_en();
} }
...@@ -94,14 +68,6 @@ void mt_gic_set_pending(uint32_t irq) ...@@ -94,14 +68,6 @@ void mt_gic_set_pending(uint32_t irq)
gicv3_set_interrupt_pending(irq, plat_my_core_pos()); gicv3_set_interrupt_pending(irq, plat_my_core_pos());
} }
uint32_t mt_gic_get_pending(uint32_t irq)
{
uint32_t bit = 1 << (irq % 32);
return (mmio_read_32(gicv3_driver_data->gicd_base +
GICD_ISPENDR + irq / 32 * 4) & bit) ? 1 : 0;
}
void mt_gic_cpuif_enable(void) void mt_gic_cpuif_enable(void)
{ {
gicv3_cpuif_enable(plat_my_core_pos()); gicv3_cpuif_enable(plat_my_core_pos());
......
/* /*
* Copyright (c) 2019, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2019, MediaTek Inc. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -15,25 +15,151 @@ ...@@ -15,25 +15,151 @@
/* mediatek platform specific headers */ /* mediatek platform specific headers */
#include <platform_def.h> #include <platform_def.h>
#include <scu.h> #include <scu.h>
#include <mt_gic_v3.h>
#include <mtk_plat_common.h> #include <mtk_plat_common.h>
#include <power_tracer.h> #include <mtgpio.h>
#include <mtspmc.h>
#include <plat_dcm.h>
#include <plat_debug.h>
#include <plat_params.h>
#include <plat_private.h> #include <plat_private.h>
#include <power_tracer.h>
#include <pmic.h>
#include <rtc.h>
#define MTK_LOCAL_STATE_OFF 2
static uintptr_t secure_entrypoint;
static void mp1_L2_desel_config(void)
{
mmio_write_64(MCUCFG_BASE + 0x2200, 0x2092c820);
dsb();
}
static int plat_mtk_power_domain_on(unsigned long mpidr)
{
int cpu = MPIDR_AFFLVL0_VAL(mpidr);
int cluster = MPIDR_AFFLVL1_VAL(mpidr);
INFO("%s():%d: mpidr: %lx, c.c: %d.%d\n",
__func__, __LINE__, mpidr, cluster, cpu);
/* power on cluster */
if (!spm_get_cluster_powerstate(cluster)) {
spm_poweron_cluster(cluster);
if (cluster == 1) {
l2c_parity_check_setup();
circular_buffer_setup();
mp1_L2_desel_config();
mt_gic_sync_dcm_disable();
}
}
/* init cpu reset arch as AARCH64 */
mcucfg_init_archstate(cluster, cpu, 1);
mcucfg_set_bootaddr(cluster, cpu, secure_entrypoint);
spm_poweron_cpu(cluster, cpu);
return PSCI_E_SUCCESS;
}
static void plat_mtk_power_domain_off(const psci_power_state_t *state)
{
uint64_t mpidr = read_mpidr();
int cpu = MPIDR_AFFLVL0_VAL(mpidr);
int cluster = MPIDR_AFFLVL1_VAL(mpidr);
INFO("%s():%d: c.c: %d.%d\n", __func__, __LINE__, cluster, cpu);
/* Prevent interrupts from spuriously waking up this cpu */
mt_gic_cpuif_disable();
spm_enable_cpu_auto_off(cluster, cpu);
if (state->pwr_domain_state[MPIDR_AFFLVL1] == MTK_LOCAL_STATE_OFF) {
if (cluster == 1)
mt_gic_sync_dcm_enable();
plat_mtk_cci_disable();
spm_enable_cluster_auto_off(cluster);
}
spm_set_cpu_power_off(cluster, cpu);
}
static void plat_mtk_power_domain_on_finish(const psci_power_state_t *state)
{
uint64_t mpidr = read_mpidr();
int cpu = MPIDR_AFFLVL0_VAL(mpidr);
int cluster = MPIDR_AFFLVL1_VAL(mpidr);
INFO("%s():%d: c.c: %d.%d\n", __func__, __LINE__, cluster, cpu);
assert(state->pwr_domain_state[MPIDR_AFFLVL0] == MTK_LOCAL_STATE_OFF);
if (state->pwr_domain_state[MPIDR_AFFLVL1] == MTK_LOCAL_STATE_OFF) {
enable_scu(mpidr);
/* Enable coherency if this cluster was off */
plat_mtk_cci_enable();
/* Enable big core dcm if this cluster was on */
plat_dcm_restore_cluster_on(mpidr);
/* Enable rgu dcm if this cluster was off */
plat_dcm_rgu_enable();
}
spm_disable_cpu_auto_off(cluster, cpu);
/* Enable the gic cpu interface */
mt_gic_pcpu_init();
mt_gic_cpuif_enable();
}
/*******************************************************************************
* MTK handlers to shutdown/reboot the system
******************************************************************************/
static void __dead2 plat_mtk_system_off(void)
{
INFO("MTK System Off\n");
rtc_power_off_sequence();
wk_pmic_enable_sdn_delay();
pmic_power_off();
wfi();
ERROR("MTK System Off: operation not handled.\n");
panic();
}
static void __dead2 plat_mtk_system_reset(void)
{
struct bl_aux_gpio_info *gpio_reset = plat_get_mtk_gpio_reset();
INFO("MTK System Reset\n");
mt_set_gpio_out(gpio_reset->index, gpio_reset->polarity);
wfi();
ERROR("MTK System Reset: operation not handled.\n");
panic();
}
/******************************************************************************* /*******************************************************************************
* MTK_platform handler called when an affinity instance is about to be turned * MTK_platform handler called when an affinity instance is about to be turned
* on. The level and mpidr determine the affinity instance. * on. The level and mpidr determine the affinity instance.
******************************************************************************/ ******************************************************************************/
static uintptr_t secure_entrypoint;
static const plat_psci_ops_t plat_plat_pm_ops = { static const plat_psci_ops_t plat_plat_pm_ops = {
.cpu_standby = NULL, .cpu_standby = NULL,
.pwr_domain_on = NULL, .pwr_domain_on = plat_mtk_power_domain_on,
.pwr_domain_on_finish = NULL, .pwr_domain_on_finish = plat_mtk_power_domain_on_finish,
.pwr_domain_off = NULL, .pwr_domain_off = plat_mtk_power_domain_off,
.pwr_domain_suspend = NULL, .pwr_domain_suspend = NULL,
.pwr_domain_suspend_finish = NULL, .pwr_domain_suspend_finish = NULL,
.system_off = NULL, .system_off = plat_mtk_system_off,
.system_reset = NULL, .system_reset = plat_mtk_system_reset,
.validate_power_state = NULL, .validate_power_state = NULL,
.get_sys_suspend_power_state = NULL, .get_sys_suspend_power_state = NULL,
}; };
......
# #
# Copyright (c) 2019, ARM Limited and Contributors. All rights reserved. # Copyright (c) 2019, MediaTek Inc. All rights reserved.
# #
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
...@@ -9,6 +9,10 @@ MTK_PLAT_SOC := ${MTK_PLAT}/${PLAT} ...@@ -9,6 +9,10 @@ MTK_PLAT_SOC := ${MTK_PLAT}/${PLAT}
PLAT_INCLUDES := -I${MTK_PLAT}/common/ \ PLAT_INCLUDES := -I${MTK_PLAT}/common/ \
-I${MTK_PLAT_SOC}/drivers/ \ -I${MTK_PLAT_SOC}/drivers/ \
-I${MTK_PLAT_SOC}/drivers/spmc/ \
-I${MTK_PLAT_SOC}/drivers/gpio/ \
-I${MTK_PLAT_SOC}/drivers/pmic/ \
-I${MTK_PLAT_SOC}/drivers/rtc/ \
-I${MTK_PLAT_SOC}/include/ -I${MTK_PLAT_SOC}/include/
PLAT_BL_COMMON_SOURCES := lib/xlat_tables/aarch64/xlat_tables.c \ PLAT_BL_COMMON_SOURCES := lib/xlat_tables/aarch64/xlat_tables.c \
...@@ -27,17 +31,26 @@ BL31_SOURCES += common/desc_image_load.c \ ...@@ -27,17 +31,26 @@ BL31_SOURCES += common/desc_image_load.c \
drivers/delay_timer/generic_delay_timer.c \ drivers/delay_timer/generic_delay_timer.c \
drivers/gpio/gpio.c \ drivers/gpio/gpio.c \
drivers/ti/uart/aarch64/16550_console.S \ drivers/ti/uart/aarch64/16550_console.S \
lib/bl_aux_params/bl_aux_params.c \
lib/cpus/aarch64/aem_generic.S \ lib/cpus/aarch64/aem_generic.S \
lib/cpus/aarch64/cortex_a53.S \ lib/cpus/aarch64/cortex_a53.S \
lib/cpus/aarch64/cortex_a73.S \ lib/cpus/aarch64/cortex_a73.S \
plat/common/plat_gicv3.c \ plat/common/plat_gicv3.c \
${MTK_PLAT}/common/mtk_plat_common.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/plat_helpers.S \
${MTK_PLAT_SOC}/aarch64/platform_common.c \ ${MTK_PLAT_SOC}/aarch64/platform_common.c \
${MTK_PLAT_SOC}/drivers/mcsi/mcsi.c \ ${MTK_PLAT_SOC}/drivers/mcsi/mcsi.c \
${MTK_PLAT_SOC}/drivers/pmic/pmic.c \
${MTK_PLAT_SOC}/drivers/rtc/rtc.c \
${MTK_PLAT_SOC}/drivers/spmc/mtspmc.c \
${MTK_PLAT_SOC}/drivers/gpio/mtgpio.c \
${MTK_PLAT_SOC}/plat_pm.c \ ${MTK_PLAT_SOC}/plat_pm.c \
${MTK_PLAT_SOC}/plat_topology.c \ ${MTK_PLAT_SOC}/plat_topology.c \
${MTK_PLAT_SOC}/plat_mt_gic.c \ ${MTK_PLAT_SOC}/plat_mt_gic.c \
${MTK_PLAT_SOC}/plat_dcm.c \
${MTK_PLAT_SOC}/bl31_plat_setup.c \ ${MTK_PLAT_SOC}/bl31_plat_setup.c \
${MTK_PLAT_SOC}/plat_debug.c \ ${MTK_PLAT_SOC}/plat_debug.c \
${MTK_PLAT_SOC}/scu.c ${MTK_PLAT_SOC}/scu.c
...@@ -57,3 +70,5 @@ MULTI_CONSOLE_API := 1 ...@@ -57,3 +70,5 @@ MULTI_CONSOLE_API := 1
MACH_MT8183 := 1 MACH_MT8183 := 1
$(eval $(call add_define,MACH_MT8183)) $(eval $(call add_define,MACH_MT8183))
include lib/coreboot/coreboot.mk
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment