summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/ryu_sh/board.c7
-rw-r--r--board/ryu_sh/board.h12
-rw-r--r--board/ryu_sh/ec.tasklist1
-rw-r--r--board/ryu_sh/gpio.inc2
-rw-r--r--common/chipset.c2
-rw-r--r--include/config.h4
-rw-r--r--power/build.mk1
-rw-r--r--power/common.c2
-rw-r--r--power/ec_driven.c55
9 files changed, 85 insertions, 1 deletions
diff --git a/board/ryu_sh/board.c b/board/ryu_sh/board.c
index 8a0ffe7968..c6af0f8388 100644
--- a/board/ryu_sh/board.c
+++ b/board/ryu_sh/board.c
@@ -9,6 +9,7 @@
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "power.h"
#include "registers.h"
#include "task.h"
#include "util.h"
@@ -21,6 +22,12 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+/* power signal list. Must match order of enum power_signal. */
+const struct power_signal_info power_signal_list[] = {
+ {GPIO_AP_IN_SUSPEND, 1, "SUSPEND_ASSERTED"},
+};
+BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
+
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
{"master", I2C_PORT_MASTER, 100,
diff --git a/board/ryu_sh/board.h b/board/ryu_sh/board.h
index fa30c89760..7db8da45b3 100644
--- a/board/ryu_sh/board.h
+++ b/board/ryu_sh/board.h
@@ -19,10 +19,15 @@
#define CC_DEFAULT CC_ALL
/* Optional features */
+#undef CONFIG_EXTPOWER
+#undef CONFIG_HIBERNATE
#define CONFIG_STM_HWTIMER32
#define CONFIG_I2C
#define CONFIG_BOARD_PRE_INIT
#undef CONFIG_LID_SWITCH
+#undef CONFIG_CMD_POWER_AP
+#define CONFIG_POWER_COMMON
+#define CONFIG_CHIPSET_ECDRIVEN
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
@@ -46,6 +51,13 @@
#include "gpio_signal.h"
+enum power_signal {
+ ECDRIVEN_SUSPEND_ASSERTED,
+
+ /* Number of power signals */
+ POWER_SIGNAL_COUNT
+};
+
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */
diff --git a/board/ryu_sh/ec.tasklist b/board/ryu_sh/ec.tasklist
index aaed7865c8..a3fe8448af 100644
--- a/board/ryu_sh/ec.tasklist
+++ b/board/ryu_sh/ec.tasklist
@@ -19,4 +19,5 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)
diff --git a/board/ryu_sh/gpio.inc b/board/ryu_sh/gpio.inc
index c1f4357910..4f3ecf9ca1 100644
--- a/board/ryu_sh/gpio.inc
+++ b/board/ryu_sh/gpio.inc
@@ -6,6 +6,7 @@
*/
/* Interrupts */
+GPIO(AP_IN_SUSPEND, E, 9, GPIO_INT_BOTH, power_signal_interrupt)
/*
* TODO(gwendal): Follow Rambus work.
* Combined accelerometer input. This will become an interrupt, once we have
@@ -21,7 +22,6 @@ GPIO(SH_IRQ_L, A, 11, GPIO_OUT_LOW, NULL)
GPIO(LID_CLOSED, A, 2, GPIO_INPUT, NULL)
GPIO(BASE_PRESENT, A, 3, GPIO_INPUT, NULL)
GPIO(COMPASS_DRDY, B, 11, GPIO_INPUT, NULL)
-GPIO(AP_IN_SUSPEND, B, 15, GPIO_INPUT, NULL)
#if 0
/* Alternate functions */
diff --git a/common/chipset.c b/common/chipset.c
index 6c98945aad..c62fb6ec7a 100644
--- a/common/chipset.c
+++ b/common/chipset.c
@@ -17,6 +17,7 @@
/*****************************************************************************/
/* Console commands */
+#ifdef CONFIG_CMD_POWER_AP
static int command_apreset(int argc, char **argv)
{
int is_cold = 1;
@@ -45,3 +46,4 @@ DECLARE_CONSOLE_COMMAND(apshutdown, command_apshutdown,
NULL,
"Force AP shutdown",
NULL);
+#endif
diff --git a/include/config.h b/include/config.h
index b0e2536e2a..b3e753843d 100644
--- a/include/config.h
+++ b/include/config.h
@@ -327,6 +327,7 @@
#define CONFIG_CMD_PD
#undef CONFIG_CMD_PLL
#undef CONFIG_CMD_PMU
+#define CONFIG_CMD_POWER_AP
#define CONFIG_CMD_POWERINDEBUG
#undef CONFIG_CMD_POWERLED
#undef CONFIG_CMD_RTC_ALARM
@@ -480,6 +481,9 @@
*/
#undef CONFIG_EOPTION
+/* Include code for handling external power */
+#define CONFIG_EXTPOWER
+
/* Support turbo-mode chargers */
#undef CONFIG_EXTPOWER_FALCO
diff --git a/power/build.mk b/power/build.mk
index 5e62330490..8d2d10ff8c 100644
--- a/power/build.mk
+++ b/power/build.mk
@@ -7,6 +7,7 @@
#
power-$(CONFIG_CHIPSET_BAYTRAIL)+=baytrail.o
+power-$(CONFIG_CHIPSET_ECDRIVEN)+=ec_driven.o
power-$(CONFIG_CHIPSET_GAIA)+=gaia.o
power-$(CONFIG_CHIPSET_HASWELL)+=haswell.o
power-$(CONFIG_CHIPSET_IVYBRIDGE)+=ivybridge.o
diff --git a/power/common.c b/power/common.c
index e08fcf369c..b1bced365d 100644
--- a/power/common.c
+++ b/power/common.c
@@ -328,6 +328,7 @@ static void power_lid_change(void)
}
DECLARE_HOOK(HOOK_LID_CHANGE, power_lid_change, HOOK_PRIO_DEFAULT);
+#ifdef CONFIG_EXTPOWER
static void power_ac_change(void)
{
if (extpower_is_present()) {
@@ -342,6 +343,7 @@ static void power_ac_change(void)
}
}
DECLARE_HOOK(HOOK_AC_CHANGE, power_ac_change, HOOK_PRIO_DEFAULT);
+#endif
/*****************************************************************************/
/* Interrupts */
diff --git a/power/ec_driven.c b/power/ec_driven.c
new file mode 100644
index 0000000000..67cfefb95e
--- /dev/null
+++ b/power/ec_driven.c
@@ -0,0 +1,55 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * Dummy power module for Sensor HUB.
+ *
+ * This implements the following features:
+ * when AP_IN_SUSPEND is low, in S0, otherwise S3.
+ *
+ */
+
+#include "chipset.h" /* This module implements chipset functions too */
+#include "common.h"
+#include "console.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "power.h"
+#include "task.h"
+#include "util.h"
+
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+
+#define IN_SUSPEND POWER_SIGNAL_MASK(ECDRIVEN_SUSPEND_ASSERTED)
+
+enum power_state power_chipset_init(void)
+{
+ return POWER_S3;
+}
+
+enum power_state power_handle_state(enum power_state state)
+{
+ switch (state) {
+ case POWER_S3:
+ if (!(power_get_signals() & IN_SUSPEND)) {
+ hook_notify(HOOK_CHIPSET_RESUME);
+ return POWER_S0;
+ }
+ return state;
+
+ case POWER_S0:
+ if (power_get_signals() & IN_SUSPEND) {
+ hook_notify(HOOK_CHIPSET_SUSPEND);
+ return POWER_S3;
+ }
+ return state;
+ default:
+ CPRINTS("Unexpected state: $d", state);
+ }
+
+ return state;
+}