Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758545Ab3EXHWm (ORCPT ); Fri, 24 May 2013 03:22:42 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:40768 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753211Ab3EXHWl convert rfc822-to-8bit (ORCPT ); Fri, 24 May 2013 03:22:41 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 24 May 2013 12:52:40 +0530 Message-ID: Subject: Re: [I2C] informations + advice about messages handling From: anish singh To: Mylene Josserand Cc: kernelnewbies , Linux I2C , linux-kernel-mail , Jean Delvare , Arnd Bergmann , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2555 Lines: 58 On Fri, May 24, 2013 at 12:41 PM, Mylene Josserand wrote: > 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". Only in case your device is smbus compliant. > 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 Message collision and detection is the job of i2c controller and if I am not wrong you are writing a chip driver. > 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 ? It is not possible as the data contains the chip address which is unique.7/10 bit mode addressing is used for addresses. > > 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 ? Don't know what you are referring here. > > 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 ? AFAIK collision handling and detection was not supported till now in linux kernel until recently but I think this patch is doing that. I may be wrong but I didn't see collision handling in earlier linux kernels. http://thread.gmane.org/gmane.linux.kernel/1410276 > > 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 > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/