diff options
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r-- | drivers/net/sky2.c | 111 |
1 files changed, 16 insertions, 95 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 5257cf464f1a..e24b25ca1c69 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | #include <linux/crc32.h> | 25 | #include <linux/crc32.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/version.h> | ||
28 | #include <linux/module.h> | 27 | #include <linux/module.h> |
29 | #include <linux/netdevice.h> | 28 | #include <linux/netdevice.h> |
30 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
@@ -275,86 +274,6 @@ static void sky2_power_aux(struct sky2_hw *hw) | |||
275 | PC_VAUX_ON | PC_VCC_OFF)); | 274 | PC_VAUX_ON | PC_VCC_OFF)); |
276 | } | 275 | } |
277 | 276 | ||
278 | static void sky2_power_state(struct sky2_hw *hw, pci_power_t state) | ||
279 | { | ||
280 | u16 power_control = sky2_pci_read16(hw, hw->pm_cap + PCI_PM_CTRL); | ||
281 | int pex = pci_find_capability(hw->pdev, PCI_CAP_ID_EXP); | ||
282 | u32 reg; | ||
283 | |||
284 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); | ||
285 | |||
286 | switch (state) { | ||
287 | case PCI_D0: | ||
288 | break; | ||
289 | |||
290 | case PCI_D1: | ||
291 | power_control |= 1; | ||
292 | break; | ||
293 | |||
294 | case PCI_D2: | ||
295 | power_control |= 2; | ||
296 | break; | ||
297 | |||
298 | case PCI_D3hot: | ||
299 | case PCI_D3cold: | ||
300 | power_control |= 3; | ||
301 | if (hw->flags & SKY2_HW_ADV_POWER_CTL) { | ||
302 | /* additional power saving measurements */ | ||
303 | reg = sky2_pci_read32(hw, PCI_DEV_REG4); | ||
304 | |||
305 | /* set gating core clock for LTSSM in L1 state */ | ||
306 | reg |= P_PEX_LTSSM_STAT(P_PEX_LTSSM_L1_STAT) | | ||
307 | /* auto clock gated scheme controlled by CLKREQ */ | ||
308 | P_ASPM_A1_MODE_SELECT | | ||
309 | /* enable Gate Root Core Clock */ | ||
310 | P_CLK_GATE_ROOT_COR_ENA; | ||
311 | |||
312 | if (pex && (hw->flags & SKY2_HW_CLK_POWER)) { | ||
313 | /* enable Clock Power Management (CLKREQ) */ | ||
314 | u16 ctrl = sky2_pci_read16(hw, pex + PCI_EXP_DEVCTL); | ||
315 | |||
316 | ctrl |= PCI_EXP_DEVCTL_AUX_PME; | ||
317 | sky2_pci_write16(hw, pex + PCI_EXP_DEVCTL, ctrl); | ||
318 | } else | ||
319 | /* force CLKREQ Enable in Our4 (A1b only) */ | ||
320 | reg |= P_ASPM_FORCE_CLKREQ_ENA; | ||
321 | |||
322 | /* set Mask Register for Release/Gate Clock */ | ||
323 | sky2_pci_write32(hw, PCI_DEV_REG5, | ||
324 | P_REL_PCIE_EXIT_L1_ST | P_GAT_PCIE_ENTER_L1_ST | | ||
325 | P_REL_PCIE_RX_EX_IDLE | P_GAT_PCIE_RX_EL_IDLE | | ||
326 | P_REL_GPHY_LINK_UP | P_GAT_GPHY_LINK_DOWN); | ||
327 | } else | ||
328 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_CLK_HALT); | ||
329 | |||
330 | /* put CPU into reset state */ | ||
331 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, HCU_CCSR_ASF_RESET); | ||
332 | if (hw->chip_id == CHIP_ID_YUKON_SUPR && hw->chip_rev == CHIP_REV_YU_SU_A0) | ||
333 | /* put CPU into halt state */ | ||
334 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, HCU_CCSR_ASF_HALTED); | ||
335 | |||
336 | if (pex && !(hw->flags & SKY2_HW_RAM_BUFFER)) { | ||
337 | reg = sky2_pci_read32(hw, PCI_DEV_REG1); | ||
338 | /* force to PCIe L1 */ | ||
339 | reg |= PCI_FORCE_PEX_L1; | ||
340 | sky2_pci_write32(hw, PCI_DEV_REG1, reg); | ||
341 | } | ||
342 | break; | ||
343 | |||
344 | default: | ||
345 | dev_warn(&hw->pdev->dev, PFX "Invalid power state (%d) ", | ||
346 | state); | ||
347 | return; | ||
348 | } | ||
349 | |||
350 | power_control |= PCI_PM_CTRL_PME_ENABLE; | ||
351 | /* Finally, set the new power state. */ | ||
352 | sky2_pci_write32(hw, hw->pm_cap + PCI_PM_CTRL, power_control); | ||
353 | |||
354 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); | ||
355 | sky2_pci_read32(hw, B0_CTST); | ||
356 | } | ||
357 | |||
358 | static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port) | 277 | static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port) |
359 | { | 278 | { |
360 | u16 reg; | 279 | u16 reg; |
@@ -709,6 +628,11 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port) | |||
709 | sky2_pci_write32(hw, PCI_DEV_REG1, reg1); | 628 | sky2_pci_write32(hw, PCI_DEV_REG1, reg1); |
710 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); | 629 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); |
711 | sky2_pci_read32(hw, PCI_DEV_REG1); | 630 | sky2_pci_read32(hw, PCI_DEV_REG1); |
631 | |||
632 | if (hw->chip_id == CHIP_ID_YUKON_FE) | ||
633 | gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_ANE); | ||
634 | else if (hw->flags & SKY2_HW_ADV_POWER_CTL) | ||
635 | sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); | ||
712 | } | 636 | } |
713 | 637 | ||
714 | static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port) | 638 | static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port) |
@@ -741,11 +665,16 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port) | |||
741 | 665 | ||
742 | if (hw->chip_id != CHIP_ID_YUKON_EC) { | 666 | if (hw->chip_id != CHIP_ID_YUKON_EC) { |
743 | if (hw->chip_id == CHIP_ID_YUKON_EC_U) { | 667 | if (hw->chip_id == CHIP_ID_YUKON_EC_U) { |
744 | ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); | 668 | /* select page 2 to access MAC control register */ |
669 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 2); | ||
745 | 670 | ||
671 | ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); | ||
746 | /* enable Power Down */ | 672 | /* enable Power Down */ |
747 | ctrl |= PHY_M_PC_POW_D_ENA; | 673 | ctrl |= PHY_M_PC_POW_D_ENA; |
748 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl); | 674 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl); |
675 | |||
676 | /* set page register back to 0 */ | ||
677 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0); | ||
749 | } | 678 | } |
750 | 679 | ||
751 | /* set IEEE compatible Power Down Mode (dev. #4.99) */ | 680 | /* set IEEE compatible Power Down Mode (dev. #4.99) */ |
@@ -2855,10 +2784,6 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2855 | hw->flags = SKY2_HW_GIGABIT | 2784 | hw->flags = SKY2_HW_GIGABIT |
2856 | | SKY2_HW_NEWER_PHY | 2785 | | SKY2_HW_NEWER_PHY |
2857 | | SKY2_HW_ADV_POWER_CTL; | 2786 | | SKY2_HW_ADV_POWER_CTL; |
2858 | |||
2859 | /* check for Rev. A1 dev 4200 */ | ||
2860 | if (sky2_read16(hw, Q_ADDR(Q_XA1, Q_WM)) == 0) | ||
2861 | hw->flags |= SKY2_HW_CLK_POWER; | ||
2862 | break; | 2787 | break; |
2863 | 2788 | ||
2864 | case CHIP_ID_YUKON_EX: | 2789 | case CHIP_ID_YUKON_EX: |
@@ -2914,12 +2839,6 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2914 | if (hw->pmd_type == 'L' || hw->pmd_type == 'S' || hw->pmd_type == 'P') | 2839 | if (hw->pmd_type == 'L' || hw->pmd_type == 'S' || hw->pmd_type == 'P') |
2915 | hw->flags |= SKY2_HW_FIBRE_PHY; | 2840 | hw->flags |= SKY2_HW_FIBRE_PHY; |
2916 | 2841 | ||
2917 | hw->pm_cap = pci_find_capability(hw->pdev, PCI_CAP_ID_PM); | ||
2918 | if (hw->pm_cap == 0) { | ||
2919 | dev_err(&hw->pdev->dev, "cannot find PowerManagement capability\n"); | ||
2920 | return -EIO; | ||
2921 | } | ||
2922 | |||
2923 | hw->ports = 1; | 2842 | hw->ports = 1; |
2924 | t8 = sky2_read8(hw, B2_Y2_HW_RES); | 2843 | t8 = sky2_read8(hw, B2_Y2_HW_RES); |
2925 | if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) { | 2844 | if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) { |
@@ -4512,7 +4431,7 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4512 | 4431 | ||
4513 | pci_save_state(pdev); | 4432 | pci_save_state(pdev); |
4514 | pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); | 4433 | pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); |
4515 | sky2_power_state(hw, pci_choose_state(pdev, state)); | 4434 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
4516 | 4435 | ||
4517 | return 0; | 4436 | return 0; |
4518 | } | 4437 | } |
@@ -4525,7 +4444,9 @@ static int sky2_resume(struct pci_dev *pdev) | |||
4525 | if (!hw) | 4444 | if (!hw) |
4526 | return 0; | 4445 | return 0; |
4527 | 4446 | ||
4528 | sky2_power_state(hw, PCI_D0); | 4447 | err = pci_set_power_state(pdev, PCI_D0); |
4448 | if (err) | ||
4449 | goto out; | ||
4529 | 4450 | ||
4530 | err = pci_restore_state(pdev); | 4451 | err = pci_restore_state(pdev); |
4531 | if (err) | 4452 | if (err) |
@@ -4595,7 +4516,7 @@ static void sky2_shutdown(struct pci_dev *pdev) | |||
4595 | pci_enable_wake(pdev, PCI_D3cold, wol); | 4516 | pci_enable_wake(pdev, PCI_D3cold, wol); |
4596 | 4517 | ||
4597 | pci_disable_device(pdev); | 4518 | pci_disable_device(pdev); |
4598 | sky2_power_state(hw, PCI_D3hot); | 4519 | pci_set_power_state(pdev, PCI_D3hot); |
4599 | } | 4520 | } |
4600 | 4521 | ||
4601 | static struct pci_driver sky2_driver = { | 4522 | static struct pci_driver sky2_driver = { |