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
        controller = device_get_parent(bus);
        if (strcmp(device_get_name(controller), "ig4iic") != 0)

        for (i = 0; i < nitems(slaves); i++) {
                if (device_find_child(bus, slave->name, -1) != NULL)
                if (slave->ctlrid != pci_get_devid(controller))
                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 = {
        0       /* no softc */

static devclass_t chromebook_i2c_devclass;

DRIVER_MODULE(chromebook_i2c, iicbus, chromebook_i2c_driver,
    chromebook_i2c_devclass, 0, 0);
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
freebsd-current@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to