diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2016-11-08 23:21:25 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-05-01 21:20:28 +0000 |
commit | a8a46316132256778c8da3d44e77816c2ca06b6f (patch) | |
tree | 7a378ce2da50e4d329b87c2e8b178f72c372b7ec | |
parent | d7ceef057cfdc28e7d272d608113d8ef331ee7b4 (diff) | |
download | chrome-ec-a8a46316132256778c8da3d44e77816c2ca06b6f.tar.gz |
BACKPORT: board: strago: Adapt to new sensor stack.
Remove sensor stack on devices that do not have sensors: umaro wizpig
kunimitsu [last one is not used anyway]
Add FIFO on strago, kefka, ultima and setzer only.
Remove code included by #ifdef CONFIG_GYRO_L3GD20H, unused.
Add MKBP support on ultima.
BUG=b:27849483, b:36973851
TEST=Check on Kefka, Ultima
BRANCH=strago, ultima, ultima
Reviewed-on: https://chromium-review.googlesource.com/409508
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 5246e8bffed2cea283f4e0104468b8d73d77789c)
Change-Id: I634ec16ad5df91fe002dc126a4d5b592ff0cc10c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/489781
-rw-r--r-- | board/cyan/board.c | 1 | ||||
-rw-r--r-- | board/setzer/board.c | 141 | ||||
-rw-r--r-- | board/setzer/board.h | 31 | ||||
-rw-r--r-- | board/strago/board.c | 141 | ||||
-rw-r--r-- | board/strago/board.h | 18 | ||||
-rw-r--r-- | board/ultima/board.c | 90 | ||||
-rw-r--r-- | board/ultima/board.h | 34 | ||||
-rw-r--r-- | board/wizpig/board.c | 119 | ||||
-rw-r--r-- | board/wizpig/board.h | 10 | ||||
-rw-r--r-- | board/wizpig/ec.tasklist | 1 |
10 files changed, 253 insertions, 333 deletions
diff --git a/board/cyan/board.c b/board/cyan/board.c index 8eae0ae633..ebe9c92e07 100644 --- a/board/cyan/board.c +++ b/board/cyan/board.c @@ -8,7 +8,6 @@ #include "charger.h" #include "charge_state.h" #include "driver/accel_kionix.h" -#include "driver/accel_kxcj9.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" diff --git a/board/setzer/board.c b/board/setzer/board.c index 0e0e93c9e4..8d14fe1c56 100644 --- a/board/setzer/board.c +++ b/board/setzer/board.c @@ -9,7 +9,7 @@ #include "button.h" #include "charger.h" #include "charge_state.h" -#include "driver/accel_kxcj9.h" +#include "driver/accel_kionix.h" #include "driver/als_isl29035.h" #include "driver/gyro_l3gd20h.h" #include "driver/temp_sensor/tmp432.h" @@ -122,14 +122,7 @@ BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); /* Four Motion sensors */ /* kxcj9 mutex and local/private data*/ static struct mutex g_kxcj9_mutex[2]; -struct kxcj9_data g_kxcj9_data[2]; - -#ifdef CONFIG_GYRO_L3GD20H -/* Gyro sensor */ -/* l3gd20h mutex and local/private data*/ -static struct mutex g_l3gd20h_mutex; -struct l3gd20_data g_l3gd20h_data; -#endif +struct kionix_accel_data g_kxcj9_data[2]; /* Matrix to rotate accelrator into standard reference frame */ const matrix_3x3_t base_standard_ref = { @@ -145,97 +138,81 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, + [BASE_ACCEL] = { + .name = "Base", + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[0], .drv_data = &g_kxcj9_data[0], - .i2c_addr = KXCJ9_ADDR1, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, .rot_standard_ref = &base_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, } }, - {.name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, + [LID_ACCEL] = { + .name = "Lid", + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[1], .drv_data = &g_kxcj9_data[1], - .i2c_addr = KXCJ9_ADDR0, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR0, .rot_standard_ref = &lid_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } - }, -#ifdef CONFIG_GYRO_L3GD20H - {.name = "Lid Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_L3GD20H, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_LID, - .drv = &l3gd20h_drv, - .mutex = &g_l3gd20h_mutex, - .drv_data = &g_l3gd20h_data, - .i2c_addr = L3GD20_ADDR1, - .rot_standard_ref = NULL, - .default_config = { - .odr = 190000, - .range = 2000, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, }, -#endif }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); -/* Define the accelerometer orientation matrices. */ -const struct accel_orientation acc_orient = { - /* Hinge aligns with x axis. */ - .rot_hinge_90 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)}, - { 0, FLOAT_TO_FP(-1), 0} - }, - .rot_hinge_180 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} - }, - .hinge_axis = {1, 0, 0}, -}; - -/* - * In S3, power rail for sensors (+V3p3S) goes down asynchronous to EC. We need - * to execute this routine first and set the sensor state to "Not Initialized". - * This prevents the motion_sense_suspend hook routine from communicating with - * the sensor. - */ -static void motion_sensors_pre_init(void) -{ - struct motion_sensor_t *sensor; - int i; - - for (i = 0; i < motion_sensor_count; ++i) { - sensor = &motion_sensors[i]; - sensor->state = SENSOR_NOT_INITIALIZED; - - sensor->runtime_config.odr = sensor->default_config.odr; - sensor->runtime_config.range = sensor->default_config.range; - } -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, motion_sensors_pre_init, - MOTION_SENSE_HOOK_PRIO - 1); - /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/setzer/board.h b/board/setzer/board.h index a17d2805d8..30c14dea50 100644 --- a/board/setzer/board.h +++ b/board/setzer/board.h @@ -8,6 +8,15 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* + * By default, enable all console messages excepted HC, ACPI and event: + * The sensor stack is generating a lot of activity. + */ +#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC))) +/* By default, set hcdebug to off */ +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + /* Optional features */ #define CONFIG_WATCHDOG_HELP #define CONFIG_CLOCK_CRYSTAL @@ -71,8 +80,10 @@ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 + +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO 512 +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) /* Wireless signals */ #define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L @@ -108,6 +119,22 @@ enum adc_channel { ADC_CH_COUNT }; +/* Sensor index definition */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL = 1, +}; + +/* + * We have not enabled the sensor FIFO on the accels, so we force the EC + * to collect at every sample. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << BASE_ACCEL) | (1 << LID_ACCEL)) + +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + /* power signal definitions */ enum power_signal { X86_ALL_SYS_PWRGD = 0, diff --git a/board/strago/board.c b/board/strago/board.c index b0e61f89c8..c749d809ac 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -9,7 +9,7 @@ #include "button.h" #include "charger.h" #include "charge_state.h" -#include "driver/accel_kxcj9.h" +#include "driver/accel_kionix.h" #include "driver/als_isl29035.h" #include "driver/gyro_l3gd20h.h" #include "driver/temp_sensor/tmp432.h" @@ -122,14 +122,7 @@ BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); /* Four Motion sensors */ /* kxcj9 mutex and local/private data*/ static struct mutex g_kxcj9_mutex[2]; -struct kxcj9_data g_kxcj9_data[2]; - -#ifdef CONFIG_GYRO_L3GD20H -/* Gyro sensor */ -/* l3gd20h mutex and local/private data*/ -static struct mutex g_l3gd20h_mutex; -struct l3gd20_data g_l3gd20h_data; -#endif +struct kionix_accel_data g_kxcj9_data[2]; /* Matrix to rotate accelrator into standard reference frame */ const matrix_3x3_t base_standard_ref = { @@ -145,97 +138,81 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[0], .drv_data = &g_kxcj9_data[0], - .i2c_addr = KXCJ9_ADDR1, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, .rot_standard_ref = &base_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, } }, - {.name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[1], .drv_data = &g_kxcj9_data[1], - .i2c_addr = KXCJ9_ADDR0, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR0, .rot_standard_ref = &lid_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } - }, -#ifdef CONFIG_GYRO_L3GD20H - {.name = "Lid Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_L3GD20H, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_LID, - .drv = &l3gd20h_drv, - .mutex = &g_l3gd20h_mutex, - .drv_data = &g_l3gd20h_data, - .i2c_addr = L3GD20_ADDR1, - .rot_standard_ref = NULL, - .default_config = { - .odr = 190000, - .range = 2000, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, }, -#endif }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); -/* Define the accelerometer orientation matrices. */ -const struct accel_orientation acc_orient = { - /* Hinge aligns with x axis. */ - .rot_hinge_90 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)}, - { 0, FLOAT_TO_FP(-1), 0} - }, - .rot_hinge_180 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} - }, - .hinge_axis = {1, 0, 0}, -}; - -/* - * In S3, power rail for sensors (+V3p3S) goes down asynchronous to EC. We need - * to execute this routine first and set the sensor state to "Not Initialized". - * This prevents the motion_sense_suspend hook routine from communicating with - * the sensor. - */ -static void motion_sensors_pre_init(void) -{ - struct motion_sensor_t *sensor; - int i; - - for (i = 0; i < motion_sensor_count; ++i) { - sensor = &motion_sensors[i]; - sensor->state = SENSOR_NOT_INITIALIZED; - - sensor->runtime_config.odr = sensor->default_config.odr; - sensor->runtime_config.range = sensor->default_config.range; - } -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, motion_sensors_pre_init, - MOTION_SENSE_HOOK_PRIO - 1); - /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/strago/board.h b/board/strago/board.h index cf0a02b29c..29214bec14 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -71,8 +71,6 @@ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 /* Wireless signals */ #define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L @@ -108,6 +106,22 @@ enum adc_channel { ADC_CH_COUNT }; +/* Sensor index definition */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL = 1, +}; + +/* + * We have not enabled the sensor FIFO on the accels, so we force the EC + * to collect at every sample. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << BASE_ACCEL) | (1 << LID_ACCEL)) + +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + /* power signal definitions */ enum power_signal { X86_ALL_SYS_PWRGD = 0, diff --git a/board/ultima/board.c b/board/ultima/board.c index e7f78cc1f2..e2731faf54 100644 --- a/board/ultima/board.c +++ b/board/ultima/board.c @@ -8,7 +8,7 @@ #include "button.h" #include "charger.h" #include "charge_state.h" -#include "driver/accel_kxcj9.h" +#include "driver/accel_kionix.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" @@ -112,7 +112,7 @@ BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); /* Four Motion sensors */ /* kxcj9 mutex and local/private data*/ static struct mutex g_kxcj9_mutex[2]; -struct kxcj9_data g_kxcj9_data[2]; +struct kionix_accel_data g_kxcj9_data[2]; /* Matrix to rotate accelrator into standard reference frame */ const matrix_3x3_t base_standard_ref = { @@ -128,57 +128,81 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", + [BASE_ACCEL] = { + .name = "Base", .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_BASE, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[0], .drv_data = &g_kxcj9_data[0], - .i2c_addr = KXCJ9_ADDR1, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, .rot_standard_ref = &base_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, } }, - {.name = "Lid Accel", + [LID_ACCEL] = { + .name = "Lid", .active_mask = SENSOR_ACTIVE_S0_S3, .chip = MOTIONSENSE_CHIP_KXCJ9, .type = MOTIONSENSE_TYPE_ACCEL, .location = MOTIONSENSE_LOC_LID, - .drv = &kxcj9_drv, + .drv = &kionix_accel_drv, .mutex = &g_kxcj9_mutex[1], .drv_data = &g_kxcj9_data[1], - .i2c_addr = KXCJ9_ADDR0, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR0, .rot_standard_ref = &lid_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); -/* Define the accelerometer orientation matrices. */ -const struct accel_orientation acc_orient = { - /* Hinge aligns with x axis. */ - .rot_hinge_90 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)}, - { 0, FLOAT_TO_FP(-1), 0} - }, - .rot_hinge_180 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} - }, - .hinge_axis = {1, 0, 0}, -}; - /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/ultima/board.h b/board/ultima/board.h index 0a3ea76e43..01c0f9b360 100644 --- a/board/ultima/board.h +++ b/board/ultima/board.h @@ -8,6 +8,15 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* + * By default, enable all console messages excepted HC, ACPI and event: + * The sensor stack is generating a lot of activity. + */ +#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC))) +/* By default, set hcdebug to off */ +#undef CONFIG_HOSTCMD_DEBUG_MODE +#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF + /* Optional features */ #define CONFIG_WATCHDOG_HELP #define CONFIG_CLOCK_CRYSTAL @@ -26,6 +35,8 @@ #define CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_LOW_POWER_PSEUDO_G3 +#define CONFIG_MKBP_EVENT +#define CONFIG_MKBP_USE_HOST_EVENT #define CONFIG_POWER_COMMON #define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 #define CONFIG_EXTPOWER_GPIO @@ -70,9 +81,12 @@ #define CONFIG_ACCEL_KXCJ9 #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO + +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO 512 +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) + #define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 #define CONFIG_LID_ANGLE_UPDATE /* Wireless signals */ @@ -113,6 +127,22 @@ enum adc_channel { ADC_CH_COUNT }; +/* Sensor index definition */ +enum sensor_id { + BASE_ACCEL = 0, + LID_ACCEL = 1, +}; + +/* + * We have not enabled the sensor FIFO on the accels, so we force the EC + * to collect at every sample. + */ +#define CONFIG_ACCEL_FORCE_MODE_MASK \ + ((1 << BASE_ACCEL) | (1 << LID_ACCEL)) + +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + /* power signal definitions */ enum power_signal { X86_ALL_SYS_PWRGD = 0, diff --git a/board/wizpig/board.c b/board/wizpig/board.c index 532b582ce8..83207468f9 100644 --- a/board/wizpig/board.c +++ b/board/wizpig/board.c @@ -9,7 +9,7 @@ #include "button.h" #include "charger.h" #include "charge_state.h" -#include "driver/accel_kxcj9.h" +#include "driver/accel_kionix.h" #include "driver/gyro_l3gd20h.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" @@ -112,123 +112,6 @@ const struct button_config buttons[] = { }; BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT); -/* Four Motion sensors */ -/* kxcj9 mutex and local/private data*/ -static struct mutex g_kxcj9_mutex[2]; -struct kxcj9_data g_kxcj9_data[2]; - -#ifdef CONFIG_GYRO_L3GD20H -/* Gyro sensor */ -/* l3gd20h mutex and local/private data*/ -static struct mutex g_l3gd20h_mutex; -struct l3gd20_data g_l3gd20h_data; -#endif - -/* Matrix to rotate accelrator into standard reference frame */ -const matrix_3x3_t base_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - {FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; - -const matrix_3x3_t lid_standard_ref = { - {FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(1), 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; - -struct motion_sensor_t motion_sensors[] = { - {.name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KXCJ9, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &kxcj9_drv, - .mutex = &g_kxcj9_mutex[0], - .drv_data = &g_kxcj9_data[0], - .i2c_addr = KXCJ9_ADDR1, - .rot_standard_ref = &base_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } - }, - {.name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KXCJ9, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kxcj9_drv, - .mutex = &g_kxcj9_mutex[1], - .drv_data = &g_kxcj9_data[1], - .i2c_addr = KXCJ9_ADDR0, - .rot_standard_ref = &lid_standard_ref, - .default_config = { - .odr = 100000, - .range = 2, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } - }, -#ifdef CONFIG_GYRO_L3GD20H - {.name = "Lid Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_L3GD20H, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_LID, - .drv = &l3gd20h_drv, - .mutex = &g_l3gd20h_mutex, - .drv_data = &g_l3gd20h_data, - .i2c_addr = L3GD20_ADDR1, - .rot_standard_ref = NULL, - .default_config = { - .odr = 190000, - .range = 2000, - .ec_rate = SUSPEND_SAMPLING_INTERVAL, - } - }, -#endif -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -/* Define the accelerometer orientation matrices. */ -const struct accel_orientation acc_orient = { - /* Hinge aligns with x axis. */ - .rot_hinge_90 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)}, - { 0, FLOAT_TO_FP(-1), 0} - }, - .rot_hinge_180 = { - { FLOAT_TO_FP(1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} - }, - .hinge_axis = {1, 0, 0}, -}; - -/* - * In S3, power rail for sensors (+V3p3S) goes down asynchronous to EC. We need - * to execute this routine first and set the sensor state to "Not Initialized". - * This prevents the motion_sense_suspend hook routine from communicating with - * the sensor. - */ -static void motion_sensors_pre_init(void) -{ - struct motion_sensor_t *sensor; - int i; - - for (i = 0; i < motion_sensor_count; ++i) { - sensor = &motion_sensors[i]; - sensor->state = SENSOR_NOT_INITIALIZED; - - sensor->runtime_config.odr = sensor->default_config.odr; - sensor->runtime_config.range = sensor->default_config.range; - } -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, motion_sensors_pre_init, - MOTION_SENSE_HOOK_PRIO - 1); - /* init ADC ports to avoid floating state due to thermistors */ static void adc_pre_init(void) { diff --git a/board/wizpig/board.h b/board/wizpig/board.h index a337eb4553..c1f4edc5ae 100644 --- a/board/wizpig/board.h +++ b/board/wizpig/board.h @@ -64,14 +64,6 @@ #define CONFIG_I2C -/* Accelerometer */ -#define CONFIG_ACCEL_KXCJ9 -#define CONFIG_CMD_ACCELS -#define CONFIG_CMD_ACCEL_INFO -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE 0 -#define CONFIG_LID_ANGLE_SENSOR_LID 1 - /* Wireless signals */ #define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L @@ -95,8 +87,6 @@ #define I2C_PORT_CHARGER MEC1322_I2C0_0 #define I2C_PORT_PD_MCU MEC1322_I2C1 #define I2C_PORT_TCPC MEC1322_I2C1 -#define I2C_PORT_ACCEL MEC1322_I2C2 -#define I2C_PORT_GYRO MEC1322_I2C2 #define I2C_PORT_THERMAL MEC1322_I2C3 /* ADC signal */ diff --git a/board/wizpig/ec.tasklist b/board/wizpig/ec.tasklist index 3261d956d6..33240cdf02 100644 --- a/board/wizpig/ec.tasklist +++ b/board/wizpig/ec.tasklist @@ -19,7 +19,6 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ |