summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2020-11-04 18:49:51 +0800
committerCommit Bot <commit-bot@chromium.org>2020-11-10 13:48:35 +0000
commiteea8ce1dc6efee0743c874f2eea1cf48e2b3c715 (patch)
tree34d471e53938f01215d394df6bc93f604429f9a9
parentdecb6363e9ca50b0c15f9073872af28ba54e726a (diff)
downloadchrome-ec-eea8ce1dc6efee0743c874f2eea1cf48e2b3c715.tar.gz
dooly: enable red LEDstabilize-13591.B-master
This patch enable red LED on dooly. BUG=b:163574191, b:172781906 BRANCH=puff TEST=verify with console command: LED red/pink, confirm LED change to red/pink. Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: I320e716a8243421a827897b5e86902ad459fc462 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519242 Reviewed-by: Andrew McRae <amcrae@chromium.org> Tested-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Commit-Queue: Zick Wei <zick.wei@quanta.corp-partner.google.com>
-rw-r--r--board/dooly/board.c4
-rw-r--r--board/dooly/board.h1
-rw-r--r--board/dooly/gpio.inc1
-rw-r--r--board/dooly/led.c33
4 files changed, 35 insertions, 4 deletions
diff --git a/board/dooly/board.c b/board/dooly/board.c
index 7ff5ea661a..9fe568d053 100644
--- a/board/dooly/board.c
+++ b/board/dooly/board.c
@@ -406,6 +406,10 @@ const struct pwm_t pwm_channels[] = {
[PWM_CH_FAN] = { .channel = 5,
.flags = PWM_CONFIG_OPEN_DRAIN,
.freq = 25000},
+ [PWM_CH_LED_RED] = { .channel = 0,
+ .flags = PWM_CONFIG_ACTIVE_LOW |
+ PWM_CONFIG_DSLEEP,
+ .freq = 2000 },
[PWM_CH_LED_WHITE] = { .channel = 2,
.flags = PWM_CONFIG_ACTIVE_LOW |
PWM_CONFIG_DSLEEP,
diff --git a/board/dooly/board.h b/board/dooly/board.h
index 1488f6a9a8..25ca27f211 100644
--- a/board/dooly/board.h
+++ b/board/dooly/board.h
@@ -240,6 +240,7 @@ enum adc_channel {
enum pwm_channel {
PWM_CH_FAN,
+ PWM_CH_LED_RED,
PWM_CH_LED_WHITE,
/* Number of PWM channels */
PWM_CH_COUNT
diff --git a/board/dooly/gpio.inc b/board/dooly/gpio.inc
index 2b71948401..b7f1200296 100644
--- a/board/dooly/gpio.inc
+++ b/board/dooly/gpio.inc
@@ -134,6 +134,7 @@ ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* I2C5 */
ALTERNATE(PIN_MASK(B, 0x0C), 0, MODULE_I2C, 0) /* I2C7 */
/* PWM */
+ALTERNATE(PIN_MASK(C, 0x08), 0, MODULE_PWM, 0) /* PWM0 - Red Led */
ALTERNATE(PIN_MASK(C, 0x10), 0, MODULE_PWM, 0) /* PWM2 - White Led */
ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* PWM5 - Fan 1 */
ALTERNATE(PIN_MASK(7, 0x08), 0, MODULE_PWM, 0) /* TA2 - Fan Tachometer */
diff --git a/board/dooly/led.c b/board/dooly/led.c
index eeb52b2844..bf201cbfc7 100644
--- a/board/dooly/led.c
+++ b/board/dooly/led.c
@@ -33,28 +33,48 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
enum led_color {
LED_OFF = 0,
+ LED_RED,
LED_WHITE,
-
+ LED_PINK,
/* Number of colors, not a color itself */
LED_COLOR_COUNT
};
static int set_color_power(enum led_color color, int duty)
{
+ int white = 0;
+ int red = 0;
+
if (duty < 0 || 100 < duty)
return EC_ERROR_UNKNOWN;
switch (color) {
case LED_OFF:
- pwm_set_duty(PWM_CH_LED_WHITE, 0);
break;
case LED_WHITE:
- pwm_set_duty(PWM_CH_LED_WHITE, duty);
+ white = 1;
+ break;
+ case LED_RED:
+ red = 1;
+ break;
+ case LED_PINK:
+ white = 1;
+ red = 1;
break;
default:
return EC_ERROR_UNKNOWN;
}
+ if (red)
+ pwm_set_duty(PWM_CH_LED_RED, duty);
+ else
+ pwm_set_duty(PWM_CH_LED_RED, 0);
+
+ if (white)
+ pwm_set_duty(PWM_CH_LED_WHITE, duty);
+ else
+ pwm_set_duty(PWM_CH_LED_WHITE, 0);
+
return EC_SUCCESS;
}
@@ -165,6 +185,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, led_resume, HOOK_PRIO_DEFAULT);
static void led_init(void)
{
pwm_enable(PWM_CH_LED_WHITE, 1);
+ pwm_enable(PWM_CH_LED_RED, 1);
}
DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_INIT_PWM + 1);
@@ -204,8 +225,12 @@ static int command_led(int argc, char **argv)
ccprintf("o%s\n", led_auto_control_is_enabled(id) ? "ff" : "n");
} else if (!strcasecmp(argv[1], "off")) {
set_color(id, LED_OFF, 0);
+ } else if (!strcasecmp(argv[1], "red")) {
+ set_color(id, LED_RED, 100);
} else if (!strcasecmp(argv[1], "white")) {
set_color(id, LED_WHITE, 100);
+ } else if (!strcasecmp(argv[1], "pink")) {
+ set_color(id, LED_PINK, 100);
} else if (!strcasecmp(argv[1], "alert")) {
led_alert(1);
} else if (!strcasecmp(argv[1], "crit")) {
@@ -216,7 +241,7 @@ static int command_led(int argc, char **argv)
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(led, command_led,
- "[debug|red|green|amber|off|alert|crit]",
+ "[debug|red|white|pink|off|alert|crit]",
"Turn on/off LED.");
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)