summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-09-09 11:15:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-09-09 15:44:30 +0200
commitf1bdb261ca5e2af8bdcacb4bd1a884865b280c7d (patch)
tree5fe6a940457bfc2497536bfa1d784517a759949c /include
parentfe2a71d7f85a811c29586de99ced12ef89ad9e95 (diff)
downloadbarebox-f1bdb261ca5e2af8bdcacb4bd1a884865b280c7d.tar.gz
barebox-f1bdb261ca5e2af8bdcacb4bd1a884865b280c7d.tar.xz
i2c: port Linux i2c_parse_fw_timings
Linux has a generic function for extracting i2c timings parameters from device-associated firmware nodes. Port this function to barebox, but have it only work on device tree nodes for now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/i2c/i2c.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 17b507ca22..a694e4ab2f 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -239,6 +239,24 @@ struct i2c_board_info {
};
/**
+ * struct i2c_timings - I2C timing information
+ * @bus_freq_hz: the bus frequency in Hz
+ * @scl_rise_ns: time SCL signal takes to rise in ns; t(r) in the I2C specification
+ * @scl_fall_ns: time SCL signal takes to fall in ns; t(f) in the I2C specification
+ * @scl_int_delay_ns: time IP core additionally needs to setup SCL in ns
+ * @sda_fall_ns: time SDA signal takes to fall in ns; t(f) in the I2C specification
+ * @sda_hold_ns: time IP core additionally needs to hold SDA in ns
+ */
+struct i2c_timings {
+ u32 bus_freq_hz;
+ u32 scl_rise_ns;
+ u32 scl_fall_ns;
+ u32 scl_int_delay_ns;
+ u32 sda_fall_ns;
+ u32 sda_hold_ns;
+};
+
+/**
* I2C_BOARD_INFO - macro used to list an i2c device and its address
* @dev_type: identifies the device type
* @dev_addr: the device's address on the bus.
@@ -264,6 +282,8 @@ extern int i2c_add_numbered_adapter(struct i2c_adapter *adapter);
struct i2c_adapter *i2c_get_adapter(int busnum);
struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
+void i2c_parse_fw_timings(struct device_d *dev, struct i2c_timings *t, bool use_defaults);
+
extern struct list_head i2c_adapter_list;
#define for_each_i2c_adapter(adap) \
list_for_each_entry(adap, &i2c_adapter_list, list)