aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-07-13 05:27:28 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-14 11:41:59 -0400
commit168212858712b12c65e0fa1bec6c9c65808e7621 (patch)
treef157f4e1dd6ec271c0f21e9c917f814440618873 /drivers/net/tg3.c
parentc9cab24e954867a03ab833ea3b4c0e6e607eb0d6 (diff)
tg3: Move power state transitions to init_one
The tg3 driver is going to require memory mapped register access much sooner than before. This patch makes sure the device is in the D0 power state as soon as possible, and moves the code that enables the memory arbiter outside tg3_get_eeprom_hw_cfg() where it can be more easily monitored. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c77
1 files changed, 34 insertions, 43 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 01d3a271a040..ecbc10fed1a6 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12678,29 +12678,6 @@ static struct subsys_tbl_ent * __devinit tg3_lookup_by_subsys(struct tg3 *tp)
12678static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) 12678static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
12679{ 12679{
12680 u32 val; 12680 u32 val;
12681 u16 pmcsr;
12682
12683 /* On some early chips the SRAM cannot be accessed in D3hot state,
12684 * so need make sure we're in D0.
12685 */
12686 pci_read_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, &pmcsr);
12687 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
12688 pci_write_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, pmcsr);
12689 msleep(1);
12690
12691 /* Make sure register accesses (indirect or otherwise)
12692 * will function correctly.
12693 */
12694 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
12695 tp->misc_host_ctrl);
12696
12697 /* The memory arbiter has to be enabled in order for SRAM accesses
12698 * to succeed. Normally on powerup the tg3 chip firmware will make
12699 * sure it is enabled, but other entities such as system netboot
12700 * code might disable it.
12701 */
12702 val = tr32(MEMARB_MODE);
12703 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
12704 12681
12705 tp->phy_id = TG3_PHY_ID_INVALID; 12682 tp->phy_id = TG3_PHY_ID_INVALID;
12706 tp->led_ctrl = LED_CTRL_MODE_PHY_1; 12683 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
@@ -13498,14 +13475,17 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13498 pci_cmd &= ~PCI_COMMAND_INVALIDATE; 13475 pci_cmd &= ~PCI_COMMAND_INVALIDATE;
13499 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); 13476 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
13500 13477
13501 /* It is absolutely critical that TG3PCI_MISC_HOST_CTRL 13478 /* Important! -- Make sure register accesses are byteswapped
13502 * has the register indirect write enable bit set before 13479 * correctly. Also, for those chips that require it, make
13503 * we try to access any of the MMIO registers. It is also 13480 * sure that indirect register accesses are enabled before
13504 * critical that the PCI-X hw workaround situation is decided 13481 * the first operation.
13505 * before that as well.
13506 */ 13482 */
13507 pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, 13483 pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
13508 &misc_ctrl_reg); 13484 &misc_ctrl_reg);
13485 tp->misc_host_ctrl |= (misc_ctrl_reg &
13486 MISC_HOST_CTRL_CHIPREV);
13487 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
13488 tp->misc_host_ctrl);
13509 13489
13510 tp->pci_chip_rev_id = (misc_ctrl_reg >> 13490 tp->pci_chip_rev_id = (misc_ctrl_reg >>
13511 MISC_HOST_CTRL_CHIPREV_SHIFT); 13491 MISC_HOST_CTRL_CHIPREV_SHIFT);
@@ -13661,12 +13641,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13661 } while (bridge); 13641 } while (bridge);
13662 } 13642 }
13663 13643
13664 /* Initialize misc host control in PCI block. */
13665 tp->misc_host_ctrl |= (misc_ctrl_reg &
13666 MISC_HOST_CTRL_CHIPREV);
13667 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
13668 tp->misc_host_ctrl);
13669
13670 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || 13644 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
13671 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 || 13645 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 ||
13672 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || 13646 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 ||
@@ -13851,6 +13825,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13851 tp->pci_lat_timer); 13825 tp->pci_lat_timer);
13852 } 13826 }
13853 13827
13828 /* Important! -- It is critical that the PCI-X hw workaround
13829 * situation is decided before the first MMIO register access.
13830 */
13854 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) { 13831 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) {
13855 /* 5700 BX chips need to have their TX producer index 13832 /* 5700 BX chips need to have their TX producer index
13856 * mailboxes written twice to workaround a bug. 13833 * mailboxes written twice to workaround a bug.
@@ -13957,6 +13934,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13957 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701))) 13934 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
13958 tg3_flag_set(tp, SRAM_USE_CONFIG); 13935 tg3_flag_set(tp, SRAM_USE_CONFIG);
13959 13936
13937 /* The memory arbiter has to be enabled in order for SRAM accesses
13938 * to succeed. Normally on powerup the tg3 chip firmware will make
13939 * sure it is enabled, but other entities such as system netboot
13940 * code might disable it.
13941 */
13942 val = tr32(MEMARB_MODE);
13943 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
13944
13960 /* Get eeprom hw config before calling tg3_set_power_state(). 13945 /* Get eeprom hw config before calling tg3_set_power_state().
13961 * In particular, the TG3_FLAG_IS_NIC flag must be 13946 * In particular, the TG3_FLAG_IS_NIC flag must be
13962 * determined before calling tg3_set_power_state() so that 13947 * determined before calling tg3_set_power_state() so that
@@ -13987,8 +13972,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13987 tg3_flag(tp, 57765_PLUS)) 13972 tg3_flag(tp, 57765_PLUS))
13988 tg3_flag_set(tp, CPMU_PRESENT); 13973 tg3_flag_set(tp, CPMU_PRESENT);
13989 13974
13990 /* Set up tp->grc_local_ctrl before calling tg3_power_up(). 13975 /* Set up tp->grc_local_ctrl before calling
13991 * GPIO1 driven high will bring 5700's external PHY out of reset. 13976 * tg3_pwrsrc_switch_to_vmain(). GPIO1 driven high
13977 * will bring 5700's external PHY out of reset.
13992 * It is also used as eeprom write protect on LOMs. 13978 * It is also used as eeprom write protect on LOMs.
13993 */ 13979 */
13994 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; 13980 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
@@ -14017,12 +14003,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
14017 GRC_LCLCTRL_GPIO_OUTPUT0; 14003 GRC_LCLCTRL_GPIO_OUTPUT0;
14018 } 14004 }
14019 14005
14020 /* Force the chip into D0. */ 14006 /* Switch out of Vaux if it is a NIC */
14021 err = tg3_power_up(tp); 14007 tg3_pwrsrc_switch_to_vmain(tp);
14022 if (err) {
14023 dev_err(&tp->pdev->dev, "Transition to D0 failed\n");
14024 return err;
14025 }
14026 14008
14027 /* Derive initial jumbo mode from MTU assigned in 14009 /* Derive initial jumbo mode from MTU assigned in
14028 * ether_setup() via the alloc_etherdev() call 14010 * ether_setup() via the alloc_etherdev() call
@@ -15037,11 +15019,17 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
15037 goto err_out_free_res; 15019 goto err_out_free_res;
15038 } 15020 }
15039 15021
15022 err = pci_set_power_state(pdev, PCI_D0);
15023 if (err) {
15024 dev_err(&pdev->dev, "Transition to D0 failed, aborting\n");
15025 goto err_out_free_res;
15026 }
15027
15040 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS); 15028 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS);
15041 if (!dev) { 15029 if (!dev) {
15042 dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n"); 15030 dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n");
15043 err = -ENOMEM; 15031 err = -ENOMEM;
15044 goto err_out_free_res; 15032 goto err_out_power_down;
15045 } 15033 }
15046 15034
15047 SET_NETDEV_DEV(dev, &pdev->dev); 15035 SET_NETDEV_DEV(dev, &pdev->dev);
@@ -15356,6 +15344,9 @@ err_out_iounmap:
15356err_out_free_dev: 15344err_out_free_dev:
15357 free_netdev(dev); 15345 free_netdev(dev);
15358 15346
15347err_out_power_down:
15348 pci_set_power_state(pdev, PCI_D3hot);
15349
15359err_out_free_res: 15350err_out_free_res:
15360 pci_release_regions(pdev); 15351 pci_release_regions(pdev);
15361 15352