summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/aleena/battery.c124
-rw-r--r--board/aleena/board.c24
-rw-r--r--board/aleena/board.h25
-rw-r--r--board/aleena/gpio.inc12
-rw-r--r--board/aleena/led.c169
-rw-r--r--board/liara/battery.c124
-rw-r--r--board/liara/board.c24
-rw-r--r--board/liara/board.h25
-rw-r--r--board/liara/gpio.inc12
-rw-r--r--board/liara/led.c169
10 files changed, 222 insertions, 486 deletions
diff --git a/board/aleena/battery.c b/board/aleena/battery.c
index e0cd82eb94..db2be8e2b3 100644
--- a/board/aleena/battery.c
+++ b/board/aleena/battery.c
@@ -32,122 +32,34 @@
* address, mask, and disconnect value need to be provided.
*/
const struct board_batt_params board_battery_info[] = {
- /* DynaPack Coslight Battery Information */
- [BATTERY_DANAPACK_COS] = {
+ /* Panasonic AP15O5L Battery Information */
+ [BATTERY_PANASONIC] = {
.fuel_gauge = {
- .manuf_name = "333-2C-DA-A",
+ .manuf_name = "PANASONIC",
.ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
+ .reg_addr = 0x3A,
+ .reg_data = { 0xC574, 0xC574 },
},
.fet = {
- .mfgacc_support = 1,
.reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
+ .reg_mask = 0x4000,
+ .disconnect_val = 0x0,
}
},
.batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* DynaPack ATL Battery Information */
- [BATTERY_DANAPACK_ATL] = {
- .fuel_gauge = {
- .manuf_name = "333-27-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* DynaPack SDI Battery Information */
- [BATTERY_DANAPACK_SDI] = {
- .fuel_gauge = {
- .manuf_name = "333-24-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Samsung SDI Battery Information */
- [BATTERY_SAMSUNG_SDI] = {
- .fuel_gauge = {
- .manuf_name = "333-54-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
+ .voltage_max = 13200,
+ .voltage_normal = 11550, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 60,
},
},
};
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_DANAPACK_COS;
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC;
diff --git a/board/aleena/board.c b/board/aleena/board.c
index 65c9eb2d2f..3ad74796bd 100644
--- a/board/aleena/board.c
+++ b/board/aleena/board.c
@@ -108,6 +108,7 @@ const struct i2c_port_t i2c_ports[] = {
{"tcpc0", I2C_PORT_TCPC0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
{"tcpc1", I2C_PORT_TCPC1, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
{"thermal", I2C_PORT_THERMAL, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA},
+ {"kblight", I2C_PORT_KBLIGHT, 100, GPIO_I2C5_SCL, GPIO_I2C5_SDA},
{"sensor", I2C_PORT_SENSOR, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -119,6 +120,18 @@ 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);
@@ -239,3 +252,14 @@ void board_reset_pd_mcu(void)
msleep(ANX74XX_PWR_L_PWR_H_DELAY_MS);
board_set_tcpc_power_mode(USB_PD_PORT_ANX74XX, 1);
}
+
+static void board_kblight_init(void)
+{
+ /*
+ * Enable keyboard backlight. This needs to be done here because
+ * the chip doesn't have power until PP3300_S0 comes up.
+ */
+ gpio_set_level(GPIO_KB_BL_EN, 1);
+ lm3630a_poweron();
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_kblight_init, HOOK_PRIO_DEFAULT);
diff --git a/board/aleena/board.h b/board/aleena/board.h
index 53a404bd25..9e2cea8bb3 100644
--- a/board/aleena/board.h
+++ b/board/aleena/board.h
@@ -20,21 +20,38 @@
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
+/* Power and battery LEDs */
#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 I2C_PORT_KBLIGHT NPCX_I2C_PORT5_0
+
+/* KB backlight driver */
+#define CONFIG_LED_DRIVER_LM3630A
+
#ifndef __ASSEMBLER__
enum pwm_channel {
PWM_CH_KBLIGHT = 0,
+ PWM_CH_LED1_AMBER,
+ PWM_CH_LED2_BLUE,
PWM_CH_COUNT
};
enum battery_type {
- BATTERY_DANAPACK_COS,
- BATTERY_DANAPACK_ATL,
- BATTERY_DANAPACK_SDI,
- BATTERY_SAMSUNG_SDI,
+ BATTERY_PANASONIC,
BATTERY_TYPE_COUNT,
};
diff --git a/board/aleena/gpio.inc b/board/aleena/gpio.inc
index 9d7799ab8a..de92aa2ff9 100644
--- a/board/aleena/gpio.inc
+++ b/board/aleena/gpio.inc
@@ -31,22 +31,19 @@ GPIO(ENABLE_BACKLIGHT_L, PIN(D, 3), GPIO_OUT_HIGH) /* Enable Backlight */
GPIO(PCH_RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* RSMRST# to SOC */
GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_OUT_HIGH) /* Power Button to SOC */
GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_OUT_HIGH) /* Wake SOC */
-GPIO(SYS_RESET_L, PIN(3, 5), GPIO_ODR_HIGH) /* Cold Reset to SOC */
+GPIO(SYS_RESET_L, PIN(E, 4), GPIO_ODR_HIGH) /* Cold Reset to SOC */
GPIO(CCD_MODE_ODL, PIN(E, 3), GPIO_INPUT) /* Case Closed Debug Mode */
GPIO(ENTERING_RW, PIN(E, 1), GPIO_OUT_LOW) /* EC Entering RW */
GPIO(EC_BATT_PRES_L, PIN(E, 5), GPIO_INPUT | GPIO_PULL_UP) /* Battery Present */
GPIO(PCH_SYS_PWROK, PIN(D, 6), GPIO_OUT_LOW) /* Power OK to SOC */
-GPIO(EC_APU_RST, PIN(E, 4), GPIO_INPUT) /* Reset to SOC */
GPIO(CPU_PROCHOT, PIN(3, 4), GPIO_INPUT | GPIO_SEL_1P8V) /* PROCHOT to SOC */
GPIO(APU_ALERT_L, PIN(A, 2), GPIO_INPUT) /* Alert to SOC */
GPIO(3AXIS_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) /* 3 Axis Accel */
+GPIO(KB_BL_EN, PIN(F, 2), GPIO_OUT_LOW) /* Enable KB Backlight */
/* We don't have 5V rail control but the BQ24392 driver expects the GPIO */
UNIMPLEMENTED(EN_PP5000)
-GPIO(BAT_LED_AMBER_L, PIN(C, 3), GPIO_OUT_HIGH)
-GPIO(BAT_LED_WHITE_L, PIN(C, 4), GPIO_OUT_HIGH)
-
/* I2C pins - these will be reconfigured for alternate function below */
GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_POWER_SCL */
GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C_POWER_SDA */
@@ -56,6 +53,10 @@ GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SCL */
GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SDA */
GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT | GPIO_SEL_1P8V) /* APU_SIC */
GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT | GPIO_SEL_1P8V) /* APU_SID */
+GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) /* EC_I2C_EEPROM_SCL and
+ EC_I2C_KB_BL_SCL */
+GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) /* EC_I2C_EEPROM_SDA and
+ EC_I2C_KB_BL_SDA */
GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT | GPIO_SEL_1P8V) /* EC_I2C_SENSOR_SCL */
GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT | GPIO_SEL_1P8V) /* EC_I2C_SENSOR_SDA */
@@ -101,6 +102,7 @@ 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 1b9c043043..fc6f427cd2 100644
--- a/board/aleena/led.c
+++ b/board/aleena/led.c
@@ -1,153 +1,66 @@
/* 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.
- *
- * LED control for Aleena
*/
-#include "battery.h"
-#include "charge_state.h"
-#include "chipset.h"
+#include "common.h"
#include "ec_commands.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "led_common.h"
+#include "led_pwm.h"
#include "util.h"
-#include "system.h"
-
-#define BAT_LED_ON 0
-#define BAT_LED_OFF 1
-
-const enum ec_led_id supported_led_ids[] = {EC_LED_ID_BATTERY_LED};
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_POWER_LED,
+};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-enum led_color {
- LED_OFF = 0,
- LED_AMBER,
- LED_WHITE,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
+/*
+ * 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 },
};
-static int led_set_color_battery(enum led_color color)
-{
- switch (color) {
- case LED_OFF:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_OFF);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_OFF);
- break;
- case LED_WHITE:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_ON);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_OFF);
- break;
- case LED_AMBER:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_OFF);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_ON);
- break;
- default:
- return EC_ERROR_UNKNOWN;
- }
- return EC_SUCCESS;
-}
+/* 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,
+ },
+};
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
- brightness_range[EC_LED_COLOR_WHITE] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
+ 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;
}
-static int led_set_color(enum ec_led_id led_id, enum led_color color)
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
{
- int rv;
+ enum pwm_led_id pwm_id;
- switch (led_id) {
- case EC_LED_ID_BATTERY_LED:
- rv = led_set_color_battery(color);
- break;
- default:
+ /* 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;
- }
- return rv;
-}
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color(led_id, LED_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color(led_id, LED_AMBER);
+ 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);
else
- led_set_color(led_id, LED_OFF);
+ /* Otherwise, the "color" is "off". */
+ set_pwm_led_color(pwm_id, -1);
return EC_SUCCESS;
}
-
-static void led_set_battery(void)
-{
- static int battery_ticks;
- static int power_ticks;
- uint32_t chflags = charge_get_flags();
-
- battery_ticks++;
-
- /* override battery led for system suspend */
- if (chipset_in_state(CHIPSET_STATE_SUSPEND |
- CHIPSET_STATE_STANDBY) &&
- charge_get_state() != PWR_STATE_CHARGE) {
- led_set_color_battery(power_ticks++ & 0x4 ?
- LED_WHITE : LED_OFF);
- return;
- }
-
- power_ticks = 0;
-
- switch (charge_get_state()) {
- case PWR_STATE_CHARGE:
- led_set_color_battery(LED_AMBER);
- break;
- case PWR_STATE_DISCHARGE_FULL:
- if (extpower_is_present()) {
- led_set_color_battery(LED_WHITE);
- break;
- }
- /* Intentional fall-through */
- case PWR_STATE_DISCHARGE:
- /*
- * Blink white light (1 sec on, 1 sec off)
- * when battery capacity is less than 10%
- */
- if (charge_get_percent() < 10)
- led_set_color_battery(
- (battery_ticks & 0x4) ? LED_WHITE : LED_OFF);
- else
- led_set_color_battery(LED_OFF);
- break;
- case PWR_STATE_ERROR:
- led_set_color_battery(
- (battery_ticks & 0x2) ? LED_WHITE : LED_OFF);
- break;
- case PWR_STATE_CHARGE_NEAR_FULL:
- led_set_color_battery(LED_WHITE);
- break;
- case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (chflags & CHARGE_FLAG_FORCE_IDLE)
- led_set_color_battery(
- (battery_ticks & 0x4) ? LED_AMBER : LED_OFF);
- else
- led_set_color_battery(LED_WHITE);
- break;
- default:
- /* Other states don't alter LED behavior */
- break;
- }
-}
-
-/* Called by hook task every TICK */
-static void led_tick(void)
-{
- if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
- led_set_battery();
-}
-DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
diff --git a/board/liara/battery.c b/board/liara/battery.c
index 6b0c24ca96..9172300ed5 100644
--- a/board/liara/battery.c
+++ b/board/liara/battery.c
@@ -32,122 +32,34 @@
* address, mask, and disconnect value need to be provided.
*/
const struct board_batt_params board_battery_info[] = {
- /* DynaPack Coslight Battery Information */
- [BATTERY_DANAPACK_COS] = {
+ /* Panasonic AP15O5L Battery Information */
+ [BATTERY_PANASONIC] = {
.fuel_gauge = {
- .manuf_name = "333-2C-DA-A",
+ .manuf_name = "PANASONIC",
.ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
+ .reg_addr = 0x3A,
+ .reg_data = { 0xC574, 0xC574 },
},
.fet = {
- .mfgacc_support = 1,
.reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
+ .reg_mask = 0x4000,
+ .disconnect_val = 0x0,
}
},
.batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* DynaPack ATL Battery Information */
- [BATTERY_DANAPACK_ATL] = {
- .fuel_gauge = {
- .manuf_name = "333-27-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* DynaPack SDI Battery Information */
- [BATTERY_DANAPACK_SDI] = {
- .fuel_gauge = {
- .manuf_name = "333-24-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Samsung SDI Battery Information */
- [BATTERY_SAMSUNG_SDI] = {
- .fuel_gauge = {
- .manuf_name = "333-54-DA-A",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x0010, 0x0010 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = 8800, /* mV */
- .voltage_normal = 7600,
- .voltage_min = 6000,
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
+ .voltage_max = 13200,
+ .voltage_normal = 11550, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 60,
},
},
};
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_DANAPACK_COS;
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC;
diff --git a/board/liara/board.c b/board/liara/board.c
index 3962ad6c67..28819b9e0b 100644
--- a/board/liara/board.c
+++ b/board/liara/board.c
@@ -108,6 +108,7 @@ const struct i2c_port_t i2c_ports[] = {
{"tcpc0", I2C_PORT_TCPC0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
{"tcpc1", I2C_PORT_TCPC1, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
{"thermal", I2C_PORT_THERMAL, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA},
+ {"kblight", I2C_PORT_KBLIGHT, 100, GPIO_I2C5_SCL, GPIO_I2C5_SDA},
{"sensor", I2C_PORT_SENSOR, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -119,6 +120,18 @@ 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);
@@ -239,3 +252,14 @@ void board_reset_pd_mcu(void)
msleep(ANX74XX_PWR_L_PWR_H_DELAY_MS);
board_set_tcpc_power_mode(USB_PD_PORT_ANX74XX, 1);
}
+
+static void board_kblight_init(void)
+{
+ /*
+ * Enable keyboard backlight. This needs to be done here because
+ * the chip doesn't have power until PP3300_S0 comes up.
+ */
+ gpio_set_level(GPIO_KB_BL_EN, 1);
+ lm3630a_poweron();
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_kblight_init, HOOK_PRIO_DEFAULT);
diff --git a/board/liara/board.h b/board/liara/board.h
index 690306a09a..6ed99a09d1 100644
--- a/board/liara/board.h
+++ b/board/liara/board.h
@@ -20,21 +20,38 @@
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
+/* Power and battery LEDs */
#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 I2C_PORT_KBLIGHT NPCX_I2C_PORT5_0
+
+/* KB backlight driver */
+#define CONFIG_LED_DRIVER_LM3630A
+
#ifndef __ASSEMBLER__
enum pwm_channel {
PWM_CH_KBLIGHT = 0,
+ PWM_CH_LED1_AMBER,
+ PWM_CH_LED2_BLUE,
PWM_CH_COUNT
};
enum battery_type {
- BATTERY_DANAPACK_COS,
- BATTERY_DANAPACK_ATL,
- BATTERY_DANAPACK_SDI,
- BATTERY_SAMSUNG_SDI,
+ BATTERY_PANASONIC,
BATTERY_TYPE_COUNT,
};
diff --git a/board/liara/gpio.inc b/board/liara/gpio.inc
index fe9a5eb7b8..11278d4ca5 100644
--- a/board/liara/gpio.inc
+++ b/board/liara/gpio.inc
@@ -31,22 +31,19 @@ GPIO(ENABLE_BACKLIGHT_L, PIN(D, 3), GPIO_OUT_HIGH) /* Enable Backlight */
GPIO(PCH_RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* RSMRST# to SOC */
GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_OUT_HIGH) /* Power Button to SOC */
GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_OUT_HIGH) /* Wake SOC */
-GPIO(SYS_RESET_L, PIN(3, 5), GPIO_ODR_HIGH) /* Cold Reset to SOC */
+GPIO(SYS_RESET_L, PIN(E, 4), GPIO_ODR_HIGH) /* Cold Reset to SOC */
GPIO(CCD_MODE_ODL, PIN(E, 3), GPIO_INPUT) /* Case Closed Debug Mode */
GPIO(ENTERING_RW, PIN(E, 1), GPIO_OUT_LOW) /* EC Entering RW */
GPIO(EC_BATT_PRES_L, PIN(E, 5), GPIO_INPUT | GPIO_PULL_UP) /* Battery Present */
GPIO(PCH_SYS_PWROK, PIN(D, 6), GPIO_OUT_LOW) /* Power OK to SOC */
-GPIO(EC_APU_RST, PIN(E, 4), GPIO_INPUT) /* Reset to SOC */
GPIO(CPU_PROCHOT, PIN(3, 4), GPIO_INPUT | GPIO_SEL_1P8V) /* PROCHOT to SOC */
GPIO(APU_ALERT_L, PIN(A, 2), GPIO_INPUT) /* Alert to SOC */
GPIO(3AXIS_INT_L, PIN(5, 0), GPIO_INPUT | GPIO_SEL_1P8V) /* 3 Axis Accel */
+GPIO(KB_BL_EN, PIN(F, 2), GPIO_OUT_LOW) /* Enable KB Backlight */
/* We don't have 5V rail control but the BQ24392 driver expects the GPIO */
UNIMPLEMENTED(EN_PP5000)
-GPIO(BAT_LED_AMBER_L, PIN(C, 3), GPIO_OUT_HIGH)
-GPIO(BAT_LED_WHITE_L, PIN(C, 4), GPIO_OUT_HIGH)
-
/* I2C pins - these will be reconfigured for alternate function below */
GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_POWER_SCL */
GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C_POWER_SDA */
@@ -56,6 +53,10 @@ GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SCL */
GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SDA */
GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT | GPIO_SEL_1P8V) /* APU_SIC */
GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT | GPIO_SEL_1P8V) /* APU_SID */
+GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) /* EC_I2C_EEPROM_SCL and
+ EC_I2C_KB_BL_SCL */
+GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) /* EC_I2C_EEPROM_SDA and
+ EC_I2C_KB_BL_SDA */
GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT | GPIO_SEL_1P8V) /* EC_I2C_SENSOR_SCL */
GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT | GPIO_SEL_1P8V) /* EC_I2C_SENSOR_SDA */
@@ -101,6 +102,7 @@ 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/liara/led.c b/board/liara/led.c
index b5b0960647..fc6f427cd2 100644
--- a/board/liara/led.c
+++ b/board/liara/led.c
@@ -1,153 +1,66 @@
/* 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.
- *
- * LED control for Liara
*/
-#include "battery.h"
-#include "charge_state.h"
-#include "chipset.h"
+#include "common.h"
#include "ec_commands.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "led_common.h"
+#include "led_pwm.h"
#include "util.h"
-#include "system.h"
-
-#define BAT_LED_ON 0
-#define BAT_LED_OFF 1
-
-const enum ec_led_id supported_led_ids[] = {EC_LED_ID_BATTERY_LED};
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_POWER_LED,
+};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-enum led_color {
- LED_OFF = 0,
- LED_AMBER,
- LED_WHITE,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
+/*
+ * 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 },
};
-static int led_set_color_battery(enum led_color color)
-{
- switch (color) {
- case LED_OFF:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_OFF);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_OFF);
- break;
- case LED_WHITE:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_ON);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_OFF);
- break;
- case LED_AMBER:
- gpio_set_level(GPIO_BAT_LED_WHITE_L, BAT_LED_OFF);
- gpio_set_level(GPIO_BAT_LED_AMBER_L, BAT_LED_ON);
- break;
- default:
- return EC_ERROR_UNKNOWN;
- }
- return EC_SUCCESS;
-}
+/* 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,
+ },
+};
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
- brightness_range[EC_LED_COLOR_WHITE] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
+ 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;
}
-static int led_set_color(enum ec_led_id led_id, enum led_color color)
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
{
- int rv;
+ enum pwm_led_id pwm_id;
- switch (led_id) {
- case EC_LED_ID_BATTERY_LED:
- rv = led_set_color_battery(color);
- break;
- default:
+ /* 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;
- }
- return rv;
-}
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color(led_id, LED_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color(led_id, LED_AMBER);
+ 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);
else
- led_set_color(led_id, LED_OFF);
+ /* Otherwise, the "color" is "off". */
+ set_pwm_led_color(pwm_id, -1);
return EC_SUCCESS;
}
-
-static void led_set_battery(void)
-{
- static int battery_ticks;
- static int power_ticks;
- uint32_t chflags = charge_get_flags();
-
- battery_ticks++;
-
- /* override battery led for system suspend */
- if (chipset_in_state(CHIPSET_STATE_SUSPEND |
- CHIPSET_STATE_STANDBY) &&
- charge_get_state() != PWR_STATE_CHARGE) {
- led_set_color_battery(power_ticks++ & 0x4 ?
- LED_WHITE : LED_OFF);
- return;
- }
-
- power_ticks = 0;
-
- switch (charge_get_state()) {
- case PWR_STATE_CHARGE:
- led_set_color_battery(LED_AMBER);
- break;
- case PWR_STATE_DISCHARGE_FULL:
- if (extpower_is_present()) {
- led_set_color_battery(LED_WHITE);
- break;
- }
- /* Intentional fall-through */
- case PWR_STATE_DISCHARGE:
- /*
- * Blink white light (1 sec on, 1 sec off)
- * when battery capacity is less than 10%
- */
- if (charge_get_percent() < 10)
- led_set_color_battery(
- (battery_ticks & 0x4) ? LED_WHITE : LED_OFF);
- else
- led_set_color_battery(LED_OFF);
- break;
- case PWR_STATE_ERROR:
- led_set_color_battery(
- (battery_ticks & 0x2) ? LED_WHITE : LED_OFF);
- break;
- case PWR_STATE_CHARGE_NEAR_FULL:
- led_set_color_battery(LED_WHITE);
- break;
- case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (chflags & CHARGE_FLAG_FORCE_IDLE)
- led_set_color_battery(
- (battery_ticks & 0x4) ? LED_AMBER : LED_OFF);
- else
- led_set_color_battery(LED_WHITE);
- break;
- default:
- /* Other states don't alter LED behavior */
- break;
- }
-}
-
-/* Called by hook task every TICK */
-static void led_tick(void)
-{
- if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
- led_set_battery();
-}
-DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);