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-16 13:52:41 +0000
commit732636848d50961d6bb4d5f2c689f709c39ddc79 (patch)
tree9ef84ca4e52492512dcd68548e4ceb9670a38772
parent9828699f9b4dfdb9b3849793a574ffdb749cc7ab (diff)
downloadchrome-ec-732636848d50961d6bb4d5f2c689f709c39ddc79.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 (cherry picked from commit c09e13ca676a25c64a66f5db2149d8e2197ffbb9) 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> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3463084
-rw-r--r--driver/als_tcs3400.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index f1d9965d96..f0c4585b1a 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -77,11 +77,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, 0);
}
+#ifdef CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT
DECLARE_DEFERRED(tcs3400_read_deferred);
+#endif
/* convert ATIME register to integration time, in microseconds */
static int tcs3400_get_integration_time(int atime)
@@ -114,16 +123,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
@@ -489,15 +492,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, 0);
-}
-
/*
* tcs3400_irq_handler - bottom half of the interrupt stack.
* Ran from the motion_sense task, finds the events that raised the interrupt,