Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46402 )
Change subject: soc/mediatek/mt8192: devapc: add basic dapc drivers ......................................................................
soc/mediatek/mt8192: devapc: add basic dapc drivers
Add basic dapc drivers: 1. init dapc 2. set CPUEB to secure sideband
Change-Id: I2ad47c86b88047c76854a6f8a67b251b6a9d4013 Signed-off-by: Nina Wu nina-cm.wu@mediatek.com --- M src/soc/mediatek/mt8192/Makefile.inc A src/soc/mediatek/mt8192/devapc.c M src/soc/mediatek/mt8192/include/soc/addressmap.h A src/soc/mediatek/mt8192/include/soc/devapc.h M src/soc/mediatek/mt8192/soc.c 5 files changed, 54 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/46402/1
diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index 5609a06..4ce5e6a 100755 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -47,6 +47,7 @@ ramstage-y += ../common/mmu_operations.c mmu_operations.c ramstage-y += ../common/mtcmos.c mtcmos.c ramstage-y += soc.c +ramstage-y += devapc.c ramstage-y += mcupm.c ramstage-y += ../common/timer.c ramstage-y += ../common/uart.c diff --git a/src/soc/mediatek/mt8192/devapc.c b/src/soc/mediatek/mt8192/devapc.c new file mode 100644 index 0000000..96a2a01 --- /dev/null +++ b/src/soc/mediatek/mt8192/devapc.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <soc/devapc.h> + +static unsigned long devapc_ao_base = (unsigned long)DEVAPC_INFRA_AO_BASE; + +static void master_sec_init(void) +{ + unsigned int val = 0; + + SET32_BITFIELDS(&val, CPU_EB_SEC, 1); + + write32((void*)MAS_SEC, val); + + if (read32((const void*)MAS_SEC) != val) + printk(BIOS_ERR, "[DEVAPC] %s: FAILED to set INFRA MAS_SEC\n", __func__); + else + printk(BIOS_INFO, "[DEVAPC] %s: INFRA MAS_SEC is set to 0x%x\n", __func__, val); +} + +void dapc_init(void) +{ + /* Init dapc */ + write32((void*)AO_APC_CON, 0x1); + + /* Init master sideband */ + master_sec_init(); +} diff --git a/src/soc/mediatek/mt8192/include/soc/addressmap.h b/src/soc/mediatek/mt8192/include/soc/addressmap.h index bd9b755..19728a3 100644 --- a/src/soc/mediatek/mt8192/include/soc/addressmap.h +++ b/src/soc/mediatek/mt8192/include/soc/addressmap.h @@ -60,6 +60,7 @@ IOCFG_TL_BASE = IO_PHYS + 0x01F30000, MSDC0_TOP_BASE = IO_PHYS + 0x01F50000, MSDC0_BASE = IO_PHYS + 0x01F60000, + DEVAPC_INFRA_AO_BASE = IO_PHYS + 0x00030000, };
#endif diff --git a/src/soc/mediatek/mt8192/include/soc/devapc.h b/src/soc/mediatek/mt8192/include/soc/devapc.h new file mode 100644 index 0000000..0cd67d3 --- /dev/null +++ b/src/soc/mediatek/mt8192/include/soc/devapc.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_MT8192_DEVAPC_H +#define SOC_MEDIATEK_MT8192_DEVAPC_H + +#include <device/mmio.h> +#include <soc/addressmap.h> + +void dapc_init(void); + +enum devapc_ao_offset { + OFF_AO_APC_CON = 0x0F00, + OFF_MAS_SEC_0 = 0x0A00, +}; + +#define AO_APC_CON (devapc_ao_base + (unsigned long)OFF_AO_APC_CON) +#define MAS_SEC (devapc_ao_base + (unsigned long)OFF_MAS_SEC_0) + +DEFINE_BIT(CPU_EB_SEC, 4) + +#endif /* SOC_MEDIATEK_MT8192_DEVAPC_H */ diff --git a/src/soc/mediatek/mt8192/soc.c b/src/soc/mediatek/mt8192/soc.c index 6deb833..ba153f2 100644 --- a/src/soc/mediatek/mt8192/soc.c +++ b/src/soc/mediatek/mt8192/soc.c @@ -4,6 +4,7 @@ #include <soc/emi.h> #include <soc/mmu_operations.h> #include <symbols.h> +#include <soc/devapc.h> #include <soc/mcupm.h>
static void soc_read_resources(struct device *dev) @@ -14,6 +15,7 @@ static void soc_init(struct device *dev) { mtk_mmu_disable_l2c_sram(); + dapc_init(); mcupm_init(); }