aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r--include/linux/i2c.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index d0c4db7b4872..e988fa935b3c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -125,7 +125,6 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
125 * struct i2c_driver - represent an I2C device driver 125 * struct i2c_driver - represent an I2C device driver
126 * @class: What kind of i2c device we instantiate (for detect) 126 * @class: What kind of i2c device we instantiate (for detect)
127 * @attach_adapter: Callback for bus addition (deprecated) 127 * @attach_adapter: Callback for bus addition (deprecated)
128 * @detach_adapter: Callback for bus removal (deprecated)
129 * @probe: Callback for device binding 128 * @probe: Callback for device binding
130 * @remove: Callback for device unbinding 129 * @remove: Callback for device unbinding
131 * @shutdown: Callback for device shutdown 130 * @shutdown: Callback for device shutdown
@@ -162,12 +161,10 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
162struct i2c_driver { 161struct i2c_driver {
163 unsigned int class; 162 unsigned int class;
164 163
165 /* Notifies the driver that a new bus has appeared or is about to be 164 /* Notifies the driver that a new bus has appeared. You should avoid
166 * removed. You should avoid using this, it will be removed in a 165 * using this, it will be removed in a near future.
167 * near future.
168 */ 166 */
169 int (*attach_adapter)(struct i2c_adapter *) __deprecated; 167 int (*attach_adapter)(struct i2c_adapter *) __deprecated;
170 int (*detach_adapter)(struct i2c_adapter *) __deprecated;
171 168
172 /* Standard driver model interfaces */ 169 /* Standard driver model interfaces */
173 int (*probe)(struct i2c_client *, const struct i2c_device_id *); 170 int (*probe)(struct i2c_client *, const struct i2c_device_id *);
@@ -370,6 +367,45 @@ struct i2c_algorithm {
370 u32 (*functionality) (struct i2c_adapter *); 367 u32 (*functionality) (struct i2c_adapter *);
371}; 368};
372 369
370/**
371 * struct i2c_bus_recovery_info - I2C bus recovery information
372 * @recover_bus: Recover routine. Either pass driver's recover_bus() routine, or
373 * i2c_generic_scl_recovery() or i2c_generic_gpio_recovery().
374 * @get_scl: This gets current value of SCL line. Mandatory for generic SCL
375 * recovery. Used internally for generic GPIO recovery.
376 * @set_scl: This sets/clears SCL line. Mandatory for generic SCL recovery. Used
377 * internally for generic GPIO recovery.
378 * @get_sda: This gets current value of SDA line. Optional for generic SCL
379 * recovery. Used internally, if sda_gpio is a valid GPIO, for generic GPIO
380 * recovery.
381 * @prepare_recovery: This will be called before starting recovery. Platform may
382 * configure padmux here for SDA/SCL line or something else they want.
383 * @unprepare_recovery: This will be called after completing recovery. Platform
384 * may configure padmux here for SDA/SCL line or something else they want.
385 * @scl_gpio: gpio number of the SCL line. Only required for GPIO recovery.
386 * @sda_gpio: gpio number of the SDA line. Only required for GPIO recovery.
387 */
388struct i2c_bus_recovery_info {
389 int (*recover_bus)(struct i2c_adapter *);
390
391 int (*get_scl)(struct i2c_adapter *);
392 void (*set_scl)(struct i2c_adapter *, int val);
393 int (*get_sda)(struct i2c_adapter *);
394
395 void (*prepare_recovery)(struct i2c_bus_recovery_info *bri);
396 void (*unprepare_recovery)(struct i2c_bus_recovery_info *bri);
397
398 /* gpio recovery */
399 int scl_gpio;
400 int sda_gpio;
401};
402
403int i2c_recover_bus(struct i2c_adapter *adap);
404
405/* Generic recovery routines */
406int i2c_generic_gpio_recovery(struct i2c_adapter *adap);
407int i2c_generic_scl_recovery(struct i2c_adapter *adap);
408
373/* 409/*
374 * i2c_adapter is the structure used to identify a physical i2c bus along 410 * i2c_adapter is the structure used to identify a physical i2c bus along
375 * with the access algorithms necessary to access it. 411 * with the access algorithms necessary to access it.
@@ -393,6 +429,8 @@ struct i2c_adapter {
393 429
394 struct mutex userspace_clients_lock; 430 struct mutex userspace_clients_lock;
395 struct list_head userspace_clients; 431 struct list_head userspace_clients;
432
433 struct i2c_bus_recovery_info *bus_recovery_info;
396}; 434};
397#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 435#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
398 436
@@ -450,7 +488,7 @@ void i2c_unlock_adapter(struct i2c_adapter *);
450 */ 488 */
451#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 489#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
452extern int i2c_add_adapter(struct i2c_adapter *); 490extern int i2c_add_adapter(struct i2c_adapter *);
453extern int i2c_del_adapter(struct i2c_adapter *); 491extern void i2c_del_adapter(struct i2c_adapter *);
454extern int i2c_add_numbered_adapter(struct i2c_adapter *); 492extern int i2c_add_numbered_adapter(struct i2c_adapter *);
455 493
456extern int i2c_register_driver(struct module *, struct i2c_driver *); 494extern int i2c_register_driver(struct module *, struct i2c_driver *);