<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.8.1">
</HEAD>
<BODY>
Here's how I've done things in my sandbox:<BR>
<BR>
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:<BR>
<BR>
#define i2c_wr(bus, dev, ...) i2c_write((bus)==2 ? dev+0x80 : dev, ...)<BR>
<BR>
Of course, this solution isn't scalable beyond two controllers, but I'm not sure we need to worry about that.<BR>
<BR>
Any thoughts?<BR>
<BR>
Ben<BR>
. On Fri, 2006-05-12 at 13:00 -0500, Kumar Gala wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">On May 12, 2006, at 9:36 AM, Ben Warren wrote:</FONT>
<FONT COLOR="#000000">> Hello,</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> The CPU I'm using (MPC8349) has two hardware I2C interfaces, and </FONT>
<FONT COLOR="#000000">> I'd like to access the second one in U-boot. Implementing this </FONT>
<FONT COLOR="#000000">> looks easy to me, but I don't want to reinvent the wheel if it's </FONT>
<FONT COLOR="#000000">> already been done elsewhere. Has anyone done this? If not, I'll </FONT>
<FONT COLOR="#000000">> follow up with a proposal.</FONT>
<FONT COLOR="#000000">Depending on what you want to do, you can cheat and just change the </FONT>
<FONT COLOR="#000000">pointer to the 2nd interface. If you want something more full </FONT>
<FONT COLOR="#000000">featured up to the command level then I think some discussion would </FONT>
<FONT COLOR="#000000">be required on how the commands should work for specifying which </FONT>
<FONT COLOR="#000000">controller to use.</FONT>
<FONT COLOR="#000000">- kumar</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>