i2c: core: Add function for finding the bus speed from ACPI
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Mon, 6 Jun 2016 11:26:22 +0000 (14:26 +0300)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 14 Jul 2016 13:25:10 +0000 (22:25 +0900)
commit55d38d060e999ca1a3ea6eb132105a0301e4cd04
treedb0d07a56dd5af1d74943232e8c53c7a0fb5555d
parenta7003b65801e17a19617a509b2dbae3442ddd709
i2c: core: Add function for finding the bus speed from ACPI

ACPI 5 specification doesn't have property for the I2C bus speed but
I2cSerialBus resource descriptors which define each controller-slave
connection define the maximum speed supported by that connection.

Thus finding the maximum safe speed for the bus is to walk all
I2cSerialBus resources that are associated to I2C controller and use
the speed of slowest connection.

Add function i2c_acpi_find_bus_speed() to the i2c-core that adapter
drivers can call prior registering itself to core.

This implies two-step walk through the I2cSerialBus resources: call to
i2c_acpi_find_bus_speed() does the first scan and finds the safe bus
speed that adapter drivers can set up. Adapter driver registration does
the second scan when i2c-core creates the I2C slaves by calling the
i2c_acpi_register_devices(). In that way the bus speed is set in case
slave device probe gets called during registration and does
communication.

Implement this by reusing the existing ACPI I2C walk routines in the
i2c-core. Extend them so that slowest connection speed is saved during
the walk and I2C slaves are registered only when calling through the
i2c_acpi_register_devices() with the i2c_adapter pointer.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/i2c-core.c
include/linux/i2c.h