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>
This commit is contained in:
Jarried Lin 2024-08-20 15:40:44 +08:00 committed by Felix Held
commit b16ac8d280
2 changed files with 26 additions and 0 deletions

View file

@ -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;
}

View file

@ -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 @@ 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__ */