[i2c] linux 2.6.20.2 patched from maxim, and i2c
Matt Gessner
mgessner at gmail.com
Wed Apr 18 15:20:23 CEST 2007
Hi, thanks for your reply,
On 4/18/07, Jean Delvare <khali at linux-fr.org> wrote:
>
> Hi Matt,
>
> On Mon, 16 Apr 2007 15:36:31 -0400, Matt Gessner wrote:
> > I've been doing a lot of looking, and haven't found the answer to this
> > question:
> >
> > I have two devices on my AT91RM9200 TWI bus, tlv320 from TI.
> >
> > How do I talk to these two devices? Do I make /dev/i2c-0 and
> /dev/i2c-1?
>
> No. /dev/i2c-* nodes correspond to I2C buses, not I2C devices. If you
> only have the AT91RM9200 TWI bus, it should show as /dev/i2c-0
> (or /dev/i2c/0) as soon as you load the i2c-dev driver.
I thought as much, but decided it would be wise to ask.
> That didn't work. If I just open /dev/i2c-0, when I try to ioctl
> I2C_SLAVE
> > before each write, I get an illegal seek error (turns out I think it's
> > really -EBUSY returned by i2c-dev.c's ioctl function.
>
> The I2C_SLAVE ioctl only needs to be used once, before the first
> message. Then i2c-dev will remember the slave address for all
> subsequent messages, until another I2C_SLAVE ioctl is issued.
>
> That being said, setting I2C_SLAVE shouldn't return an illegal seek
> error. This error message corresponds to ESPIPE and i2c-dev never
> returns that. I suspect you've done something wrong.
I set a breakpoint in the ioctl function. It did return -EBUSY, and that
somehow got translated upwards as an illegal seek. I haven't traced the
code up to see where that happens.
i2c-dev will return -EBUSY if you attempt to set the slave address to
> an address which the kernel is already using. If you know what you're
> doing, you can use the I2C_SLAVE_FORCE ioctl to bypass this check. But
> in general this is a bad idea and you don't want to do that. An I2C
> device should be handled either by a kernel driver, or through i2c-dev,
> not both.
Well, I have two DAC's on this I2C bus, and I'm going to be taking requests
from the user to change volume at any time. I *could* open, ioctl, write,
close, every time, but this seems like a waste. However, given that the cpu
only gets about a maximum 30% load, it's not really a big deal. I'll do it
that way then.
You can use "i2cdetect 0" (from the lm-sensors package) to probe your
> I2C bus and see what devices are present, and whether they are in use
> (UU) or not.
>
> > Or do I have to open only one at a time, set the I2C_SLAVE and do
> everything
> > I want in one shot, close the device, and then open the other one?
>
> You can to pretty much everything you want, the i2c-dev interface is
> very flexible. As long as you set the I2C slave address after each
> open, it should work OK. But ideally you would only close the device
> node when you're completely done, as additional close and open have a
> cost.
Well, I'll never be "completely" done, because as long as the system is
running, there is the possibility that the user will want to change the
volume on the DAC, at which time I'll have to repeat the sequence. But I'm
not very worried about that.
Thanks for your reply.
Regards,
MG
--
> Jean Delvare
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.lm-sensors.org/pipermail/i2c/attachments/20070418/01e0d83e/attachment.html
More information about the i2c
mailing list