mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00

The timer driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_timer_init() performs a best-effort initialization of all matching DT nodes. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
50 lines
1018 B
C
50 lines
1018 B
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2022 Andes Technology Corporation
|
|
*
|
|
* Authors:
|
|
* Yu Chien Peter Lin <peterlin@andestech.com>
|
|
*/
|
|
|
|
#include <sbi_utils/fdt/fdt_helper.h>
|
|
#include <sbi_utils/timer/fdt_timer.h>
|
|
#include <sbi_utils/timer/andes_plmt.h>
|
|
|
|
extern struct plmt_data plmt;
|
|
|
|
static int fdt_plmt_cold_timer_init(const void *fdt, int nodeoff,
|
|
const struct fdt_match *match)
|
|
{
|
|
int rc;
|
|
unsigned long plmt_base;
|
|
|
|
rc = fdt_parse_plmt_node(fdt, nodeoff, &plmt_base, &plmt.size,
|
|
&plmt.hart_count);
|
|
if (rc)
|
|
return rc;
|
|
|
|
plmt.time_val = (u64 *)plmt_base;
|
|
plmt.time_cmp = (u64 *)(plmt_base + 0x8);
|
|
|
|
rc = fdt_parse_timebase_frequency(fdt, &plmt.timer_freq);
|
|
if (rc)
|
|
return rc;
|
|
|
|
rc = plmt_cold_timer_init(&plmt);
|
|
if (rc)
|
|
return rc;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct fdt_match timer_plmt_match[] = {
|
|
{ .compatible = "andestech,plmt0" },
|
|
{},
|
|
};
|
|
|
|
const struct fdt_driver fdt_timer_plmt = {
|
|
.match_table = timer_plmt_match,
|
|
.init = fdt_plmt_cold_timer_init,
|
|
};
|