[I2C] informations + advice about messages handling

Mylene Josserand Mylene.Josserand at navocap.com
Fri May 24 03:11:09 EDT 2013


Hi all,


I am learning how i2c is working and I read that, to write in an i2c 
register, I need to use the function "i2c_smbus_write_byte_data".
I wanted to know how the message are handled by using this function. If 
I use this function to talk with 2 different i2d devices, how it will 
handle "message collision" ? should I have to add a kind of mutex on the 
access of the i2c bus ?
Is it possible that the message destined for one device is sent to 
another one ? Or a "mix" of messages is impossible ?

I have read that this function "i2c_smbus_write_byte_data" uses 
"i2c_smbus_xfer" which uses "i2c_lock_adapter".
In this function, there is a mutex so I thought that it will handle it 
but it says "Get exclusive access to an I2C bus segment". What is 
exactly an I2C segment ? Is it the device we are talking about ? Or is 
it the use of the i2c bus ?

I will certainly have to create an i2c driver and I would like to know 
if this "collision" handling (if it is handled) is done in old kernel 
(2.6.32) or is it handled only in new kernel versions ?

If you have any documentation on how the i2c messages are handled in 
case of different devices uses, it will help me a lot ! I will search in 
the kernel documentation but there is many files about i2c.
And if you know a good i2c driver that I can use as an example to design 
mine, it will be great !


Thank you in advance,

-- 
Mylène JOSSERAND



More information about the Kernelnewbies mailing list