aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/i2c/writing-clients
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/i2c/writing-clients')
-rw-r--r--Documentation/i2c/writing-clients38
1 files changed, 38 insertions, 0 deletions
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 54255fd68ec7..e62fbfa1282d 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -200,6 +200,44 @@ device typing support in the hardware. The driver and module name should
200match, so hotplug/coldplug mechanisms will modprobe the driver. 200match, so hotplug/coldplug mechanisms will modprobe the driver.
201 201
202 202
203Device Creation (Standard driver model)
204---------------------------------------
205
206If you know for a fact that an I2C device is connected to a given I2C bus,
207you can instantiate that device by simply filling an i2c_board_info
208structure with the device address and driver name, and calling
209i2c_new_device(). This will create the device, then the driver core will
210take care of finding the right driver and will call its probe() method.
211If a driver supports different device types, you can specify the type you
212want using the type field. You can also specify an IRQ and platform data
213if needed.
214
215Sometimes you know that a device is connected to a given I2C bus, but you
216don't know the exact address it uses. This happens on TV adapters for
217example, where the same driver supports dozens of slightly different
218models, and I2C device addresses change from one model to the next. In
219that case, you can use the i2c_new_probed_device() variant, which is
220similar to i2c_new_device(), except that it takes an additional list of
221possible I2C addresses to probe. A device is created for the first
222responsive address in the list. If you expect more than one device to be
223present in the address range, simply call i2c_new_probed_device() that
224many times.
225
226The call to i2c_new_device() or i2c_new_probed_device() typically happens
227in the I2C bus driver. You may want to save the returned i2c_client
228reference for later use.
229
230
231Device Deletion (Standard driver model)
232---------------------------------------
233
234Each I2C device which has been created using i2c_new_device() or
235i2c_new_probed_device() can be unregistered by calling
236i2c_unregister_device(). If you don't call it explicitly, it will be
237called automatically before the underlying I2C bus itself is removed, as a
238device can't survive its parent in the device driver model.
239
240
203Legacy Driver Binding Model 241Legacy Driver Binding Model
204--------------------------- 242---------------------------
205 243