From owner-freebsd-current@freebsd.org Mon Oct 10 11:36:21 2016 Return-Path: Delivered-To: freebsd-current@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 7B7E6C0B821 for ; Mon, 10 Oct 2016 11:36:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 7A995BFD; Mon, 10 Oct 2016 11:36:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id OAA19275; Mon, 10 Oct 2016 14:36:18 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1btYsT-000F8w-SJ; Mon, 10 Oct 2016 14:36:17 +0300 Subject: Re: [request for testing] isl, cyapa on chromebooks To: Warner Losh , Matthias Apitz , Michael Gmelin , FreeBSD Current References: <53bca4d2-975f-f4a0-d12a-5d73fba01a0c@FreeBSD.org> <20161006044732.GA2393@c720-r292778-amd64.oa.oclc.org> <734c7ac0-9018-051e-1df4-a3b719057e19@FreeBSD.org> <773efe54-8ebb-e0e7-7824-10cfaa96d850@FreeBSD.org> <1EE0A2F3-86B9-4806-875E-3845A209A743@freebsd.org> <20161008180742.GA1912@c720-r292778-amd64> <846bf31f-a757-2be0-a293-8c4ce3d42a2f@FreeBSD.org> <20161009015324.007a7b42@bsd64.grem.de> <20161009065423.GA2012@c720-r292778-amd64> From: Andriy Gapon Message-ID: <23c6b4f0-77e9-fe90-0eed-9d0125e7624b@FreeBSD.org> Date: Mon, 10 Oct 2016 14:35:22 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:36:21 -0000 On 09/10/2016 23:22, Warner Losh wrote: > There seems to be enough information present in the smbios data to > know what devices are at what addresses. Perhaps we should use it as > much as possible in well controlled situations to move this knowledge > into the OS. So, I was thinking about maybe doing something like this to preserve the status quo, to avoid requiring manual hints and to lay a foundation for the proper Chromebook I2C slave discovery: static struct { uint32_t ctlrid, const char *name; uint_t addr; } slaves[] = { { 0x9c628086, "isl", 0x88 }, { 0x9c628086, "cyapa", 0xce }, } static void chromebook_i2c_identify(driver_t *driver, device_t bus) { device_t controller; device_t child; int i; /* * A stop gap approach to preserve the status quo. * A more intelligent approach is required to correctly * identify a machine model and hadrdware available on it. * For instance, DMI could be used. * See http://lxr.free-electrons.com/source/drivers/platform/chrome/chromeos_laptop.c */ controller = device_get_parent(bus); if (strcmp(device_get_name(controller), "ig4iic") != 0) return; for (i = 0; i < nitems(slaves); i++) { if (device_find_child(bus, slave->name, -1) != NULL) continue; if (slave->ctlrid != pci_get_devid(controller)) continue; child = BUS_ADD_CHILD(bus, 0, slave->name, -1); if (child != NULL) iicbus_set_addr(child, slave->addr); } } static device_method_t chromebook_i2c_methods[] = { DEVMETHOD(device_identify, chromebook_i2c_identify), { 0, 0 } }; static driver_t chromebook_i2c_driver = { "chromebook_i2c", chromebook_i2c_methods, 0 /* no softc */ }; static devclass_t chromebook_i2c_devclass; DRIVER_MODULE(chromebook_i2c, iicbus, chromebook_i2c_driver, chromebook_i2c_devclass, 0, 0); MODULE_DEPEND(chromebook_i2c, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); MODULE_VERSION(chromebook_i2c, 1); The idea is that this is a driver that listens for new iicbus-es and adds isl and cyapa devices to a bus if some criteria are met. -- Andriy Gapon