From 0ef87a741c2be6f5688ea1bea618085a3907cf5c Mon Sep 17 00:00:00 2001 From: Bruce Date: Fri, 21 Oct 2016 14:50:37 +0800 Subject: [PATCH] Pyro: Fix sensors order for devices with BM160 and LPC mode. When the kernel reads sensor data via LPC, it expects the order to be: - ACCEL - ACCEL - GYRO (other sensors data are read through EC commands) BMI160 expects ACCEL, GYRO and MAG to be next to each other. Reorganize motion_sensor array to fit these 2 requirements: If BMI160 in the lid: - BASE_ACCEL - LID_ACCEL - LID_GYRO ... If BMI160 in the base: - LID_ACCEL - BASE_ACCEL - BASE_GRYO ... BUG=none BRANCH=none TEST=make buildall Change-Id: If89cf29d28b70e9a46dde8a3301a1942b3a1dd8b Signed-off-by: Bruce.Wan Reviewed-on: https://chromium-review.googlesource.com/401206 Commit-Ready: Keith Tzeng Tested-by: Keith Tzeng Reviewed-by: Gwendal Grignou Reviewed-by: Aaron Durbin --- board/pyro/board.c | 77 ++++++++++++++++++++++------------------------ board/pyro/board.h | 11 +++++-- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/board/pyro/board.c b/board/pyro/board.c index 54cf7f0554..8ad3dc67af 100644 --- a/board/pyro/board.c +++ b/board/pyro/board.c @@ -721,11 +721,42 @@ struct kionix_accel_data g_kx022_data; /* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Pyro */ struct motion_sensor_t motion_sensors[] = { - /* - * Note: bmi160: supports accelerometer and gyro sensor - * Requirement: accelerometer sensor must init before gyro sensor - * DO NOT change the order of the following table. - */ + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_LID_ACCEL, + .addr = KX022_ADDR1, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [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 = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + [BASE_ACCEL] = { .name = "Base Accel", .active_mask = SENSOR_ACTIVE_S0, @@ -837,42 +868,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kionix_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_LID_ACCEL, - .addr = KX022_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [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 = 100 * MSEC, - }, - /* unused */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 0, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, - [BASE_BARO] = { .name = "Base Baro", .active_mask = SENSOR_ACTIVE_S0, diff --git a/board/pyro/board.h b/board/pyro/board.h index 043b990358..4908317a94 100644 --- a/board/pyro/board.h +++ b/board/pyro/board.h @@ -243,12 +243,17 @@ enum als_id { ALS_COUNT }; -/* Motion sensors */ +/* + * Motion sensors: + * When reading through IO memory is set up for sensors (LPC is used), + * the first 2 entries must be accelerometers, then gyroscope. + * For BMI160, accel, gyro and compass sensors must be next to each other. + */ enum sensor_id { - BASE_ACCEL = 0, + LID_ACCEL = 0, + BASE_ACCEL, BASE_GYRO, BASE_MAG, - LID_ACCEL, BASE_BARO, };