summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2016-06-24 15:49:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-12 22:34:56 -0700
commit49312e06cdb93091b20ac3249fccb4dd711996b6 (patch)
treeaad434ac48eaeda17750ae6138146f95c138bd19 /board
parent9146e44c7d14ce73061b949373b4787483c39ad8 (diff)
downloadchrome-ec-49312e06cdb93091b20ac3249fccb4dd711996b6.tar.gz
cr50: disable device monitoring when not in ccd
When cr50 is not trying to do ccd, we dont need to monitor the devices. Disable device state detection interrupts and the AP and EC UARTs. BUG=none BRANCH=none TEST=gru and kevin monitor devices correctly when ccd is enabled, and dont monitor anything when it is disabled. Change-Id: Ic3f5974320486ff6dd0147c490a1c294cc2f6a76 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356770 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/cr50/board.c38
-rw-r--r--board/cr50/board.h6
-rw-r--r--board/cr50/rdd.c26
3 files changed, 37 insertions, 33 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index 0ba8712bf2..f2c1b99569 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -322,24 +322,32 @@ struct device_config device_states[] = {
[DEVICE_SERVO_AP] = {
.deferred = &servo_ap_deferred_data,
.detect_on = GPIO_SERVO_UART1_ON,
- .detect_off = GPIO_SERVO_UART1_OFF
+ .detect_off = GPIO_SERVO_UART1_OFF,
+ .name = "Servo AP"
},
[DEVICE_SERVO_EC] = {
.deferred = &servo_ec_deferred_data,
.detect_on = GPIO_SERVO_UART2_ON,
- .detect_off = GPIO_SERVO_UART2_OFF
+ .detect_off = GPIO_SERVO_UART2_OFF,
+ .name = "Servo EC"
},
[DEVICE_AP] = {
.deferred = &ap_deferred_data,
.detect_on = GPIO_AP_ON,
- .detect_off = GPIO_AP_OFF
+ .detect_off = GPIO_AP_OFF,
+ .name = "AP"
},
[DEVICE_EC] = {
.deferred = &ec_deferred_data,
.detect_on = GPIO_EC_ON,
- .detect_off = GPIO_EC_OFF
+ .detect_off = GPIO_EC_OFF,
+ .name = "EC"
+ },
+ [DEVICE_SERVO] = {
+ .detect_on = GPIO_COUNT,
+ .detect_off = GPIO_COUNT,
+ .name = "Servo"
},
- [DEVICE_SERVO] = {},
};
BUILD_ASSERT(ARRAY_SIZE(device_states) == DEVICE_COUNT);
@@ -448,23 +456,3 @@ void board_update_device_state(enum device_type device)
hook_call_deferred(device_states[device].deferred, 50);
}
}
-
-static void print_state(const char *name, enum device_state state)
-{
- ccprintf("%s %s\n", name, state == DEVICE_STATE_ON ? "on" :
- state == DEVICE_STATE_OFF ? "off" : "unknown");
-}
-static int command_devices(int argc, char **argv)
-{
-
- print_state("AP", device_get_state(DEVICE_AP));
- print_state("EC", device_get_state(DEVICE_EC));
- print_state("Servo", device_get_state(DEVICE_SERVO));
- print_state(" AP", device_get_state(DEVICE_SERVO_AP));
- print_state(" EC", device_get_state(DEVICE_SERVO_EC));
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(devices, command_devices,
- "",
- "Get the AP, EC, and servo device states",
- NULL);
diff --git a/board/cr50/board.h b/board/cr50/board.h
index 6c1ba85795..0bfc3eaa53 100644
--- a/board/cr50/board.h
+++ b/board/cr50/board.h
@@ -109,11 +109,11 @@ enum usb_strings {
/* Device indexes */
enum device_type {
- DEVICE_SERVO_AP = 0,
- DEVICE_SERVO_EC,
- DEVICE_AP,
+ DEVICE_AP = 0,
DEVICE_EC,
DEVICE_SERVO,
+ DEVICE_SERVO_AP,
+ DEVICE_SERVO_EC,
DEVICE_COUNT
};
diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c
index beefc761dd..2aab5be6a3 100644
--- a/board/cr50/rdd.c
+++ b/board/cr50/rdd.c
@@ -27,6 +27,11 @@ static struct uart_config uarts[] = {
[UART_EC] = {"EC", DEVICE_EC, GC_PINMUX_UART2_TX_SEL},
};
+static int ccd_is_enabled(void)
+{
+ return !gpio_get_level(GPIO_CCD_MODE_L);
+}
+
/* If the UART TX is enabled the pinmux select will have a non-zero value */
int uartn_enabled(int uart)
{
@@ -51,7 +56,7 @@ static int servo_is_connected(void)
void uartn_tx_connect(int uart)
{
- if (!uart_enabled)
+ if (!uart_enabled || !ccd_is_enabled())
return;
if (servo_is_connected()) {
@@ -81,18 +86,30 @@ void rdd_attached(void)
/* Indicate case-closed debug mode (active low) */
gpio_set_level(GPIO_CCD_MODE_L, 0);
+ /* Enable CCD */
ccd_set_mode(CCD_MODE_ENABLED);
+
+ /* Enable device state monitoring */
+ device_detect_state_enable(1);
}
void rdd_detached(void)
{
- /* Disconnect from AP and EC UART TX */
+ /* Disable device state monitoring */
+ device_detect_state_enable(0);
+
+ /* Disconnect from AP and EC UART TX peripheral from gpios */
uartn_tx_disconnect(UART_EC);
uartn_tx_disconnect(UART_AP);
+ /* Disable the AP and EC UART peripheral */
+ uartn_disable(UART_AP);
+ uartn_disable(UART_EC);
+
/* Done with case-closed debug mode */
gpio_set_level(GPIO_CCD_MODE_L, 1);
+ /* Disable CCD */
ccd_set_mode(CCD_MODE_DISABLED);
}
@@ -118,9 +135,8 @@ static int command_ccd(int argc, char **argv)
return EC_ERROR_PARAM1;
}
- ccprintf("CCD: %s\n", !gpio_get_level(GPIO_CCD_MODE_L) ?
- " enabled" : "disabled");
- ccprintf("AP UART: %s\nEC UART: %s\n",
+ ccprintf("CCD: %s\nAP UART: %s\nEC UART: %s\n",
+ ccd_is_enabled() ? " enabled" : "disabled",
uartn_enabled(UART_AP) ? " enabled" : "disabled",
uartn_enabled(UART_EC) ? " enabled" : "disabled");
return EC_SUCCESS;