diff options
Diffstat (limited to 'board/jacuzzi')
-rw-r--r-- | board/jacuzzi/board.c | 8 | ||||
-rw-r--r-- | board/jacuzzi/board.h | 14 | ||||
-rw-r--r-- | board/jacuzzi/gpio.inc | 4 | ||||
-rw-r--r-- | board/jacuzzi/led.c | 109 |
4 files changed, 67 insertions, 68 deletions
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index edd6530f19..7fb0f45fcc 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -131,14 +131,6 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { }; /******************************************************************************/ -const struct it8801_pwm_t it8801_pwm_channels[] = { - [PWM_CH_LED_RED] = { 1 }, - [PWM_CH_LED_GREEN] = { 2 }, - [PWM_CH_LED_BLUE] = { 3 }, -}; -BUILD_ASSERT(ARRAY_SIZE(it8801_pwm_channels) == PWM_CH_COUNT); - -/******************************************************************************/ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h index 38d89f282a..b903b3edb7 100644 --- a/board/jacuzzi/board.h +++ b/board/jacuzzi/board.h @@ -99,17 +99,14 @@ #define CONFIG_KEYBOARD_BOARD_CONFIG #define CONFIG_KEYBOARD_COL2_INVERTED +#define CONFIG_LED_ONOFF_STATES + #define CONFIG_GMR_TABLET_MODE #define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L #define CONFIG_TABLET_MODE_SWITCH #define PD_OPERATING_POWER_MW 30000 -#define CONFIG_LED_PWM -#define CONFIG_LED_PWM_CHARGE_STATE_ONLY -#define CONFIG_IO_EXPANDER_IT8801_PWM -#define CONFIG_LED_PWM_COUNT 1 - #ifndef __ASSEMBLER__ enum adc_channel { @@ -148,13 +145,6 @@ enum battery_type { BATTERY_TYPE_COUNT, }; -enum pwm_channel { - PWM_CH_LED_RED, - PWM_CH_LED_GREEN, - PWM_CH_LED_BLUE, - PWM_CH_COUNT -}; - #include "gpio_signal.h" #include "registers.h" diff --git a/board/jacuzzi/gpio.inc b/board/jacuzzi/gpio.inc index c3c71daecd..35e307d917 100644 --- a/board/jacuzzi/gpio.inc +++ b/board/jacuzzi/gpio.inc @@ -83,6 +83,10 @@ GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW) GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH) GPIO(USB_C0_DISCHARGE, PIN(B, 6), GPIO_OUT_LOW) +IOEX(LED_BLUE, EXPIN(0, 1, 4), GPIO_OUT_HIGH) /* LED BLUE */ +IOEX(LED_GREEN, EXPIN(0, 1, 3), GPIO_OUT_HIGH) /* LED GREEN */ +IOEX(LED_ORANGE, EXPIN(0, 1, 2), GPIO_OUT_HIGH) /* LED ORANGE */ + #ifdef BOARD_JACUZZI GPIO(LID_ACCEL_INT_ODL, PIN(A, 14), GPIO_INPUT) /* Jacuzzi doesn't have EN_PP1800_S5_L. */ diff --git a/board/jacuzzi/led.c b/board/jacuzzi/led.c index 26ef39a245..d0039cbfae 100644 --- a/board/jacuzzi/led.c +++ b/board/jacuzzi/led.c @@ -4,64 +4,77 @@ * * Power and battery LED control for Jacuzzi */ - #include "common.h" +#include "ioexpander.h" #include "driver/ioexpander/it8801.h" #include "ec_commands.h" #include "led_common.h" -#include "led_pwm.h" - +#include "led_onoff_states.h" +#define LED_ON_LVL 0 +#define LED_OFF_LVL 1 +const int led_charge_lvl_1 = 5; +const int led_charge_lvl_2 = 95; +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_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_BLUE, 2 * LED_ONE_SEC}, + {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, +}; const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_POWER_LED, + EC_LED_ID_BATTERY_LED }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = { - [EC_LED_COLOR_RED] = {5, 0, 0}, - [EC_LED_COLOR_GREEN] = {0, 5, 0}, - [EC_LED_COLOR_BLUE] = {0, 0, 5}, - [EC_LED_COLOR_YELLOW] = {5, 5, 0}, - [EC_LED_COLOR_WHITE] = {2, 2, 2}, - [EC_LED_COLOR_AMBER] = {5, 3, 0}, -}; - -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - [PWM_LED0] = { - .ch0 = PWM_CH_LED_RED, - .ch1 = PWM_CH_LED_GREEN, - .ch2 = PWM_CH_LED_BLUE, - .enable = &it8801_pwm_enable, - .set_duty = &it8801_pwm_set_duty, - }, -}; - +void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_AMBER: + ioex_set_level(IOEX_LED_ORANGE, LED_ON_LVL); + ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); + ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); + break; + case EC_LED_COLOR_BLUE: + ioex_set_level(IOEX_LED_BLUE, LED_ON_LVL); + ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); + ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); + break; + case EC_LED_COLOR_GREEN: + ioex_set_level(IOEX_LED_GREEN, LED_ON_LVL); + ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); + ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + ioex_set_level(IOEX_LED_GREEN, LED_OFF_LVL); + ioex_set_level(IOEX_LED_BLUE, LED_OFF_LVL); + ioex_set_level(IOEX_LED_ORANGE, LED_OFF_LVL); + break; + } +} void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { - brightness_range[EC_LED_COLOR_RED] = 100; - brightness_range[EC_LED_COLOR_GREEN] = 100; - brightness_range[EC_LED_COLOR_YELLOW] = 100; - brightness_range[EC_LED_COLOR_AMBER] = 100; - brightness_range[EC_LED_COLOR_BLUE] = 100; - brightness_range[EC_LED_COLOR_WHITE] = 100; + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_BLUE] = 1; + brightness_range[EC_LED_COLOR_GREEN] = 1; + } } - int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - if (brightness[EC_LED_COLOR_RED]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_RED); - else if (brightness[EC_LED_COLOR_GREEN]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_GREEN); - else if (brightness[EC_LED_COLOR_YELLOW]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_YELLOW); - else if (brightness[EC_LED_COLOR_AMBER]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_AMBER); - else if (brightness[EC_LED_COLOR_BLUE]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_BLUE); - else if (brightness[EC_LED_COLOR_WHITE]) - set_pwm_led_color(PWM_LED0, EC_LED_COLOR_WHITE); - else - /* Otherwise, the "color" is "off". */ - set_pwm_led_color(PWM_LED0, -1); - + 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_BLUE] != 0) + led_set_color_battery(EC_LED_COLOR_BLUE); + else if (brightness[EC_LED_COLOR_GREEN] != 0) + led_set_color_battery(EC_LED_COLOR_GREEN); + else + led_set_color_battery(LED_OFF); + } return EC_SUCCESS; -} +}
\ No newline at end of file |