[U-Boot-Users] Using a second I2C interface

Ben Warren bwarren at qstreams.com
Fri May 12 20:27:55 CEST 2006


Here's how I've done things in my sandbox:

All public I2C calls take a uchar as the first argument.  Since I2C only
uses 7 bits for addressing, the MSB is unused (at least, at the function
call level.  I know the hardware uses the bit for w/r).  I've
commandeered this bit to denote controller number.  This way, the
existing API doesn't need to be changed, just the drivers that choose to
implement it.  I've modified the MPC8349 driver and the 'iprobe' command
to do this.  To use the other commands, as well as the API itself, I've
just been adding 0x80 manually, but it could be done more nicely like:

#define i2c_wr(bus, dev, ...)  i2c_write((bus)==2 ? dev+0x80 : dev, ...)

Of course, this solution isn't scalable beyond two controllers, but I'm
not sure we need to worry about that.

Any thoughts?

Ben
.   On Fri, 2006-05-12 at 13:00 -0500, Kumar Gala wrote:

> On May 12, 2006, at 9:36 AM, Ben Warren wrote:
> 
> > Hello,
> >
> > The CPU I'm using (MPC8349) has two hardware I2C interfaces, and  
> > I'd like to access the second one in U-boot.  Implementing this  
> > looks easy to me, but I don't want to reinvent the wheel if it's  
> > already been done elsewhere.  Has anyone done this?  If not, I'll  
> > follow up with a proposal.
> 
> Depending on what you want to do, you can cheat and just change the  
> pointer to the 2nd interface.  If you want something more full  
> featured up to the command level then I think some discussion would  
> be required on how the commands should work for specifying which  
> controller to use.
> 
> - kumar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20060512/c33e880b/attachment.htm 


More information about the U-Boot mailing list