lib: utils/timer: mtimer: add a quirk for lacking mtime register
authorIcenowy Zheng <uwu@icenowy.me>
Mon, 12 Dec 2022 08:22:37 +0000 (16:22 +0800)
committerAnup Patel <anup@brainfault.org>
Sat, 17 Dec 2022 05:31:03 +0000 (11:01 +0530)
commitca7810aecdbae0630c506f05dbed641f3875ec5b
treec2edf0a92745e26543f733ae4866c71ee6f5c30b
parenta8ee82cd8c008f09c91b5c307de4c9b37660ff71
lib: utils/timer: mtimer: add a quirk for lacking mtime register

T-Head developers surely have a different understanding of time CSR and
CLINT's mtime register with SiFive ones, that they did not implement
the mtime register at all -- as shown in openC906 source code, their
time CSR value is just exposed at the top of their processor IP block
and expects an external continous counter, which makes it not
overrideable, and thus mtime register is not implemented, even not for
reading. However, if CLINTEE is not enabled in T-Head's MXSTATUS
extended CSR, these systems still rely on the mtimecmp registers to
generate timer interrupts. This makes it necessary to implement T-Head
C9xx CLINT support in OpenSBI MTIMER driver, which skips implementing
reading mtime register and falls back to default code that reads time
CSR.

Add a quirk into MTIMER driver, which represents a mtime register is
lacking and time CSR value should be used instead.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/timer/aclint_mtimer.c
lib/utils/timer/fdt_timer_mtimer.c