summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chen <ben.chen2@quanta.corp-partner.google.com>2021-03-04 14:49:20 +0800
committerCommit Bot <commit-bot@chromium.org>2021-03-04 12:34:23 +0000
commit75316933a92c3cf26690c91b4c1eb6ca219e2dbc (patch)
treec60d197a66e519ffa0c52b15f152b8cf164fadf8
parent723d411da02ce6e0de7f901c1f91a774a1adf19c (diff)
downloadchrome-ec-75316933a92c3cf26690c91b4c1eb6ca219e2dbc.tar.gz
spherion: Reconfig LED conftol, and update Led behavior
CONFIG GPIOA0, GPIOA1, GPIOA2 to INPUT type Supports the LED control Behavior as below Charge: Amber on (S0/S3/S5) Full: Blue on (S0/S3/S5) Discharge in s0: Blue on Discharge in s3: Amber on 1 sec off 3 sec Discharge in s5: off Error: Amber on 1 sec off 1 sec Factory mode: Blue on 2 sec Amber on 2 sec BUG=b:181799732 BRANCH=none TEST=make buildall PASS Change-Id: Ia54bc078cd26b80d8ca44517d72663b1482d0378 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2734062 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--board/spherion/board.h2
-rw-r--r--board/spherion/gpio.inc7
-rw-r--r--board/spherion/led.c73
3 files changed, 21 insertions, 61 deletions
diff --git a/board/spherion/board.h b/board/spherion/board.h
index 26081bcee1..135be0d6a6 100644
--- a/board/spherion/board.h
+++ b/board/spherion/board.h
@@ -23,9 +23,7 @@
#define CONFIG_IT83XX_RESET_PD_CONTRACT_IN_BRAM
/* LED */
-#define CONFIG_LED_POWER_LED
#define CONFIG_LED_ONOFF_STATES
-#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
/* PD / USB-C / PPC */
#define CONFIG_USB_PD_DEBUG_LEVEL 3
diff --git a/board/spherion/gpio.inc b/board/spherion/gpio.inc
index 2999936d6c..5b07faf43d 100644
--- a/board/spherion/gpio.inc
+++ b/board/spherion/gpio.inc
@@ -113,9 +113,6 @@ ALTERNATE(PIN_MASK(E, 0x81), 1, MODULE_I2C, 0) /* I2C E */
/* UART */
ALTERNATE(PIN_MASK(B, 0x03), 1, MODULE_UART, 0) /* EC to Servo */
-/* PWM */
-ALTERNATE(PIN_MASK(A, 0x07), 1, MODULE_PWM, 0) /* PWM 0~2 */
-
/* ADC */
ALTERNATE(PIN_MASK(I, 0x4F), 0, MODULE_ADC, 0) /* ADC 0,1,2,3,6 */
@@ -126,6 +123,10 @@ ALTERNATE(PIN_MASK(M, 0x33), 0, MODULE_SPI, 0) /* SPI */
GPIO(SET_VMC_VOLT_AT_1V8, PIN(D, 4), GPIO_INPUT | GPIO_PULL_DOWN | GPIO_SEL_1P8V)
GPIO(EN_PP3000_VMC_PMU, PIN(D, 2), GPIO_INPUT | GPIO_PULL_DOWN | GPIO_SEL_1P8V)
GPIO(PACKET_MODE_EN, PIN(A, 3), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(UNUSED_GPIOA0, PIN(A, 0), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(UNUSED_GPIOA1, PIN(A, 1), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(UNUSED_GPIOA2, PIN(A, 2), GPIO_INPUT | GPIO_PULL_UP)
+
/* b/160218054: behavior not defined */
/* *_ODL pin has external pullup so don't pull it down. */
GPIO(USB_A0_FAULT_ODL, PIN(A, 7), GPIO_INPUT)
diff --git a/board/spherion/led.c b/board/spherion/led.c
index d1ae0761ba..1c4d62730f 100644
--- a/board/spherion/led.c
+++ b/board/spherion/led.c
@@ -2,8 +2,9 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
- * Power and battery LED control for Spherion
+ * Battery LED control for Spherion
*/
+
#include "ec_commands.h"
#include "gpio.h"
#include "led_common.h"
@@ -17,72 +18,50 @@ const int led_charge_lvl_2 = 95;
struct led_descriptor led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
[STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
[STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
- [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
- [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC},
- {LED_OFF, 3 * LED_ONE_SEC} },
- [STATE_DISCHARGE_S3] = {{LED_OFF, 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_WHITE, 2 * LED_ONE_SEC},
+ [STATE_FACTORY_TEST] = {{EC_LED_COLOR_BLUE, 2 * LED_ONE_SEC},
{EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} },
};
-const struct led_descriptor
- led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
- [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
- [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC},
- {LED_OFF, 3 * LED_ONE_SEC} },
- [PWR_LED_STATE_SUSPEND_NO_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC},
- {LED_OFF, 3 * LED_ONE_SEC} },
- [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} },
-};
-
-
const enum ec_led_id supported_led_ids[] = {
EC_LED_ID_BATTERY_LED,
- EC_LED_ID_POWER_LED,
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
void led_set_color_battery(enum ec_led_colors color)
{
- mt6360_led_set_brightness(MT6360_LED_RGB2, 50);
+ mt6360_led_set_brightness(MT6360_LED_RGB1, 50);
mt6360_led_set_brightness(MT6360_LED_RGB3, 50);
switch (color) {
case EC_LED_COLOR_AMBER:
- mt6360_led_enable(MT6360_LED_RGB2, 0);
- mt6360_led_enable(MT6360_LED_RGB3, 1);
- break;
- case EC_LED_COLOR_WHITE:
- mt6360_led_enable(MT6360_LED_RGB2, 1);
+ mt6360_led_enable(MT6360_LED_RGB1, 1);
mt6360_led_enable(MT6360_LED_RGB3, 0);
break;
+ case EC_LED_COLOR_BLUE:
+ mt6360_led_enable(MT6360_LED_RGB1, 0);
+ mt6360_led_enable(MT6360_LED_RGB3, 1);
+ break;
default: /* LED_OFF and other unsupported colors */
- mt6360_led_enable(MT6360_LED_RGB2, 0);
+ mt6360_led_enable(MT6360_LED_RGB1, 0);
mt6360_led_enable(MT6360_LED_RGB3, 0);
break;
}
}
-void led_set_color_power(enum ec_led_colors color)
-{
- mt6360_led_set_brightness(MT6360_LED_RGB1, 1);
- mt6360_led_enable(MT6360_LED_RGB1, color == EC_LED_COLOR_WHITE);
-}
-
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
if (led_id == EC_LED_ID_BATTERY_LED) {
brightness_range[EC_LED_COLOR_AMBER] =
MT6360_LED_BRIGHTNESS_MAX;
- brightness_range[EC_LED_COLOR_WHITE] =
- MT6360_LED_BRIGHTNESS_MAX;
- } else if (led_id == EC_LED_ID_POWER_LED) {
- brightness_range[EC_LED_COLOR_WHITE] =
+ brightness_range[EC_LED_COLOR_BLUE] =
MT6360_LED_BRIGHTNESS_MAX;
}
}
@@ -92,29 +71,11 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
if (led_id == EC_LED_ID_BATTERY_LED) {
if (brightness[EC_LED_COLOR_AMBER] != 0)
led_set_color_battery(EC_LED_COLOR_AMBER);
- else if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_battery(EC_LED_COLOR_WHITE);
+ else if (brightness[EC_LED_COLOR_BLUE] != 0)
+ led_set_color_battery(EC_LED_COLOR_BLUE);
else
led_set_color_battery(LED_OFF);
- } else if (led_id == EC_LED_ID_POWER_LED) {
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_power(EC_LED_COLOR_WHITE);
- else
- led_set_color_power(LED_OFF);
}
return EC_SUCCESS;
}
-
-__override enum led_states board_led_get_state(enum led_states desired_state)
-{
- if (desired_state == STATE_BATTERY_ERROR) {
- if (chipset_in_state(CHIPSET_STATE_ON))
- return desired_state;
- else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND))
- return STATE_DISCHARGE_S3;
- else
- return STATE_DISCHARGE_S5;
- }
- return desired_state;
-}