From a7a627d8f50ac9b9428a4183377babf6ebd77289 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 20 Jan 2026 16:19:18 +0530 Subject: [PATCH] ec/google/chromeec: Add helper to set LED RGB colors This patch adds google_chromeec_set_lightbar_rgb() to allow mainboards to manually control the individual LED colors. This is useful for providing visual feedback during early boot or platform-specific events, such as low-battery warnings. TEST=Build and boot google/fatcat. Change-Id: I146006511ea727787ea496b0674b67fa950ce8f2 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/90807 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/ec/google/chromeec/ec.c | 36 ++++++++++++++++++++++++++++++++++++ src/ec/google/chromeec/ec.h | 16 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index ee04d4a669..b9d53e7788 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1945,3 +1945,39 @@ int google_chromeec_read_batt_state_of_charge(uint32_t *state) return ret; } + +/* + * Set the RGB color of a specific LED on the Lightbar. + * + * This function communicates with the Embedded Controller (EC) + * to update the color of an individual LED. + * + * led: The index of the LED to be updated. + * red: Red intensity value (0x00 - 0xff). + * green: Green intensity value (0x00 - 0xff). + * blue: Blue intensity value (0x00 - 0xff). + * Return: 0 on success, or a non-zero error code from the EC host command. + */ +int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green, + int blue) +{ + const struct ec_params_lightbar req = { + .cmd = LIGHTBAR_CMD_SET_RGB, + .set_rgb = { + .led = led, + .red = red, + .green = green, + .blue = blue + } + }; + + struct chromeec_command cmd = { + .cmd_code = EC_CMD_LIGHTBAR_CMD, + .cmd_size_out = 0, + .cmd_data_out = NULL, + .cmd_size_in = sizeof(req), + .cmd_data_in = &req, + }; + + return google_chromeec_command(&cmd); +} diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index e4120dabeb..e5a4b0647d 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -546,4 +546,20 @@ void chipset_ioport_range(uint16_t *base, size_t *size); */ int google_chromeec_read_batt_state_of_charge(uint32_t *state); +/* + * Set the RGB color of a specific LED on the Lightbar. + * + * This function communicates with the Embedded Controller (EC) + * to update the color of an individual LED. + * + * @param led: The index of the LED to be updated. + * @param red: Red intensity value (0x00 - 0xff). + * @param green: Green intensity value (0x00 - 0xff). + * @param blue: Blue intensity value (0x00 - 0xff). + * + * @return 0 on success, or a non-zero error code from the EC host command. + */ +int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green, + int blue); + #endif /* _EC_GOOGLE_CHROMEEC_EC_H */