diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-07-30 19:37:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-30 19:37:33 -0400 |
commit | 12dac0756d357325b107fe6ec24921ec38661839 (patch) | |
tree | 8192114f80c7c3359f672a210dcb4ffaa05b38a0 /drivers/net/tg3.c | |
parent | 849e8caa477d72cf153e5c0b6ce0c00b89738abb (diff) |
tg3: adapt tg3 to use reworked PCI PM code
Adapt the tg3 driver to use the reworked PCI PM and make it use the
exported PCI PM core functions instead of accessing the PCI PM registers
directly by itself.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 633c128a6228..26aa37aa531f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -1982,8 +1982,6 @@ static void tg3_power_down_phy(struct tg3 *tp) | |||
1982 | static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | 1982 | static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) |
1983 | { | 1983 | { |
1984 | u32 misc_host_ctrl; | 1984 | u32 misc_host_ctrl; |
1985 | u16 power_control, power_caps; | ||
1986 | int pm = tp->pm_cap; | ||
1987 | 1985 | ||
1988 | /* Make sure register accesses (indirect or otherwise) | 1986 | /* Make sure register accesses (indirect or otherwise) |
1989 | * will function correctly. | 1987 | * will function correctly. |
@@ -1992,18 +1990,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
1992 | TG3PCI_MISC_HOST_CTRL, | 1990 | TG3PCI_MISC_HOST_CTRL, |
1993 | tp->misc_host_ctrl); | 1991 | tp->misc_host_ctrl); |
1994 | 1992 | ||
1995 | pci_read_config_word(tp->pdev, | ||
1996 | pm + PCI_PM_CTRL, | ||
1997 | &power_control); | ||
1998 | power_control |= PCI_PM_CTRL_PME_STATUS; | ||
1999 | power_control &= ~(PCI_PM_CTRL_STATE_MASK); | ||
2000 | switch (state) { | 1993 | switch (state) { |
2001 | case PCI_D0: | 1994 | case PCI_D0: |
2002 | power_control |= 0; | 1995 | pci_enable_wake(tp->pdev, state, false); |
2003 | pci_write_config_word(tp->pdev, | 1996 | pci_set_power_state(tp->pdev, PCI_D0); |
2004 | pm + PCI_PM_CTRL, | ||
2005 | power_control); | ||
2006 | udelay(100); /* Delay after power state change */ | ||
2007 | 1997 | ||
2008 | /* Switch out of Vaux if it is a NIC */ | 1998 | /* Switch out of Vaux if it is a NIC */ |
2009 | if (tp->tg3_flags2 & TG3_FLG2_IS_NIC) | 1999 | if (tp->tg3_flags2 & TG3_FLG2_IS_NIC) |
@@ -2012,26 +2002,15 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
2012 | return 0; | 2002 | return 0; |
2013 | 2003 | ||
2014 | case PCI_D1: | 2004 | case PCI_D1: |
2015 | power_control |= 1; | ||
2016 | break; | ||
2017 | |||
2018 | case PCI_D2: | 2005 | case PCI_D2: |
2019 | power_control |= 2; | ||
2020 | break; | ||
2021 | |||
2022 | case PCI_D3hot: | 2006 | case PCI_D3hot: |
2023 | power_control |= 3; | ||
2024 | break; | 2007 | break; |
2025 | 2008 | ||
2026 | default: | 2009 | default: |
2027 | printk(KERN_WARNING PFX "%s: Invalid power state (%d) " | 2010 | printk(KERN_ERR PFX "%s: Invalid power state (D%d) requested\n", |
2028 | "requested.\n", | 2011 | tp->dev->name, state); |
2029 | tp->dev->name, state); | ||
2030 | return -EINVAL; | 2012 | return -EINVAL; |
2031 | } | 2013 | } |
2032 | |||
2033 | power_control |= PCI_PM_CTRL_PME_ENABLE; | ||
2034 | |||
2035 | misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL); | 2014 | misc_host_ctrl = tr32(TG3PCI_MISC_HOST_CTRL); |
2036 | tw32(TG3PCI_MISC_HOST_CTRL, | 2015 | tw32(TG3PCI_MISC_HOST_CTRL, |
2037 | misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT); | 2016 | misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT); |
@@ -2109,8 +2088,6 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
2109 | WOL_DRV_WOL | | 2088 | WOL_DRV_WOL | |
2110 | WOL_SET_MAGIC_PKT); | 2089 | WOL_SET_MAGIC_PKT); |
2111 | 2090 | ||
2112 | pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); | ||
2113 | |||
2114 | if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { | 2091 | if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { |
2115 | u32 mac_mode; | 2092 | u32 mac_mode; |
2116 | 2093 | ||
@@ -2143,8 +2120,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
2143 | if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) | 2120 | if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS)) |
2144 | tw32(MAC_LED_CTRL, tp->led_ctrl); | 2121 | tw32(MAC_LED_CTRL, tp->led_ctrl); |
2145 | 2122 | ||
2146 | if (((power_caps & PCI_PM_CAP_PME_D3cold) && | 2123 | if (pci_pme_capable(tp->pdev, state) && |
2147 | (tp->tg3_flags & TG3_FLAG_WOL_ENABLE))) | 2124 | (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) |
2148 | mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE; | 2125 | mac_mode |= MAC_MODE_MAGIC_PKT_ENABLE; |
2149 | 2126 | ||
2150 | tw32_f(MAC_MODE, mac_mode); | 2127 | tw32_f(MAC_MODE, mac_mode); |
@@ -2236,9 +2213,11 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state) | |||
2236 | 2213 | ||
2237 | tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); | 2214 | tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); |
2238 | 2215 | ||
2216 | if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) | ||
2217 | pci_enable_wake(tp->pdev, state, true); | ||
2218 | |||
2239 | /* Finally, set the new power state. */ | 2219 | /* Finally, set the new power state. */ |
2240 | pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); | 2220 | pci_set_power_state(tp->pdev, state); |
2241 | udelay(100); /* Delay after power state change */ | ||
2242 | 2221 | ||
2243 | return 0; | 2222 | return 0; |
2244 | } | 2223 | } |
@@ -9065,7 +9044,8 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
9065 | { | 9044 | { |
9066 | struct tg3 *tp = netdev_priv(dev); | 9045 | struct tg3 *tp = netdev_priv(dev); |
9067 | 9046 | ||
9068 | if (tp->tg3_flags & TG3_FLAG_WOL_CAP) | 9047 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && |
9048 | device_can_wakeup(&tp->pdev->dev)) | ||
9069 | wol->supported = WAKE_MAGIC; | 9049 | wol->supported = WAKE_MAGIC; |
9070 | else | 9050 | else |
9071 | wol->supported = 0; | 9051 | wol->supported = 0; |
@@ -9078,18 +9058,22 @@ static void tg3_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
9078 | static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 9058 | static int tg3_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
9079 | { | 9059 | { |
9080 | struct tg3 *tp = netdev_priv(dev); | 9060 | struct tg3 *tp = netdev_priv(dev); |
9061 | struct device *dp = &tp->pdev->dev; | ||
9081 | 9062 | ||
9082 | if (wol->wolopts & ~WAKE_MAGIC) | 9063 | if (wol->wolopts & ~WAKE_MAGIC) |
9083 | return -EINVAL; | 9064 | return -EINVAL; |
9084 | if ((wol->wolopts & WAKE_MAGIC) && | 9065 | if ((wol->wolopts & WAKE_MAGIC) && |
9085 | !(tp->tg3_flags & TG3_FLAG_WOL_CAP)) | 9066 | !((tp->tg3_flags & TG3_FLAG_WOL_CAP) && device_can_wakeup(dp))) |
9086 | return -EINVAL; | 9067 | return -EINVAL; |
9087 | 9068 | ||
9088 | spin_lock_bh(&tp->lock); | 9069 | spin_lock_bh(&tp->lock); |
9089 | if (wol->wolopts & WAKE_MAGIC) | 9070 | if (wol->wolopts & WAKE_MAGIC) { |
9090 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 9071 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
9091 | else | 9072 | device_set_wakeup_enable(dp, true); |
9073 | } else { | ||
9092 | tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; | 9074 | tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; |
9075 | device_set_wakeup_enable(dp, false); | ||
9076 | } | ||
9093 | spin_unlock_bh(&tp->lock); | 9077 | spin_unlock_bh(&tp->lock); |
9094 | 9078 | ||
9095 | return 0; | 9079 | return 0; |
@@ -11296,7 +11280,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
11296 | if (val & VCPU_CFGSHDW_ASPM_DBNC) | 11280 | if (val & VCPU_CFGSHDW_ASPM_DBNC) |
11297 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; | 11281 | tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; |
11298 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && | 11282 | if ((val & VCPU_CFGSHDW_WOL_ENABLE) && |
11299 | (val & VCPU_CFGSHDW_WOL_MAGPKT)) | 11283 | (val & VCPU_CFGSHDW_WOL_MAGPKT) && |
11284 | device_may_wakeup(&tp->pdev->dev)) | ||
11300 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 11285 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
11301 | return; | 11286 | return; |
11302 | } | 11287 | } |
@@ -11426,8 +11411,9 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
11426 | !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)) | 11411 | !(nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)) |
11427 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; | 11412 | tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; |
11428 | 11413 | ||
11429 | if (tp->tg3_flags & TG3_FLAG_WOL_CAP && | 11414 | if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && |
11430 | nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE) | 11415 | (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE) && |
11416 | device_may_wakeup(&tp->pdev->dev)) | ||
11431 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; | 11417 | tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; |
11432 | 11418 | ||
11433 | if (cfg2 & (1 << 17)) | 11419 | if (cfg2 & (1 << 17)) |
@@ -13613,6 +13599,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state) | |||
13613 | { | 13599 | { |
13614 | struct net_device *dev = pci_get_drvdata(pdev); | 13600 | struct net_device *dev = pci_get_drvdata(pdev); |
13615 | struct tg3 *tp = netdev_priv(dev); | 13601 | struct tg3 *tp = netdev_priv(dev); |
13602 | pci_power_t target_state; | ||
13616 | int err; | 13603 | int err; |
13617 | 13604 | ||
13618 | /* PCI register 4 needs to be saved whether netif_running() or not. | 13605 | /* PCI register 4 needs to be saved whether netif_running() or not. |
@@ -13641,7 +13628,9 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state) | |||
13641 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; | 13628 | tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; |
13642 | tg3_full_unlock(tp); | 13629 | tg3_full_unlock(tp); |
13643 | 13630 | ||
13644 | err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); | 13631 | target_state = pdev->pm_cap ? pci_target_state(pdev) : PCI_D3hot; |
13632 | |||
13633 | err = tg3_set_power_state(tp, target_state); | ||
13645 | if (err) { | 13634 | if (err) { |
13646 | int err2; | 13635 | int err2; |
13647 | 13636 | ||