Powering down an ethernet PHY
I am running embedded linux on an OMAP ARM (OMAP-L138). The ethernet controller on this is connected to an external PHY chip. Everything is working fine, except in some c开发者_运维知识库ircumstances, I would like to save power and power down the PHY (but not suspend the whole system).
I know Linux can suspend the PHY easily, as when I put the whole system in a suspend to ram state, the PHY does indeed power down.
However, what I want to be able to do is to turn the PHY on and off via a user-space application, turning it on and off as I wish.
How do I achieve this? I am fairly new to linux, and I can write userspace applications in C to open device drivers and access them.
The PHY is connected via a MII interface, but I don't see a mii under /dev/? (i.e. for accessing the i2c driver, I have been doing fd = open( "/dev/i2c-0", O_RDWR );) Where is the mii driver kept? How can I access it? If only I could read and write a few registers to the PHY chip via the mii driver, then I think it would be easily achievable.
Thanks.
Find the source code in whatever driver is running the PHY (either by looking in the active kernel config, looking in the kernel messages, guessing, or grepping) and read through it.
See if it supports this. See if it supports a way to tell it to. If so, learn to use it.
If not, and you know from data sheets that the hardware supports it, add a mechanism, either as part of an existing power control scheme or just freehanded on its own. A node in sysfs seems to be the currently in vogue generic interface for telling the kernel simple on/off option settings, doing it in /proc the slightly older way.
This is also one of the areas where there is one (or a few) "right" solutions that would be acceptable for getting your code upstream, and a lot of more controversial solutions that you can probably get working for your own purposes quite quickly, especially if they use mechanisms you are already familiar with. It's a judgment call based on the purpose and future of your work.
精彩评论