summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2016-09-14 10:37:54 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-21 19:37:03 -0700
commit05d387da7873d318d20a5480a761ae35866630a0 (patch)
treef4e36caae155799ee98c12c893cbd80527b705cd
parent7d430cde7ee6f39e55b5b7ef2863c1263f699eaf (diff)
downloadchrome-ec-05d387da7873d318d20a5480a761ae35866630a0.tar.gz
cr50: remove unused detect_off interrupt
The interrupts to detect when the falling edge on the UART signals are currently disabled and never reenabled. Power off is detected by polling and not through interrupts. This change removes all of those falling edge interrupts. BUG=none BRANCH=none TEST=cr50 can detect when the EC, AP, and Servo are off or on Change-Id: I0fd8a0d970f3235b26af6b90dd395ea7c75e0c17 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/385192 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--board/cr50/board.c60
-rw-r--r--board/cr50/board.h1
-rw-r--r--board/cr50/gpio.inc19
-rw-r--r--common/device_state.c9
-rw-r--r--include/device_state.h3
5 files changed, 24 insertions, 68 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c
index c80c2f3930..ccdc4a626f 100644
--- a/board/cr50/board.c
+++ b/board/cr50/board.c
@@ -407,10 +407,6 @@ static void device_state_changed(enum device_type device,
{
device_set_state(device, state);
- /* Disable interrupts */
- gpio_disable_interrupt(device_states[device].detect_on);
- gpio_disable_interrupt(device_states[device].detect_off);
-
/*
* We've determined the device state, so cancel any deferred callbacks.
*/
@@ -444,8 +440,6 @@ static void device_powered_off(enum device_type device, int uart)
/* Disconnect the TX pin from the UART peripheral */
uartn_tx_disconnect(uart);
}
-
- gpio_enable_interrupt(device_states[device].detect_on);
}
static void servo_deferred(void)
@@ -472,20 +466,17 @@ DECLARE_DEFERRED(ec_deferred);
struct device_config device_states[] = {
[DEVICE_SERVO] = {
.deferred = &servo_deferred_data,
- .detect_on = GPIO_SERVO_UART2_ON,
- .detect_off = GPIO_SERVO_UART2_OFF,
+ .detect = GPIO_DETECT_SERVO,
.name = "Servo"
},
[DEVICE_AP] = {
.deferred = &ap_deferred_data,
- .detect_on = GPIO_AP_ON,
- .detect_off = GPIO_AP_OFF,
+ .detect = GPIO_DETECT_AP,
.name = "AP"
},
[DEVICE_EC] = {
.deferred = &ec_deferred_data,
- .detect_on = GPIO_EC_ON,
- .detect_off = GPIO_EC_OFF,
+ .detect = GPIO_DETECT_EC,
.name = "EC"
},
};
@@ -520,14 +511,16 @@ static void servo_attached(void)
void device_state_on(enum gpio_signal signal)
{
+ gpio_disable_interrupt(signal);
+
switch (signal) {
- case GPIO_AP_ON:
+ case GPIO_DETECT_AP:
device_powered_on(DEVICE_AP, UART_AP);
break;
- case GPIO_EC_ON:
+ case GPIO_DETECT_EC:
device_powered_on(DEVICE_EC, UART_EC);
break;
- case GPIO_SERVO_UART2_ON:
+ case GPIO_DETECT_SERVO:
servo_attached();
break;
default:
@@ -536,47 +529,22 @@ void device_state_on(enum gpio_signal signal)
}
}
-void device_state_off(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_AP_OFF:
- board_update_device_state(DEVICE_AP);
- break;
- case GPIO_EC_OFF:
- board_update_device_state(DEVICE_EC);
- break;
- case GPIO_SERVO_UART2_OFF:
- board_update_device_state(DEVICE_SERVO);
- break;
- default:
- CPRINTS("Device not supported");
- }
-}
-
void board_update_device_state(enum device_type device)
{
- int state;
-
- if (device == DEVICE_SERVO) {
- /*
- * If EC UART TX is pulled high when EC UART is not enabled,
- * then servo is attached.
- */
- state = (!uartn_enabled(UART_EC) &&
- gpio_get_level(GPIO_SERVO_UART2_ON));
- } else
- state = gpio_get_level(device_states[device].detect_on);
+ if (device == DEVICE_SERVO && servo_state_unknown())
+ return;
/*
* If the device is currently on set its state immediately. If it
* thinks the device is powered off debounce the signal.
*/
- if (state)
- device_state_on(device_states[device].detect_on);
+ if (gpio_get_level(device_states[device].detect))
+ device_state_on(device_states[device].detect);
else {
device_set_state(device, DEVICE_STATE_UNKNOWN);
- gpio_enable_interrupt(device_states[device].detect_on);
+ gpio_enable_interrupt(device_states[device].detect);
+
/*
* Wait a bit. If cr50 detects this device is ever powered on
* during this time then the status wont be set to powered off.
diff --git a/board/cr50/board.h b/board/cr50/board.h
index c7814e5b36..7d11abd60d 100644
--- a/board/cr50/board.h
+++ b/board/cr50/board.h
@@ -127,7 +127,6 @@ void board_configure_deep_sleep_wakepins(void);
/* Interrupt handler */
void sys_rst_asserted(enum gpio_signal signal);
void device_state_on(enum gpio_signal signal);
-void device_state_off(enum gpio_signal signal);
/* Special controls over EC and AP */
void assert_sys_rst(void);
diff --git a/board/cr50/gpio.inc b/board/cr50/gpio.inc
index 3c40599034..780ec633e7 100644
--- a/board/cr50/gpio.inc
+++ b/board/cr50/gpio.inc
@@ -13,14 +13,10 @@
* so we attach two internal GPIOs to the same pad.
*/
GPIO_INT(SYS_RST_L_IN, PIN(1, 0), GPIO_INT_FALLING, sys_rst_asserted)
-GPIO_INT(AP_ON, PIN(1, 1), GPIO_INT_RISING, device_state_on)
-GPIO_INT(EC_ON, PIN(1, 2), GPIO_INT_RISING, device_state_on)
-GPIO_INT(SERVO_UART2_ON, PIN(1, 3), GPIO_INT_RISING | GPIO_PULL_DOWN,
+GPIO_INT(DETECT_AP, PIN(1, 1), GPIO_INT_RISING, device_state_on)
+GPIO_INT(DETECT_EC, PIN(1, 2), GPIO_INT_RISING, device_state_on)
+GPIO_INT(DETECT_SERVO, PIN(1, 3), GPIO_INT_RISING | GPIO_PULL_DOWN,
device_state_on)
-GPIO_INT(AP_OFF, PIN(1, 4), GPIO_INT_FALLING, device_state_off)
-GPIO_INT(EC_OFF, PIN(1, 5), GPIO_INT_FALLING, device_state_off)
-GPIO_INT(SERVO_UART2_OFF, PIN(1, 6), GPIO_INT_FALLING | GPIO_PULL_DOWN,
- device_state_off)
/* Pull this low to interrupt the AP */
GPIO(INT_AP_L, PIN(0, 0), GPIO_OUT_HIGH)
@@ -97,12 +93,9 @@ PINMUX(FUNC(UART2_RX), B6, DIO_INPUT) /* EC console */
* driving the cr50 uart TX at the same time as servo is driving those pins may
* damage both servo and cr50.
*/
-PINMUX(GPIO(AP_ON), A3, DIO_INPUT)
-PINMUX(GPIO(AP_OFF), A3, DIO_INPUT)
-PINMUX(GPIO(EC_ON), B6, DIO_INPUT)
-PINMUX(GPIO(EC_OFF), B6, DIO_INPUT)
-PINMUX(GPIO(SERVO_UART2_ON), B5, DIO_INPUT)
-PINMUX(GPIO(SERVO_UART2_OFF), B5, DIO_INPUT)
+PINMUX(GPIO(DETECT_AP), A3, DIO_INPUT)
+PINMUX(GPIO(DETECT_EC), B6, DIO_INPUT)
+PINMUX(GPIO(DETECT_SERVO), B5, DIO_INPUT)
/*
* I2CS pins are bi-directional and would be configured here as shown. However,
diff --git a/common/device_state.c b/common/device_state.c
index f8e57c35ff..0c4024880a 100644
--- a/common/device_state.c
+++ b/common/device_state.c
@@ -37,8 +37,7 @@ DECLARE_HOOK(HOOK_SECOND, check_device_state, HOOK_PRIO_DEFAULT);
static int device_has_interrupts(enum device_type device)
{
return (device_states[device].deferred &&
- device_states[device].detect_on != GPIO_COUNT &&
- device_states[device].detect_off != GPIO_COUNT);
+ device_states[device].detect != GPIO_COUNT);
}
static void disable_interrupts(enum device_type device)
@@ -50,8 +49,7 @@ static void disable_interrupts(enum device_type device)
hook_call_deferred(device_states[device].deferred, -1);
/* Disable gpio interrupts */
- gpio_disable_interrupt(device_states[device].detect_on);
- gpio_disable_interrupt(device_states[device].detect_off);
+ gpio_disable_interrupt(device_states[device].detect);
}
static void enable_interrupts(enum device_type device)
@@ -60,8 +58,7 @@ static void enable_interrupts(enum device_type device)
return;
/* Enable gpio interrupts */
- gpio_enable_interrupt(device_states[device].detect_on);
- gpio_enable_interrupt(device_states[device].detect_off);
+ gpio_enable_interrupt(device_states[device].detect);
}
void device_detect_state_enable(int enable)
diff --git a/include/device_state.h b/include/device_state.h
index d7ff0661dc..1ad78f002c 100644
--- a/include/device_state.h
+++ b/include/device_state.h
@@ -21,8 +21,7 @@ struct device_config {
enum device_state state; /* Device status */
/* Deferred handler to detect power off */
const struct deferred_data *deferred;
- enum gpio_signal detect_on; /* GPIO detecting power on */
- enum gpio_signal detect_off; /* GPIO detecting power off */
+ enum gpio_signal detect; /* GPIO detecting power on */
};
enum device_type;