summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2022-02-10 12:43:56 -0800
committerCommit Bot <commit-bot@chromium.org>2022-02-18 05:32:21 +0000
commitd74f95377098a94b69dedbccead50e635470ba52 (patch)
treee5a70b1455dd1a6f6e2c7ef6a827260025024e00
parentb41d5a853cb0fd56e5fb9528d79577e21cfe49a1 (diff)
downloadchrome-ec-d74f95377098a94b69dedbccead50e635470ba52.tar.gz
driver/tcs3400: Set timestamp when emulating interrupt
Use the same interrupt handler for wire or emulated interrupt, so we are sure to timestamp the samples. BUG=b:218890983,b:129419982 TEST=make -j buildall Check on kukui/krane that tast test hardware.SensorIioserviceHard passes. It would fail previously with error like: "error during validation: too much delta between samples for lid cros-ec-gyro at index 174(1m52.310435376s): got 14.894431ms; want <= 7.5ms" BRANCH=kukui,asurada Fixes: commit ae22b703601 ("driver: add an option to emulate irq event in TCS3400") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I9f4deaa214abe6e8ac7a2aa6b6071a02565f8825 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3454215 Reviewed-by: Ting Shen <phoenixshen@chromium.org> (cherry picked from commit c09e13ca676a25c64a66f5db2149d8e2197ffbb9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3465945
-rw-r--r--driver/als_tcs3400.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index 0626e679ee..e590f0db54 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -97,11 +97,20 @@ static inline int tcs3400_i2c_write8(const struct motion_sensor_t *s,
return i2c_write8(s->port, s->i2c_spi_addr_flags, reg, data);
}
+#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT
static void tcs3400_read_deferred(void)
+#else
+void tcs3400_interrupt(enum gpio_signal signal)
+#endif
{
+ if (IS_ENABLED(CONFIG_ACCEL_FIFO))
+ last_interrupt_timestamp = __hw_clock_source_read();
+
task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT);
}
+#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT
DECLARE_DEFERRED(tcs3400_read_deferred);
+#endif
/* convert ATIME register to integration time, in microseconds */
int tcs3400_get_integration_time(int atime)
@@ -134,16 +143,10 @@ static int tcs3400_read(const struct motion_sensor_t *s, intv3_t v)
if (ret)
return ret;
- if (IS_ENABLED(CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT)) {
- int atime;
-
- ret = tcs3400_i2c_read8(s, TCS_I2C_ATIME, &atime);
- if (ret)
- return ret;
-
- hook_call_deferred(&tcs3400_read_deferred_data,
- tcs3400_get_integration_time(atime));
- }
+#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT
+ hook_call_deferred(&tcs3400_read_deferred_data,
+ tcs3400_get_integration_time(atime));
+#endif
/*
* If write succeeded, we've started the read process, but can't
@@ -516,14 +519,6 @@ static int tcs3400_post_events(struct motion_sensor_t *s,
return ret;
}
-void tcs3400_interrupt(enum gpio_signal signal)
-{
- if (IS_ENABLED(CONFIG_ACCEL_FIFO))
- last_interrupt_timestamp = __hw_clock_source_read();
-
- task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT);
-}
-
/*
* tcs3400_irq_handler - bottom half of the interrupt stack.
* Ran from the motion_sense task, finds the events that raised the interrupt,