From f3b698462975a5b23004affca45a6dd1a3ff46a6 Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Thu, 5 Sep 2024 17:10:33 +0800 Subject: soc/mediatek: Remove redundant struct pad_func and PAD_* definitions Clean up redundant `struct pad_func` and `PAD_*` definitions. This patch also refactors the PAD_* macros by, - Repurposing PAD_FUNC and dropping PAD_FUNC_SEL. - Adding PAD_FUNC_DOWN and PAD_FUNC_UP to avoid the implicit initialization. BUG=none TEST=emerge-{elm, kukui, asurada, cherry, corsola, geralt, rauru} coreboot Change-Id: I12b8f6749015bff52988208a7c3aa01e952612c6 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/84222 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/soc/mediatek/mt8192/spi.c | 58 +++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'src/soc/mediatek/mt8192/spi.c') diff --git a/src/soc/mediatek/mt8192/spi.c b/src/soc/mediatek/mt8192/spi.c index 42e5b4aaa9..2b31d28baa 100644 --- a/src/soc/mediatek/mt8192/spi.c +++ b/src/soc/mediatek/mt8192/spi.c @@ -42,62 +42,54 @@ struct mtk_spi_bus spi_bus[SPI_BUS_NUMBER] = { } }; -struct pad_func { - u8 pin_id; - u8 func; -}; - -#define PAD_FUNC(name, func) {PAD_##name##_ID, PAD_##name##_FUNC_##func} -#define PAD_FUNC_GPIO(name) {PAD_##name##_ID, 0} - static const struct pad_func pad0_funcs[SPI_BUS_NUMBER][4] = { { - PAD_FUNC(SPI0_MI, SPI0_A_MI), + PAD_FUNC_DOWN(SPI0_MI, SPI0_A_MI), PAD_FUNC_GPIO(SPI0_CSB), - PAD_FUNC(SPI0_MO, SPI0_A_MO), - PAD_FUNC(SPI0_CLK, SPI0_A_CLK), + PAD_FUNC_DOWN(SPI0_MO, SPI0_A_MO), + PAD_FUNC_DOWN(SPI0_CLK, SPI0_A_CLK), }, { - PAD_FUNC(SPI1_MI, SPI1_A_MI), + PAD_FUNC_DOWN(SPI1_MI, SPI1_A_MI), PAD_FUNC_GPIO(SPI1_CSB), - PAD_FUNC(SPI1_MO, SPI1_A_MO), - PAD_FUNC(SPI1_CLK, SPI1_A_CLK), + PAD_FUNC_DOWN(SPI1_MO, SPI1_A_MO), + PAD_FUNC_DOWN(SPI1_CLK, SPI1_A_CLK), }, { - PAD_FUNC(SCP_SPI2_MI, SPI2_MI), + PAD_FUNC_DOWN(SCP_SPI2_MI, SPI2_MI), PAD_FUNC_GPIO(SCP_SPI2_CSB), - PAD_FUNC(SCP_SPI2_MO, SPI2_MO), - PAD_FUNC(SCP_SPI2_CK, SPI2_CLK), + PAD_FUNC_DOWN(SCP_SPI2_MO, SPI2_MO), + PAD_FUNC_DOWN(SCP_SPI2_CK, SPI2_CLK), }, { - PAD_FUNC(CAM_RST2, SPI3_MI), + PAD_FUNC_DOWN(CAM_RST2, SPI3_MI), PAD_FUNC_GPIO(CAM_RST1), - PAD_FUNC(CAM_PDN0, SPI3_MO), - PAD_FUNC(CAM_RST0, SPI3_CLK), + PAD_FUNC_DOWN(CAM_PDN0, SPI3_MO), + PAD_FUNC_DOWN(CAM_RST0, SPI3_CLK), }, { - PAD_FUNC(EINT6, SPI4_A_MI), + PAD_FUNC_DOWN(EINT6, SPI4_A_MI), PAD_FUNC_GPIO(EINT5), - PAD_FUNC(EINT7, SPI4_A_MO), - PAD_FUNC(EINT4, SPI4_A_CLK), + PAD_FUNC_DOWN(EINT7, SPI4_A_MO), + PAD_FUNC_DOWN(EINT4, SPI4_A_CLK), }, { - PAD_FUNC(SPI5_MI, SPI5_A_MI), + PAD_FUNC_DOWN(SPI5_MI, SPI5_A_MI), PAD_FUNC_GPIO(SPI5_CSB), - PAD_FUNC(SPI5_MO, SPI5_A_MO), - PAD_FUNC(SPI5_CLK, SPI5_A_CLK), + PAD_FUNC_DOWN(SPI5_MO, SPI5_A_MO), + PAD_FUNC_DOWN(SPI5_CLK, SPI5_A_CLK), }, { - PAD_FUNC(EINT2, SPI6_MI), + PAD_FUNC_DOWN(EINT2, SPI6_MI), PAD_FUNC_GPIO(EINT1), - PAD_FUNC(EINT3, SPI6_MO), - PAD_FUNC(EINT0, SPI6_CLK), + PAD_FUNC_DOWN(EINT3, SPI6_MO), + PAD_FUNC_DOWN(EINT0, SPI6_CLK), }, { - PAD_FUNC(EINT16, SPI7_A_MI), + PAD_FUNC_DOWN(EINT16, SPI7_A_MI), PAD_FUNC_GPIO(SDA0), - PAD_FUNC(EINT17, SPI7_A_MO), - PAD_FUNC(SCL0, SPI7_A_CLK), + PAD_FUNC_DOWN(EINT17, SPI7_A_MO), + PAD_FUNC_DOWN(SCL0, SPI7_A_CLK), } }; @@ -109,7 +101,7 @@ void mtk_spi_set_gpio_pinmux(unsigned int bus, enum spi_pad_mask pad_select) ptr = pad0_funcs[bus]; for (int i = 0; i < 4; i++) - gpio_set_mode((gpio_t){.id = ptr[i].pin_id}, ptr[i].func); + gpio_set_mode(ptr[i].gpio, ptr[i].func); } static const struct spi_ctrlr spi_flash_ctrlr = { -- cgit v1.2.3