diff --git a/board/kevin/board.c b/board/kevin/board.c index 940c2e4045..cc6f03bf62 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -298,7 +298,7 @@ static void board_spi_enable(void) { spi_enable(CONFIG_SPI_ACCEL_PORT, 1); } -DECLARE_HOOK(HOOK_CHIPSET_RESUME, +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_spi_enable, MOTION_SENSE_HOOK_PRIO - 1); @@ -321,7 +321,7 @@ static void board_spi_disable(void) spi_enable(CONFIG_SPI_ACCEL_PORT, 0); } -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_spi_disable, MOTION_SENSE_HOOK_PRIO + 1); @@ -517,7 +517,7 @@ struct motion_sensor_t motion_sensors[] = { */ [BASE_ACCEL] = { .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, @@ -539,10 +539,10 @@ struct motion_sensor_t motion_sensors[] = { .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 100 * MSEC, }, - /* Sensor off in S3/S5 */ + /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0 + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, }, /* Sensor off in S3/S5 */ [SENSOR_CONFIG_EC_S5] = { @@ -553,7 +553,7 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_GYRO] = { .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMI160, .type = MOTIONSENSE_TYPE_GYRO, .location = MOTIONSENSE_LOC_BASE, @@ -594,7 +594,7 @@ struct motion_sensor_t motion_sensors[] = { #ifdef BOARD_KEVIN [LID_ACCEL] = { .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMA255, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, @@ -616,9 +616,9 @@ struct motion_sensor_t motion_sensors[] = { .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 0, }, - /* unused */ + /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S3] = { - .odr = 0, + .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 0, }, [SENSOR_CONFIG_EC_S5] = { @@ -630,7 +630,7 @@ struct motion_sensor_t motion_sensors[] = { #else [LID_ACCEL] = { .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KX022, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, @@ -652,9 +652,9 @@ struct motion_sensor_t motion_sensors[] = { .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 0, }, - /* unused */ + /* EC use accel for angle detection */ [SENSOR_CONFIG_EC_S3] = { - .odr = 0, + .odr = 10000 | ROUND_UP_FLAG, .ec_rate = 0, }, [SENSOR_CONFIG_EC_S5] = { @@ -665,7 +665,7 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_BARO] = { .name = "Base Baro", - .active_mask = SENSOR_ACTIVE_S0, + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_BMP280, .type = MOTIONSENSE_TYPE_BARO, .location = MOTIONSENSE_LOC_BASE, @@ -701,6 +701,16 @@ struct motion_sensor_t motion_sensors[] = { }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +#ifndef TEST_BUILD +void lid_angle_peripheral_enable(int enable) +{ + keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE); + + /* enable/disable touchpad */ + gpio_set_level(GPIO_PP3300_TRACKPAD_EN_L, !enable); +} +#endif + #ifdef BOARD_GRU static void usb_charge_resume(void) { diff --git a/board/kevin/board.h b/board/kevin/board.h index 901e498eb5..2ae593221d 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -82,6 +82,7 @@ #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_INVALID_CHECK #define CONFIG_LID_ANGLE_TABLET_MODE +#define CONFIG_LID_ANGLE_UPDATE #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL #define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL @@ -149,7 +150,6 @@ #define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED /* Optional features for test commands */ -#define CONFIG_CMD_ACCELS #define CONFIG_CMD_CHARGER_PSYS #ifdef BOARD_GRU @@ -183,7 +183,6 @@ #define CONFIG_HOSTCMD_ALIGNED /* Modules we want to exclude */ -#undef CONFIG_CMD_ACCEL_INFO #undef CONFIG_CMD_FLASH #undef CONFIG_CMD_HASH #undef CONFIG_CMD_I2C_SCAN diff --git a/power/rk3399.c b/power/rk3399.c index 7352af8efc..1b6916c06d 100644 --- a/power/rk3399.c +++ b/power/rk3399.c @@ -224,6 +224,10 @@ enum power_state power_handle_state(enum power_state state) msleep(1); gpio_set_level(GPIO_PP1800_LID_EN_L, 0); + gpio_set_level(GPIO_PP1800_SIXAXIS_EN_L, 0); + msleep(2); + gpio_set_level(GPIO_PP1800_SENSOR_EN_L, 0); + /* * TODO: Consider ADC_PP900_AP / ADC_PP1200_LPDDR analog * voltage levels for state transition. @@ -260,10 +264,6 @@ enum power_state power_handle_state(enum power_state state) sys_reset_asserted = 0; } - gpio_set_level(GPIO_PP1800_SIXAXIS_EN_L, 0); - msleep(2); - gpio_set_level(GPIO_PP1800_SENSOR_EN_L, 0); - if (power_wait_signals(IN_PGOOD_S0)) { chipset_force_shutdown(); return POWER_S3S0; @@ -286,8 +286,6 @@ enum power_state power_handle_state(enum power_state state) hook_notify(HOOK_CHIPSET_SUSPEND); MSLEEP_CHECK_ABORTED_SUSPEND(20); - gpio_set_level(GPIO_PP1800_SENSOR_EN_L, 1); - gpio_set_level(GPIO_PP1800_SIXAXIS_EN_L, 1); gpio_set_level(GPIO_PP3300_S0_EN_L, 1); MSLEEP_CHECK_ABORTED_SUSPEND(20); @@ -326,6 +324,8 @@ enum power_state power_handle_state(enum power_state state) /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); + gpio_set_level(GPIO_PP1800_SENSOR_EN_L, 1); + gpio_set_level(GPIO_PP1800_SIXAXIS_EN_L, 1); gpio_set_level(GPIO_PP1800_LID_EN_L, 1); gpio_set_level(GPIO_PP3300_TRACKPAD_EN_L, 1); gpio_set_level(GPIO_PP5000_EN, 0);