summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJarried Lin <jarried.lin@mediatek.corp-partner.google.com>2024-08-20 15:40:44 +0800
committerFelix Held <felix-coreboot@felixheld.de>2024-08-24 12:55:52 +0000
commitb16ac8d28034b1275a2cde2b3144d82bfcaf801f (patch)
tree0d0d1dc2ddc8aca14183e518a910ea6ce303eb84 /src
parentc14cde65767c404dba9dbe5fdcac89fc64c43750 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/soc/mediatek/common/flash_controller.c18
-rw-r--r--src/soc/mediatek/common/include/soc/flash_controller_common.h8
2 files changed, 26 insertions, 0 deletions
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 <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__ */