summaryrefslogtreecommitdiffstats
path: root/include/i2c
diff options
context:
space:
mode:
authorJan Luebbe <jluebbe@debian.org>2015-07-30 16:52:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-08-20 07:47:14 +0200
commite1944fb6b2c5bbdc6d8927e19cdf68aab6e92760 (patch)
tree27be9cb3fc2f4563f1cf2da1e86d3d08f383c145 /include/i2c
parente87360ad056bce90318aaa2da1627969922d9053 (diff)
downloadbarebox-e1944fb6b2c5bbdc6d8927e19cdf68aab6e92760.tar.gz
barebox-e1944fb6b2c5bbdc6d8927e19cdf68aab6e92760.tar.xz
i2c: add bus recovery infrastructure
This is based on the code introduced to the kernel in 5f9296ba21b3c395e53dd84e7ff9578f97f24295. Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/i2c')
-rw-r--r--include/i2c/i2c.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 4696f43e31..12e4827755 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -19,6 +19,8 @@
#include <driver.h>
#include <linux/types.h>
+struct i2c_adapter;
+
/*
* struct i2c_platform_data - structure of platform data for MXC I2C driver
* @param bitrate Bus speed measured in Hz
@@ -61,6 +63,47 @@ struct i2c_msg {
__u16 len; /**< Number of data bytes in @buf being read from or written to the I2C slave address. */
};
+/**
+ * struct i2c_bus_recovery_info - I2C bus recovery information
+ * @recover_bus: Recover routine. Either pass driver's recover_bus() routine, or
+ * i2c_generic_scl_recovery() or i2c_generic_gpio_recovery().
+ * @get_scl: This gets current value of SCL line. Mandatory for generic SCL
+ * recovery. Used internally for generic GPIO recovery.
+ * @set_scl: This sets/clears SCL line. Mandatory for generic SCL recovery. Used
+ * internally for generic GPIO recovery.
+ * @get_sda: This gets current value of SDA line. Optional for generic SCL
+ * recovery. Used internally, if sda_gpio is a valid GPIO, for generic GPIO
+ * recovery.
+ * @prepare_recovery: This will be called before starting recovery. Platform may
+ * configure padmux here for SDA/SCL line or something else they want.
+ * @unprepare_recovery: This will be called after completing recovery. Platform
+ * may configure padmux here for SDA/SCL line or something else they want.
+ * @scl_gpio: gpio number of the SCL line. Only required for GPIO recovery.
+ * @sda_gpio: gpio number of the SDA line. Only required for GPIO recovery.
+ */
+struct i2c_bus_recovery_info {
+ int (*recover_bus)(struct i2c_adapter *);
+
+ int (*get_scl)(struct i2c_adapter *);
+ void (*set_scl)(struct i2c_adapter *, int val);
+ int (*get_sda)(struct i2c_adapter *);
+
+ void (*prepare_recovery)(struct i2c_adapter *);
+ void (*unprepare_recovery)(struct i2c_adapter *);
+
+ /* gpio recovery */
+ int scl_gpio;
+ int sda_gpio;
+};
+
+int i2c_recover_bus(struct i2c_adapter *adap);
+
+/* Generic recovery routines */
+int i2c_get_scl_gpio_value(struct i2c_adapter *adap);
+void i2c_set_scl_gpio_value(struct i2c_adapter *adap, int val);
+int i2c_get_sda_gpio_value(struct i2c_adapter *adap);
+int i2c_generic_gpio_recovery(struct i2c_adapter *adap);
+int i2c_generic_scl_recovery(struct i2c_adapter *adap);
/**
* i2c_adapter is the structure used to identify a physical i2c bus
@@ -74,6 +117,8 @@ struct i2c_adapter {
struct list_head list;
int retries;
void *algo_data;
+
+ struct i2c_bus_recovery_info *bus_recovery_info;
};