diff options
author | Scott <scollyer@chromium.org> | 2017-02-09 14:52:22 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-02-20 14:28:02 -0800 |
commit | 8cef7bab3bf2deec5832561b5a1c5651b6f7b4b0 (patch) | |
tree | 97bbf9f0031f4e861d78d5ab9a9f2c92c7239cc8 /driver | |
parent | a24d8db15402a25ca0e6e2d571b024236488a393 (diff) | |
download | chrome-ec-8cef7bab3bf2deec5832561b5a1c5651b6f7b4b0.tar.gz |
driver: Add polling mode support to Si114x ALS sensor
Eve P1 is missing the ALS_INT_L signal and so needs to poll the
Si114x. This CL adds a new config option CONFIG_ALS_SI114X_POLLING
that when defined uses a deferred callback to trigger the motion
sensor event that reads sensor registers. The deferred callback uses a
8 msec delay which is ~2x longer than the time required by the sensor
to complete the measurement.
BUG=chrome-os-partner:61470
BRANCH=none
TEST=On Eve verify that light sensor measurments are present with the
'accelinfo on 1000' command.
Change-Id: I212bebf2ceacbac87ccb0734cc4990dbc349b028
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/440377
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/als_si114x.c | 14 | ||||
-rw-r--r-- | driver/als_si114x.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 4e941a0534..f1b6d23966 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -163,6 +163,16 @@ void si114x_interrupt(enum gpio_signal signal) CONFIG_ALS_SI114X_INT_EVENT, 0); } +#ifdef CONFIG_ALS_SI114X_POLLING +static void si114x_read_deferred(void) +{ + task_set_event(TASK_ID_MOTIONSENSE, + CONFIG_ALS_SI114X_INT_EVENT, 0); + +} +DECLARE_DEFERRED(si114x_read_deferred); +#endif + /** * irq_handler - bottom half of the interrupt stack. * Ran from the motion_sense task, finds the events that raised the interrupt. @@ -266,6 +276,10 @@ static int read(const struct motion_sensor_t *s, vector_3_t v) return EC_ERROR_INVAL; } ret = raw_write8(s->port, s->addr, SI114X_REG_COMMAND, cmd); +#ifdef CONFIG_ALS_SI114X_POLLING + hook_call_deferred(&si114x_read_deferred_data, + SI114x_POLLING_DELAY); +#endif ret = EC_RES_IN_PROGRESS; break; case SI114X_ALS_IN_PROGRESS_PS_PENDING: diff --git a/driver/als_si114x.h b/driver/als_si114x.h index 5fbc3c665f..78fed24c78 100644 --- a/driver/als_si114x.h +++ b/driver/als_si114x.h @@ -211,6 +211,9 @@ /* Time to wait before re-initializing the device if access is denied */ #define SI114X_DENIED_THRESHOLD (10 * SECOND) +/* Delay used for deferred callback when polling is enabled */ +#define SI114x_POLLING_DELAY (8 * MSEC) + extern const struct accelgyro_drv si114x_drv; enum si114x_state { |