summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-05-19 15:03:27 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-21 20:32:17 +0000
commitffac23c0ea1bd4ff4568f5bd709a98f912b833a7 (patch)
tree362dd0ba205731aa07be97dd35b44b237799b23b /power
parent478361de694b1fb45abf3c38dafbbf7fd1aa5f71 (diff)
downloadchrome-ec-ffac23c0ea1bd4ff4568f5bd709a98f912b833a7.tar.gz
Add cprints() and ccprints()
Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/baytrail.c16
-rw-r--r--power/common.c20
-rw-r--r--power/gaia.c38
-rw-r--r--power/haswell.c10
-rw-r--r--power/ivybridge.c8
-rw-r--r--power/tegra.c50
6 files changed, 71 insertions, 71 deletions
diff --git a/power/baytrail.c b/power/baytrail.c
index d0289aabc2..c84e74130a 100644
--- a/power/baytrail.c
+++ b/power/baytrail.c
@@ -24,7 +24,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/* Input state flags */
#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000)
@@ -58,7 +58,7 @@ static int fake_pltrst_timeout; /* Fake PLTRST# timeout at next power-on */
void chipset_force_shutdown(void)
{
- CPRINTF("[%T %s()]\n", __func__);
+ CPRINTS("%s()", __func__);
/*
* Force power off. This condition will reset once the state machine
@@ -70,7 +70,7 @@ void chipset_force_shutdown(void)
void chipset_reset(int cold_reset)
{
- CPRINTF("[%T %s(%d)]\n", __func__, cold_reset);
+ CPRINTS("%s(%d)", __func__, cold_reset);
if (cold_reset) {
/*
* Drop and restore PWROK. This causes the PCH to reboot,
@@ -120,11 +120,11 @@ enum power_state power_chipset_init(void)
/* Disable idle task deep sleep when in S0. */
disable_sleep(SLEEP_MASK_AP_RUN);
- CPRINTF("[%T already in S0]\n");
+ CPRINTS("already in S0");
return POWER_S0;
} else {
/* Force all signals to their G3 states */
- CPRINTF("[%T forcing G3]\n");
+ CPRINTS("forcing G3");
gpio_set_level(GPIO_PCH_CORE_PWROK, 0);
gpio_set_level(GPIO_VCORE_EN, 0);
gpio_set_level(GPIO_SUSP_VR_EN, 0);
@@ -299,10 +299,10 @@ enum power_state power_handle_state(enum power_state state)
if (i < 50 && !fake_pltrst_timeout) {
/* Deasserted in time */
- CPRINTF("[%T power PLTRST# deasserted]\n");
+ CPRINTS("power PLTRST# deasserted");
} else {
/* Force a reset. See crosbug.com/p/28422 */
- CPRINTF("[%T power PLTRST# timeout]\n");
+ CPRINTS("power PLTRST# timeout");
power_button_pch_release();
chipset_force_shutdown();
restart_from_s5 = 1;
@@ -381,7 +381,7 @@ enum power_state power_handle_state(enum power_state state)
* See crosbug.com/p/28422.
*/
if (restart_from_s5) {
- CPRINTF("[%T power restart from S5]\n");
+ CPRINTS("power restart from S5");
restart_from_s5 = 0;
diff --git a/power/common.c b/power/common.c
index 1a4a906a88..1dffd64163 100644
--- a/power/common.c
+++ b/power/common.c
@@ -19,7 +19,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/*
* Default timeout in us; if we've been waiting this long for an input
@@ -69,7 +69,7 @@ static void power_update_signals(void)
}
if ((in_signals & in_debug) != (inew & in_debug))
- CPRINTF("[%T power in 0x%04x]\n", inew);
+ CPRINTS("power in 0x%04x", inew);
in_signals = inew;
}
@@ -84,7 +84,7 @@ int power_has_signals(uint32_t want)
if ((in_signals & want) == want)
return 1;
- CPRINTF("[%T power lost input; wanted 0x%04x, got 0x%04x]\n",
+ CPRINTS("power lost input; wanted 0x%04x, got 0x%04x",
want, in_signals & want);
return 0;
@@ -99,8 +99,8 @@ int power_wait_signals(uint32_t want)
while ((in_signals & in_want) != in_want) {
if (task_wait_event(DEFAULT_TIMEOUT) == TASK_EVENT_TIMER) {
power_update_signals();
- CPRINTF("[%T power timeout on input; "
- "wanted 0x%04x, got 0x%04x]\n",
+ CPRINTS("power timeout on input; "
+ "wanted 0x%04x, got 0x%04x",
in_want, in_signals & in_want);
return EC_ERROR_TIMEOUT;
}
@@ -150,7 +150,7 @@ static enum power_state power_common_state(enum power_state state)
* Time's up. Hibernate until wake pin
* asserted.
*/
- CPRINTF("[%T hibernating]\n");
+ CPRINTS("hibernating");
system_hibernate(0, 0);
} else {
uint64_t wait = target_time - time_now;
@@ -262,7 +262,7 @@ void chipset_task(void)
enum power_state new_state;
while (1) {
- CPRINTF("[%T power state %d = %s, in 0x%04x]\n",
+ CPRINTS("power state %d = %s, in 0x%04x",
state, state_names[state], in_signals);
/* Always let the specific chipset handle the state first */
@@ -317,9 +317,9 @@ DECLARE_HOOK(HOOK_LID_CHANGE, power_lid_change, HOOK_PRIO_DEFAULT);
static void power_ac_change(void)
{
if (extpower_is_present()) {
- CPRINTF("[%T AC on]\n");
+ CPRINTS("AC on");
} else {
- CPRINTF("[%T AC off]\n");
+ CPRINTS("AC off");
if (state == POWER_G3) {
last_shutdown_time = get_time().val;
@@ -350,7 +350,7 @@ static int command_powerinfo(int argc, char **argv)
* Print power state in same format as state machine. This is
* used by FAFT tests, so must match exactly.
*/
- ccprintf("[%T power state %d = %s, in 0x%04x]\n",
+ ccprints("power state %d = %s, in 0x%04x",
state, state_names[state], in_signals);
return EC_SUCCESS;
diff --git a/power/gaia.c b/power/gaia.c
index d115e2d52c..553b01bfcc 100644
--- a/power/gaia.c
+++ b/power/gaia.c
@@ -41,7 +41,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/* Time necessary for the 5V and 3.3V regulator outputs to stabilize */
#ifdef BOARD_PIT
@@ -152,7 +152,7 @@ static int wait_in_signal(enum gpio_signal signal, int value, int timeout)
} else if (timestamp_expired(deadline, &now) ||
(task_wait_event(deadline.val - now.val) ==
TASK_EVENT_TIMER)) {
- CPRINTF("[%T power timeout waiting for GPIO %d/%s]\n",
+ CPRINTS("power timeout waiting for GPIO %d/%s",
signal, gpio_get_name(signal));
return EC_ERROR_TIMEOUT;
}
@@ -212,16 +212,16 @@ static int check_for_power_off_event(void)
if (!power_button_was_pressed) {
power_off_deadline.val = now.val + DELAY_FORCE_SHUTDOWN;
- CPRINTF("[%T power waiting for long press %u]\n",
+ CPRINTS("power waiting for long press %u",
power_off_deadline.le.lo);
} else if (timestamp_expired(power_off_deadline, &now)) {
power_off_deadline.val = 0;
- CPRINTF("[%T power off after long press now=%u, %u]\n",
+ CPRINTS("power off after long press now=%u, %u",
now.le.lo, power_off_deadline.le.lo);
return 2;
}
} else if (power_button_was_pressed) {
- CPRINTF("[%T power off cancel]\n");
+ CPRINTS("power off cancel");
set_pmic_pwrok(0);
}
@@ -316,7 +316,7 @@ static int gaia_power_init(void)
/* Leave power off only if requested by reset flags */
if (!(system_get_reset_flags() & RESET_FLAG_AP_OFF)) {
- CPRINTF("[%T auto_power_on is set due to reset_flag 0x%x]\n",
+ CPRINTS("auto_power_on is set due to reset_flag 0x%x",
system_get_reset_flags());
auto_power_on = 1;
}
@@ -329,7 +329,7 @@ static int gaia_power_init(void)
* See crosbug.com/p/22233.
*/
if (!(system_get_reset_flags() & RESET_FLAG_SYSJUMP)) {
- CPRINTF("[%T not sysjump; forcing AP reset]\n");
+ CPRINTS("not sysjump; forcing AP reset");
gpio_set_level(GPIO_AP_RESET_L, 0);
udelay(1000);
gpio_set_level(GPIO_AP_RESET_L, 1);
@@ -375,7 +375,7 @@ void chipset_reset(int is_cold)
* TODO(crosbug.com/p/23822): Implement cold reset. For now, all
* resets are warm resets.
*/
- CPRINTF("[%T EC triggered warm reboot]\n");
+ CPRINTS("EC triggered warm reboot");
/*
* This is a hack to do an AP warm reboot while still preserving RAM
@@ -434,7 +434,7 @@ static int check_for_power_on_event(void)
{
/* Check if we've already powered the system on */
if (gpio_get_level(GPIO_EN_PP3300)) {
- CPRINTF("[%T system is on, thus clear auto_power_on]\n");
+ CPRINTS("system is on, thus clear auto_power_on");
auto_power_on = 0; /* no need to arrange another power on */
return 1;
}
@@ -510,7 +510,7 @@ static int power_on(void)
gpio_set_level(GPIO_EN_PP5000, 0);
gpio_set_level(GPIO_EN_PP3300, 0);
usleep(DELAY_5V_SETUP);
- CPRINTF("[%T power error: PMIC failed to enable]\n");
+ CPRINTS("power error: PMIC failed to enable");
return -1;
}
@@ -529,7 +529,7 @@ static int power_on(void)
/* Call hooks now that AP is running */
hook_notify(HOOK_CHIPSET_STARTUP);
- CPRINTF("[%T AP running ...]\n");
+ CPRINTS("AP running ...");
return 0;
}
@@ -545,10 +545,10 @@ static int wait_for_power_button_release(unsigned int timeout_us)
udelay(KB_PWR_ON_DEBOUNCE);
if (gpio_get_level(GPIO_KB_PWR_ON_L) == 0) {
- CPRINTF("[%T power button not released in time]\n");
+ CPRINTS("power button not released in time");
return -1;
}
- CPRINTF("[%T power button released]\n");
+ CPRINTS("power button released");
return 0;
}
@@ -564,10 +564,10 @@ static int react_to_xpshold(unsigned int timeout_us)
wait_in_signal(GPIO_SOC1V8_XPSHOLD, 1, timeout_us);
if (gpio_get_level(GPIO_SOC1V8_XPSHOLD) == 0) {
- CPRINTF("[%T XPSHOLD not seen in time]\n");
+ CPRINTS("XPSHOLD not seen in time");
return -1;
}
- CPRINTF("[%T XPSHOLD seen]\n");
+ CPRINTS("XPSHOLD seen");
set_pmic_pwrok(0);
return 0;
}
@@ -589,7 +589,7 @@ static void power_off(void)
#ifdef CONFIG_PMU_TPS65090
pmu_shutdown();
#endif
- CPRINTF("[%T power shutdown complete]\n");
+ CPRINTS("power shutdown complete");
}
@@ -627,12 +627,12 @@ static int wait_for_power_on(void)
* shutdown the system from EC.
*/
if (value != 1 && charge_keep_power_off()) {
- CPRINTF("[%T power on ignored due to low battery]\n");
+ CPRINTS("power on ignored due to low battery");
continue;
}
#endif
- CPRINTF("[%T power on %d]\n", value);
+ CPRINTS("power on %d", value);
return value;
}
}
@@ -668,7 +668,7 @@ void chipset_task(void)
power_button_was_pressed = 0;
while (!(value = check_for_power_off_event()))
task_wait_event(next_pwr_event());
- CPRINTF("[%T power ending loop %d]\n", value);
+ CPRINTS("power ending loop %d", value);
}
}
power_off();
diff --git a/power/haswell.c b/power/haswell.c
index b5250379ad..ae7cf7a14a 100644
--- a/power/haswell.c
+++ b/power/haswell.c
@@ -21,7 +21,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/* Input state flags */
#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000)
@@ -56,7 +56,7 @@ static int pause_in_s5; /* Pause in S5 when shutting down? */
void chipset_force_shutdown(void)
{
- CPRINTF("[%T %s()]\n", __func__);
+ CPRINTS("%s()", __func__);
/*
* Force power off. This condition will reset once the state machine
@@ -68,7 +68,7 @@ void chipset_force_shutdown(void)
void chipset_reset(int cold_reset)
{
- CPRINTF("[%T %s(%d)]\n", __func__, cold_reset);
+ CPRINTS("%s(%d)", __func__, cold_reset);
if (cold_reset) {
/*
* Drop and restore PWROK. This causes the PCH to reboot,
@@ -131,11 +131,11 @@ enum power_state power_chipset_init(void)
if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) {
/* Disable idle task deep sleep when in S0. */
disable_sleep(SLEEP_MASK_AP_RUN);
- CPRINTF("[%T already in S0]\n");
+ CPRINTS("already in S0");
return POWER_S0;
} else {
/* Force all signals to their G3 states */
- CPRINTF("[%T forcing G3]\n");
+ CPRINTS("forcing G3");
gpio_set_level(GPIO_PCH_PWROK, 0);
gpio_set_level(GPIO_VCORE_EN, 0);
gpio_set_level(GPIO_SUSP_VR_EN, 0);
diff --git a/power/ivybridge.c b/power/ivybridge.c
index 10086a862a..163afb330b 100644
--- a/power/ivybridge.c
+++ b/power/ivybridge.c
@@ -19,7 +19,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/* Input state flags */
#define IN_PGOOD_5VALW POWER_SIGNAL_MASK(X86_PGOOD_5VALW)
@@ -62,7 +62,7 @@ static int throttle_cpu; /* Throttle CPU? */
void chipset_force_shutdown(void)
{
- CPRINTF("[%T chipset force shutdown]\n");
+ CPRINTS("chipset force shutdown");
/*
* Force power off. This condition will reset once the state machine
@@ -124,11 +124,11 @@ enum power_state power_chipset_init(void)
*/
if (system_jumped_to_this_image()) {
if ((power_get_signals() & IN_ALL_S0) == IN_ALL_S0) {
- CPRINTF("[%T already in S0]\n");
+ CPRINTS("already in S0");
return POWER_S0;
} else {
/* Force all signals to their G3 states */
- CPRINTF("[%T forcing G3]\n");
+ CPRINTS("forcing G3");
gpio_set_level(GPIO_PCH_PWROK, 0);
gpio_set_level(GPIO_ENABLE_VCORE, 0);
gpio_set_level(GPIO_ENABLE_VS, 0);
diff --git a/power/tegra.c b/power/tegra.c
index dac1d2f475..41c1e83b16 100644
--- a/power/tegra.c
+++ b/power/tegra.c
@@ -45,7 +45,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
/* masks for power signals */
#define IN_XPSHOLD POWER_SIGNAL_MASK(TEGRA_XPSHOLD)
@@ -196,16 +196,16 @@ static int check_for_power_off_event(void)
if (!power_button_was_pressed) {
power_off_deadline.val = now.val + DELAY_FORCE_SHUTDOWN;
- CPRINTF("[%T power waiting for long press %u]\n",
+ CPRINTS("power waiting for long press %u",
power_off_deadline.le.lo);
} else if (timestamp_expired(power_off_deadline, &now)) {
power_off_deadline.val = 0;
- CPRINTF("[%T power off after long press now=%u, %u]\n",
+ CPRINTS("power off after long press now=%u, %u",
now.le.lo, power_off_deadline.le.lo);
return 2;
}
} else if (power_button_was_pressed) {
- CPRINTF("[%T power off cancel]\n");
+ CPRINTS("power off cancel");
set_pmic_pwron(0);
}
@@ -240,7 +240,7 @@ enum power_state power_chipset_init(void)
* the AP could stay in strange state.
*/
if (!(reset_flags & RESET_FLAG_SYSJUMP)) {
- CPRINTF("[%T not sysjump; forcing AP shutdown]\n");
+ CPRINTS("not sysjump; forcing AP shutdown");
chipset_turn_off_power_rails();
/*
@@ -261,7 +261,7 @@ enum power_state power_chipset_init(void)
/* Leave power off only if requested by reset flags */
if (!(reset_flags & RESET_FLAG_AP_OFF) &&
!(reset_flags & RESET_FLAG_SYSJUMP)) {
- CPRINTF("[%T auto_power_on is set due to reset_flag 0x%x]\n",
+ CPRINTS("auto_power_on set due to reset_flag 0x%x",
system_get_reset_flags());
auto_power_on = 1;
}
@@ -319,14 +319,14 @@ static int check_for_power_on_event(void)
/* check if system is already ON */
if (power_get_signals() & IN_XPSHOLD) {
if (ap_off_flag) {
- CPRINTF(
- "[%T system is on, but "
- "RESET_FLAG_AP_OFF is on]\n");
+ CPRINTS(
+ "system is on, but "
+ "RESET_FLAG_AP_OFF is on");
return 0;
} else {
- CPRINTF(
- "[%T system is on, thus clear "
- "auto_power_on]\n");
+ CPRINTS(
+ "system is on, thus clear "
+ "auto_power_on");
/* no need to arrange another power on */
auto_power_on = 0;
return 1;
@@ -379,7 +379,7 @@ static void power_on(void)
t = get_time().val;
if (t < PMIC_RTC_STARTUP) {
uint32_t wait = PMIC_RTC_STARTUP - t;
- CPRINTF("[%T wait for %dms for PMIC RTC start-up]\n",
+ CPRINTS("wait for %dms for PMIC RTC start-up",
wait / MSEC);
usleep(wait);
}
@@ -398,7 +398,7 @@ static void power_on(void)
/* Call hooks now that AP is running */
hook_notify(HOOK_CHIPSET_STARTUP);
- CPRINTF("[%T AP running ...]\n");
+ CPRINTS("AP running ...");
}
/**
@@ -422,12 +422,12 @@ static int wait_for_power_button_release(unsigned int timeout_us)
} else if (timestamp_expired(deadline, &now) ||
(task_wait_event(deadline.val - now.val) ==
TASK_EVENT_TIMER)) {
- CPRINTF("[%T power button not released in time]\n");
+ CPRINTS("power button not released in time");
return EC_ERROR_TIMEOUT;
}
}
- CPRINTF("[%T power button released]\n");
+ CPRINTS("power button released");
power_button_was_pressed = 0;
return EC_SUCCESS;
}
@@ -448,19 +448,19 @@ static void power_off(void)
lid_opened = 0;
enable_sleep(SLEEP_MASK_AP_RUN);
powerled_set_state(POWERLED_STATE_OFF);
- CPRINTF("[%T power shutdown complete]\n");
+ CPRINTS("power shutdown complete");
}
void chipset_reset(int is_cold)
{
if (is_cold) {
- CPRINTF("[%T EC triggered cold reboot]\n");
+ CPRINTS("EC triggered cold reboot");
power_off();
/* After XPSHOLD is dropped off, the system will be on again */
power_request = POWER_REQ_ON;
} else {
- CPRINTF("[%T EC triggered warm reboot]\n");
- CPRINTF("[%T assert GPIO_PMIC_WARM_RESET_L for %d ms]\n",
+ CPRINTS("EC triggered warm reboot");
+ CPRINTS("assert GPIO_PMIC_WARM_RESET_L for %d ms",
PMIC_WARM_RESET_L_HOLD_TIME / MSEC);
gpio_set_level(GPIO_PMIC_WARM_RESET_L, 0);
usleep(PMIC_WARM_RESET_L_HOLD_TIME);
@@ -492,7 +492,7 @@ enum power_state power_handle_state(enum power_state state)
}
if (value) {
- CPRINTF("[%T power on %d]\n", value);
+ CPRINTS("power on %d", value);
return POWER_S5S3;
}
return state;
@@ -500,14 +500,14 @@ enum power_state power_handle_state(enum power_state state)
case POWER_S5S3:
power_on();
if (power_wait_signals(IN_XPSHOLD) == EC_SUCCESS) {
- CPRINTF("[%T XPSHOLD seen]\n");
+ CPRINTS("XPSHOLD seen");
if (wait_for_power_button_release(
DELAY_SHUTDOWN_ON_POWER_HOLD) ==
EC_SUCCESS) {
set_pmic_pwron(0);
return POWER_S3;
} else {
- CPRINTF("[%T long-press button, shutdown]\n");
+ CPRINTS("long-press button, shutdown");
power_off();
/*
* Since the AP may be up already, return S0S3
@@ -516,7 +516,7 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S0S3;
}
} else {
- CPRINTF("[%T XPSHOLD not seen in time]\n");
+ CPRINTS("XPSHOLD not seen in time");
}
set_pmic_pwron(0);
return POWER_S5;
@@ -536,7 +536,7 @@ enum power_state power_handle_state(enum power_state state)
case POWER_S0:
value = check_for_power_off_event();
if (value) {
- CPRINTF("[%T power off %d]\n", value);
+ CPRINTS("power off %d", value);
power_off();
return POWER_S0S3;
} else if (power_get_signals() & IN_SUSPEND)