diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2021-06-15 17:20:32 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-17 09:41:11 +0000 |
commit | 12cb573e33cacd1b8ec5804477b3139265708cf9 (patch) | |
tree | 43ee8badbb2afebfbc807b0bf218e0b37dba063b /board | |
parent | 50f86ad11ff688c5839c40315b2983906545f1af (diff) | |
download | chrome-ec-12cb573e33cacd1b8ec5804477b3139265708cf9.tar.gz |
Tomato: Update LED behavior
Disable PWM_CH_LED2 (Green) at init.
PWM_CH_LED1 -> amber, PWM_CH_LED3 -> blue
LED Behavior:
Charge(S0/S3/S5) Amber on
Full Charge(S0/S3/S5) Blue on
Discharge in S3 Amber on 1s off 3s
Discharge in S5 Off
Discharge in S0 Blue on
Battery Error Amber on 1s off 1s
Factory mode Blue on 2s Amber on 2s
BUG=none
BRANCH=none
TEST=LED behavior meets the SPEC
Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com>
Change-Id: I8ee8188b6f60434b400a5e245e3cb9186a9a7338
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2966521
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/cherry/board.c | 3 | ||||
-rw-r--r-- | board/cherry/led.c | 87 |
2 files changed, 29 insertions, 61 deletions
diff --git a/board/cherry/board.c b/board/cherry/board.c index e45699704a..612f7ef720 100644 --- a/board/cherry/board.c +++ b/board/cherry/board.c @@ -58,6 +58,9 @@ static void board_init(void) /* Enable motion sensor interrupt */ gpio_enable_interrupt(GPIO_BASE_IMU_INT_L); gpio_enable_interrupt(GPIO_LID_ACCEL_INT_L); + + /* Disable PWM_CH_LED2(Green) for unuse */ + pwm_enable(PWM_CH_LED2, 0); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/cherry/led.c b/board/cherry/led.c index 050232478f..43c4e45b86 100644 --- a/board/cherry/led.c +++ b/board/cherry/led.c @@ -3,12 +3,15 @@ * found in the LICENSE file. */ -#include "ec_commands.h" +#include "chipset.h" +#include "common.h" #include "gpio.h" #include "led_common.h" #include "led_onoff_states.h" -#include "chipset.h" -#include "driver/bc12/mt6360.h" +#include "pwm.h" + +#define LED_OFF_LVL 0 +#define LED_ON_LVL 1 __override const int led_charge_lvl_1 = 5; __override const int led_charge_lvl_2 = 95; @@ -17,92 +20,54 @@ __override struct led_descriptor led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, + [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, + {LED_OFF, 3 * LED_ONE_SEC} }, [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC}, + [STATE_FACTORY_TEST] = {{EC_LED_COLOR_BLUE, 2 * LED_ONE_SEC}, {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, }; -__override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_SUSPEND_NO_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} }, -}; - - 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); __override void led_set_color_battery(enum ec_led_colors color) { - mt6360_led_set_brightness(MT6360_LED_RGB2, 50); - mt6360_led_set_brightness(MT6360_LED_RGB3, 50); - switch (color) { case EC_LED_COLOR_AMBER: - mt6360_led_enable(MT6360_LED_RGB2, 0); - mt6360_led_enable(MT6360_LED_RGB3, 1); + pwm_enable(PWM_CH_LED1, LED_ON_LVL); + pwm_enable(PWM_CH_LED3, LED_OFF_LVL); break; - case EC_LED_COLOR_WHITE: - mt6360_led_enable(MT6360_LED_RGB2, 1); - mt6360_led_enable(MT6360_LED_RGB3, 0); + case EC_LED_COLOR_BLUE: + pwm_enable(PWM_CH_LED1, LED_OFF_LVL); + pwm_enable(PWM_CH_LED3, LED_ON_LVL); break; default: /* LED_OFF and other unsupported colors */ - mt6360_led_enable(MT6360_LED_RGB2, 0); - mt6360_led_enable(MT6360_LED_RGB3, 0); + pwm_enable(PWM_CH_LED1, LED_OFF_LVL); + pwm_enable(PWM_CH_LED3, LED_OFF_LVL); break; } } -__override void led_set_color_power(enum ec_led_colors color) -{ - mt6360_led_set_brightness(MT6360_LED_RGB1, 1); - mt6360_led_enable(MT6360_LED_RGB1, color == EC_LED_COLOR_WHITE); -} - void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { - if (led_id == EC_LED_ID_BATTERY_LED) { - brightness_range[EC_LED_COLOR_AMBER] = - MT6360_LED_BRIGHTNESS_MAX; - brightness_range[EC_LED_COLOR_WHITE] = - MT6360_LED_BRIGHTNESS_MAX; - } else if (led_id == EC_LED_ID_POWER_LED) { - brightness_range[EC_LED_COLOR_WHITE] = - MT6360_LED_BRIGHTNESS_MAX; - } + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_BLUE] = 1; } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - if (led_id == EC_LED_ID_BATTERY_LED) { - if (brightness[EC_LED_COLOR_AMBER] != 0) - led_set_color_battery(EC_LED_COLOR_AMBER); - else if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_battery(EC_LED_COLOR_WHITE); - else - led_set_color_battery(LED_OFF); - } else if (led_id == EC_LED_ID_POWER_LED) { - if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_power(EC_LED_COLOR_WHITE); - else - led_set_color_power(LED_OFF); - } - + if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else if (brightness[EC_LED_COLOR_BLUE] != 0) + led_set_color_battery(EC_LED_COLOR_BLUE); + else + led_set_color_battery(LED_OFF); return EC_SUCCESS; } |