From b16ac8d28034b1275a2cde2b3144d82bfcaf801f Mon Sep 17 00:00:00 2001 From: Jarried Lin Date: Tue, 20 Aug 2024 15:40:44 +0800 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/83989 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu Reviewed-by: Yidi Lin --- src/soc/mediatek/common/flash_controller.c | 18 ++++++++++++++++++ .../common/include/soc/flash_controller_common.h | 8 ++++++++ 2 files changed, 26 insertions(+) (limited to 'src/soc/mediatek/common') diff --git a/src/soc/mediatek/common/flash_controller.c b/src/soc/mediatek/common/flash_controller.c index c4c758ef19..4eaa37d3c3 100644 --- a/src/soc/mediatek/common/flash_controller.c +++ b/src/soc/mediatek/common/flash_controller.c @@ -223,3 +223,21 @@ int mtk_spi_flash_probe(const struct spi_slave *spi, 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 2da3805da1..c71ae1773d 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 #include #include #include @@ -75,6 +76,13 @@ struct mtk_nor_regs { }; 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__ */ -- cgit v1.2.3