Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83989?usp=email )
Change subject: soc/mediatek: Move SNFC pad_func into MediaTek common directory ......................................................................
soc/mediatek: Move SNFC pad_func into MediaTek common directory
To reduce duplicate pad_func of MediaTek SoCs, move the pad_fun to a common directory.
TEST=Build pass BUG=b:317009620
Change-Id: I145233ef887a38251e8fc129b8357f236c5f7a2b Signed-off-by: Jarried Lin jarried.lin@mediatek.corp-partner.google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/83989 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Yu-Ping Wu yupingso@google.com Reviewed-by: Yidi Lin yidilin@google.com --- M src/soc/mediatek/common/flash_controller.c M src/soc/mediatek/common/include/soc/flash_controller_common.h 2 files changed, 26 insertions(+), 0 deletions(-)
Approvals: Yidi Lin: Looks good to me, approved build bot (Jenkins): Verified Yu-Ping Wu: Looks good to me, approved
diff --git a/src/soc/mediatek/common/flash_controller.c b/src/soc/mediatek/common/flash_controller.c index c4c758e..4eaa37d 100644 --- a/src/soc/mediatek/common/flash_controller.c +++ b/src/soc/mediatek/common/flash_controller.c @@ -223,3 +223,21 @@
return 0; } + +int mtk_snfc_init_pad_func(const struct mtk_snfc_pad_func *pad_func, 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); + + if (gpio_set_driving(pad_func->gpio, strength) < 0) { + printk(BIOS_ERR, + "%s: failed to set pin drive to %d for %d\n", + __func__, strength, pad_func->gpio.id); + return -1; + } + + printk(BIOS_DEBUG, "%s: got pin drive: %#x\n", __func__, + gpio_get_driving(pad_func->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 2da3805..c71ae17 100644 --- a/src/soc/mediatek/common/include/soc/flash_controller_common.h +++ b/src/soc/mediatek/common/include/soc/flash_controller_common.h @@ -3,6 +3,7 @@ #ifndef __SOC_MEDIATEK_COMMON_FLASH_CONTROLLER_COMMON_H__ #define __SOC_MEDIATEK_COMMON_FLASH_CONTROLLER_COMMON_H__
+#include <gpio.h> #include <spi-generic.h> #include <stdint.h> #include <soc/addressmap.h> @@ -75,6 +76,13 @@ }; 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);
#endif /* __SOC_MEDIATEK_COMMON_FLASH_CONTROLLER_COMMON_H__ */