summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-An Chen <yu-an.chen@quanta.corp-partner.google.com>2023-05-09 17:02:53 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-10 03:35:50 +0000
commit02417e0c2082d6f7666dffed5a83c26c403a6dd9 (patch)
treee829fa9181a54ef1d360c8209f6974edaaeeee00
parentecab2bd4a7bd388483a6eee18fbcf6dfcfd5f261 (diff)
downloadchrome-ec-02417e0c2082d6f7666dffed5a83c26c403a6dd9.tar.gz
taranza: Implement LED behavior
Power led behavior: S0 - white S3 - off S5 - off BUG=b:278167979 TEST=make BOARD=taranza Change-Id: Idf3e81e162dfb043ded54b003a72948f44929a93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516817 Tested-by: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> Reviewed-by: Bob Moragues <moragues@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Auto-Submit: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com> Commit-Queue: Yu-An Chen <yu-an.chen@quanta.corp-partner.google.com>
-rw-r--r--board/taranza/board.c25
-rw-r--r--board/taranza/board.h14
-rw-r--r--board/taranza/gpio.inc10
-rw-r--r--board/taranza/led.c95
4 files changed, 46 insertions, 98 deletions
diff --git a/board/taranza/board.c b/board/taranza/board.c
index 3c9cc62e2b..09a44f3b79 100644
--- a/board/taranza/board.c
+++ b/board/taranza/board.c
@@ -20,8 +20,6 @@
#include "intc.h"
#include "power.h"
#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "switch.h"
#include "system.h"
#include "tablet_mode.h"
@@ -112,29 +110,6 @@ const int usb_port_enable[USB_PORT_COUNT] = {
GPIO_EN_USB_A3_VBUS, GPIO_EN_USB_A4_VBUS,
};
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- [PWM_CH_LED_RED] = {
- .channel = 1,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
- },
-
- [PWM_CH_LED_GREEN] = {
- .channel = 2,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
- },
-
- [PWM_CH_LED_BLUE] = {
- .channel = 3,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
- }
-
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
/* Thermistors */
const struct temp_sensor_t temp_sensors[] = {
[TEMP_SENSOR_1] = { .name = "Memory",
diff --git a/board/taranza/board.h b/board/taranza/board.h
index 9078e4a137..23453da79c 100644
--- a/board/taranza/board.h
+++ b/board/taranza/board.h
@@ -77,13 +77,6 @@
#undef CONFIG_BATTERY_REVIVE_DISCONNECT
#undef CONFIG_BATTERY_SMART
-/* LED */
-#define CONFIG_LED_PWM
-#define CONFIG_LED_PWM_COUNT 1
-
-/* PWM */
-#define CONFIG_PWM
-
/* Thermistors */
#define CONFIG_TEMP_SENSOR
#define CONFIG_THERMISTOR
@@ -137,13 +130,6 @@ enum charge_port {
enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_COUNT };
-enum pwm_channel {
- PWM_CH_LED_RED,
- PWM_CH_LED_GREEN,
- PWM_CH_LED_BLUE,
- PWM_CH_COUNT,
-};
-
/* ADC channels */
enum adc_channel {
ADC_VSNS_PP3300_A, /* ADC0 */
diff --git a/board/taranza/gpio.inc b/board/taranza/gpio.inc
index 7a9b1c3fdc..652c457f62 100644
--- a/board/taranza/gpio.inc
+++ b/board/taranza/gpio.inc
@@ -129,6 +129,9 @@ GPIO(ECH1_PACKET_MODE, PIN(C, 0), GPIO_OUT_LOW)
GPIO(EN_RS232_X, PIN(E, 6), GPIO_OUT_LOW)
GPIO(UART0_RX, PIN(B, 1), GPIO_OUT_LOW) /* UART_EC_TX_DBG_RX */
+/* LED */
+GPIO(LED_W_ODL, PIN(A, 2), GPIO_OUT_HIGH)
+
/* NC pins, enable internal pull-down to avoid floating state. */
GPIO(GPIOG0_NC, PIN(G, 0), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOG3_NC, PIN(G, 3), GPIO_INPUT | GPIO_PULL_DOWN)
@@ -142,6 +145,8 @@ GPIO(GPIOI4_NC, PIN(I, 4), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOK3_NC, PIN(K, 3), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOA1_NC, PIN(A, 1), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOA3_NC, PIN(A, 3), GPIO_INPUT | GPIO_PULL_DOWN)
/* Alternate functions GPIO definitions */
/* UART */
@@ -172,8 +177,3 @@ ALTERNATE(PIN_MASK(L, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC,
ADC16:
SNS_PPVAR_PWR_IN
*/
-
-/* PWM */
-ALTERNATE(PIN_MASK(A, BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM,
- 0) /* LED_[R,G,B]_ODL
- */
diff --git a/board/taranza/led.c b/board/taranza/led.c
index 31ab932829..4f41c3c6c1 100644
--- a/board/taranza/led.c
+++ b/board/taranza/led.c
@@ -3,78 +3,65 @@
* found in the LICENSE file.
*/
-/* Taranza specific PWM LED settings. */
+/* Taranza specific LED settings. */
-#include "common.h"
+#include "chipset.h"
#include "ec_commands.h"
-#include "led_pwm.h"
-#include "pwm.h"
-#include "util.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "led_common.h"
+
+#define LED_ON_LVL 0
+#define LED_OFF_LVL 1
const enum ec_led_id supported_led_ids[] = {
EC_LED_ID_POWER_LED,
};
+
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-/* One physical LED with red, green, and blue. */
-struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
- /* Red, Green, Blue */
- [EC_LED_COLOR_RED] = { 100, 0, 0 },
- [EC_LED_COLOR_GREEN] = { 0, 100, 0 },
- [EC_LED_COLOR_BLUE] = { 0, 0, 100 },
- [EC_LED_COLOR_YELLOW] = { 50, 50, 0 },
- [EC_LED_COLOR_WHITE] = { 50, 50, 50 },
- [EC_LED_COLOR_AMBER] = { 70, 30, 0 },
+enum led_color {
+ LED_OFF = 0,
+ LED_WHITE,
+ LED_COLOR_COUNT /* Number of colors, not a color itself */
};
-/* One logical LED with red, green, and blue channels. */
-struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = {
- {
- .ch0 = PWM_CH_LED_RED,
- .ch1 = PWM_CH_LED_GREEN,
- .ch2 = PWM_CH_LED_BLUE,
- .enable = &pwm_enable,
- .set_duty = &pwm_set_duty,
- },
-};
+static int led_set_color_power(enum led_color color)
+{
+ switch (color) {
+ case LED_WHITE:
+ gpio_set_level(GPIO_LED_W_ODL, LED_ON_LVL);
+ break;
+ case LED_OFF:
+ gpio_set_level(GPIO_LED_W_ODL, LED_OFF_LVL);
+ break;
+ default:
+ return EC_ERROR_UNKNOWN;
+ }
+ return EC_SUCCESS;
+}
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
- memset(brightness_range, '\0',
- sizeof(*brightness_range) * EC_LED_COLOR_COUNT);
- brightness_range[EC_LED_COLOR_RED] = 100;
- brightness_range[EC_LED_COLOR_GREEN] = 100;
- brightness_range[EC_LED_COLOR_BLUE] = 100;
- brightness_range[EC_LED_COLOR_YELLOW] = 100;
- brightness_range[EC_LED_COLOR_WHITE] = 100;
- brightness_range[EC_LED_COLOR_AMBER] = 100;
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
}
int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
{
- enum pwm_led_id pwm_id;
-
- /* Convert ec_led_id to pwm_led_id. */
- if (led_id == EC_LED_ID_POWER_LED)
- pwm_id = PWM_LED0;
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_power(LED_WHITE);
else
- return EC_ERROR_UNKNOWN;
-
- if (brightness[EC_LED_COLOR_RED])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_RED);
- else if (brightness[EC_LED_COLOR_GREEN])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN);
- else if (brightness[EC_LED_COLOR_BLUE])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE);
- else if (brightness[EC_LED_COLOR_YELLOW])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW);
- else if (brightness[EC_LED_COLOR_WHITE])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER);
- else
- /* Otherwise, the "color" is "off". */
- set_pwm_led_color(pwm_id, -1);
+ led_set_color_power(LED_OFF);
return EC_SUCCESS;
}
+
+/* Called by hook task every TICK */
+static void led_tick(void)
+{
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ led_set_color_power(LED_WHITE);
+ else
+ led_set_color_power(LED_OFF);
+}
+DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);