Philipp Hug has uploaded this change for review. ( https://review.coreboot.org/27434
Change subject: uart/sifive: provide a monotonic timer using CLINT timer register ......................................................................
uart/sifive: provide a monotonic timer using CLINT timer register
Makes it possible to use the generic udelay.
Change-Id: I5139601226e6f89da69e302a10f2fb56b4b24f38 Signed-off-by: Philipp Hug philipp@hug.cx --- M src/arch/riscv/misc.c M src/soc/sifive/fu540/Kconfig M src/soc/sifive/fu540/Makefile.inc A src/soc/sifive/fu540/timer.c 4 files changed, 29 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/27434/1
diff --git a/src/arch/riscv/misc.c b/src/arch/riscv/misc.c index 65b8ecf..1909dbc 100644 --- a/src/arch/riscv/misc.c +++ b/src/arch/riscv/misc.c @@ -16,7 +16,3 @@ void init_timer(void) { } - -void udelay(unsigned int n) -{ -} diff --git a/src/soc/sifive/fu540/Kconfig b/src/soc/sifive/fu540/Kconfig index d247c28..4db34f7 100644 --- a/src/soc/sifive/fu540/Kconfig +++ b/src/soc/sifive/fu540/Kconfig @@ -20,6 +20,8 @@ select ARCH_RAMSTAGE_RISCV select BOOTBLOCK_CONSOLE select DRIVERS_UART_SIFIVE + select HAVE_MONOTONIC_TIMER + select GENERIC_UDELAY
if SOC_SIFIVE_FU540
diff --git a/src/soc/sifive/fu540/Makefile.inc b/src/soc/sifive/fu540/Makefile.inc index 8a2f3a6..4ac080b 100644 --- a/src/soc/sifive/fu540/Makefile.inc +++ b/src/soc/sifive/fu540/Makefile.inc @@ -19,10 +19,12 @@
romstage-y += uart.c romstage-y += media.c +romstage-y += timer.c
ramstage-y += uart.c ramstage-y += media.c ramstage-y += cbmem.c +ramstage-y += timer.c
CPPFLAGS_common += -Isrc/soc/sifive/fu540/include
diff --git a/src/soc/sifive/fu540/timer.c b/src/soc/sifive/fu540/timer.c new file mode 100644 index 0000000..57afc88 --- /dev/null +++ b/src/soc/sifive/fu540/timer.c @@ -0,0 +1,25 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 Philipp Hug philipp@hug.cx + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <arch/io.h> +#include <arch/encoding.h> +#include <timer.h> + +#define CLINT_MTIME CLINT_BASE + 0xbff8 + +void timer_monotonic_get(struct mono_time *mt) +{ + mono_time_set_usecs(mt, read32((void *)(CLINT_MTIME))); +}