From 9cf07f0cb90245e50489e98984ee2aa3c1da043e Mon Sep 17 00:00:00 2001 From: Rex-BC Chen Date: Fri, 21 May 2021 11:12:19 +0800 Subject: soc/mediatek: Move the MT8192 MCUPM driver to common The MPUCM drivers can be shared by MT8192 and MT8195. TEST=emerge-asurada coreboot; Signed-off-by: Rex-BC Chen Change-Id: I07a66bcf5a149582f34df1cfd08b5514fc5c2eb9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/54898 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/common/include/soc/mcupm.h | 14 ++++++++++++ src/soc/mediatek/common/mcupm.c | 33 +++++++++++++++++++++++++++++ src/soc/mediatek/mt8192/Makefile.inc | 2 +- src/soc/mediatek/mt8192/include/soc/mcupm.h | 14 ------------ src/soc/mediatek/mt8192/mcupm.c | 33 ----------------------------- 5 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 src/soc/mediatek/common/include/soc/mcupm.h create mode 100644 src/soc/mediatek/common/mcupm.c delete mode 100644 src/soc/mediatek/mt8192/include/soc/mcupm.h delete mode 100644 src/soc/mediatek/mt8192/mcupm.c (limited to 'src') diff --git a/src/soc/mediatek/common/include/soc/mcupm.h b/src/soc/mediatek/common/include/soc/mcupm.h new file mode 100644 index 0000000000..c9642afefe --- /dev/null +++ b/src/soc/mediatek/common/include/soc/mcupm.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_COMMON_MCUPM_H +#define SOC_MEDIATEK_COMMON_MCUPM_H + +#include +#include + +struct mcupm_regs { + u32 sw_rstn; +}; +static struct mcupm_regs *const mcupm_reg = (void *)MCUPM_CFG_BASE; +void mcupm_init(void); +#endif /* SOC_MEDIATEK_COMMON_MCUPM_H */ diff --git a/src/soc/mediatek/common/mcupm.c b/src/soc/mediatek/common/mcupm.c new file mode 100644 index 0000000000..dde10e21ca --- /dev/null +++ b/src/soc/mediatek/common/mcupm.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include + +#define ABNORMALBOOT_REG 0x0C55FAA0 + +static void reset_mcupm(struct mtk_mcu *mcu) +{ + /* Clear abnormal boot register */ + write32((void *)ABNORMALBOOT_REG, 0x0); + write32(&mcupm_reg->sw_rstn, 0x1); +} + +static struct mtk_mcu mcupm = { + .firmware_name = CONFIG_MCUPM_FIRMWARE, + .run_address = (void *)MCUPM_SRAM_BASE, + .reset = reset_mcupm, +}; + +void mcupm_init(void) +{ + mcupm.load_buffer = _dram_dma; + mcupm.buffer_size = REGION_SIZE(dram_dma); + + write32(&mcupm_reg->sw_rstn, 0x0); + + if (mtk_init_mcu(&mcupm)) + die("%s() failed\n", __func__); +} diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index f69274e3fe..bdff835c0e 100644 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -53,7 +53,7 @@ ramstage-y += ../common/gpio.c gpio.c ramstage-y += ../common/i2c.c i2c.c ramstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c ramstage-y += ../common/mcu.c -ramstage-y += mcupm.c +ramstage-y += ../common/mcupm.c ramstage-y += ../common/mmu_operations.c mmu_operations.c ramstage-$(CONFIG_COMMONLIB_STORAGE_MMC) += ../common/msdc.c ramstage-y += ../common/mtcmos.c mtcmos.c diff --git a/src/soc/mediatek/mt8192/include/soc/mcupm.h b/src/soc/mediatek/mt8192/include/soc/mcupm.h deleted file mode 100644 index dcb8c4a3e0..0000000000 --- a/src/soc/mediatek/mt8192/include/soc/mcupm.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef SOC_MEDIATEK_MT8192_MCUPM_H -#define SOC_MEDIATEK_MT8192_MCUPM_H - -#include -#include - -struct mt8192_mcupm_regs { - u32 sw_rstn; -}; -static struct mt8192_mcupm_regs *const mt8192_mcupm = (void *)MCUPM_CFG_BASE; -void mcupm_init(void); -#endif /* SOC_MEDIATEK_MT8192_MCUPM_H */ diff --git a/src/soc/mediatek/mt8192/mcupm.c b/src/soc/mediatek/mt8192/mcupm.c deleted file mode 100644 index 70981a05ec..0000000000 --- a/src/soc/mediatek/mt8192/mcupm.c +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include -#include - -#define ABNORMALBOOT_REG 0x0C55FAA0 - -static void reset_mcupm(struct mtk_mcu *mcu) -{ - /* Clear abnormal boot register */ - write32((void *)ABNORMALBOOT_REG, 0x0); - write32(&mt8192_mcupm->sw_rstn, 0x1); -} - -static struct mtk_mcu mcupm = { - .firmware_name = CONFIG_MCUPM_FIRMWARE, - .run_address = (void *)MCUPM_SRAM_BASE, - .reset = reset_mcupm, -}; - -void mcupm_init(void) -{ - mcupm.load_buffer = _dram_dma; - mcupm.buffer_size = REGION_SIZE(dram_dma); - - write32(&mt8192_mcupm->sw_rstn, 0x0); - - if (mtk_init_mcu(&mcupm)) - die("%s() failed\n", __func__); -} -- cgit v1.2.3