summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-07-22 11:41:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-22 18:40:09 -0700
commit1f99b58bd3fb33a2c53e12aad3e99f1e9c016320 (patch)
treea7a1d21d03b9e4b973bf4cfbfa8f7525cc6f8407
parent29d42a5e39cc6d5fc23c7c6f27f754f50156d177 (diff)
downloadchrome-ec-1f99b58bd3fb33a2c53e12aad3e99f1e9c016320.tar.gz
kevin / gru: Warn users when incompatible GPIO config is used
Old kevin / gru boards are no longer supported by our current GPIO configuration and must revert a CL to boot properly. Detect if old boards are used with an incompatible config and warn users of this fact by spamming the EC console and blinking the LED red. BUG=chrome-os-partner:55561 BRANCH=None TEST=Boot new kevin, verify no console spam or LED blinkage is seen. Verify old kevin + old gru spam the console and blink LED. Change-Id: I6d49720f760a6bef2bb3db6872857a5f61259e06 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362653 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/kevin/board.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/board/kevin/board.c b/board/kevin/board.c
index 9336b681cb..195b80f17a 100644
--- a/board/kevin/board.c
+++ b/board/kevin/board.c
@@ -24,6 +24,7 @@
#include "host_command.h"
#include "i2c.h"
#include "keyboard_scan.h"
+#include "led_common.h"
#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
@@ -315,6 +316,11 @@ int board_get_version(void)
/* Wait to allow cap charge */
msleep(10);
mv = adc_read_channel(ADC_BOARD_ID);
+
+ /* TODO(crosbug.com/p/54971): Fix failure on first ADC conversion. */
+ if (mv == ADC_READ_ERROR)
+ mv = adc_read_channel(ADC_BOARD_ID);
+
gpio_set_level(GPIO_EC_BOARD_ID_EN_L, 1);
for (i = 0; i < BOARD_VERSION_COUNT; ++i) {
@@ -327,6 +333,52 @@ int board_get_version(void)
return version;
}
+/*
+ * Detect 'old' boards which are incompatible with our new GPIO configuration
+ * and warn the user about the incompatibility by spamming the EC console and
+ * blinking our red LED.
+ *
+ * TODO(crosbug.com/p/55561): Remove version checking / warning prints once
+ * old boards are obsoleted.
+ */
+#ifdef BOARD_KEVIN
+#define BOARD_VERSION_NEW_GPIO_CFG BOARD_VERSION_REV3
+#else
+#define BOARD_VERSION_NEW_GPIO_CFG BOARD_VERSION_REV1
+#endif
+
+/* CONFIG removed in CL:351151. */
+#ifndef CONFIG_USB_PD_5V_EN_ACTIVE_LOW
+static void board_config_warning(void);
+DECLARE_DEFERRED(board_config_warning);
+
+static void board_config_warning(void)
+{
+ static int led_toggle;
+
+ ccprintf("WARNING: Invalid GPIO config detected.\n"
+ "PLEASE REVERT CL:351151 in local EC source:\n"
+ "`git revert d1138722`\n");
+
+ /* Flash red LED as warning */
+ led_auto_control(EC_LED_ID_POWER_LED, 0);
+ led_auto_control(EC_LED_ID_BATTERY_LED, 0);
+ pwm_set_duty(PWM_CH_LED_RED, led_toggle ? 0 : 100);
+ led_toggle = !led_toggle;
+
+ hook_call_deferred(&board_config_warning_data, SECOND);
+}
+
+static void board_config_check(void)
+{
+ int board_ver = board_get_version();
+
+ if (board_ver < BOARD_VERSION_NEW_GPIO_CFG)
+ hook_call_deferred(&board_config_warning_data, 0);
+}
+DECLARE_HOOK(HOOK_INIT, board_config_check, HOOK_PRIO_LAST);
+#endif /* ifndef CONFIG_USB_PD_5V_EN_ACTIVE_LOW */
+
static void overtemp_interrupt_enable(void)
{
gpio_enable_interrupt(GPIO_AP_OVERTEMP);