summaryrefslogtreecommitdiff
path: root/chip/mt_scp
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2019-06-21 19:39:18 +0800
committerCommit Bot <commit-bot@chromium.org>2019-06-24 06:45:18 +0000
commitca5beb84948426fb8b84d2932a9ce272284c9359 (patch)
tree8d00f762a69c96645615f1b63f2b84f595bf3cd2 /chip/mt_scp
parent81d5f99910334d09768593519767f571392c5238 (diff)
downloadchrome-ec-ca5beb84948426fb8b84d2932a9ce272284c9359.tar.gz
chip/mt_scp/hrtimer: Change 26Mhz to a define
Instead of hardcoding 25/26 all over the place, define the value at the top of the file. That'll make it easier to change the clock later. BRANCH=none BUG=b:134035444 TEST=make BOARD=kukui_scp -j && \ bash board/kukui_scp/update_scp $IP Change-Id: I32df164c172a624560c1299049269899211815ce Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1672644 Reviewed-by: Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'chip/mt_scp')
-rw-r--r--chip/mt_scp/hrtimer.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/chip/mt_scp/hrtimer.c b/chip/mt_scp/hrtimer.c
index ca94f79785..23d260faf4 100644
--- a/chip/mt_scp/hrtimer.c
+++ b/chip/mt_scp/hrtimer.c
@@ -27,8 +27,10 @@
#define TIMER_SYSTEM 5
#define TIMER_EVENT 3
+#define TIMER_CLOCK_MHZ 26
+
/* Common timer overflows at 0x100000000 micro seconds */
-#define OVERFLOW_TICKS (26 * 0x100000000 - 1)
+#define OVERFLOW_TICKS (TIMER_CLOCK_MHZ * 0x100000000 - 1)
static uint8_t sys_high;
static uint8_t event_high;
@@ -44,7 +46,7 @@ static inline uint64_t timer_read_raw_system(void)
* sys_high value.
*/
if (timer_ctrl & TIMER_IRQ_STATUS)
- sys_high_adj = sys_high ? (sys_high - 1) : 25;
+ sys_high_adj = sys_high ? (sys_high - 1) : (TIMER_CLOCK_MHZ-1);
return OVERFLOW_TICKS - (((uint64_t)sys_high_adj << 32) |
SCP_TIMER_VAL(TIMER_SYSTEM));
@@ -114,7 +116,7 @@ void __hw_clock_event_clear(void)
void __hw_clock_event_set(uint32_t deadline)
{
- uint64_t deadline_raw = (uint64_t)deadline * 26;
+ uint64_t deadline_raw = (uint64_t)deadline * TIMER_CLOCK_MHZ;
uint64_t now_raw = timer_read_raw_system();
uint32_t event_deadline;
@@ -174,7 +176,7 @@ int __hw_clock_source_init(uint32_t start_t)
/* System timestamp timer */
timer_set_clock(TIMER_SYSTEM, TIMER_CLK_26M);
- sys_high = 25;
+ sys_high = TIMER_CLOCK_MHZ-1;
timer_set_reset_value(TIMER_SYSTEM, 0xffffffff);
__hw_timer_enable_clock(TIMER_SYSTEM, 1);
task_enable_irq(IRQ_TIMER(TIMER_SYSTEM));
@@ -187,12 +189,13 @@ int __hw_clock_source_init(uint32_t start_t)
uint32_t __hw_clock_source_read(void)
{
- return timer_read_raw_system() / 26;
+ return timer_read_raw_system() / TIMER_CLOCK_MHZ;
}
uint32_t __hw_clock_event_get(void)
{
- return (timer_read_raw_event() + timer_read_raw_system()) / 26;
+ return (timer_read_raw_event() + timer_read_raw_system())
+ / TIMER_CLOCK_MHZ;
}
static void __hw_clock_source_irq(int n)
@@ -219,7 +222,7 @@ static void __hw_clock_source_irq(int n)
process_timers(0);
} else {
/* Overflow, reload system timer */
- sys_high = 25;
+ sys_high = TIMER_CLOCK_MHZ-1;
process_timers(1);
}
} else {