2024-07-12 13:19:10 +02:00
|
|
|
diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c
|
|
|
|
index 7b618de..65e42b0 100644
|
|
|
|
--- a/lib/sbi/sbi_timer.c
|
|
|
|
+++ b/lib/sbi/sbi_timer.c
|
|
|
|
@@ -183,13 +183,17 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
|
|
|
|
u64 *time_delta;
|
|
|
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
|
|
|
|
|
|
|
+ sbi_printf("sbi_timer_init: begins\n");
|
|
|
|
+
|
|
|
|
if (cold_boot) {
|
|
|
|
time_delta_off = sbi_scratch_alloc_offset(sizeof(*time_delta));
|
|
|
|
if (!time_delta_off)
|
|
|
|
return SBI_ENOMEM;
|
|
|
|
|
|
|
|
- if (sbi_hart_has_extension(scratch, SBI_HART_EXT_ZICNTR))
|
|
|
|
+ if (sbi_hart_has_extension(scratch, SBI_HART_EXT_ZICNTR)) {
|
|
|
|
+ sbi_printf("sbi_timer_init: got Zicntr extension\n");
|
|
|
|
get_time_val = get_ticks;
|
|
|
|
+ }
|
|
|
|
} else {
|
|
|
|
if (!time_delta_off)
|
|
|
|
return SBI_ENOMEM;
|
|
|
|
@@ -198,7 +202,10 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
|
|
|
|
time_delta = sbi_scratch_offset_ptr(scratch, time_delta_off);
|
|
|
|
*time_delta = 0;
|
|
|
|
|
|
|
|
- return sbi_platform_timer_init(plat, cold_boot);
|
|
|
|
+ int rc = sbi_platform_timer_init(plat, cold_boot);
|
|
|
|
+ if (rc)
|
|
|
|
+ sbi_printf("sbi_platform_timer: sbi_platform_timer_init failed (%d)\n", rc);
|
|
|
|
+ return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sbi_timer_exit(struct sbi_scratch *scratch)
|
|
|
|
diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c
|
|
|
|
index f468730..db20526 100644
|
|
|
|
--- a/lib/utils/timer/fdt_timer.c
|
|
|
|
+++ b/lib/utils/timer/fdt_timer.c
|
|
|
|
@@ -7,6 +7,7 @@
|
|
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#include <sbi/sbi_console.h>
|
|
|
|
#include <sbi/sbi_error.h>
|
|
|
|
#include <sbi/sbi_scratch.h>
|
|
|
|
#include <sbi_utils/fdt/fdt_helper.h>
|
|
|
|
@@ -39,19 +40,26 @@ static int fdt_timer_cold_init(void)
|
|
|
|
void *fdt = fdt_get_address();
|
|
|
|
|
|
|
|
for (pos = 0; pos < fdt_timer_drivers_size; pos++) {
|
|
|
|
+ sbi_printf("fdt_timer_cold_init: pos = %d\n", pos);
|
|
|
|
drv = fdt_timer_drivers[pos];
|
|
|
|
|
|
|
|
noff = -1;
|
|
|
|
while ((noff = fdt_find_match(fdt, noff,
|
|
|
|
drv->match_table, &match)) >= 0) {
|
|
|
|
+
|
|
|
|
+ sbi_printf("fdt_timer_cold_init: got match, name = %s\n", match->compatible);
|
|
|
|
if (!fdt_node_is_enabled(fdt, noff))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
+ sbi_printf("fdt_timer_cold_init: enabled\n");
|
|
|
|
+
|
|
|
|
/* drv->cold_init must not be NULL */
|
|
|
|
if (drv->cold_init == NULL)
|
|
|
|
return SBI_EFAIL;
|
|
|
|
|
|
|
|
rc = drv->cold_init(fdt, noff, match);
|
|
|
|
+ sbi_printf("fdt_timer_cold_init: drc->cold_init = %d\n", rc);
|
|
|
|
+
|
|
|
|
if (rc == SBI_ENODEV)
|
|
|
|
continue;
|
|
|
|
if (rc)
|
|
|
|
@@ -69,6 +77,7 @@ static int fdt_timer_cold_init(void)
|
|
|
|
* We can't fail here since systems with Sstc might not provide
|
|
|
|
* mtimer/clint DT node in the device tree.
|
|
|
|
*/
|
|
|
|
+ sbi_printf("fdt_timer_cold_init: returns 0\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -78,9 +87,15 @@ int fdt_timer_init(bool cold_boot)
|
|
|
|
|
|
|
|
if (cold_boot) {
|
|
|
|
rc = fdt_timer_cold_init();
|
|
|
|
- if (rc)
|
|
|
|
+ if (rc) {
|
|
|
|
+ sbi_printf("fdt_timer_init: fdt_timer_cold_init failed (%d)\n", rc);
|
|
|
|
return rc;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
- return fdt_timer_warm_init();
|
|
|
|
+ rc = fdt_timer_warm_init();
|
|
|
|
+ if (rc)
|
|
|
|
+ sbi_printf("fdt_timer_init: fdt_timer_warm_init failed (%d)\n", rc);
|
|
|
|
+
|
|
|
|
+ return rc;
|
|
|
|
}
|
2024-07-12 13:47:01 +02:00
|
|
|
diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c
|
|
|
|
index 9e27e3a..fba48ca 100644
|
|
|
|
--- a/lib/utils/timer/fdt_timer_mtimer.c
|
|
|
|
+++ b/lib/utils/timer/fdt_timer_mtimer.c
|
|
|
|
@@ -8,6 +8,7 @@
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <libfdt.h>
|
|
|
|
+#include <sbi/sbi_console.h>
|
|
|
|
#include <sbi/sbi_error.h>
|
|
|
|
#include <sbi/sbi_heap.h>
|
|
|
|
#include <sbi/sbi_list.h>
|
|
|
|
@@ -33,6 +34,7 @@ static struct aclint_mtimer_data *mt_reference = NULL;
|
|
|
|
static int timer_mtimer_cold_init(void *fdt, int nodeoff,
|
|
|
|
const struct fdt_match *match)
|
|
|
|
{
|
|
|
|
+
|
|
|
|
int rc;
|
|
|
|
unsigned long addr[2], size[2];
|
|
|
|
struct timer_mtimer_node *mtn, *n;
|
|
|
|
@@ -40,6 +42,8 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
|
|
|
|
const struct timer_mtimer_quirks *quirks = match->data;
|
|
|
|
bool is_clint = quirks && quirks->is_clint;
|
|
|
|
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: begins, is_clint = %d\n", (int) is_clint);
|
|
|
|
+
|
|
|
|
mtn = sbi_zalloc(sizeof(*mtn));
|
|
|
|
if (!mtn)
|
|
|
|
return SBI_ENOMEM;
|
|
|
|
@@ -49,6 +53,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
|
|
|
|
&addr[0], &size[0], &addr[1], &size[1],
|
|
|
|
&mt->first_hartid, &mt->hart_count);
|
|
|
|
if (rc) {
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: fdt_parse_aclint_node failed (%d)\n", rc);
|
|
|
|
sbi_free(mtn);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
@@ -57,6 +62,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
|
|
|
|
|
|
|
|
rc = fdt_parse_timebase_frequency(fdt, &mt->mtime_freq);
|
|
|
|
if (rc) {
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: fdt_parse_timebase_frequency failed (%d)\n", rc);
|
|
|
|
sbi_free(mtn);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
@@ -83,6 +89,11 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
|
|
|
|
mt->mtimecmp_size = size[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: mtime_addr = 0x%08lx\n", mt->mtime_addr);
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: mtime_size = 0x%08lx\n", mt->mtime_size);
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: mtime_addr = 0x%08lx\n", mt->mtimecmp_addr);
|
|
|
|
+ sbi_printf("timer_mtimer_cold_init: mtime_addr = 0x%08lx\n", mt->mtimecmp_size);
|
|
|
|
+
|
|
|
|
/* Apply additional quirks */
|
|
|
|
if (quirks) {
|
|
|
|
mt->has_64bit_mmio = quirks->has_64bit_mmio;
|