From: Ben Warren Date: Fri, 12 May 2006 14:27:55 -0400 Subject: [U-Boot-Users] Using a second I2C interface In-Reply-To: References: <1147444584.16780.84.camel@saruman.qstreams.net> Message-ID: <1147458475.16780.105.camel@saruman.qstreams.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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