diff options
author | Ting Shen <phoenixshen@google.com> | 2019-10-30 16:23:14 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-27 08:52:16 +0000 |
commit | 8893119c6fab824abef7e38a2a902fbf5f6f353f (patch) | |
tree | d4a30d92476fd3be8b1ea1486e16539c02f406bb /board/jacuzzi | |
parent | d15356206765437a27bc975c46175b055ff25af7 (diff) | |
download | chrome-ec-8893119c6fab824abef7e38a2a902fbf5f6f353f.tar.gz |
jacuzzi: enable led
Implemented pwm module using it8801, and enable led_pwm on jacuzzi.
BUG=b:135086465
TEST=1) verify the led status looks good (full=green, charging=blue)
2) enable CONFIG_CMD_LEDTEST and verify the color settings looks
good.
BRANCH=none
Change-Id: Ifa682473c02fec98ae026e2502df775505d614d7
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1892381
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/jacuzzi')
-rw-r--r-- | board/jacuzzi/board.c | 10 | ||||
-rw-r--r-- | board/jacuzzi/board.h | 15 | ||||
-rw-r--r-- | board/jacuzzi/build.mk | 2 | ||||
-rw-r--r-- | board/jacuzzi/led.c | 67 |
4 files changed, 88 insertions, 6 deletions
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index 49bd9e191c..0626e97b37 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -32,8 +32,6 @@ #include "lid_switch.h" #include "power.h" #include "power_button.h" -#include "pwm.h" -#include "pwm_chip.h" #include "registers.h" #include "spi.h" #include "system.h" @@ -114,6 +112,14 @@ 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 e965ce128f..288d5e3faf 100644 --- a/board/jacuzzi/board.h +++ b/board/jacuzzi/board.h @@ -22,9 +22,6 @@ #define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 #endif -/* TODO(b:135086465) led implementation */ -#undef CONFIG_LED_COMMON - #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS @@ -89,6 +86,11 @@ #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 { @@ -126,6 +128,13 @@ 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/build.mk b/board/jacuzzi/build.mk index 7f9669d7d7..e449fce9fc 100644 --- a/board/jacuzzi/build.mk +++ b/board/jacuzzi/build.mk @@ -12,4 +12,4 @@ CHIP_FAMILY:=stm32f0 CHIP_VARIANT:=stm32f09x BASEBOARD:=kukui -board-y=battery.o board.o +board-y=battery.o board.o led.o diff --git a/board/jacuzzi/led.c b/board/jacuzzi/led.c new file mode 100644 index 0000000000..26ef39a245 --- /dev/null +++ b/board/jacuzzi/led.c @@ -0,0 +1,67 @@ +/* Copyright 2019 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. + * + * Power and battery LED control for Jacuzzi + */ + +#include "common.h" +#include "driver/ioexpander/it8801.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_pwm.h" + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_POWER_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_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; +} + +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); + + return EC_SUCCESS; +} |