mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
First implementation of a low power idle task for the LM4 chip. The low power mode is selected by defining CONFIG_LOW_POWER_IDLE in a board.h file. This commit turns it on for Peppy, Slippy, and Falco only because those are the only boards tested. When using the low power idle task, the chip goes in to deep sleep when it can. Deep sleep disables clocks to most peripherals and puts the onboard flash and RAM into a low power mode. The chip is woken out of deep sleep using the RTC in the hibernate module. Increased the idle task stack size to handle more involved idle task. In board.c, the array of GPIO info can be used to select which GPIO points can wake up the EC from deep sleep. Currenlty selected are the power button, lid open, AC present, PCH_SLP_S3, and PCH_SLP_S5. Additionally the port with the KB scan row GPIO point is also enabled to wake up the EC from deep sleep. Signed-off-by: Alec Berg <alecaberg@chromium.org> BUG=None BRANCH=none TEST=Passes all unit tests. Runs on slippy, peppy, and falco with no noticeable side affects. Verified that the power consumed by the EC is lower when in S3, S5 and G3 by scoping the sense resistor powering the chip. Change-Id: I83fa9a159a4b79201b99f2c32678dc4fc8921726 Reviewed-on: https://chromium-review.googlesource.com/172183 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
128 lines
2.6 KiB
C
128 lines
2.6 KiB
C
/* Copyright (c) 2012 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.
|
|
*/
|
|
|
|
/* Console output module for Chrome EC */
|
|
|
|
#include "console.h"
|
|
#include "uart.h"
|
|
#include "util.h"
|
|
|
|
/* Default to all channels active */
|
|
#ifndef CC_DEFAULT
|
|
#define CC_DEFAULT CC_ALL
|
|
#endif
|
|
static uint32_t channel_mask = CC_DEFAULT;
|
|
static uint32_t channel_mask_saved = CC_DEFAULT;
|
|
|
|
/* List of channel names; must match enum console_channel. */
|
|
/* TODO: move this to board.c */
|
|
static const char * const channel_names[] = {
|
|
"command",
|
|
"charger",
|
|
"chipset",
|
|
"clock",
|
|
"dma",
|
|
"events",
|
|
"gpio",
|
|
"hostcmd",
|
|
"i2c",
|
|
"keyboard",
|
|
"keyscan",
|
|
"lightbar",
|
|
"lpc",
|
|
"port80",
|
|
"pwm",
|
|
"spi",
|
|
"switch",
|
|
"system",
|
|
"task",
|
|
"thermal",
|
|
"usbcharge",
|
|
"vboot",
|
|
"hook",
|
|
};
|
|
BUILD_ASSERT(ARRAY_SIZE(channel_names) == CC_CHANNEL_COUNT);
|
|
|
|
/*****************************************************************************/
|
|
/* Channel-based console output */
|
|
|
|
int cputs(enum console_channel channel, const char *outstr)
|
|
{
|
|
/* Filter out inactive channels */
|
|
if (!(CC_MASK(channel) & channel_mask))
|
|
return EC_SUCCESS;
|
|
|
|
return uart_puts(outstr);
|
|
}
|
|
|
|
int cprintf(enum console_channel channel, const char *format, ...)
|
|
{
|
|
int rv;
|
|
va_list args;
|
|
|
|
/* Filter out inactive channels */
|
|
if (!(CC_MASK(channel) & channel_mask))
|
|
return EC_SUCCESS;
|
|
|
|
va_start(args, format);
|
|
rv = uart_vprintf(format, args);
|
|
va_end(args);
|
|
return rv;
|
|
}
|
|
|
|
void cflush(void)
|
|
{
|
|
uart_flush_output();
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/* Console commands */
|
|
|
|
/* Set active channels */
|
|
static int command_ch(int argc, char **argv)
|
|
{
|
|
int i;
|
|
char *e;
|
|
|
|
/* If one arg, save / restore, or set the mask */
|
|
if (argc == 2) {
|
|
if (strcasecmp(argv[1], "save") == 0) {
|
|
channel_mask_saved = channel_mask;
|
|
return EC_SUCCESS;
|
|
} else if (strcasecmp(argv[1], "restore") == 0) {
|
|
channel_mask = channel_mask_saved;
|
|
return EC_SUCCESS;
|
|
|
|
} else {
|
|
/* Set the mask */
|
|
int m = strtoi(argv[1], &e, 0);
|
|
if (*e)
|
|
return EC_ERROR_PARAM1;
|
|
|
|
/* No disabling the command output channel */
|
|
channel_mask = m | CC_MASK(CC_COMMAND);
|
|
|
|
/* TODO: save channel list to EEPROM */
|
|
|
|
return EC_SUCCESS;
|
|
}
|
|
}
|
|
|
|
/* Print the list of channels */
|
|
ccputs(" # Mask E Channel\n");
|
|
for (i = 0; i < CC_CHANNEL_COUNT; i++) {
|
|
ccprintf("%2d %08x %c %s\n",
|
|
i, CC_MASK(i),
|
|
(channel_mask & CC_MASK(i)) ? '*' : ' ',
|
|
channel_names[i]);
|
|
cflush();
|
|
}
|
|
return EC_SUCCESS;
|
|
};
|
|
DECLARE_CONSOLE_COMMAND(chan, command_ch,
|
|
"[ save | restore | <mask> ]",
|
|
"Save, restore, get or set console channel mask",
|
|
NULL);
|