diff options
author | Yidi Lin <yidilin@chromium.org> | 2024-09-05 17:10:33 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-09-12 16:57:11 +0000 |
commit | f3b698462975a5b23004affca45a6dd1a3ff46a6 (patch) | |
tree | a94a1af1b963d6140081e5c4b8c2e4d50304d974 /src/soc/mediatek/mt8196 | |
parent | ffc48178de6eee2e4efd33b4943f922475badc71 (diff) |
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 <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84222
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/mt8196')
-rw-r--r-- | src/soc/mediatek/mt8196/i2c.c | 69 | ||||
-rw-r--r-- | src/soc/mediatek/mt8196/spi.c | 12 |
2 files changed, 36 insertions, 45 deletions
diff --git a/src/soc/mediatek/mt8196/i2c.c b/src/soc/mediatek/mt8196/i2c.c index 94e3c3f0ba..c3d3ccb31c 100644 --- a/src/soc/mediatek/mt8196/i2c.c +++ b/src/soc/mediatek/mt8196/i2c.c @@ -93,73 +93,66 @@ struct mtk_i2c mtk_i2c_bus_controller[] = { _Static_assert(ARRAY_SIZE(mtk_i2c_bus_controller) == I2C_BUS_NUMBER, "Wrong size of mtk_i2c_bus_controller"); -struct pad_func { - gpio_t gpio; - u8 func; -}; - -#define PAD_FUNC(name, func) {GPIO(name), PAD_##name##_FUNC_##func} - static const struct pad_func i2c_funcs[I2C_BUS_NUMBER][2] = { [0] = { - PAD_FUNC(SDA0, SDA0), - PAD_FUNC(SCL0, SCL0), + PAD_FUNC_UP(SDA0, SDA0), + PAD_FUNC_UP(SCL0, SCL0), }, [1] = { - PAD_FUNC(SDA1, SDA1), - PAD_FUNC(SCL1, SCL1), + PAD_FUNC_UP(SDA1, SDA1), + PAD_FUNC_UP(SCL1, SCL1), }, [2] = { - PAD_FUNC(CAM_SDA2, SDA2), - PAD_FUNC(CAM_SCL2, SCL2), + PAD_FUNC_UP(CAM_SDA2, SDA2), + PAD_FUNC_UP(CAM_SCL2, SCL2), }, [3] = { - PAD_FUNC(SDA3, SDA3), - PAD_FUNC(SCL3, SCL3), + PAD_FUNC_UP(SDA3, SDA3), + PAD_FUNC_UP(SCL3, SCL3), }, [4] = { - PAD_FUNC(CAM_SDA4, SDA4), - PAD_FUNC(CAM_SCL4, SCL4), + PAD_FUNC_UP(CAM_SDA4, SDA4), + PAD_FUNC_UP(CAM_SCL4, SCL4), }, [5] = { - PAD_FUNC(SDA5, SDA5), - PAD_FUNC(SCL5, SCL5), + PAD_FUNC_UP(SDA5, SDA5), + PAD_FUNC_UP(SCL5, SCL5), }, [6] = { - PAD_FUNC(SDA6, SDA6), - PAD_FUNC(SCL6, SCL6), + PAD_FUNC_UP(SDA6, SDA6), + PAD_FUNC_UP(SCL6, SCL6), }, [7] = { - PAD_FUNC(CAM_SDA7, SDA7), - PAD_FUNC(CAM_SCL7, SCL7), + PAD_FUNC_UP(CAM_SDA7, SDA7), + PAD_FUNC_UP(CAM_SCL7, SCL7), }, [8] = { - PAD_FUNC(CAM_SDA8, SDA8), - PAD_FUNC(CAM_SCL8, SCL8), + PAD_FUNC_UP(CAM_SDA8, SDA8), + PAD_FUNC_UP(CAM_SCL8, SCL8), }, [9] = { - PAD_FUNC(CAM_SDA9, SDA9), - PAD_FUNC(CAM_SCL9, SCL9), + PAD_FUNC_UP(CAM_SDA9, SDA9), + PAD_FUNC_UP(CAM_SCL9, SCL9), }, [10] = { - PAD_FUNC(SDA10, SDA10), - PAD_FUNC(SCL10, SCL10), + PAD_FUNC_UP(SDA10, SDA10), + PAD_FUNC_UP(SCL10, SCL10), }, [11] = { - PAD_FUNC(CAM_PDN3, SDA11), - PAD_FUNC(CAM_PDN2, SCL11), + PAD_FUNC_UP(CAM_PDN3, SDA11), + PAD_FUNC_UP(CAM_PDN2, SCL11), }, [12] = { - PAD_FUNC(CAM_PDN5, SDA12), - PAD_FUNC(CAM_PDN4, SCL12), + PAD_FUNC_UP(CAM_PDN5, SDA12), + PAD_FUNC_UP(CAM_PDN4, SCL12), }, [13] = { - PAD_FUNC(CAM_PDN7, SDA13), - PAD_FUNC(CAM_PDN6, SCL13), + PAD_FUNC_UP(CAM_PDN7, SDA13), + PAD_FUNC_UP(CAM_PDN6, SCL13), }, [14] = { - PAD_FUNC(SCP_SDA3, SDA14), - PAD_FUNC(SCP_SCL3, SCL14), + PAD_FUNC_UP(SCP_SDA3, SDA14), + PAD_FUNC_UP(SCP_SCL3, SCL14), }, }; @@ -171,7 +164,7 @@ static void mtk_i2c_set_gpio_pinmux(uint8_t bus) for (size_t i = 0; i < 2; i++) { gpio_set_mode(ptr[i].gpio, ptr[i].func); - gpio_set_pull(ptr[i].gpio, GPIO_PULL_ENABLE, GPIO_PULL_UP); + gpio_set_pull(ptr[i].gpio, GPIO_PULL_ENABLE, ptr[i].select); } } diff --git a/src/soc/mediatek/mt8196/spi.c b/src/soc/mediatek/mt8196/spi.c index 09cd073f8a..770b5b0954 100644 --- a/src/soc/mediatek/mt8196/spi.c +++ b/src/soc/mediatek/mt8196/spi.c @@ -12,13 +12,11 @@ #include <soc/spi.h> #include <spi_flash.h> -#define PAD_FUNC_SEL(name, func, sel) {GPIO(name), PAD_##name##_FUNC_##func, sel} - -static const struct mtk_snfc_pad_func nor_pinmux[4] = { - PAD_FUNC_SEL(SDA10, SF_CK, GPIO_PULL_DOWN), - PAD_FUNC_SEL(SCL10, SF_CS, GPIO_PULL_UP), - PAD_FUNC_SEL(PERIPHERAL_EN5, SF_D0, GPIO_PULL_DOWN), - PAD_FUNC_SEL(PERIPHERAL_EN6, SF_D1, GPIO_PULL_DOWN), +static const struct pad_func nor_pinmux[4] = { + PAD_FUNC(SDA10, SF_CK, GPIO_PULL_DOWN), + PAD_FUNC(SCL10, SF_CS, GPIO_PULL_UP), + PAD_FUNC(PERIPHERAL_EN5, SF_D0, GPIO_PULL_DOWN), + PAD_FUNC(PERIPHERAL_EN6, SF_D1, GPIO_PULL_DOWN), }; void mtk_snfc_init(void) |