Attention is currently required from: Hung-Te Lin, Xi Chen, Yu-Ping Wu.
Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84222?usp=email )
Change subject: soc/mediatek: Remove redundant struct pad_func and PAD_* definitions ......................................................................
soc/mediatek: Remove redundant struct pad_func and PAD_* definitions
Clean up redundant `struct pad_func` and `PAD_*` definitions.
BUG=none TEST=emerge-{elm, kukui, asurada, cherry, corsola, geralt, rauru} coreboot
Change-Id: I12b8f6749015bff52988208a7c3aa01e952612c6 Signed-off-by: Yidi Lin yidilin@chromium.org --- M src/mainboard/google/cherry/bootblock.c M src/soc/mediatek/common/flash_controller.c M src/soc/mediatek/common/include/soc/flash_controller_common.h M src/soc/mediatek/common/include/soc/gpio_common.h M src/soc/mediatek/mt8183/i2c.c M src/soc/mediatek/mt8183/spi.c M src/soc/mediatek/mt8186/i2c.c M src/soc/mediatek/mt8186/spi.c M src/soc/mediatek/mt8188/i2c.c M src/soc/mediatek/mt8188/spi.c M src/soc/mediatek/mt8192/i2c.c M src/soc/mediatek/mt8192/spi.c M src/soc/mediatek/mt8195/i2c.c M src/soc/mediatek/mt8195/pcie.c M src/soc/mediatek/mt8195/spi.c M src/soc/mediatek/mt8196/i2c.c M src/soc/mediatek/mt8196/spi.c 17 files changed, 23 insertions(+), 122 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/84222/1
diff --git a/src/mainboard/google/cherry/bootblock.c b/src/mainboard/google/cherry/bootblock.c index 5091dcc..ddeb537 100644 --- a/src/mainboard/google/cherry/bootblock.c +++ b/src/mainboard/google/cherry/bootblock.c @@ -9,13 +9,6 @@
#include "gpio.h"
-struct pad_func { - u8 pin_id; - u8 func; -}; - -#define PAD_FUNC(name, func) {PAD_##name##_ID, PAD_##name##_FUNC_##func} - static void nor_set_gpio_pinmux(void) { const struct pad_func *ptr = NULL; @@ -30,9 +23,8 @@
ptr = nor_pinmux; for (size_t i = 0; i < ARRAY_SIZE(nor_pinmux); i++) { - gpio_set_pull((gpio_t){.id = ptr[i].pin_id}, - GPIO_PULL_ENABLE, GPIO_PULL_UP); - gpio_set_mode((gpio_t){.id = ptr[i].pin_id}, ptr[i].func); + gpio_set_pull(ptr[i].gpio, GPIO_PULL_ENABLE, GPIO_PULL_UP); + gpio_set_mode(ptr[i].gpio, ptr[i].func); } }
diff --git a/src/soc/mediatek/common/flash_controller.c b/src/soc/mediatek/common/flash_controller.c index 4eaa37d..4f0d4b0 100644 --- a/src/soc/mediatek/common/flash_controller.c +++ b/src/soc/mediatek/common/flash_controller.c @@ -224,20 +224,20 @@ return 0; }
-int mtk_snfc_init_pad_func(const struct mtk_snfc_pad_func *pad_func, enum gpio_drv strength) +int mtk_snfc_init_pad_func(const struct pad_func *pad, enum gpio_drv strength) { - gpio_set_pull(pad_func->gpio, GPIO_PULL_ENABLE, pad_func->select); - gpio_set_mode(pad_func->gpio, pad_func->func); + gpio_set_pull(pad->gpio, GPIO_PULL_ENABLE, pad->select); + gpio_set_mode(pad->gpio, pad->func);
- if (gpio_set_driving(pad_func->gpio, strength) < 0) { + if (gpio_set_driving(pad->gpio, strength) < 0) { printk(BIOS_ERR, "%s: failed to set pin drive to %d for %d\n", - __func__, strength, pad_func->gpio.id); + __func__, strength, pad->gpio.id); return -1; }
printk(BIOS_DEBUG, "%s: got pin drive: %#x\n", __func__, - gpio_get_driving(pad_func->gpio)); + gpio_get_driving(pad->gpio));
return 0; } diff --git a/src/soc/mediatek/common/include/soc/flash_controller_common.h b/src/soc/mediatek/common/include/soc/flash_controller_common.h index c71ae17..69ff3c7 100644 --- a/src/soc/mediatek/common/include/soc/flash_controller_common.h +++ b/src/soc/mediatek/common/include/soc/flash_controller_common.h @@ -76,13 +76,7 @@ }; check_member(mtk_nor_regs, fdma_end_dadr, 0x724);
-struct mtk_snfc_pad_func { - gpio_t gpio; - u8 func; - enum pull_select select; -}; - int mtk_spi_flash_probe(const struct spi_slave *spi, struct spi_flash *flash); -int mtk_snfc_init_pad_func(const struct mtk_snfc_pad_func *pad_func, enum gpio_drv strength); +int mtk_snfc_init_pad_func(const struct pad_func *pad, enum gpio_drv strength);
#endif /* __SOC_MEDIATEK_COMMON_FLASH_CONTROLLER_COMMON_H__ */ diff --git a/src/soc/mediatek/common/include/soc/gpio_common.h b/src/soc/mediatek/common/include/soc/gpio_common.h index 870dac5..2fc850a 100644 --- a/src/soc/mediatek/common/include/soc/gpio_common.h +++ b/src/soc/mediatek/common/include/soc/gpio_common.h @@ -50,6 +50,16 @@ uint8_t width; };
+struct pad_func { + gpio_t gpio; + u8 func; + enum pull_select select; +}; + +#define PAD_FUNC(name, func) { GPIO(name), PAD_##name##_FUNC_##func } +#define PAD_FUNC_GPIO(name) { GPIO(name), 0 } +#define PAD_FUNC_SEL(name, func, sel) { GPIO(name), PAD_##name##_FUNC_##func, sel } + void gpio_set_pull(gpio_t gpio, enum pull_enable enable, enum pull_select select); void gpio_set_mode(gpio_t gpio, int mode); diff --git a/src/soc/mediatek/mt8183/i2c.c b/src/soc/mediatek/mt8183/i2c.c index 8bd7c36..ec7c169 100644 --- a/src/soc/mediatek/mt8183/i2c.c +++ b/src/soc/mediatek/mt8183/i2c.c @@ -53,13 +53,6 @@ _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] = { { PAD_FUNC(SDA0, SDA0), diff --git a/src/soc/mediatek/mt8183/spi.c b/src/soc/mediatek/mt8183/spi.c index 9404f93..2105d26 100644 --- a/src/soc/mediatek/mt8183/spi.c +++ b/src/soc/mediatek/mt8183/spi.c @@ -35,14 +35,6 @@ } };
-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(SPI_MI, SPI0_MI), @@ -100,7 +92,7 @@ ptr = bus1_pad1_funcs; } 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); }
const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = { diff --git a/src/soc/mediatek/mt8186/i2c.c b/src/soc/mediatek/mt8186/i2c.c index 9e7e4b3..d33fdad 100644 --- a/src/soc/mediatek/mt8186/i2c.c +++ b/src/soc/mediatek/mt8186/i2c.c @@ -58,13 +58,6 @@ _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), diff --git a/src/soc/mediatek/mt8186/spi.c b/src/soc/mediatek/mt8186/spi.c index adbd437..9f912ad 100644 --- a/src/soc/mediatek/mt8186/spi.c +++ b/src/soc/mediatek/mt8186/spi.c @@ -41,16 +41,6 @@ } };
-struct pad_func { - gpio_t gpio; - u8 func; - enum pull_select select; -}; - -#define PAD_FUNC(name, func) {GPIO(name), PAD_##name##_FUNC_##func, GPIO_PULL_DOWN} -#define PAD_FUNC_SEL(name, func, sel) {GPIO(name), PAD_##name##_FUNC_##func, sel} -#define PAD_FUNC_GPIO(name) {GPIO(name), 0, GPIO_PULL_DOWN} - static const struct pad_func pad0_funcs[SPI_BUS_NUMBER][4] = { { PAD_FUNC(SPI0_MI, SPI0_MI_A), diff --git a/src/soc/mediatek/mt8188/i2c.c b/src/soc/mediatek/mt8188/i2c.c index 1de37c5..5d5ba37 100644 --- a/src/soc/mediatek/mt8188/i2c.c +++ b/src/soc/mediatek/mt8188/i2c.c @@ -53,13 +53,6 @@ _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), diff --git a/src/soc/mediatek/mt8188/spi.c b/src/soc/mediatek/mt8188/spi.c index 0596bb9..2e7052f 100644 --- a/src/soc/mediatek/mt8188/spi.c +++ b/src/soc/mediatek/mt8188/spi.c @@ -41,16 +41,6 @@ }, };
-struct pad_func { - gpio_t gpio; - u8 func; - enum pull_select select; -}; - -#define PAD_FUNC_SEL(name, func, sel) {GPIO(name), PAD_##name##_FUNC_##func, sel} -#define PAD_FUNC(name, func) {GPIO(name), PAD_##name##_FUNC_##func} -#define PAD_FUNC_GPIO(name) {GPIO(name), 0} - static const struct pad_func pad_funcs[SPI_BUS_NUMBER][4] = { { PAD_FUNC(SPIM0_MISO, SPIM0_MISO), diff --git a/src/soc/mediatek/mt8192/i2c.c b/src/soc/mediatek/mt8192/i2c.c index a3f236a..a044b184 100644 --- a/src/soc/mediatek/mt8192/i2c.c +++ b/src/soc/mediatek/mt8192/i2c.c @@ -66,13 +66,6 @@ _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), diff --git a/src/soc/mediatek/mt8192/spi.c b/src/soc/mediatek/mt8192/spi.c index 42e5b4a..45e941f 100644 --- a/src/soc/mediatek/mt8192/spi.c +++ b/src/soc/mediatek/mt8192/spi.c @@ -42,14 +42,6 @@ } };
-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), @@ -109,7 +101,7 @@
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 = { diff --git a/src/soc/mediatek/mt8195/i2c.c b/src/soc/mediatek/mt8195/i2c.c index e404107..e49f1f9 100644 --- a/src/soc/mediatek/mt8195/i2c.c +++ b/src/soc/mediatek/mt8195/i2c.c @@ -53,13 +53,6 @@ _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), diff --git a/src/soc/mediatek/mt8195/pcie.c b/src/soc/mediatek/mt8195/pcie.c index 2676207..1c93d46 100644 --- a/src/soc/mediatek/mt8195/pcie.c +++ b/src/soc/mediatek/mt8195/pcie.c @@ -10,13 +10,6 @@
#define PCIE_REG_BASE_PORT0 0x112f0000
-struct pad_func { - gpio_t gpio; - u8 func; -}; - -#define PAD_FUNC(name, func) {GPIO(name), PAD_##name##_FUNC_##func} - static const struct pad_func pcie_pins[2][3] = { { PAD_FUNC(PCIE_WAKE_N, WAKEN), diff --git a/src/soc/mediatek/mt8195/spi.c b/src/soc/mediatek/mt8195/spi.c index 98b0d54..016cc29 100644 --- a/src/soc/mediatek/mt8195/spi.c +++ b/src/soc/mediatek/mt8195/spi.c @@ -34,14 +34,6 @@ }, };
-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(SPIM0_MI, SPIM0_MI), @@ -89,7 +81,7 @@
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 = { diff --git a/src/soc/mediatek/mt8196/i2c.c b/src/soc/mediatek/mt8196/i2c.c index 94e3c3f..3a2f9ed 100644 --- a/src/soc/mediatek/mt8196/i2c.c +++ b/src/soc/mediatek/mt8196/i2c.c @@ -93,13 +93,6 @@ _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), diff --git a/src/soc/mediatek/mt8196/spi.c b/src/soc/mediatek/mt8196/spi.c index 09cd073..1a760e7 100644 --- a/src/soc/mediatek/mt8196/spi.c +++ b/src/soc/mediatek/mt8196/spi.c @@ -12,9 +12,7 @@ #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] = { +static const struct 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),