summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8188/gpio.c
diff options
context:
space:
mode:
authorGuodong Liu <guodong.liu@mediatek.corp-partner.google.com>2022-06-11 10:37:47 +0800
committerFelix Held <felix-coreboot@felixheld.de>2022-07-06 15:32:23 +0000
commitccaafdfa5a9834a43134f0b5d0bafd8a0748eec6 (patch)
tree03ed43590c4c05afbbca0f59816c3de500e7ffce /src/soc/mediatek/mt8188/gpio.c
parentb4c5aed0a6b06e49f97d76755b17d292a36cad4c (diff)
soc/mediatek/mt8188: Add GPIO drivers
Add GPIO drivers to let other module control GPIOs. TEST=build pass BUG=b:233720142 Signed-off-by: Guodong Liu <guodong.liu@mediatek.corp-partner.google.com> Change-Id: I0a2a5178949e9ad3e033ac332e0f1e8565e39b3d Reviewed-on: https://review.coreboot.org/c/coreboot/+/65619 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Yidi Lin <yidilin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/mediatek/mt8188/gpio.c')
-rw-r--r--src/soc/mediatek/mt8188/gpio.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/soc/mediatek/mt8188/gpio.c b/src/soc/mediatek/mt8188/gpio.c
new file mode 100644
index 0000000000..4c4ee31edc
--- /dev/null
+++ b/src/soc/mediatek/mt8188/gpio.c
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * This file is created based on MT8188 Functional Specification
+ * Chapter number: 5.2
+ */
+
+#include <device/mmio.h>
+#include <gpio.h>
+
+void *gpio_find_reg_addr(gpio_t gpio)
+{
+ void *reg_addr;
+ switch (gpio.base & 0x0f) {
+ case 1:
+ reg_addr = (void *)IOCFG_RM_BASE;
+ break;
+ case 2:
+ reg_addr = (void *)IOCFG_LT_BASE;
+ break;
+ case 3:
+ reg_addr = (void *)IOCFG_LM_BASE;
+ break;
+ case 4:
+ reg_addr = (void *)IOCFG_RT_BASE;
+ break;
+ default:
+ reg_addr = NULL;
+ break;
+ }
+
+ return reg_addr;
+}