diff options
author | Giuseppe Cavallaro <peppe.cavallaro@st.com> | 2008-11-28 19:24:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-28 19:24:56 -0500 |
commit | 0f0ca340e57bd7446855fefd07a64249acf81223 (patch) | |
tree | 9a3af0f86f8bcce9eb86a38bf4dd5f4a2c5da2d1 /drivers/net/phy/phy_device.c | |
parent | 914804b95caa61c633431262044034ab05c78ba4 (diff) |
phy: power management support
This patch adds the power management support into the physical
abstraction layer.
Suspend and resume functions respectively turns on/off the bit 11
into the PHY Basic mode control register.
Generic PHY device starts supporting PM.
In order to support the wake-on LAN and avoid to put in power down
the PHY device, the MDIO is aware of what the Ethernet device wants to do.
Voluntary, no CONFIG_PM defines were added into the sources.
Also generic suspend/resume functions are exported to allow
other drivers use them (such as genphy_config_aneg etc.).
Within the phy_driver_register function, we need to remove the
memset. It overrides the device driver owner and it is not good.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 29546a206045..4cc75a290c06 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -779,7 +779,35 @@ static int genphy_config_init(struct phy_device *phydev) | |||
779 | 779 | ||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | int genphy_suspend(struct phy_device *phydev) | ||
783 | { | ||
784 | int value; | ||
785 | |||
786 | mutex_lock(&phydev->lock); | ||
787 | |||
788 | value = phy_read(phydev, MII_BMCR); | ||
789 | phy_write(phydev, MII_BMCR, (value | BMCR_PDOWN)); | ||
790 | |||
791 | mutex_unlock(&phydev->lock); | ||
792 | |||
793 | return 0; | ||
794 | } | ||
795 | EXPORT_SYMBOL(genphy_suspend); | ||
782 | 796 | ||
797 | int genphy_resume(struct phy_device *phydev) | ||
798 | { | ||
799 | int value; | ||
800 | |||
801 | mutex_lock(&phydev->lock); | ||
802 | |||
803 | value = phy_read(phydev, MII_BMCR); | ||
804 | phy_write(phydev, MII_BMCR, (value & ~BMCR_PDOWN)); | ||
805 | |||
806 | mutex_unlock(&phydev->lock); | ||
807 | |||
808 | return 0; | ||
809 | } | ||
810 | EXPORT_SYMBOL(genphy_resume); | ||
783 | 811 | ||
784 | /** | 812 | /** |
785 | * phy_probe - probe and init a PHY device | 813 | * phy_probe - probe and init a PHY device |
@@ -855,7 +883,6 @@ int phy_driver_register(struct phy_driver *new_driver) | |||
855 | { | 883 | { |
856 | int retval; | 884 | int retval; |
857 | 885 | ||
858 | memset(&new_driver->driver, 0, sizeof(new_driver->driver)); | ||
859 | new_driver->driver.name = new_driver->name; | 886 | new_driver->driver.name = new_driver->name; |
860 | new_driver->driver.bus = &mdio_bus_type; | 887 | new_driver->driver.bus = &mdio_bus_type; |
861 | new_driver->driver.probe = phy_probe; | 888 | new_driver->driver.probe = phy_probe; |
@@ -890,6 +917,8 @@ static struct phy_driver genphy_driver = { | |||
890 | .features = 0, | 917 | .features = 0, |
891 | .config_aneg = genphy_config_aneg, | 918 | .config_aneg = genphy_config_aneg, |
892 | .read_status = genphy_read_status, | 919 | .read_status = genphy_read_status, |
920 | .suspend = genphy_suspend, | ||
921 | .resume = genphy_resume, | ||
893 | .driver = {.owner= THIS_MODULE, }, | 922 | .driver = {.owner= THIS_MODULE, }, |
894 | }; | 923 | }; |
895 | 924 | ||