summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-03-07 13:17:40 -0800
committerRandall Spangler <rspangler@chromium.org>2012-03-07 13:28:12 -0800
commit6500cb9481a54dfe3e3106f06cc6c0244836bc71 (patch)
treeafe84d1d5ed8034c147f0a9f2165e0aac301ac54
parent321b077ed5dbe2848765d9c49da10f3bc86b096b (diff)
downloadchrome-ec-6500cb9481a54dfe3e3106f06cc6c0244836bc71.tar.gz
Update LPC mapped switch states with write protect and recovery states
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8325 TEST=manual Boot system with lid open. 'ectool switches' should show lid open. Use 'dut-control goog_rec_mode:on'. 'ectool switches should show dedicated recovery signal on.' Use 'dut-control goog_rec_mode:off'. 'ectool switches should show dedicated recovery signal off.' Disable write protect via screw. 'ectool switches' should show WP signal disabled. Boot system in recovery mode (power+esc+reload). Should show 0x09. Change-Id: I0434427c4b5f8c07c02a8714618f7eb101b86fed
-rw-r--r--board/bds/board.c2
-rw-r--r--board/bds/board.h2
-rw-r--r--board/link/board.c6
-rw-r--r--chip/lm4/power_button.c39
-rw-r--r--include/lpc_commands.h4
-rw-r--r--util/ectool.c12
6 files changed, 57 insertions, 8 deletions
diff --git a/board/bds/board.c b/board/bds/board.c
index fc66023c46..8f5013cafc 100644
--- a/board/bds/board.c
+++ b/board/bds/board.c
@@ -70,6 +70,8 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
GPIO_SIGNAL_NOT_IMPLEMENTED("PCH_SMIn"),
GPIO_SIGNAL_NOT_IMPLEMENTED("PCH_SUSACKn"),
GPIO_SIGNAL_NOT_IMPLEMENTED("SHUNT_1_5V_DDR"),
+ GPIO_SIGNAL_NOT_IMPLEMENTED("RECOVERYn"),
+ GPIO_SIGNAL_NOT_IMPLEMENTED("WRITE_PROTECTn"),
};
diff --git a/board/bds/board.h b/board/bds/board.h
index de641f0b7f..22f7ebc45c 100644
--- a/board/bds/board.h
+++ b/board/bds/board.h
@@ -121,6 +121,8 @@ enum gpio_signal {
GPIO_PCH_SUSACKn, /* Acknowledge PCH SUSWARN# signal */
GPIO_SHUNT_1_5V_DDR, /* Shunt +1.5V_DDR; may also enable +3V_TP
* depending on stuffing. */
+ GPIO_RECOVERYn, /* Recovery signal from servo */
+ GPIO_WRITE_PROTECTn, /* Write protect input */
/* Number of GPIOs; not an actual GPIO */
GPIO_COUNT
diff --git a/board/link/board.c b/board/link/board.c
index 0b18e8ba93..607e1f7fcc 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -65,10 +65,12 @@ const struct gpio_info gpio_list[GPIO_COUNT] = {
x86_power_interrupt},
{"PGOOD_VGFX_CORE", LM4_GPIO_D, (1<<2), GPIO_INT_BOTH,
x86_power_interrupt},
- {"RECOVERYn", LM4_GPIO_H, (1<<7), 0, NULL},
+ {"RECOVERYn", LM4_GPIO_H, (1<<7), GPIO_INT_BOTH,
+ power_button_interrupt},
{"USB1_STATUSn", LM4_GPIO_E, (1<<7), 0, NULL},
{"USB2_STATUSn", LM4_GPIO_E, (1<<1), 0, NULL},
- {"WRITE_PROTECTn", LM4_GPIO_J, (1<<4), 0, NULL},
+ {"WRITE_PROTECTn", LM4_GPIO_J, (1<<4), GPIO_INT_BOTH,
+ power_button_interrupt},
/* Outputs; all unasserted by default */
{"CPU_PROCHOTn", LM4_GPIO_F, (1<<2), GPIO_OUT_HIGH, NULL},
{"ENABLE_1_5V_DDR", LM4_GPIO_H, (1<<5), GPIO_OUT_LOW, NULL},
diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c
index 65e3824e40..f84f8e40a9 100644
--- a/chip/lm4/power_button.c
+++ b/chip/lm4/power_button.c
@@ -9,6 +9,7 @@
#include "console.h"
#include "gpio.h"
#include "keyboard.h"
+#include "keyboard_scan.h"
#include "lpc.h"
#include "lpc_commands.h"
#include "power_button.h"
@@ -61,6 +62,26 @@ static uint64_t tdebounce_pwr;
static uint8_t *memmap_switches;
+/* Update status of non-debounced switches */
+static void update_other_switches(void)
+{
+ if (gpio_get_level(GPIO_WRITE_PROTECTn) != 0)
+ *memmap_switches |= EC_LPC_SWITCH_WRITE_PROTECT_DISABLED;
+ else
+ *memmap_switches &= ~EC_LPC_SWITCH_WRITE_PROTECT_DISABLED;
+
+ if (keyboard_scan_recovery_pressed())
+ *memmap_switches |= EC_LPC_SWITCH_KEYBOARD_RECOVERY;
+ else
+ *memmap_switches &= ~EC_LPC_SWITCH_KEYBOARD_RECOVERY;
+
+ if (gpio_get_level(GPIO_RECOVERYn) == 0)
+ *memmap_switches |= EC_LPC_SWITCH_DEDICATED_RECOVERY;
+ else
+ *memmap_switches &= ~EC_LPC_SWITCH_DEDICATED_RECOVERY;
+}
+
+
static void set_pwrbtn_to_pch(int high)
{
uart_printf("[PB PCH pwrbtn=%s]\n", high ? "HIGH" : "LOW");
@@ -159,10 +180,18 @@ static void lid_switch_changed(uint64_t tnow)
void power_button_interrupt(enum gpio_signal signal)
{
/* Reset debounce time for the changed signal */
- if (signal == GPIO_LID_SWITCHn)
+ switch (signal) {
+ case GPIO_LID_SWITCHn:
tdebounce_lid = get_time().val + LID_DEBOUNCE_US;
- else
+ break;
+ case GPIO_POWER_BUTTONn:
tdebounce_pwr = get_time().val + PWRBTN_DEBOUNCE_US;
+ break;
+ default:
+ /* Non-debounced switches; we'll update their state
+ * automatically the next time through the task loop. */
+ break;
+ }
/* We don't have a way to tell the task to wake up at the end of the
* debounce interval; wake it up now so it can go back to sleep for the
@@ -182,6 +211,7 @@ int power_button_init(void)
*memmap_switches |= EC_LPC_SWITCH_POWER_BUTTON_PRESSED;
if (gpio_get_level(GPIO_PCH_LID_SWITCHn) != 0)
*memmap_switches |= EC_LPC_SWITCH_LID_OPEN;
+ update_other_switches();
/* Copy initial switch states to PCH */
gpio_set_level(GPIO_PCH_PWRBTNn, gpio_get_level(GPIO_POWER_BUTTONn));
@@ -190,6 +220,8 @@ int power_button_init(void)
/* Enable interrupts, now that we've initialized */
gpio_enable_interrupt(GPIO_POWER_BUTTONn);
gpio_enable_interrupt(GPIO_LID_SWITCHn);
+ gpio_enable_interrupt(GPIO_WRITE_PROTECTn);
+ gpio_enable_interrupt(GPIO_RECOVERYn);
return EC_SUCCESS;
}
@@ -212,6 +244,9 @@ void power_button_task(void)
lid_switch_changed(t);
}
+ /* Handle non-debounced switches */
+ update_other_switches();
+
/* Update state machine */
state_machine(t);
diff --git a/include/lpc_commands.h b/include/lpc_commands.h
index 78c9df5cac..c9d8cfedb3 100644
--- a/include/lpc_commands.h
+++ b/include/lpc_commands.h
@@ -60,6 +60,10 @@
#define EC_LPC_SWITCH_LID_OPEN 0x01
#define EC_LPC_SWITCH_POWER_BUTTON_PRESSED 0x02
#define EC_LPC_SWITCH_WRITE_PROTECT_DISABLED 0x04
+/* Recovery requested via keyboard */
+#define EC_LPC_SWITCH_KEYBOARD_RECOVERY 0x08
+/* Recovery requested via dedicated signal (from servo board) */
+#define EC_LPC_SWITCH_DEDICATED_RECOVERY 0x10
/* The offset of temperature value stored in mapped memory.
* This allows reporting a temperature range of
diff --git a/util/ectool.c b/util/ectool.c
index 85ef934436..6bf7328a87 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -1037,13 +1037,17 @@ int cmd_host_event_clear(int argc, char *argv[])
int cmd_switches(int argc, char *argv[])
{
uint8_t s = read_mapped_mem8(EC_LPC_MEMMAP_SWITCHES);
- printf("Current switches: 0x%02x\n", s);
- printf("Lid switch: %s\n",
+ printf("Current switches: 0x%02x\n", s);
+ printf("Lid switch: %s\n",
(s & EC_LPC_SWITCH_LID_OPEN ? "OPEN" : "CLOSED"));
- printf("Power button: %s\n",
+ printf("Power button: %s\n",
(s & EC_LPC_SWITCH_POWER_BUTTON_PRESSED ? "DOWN" : "UP"));
- printf("Write protect: %sABLED\n",
+ printf("Write protect: %sABLED\n",
(s & EC_LPC_SWITCH_WRITE_PROTECT_DISABLED ? "DIS" : "EN"));
+ printf("Keyboard recovery: %sABLED\n",
+ (s & EC_LPC_SWITCH_KEYBOARD_RECOVERY ? "EN" : "DIS"));
+ printf("Dedicated recovery: %sABLED\n",
+ (s & EC_LPC_SWITCH_DEDICATED_RECOVERY ? "EN" : "DIS"));
return 0;
}