diff options
Diffstat (limited to 'board/kingoftown')
-rw-r--r-- | board/kingoftown/battery.c | 4 | ||||
-rw-r--r-- | board/kingoftown/board.h | 1 | ||||
-rw-r--r-- | board/kingoftown/led.c | 64 |
3 files changed, 54 insertions, 15 deletions
diff --git a/board/kingoftown/battery.c b/board/kingoftown/battery.c index c039fb3e45..3fd82bc282 100644 --- a/board/kingoftown/battery.c +++ b/board/kingoftown/battery.c @@ -59,6 +59,7 @@ const struct board_batt_params board_battery_info[] = { .charging_max_c = 45, .discharging_min_c = -10, .discharging_max_c = 60, + .vendor_param_start = 0x70, }, }, @@ -88,6 +89,7 @@ const struct board_batt_params board_battery_info[] = { .charging_max_c = 45, .discharging_min_c = -10, .discharging_max_c = 60, + .vendor_param_start = 0x70, }, }, @@ -117,6 +119,7 @@ const struct board_batt_params board_battery_info[] = { .charging_max_c = 45, .discharging_min_c = -10, .discharging_max_c = 60, + .vendor_param_start = 0x70, }, }, @@ -148,6 +151,7 @@ const struct board_batt_params board_battery_info[] = { .charging_max_c = 45, .discharging_min_c = -10, .discharging_max_c = 60, + .vendor_param_start = 0x70, }, }, }; diff --git a/board/kingoftown/board.h b/board/kingoftown/board.h index 5b49618d12..1ba0ed0c34 100644 --- a/board/kingoftown/board.h +++ b/board/kingoftown/board.h @@ -30,6 +30,7 @@ #define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION" #define CONFIG_BATTERY_REVIVE_DISCONNECT #define CONFIG_BATTERY_FUEL_GAUGE +#define CONFIG_BATTERY_VENDOR_PARAM /* BC 1.2 Charger */ #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/board/kingoftown/led.c b/board/kingoftown/led.c index 295c8effeb..09c1f89598 100644 --- a/board/kingoftown/led.c +++ b/board/kingoftown/led.c @@ -17,12 +17,17 @@ #include "system.h" #include "util.h" +/* Times of tick per 1 second */ +#define TIMES_TICK_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS) +/* Times of tick per half second */ +#define TIMES_TICK_HALF_SEC (500 / HOOK_TICK_INTERVAL_MS) + #define BAT_LED_ON 1 #define BAT_LED_OFF 0 const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_RIGHT_LED, EC_LED_ID_LEFT_LED, + EC_LED_ID_RIGHT_LED, }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); @@ -53,10 +58,10 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) int port; switch (led_id) { - case EC_LED_ID_RIGHT_LED: + case EC_LED_ID_LEFT_LED: port = 0; break; - case EC_LED_ID_LEFT_LED: + case EC_LED_ID_RIGHT_LED: port = 1; break; default: @@ -81,19 +86,41 @@ static void set_active_port_color(enum led_color color) { int port = charge_manager_get_active_charge_port(); - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) - side_led_set_color(0, (port == 0) ? color : LED_OFF); if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) + side_led_set_color(0, (port == 0) ? color : LED_OFF); + if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) side_led_set_color(1, (port == 1) ? color : LED_OFF); } static void board_led_set_battery(void) { static int battery_ticks; + static int power_ticks; + int led_blink_cycle; uint32_t chflags = charge_get_flags(); battery_ticks++; + /* + * Override battery LED for kingoftown which doesn't have power LED, + * blinking battery white LED to indicate system suspend without + * charging. + */ + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && + charge_get_state() != PWR_STATE_CHARGE) { + + power_ticks++; + led_blink_cycle = power_ticks % (2 * TIMES_TICK_ONE_SEC); + + side_led_set_color(0, (led_blink_cycle < TIMES_TICK_ONE_SEC) ? + LED_WHITE : LED_OFF); + side_led_set_color(1, (led_blink_cycle < TIMES_TICK_ONE_SEC) ? + LED_WHITE : LED_OFF); + return; + } + + power_ticks = 0; + switch (charge_get_state()) { case PWR_STATE_CHARGE: /* Always indicate when charging, even in suspend. */ @@ -101,28 +128,35 @@ static void board_led_set_battery(void) break; case PWR_STATE_DISCHARGE: if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { - if (charge_get_percent() <= 10) - side_led_set_color(0, - (battery_ticks & 0x4) ? LED_WHITE : LED_OFF); + if (charge_get_percent() <= 10) { + led_blink_cycle = + battery_ticks % (2 * TIMES_TICK_ONE_SEC); + side_led_set_color(1, + (led_blink_cycle < TIMES_TICK_ONE_SEC) ? + LED_WHITE : LED_OFF); + } else - side_led_set_color(0, LED_OFF); + side_led_set_color(1, LED_OFF); } if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) - side_led_set_color(1, LED_OFF); + side_led_set_color(0, LED_OFF); break; case PWR_STATE_ERROR: - set_active_port_color((battery_ticks & 0x2) ? - LED_WHITE : LED_OFF); + led_blink_cycle = battery_ticks % TIMES_TICK_ONE_SEC; + set_active_port_color((led_blink_cycle < TIMES_TICK_HALF_SEC) ? + LED_WHITE : LED_OFF); break; case PWR_STATE_CHARGE_NEAR_FULL: set_active_port_color(LED_WHITE); break; case PWR_STATE_IDLE: /* External power connected in IDLE */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - set_active_port_color((battery_ticks & 0x4) ? + if (chflags & CHARGE_FLAG_FORCE_IDLE) { + led_blink_cycle = battery_ticks % (2 * TIMES_TICK_ONE_SEC); + set_active_port_color( + (led_blink_cycle < TIMES_TICK_ONE_SEC) ? LED_AMBER : LED_OFF); - else + } else set_active_port_color(LED_WHITE); break; default: |