diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2011-07-13 05:27:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-14 11:41:59 -0400 |
commit | cd0d7228b4f0279f219bc555fa0192dc072d79cd (patch) | |
tree | 6eb50748e316ea6e806dd454552dedc8cb31cf7e /drivers/net/tg3.c | |
parent | 3a1e19d383c7b91c8af52e8938ab60c40e3d26b3 (diff) |
tg3: Match power source to driver state
Now that the driver state (and power source) is being more intensely
scrutinized, we need to make sure it is correct 100% of the time. This
patch finds and fixes all dangling power state transitions.
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.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 0d1b0c0ef483..a5ff82d3b750 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -2357,7 +2357,7 @@ static void tg3_pwrsrc_switch_to_vaux(struct tg3 *tp) | |||
2357 | } | 2357 | } |
2358 | } | 2358 | } |
2359 | 2359 | ||
2360 | static void tg3_frob_aux_power_5717(struct tg3 *tp) | 2360 | static void tg3_frob_aux_power_5717(struct tg3 *tp, bool wol_enable) |
2361 | { | 2361 | { |
2362 | u32 msg = 0; | 2362 | u32 msg = 0; |
2363 | 2363 | ||
@@ -2365,8 +2365,7 @@ static void tg3_frob_aux_power_5717(struct tg3 *tp) | |||
2365 | if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO)) | 2365 | if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO)) |
2366 | return; | 2366 | return; |
2367 | 2367 | ||
2368 | if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE) || | 2368 | if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE) || wol_enable) |
2369 | tg3_flag(tp, WOL_ENABLE)) | ||
2370 | msg = TG3_GPIO_MSG_NEED_VAUX; | 2369 | msg = TG3_GPIO_MSG_NEED_VAUX; |
2371 | 2370 | ||
2372 | msg = tg3_set_function_status(tp, msg); | 2371 | msg = tg3_set_function_status(tp, msg); |
@@ -2383,7 +2382,7 @@ done: | |||
2383 | tg3_ape_unlock(tp, TG3_APE_LOCK_GPIO); | 2382 | tg3_ape_unlock(tp, TG3_APE_LOCK_GPIO); |
2384 | } | 2383 | } |
2385 | 2384 | ||
2386 | static void tg3_frob_aux_power(struct tg3 *tp) | 2385 | static void tg3_frob_aux_power(struct tg3 *tp, bool include_wol) |
2387 | { | 2386 | { |
2388 | bool need_vaux = false; | 2387 | bool need_vaux = false; |
2389 | 2388 | ||
@@ -2395,7 +2394,8 @@ static void tg3_frob_aux_power(struct tg3 *tp) | |||
2395 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || | 2394 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || |
2396 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || | 2395 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || |
2397 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) { | 2396 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) { |
2398 | tg3_frob_aux_power_5717(tp); | 2397 | tg3_frob_aux_power_5717(tp, include_wol ? |
2398 | tg3_flag(tp, WOL_ENABLE) != 0 : 0); | ||
2399 | return; | 2399 | return; |
2400 | } | 2400 | } |
2401 | 2401 | ||
@@ -2411,13 +2411,14 @@ static void tg3_frob_aux_power(struct tg3 *tp) | |||
2411 | if (tg3_flag(tp_peer, INIT_COMPLETE)) | 2411 | if (tg3_flag(tp_peer, INIT_COMPLETE)) |
2412 | return; | 2412 | return; |
2413 | 2413 | ||
2414 | if (tg3_flag(tp_peer, WOL_ENABLE) || | 2414 | if ((include_wol && tg3_flag(tp_peer, WOL_ENABLE)) || |
2415 | tg3_flag(tp_peer, ENABLE_ASF)) | 2415 | tg3_flag(tp_peer, ENABLE_ASF)) |
2416 | need_vaux = true; | 2416 | need_vaux = true; |
2417 | } | 2417 | } |
2418 | } | 2418 | } |
2419 | 2419 | ||
2420 | if (tg3_flag(tp, WOL_ENABLE) || tg3_flag(tp, ENABLE_ASF)) | 2420 | if ((include_wol && tg3_flag(tp, WOL_ENABLE)) || |
2421 | tg3_flag(tp, ENABLE_ASF)) | ||
2421 | need_vaux = true; | 2422 | need_vaux = true; |
2422 | 2423 | ||
2423 | if (need_vaux) | 2424 | if (need_vaux) |
@@ -3000,7 +3001,7 @@ static int tg3_power_down_prepare(struct tg3 *tp) | |||
3000 | if (!(device_should_wake) && !tg3_flag(tp, ENABLE_ASF)) | 3001 | if (!(device_should_wake) && !tg3_flag(tp, ENABLE_ASF)) |
3001 | tg3_power_down_phy(tp, do_low_power); | 3002 | tg3_power_down_phy(tp, do_low_power); |
3002 | 3003 | ||
3003 | tg3_frob_aux_power(tp); | 3004 | tg3_frob_aux_power(tp, true); |
3004 | 3005 | ||
3005 | /* Workaround for unstable PLL clock */ | 3006 | /* Workaround for unstable PLL clock */ |
3006 | if ((GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX) || | 3007 | if ((GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX) || |
@@ -9556,6 +9557,8 @@ err_out2: | |||
9556 | 9557 | ||
9557 | err_out1: | 9558 | err_out1: |
9558 | tg3_ints_fini(tp); | 9559 | tg3_ints_fini(tp); |
9560 | tg3_frob_aux_power(tp, false); | ||
9561 | pci_set_power_state(tp->pdev, PCI_D3hot); | ||
9559 | return err; | 9562 | return err; |
9560 | } | 9563 | } |
9561 | 9564 | ||
@@ -15400,6 +15403,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
15400 | 15403 | ||
15401 | pci_set_drvdata(pdev, dev); | 15404 | pci_set_drvdata(pdev, dev); |
15402 | 15405 | ||
15406 | if (tg3_flag(tp, 5717_PLUS)) { | ||
15407 | /* Resume a low-power mode */ | ||
15408 | tg3_frob_aux_power(tp, false); | ||
15409 | } | ||
15410 | |||
15403 | err = register_netdev(dev); | 15411 | err = register_netdev(dev); |
15404 | if (err) { | 15412 | if (err) { |
15405 | dev_err(&pdev->dev, "Cannot register net device, aborting\n"); | 15413 | dev_err(&pdev->dev, "Cannot register net device, aborting\n"); |