common/led_common: Add API for controlling LED state

1. Provide led_control API that can be used by different drivers to
control the state of LED (0=off, 1=on, 2=reset)
2. Add a new LED ID for recovery HW_REINIT indication.

BUG=b:37682514
BRANCH=None
TEST=make -j buildall

Change-Id: I27334bde2b879046746456a610208f3fc2dd68b4
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/487840
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Furquan Shaikh
2017-04-26 22:47:36 -07:00
committed by chrome-bot
parent 5bc66e2995
commit 2bb9aec01a
4 changed files with 28 additions and 1 deletions

View File

@@ -71,3 +71,12 @@ static int led_command_control(struct host_cmd_handler_args *args)
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_LED_CONTROL, led_command_control, EC_VER_MASK(1));
__attribute__((weak))
void led_control(enum ec_led_id led_id, enum ec_led_state state)
{
/*
* Default weak implementation that does not affect the state of
* LED. Boards can provide their own implementation.
*/
}

View File

@@ -1720,6 +1720,8 @@ enum ec_led_id {
EC_LED_ID_LEFT_LED,
/* LED to indicate right side */
EC_LED_ID_RIGHT_LED,
/* LED to indicate recovery mode with HW_REINIT */
EC_LED_ID_RECOVERY_HW_REINIT_LED,
EC_LED_ID_COUNT
};

View File

@@ -67,4 +67,20 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness);
*
*/
void led_enable(int enable);
enum ec_led_state {
LED_STATE_OFF = 0,
LED_STATE_ON = 1,
LED_STATE_RESET = 2,
};
/**
* Control state of LED.
*
* @param led_id ID of LED to control
* @param state 0=off, 1=on, 2=reset to default
*
*/
void led_control(enum ec_led_id id, enum ec_led_state state);
#endif /* __CROS_EC_LED_COMMON_H */

View File

@@ -254,7 +254,7 @@ BUILD_ASSERT(ARRAY_SIZE(led_color_names) == EC_LED_COLOR_COUNT);
/* Note: depends on enum ec_led_id */
static const char * const led_names[] = {
"battery", "power", "adapter", "left", "right"};
"battery", "power", "adapter", "left", "right", "recovery_hwreinit"};
BUILD_ASSERT(ARRAY_SIZE(led_names) == EC_LED_ID_COUNT);
/* Check SBS numerical value range */