summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreast <andreast@FreeBSD.org>2015-11-08 21:06:51 +0000
committerandreast <andreast@FreeBSD.org>2015-11-08 21:06:51 +0000
commit348c4c582f2d67c757e0d40f59064b12fdb03e13 (patch)
tree32254f40f6f00c012f3bf165388e626f876962bc
parent20c0ff4341904e8a4596e312345f3230a531deaf (diff)
downloadFreeBSD-src-348c4c582f2d67c757e0d40f59064b12fdb03e13.zip
FreeBSD-src-348c4c582f2d67c757e0d40f59064b12fdb03e13.tar.gz
Improve r290373, do a runtime check rather than a compile time switch. I
learned that the Power8 and the PS3 have a mix of OFW and FDT. Both have AIM defined. But currently they are not affected. They have no I2C devices under OFW. This version was tested on a Quad G5 and build tested for armv6*. Discussed with nwhitehorn@ Reviewed by: ian@
-rw-r--r--sys/dev/ofw/ofw_iicbus.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/sys/dev/ofw/ofw_iicbus.c b/sys/dev/ofw/ofw_iicbus.c
index badefed..e27cc09 100644
--- a/sys/dev/ofw/ofw_iicbus.c
+++ b/sys/dev/ofw/ofw_iicbus.c
@@ -101,9 +101,13 @@ ofw_iicbus_attach(device_t dev)
{
struct iicbus_softc *sc = IICBUS_SOFTC(dev);
struct ofw_iicbus_devinfo *dinfo;
- phandle_t child, node;
+ phandle_t child, node, root;
pcell_t freq, paddr;
device_t childdev;
+ ssize_t compatlen;
+ char compat[255];
+ char *curstr;
+ u_int iic_addr_8bit = 0;
sc->dev = dev;
mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF);
@@ -125,6 +129,21 @@ ofw_iicbus_attach(device_t dev)
bus_enumerate_hinted_children(dev);
/*
+ * Check if we're running on a PowerMac, needed for the I2C
+ * address below.
+ */
+ root = OF_peer(0);
+ compatlen = OF_getprop(root, "compatible", compat,
+ sizeof(compat));
+ if (compatlen != -1) {
+ for (curstr = compat; curstr < compat + compatlen;
+ curstr += strlen(curstr) + 1) {
+ if (strncmp(curstr, "MacRISC", 7) == 0)
+ iic_addr_8bit = 1;
+ }
+ }
+
+ /*
* Attach those children represented in the device tree.
*/
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
@@ -153,11 +172,11 @@ ofw_iicbus_attach(device_t dev)
* Linux FDT data contains 7-bit values, so shift them up to
* 8-bit format.
*/
-#ifdef AIM
- dinfo->opd_dinfo.addr = paddr;
-#else
- dinfo->opd_dinfo.addr = paddr << 1;
-#endif
+ if (iic_addr_8bit)
+ dinfo->opd_dinfo.addr = paddr;
+ else
+ dinfo->opd_dinfo.addr = paddr << 1;
+
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
0) {
free(dinfo, M_DEVBUF);
OpenPOWER on IntegriCloud