summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/g/hwtimer.c9
-rw-r--r--chip/g/sps.c10
-rw-r--r--common/i2cs_tpm.c10
-rw-r--r--include/timer.h7
4 files changed, 36 insertions, 0 deletions
diff --git a/chip/g/hwtimer.c b/chip/g/hwtimer.c
index 9fbe3f0920..7d9b31e470 100644
--- a/chip/g/hwtimer.c
+++ b/chip/g/hwtimer.c
@@ -211,3 +211,12 @@ void udelay(unsigned us)
;
}
#endif /* CONFIG_HW_SPECIFIC_UDELAY */
+
+void tick_delay(uint32_t ticks)
+{
+ uint32_t cur_tick = GREG32(TIMELS, SOURCE(VALUE));
+
+ /* Note: the counter counts down. */
+ while ((cur_tick - GREG32(TIMELS, SOURCE(VALUE))) < ticks)
+ ;
+}
diff --git a/chip/g/sps.c b/chip/g/sps.c
index 5fd6735dd8..7f8b81de9b 100644
--- a/chip/g/sps.c
+++ b/chip/g/sps.c
@@ -344,6 +344,16 @@ static void sps_rx_interrupt(uint32_t port, int cs_deasserted)
* completed.
*/
gpio_set_level(GPIO_INT_AP_L, 0);
+
+ /*
+ * This is to meet the AP requirement of minimum 4 usec
+ * duration of INT_AP_L assertion.
+ *
+ * TODO(b/130515803): Ideally, this should be improved
+ * to support any duration requirement in future.
+ */
+ tick_delay(2);
+
gpio_set_level(GPIO_INT_AP_L, 1);
seen_data = 0;
}
diff --git a/common/i2cs_tpm.c b/common/i2cs_tpm.c
index 4518eddbb9..cb893cf84f 100644
--- a/common/i2cs_tpm.c
+++ b/common/i2cs_tpm.c
@@ -208,6 +208,16 @@ static void wr_complete_handler(void *i2cs_data, size_t i2cs_data_size)
* on the AP interrupt line for that.
*/
gpio_set_level(GPIO_INT_AP_L, 0);
+
+ /*
+ * This is to meet the AP requirement of minimum 4 usec
+ * duration of INT_AP_L assertion.
+ *
+ * TODO(b/130515803): Ideally, this should be improved
+ * to support any duration requirement in future.
+ */
+ tick_delay(2);
+
gpio_set_level(GPIO_INT_AP_L, 1);
}
diff --git a/include/timer.h b/include/timer.h
index d8bc252ba0..89a49762ae 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -178,3 +178,10 @@ static inline int time_after(uint32_t a, uint32_t b)
}
#endif /* __CROS_EC_TIMER_H */
+
+/**
+ * Busy-wait for the given ticks.
+ *
+ * @param ticks Number of ticks to delay.
+ */
+void tick_delay(uint32_t ticks);