diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-05-12 07:45:33 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-12 23:35:51 +0000 |
commit | a9a9ae1abc4ddb6a89ee0d29b88fbdd1d2ef67b1 (patch) | |
tree | 26b9855187a83412b181009031878826faab8b97 /board | |
parent | 39bd18b890bb708e79e9ba50dd3b5bf3d35e9ff1 (diff) | |
download | chrome-ec-a9a9ae1abc4ddb6a89ee0d29b88fbdd1d2ef67b1.tar.gz |
driver: Use common data structure to store default accel values
Move structure used by lms6ds0 to motion_sense.h,
so that bosh driver can use the same mechanism.
Use code to avoid reading chip range when reading data.
BUG=none
BRANCH=none
TEST=Check Bosh driver is working as expected.
Change-Id: Id8b5bb8735e479a122ef32ab9a400fba189d7488
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270453
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/cyan/board.c | 42 | ||||
-rw-r--r-- | board/ryu_sh/board.c | 22 | ||||
-rw-r--r-- | board/samus/board.c | 24 | ||||
-rw-r--r-- | board/strago/board.c | 42 |
4 files changed, 92 insertions, 38 deletions
diff --git a/board/cyan/board.c b/board/cyan/board.c index 1118e4d5a8..90ffc7333a 100644 --- a/board/cyan/board.c +++ b/board/cyan/board.c @@ -109,14 +109,36 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {SENSOR_ACTIVE_S0, "Base", MOTIONSENSE_CHIP_KXCJ9, - MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_BASE, - &kxcj9_drv, &g_kxcj9_mutex[0], &g_kxcj9_data[0], - KXCJ9_ADDR1, &base_standard_ref, 100000, 2}, - {SENSOR_ACTIVE_S0, "Lid", MOTIONSENSE_CHIP_KXCJ9, - MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_LID, - &kxcj9_drv, &g_kxcj9_mutex[1], &g_kxcj9_data[1], - KXCJ9_ADDR0, &lid_standard_ref, 100000, 2}, + {.name = "Base", + .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 + } + }, + {.name = "Lid", + .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 + } + }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); @@ -151,8 +173,8 @@ static void motion_sensors_pre_init(void) sensor = &motion_sensors[i]; sensor->state = SENSOR_NOT_INITIALIZED; - sensor->odr = sensor->default_odr; - sensor->range = sensor->default_range; + 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, diff --git a/board/ryu_sh/board.c b/board/ryu_sh/board.c index 4e2f68f18a..dd2bb1fed6 100644 --- a/board/ryu_sh/board.c +++ b/board/ryu_sh/board.c @@ -37,8 +37,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* Sensor mutex */ static struct mutex g_mutex; -/* lsm6ds0 local sensor data (per-sensor) */ -struct lsm6ds0_data g_lsm6ds0_data[2]; +/* local sensor data (per-sensor) */ +struct motion_data_t g_saved_data[2]; struct motion_sensor_t motion_sensors[] = { @@ -54,11 +54,13 @@ struct motion_sensor_t motion_sensors[] = { .location = MOTIONSENSE_LOC_LID, .drv = &lsm6ds0_drv, .mutex = &g_mutex, - .drv_data = &g_lsm6ds0_data[0], + .drv_data = &g_saved_data[0], .i2c_addr = LSM6DS0_ADDR1, .rot_standard_ref = NULL, - .default_odr = 119000, - .default_range = 2 + .default_config = { + .odr = 119000, + .range = 2 + } }, {.name = "Gyro", @@ -68,11 +70,13 @@ struct motion_sensor_t motion_sensors[] = { .location = MOTIONSENSE_LOC_LID, .drv = &lsm6ds0_drv, .mutex = &g_mutex, - .drv_data = &g_lsm6ds0_data[1], + .drv_data = &g_saved_data[1], .i2c_addr = LSM6DS0_ADDR1, .rot_standard_ref = NULL, - .default_odr = 119000, - .default_range = 2000 + .default_config = { + .odr = 119000, + .range = 2000 + } }, }; @@ -82,7 +86,7 @@ const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); * Note: If a new sensor driver is added, make sure to update the following * assert. */ -BUILD_ASSERT(ARRAY_SIZE(motion_sensors) == ARRAY_SIZE(g_lsm6ds0_data)); +BUILD_ASSERT(ARRAY_SIZE(motion_sensors) == ARRAY_SIZE(g_saved_data)); void board_config_pre_init(void) { diff --git a/board/samus/board.c b/board/samus/board.c index 1222528959..909ba7eca3 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -262,7 +262,7 @@ static struct mutex g_lid_mutex; struct kxcj9_data g_kxcj9_data; /* lsm6ds0 local sensor data (per-sensor) */ -struct lsm6ds0_data g_lsm6ds0_data[2]; +struct motion_data_t g_saved_data[2]; /* Four Motion sensors */ /* Matrix to rotate accelrator into standard reference frame */ @@ -291,11 +291,13 @@ struct motion_sensor_t motion_sensors[] = { .location = MOTIONSENSE_LOC_BASE, .drv = &lsm6ds0_drv, .mutex = &g_base_mutex, - .drv_data = &g_lsm6ds0_data[0], + .drv_data = &g_saved_data[0], .i2c_addr = LSM6DS0_ADDR1, .rot_standard_ref = &base_standard_ref, - .default_odr = 119000, - .default_range = 2 + .default_config = { + .odr = 119000, + .range = 2 + } }, {.name = "Lid", @@ -308,8 +310,10 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_kxcj9_data, .i2c_addr = KXCJ9_ADDR0, .rot_standard_ref = &lid_standard_ref, - .default_odr = 100000, - .default_range = 2 + .default_config = { + .odr = 100000, + .range = 2 + } }, {.name = "Base Gyro", @@ -319,11 +323,13 @@ struct motion_sensor_t motion_sensors[] = { .location = MOTIONSENSE_LOC_BASE, .drv = &lsm6ds0_drv, .mutex = &g_base_mutex, - .drv_data = &g_lsm6ds0_data[1], + .drv_data = &g_saved_data[1], .i2c_addr = LSM6DS0_ADDR1, .rot_standard_ref = NULL, - .default_odr = 119000, - .default_range = 2000 + .default_config = { + .odr = 119000, + .range = 2000 + } }, }; diff --git a/board/strago/board.c b/board/strago/board.c index 2ed9b9c426..a18dd7ed78 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -123,14 +123,36 @@ const matrix_3x3_t lid_standard_ref = { }; struct motion_sensor_t motion_sensors[] = { - {SENSOR_ACTIVE_S0, "Base Accel", MOTIONSENSE_CHIP_KXCJ9, - MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_BASE, - &kxcj9_drv, &g_kxcj9_mutex[0], &g_kxcj9_data[0], - KXCJ9_ADDR1, &base_standard_ref, 100000, 2}, - {SENSOR_ACTIVE_S0, "Lid Accel", MOTIONSENSE_CHIP_KXCJ9, - MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_LID, - &kxcj9_drv, &g_kxcj9_mutex[1], &g_kxcj9_data[1], - KXCJ9_ADDR0, &lid_standard_ref, 100000, 2}, + {.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 + } + }, + {.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 + } + }, }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); @@ -165,8 +187,8 @@ static void motion_sensors_pre_init(void) sensor = &motion_sensors[i]; sensor->state = SENSOR_NOT_INITIALIZED; - sensor->odr = sensor->default_odr; - sensor->range = sensor->default_range; + 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, |