summaryrefslogtreecommitdiffstats
path: root/sys/arm/at91/at91_rst.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2014-02-09 20:59:46 +0000
committerimp <imp@FreeBSD.org>2014-02-09 20:59:46 +0000
commitd8e5eadddc65a4fc366d5f1f648d297d30905ee8 (patch)
treefec6ad90f3cac8ddd27c0061a03cf550cd6738d4 /sys/arm/at91/at91_rst.c
parent5d72dffadda514d765a2813fbf7667e3334c7f2e (diff)
downloadFreeBSD-src-d8e5eadddc65a4fc366d5f1f648d297d30905ee8.zip
FreeBSD-src-d8e5eadddc65a4fc366d5f1f648d297d30905ee8.tar.gz
Add FDT attachment. Flag lost functionality with FDT_HACKS so we can
find it later.
Diffstat (limited to 'sys/arm/at91/at91_rst.c')
-rw-r--r--sys/arm/at91/at91_rst.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/arm/at91/at91_rst.c b/sys/arm/at91/at91_rst.c
index 0879072..77ace5f 100644
--- a/sys/arm/at91/at91_rst.c
+++ b/sys/arm/at91/at91_rst.c
@@ -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 @@ out:
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
OpenPOWER on IntegriCloud