diff options
author | loos <loos@FreeBSD.org> | 2014-02-13 18:22:49 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2014-02-13 18:22:49 +0000 |
commit | 67ace023223265e6cde1250d101391d11756c6df (patch) | |
tree | c184aa78e88b541be8092b2e59cff1c238ba6ad2 /sys/dev/iicbus/iicbb.c | |
parent | 4969f2c1cac596d80cba8e9f98f3be2f87a8c639 (diff) | |
download | FreeBSD-src-67ace023223265e6cde1250d101391d11756c6df.zip FreeBSD-src-67ace023223265e6cde1250d101391d11756c6df.tar.gz |
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)
Diffstat (limited to 'sys/dev/iicbus/iicbb.c')
-rw-r--r-- | sys/dev/iicbus/iicbb.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index 44a069f..977d52a 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -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 char *, int, int *, int); 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 ) { |