Attention is currently required from: Hung-Te Lin, Yidi Lin, Yu-Ping Wu.
Jarried Lin has uploaded this change for review. ( 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 --- A src/soc/mediatek/common/include/soc/snfc.h A src/soc/mediatek/common/snfc.c 2 files changed, 42 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/83989/1
diff --git a/src/soc/mediatek/common/include/soc/snfc.h b/src/soc/mediatek/common/include/soc/snfc.h new file mode 100644 index 0000000..84c7f15 --- /dev/null +++ b/src/soc/mediatek/common/include/soc/snfc.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_COMMON_SNFC_H +#define SOC_MEDIATEK_COMMON_SNFC_H + +#include <device/mmio.h> +#include <gpio.h> +#include <types.h> + +struct pad_func { + gpio_t gpio; + u8 func; + enum pull_select select; +}; + +void mtk_snfc_init_pad_func(const struct pad_func *pad_func, uint8_t drive_strength); + +#endif diff --git a/src/soc/mediatek/common/snfc.c b/src/soc/mediatek/common/snfc.c new file mode 100644 index 0000000..ed69b1d --- /dev/null +++ b/src/soc/mediatek/common/snfc.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <device/mmio.h> +#include <device/device.h> +#include <soc/snfc.h> +#include <symbols.h> +#include <types.h> + +void mtk_snfc_init_pad_func(const struct pad_func *pad_func, uint8_t drive_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, drive_strength) < 0) + printk(BIOS_ERR, + "%s: failed to set pin drive to 14 mA for %d\n", + __func__, pad_func->gpio.id); + else + printk(BIOS_DEBUG, "%s: got pin drive: %#x\n", __func__, + gpio_get_driving(pad_func->gpio)); +} + +