diff options
author | Jarried Lin <jarried.lin@mediatek.corp-partner.google.com> | 2024-07-14 18:57:15 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-07-23 13:45:33 +0000 |
commit | 8cb9641eca5d24048bf9e9a5a4707cae1e26d366 (patch) | |
tree | a54bfa575bbd20021b896df64013f94f2eb9e40b /src/soc/mediatek | |
parent | 24eee9bcb0bba13747345f47c88dacc541de0551 (diff) |
soc/mediatek/mt8196: Add a stub implementation of the MT8196 SoC
Add new folder and basic drivers for Mediatek SoC 'MT8196'.
Refer to MT8196_Chromebook_Application_Processor_Datasheet_V1.0 for
MT8196 SPEC detail.
This patch also enables UART and ARM arch timer.
TEST=saw the coreboot uart log to bootblock
BUG=b:317009620
Change-Id: I8190253ed000db879b04a806ca0bdf29c14be806
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83572
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek')
-rw-r--r-- | src/soc/mediatek/mt8196/Kconfig | 22 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/Makefile.mk | 24 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/bootblock.c | 9 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/emi.c | 13 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/addressmap.h | 82 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/emi.h | 15 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/memlayout.ld | 58 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/pll.h | 23 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/spi.h | 13 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/include/soc/timer.h | 13 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/soc.c | 30 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/spi.c | 22 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/timer.c | 10 |
13 files changed, 334 insertions, 0 deletions
diff --git a/src/soc/mediatek/mt8196/Kconfig b/src/soc/mediatek/mt8196/Kconfig new file mode 100644 index 0000000000..309622776e --- /dev/null +++ b/src/soc/mediatek/mt8196/Kconfig @@ -0,0 +1,22 @@ +## SPDX-License-Identifier: GPL-2.0-only + +config SOC_MEDIATEK_MT8196 + bool + default n + select ARCH_BOOTBLOCK_ARMV8_64 + select ARCH_VERSTAGE_ARMV8_64 + select ARCH_ROMSTAGE_ARMV8_64 + select ARCH_RAMSTAGE_ARMV8_64 + select HAVE_UART_SPECIAL + select SOC_MEDIATEK_COMMON + select ARM64_USE_ARCH_TIMER + +if SOC_MEDIATEK_MT8196 + +config VBOOT + select VBOOT_MUST_REQUEST_DISPLAY + select VBOOT_STARTS_IN_BOOTBLOCK + select VBOOT_SEPARATE_VERSTAGE + select VBOOT_RETURN_FROM_VERSTAGE + +endif diff --git a/src/soc/mediatek/mt8196/Makefile.mk b/src/soc/mediatek/mt8196/Makefile.mk new file mode 100644 index 0000000000..5afbb9ebef --- /dev/null +++ b/src/soc/mediatek/mt8196/Makefile.mk @@ -0,0 +1,24 @@ +## SPDX-License-Identifier: GPL-2.0-only + +ifeq ($(CONFIG_SOC_MEDIATEK_MT8196),y) + +all-$(CONFIG_SPI_FLASH) += spi.c +all-y += timer.c +all-y += ../common/uart.c + +bootblock-y += bootblock.c +bootblock-y += ../common/mmu_operations.c + +romstage-y += ../common/cbmem.c +romstage-y += emi.c + +ramstage-y += emi.c +ramstage-y += soc.c + +CPPFLAGS_common += -Isrc/soc/mediatek/mt8196/include +CPPFLAGS_common += -Isrc/soc/mediatek/common/include + +$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin + ./util/mtkheader/gen-bl-img.py mt8196 sf $< $@ + +endif diff --git a/src/soc/mediatek/mt8196/bootblock.c b/src/soc/mediatek/mt8196/bootblock.c new file mode 100644 index 0000000000..f48e78c309 --- /dev/null +++ b/src/soc/mediatek/mt8196/bootblock.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <bootblock_common.h> +#include <soc/mmu_operations.h> + +void bootblock_soc_init(void) +{ + mtk_mmu_init(); +} diff --git a/src/soc/mediatek/mt8196/emi.c b/src/soc/mediatek/mt8196/emi.c new file mode 100644 index 0000000000..1129ce13bb --- /dev/null +++ b/src/soc/mediatek/mt8196/emi.c @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 10.2 + */ + +#include <soc/emi.h> + +size_t sdram_size(void) +{ + return (size_t)4 * GiB; +} diff --git a/src/soc/mediatek/mt8196/include/soc/addressmap.h b/src/soc/mediatek/mt8196/include/soc/addressmap.h new file mode 100644 index 0000000000..b95e0ea87f --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/addressmap.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#ifndef __SOC_MEDIATEK_MT8196_INCLUDE_SOC_ADDRESSMAP_H__ +#define __SOC_MEDIATEK_MT8196_INCLUDE_SOC_ADDRESSMAP_H__ + +enum { + MCUSYS_BASE = 0x0C000000, + MCUPM_CFG_BASE = 0x0C240000, + IO_PHYS = 0x10000000, +}; + +enum { + MCUCFG_BASE = MCUSYS_BASE, +}; + +enum { + CKSYS_BASE = IO_PHYS + 0x00000000, + APMIXED_BASE = IO_PHYS + 0x00000800, + INFRACFG_AO_BASE = IO_PHYS + 0x00001000, + CKSYS_GP2_BASE = IO_PHYS + 0x0000C000, + APMIXEDSYS_GP2_BASE = IO_PHYS + 0x0000C800, + BCRM_INFRA_AO_BASE = IO_PHYS + 0x00022000, + BCRM_INFRA1_AO_BASE = IO_PHYS + 0x0002A000, + GPIO_BASE = IO_PHYS + 0x0002D000, + DRAMC_CHA_AO_BASE = IO_PHYS + 0x00230000, + EMI0_BASE = IO_PHYS + 0x00469000, + EMI0_MPU_BASE = IO_PHYS + 0x00468000, + EMI1_BASE = IO_PHYS + 0x00569000, + DPM_PM_SRAM_BASE = IO_PHYS + 0x00900000, + DPM_DM_SRAM_BASE = IO_PHYS + 0x00920000, + DPM_CFG_BASE = IO_PHYS + 0x00940000, + DPM_PM_SRAM_BASE2 = IO_PHYS + 0x00A00000, + DPM_DM_SRAM_BASE2 = IO_PHYS + 0x00A20000, + DPM_CFG_BASE2 = IO_PHYS + 0x00A40000, + IOCFG_RT_BASE = IO_PHYS + 0x02000000, + IOCFG_RM1_BASE = IO_PHYS + 0x02020000, + IOCFG_RM2_BASE = IO_PHYS + 0x02040000, + IOCFG_RB_BASE = IO_PHYS + 0x02060000, + IOCFG_BM1_BASE = IO_PHYS + 0x02820000, + IOCFG_BM2_BASE = IO_PHYS + 0x02840000, + IOCFG_BM3_BASE = IO_PHYS + 0x02860000, + IOCFG_LT_BASE = IO_PHYS + 0x03000000, + IOCFG_LM1_BASE = IO_PHYS + 0x03020000, + IOCFG_LM2_BASE = IO_PHYS + 0x03040000, + MIPITX0_BASE = IO_PHYS + 0x030b0000, + IOCFG_LB1_BASE = IO_PHYS + 0x030f0000, + IOCFG_LB2_BASE = IO_PHYS + 0x03110000, + EFUSEC_BASE = IO_PHYS + 0x03260000, + IOCFG_TM1_BASE = IO_PHYS + 0x03800000, + IOCFG_TM2_BASE = IO_PHYS + 0x03820000, + IOCFG_TM3_BASE = IO_PHYS + 0x03860000, + THERM_CTRL_BASE = IO_PHYS + 0x04414000, + UART0_BASE = IO_PHYS + 0x06000000, + SPI0_BASE = IO_PHYS + 0x06110000, + SPI1_BASE = IO_PHYS + 0x06130000, + SPI2_BASE = IO_PHYS + 0x06150000, + SPI3_BASE = IO_PHYS + 0x06170000, + SPI4_BASE = IO_PHYS + 0x06190000, + SPI5_BASE = IO_PHYS + 0x061B0000, + SPI6_BASE = IO_PHYS + 0x0619D000, + SPI7_BASE = IO_PHYS + 0x061F0000, + SFLASH_REG_BASE = IO_PHYS + 0x06340000, + PERICFG_AO_BASE = IO_PHYS + 0x06640000, + SSUSB_IPPC_BASE = IO_PHYS + 0x06703E00, + SSUSB_SIF_BASE = IO_PHYS + 0x06730300, + UFSHCI_BASE = IO_PHYS + 0x06810000, + SCP_BASE = IO_PHYS + 0x0C004000, + SCP_PBUS_BASE = IO_PHYS + 0x0C00D000, + RGU_BASE = IO_PHYS + 0x0C010000, + GPT_BASE = IO_PHYS + 0x0C015000, + PMIF_SPMI_P_BASE = IO_PHYS + 0x0C018000, + PMIF_SPMI_BASE = IO_PHYS + 0x0C01A000, + SPMI_MST_BASE = IO_PHYS + 0x0C01C000, + SPMI_MST_P_BASE = IO_PHYS + 0x0C01C800, + SYSTIMER_BASE = IO_PHYS + 0x0C400000, + EINT_BASE = IO_PHYS + 0x0C54A000, + DSI0_BASE = IO_PHYS + 0x22490000, + DISP_DVO0 = IO_PHYS + 0x224C0000, + EDP_BASE = IO_PHYS + 0x2EC40000, +}; + +#endif diff --git a/src/soc/mediatek/mt8196/include/soc/emi.h b/src/soc/mediatek/mt8196/include/soc/emi.h new file mode 100644 index 0000000000..6acc0cfb46 --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/emi.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 10.2 + */ + +#ifndef SOC_MEDIATEK_MT8196_EMI_H +#define SOC_MEDIATEK_MT8196_EMI_H + +#include <stddef.h> + +size_t sdram_size(void); + +#endif /* SOC_MEDIATEK_MT8196_EMI_H */ diff --git a/src/soc/mediatek/mt8196/include/soc/memlayout.ld b/src/soc/mediatek/mt8196/include/soc/memlayout.ld new file mode 100644 index 0000000000..e0975c7c81 --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/memlayout.ld @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#include <soc/memlayout.h> + +SECTIONS +{ + /* MT8196 has 256KB SRAM. */ + SRAM_START(0x00100000) + /* Regions that need to stay in SRAM. */ + TTB(0x00100000, 28K) + DMA_COHERENT(0x00107000, 4K) + STACK(0x00108000, 15K) + WATCHDOG_TOMBSTONE(0x0010bc00, 4) + /* EMPTY(0x0010bc04, 29K - 4) */ + /* + * MCUPM exchanges data with kernel driver using SRAM 0x00113000 ~ + * 0x0011ffff. The address is hardcoded in MCUPM image. + */ + REGION(mcufw_reserved, 0x00113000, 52K, 4K) + /* End of regions that need to stay in SRAM. */ + /* Regions can be moved to SRAM_L2C. */ + CBFS_MCACHE(0x00120000, 16k) + VBOOT2_WORK(0x00124000, 12K) + FMAP_CACHE(0x00127000, 2k) + TPM_LOG(0x00127800, 2k) + TIMESTAMP(0x00128000, 1k) + /* End of regions that can also be moved to SRAM_L2C. */ + /* EMPTY(0x00128400, 95K) */ + SRAM_END(0x00140000) + + /* + * The L3 (can be used as SRAM_L2C) currently using is 2MB. + * The BootROM has configured all cache as SRAM so we can't use them + * unless if we disable L2C and reconfigure. + */ + SRAM_L2C_START(0x02000000) + #if ENV_ROMSTAGE + /* + * The needed size can be obtained by: + * aarch64-cros-linux-gnu-objdump -x dram.elf | grep memsz + */ + DRAM_INIT_CODE(0x02000000, 600K) + /* 4K reserved for BOOTROM until BOOTBLOCK is started */ + #else + BOOTBLOCK(0x02001000, 60K) + #endif + OVERLAP_DECOMPRESSOR_VERSTAGE_ROMSTAGE(0x02096000, 272K) + PRERAM_CBFS_CACHE(0x020DA000, 48K) + PRERAM_CBMEM_CONSOLE(0x020E6000, 340K) + SRAM_L2C_END(0x02200000) + + DRAM_START(0x80000000) + DRAM_DMA(0x80000000, 1M) + POSTRAM_CBFS_CACHE(0x80100000, 2M) + RAMSTAGE(0x80300000, 2M) + + BL31(0x94600000, 0x200000) +} diff --git a/src/soc/mediatek/mt8196/include/soc/pll.h b/src/soc/mediatek/mt8196/include/soc/pll.h new file mode 100644 index 0000000000..1f6d1c906f --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/pll.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 14.1 + */ + +#ifndef SOC_MEDIATEK_MT8196_PLL_H +#define SOC_MEDIATEK_MT8196_PLL_H + +#include <soc/pll_common.h> + +/* top_div rate */ +enum { + CLK26M_HZ = 26 * MHz, +}; + +/* top_mux rate */ +enum { + UART_HZ = CLK26M_HZ, +}; + +#endif /* SOC_MEDIATEK_MT8196_PLL_H */ diff --git a/src/soc/mediatek/mt8196/include/soc/spi.h b/src/soc/mediatek/mt8196/include/soc/spi.h new file mode 100644 index 0000000000..69025d2a3d --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/spi.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 13.9 + */ + +#ifndef SOC_MEDIATEK_MT8196_SPI_H +#define SOC_MEDIATEK_MT8196_SPI_H + +#include <spi-generic.h> + +#endif diff --git a/src/soc/mediatek/mt8196/include/soc/timer.h b/src/soc/mediatek/mt8196/include/soc/timer.h new file mode 100644 index 0000000000..d6422c5442 --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/timer.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 5.13 + */ + +#ifndef SOC_MEDIATEK_MT8196_TIMER_H +#define SOC_MEDIATEK_MT8196_TIMER_H + +#include <soc/timer_v2.h> + +#endif diff --git a/src/soc/mediatek/mt8196/soc.c b/src/soc/mediatek/mt8196/soc.c new file mode 100644 index 0000000000..b77735ceed --- /dev/null +++ b/src/soc/mediatek/mt8196/soc.c @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <device/device.h> +#include <soc/emi.h> +#include <symbols.h> + +static void soc_read_resources(struct device *dev) +{ + ram_range(dev, 0, (uintptr_t)_dram, sdram_size()); +} + +static void soc_init(struct device *dev) +{ +} + +static struct device_operations soc_ops = { + .read_resources = soc_read_resources, + .set_resources = noop_set_resources, + .init = soc_init, +}; + +static void enable_soc_dev(struct device *dev) +{ + dev->ops = &soc_ops; +} + +struct chip_operations soc_mediatek_mt8196_ops = { + .name = "SOC Mediatek MT8196", + .enable_dev = enable_soc_dev, +}; diff --git a/src/soc/mediatek/mt8196/spi.c b/src/soc/mediatek/mt8196/spi.c new file mode 100644 index 0000000000..11bbb5f143 --- /dev/null +++ b/src/soc/mediatek/mt8196/spi.c @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 13.9 + */ + +#include <device/mmio.h> +#include <soc/addressmap.h> +#include <soc/spi.h> + +static const struct spi_ctrlr spi_flash_ctrlr = { + .max_xfer_size = 65535, +}; + +const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = { + { + .ctrlr = &spi_flash_ctrlr, + }, +}; + +const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map); diff --git a/src/soc/mediatek/mt8196/timer.c b/src/soc/mediatek/mt8196/timer.c new file mode 100644 index 0000000000..9d8dd7a9a6 --- /dev/null +++ b/src/soc/mediatek/mt8196/timer.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <arch/lib_helpers.h> +#include <commonlib/helpers.h> +#include <delay.h> + +void init_timer(void) +{ + raw_write_cntfrq_el0(13 * MHz); +} |