summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-01-07 21:25:48 +0800
committerChromeBot <chrome-bot@google.com>2013-01-08 09:30:00 -0800
commitfd29230988fc90e9535b84c8fe65738e17ba50dd (patch)
tree76ea9b0df37122824d9d81f2e7ee7a2157b4e5c3 /common
parent92bf81948de9333764ed62d620a27f5a46b215d6 (diff)
downloadchrome-ec-fd29230988fc90e9535b84c8fe65738e17ba50dd.tar.gz
spring: Add a host command for USB mux switching
To make test and bring-up easier, adds a host command for USB mux switching. BUG=chrome-os-partner:17111 TEST=manual BRANCH=none Change-Id: I9da43fe934881ce24f326275ef312c4e6a474f11 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/40586 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/tsu6721.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/tsu6721.c b/common/tsu6721.c
index d6fc67ce23..ba6d3ad4b0 100644
--- a/common/tsu6721.c
+++ b/common/tsu6721.c
@@ -7,8 +7,11 @@
#include "board.h"
#include "console.h"
+#include "ec_commands.h"
#include "hooks.h"
+#include "host_command.h"
#include "i2c.h"
+#include "system.h"
#include "timer.h"
#include "tsu6721.h"
#include "uart.h"
@@ -146,6 +149,9 @@ static void tsu6721_dump(void)
ccprintf("\n");
}
+/*****************************************************************************/
+/* Console commands */
+
static int command_usbmux(int argc, char **argv)
{
if (1 == argc) { /* dump all registers */
@@ -173,3 +179,26 @@ DECLARE_CONSOLE_COMMAND(usbmux, command_usbmux,
"[usb|uart1|uart2|auto]",
"TSU6721 USB mux control",
NULL);
+
+/*****************************************************************************/
+/* Host commands */
+
+static int usb_command_mux(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_usb_mux *p = args->params;
+
+ if (system_is_locked())
+ return EC_RES_ACCESS_DENIED;
+
+ /* Safety check */
+ if (p->mux != TSU6721_MUX_NONE &&
+ p->mux != TSU6721_MUX_USB &&
+ p->mux != TSU6721_MUX_UART &&
+ p->mux != TSU6721_MUX_AUDIO)
+ return EC_RES_ERROR;
+
+ if (tsu6721_mux(p->mux))
+ return EC_RES_ERROR;
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_USB_MUX, usb_command_mux, EC_VER_MASK(0));