diff options
author | Andrew McRae <amcrae@google.com> | 2021-12-29 19:42:21 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-30 09:46:21 +0000 |
commit | f956457f58ec6db287f75e190066a9f7ebf44c87 (patch) | |
tree | 37550109b97ce863545efea73c6d6c9f4bead482 /driver | |
parent | bb3654f2b2a32a4376c6fcd1e81f6127472f1e82 (diff) | |
download | chrome-ec-f956457f58ec6db287f75e190066a9f7ebf44c87.tar.gz |
zephyr: Add initial shim for lsm6dso sensor
Add the initial shim for the lsm6dso accel/gyro sensor.
BUG=b:212497341
TEST=zmake testall
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: I01b5787f960971a637da743131ef4b74ba07885c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3360326
Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/accelgyro_lsm6dso.c | 17 | ||||
-rw-r--r-- | driver/accelgyro_lsm6dso.h | 13 |
2 files changed, 18 insertions, 12 deletions
diff --git a/driver/accelgyro_lsm6dso.c b/driver/accelgyro_lsm6dso.c index 61e93cd1cd..ca5850ac8f 100644 --- a/driver/accelgyro_lsm6dso.c +++ b/driver/accelgyro_lsm6dso.c @@ -25,6 +25,23 @@ STATIC_IF(CONFIG_ACCEL_FIFO) volatile uint32_t last_interrupt_timestamp; STATIC_IF(CONFIG_ACCEL_INTERRUPTS) int config_interrupt( const struct motion_sensor_t *s); +#if defined(CONFIG_ZEPHYR) && defined(CONFIG_ACCEL_INTERRUPTS) +/* Get the motion sensor ID of the LSM6DSO sensor that generates the + * interrupt. The interrupt is converted to the event and transferred to + * motion sense task that actually handles the interrupt. + * + * Here we use an alias (lsm6dso_int) to get the motion sensor ID. This alias + * MUST be defined for this driver to work. + * aliases { + * lsm6dso-int = &lid_accel; + * }; + */ +#if DT_NODE_EXISTS(DT_ALIAS(lsm6dso_int)) +#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(lsm6dso_int))) +#endif +#endif + /* * When ODR change, the sensor filters need settling time; * Add a counter to discard a well known number of data with diff --git a/driver/accelgyro_lsm6dso.h b/driver/accelgyro_lsm6dso.h index 9a58fe7d36..15c17f167a 100644 --- a/driver/accelgyro_lsm6dso.h +++ b/driver/accelgyro_lsm6dso.h @@ -8,15 +8,9 @@ #ifndef __CROS_EC_ACCELGYRO_LSM6DSO_H #define __CROS_EC_ACCELGYRO_LSM6DSO_H +#include "driver/accelgyro_lsm6dso_public.h" #include "stm_mems_common.h" -/* - * 7-bit address is 110101xb. Where 'x' is determined - * by the voltage on the ADDR pin - */ -#define LSM6DSO_ADDR0_FLAGS 0x6a -#define LSM6DSO_ADDR1_FLAGS 0x6b - /* Access to embedded sensor hub register bank */ #define LSM6DSO_FUNC_CFG_ACC_ADDR 0x01 #define LSM6DSO_FUNC_CFG_EN 0x80 @@ -113,11 +107,6 @@ struct lsm6dso_fstatus { uint16_t pattern; }; -/* Absolute maximum rate for Acc and Gyro sensors */ -#define LSM6DSO_ODR_MIN_VAL 13000 -#define LSM6DSO_ODR_MAX_VAL \ - MOTION_MAX_SENSOR_FREQUENCY(416000, 13000) - /* ODR reg value from selected data rate in mHz */ #define LSM6DSO_ODR_TO_REG(_odr) (__fls(_odr / LSM6DSO_ODR_MIN_VAL) + 1) |