mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
Support host event get/set/clear on all host interfaces
BUG=chrome-os-partner:11090 TEST=suspend laptop, then press power button; should resume from suspend Change-Id: I36b7c62b2e115bb97d37defcd3c783af0f91d5f8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26730
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include "host_command.h"
|
||||
#include "keyboard.h"
|
||||
#include "keyboard_scan.h"
|
||||
#include "lpc.h"
|
||||
#include "power_button.h"
|
||||
#include "pwm.h"
|
||||
#include "system.h"
|
||||
@@ -189,7 +188,7 @@ static void power_button_pressed(uint64_t tnow)
|
||||
tnext_state = tnow;
|
||||
*memmap_switches |= EC_SWITCH_POWER_BUTTON_PRESSED;
|
||||
keyboard_set_power_button(1);
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON));
|
||||
host_set_single_event(EC_HOST_EVENT_POWER_BUTTON);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +223,7 @@ static void lid_switch_open(uint64_t tnow)
|
||||
*memmap_switches |= EC_SWITCH_LID_OPEN;
|
||||
hook_notify(HOOK_LID_CHANGE, 0);
|
||||
update_backlight();
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN));
|
||||
host_set_single_event(EC_HOST_EVENT_LID_OPEN);
|
||||
|
||||
/* If the chipset is off, clear keyboard recovery and send a power
|
||||
* button pulse to wake up the chipset. */
|
||||
@@ -252,7 +251,7 @@ static void lid_switch_close(uint64_t tnow)
|
||||
*memmap_switches &= ~EC_SWITCH_LID_OPEN;
|
||||
hook_notify(HOOK_LID_CHANGE, 0);
|
||||
update_backlight();
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED));
|
||||
host_set_single_event(EC_HOST_EVENT_LID_CLOSED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "lpc.h"
|
||||
#include "pwm.h"
|
||||
#include "registers.h"
|
||||
#include "task.h"
|
||||
@@ -128,8 +127,7 @@ static void check_fan_failure(void)
|
||||
* Fan enabled but stalled. Issues warning. As we have thermal
|
||||
* shutdown protection, issuing warning here should be enough.
|
||||
*/
|
||||
lpc_set_host_events(
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL));
|
||||
host_set_single_event(EC_HOST_EVENT_THERMAL);
|
||||
cputs(CC_PWM, "[Fan stalled!]\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ common-$(CONFIG_PMU_TPS65090)+=pmu_tps65090.o pmu_tps65090_charger.o
|
||||
common-$(CONFIG_EOPTION)+=eoption.o
|
||||
common-$(CONFIG_FLASH)+=flash_common.o flash_commands.o fmap.o
|
||||
common-$(CONFIG_IR357x)+=ir357x.o
|
||||
common-$(CONFIG_LPC)+=port80.o host_event_commands.o
|
||||
common-$(CONFIG_LPC)+=port80.o
|
||||
common-$(CONFIG_POWER_LED)+=power_led.o
|
||||
common-$(CONFIG_PSTORE)+=pstore_commands.o
|
||||
common-$(CONFIG_SMART_BATTERY)+=smart_battery.o smart_battery_stub.o
|
||||
common-$(CONFIG_TASK_CONSOLE)+=console.o
|
||||
common-$(CONFIG_TASK_GAIAPOWER)+=gaia_power.o
|
||||
common-$(CONFIG_TASK_HOSTCMD)+=host_command.o
|
||||
common-$(CONFIG_TASK_HOSTCMD)+=host_command.o host_event_commands.o
|
||||
common-$(CONFIG_TASK_I8042CMD)+=i8042.o keyboard.o
|
||||
common-$(CONFIG_TASK_LIGHTBAR)+=lightbar.o
|
||||
common-$(CONFIG_TASK_POWERSTATE)+=charge_state.o battery_precharge.o
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
* Battery charging task and state machine.
|
||||
*/
|
||||
|
||||
|
||||
#include "battery.h"
|
||||
#include "battery_pack.h"
|
||||
#include "charge_state.h"
|
||||
@@ -15,7 +14,6 @@
|
||||
#include "console.h"
|
||||
#include "gpio.h"
|
||||
#include "host_command.h"
|
||||
#include "lpc.h"
|
||||
#include "power_button.h"
|
||||
#include "power_led.h"
|
||||
#include "printf.h"
|
||||
@@ -117,12 +115,10 @@ static int state_common(struct power_state_context *ctx)
|
||||
rv = charger_post_init();
|
||||
if (rv)
|
||||
curr->error |= F_CHARGER_INIT;
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(
|
||||
EC_HOST_EVENT_AC_CONNECTED));
|
||||
host_set_single_event(EC_HOST_EVENT_AC_CONNECTED);
|
||||
} else {
|
||||
/* AC off */
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(
|
||||
EC_HOST_EVENT_AC_DISCONNECTED));
|
||||
host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,16 +198,14 @@ static int state_common(struct power_state_context *ctx)
|
||||
/* Battery charge level low */
|
||||
if (batt->state_of_charge <= BATTERY_LEVEL_LOW &&
|
||||
prev->batt.state_of_charge > BATTERY_LEVEL_LOW)
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(
|
||||
EC_HOST_EVENT_BATTERY_LOW));
|
||||
host_set_single_event(EC_HOST_EVENT_BATTERY_LOW);
|
||||
|
||||
/* Battery charge level critical */
|
||||
if (batt->state_of_charge <= BATTERY_LEVEL_CRITICAL) {
|
||||
*ctx->memmap_batt_flags |= EC_BATT_FLAG_LEVEL_CRITICAL;
|
||||
/* Send battery critical host event */
|
||||
if (prev->batt.state_of_charge > BATTERY_LEVEL_CRITICAL)
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(
|
||||
EC_HOST_EVENT_BATTERY_CRITICAL));
|
||||
host_set_single_event(EC_HOST_EVENT_BATTERY_CRITICAL);
|
||||
} else
|
||||
*ctx->memmap_batt_flags &= ~EC_BATT_FLAG_LEVEL_CRITICAL;
|
||||
|
||||
@@ -270,8 +264,7 @@ static enum power_state state_init(struct power_state_context *ctx)
|
||||
update_battery_info();
|
||||
|
||||
/* Send battery event to host */
|
||||
lpc_set_host_events(EC_HOST_EVENT_MASK(
|
||||
EC_HOST_EVENT_BATTERY));
|
||||
host_set_single_event(EC_HOST_EVENT_BATTERY);
|
||||
|
||||
return PWR_STATE_IDLE;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,39 @@
|
||||
#include "lpc.h"
|
||||
#include "util.h"
|
||||
|
||||
uint32_t host_get_events(void)
|
||||
{
|
||||
#ifdef CONFIG_LPC
|
||||
return lpc_get_host_events();
|
||||
#else
|
||||
uint32_t *mapped_raw_events =
|
||||
(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS);
|
||||
return *mapped_raw_events;
|
||||
#endif
|
||||
}
|
||||
|
||||
void host_set_events(uint32_t mask)
|
||||
{
|
||||
#ifdef CONFIG_LPC
|
||||
lpc_set_host_events(mask);
|
||||
#else
|
||||
uint32_t *mapped_raw_events =
|
||||
(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS);
|
||||
*mapped_raw_events |= mask;
|
||||
#endif
|
||||
}
|
||||
|
||||
void host_clear_events(uint32_t mask)
|
||||
{
|
||||
#ifdef CONFIG_LPC
|
||||
lpc_clear_host_events(mask);
|
||||
#else
|
||||
uint32_t *mapped_raw_events =
|
||||
(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS);
|
||||
*mapped_raw_events &= ~mask;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Console commands */
|
||||
|
||||
@@ -23,27 +56,31 @@ static int command_host_event(int argc, char **argv)
|
||||
return EC_ERROR_PARAM2;
|
||||
|
||||
if (!strcasecmp(argv[1], "set"))
|
||||
lpc_set_host_events(i);
|
||||
host_set_events(i);
|
||||
else if (!strcasecmp(argv[1], "clear"))
|
||||
lpc_clear_host_events(i);
|
||||
host_clear_events(i);
|
||||
#ifdef CONFIG_LPC
|
||||
else if (!strcasecmp(argv[1], "smi"))
|
||||
lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, i);
|
||||
else if (!strcasecmp(argv[1], "sci"))
|
||||
lpc_set_host_event_mask(LPC_HOST_EVENT_SCI, i);
|
||||
else if (!strcasecmp(argv[1], "wake"))
|
||||
lpc_set_host_event_mask(LPC_HOST_EVENT_WAKE, i);
|
||||
#endif
|
||||
else
|
||||
return EC_ERROR_PARAM1;
|
||||
}
|
||||
|
||||
/* Print current SMI/SCI status */
|
||||
ccprintf("Events: 0x%08x\n", lpc_get_host_events());
|
||||
ccprintf("Events: 0x%08x\n", host_get_events());
|
||||
#ifdef CONFIG_LPC
|
||||
ccprintf("SMI mask: 0x%08x\n",
|
||||
lpc_get_host_event_mask(LPC_HOST_EVENT_SMI));
|
||||
ccprintf("SCI mask: 0x%08x\n",
|
||||
lpc_get_host_event_mask(LPC_HOST_EVENT_SCI));
|
||||
ccprintf("Wake mask: 0x%08x\n",
|
||||
lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE));
|
||||
#endif
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(hostevent, command_host_event,
|
||||
@@ -54,6 +91,8 @@ DECLARE_CONSOLE_COMMAND(hostevent, command_host_event,
|
||||
/*****************************************************************************/
|
||||
/* Host commands */
|
||||
|
||||
#ifdef CONFIG_LPC
|
||||
|
||||
static int host_event_get_smi_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
struct ec_response_host_event_mask *r =
|
||||
@@ -66,7 +105,6 @@ static int host_event_get_smi_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_SMI_MASK,
|
||||
host_event_get_smi_mask);
|
||||
|
||||
|
||||
static int host_event_get_sci_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
struct ec_response_host_event_mask *r =
|
||||
@@ -79,7 +117,6 @@ static int host_event_get_sci_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_SCI_MASK,
|
||||
host_event_get_sci_mask);
|
||||
|
||||
|
||||
static int host_event_get_wake_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
struct ec_response_host_event_mask *r =
|
||||
@@ -92,7 +129,6 @@ static int host_event_get_wake_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_GET_WAKE_MASK,
|
||||
host_event_get_wake_mask);
|
||||
|
||||
|
||||
static int host_event_set_smi_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
const struct ec_params_host_event_mask *p =
|
||||
@@ -104,7 +140,6 @@ static int host_event_set_smi_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_SMI_MASK,
|
||||
host_event_set_smi_mask);
|
||||
|
||||
|
||||
static int host_event_set_sci_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
const struct ec_params_host_event_mask *p =
|
||||
@@ -116,7 +151,6 @@ static int host_event_set_sci_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_SCI_MASK,
|
||||
host_event_set_sci_mask);
|
||||
|
||||
|
||||
static int host_event_set_wake_mask(uint8_t *data, int *resp_size)
|
||||
{
|
||||
const struct ec_params_host_event_mask *p =
|
||||
@@ -128,13 +162,14 @@ static int host_event_set_wake_mask(uint8_t *data, int *resp_size)
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_SET_WAKE_MASK,
|
||||
host_event_set_wake_mask);
|
||||
|
||||
#endif /* CONFIG_LPC */
|
||||
|
||||
static int host_event_clear(uint8_t *data, int *resp_size)
|
||||
{
|
||||
const struct ec_params_host_event_mask *p =
|
||||
(const struct ec_params_host_event_mask *)data;
|
||||
|
||||
lpc_clear_host_events(p->mask);
|
||||
host_clear_events(p->mask);
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_EVENT_CLEAR, host_event_clear);
|
||||
|
||||
@@ -263,7 +263,8 @@ void keyboard_clear_underlying_buffer(void)
|
||||
}
|
||||
|
||||
|
||||
/* TODO: Move this implementation to platform-dependent files.
|
||||
/*
|
||||
* TODO: Move this implementation to platform-dependent files.
|
||||
* We don't do it now because not every board implement x86_power.c
|
||||
* bds: no CONFIG_LPC and no CONFIG_TASK_X86POWER
|
||||
* daisy(variants): no CONFIG_LPC and no CONFIG_TASK_X86POWER
|
||||
@@ -271,10 +272,7 @@ void keyboard_clear_underlying_buffer(void)
|
||||
*/
|
||||
static void keyboard_wakeup(void)
|
||||
{
|
||||
#ifdef CONFIG_LPC
|
||||
lpc_set_host_events(
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED));
|
||||
#endif
|
||||
host_set_single_event(EC_HOST_EVENT_KEY_PRESSED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
|
||||
/* Thermal engine module for Chrome EC */
|
||||
|
||||
#include "board.h"
|
||||
#include "chipset.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "gpio.h"
|
||||
#include "lpc.h"
|
||||
#include "ec_commands.h"
|
||||
#include "host_command.h"
|
||||
#include "pwm.h"
|
||||
#include "task.h"
|
||||
#include "temp_sensor.h"
|
||||
@@ -89,18 +88,14 @@ int thermal_toggle_auto_fan_ctrl(int auto_fan_on)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void smi_overheated_warning(void)
|
||||
{
|
||||
lpc_set_host_events(
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_OVERLOAD));
|
||||
host_set_single_event(EC_HOST_EVENT_THERMAL_OVERLOAD);
|
||||
}
|
||||
|
||||
|
||||
static void smi_sensor_failure_warning(void)
|
||||
{
|
||||
lpc_set_host_events(
|
||||
EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL));
|
||||
host_set_single_event(EC_HOST_EVENT_THERMAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,11 +46,42 @@ uint8_t *host_get_memmap(int offset);
|
||||
enum ec_status host_command_process(int slot, int command, uint8_t *data,
|
||||
int *response_size);
|
||||
|
||||
/* Called by LPC module when a command is written to one of the
|
||||
command slots (0=kernel, 1=user). */
|
||||
/**
|
||||
* Set one or more host event bits.
|
||||
*
|
||||
* @param mask Event bits to set (use EC_HOST_EVENT_MASK()).
|
||||
*/
|
||||
void host_set_events(uint32_t mask);
|
||||
|
||||
/**
|
||||
* Set a single host event.
|
||||
*
|
||||
* @param event Event to set (EC_HOST_EVENT_*).
|
||||
*/
|
||||
static inline void host_set_single_event(int event)
|
||||
{
|
||||
host_set_events(EC_HOST_EVENT_MASK(event));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear one or more host event bits.
|
||||
*
|
||||
* @param mask Event bits to clear (use EC_HOST_EVENT_MASK()).
|
||||
* Write 1 to a bit to clear it.
|
||||
*/
|
||||
void host_clear_events(uint32_t mask);
|
||||
|
||||
/**
|
||||
* Return the raw SCI/SMI event state.
|
||||
*/
|
||||
uint32_t host_get_events(void);
|
||||
|
||||
/**
|
||||
* Called by host interface module when a command is written to one of the
|
||||
* command slots (0=kernel, 1=user).
|
||||
*/
|
||||
void host_command_received(int slot, int command);
|
||||
|
||||
// success results with response data
|
||||
/* Send a successful result code along with response data to a host command.
|
||||
* <slot> is 0 for kernel-originated commands,
|
||||
* 1 for usermode-originated commands.
|
||||
|
||||
Reference in New Issue
Block a user