summaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2016-08-12 17:02:53 +0300
committerWolfram Sang <wsa@the-dreams.de>2016-08-26 00:42:10 +0200
commit5853b22d96fa786365ff11fe9f008a68a533f043 (patch)
treeb50801019fadf47b6b9efee685e3cc713a15320c /include/linux/i2c.h
parentaec809fc63f61a85e4300bb70081fbe6b492171c (diff)
downloadlinux-5853b22d96fa786365ff11fe9f008a68a533f043.tar.gz
linux-5853b22d96fa786365ff11fe9f008a68a533f043.tar.bz2
linux-5853b22d96fa786365ff11fe9f008a68a533f043.zip
i2c: core: Add function for finding the bus speed from ACPI, take 2
ACPI 5 specification doesn't have property for the I2C bus speed but I2cSerialBus resource descriptor 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 through 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. Previous version commit 55d38d060e99 ("i2c: core: Add function for finding the bus speed from ACPI") got reverted due merge conflicts from commit 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications"). This version is a bit bigger than previous version but is still sharing the lowest and complicated part of I2cSerialBus lookup routines with the existing code. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@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 c1f60a345db7..5b4a3cbe5d7d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -780,4 +780,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 */