diff options
author | Jan Dabros <jsd@semihalf.com> | 2021-01-12 09:51:37 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-15 20:05:42 +0000 |
commit | 74414b44d7d8877f0822b2ec39960464bdf584f0 (patch) | |
tree | 7893a85448ee979e12ff79539f3483a5001ceb03 /driver/gl3590.c | |
parent | 0563daab68246e1e36de630356e9fe202dd29639 (diff) | |
download | chrome-ec-74414b44d7d8877f0822b2ec39960464bdf584f0.tar.gz |
gl3590: Add CLI for managing USB hub
Initially `gl3590` command allows only for enabling/disabling downstream
facing ports.
BUG=177295270
BRANCH=main
TEST=On servo_v4p1 verify that ports power may be enabled/disabled via
gl3590 command. In order to disable USB3.0 port on top (A0):
gl3590 disable 0x2
In order to enable USB3.0 port at the bottom (A1):
gl3590 enable 0x1
In order to disable uServo port:
gl3590 disable 0x8
Signed-off-by: Jan Dabros <jsd@semihalf.com>
Change-Id: Id9f82454fc9309e56c76215bce7058de776a806d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2624471
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/gl3590.c')
-rw-r--r-- | driver/gl3590.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/driver/gl3590.c b/driver/gl3590.c index 40e4df2d05..573ba8d763 100644 --- a/driver/gl3590.c +++ b/driver/gl3590.c @@ -210,3 +210,35 @@ int gl3590_enable_ports(int hub, uint8_t port_mask, bool enable) return rv; } + +#ifdef CONFIG_CMD_GL3590 +static int command_gl3590(int argc, char **argv) +{ + char *e; + int port; + + if (argc < 2) + return EC_ERROR_PARAM_COUNT; + + port = strtoi(argv[2], &e, 0); + if (*e) + return EC_ERROR_PARAM2; + + if (strcasecmp(argv[1], "enable") == 0) { + if (!gl3590_enable_ports(0, port, 1)) + return EC_SUCCESS; + else + return EC_ERROR_HW_INTERNAL; + } else if (strcasecmp(argv[1], "disable") == 0) { + if (!gl3590_enable_ports(0, port, 0)) + return EC_SUCCESS; + else + return EC_ERROR_HW_INTERNAL; + } + + return EC_ERROR_PARAM1; +} +DECLARE_CONSOLE_COMMAND(gl3590, command_gl3590, + "<enable | disable> <port_bitmask>", + "Manage GL3590 USB3.1 hub and its ports"); +#endif /* CONFIG_CMD_GL3590 */ |