diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2018-11-30 17:06:39 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-02 17:47:22 +0000 |
commit | d784719619aeee67ae50ff1f3c8844902f2eb30a (patch) | |
tree | 911b10b08fd2a4668ed413db4a8ad440ee0ae19f /board | |
parent | e58e2fc0a457b3929b04a94e52783453953978c8 (diff) | |
download | chrome-ec-d784719619aeee67ae50ff1f3c8844902f2eb30a.tar.gz |
driver: lsm6dsm: Integrate LIS2MDL behind LSM6DSM
- Cros set_rate and normalize between LIS2MDL and LSM6DSM
- Remove unused sensor hub function.
- Remove parent field, use macro instead (magnetometer is just after the
gyroscope).
BUG=b:110143516,b:115587004
BRANCH=none
TEST=On meep, check the magnetometer is returning data with shell/python
script.
Check calibration quick in.
Check with AIDA64, compass and sensor app the magnetometer is seen.
Change-Id: I2efef99eda095e33b6a0555b1cbc4ac8fdbfab5d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/1361992
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Trybot-Ready: Justin TerAvest <teravest@chromium.org>
Tested-by: Justin TerAvest <teravest@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719525
Reviewed-by: Edward Hill <ecgh@chromium.org>
Tested-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/fleex/board.c | 85 | ||||
-rw-r--r-- | board/meep/board.c | 142 | ||||
-rw-r--r-- | board/meep/board.h | 10 | ||||
-rw-r--r-- | board/phaser/board.c | 82 | ||||
-rw-r--r-- | board/yorp/board.c | 85 |
5 files changed, 218 insertions, 186 deletions
diff --git a/board/fleex/board.c b/board/fleex/board.c index af6dda79bc..095724d7e9 100644 --- a/board/fleex/board.c +++ b/board/fleex/board.c @@ -138,8 +138,7 @@ const mat33_fp_t lid_standard_ref = { /* sensor private data */ static struct stprivate_data g_lis2dh_data; -static struct lsm6dsm_data lsm6dsm_g_data; -static struct lsm6dsm_data lsm6dsm_a_data; +static struct lsm6dsm_data lsm6dsm_data; static uint16_t sku_id; /* Drivers */ @@ -173,49 +172,51 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_a_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* Sensor on for angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .rot_standard_ref = &base_standard_ref, + .default_range = 4, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_g_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, }, }; diff --git a/board/meep/board.c b/board/meep/board.c index b85a3fbe43..1d27b0ed8a 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -138,29 +138,33 @@ const mat33_fp_t base_standard_ref = { }; /* sensor private data */ -static struct kionix_accel_data g_kx022_data; -static struct lsm6dsm_data lsm6dsm_g_data; -static struct lsm6dsm_data lsm6dsm_a_data; +static struct kionix_accel_data kx022_data; +static struct lsm6dsm_data lsm6dsm_data; /* Drivers */ struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .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_SENSOR, - .addr = KX022_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 4, /* g */ - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &kx022_data, + .port = I2C_PORT_SENSOR, + .addr = KX022_ADDR1, + .rot_standard_ref = &lid_standrd_ref, + .default_range = 2, /* g */ + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + /* Sensor on for lid angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, }, /* Sensor on for lid angle detection */ [SENSOR_CONFIG_EC_S3] = { @@ -170,50 +174,70 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_a_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* Sensor on for angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .rot_standard_ref = &base_standard_ref, + .default_range = 2, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_g_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, }, + + [BASE_MAG] = { + .name = "Base Mag", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LIS2MDL, + .type = MOTIONSENSE_TYPE_MAG, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lis2mdl_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, MOTIONSENSE_TYPE_MAG), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 1 << 11, /* 16LSB / uT, fixed */ + .rot_standard_ref = &mag_standard_ref, + .min_frequency = LIS2MDL_ODR_MIN_VAL, + .max_frequency = LIS2MDL_ODR_MAX_VAL, + }, + }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); diff --git a/board/meep/board.h b/board/meep/board.h index 4bfbed998e..310caab438 100644 --- a/board/meep/board.h +++ b/board/meep/board.h @@ -34,12 +34,16 @@ /* TODO(b/111842131): confirm lid accelerometer matches yorp */ #define CONFIG_ACCEL_KX022 /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ +#define CONFIG_MAG_LSM6DSM_LIS2MDL /* Magnetometer behind base accel */ +#define CONFIG_ACCELGYRO_SEC_ADDR LIS2MDL_ADDR0 +#define CONFIG_SENSORHUB_LSM6DSM +#define CONFIG_MAG_CALIBRATE +#define CONFIG_FPU + /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) -/* USB PD */ -#undef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT -#define CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE diff --git a/board/phaser/board.c b/board/phaser/board.c index c889f45301..5913b0439f 100644 --- a/board/phaser/board.c +++ b/board/phaser/board.c @@ -120,8 +120,7 @@ const mat33_fp_t standard_rot_ref = { /* sensor private data */ static struct stprivate_data g_lis2dh_data; -static struct lsm6dsm_data lsm6dsm_g_data; -static struct lsm6dsm_data lsm6dsm_a_data; +static struct lsm6dsm_data lsm6dsm_data; /* Drivers */ struct motion_sensor_t motion_sensors[] = { @@ -154,49 +153,52 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_a_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = &standard_rot_ref, - .default_range = 4, /* g */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* Sensor on for angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .rot_standard_ref = &standard_rot_ref, + .default_range = 4, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, }, }, }, [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_g_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &standard_rot_ref, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = &standard_rot_ref, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, }, }; diff --git a/board/yorp/board.c b/board/yorp/board.c index 5a4b415ffa..15b33196e6 100644 --- a/board/yorp/board.c +++ b/board/yorp/board.c @@ -117,8 +117,7 @@ const mat33_fp_t base_standard_ref = { /* sensor private data */ static struct kionix_accel_data g_kx022_data; -static struct lsm6dsm_data lsm6dsm_g_data; -static struct lsm6dsm_data lsm6dsm_a_data; +static struct lsm6dsm_data lsm6dsm_data; /* Drivers */ struct motion_sensor_t motion_sensors[] = { @@ -148,49 +147,51 @@ struct motion_sensor_t motion_sensors[] = { }, [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_a_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - /* Sensor on for angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .rot_standard_ref = &base_standard_ref, + .default_range = 4, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor on for angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, }, [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_g_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .addr = LSM6DSM_ADDR0, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, }, }; |