From f1bdb261ca5e2af8bdcacb4bd1a884865b280c7d Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 9 Sep 2019 11:15:39 +0200 Subject: 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 Signed-off-by: Sascha Hauer --- include/i2c/i2c.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') 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 @@ -238,6 +238,24 @@ struct i2c_board_info { struct device_node *of_node; }; +/** + * 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 @@ -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) -- cgit v1.2.3