summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-03-22 11:50:08 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-04-02 19:09:54 +0000
commit7a67d437f26005f00d8c2c4474489c00303d4af9 (patch)
tree5b640ea5313fca810680b7f458bbc16ed2e333a6
parente879713cee3212b4afffb3f0dd3c4dfbf8237c4a (diff)
downloadchrome-ec-7a67d437f26005f00d8c2c4474489c00303d4af9.tar.gz
Nami: Allow Ekko, Bard, Pyke to defer enabling BC 1.2
Currently, Nami variants prevents AP from booting when the battery is discharged and the power supply is not more than 15W. A user has to wait for a battery to be charged, which takes several minutes. This patch reduces the AP boot threshold to 15W. This is possible because BC 1.2 controllers can be now enabled or disabled by the EC. When a battery is discharged, the following sequence is expected: 1. When EC starts up, BC1.2 controllers are disabled. 2. EC boots AP when 15W AC power is available. 3. BIOS verifies EC-RW and EC jumps to RW. 4. EC-RW negotiates higher power from USBC-C charger. 5. BIOS asks EC whether OS power is ready in a loop. 6. EC checks AC power. If it's enough, it enables BC1.2. If not, returns NACK to BIOS. (Go to step 5) 7. BIOS verifies and boots kernel Note 1: EC enables BC 1.2 unconditionally in recovery mode. Note 2: Once BC1.2 is enabled, it won't be disabled until EC resets. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/122896801,b/111990386,b/112172032 BRANCH=nami TEST=Boot Ekko on discharged battery with USB-C charger. TEST=Verify USB flash drive works in recovery mode. TEST=Verify USB keyboard works. TEST=Verify keyboard backlight works. Change-Id: Ie69e3dc6cb0a02c26f7d8c07baf5ad631ac282eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1548509 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--board/nami/board.c53
-rw-r--r--board/nami/board.h7
-rw-r--r--board/nami/gpio.inc10
3 files changed, 68 insertions, 2 deletions
diff --git a/board/nami/board.c b/board/nami/board.c
index c6e3d9c856..57b3d9d1e6 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -704,12 +704,14 @@ const struct pwm_t pwm_channels[] = {
[PWM_CH_LED1] = { 3, PWM_CONFIG_DSLEEP, 1200 },
[PWM_CH_LED2] = { 5, PWM_CONFIG_DSLEEP, 1200 },
[PWM_CH_FAN] = {4, PWM_CONFIG_OPEN_DRAIN, 25000},
+#ifdef CONFIG_PWM_KBLIGHT
/*
* 1.2kHz is a multiple of both 50 and 60. So a video recorder
* (generally designed to ignore either 50 or 60 Hz flicker) will not
* alias with refresh rate.
*/
[PWM_CH_KBLIGHT] = { 2, 0, 1200 },
+#endif
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
@@ -974,6 +976,24 @@ struct keyboard_scan_config keyscan_config = {
},
};
+static void bc12_enable(void)
+{
+ enum gpio_signal pin;
+ /* This branch is only for 2nd gen.. No need to check SKU or MODEL. */
+ switch (oem) {
+ case PROJECT_AKALI: /* For Ekko, Bard */
+ pin = GPIO_BC12_ENABLE_1;
+ break;
+ case PROJECT_PANTHEON: /* For Pyke */
+ pin = GPIO_BC12_ENABLE_2;
+ break;
+ default:
+ return;
+ }
+ gpio_set_level(pin, 1);
+ CPRINTS("BC12 enabled");
+}
+
static void board_init(void)
{
int reg;
@@ -1032,6 +1052,11 @@ static void board_init(void)
*/
swap(scancode_set2[0][4], scancode_set2[7][2]);
#endif
+ if (host_get_events() &
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY))
+ /* If recovery mode is being entered, enable BC1.2 for a USB
+ * drive. */
+ bc12_enable();
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -1054,7 +1079,9 @@ void board_kblight_init(void)
case PROJECT_SONA:
if (sku == 0x3AE2)
break;
+#ifdef CONFIG_PWM_KBLIGHT
kblight_register(&kblight_pwm);
+#endif
break;
}
}
@@ -1068,3 +1095,29 @@ enum critical_shutdown board_critical_shutdown_check(
return CRITICAL_SHUTDOWN_HIBERNATE;
}
+
+/*
+ * Check if the board supports BC1.2 toggling. If it does, AP can boot on 15W.
+ */
+static int is_low_power_boot_supported(void)
+{
+ if ((oem == PROJECT_AKALI) &&
+ (model == MODEL_BARD || model == MODEL_EKKO))
+ return 1;
+ if ((oem == PROJECT_PANTHEON) && (sku & SKU_ID_MASK_PYKE))
+ return 1;
+ return 0;
+}
+
+int board_check_os_boot_power(void)
+{
+ int limit = charge_state_limit_power();
+
+ if (is_low_power_boot_supported()) {
+ if (!limit)
+ /* Power is ready. Enable BC1.2 before booting OS */
+ bc12_enable();
+ }
+
+ return limit;
+}
diff --git a/board/nami/board.h b/board/nami/board.h
index 5ce8970964..57a29ea40b 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -58,7 +58,7 @@
#undef CONFIG_FAN_INIT_SPEED
#define CONFIG_FAN_INIT_SPEED 50
#define CONFIG_THROTTLE_AP
-#define CONFIG_PWM_KBLIGHT
+#define CONFIG_KEYBOARD_BACKLIGHT
#define CONFIG_SUPPRESSED_HOST_COMMANDS \
EC_CMD_CONSOLE_SNAPSHOT, EC_CMD_CONSOLE_READ, EC_CMD_PD_GET_LOG_ENTRY, \
EC_CMD_MOTION_SENSE_CMD
@@ -104,7 +104,7 @@
/* EC's thresholds. 3%: boot, 2%: no boot. Required for soft sync. */
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15000
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
/* AP's thresholds. */
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 3
@@ -267,7 +267,9 @@ enum pwm_channel {
PWM_CH_LED1,
PWM_CH_LED2,
PWM_CH_FAN,
+#ifdef CONFIG_PWM_KBLIGHT
PWM_CH_KBLIGHT,
+#endif
/* Number of PWM channels */
PWM_CH_COUNT,
};
@@ -304,6 +306,7 @@ enum model_id {
#define SKU_ID_MASK_CONVERTIBLE (1 << 9)
#define SKU_ID_MASK_KEYPAD (1 << 15)
#define SKU_ID_MASK_UK2 (1 << 18)
+#define SKU_ID_MASK_PYKE (1 << 24)
/* TODO(crosbug.com/p/61098): Verify the numbers below. */
/*
diff --git a/board/nami/gpio.inc b/board/nami/gpio.inc
index 8884a8b48d..5ac3f5a8da 100644
--- a/board/nami/gpio.inc
+++ b/board/nami/gpio.inc
@@ -49,6 +49,14 @@ GPIO(BATTERY_PRESENT_L, PIN(3, 4), GPIO_INPUT) /* Battery Present */
GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT) /* Case Closed Debug Mode */
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC Entering RW */
GPIO(PMIC_INT_L, PIN(6, 0), GPIO_INPUT) /* PMIC interrupt */
+#ifndef CONFIG_PWM_KBLIGHT
+/* For Ekko, Bard to control BC1.2 power.
+ * Sona uses C4 for keyboard backlight but its firmware isn't built here. */
+GPIO(BC12_ENABLE_1, PIN(C, 4), GPIO_OUT_LOW)
+#endif
+/* For Pyke to control BC1.2 power.
+ * Akali360 uses 72 for GMR sensor but its firmware isn't built here. */
+GPIO(BC12_ENABLE_2, PIN(7, 2), GPIO_OUT_LOW)
#ifndef CONFIG_POWER_S0IX
GPIO(PCH_SLP_S0_L, PIN(7, 5), GPIO_INPUT)
#endif
@@ -105,7 +113,9 @@ ALTERNATE(PIN_MASK(B, 0x40), 1, MODULE_PWM, 0) /* GPIOB6 PWM1 Fan control */
ALTERNATE(PIN_MASK(8, 0x01), 1, MODULE_PWM, 0) /* GPIO80 PWM3 LED White */
ALTERNATE(PIN_MASK(B, 0x80), 1, MODULE_PWM, 0) /* GPIOB7 PWM5 LED Yellow */
ALTERNATE(PIN_MASK(A, 0x40), 1, MODULE_PWM, 0) /* GPIOA6 TA2 */
+#ifdef CONFIG_PWM_KBLIGHT
ALTERNATE(PIN_MASK(C, 0x10), 1, MODULE_PWM, 0) /* GPIOC4 PWM2 */
+#endif
/* Keyboard pins */
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP)