[i2c] Doubts related to I2c Subsystem

Jean Delvare khali at linux-fr.org
Sat May 5 22:15:04 CEST 2007


Hi Kishore,

On Thu, 3 May 2007 21:10:31 +0200, kishore kadiyala wrote:
> Can any one please clarify the Following doubts regarding I2c Subsystem
> 
> 1) Regarding I2c-dev interface
>      a)I have  a setup with a codec Chip interfaced with the processor
> through I2c bus.
>         My doubt is when i open a /dev/i2c-0 twice i will be getting a
> file-descriptor say fd1 & fd2.
>         Does fd1 and fd2 mean different clients?

Yes. Each time you open an i2c device node, you get a new client on
that specific i2c bus.

>        If so how can a Single Slave can have different Clients.?

It doesn't. /dev/i2c-0 corresponds to the whole i2c bus #0, not to a
specific slave. You can have one client per slave device.

>      b) USing Dev interface can I Communicate with two slaves on i2c bus
> interfaced with processor?

Yes, you can. As you described above yourself, just open /dev/i2c-0
twice, so you have one client for each slave device.

> 2)Regarding Chip driver
> 
>         i have a setup with two different slave devices say S1 & S2 on I2c
> bus interface towards processor .
>       Using Chip driver with Slave address mentioned in normal_i2c[] =
> {s1_address,s2_address ,I2C_CLIENT_END };
>        Is it possible to communicate with the 2 slave devices .?

Yes. The i2c core will call your driver's attach_adapter callback when
your driver is loaded, from there you should call i2c_probe with your
address data and your detect function as parameters. This will call
your detect function once for every possible address (if a chip is
found at said address.)

Alternatively, you can use the new i2c probing method, by using static
i2c device declarations in the platform code, or by calling
i2c_new_device(). This is relatively new so there aren't many example
in the kernel tree yet.

>        If not Do I have to write Two different chip drivers for two slaves?

No, you don't. But then it depends if the slaves are the same chip
type. If they are not, then it really doesn't make sense to support
them both in the same driver!

> 3) Regarding Sub system Layering
> 
>           What is the Role of I2c_driver in the Subsytem?

Sorry, I don't understand this question. Please be more precise.

-- 
Jean Delvare



More information about the i2c mailing list