summaryrefslogtreecommitdiff
path: root/board/taeko
diff options
context:
space:
mode:
Diffstat (limited to 'board/taeko')
-rw-r--r--board/taeko/board.c16
-rw-r--r--board/taeko/board.h35
-rw-r--r--board/taeko/ec.tasklist1
-rw-r--r--board/taeko/gpio.inc3
-rw-r--r--board/taeko/i2c.c5
-rw-r--r--board/taeko/sensors.c52
-rw-r--r--board/taeko/usbc_config.c19
7 files changed, 100 insertions, 31 deletions
diff --git a/board/taeko/board.c b/board/taeko/board.c
index c3b496d9ce..6fb96f7d21 100644
--- a/board/taeko/board.c
+++ b/board/taeko/board.c
@@ -5,7 +5,9 @@
#include "battery.h"
#include "button.h"
+#include "charge_manager.h"
#include "charge_ramp.h"
+#include "charge_state_v2.h"
#include "charger.h"
#include "common.h"
#include "compile_time_macros.h"
@@ -109,3 +111,17 @@ enum battery_present battery_hw_present(void)
/* The GPIO is low when the battery is physically present */
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
+
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
+{
+ /*
+ * Follow OEM request to limit the input current to
+ * 95% negotiated limit.
+ */
+ charge_ma = charge_ma * 95 / 100;
+
+ charge_set_input_current_limit(MAX(charge_ma,
+ CONFIG_CHARGER_INPUT_CURRENT),
+ charge_mv);
+}
diff --git a/board/taeko/board.h b/board/taeko/board.h
index 66905bb82d..5ba767bdb9 100644
--- a/board/taeko/board.h
+++ b/board/taeko/board.h
@@ -19,6 +19,7 @@
#include "baseboard.h"
#define CONFIG_SYSTEM_UNLOCKED
+#define CONFIG_BYPASS_CBI_EEPROM_WP_CHECK
/*
* This will happen automatically on NPCX9 ES2 and later. Do not remove
@@ -91,6 +92,12 @@
#define CONFIG_USBC_PPC_SYV682X
#define CONFIG_USBC_PPC_NX20P3483
+/* I2C speed console command */
+#define CONFIG_CMD_I2C_SPEED
+
+/* I2C control host command */
+#define CONFIG_HOSTCMD_I2C_CONTROL
+
/* TODO: b/177608416 - measure and check these values on brya */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
@@ -104,6 +111,9 @@
#define PD_MAX_CURRENT_MA 3000
#define PD_MAX_VOLTAGE_MV 20000
+/* The lower the input voltage, the higher the power efficiency. */
+#define PD_PREFER_LOW_VOLTAGE
+
/*
* Macros for GPIO signals used in common code that don't match the
* schematic names. Signal names in gpio.inc match the schematic and are
@@ -122,6 +132,7 @@
#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST
#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L
#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
/*
@@ -162,7 +173,7 @@
/* Thermal features */
#define CONFIG_THERMISTOR
#define CONFIG_TEMP_SENSOR
-#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK
+#define CONFIG_TEMP_SENSOR_POWER
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
/* Fan */
@@ -171,10 +182,30 @@
/* Charger defines */
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM
-#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
+/* 37h BIT7:2 VSYS_TH2 6.0V */
+#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 60
#define CONFIG_CHARGE_RAMP_SW
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
+/* 30h BIT13:12 Enable PSYS 00b */
+#define CONFIG_CHARGER_BQ25710_PSYS_SENSING
+/* 31h BIT3 = 1 Enable ACOC */
+#define CONFIG_CHARGER_BQ25710_EN_ACOC
+/* 33h BIT15:11 ILIM2 TH 140% */
+#define CONFIG_CHARGER_BQ257X0_ILIM2_VTH_CUSTOM
+#define CONFIG_CHARGER_BQ257X0_ILIM2_VTH \
+ BQ257X0_PROCHOT_OPTION_0_ILIM2_VTH__1P40
+/* 34h BIT0 CONFIG_CHARGER_BQ25710_PP_ACOK */
+#define CONFIG_CHARGER_BQ25710_PP_ACOK
+/* 34h BIT3 and BIT15:10 IDCHG 9728mA, step is 512mA */
+#define CONFIG_CHARGER_BQ25710_IDCHG_LIMIT_MA 9728
+/* 36h UVP 5600mV */
+#define CONFIG_CHARGER_BQ25720_VSYS_UVP_CUSTOM
+#define CONFIG_CHARGER_BQ25720_VSYS_UVP \
+ BQ25720_CHARGE_OPTION_4_VSYS_UVP__5P6
+/* 3Eh BIT15:8 VSYS_MIN 6.1V */
+#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV 6100
#ifndef __ASSEMBLER__
diff --git a/board/taeko/ec.tasklist b/board/taeko/ec.tasklist
index 41d86da3d6..6d995d6b44 100644
--- a/board/taeko/ec.tasklist
+++ b/board/taeko/ec.tasklist
@@ -19,6 +19,7 @@
TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \
+ TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, CONSOLE_TASK_STACK_SIZE) \
TASK_ALWAYS(POWERBTN, power_button_task, NULL, BASEBOARD_POWERBTN_TASK_STACK_SIZE) \
diff --git a/board/taeko/gpio.inc b/board/taeko/gpio.inc
index 7e97007af6..583efc308c 100644
--- a/board/taeko/gpio.inc
+++ b/board/taeko/gpio.inc
@@ -73,7 +73,7 @@ GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
GPIO(USB_C0_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW)
GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT)
-GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_LOW)
+GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_HIGH)
GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW)
/* UART alternate functions */
@@ -120,6 +120,7 @@ UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */
UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */
UNUSED(PIN(4, 1)) /* GPIO41/ADC4 */
UNUSED(PIN(6, 6)) /* GPIO66 */
+UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */
/* Pre-configured PSL balls: J8 K6 */
diff --git a/board/taeko/i2c.c b/board/taeko/i2c.c
index 0a32a502ab..2c990254fa 100644
--- a/board/taeko/i2c.c
+++ b/board/taeko/i2c.c
@@ -38,9 +38,10 @@ const struct i2c_port_t i2c_ports[] = {
/* I2C4 C1 TCPC */
.name = "tcpc1",
.port = I2C_PORT_USB_C1_TCPC,
- .kbps = 400,
+ .kbps = 1000,
.scl = GPIO_EC_I2C_USB_C1_TCPC_SCL,
.sda = GPIO_EC_I2C_USB_C1_TCPC_SDA,
+ .flags = I2C_PORT_FLAG_DYNAMIC_SPEED,
},
{
/* I2C5 */
@@ -54,7 +55,7 @@ const struct i2c_port_t i2c_ports[] = {
/* I2C6 */
.name = "ppc1",
.port = I2C_PORT_USB_C1_PPC,
- .kbps = 400,
+ .kbps = 1000,
.scl = GPIO_EC_I2C_USB_C1_MIX_SCL,
.sda = GPIO_EC_I2C_USB_C1_MIX_SDA,
},
diff --git a/board/taeko/sensors.c b/board/taeko/sensors.c
index b5d75460fe..f12e2a9f94 100644
--- a/board/taeko/sensors.c
+++ b/board/taeko/sensors.c
@@ -67,21 +67,24 @@ static struct accelgyro_saved_data_t g_bma422_data;
static struct lsm6dso_data lsm6dso_data;
static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA;
-/* TODO(b/201504044): calibrate the orientation matrix on later board stage */
-#if 0
-static const mat33_fp_t lid_standard_ref = {
+/* The matrix for new DB */
+static const mat33_fp_t lid_ref_for_new_DB = {
+ { FLOAT_TO_FP(-1), 0, 0},
{ 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(1), 0, 0},
{ 0, 0, FLOAT_TO_FP(-1)}
};
+/* Matrix to rotate lid and base sensor into standard reference frame */
+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 = {
- { FLOAT_TO_FP(1), 0, 0},
- { 0, FLOAT_TO_FP(-1), 0},
+ { FLOAT_TO_FP(-1), 0, 0},
+ { 0, FLOAT_TO_FP(1), 0},
{ 0, 0, FLOAT_TO_FP(-1)}
};
-#endif
-
struct motion_sensor_t bma422_lid_accel = {
.name = "Lid Accel - BMA",
@@ -94,7 +97,7 @@ struct motion_sensor_t bma422_lid_accel = {
.drv_data = &g_bma422_data,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = BMA4_I2C_ADDR_PRIMARY, /* 0x18 */
- .rot_standard_ref = NULL, /* identity matrix */
+ .rot_standard_ref = &lid_standard_ref, /* identity matrix */
.default_range = 2, /* g, enough for laptop. */
.min_frequency = BMA4_ACCEL_MIN_FREQ,
.max_frequency = BMA4_ACCEL_MAX_FREQ,
@@ -122,11 +125,9 @@ struct motion_sensor_t lsm6dsm_base_accel = {
.mutex = &g_base_accel_mutex,
.drv_data = LSM6DSM_ST_DATA(lsm6dsm_data,
MOTIONSENSE_TYPE_ACCEL),
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
@@ -153,12 +154,10 @@ struct motion_sensor_t lsm6dsm_base_gyro = {
.drv = &lsm6dsm_drv,
.mutex = &g_base_accel_mutex,
.drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_GYRO),
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
};
@@ -173,11 +172,9 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &lis2dw12_drv,
.mutex = &g_lid_accel_mutex,
.drv_data = &g_lis2dw12_data,
- .int_signal = GPIO_EC_ACCEL_INT_R_L,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LIS2DW12_ADDR1, /* 0x19 */
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .rot_standard_ref = NULL, /* identity matrix */
+ .rot_standard_ref = &lid_standard_ref, /* identity matrix */
.default_range = 2, /* g */
.min_frequency = LIS2DW12_ODR_MIN_VAL,
.max_frequency = LIS2DW12_ODR_MAX_VAL,
@@ -202,11 +199,9 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &lsm6dso_drv,
.mutex = &g_base_accel_mutex,
.drv_data = &lsm6dso_data,
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.default_range = 4, /* g */
.min_frequency = LSM6DSO_ODR_MIN_VAL,
.max_frequency = LSM6DSO_ODR_MAX_VAL,
@@ -231,12 +226,10 @@ struct motion_sensor_t motion_sensors[] = {
.drv = &lsm6dso_drv,
.mutex = &g_base_accel_mutex,
.drv_data = &lsm6dso_data,
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSO_ODR_MIN_VAL,
.max_frequency = LSM6DSO_ODR_MAX_VAL,
},
@@ -287,6 +280,11 @@ static void board_detect_motionsensor(void)
* we don't use INT1. Keep this pin as input w/o enable
* interrupt.
*/
+ if (get_board_id() >= 2) {
+ /* Need to change matrix when board ID >= 2 */
+ bma422_lid_accel.rot_standard_ref =
+ &lid_ref_for_new_DB;
+ }
return;
}
@@ -322,6 +320,12 @@ static void baseboard_sensors_init(void)
motion_sensors[BASE_GYRO] = lsm6dsm_base_gyro;
}
+ if (get_board_id() >= 2) {
+ /* Need to change matrix when board ID >= 2 */
+ motion_sensors[LID_ACCEL].rot_standard_ref =
+ &lid_ref_for_new_DB;
+ }
+
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L);
} else {
diff --git a/board/taeko/usbc_config.c b/board/taeko/usbc_config.c
index c8e02581be..4cdb29b779 100644
--- a/board/taeko/usbc_config.c
+++ b/board/taeko/usbc_config.c
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include "battery.h"
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
@@ -64,7 +65,8 @@ const struct tcpc_config_t tcpc_config[] = {
},
.drv = &ps8xxx_tcpm_drv,
.flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V,
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN,
},
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
@@ -168,6 +170,11 @@ static void ps8815_reset(void)
if (i2c_read8(I2C_PORT_USB_C1_TCPC,
PS8751_I2C_ADDR1_FLAGS, 0x0f, &val) == EC_SUCCESS)
CPRINTS("ps8815: reg 0x0f was %02x", val);
+ else {
+ CPRINTS("delay 10ms to make sure PS8815 is waken from idle");
+ msleep(10);
+ }
+
if (i2c_write8(I2C_PORT_USB_C1_TCPC,
PS8751_I2C_ADDR1_FLAGS, 0x0f, 0x31) == EC_SUCCESS)
@@ -235,7 +242,15 @@ void board_reset_pd_mcu(void)
*/
gpio_set_level(GPIO_USB_C0_TCPC_RST_ODL, 0);
- gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0);
+
+ /*
+ * (b/202489681): Nx20p3483 cannot sink power after reset ec
+ * To avoid nx20p3483 cannot sink power after reset ec w/ AC
+ * only in TCPC1 port, EC shouldn't assert GPIO_USB_C1_RT_RST_R_ODL
+ * if no battery.
+ */
+ if (battery_hw_present())
+ gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0);
/*
* delay for power-on to reset-off and min. assertion time