svn commit: r261844 - in head/sys/dev: iicbus ofw

Luiz Otavio O Souza loos at FreeBSD.org
Thu Feb 13 18:22:52 UTC 2014


Author: loos
Date: Thu Feb 13 18:22:49 2014
New Revision: 261844
URL: http://svnweb.freebsd.org/changeset/base/261844

Log:
  Allow the use of OFW I2C bus together with iicbb(4) on OFW-based systems.
  
  This change makes ofw_iicbus attach to iicbb(4) controllers in addition to
  the already supported i2c host bridges (iichb).
  
  On iicbb(4) allow the direct access of the OFW parent node by its children,
  so they can be directly attached to iicbb(4) node on the DTS without the
  need of describing the i2c bus.
  
  Approved by:	adrian (mentor, implicit)

Modified:
  head/sys/dev/iicbus/iicbb.c
  head/sys/dev/ofw/ofw_iicbus.c

Modified: head/sys/dev/iicbus/iicbb.c
==============================================================================
--- head/sys/dev/iicbus/iicbb.c	Thu Feb 13 17:58:52 2014	(r261843)
+++ head/sys/dev/iicbus/iicbb.c	Thu Feb 13 18:22:49 2014	(r261844)
@@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$");
  *
  */
 
+#include "opt_platform.h"
+
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
@@ -50,6 +52,11 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/uio.h>
 
+#ifdef FDT
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/fdt/fdt_common.h>
+#endif
 
 #include <dev/iicbus/iiconf.h>
 #include <dev/iicbus/iicbus.h>
@@ -77,6 +84,9 @@ static int iicbb_write(device_t, const c
 static int iicbb_read(device_t, char *, int, int *, int, int);
 static int iicbb_reset(device_t, u_char, u_char, u_char *);
 static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs);
+#ifdef FDT
+static phandle_t iicbb_get_node(device_t, device_t);
+#endif
 
 static device_method_t iicbb_methods[] = {
 	/* device interface */
@@ -98,6 +108,11 @@ static device_method_t iicbb_methods[] =
 	DEVMETHOD(iicbus_reset,		iicbb_reset),
 	DEVMETHOD(iicbus_transfer,	iicbb_transfer),
 
+#ifdef FDT
+	/* ofw_bus interface */
+	DEVMETHOD(ofw_bus_get_node,	iicbb_get_node),
+#endif
+
 	{ 0, 0 }
 };
 
@@ -154,6 +169,16 @@ iicbb_detach(device_t dev)
 	return (0);
 }
 
+#ifdef FDT
+static phandle_t
+iicbb_get_node(device_t bus, device_t dev)
+{
+
+	/* We only have one child, the I2C bus, which needs our own node. */
+	return (ofw_bus_get_node(bus));
+}
+#endif
+
 static void
 iicbb_child_detached( device_t dev, device_t child )
 {

Modified: head/sys/dev/ofw/ofw_iicbus.c
==============================================================================
--- head/sys/dev/ofw/ofw_iicbus.c	Thu Feb 13 17:58:52 2014	(r261843)
+++ head/sys/dev/ofw/ofw_iicbus.c	Thu Feb 13 18:22:49 2014	(r261844)
@@ -80,6 +80,7 @@ static devclass_t ofwiicbus_devclass;
 
 DEFINE_CLASS_1(iicbus, ofw_iicbus_driver, ofw_iicbus_methods,
     sizeof(struct iicbus_softc), iicbus_driver);
+DRIVER_MODULE(ofw_iicbus, iicbb, ofw_iicbus_driver, ofwiicbus_devclass, 0, 0);
 DRIVER_MODULE(ofw_iicbus, iichb, ofw_iicbus_driver, ofwiicbus_devclass, 0, 0);
 MODULE_VERSION(ofw_iicbus, 1);
 MODULE_DEPEND(ofw_iicbus, iicbus, 1, 1, 1);


More information about the svn-src-all mailing list