summaryrefslogtreecommitdiff
path: root/board/aleena
diff options
context:
space:
mode:
authorBen Chen <ben.chen2@quanta.corp-partner.google.com>2018-10-01 13:11:05 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-10-03 06:51:06 -0700
commit77a5ab046c0e55756aa1eeef8749301459570e0c (patch)
tree1e34b370d79c8085e52a4fcbcc9e2d1c86faf24b /board/aleena
parentc0b793daf846f326edfbc099378efdfb1f271244 (diff)
downloadchrome-ec-77a5ab046c0e55756aa1eeef8749301459570e0c.tar.gz
Aleena: Add GPIO-controlled tables for LED status
The LEDs status defined as below a lookup table. Charge Amber on (S3/S4/S5) Full charge Blue on (S0/S3/S5) Discharging in S3 Amber on 1sec off 3 sec Discharging in S5 off Error Amber on 1sec off 1sec Discharging in S0 Blue on Factory mode Blue on 2sec Amber on 2sec BUG=b:113611642 BRANCH=master TEST=manual Check charge led Amber on (S3/S4/S5) when battery is charging Check charge led Blue on (S0/S3/S5) when battery is full Check charge led Amber on 1sec off 3 sec when discharging on S3 check charge led is off when battery discharging on S5 Check charge led is Amber on 1sec off 1sec when battery error Check charge led is blue when battery is discharhing on S0 Check charge led is blue on 2sec Amber on 2sec when factory testing Change-Id: Id45390ca0f5bb173fe16485eae6f605d1191b8e4 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1253371 Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/aleena')
-rw-r--r--board/aleena/board.c12
-rw-r--r--board/aleena/board.h14
-rw-r--r--board/aleena/gpio.inc5
-rw-r--r--board/aleena/led.c95
4 files changed, 55 insertions, 71 deletions
diff --git a/board/aleena/board.c b/board/aleena/board.c
index d84d3a5bb5..85955d7081 100644
--- a/board/aleena/board.c
+++ b/board/aleena/board.c
@@ -103,18 +103,6 @@ const struct pwm_t pwm_channels[] = {
.flags = 0,
.freq = 100,
},
- [PWM_CH_LED1_AMBER] = {
- .channel = 0,
- .flags = (PWM_CONFIG_OPEN_DRAIN | PWM_CONFIG_ACTIVE_LOW
- | PWM_CONFIG_DSLEEP),
- .freq = 100,
- },
- [PWM_CH_LED2_BLUE] = {
- .channel = 2,
- .flags = (PWM_CONFIG_OPEN_DRAIN | PWM_CONFIG_ACTIVE_LOW
- | PWM_CONFIG_DSLEEP),
- .freq = 100,
- },
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
diff --git a/board/aleena/board.h b/board/aleena/board.h
index a1e8a4f801..12e6869821 100644
--- a/board/aleena/board.h
+++ b/board/aleena/board.h
@@ -22,17 +22,7 @@
#define CONFIG_LED_COMMON
#define CONFIG_CMD_LEDTEST
-#undef CONFIG_LED_PWM_NEAR_FULL_COLOR
-#undef CONFIG_LED_PWM_CHARGE_ERROR_COLOR
-#undef CONFIG_LED_PWM_SOC_ON_COLOR
-#undef CONFIG_LED_PWM_SOC_SUSPEND_COLOR
-
-#define CONFIG_LED_PWM_NEAR_FULL_COLOR EC_LED_COLOR_BLUE
-#define CONFIG_LED_PWM_CHARGE_ERROR_COLOR EC_LED_COLOR_AMBER
-#define CONFIG_LED_PWM_SOC_ON_COLOR EC_LED_COLOR_BLUE
-#define CONFIG_LED_PWM_SOC_SUSPEND_COLOR EC_LED_COLOR_BLUE
-
-#define CONFIG_LED_PWM_COUNT 1
+#define CONFIG_LED_ONOFF_STATES
#define I2C_PORT_KBLIGHT NPCX_I2C_PORT5_0
@@ -43,8 +33,6 @@
enum pwm_channel {
PWM_CH_KBLIGHT = 0,
- PWM_CH_LED1_AMBER,
- PWM_CH_LED2_BLUE,
PWM_CH_COUNT
};
diff --git a/board/aleena/gpio.inc b/board/aleena/gpio.inc
index 4c336aa644..9b2f73fd4a 100644
--- a/board/aleena/gpio.inc
+++ b/board/aleena/gpio.inc
@@ -85,6 +85,10 @@ GPIO(BOARD_VERSION3, PIN(8, 0), GPIO_INPUT)
GPIO(SKU_ID1, PIN(F, 0), GPIO_INPUT)
GPIO(SKU_ID2, PIN(4, 1), GPIO_INPUT)
+/* LED */
+GPIO(BAT_LED_ORANGE_L, PIN(C, 3), GPIO_OUT_HIGH) /* LED_1_L */
+GPIO(BAT_LED_BLUE_L, PIN(C, 4), GPIO_OUT_HIGH) /* LED_2_L */
+
/* Alternate functions GPIO definitions */
/* Cr50 requires no pull-ups on UART pins. */
ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART from EC to Servo */
@@ -99,7 +103,6 @@ ALTERNATE(PIN_MASK(4, 0x02), 0, MODULE_ADC, 0) /* ADC4 */
ALTERNATE(PIN_MASK(F, 0x02), 0, MODULE_ADC, 0) /* ADC8 */
ALTERNATE(PIN_MASK(F, 0x01), 0, MODULE_ADC, 0) /* ADC9 */
ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* KB Backlight */
-ALTERNATE(PIN_MASK(C, 0x18), 0, MODULE_PWM, 0) /* LED 1 & 2 */
/* Keyboard Pins */
ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT) /* KSI_00-01 */
diff --git a/board/aleena/led.c b/board/aleena/led.c
index fc6f427cd2..41e0a1ec94 100644
--- a/board/aleena/led.c
+++ b/board/aleena/led.c
@@ -4,63 +4,68 @@
*/
#include "common.h"
-#include "ec_commands.h"
-#include "led_pwm.h"
-#include "util.h"
+#include "led_onoff_states.h"
+#include "led_common.h"
+#include "gpio.h"
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_POWER_LED,
-};
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+#define LED_OFF_LVL 1
+#define LED_ON_LVL 0
-/*
- * We only have a blue and an amber LED, so setting any other colour results in
- * both LEDs being off.
- */
-struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = {
- /* Amber, Blue */
- [EC_LED_COLOR_RED] = { 0, 0 },
- [EC_LED_COLOR_GREEN] = { 0, 0 },
- [EC_LED_COLOR_BLUE] = { 0, 100 },
- [EC_LED_COLOR_YELLOW] = { 0, 0 },
- [EC_LED_COLOR_WHITE] = { 0, 0 },
- [EC_LED_COLOR_AMBER] = { 100, 0 },
-};
+const int led_charge_lvl_1;
-/* One logical LED with amber and blue channels. */
-struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = {
- {
- PWM_CH_LED1_AMBER,
- PWM_CH_LED2_BLUE,
- PWM_LED_NO_CHANNEL,
- },
+const int led_charge_lvl_2 = 100;
+
+/* Note there is only LED for charge / power */
+const struct led_descriptor
+ led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
+ [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
+ [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_BLUE, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC},
+ {LED_OFF, 3 * LED_ONE_SEC} },
+ [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} },
+ [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC},
+ {LED_OFF, 1 * LED_ONE_SEC} },
+ [STATE_FACTORY_TEST] = {{EC_LED_COLOR_BLUE, 2 * LED_ONE_SEC},
+ {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} },
};
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED };
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+void led_set_color_battery(enum ec_led_colors color)
+{
+ switch (color) {
+ case EC_LED_COLOR_BLUE:
+ gpio_set_level(GPIO_BAT_LED_BLUE_L, LED_ON_LVL);
+ gpio_set_level(GPIO_BAT_LED_ORANGE_L, LED_OFF_LVL);
+ break;
+ case EC_LED_COLOR_AMBER:
+ gpio_set_level(GPIO_BAT_LED_BLUE_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_BAT_LED_ORANGE_L, LED_ON_LVL);
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ gpio_set_level(GPIO_BAT_LED_BLUE_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_BAT_LED_ORANGE_L, LED_OFF_LVL);
+ break;
+ }
+}
+
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_AMBER] = 100;
- brightness_range[EC_LED_COLOR_BLUE] = 100;
+ brightness_range[EC_LED_COLOR_BLUE] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 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;
- else
- return EC_ERROR_UNKNOWN;
-
- if (brightness[EC_LED_COLOR_BLUE])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE);
- else if (brightness[EC_LED_COLOR_AMBER])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER);
+ if (brightness[EC_LED_COLOR_BLUE] != 0)
+ led_set_color_battery(EC_LED_COLOR_BLUE);
+ else if (brightness[EC_LED_COLOR_AMBER] != 0)
+ led_set_color_battery(EC_LED_COLOR_AMBER);
else
- /* Otherwise, the "color" is "off". */
- set_pwm_led_color(pwm_id, -1);
+ led_set_color_battery(LED_OFF);
return EC_SUCCESS;
}