mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 23:51:28 +00:00
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
This commit is contained in:
@@ -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"),
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user