summaryrefslogtreecommitdiff
path: root/lib/utils/timer/fdt_timer_mtimer.c
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-07-23 13:07:51 +0300
committerAnup Patel <anup@brainfault.org>2021-08-14 06:32:39 +0300
commitf3a0eb8583828b0223f9e924672fc455359ea6c8 (patch)
tree611d50c4ece9e7c14a5eede13107bed6be24fa03 /lib/utils/timer/fdt_timer_mtimer.c
parent7a3a0cce4d5b145b5659d4204c1ed8c8efae31cc (diff)
downloadopensbi-f3a0eb8583828b0223f9e924672fc455359ea6c8.tar.xz
lib: utils/fdt: Extend fdt_parse_aclint_node() function
The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have no interrupts-extended DT property when the MTIMER device has no associated HARTs (i.e. the MTIMER device has no MTIMECMPx registers) This patch extends fdt_parse_aclint_node() to handle above mentioned changes in ACLINT MTIMER DT bindings. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/utils/timer/fdt_timer_mtimer.c')
-rw-r--r--lib/utils/timer/fdt_timer_mtimer.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c
index 3f830ad..b08ed38 100644
--- a/lib/utils/timer/fdt_timer_mtimer.c
+++ b/lib/utils/timer/fdt_timer_mtimer.c
@@ -22,7 +22,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
const struct fdt_match *match)
{
int rc;
- unsigned long offset, addr, size;
+ unsigned long offset, addr[2], size[2];
struct aclint_mtimer_data *mt, *mtmaster = NULL;
if (MTIMER_MAX_NR <= mtimer_count)
@@ -31,18 +31,19 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
if (0 < mtimer_count)
mtmaster = &mtimer[0];
- rc = fdt_parse_aclint_node(fdt, nodeoff, true, &addr, &size,
+ rc = fdt_parse_aclint_node(fdt, nodeoff, true,
+ &addr[0], &size[0], &addr[1], &size[1],
&mt->first_hartid, &mt->hart_count);
if (rc)
return rc;
mt->has_64bit_mmio = true;
- mt->mtimecmp_addr = addr + ACLINT_DEFAULT_MTIMECMP_OFFSET;
- mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE;
- mt->mtime_addr = addr + ACLINT_DEFAULT_MTIME_OFFSET;
- mt->mtime_size = size - mt->mtimecmp_size;
-
- if (match->data) {
+ if (match->data) { /* SiFive CLINT */
+ /* Set CLINT addresses */
+ mt->mtimecmp_addr = addr[0] + ACLINT_DEFAULT_MTIMECMP_OFFSET;
+ mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE;
+ mt->mtime_addr = addr[0] + ACLINT_DEFAULT_MTIME_OFFSET;
+ mt->mtime_size = size[0] - mt->mtimecmp_size;
/* Adjust MTIMER address and size for CLINT device */
offset = *((unsigned long *)match->data);
mt->mtime_addr += offset;
@@ -51,6 +52,12 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
/* Parse additional CLINT properties */
if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc))
mt->has_64bit_mmio = false;
+ } else { /* RISC-V ACLINT MTIMER */
+ /* Set ACLINT MTIMER addresses */
+ mt->mtime_addr = addr[0];
+ mt->mtime_size = size[0];
+ mt->mtimecmp_addr = addr[1];
+ mt->mtimecmp_size = size[1];
}
rc = aclint_mtimer_cold_init(mt, mtmaster);