Date: Mon, 10 Oct 2016 13:46:10 +0200 From: Michael Gmelin <grembo@freebsd.org> To: Andriy Gapon <avg@FreeBSD.org> Cc: Warner Losh <imp@bsdimp.com>, Matthias Apitz <guru@unixarea.de>, FreeBSD Current <freebsd-current@FreeBSD.org> Subject: Re: [request for testing] isl, cyapa on chromebooks Message-ID: <20161010134610.32120b55@bsd64.grem.de> In-Reply-To: <23c6b4f0-77e9-fe90-0eed-9d0125e7624b@FreeBSD.org> 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> <d4501bd4-7b53-0fb7-ab89-f721368f3f04@FreeBSD.org> <20161008180742.GA1912@c720-r292778-amd64> <846bf31f-a757-2be0-a293-8c4ce3d42a2f@FreeBSD.org> <CANCZdfrYhczHJHR3Kq8GSFx5c_6hcrK=1HU12PXcVB-WAo-8QA@mail.gmail.com> <20161009015324.007a7b42@bsd64.grem.de> <20161009065423.GA2012@c720-r292778-amd64> <CANCZdfrSgKv7Gs6hjd8MOH1cb9UyFcMuJQUkUkMvKxtuUYawRA@mail.gmail.com> <23c6b4f0-77e9-fe90-0eed-9d0125e7624b@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 10 Oct 2016 14:35:22 +0300
Andriy Gapon <avg@FreeBSD.org> wrote:
> 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.
>
For the Acer c720, these criteria would be:
smbios.bios.vendor=="coreboot"
smbios.system.maker=="Acer"
smbios.system.product=="Peppy"
See also
boot/i386/libi386/biosmem.c
dev/atkbdc/atkbdc.c
- Michael
--
Michael Gmelin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161010134610.32120b55>
