summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2014-02-09 21:01:10 +0000
committerimp <imp@FreeBSD.org>2014-02-09 21:01:10 +0000
commitbdaa9ef2459fdc4e3a8cbe7bc5c0e8581df5c627 (patch)
tree70435a7395d8228d177cb08b3abe025d91b81020
parentda8067e1635e97f16ee8be7b7afc78cf899fc467 (diff)
downloadFreeBSD-src-bdaa9ef2459fdc4e3a8cbe7bc5c0e8581df5c627.zip
FreeBSD-src-bdaa9ef2459fdc4e3a8cbe7bc5c0e8581df5c627.tar.gz
Add TWI attachment for FDT. We're only matching the SAMG20 device for
now, others to follow.
-rw-r--r--sys/arm/at91/at91_twi.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/arm/at91/at91_twi.c b/sys/arm/at91/at91_twi.c
index 523f23e..559200c 100644
--- a/sys/arm/at91/at91_twi.c
+++ b/sys/arm/at91/at91_twi.c
@@ -23,6 +23,8 @@
* SUCH DAMAGE.
*/
+#include "opt_platform.h"
+
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -46,6 +48,12 @@ __FBSDID("$FreeBSD$");
#include <dev/iicbus/iicbus.h>
#include "iicbus_if.h"
+#ifdef FDT
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#endif
+
#define TWI_SLOW_CLOCK 1500
#define TWI_FAST_CLOCK 45000
#define TWI_FASTEST_CLOCK 90000
@@ -104,7 +112,11 @@ static void at91_twi_deactivate(device_t dev);
static int
at91_twi_probe(device_t dev)
{
-
+#ifdef FDT
+ /* XXXX need a whole list, since there's at least 4 different ones */
+ if (!ofw_bus_is_compatible(dev, "atmel,at91sam9g20-i2c"))
+ return (ENXIO);
+#endif
device_set_desc(dev, "TWI");
return (0);
}
@@ -397,7 +409,12 @@ static driver_t at91_twi_driver = {
sizeof(struct at91_twi_softc),
};
+#ifdef FDT
+DRIVER_MODULE(at91_twi, simplebus, at91_twi_driver, at91_twi_devclass, NULL,
+ NULL);
+#else
DRIVER_MODULE(at91_twi, atmelarm, at91_twi_driver, at91_twi_devclass, NULL,
NULL);
+#endif
DRIVER_MODULE(iicbus, at91_twi, iicbus_driver, iicbus_devclass, NULL, NULL);
MODULE_DEPEND(at91_twi, iicbus, 1, 1, 1);
OpenPOWER on IntegriCloud