riscv timer: cleanup
- Prune unused definitions and includes - Slight renaming of callback functions to indicate their usage - Place vdso_fill_timehands callback logically in the file - Small style nits MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35460
This commit is contained in:
parent
8701571df9
commit
715276a08b
@ -46,52 +46,35 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/timeet.h>
|
||||
#include <sys/timetc.h>
|
||||
#include <sys/vdso.h>
|
||||
#include <sys/watchdog.h>
|
||||
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/intr.h>
|
||||
#include <machine/asm.h>
|
||||
#include <machine/trap.h>
|
||||
#include <machine/sbi.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
|
||||
#define TIMER_COUNTS 0x00
|
||||
#define TIMER_MTIMECMP(cpu) (cpu * 8)
|
||||
|
||||
struct riscv_timer_softc {
|
||||
void *ih;
|
||||
uint32_t clkfreq;
|
||||
struct eventtimer et;
|
||||
};
|
||||
|
||||
static struct riscv_timer_softc *riscv_timer_sc = NULL;
|
||||
|
||||
static uint32_t riscv_timer_fill_vdso_timehands(struct vdso_timehands *vdso_th,
|
||||
struct timecounter *tc);
|
||||
|
||||
static timecounter_get_t riscv_timer_get_timecount;
|
||||
static timecounter_get_t riscv_timer_tc_get_timecount;
|
||||
static timecounter_fill_vdso_timehands_t riscv_timer_tc_fill_vdso_timehands;
|
||||
|
||||
static struct timecounter riscv_timer_timecount = {
|
||||
.tc_name = "RISC-V Timecounter",
|
||||
.tc_get_timecount = riscv_timer_get_timecount,
|
||||
.tc_get_timecount = riscv_timer_tc_get_timecount,
|
||||
.tc_poll_pps = NULL,
|
||||
.tc_counter_mask = ~0u,
|
||||
.tc_frequency = 0,
|
||||
.tc_quality = 1000,
|
||||
.tc_fill_vdso_timehands = riscv_timer_fill_vdso_timehands,
|
||||
.tc_fill_vdso_timehands = riscv_timer_tc_fill_vdso_timehands,
|
||||
};
|
||||
|
||||
static inline uint64_t
|
||||
@ -111,8 +94,8 @@ get_counts(struct riscv_timer_softc *sc)
|
||||
return (counts);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
riscv_timer_get_timecount(struct timecounter *tc)
|
||||
static u_int
|
||||
riscv_timer_tc_get_timecount(struct timecounter *tc)
|
||||
{
|
||||
struct riscv_timer_softc *sc;
|
||||
|
||||
@ -121,8 +104,17 @@ riscv_timer_get_timecount(struct timecounter *tc)
|
||||
return (get_counts(sc));
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
riscv_timer_tc_fill_vdso_timehands(struct vdso_timehands *vdso_th,
|
||||
struct timecounter *tc)
|
||||
{
|
||||
vdso_th->th_algo = VDSO_TH_ALGO_RISCV_RDTIME;
|
||||
bzero(vdso_th->th_res, sizeof(vdso_th->th_res));
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
riscv_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
|
||||
riscv_timer_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
|
||||
{
|
||||
uint64_t counts;
|
||||
|
||||
@ -135,11 +127,10 @@ riscv_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
|
||||
}
|
||||
|
||||
return (EINVAL);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
riscv_timer_stop(struct eventtimer *et)
|
||||
riscv_timer_et_stop(struct eventtimer *et)
|
||||
{
|
||||
|
||||
/* TODO */
|
||||
@ -204,7 +195,7 @@ riscv_timer_attach(device_t dev)
|
||||
int error;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (riscv_timer_sc)
|
||||
if (riscv_timer_sc != NULL)
|
||||
return (ENXIO);
|
||||
|
||||
if (device_get_unit(dev) != 0)
|
||||
@ -236,8 +227,8 @@ riscv_timer_attach(device_t dev)
|
||||
sc->et.et_frequency = sc->clkfreq;
|
||||
sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency;
|
||||
sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
|
||||
sc->et.et_start = riscv_timer_start;
|
||||
sc->et.et_stop = riscv_timer_stop;
|
||||
sc->et.et_start = riscv_timer_et_start;
|
||||
sc->et.et_stop = riscv_timer_et_stop;
|
||||
sc->et.et_priv = sc;
|
||||
et_register(&sc->et);
|
||||
|
||||
@ -304,12 +295,3 @@ DELAY(int usec)
|
||||
}
|
||||
TSEXIT();
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
riscv_timer_fill_vdso_timehands(struct vdso_timehands *vdso_th,
|
||||
struct timecounter *tc)
|
||||
{
|
||||
vdso_th->th_algo = VDSO_TH_ALGO_RISCV_RDTIME;
|
||||
bzero(vdso_th->th_res, sizeof(vdso_th->th_res));
|
||||
return (1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user