Add MULTIDELAY support to the am335x dmtimer. This will be useful for
testing Cortex-A8 support in GENERIC. Sponsored by: ABT Systems Ltd
This commit is contained in:
parent
12f7add9f7
commit
8fcbb32311
@ -38,6 +38,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/timetc.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
#include <machine/machdep.h> /* For arm_set_delay */
|
||||
#endif
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
@ -67,6 +71,8 @@ struct am335x_dmtimer_softc {
|
||||
static struct am335x_dmtimer_softc *am335x_dmtimer_et_sc = NULL;
|
||||
static struct am335x_dmtimer_softc *am335x_dmtimer_tc_sc = NULL;
|
||||
|
||||
static void am335x_dmtimer_delay(int, void *);
|
||||
|
||||
/*
|
||||
* We use dmtimer2 for eventtimer and dmtimer3 for timecounter.
|
||||
*/
|
||||
@ -235,6 +241,10 @@ am335x_dmtimer_tc_init(struct am335x_dmtimer_softc *sc)
|
||||
am335x_dmtimer_tc_sc = sc;
|
||||
tc_init(&sc->func.tc);
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
arm_set_delay(am335x_dmtimer_delay, sc);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -328,23 +338,13 @@ static devclass_t am335x_dmtimer_devclass;
|
||||
DRIVER_MODULE(am335x_dmtimer, simplebus, am335x_dmtimer_driver, am335x_dmtimer_devclass, 0, 0);
|
||||
MODULE_DEPEND(am335x_dmtimer, am335x_prcm, 1, 1, 1);
|
||||
|
||||
void
|
||||
DELAY(int usec)
|
||||
static void
|
||||
am335x_dmtimer_delay(int usec, void *arg)
|
||||
{
|
||||
struct am335x_dmtimer_softc *sc;
|
||||
struct am335x_dmtimer_softc *sc = arg;
|
||||
int32_t counts;
|
||||
uint32_t first, last;
|
||||
|
||||
sc = am335x_dmtimer_tc_sc;
|
||||
|
||||
if (sc == NULL) {
|
||||
for (; usec > 0; usec--)
|
||||
for (counts = 200; counts > 0; counts--)
|
||||
/* Prevent gcc from optimizing out the loop */
|
||||
cpufunc_nullop();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the number of times to count */
|
||||
counts = (usec + 1) * (sc->sysclk_freq / 1000000);
|
||||
|
||||
@ -361,3 +361,19 @@ DELAY(int usec)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MULTIDELAY
|
||||
void
|
||||
DELAY(int usec)
|
||||
{
|
||||
int32_t counts;
|
||||
|
||||
if (am335x_dmtimer_tc_sc == NULL) {
|
||||
for (; usec > 0; usec--)
|
||||
for (counts = 200; counts > 0; counts--)
|
||||
/* Prevent gcc from optimizing out the loop */
|
||||
cpufunc_nullop();
|
||||
return;
|
||||
} else
|
||||
am335x_dmtimer_delay(usec, am335x_dmtimer_tc_sc);
|
||||
}
|
||||
#endif
|
||||
|
@ -124,5 +124,5 @@ static platform_method_t am335x_methods[] = {
|
||||
PLATFORMMETHOD_END,
|
||||
};
|
||||
|
||||
FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am335x", 0);
|
||||
FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am335x", 200);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user