diff options
Diffstat (limited to 'zephyr/shim/src/motionsense_driver')
14 files changed, 104 insertions, 46 deletions
diff --git a/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc index 7db46811ad..a16c4f0fbc 100644 --- a/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc index 2d40c55de7..3d02e5db70 100644 --- a/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc index dd7b21641b..36d20db7be 100644 --- a/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc index 2457fca31a..72bfc5b4b3 100644 --- a/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/bmi3xx-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi3xx-drvinfo.inc index ce6f686cc2..c28f5c1786 100644 --- a/zephyr/shim/src/motionsense_driver/bmi3xx-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/bmi3xx-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h b/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h index 069587f90f..ab2f08a496 100644 --- a/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h +++ b/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -23,28 +23,27 @@ * cover-scale = <1>; * }; */ -#define ACCELGYRO_ALS_CHANNEL_SCALE(id) \ - { \ - .k_channel_scale = \ - ALS_CHANNEL_SCALE(DT_PROP(id, k_channel_scale)),\ - .cover_scale = \ - ALS_CHANNEL_SCALE(DT_PROP(id, cover_scale)), \ +#define ACCELGYRO_ALS_CHANNEL_SCALE(id) \ + { \ + .k_channel_scale = \ + ALS_CHANNEL_SCALE(DT_PROP(id, k_channel_scale)), \ + .cover_scale = ALS_CHANNEL_SCALE(DT_PROP(id, cover_scale)), \ } -#define ALS_CALIBRATION_CHANNEL_SCALE(id) \ +#define ALS_CALIBRATION_CHANNEL_SCALE(id) \ .als_cal.channel_scale = ACCELGYRO_ALS_CHANNEL_SCALE(id), -#define ALS_CALIBRATION_SET(id) \ - .als_cal.scale = DT_PROP(id, scale), \ - .als_cal.uscale = DT_PROP(id, uscale), \ - .als_cal.offset = DT_PROP(id, offset), \ +#define ALS_CALIBRATION_SET(id) \ + .als_cal.scale = DT_PROP(id, scale), \ + .als_cal.uscale = DT_PROP(id, uscale), \ + .als_cal.offset = DT_PROP(id, offset), \ ALS_CALIBRATION_CHANNEL_SCALE(DT_CHILD(id, als_channel_scale)) /* * compatible = "cros-ec,accelgyro-als-drv-data" * als_drv_data_t in accelgyro.h * - * e.g) The following is the example in DT for als_drv_data_t + * e.g) The following is the example in DT for als_drv_data_t * als-drv-data { * compatible = "cros-ec,accelgyro-als-drv-data"; * als-cal { @@ -59,22 +58,21 @@ * }; * }; */ -#define ACCELGYRO_ALS_DRV_DATA(id) \ - { \ - ALS_CALIBRATION_SET(DT_CHILD(id, als_cal)) \ +#define ACCELGYRO_ALS_DRV_DATA(id) \ + { \ + ALS_CALIBRATION_SET(DT_CHILD(id, als_cal)) \ } -#define RGB_CAL_RGB_SET_SCALE(id) \ - .scale = ACCELGYRO_ALS_CHANNEL_SCALE(id), +#define RGB_CAL_RGB_SET_SCALE(id) .scale = ACCELGYRO_ALS_CHANNEL_SCALE(id), -#define RGB_CAL_RGB_SET_ONE(id, suffix) \ - .rgb_cal[suffix] = { \ - .offset = DT_PROP(id, offset), \ - .coeff[0] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 0)), \ - .coeff[1] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 1)), \ - .coeff[2] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 2)), \ - .coeff[3] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 3)), \ - RGB_CAL_RGB_SET_SCALE(DT_CHILD(id, als_channel_scale)) \ +#define RGB_CAL_RGB_SET_ONE(id, suffix) \ + .rgb_cal[suffix] = { \ + .offset = DT_PROP(id, offset), \ + .coeff[0] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 0)), \ + .coeff[1] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 1)), \ + .coeff[2] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 2)), \ + .coeff[3] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 3)), \ + RGB_CAL_RGB_SET_SCALE(DT_CHILD(id, als_channel_scale)) \ }, /* @@ -116,12 +114,12 @@ * }; * }; */ -#define ACCELGYRO_RGB_CALIBRATION(id) \ - { \ - RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_x), X) \ - RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_y), Y) \ - RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_z), Z) \ - .irt = INT_TO_FP(DT_PROP(id, irt)), \ +#define ACCELGYRO_RGB_CALIBRATION(id) \ + { \ + RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_x), X) \ + RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_y), Y) \ + RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_z), Z).irt = \ + INT_TO_FP(DT_PROP(id, irt)), \ } #endif /* __ZEPHYR_SHIM_SRC_MOTIONSENSE_DRIVER_DRVDATA_ACCELGYRO_H */ diff --git a/zephyr/shim/src/motionsense_driver/icm42607-drvinfo.inc b/zephyr/shim/src/motionsense_driver/icm42607-drvinfo.inc index e8199eaacf..ede16342ea 100644 --- a/zephyr/shim/src/motionsense_driver/icm42607-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/icm42607-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/icm426xx-drvinfo.inc b/zephyr/shim/src/motionsense_driver/icm426xx-drvinfo.inc index 5513ff934c..d949829750 100644 --- a/zephyr/shim/src/motionsense_driver/icm426xx-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/icm426xx-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc index 800a9a1543..26885230e1 100644 --- a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc b/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc index 433a9d4192..4605fcd749 100644 --- a/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/motionsense_driver/lsm6dsm-drvinfo.inc b/zephyr/shim/src/motionsense_driver/lsm6dsm-drvinfo.inc new file mode 100644 index 0000000000..32faaa087f --- /dev/null +++ b/zephyr/shim/src/motionsense_driver/lsm6dsm-drvinfo.inc @@ -0,0 +1,57 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "driver/accelgyro_lsm6dsm.h" +#include "driver/stm_mems_common.h" + +/* + * CREATE_SENSOR_DATA which is defined in motionsense_sensors.c is + * the helper to create sensor driver specific data. + * + * CREATE_SENSOR_DATA gets two arguments. One is the compatible + * property value specified in device tree and the other one is the macro + * that actually creates sensor driver specific data. The macro gets + * node id and the name to be used for the sensor driver data. + */ + +/* + * Create driver data. This must be a separate instance for + * each entry of the lsm6dsm device in the motion_sensors array. + */ +#define CREATE_SENSOR_DATA_LSM6DSM(id, drvdata_name) \ + static struct lsm6dsm_data drvdata_name = LSM6DSM_DATA; + +/* + * Create driver data for each lsm6dsm drvinfo instance in device tree. + * (compatible = "cros-ec,drvdata-lsm6dsm") + */ +CREATE_SENSOR_DATA(cros_ec_drvdata_lsm6dsm, CREATE_SENSOR_DATA_LSM6DSM) +/* + * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is + * the macro to create an entry in motion_sensors array. + * The macro gets value of compatible property of + * the sensor in device tree and sensor specific values like chip ID, + * type of sensor, name of driver, default min/max frequency. + * Then using the values, it creates the corresponding motion_sense_t entry + * in motion_sensors array. + */ + +/* + * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry + * for each lsm6dsm accel instance(compatible = "cros-ec,lsm6dsm-accel") + * in device tree. + */ +CREATE_MOTION_SENSOR(cros_ec_lsm6dsm_accel, MOTIONSENSE_CHIP_LSM6DSM, \ + MOTIONSENSE_TYPE_ACCEL, lsm6dsm_drv, \ + LSM6DSM_ODR_MIN_VAL, LSM6DSM_ODR_MAX_VAL) + +/* + * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry + * for each lsm6dsm gyro instance (compatible = "cros-ec,lsm6dsm-gyro") + * in device tree. + */ +CREATE_MOTION_SENSOR(cros_ec_lsm6dsm_gyro, MOTIONSENSE_CHIP_LSM6DSM, \ + MOTIONSENSE_TYPE_GYRO, lsm6dsm_drv, \ + LSM6DSM_ODR_MIN_VAL, LSM6DSM_ODR_MAX_VAL) diff --git a/zephyr/shim/src/motionsense_driver/lsm6dso-drvinfo.inc b/zephyr/shim/src/motionsense_driver/lsm6dso-drvinfo.inc index a759993ba4..dfffa2fe2a 100644 --- a/zephyr/shim/src/motionsense_driver/lsm6dso-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/lsm6dso-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -17,8 +17,8 @@ */ /* - * Create driver data. It can be shared among the entries in - * motion_sensors array which are using the same lsm6dso driver. + * Create driver data. This must be a separate instance for + * each entry of the lsm6dso device in the motion_sensors array. */ #define CREATE_SENSOR_DATA_LSM6DSO(id, drvdata_name) \ static struct stprivate_data drvdata_name; diff --git a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc index 2b70a6ec16..1ea1ba2a2d 100644 --- a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc +++ b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -52,3 +52,6 @@ #ifdef CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO #include "lsm6dso-drvinfo.inc" #endif +#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM +#include "lsm6dsm-drvinfo.inc" +#endif diff --git a/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc b/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc index 346688d646..9d42860ac7 100644 --- a/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc +++ b/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ |