From 8980e9a53af9676f721474c141c8b29545de0af5 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Fri, 25 Apr 2014 16:09:03 -0700 Subject: blaze: remove from ToT. Since we already created the firmware-nyan-5771.B branch, we can remove this from ToT now. But for sure we are still able to cherry-pick changes back to ToT or from ToT. BUG=none BRANCH=tot TEST=make buildall Change-Id: I637d27b9f8672c5d17b60e210a5211ab8e19b54a Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://chromium-review.googlesource.com/197165 --- board/blaze/battery.c | 251 ------------------------------------------------ board/blaze/board.c | 128 ------------------------ board/blaze/board.h | 126 ------------------------ board/blaze/build.mk | 13 --- board/blaze/ec.tasklist | 23 ----- board/blaze/led.c | 193 ------------------------------------- util/flash_ec | 2 +- 7 files changed, 1 insertion(+), 735 deletions(-) delete mode 100644 board/blaze/battery.c delete mode 100644 board/blaze/board.c delete mode 100644 board/blaze/board.h delete mode 100644 board/blaze/build.mk delete mode 100644 board/blaze/ec.tasklist delete mode 100644 board/blaze/led.c diff --git a/board/blaze/battery.c b/board/blaze/battery.c deleted file mode 100644 index f024445f44..0000000000 --- a/board/blaze/battery.c +++ /dev/null @@ -1,251 +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 pack vendor provided charging profile - */ - -#include "battery.h" -#include "battery_smart.h" -#include "gpio.h" -#include "host_command.h" -#include "util.h" -#include "console.h" - -/* Console output macros */ -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) - -/* Shutdown mode parameter to write to manufacturer access register */ -#define SB_SHUTDOWN_DATA 0x0010 - -static struct battery_info *battery_info; -static int support_cut_off; - -struct battery_device { - char manuf[9]; - char device[9]; - int design_mv; - struct battery_info *battery_info; - int support_cut_off; -}; - -/* - * Used for the case that battery cannot be detected, such as the pre-charge - * case. In this case, we need to provide the battery with the enough voltage - * (usually the highest voltage among batteries, but the smallest precharge - * current). This should be as conservative as possible. - */ -static struct battery_info info_precharge = { - - .voltage_max = 13050, /* the max voltage among batteries */ - .voltage_normal = 11400, - .voltage_min = 9000, - - /* Pre-charge values. */ - .precharge_current = 392, /* mA, the min current among batteries */ - - .start_charging_min_c = 0, - .start_charging_max_c = 60, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - - -static struct battery_info info_3s = { - - .voltage_max = 13050, - .voltage_normal = 11400, /* Average of max & min */ - .voltage_min = 9000, - - /* Pre-charge values. */ - .precharge_current = 392, /* mA */ - - .start_charging_min_c = 0, - .start_charging_max_c = 60, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - -static struct battery_device support_batteries[] = { - { - .manuf = "13-1B", - .device = "BO03037X", - .design_mv = 11400, - .battery_info = &info_3s, - .support_cut_off = 1, - }, - { - .manuf = "13-1C", - .device = "BO03037X", - .design_mv = 11400, - .battery_info = &info_3s, - .support_cut_off = 1, - }, - { - .manuf = "13-1B", - .device = "BO03032X", - .design_mv = 11100, - .battery_info = &info_3s, - .support_cut_off = 1, - } -}; - -#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS -/* - * The following parameters are for 2S battery. - * There is no corresponding params for 3S battery. - */ -enum { - TEMP_RANGE_10, - TEMP_RANGE_23, - TEMP_RANGE_35, - TEMP_RANGE_45, - TEMP_RANGE_50, - TEMP_RANGE_MAX -}; - -enum { - VOLT_RANGE_7200, - VOLT_RANGE_8000, - VOLT_RANGE_8400, - VOLT_RANGE_MAX -}; - -/* - * Vendor provided charging method - * temp : < 7.2V, 7.2V ~ 8.0V, 8.0V ~ 8.4V - * - 0 ~ 10 : 0.8A 1.6A 0.8A - * - 10 ~ 23 : 1.6A 4.0A 1.6A - * - 23 ~ 35 : 4.0A 4.0A 4.0A - * - 35 ~ 45 : 1.6A 4.0A 1.6A - * - 45 ~ 50 : 0.8A 1.6A 0.8A - */ -static const int const current_limit[TEMP_RANGE_MAX][VOLT_RANGE_MAX] = { - { 800, 1600, 800}, - {1600, 4000, 1600}, - {4000, 4000, 4000}, - {1600, 4000, 1600}, - { 800, 1600, 800}, -}; - -static inline void limit_value(int *val, int limit) -{ - if (*val > limit) - *val = limit; -} - -void battery_override_params(struct batt_params *batt) -{ - int *desired_current = &batt->desired_current; - int temp_range, volt_range; - int bat_temp_c = DECI_KELVIN_TO_CELSIUS(batt->temperature); - - if (battery_info == NULL) - return; - - /* Return if the battery is not a 2S battery */ - if (battery_info->voltage_max != info_2s.voltage_max) - return; - - /* Limit charging voltage */ - if (batt->desired_voltage > battery_info->voltage_max) - batt->desired_voltage = battery_info->voltage_max; - - /* Don't charge if outside of allowable temperature range */ - if (bat_temp_c >= battery_info->charging_max_c || - bat_temp_c < battery_info->charging_min_c) { - batt->desired_voltage = 0; - batt->desired_current = 0; - batt->flags &= ~BATT_FLAG_WANT_CHARGE; - return; - } - - if (bat_temp_c <= 10) - temp_range = TEMP_RANGE_10; - else if (bat_temp_c <= 23) - temp_range = TEMP_RANGE_23; - else if (bat_temp_c <= 35) - temp_range = TEMP_RANGE_35; - else if (bat_temp_c <= 45) - temp_range = TEMP_RANGE_45; - else - temp_range = TEMP_RANGE_50; - - if (batt->voltage < 7200) - volt_range = VOLT_RANGE_7200; - else if (batt->voltage < 8000) - volt_range = VOLT_RANGE_8000; - else - volt_range = VOLT_RANGE_8400; - - limit_value(desired_current, current_limit[temp_range][volt_range]); - - /* If battery wants current, give it at least the precharge current */ - if (*desired_current > 0 && - *desired_current < battery_info->precharge_current) - *desired_current = battery_info->precharge_current; -} -#endif /* CONFIG_BATTERY_OVERRIDE_PARAMS */ - -const struct battery_info *battery_get_info(void) -{ - int i; - char manuf[9]; - char device[9]; - int design_mv; - - if (battery_manufacturer_name(manuf, sizeof(manuf))) { - CPRINTF("[%T Failed to get MANUF name]\n"); - return &info_precharge; - } - - if (battery_device_name(device, sizeof(device))) { - CPRINTF("[%T Failed to get DEVICE name]\n"); - return &info_precharge; - } - if (battery_design_voltage((int *)&design_mv)) { - CPRINTF("[%T Failed to get DESIGN_VOLTAGE]\n"); - return &info_precharge; - } - - for (i = 0; i < ARRAY_SIZE(support_batteries); ++i) { - if ((strcasecmp(support_batteries[i].manuf, manuf) == 0) && - (strcasecmp(support_batteries[i].device, device) == 0) && - (support_batteries[i].design_mv == design_mv)) { - CPRINTF("[%T battery Manuf:%s, Device=%s, design=%u]\n", - manuf, device, design_mv); - support_cut_off = support_batteries[i].support_cut_off; - battery_info = support_batteries[i].battery_info; - return battery_info; - } - } - - CPRINTF("[%T un-recognized battery Manuf:%s, Device:%s]\n", - manuf, device); - return &info_precharge; -} - -int board_cut_off_battery(void) -{ - int rv; - - if (!support_cut_off) - return EC_RES_INVALID_COMMAND; - - /* Ship mode command must be sent twice to take effect */ - rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); - - if (rv != EC_SUCCESS) - goto out; - - rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); -out: - if (rv) - return EC_RES_ERROR; - else - return EC_RES_SUCCESS; -} diff --git a/board/blaze/board.c b/board/blaze/board.c deleted file mode 100644 index b7978013c7..0000000000 --- a/board/blaze/board.c +++ /dev/null @@ -1,128 +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. - */ -/* Blaze board-specific configuration */ - -#include "battery.h" -#include "chipset.h" -#include "common.h" -#include "extpower.h" -#include "gpio.h" -#include "i2c.h" -#include "keyboard_raw.h" -#include "lid_switch.h" -#include "power.h" -#include "power_button.h" -#include "power.h" -#include "pwm.h" -#include "pwm_chip.h" -#include "registers.h" -#include "spi.h" -#include "task.h" -#include "util.h" -#include "timer.h" -#include "charger.h" - -#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH) -#define GPIO_KB_OUTPUT GPIO_ODR_HIGH - -/* GPIO signal list. Must match order from enum gpio_signal. */ -const struct gpio_info gpio_list[] = { - /* Inputs with interrupt handlers are first for efficiency */ - {"POWER_BUTTON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, - power_button_interrupt}, - {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, - power_signal_interrupt}, - {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt}, - {"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, - power_signal_interrupt}, - {"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP, - spi_event}, - {"AC_PRESENT", GPIO_A, (1<<0), GPIO_INT_BOTH, extpower_interrupt}, - {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN01", GPIO_C, (1<<9), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN02", GPIO_C, (1<<10), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN03", GPIO_C, (1<<11), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN04", GPIO_C, (1<<12), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN05", GPIO_C, (1<<14), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN06", GPIO_C, (1<<15), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - {"KB_IN07", GPIO_D, (1<<2), GPIO_KB_INPUT, - keyboard_raw_gpio_interrupt}, - /* Other inputs */ - {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL}, - /* Outputs */ - {"AP_RESET_L", GPIO_B, (1<<3), GPIO_ODR_HIGH, NULL}, - {"CHARGER_EN", GPIO_B, (1<<2), GPIO_OUT_LOW, NULL}, - {"EC_INT", GPIO_B, (1<<9), GPIO_ODR_HIGH, NULL}, - {"ENTERING_RW", GPIO_H, (1<<0), GPIO_OUT_LOW, NULL}, - {"I2C1_SCL", GPIO_B, (1<<6), GPIO_ODR_HIGH, NULL}, - {"I2C1_SDA", GPIO_B, (1<<7), GPIO_ODR_HIGH, NULL}, - {"LED_POWER_L", GPIO_A, (1<<2), GPIO_OUT_HIGH, NULL}, /* PWR_LED1 */ - {"PMIC_PWRON_L", GPIO_A, (1<<12), GPIO_OUT_HIGH, NULL}, - {"PMIC_RESET", GPIO_A, (1<<15), GPIO_OUT_LOW, NULL}, - {"KB_OUT00", GPIO_B, (1<<0), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT01", GPIO_B, (1<<8), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT02", GPIO_B, (1<<12), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT03", GPIO_B, (1<<13), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT04", GPIO_B, (1<<14), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT05", GPIO_B, (1<<15), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT06", GPIO_C, (1<<0), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT07", GPIO_C, (1<<1), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT08", GPIO_C, (1<<2), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT09", GPIO_B, (1<<1), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT10", GPIO_C, (1<<5), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT11", GPIO_C, (1<<4), GPIO_KB_OUTPUT, NULL}, - {"KB_OUT12", GPIO_A, (1<<13), GPIO_KB_OUTPUT, NULL}, - {"AC_LED", GPIO_B, (1<<10), GPIO_OUT_LOW, NULL}, - {"CHG_LED", GPIO_B, (1<<11), GPIO_OUT_LOW, NULL}, - {"BAT_LED1", GPIO_A, (1<<8), GPIO_OUT_LOW, NULL}, - {"CHARGING", GPIO_A, (1<<11), GPIO_OUT_LOW, NULL}, - {"EC_BL_OVERRIDE", GPIO_H, (1<<1), GPIO_ODR_HIGH, NULL}, - {"PMIC_THERM_L", GPIO_A, (1<<1), GPIO_ODR_HIGH, NULL}, - {"PMIC_WARM_RESET_L", GPIO_C, (1<<3), GPIO_ODR_HIGH, NULL}, -}; -BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); - -/* Pins with alternate functions */ -const struct gpio_alt_func gpio_alt_funcs[] = { - {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI, GPIO_DEFAULT}, - {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART, GPIO_DEFAULT}, - {GPIO_B, 0x00c0, GPIO_ALT_I2C, MODULE_I2C, GPIO_DEFAULT}, -}; -const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); - -/* power signal list. Must match order of enum power_signal. */ -const struct power_signal_info power_signal_list[] = { - {GPIO_SOC1V8_XPSHOLD, 1, "XPSHOLD"}, - {GPIO_SUSPEND_L, 0, "SUSPEND#_ASSERTED"}, -}; -BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); - -/* I2C ports */ -const struct i2c_port_t i2c_ports[] = { - {"master", I2C_PORT_MASTER, 100, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, -}; -const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); - -/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ -const struct pwm_t pwm_channels[] = { - {STM32_TIM(2), STM32_TIM_CH(3), - PWM_CONFIG_ACTIVE_LOW, GPIO_LED_POWER_L}, -}; -BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); - -/** - * Discharge battery when on AC power for factory test. - */ -int board_discharge_on_ac(int enable) -{ - return charger_discharge_on_ac(enable); -} diff --git a/board/blaze/board.h b/board/blaze/board.h deleted file mode 100644 index 23fc04395a..0000000000 --- a/board/blaze/board.h +++ /dev/null @@ -1,126 +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. - */ - -/* Blaze board configuration */ - -#ifndef __BOARD_H -#define __BOARD_H - -/* Optional features */ -#define CONFIG_AP_HANG_DETECT -#define CONFIG_BATTERY_SMART -#define CONFIG_BATTERY_CUT_OFF -#define CONFIG_CHARGER -#define CONFIG_CHARGER_V2 -#define CONFIG_CHARGER_BQ24725 -#define CONFIG_CHIPSET_TEGRA -#define CONFIG_POWER_COMMON -#define CONFIG_EXTPOWER_GPIO -#define CONFIG_HOST_COMMAND_STATUS -#define CONFIG_I2C -#define CONFIG_KEYBOARD_PROTOCOL_MKBP -#define CONFIG_SPI -#define CONFIG_PWM -#define CONFIG_POWER_BUTTON -#define CONFIG_VBOOT_HASH -#define CONFIG_LED_COMMON -#define CONFIG_CHARGER_DISCHARGE_ON_AC - -#ifndef __ASSEMBLER__ - -/* Keyboard output port list */ -#define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C - -/* Single I2C port, where the EC is the master. */ -#define I2C_PORT_MASTER 0 -#define I2C_PORT_BATTERY I2C_PORT_MASTER -#define I2C_PORT_CHARGER I2C_PORT_MASTER - -/* Timer selection */ -#define TIM_CLOCK_MSB 3 -#define TIM_CLOCK_LSB 9 -#define TIM_POWER_LED 2 -#define TIM_WATCHDOG 4 - -/* GPIO signal list */ -enum gpio_signal { - /* Inputs with interrupt handlers are first for efficiency */ - GPIO_POWER_BUTTON_L = 0, - GPIO_SOC1V8_XPSHOLD, - GPIO_LID_OPEN, - GPIO_SUSPEND_L, - GPIO_SPI1_NSS, - GPIO_AC_PRESENT, - /* Keyboard inputs */ - GPIO_KB_IN00, - GPIO_KB_IN01, - GPIO_KB_IN02, - GPIO_KB_IN03, - GPIO_KB_IN04, - GPIO_KB_IN05, - GPIO_KB_IN06, - GPIO_KB_IN07, - /* Other inputs */ - GPIO_WP_L, - /* Outputs */ - GPIO_AP_RESET_L, - GPIO_CHARGER_EN, - GPIO_EC_INT, - GPIO_ENTERING_RW, - GPIO_I2C1_SCL, - GPIO_I2C1_SDA, - GPIO_LED_POWER_L, /* alias to GPIO_PWR_LED1 */ - GPIO_PMIC_PWRON_L, - GPIO_PMIC_RESET, - GPIO_KB_OUT00, - GPIO_KB_OUT01, - GPIO_KB_OUT02, - GPIO_KB_OUT03, - GPIO_KB_OUT04, - GPIO_KB_OUT05, - GPIO_KB_OUT06, - GPIO_KB_OUT07, - GPIO_KB_OUT08, - GPIO_KB_OUT09, - GPIO_KB_OUT10, - GPIO_KB_OUT11, - GPIO_KB_OUT12, - GPIO_AC_LED, - GPIO_CHG_LED, - GPIO_BAT_LED1, - GPIO_CHARGING, - GPIO_EC_BL_OVERRIDE, - GPIO_PMIC_THERM_L, - GPIO_PMIC_WARM_RESET_L, - /* Number of GPIOs; not an actual GPIO */ - GPIO_COUNT -}; - -enum power_signal { - TEGRA_XPSHOLD = 0, - TEGRA_SUSPEND_ASSERTED, - - /* Number of power signals */ - POWER_SIGNAL_COUNT -}; - -enum pwm_channel { - PWM_CH_POWER_LED = 0, - /* Number of PWM channels */ - PWM_CH_COUNT -}; - -/* Charger module */ -#define CONFIG_CHARGER_SENSE_RESISTOR 10 /* Charge sense resistor, mOhm */ -#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 /* Input sensor resistor, mOhm */ -#define CONFIG_CHARGER_INPUT_CURRENT 4032 /* mA, based on Link HW design */ -#define CONFIG_CHARGER_CURRENT_LIMIT 3000 /* PL102 inductor 3.0A(3.8A) */ - -/* Discharge battery when on AC power for factory test. */ -int board_discharge_on_ac(int enable); - -#endif /* !__ASSEMBLER__ */ - -#endif /* __BOARD_H */ diff --git a/board/blaze/build.mk b/board/blaze/build.mk deleted file mode 100644 index 605af9c169..0000000000 --- a/board/blaze/build.mk +++ /dev/null @@ -1,13 +0,0 @@ -# -*- makefile -*- -# 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. -# -# Board specific files build - -# the IC is STmicro STM32L100RBT6 -CHIP:=stm32 -CHIP_FAMILY:=stm32l -CHIP_VARIANT:=stm32l100 - -board-y=board.o battery.o led.o diff --git a/board/blaze/ec.tasklist b/board/blaze/ec.tasklist deleted file mode 100644 index 17add5094d..0000000000 --- a/board/blaze/ec.tasklist +++ /dev/null @@ -1,23 +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. - */ - -/** - * List of enabled tasks in the priority order - * - * The first one has the lowest priority. - * - * For each task, use the macro TASK(n, r, d, s) where : - * 'n' in the name of the task - * 'r' in the main routine of the task - * 'd' in an opaque parameter passed to the routine at startup - * 's' is the stack size in bytes; must be a multiple of 8 - */ -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \ - TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \ - TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) diff --git a/board/blaze/led.c b/board/blaze/led.c deleted file mode 100644 index 5c3adacb17..0000000000 --- a/board/blaze/led.c +++ /dev/null @@ -1,193 +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 control for Blaze - */ - -#include "charge_state.h" -#include "chipset.h" -#include "extpower.h" -#include "gpio.h" -#include "hooks.h" -#include "led_common.h" -#include "util.h" -#include "battery.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_OFF = 0, - LED_WHITE, - LED_AMBER, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -static int bat_led_set_color(enum led_color color) -{ - switch (color) { - case LED_OFF: - gpio_set_level(GPIO_AC_LED, 0); - gpio_set_level(GPIO_CHG_LED, 0); - break; - case LED_WHITE: - gpio_set_level(GPIO_AC_LED, 1); - gpio_set_level(GPIO_CHG_LED, 0); - break; - case LED_AMBER: - gpio_set_level(GPIO_AC_LED, 0); - gpio_set_level(GPIO_CHG_LED, 1); - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -static int pwr_led_set_color(enum led_color color) -{ - switch (color) { - case LED_OFF: - gpio_set_level(GPIO_LED_POWER_L, 1); - break; - case LED_WHITE: - gpio_set_level(GPIO_LED_POWER_L, 0); - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - brightness_range[EC_LED_COLOR_WHITE] = 100; - brightness_range[EC_LED_COLOR_YELLOW] = 100; - break; - case EC_LED_ID_POWER_LED: - brightness_range[EC_LED_COLOR_WHITE] = 100; - break; - default: - /* Nothing to do */ - break; - } -} - -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_WHITE] != 0) - bat_led_set_color(LED_WHITE); - else if (brightness[EC_LED_COLOR_YELLOW] != 0) - bat_led_set_color(LED_AMBER); - else - bat_led_set_color(LED_OFF); - break; - case EC_LED_ID_POWER_LED: - if (brightness[EC_LED_COLOR_WHITE] != 0) - pwr_led_set_color(LED_WHITE); - else - pwr_led_set_color(LED_OFF); - break; - default: - break; - } - return EC_SUCCESS; -} - -static void blaze_led_set_power(void) -{ - static int power_ticks; - static int previous_state_suspend; - - power_ticks++; - - /* Solid On: when the computer is ON (S0) & the LED color is White. - * Blinking: when the computer is in Standby, sequence of 1 second ON, - * 1 second OFF, The LED color is white. */ - - if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { - /* Reset ticks if entering suspend so LED turns off - * as soon as possible. */ - if (!previous_state_suspend) - power_ticks = 0; - - pwr_led_set_color((power_ticks & 0x2) ? LED_WHITE : LED_OFF); - - previous_state_suspend = 1; - return; - } - - previous_state_suspend = 0; - - if (chipset_in_state(CHIPSET_STATE_ON)) - pwr_led_set_color(LED_WHITE); - else - pwr_led_set_color(LED_OFF); -} - -static void blaze_led_set_battery(void) -{ - static int battery_ticks; - uint32_t chflags = charge_get_flags(); - - battery_ticks++; - - /* Solid ON White: means AC adapter is attached to system - * and battery is full. - * Solid ON Amber: means a battery is charging. - * Blinking white slowly: The fuel gauge is less than 12%. - * Sequence of Blink is 1 second On, - * 1 second Off. - * Blinking white quickly: When the primary or secondary battery is not - * communicating with EC, EC will blink the - * white LED at the sequence 0.5 second On - * and 0.5 second Off. */ - - /* Battery LED is solid white if AC connected, unless the battery is - * is charging or there is an error. - * Battery LED should be off if AC not present*/ - bat_led_set_color(extpower_is_present() ? LED_WHITE : LED_OFF); - - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - bat_led_set_color(LED_AMBER); - break; - case PWR_STATE_DISCHARGE: - /* See crosbug.com/p/22159. There's a 3% difference - * between the battery level seen by the kernel and what's - * really going on, so if they want to see 12%, we use 15%. - * Hard code this number here, because this only affects the - * LED color, not the battery charge state. */ - if (charge_get_percent() < 15) - bat_led_set_color( - (battery_ticks & 0x2) ? LED_WHITE : LED_OFF); - break; - case PWR_STATE_ERROR: - bat_led_set_color((battery_ticks & 0x1) ? LED_WHITE : LED_OFF); - break; - case PWR_STATE_IDLE: - if (chflags & CHARGE_FLAG_FORCE_IDLE) - bat_led_set_color( - (battery_ticks & 0x2) ? LED_AMBER : LED_OFF); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -} - -/* Called by hook task every 500mSec */ -static void led_tick(void) -{ - if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - blaze_led_set_power(); - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - blaze_led_set_battery(); -} -DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); diff --git a/util/flash_ec b/util/flash_ec index 341bef6c5e..1727b9120e 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -244,7 +244,7 @@ fi save="$(servo_save)" case "${BOARD}" in - big | blaze | discovery | nyan | pit | snow | spring ) flash_stm32 ;; + big | discovery | nyan | pit | snow | spring ) flash_stm32 ;; fruitpie | zinger | firefly) flash_stm32 ;; falco | peppy | rambi | samus | squawks ) flash_lm4 ;; link ) flash_link ;; -- cgit v1.2.1