summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/homestar/board.c40
-rw-r--r--board/homestar/board.h4
-rw-r--r--board/homestar/gpio.inc12
3 files changed, 45 insertions, 11 deletions
diff --git a/board/homestar/board.c b/board/homestar/board.c
index 1afb735bbc..8e1977b49a 100644
--- a/board/homestar/board.c
+++ b/board/homestar/board.c
@@ -13,6 +13,7 @@
#include "extpower.h"
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi_common.h"
+#include "driver/ln9310.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/tcpci.h"
@@ -47,6 +48,7 @@ static void usb0_evt(enum gpio_signal signal);
static void usb1_evt(enum gpio_signal signal);
static void ppc_interrupt(enum gpio_signal signal);
static void board_connect_c0_sbu(enum gpio_signal s);
+static void switchcap_interrupt(enum gpio_signal signal);
#include "gpio_list.h"
@@ -108,6 +110,11 @@ static void board_connect_c0_sbu(enum gpio_signal s)
hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
}
+static void switchcap_interrupt(enum gpio_signal signal)
+{
+ ln9310_interrupt(signal);
+}
+
/* I2C port map */
const struct i2c_port_t i2c_ports[] = {
{"power", I2C_PORT_POWER, 100, GPIO_EC_I2C_POWER_SCL,
@@ -175,6 +182,12 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+/* LN9310 switchcap */
+const struct ln9310_config_t ln9310_config = {
+ .i2c_port = I2C_PORT_POWER,
+ .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS,
+};
+
/* Power Path Controller */
struct ppc_config_t ppc_chips[] = {
{
@@ -300,6 +313,25 @@ struct motion_sensor_t motion_sensors[] = {
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+enum battery_cell_type board_get_battery_cell_type(void)
+{
+ return BATTERY_CELL_TYPE_2S;
+}
+
+static void board_switchcap_init(void)
+{
+ CPRINTS("Use switchcap: LN9310");
+
+ /* Configure and enable interrupt for LN9310 */
+ gpio_set_flags(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_FALLING);
+ gpio_enable_interrupt(GPIO_SWITCHCAP_PG_INT_L);
+
+ /* Only configure the switchcap if not sysjump */
+ if (!system_jumped_late()) {
+ ln9310_init();
+ }
+}
+
/* Initialize board. */
static void board_init(void)
{
@@ -317,6 +349,8 @@ static void board_init(void)
/* Set the backlight duty cycle to 0. AP will override it later. */
pwm_set_duty(PWM_CH_DISPLIGHT, 0);
+
+ board_switchcap_init();
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -404,17 +438,17 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
void board_set_switchcap_power(int enable)
{
- gpio_set_level(GPIO_SWITCHCAP_ON, enable);
+ gpio_set_level(GPIO_SWITCHCAP_ON_L, !enable);
}
int board_is_switchcap_enabled(void)
{
- return gpio_get_level(GPIO_SWITCHCAP_ON);
+ return !gpio_get_level(GPIO_SWITCHCAP_ON_L);
}
int board_is_switchcap_power_good(void)
{
- return gpio_get_level(GPIO_DA9313_GPIO0);
+ return ln9310_power_good();
}
void board_reset_pd_mcu(void)
diff --git a/board/homestar/board.h b/board/homestar/board.h
index c5d2e4aaf3..0e715b9078 100644
--- a/board/homestar/board.h
+++ b/board/homestar/board.h
@@ -32,6 +32,9 @@
/* Internal SPI flash on NPCX7 */
#define CONFIG_FLASH_SIZE_BYTES (512 * 1024) /* 512KB internal spi flash */
+/* Switchcap */
+#define CONFIG_LN9310
+
/* Battery */
#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
#define CONFIG_BATTERY_REVIVE_DISCONNECT
@@ -66,6 +69,7 @@
#define GPIO_PMIC_RESIN_L GPIO_PM845_RESIN_L
/* TODO(Dolan): check which pin was used for tablet mode detect */
#define GMR_TABLET_MODE_GPIO_L GPIO_LID_OPEN_EC
+#define GPIO_SWITCHCAP_PG_INT_L GPIO_LN9310_INT
#ifndef __ASSEMBLER__
diff --git a/board/homestar/gpio.inc b/board/homestar/gpio.inc
index 23461fc432..165968d48c 100644
--- a/board/homestar/gpio.inc
+++ b/board/homestar/gpio.inc
@@ -44,6 +44,9 @@ GPIO_INT(BASE_DET_L, PIN(3, 7), GPIO_INT_BOTH, base_detect_interrupt) /*
/* Sensor interrupts */
GPIO_INT(ACCEL_GYRO_INT_L, PIN(A, 0), GPIO_INT_FALLING, bmi160_interrupt) /* Accelerometer/gyro interrupt */
+/* Switchcap, for LN9310, it is the interrupt line of LN9310. */
+GPIO_INT(LN9310_INT, PIN(E, 2), GPIO_INT_FALLING, switchcap_interrupt)
+
/*
* EC_RST_ODL acts as a wake source from hibernate mode. However, it does not
* need to be an interrupt for normal EC operations. Simply set it an INPUT.
@@ -60,7 +63,7 @@ GPIO(QSIP_ON, PIN(5, 0), GPIO_OUT_LOW) /* Not used, for non-swit
/* Power enables */
GPIO(HIBERNATE_L, PIN(5, 2), GPIO_OUT_HIGH) /* EC hibernate */
-GPIO(SWITCHCAP_ON, PIN(D, 5), GPIO_OUT_LOW) /* Enable switch cap; will be configured in the board init */
+GPIO(SWITCHCAP_ON_L, PIN(D, 5), GPIO_ODR_HIGH) /* Enable switch cap */
GPIO(EN_PP3300_A, PIN(A, 6), GPIO_OUT_LOW) /* Enable PP3300 */
GPIO(EN_PP5000_A, PIN(6, 7), GPIO_OUT_LOW) /* Enable PP5000 */
GPIO(EC_BL_DISABLE_L, PIN(B, 6), GPIO_OUT_LOW) /* Backlight disable signal from EC */
@@ -121,13 +124,6 @@ GPIO(SKU_ID0, PIN(F, 0), GPIO_INPUT)
GPIO(SKU_ID1, PIN(4, 1), GPIO_INPUT)
GPIO(SKU_ID2, PIN(D, 4), GPIO_INPUT)
-/* Switchcap */
-/*
- * GPIO0 is configured as PVC_PG. When the chip in power down mode, it outputs
- * high-Z. Set pull-down to avoid floating.
- */
-GPIO(DA9313_GPIO0, PIN(E, 2), GPIO_INPUT | GPIO_PULL_DOWN) /* Switchcap GPIO0 */
-
/* Special straps */
GPIO(ARM_X86, PIN(6, 6), GPIO_OUT_LOW) /* NC, low for power saving */