i2c multi-master mode
Hi!
I am in need of an MPC5200 I2C driver which operates in multi-master mode. My immediate need is for the MPC5200, but I'll be happy with mods to the main I2C tree which allow me to use any supported device in multi-master mode...
..and, since I haven't found anything in the tree to do this, I am currently hacking *my own* changes into the Denx 2.4.25 I2C driver "kit".
I've spoken via email to Simon Vogl, who recommends that I use an ioctl-based command system to control my device. Yes, this would work, but would be specific to the MPC5200... and I may have to support multimaster mode on the MPC8260/8270 in the future.
So, being a pedantic sort, I'm leaning towards changing "struct i2c_algorithm" and adding " int (*slave_xfer)" to be symmetrical with the "int (*master_xfer)" already in place. I know this means that I'll be "changing the world", but I'm really only interested in my own needs right now :-) LOL
This change would required a retrofit to all of the current I2C drivers in the Denx kit (the base I'm working from). The retrofit would be a NULL in each non-5200-based driver's i2c_algorithm initialization data to provide the "unsupported" placeholder for the new function. This is a quickie change that I can roll into all of the drivers I'm not working on... but, like I said, I'm really only interested in *MY* driver... :-)
I also know that I'll need to add the underlying support for the slave_xfer code to all of the internal routines within the I2C kit so that interrupt handlers and other top-down function calls work properly. This is something I'm quite willing to do... ...my driver... yada yada... :-)
Unless, of course, someone has already implemented multimaster mode handlers for the I2C kit so I can operate a master device in slave mode until it needs to do a transmit...
Thanks!!!
\but
--
Burt Janz
603.880.0482
[email protected]
www.ccsneinc.com/bjanz
Quoted 4 lines · Burt Janz
Precisely. I don't expect to be operating in both modes simultaneously on the same port... but, since the MPC5200 does have 2 I2C ports, it is quite possible that one might be in "slave" and the other in "master" at the same time.
Just so you know, I2C on the MPC5200 has been discussed a few times on the linuxppc-embedded list recently. My driver for MPC107/824x/85xx/52xx is in Greg KH's queue and should go to Linus sometime after 2.6.8 comes out. The MPC5200 requires further patches to add the correct OCP entries; Sylvain Munaut is preparing these. The driver does have some problems with interrupts on MPC5200, but I'm told it works correctly in polled mode.
See the archive:
http://lists.linuxppc.org/linuxppc-embedded/200407/msg00388.html
and mail me if you want to see the tidied version.
- Adrian Cox
Humboldt Solutions Ltd.
Hello Burt:
Quoted 12 lines · Burt Janz
I am in need of an MPC5200 I2C driver which operates in multi-master mode. My immediate need is for the MPC5200, but I'll be happy with mods to the main I2C tree which allow me to use any supported device in multi-master mode...
..and, since I haven't found anything in the tree to do this, I am currently hacking *my own* changes into the Denx 2.4.25 I2C driver "kit".
I've spoken via email to Simon Vogl, who recommends that I use an ioctl-based command system to control my device. Yes, this would work, but would be specific to the MPC5200... and I may have to support multimaster mode on the MPC8260/8270 in the future.
Quoted 4 lines
So, being a pedantic sort, I'm leaning towards changing "struct
i2c_algorithm" and adding " int (*slave_xfer)" to be symmetrical with the "int (*master_xfer)" already in place. I know this means that I'll be "changing the world", but I'm really only interested in my own needs right now :-) LOL
First of all, you are confusing some terms. I2C is a multi-master bus, period. There is no such multi-master "mode". All of our i2c host adapter drivers should operate properly on a bus with other masters - if not that's a bug.
I think you just want to add slave support to i2c host adapters.
On page 7 of the Philips I2C bus specification (V2.1) [1] there is a table of terms, a diagram, and some text that will make this clear. It is required reading especially for pedants. :)
Quoted 6 lines
This change would required a retrofit to all of the current I2C drivers in the Denx kit (the base I'm working from). The retrofit would be a NULL in each non-5200-based driver's
i2c_algorithminitialization data to provide the "unsupported" placeholder for the new function. This is a quickie change that I can roll into all of the drivers I'm not working on... but, like I said, I'm really only interested in *MY* driver... :-)
It's the first I've heard of the Denx kit. What is *it* based on? What we have in CVS is somewhat different from what's in official 2.4, and they're not likely to ever get back in sync.
Have you seen our CVS? There are already *slave_send and *slave_recv place-holders. Not in use, AFAIK; also not sure why not *slave_xfer as you mention.
Quoted 8 lines
I also know that I'll need to add the underlying support for the
slave_xfercode to all of the internal routines within the I2C kit so that interrupt handlers and other top-down function calls work properly. This is something I'm quite willing to do... ...my driver... yada yada... :-)Unless, of course, someone has already implemented multimaster mode handlers for the I2C kit so I can operate a master device in slave mode until it needs to do a transmit...
Again with the terminology. :) I think you're asking if someone has implemented host adapter slave support... well, it's in the i2c package TODO list for a long time now. If you're adding support for kernel 2.4, you'll probably be maintaining it yourself - we're not inclined to accept new features, and Marcelo is definitely not accepting patches for I2C.
However, development continues on kernel 2.6. If you come up with something good for 2.4, maybe someone here could port it to 2.6. I.e. whatever you come up with, we'd like to see it... good luck.
[1] http://www.semiconductors.philips.com/buses/i2c/
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 4 lines · Mark M. Hoffman
Hello Burt:
[email protected] bounced, so I scraped this address off the web page in your signature. Check your reply-to?
Very strange... unless the bit-net server was down. Bit-Net is my ISP, but all email is forwarded directly to a postfix server on my own system. Most people reply directly and I get the emails.... I just checked it, and [email protected] caught a test message... hmmm...
I'm behind a firewall here at work, so I have to use the mac.com address to send mail *out*. Replying to [email protected] should work.
Quoted 4 lines
First of all, you are confusing some terms. I2C is a multi-master bus, period. There is no such multi-master "mode". All of our i2c host adapter drivers should operate properly on a bus with other masters - if not that's a bug.
Er, I may not have explained my needs properly.
I am adding support to allow the MPC5200 to operate simultaneously as *both* a master *and* a slave on a bus. It must be able to send commands to the bus when in master mode, receive commands when in slave mode, and reside on the bus with at least one other MPC5200. This would provide a true multi-master
environment: multiple masters which would need to negotiate for control of the bus, but act as slaves when not acting as masters.
Quoted 1 line
I think you just want to add slave support to i2c host adapters.
If the above fits, then -- yes: the device will be in slave mode and responding to requests, but will occasionally *originate* commands as a master on a bus with at least one other master.
I'm not trying to quibble -- I'm just trying to explain my needs as clearly as I can...
Quoted 3 lines
On page 7 of the Philips I2C bus specification (V2.1) [1] there is a table of terms, a diagram, and some text that will make this clear. It is required reading especially for pedants. :)
Yeh, I got the doc right here... :-)
[snip]
Quoted 3 lines
It's the first I've heard of the Denx kit. What is *it* based on? What we have in CVS is somewhat different from what's in official 2.4, and they're not likely to ever get back in sync.
Denx supports the PPC architecture, not the x86 architecture. The current kit is based on 2.4.25.
Quoted 3 lines
Have you seen our CVS? There are already
*slave_sendand*slave_recvplace-holders. Not in use, AFAIK; also not sure why not*slave_xferas you mention.
I have not seen your CVS.
In my exploration of the 2.4.25 kernel, I did find the slave_send and slave_recv function pointers. But, my needs are a bit more deep... or, at least, I think they are. There are other implications as well: how do I retrofit IPMI to allow for the special devices I'm using, what commands will be appropriate, etc.
Quoted 5 lines
Again with the terminology. :) I think you're asking if someone has implemented host adapter slave support... well, it's in the i2c package TODO list for a long time now. If you're adding support for kernel 2.4, you'll probably be maintaining it yourself - we're not inclined to accept new features, and Marcelo is definitely not accepting patches for I2C.
Ok, that (unfortunately) answers my questions. If no patches are being accepted for I2C (I assume for the 2.4 kernel), then I will go my own route and develop a stand-alone driver for my needs.
Quoted 3 lines
However, development continues on kernel 2.6. If you come up with something good for 2.4, maybe someone here could port it to 2.6. I.e. whatever you come up with, we'd like to see it... good luck.
Let's see what happens. My driver will probably *NOT* use the I2C architecture, since it will be far easier for me to build a standalone driver than to try to enhance an intricate architecture that I will have to support on my own (re. "not accepting patches"). And, since we don't plan on going to the 2.4 kernel for a while (embedded system), porting to the 2.6 kernel is
- for now - a non-issue.
Let me know if you're still interested in seeing my driver after I have finished it.
Thanks for your help!
\burt
Signature · 4 lines
Burt Janz 603.880.0482 [email protected] www.ccsneinc.com/bjanz
Hello Burt:
Quoted 15 lines · Burt Janz
Quoted 4 lines · Mark M. Hoffman
First of all, you are confusing some terms. I2C is a multi-master bus, period. There is no such multi-master "mode". All of our i2c host adapter drivers should operate properly on a bus with other masters - if not that's a bug.
Er, I may not have explained my needs properly.
I am adding support to allow the MPC5200 to operate simultaneously as *both* a master *and* a slave on a bus. It must be able to send commands to the bus when in master mode, receive commands when in slave mode, and reside on the bus with at least one other MPC5200. This would provide a true multi-master
environment: multiple masters which would need to negotiate for control of the bus, but act as slaves when not acting as masters.
Quoted 8 lines
Quoted 1 line
I think you just want to add slave support to i2c host adapters.
If the above fits, then -- yes: the device will be in slave mode and responding to requests, but will occasionally *originate* commands as a master on a bus with at least one other master.
I'm not trying to quibble -- I'm just trying to explain my needs as clearly as I can...
OK, I think I get your intended distinction now... not just adding slave support... but also adding the ability to change the host from a master to a slave and back while the driver is loaded, maybe even operating as both simultaneously. Is that it?
Well that's a feature - let's call it "adapter mode switching" - that we obviously don't support. I'm not sure anyone's ever even considered it or asked for it before. I wonder what kind of system it is that this is required?
<snip>
Quoted 14 lines
Quoted 5 lines
Again with the terminology. :) I think you're asking if someone has implemented host adapter slave support... well, it's in the i2c package TODO list for a long time now. If you're adding support for kernel 2.4, you'll probably be maintaining it yourself - we're not inclined to accept new features, and Marcelo is definitely not accepting patches for I2C.
Ok, that (unfortunately) answers my questions. If no patches are being accepted for I2C (I assume for the 2.4 kernel), then I will go my own route and develop a stand-alone driver for my needs.
Quoted 3 lines
However, development continues on kernel 2.6. If you come up with something good for 2.4, maybe someone here could port it to 2.6. I.e. whatever you come up with, we'd like to see it... good luck.
Quoted 6 lines
Let's see what happens. My driver will probably *NOT* use the I2C architecture, since it will be far easier for me to build a standalone driver than to try to enhance an intricate architecture that I will have to support on my own (re. "not accepting patches"). And, since we don't plan on going to the 2.4 kernel for a while (embedded system), porting to the 2.6 kernel is
- for now - a non-issue.
As long as maintainers are demanding some level of API stability, by the time you're ready to move to 2.6 you won't be able to add the support you need there either. I.e. if you have requirements for the I2C layer, let's hear them - or better yet, send patches. :)
Quoted 2 lines
Let me know if you're still interested in seeing my driver after I have finished it.
Driver source outside the I2C layer is probably better than nothing w.r.t. understanding what is lacking in the I2C layer; yes please send it.
Quoted 1 line
Thanks for your help!
What little it's been, sorry.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
On Aug 05 2004, at 00:51, Mark M. Hoffman was caught saying:
Quoted 8 lines
Quoted 2 lines
I'm not trying to quibble -- I'm just trying to explain my needs as clearly as I can...
OK, I think I get your intended distinction now... not just adding slave support... but also adding the ability to change the host from a master to a slave and back while the driver is loaded, maybe even operating as both simultaneously. Is that it?
Quoted 4 lines
Well that's a feature - let's call it "adapter mode switching" - that we obviously don't support. I'm not sure anyone's ever even considered it or asked for it before. I wonder what kind of system it is that this is required?
It wouldn't be that hard to add support for this would it? Basically when you are not sending a packet, you automatically switch to slave mode and listen for your address. The biggest problem is adding hooks for async callbacks so some upper layer code can go off and do some other work and be interrupted when an inbound message comes in. Would only work with intelligent I2C controllers and not bit-bang adapters as you don't want to actively be polling the lines for your address (ick!).
~Deepak
Signature · 4 lines
Deepak Saxena - dsaxena at plexity dot net - http://www.plexity.net/ "Unlike me, many of you have accepted the situation of your imprisonment and will die here like rotten cabbages." - Number 6
Quoted 2 lines · Mark M. Hoffman
Hello Burt:
[snip]
Quoted 4 lines
OK, I think I get your intended distinction now... not just adding slave support... but also adding the ability to change the host from a master to a slave and back while the driver is loaded, maybe even operating as both simultaneously. Is that it?
Precisely. I don't expect to be operating in both modes simultaneously on the same port... but, since the MPC5200 does have 2 I2C ports, it is quite possible that one might be in "slave" and the other in "master" at the same time.
Quoted 4 lines
Well that's a feature - let's call it "adapter mode switching" - that we obviously don't support. I'm not sure anyone's ever even considered it or asked for it before. I wonder what kind of system it is that this is required?
I didn't think it was supported in the I2C code for 2.4.25 - at least, I wasn't able to find it :-)
The MPC5200 is being implemented as the controller for a system which monitors telecom operations (can't say much more - I'm sure you understand). There are multiple local devices which it must control/query as a local "master". And, since there will be several MPC5200-based boards in the system, each MPC5200 must respond as a "slave" to the parent controller. This allows the parent to control individual devices on each of the slave boards, and allows the slave boards to be "swapped" without affecting operations.
I think it's pretty neat...
[snip]
Quoted 4 lines
As long as maintainers are demanding some level of API stability, by the time you're ready to move to 2.6 you won't be able to add the support you need there either. I.e. if you have requirements for the I2C layer, let's hear them - or better yet, send patches. :)
No, I have no requirements for the I2C layer. In fact, I'm coding up my driver to be compatible with the IPMI kit so we can eventually use IPMI to interface to the driver and be able to take advantage of high-level command/response structures. Simple read() and write() leave a lot to be desired, especially with complex command sequences :-)
Quoted 2 lines
Driver source outside the I2C layer is probably better than nothing w.r.t. understanding what is lacking in the I2C layer; yes please send it.
If I can get the OK, then you'll get the driver. The code should be fairly easy to understand: I'm segmenting the driver source so the concepts can be rolled back into the I2C kit for 2.4.25... or 2.6.
I'm *sure* that someone else will eventually ask "Gee, how do we make our xyz system act as both a slave *and* a master..." :-)
\burt
Signature · 4 lines
Burt Janz 603.880.0482 [email protected] www.ccsneinc.com/bjanz