Skip to contentSkip to conversation

i2c: Document the different ways to instantiate i2c devices

PATCH In review Jean Delvare 3 participants 3 messages Mar 9, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: Document the different ways to instantiate i2c devices

On popular demand, here comes some documentation about how to instantiate i2c devices in the new (standard) i2c device driver binding model.

I have also clarified how the class bitfield lets driver authors control which buses are probed in the auto-detect case, and warned more loudly against the abuse of this method.

Cc Michael Lawnick <[email protected]>
Cc Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]>
---
 Documentation/i2c/instantiating-devices |  167 +++++++++++++++++++++++++++++++
 Documentation/i2c/writing-clients       |   19 ++-
 2 files changed, 182 insertions(+), 4 deletions(-)
Documentation/i2c/writing-clients +15 -4
@@ -207,15 +207,26 @@ You simply have to define a detect callb
 identify supported devices (returning 0 for supported ones and -ENODEV
 for unsupported ones), a list of addresses to probe, and a device type
 (or class) so that only I2C buses which may have that type of device
-connected (and not otherwise enumerated) will be probed.  The i2c
-core will then call you back as needed and will instantiate a device
-for you for every successful detection.
+connected (and not otherwise enumerated) will be probed.  For example,
+a driver for a hardware monitoring chip for which auto-detection is
+needed would set its class to I2C_CLASS_HWMON, and only I2C adapters
+with a class including I2C_CLASS_HWMON would be probed by this driver.
+Note that the absence of matching classes does not prevent the use of
+a device of that type on the given I2C adapter.  All it prevents is
+auto-detection; explicit instantiation of devices is still possible.
 
 Note that this mechanism is purely optional and not suitable for all
 devices.  You need some reliable way to identify the supported devices
 (typically using device-specific, dedicated identification registers),
 otherwise misdetections are likely to occur and things can get wrong
-quickly.
+quickly.  Keep in mind that the I2C protocol doesn't include any
+standard way to detect the presence of a chip at a given address, let
+alone a standard way to identify devices.  Even worse is the lack of
+semantics associated to bus transfers, which means that the same
+transfer can be seen as a read operation by a chip and as a write
+operation by another chip.  For these reasons, explicit device
+instantiation should always be preferred to auto-detection where
+possible.
 
 
 Device Deletion
Documentation/i2c/instantiating-devices new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Jean Delvare said the following:

Quoted 11 lines

On popular demand, here comes some documentation about how to instantiate i2c devices in the new (standard) i2c device driver binding model.

I have also clarified how the class bitfield lets driver authors control which buses are probed in the auto-detect case, and warned more loudly against the abuse of this method.

Cc Michael Lawnick <[email protected]>
Cc Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]>

Reads fine,

Acked-by
#3 lore raw
Quoted 9 lines · On Monday 09 March 2009 15:17:00 Michael Lawnick wrote:

Jean Delvare said the following:

Quoted 8 lines

On popular demand, here comes some documentation about how to instantiate i2c devices in the new (standard) i2c device driver binding model.

I have also clarified how the class bitfield lets driver authors control which buses are probed in the auto-detect case, and warned more loudly against the abuse of this method.

Quoted 7 lines
Quoted 3 lines
Cc Michael Lawnick <[email protected]>
Cc Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]>

Reads fine,

Ditto,

Thanks!

Hans

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG