svn commit: r261683 - head/sys/arm/at91

Warner Losh imp at FreeBSD.org
Sun Feb 9 20:57:27 UTC 2014


Author: imp
Date: Sun Feb  9 20:57:26 2014
New Revision: 261683
URL: http://svnweb.freebsd.org/changeset/base/261683

Log:
  Add FDT attachment, plus minor code shuffle.

Modified:
  head/sys/arm/at91/at91_pit.c

Modified: head/sys/arm/at91/at91_pit.c
==============================================================================
--- head/sys/arm/at91/at91_pit.c	Sun Feb  9 20:56:39 2014	(r261682)
+++ head/sys/arm/at91/at91_pit.c	Sun Feb  9 20:57:26 2014	(r261683)
@@ -24,6 +24,8 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_platform.h"
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
@@ -48,6 +50,12 @@ __FBSDID("$FreeBSD$");
 #include <arm/at91/at91var.h>
 #include <arm/at91/at91_pitreg.h>
 
+#ifdef FDT
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#endif
+
 #ifndef PIT_PRESCALE
 #define PIT_PRESCALE (16)
 #endif
@@ -83,6 +91,9 @@ at91_pit_delay(int us)
 	uint64_t pit_freq;
 	const uint64_t mhz  = 1E6;
 
+	if (sc == NULL)
+		return;
+
 	last = PIT_PIV(RD4(sc, PIT_PIIR));
 
 	/* Max delay ~= 260s. @ 133Mhz */
@@ -111,7 +122,10 @@ static struct timecounter at91_pit_timec
 static int
 at91_pit_probe(device_t dev)
 {
-
+#ifdef FDT
+	if (!ofw_bus_is_compatible(dev, "atmel,at91sam9260-pit"))
+		return (ENXIO);
+#endif
 	device_set_desc(dev, "AT91SAM9 PIT");
         return (0);
 }
@@ -121,10 +135,8 @@ at91_pit_attach(device_t dev)
 {
 	void *ih;
 	int rid, err = 0;
-	struct at91_softc *at91_sc;
 	struct resource *irq;
 
-	at91_sc = device_get_softc(device_get_parent(dev));
 	sc = device_get_softc(dev);
 	sc->sc_dev = dev;
 
@@ -158,22 +170,6 @@ out:
 	return (err);
 }
 
-static device_method_t at91_pit_methods[] = {
-	DEVMETHOD(device_probe, at91_pit_probe),
-	DEVMETHOD(device_attach, at91_pit_attach),
-	DEVMETHOD_END
-};
-
-static driver_t at91_pit_driver = {
-	"at91_pit",
-	at91_pit_methods,
-	sizeof(struct pit_softc),
-};
-
-static devclass_t at91_pit_devclass;
-
-DRIVER_MODULE(at91_pit, atmelarm, at91_pit_driver, at91_pit_devclass, NULL,
-    NULL);
 
 static int
 pit_intr(void *arg)
@@ -202,3 +198,25 @@ at91_pit_get_timecount(struct timecounte
 	icnt = piir >> 20;	/* Overflows */
 	return (timecount + PIT_PIV(piir) + PIT_PIV(RD4(sc, PIT_MR)) * icnt);
 }
+
+static device_method_t at91_pit_methods[] = {
+	DEVMETHOD(device_probe, at91_pit_probe),
+	DEVMETHOD(device_attach, at91_pit_attach),
+	DEVMETHOD_END
+};
+
+static driver_t at91_pit_driver = {
+	"at91_pit",
+	at91_pit_methods,
+	sizeof(struct pit_softc),
+};
+
+static devclass_t at91_pit_devclass;
+
+#ifdef FDT
+DRIVER_MODULE(at91_pit, simplebus, at91_pit_driver, at91_pit_devclass, NULL,
+    NULL);
+#else
+DRIVER_MODULE(at91_pit, atmelarm, at91_pit_driver, at91_pit_devclass, NULL,
+    NULL);
+#endif


More information about the svn-src-all mailing list