Subject: [PATCH 2.6.12-rc2 4/11] tg3: Fix tg3_set_power_state()

From: "Michael Chan" <[email-masked]>
Date: Mon, 18 Apr 2005 00:28:44 -0700

Fix tg3_set_power_state to drive GPIOs properly based on the
TG3_FLAG_EEPROM_WRITE_PROTECT flag. Some delays are also added after D0
and D3 power state changes.

Signed-off-by: Michael Chan <[email-masked]>
diff -Nru 103/drivers/net/tg3.c 104/drivers/net/tg3.c
--- 103/drivers/net/tg3.c	2005-04-15 15:01:37.000000000 -0700
+++ 104/drivers/net/tg3.c	2005-04-15 16:36:23.000000000 -0700
@@ -1005,8 +1005,13 @@
 		pci_write_config_word(tp->pdev,
 				      pm + PCI_PM_CTRL,
 				      power_control);
-		tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
-		udelay(100);
+		udelay(100);	/* Delay after power state change */
+
+		/* Switch out of Vaux if it is not a LOM */
+		if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) {
+			tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
+			udelay(100);
+		}
 
 		return 0;
 
@@ -1151,6 +1156,7 @@
 
 	/* Finally, set the new power state. */
 	pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
+	udelay(100);	/* Delay after power state change */
 
 	tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);