This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to shut down PHY to save power, DM6467T EVM

This post contains my method for shutting down the Internet PHY chip whenever no network cable is connected. I know it's very crude, but it's the best I could figure out.

There should be an attachment to this post, if the forum's working and I did it correctly. The attachment includes my kernel modifications.

PHILOSOPHY: The network cable should be plugged in when the target system is booted. If it is, great. If not, shut down the PHY chip in order to save power. Note that once this is done, plugging the network cable back in won't help. You have to reboot to get network connectivity back.

POWER: My target system, derived from the DM6467T EVM, when provided a 12.0V main supply, when running my custom codec application, consumes 0.53A, making 6.36W. I find that unplugging the network cable reduces this power to 4.8W. I find that pulling to ground the RESETn pin of the ET1011C reduces this further to 4.2W. Since my application only needs the Internet connection for development and perhaps maintenance, I'm far better off drawing 4.2W than 6.36W. And the improvement of 4.2W over 4.8W (12.5%) is worthwhile.

METHOD:

1) On my board, derived from the DM6467T EVM, the signal SYS_RESETn goes nowhere other than the ET1011C PHY chip, and it comes from the CPLD. Therefore, I modified the CPLD program so that I could control the SYS_RESETn signal from the CPLD Reg0 Bit2 position. Because this bit defaults to 0, I defined it as the inverse of SYS_RESETn. That is, when the bit is 0, SYS_RESETn is high and the PHY consumes power. When the bit is 1, SYS_RESETn is driven low and the PHY consumes less power.

2) The file board-dm646x-evm.c has access to the CPLD registers. I could find no published method to get at this ability from user space, and attempts to make a driver met with resource conflicts. I gave up on this and wrote a small function hgf_phy_power(u8 on) within board-dm646x-evm.c and then exported it. By calling this function, the CPLD Reg0 Bit2 can be set or cleared, thus powering off or on the PHY.

3) Next, I needed to perform an action if the Internet cable was unplugged. I tried to intercept the "No lease, failed" message that seems to come from udhcpc, but was unable to find source code. Instead, I found that "more /sys/class/net/eth0/operstate" would return "up" or "down", depending on the network cable plug status (and other things, of course). I further found that I could get at the source for this, show_operstate() function in net-sysfs.c. This function being a kernel function that could access my exported hgf_phy_power() function from board-dm646x-evm.c, I modified the function to call hgf_phy_power(0) whenever the network as down.

4) I then had to invoke the show_operstate(). I already had an autorun.sh configured in init.d, etc, to run my custom codec application upon boot completion. Therefore, I simply added a line to the beginning of autorun.sh to do the command "more /sys/class/net/eth0/operstate".

As a result, after the target system has booted and autorun.sh is executed, the "more" invokes show_operstate(). If this function finds the network down, then it calls hgf_phy_power(0) which sets CPLD Reg0 Bit2, which pulls SYS_RESETn low, which causes the PHY chip to draw much less power.

To get network connectivity working again, one must reboot the target while the network cable is plugged in. This worked for a cold boot (power off-on). However, for a warm boot, a prior setting of CPLD Reg0 Bit2 was never cleared. I realized I had to add some initialization for this bit as well, which I added to the board-dm646x-evm.c probe function by calling hgf_phy_power(1). Thus, even on a warm boot, the PHY power comes back on, in case the cable is plugged in. If it is, things work. If it's now, the PHY is powered down.