mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
ryu: add a dummy power module for controlling sensors.
With this change we can use power event to configure sensors and trigger motion detection in suspend. BUG=chrome-os-partner:31071 BRANCH=ToT TEST=Check power states. Check power up messages and commands are present at the console. Message at boot: [0.007142 hash start 0x00010000 0x000096dd] [0.007293 Inits done] [0.007506 power state 2 = S3, in 0x0000] [0.007765 power state 3 = S0, in 0x0000] [0.007908 event set 0x00002000] [0.008021 hostcmd init 0x2000] [0.146870 hash done f87d7824b439db923d270df016af5aabec51b73505b7c4faa6e40c16b12dd392] Change-Id: I9c56fe5203506462f0820bbc8a5fe4528f6805ac Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226881 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
4b154c6f95
commit
3bdd18d246
@@ -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,
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
55
power/ec_driven.c
Normal file
55
power/ec_driven.c
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user