summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2020-03-20 19:00:10 -0600
committerCommit Bot <commit-bot@chromium.org>2020-03-30 23:10:16 +0000
commit0e423969f1ebfb627aad04810802e414c92a4c6e (patch)
tree825d006f39d638dcc908f516957c991ad7c4e9a6
parentd5facd1417b59b822caaec065c5ec2525b3f37d4 (diff)
downloadchrome-ec-0e423969f1ebfb627aad04810802e414c92a4c6e.tar.gz
volteer: Select LED based on charge port
If a port is charging, illuminate the LED next the the charging port. If no port is charging, illuminate both LEDs. BUG=b:139554899 TEST=Attach charger to C0 or C1; LED on attached side is illuminated BRANCH=none Change-Id: I85e3851132f42a35032bcd43bfd02c59c23cc589 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2113121 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--baseboard/volteer/baseboard.c5
-rw-r--r--baseboard/volteer/led.c26
2 files changed, 27 insertions, 4 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
index 4f2df794cc..57abe21bb3 100644
--- a/baseboard/volteer/baseboard.c
+++ b/baseboard/volteer/baseboard.c
@@ -655,10 +655,7 @@ __override void board_icl_tgl_all_sys_pwrgood(void)
static void baseboard_init(void)
{
- /* Illuminate motherboard and daughter board LEDs equally.
- * TODO(b/139554899): Illuminate only the LED next to the active
- * charging port.
- */
+ /* Illuminate motherboard and daughter board LEDs equally to start. */
pwm_enable(PWM_CH_LED4_SIDESEL, 1);
pwm_set_duty(PWM_CH_LED4_SIDESEL, 50);
diff --git a/baseboard/volteer/led.c b/baseboard/volteer/led.c
index 60f3a103bb..f10e95235a 100644
--- a/baseboard/volteer/led.c
+++ b/baseboard/volteer/led.c
@@ -5,8 +5,10 @@
* Power and battery LED control for Volteer
*/
+#include "charge_manager.h"
#include "common.h"
#include "ec_commands.h"
+#include "hooks.h"
#include "led_common.h"
#include "led_pwm.h"
#include "pwm.h"
@@ -75,3 +77,27 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
return EC_SUCCESS;
}
+
+/* Illuminates the LED on the side of the active charging port. If not charging,
+ * illuminates both LEDs.
+ */
+static void led_set_charge_port_tick(void)
+{
+ int port;
+ int side_select_duty;
+
+ port = charge_manager_get_active_charge_port();
+ switch (port) {
+ case 0:
+ side_select_duty = 100;
+ break;
+ case 1:
+ side_select_duty = 0;
+ break;
+ default:
+ side_select_duty = 50;
+ }
+
+ pwm_set_duty(PWM_CH_LED4_SIDESEL, side_select_duty);
+}
+DECLARE_HOOK(HOOK_TICK, led_set_charge_port_tick, HOOK_PRIO_DEFAULT);