Skip to content

Commit

Permalink
drivers: mediatek: mt8365: Add a comment to timer.c
Browse files Browse the repository at this point in the history
Add a comment explaining that the CNTCV_L register must be read before the CNTCV_H to get a valid 64-bit timestamp value

Signed-off-by: Andrew Perepech <[email protected]>
  • Loading branch information
andrew-mtk authored Feb 19, 2025
1 parent 2751ee8 commit fd54677
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/drivers/mediatek/mt8365/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ uint64_t platform_timer_get(struct timer *timer)
if (timer->id >= NR_TMRS)
return -EINVAL;

/* must read 'low' first, and 'high' next */
/* CNTCV_H is only updated when the CNTCV_L is read.
* Always read CNTCV_L before CNTCV_H to get a valid 64-bit timestamp.
*/
low = io_reg_read(CNTCV_L);
high = io_reg_read(CNTCV_H);
time = ((uint64_t)high << 32) | low;
Expand Down

0 comments on commit fd54677

Please sign in to comment.