Add FDT attachment. Flag lost functionality with FDT_HACKS so we can
find it later.
This commit is contained in:
parent
5d72dffadd
commit
d8e5eadddc
@ -23,6 +23,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@ -39,10 +41,19 @@ __FBSDID("$FreeBSD$");
|
||||
#include <arm/at91/at91_rstreg.h>
|
||||
#include <arm/at91/at91board.h>
|
||||
|
||||
#ifdef FDT
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#define FDT_HACKS 1
|
||||
#endif
|
||||
|
||||
#define RST_TIMEOUT (5) /* Seconds to hold NRST for hard reset */
|
||||
#define RST_TICK (20) /* sample NRST at hz/RST_TICK intervals */
|
||||
|
||||
#ifndef FDT
|
||||
static int at91_rst_intr(void *arg);
|
||||
#endif
|
||||
|
||||
static struct at91_rst_softc {
|
||||
struct resource *mem_res; /* Memory resource */
|
||||
@ -93,6 +104,10 @@ at91_rst_cpu_reset(void)
|
||||
static int
|
||||
at91_rst_probe(device_t dev)
|
||||
{
|
||||
#ifdef FDT
|
||||
if (!ofw_bus_is_compatible(dev, "atmel,at91sam9260-rstc"))
|
||||
return (ENXIO);
|
||||
#endif
|
||||
|
||||
device_set_desc(dev, "AT91SAM9 Reset Controller");
|
||||
return (0);
|
||||
@ -103,7 +118,7 @@ at91_rst_attach(device_t dev)
|
||||
{
|
||||
struct at91_rst_softc *sc;
|
||||
const char *cause;
|
||||
int rid, err;
|
||||
int rid, err = 0;
|
||||
|
||||
at91_rst_sc = sc = device_get_softc(dev);
|
||||
sc->sc_dev = dev;
|
||||
@ -118,6 +133,8 @@ at91_rst_attach(device_t dev)
|
||||
err = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifndef FDT_HACKS
|
||||
rid = 0;
|
||||
sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
||||
RF_ACTIVE | RF_SHAREABLE);
|
||||
@ -132,6 +149,7 @@ at91_rst_attach(device_t dev)
|
||||
at91_rst_intr, NULL, sc, &sc->intrhand);
|
||||
if (err)
|
||||
device_printf(dev, "could not establish interrupt handler.\n");
|
||||
#endif
|
||||
|
||||
WR4(at91_rst_sc, RST_MR, RST_MR_ERSTL(0xd) | RST_MR_URSIEN | RST_MR_KEY);
|
||||
|
||||
@ -161,6 +179,7 @@ at91_rst_attach(device_t dev)
|
||||
return (err);
|
||||
}
|
||||
|
||||
#ifndef FDT_HACKS
|
||||
static void
|
||||
at91_rst_tick(void *argp)
|
||||
{
|
||||
@ -191,6 +210,7 @@ at91_rst_intr(void *argp)
|
||||
}
|
||||
return (FILTER_STRAY);
|
||||
}
|
||||
#endif
|
||||
|
||||
static device_method_t at91_rst_methods[] = {
|
||||
DEVMETHOD(device_probe, at91_rst_probe),
|
||||
@ -206,5 +226,10 @@ static driver_t at91_rst_driver = {
|
||||
|
||||
static devclass_t at91_rst_devclass;
|
||||
|
||||
#ifdef FDT
|
||||
DRIVER_MODULE(at91_rst, simplebus, at91_rst_driver, at91_rst_devclass, NULL,
|
||||
NULL);
|
||||
#else
|
||||
DRIVER_MODULE(at91_rst, atmelarm, at91_rst_driver, at91_rst_devclass, NULL,
|
||||
NULL);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user