diff options
author | Alexandru M Stan <amstan@chromium.org> | 2015-01-12 18:27:21 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-14 21:49:45 +0000 |
commit | 4003052d66eb9dfb7c23c07be52bf66aa1b4dea6 (patch) | |
tree | 276063049b3b0c0efa43f60b8542791bd11ba287 | |
parent | 35b13dc19a258ce4c751c9e50364ff3ccfc58eff (diff) | |
download | chrome-ec-4003052d66eb9dfb7c23c07be52bf66aa1b4dea6.tar.gz |
jerry: Switch led to CONFIG_LED_POLICY_STD
BUG=chrome-os-partner:35355,
TEST=The led behavior should match the cros spec
BRANCH=None
Change-Id: I360e30ff72d8c874651544ea41479189a0ac7e08
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/240706
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/jerry/board.h | 3 | ||||
-rw-r--r-- | board/jerry/build.mk | 2 | ||||
-rw-r--r-- | board/jerry/gpio.inc | 6 | ||||
-rw-r--r-- | board/jerry/led.c | 152 |
4 files changed, 7 insertions, 156 deletions
diff --git a/board/jerry/board.h b/board/jerry/board.h index bebfdc6b2b..6ba79dbe1b 100644 --- a/board/jerry/board.h +++ b/board/jerry/board.h @@ -25,6 +25,9 @@ #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_LED_COMMON +#define CONFIG_LED_POLICY_STD +#define CONFIG_LED_BAT_ACTIVE_LOW +#define CONFIG_LED_POWER_ACTIVE_LOW #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_S0 #define CONFIG_POWER_BUTTON diff --git a/board/jerry/build.mk b/board/jerry/build.mk index a0f9570511..e9b9999094 100644 --- a/board/jerry/build.mk +++ b/board/jerry/build.mk @@ -10,4 +10,4 @@ CHIP:=stm32 CHIP_FAMILY:=stm32f0 CHIP_VARIANT:=stm32f07x -board-y=board.o battery.o led.o +board-y=board.o battery.o diff --git a/board/jerry/gpio.inc b/board/jerry/gpio.inc index 0e14765520..30800f347c 100644 --- a/board/jerry/gpio.inc +++ b/board/jerry/gpio.inc @@ -28,8 +28,8 @@ GPIO(EC_WAKE, A, 0, GPIO_INPUT | GPIO_PULL_DOWN, NULL) /* wk1 */ GPIO(WP_L, B, 4, GPIO_INPUT, NULL) /* Outputs */ -GPIO(BAT_LED0, B, 11, GPIO_OUT_LOW, NULL) -GPIO(BAT_LED1, A, 11, GPIO_OUT_LOW, NULL) +GPIO(BAT_LED_RED, B, 11, GPIO_OUT_HIGH, NULL) +GPIO(BAT_LED_GREEN, A, 11, GPIO_OUT_HIGH, NULL) GPIO(EC_BL_OVERRIDE, F, 1, GPIO_OUT_LOW, NULL) GPIO(EC_INT, B, 9, GPIO_OUT_LOW, NULL) GPIO(ENTERING_RW, F, 0, GPIO_OUT_LOW, NULL) @@ -48,7 +48,7 @@ GPIO(KB_OUT09, B, 1, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT10, C, 5, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT11, C, 4, GPIO_KB_OUTPUT, NULL) GPIO(KB_OUT12, A, 13, GPIO_KB_OUTPUT, NULL) -GPIO(POWER_LED, A, 2, GPIO_OUT_LOW, NULL) +GPIO(POWER_LED, A, 2, GPIO_OUT_HIGH, NULL) GPIO(PMIC_PWRON, A, 12, GPIO_OUT_LOW, NULL) GPIO(PMIC_RESET, B, 3, GPIO_OUT_LOW, NULL) GPIO(PMIC_SOURCE_PWREN, B, 10, GPIO_OUT_LOW, NULL) diff --git a/board/jerry/led.c b/board/jerry/led.c deleted file mode 100644 index 659803476d..0000000000 --- a/board/jerry/led.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (c) 2014 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. - * - * Battery LED and Power LED control for jerry - */ - -#include "gpio.h" -#include "hooks.h" -#include "battery.h" -#include "charge_state.h" -#include "chipset.h" -#include "led_common.h" -#include "util.h" - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED, -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -enum led_color { - LED_GREEN = 0, - LED_ORANGE, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -static int bat_led_set(enum led_color color, int on) -{ - switch (color) { - case LED_GREEN: - gpio_set_level(GPIO_BAT_LED1, on ? 0 : 1); - break; - case LED_ORANGE: - gpio_set_level(GPIO_BAT_LED0, on ? 0 : 1); - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -static int pwr_led_set(int on) -{ - gpio_set_level(GPIO_POWER_LED, on ? 0 : 1); - return EC_SUCCESS; -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - /* Ignoring led_id as both leds support the same colors */ - brightness_range[EC_LED_COLOR_GREEN] = 1; - brightness_range[EC_LED_COLOR_YELLOW] = 1; -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - if (brightness[EC_LED_COLOR_GREEN] != 0) { - bat_led_set(LED_GREEN, 1); - bat_led_set(LED_ORANGE, 0); - } else if (brightness[EC_LED_COLOR_YELLOW] != 0) { - bat_led_set(LED_GREEN, 1); - bat_led_set(LED_ORANGE, 1); - } else { - bat_led_set(LED_GREEN, 0); - bat_led_set(LED_ORANGE, 0); - } - break; - case EC_LED_ID_POWER_LED: - pwr_led_set(brightness[EC_LED_COLOR_BLUE]); - break; - default: - return EC_ERROR_UNKNOWN; - - } - return EC_SUCCESS; -} - -static void jerry_led_set_power(void) -{ - static int power_second; - - power_second++; - - /* PWR LED behavior: - * Power on: Green - * Suspend: Green in breeze mode ( 1 sec on/ 3 sec off) - * Power off: OFF - */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - pwr_led_set(0); - else if (chipset_in_state(CHIPSET_STATE_ON)) - pwr_led_set(1); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) - pwr_led_set((power_second & 3) ? 0 : 1); -} - - -static void jerry_led_set_battery(void) -{ - static int battery_second; - - battery_second++; - - /* BAT LED behavior: - * Fully charged / idle: Off - * Under charging: Orange - * Battery low (10%): Orange in breeze mode (1 sec on, 3 sec off) - * Battery critical low (less than 3%) or abnormal battery - * situation: Orange in blinking mode (1 sec on, 1 sec off) - * Using battery or not connected to AC power: OFF - */ - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - bat_led_set(LED_ORANGE, 1); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set(LED_ORANGE, 1); - break; - case PWR_STATE_DISCHARGE: - if (charge_get_percent() < 3) - bat_led_set(LED_ORANGE, (battery_second & 1) ? 0 : 1); - else if (charge_get_percent() < 10) - bat_led_set(LED_ORANGE, (battery_second & 3) ? 0 : 1); - else - bat_led_set(LED_ORANGE, 0); - break; - case PWR_STATE_ERROR: - bat_led_set(LED_ORANGE, (battery_second & 1) ? 0 : 1); - break; - case PWR_STATE_IDLE: /* External power connected in IDLE. */ - bat_led_set(LED_ORANGE, 0); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -} - -/** * Called by hook task every 1 sec */ -static void led_second(void) -{ - if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - jerry_led_set_power(); - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - jerry_led_set_battery(); -} -DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); - |