#include <dm/device-internal.h>
#include <linux/err.h>
+#define CLINT_MTIME_OFFSET 0xbff8
+#define ACLINT_MTIME_OFFSET 0
+
/* mtime register */
-#define MTIME_REG(base) ((ulong)(base) + 0xbff8)
+#define MTIME_REG(base, offset) ((ulong)(base) + (offset))
static u64 notrace sifive_clint_get_count(struct udevice *dev)
{
- return readq((void __iomem *)MTIME_REG(dev_get_priv(dev)));
+ return readq((void __iomem *)MTIME_REG(dev_get_priv(dev),
+ dev_get_driver_data(dev)));
}
#if CONFIG_IS_ENABLED(RISCV_MMODE) && IS_ENABLED(CONFIG_TIMER_EARLY)
*/
u64 notrace timer_early_get_count(void)
{
- return readq((void __iomem *)MTIME_REG(RISCV_MMODE_TIMERBASE));
+ return readq((void __iomem *)MTIME_REG(RISCV_MMODE_TIMERBASE,
+ RISCV_MMODE_TIMEROFF));
}
#endif
}
static const struct udevice_id sifive_clint_ids[] = {
- { .compatible = "riscv,clint0" },
- { .compatible = "sifive,clint0" },
+ { .compatible = "riscv,clint0", .data = CLINT_MTIME_OFFSET },
+ { .compatible = "sifive,clint0", .data = CLINT_MTIME_OFFSET },
+ { .compatible = "riscv,aclint-mtimer", .data = ACLINT_MTIME_OFFSET },
{ }
};
#define CFG_SYS_SDRAM_BASE 0x80000000
#define RISCV_MMODE_TIMERBASE 0x2000000
+#define RISCV_MMODE_TIMEROFF 0xbff8
#define RISCV_MMODE_TIMER_FREQ 1000000
-
#define RISCV_SMODE_TIMER_FREQ 1000000
/* Environment options */
#define CFG_SYS_SDRAM_BASE 0x80000000
#define RISCV_MMODE_TIMERBASE 0x2000000
+#define RISCV_MMODE_TIMEROFF 0xbff8
#define RISCV_MMODE_TIMER_FREQ 1000000
-
#define RISCV_SMODE_TIMER_FREQ 1000000
/* Environment options */