summaryrefslogtreecommitdiff
path: root/app/boards/arm/mikoto/pinmux.c
diff options
context:
space:
mode:
authorHai-Ninh Dang <30751439+mrninhvn@users.noreply.github.com>2021-11-09 12:57:24 +0700
committerGitHub <noreply@github.com>2021-11-09 00:57:24 -0500
commitf2e0642291621611f3abce69f73a22c33b1ce801 (patch)
treeb19c681188373e28fc7e03b9f8366a99c11a5d96 /app/boards/arm/mikoto/pinmux.c
parent944f93170454008759200a27a11225da40935edf (diff)
feat(boards): Add Mikoto board
* Supports selecting from several possible charge currents Co-authored-by: Pete Johanson <peter@peterjohanson.com>
Diffstat (limited to 'app/boards/arm/mikoto/pinmux.c')
-rw-r--r--app/boards/arm/mikoto/pinmux.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/boards/arm/mikoto/pinmux.c b/app/boards/arm/mikoto/pinmux.c
new file mode 100644
index 0000000..59a38fb
--- /dev/null
+++ b/app/boards/arm/mikoto/pinmux.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <kernel.h>
+#include <device.h>
+#include <init.h>
+#include <drivers/gpio.h>
+#include <sys/sys_io.h>
+#include <devicetree.h>
+
+static int pinmux_mikoto_init(const struct device *port) {
+ ARG_UNUSED(port);
+
+#if CONFIG_BOARD_MIKOTO_520
+ const struct device *p0 = device_get_binding("GPIO_0");
+ const struct device *p1 = device_get_binding("GPIO_1");
+#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_40MA
+ gpio_pin_configure(p0, 26, GPIO_INPUT | GPIO_PULL_DOWN);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_100MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_150MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_INPUT | GPIO_PULL_DOWN);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_250MA
+ gpio_pin_configure(p0, 26, GPIO_INPUT);
+ gpio_pin_configure(p1, 15, GPIO_OUTPUT);
+ gpio_pin_set(p1, 15, 0);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_350MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_OUTPUT);
+ gpio_pin_set(p1, 15, 0);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_NONE
+ gpio_pin_configure(p0, 26, GPIO_INPUT);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#endif
+#endif
+ return 0;
+}
+
+SYS_INIT(pinmux_mikoto_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);