summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-11-09 13:48:16 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-18 04:46:55 +0000
commitf38b3d8ee17158758e5f405cdb1d85a1c6712df4 (patch)
treee50cc29c9d99ae29756af11c7141068bcf56ce78 /common
parente90affa77fd441ae7e635489bbc79886658fcdcc (diff)
downloadchrome-ec-f38b3d8ee17158758e5f405cdb1d85a1c6712df4.tar.gz
Revert "common: provide config option for 64-bit hwtimer"
This reverts commit c6aa7a384d179128339068531f79baed3a42ceef. BUG=b:200823466 TEST=make buildall -j Change-Id: Ibc096077dec6d2f454dab91a2db545d6c5325903 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273367 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/timer.c95
1 files changed, 27 insertions, 68 deletions
diff --git a/common/timer.c b/common/timer.c
index b43ff265ee..5c0a784ddd 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -17,16 +17,8 @@
#define TIMER_SYSJUMP_TAG 0x4d54 /* "TM" */
-/*
- * High word of the 64-bit timestamp counter. Not used if
- * CONFIG_HWTIMER_64BIT is enabled.
- */
-#ifdef CONFIG_HWTIMER_64BIT
-/* Declaring as extern will cause linker errors if used */
-extern uint32_t clksrc_high;
-#else
+/* High word of the 64-bit timestamp counter */
static volatile uint32_t clksrc_high;
-#endif /* CONFIG_HWTIMER_64BIT */
/* Bitmap of currently running timers */
static uint32_t timer_running;
@@ -64,7 +56,7 @@ void process_timers(int overflow)
timestamp_t next;
timestamp_t now;
- if (!IS_ENABLED(CONFIG_HWTIMER_64BIT) && overflow)
+ if (overflow)
clksrc_high++;
do {
@@ -122,21 +114,19 @@ void udelay(unsigned us)
}
#endif
-int timer_arm(timestamp_t event, task_id_t tskid)
+int timer_arm(timestamp_t tstamp, task_id_t tskid)
{
- timestamp_t now = get_time();
-
ASSERT(tskid < TASK_ID_COUNT);
- if (timer_running & BIT(tskid))
+ if (timer_running & (1<<tskid))
return EC_ERROR_BUSY;
- timer_deadline[tskid] = event;
- atomic_or(&timer_running, BIT(tskid));
+ timer_deadline[tskid] = tstamp;
+ atomic_or(&timer_running, 1<<tskid);
/* Modify the next event if needed */
- if ((event.le.hi < now.le.hi) ||
- ((event.le.hi == now.le.hi) && (event.le.lo <= next_deadline)))
+ if ((tstamp.le.hi < clksrc_high) ||
+ ((tstamp.le.hi == clksrc_high) && (tstamp.le.lo <= next_deadline)))
task_trigger_irq(timer_irq);
return EC_SUCCESS;
@@ -146,7 +136,7 @@ void timer_cancel(task_id_t tskid)
{
ASSERT(tskid < TASK_ID_COUNT);
- atomic_clear(&timer_running, BIT(tskid));
+ atomic_clear(&timer_running, 1 << tskid);
/*
* Don't need to cancel the hardware timer interrupt, instead do
* timer-related housekeeping when the next timer interrupt fires.
@@ -185,18 +175,12 @@ void usleep(unsigned us)
timestamp_t get_time(void)
{
timestamp_t ts;
-
- if (IS_ENABLED(CONFIG_HWTIMER_64BIT)) {
- ts.val = __hw_clock_source_read64();
- } else {
+ ts.le.hi = clksrc_high;
+ ts.le.lo = __hw_clock_source_read();
+ if (ts.le.hi != clksrc_high) {
ts.le.hi = clksrc_high;
ts.le.lo = __hw_clock_source_read();
- if (ts.le.hi != clksrc_high) {
- ts.le.hi = clksrc_high;
- ts.le.lo = __hw_clock_source_read();
- }
}
-
return ts;
}
@@ -208,57 +192,38 @@ clock_t clock(void)
void force_time(timestamp_t ts)
{
- if (IS_ENABLED(CONFIG_HWTIMER_64BIT)) {
- __hw_clock_source_set64(ts.val);
- } else {
- clksrc_high = ts.le.hi;
- __hw_clock_source_set(ts.le.lo);
- }
-
+ clksrc_high = ts.le.hi;
+ __hw_clock_source_set(ts.le.lo);
/* some timers might be already expired : process them */
task_trigger_irq(timer_irq);
}
-/*
- * Define versions of __hw_clock_source_read and __hw_clock_source_set
- * that wrap the 64-bit versions for chips with CONFIG_HWTIMER_64BIT.
- */
-#ifdef CONFIG_HWTIMER_64BIT
-__overridable uint32_t __hw_clock_source_read(void)
-{
- return (uint32_t)__hw_clock_source_read64();
-}
-
-void __hw_clock_source_set(uint32_t ts)
-{
- uint64_t current = __hw_clock_source_read64();
-
- __hw_clock_source_set64(((current >> 32) << 32) | ts);
-}
-#endif /* CONFIG_HWTIMER_64BIT */
-
+#ifdef CONFIG_CMD_TIMERINFO
void timer_print_info(void)
{
- timestamp_t t = get_time();
- uint64_t deadline = (uint64_t)t.le.hi << 32 |
+ uint64_t t = get_time().val;
+ uint64_t deadline = (uint64_t)clksrc_high << 32 |
__hw_clock_event_get();
int tskid;
ccprintf("Time: 0x%016llx us, %11.6lld s\n"
"Deadline: 0x%016llx -> %11.6lld s from now\n"
"Active timers:\n",
- t.val, t.val, deadline, deadline - t.val);
+ t, t, deadline, deadline - t);
cflush();
for (tskid = 0; tskid < TASK_ID_COUNT; tskid++) {
- if (timer_running & BIT(tskid)) {
+ if (timer_running & (1<<tskid)) {
ccprintf(" Tsk %2d 0x%016llx -> %11.6lld\n", tskid,
timer_deadline[tskid].val,
- timer_deadline[tskid].val - t.val);
+ timer_deadline[tskid].val - t);
cflush();
}
}
}
+#else
+void timer_print_info(void) { }
+#endif
void timer_init(void)
{
@@ -271,17 +236,11 @@ void timer_init(void)
ts = (const timestamp_t *)system_get_jump_tag(TIMER_SYSJUMP_TAG,
&version, &size);
if (ts && version == 1 && size == sizeof(timestamp_t)) {
- if (IS_ENABLED(CONFIG_HWTIMER_64BIT)) {
- timer_irq = __hw_clock_source_init64(ts->val);
- } else {
- clksrc_high = ts->le.hi;
- timer_irq = __hw_clock_source_init(ts->le.lo);
- }
+ clksrc_high = ts->le.hi;
+ timer_irq = __hw_clock_source_init(ts->le.lo);
} else {
- if (IS_ENABLED(CONFIG_HWTIMER_64BIT))
- timer_irq = __hw_clock_source_init64(0);
- else
- timer_irq = __hw_clock_source_init(0);
+ clksrc_high = 0;
+ timer_irq = __hw_clock_source_init(0);
}
}