1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* Copyright 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "console.h"
#include "rdd.h"
#include "registers.h"
#include "usb_api.h"
static void usart_tx_connect(void)
{
GWRITE(PINMUX, DIOA7_SEL, GC_PINMUX_UART1_TX_SEL);
GWRITE(PINMUX, DIOB5_SEL, GC_PINMUX_UART2_TX_SEL);
}
static void usart_tx_disconnect(void)
{
GWRITE(PINMUX, DIOA7_SEL, GC_PINMUX_DIOA3_SEL_DEFAULT);
GWRITE(PINMUX, DIOB5_SEL, GC_PINMUX_DIOB5_SEL_DEFAULT);
}
void rdd_attached(void)
{
/* Select the CCD PHY */
usb_select_phy(USB_SEL_PHY1);
/* Connect to selected phy */
usb_init();
}
void rdd_detached(void)
{
/* Disconnect from AP and EC UART TX */
usart_tx_disconnect();
/* Select the AP PHY */
usb_select_phy(USB_SEL_PHY0);
/* Connect to selected phy */
usb_init();
}
static int command_uart(int argc, char **argv)
{
static int enabled;
if (argc > 1) {
if (!strcasecmp("enable", argv[1])) {
enabled = 1;
usart_tx_connect();
} else if (!strcasecmp("disable", argv[1])) {
enabled = 0;
usart_tx_disconnect();
}
}
ccprintf("UART %s\n", enabled ? "enabled" : "disabled");
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(uart, command_uart,
"[enable|disable]",
"Get/set the UART TX connection state",
NULL);
|