aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2015-12-17 07:32:36 -0500
committerWolfram Sang <wsa@the-dreams.de>2015-12-17 14:36:39 -0500
commit54177ccfbe95fcf250a89508a705bfe4706e3b86 (patch)
tree395c72bd98b11a6feee4390d13772d1a48aeb776
parentb7d518e6f4c6d8a0b66effe3bda22417b7dc1e04 (diff)
i2c: make i2c_parse_fw_timings() always visible
This function used to be DT only, so it lived inside a CONFIG_OF block. Now it uses device attributes and must be moved outside of it. No further code changes, only one whitespace improvement. Reported-by: Jim Davis <jim.epost@gmail.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/i2c-core.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b34c412bd2c2..7349b00f4101 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1439,58 +1439,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
1439 } 1439 }
1440} 1440}
1441 1441
1442/**
1443 * i2c_parse_fw_timings - get I2C related timing parameters from firmware
1444 * @dev: The device to scan for I2C timing properties
1445 * @t: the i2c_timings struct to be filled with values
1446 * @use_defaults: bool to use sane defaults derived from the I2C specification
1447 * when properties are not found, otherwise use 0
1448 *
1449 * Scan the device for the generic I2C properties describing timing parameters
1450 * for the signal and fill the given struct with the results. If a property was
1451 * not found and use_defaults was true, then maximum timings are assumed which
1452 * are derived from the I2C specification. If use_defaults is not used, the
1453 * results will be 0, so drivers can apply their own defaults later. The latter
1454 * is mainly intended for avoiding regressions of existing drivers which want
1455 * to switch to this function. New drivers almost always should use the defaults.
1456 */
1457
1458void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_defaults)
1459{
1460 int ret;
1461
1462 memset(t, 0, sizeof(*t));
1463
1464 ret = device_property_read_u32(dev, "clock-frequency", &t->bus_freq_hz);
1465 if (ret && use_defaults)
1466 t->bus_freq_hz = 100000;
1467
1468 ret = device_property_read_u32(dev, "i2c-scl-rising-time-ns", &t->scl_rise_ns);
1469 if (ret && use_defaults) {
1470 if (t->bus_freq_hz <= 100000)
1471 t->scl_rise_ns = 1000;
1472 else if (t->bus_freq_hz <= 400000)
1473 t->scl_rise_ns = 300;
1474 else
1475 t->scl_rise_ns = 120;
1476 }
1477
1478 ret = device_property_read_u32(dev, "i2c-scl-falling-time-ns", &t->scl_fall_ns);
1479 if (ret && use_defaults) {
1480 if (t->bus_freq_hz <= 400000)
1481 t->scl_fall_ns = 300;
1482 else
1483 t->scl_fall_ns = 120;
1484 }
1485
1486 device_property_read_u32(dev, "i2c-scl-internal-delay-ns", &t->scl_int_delay_ns);
1487
1488 ret = device_property_read_u32(dev, "i2c-sda-falling-time-ns", &t->sda_fall_ns);
1489 if (ret && use_defaults)
1490 t->sda_fall_ns = t->scl_fall_ns;
1491}
1492EXPORT_SYMBOL_GPL(i2c_parse_fw_timings);
1493
1494static int of_dev_node_match(struct device *dev, void *data) 1442static int of_dev_node_match(struct device *dev, void *data)
1495{ 1443{
1496 return dev->of_node == data; 1444 return dev->of_node == data;
@@ -1892,6 +1840,58 @@ void i2c_del_adapter(struct i2c_adapter *adap)
1892} 1840}
1893EXPORT_SYMBOL(i2c_del_adapter); 1841EXPORT_SYMBOL(i2c_del_adapter);
1894 1842
1843/**
1844 * i2c_parse_fw_timings - get I2C related timing parameters from firmware
1845 * @dev: The device to scan for I2C timing properties
1846 * @t: the i2c_timings struct to be filled with values
1847 * @use_defaults: bool to use sane defaults derived from the I2C specification
1848 * when properties are not found, otherwise use 0
1849 *
1850 * Scan the device for the generic I2C properties describing timing parameters
1851 * for the signal and fill the given struct with the results. If a property was
1852 * not found and use_defaults was true, then maximum timings are assumed which
1853 * are derived from the I2C specification. If use_defaults is not used, the
1854 * results will be 0, so drivers can apply their own defaults later. The latter
1855 * is mainly intended for avoiding regressions of existing drivers which want
1856 * to switch to this function. New drivers almost always should use the defaults.
1857 */
1858
1859void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_defaults)
1860{
1861 int ret;
1862
1863 memset(t, 0, sizeof(*t));
1864
1865 ret = device_property_read_u32(dev, "clock-frequency", &t->bus_freq_hz);
1866 if (ret && use_defaults)
1867 t->bus_freq_hz = 100000;
1868
1869 ret = device_property_read_u32(dev, "i2c-scl-rising-time-ns", &t->scl_rise_ns);
1870 if (ret && use_defaults) {
1871 if (t->bus_freq_hz <= 100000)
1872 t->scl_rise_ns = 1000;
1873 else if (t->bus_freq_hz <= 400000)
1874 t->scl_rise_ns = 300;
1875 else
1876 t->scl_rise_ns = 120;
1877 }
1878
1879 ret = device_property_read_u32(dev, "i2c-scl-falling-time-ns", &t->scl_fall_ns);
1880 if (ret && use_defaults) {
1881 if (t->bus_freq_hz <= 400000)
1882 t->scl_fall_ns = 300;
1883 else
1884 t->scl_fall_ns = 120;
1885 }
1886
1887 device_property_read_u32(dev, "i2c-scl-internal-delay-ns", &t->scl_int_delay_ns);
1888
1889 ret = device_property_read_u32(dev, "i2c-sda-falling-time-ns", &t->sda_fall_ns);
1890 if (ret && use_defaults)
1891 t->sda_fall_ns = t->scl_fall_ns;
1892}
1893EXPORT_SYMBOL_GPL(i2c_parse_fw_timings);
1894
1895/* ------------------------------------------------------------------------- */ 1895/* ------------------------------------------------------------------------- */
1896 1896
1897int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *)) 1897int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))