summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-03 15:55:09 -0700
committerGerrit <chrome-bot@google.com>2012-07-07 17:36:46 -0700
commite129d5f1fa1a686c6f06aecbcc28e27cc8334483 (patch)
tree7e7d22a5824f29a023da6e5ef6800dbc415d3471 /common
parent7f5f7be3e5df92ec2e9447b3d5d0b8ddeb96c9a0 (diff)
downloadchrome-ec-e129d5f1fa1a686c6f06aecbcc28e27cc8334483.tar.gz
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
Diffstat (limited to 'common')
-rw-r--r--common/build.mk4
-rw-r--r--common/charge_state.c17
-rw-r--r--common/host_event_commands.c53
-rw-r--r--common/keyboard.c8
-rw-r--r--common/thermal.c13
5 files changed, 58 insertions, 37 deletions
diff --git a/common/build.mk b/common/build.mk
index cecfc60a8a..b417d39bff 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -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
diff --git a/common/charge_state.c b/common/charge_state.c
index 128a1db293..02c33833a6 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -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;
}
diff --git a/common/host_event_commands.c b/common/host_event_commands.c
index 507d603f7b..0d87fcac38 100644
--- a/common/host_event_commands.c
+++ b/common/host_event_commands.c
@@ -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);
diff --git a/common/keyboard.c b/common/keyboard.c
index 3fb619f0af..3ceab3548c 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -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);
}
diff --git a/common/thermal.c b/common/thermal.c
index d95df670dd..fa54b3123b 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -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);
}