summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorYongBeum.Ha <ybha@samsung.corp-partner.google.com>2020-12-02 12:35:39 +0900
committerCommit Bot <commit-bot@chromium.org>2020-12-09 01:38:27 +0000
commitdb240bf9ab317cfc71ed1e8e6613b81b4e1afa4f (patch)
tree710ccfa99963b0453c4b500e23207ba6a3887c5d /board
parente1718af45bb6fe5a7da9572280674122249ae2c1 (diff)
downloadchrome-ec-db240bf9ab317cfc71ed1e8e6613b81b4e1afa4f.tar.gz
sasuke : apply EC change in sasuke
Sync with schematics of sasuke BUG=b:172869638 BRANCH=None TEST=make BOARD=sasuke Signed-off-by: YongBeum.Ha <ybha@samsung.corp-partner.google.com> Change-Id: Ib19431e2f4dd6b9da1e5f2e06a44883496bead54 Signed-off-by: YongBeum.Ha <ybha@samsung.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2569070 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Raymond Chung <raymondchung@ami.corp-partner.google.com>
Diffstat (limited to 'board')
-rw-r--r--board/sasuke/board.c182
-rw-r--r--board/sasuke/board.h66
-rw-r--r--board/sasuke/ec.tasklist1
-rw-r--r--board/sasuke/gpio.inc23
-rw-r--r--board/sasuke/led.c158
5 files changed, 136 insertions, 294 deletions
diff --git a/board/sasuke/board.c b/board/sasuke/board.c
index 4ce4deff8f..23555facda 100644
--- a/board/sasuke/board.c
+++ b/board/sasuke/board.c
@@ -14,8 +14,6 @@
#include "chipset.h"
#include "common.h"
#include "compile_time_macros.h"
-#include "driver/accel_bma2x2.h"
-#include "driver/accelgyro_bmi_common.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/charger/isl923x.h"
#include "driver/retimer/nb7v904m.h"
@@ -28,15 +26,11 @@
#include "i2c.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
-#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "stdbool.h"
#include "switch.h"
#include "system.h"
-#include "tablet_mode.h"
#include "task.h"
#include "usb_mux.h"
#include "usb_pd.h"
@@ -146,8 +140,6 @@ void board_init(void)
/* Enable C1 interrupts */
gpio_enable_interrupt(GPIO_SUB_C1_INT_EN_RAILS_ODL);
}
- /* Enable gpio interrupt for base accelgyro sensor */
- gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
/* Turn on 5V if the system is on, otherwise turn it off. */
on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND |
@@ -190,40 +182,9 @@ void board_reset_pd_mcu(void)
*/
}
-static void reconfigure_5v_gpio(void)
-{
- /*
- * b/147257497: On early boards, GPIO_EN_PP5000 was swapped with
- * GPIO_VOLUP_BTN_ODL. Therefore, we'll actually need to set that GPIO
- * instead for those boards. Note that this breaks the volume up button
- * functionality.
- */
- if (system_get_board_version() < 0) {
- CPRINTS("old board - remapping 5V en");
- gpio_set_flags(GPIO_VOLUP_BTN_ODL, GPIO_OUT_LOW);
- }
-}
-DECLARE_HOOK(HOOK_INIT, reconfigure_5v_gpio, HOOK_PRIO_INIT_I2C+1);
-
static void set_5v_gpio(int level)
{
- int version;
- enum gpio_signal gpio;
-
- /*
- * b/147257497: On early boards, GPIO_EN_PP5000 was swapped with
- * GPIO_VOLUP_BTN_ODL. Therefore, we'll actually need to set that GPIO
- * instead for those boards. Note that this breaks the volume up button
- * functionality.
- */
- version = system_get_board_version();
-
- /*
- * If the CBI EEPROM wasn't formatted, assume it's a very early board.
- */
- gpio = version < 0 ? GPIO_VOLUP_BTN_ODL : GPIO_EN_PP5000;
-
- gpio_set_level(gpio, level);
+ gpio_set_level(GPIO_EN_PP5000, level);
}
__override void board_power_5v_enable(int enable)
@@ -347,97 +308,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
charge_set_input_current_limit(icl, charge_mv);
}
-/* Sensors */
-static struct mutex g_lid_mutex;
-static struct mutex g_base_mutex;
-
-/* Matrices to rotate accelerometers into the standard reference. */
-static const mat33_fp_t lid_standard_ref = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(1)}
-};
-
-static const mat33_fp_t base_standard_ref = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(1)}
-};
-
-static struct accelgyro_saved_data_t g_bma253_data;
-static struct bmi_drv_data_t g_bmi160_data;
-
-struct motion_sensor_t motion_sensors[] = {
- [LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMA255,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &bma2x2_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_bma253_data,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS,
- .rot_standard_ref = &lid_standard_ref,
- .default_range = 2,
- .min_frequency = BMA255_ACCEL_MIN_FREQ,
- .max_frequency = BMA255_ACCEL_MAX_FREQ,
- .config = {
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- },
- },
- [BASE_ACCEL] = {
- .name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .rot_standard_ref = &base_standard_ref,
- .default_range = 4,
- .min_frequency = BMI_ACCEL_MIN_FREQ,
- .max_frequency = BMI_ACCEL_MAX_FREQ,
- .config = {
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 13000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
- },
- [BASE_GYRO] = {
- .name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_BMI160,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &bmi160_drv,
- .mutex = &g_base_mutex,
- .drv_data = &g_bmi160_data,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
- .default_range = 1000, /* dps */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = BMI_GYRO_MIN_FREQ,
- .max_frequency = BMI_GYRO_MAX_FREQ,
- },
-};
-
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-
__override void ocpc_get_pid_constants(int *kp, int *kp_div,
int *ki, int *ki_div,
int *kd, int *kd_div)
@@ -496,28 +366,6 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
},
};
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- [PWM_CH_KBLIGHT] = {
- .channel = 3,
- .flags = PWM_CONFIG_DSLEEP,
- .freq = 10000,
- },
-
- [PWM_CH_LED1_AMBER] = {
- .channel = 2,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq = 2400,
- },
-
- [PWM_CH_LED2_WHITE] = {
- .channel = 0,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq = 2400,
- }
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.bus_type = EC_BUS_TYPE_I2C,
@@ -597,31 +445,3 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-
-#ifndef TEST_BUILD
-/* This callback disables keyboard when convertibles are fully open */
-void lid_angle_peripheral_enable(int enable)
-{
- int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
-
- /*
- * If the lid is in tablet position via other sensors,
- * ignore the lid angle, which might be faulty then
- * disable keyboard.
- */
- if (tablet_get_mode())
- enable = 0;
-
- if (enable) {
- keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
- } else {
- /*
- * Ensure that the chipset is off before disabling the keyboard.
- * When the chipset is on, the EC keeps the keyboard enabled and
- * the AP decides whether to ignore input devices or not.
- */
- if (!chipset_in_s0)
- keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
- }
-}
-#endif
diff --git a/board/sasuke/board.h b/board/sasuke/board.h
index fa2e39a453..aea8051562 100644
--- a/board/sasuke/board.h
+++ b/board/sasuke/board.h
@@ -10,6 +10,9 @@
#define VARIANT_DEDEDE_EC_NPCX796FC
#include "baseboard.h"
+#undef GPIO_VOLUME_UP_L
+#undef GPIO_VOLUME_DOWN_L
+#undef CONFIG_VOLUME_BUTTONS
/*
* Keep the system unlocked in early development.
@@ -44,23 +47,18 @@
#define GPIO_USB_C1_INT_ODL GPIO_SUB_C1_INT_EN_RAILS_ODL
/* Keyboard */
-#define CONFIG_PWM_KBLIGHT
/* LED */
-#define CONFIG_LED_PWM
-#define CONFIG_LED_PWM_COUNT 1
-#undef CONFIG_LED_PWM_NEAR_FULL_COLOR
-#undef CONFIG_LED_PWM_SOC_ON_COLOR
-#undef CONFIG_LED_PWM_SOC_SUSPEND_COLOR
-#undef CONFIG_LED_PWM_LOW_BATT_COLOR
-#define CONFIG_LED_PWM_NEAR_FULL_COLOR EC_LED_COLOR_WHITE
-#define CONFIG_LED_PWM_SOC_ON_COLOR EC_LED_COLOR_WHITE
-#define CONFIG_LED_PWM_SOC_SUSPEND_COLOR EC_LED_COLOR_WHITE
-#define CONFIG_LED_PWM_LOW_BATT_COLOR EC_LED_COLOR_AMBER
+#define CONFIG_LED_COMMON
+#define CONFIG_LED_ONOFF_STATES
+#define CONFIG_LED_POWER_LED
+#define GPIO_BAT_LED_RED_L GPIO_LED_R_ODL
+#define GPIO_BAT_LED_GREEN_L GPIO_LED_G_ODL
+#define GPIO_PWR_LED_BLUE_L GPIO_LED_B_ODL
+
/* PWM */
-#define CONFIG_PWM
-#define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */
+#define NPCX7_PWM1_SEL 0 /* GPIO C2 is not used as PWM1. */
/* USB */
#define CONFIG_BC12_DETECT_PI3USB9201
@@ -111,35 +109,11 @@
#define GPIO_EC_I2C_SUB_USB_C1_SCL GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL
#define GPIO_EC_I2C_SUB_USB_C1_SDA GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL
-/* Sensors */
-#define CONFIG_CMD_ACCELS
-#define CONFIG_CMD_ACCEL_INFO
-
-#define CONFIG_ACCEL_BMA255 /* Lid accel */
-#define CONFIG_ACCELGYRO_BMI160 /* Base accel */
-
-/* Lid operates in forced mode, base in FIFO */
-#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL)
-#define CONFIG_ACCEL_FIFO
-#define CONFIG_ACCEL_FIFO_SIZE 256 /* Must be a power of 2 */
-#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
-
-#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-
-#define CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_UPDATE
-#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
-#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
-
-#define CONFIG_TABLET_MODE
-#define CONFIG_TABLET_MODE_SWITCH
-#define CONFIG_GMR_TABLET_MODE
-
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_GPIO
+#define CONFIG_MATH_UTIL
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
@@ -159,20 +133,6 @@ enum adc_channel {
ADC_CH_COUNT
};
-enum sensor_id {
- LID_ACCEL,
- BASE_ACCEL,
- BASE_GYRO,
- SENSOR_COUNT
-};
-
-enum pwm_channel {
- PWM_CH_KBLIGHT,
- PWM_CH_LED1_AMBER,
- PWM_CH_LED2_WHITE,
- PWM_CH_COUNT,
-};
-
/* List of possible batteries */
enum battery_type {
BATTERY_POWER_TECH,
diff --git a/board/sasuke/ec.tasklist b/board/sasuke/ec.tasklist
index 0aba1fabeb..a867bdbbae 100644
--- a/board/sasuke/ec.tasklist
+++ b/board/sasuke/ec.tasklist
@@ -9,7 +9,6 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, VENTI_TASK_STACK_SIZE) \
diff --git a/board/sasuke/gpio.inc b/board/sasuke/gpio.inc
index e6bc32af1e..b9169912f1 100644
--- a/board/sasuke/gpio.inc
+++ b/board/sasuke/gpio.inc
@@ -31,14 +31,10 @@ GPIO_INT(EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, PIN(9, 1), GPIO_INT_BOTH, sub_hdmi_hpd_
/* Button interrupts */
GPIO_INT(H1_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt)
-GPIO_INT(VOLDN_BTN_ODL, PIN(4, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(VOLUP_BTN_ODL, PIN(7, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
/* Other interrupts */
GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH, lid_interrupt)
GPIO_INT(EC_WP_OD, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
-GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt)
-GPIO_INT(LID_360_L, PIN(9, 5), GPIO_INT_BOTH, gmr_tablet_switch_isr)
/* I2C Ports */
GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT)
@@ -59,14 +55,15 @@ GPIO(EC_SUB_IO_2, PIN(3, 4), GPIO_OUT_LOW)
GPIO(EN_VCCIO_EXT, PIN(6, 1), GPIO_OUT_LOW)
/* TODO(b:149775160) - Modify if needed if we ever use this signal. */
GPIO(EN_VCCST, PIN(A, 7), GPIO_INPUT)
-GPIO(EN_PP3300_PEN, PIN(6, 3), GPIO_OUT_LOW)
GPIO(EN_PP3300_A, PIN(0, 3), GPIO_OUT_LOW)
GPIO(EN_PP5000_U, PIN(A, 4), GPIO_OUT_LOW)
GPIO(EN_SLP_Z, PIN(8, 3), GPIO_OUT_LOW)
-GPIO(EN_KB_BL, PIN(6, 0), GPIO_OUT_LOW)
GPIO(EN_BL_OD, PIN(D, 3), GPIO_ODR_LOW)
GPIO(IMVP9_PE, PIN(E, 0), GPIO_OUT_LOW)
GPIO(ECH1_PACKET_MODE, PIN(7, 5), GPIO_OUT_LOW)
+GPIO(LED_R_ODL, PIN(C, 4), GPIO_ODR_HIGH)
+GPIO(LED_G_ODL, PIN(C, 3), GPIO_ODR_HIGH)
+GPIO(LED_B_ODL, PIN(C, 2), GPIO_ODR_HIGH)
/* Power Sequencing */
GPIO(EC_AP_PSYS, PIN(B, 7), GPIO_OUT_LOW)
@@ -113,10 +110,6 @@ ALTERNATE(PIN_MASK(0, 0xF0), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO10-
ALTERNATE(PIN_MASK(8, 0x04), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO14 */
GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW) /* KSO2 inverted */
-/* PWM */
-ALTERNATE(PIN_MASK(C, 0x1C), 0, MODULE_PWM, 0) /* PWM0-2 */
-ALTERNATE(PIN_MASK(8, BIT(0)), 0, MODULE_PWM, 0) /* PWM3 */
-
/* UART */
ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART1 */
@@ -127,12 +120,22 @@ ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* I2C2, I2C1 SCL */
ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* I2C1 SDA */
/* NC pins, enable internal pull-up to avoid floating state. */
+GPIO(GPIO00_NC, PIN(0, 0), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO32_NC, PIN(3, 2), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO35_NC, PIN(3, 5), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO40_NC, PIN(4, 0), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO41_NC, PIN(4, 1), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO50_NC, PIN(5, 0), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO56_NC, PIN(5, 6), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO57_NC, PIN(5, 7), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO60_NC, PIN(6, 0), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO63_NC, PIN(6, 3), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO73_NC, PIN(7, 3), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO80_NC, PIN(8, 0), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO81_NC, PIN(8, 1), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIO86_NC, PIN(8, 6), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIO95_NC, PIN(9, 5), GPIO_INPUT | GPIO_PULL_UP)
+GPIO(GPIOA2_NC, PIN(A, 2), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIOD0_NC, PIN(D, 0), GPIO_INPUT | GPIO_PULL_UP)
GPIO(GPIOD1_NC, PIN(D, 1), GPIO_INPUT | GPIO_PULL_UP)
diff --git a/board/sasuke/led.c b/board/sasuke/led.c
index ca9a05bd84..335865cd60 100644
--- a/board/sasuke/led.c
+++ b/board/sasuke/led.c
@@ -1,70 +1,130 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
* 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 sasuke
*/
-/* Waddledoo specific PWM 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"
+#include "led_onoff_states.h"
+
+#define LED_OFF_LVL 1
+#define LED_ON_LVL 0
+
+const int led_charge_lvl_1 = 1;
+
+const int led_charge_lvl_2 = 100;
+
+/* sasuke : There are 3 leds for AC, Battery and Power */
+struct led_descriptor led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
+ [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC},
+ {LED_OFF, 1 * LED_ONE_SEC} },
+ [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_RED, LED_INDEFINITE} },
+ [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S0_BAT_LOW] = {{LED_OFF, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} },
+ [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} },
+ [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_RED, 0.5 * LED_ONE_SEC},
+ {LED_OFF, 0.5 * LED_ONE_SEC} },
+ [STATE_FACTORY_TEST] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC},
+ {LED_OFF, 1 * 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_BLUE, LED_INDEFINITE} },
+ [PWR_LED_STATE_SUSPEND_AC] = {{LED_OFF, LED_INDEFINITE} },
+ [PWR_LED_STATE_SUSPEND_NO_AC] = {{LED_OFF, LED_INDEFINITE} },
+ [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} },
+};
const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_POWER_LED,
+ EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED
};
+
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-/*
- * We only have a white 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, White */
- [EC_LED_COLOR_RED] = { 0, 0 },
- [EC_LED_COLOR_GREEN] = { 0, 0 },
- [EC_LED_COLOR_BLUE] = { 0, 0 },
- [EC_LED_COLOR_YELLOW] = { 0, 0 },
- [EC_LED_COLOR_WHITE] = { 0, 100 },
- [EC_LED_COLOR_AMBER] = { 100, 0 },
-};
-/* One logical LED with amber and white channels. */
-struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = {
+void led_set_color_power(enum ec_led_colors color)
+{
+ /* Don't set led if led_auto_control is disabled. */
+ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED) ||
+ !led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) {
+ return;
+ }
+
+ if (color == EC_LED_COLOR_BLUE)
{
- .ch0 = PWM_CH_LED1_AMBER,
- .ch1 = PWM_CH_LED2_WHITE,
- .ch2 = PWM_LED_NO_CHANNEL,
- .enable = &pwm_enable,
- .set_duty = &pwm_set_duty,
- },
-};
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_PWR_LED_BLUE_L, LED_ON_LVL);
+ } else {
+ /* LED_OFF and unsupported colors */
+ gpio_set_level(GPIO_PWR_LED_BLUE_L, LED_OFF_LVL);
+ }
+}
+
+void led_set_color_battery(enum ec_led_colors color)
+{
+ /* Don't set led if led_auto_control is disabled. */
+ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED) ||
+ !led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) {
+ return;
+ }
+
+ /* Battery leds must be turn off when blue led is on
+ * because casta has 3-in-1 led.
+ */
+ if(!gpio_get_level(GPIO_PWR_LED_BLUE_L))
+ {
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL); /*red*/
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_OFF_LVL); /*green*/
+ return;
+ }
+
+ switch (color) {
+ case EC_LED_COLOR_GREEN:
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL); /*red*/
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_ON_LVL); /*green*/
+ break;
+ case EC_LED_COLOR_RED:
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_ON_LVL); /*red*/
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_OFF_LVL); /*green*/
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL); /*red*/
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_OFF_LVL); /*green*/
+ 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_WHITE] = 100;
+ if (led_id == EC_LED_ID_BATTERY_LED) {
+ brightness_range[EC_LED_COLOR_GREEN] = 1;
+ brightness_range[EC_LED_COLOR_RED] = 1;
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ brightness_range[EC_LED_COLOR_BLUE] = 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_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);
+ if (led_id == EC_LED_ID_BATTERY_LED) {
+ gpio_set_level(GPIO_PWR_LED_BLUE_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, !brightness[EC_LED_COLOR_GREEN]);
+ gpio_set_level(GPIO_BAT_LED_RED_L, !brightness[EC_LED_COLOR_RED]);
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ gpio_set_level(GPIO_PWR_LED_BLUE_L, !brightness[EC_LED_COLOR_BLUE]);
+ gpio_set_level(GPIO_BAT_LED_GREEN_L, LED_OFF_LVL);
+ gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL);
+ }
return EC_SUCCESS;
}
+