diff options
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index fb9af6a0fe9c..08be0d21864c 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <linux/sched.h> /* for completion */ | 35 | #include <linux/sched.h> /* for completion */ |
36 | #include <linux/mutex.h> | 36 | #include <linux/mutex.h> |
37 | 37 | ||
38 | extern struct bus_type i2c_bus_type; | ||
39 | |||
38 | /* --- General options ------------------------------------------------ */ | 40 | /* --- General options ------------------------------------------------ */ |
39 | 41 | ||
40 | struct i2c_msg; | 42 | struct i2c_msg; |
@@ -43,6 +45,7 @@ struct i2c_adapter; | |||
43 | struct i2c_client; | 45 | struct i2c_client; |
44 | struct i2c_driver; | 46 | struct i2c_driver; |
45 | union i2c_smbus_data; | 47 | union i2c_smbus_data; |
48 | struct i2c_board_info; | ||
46 | 49 | ||
47 | /* | 50 | /* |
48 | * The master routines are the ones normally used to transmit data to devices | 51 | * The master routines are the ones normally used to transmit data to devices |
@@ -69,9 +72,8 @@ extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, | |||
69 | union i2c_smbus_data * data); | 72 | union i2c_smbus_data * data); |
70 | 73 | ||
71 | /* Now follow the 'nice' access routines. These also document the calling | 74 | /* Now follow the 'nice' access routines. These also document the calling |
72 | conventions of smbus_access. */ | 75 | conventions of i2c_smbus_xfer. */ |
73 | 76 | ||
74 | extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value); | ||
75 | extern s32 i2c_smbus_read_byte(struct i2c_client * client); | 77 | extern s32 i2c_smbus_read_byte(struct i2c_client * client); |
76 | extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); | 78 | extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); |
77 | extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); | 79 | extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); |
@@ -93,15 +95,33 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, | |||
93 | u8 command, u8 length, | 95 | u8 command, u8 length, |
94 | const u8 *values); | 96 | const u8 *values); |
95 | 97 | ||
96 | /* | 98 | /** |
97 | * A driver is capable of handling one or more physical devices present on | 99 | * struct i2c_driver - represent an I2C device driver |
98 | * I2C adapters. This information is used to inform the driver of adapter | 100 | * @class: What kind of i2c device we instantiate (for detect) |
99 | * events. | 101 | * @detect: Callback for device detection |
102 | * @address_data: The I2C addresses to probe, ignore or force (for detect) | ||
103 | * @clients: List of detected clients we created (for i2c-core use only) | ||
100 | * | 104 | * |
101 | * The driver.owner field should be set to the module owner of this driver. | 105 | * The driver.owner field should be set to the module owner of this driver. |
102 | * The driver.name field should be set to the name of this driver. | 106 | * The driver.name field should be set to the name of this driver. |
107 | * | ||
108 | * For automatic device detection, both @detect and @address_data must | ||
109 | * be defined. @class should also be set, otherwise only devices forced | ||
110 | * with module parameters will be created. The detect function must | ||
111 | * fill at least the name field of the i2c_board_info structure it is | ||
112 | * handed upon successful detection, and possibly also the flags field. | ||
113 | * | ||
114 | * If @detect is missing, the driver will still work fine for enumerated | ||
115 | * devices. Detected devices simply won't be supported. This is expected | ||
116 | * for the many I2C/SMBus devices which can't be detected reliably, and | ||
117 | * the ones which can always be enumerated in practice. | ||
118 | * | ||
119 | * The i2c_client structure which is handed to the @detect callback is | ||
120 | * not a real i2c_client. It is initialized just enough so that you can | ||
121 | * call i2c_smbus_read_byte_data and friends on it. Don't do anything | ||
122 | * else with it. In particular, calling dev_dbg and friends on it is | ||
123 | * not allowed. | ||
103 | */ | 124 | */ |
104 | |||
105 | struct i2c_driver { | 125 | struct i2c_driver { |
106 | int id; | 126 | int id; |
107 | unsigned int class; | 127 | unsigned int class; |
@@ -141,6 +161,11 @@ struct i2c_driver { | |||
141 | 161 | ||
142 | struct device_driver driver; | 162 | struct device_driver driver; |
143 | const struct i2c_device_id *id_table; | 163 | const struct i2c_device_id *id_table; |
164 | |||
165 | /* Device detection callback for automatic device creation */ | ||
166 | int (*detect)(struct i2c_client *, int kind, struct i2c_board_info *); | ||
167 | const struct i2c_client_address_data *address_data; | ||
168 | struct list_head clients; | ||
144 | }; | 169 | }; |
145 | #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) | 170 | #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) |
146 | 171 | ||
@@ -156,6 +181,7 @@ struct i2c_driver { | |||
156 | * @dev: Driver model device node for the slave. | 181 | * @dev: Driver model device node for the slave. |
157 | * @irq: indicates the IRQ generated by this device (if any) | 182 | * @irq: indicates the IRQ generated by this device (if any) |
158 | * @list: list of active/busy clients (DEPRECATED) | 183 | * @list: list of active/busy clients (DEPRECATED) |
184 | * @detected: member of an i2c_driver.clients list | ||
159 | * @released: used to synchronize client releases & detaches and references | 185 | * @released: used to synchronize client releases & detaches and references |
160 | * | 186 | * |
161 | * An i2c_client identifies a single device (i.e. chip) connected to an | 187 | * An i2c_client identifies a single device (i.e. chip) connected to an |
@@ -171,8 +197,9 @@ struct i2c_client { | |||
171 | struct i2c_adapter *adapter; /* the adapter we sit on */ | 197 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
172 | struct i2c_driver *driver; /* and our access routines */ | 198 | struct i2c_driver *driver; /* and our access routines */ |
173 | struct device dev; /* the device structure */ | 199 | struct device dev; /* the device structure */ |
174 | int irq; /* irq issued by device (or -1) */ | 200 | int irq; /* irq issued by device */ |
175 | struct list_head list; /* DEPRECATED */ | 201 | struct list_head list; /* DEPRECATED */ |
202 | struct list_head detected; | ||
176 | struct completion released; | 203 | struct completion released; |
177 | }; | 204 | }; |
178 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) | 205 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) |
@@ -350,10 +377,11 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) | |||
350 | #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ | 377 | #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ |
351 | #define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ | 378 | #define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ |
352 | #define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */ | 379 | #define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */ |
353 | #define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ | 380 | #define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */ |
354 | #define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */ | 381 | #define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */ |
355 | #define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */ | 382 | #define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */ |
356 | #define I2C_CLASS_SOUND (1<<6) /* sound devices */ | 383 | #define I2C_CLASS_SOUND (1<<6) /* sound devices */ |
384 | #define I2C_CLASS_SPD (1<<7) /* SPD EEPROMs and similar */ | ||
357 | #define I2C_CLASS_ALL (UINT_MAX) /* all of the above */ | 385 | #define I2C_CLASS_ALL (UINT_MAX) /* all of the above */ |
358 | 386 | ||
359 | /* i2c_client_address_data is the struct for holding default client | 387 | /* i2c_client_address_data is the struct for holding default client |
@@ -537,7 +565,7 @@ union i2c_smbus_data { | |||
537 | /* and one more for user-space compatibility */ | 565 | /* and one more for user-space compatibility */ |
538 | }; | 566 | }; |
539 | 567 | ||
540 | /* smbus_access read or write markers */ | 568 | /* i2c_smbus_xfer read or write markers */ |
541 | #define I2C_SMBUS_READ 1 | 569 | #define I2C_SMBUS_READ 1 |
542 | #define I2C_SMBUS_WRITE 0 | 570 | #define I2C_SMBUS_WRITE 0 |
543 | 571 | ||