staticbool probe_i2c_addr;
module_param(probe_i2c_addr, bool, 0444);
MODULE_PARM_DESC(probe_i2c_addr, "Probe the i801 I2C bus for the accelerometer on models where the address is unknown, this may be dangerous.");
staticint detect_lis3lv02d(struct i2c_adapter *adap, unsignedshort addr)
{ union i2c_smbus_data smbus_data; int err;
dev_info(&adap->dev, "Probing for lis3lv02d on address 0x%02x\n", addr);
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, LIS3_WHO_AM_I,
I2C_SMBUS_BYTE_DATA, &smbus_data); if (err < 0) return 0; /* Not found */
/* valid who-am-i values are from drivers/misc/lis3lv02d/lis3lv02d.c */ switch (smbus_data.byte) { case 0x32: case 0x33: case 0x3a: case 0x3b: break; default:
dev_warn(&adap->dev, "Unknown who-am-i register value 0x%02x\n",
smbus_data.byte); return 0; /* Not found */
}
dev_info(&adap->dev, "Detected lis3lv02d on address 0x%02x, please report this upstream to platform-driver-x86@vger.kernel.org so that a quirk can be added\n",
addr);
return 1; /* Found */
}
staticbool i2c_adapter_is_main_i801(struct i2c_adapter *adap)
{ /* * Only match the main I801 adapter and reject secondary adapters * which names start with "SMBus I801 IDF adapter".
*/ return strstarts(adap->name, "SMBus I801 adapter");
}
/* * bus_for_each_dev() and not i2c_for_each_dev() to avoid * a deadlock when find_i801() calls i2c_get_adapter().
*/
bus_for_each_dev(&i2c_bus_type, NULL, &adap, find_i801); if (!adap) return;
strscpy(info.type, "lis3lv02d", I2C_NAME_SIZE);
if (i2c_addr) {
info.addr = i2c_addr;
i2c_dev = i2c_new_client_device(adap, &info);
} else { /* First try address 0x29 (most used) and then try 0x1d */ staticconstunsignedshort addr_list[] = { 0x29, 0x1d, I2C_CLIENT_END };
switch (action) { case BUS_NOTIFY_ADD_DEVICE:
adap = i2c_verify_adapter(dev); if (!adap) break;
if (i2c_adapter_is_main_i801(adap))
queue_work(system_long_wq, &i2c_work); break; case BUS_NOTIFY_REMOVED_DEVICE:
client = i2c_verify_client(dev); if (!client) break;
/* * First check for a matching platform_device. This protects against * SMO88xx ACPI fwnodes which actually do have an I2C resource, which * will already have an i2c_client instantiated (not a platform_device).
*/
dev = bus_find_device(&platform_bus_type, NULL, smo8800_ids, match_acpi_device_ids); if (!dev) {
pr_debug("No SMO88xx platform-device found\n"); return 0;
}
put_device(dev);
lis3lv02d_dmi_id = dmi_first_match(lis3lv02d_devices); if (!lis3lv02d_dmi_id && !probe_i2c_addr) {
pr_warn("accelerometer is present on SMBus but its address is unknown, skipping registration\n");
pr_info("Pass dell_lis3lv02d.probe_i2c_addr=1 on the kernel command line to probe, this may be dangerous!\n"); return 0;
}
if (lis3lv02d_dmi_id)
i2c_addr = (long)lis3lv02d_dmi_id->driver_data;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.