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.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 21067b418536..4bae0b72ed3c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -37,6 +37,7 @@
37#include <linux/of.h> /* for struct device_node */ 37#include <linux/of.h> /* for struct device_node */
38 38
39extern struct bus_type i2c_bus_type; 39extern struct bus_type i2c_bus_type;
40extern struct device_type i2c_adapter_type;
40 41
41/* --- General options ------------------------------------------------ */ 42/* --- General options ------------------------------------------------ */
42 43
@@ -108,6 +109,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
108 * @shutdown: Callback for device shutdown 109 * @shutdown: Callback for device shutdown
109 * @suspend: Callback for device suspend 110 * @suspend: Callback for device suspend
110 * @resume: Callback for device resume 111 * @resume: Callback for device resume
112 * @alert: Alert callback, for example for the SMBus alert protocol
111 * @command: Callback for bus-wide signaling (optional) 113 * @command: Callback for bus-wide signaling (optional)
112 * @driver: Device driver model driver 114 * @driver: Device driver model driver
113 * @id_table: List of I2C devices supported by this driver 115 * @id_table: List of I2C devices supported by this driver
@@ -233,6 +235,7 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
233 * @addr: stored in i2c_client.addr 235 * @addr: stored in i2c_client.addr
234 * @platform_data: stored in i2c_client.dev.platform_data 236 * @platform_data: stored in i2c_client.dev.platform_data
235 * @archdata: copied into i2c_client.dev.archdata 237 * @archdata: copied into i2c_client.dev.archdata
238 * @of_node: pointer to OpenFirmware device node
236 * @irq: stored in i2c_client.irq 239 * @irq: stored in i2c_client.irq
237 * 240 *
238 * I2C doesn't actually support hardware probing, although controllers and 241 * I2C doesn't actually support hardware probing, although controllers and
@@ -282,12 +285,18 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info);
282 285
283/* If you don't know the exact address of an I2C device, use this variant 286/* If you don't know the exact address of an I2C device, use this variant
284 * instead, which can probe for device presence in a list of possible 287 * instead, which can probe for device presence in a list of possible
285 * addresses. 288 * addresses. The "probe" callback function is optional. If it is provided,
289 * it must return 1 on successful probe, 0 otherwise. If it is not provided,
290 * a default probing method is used.
286 */ 291 */
287extern struct i2c_client * 292extern struct i2c_client *
288i2c_new_probed_device(struct i2c_adapter *adap, 293i2c_new_probed_device(struct i2c_adapter *adap,
289 struct i2c_board_info *info, 294 struct i2c_board_info *info,
290 unsigned short const *addr_list); 295 unsigned short const *addr_list,
296 int (*probe)(struct i2c_adapter *, unsigned short addr));
297
298/* Common custom probe functions */
299extern int i2c_probe_func_quick_read(struct i2c_adapter *, unsigned short addr);
291 300
292/* For devices that use several addresses, use i2c_new_dummy() to make 301/* For devices that use several addresses, use i2c_new_dummy() to make
293 * client handles for the extra addresses. 302 * client handles for the extra addresses.
@@ -360,6 +369,7 @@ struct i2c_adapter {
360 char name[48]; 369 char name[48];
361 struct completion dev_released; 370 struct completion dev_released;
362 371
372 struct mutex userspace_clients_lock;
363 struct list_head userspace_clients; 373 struct list_head userspace_clients;
364}; 374};
365#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 375#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
@@ -374,23 +384,16 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
374 dev_set_drvdata(&dev->dev, data); 384 dev_set_drvdata(&dev->dev, data);
375} 385}
376 386
377/** 387static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
378 * i2c_lock_adapter - Prevent access to an I2C bus segment
379 * @adapter: Target I2C bus segment
380 */
381static inline void i2c_lock_adapter(struct i2c_adapter *adapter)
382{ 388{
383 rt_mutex_lock(&adapter->bus_lock); 389 return adapter->dev.parent != NULL
390 && adapter->dev.parent->bus == &i2c_bus_type
391 && adapter->dev.parent->type == &i2c_adapter_type;
384} 392}
385 393
386/** 394/* Adapter locking functions, exported for shared pin cases */
387 * i2c_unlock_adapter - Reauthorize access to an I2C bus segment 395void i2c_lock_adapter(struct i2c_adapter *);
388 * @adapter: Target I2C bus segment 396void i2c_unlock_adapter(struct i2c_adapter *);
389 */
390static inline void i2c_unlock_adapter(struct i2c_adapter *adapter)
391{
392 rt_mutex_unlock(&adapter->bus_lock);
393}
394 397
395/*flags for the client struct: */ 398/*flags for the client struct: */
396#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ 399#define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */