From owner-svn-src-head@freebsd.org Sun Nov 8 21:06:52 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEA41A29B86; Sun, 8 Nov 2015 21:06:52 +0000 (UTC) (envelope-from andreast@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8D35D1FE2; Sun, 8 Nov 2015 21:06:52 +0000 (UTC) (envelope-from andreast@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA8L6pR6002498; Sun, 8 Nov 2015 21:06:51 GMT (envelope-from andreast@FreeBSD.org) Received: (from andreast@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA8L6pYw002497; Sun, 8 Nov 2015 21:06:51 GMT (envelope-from andreast@FreeBSD.org) Message-Id: <201511082106.tA8L6pYw002497@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andreast set sender to andreast@FreeBSD.org using -f From: Andreas Tobler Date: Sun, 8 Nov 2015 21:06:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290557 - head/sys/dev/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Nov 2015 21:06:53 -0000 Author: andreast Date: Sun Nov 8 21:06:51 2015 New Revision: 290557 URL: https://svnweb.freebsd.org/changeset/base/290557 Log: 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@ Modified: head/sys/dev/ofw/ofw_iicbus.c Modified: head/sys/dev/ofw/ofw_iicbus.c ============================================================================== --- head/sys/dev/ofw/ofw_iicbus.c Sun Nov 8 20:56:04 2015 (r290556) +++ head/sys/dev/ofw/ofw_iicbus.c Sun Nov 8 21:06:51 2015 (r290557) @@ -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);