diff options
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 50cbab4b62b0..08be0d21864c 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -45,6 +45,7 @@ struct i2c_adapter; | |||
45 | struct i2c_client; | 45 | struct i2c_client; |
46 | struct i2c_driver; | 46 | struct i2c_driver; |
47 | union i2c_smbus_data; | 47 | union i2c_smbus_data; |
48 | struct i2c_board_info; | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * 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 |
@@ -94,15 +95,33 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, | |||
94 | u8 command, u8 length, | 95 | u8 command, u8 length, |
95 | const u8 *values); | 96 | const u8 *values); |
96 | 97 | ||
97 | /* | 98 | /** |
98 | * A driver is capable of handling one or more physical devices present on | 99 | * struct i2c_driver - represent an I2C device driver |
99 | * I2C adapters. This information is used to inform the driver of adapter | 100 | * @class: What kind of i2c device we instantiate (for detect) |
100 | * 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) | ||
101 | * | 104 | * |
102 | * 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. |
103 | * 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. | ||
104 | */ | 124 | */ |
105 | |||
106 | struct i2c_driver { | 125 | struct i2c_driver { |
107 | int id; | 126 | int id; |
108 | unsigned int class; | 127 | unsigned int class; |
@@ -142,6 +161,11 @@ struct i2c_driver { | |||
142 | 161 | ||
143 | struct device_driver driver; | 162 | struct device_driver driver; |
144 | 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; | ||
145 | }; | 169 | }; |
146 | #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) |
147 | 171 | ||
@@ -157,6 +181,7 @@ struct i2c_driver { | |||
157 | * @dev: Driver model device node for the slave. | 181 | * @dev: Driver model device node for the slave. |
158 | * @irq: indicates the IRQ generated by this device (if any) | 182 | * @irq: indicates the IRQ generated by this device (if any) |
159 | * @list: list of active/busy clients (DEPRECATED) | 183 | * @list: list of active/busy clients (DEPRECATED) |
184 | * @detected: member of an i2c_driver.clients list | ||
160 | * @released: used to synchronize client releases & detaches and references | 185 | * @released: used to synchronize client releases & detaches and references |
161 | * | 186 | * |
162 | * 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 |
@@ -174,6 +199,7 @@ struct i2c_client { | |||
174 | struct device dev; /* the device structure */ | 199 | struct device dev; /* the device structure */ |
175 | int irq; /* irq issued by device */ | 200 | int irq; /* irq issued by device */ |
176 | struct list_head list; /* DEPRECATED */ | 201 | struct list_head list; /* DEPRECATED */ |
202 | struct list_head detected; | ||
177 | struct completion released; | 203 | struct completion released; |
178 | }; | 204 | }; |
179 | #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) |