From e235f9a56be94c621019b54d7748969c5d66ba79 Mon Sep 17 00:00:00 2001 From: Rex-BC Chen Date: Thu, 27 May 2021 21:10:17 +0800 Subject: soc/mediatek: Move the SSPM driver to common The SSPM driver can be shared by MT8183, MT8192 and MT8195. TEST=emerge-{asurada, kukui} coreboot; Signed-off-by: Rex-BC Chen Change-Id: If9779853becb298eeeabb3dc6096bc474baae202 Reviewed-on: https://review.coreboot.org/c/coreboot/+/55050 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/soc/mediatek/common/include/soc/sspm.h | 14 ++++++++++++++ src/soc/mediatek/common/sspm.c | 25 +++++++++++++++++++++++++ src/soc/mediatek/mt8183/Makefile.inc | 2 +- src/soc/mediatek/mt8183/include/soc/sspm.h | 14 -------------- src/soc/mediatek/mt8183/sspm.c | 25 ------------------------- src/soc/mediatek/mt8192/Makefile.inc | 2 +- src/soc/mediatek/mt8192/include/soc/sspm.h | 14 -------------- src/soc/mediatek/mt8192/sspm.c | 25 ------------------------- 8 files changed, 41 insertions(+), 80 deletions(-) create mode 100644 src/soc/mediatek/common/include/soc/sspm.h create mode 100644 src/soc/mediatek/common/sspm.c delete mode 100644 src/soc/mediatek/mt8183/include/soc/sspm.h delete mode 100644 src/soc/mediatek/mt8183/sspm.c delete mode 100644 src/soc/mediatek/mt8192/include/soc/sspm.h delete mode 100644 src/soc/mediatek/mt8192/sspm.c (limited to 'src/soc') diff --git a/src/soc/mediatek/common/include/soc/sspm.h b/src/soc/mediatek/common/include/soc/sspm.h new file mode 100644 index 0000000000..ff405ce762 --- /dev/null +++ b/src/soc/mediatek/common/include/soc/sspm.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_COMMON_SSPM_H +#define SOC_MEDIATEK_COMMON_SSPM_H + +#include +#include + +struct sspm_regs { + u32 sw_rstn; +}; +static struct sspm_regs *const sspm_reg = (void *)SSPM_CFG_BASE; +void sspm_init(void); +#endif /* SOC_MEDIATEK_COMMON_SSPM_H */ diff --git a/src/soc/mediatek/common/sspm.c b/src/soc/mediatek/common/sspm.c new file mode 100644 index 0000000000..0a4d5b0cd6 --- /dev/null +++ b/src/soc/mediatek/common/sspm.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +static void reset_sspm(struct mtk_mcu *mcu) +{ + write32(&sspm_reg->sw_rstn, 0x1); +} + +static struct mtk_mcu sspm = { + .firmware_name = CONFIG_SSPM_FIRMWARE, + .run_address = (void *)SSPM_SRAM_BASE, + .reset = reset_sspm, +}; + +void sspm_init(void) +{ + sspm.load_buffer = _dram_dma; + sspm.buffer_size = REGION_SIZE(dram_dma); + + mtk_init_mcu(&sspm); +} diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc index e0ec81012b..2cf813316b 100644 --- a/src/soc/mediatek/mt8183/Makefile.inc +++ b/src/soc/mediatek/mt8183/Makefile.inc @@ -58,7 +58,7 @@ ramstage-y += ../common/rtc.c ../common/rtc_osc_init.c rtc.c ramstage-y += soc.c ramstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c ramstage-y += spm.c -ramstage-y += sspm.c +ramstage-y += ../common/sspm.c ramstage-y += ../common/timer.c ramstage-y += ../common/uart.c ramstage-y += ../common/usb.c diff --git a/src/soc/mediatek/mt8183/include/soc/sspm.h b/src/soc/mediatek/mt8183/include/soc/sspm.h deleted file mode 100644 index 23160a80d1..0000000000 --- a/src/soc/mediatek/mt8183/include/soc/sspm.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef SOC_MEDIATEK_MT8183_SSPM_H -#define SOC_MEDIATEK_MT8183_SSPM_H - -#include -#include - -struct mt8183_sspm_regs { - u32 sw_rstn; -}; -static struct mt8183_sspm_regs *const mt8183_sspm = (void *)SSPM_CFG_BASE; -void sspm_init(void); -#endif /* SOC_MEDIATEK_MT8183_SSPM_H */ diff --git a/src/soc/mediatek/mt8183/sspm.c b/src/soc/mediatek/mt8183/sspm.c deleted file mode 100644 index e0ac84a1e3..0000000000 --- a/src/soc/mediatek/mt8183/sspm.c +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include - -static void reset_sspm(struct mtk_mcu *mcu) -{ - write32(&mt8183_sspm->sw_rstn, 0x1); -} - -static struct mtk_mcu sspm = { - .firmware_name = CONFIG_SSPM_FIRMWARE, - .run_address = (void *)SSPM_SRAM_BASE, - .reset = reset_sspm, -}; - -void sspm_init(void) -{ - sspm.load_buffer = _dram_dma; - sspm.buffer_size = REGION_SIZE(dram_dma); - - mtk_init_mcu(&sspm); -} diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc index bdff835c0e..0943e7c87d 100644 --- a/src/soc/mediatek/mt8192/Makefile.inc +++ b/src/soc/mediatek/mt8192/Makefile.inc @@ -61,7 +61,7 @@ ramstage-y += ../common/pmif.c ramstage-y += ../common/rtc.c ../common/rtc_mt6359p.c ramstage-y += soc.c ramstage-y += spm.c -ramstage-y += sspm.c +ramstage-y += ../common/sspm.c ramstage-y += ../common/timer.c ramstage-y += ../common/uart.c ramstage-y += ../common/ufs.c diff --git a/src/soc/mediatek/mt8192/include/soc/sspm.h b/src/soc/mediatek/mt8192/include/soc/sspm.h deleted file mode 100644 index 5749fa4be3..0000000000 --- a/src/soc/mediatek/mt8192/include/soc/sspm.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef SOC_MEDIATEK_MT8192_SSPM_H -#define SOC_MEDIATEK_MT8192_SSPM_H - -#include -#include - -struct mt8192_sspm_regs { - u32 sw_rstn; -}; -static struct mt8192_sspm_regs *const mt8192_sspm = (void *)SSPM_CFG_BASE; -void sspm_init(void); -#endif /* SOC_MEDIATEK_MT8192_SSPM_H */ diff --git a/src/soc/mediatek/mt8192/sspm.c b/src/soc/mediatek/mt8192/sspm.c deleted file mode 100644 index cce08c2e2a..0000000000 --- a/src/soc/mediatek/mt8192/sspm.c +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include - -static void reset_sspm(struct mtk_mcu *mcu) -{ - write32(&mt8192_sspm->sw_rstn, 0x1); -} - -static struct mtk_mcu sspm = { - .firmware_name = CONFIG_SSPM_FIRMWARE, - .run_address = (void *)SSPM_SRAM_BASE, - .reset = reset_sspm, -}; - -void sspm_init(void) -{ - sspm.load_buffer = _dram_dma; - sspm.buffer_size = REGION_SIZE(dram_dma); - - mtk_init_mcu(&sspm); -} -- cgit v1.2.3