summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-06-04 11:07:30 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-05 01:36:44 +0000
commit565f1cb5ae1ebd287e1bf00ab8245274a5ecbaa6 (patch)
treee59d9553de268a1c4a665313d866b881467f480b
parent1732ba691e7cafc83f25ce23eef61c9c98794de1 (diff)
downloadchrome-ec-565f1cb5ae1ebd287e1bf00ab8245274a5ecbaa6.tar.gz
Add CONFIG_BRINGUP option to help debug signals for bringup
When this option is configured, two changes take place. First, the AP doesn't power on by default when the EC reboots. To boot it, you can run the "powerbtn" command, or poke the power button manually, or any of the normal things. Second, we watch for power-related signal changes (anything that's connected to the power_signal_interrupt() function) and keep track of them as they happen. After a second with no further changes, we print the time and value of each change. For example: [19.939212 Port 80: 0x29] [19.967971 HC 0x23] [19.976236 Port 80: 0x3a] [19.995700 HC 0x87] [20.567884 Port 80: 0x73] 11 signal changes: 19.638241 +0.000000 PCH_SLP_SUS_L => 1 19.654378 +0.016137 PCH_SLP_S5_L => 1 19.654457 +0.000079 PCH_SLP_A_L => 1 19.654535 +0.000078 PCH_SLP_S3_L => 1 19.654587 +0.000052 PCH_SLP_S4_L => 1 19.659630 +0.005043 PGOOD_1_5V_DDR => 1 19.663199 +0.003569 PGOOD_1_5V_PCH => 1 19.664751 +0.001552 PGOOD_1_8VS => 1 19.668735 +0.003984 PGOOD_VCCP => 1 19.671883 +0.003148 PGOOD_VCCSA => 1 19.868406 +0.196523 PGOOD_CPU_CORE => 1 [21.908551 Port 80: 0xf0] [21.908855 HC 0x48] BUG=none BRANCH=ToT TEST=manual Build with CONFIG_BRINGUP, notice those two changes. Change-Id: I55fd2021a0eae7dbfd1aaf5d93971f65bf2367b9 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202574 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
-rw-r--r--common/main.c4
-rw-r--r--common/power_button_x86.c5
-rw-r--r--include/config.h4
-rw-r--r--power/common.c66
4 files changed, 79 insertions, 0 deletions
diff --git a/common/main.c b/common/main.c
index e60a57f6bc..269781f9f6 100644
--- a/common/main.c
+++ b/common/main.c
@@ -111,6 +111,10 @@ test_mockable int main(void)
CPRINTF("[Image: %s, %s]\n",
system_get_image_copy_string(), system_get_build_info());
+#ifdef CONFIG_BRINGUP
+ ccprintf("\n\nWARNING: BRINGUP BUILD\n\n\n");
+#endif
+
#ifdef CONFIG_WATCHDOG
/*
* Intialize watchdog timer. All lengthy operations between now and
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index dc035fbb5b..539bfce347 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -214,8 +214,13 @@ static void set_initial_pwrbtn_state(void)
* All other EC reset conditions power on the main processor so
* it can verify the EC.
*/
+#ifdef CONFIG_BRINGUP
+ CPRINTS("PB idle");
+ pwrbtn_state = PWRBTN_STATE_IDLE;
+#else
CPRINTS("PB init-on");
pwrbtn_state = PWRBTN_STATE_INIT_ON;
+#endif
}
}
diff --git a/include/config.h b/include/config.h
index e266ea9b80..4700e00dbb 100644
--- a/include/config.h
+++ b/include/config.h
@@ -164,6 +164,10 @@
#undef CONFIG_BOOTCFG_VALUE
/*****************************************************************************/
+/* Modify the default behavior to make system bringup easier. */
+#undef CONFIG_BRINGUP
+
+/*****************************************************************************/
/*
* Number of extra buttons not on the keyboard scan matrix. Doesn't include
diff --git a/power/common.c b/power/common.c
index 1dffd64163..7489f1939f 100644
--- a/power/common.c
+++ b/power/common.c
@@ -20,6 +20,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_SWITCH, format, ## args)
/*
* Default timeout in us; if we've been waiting this long for an input
@@ -332,8 +333,73 @@ DECLARE_HOOK(HOOK_AC_CHANGE, power_ac_change, HOOK_PRIO_DEFAULT);
/*****************************************************************************/
/* Interrupts */
+#ifdef CONFIG_BRINGUP
+#define MAX_SIGLOG_ENTRIES 24
+
+static unsigned int siglog_entries;
+static unsigned int siglog_truncated;
+
+static struct {
+ timestamp_t time;
+ enum gpio_signal signal;
+ int level;
+} siglog[MAX_SIGLOG_ENTRIES];
+
+static void siglog_deferred(void)
+{
+ const struct gpio_info *g = gpio_list;
+ unsigned int i;
+ timestamp_t tdiff = {.val = 0};
+
+ /* Disable interrupts for input signals while we print stuff.*/
+ for (i = 0; i < POWER_SIGNAL_COUNT; i++)
+ gpio_disable_interrupt(power_signal_list[i].gpio);
+
+ CPRINTF("%d signal changes:\n", siglog_entries);
+ for (i = 0; i < siglog_entries; i++) {
+ if (i)
+ tdiff.val = siglog[i].time.val - siglog[i-1].time.val;
+ CPRINTF(" %.6ld +%.6ld %s => %d\n",
+ siglog[i].time.val, tdiff.val,
+ g[siglog[i].signal].name,
+ siglog[i].level);
+ }
+ if (siglog_truncated)
+ CPRINTF(" SIGNAL LOG TRUNCATED...\n");
+ siglog_entries = siglog_truncated = 0;
+
+ /* Okay, turn 'em on again. */
+ for (i = 0; i < POWER_SIGNAL_COUNT; i++)
+ gpio_enable_interrupt(power_signal_list[i].gpio);
+}
+DECLARE_DEFERRED(siglog_deferred);
+
+static void siglog_add(enum gpio_signal signal)
+{
+ if (siglog_entries >= MAX_SIGLOG_ENTRIES) {
+ siglog_truncated = 1;
+ return;
+ }
+
+ siglog[siglog_entries].time = get_time();
+ siglog[siglog_entries].signal = signal;
+ siglog[siglog_entries].level = gpio_get_level(signal);
+ siglog_entries++;
+
+ hook_call_deferred(siglog_deferred, SECOND);
+}
+
+#define SIGLOG(S) siglog_add(S)
+
+#else
+#define SIGLOG(S)
+#endif /* CONFIG_BRINGUP */
+
+
void power_signal_interrupt(enum gpio_signal signal)
{
+ SIGLOG(signal);
+
/* Shadow signals and compare with our desired signal state. */
power_update_signals();