summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Lin <tim2.lin@ite.corp-partner.google.com>2021-12-16 11:32:40 +0800
committerCommit Bot <commit-bot@chromium.org>2022-01-14 20:31:04 +0000
commitfa52c86e529e1447479c21325858d923118c476f (patch)
treee737c04d8d28f1144901f37fd3c35e493a406ede
parentbc7e2e97557a00c1ba8eb32f7811594f990664e6 (diff)
downloadchrome-ec-fa52c86e529e1447479c21325858d923118c476f.tar.gz
zephyr: it8xxx2: pinmux: read pinctrl-0 property instead of hardcoding
The parameters in pinmux_pin_set() are read by pinctrl-0 property instead of hardcoding. Since the i2c alternate function will be set to GPIO input in shim:gpio.c if gpio.dts has a corresponding set. So it must be set back to i2c alternate. BUG=b:210800948 BRANCH=none TEST=zmake configure -b zephyr/projects/it8xxx2_evb/ Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Change-Id: I079f4091ef7627d252a435107ef39b0363265faf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3346769 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/shim/chip/it8xxx2/pinmux.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/zephyr/shim/chip/it8xxx2/pinmux.c b/zephyr/shim/chip/it8xxx2/pinmux.c
index fd8dc7fc8e..3e00f7ce5a 100644
--- a/zephyr/shim/chip/it8xxx2/pinmux.c
+++ b/zephyr/shim/chip/it8xxx2/pinmux.c
@@ -8,6 +8,15 @@
#include <dt-bindings/pinctrl/it8xxx2-pinctrl.h>
#include <soc.h>
+#define SCL 0
+#define SDA 1
+#define IT8XXX2_I2C_DEV_PINMUX(node, signal) DEVICE_DT_GET(DT_PHANDLE( \
+ DT_PINCTRL_BY_IDX(DT_NODELABEL(node), 0, signal), pinctrls))
+#define IT8XXX2_I2C_DEV_PIN(node, signal) DT_PHA( \
+ DT_PINCTRL_BY_IDX(DT_NODELABEL(node), 0, signal), pinctrls, pin)
+#define IT8XXX2_I2C_DEV_ALT_FUNC(node, signal) DT_PHA( \
+ DT_PINCTRL_BY_IDX(DT_NODELABEL(node), 0, signal), pinctrls, alt_func)
+
static int it8xxx2_pinmux_init(const struct device *dev)
{
ARG_UNUSED(dev);
@@ -70,17 +79,21 @@ static int it8xxx2_pinmux_init_latr(const struct device *dev)
pinmux_pin_set(portf, 7, IT8XXX2_PINMUX_FUNC_1);
}
#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c3), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxh), okay)
- {
- const struct device *porth =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxh));
+#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c3), okay)
+ /* Pinmux control group */
+ const struct device *clk_pinctrls = IT8XXX2_I2C_DEV_PINMUX(i2c3, SCL);
+ const struct device *dat_pinctrls = IT8XXX2_I2C_DEV_PINMUX(i2c3, SDA);
+ /* GPIO pin */
+ uint8_t clk_pin = IT8XXX2_I2C_DEV_PIN(i2c3, SCL);
+ uint8_t dat_pin = IT8XXX2_I2C_DEV_PIN(i2c3, SDA);
+ /* Alternate function */
+ uint8_t clk_alt = IT8XXX2_I2C_DEV_ALT_FUNC(i2c3, SCL);
+ uint8_t dat_alt = IT8XXX2_I2C_DEV_ALT_FUNC(i2c3, SDA);
- /* I2C3 CLK */
- pinmux_pin_set(porth, 1, IT8XXX2_PINMUX_FUNC_3);
- /* I2C3 DAT */
- pinmux_pin_set(porth, 2, IT8XXX2_PINMUX_FUNC_3);
- }
+ /* I2C3 CLK */
+ pinmux_pin_set(clk_pinctrls, clk_pin, clk_alt);
+ /* I2C3 DAT */
+ pinmux_pin_set(dat_pinctrls, dat_pin, dat_alt);
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c4), okay) && \
DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxe), okay)