Re: [request for testing] isl, cyapa on chromebooks

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Mon, 10 Oct 2016 14:35:22 +0300
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
Received on Mon Oct 10 2016 - 09:36:21 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:08 UTC