diff options
author | Dino Li <Dino.Li@ite.com.tw> | 2021-04-29 11:04:29 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-13 16:08:35 +0000 |
commit | 87c7879c6848263c56cdc29e6bf53cef1e50e936 (patch) | |
tree | 596f7f573fcb762415a235dcd49e0c5eba1673f6 | |
parent | c975b4c6eeff51b3ed9958d59058e2b9cbfc3cb3 (diff) | |
download | chrome-ec-87c7879c6848263c56cdc29e6bf53cef1e50e936.tar.gz |
zephyr: it8xxx2/pinmux: use new pinmux driver
Enable i2c ports alt function with new pinmux driver.
BUG=b:187043683
BRANCH=none
TEST=On Asurada, verify I2C ports' alt function are set correctly.
Cq-Depend: chromium:2857993
Signed-off-by: Denis Brockus <dbrockus@google.com>
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I816aa7e9f9aff1eecf3ebcd55bf822f0e66cdff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858298
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r-- | zephyr/shim/chip/it8xxx2/pinmux.c | 109 |
1 files changed, 94 insertions, 15 deletions
diff --git a/zephyr/shim/chip/it8xxx2/pinmux.c b/zephyr/shim/chip/it8xxx2/pinmux.c index 4b7c3a6577..da5060ebf4 100644 --- a/zephyr/shim/chip/it8xxx2/pinmux.c +++ b/zephyr/shim/chip/it8xxx2/pinmux.c @@ -7,26 +7,105 @@ #include <drivers/pinmux.h> #include <soc.h> -static int it8xxx2_evb_pinmux_init(const struct device *dev) +static int it8xxx2_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); - ite_write(0xf02204, 1, 0xa5); - const struct device *p = DEVICE_DT_GET(DT_NODELABEL(pinmux)); +#if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxb), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) + const struct device *portb = DEVICE_DT_GET(DT_NODELABEL(pinmuxb)); - __ASSERT_NO_MSG(device_is_ready(p)); + /* SIN0 */ + pinmux_pin_set(portb, 0, IT8XXX2_PINMUX_FUNC_3); + /* SOUT0 */ + pinmux_pin_set(portb, 1, IT8XXX2_PINMUX_FUNC_3); +#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) - pinmux_pin_set(p, 0, IT8XXX2_PINMUX_IOF1); - pinmux_pin_set(p, 56, IT8XXX2_PINMUX_IOF1); -#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) */ - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) - pinmux_pin_set(p, 3, IT8XXX2_PINMUX_IOF1); - pinmux_pin_set(p, 59, IT8XXX2_PINMUX_IOF1); -#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) */ - ite_write(0xf02205, 1, 0xa4); return 0; } +SYS_INIT(it8xxx2_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); + +/* + * Init priority is behind CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY to overwrite + * GPIO_INPUT setting of i2c ports. + */ +static int it8xxx2_pinmux_init_latr(const struct device *dev) +{ + ARG_UNUSED(dev); + +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxb), okay) + { + const struct device *portb = + DEVICE_DT_GET(DT_NODELABEL(pinmuxb)); + + /* I2C0 CLK */ + pinmux_pin_set(portb, 3, IT8XXX2_PINMUX_FUNC_1); + /* I2C0 DAT */ + pinmux_pin_set(portb, 4, IT8XXX2_PINMUX_FUNC_1); + } +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxc), okay) + { + const struct device *portc = + DEVICE_DT_GET(DT_NODELABEL(pinmuxc)); -SYS_INIT(it8xxx2_evb_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); + /* I2C1 CLK */ + pinmux_pin_set(portc, 1, IT8XXX2_PINMUX_FUNC_1); + /* I2C1 DAT */ + pinmux_pin_set(portc, 2, IT8XXX2_PINMUX_FUNC_1); + } +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxf), okay) + { + const struct device *portf = + DEVICE_DT_GET(DT_NODELABEL(pinmuxf)); + + /* I2C2 CLK */ + pinmux_pin_set(portf, 6, IT8XXX2_PINMUX_FUNC_1); + /* I2C2 DAT */ + 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)); + + /* I2C3 CLK */ + pinmux_pin_set(porth, 1, IT8XXX2_PINMUX_FUNC_3); + /* I2C3 DAT */ + pinmux_pin_set(porth, 2, IT8XXX2_PINMUX_FUNC_3); + } +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c4), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxe), okay) + { + const struct device *porte = + DEVICE_DT_GET(DT_NODELABEL(pinmuxe)); + + /* I2C4 CLK */ + pinmux_pin_set(porte, 0, IT8XXX2_PINMUX_FUNC_3); + /* I2C4 DAT */ + pinmux_pin_set(porte, 7, IT8XXX2_PINMUX_FUNC_3); + } +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c5), okay) && \ + DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxa), okay) + { + const struct device *porta = + DEVICE_DT_GET(DT_NODELABEL(pinmuxa)); + + /* I2C5 CLK */ + pinmux_pin_set(porta, 4, IT8XXX2_PINMUX_FUNC_3); + /* I2C5 DAT */ + pinmux_pin_set(porta, 5, IT8XXX2_PINMUX_FUNC_3); + } +#endif + + return 0; +} +SYS_INIT(it8xxx2_pinmux_init_latr, POST_KERNEL, 52); |