RE: Need help on selecting one (and only one) i2c bus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After some researches I guess I have to use the normal_i2c and ignore
arrays:

static unsigned short normal_i2c[] = { 0x71, I2C_CLIENT_END};
static unsigned short ignore[] = { 0x01, 0x71, 0x02, 0x71, I2C_CLIENT_END};

static struct i2c_client_address_data addr_data = {
    .normal_i2c = normal_i2c,
    .ignore     = ignore,
};

Int the init function I have to allocate a major to the driver, and than add
the I2c driver:
i2c_add_driver(&i2c_my_drv);

After doing that, i2c_my_drv.attach_adapter is called.

Which will call (among others) my probe function, in which I call
i2c_attach_client.


Am I in the right way ?

-----Original Message-----
From: linux-i2c-owner@xxxxxxxxxxxxxxx
[mailto:linux-i2c-owner@xxxxxxxxxxxxxxx] On Behalf Of Jean Delvare
Sent: Tuesday, March 10, 2009 4:31 PM
To: Ayman KHAMOUMA
Cc: linux-i2c@xxxxxxxxxxxxxxx
Subject: Re: Need help on selecting one (and only one) i2c bus

Hi Ayman,

On Mon, 9 Mar 2009 15:52:56 +0100, Ayman KHAMOUMA wrote:
> I'm new on I2C device drivers programming and I'm facing a little problem,
I can't find how to select my i2c-0 bus (I have 3 of them: i2c-0, i2c-1 and
i2c-2) I'd like my probe function to probe only this bus and ignore the
others.
> I guess I can find the solution with the i2c_address_data structure, but I
don't really understand how to use it...

It would help if you would first tell us what kernel version you are using,
what device you are writing a driver for, and what architecture / system
type this is all working on.

> Do I have to use the ignore_range array ?

ignore_range has gone away long ago. The last kernel that had it was
2.6.12.6, released in late August 2005. Are really you using such an old
kernel?

> Once filed, I have nothing to do ?
> 
> The device I want to probe/send data to is located on bus i2c-0 and at 
> the adresses 0x00 to 0x15

I seriously doubt this. Addresses 0x00, 0x01 and 0x02 are very special for
I2C, no device can use them. I suspect you are mixing register addresses
(the map of which is internal and specific to each device) with device
addresses on the bus.

> I guess I have to do:
> static unsigned short ignore_range[] = { 0x00, 0x16, 0xff, 0x01, 0x00, 
> 0xff, 0x02, 0x00, 0xff, I2C_CLIENT_END };
> 
> Am I right ?

No, this is seriously wrong. But I can't tell more without additional
information about what you are trying to achieve in the first place.

--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the
body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at
http://vger.kernel.org/majordomo-info.html

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

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux