diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2021-12-14 13:06:43 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-06 09:13:22 +0000 |
commit | b703dad1001234bdd69cb424a70fbbc2b16e1293 (patch) | |
tree | 9c443961de7874ea6efd5c2a23246a466380213c /driver | |
parent | 0790baf68a0f258f41ec2feced65511d369c1987 (diff) | |
download | chrome-ec-b703dad1001234bdd69cb424a70fbbc2b16e1293.tar.gz |
rt1718s: add console command for gpio
BUG=b:203739613
TEST=uart:~$ rt1718s_gpio
C1 GPIO0 OD=1 PU=0 PD=0 OE=1 HL=0
C1 GPIO1 OD=1 PU=0 PD=0 OE=1 HL=0
C1 GPIO2 OD=1 PU=0 PD=0 OE=1 HL=0
BRANCH=none
Change-Id: I4292be49eed48000745e0965a26375955ad1e31b
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3336641
Tested-by: Eric Yilun Lin <yllin@google.com>
Auto-Submit: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/rt1718s.c | 29 | ||||
-rw-r--r-- | driver/tcpm/rt1718s.h | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/driver/tcpm/rt1718s.c b/driver/tcpm/rt1718s.c index 8d36d3e0b3..81356c946c 100644 --- a/driver/tcpm/rt1718s.c +++ b/driver/tcpm/rt1718s.c @@ -527,6 +527,35 @@ int rt1718s_gpio_get_level(int port, enum rt1718s_gpio signal) return !!(val & RT1718S_GPIO_CTRL_I); } +static int command_rt1718s_gpio(int argc, char **argv) +{ + int i, j; + uint32_t flags; + + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + + if (tcpc_config[i].drv != &rt1718s_tcpm_drv) + continue; + + for (j = 0; j < RT1718S_GPIO_COUNT; j++) { + int rv; + + rv = rt1718s_read8(i, RT1718S_GPIO_CTRL(j), &flags); + if (rv) + return EC_ERROR_UNKNOWN; + + ccprintf("C%d GPIO%d OD=%d PU=%d PD=%d OE=%d HL=%d\n", + i, j, !(flags & RT1718S_GPIO_CTRL_OD_N), + !!(flags & RT1718S_GPIO_CTRL_PU), + !!(flags & RT1718S_GPIO_CTRL_PD), + !!(flags & RT1718S_GPIO_CTRL_OE), + !!(flags & RT1718S_GPIO_CTRL_O)); + } + } + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(rt1718s_gpio, command_rt1718s_gpio, "", "RT1718S GPIO"); + /* RT1718S is a TCPCI compatible port controller */ const struct tcpm_drv rt1718s_tcpm_drv = { .init = &rt1718s_init, diff --git a/driver/tcpm/rt1718s.h b/driver/tcpm/rt1718s.h index 4b8ea5972e..2e74132847 100644 --- a/driver/tcpm/rt1718s.h +++ b/driver/tcpm/rt1718s.h @@ -214,6 +214,7 @@ enum rt1718s_gpio { RT1718S_GPIO1 = 0, RT1718S_GPIO2, RT1718S_GPIO3, + RT1718S_GPIO_COUNT, }; /** |