diff options
author | Diana Z <dzigterman@chromium.org> | 2018-08-01 15:53:41 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-02 13:53:53 -0700 |
commit | 7a4c1d07ea6e836d9bbf9717d0e862550601d5bb (patch) | |
tree | bfe5f399261ae7dee8e42d7a27dd1574bae265a1 /board/fleex | |
parent | 3bc7f7d273caf9264c6723e95f911bd3ca3a9fe1 (diff) | |
download | chrome-ec-7a4c1d07ea6e836d9bbf9717d0e862550601d5bb.tar.gz |
Fleex: implement LED behavior
This change adds the charger LED behavior for fleex. Since fleex isn't
actually using a power LED, removed the GPIO referencing it.
BRANCH=none
BUG=b:109872754
TEST=ran through all charger and power states on the fleex to confirm
correct LED behavior
Change-Id: Ia0952587075026c6e2cbe20dcd7ccc6746442df1
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1159355
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/fleex')
-rw-r--r-- | board/fleex/board.h | 2 | ||||
-rw-r--r-- | board/fleex/build.mk | 2 | ||||
-rw-r--r-- | board/fleex/gpio.inc | 1 | ||||
-rw-r--r-- | board/fleex/led.c | 79 |
4 files changed, 82 insertions, 2 deletions
diff --git a/board/fleex/board.h b/board/fleex/board.h index ae8a8ccdbf..30fab484ac 100644 --- a/board/fleex/board.h +++ b/board/fleex/board.h @@ -20,6 +20,8 @@ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO +#define CONFIG_LED_COMMON + /* Sensors */ #define CONFIG_ACCEL_KX022 /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ diff --git a/board/fleex/build.mk b/board/fleex/build.mk index e25c6bb88d..7e806f4667 100644 --- a/board/fleex/build.mk +++ b/board/fleex/build.mk @@ -11,6 +11,6 @@ CHIP_FAMILY:=npcx7 CHIP_VARIANT:=npcx7m6fb BASEBOARD:=octopus -board-y=board.o +board-y=board.o led.o board-$(CONFIG_BATTERY_SMART)+=battery.o board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o diff --git a/board/fleex/gpio.inc b/board/fleex/gpio.inc index 3f0f3dd423..4170c84ee2 100644 --- a/board/fleex/gpio.inc +++ b/board/fleex/gpio.inc @@ -121,7 +121,6 @@ GPIO(USB2_OTG_ID, PIN(8, 3), GPIO_ODR_LOW) /* OTG ID */ /* LED */ GPIO(LED_1_PWR_WHITE_L, PIN(C, 3), GPIO_OUT_HIGH) GPIO(LED_2_CHG_AMBER_L, PIN(C, 4), GPIO_OUT_HIGH) -GPIO(LED_3_L, PIN(D, 7), GPIO_OUT_HIGH) /* Keyboard Backlight */ GPIO(KB_BL_PWR_EN, PIN(6, 2), GPIO_OUT_LOW) diff --git a/board/fleex/led.c b/board/fleex/led.c new file mode 100644 index 0000000000..3b0280d299 --- /dev/null +++ b/board/fleex/led.c @@ -0,0 +1,79 @@ +/* Copyright 2018 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 Fleex + */ + +#include "ec_commands.h" +#include "gpio.h" +#include "led_common.h" +#include "led_states.h" + +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 + +const int led_charge_lvl_1; + +const int led_charge_lvl_2 = 100; + +/* Fleex: Note there is only LED for charge / power */ +const struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + /* + * NOTE: STATE_CHARGING_LVL_1 shouldn't be reachable and should cause + * an error print to the console + */ + [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, + [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, + {LED_OFF, 1 * 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}, + {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, +}; +BUILD_ASSERT(ARRAY_SIZE(led_bat_state_table) == LED_NUM_STATES); + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED }; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_WHITE: + gpio_set_level(GPIO_LED_1_PWR_WHITE_L, LED_ON_LVL); + gpio_set_level(GPIO_LED_2_CHG_AMBER_L, LED_OFF_LVL); + break; + case EC_LED_COLOR_AMBER: + gpio_set_level(GPIO_LED_1_PWR_WHITE_L, LED_OFF_LVL); + gpio_set_level(GPIO_LED_2_CHG_AMBER_L, LED_ON_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + gpio_set_level(GPIO_LED_1_PWR_WHITE_L, LED_OFF_LVL); + gpio_set_level(GPIO_LED_2_CHG_AMBER_L, LED_OFF_LVL); + break; + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + brightness_range[EC_LED_COLOR_WHITE] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(EC_LED_COLOR_WHITE); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else + led_set_color_battery(LED_OFF); + + return EC_SUCCESS; +} + |