2 * Copyright (c) 2016 The FreeBSD Project.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
37 #include <sys/errno.h>
40 #include <dev/pci/pcivar.h>
41 #include <dev/pci/pcireg.h>
42 #include <dev/iicbus/iicbus.h>
43 #include <dev/iicbus/iiconf.h>
46 * Driver that attaches I2C devices.
53 { 0x9c628086, "isl", 0x88 },
54 { 0x9c618086, "cyapa", 0xce },
58 chromebook_i2c_identify(driver_t *driver, device_t bus)
65 * A stopgap approach to preserve the status quo.
66 * A more intelligent approach is required to correctly
67 * identify a machine model and hardware available on it.
68 * For instance, DMI could be used.
69 * See http://lxr.free-electrons.com/source/drivers/platform/chrome/chromeos_laptop.c
71 controller = device_get_parent(bus);
72 if (strcmp(device_get_name(controller), "ig4iic") != 0)
75 for (i = 0; i < nitems(slaves); i++) {
76 if (device_find_child(bus, slaves[i].name, -1) != NULL)
78 if (slaves[i].pci_id != pci_get_devid(controller))
80 child = BUS_ADD_CHILD(bus, 0, slaves[i].name, -1);
82 iicbus_set_addr(child, slaves[i].addr);
86 static device_method_t chromebook_i2c_methods[] = {
87 DEVMETHOD(device_identify, chromebook_i2c_identify),
91 static driver_t chromebook_i2c_driver = {
93 chromebook_i2c_methods,
97 static devclass_t chromebook_i2c_devclass;
99 DRIVER_MODULE(chromebook_i2c, iicbus, chromebook_i2c_driver,
100 chromebook_i2c_devclass, 0, 0);
101 MODULE_VERSION(chromebook_i2c, 1);