[i2c] i2c device attached to a SoC bus

Jean Delvare khali at linux-fr.org
Tue Jun 12 22:11:46 CEST 2007


Hi Jorge Luis,

On Mon, 11 Jun 2007 12:22:51 +0200, Jorge Luis Zapata Muga wrote:
> Hi all, ive already posted a message to the v4l ml without luck. I'll
> explain first what im trying to do:
> I have a tvp5150 device attached to a SoC i2c bus and would like to
> use a v4l interface for it, so basically my driver would be an i2c
> driver wrapper. The tvp5150 is already on the kernel with an
> i2c_client interface, and i already coded the SoC bus driver under
> drivers/i2c/busses.
> 
> Now, in order to send commands to the i2c client, i need the
> i2c_client struct, which is stored on the client_register callback of
> the adapter. This approach fits well when the i2c bus is part of the
> device driver i want to code (like in other v4l drivers), but as my
> i2c bus code is generic (i.e there can be any type of i2c client
> attached, not a static list) there's no way to retrieve what clients
> are attached to an adapter from kernel space, but it is possible from
> user space using the i2c-dev interface.

This statement is not correct. You can do more in kernel space than
through i2c-dev, not less. And i2c-dev certainly doesn't give you
access to the attached i2c_clients; it only lets you create new
i2c_clients.

> There is a possible solution i could use: code my v4l driver as an i2c
> adapter,  and reuse my generic i2c bus algo. I would need to export
> some symbols, but still it don't like this approach because some arch
> specific code (like setting up the gpios, clocks, etc) are also
> duplicated and may cause errors.

This sounds like a bad idea, agreed.

> Is some other way? someone with experience on a similar problem?

Admittedly, this isn't a case which is properly supported at the
moment. Multimedia chips are supposed to be on multimedia adapters, not 
random I2C adapters.

Getting a reference to the i2c_client is only one of your problems.
Once you have it, you'll need to send commands to it. The commands are
supposed to come through /dev/videoN, right? So you'll need some code
to register a video device and route the requests to the i2c_client.
The question is, where do you plan to put this code? In your i2c bus
driver? Or in another driver?

I would also like to see your bus driver. How is the i2c adapter
instantiated? Based on a platform device declaration?

-- 
Jean Delvare



More information about the i2c mailing list