summaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2016-06-06 14:26:22 +0300
committerWolfram Sang <wsa@the-dreams.de>2016-07-14 22:25:10 +0900
commit55d38d060e999ca1a3ea6eb132105a0301e4cd04 (patch)
treedb0d07a56dd5af1d74943232e8c53c7a0fb5555d /include/linux/i2c.h
parenta7003b65801e17a19617a509b2dbae3442ddd709 (diff)
downloadlinux-55d38d060e999ca1a3ea6eb132105a0301e4cd04.tar.gz
linux-55d38d060e999ca1a3ea6eb132105a0301e4cd04.tar.bz2
linux-55d38d060e999ca1a3ea6eb132105a0301e4cd04.zip
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>
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r--include/linux/i2c.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index fffdc270ca18..5cde08719fb6 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -766,4 +766,13 @@ static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node
}
#endif /* CONFIG_OF */
+#if IS_ENABLED(CONFIG_ACPI)
+u32 i2c_acpi_find_bus_speed(struct device *dev);
+#else
+static inline u32 i2c_acpi_find_bus_speed(struct device *dev)
+{
+ return 0;
+}
+#endif /* CONFIG_ACPI */
+
#endif /* _LINUX_I2C_H */