forked from Mirrors/opensbi
lib: sbi_timer: Call driver warm_init from SBI core
Currently, the platform's timer device is tracked in two places: the core SBI implementation has `timer_dev`, and the FDT timer layer has `current_driver`. The latter is used for warm initialization of the timer device. However, this warm init is not specific to FDT-based platforms; other platforms call exactly the same functions from the same point in the boot sequence. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
1a2e507d23
commit
4500828743
@@ -143,7 +143,7 @@ void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt,
|
||||
mt->time_delta_computed = 0;
|
||||
}
|
||||
|
||||
int aclint_mtimer_warm_init(void)
|
||||
static int aclint_mtimer_warm_init(void)
|
||||
{
|
||||
u64 *mt_time_cmp;
|
||||
u32 target_hart = current_hartid();
|
||||
@@ -260,6 +260,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
|
||||
}
|
||||
|
||||
mtimer.timer_freq = mt->mtime_freq;
|
||||
mtimer.warm_init = aclint_mtimer_warm_init;
|
||||
sbi_timer_set_device(&mtimer);
|
||||
|
||||
return 0;
|
||||
|
@@ -67,12 +67,23 @@ static void plmt_timer_event_start(u64 next_event)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int plmt_warm_timer_init(void)
|
||||
{
|
||||
if (!plmt.time_val)
|
||||
return SBI_ENODEV;
|
||||
|
||||
plmt_timer_event_stop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct sbi_timer_device plmt_timer = {
|
||||
.name = "andes_plmt",
|
||||
.timer_freq = DEFAULT_AE350_PLMT_FREQ,
|
||||
.timer_value = plmt_timer_value,
|
||||
.timer_event_start = plmt_timer_event_start,
|
||||
.timer_event_stop = plmt_timer_event_stop
|
||||
.timer_event_stop = plmt_timer_event_stop,
|
||||
.warm_init = plmt_warm_timer_init,
|
||||
};
|
||||
|
||||
int plmt_cold_timer_init(struct plmt_data *plmt)
|
||||
@@ -95,13 +106,3 @@ int plmt_cold_timer_init(struct plmt_data *plmt)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int plmt_warm_timer_init(void)
|
||||
{
|
||||
if (!plmt.time_val)
|
||||
return SBI_ENODEV;
|
||||
|
||||
plmt_timer_event_stop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -165,6 +165,6 @@ static const struct fdt_match timer_mtimer_match[] = {
|
||||
struct fdt_timer fdt_timer_mtimer = {
|
||||
.match_table = timer_mtimer_match,
|
||||
.cold_init = timer_mtimer_cold_init,
|
||||
.warm_init = aclint_mtimer_warm_init,
|
||||
.warm_init = NULL,
|
||||
.exit = NULL,
|
||||
};
|
||||
|
@@ -46,6 +46,6 @@ static const struct fdt_match timer_plmt_match[] = {
|
||||
struct fdt_timer fdt_timer_plmt = {
|
||||
.match_table = timer_plmt_match,
|
||||
.cold_init = fdt_plmt_cold_timer_init,
|
||||
.warm_init = plmt_warm_timer_init,
|
||||
.warm_init = NULL,
|
||||
.exit = NULL,
|
||||
};
|
||||
|
Reference in New Issue
Block a user