Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6

* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (23 commits)
[PATCH] 8139too deadlock fix
[netdrvr] 3c59x: snip changelog from source code
e1000: increase version to 7.1.9-k2
e1000: add ich8lan device ID's
e1000: allow user to disable ich8 lock loss workaround
e1000: integrate ich8 support into driver
e1000: add ich8lan core functions
e1000: disable ERT
e1000: check return value of _get_speed_and_duplex
e1000: M88 PHY workaround
e1000: fix adapter led blinking inconsistency
e1000: disable CRC stripping workaround
e1000: force register write flushes to circumvent broken platforms
e1000: rework module param code with uninitialized values
e1000: recycle skb
e1000: change printk into DPRINTK
e1000: add smart power down code
e1000: small performance tweak by removing double code
e1000: fix CONFIG_PM blocks
e1000: Make PHY powerup/down a function
...

+2522 -558
-166
drivers/net/3c59x.c
··· 17 17 410 Severn Ave., Suite 210 18 18 Annapolis MD 21403 19 19 20 - Linux Kernel Additions: 21 - 22 - 0.99H+lk0.9 - David S. Miller - softnet, PCI DMA updates 23 - 0.99H+lk1.0 - Jeff Garzik <jgarzik@pobox.com> 24 - Remove compatibility defines for kernel versions < 2.2.x. 25 - Update for new 2.3.x module interface 26 - LK1.1.2 (March 19, 2000) 27 - * New PCI interface (jgarzik) 28 - 29 - LK1.1.3 25 April 2000, Andrew Morton <andrewm@uow.edu.au> 30 - - Merged with 3c575_cb.c 31 - - Don't set RxComplete in boomerang interrupt enable reg 32 - - spinlock in vortex_timer to protect mdio functions 33 - - disable local interrupts around call to vortex_interrupt in 34 - vortex_tx_timeout() (So vortex_interrupt can use spin_lock()) 35 - - Select window 3 in vortex_timer()'s write to Wn3_MAC_Ctrl 36 - - In vortex_start_xmit(), move the lock to _after_ we've altered 37 - vp->cur_tx and vp->tx_full. This defeats the race between 38 - vortex_start_xmit() and vortex_interrupt which was identified 39 - by Bogdan Costescu. 40 - - Merged back support for six new cards from various sources 41 - - Set vortex_have_pci if pci_module_init returns zero (fixes cardbus 42 - insertion oops) 43 - - Tell it that 3c905C has NWAY for 100bT autoneg 44 - - Fix handling of SetStatusEnd in 'Too much work..' code, as 45 - per 2.3.99's 3c575_cb (Dave Hinds). 46 - - Split ISR into two for vortex & boomerang 47 - - Fix MOD_INC/DEC races 48 - - Handle resource allocation failures. 49 - - Fix 3CCFE575CT LED polarity 50 - - Make tx_interrupt_mitigation the default 51 - 52 - LK1.1.4 25 April 2000, Andrew Morton <andrewm@uow.edu.au> 53 - - Add extra TxReset to vortex_up() to fix 575_cb hotplug initialisation probs. 54 - - Put vortex_info_tbl into __devinitdata 55 - - In the vortex_error StatsFull HACK, disable stats in vp->intr_enable as well 56 - as in the hardware. 57 - - Increased the loop counter in issue_and_wait from 2,000 to 4,000. 58 - 59 - LK1.1.5 28 April 2000, andrewm 60 - - Added powerpc defines (John Daniel <jdaniel@etresoft.com> said these work...) 61 - - Some extra diagnostics 62 - - In vortex_error(), reset the Tx on maxCollisions. Otherwise most 63 - chips usually get a Tx timeout. 64 - - Added extra_reset module parm 65 - - Replaced some inline timer manip with mod_timer 66 - (Franois romieu <Francois.Romieu@nic.fr>) 67 - - In vortex_up(), don't make Wn3_config initialisation dependent upon has_nway 68 - (this came across from 3c575_cb). 69 - 70 - LK1.1.6 06 Jun 2000, andrewm 71 - - Backed out the PPC defines. 72 - - Use del_timer_sync(), mod_timer(). 73 - - Fix wrapped ulong comparison in boomerang_rx() 74 - - Add IS_TORNADO, use it to suppress 3c905C checksum error msg 75 - (Donald Becker, I Lee Hetherington <ilh@sls.lcs.mit.edu>) 76 - - Replace union wn3_config with BFINS/BFEXT manipulation for 77 - sparc64 (Pete Zaitcev, Peter Jones) 78 - - In vortex_error, do_tx_reset and vortex_tx_timeout(Vortex): 79 - do a netif_wake_queue() to better recover from errors. (Anders Pedersen, 80 - Donald Becker) 81 - - Print a warning on out-of-memory (rate limited to 1 per 10 secs) 82 - - Added two more Cardbus 575 NICs: 5b57 and 6564 (Paul Wagland) 83 - 84 - LK1.1.7 2 Jul 2000 andrewm 85 - - Better handling of shared IRQs 86 - - Reset the transmitter on a Tx reclaim error 87 - - Fixed crash under OOM during vortex_open() (Mark Hemment) 88 - - Fix Rx cessation problem during OOM (help from Mark Hemment) 89 - - The spinlocks around the mdio access were blocking interrupts for 300uS. 90 - Fix all this to use spin_lock_bh() within mdio_read/write 91 - - Only write to TxFreeThreshold if it's a boomerang - other NICs don't 92 - have one. 93 - - Added 802.3x MAC-layer flow control support 94 - 95 - LK1.1.8 13 Aug 2000 andrewm 96 - - Ignore request_region() return value - already reserved if Cardbus. 97 - - Merged some additional Cardbus flags from Don's 0.99Qk 98 - - Some fixes for 3c556 (Fred Maciel) 99 - - Fix for EISA initialisation (Jan Rekorajski) 100 - - Renamed MII_XCVR_PWR and EEPROM_230 to align with 3c575_cb and D. Becker's drivers 101 - - Fixed MII_XCVR_PWR for 3CCFE575CT 102 - - Added INVERT_LED_PWR, used it. 103 - - Backed out the extra_reset stuff 104 - 105 - LK1.1.9 12 Sep 2000 andrewm 106 - - Backed out the tx_reset_resume flags. It was a no-op. 107 - - In vortex_error, don't reset the Tx on txReclaim errors 108 - - In vortex_error, don't reset the Tx on maxCollisions errors. 109 - Hence backed out all the DownListPtr logic here. 110 - - In vortex_error, give Tornado cards a partial TxReset on 111 - maxCollisions (David Hinds). Defined MAX_COLLISION_RESET for this. 112 - - Redid some driver flags and device names based on pcmcia_cs-3.1.20. 113 - - Fixed a bug where, if vp->tx_full is set when the interface 114 - is downed, it remains set when the interface is upped. Bad 115 - things happen. 116 - 117 - LK1.1.10 17 Sep 2000 andrewm 118 - - Added EEPROM_8BIT for 3c555 (Fred Maciel) 119 - - Added experimental support for the 3c556B Laptop Hurricane (Louis Gerbarg) 120 - - Add HAS_NWAY to "3c900 Cyclone 10Mbps TPO" 121 - 122 - LK1.1.11 13 Nov 2000 andrewm 123 - - Dump MOD_INC/DEC_USE_COUNT, use SET_MODULE_OWNER 124 - 125 - LK1.1.12 1 Jan 2001 andrewm (2.4.0-pre1) 126 - - Call pci_enable_device before we request our IRQ (Tobias Ringstrom) 127 - - Add 3c590 PCI latency timer hack to vortex_probe1 (from 0.99Ra) 128 - - Added extended issue_and_wait for the 3c905CX. 129 - - Look for an MII on PHY index 24 first (3c905CX oddity). 130 - - Add HAS_NWAY to 3cSOHO100-TX (Brett Frankenberger) 131 - - Don't free skbs we don't own on oom path in vortex_open(). 132 - 133 - LK1.1.13 27 Jan 2001 134 - - Added explicit `medialock' flag so we can truly 135 - lock the media type down with `options'. 136 - - "check ioremap return and some tidbits" (Arnaldo Carvalho de Melo <acme@conectiva.com.br>) 137 - - Added and used EEPROM_NORESET for 3c556B PM resumes. 138 - - Fixed leakage of vp->rx_ring. 139 - - Break out separate HAS_HWCKSM device capability flag. 140 - - Kill vp->tx_full (ANK) 141 - - Merge zerocopy fragment handling (ANK?) 142 - 143 - LK1.1.14 15 Feb 2001 144 - - Enable WOL. Can be turned on with `enable_wol' module option. 145 - - EISA and PCI initialisation fixes (jgarzik, Manfred Spraul) 146 - - If a device's internalconfig register reports it has NWAY, 147 - use it, even if autoselect is enabled. 148 - 149 - LK1.1.15 6 June 2001 akpm 150 - - Prevent double counting of received bytes (Lars Christensen) 151 - - Add ethtool support (jgarzik) 152 - - Add module parm descriptions (Andrzej M. Krzysztofowicz) 153 - - Implemented alloc_etherdev() API 154 - - Special-case the 'Tx error 82' message. 155 - 156 - LK1.1.16 18 July 2001 akpm 157 - - Make NETIF_F_SG dependent upon nr_free_highpages(), not on CONFIG_HIGHMEM 158 - - Lessen verbosity of bootup messages 159 - - Fix WOL - use new PM API functions. 160 - - Use netif_running() instead of vp->open in suspend/resume. 161 - - Don't reset the interface logic on open/close/rmmod. It upsets 162 - autonegotiation, and hence DHCP (from 0.99T). 163 - - Back out EEPROM_NORESET flag because of the above (we do it for all 164 - NICs). 165 - - Correct 3c982 identification string 166 - - Rename wait_for_completion() to issue_and_wait() to avoid completion.h 167 - clash. 168 - 169 - LK1.1.17 18Dec01 akpm 170 - - PCI ID 9805 is a Python-T, not a dual-port Cyclone. Apparently. 171 - And it has NWAY. 172 - - Mask our advertised modes (vp->advertising) with our capabilities 173 - (MII reg5) when deciding which duplex mode to use. 174 - - Add `global_options' as default for options[]. Ditto global_enable_wol, 175 - global_full_duplex. 176 - 177 - LK1.1.18 01Jul02 akpm 178 - - Fix for undocumented transceiver power-up bit on some 3c566B's 179 - (Donald Becker, Rahul Karnik) 180 - 181 - - See http://www.zip.com.au/~akpm/linux/#3c59x-2.3 for more details. 182 - - Also see Documentation/networking/vortex.txt 183 - 184 - LK1.1.19 10Nov02 Marc Zyngier <maz@wild-wind.fr.eu.org> 185 - - EISA sysfs integration. 186 20 */ 187 21 188 22 /*
+3 -2
drivers/net/8139too.c
··· 1709 1709 void __iomem *ioaddr = tp->mmio_addr; 1710 1710 unsigned int entry; 1711 1711 unsigned int len = skb->len; 1712 + unsigned long flags; 1712 1713 1713 1714 /* Calculate the next Tx descriptor entry. */ 1714 1715 entry = tp->cur_tx % NUM_TX_DESC; ··· 1726 1725 return 0; 1727 1726 } 1728 1727 1729 - spin_lock_irq(&tp->lock); 1728 + spin_lock_irqsave(&tp->lock, flags); 1730 1729 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), 1731 1730 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); 1732 1731 ··· 1737 1736 1738 1737 if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) 1739 1738 netif_stop_queue (dev); 1740 - spin_unlock_irq(&tp->lock); 1739 + spin_unlock_irqrestore(&tp->lock, flags); 1741 1740 1742 1741 if (netif_msg_tx_queued(tp)) 1743 1742 printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n",
+8 -2
drivers/net/e1000/e1000.h
··· 68 68 #ifdef NETIF_F_TSO 69 69 #include <net/checksum.h> 70 70 #endif 71 - #include <linux/workqueue.h> 72 71 #include <linux/mii.h> 73 72 #include <linux/ethtool.h> 74 73 #include <linux/if_vlan.h> ··· 142 143 143 144 #define AUTO_ALL_MODES 0 144 145 #define E1000_EEPROM_82544_APM 0x0004 146 + #define E1000_EEPROM_ICH8_APME 0x0004 145 147 #define E1000_EEPROM_APME 0x0400 146 148 147 149 #ifndef E1000_MASTER_SLAVE ··· 254 254 spinlock_t tx_queue_lock; 255 255 #endif 256 256 atomic_t irq_sem; 257 - struct work_struct watchdog_task; 258 257 struct work_struct reset_task; 259 258 uint8_t fc_autoneg; 260 259 ··· 338 339 #ifdef NETIF_F_TSO 339 340 boolean_t tso_force; 340 341 #endif 342 + boolean_t smart_power_down; /* phy smart power down */ 343 + unsigned long flags; 341 344 }; 342 345 346 + enum e1000_state_t { 347 + __E1000_DRIVER_TESTING, 348 + __E1000_RESETTING, 349 + }; 343 350 344 351 /* e1000_main.c */ 345 352 extern char e1000_driver_name[]; ··· 353 348 int e1000_up(struct e1000_adapter *adapter); 354 349 void e1000_down(struct e1000_adapter *adapter); 355 350 void e1000_reset(struct e1000_adapter *adapter); 351 + void e1000_reinit_locked(struct e1000_adapter *adapter); 356 352 int e1000_setup_all_tx_resources(struct e1000_adapter *adapter); 357 353 void e1000_free_all_tx_resources(struct e1000_adapter *adapter); 358 354 int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
+85 -56
drivers/net/e1000/e1000_ethtool.c
··· 109 109 SUPPORTED_1000baseT_Full| 110 110 SUPPORTED_Autoneg | 111 111 SUPPORTED_TP); 112 - 112 + if (hw->phy_type == e1000_phy_ife) 113 + ecmd->supported &= ~SUPPORTED_1000baseT_Full; 113 114 ecmd->advertising = ADVERTISED_TP; 114 115 115 116 if (hw->autoneg == 1) { ··· 204 203 205 204 /* reset the link */ 206 205 207 - if (netif_running(adapter->netdev)) { 208 - e1000_down(adapter); 209 - e1000_reset(adapter); 210 - e1000_up(adapter); 211 - } else 206 + if (netif_running(adapter->netdev)) 207 + e1000_reinit_locked(adapter); 208 + else 212 209 e1000_reset(adapter); 213 210 214 211 return 0; ··· 253 254 hw->original_fc = hw->fc; 254 255 255 256 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 256 - if (netif_running(adapter->netdev)) { 257 - e1000_down(adapter); 258 - e1000_up(adapter); 259 - } else 257 + if (netif_running(adapter->netdev)) 258 + e1000_reinit_locked(adapter); 259 + else 260 260 e1000_reset(adapter); 261 261 } else 262 262 return ((hw->media_type == e1000_media_type_fiber) ? ··· 277 279 struct e1000_adapter *adapter = netdev_priv(netdev); 278 280 adapter->rx_csum = data; 279 281 280 - if (netif_running(netdev)) { 281 - e1000_down(adapter); 282 - e1000_up(adapter); 283 - } else 282 + if (netif_running(netdev)) 283 + e1000_reinit_locked(adapter); 284 + else 284 285 e1000_reset(adapter); 285 286 return 0; 286 287 } ··· 574 577 case e1000_82572: 575 578 case e1000_82573: 576 579 case e1000_80003es2lan: 580 + case e1000_ich8lan: 577 581 sprintf(firmware_version, "%d.%d-%d", 578 582 (eeprom_data & 0xF000) >> 12, 579 583 (eeprom_data & 0x0FF0) >> 4, ··· 628 630 629 631 tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues; 630 632 rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues; 633 + 634 + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) 635 + msleep(1); 631 636 632 637 if (netif_running(adapter->netdev)) 633 638 e1000_down(adapter); ··· 692 691 adapter->rx_ring = rx_new; 693 692 adapter->tx_ring = tx_new; 694 693 if ((err = e1000_up(adapter))) 695 - return err; 694 + goto err_setup; 696 695 } 696 + 697 + clear_bit(__E1000_RESETTING, &adapter->flags); 697 698 698 699 return 0; 699 700 err_setup_tx: ··· 704 701 adapter->rx_ring = rx_old; 705 702 adapter->tx_ring = tx_old; 706 703 e1000_up(adapter); 704 + err_setup: 705 + clear_bit(__E1000_RESETTING, &adapter->flags); 707 706 return err; 708 707 } 709 708 ··· 759 754 toggle = 0x7FFFF3FF; 760 755 break; 761 756 case e1000_82573: 757 + case e1000_ich8lan: 762 758 toggle = 0x7FFFF033; 763 759 break; 764 760 default: ··· 779 773 } 780 774 /* restore previous status */ 781 775 E1000_WRITE_REG(&adapter->hw, STATUS, before); 782 - 783 - REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 784 - REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 785 - REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); 786 - REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF); 776 + if (adapter->hw.mac_type != e1000_ich8lan) { 777 + REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 778 + REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 779 + REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); 780 + REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF); 781 + } 787 782 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF); 788 783 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); 789 784 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF); ··· 797 790 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF); 798 791 799 792 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000); 800 - REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0x003FFFFB); 793 + before = (adapter->hw.mac_type == e1000_ich8lan ? 794 + 0x06C3B33E : 0x06DFB3FE); 795 + REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB); 801 796 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); 802 797 803 798 if (adapter->hw.mac_type >= e1000_82543) { 804 799 805 - REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0xFFFFFFFF); 800 + REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF); 806 801 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 807 - REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); 802 + if (adapter->hw.mac_type != e1000_ich8lan) 803 + REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); 808 804 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 809 805 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF); 810 - 811 - for (i = 0; i < E1000_RAR_ENTRIES; i++) { 812 - REG_PATTERN_TEST(RA + ((i << 1) << 2), 0xFFFFFFFF, 813 - 0xFFFFFFFF); 806 + value = (adapter->hw.mac_type == e1000_ich8lan ? 807 + E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES); 808 + for (i = 0; i < value; i++) { 814 809 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, 815 810 0xFFFFFFFF); 816 811 } ··· 826 817 827 818 } 828 819 829 - for (i = 0; i < E1000_MC_TBL_SIZE; i++) 820 + value = (adapter->hw.mac_type == e1000_ich8lan ? 821 + E1000_MC_TBL_SIZE_ICH8LAN : E1000_MC_TBL_SIZE); 822 + for (i = 0; i < value; i++) 830 823 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF); 831 824 832 825 *data = 0; ··· 900 889 /* Test each interrupt */ 901 890 for (; i < 10; i++) { 902 891 892 + if (adapter->hw.mac_type == e1000_ich8lan && i == 8) 893 + continue; 903 894 /* Interrupt to test */ 904 895 mask = 1 << i; 905 896 ··· 1259 1246 } else if (adapter->hw.phy_type == e1000_phy_gg82563) { 1260 1247 e1000_write_phy_reg(&adapter->hw, 1261 1248 GG82563_PHY_KMRN_MODE_CTRL, 1262 - 0x1CE); 1249 + 0x1CC); 1263 1250 } 1264 - /* force 1000, set loopback */ 1265 - e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140); 1266 1251 1267 - /* Now set up the MAC to the same speed/duplex as the PHY. */ 1268 1252 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); 1269 - ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1270 - ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1271 - E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1272 - E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ 1273 - E1000_CTRL_FD); /* Force Duplex to FULL */ 1253 + 1254 + if (adapter->hw.phy_type == e1000_phy_ife) { 1255 + /* force 100, set loopback */ 1256 + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x6100); 1257 + 1258 + /* Now set up the MAC to the same speed/duplex as the PHY. */ 1259 + ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1260 + ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1261 + E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1262 + E1000_CTRL_SPD_100 |/* Force Speed to 100 */ 1263 + E1000_CTRL_FD); /* Force Duplex to FULL */ 1264 + } else { 1265 + /* force 1000, set loopback */ 1266 + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140); 1267 + 1268 + /* Now set up the MAC to the same speed/duplex as the PHY. */ 1269 + ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); 1270 + ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1271 + ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1272 + E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1273 + E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ 1274 + E1000_CTRL_FD); /* Force Duplex to FULL */ 1275 + } 1274 1276 1275 1277 if (adapter->hw.media_type == e1000_media_type_copper && 1276 1278 adapter->hw.phy_type == e1000_phy_m88) { ··· 1345 1317 case e1000_82572: 1346 1318 case e1000_82573: 1347 1319 case e1000_80003es2lan: 1320 + case e1000_ich8lan: 1348 1321 return e1000_integrated_phy_loopback(adapter); 1349 1322 break; 1350 1323 ··· 1597 1568 struct e1000_adapter *adapter = netdev_priv(netdev); 1598 1569 boolean_t if_running = netif_running(netdev); 1599 1570 1571 + set_bit(__E1000_DRIVER_TESTING, &adapter->flags); 1600 1572 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { 1601 1573 /* Offline tests */ 1602 1574 ··· 1612 1582 eth_test->flags |= ETH_TEST_FL_FAILED; 1613 1583 1614 1584 if (if_running) 1615 - e1000_down(adapter); 1585 + /* indicate we're in test mode */ 1586 + dev_close(netdev); 1616 1587 else 1617 1588 e1000_reset(adapter); 1618 1589 ··· 1638 1607 adapter->hw.autoneg = autoneg; 1639 1608 1640 1609 e1000_reset(adapter); 1610 + clear_bit(__E1000_DRIVER_TESTING, &adapter->flags); 1641 1611 if (if_running) 1642 - e1000_up(adapter); 1612 + dev_open(netdev); 1643 1613 } else { 1644 1614 /* Online tests */ 1645 1615 if (e1000_link_test(adapter, &data[4])) ··· 1651 1619 data[1] = 0; 1652 1620 data[2] = 0; 1653 1621 data[3] = 0; 1622 + 1623 + clear_bit(__E1000_DRIVER_TESTING, &adapter->flags); 1654 1624 } 1655 1625 msleep_interruptible(4 * 1000); 1656 1626 } ··· 1812 1778 mod_timer(&adapter->blink_timer, jiffies); 1813 1779 msleep_interruptible(data * 1000); 1814 1780 del_timer_sync(&adapter->blink_timer); 1815 - } else if (adapter->hw.mac_type < e1000_82573) { 1816 - E1000_WRITE_REG(&adapter->hw, LEDCTL, 1817 - (E1000_LEDCTL_LED2_BLINK_RATE | 1818 - E1000_LEDCTL_LED0_BLINK | E1000_LEDCTL_LED2_BLINK | 1819 - (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) | 1820 - (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED0_MODE_SHIFT) | 1821 - (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED1_MODE_SHIFT))); 1781 + } else if (adapter->hw.phy_type == e1000_phy_ife) { 1782 + if (!adapter->blink_timer.function) { 1783 + init_timer(&adapter->blink_timer); 1784 + adapter->blink_timer.function = e1000_led_blink_callback; 1785 + adapter->blink_timer.data = (unsigned long) adapter; 1786 + } 1787 + mod_timer(&adapter->blink_timer, jiffies); 1822 1788 msleep_interruptible(data * 1000); 1789 + del_timer_sync(&adapter->blink_timer); 1790 + e1000_write_phy_reg(&(adapter->hw), IFE_PHY_SPECIAL_CONTROL_LED, 0); 1823 1791 } else { 1824 - E1000_WRITE_REG(&adapter->hw, LEDCTL, 1825 - (E1000_LEDCTL_LED2_BLINK_RATE | 1826 - E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK | 1827 - (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) | 1828 - (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED1_MODE_SHIFT) | 1829 - (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED0_MODE_SHIFT))); 1792 + e1000_blink_led_start(&adapter->hw); 1830 1793 msleep_interruptible(data * 1000); 1831 1794 } 1832 1795 ··· 1838 1807 e1000_nway_reset(struct net_device *netdev) 1839 1808 { 1840 1809 struct e1000_adapter *adapter = netdev_priv(netdev); 1841 - if (netif_running(netdev)) { 1842 - e1000_down(adapter); 1843 - e1000_up(adapter); 1844 - } 1810 + if (netif_running(netdev)) 1811 + e1000_reinit_locked(adapter); 1845 1812 return 0; 1846 1813 } 1847 1814
+1657 -115
drivers/net/e1000/e1000_hw.c
··· 101 101 102 102 #define E1000_WRITE_REG_IO(a, reg, val) \ 103 103 e1000_write_reg_io((a), E1000_##reg, val) 104 - static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw *hw); 104 + static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, 105 + uint16_t duplex); 105 106 static int32_t e1000_configure_kmrn_for_1000(struct e1000_hw *hw); 106 107 107 108 /* IGP cable length table */ ··· 157 156 hw->phy_type = e1000_phy_igp; 158 157 break; 159 158 } 159 + case IGP03E1000_E_PHY_ID: 160 + hw->phy_type = e1000_phy_igp_3; 161 + break; 162 + case IFE_E_PHY_ID: 163 + case IFE_PLUS_E_PHY_ID: 164 + case IFE_C_E_PHY_ID: 165 + hw->phy_type = e1000_phy_ife; 166 + break; 160 167 case GG82563_E_PHY_ID: 161 168 if (hw->mac_type == e1000_80003es2lan) { 162 169 hw->phy_type = e1000_phy_gg82563; ··· 341 332 break; 342 333 case E1000_DEV_ID_82541EI: 343 334 case E1000_DEV_ID_82541EI_MOBILE: 335 + case E1000_DEV_ID_82541ER_LOM: 344 336 hw->mac_type = e1000_82541; 345 337 break; 346 338 case E1000_DEV_ID_82541ER: ··· 351 341 hw->mac_type = e1000_82541_rev_2; 352 342 break; 353 343 case E1000_DEV_ID_82547EI: 344 + case E1000_DEV_ID_82547EI_MOBILE: 354 345 hw->mac_type = e1000_82547; 355 346 break; 356 347 case E1000_DEV_ID_82547GI: ··· 365 354 case E1000_DEV_ID_82572EI_COPPER: 366 355 case E1000_DEV_ID_82572EI_FIBER: 367 356 case E1000_DEV_ID_82572EI_SERDES: 357 + case E1000_DEV_ID_82572EI: 368 358 hw->mac_type = e1000_82572; 369 359 break; 370 360 case E1000_DEV_ID_82573E: ··· 373 361 case E1000_DEV_ID_82573L: 374 362 hw->mac_type = e1000_82573; 375 363 break; 364 + case E1000_DEV_ID_80003ES2LAN_COPPER_SPT: 365 + case E1000_DEV_ID_80003ES2LAN_SERDES_SPT: 376 366 case E1000_DEV_ID_80003ES2LAN_COPPER_DPT: 377 367 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: 378 368 hw->mac_type = e1000_80003es2lan; 369 + break; 370 + case E1000_DEV_ID_ICH8_IGP_M_AMT: 371 + case E1000_DEV_ID_ICH8_IGP_AMT: 372 + case E1000_DEV_ID_ICH8_IGP_C: 373 + case E1000_DEV_ID_ICH8_IFE: 374 + case E1000_DEV_ID_ICH8_IGP_M: 375 + hw->mac_type = e1000_ich8lan; 379 376 break; 380 377 default: 381 378 /* Should never have loaded on this device */ ··· 392 371 } 393 372 394 373 switch(hw->mac_type) { 374 + case e1000_ich8lan: 375 + hw->swfwhw_semaphore_present = TRUE; 376 + hw->asf_firmware_present = TRUE; 377 + break; 395 378 case e1000_80003es2lan: 396 379 hw->swfw_sync_present = TRUE; 397 380 /* fall through */ ··· 448 423 case e1000_82542_rev2_1: 449 424 hw->media_type = e1000_media_type_fiber; 450 425 break; 426 + case e1000_ich8lan: 451 427 case e1000_82573: 452 428 /* The STATUS_TBIMODE bit is reserved or reused for the this 453 429 * device. ··· 553 527 } while(timeout); 554 528 } 555 529 530 + /* Workaround for ICH8 bit corruption issue in FIFO memory */ 531 + if (hw->mac_type == e1000_ich8lan) { 532 + /* Set Tx and Rx buffer allocation to 8k apiece. */ 533 + E1000_WRITE_REG(hw, PBA, E1000_PBA_8K); 534 + /* Set Packet Buffer Size to 16k. */ 535 + E1000_WRITE_REG(hw, PBS, E1000_PBS_16K); 536 + } 537 + 556 538 /* Issue a global reset to the MAC. This will reset the chip's 557 539 * transmit, receive, DMA, and link units. It will not effect 558 540 * the current PCI configuration. The global reset bit is self- ··· 583 549 case e1000_82546_rev_3: 584 550 /* Reset is performed on a shadow of the control register */ 585 551 E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST)); 552 + break; 553 + case e1000_ich8lan: 554 + if (!hw->phy_reset_disable && 555 + e1000_check_phy_reset_block(hw) == E1000_SUCCESS) { 556 + /* e1000_ich8lan PHY HW reset requires MAC CORE reset 557 + * at the same time to make sure the interface between 558 + * MAC and the external PHY is reset. 559 + */ 560 + ctrl |= E1000_CTRL_PHY_RST; 561 + } 562 + 563 + e1000_get_software_flag(hw); 564 + E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST)); 565 + msec_delay(5); 586 566 break; 587 567 default: 588 568 E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST)); ··· 639 591 /* fall through */ 640 592 case e1000_82571: 641 593 case e1000_82572: 594 + case e1000_ich8lan: 642 595 case e1000_80003es2lan: 643 596 ret_val = e1000_get_auto_rd_done(hw); 644 597 if(ret_val) ··· 680 631 if(hw->mac_type == e1000_82542_rev2_0) { 681 632 if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE) 682 633 e1000_pci_set_mwi(hw); 634 + } 635 + 636 + if (hw->mac_type == e1000_ich8lan) { 637 + uint32_t kab = E1000_READ_REG(hw, KABGTXD); 638 + kab |= E1000_KABGTXD_BGSQLBIAS; 639 + E1000_WRITE_REG(hw, KABGTXD, kab); 683 640 } 684 641 685 642 return E1000_SUCCESS; ··· 730 675 731 676 /* Disabling VLAN filtering. */ 732 677 DEBUGOUT("Initializing the IEEE VLAN\n"); 733 - if (hw->mac_type < e1000_82545_rev_3) 734 - E1000_WRITE_REG(hw, VET, 0); 735 - e1000_clear_vfta(hw); 678 + /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */ 679 + if (hw->mac_type != e1000_ich8lan) { 680 + if (hw->mac_type < e1000_82545_rev_3) 681 + E1000_WRITE_REG(hw, VET, 0); 682 + e1000_clear_vfta(hw); 683 + } 736 684 737 685 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */ 738 686 if(hw->mac_type == e1000_82542_rev2_0) { ··· 763 705 /* Zero out the Multicast HASH table */ 764 706 DEBUGOUT("Zeroing the MTA\n"); 765 707 mta_size = E1000_MC_TBL_SIZE; 766 - for(i = 0; i < mta_size; i++) 708 + if (hw->mac_type == e1000_ich8lan) 709 + mta_size = E1000_MC_TBL_SIZE_ICH8LAN; 710 + for(i = 0; i < mta_size; i++) { 767 711 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 712 + /* use write flush to prevent Memory Write Block (MWB) from 713 + * occuring when accessing our register space */ 714 + E1000_WRITE_FLUSH(hw); 715 + } 768 716 769 717 /* Set the PCI priority bit correctly in the CTRL register. This 770 718 * determines if the adapter gives priority to receives, or if it ··· 808 744 break; 809 745 } 810 746 747 + /* More time needed for PHY to initialize */ 748 + if (hw->mac_type == e1000_ich8lan) 749 + msec_delay(15); 750 + 811 751 /* Call a subroutine to configure the link and setup flow control. */ 812 752 ret_val = e1000_setup_link(hw); 813 753 ··· 825 757 case e1000_82571: 826 758 case e1000_82572: 827 759 case e1000_82573: 760 + case e1000_ich8lan: 828 761 case e1000_80003es2lan: 829 762 ctrl |= E1000_TXDCTL_COUNT_DESC; 830 763 break; ··· 864 795 /* Fall through */ 865 796 case e1000_82571: 866 797 case e1000_82572: 798 + case e1000_ich8lan: 867 799 ctrl = E1000_READ_REG(hw, TXDCTL1); 868 800 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB; 869 801 if(hw->mac_type >= e1000_82571) ··· 887 817 * is no link. 888 818 */ 889 819 e1000_clear_hw_cntrs(hw); 820 + 821 + /* ICH8 No-snoop bits are opposite polarity. 822 + * Set to snoop by default after reset. */ 823 + if (hw->mac_type == e1000_ich8lan) 824 + e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL); 890 825 891 826 if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER || 892 827 hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) { ··· 980 905 */ 981 906 if (hw->fc == e1000_fc_default) { 982 907 switch (hw->mac_type) { 908 + case e1000_ich8lan: 983 909 case e1000_82573: 984 910 hw->fc = e1000_fc_full; 985 911 break; ··· 1047 971 */ 1048 972 DEBUGOUT("Initializing the Flow Control address, type and timer regs\n"); 1049 973 1050 - E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW); 1051 - E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH); 1052 - E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE); 974 + /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */ 975 + if (hw->mac_type != e1000_ich8lan) { 976 + E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE); 977 + E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH); 978 + E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW); 979 + } 1053 980 1054 981 E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time); 1055 982 ··· 1316 1237 1317 1238 /* Wait 10ms for MAC to configure PHY from eeprom settings */ 1318 1239 msec_delay(15); 1319 - 1240 + if (hw->mac_type != e1000_ich8lan) { 1320 1241 /* Configure activity LED after PHY reset */ 1321 1242 led_ctrl = E1000_READ_REG(hw, LEDCTL); 1322 1243 led_ctrl &= IGP_ACTIVITY_LED_MASK; 1323 1244 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE); 1324 1245 E1000_WRITE_REG(hw, LEDCTL, led_ctrl); 1246 + } 1325 1247 1326 1248 /* disable lplu d3 during driver init */ 1327 1249 ret_val = e1000_set_d3_lplu_state(hw, FALSE); ··· 1558 1478 if (ret_val) 1559 1479 return ret_val; 1560 1480 1561 - /* Enable Pass False Carrier on the PHY */ 1562 - phy_data |= GG82563_KMCR_PASS_FALSE_CARRIER; 1481 + phy_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; 1563 1482 1564 1483 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, 1565 1484 phy_data); ··· 1640 1561 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; 1641 1562 if(hw->disable_polarity_correction == 1) 1642 1563 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 1643 - ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1644 - if(ret_val) 1645 - return ret_val; 1646 - 1647 - /* Force TX_CLK in the Extended PHY Specific Control Register 1648 - * to 25MHz clock. 1649 - */ 1650 - ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data); 1651 - if(ret_val) 1564 + ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 1565 + if (ret_val) 1652 1566 return ret_val; 1653 1567 1654 - phy_data |= M88E1000_EPSCR_TX_CLK_25; 1655 - 1656 1568 if (hw->phy_revision < M88E1011_I_REV_4) { 1657 - /* Configure Master and Slave downshift values */ 1658 - phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | 1659 - M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); 1660 - phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | 1661 - M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); 1662 - ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data); 1663 - if(ret_val) 1569 + /* Force TX_CLK in the Extended PHY Specific Control Register 1570 + * to 25MHz clock. 1571 + */ 1572 + ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data); 1573 + if (ret_val) 1664 1574 return ret_val; 1575 + 1576 + phy_data |= M88E1000_EPSCR_TX_CLK_25; 1577 + 1578 + if ((hw->phy_revision == E1000_REVISION_2) && 1579 + (hw->phy_id == M88E1111_I_PHY_ID)) { 1580 + /* Vidalia Phy, set the downshift counter to 5x */ 1581 + phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK); 1582 + phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X; 1583 + ret_val = e1000_write_phy_reg(hw, 1584 + M88E1000_EXT_PHY_SPEC_CTRL, phy_data); 1585 + if (ret_val) 1586 + return ret_val; 1587 + } else { 1588 + /* Configure Master and Slave downshift values */ 1589 + phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | 1590 + M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); 1591 + phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | 1592 + M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); 1593 + ret_val = e1000_write_phy_reg(hw, 1594 + M88E1000_EXT_PHY_SPEC_CTRL, phy_data); 1595 + if (ret_val) 1596 + return ret_val; 1597 + } 1665 1598 } 1666 1599 1667 1600 /* SW Reset the PHY so all changes take effect */ ··· 1710 1619 */ 1711 1620 if(hw->autoneg_advertised == 0) 1712 1621 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT; 1622 + 1623 + /* IFE phy only supports 10/100 */ 1624 + if (hw->phy_type == e1000_phy_ife) 1625 + hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL; 1713 1626 1714 1627 DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); 1715 1628 ret_val = e1000_phy_setup_autoneg(hw); ··· 1812 1717 1813 1718 DEBUGFUNC("e1000_setup_copper_link"); 1814 1719 1720 + switch (hw->mac_type) { 1721 + case e1000_80003es2lan: 1722 + case e1000_ich8lan: 1723 + /* Set the mac to wait the maximum time between each 1724 + * iteration and increase the max iterations when 1725 + * polling the phy; this fixes erroneous timeouts at 10Mbps. */ 1726 + ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); 1727 + if (ret_val) 1728 + return ret_val; 1729 + ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data); 1730 + if (ret_val) 1731 + return ret_val; 1732 + reg_data |= 0x3F; 1733 + ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); 1734 + if (ret_val) 1735 + return ret_val; 1736 + default: 1737 + break; 1738 + } 1739 + 1815 1740 /* Check if it is a valid PHY and set PHY mode if necessary. */ 1816 1741 ret_val = e1000_copper_link_preconfig(hw); 1817 1742 if(ret_val) ··· 1839 1724 1840 1725 switch (hw->mac_type) { 1841 1726 case e1000_80003es2lan: 1842 - ret_val = e1000_read_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL, 1843 - &reg_data); 1844 - if (ret_val) 1845 - return ret_val; 1727 + /* Kumeran registers are written-only */ 1728 + reg_data = E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT; 1846 1729 reg_data |= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING; 1847 1730 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL, 1848 1731 reg_data); ··· 1852 1739 } 1853 1740 1854 1741 if (hw->phy_type == e1000_phy_igp || 1742 + hw->phy_type == e1000_phy_igp_3 || 1855 1743 hw->phy_type == e1000_phy_igp_2) { 1856 1744 ret_val = e1000_copper_link_igp_setup(hw); 1857 1745 if(ret_val) ··· 1917 1803 * hw - Struct containing variables accessed by shared code 1918 1804 ******************************************************************************/ 1919 1805 static int32_t 1920 - e1000_configure_kmrn_for_10_100(struct e1000_hw *hw) 1806 + e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, uint16_t duplex) 1921 1807 { 1922 1808 int32_t ret_val = E1000_SUCCESS; 1923 1809 uint32_t tipg; ··· 1936 1822 tipg &= ~E1000_TIPG_IPGT_MASK; 1937 1823 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100; 1938 1824 E1000_WRITE_REG(hw, TIPG, tipg); 1825 + 1826 + ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data); 1827 + 1828 + if (ret_val) 1829 + return ret_val; 1830 + 1831 + if (duplex == HALF_DUPLEX) 1832 + reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER; 1833 + else 1834 + reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; 1835 + 1836 + ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); 1939 1837 1940 1838 return ret_val; 1941 1839 } ··· 1973 1847 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000; 1974 1848 E1000_WRITE_REG(hw, TIPG, tipg); 1975 1849 1850 + ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data); 1851 + 1852 + if (ret_val) 1853 + return ret_val; 1854 + 1855 + reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; 1856 + ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); 1857 + 1976 1858 return ret_val; 1977 1859 } 1978 1860 ··· 2003 1869 if(ret_val) 2004 1870 return ret_val; 2005 1871 2006 - /* Read the MII 1000Base-T Control Register (Address 9). */ 2007 - ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg); 2008 - if(ret_val) 2009 - return ret_val; 1872 + if (hw->phy_type != e1000_phy_ife) { 1873 + /* Read the MII 1000Base-T Control Register (Address 9). */ 1874 + ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg); 1875 + if (ret_val) 1876 + return ret_val; 1877 + } else 1878 + mii_1000t_ctrl_reg=0; 2010 1879 2011 1880 /* Need to parse both autoneg_advertised and fc and set up 2012 1881 * the appropriate PHY registers. First we will parse for ··· 2060 1923 if(hw->autoneg_advertised & ADVERTISE_1000_FULL) { 2061 1924 DEBUGOUT("Advertise 1000mb Full duplex\n"); 2062 1925 mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS; 1926 + if (hw->phy_type == e1000_phy_ife) { 1927 + DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n"); 1928 + } 2063 1929 } 2064 1930 2065 1931 /* Check for a software override of the flow control settings, and ··· 2124 1984 2125 1985 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 2126 1986 2127 - ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); 2128 - if(ret_val) 2129 - return ret_val; 1987 + if (hw->phy_type != e1000_phy_ife) { 1988 + ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); 1989 + if (ret_val) 1990 + return ret_val; 1991 + } 2130 1992 2131 1993 return E1000_SUCCESS; 2132 1994 } ··· 2231 2089 2232 2090 /* Need to reset the PHY or these changes will be ignored */ 2233 2091 mii_ctrl_reg |= MII_CR_RESET; 2092 + /* Disable MDI-X support for 10/100 */ 2093 + } else if (hw->phy_type == e1000_phy_ife) { 2094 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data); 2095 + if (ret_val) 2096 + return ret_val; 2097 + 2098 + phy_data &= ~IFE_PMC_AUTO_MDIX; 2099 + phy_data &= ~IFE_PMC_FORCE_MDIX; 2100 + 2101 + ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data); 2102 + if (ret_val) 2103 + return ret_val; 2234 2104 } else { 2235 2105 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI 2236 2106 * forced whenever speed or duplex are forced. ··· 2875 2721 */ 2876 2722 if(hw->tbi_compatibility_en) { 2877 2723 uint16_t speed, duplex; 2878 - e1000_get_speed_and_duplex(hw, &speed, &duplex); 2879 - if(speed != SPEED_1000) { 2724 + ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex); 2725 + if (ret_val) { 2726 + DEBUGOUT("Error getting link speed and duplex\n"); 2727 + return ret_val; 2728 + } 2729 + if (speed != SPEED_1000) { 2880 2730 /* If link speed is not set to gigabit speed, we do not need 2881 2731 * to enable TBI compatibility. 2882 2732 */ ··· 3047 2889 if (*speed == SPEED_1000) 3048 2890 ret_val = e1000_configure_kmrn_for_1000(hw); 3049 2891 else 3050 - ret_val = e1000_configure_kmrn_for_10_100(hw); 2892 + ret_val = e1000_configure_kmrn_for_10_100(hw, *duplex); 2893 + if (ret_val) 2894 + return ret_val; 2895 + } 2896 + 2897 + if ((hw->phy_type == e1000_phy_igp_3) && (*speed == SPEED_1000)) { 2898 + ret_val = e1000_kumeran_lock_loss_workaround(hw); 3051 2899 if (ret_val) 3052 2900 return ret_val; 3053 2901 } ··· 3243 3079 3244 3080 DEBUGFUNC("e1000_swfw_sync_acquire"); 3245 3081 3082 + if (hw->swfwhw_semaphore_present) 3083 + return e1000_get_software_flag(hw); 3084 + 3246 3085 if (!hw->swfw_sync_present) 3247 3086 return e1000_get_hw_eeprom_semaphore(hw); 3248 3087 ··· 3284 3117 uint32_t swmask = mask; 3285 3118 3286 3119 DEBUGFUNC("e1000_swfw_sync_release"); 3120 + 3121 + if (hw->swfwhw_semaphore_present) { 3122 + e1000_release_software_flag(hw); 3123 + return; 3124 + } 3287 3125 3288 3126 if (!hw->swfw_sync_present) { 3289 3127 e1000_put_hw_eeprom_semaphore(hw); ··· 3332 3160 if (e1000_swfw_sync_acquire(hw, swfw)) 3333 3161 return -E1000_ERR_SWFW_SYNC; 3334 3162 3335 - if((hw->phy_type == e1000_phy_igp || 3163 + if ((hw->phy_type == e1000_phy_igp || 3164 + hw->phy_type == e1000_phy_igp_3 || 3336 3165 hw->phy_type == e1000_phy_igp_2) && 3337 3166 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 3338 3167 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, ··· 3472 3299 if (e1000_swfw_sync_acquire(hw, swfw)) 3473 3300 return -E1000_ERR_SWFW_SYNC; 3474 3301 3475 - if((hw->phy_type == e1000_phy_igp || 3302 + if ((hw->phy_type == e1000_phy_igp || 3303 + hw->phy_type == e1000_phy_igp_3 || 3476 3304 hw->phy_type == e1000_phy_igp_2) && 3477 3305 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 3478 3306 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, ··· 3688 3514 E1000_WRITE_FLUSH(hw); 3689 3515 3690 3516 if (hw->mac_type >= e1000_82571) 3691 - msec_delay(10); 3517 + msec_delay_irq(10); 3692 3518 e1000_swfw_sync_release(hw, swfw); 3693 3519 } else { 3694 3520 /* Read the Extended Device Control Register, assert the PHY_RESET_DIR ··· 3718 3544 ret_val = e1000_get_phy_cfg_done(hw); 3719 3545 e1000_release_software_semaphore(hw); 3720 3546 3547 + if ((hw->mac_type == e1000_ich8lan) && 3548 + (hw->phy_type == e1000_phy_igp_3)) { 3549 + ret_val = e1000_init_lcd_from_nvm(hw); 3550 + if (ret_val) 3551 + return ret_val; 3552 + } 3721 3553 return ret_val; 3722 3554 } 3723 3555 ··· 3752 3572 case e1000_82541_rev_2: 3753 3573 case e1000_82571: 3754 3574 case e1000_82572: 3575 + case e1000_ich8lan: 3755 3576 ret_val = e1000_phy_hw_reset(hw); 3756 3577 if(ret_val) 3757 3578 return ret_val; 3579 + 3758 3580 break; 3759 3581 default: 3760 3582 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data); ··· 3779 3597 } 3780 3598 3781 3599 /****************************************************************************** 3600 + * Work-around for 82566 power-down: on D3 entry- 3601 + * 1) disable gigabit link 3602 + * 2) write VR power-down enable 3603 + * 3) read it back 3604 + * if successful continue, else issue LCD reset and repeat 3605 + * 3606 + * hw - struct containing variables accessed by shared code 3607 + ******************************************************************************/ 3608 + void 3609 + e1000_phy_powerdown_workaround(struct e1000_hw *hw) 3610 + { 3611 + int32_t reg; 3612 + uint16_t phy_data; 3613 + int32_t retry = 0; 3614 + 3615 + DEBUGFUNC("e1000_phy_powerdown_workaround"); 3616 + 3617 + if (hw->phy_type != e1000_phy_igp_3) 3618 + return; 3619 + 3620 + do { 3621 + /* Disable link */ 3622 + reg = E1000_READ_REG(hw, PHY_CTRL); 3623 + E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE | 3624 + E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 3625 + 3626 + /* Write VR power-down enable */ 3627 + e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3628 + e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data | 3629 + IGP3_VR_CTRL_MODE_SHUT); 3630 + 3631 + /* Read it back and test */ 3632 + e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3633 + if ((phy_data & IGP3_VR_CTRL_MODE_SHUT) || retry) 3634 + break; 3635 + 3636 + /* Issue PHY reset and repeat at most one more time */ 3637 + reg = E1000_READ_REG(hw, CTRL); 3638 + E1000_WRITE_REG(hw, CTRL, reg | E1000_CTRL_PHY_RST); 3639 + retry++; 3640 + } while (retry); 3641 + 3642 + return; 3643 + 3644 + } 3645 + 3646 + /****************************************************************************** 3647 + * Work-around for 82566 Kumeran PCS lock loss: 3648 + * On link status change (i.e. PCI reset, speed change) and link is up and 3649 + * speed is gigabit- 3650 + * 0) if workaround is optionally disabled do nothing 3651 + * 1) wait 1ms for Kumeran link to come up 3652 + * 2) check Kumeran Diagnostic register PCS lock loss bit 3653 + * 3) if not set the link is locked (all is good), otherwise... 3654 + * 4) reset the PHY 3655 + * 5) repeat up to 10 times 3656 + * Note: this is only called for IGP3 copper when speed is 1gb. 3657 + * 3658 + * hw - struct containing variables accessed by shared code 3659 + ******************************************************************************/ 3660 + int32_t 3661 + e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw) 3662 + { 3663 + int32_t ret_val; 3664 + int32_t reg; 3665 + int32_t cnt; 3666 + uint16_t phy_data; 3667 + 3668 + if (hw->kmrn_lock_loss_workaround_disabled) 3669 + return E1000_SUCCESS; 3670 + 3671 + /* Make sure link is up before proceeding. If not just return. 3672 + * Attempting this while link is negotiating fouls up link 3673 + * stability */ 3674 + ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data); 3675 + ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data); 3676 + 3677 + if (phy_data & MII_SR_LINK_STATUS) { 3678 + for (cnt = 0; cnt < 10; cnt++) { 3679 + /* read once to clear */ 3680 + ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data); 3681 + if (ret_val) 3682 + return ret_val; 3683 + /* and again to get new status */ 3684 + ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data); 3685 + if (ret_val) 3686 + return ret_val; 3687 + 3688 + /* check for PCS lock */ 3689 + if (!(phy_data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS)) 3690 + return E1000_SUCCESS; 3691 + 3692 + /* Issue PHY reset */ 3693 + e1000_phy_hw_reset(hw); 3694 + msec_delay_irq(5); 3695 + } 3696 + /* Disable GigE link negotiation */ 3697 + reg = E1000_READ_REG(hw, PHY_CTRL); 3698 + E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE | 3699 + E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 3700 + 3701 + /* unable to acquire PCS lock */ 3702 + return E1000_ERR_PHY; 3703 + } 3704 + 3705 + return E1000_SUCCESS; 3706 + } 3707 + 3708 + /****************************************************************************** 3782 3709 * Probes the expected PHY address for known PHY IDs 3783 3710 * 3784 3711 * hw - Struct containing variables accessed by shared code 3785 3712 ******************************************************************************/ 3786 - static int32_t 3713 + int32_t 3787 3714 e1000_detect_gig_phy(struct e1000_hw *hw) 3788 3715 { 3789 3716 int32_t phy_init_status, ret_val; ··· 3904 3613 /* The 82571 firmware may still be configuring the PHY. In this 3905 3614 * case, we cannot access the PHY until the configuration is done. So 3906 3615 * we explicitly set the PHY values. */ 3907 - if(hw->mac_type == e1000_82571 || 3908 - hw->mac_type == e1000_82572) { 3616 + if (hw->mac_type == e1000_82571 || 3617 + hw->mac_type == e1000_82572) { 3909 3618 hw->phy_id = IGP01E1000_I_PHY_ID; 3910 3619 hw->phy_type = e1000_phy_igp_2; 3911 3620 return E1000_SUCCESS; ··· 3922 3631 3923 3632 /* Read the PHY ID Registers to identify which PHY is onboard. */ 3924 3633 ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high); 3925 - if(ret_val) 3634 + if (ret_val) 3926 3635 return ret_val; 3927 3636 3928 3637 hw->phy_id = (uint32_t) (phy_id_high << 16); ··· 3959 3668 break; 3960 3669 case e1000_80003es2lan: 3961 3670 if (hw->phy_id == GG82563_E_PHY_ID) match = TRUE; 3671 + break; 3672 + case e1000_ich8lan: 3673 + if (hw->phy_id == IGP03E1000_E_PHY_ID) match = TRUE; 3674 + if (hw->phy_id == IFE_E_PHY_ID) match = TRUE; 3675 + if (hw->phy_id == IFE_PLUS_E_PHY_ID) match = TRUE; 3676 + if (hw->phy_id == IFE_C_E_PHY_ID) match = TRUE; 3962 3677 break; 3963 3678 default: 3964 3679 DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type); ··· 4076 3779 else 4077 3780 phy_info->cable_length = e1000_cable_length_140; 4078 3781 } 3782 + 3783 + return E1000_SUCCESS; 3784 + } 3785 + 3786 + /****************************************************************************** 3787 + * Get PHY information from various PHY registers for ife PHY only. 3788 + * 3789 + * hw - Struct containing variables accessed by shared code 3790 + * phy_info - PHY information structure 3791 + ******************************************************************************/ 3792 + int32_t 3793 + e1000_phy_ife_get_info(struct e1000_hw *hw, 3794 + struct e1000_phy_info *phy_info) 3795 + { 3796 + int32_t ret_val; 3797 + uint16_t phy_data, polarity; 3798 + 3799 + DEBUGFUNC("e1000_phy_ife_get_info"); 3800 + 3801 + phy_info->downshift = (e1000_downshift)hw->speed_downgraded; 3802 + phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal; 3803 + 3804 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data); 3805 + if (ret_val) 3806 + return ret_val; 3807 + phy_info->polarity_correction = 3808 + (phy_data & IFE_PSC_AUTO_POLARITY_DISABLE) >> 3809 + IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT; 3810 + 3811 + if (phy_info->polarity_correction == e1000_polarity_reversal_enabled) { 3812 + ret_val = e1000_check_polarity(hw, &polarity); 3813 + if (ret_val) 3814 + return ret_val; 3815 + } else { 3816 + /* Polarity is forced. */ 3817 + polarity = (phy_data & IFE_PSC_FORCE_POLARITY) >> 3818 + IFE_PSC_FORCE_POLARITY_SHIFT; 3819 + } 3820 + phy_info->cable_polarity = polarity; 3821 + 3822 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data); 3823 + if (ret_val) 3824 + return ret_val; 3825 + 3826 + phy_info->mdix_mode = 3827 + (phy_data & (IFE_PMC_AUTO_MDIX | IFE_PMC_FORCE_MDIX)) >> 3828 + IFE_PMC_MDIX_MODE_SHIFT; 4079 3829 4080 3830 return E1000_SUCCESS; 4081 3831 } ··· 4242 3898 return -E1000_ERR_CONFIG; 4243 3899 } 4244 3900 4245 - if(hw->phy_type == e1000_phy_igp || 3901 + if (hw->phy_type == e1000_phy_igp || 3902 + hw->phy_type == e1000_phy_igp_3 || 4246 3903 hw->phy_type == e1000_phy_igp_2) 4247 3904 return e1000_phy_igp_get_info(hw, phy_info); 3905 + else if (hw->phy_type == e1000_phy_ife) 3906 + return e1000_phy_ife_get_info(hw, phy_info); 4248 3907 else 4249 3908 return e1000_phy_m88_get_info(hw, phy_info); 4250 3909 } ··· 4396 4049 eeprom->use_eerd = TRUE; 4397 4050 eeprom->use_eewr = FALSE; 4398 4051 break; 4052 + case e1000_ich8lan: 4053 + { 4054 + int32_t i = 0; 4055 + uint32_t flash_size = E1000_READ_ICH8_REG(hw, ICH8_FLASH_GFPREG); 4056 + 4057 + eeprom->type = e1000_eeprom_ich8; 4058 + eeprom->use_eerd = FALSE; 4059 + eeprom->use_eewr = FALSE; 4060 + eeprom->word_size = E1000_SHADOW_RAM_WORDS; 4061 + 4062 + /* Zero the shadow RAM structure. But don't load it from NVM 4063 + * so as to save time for driver init */ 4064 + if (hw->eeprom_shadow_ram != NULL) { 4065 + for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) { 4066 + hw->eeprom_shadow_ram[i].modified = FALSE; 4067 + hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF; 4068 + } 4069 + } 4070 + 4071 + hw->flash_base_addr = (flash_size & ICH8_GFPREG_BASE_MASK) * 4072 + ICH8_FLASH_SECTOR_SIZE; 4073 + 4074 + hw->flash_bank_size = ((flash_size >> 16) & ICH8_GFPREG_BASE_MASK) + 1; 4075 + hw->flash_bank_size -= (flash_size & ICH8_GFPREG_BASE_MASK); 4076 + hw->flash_bank_size *= ICH8_FLASH_SECTOR_SIZE; 4077 + hw->flash_bank_size /= 2 * sizeof(uint16_t); 4078 + 4079 + break; 4080 + } 4399 4081 default: 4400 4082 break; 4401 4083 } ··· 4845 4469 return ret_val; 4846 4470 } 4847 4471 4848 - if(eeprom->type == e1000_eeprom_spi) { 4472 + if (eeprom->type == e1000_eeprom_ich8) 4473 + return e1000_read_eeprom_ich8(hw, offset, words, data); 4474 + 4475 + if (eeprom->type == e1000_eeprom_spi) { 4849 4476 uint16_t word_in; 4850 4477 uint8_t read_opcode = EEPROM_READ_OPCODE_SPI; 4851 4478 ··· 5015 4636 5016 4637 DEBUGFUNC("e1000_is_onboard_nvm_eeprom"); 5017 4638 5018 - if(hw->mac_type == e1000_82573) { 4639 + if (hw->mac_type == e1000_ich8lan) 4640 + return FALSE; 4641 + 4642 + if (hw->mac_type == e1000_82573) { 5019 4643 eecd = E1000_READ_REG(hw, EECD); 5020 4644 5021 4645 /* Isolate bits 15 & 16 */ ··· 5068 4686 } 5069 4687 } 5070 4688 5071 - for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { 5072 - if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { 4689 + if (hw->mac_type == e1000_ich8lan) { 4690 + /* Drivers must allocate the shadow ram structure for the 4691 + * EEPROM checksum to be updated. Otherwise, this bit as well 4692 + * as the checksum must both be set correctly for this 4693 + * validation to pass. 4694 + */ 4695 + e1000_read_eeprom(hw, 0x19, 1, &eeprom_data); 4696 + if ((eeprom_data & 0x40) == 0) { 4697 + eeprom_data |= 0x40; 4698 + e1000_write_eeprom(hw, 0x19, 1, &eeprom_data); 4699 + e1000_update_eeprom_checksum(hw); 4700 + } 4701 + } 4702 + 4703 + for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { 4704 + if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { 5073 4705 DEBUGOUT("EEPROM Read Error\n"); 5074 4706 return -E1000_ERR_EEPROM; 5075 4707 } ··· 5109 4713 int32_t 5110 4714 e1000_update_eeprom_checksum(struct e1000_hw *hw) 5111 4715 { 4716 + uint32_t ctrl_ext; 5112 4717 uint16_t checksum = 0; 5113 4718 uint16_t i, eeprom_data; 5114 4719 ··· 5128 4731 return -E1000_ERR_EEPROM; 5129 4732 } else if (hw->eeprom.type == e1000_eeprom_flash) { 5130 4733 e1000_commit_shadow_ram(hw); 4734 + } else if (hw->eeprom.type == e1000_eeprom_ich8) { 4735 + e1000_commit_shadow_ram(hw); 4736 + /* Reload the EEPROM, or else modifications will not appear 4737 + * until after next adapter reset. */ 4738 + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); 4739 + ctrl_ext |= E1000_CTRL_EXT_EE_RST; 4740 + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 4741 + msec_delay(10); 5131 4742 } 5132 4743 return E1000_SUCCESS; 5133 4744 } ··· 5174 4769 /* 82573 writes only through eewr */ 5175 4770 if(eeprom->use_eewr == TRUE) 5176 4771 return e1000_write_eeprom_eewr(hw, offset, words, data); 4772 + 4773 + if (eeprom->type == e1000_eeprom_ich8) 4774 + return e1000_write_eeprom_ich8(hw, offset, words, data); 5177 4775 5178 4776 /* Prepare the EEPROM for writing */ 5179 4777 if (e1000_acquire_eeprom(hw) != E1000_SUCCESS) ··· 5365 4957 uint32_t flop = 0; 5366 4958 uint32_t i = 0; 5367 4959 int32_t error = E1000_SUCCESS; 5368 - 5369 - /* The flop register will be used to determine if flash type is STM */ 5370 - flop = E1000_READ_REG(hw, FLOP); 4960 + uint32_t old_bank_offset = 0; 4961 + uint32_t new_bank_offset = 0; 4962 + uint32_t sector_retries = 0; 4963 + uint8_t low_byte = 0; 4964 + uint8_t high_byte = 0; 4965 + uint8_t temp_byte = 0; 4966 + boolean_t sector_write_failed = FALSE; 5371 4967 5372 4968 if (hw->mac_type == e1000_82573) { 4969 + /* The flop register will be used to determine if flash type is STM */ 4970 + flop = E1000_READ_REG(hw, FLOP); 5373 4971 for (i=0; i < attempts; i++) { 5374 4972 eecd = E1000_READ_REG(hw, EECD); 5375 4973 if ((eecd & E1000_EECD_FLUPD) == 0) { ··· 5407 4993 if (i == attempts) { 5408 4994 return -E1000_ERR_EEPROM; 5409 4995 } 4996 + } 4997 + 4998 + if (hw->mac_type == e1000_ich8lan && hw->eeprom_shadow_ram != NULL) { 4999 + /* We're writing to the opposite bank so if we're on bank 1, 5000 + * write to bank 0 etc. We also need to erase the segment that 5001 + * is going to be written */ 5002 + if (!(E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL)) { 5003 + new_bank_offset = hw->flash_bank_size * 2; 5004 + old_bank_offset = 0; 5005 + e1000_erase_ich8_4k_segment(hw, 1); 5006 + } else { 5007 + old_bank_offset = hw->flash_bank_size * 2; 5008 + new_bank_offset = 0; 5009 + e1000_erase_ich8_4k_segment(hw, 0); 5010 + } 5011 + 5012 + do { 5013 + sector_write_failed = FALSE; 5014 + /* Loop for every byte in the shadow RAM, 5015 + * which is in units of words. */ 5016 + for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) { 5017 + /* Determine whether to write the value stored 5018 + * in the other NVM bank or a modified value stored 5019 + * in the shadow RAM */ 5020 + if (hw->eeprom_shadow_ram[i].modified == TRUE) { 5021 + low_byte = (uint8_t)hw->eeprom_shadow_ram[i].eeprom_word; 5022 + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset, 5023 + &temp_byte); 5024 + udelay(100); 5025 + error = e1000_verify_write_ich8_byte(hw, 5026 + (i << 1) + new_bank_offset, 5027 + low_byte); 5028 + if (error != E1000_SUCCESS) 5029 + sector_write_failed = TRUE; 5030 + high_byte = 5031 + (uint8_t)(hw->eeprom_shadow_ram[i].eeprom_word >> 8); 5032 + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1, 5033 + &temp_byte); 5034 + udelay(100); 5035 + } else { 5036 + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset, 5037 + &low_byte); 5038 + udelay(100); 5039 + error = e1000_verify_write_ich8_byte(hw, 5040 + (i << 1) + new_bank_offset, low_byte); 5041 + if (error != E1000_SUCCESS) 5042 + sector_write_failed = TRUE; 5043 + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1, 5044 + &high_byte); 5045 + } 5046 + 5047 + /* If the word is 0x13, then make sure the signature bits 5048 + * (15:14) are 11b until the commit has completed. 5049 + * This will allow us to write 10b which indicates the 5050 + * signature is valid. We want to do this after the write 5051 + * has completed so that we don't mark the segment valid 5052 + * while the write is still in progress */ 5053 + if (i == E1000_ICH8_NVM_SIG_WORD) 5054 + high_byte = E1000_ICH8_NVM_SIG_MASK | high_byte; 5055 + 5056 + error = e1000_verify_write_ich8_byte(hw, 5057 + (i << 1) + new_bank_offset + 1, high_byte); 5058 + if (error != E1000_SUCCESS) 5059 + sector_write_failed = TRUE; 5060 + 5061 + if (sector_write_failed == FALSE) { 5062 + /* Clear the now not used entry in the cache */ 5063 + hw->eeprom_shadow_ram[i].modified = FALSE; 5064 + hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF; 5065 + } 5066 + } 5067 + 5068 + /* Don't bother writing the segment valid bits if sector 5069 + * programming failed. */ 5070 + if (sector_write_failed == FALSE) { 5071 + /* Finally validate the new segment by setting bit 15:14 5072 + * to 10b in word 0x13 , this can be done without an 5073 + * erase as well since these bits are 11 to start with 5074 + * and we need to change bit 14 to 0b */ 5075 + e1000_read_ich8_byte(hw, 5076 + E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, 5077 + &high_byte); 5078 + high_byte &= 0xBF; 5079 + error = e1000_verify_write_ich8_byte(hw, 5080 + E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, 5081 + high_byte); 5082 + if (error != E1000_SUCCESS) 5083 + sector_write_failed = TRUE; 5084 + 5085 + /* And invalidate the previously valid segment by setting 5086 + * its signature word (0x13) high_byte to 0b. This can be 5087 + * done without an erase because flash erase sets all bits 5088 + * to 1's. We can write 1's to 0's without an erase */ 5089 + error = e1000_verify_write_ich8_byte(hw, 5090 + E1000_ICH8_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 5091 + 0); 5092 + if (error != E1000_SUCCESS) 5093 + sector_write_failed = TRUE; 5094 + } 5095 + } while (++sector_retries < 10 && sector_write_failed == TRUE); 5410 5096 } 5411 5097 5412 5098 return error; ··· 5616 5102 * the other port. */ 5617 5103 if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE)) 5618 5104 rar_num -= 1; 5105 + if (hw->mac_type == e1000_ich8lan) 5106 + rar_num = E1000_RAR_ENTRIES_ICH8LAN; 5107 + 5619 5108 /* Zero out the other 15 receive addresses. */ 5620 5109 DEBUGOUT("Clearing RAR[1-15]\n"); 5621 5110 for(i = 1; i < rar_num; i++) { 5622 5111 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); 5112 + E1000_WRITE_FLUSH(hw); 5623 5113 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); 5114 + E1000_WRITE_FLUSH(hw); 5624 5115 } 5625 5116 } 5626 5117 5627 - #if 0 5628 5118 /****************************************************************************** 5629 5119 * Updates the MAC's list of multicast addresses. 5630 5120 * ··· 5663 5145 /* Clear RAR[1-15] */ 5664 5146 DEBUGOUT(" Clearing RAR[1-15]\n"); 5665 5147 num_rar_entry = E1000_RAR_ENTRIES; 5148 + if (hw->mac_type == e1000_ich8lan) 5149 + num_rar_entry = E1000_RAR_ENTRIES_ICH8LAN; 5666 5150 /* Reserve a spot for the Locally Administered Address to work around 5667 5151 * an 82571 issue in which a reset on one port will reload the MAC on 5668 5152 * the other port. */ ··· 5673 5153 5674 5154 for(i = rar_used_count; i < num_rar_entry; i++) { 5675 5155 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); 5156 + E1000_WRITE_FLUSH(hw); 5676 5157 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); 5158 + E1000_WRITE_FLUSH(hw); 5677 5159 } 5678 5160 5679 5161 /* Clear the MTA */ 5680 5162 DEBUGOUT(" Clearing MTA\n"); 5681 5163 num_mta_entry = E1000_NUM_MTA_REGISTERS; 5164 + if (hw->mac_type == e1000_ich8lan) 5165 + num_mta_entry = E1000_NUM_MTA_REGISTERS_ICH8LAN; 5682 5166 for(i = 0; i < num_mta_entry; i++) { 5683 5167 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 5168 + E1000_WRITE_FLUSH(hw); 5684 5169 } 5685 5170 5686 5171 /* Add the new addresses */ ··· 5719 5194 } 5720 5195 DEBUGOUT("MC Update Complete\n"); 5721 5196 } 5722 - #endif /* 0 */ 5723 5197 5724 5198 /****************************************************************************** 5725 5199 * Hashes an address to determine its location in the multicast table ··· 5741 5217 * LSB MSB 5742 5218 */ 5743 5219 case 0: 5744 - /* [47:36] i.e. 0x563 for above example address */ 5745 - hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4)); 5220 + if (hw->mac_type == e1000_ich8lan) { 5221 + /* [47:38] i.e. 0x158 for above example address */ 5222 + hash_value = ((mc_addr[4] >> 6) | (((uint16_t) mc_addr[5]) << 2)); 5223 + } else { 5224 + /* [47:36] i.e. 0x563 for above example address */ 5225 + hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4)); 5226 + } 5746 5227 break; 5747 5228 case 1: 5748 - /* [46:35] i.e. 0xAC6 for above example address */ 5749 - hash_value = ((mc_addr[4] >> 3) | (((uint16_t) mc_addr[5]) << 5)); 5229 + if (hw->mac_type == e1000_ich8lan) { 5230 + /* [46:37] i.e. 0x2B1 for above example address */ 5231 + hash_value = ((mc_addr[4] >> 5) | (((uint16_t) mc_addr[5]) << 3)); 5232 + } else { 5233 + /* [46:35] i.e. 0xAC6 for above example address */ 5234 + hash_value = ((mc_addr[4] >> 3) | (((uint16_t) mc_addr[5]) << 5)); 5235 + } 5750 5236 break; 5751 5237 case 2: 5752 - /* [45:34] i.e. 0x5D8 for above example address */ 5753 - hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6)); 5238 + if (hw->mac_type == e1000_ich8lan) { 5239 + /*[45:36] i.e. 0x163 for above example address */ 5240 + hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4)); 5241 + } else { 5242 + /* [45:34] i.e. 0x5D8 for above example address */ 5243 + hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6)); 5244 + } 5754 5245 break; 5755 5246 case 3: 5756 - /* [43:32] i.e. 0x634 for above example address */ 5757 - hash_value = ((mc_addr[4]) | (((uint16_t) mc_addr[5]) << 8)); 5247 + if (hw->mac_type == e1000_ich8lan) { 5248 + /* [43:34] i.e. 0x18D for above example address */ 5249 + hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6)); 5250 + } else { 5251 + /* [43:32] i.e. 0x634 for above example address */ 5252 + hash_value = ((mc_addr[4]) | (((uint16_t) mc_addr[5]) << 8)); 5253 + } 5758 5254 break; 5759 5255 } 5760 5256 5761 5257 hash_value &= 0xFFF; 5258 + if (hw->mac_type == e1000_ich8lan) 5259 + hash_value &= 0x3FF; 5762 5260 5763 5261 return hash_value; 5764 5262 } ··· 5808 5262 * register are determined by the lower 5 bits of the value. 5809 5263 */ 5810 5264 hash_reg = (hash_value >> 5) & 0x7F; 5265 + if (hw->mac_type == e1000_ich8lan) 5266 + hash_reg &= 0x1F; 5811 5267 hash_bit = hash_value & 0x1F; 5812 5268 5813 5269 mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg); ··· 5823 5275 if((hw->mac_type == e1000_82544) && ((hash_reg & 0x1) == 1)) { 5824 5276 temp = E1000_READ_REG_ARRAY(hw, MTA, (hash_reg - 1)); 5825 5277 E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta); 5278 + E1000_WRITE_FLUSH(hw); 5826 5279 E1000_WRITE_REG_ARRAY(hw, MTA, (hash_reg - 1), temp); 5280 + E1000_WRITE_FLUSH(hw); 5827 5281 } else { 5828 5282 E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta); 5283 + E1000_WRITE_FLUSH(hw); 5829 5284 } 5830 5285 } 5831 5286 ··· 5885 5334 } 5886 5335 5887 5336 E1000_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low); 5337 + E1000_WRITE_FLUSH(hw); 5888 5338 E1000_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high); 5339 + E1000_WRITE_FLUSH(hw); 5889 5340 } 5890 5341 5891 5342 /****************************************************************************** ··· 5904 5351 { 5905 5352 uint32_t temp; 5906 5353 5907 - if((hw->mac_type == e1000_82544) && ((offset & 0x1) == 1)) { 5354 + if (hw->mac_type == e1000_ich8lan) 5355 + return; 5356 + 5357 + if ((hw->mac_type == e1000_82544) && ((offset & 0x1) == 1)) { 5908 5358 temp = E1000_READ_REG_ARRAY(hw, VFTA, (offset - 1)); 5909 5359 E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value); 5360 + E1000_WRITE_FLUSH(hw); 5910 5361 E1000_WRITE_REG_ARRAY(hw, VFTA, (offset - 1), temp); 5362 + E1000_WRITE_FLUSH(hw); 5911 5363 } else { 5912 5364 E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value); 5365 + E1000_WRITE_FLUSH(hw); 5913 5366 } 5914 5367 } 5915 5368 ··· 5931 5372 uint32_t vfta_value = 0; 5932 5373 uint32_t vfta_offset = 0; 5933 5374 uint32_t vfta_bit_in_reg = 0; 5375 + 5376 + if (hw->mac_type == e1000_ich8lan) 5377 + return; 5934 5378 5935 5379 if (hw->mac_type == e1000_82573) { 5936 5380 if (hw->mng_cookie.vlan_id != 0) { ··· 5954 5392 * manageability unit */ 5955 5393 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0; 5956 5394 E1000_WRITE_REG_ARRAY(hw, VFTA, offset, vfta_value); 5395 + E1000_WRITE_FLUSH(hw); 5957 5396 } 5958 5397 } 5959 5398 ··· 5984 5421 DEBUGOUT("EEPROM Read Error\n"); 5985 5422 return -E1000_ERR_EEPROM; 5986 5423 } 5987 - if((eeprom_data== ID_LED_RESERVED_0000) || 5988 - (eeprom_data == ID_LED_RESERVED_FFFF)) eeprom_data = ID_LED_DEFAULT; 5989 - for(i = 0; i < 4; i++) { 5424 + 5425 + if ((hw->mac_type == e1000_82573) && 5426 + (eeprom_data == ID_LED_RESERVED_82573)) 5427 + eeprom_data = ID_LED_DEFAULT_82573; 5428 + else if ((eeprom_data == ID_LED_RESERVED_0000) || 5429 + (eeprom_data == ID_LED_RESERVED_FFFF)) { 5430 + if (hw->mac_type == e1000_ich8lan) 5431 + eeprom_data = ID_LED_DEFAULT_ICH8LAN; 5432 + else 5433 + eeprom_data = ID_LED_DEFAULT; 5434 + } 5435 + for (i = 0; i < 4; i++) { 5990 5436 temp = (eeprom_data >> (i << 2)) & led_mask; 5991 5437 switch(temp) { 5992 5438 case ID_LED_ON1_DEF2: ··· 6091 5519 } 6092 5520 6093 5521 /****************************************************************************** 5522 + * Used on 82571 and later Si that has LED blink bits. 5523 + * Callers must use their own timer and should have already called 5524 + * e1000_id_led_init() 5525 + * Call e1000_cleanup led() to stop blinking 5526 + * 5527 + * hw - Struct containing variables accessed by shared code 5528 + *****************************************************************************/ 5529 + int32_t 5530 + e1000_blink_led_start(struct e1000_hw *hw) 5531 + { 5532 + int16_t i; 5533 + uint32_t ledctl_blink = 0; 5534 + 5535 + DEBUGFUNC("e1000_id_led_blink_on"); 5536 + 5537 + if (hw->mac_type < e1000_82571) { 5538 + /* Nothing to do */ 5539 + return E1000_SUCCESS; 5540 + } 5541 + if (hw->media_type == e1000_media_type_fiber) { 5542 + /* always blink LED0 for PCI-E fiber */ 5543 + ledctl_blink = E1000_LEDCTL_LED0_BLINK | 5544 + (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); 5545 + } else { 5546 + /* set the blink bit for each LED that's "on" (0x0E) in ledctl_mode2 */ 5547 + ledctl_blink = hw->ledctl_mode2; 5548 + for (i=0; i < 4; i++) 5549 + if (((hw->ledctl_mode2 >> (i * 8)) & 0xFF) == 5550 + E1000_LEDCTL_MODE_LED_ON) 5551 + ledctl_blink |= (E1000_LEDCTL_LED0_BLINK << (i * 8)); 5552 + } 5553 + 5554 + E1000_WRITE_REG(hw, LEDCTL, ledctl_blink); 5555 + 5556 + return E1000_SUCCESS; 5557 + } 5558 + 5559 + /****************************************************************************** 6094 5560 * Restores the saved state of the SW controlable LED. 6095 5561 * 6096 5562 * hw - Struct containing variables accessed by shared code ··· 6158 5548 return ret_val; 6159 5549 /* Fall Through */ 6160 5550 default: 5551 + if (hw->phy_type == e1000_phy_ife) { 5552 + e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); 5553 + break; 5554 + } 6161 5555 /* Restore LEDCTL settings */ 6162 5556 E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_default); 6163 5557 break; ··· 6206 5592 /* Clear SW Defineable Pin 0 to turn on the LED */ 6207 5593 ctrl &= ~E1000_CTRL_SWDPIN0; 6208 5594 ctrl |= E1000_CTRL_SWDPIO0; 6209 - } else if(hw->media_type == e1000_media_type_copper) { 5595 + } else if (hw->phy_type == e1000_phy_ife) { 5596 + e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 5597 + (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON)); 5598 + } else if (hw->media_type == e1000_media_type_copper) { 6210 5599 E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode2); 6211 5600 return E1000_SUCCESS; 6212 5601 } ··· 6257 5640 /* Set SW Defineable Pin 0 to turn off the LED */ 6258 5641 ctrl |= E1000_CTRL_SWDPIN0; 6259 5642 ctrl |= E1000_CTRL_SWDPIO0; 6260 - } else if(hw->media_type == e1000_media_type_copper) { 5643 + } else if (hw->phy_type == e1000_phy_ife) { 5644 + e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 5645 + (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF)); 5646 + } else if (hw->media_type == e1000_media_type_copper) { 6261 5647 E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1); 6262 5648 return E1000_SUCCESS; 6263 5649 } ··· 6298 5678 temp = E1000_READ_REG(hw, XOFFRXC); 6299 5679 temp = E1000_READ_REG(hw, XOFFTXC); 6300 5680 temp = E1000_READ_REG(hw, FCRUC); 5681 + 5682 + if (hw->mac_type != e1000_ich8lan) { 6301 5683 temp = E1000_READ_REG(hw, PRC64); 6302 5684 temp = E1000_READ_REG(hw, PRC127); 6303 5685 temp = E1000_READ_REG(hw, PRC255); 6304 5686 temp = E1000_READ_REG(hw, PRC511); 6305 5687 temp = E1000_READ_REG(hw, PRC1023); 6306 5688 temp = E1000_READ_REG(hw, PRC1522); 5689 + } 5690 + 6307 5691 temp = E1000_READ_REG(hw, GPRC); 6308 5692 temp = E1000_READ_REG(hw, BPRC); 6309 5693 temp = E1000_READ_REG(hw, MPRC); ··· 6327 5703 temp = E1000_READ_REG(hw, TOTH); 6328 5704 temp = E1000_READ_REG(hw, TPR); 6329 5705 temp = E1000_READ_REG(hw, TPT); 5706 + 5707 + if (hw->mac_type != e1000_ich8lan) { 6330 5708 temp = E1000_READ_REG(hw, PTC64); 6331 5709 temp = E1000_READ_REG(hw, PTC127); 6332 5710 temp = E1000_READ_REG(hw, PTC255); 6333 5711 temp = E1000_READ_REG(hw, PTC511); 6334 5712 temp = E1000_READ_REG(hw, PTC1023); 6335 5713 temp = E1000_READ_REG(hw, PTC1522); 5714 + } 5715 + 6336 5716 temp = E1000_READ_REG(hw, MPTC); 6337 5717 temp = E1000_READ_REG(hw, BPTC); 6338 5718 ··· 6359 5731 6360 5732 temp = E1000_READ_REG(hw, IAC); 6361 5733 temp = E1000_READ_REG(hw, ICRXOC); 5734 + 5735 + if (hw->mac_type == e1000_ich8lan) return; 5736 + 6362 5737 temp = E1000_READ_REG(hw, ICRXPTC); 6363 5738 temp = E1000_READ_REG(hw, ICRXATC); 6364 5739 temp = E1000_READ_REG(hw, ICTXPTC); ··· 6542 5911 hw->bus_width = e1000_bus_width_pciex_1; 6543 5912 break; 6544 5913 case e1000_82571: 5914 + case e1000_ich8lan: 6545 5915 case e1000_80003es2lan: 6546 5916 hw->bus_type = e1000_bus_type_pci_express; 6547 5917 hw->bus_speed = e1000_bus_speed_2500; ··· 6580 5948 break; 6581 5949 } 6582 5950 } 6583 - 6584 - #if 0 6585 5951 /****************************************************************************** 6586 5952 * Reads a value from one of the devices registers using port I/O (as opposed 6587 5953 * memory mapped I/O). Only 82544 and newer devices support port I/O. ··· 6597 5967 e1000_io_write(hw, io_addr, offset); 6598 5968 return e1000_io_read(hw, io_data); 6599 5969 } 6600 - #endif /* 0 */ 6601 5970 6602 5971 /****************************************************************************** 6603 5972 * Writes a value to one of the devices registers using port I/O (as opposed to ··· 6641 6012 { 6642 6013 int32_t ret_val; 6643 6014 uint16_t agc_value = 0; 6644 - uint16_t cur_agc, min_agc = IGP01E1000_AGC_LENGTH_TABLE_SIZE; 6645 - uint16_t max_agc = 0; 6646 6015 uint16_t i, phy_data; 6647 6016 uint16_t cable_length; 6648 6017 ··· 6713 6086 break; 6714 6087 } 6715 6088 } else if(hw->phy_type == e1000_phy_igp) { /* For IGP PHY */ 6089 + uint16_t cur_agc_value; 6090 + uint16_t min_agc_value = IGP01E1000_AGC_LENGTH_TABLE_SIZE; 6716 6091 uint16_t agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = 6717 6092 {IGP01E1000_PHY_AGC_A, 6718 6093 IGP01E1000_PHY_AGC_B, ··· 6727 6098 if(ret_val) 6728 6099 return ret_val; 6729 6100 6730 - cur_agc = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT; 6101 + cur_agc_value = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT; 6731 6102 6732 - /* Array bound check. */ 6733 - if((cur_agc >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) || 6734 - (cur_agc == 0)) 6103 + /* Value bound check. */ 6104 + if ((cur_agc_value >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) || 6105 + (cur_agc_value == 0)) 6735 6106 return -E1000_ERR_PHY; 6736 6107 6737 - agc_value += cur_agc; 6108 + agc_value += cur_agc_value; 6738 6109 6739 6110 /* Update minimal AGC value. */ 6740 - if(min_agc > cur_agc) 6741 - min_agc = cur_agc; 6111 + if (min_agc_value > cur_agc_value) 6112 + min_agc_value = cur_agc_value; 6742 6113 } 6743 6114 6744 6115 /* Remove the minimal AGC result for length < 50m */ 6745 - if(agc_value < IGP01E1000_PHY_CHANNEL_NUM * e1000_igp_cable_length_50) { 6746 - agc_value -= min_agc; 6116 + if (agc_value < IGP01E1000_PHY_CHANNEL_NUM * e1000_igp_cable_length_50) { 6117 + agc_value -= min_agc_value; 6747 6118 6748 6119 /* Get the average length of the remaining 3 channels */ 6749 6120 agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1); ··· 6759 6130 IGP01E1000_AGC_RANGE) : 0; 6760 6131 *max_length = e1000_igp_cable_length_table[agc_value] + 6761 6132 IGP01E1000_AGC_RANGE; 6762 - } else if (hw->phy_type == e1000_phy_igp_2) { 6133 + } else if (hw->phy_type == e1000_phy_igp_2 || 6134 + hw->phy_type == e1000_phy_igp_3) { 6135 + uint16_t cur_agc_index, max_agc_index = 0; 6136 + uint16_t min_agc_index = IGP02E1000_AGC_LENGTH_TABLE_SIZE - 1; 6763 6137 uint16_t agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] = 6764 6138 {IGP02E1000_PHY_AGC_A, 6765 6139 IGP02E1000_PHY_AGC_B, ··· 6777 6145 /* Getting bits 15:9, which represent the combination of course and 6778 6146 * fine gain values. The result is a number that can be put into 6779 6147 * the lookup table to obtain the approximate cable length. */ 6780 - cur_agc = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) & 6781 - IGP02E1000_AGC_LENGTH_MASK; 6148 + cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) & 6149 + IGP02E1000_AGC_LENGTH_MASK; 6150 + 6151 + /* Array index bound check. */ 6152 + if ((cur_agc_index >= IGP02E1000_AGC_LENGTH_TABLE_SIZE) || 6153 + (cur_agc_index == 0)) 6154 + return -E1000_ERR_PHY; 6782 6155 6783 6156 /* Remove min & max AGC values from calculation. */ 6784 - if (e1000_igp_2_cable_length_table[min_agc] > e1000_igp_2_cable_length_table[cur_agc]) 6785 - min_agc = cur_agc; 6786 - if (e1000_igp_2_cable_length_table[max_agc] < e1000_igp_2_cable_length_table[cur_agc]) 6787 - max_agc = cur_agc; 6157 + if (e1000_igp_2_cable_length_table[min_agc_index] > 6158 + e1000_igp_2_cable_length_table[cur_agc_index]) 6159 + min_agc_index = cur_agc_index; 6160 + if (e1000_igp_2_cable_length_table[max_agc_index] < 6161 + e1000_igp_2_cable_length_table[cur_agc_index]) 6162 + max_agc_index = cur_agc_index; 6788 6163 6789 - agc_value += e1000_igp_2_cable_length_table[cur_agc]; 6164 + agc_value += e1000_igp_2_cable_length_table[cur_agc_index]; 6790 6165 } 6791 6166 6792 - agc_value -= (e1000_igp_2_cable_length_table[min_agc] + e1000_igp_2_cable_length_table[max_agc]); 6167 + agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] + 6168 + e1000_igp_2_cable_length_table[max_agc_index]); 6793 6169 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2); 6794 6170 6795 6171 /* Calculate cable length with the error range of +/- 10 meters. */ ··· 6843 6203 return ret_val; 6844 6204 *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >> 6845 6205 M88E1000_PSSR_REV_POLARITY_SHIFT; 6846 - } else if(hw->phy_type == e1000_phy_igp || 6206 + } else if (hw->phy_type == e1000_phy_igp || 6207 + hw->phy_type == e1000_phy_igp_3 || 6847 6208 hw->phy_type == e1000_phy_igp_2) { 6848 6209 /* Read the Status register to check the speed */ 6849 6210 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, ··· 6870 6229 * 100 Mbps this bit is always 0) */ 6871 6230 *polarity = phy_data & IGP01E1000_PSSR_POLARITY_REVERSED; 6872 6231 } 6232 + } else if (hw->phy_type == e1000_phy_ife) { 6233 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_EXTENDED_STATUS_CONTROL, 6234 + &phy_data); 6235 + if (ret_val) 6236 + return ret_val; 6237 + *polarity = (phy_data & IFE_PESC_POLARITY_REVERSED) >> 6238 + IFE_PESC_POLARITY_REVERSED_SHIFT; 6873 6239 } 6874 6240 return E1000_SUCCESS; 6875 6241 } ··· 6904 6256 6905 6257 DEBUGFUNC("e1000_check_downshift"); 6906 6258 6907 - if(hw->phy_type == e1000_phy_igp || 6259 + if (hw->phy_type == e1000_phy_igp || 6260 + hw->phy_type == e1000_phy_igp_3 || 6908 6261 hw->phy_type == e1000_phy_igp_2) { 6909 6262 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH, 6910 6263 &phy_data); ··· 6922 6273 6923 6274 hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >> 6924 6275 M88E1000_PSSR_DOWNSHIFT_SHIFT; 6276 + } else if (hw->phy_type == e1000_phy_ife) { 6277 + /* e1000_phy_ife supports 10/100 speed only */ 6278 + hw->speed_downgraded = FALSE; 6925 6279 } 6926 6280 6927 6281 return E1000_SUCCESS; ··· 6969 6317 6970 6318 if(speed == SPEED_1000) { 6971 6319 6972 - e1000_get_cable_length(hw, &min_length, &max_length); 6320 + ret_val = e1000_get_cable_length(hw, &min_length, &max_length); 6321 + if (ret_val) 6322 + return ret_val; 6973 6323 6974 6324 if((hw->dsp_config_state == e1000_dsp_config_enabled) && 6975 6325 min_length >= e1000_igp_cable_length_50) { ··· 7179 6525 e1000_set_d3_lplu_state(struct e1000_hw *hw, 7180 6526 boolean_t active) 7181 6527 { 6528 + uint32_t phy_ctrl = 0; 7182 6529 int32_t ret_val; 7183 6530 uint16_t phy_data; 7184 6531 DEBUGFUNC("e1000_set_d3_lplu_state"); 7185 6532 7186 - if(hw->phy_type != e1000_phy_igp && hw->phy_type != e1000_phy_igp_2) 6533 + if (hw->phy_type != e1000_phy_igp && hw->phy_type != e1000_phy_igp_2 6534 + && hw->phy_type != e1000_phy_igp_3) 7187 6535 return E1000_SUCCESS; 7188 6536 7189 6537 /* During driver activity LPLU should not be used or it will attain link 7190 6538 * from the lowest speeds starting from 10Mbps. The capability is used for 7191 6539 * Dx transitions and states */ 7192 - if(hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) { 6540 + if (hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) { 7193 6541 ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO, &phy_data); 7194 - if(ret_val) 6542 + if (ret_val) 7195 6543 return ret_val; 6544 + } else if (hw->mac_type == e1000_ich8lan) { 6545 + /* MAC writes into PHY register based on the state transition 6546 + * and start auto-negotiation. SW driver can overwrite the settings 6547 + * in CSR PHY power control E1000_PHY_CTRL register. */ 6548 + phy_ctrl = E1000_READ_REG(hw, PHY_CTRL); 7196 6549 } else { 7197 6550 ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data); 7198 6551 if(ret_val) ··· 7214 6553 if(ret_val) 7215 6554 return ret_val; 7216 6555 } else { 6556 + if (hw->mac_type == e1000_ich8lan) { 6557 + phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; 6558 + E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl); 6559 + } else { 7217 6560 phy_data &= ~IGP02E1000_PM_D3_LPLU; 7218 6561 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, 7219 6562 phy_data); 7220 6563 if (ret_val) 7221 6564 return ret_val; 6565 + } 7222 6566 } 7223 6567 7224 6568 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during ··· 7259 6593 (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) { 7260 6594 7261 6595 if(hw->mac_type == e1000_82541_rev_2 || 7262 - hw->mac_type == e1000_82547_rev_2) { 6596 + hw->mac_type == e1000_82547_rev_2) { 7263 6597 phy_data |= IGP01E1000_GMII_FLEX_SPD; 7264 6598 ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data); 7265 6599 if(ret_val) 7266 6600 return ret_val; 7267 6601 } else { 6602 + if (hw->mac_type == e1000_ich8lan) { 6603 + phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; 6604 + E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl); 6605 + } else { 7268 6606 phy_data |= IGP02E1000_PM_D3_LPLU; 7269 6607 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, 7270 6608 phy_data); 7271 6609 if (ret_val) 7272 6610 return ret_val; 6611 + } 7273 6612 } 7274 6613 7275 6614 /* When LPLU is enabled we should disable SmartSpeed */ ··· 7309 6638 e1000_set_d0_lplu_state(struct e1000_hw *hw, 7310 6639 boolean_t active) 7311 6640 { 6641 + uint32_t phy_ctrl = 0; 7312 6642 int32_t ret_val; 7313 6643 uint16_t phy_data; 7314 6644 DEBUGFUNC("e1000_set_d0_lplu_state"); ··· 7317 6645 if(hw->mac_type <= e1000_82547_rev_2) 7318 6646 return E1000_SUCCESS; 7319 6647 6648 + if (hw->mac_type == e1000_ich8lan) { 6649 + phy_ctrl = E1000_READ_REG(hw, PHY_CTRL); 6650 + } else { 7320 6651 ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data); 7321 6652 if(ret_val) 7322 6653 return ret_val; 6654 + } 7323 6655 7324 6656 if (!active) { 6657 + if (hw->mac_type == e1000_ich8lan) { 6658 + phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; 6659 + E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl); 6660 + } else { 7325 6661 phy_data &= ~IGP02E1000_PM_D0_LPLU; 7326 6662 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data); 7327 6663 if (ret_val) 7328 6664 return ret_val; 6665 + } 7329 6666 7330 6667 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during 7331 6668 * Dx states where the power conservation is most important. During ··· 7367 6686 7368 6687 } else { 7369 6688 6689 + if (hw->mac_type == e1000_ich8lan) { 6690 + phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; 6691 + E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl); 6692 + } else { 7370 6693 phy_data |= IGP02E1000_PM_D0_LPLU; 7371 6694 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data); 7372 6695 if (ret_val) 7373 6696 return ret_val; 6697 + } 7374 6698 7375 6699 /* When LPLU is enabled we should disable SmartSpeed */ 7376 6700 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data); ··· 7614 6928 7615 6929 length >>= 2; 7616 6930 /* The device driver writes the relevant command block into the ram area. */ 7617 - for (i = 0; i < length; i++) 6931 + for (i = 0; i < length; i++) { 7618 6932 E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, i, *((uint32_t *) hdr + i)); 6933 + E1000_WRITE_FLUSH(hw); 6934 + } 7619 6935 7620 6936 return E1000_SUCCESS; 7621 6937 } ··· 7649 6961 * returns - TRUE when the mode is IAMT or FALSE. 7650 6962 ****************************************************************************/ 7651 6963 boolean_t 7652 - e1000_check_mng_mode( 7653 - struct e1000_hw *hw) 6964 + e1000_check_mng_mode(struct e1000_hw *hw) 7654 6965 { 7655 6966 uint32_t fwsm; 7656 6967 7657 6968 fwsm = E1000_READ_REG(hw, FWSM); 7658 6969 7659 - if((fwsm & E1000_FWSM_MODE_MASK) == 7660 - (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)) 6970 + if (hw->mac_type == e1000_ich8lan) { 6971 + if ((fwsm & E1000_FWSM_MODE_MASK) == 6972 + (E1000_MNG_ICH_IAMT_MODE << E1000_FWSM_MODE_SHIFT)) 6973 + return TRUE; 6974 + } else if ((fwsm & E1000_FWSM_MODE_MASK) == 6975 + (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)) 7661 6976 return TRUE; 7662 6977 7663 6978 return FALSE; ··· 7900 7209 E1000_WRITE_REG(hw, CTRL, ctrl); 7901 7210 } 7902 7211 7903 - #if 0 7904 7212 /*************************************************************************** 7905 7213 * 7906 7214 * Enables PCI-Express master access. ··· 7923 7233 ctrl &= ~E1000_CTRL_GIO_MASTER_DISABLE; 7924 7234 E1000_WRITE_REG(hw, CTRL, ctrl); 7925 7235 } 7926 - #endif /* 0 */ 7927 7236 7928 7237 /******************************************************************************* 7929 7238 * ··· 7988 7299 case e1000_82572: 7989 7300 case e1000_82573: 7990 7301 case e1000_80003es2lan: 7991 - while(timeout) { 7992 - if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD) break; 7302 + case e1000_ich8lan: 7303 + while (timeout) { 7304 + if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD) 7305 + break; 7993 7306 else msec_delay(1); 7994 7307 timeout--; 7995 7308 } ··· 8031 7340 8032 7341 switch (hw->mac_type) { 8033 7342 default: 8034 - msec_delay(10); 7343 + msec_delay_irq(10); 8035 7344 break; 8036 7345 case e1000_80003es2lan: 8037 7346 /* Separate *_CFG_DONE_* bit for each port */ ··· 8214 7523 e1000_check_phy_reset_block(struct e1000_hw *hw) 8215 7524 { 8216 7525 uint32_t manc = 0; 7526 + uint32_t fwsm = 0; 7527 + 7528 + if (hw->mac_type == e1000_ich8lan) { 7529 + fwsm = E1000_READ_REG(hw, FWSM); 7530 + return (fwsm & E1000_FWSM_RSPCIPHY) ? E1000_SUCCESS 7531 + : E1000_BLK_PHY_RESET; 7532 + } 8217 7533 8218 7534 if (hw->mac_type > e1000_82547_rev_2) 8219 7535 manc = E1000_READ_REG(hw, MANC); ··· 8247 7549 if((fwsm & E1000_FWSM_MODE_MASK) != 0) 8248 7550 return TRUE; 8249 7551 break; 7552 + case e1000_ich8lan: 7553 + return TRUE; 8250 7554 default: 8251 7555 break; 8252 7556 } 8253 7557 return FALSE; 7558 + } 7559 + 7560 + 7561 + /****************************************************************************** 7562 + * Configure PCI-Ex no-snoop 7563 + * 7564 + * hw - Struct containing variables accessed by shared code. 7565 + * no_snoop - Bitmap of no-snoop events. 7566 + * 7567 + * returns: E1000_SUCCESS 7568 + * 7569 + *****************************************************************************/ 7570 + int32_t 7571 + e1000_set_pci_ex_no_snoop(struct e1000_hw *hw, uint32_t no_snoop) 7572 + { 7573 + uint32_t gcr_reg = 0; 7574 + 7575 + DEBUGFUNC("e1000_set_pci_ex_no_snoop"); 7576 + 7577 + if (hw->bus_type == e1000_bus_type_unknown) 7578 + e1000_get_bus_info(hw); 7579 + 7580 + if (hw->bus_type != e1000_bus_type_pci_express) 7581 + return E1000_SUCCESS; 7582 + 7583 + if (no_snoop) { 7584 + gcr_reg = E1000_READ_REG(hw, GCR); 7585 + gcr_reg &= ~(PCI_EX_NO_SNOOP_ALL); 7586 + gcr_reg |= no_snoop; 7587 + E1000_WRITE_REG(hw, GCR, gcr_reg); 7588 + } 7589 + if (hw->mac_type == e1000_ich8lan) { 7590 + uint32_t ctrl_ext; 7591 + 7592 + E1000_WRITE_REG(hw, GCR, PCI_EX_82566_SNOOP_ALL); 7593 + 7594 + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); 7595 + ctrl_ext |= E1000_CTRL_EXT_RO_DIS; 7596 + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 7597 + } 7598 + 7599 + return E1000_SUCCESS; 7600 + } 7601 + 7602 + /*************************************************************************** 7603 + * 7604 + * Get software semaphore FLAG bit (SWFLAG). 7605 + * SWFLAG is used to synchronize the access to all shared resource between 7606 + * SW, FW and HW. 7607 + * 7608 + * hw: Struct containing variables accessed by shared code 7609 + * 7610 + ***************************************************************************/ 7611 + int32_t 7612 + e1000_get_software_flag(struct e1000_hw *hw) 7613 + { 7614 + int32_t timeout = PHY_CFG_TIMEOUT; 7615 + uint32_t extcnf_ctrl; 7616 + 7617 + DEBUGFUNC("e1000_get_software_flag"); 7618 + 7619 + if (hw->mac_type == e1000_ich8lan) { 7620 + while (timeout) { 7621 + extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL); 7622 + extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; 7623 + E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl); 7624 + 7625 + extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL); 7626 + if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) 7627 + break; 7628 + msec_delay_irq(1); 7629 + timeout--; 7630 + } 7631 + 7632 + if (!timeout) { 7633 + DEBUGOUT("FW or HW locks the resource too long.\n"); 7634 + return -E1000_ERR_CONFIG; 7635 + } 7636 + } 7637 + 7638 + return E1000_SUCCESS; 7639 + } 7640 + 7641 + /*************************************************************************** 7642 + * 7643 + * Release software semaphore FLAG bit (SWFLAG). 7644 + * SWFLAG is used to synchronize the access to all shared resource between 7645 + * SW, FW and HW. 7646 + * 7647 + * hw: Struct containing variables accessed by shared code 7648 + * 7649 + ***************************************************************************/ 7650 + void 7651 + e1000_release_software_flag(struct e1000_hw *hw) 7652 + { 7653 + uint32_t extcnf_ctrl; 7654 + 7655 + DEBUGFUNC("e1000_release_software_flag"); 7656 + 7657 + if (hw->mac_type == e1000_ich8lan) { 7658 + extcnf_ctrl= E1000_READ_REG(hw, EXTCNF_CTRL); 7659 + extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 7660 + E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl); 7661 + } 7662 + 7663 + return; 7664 + } 7665 + 7666 + /*************************************************************************** 7667 + * 7668 + * Disable dynamic power down mode in ife PHY. 7669 + * It can be used to workaround band-gap problem. 7670 + * 7671 + * hw: Struct containing variables accessed by shared code 7672 + * 7673 + ***************************************************************************/ 7674 + int32_t 7675 + e1000_ife_disable_dynamic_power_down(struct e1000_hw *hw) 7676 + { 7677 + uint16_t phy_data; 7678 + int32_t ret_val = E1000_SUCCESS; 7679 + 7680 + DEBUGFUNC("e1000_ife_disable_dynamic_power_down"); 7681 + 7682 + if (hw->phy_type == e1000_phy_ife) { 7683 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data); 7684 + if (ret_val) 7685 + return ret_val; 7686 + 7687 + phy_data |= IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN; 7688 + ret_val = e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, phy_data); 7689 + } 7690 + 7691 + return ret_val; 7692 + } 7693 + 7694 + /*************************************************************************** 7695 + * 7696 + * Enable dynamic power down mode in ife PHY. 7697 + * It can be used to workaround band-gap problem. 7698 + * 7699 + * hw: Struct containing variables accessed by shared code 7700 + * 7701 + ***************************************************************************/ 7702 + int32_t 7703 + e1000_ife_enable_dynamic_power_down(struct e1000_hw *hw) 7704 + { 7705 + uint16_t phy_data; 7706 + int32_t ret_val = E1000_SUCCESS; 7707 + 7708 + DEBUGFUNC("e1000_ife_enable_dynamic_power_down"); 7709 + 7710 + if (hw->phy_type == e1000_phy_ife) { 7711 + ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data); 7712 + if (ret_val) 7713 + return ret_val; 7714 + 7715 + phy_data &= ~IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN; 7716 + ret_val = e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, phy_data); 7717 + } 7718 + 7719 + return ret_val; 7720 + } 7721 + 7722 + /****************************************************************************** 7723 + * Reads a 16 bit word or words from the EEPROM using the ICH8's flash access 7724 + * register. 7725 + * 7726 + * hw - Struct containing variables accessed by shared code 7727 + * offset - offset of word in the EEPROM to read 7728 + * data - word read from the EEPROM 7729 + * words - number of words to read 7730 + *****************************************************************************/ 7731 + int32_t 7732 + e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words, 7733 + uint16_t *data) 7734 + { 7735 + int32_t error = E1000_SUCCESS; 7736 + uint32_t flash_bank = 0; 7737 + uint32_t act_offset = 0; 7738 + uint32_t bank_offset = 0; 7739 + uint16_t word = 0; 7740 + uint16_t i = 0; 7741 + 7742 + /* We need to know which is the valid flash bank. In the event 7743 + * that we didn't allocate eeprom_shadow_ram, we may not be 7744 + * managing flash_bank. So it cannot be trusted and needs 7745 + * to be updated with each read. 7746 + */ 7747 + /* Value of bit 22 corresponds to the flash bank we're on. */ 7748 + flash_bank = (E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL) ? 1 : 0; 7749 + 7750 + /* Adjust offset appropriately if we're on bank 1 - adjust for word size */ 7751 + bank_offset = flash_bank * (hw->flash_bank_size * 2); 7752 + 7753 + error = e1000_get_software_flag(hw); 7754 + if (error != E1000_SUCCESS) 7755 + return error; 7756 + 7757 + for (i = 0; i < words; i++) { 7758 + if (hw->eeprom_shadow_ram != NULL && 7759 + hw->eeprom_shadow_ram[offset+i].modified == TRUE) { 7760 + data[i] = hw->eeprom_shadow_ram[offset+i].eeprom_word; 7761 + } else { 7762 + /* The NVM part needs a byte offset, hence * 2 */ 7763 + act_offset = bank_offset + ((offset + i) * 2); 7764 + error = e1000_read_ich8_word(hw, act_offset, &word); 7765 + if (error != E1000_SUCCESS) 7766 + break; 7767 + data[i] = word; 7768 + } 7769 + } 7770 + 7771 + e1000_release_software_flag(hw); 7772 + 7773 + return error; 7774 + } 7775 + 7776 + /****************************************************************************** 7777 + * Writes a 16 bit word or words to the EEPROM using the ICH8's flash access 7778 + * register. Actually, writes are written to the shadow ram cache in the hw 7779 + * structure hw->e1000_shadow_ram. e1000_commit_shadow_ram flushes this to 7780 + * the NVM, which occurs when the NVM checksum is updated. 7781 + * 7782 + * hw - Struct containing variables accessed by shared code 7783 + * offset - offset of word in the EEPROM to write 7784 + * words - number of words to write 7785 + * data - words to write to the EEPROM 7786 + *****************************************************************************/ 7787 + int32_t 7788 + e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words, 7789 + uint16_t *data) 7790 + { 7791 + uint32_t i = 0; 7792 + int32_t error = E1000_SUCCESS; 7793 + 7794 + error = e1000_get_software_flag(hw); 7795 + if (error != E1000_SUCCESS) 7796 + return error; 7797 + 7798 + /* A driver can write to the NVM only if it has eeprom_shadow_ram 7799 + * allocated. Subsequent reads to the modified words are read from 7800 + * this cached structure as well. Writes will only go into this 7801 + * cached structure unless it's followed by a call to 7802 + * e1000_update_eeprom_checksum() where it will commit the changes 7803 + * and clear the "modified" field. 7804 + */ 7805 + if (hw->eeprom_shadow_ram != NULL) { 7806 + for (i = 0; i < words; i++) { 7807 + if ((offset + i) < E1000_SHADOW_RAM_WORDS) { 7808 + hw->eeprom_shadow_ram[offset+i].modified = TRUE; 7809 + hw->eeprom_shadow_ram[offset+i].eeprom_word = data[i]; 7810 + } else { 7811 + error = -E1000_ERR_EEPROM; 7812 + break; 7813 + } 7814 + } 7815 + } else { 7816 + /* Drivers have the option to not allocate eeprom_shadow_ram as long 7817 + * as they don't perform any NVM writes. An attempt in doing so 7818 + * will result in this error. 7819 + */ 7820 + error = -E1000_ERR_EEPROM; 7821 + } 7822 + 7823 + e1000_release_software_flag(hw); 7824 + 7825 + return error; 7826 + } 7827 + 7828 + /****************************************************************************** 7829 + * This function does initial flash setup so that a new read/write/erase cycle 7830 + * can be started. 7831 + * 7832 + * hw - The pointer to the hw structure 7833 + ****************************************************************************/ 7834 + int32_t 7835 + e1000_ich8_cycle_init(struct e1000_hw *hw) 7836 + { 7837 + union ich8_hws_flash_status hsfsts; 7838 + int32_t error = E1000_ERR_EEPROM; 7839 + int32_t i = 0; 7840 + 7841 + DEBUGFUNC("e1000_ich8_cycle_init"); 7842 + 7843 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 7844 + 7845 + /* May be check the Flash Des Valid bit in Hw status */ 7846 + if (hsfsts.hsf_status.fldesvalid == 0) { 7847 + DEBUGOUT("Flash descriptor invalid. SW Sequencing must be used."); 7848 + return error; 7849 + } 7850 + 7851 + /* Clear FCERR in Hw status by writing 1 */ 7852 + /* Clear DAEL in Hw status by writing a 1 */ 7853 + hsfsts.hsf_status.flcerr = 1; 7854 + hsfsts.hsf_status.dael = 1; 7855 + 7856 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 7857 + 7858 + /* Either we should have a hardware SPI cycle in progress bit to check 7859 + * against, in order to start a new cycle or FDONE bit should be changed 7860 + * in the hardware so that it is 1 after harware reset, which can then be 7861 + * used as an indication whether a cycle is in progress or has been 7862 + * completed .. we should also have some software semaphore mechanism to 7863 + * guard FDONE or the cycle in progress bit so that two threads access to 7864 + * those bits can be sequentiallized or a way so that 2 threads dont 7865 + * start the cycle at the same time */ 7866 + 7867 + if (hsfsts.hsf_status.flcinprog == 0) { 7868 + /* There is no cycle running at present, so we can start a cycle */ 7869 + /* Begin by setting Flash Cycle Done. */ 7870 + hsfsts.hsf_status.flcdone = 1; 7871 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 7872 + error = E1000_SUCCESS; 7873 + } else { 7874 + /* otherwise poll for sometime so the current cycle has a chance 7875 + * to end before giving up. */ 7876 + for (i = 0; i < ICH8_FLASH_COMMAND_TIMEOUT; i++) { 7877 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 7878 + if (hsfsts.hsf_status.flcinprog == 0) { 7879 + error = E1000_SUCCESS; 7880 + break; 7881 + } 7882 + udelay(1); 7883 + } 7884 + if (error == E1000_SUCCESS) { 7885 + /* Successful in waiting for previous cycle to timeout, 7886 + * now set the Flash Cycle Done. */ 7887 + hsfsts.hsf_status.flcdone = 1; 7888 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 7889 + } else { 7890 + DEBUGOUT("Flash controller busy, cannot get access"); 7891 + } 7892 + } 7893 + return error; 7894 + } 7895 + 7896 + /****************************************************************************** 7897 + * This function starts a flash cycle and waits for its completion 7898 + * 7899 + * hw - The pointer to the hw structure 7900 + ****************************************************************************/ 7901 + int32_t 7902 + e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout) 7903 + { 7904 + union ich8_hws_flash_ctrl hsflctl; 7905 + union ich8_hws_flash_status hsfsts; 7906 + int32_t error = E1000_ERR_EEPROM; 7907 + uint32_t i = 0; 7908 + 7909 + /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ 7910 + hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 7911 + hsflctl.hsf_ctrl.flcgo = 1; 7912 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 7913 + 7914 + /* wait till FDONE bit is set to 1 */ 7915 + do { 7916 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 7917 + if (hsfsts.hsf_status.flcdone == 1) 7918 + break; 7919 + udelay(1); 7920 + i++; 7921 + } while (i < timeout); 7922 + if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) { 7923 + error = E1000_SUCCESS; 7924 + } 7925 + return error; 7926 + } 7927 + 7928 + /****************************************************************************** 7929 + * Reads a byte or word from the NVM using the ICH8 flash access registers. 7930 + * 7931 + * hw - The pointer to the hw structure 7932 + * index - The index of the byte or word to read. 7933 + * size - Size of data to read, 1=byte 2=word 7934 + * data - Pointer to the word to store the value read. 7935 + *****************************************************************************/ 7936 + int32_t 7937 + e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index, 7938 + uint32_t size, uint16_t* data) 7939 + { 7940 + union ich8_hws_flash_status hsfsts; 7941 + union ich8_hws_flash_ctrl hsflctl; 7942 + uint32_t flash_linear_address; 7943 + uint32_t flash_data = 0; 7944 + int32_t error = -E1000_ERR_EEPROM; 7945 + int32_t count = 0; 7946 + 7947 + DEBUGFUNC("e1000_read_ich8_data"); 7948 + 7949 + if (size < 1 || size > 2 || data == 0x0 || 7950 + index > ICH8_FLASH_LINEAR_ADDR_MASK) 7951 + return error; 7952 + 7953 + flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 7954 + hw->flash_base_addr; 7955 + 7956 + do { 7957 + udelay(1); 7958 + /* Steps */ 7959 + error = e1000_ich8_cycle_init(hw); 7960 + if (error != E1000_SUCCESS) 7961 + break; 7962 + 7963 + hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 7964 + /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 7965 + hsflctl.hsf_ctrl.fldbcount = size - 1; 7966 + hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_READ; 7967 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 7968 + 7969 + /* Write the last 24 bits of index into Flash Linear address field in 7970 + * Flash Address */ 7971 + /* TODO: TBD maybe check the index against the size of flash */ 7972 + 7973 + E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 7974 + 7975 + error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 7976 + 7977 + /* Check if FCERR is set to 1, if set to 1, clear it and try the whole 7978 + * sequence a few more times, else read in (shift in) the Flash Data0, 7979 + * the order is least significant byte first msb to lsb */ 7980 + if (error == E1000_SUCCESS) { 7981 + flash_data = E1000_READ_ICH8_REG(hw, ICH8_FLASH_FDATA0); 7982 + if (size == 1) { 7983 + *data = (uint8_t)(flash_data & 0x000000FF); 7984 + } else if (size == 2) { 7985 + *data = (uint16_t)(flash_data & 0x0000FFFF); 7986 + } 7987 + break; 7988 + } else { 7989 + /* If we've gotten here, then things are probably completely hosed, 7990 + * but if the error condition is detected, it won't hurt to give 7991 + * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 7992 + */ 7993 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 7994 + if (hsfsts.hsf_status.flcerr == 1) { 7995 + /* Repeat for some time before giving up. */ 7996 + continue; 7997 + } else if (hsfsts.hsf_status.flcdone == 0) { 7998 + DEBUGOUT("Timeout error - flash cycle did not complete."); 7999 + break; 8000 + } 8001 + } 8002 + } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8003 + 8004 + return error; 8005 + } 8006 + 8007 + /****************************************************************************** 8008 + * Writes One /two bytes to the NVM using the ICH8 flash access registers. 8009 + * 8010 + * hw - The pointer to the hw structure 8011 + * index - The index of the byte/word to read. 8012 + * size - Size of data to read, 1=byte 2=word 8013 + * data - The byte(s) to write to the NVM. 8014 + *****************************************************************************/ 8015 + int32_t 8016 + e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size, 8017 + uint16_t data) 8018 + { 8019 + union ich8_hws_flash_status hsfsts; 8020 + union ich8_hws_flash_ctrl hsflctl; 8021 + uint32_t flash_linear_address; 8022 + uint32_t flash_data = 0; 8023 + int32_t error = -E1000_ERR_EEPROM; 8024 + int32_t count = 0; 8025 + 8026 + DEBUGFUNC("e1000_write_ich8_data"); 8027 + 8028 + if (size < 1 || size > 2 || data > size * 0xff || 8029 + index > ICH8_FLASH_LINEAR_ADDR_MASK) 8030 + return error; 8031 + 8032 + flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 8033 + hw->flash_base_addr; 8034 + 8035 + do { 8036 + udelay(1); 8037 + /* Steps */ 8038 + error = e1000_ich8_cycle_init(hw); 8039 + if (error != E1000_SUCCESS) 8040 + break; 8041 + 8042 + hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8043 + /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 8044 + hsflctl.hsf_ctrl.fldbcount = size -1; 8045 + hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_WRITE; 8046 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8047 + 8048 + /* Write the last 24 bits of index into Flash Linear address field in 8049 + * Flash Address */ 8050 + E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8051 + 8052 + if (size == 1) 8053 + flash_data = (uint32_t)data & 0x00FF; 8054 + else 8055 + flash_data = (uint32_t)data; 8056 + 8057 + E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FDATA0, flash_data); 8058 + 8059 + /* check if FCERR is set to 1 , if set to 1, clear it and try the whole 8060 + * sequence a few more times else done */ 8061 + error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 8062 + if (error == E1000_SUCCESS) { 8063 + break; 8064 + } else { 8065 + /* If we're here, then things are most likely completely hosed, 8066 + * but if the error condition is detected, it won't hurt to give 8067 + * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 8068 + */ 8069 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8070 + if (hsfsts.hsf_status.flcerr == 1) { 8071 + /* Repeat for some time before giving up. */ 8072 + continue; 8073 + } else if (hsfsts.hsf_status.flcdone == 0) { 8074 + DEBUGOUT("Timeout error - flash cycle did not complete."); 8075 + break; 8076 + } 8077 + } 8078 + } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8079 + 8080 + return error; 8081 + } 8082 + 8083 + /****************************************************************************** 8084 + * Reads a single byte from the NVM using the ICH8 flash access registers. 8085 + * 8086 + * hw - pointer to e1000_hw structure 8087 + * index - The index of the byte to read. 8088 + * data - Pointer to a byte to store the value read. 8089 + *****************************************************************************/ 8090 + int32_t 8091 + e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t* data) 8092 + { 8093 + int32_t status = E1000_SUCCESS; 8094 + uint16_t word = 0; 8095 + 8096 + status = e1000_read_ich8_data(hw, index, 1, &word); 8097 + if (status == E1000_SUCCESS) { 8098 + *data = (uint8_t)word; 8099 + } 8100 + 8101 + return status; 8102 + } 8103 + 8104 + /****************************************************************************** 8105 + * Writes a single byte to the NVM using the ICH8 flash access registers. 8106 + * Performs verification by reading back the value and then going through 8107 + * a retry algorithm before giving up. 8108 + * 8109 + * hw - pointer to e1000_hw structure 8110 + * index - The index of the byte to write. 8111 + * byte - The byte to write to the NVM. 8112 + *****************************************************************************/ 8113 + int32_t 8114 + e1000_verify_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t byte) 8115 + { 8116 + int32_t error = E1000_SUCCESS; 8117 + int32_t program_retries; 8118 + uint8_t temp_byte; 8119 + 8120 + e1000_write_ich8_byte(hw, index, byte); 8121 + udelay(100); 8122 + 8123 + for (program_retries = 0; program_retries < 100; program_retries++) { 8124 + e1000_read_ich8_byte(hw, index, &temp_byte); 8125 + if (temp_byte == byte) 8126 + break; 8127 + udelay(10); 8128 + e1000_write_ich8_byte(hw, index, byte); 8129 + udelay(100); 8130 + } 8131 + if (program_retries == 100) 8132 + error = E1000_ERR_EEPROM; 8133 + 8134 + return error; 8135 + } 8136 + 8137 + /****************************************************************************** 8138 + * Writes a single byte to the NVM using the ICH8 flash access registers. 8139 + * 8140 + * hw - pointer to e1000_hw structure 8141 + * index - The index of the byte to read. 8142 + * data - The byte to write to the NVM. 8143 + *****************************************************************************/ 8144 + int32_t 8145 + e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t data) 8146 + { 8147 + int32_t status = E1000_SUCCESS; 8148 + uint16_t word = (uint16_t)data; 8149 + 8150 + status = e1000_write_ich8_data(hw, index, 1, word); 8151 + 8152 + return status; 8153 + } 8154 + 8155 + /****************************************************************************** 8156 + * Reads a word from the NVM using the ICH8 flash access registers. 8157 + * 8158 + * hw - pointer to e1000_hw structure 8159 + * index - The starting byte index of the word to read. 8160 + * data - Pointer to a word to store the value read. 8161 + *****************************************************************************/ 8162 + int32_t 8163 + e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data) 8164 + { 8165 + int32_t status = E1000_SUCCESS; 8166 + status = e1000_read_ich8_data(hw, index, 2, data); 8167 + return status; 8168 + } 8169 + 8170 + /****************************************************************************** 8171 + * Writes a word to the NVM using the ICH8 flash access registers. 8172 + * 8173 + * hw - pointer to e1000_hw structure 8174 + * index - The starting byte index of the word to read. 8175 + * data - The word to write to the NVM. 8176 + *****************************************************************************/ 8177 + int32_t 8178 + e1000_write_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t data) 8179 + { 8180 + int32_t status = E1000_SUCCESS; 8181 + status = e1000_write_ich8_data(hw, index, 2, data); 8182 + return status; 8183 + } 8184 + 8185 + /****************************************************************************** 8186 + * Erases the bank specified. Each bank is a 4k block. Segments are 0 based. 8187 + * segment N is 4096 * N + flash_reg_addr. 8188 + * 8189 + * hw - pointer to e1000_hw structure 8190 + * segment - 0 for first segment, 1 for second segment, etc. 8191 + *****************************************************************************/ 8192 + int32_t 8193 + e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t segment) 8194 + { 8195 + union ich8_hws_flash_status hsfsts; 8196 + union ich8_hws_flash_ctrl hsflctl; 8197 + uint32_t flash_linear_address; 8198 + int32_t count = 0; 8199 + int32_t error = E1000_ERR_EEPROM; 8200 + int32_t iteration, seg_size; 8201 + int32_t sector_size; 8202 + int32_t j = 0; 8203 + int32_t error_flag = 0; 8204 + 8205 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8206 + 8207 + /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */ 8208 + /* 00: The Hw sector is 256 bytes, hence we need to erase 16 8209 + * consecutive sectors. The start index for the nth Hw sector can be 8210 + * calculated as = segment * 4096 + n * 256 8211 + * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. 8212 + * The start index for the nth Hw sector can be calculated 8213 + * as = segment * 4096 8214 + * 10: Error condition 8215 + * 11: The Hw sector size is much bigger than the size asked to 8216 + * erase...error condition */ 8217 + if (hsfsts.hsf_status.berasesz == 0x0) { 8218 + /* Hw sector size 256 */ 8219 + sector_size = seg_size = ICH8_FLASH_SEG_SIZE_256; 8220 + iteration = ICH8_FLASH_SECTOR_SIZE / ICH8_FLASH_SEG_SIZE_256; 8221 + } else if (hsfsts.hsf_status.berasesz == 0x1) { 8222 + sector_size = seg_size = ICH8_FLASH_SEG_SIZE_4K; 8223 + iteration = 1; 8224 + } else if (hsfsts.hsf_status.berasesz == 0x3) { 8225 + sector_size = seg_size = ICH8_FLASH_SEG_SIZE_64K; 8226 + iteration = 1; 8227 + } else { 8228 + return error; 8229 + } 8230 + 8231 + for (j = 0; j < iteration ; j++) { 8232 + do { 8233 + count++; 8234 + /* Steps */ 8235 + error = e1000_ich8_cycle_init(hw); 8236 + if (error != E1000_SUCCESS) { 8237 + error_flag = 1; 8238 + break; 8239 + } 8240 + 8241 + /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash 8242 + * Control */ 8243 + hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8244 + hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_ERASE; 8245 + E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8246 + 8247 + /* Write the last 24 bits of an index within the block into Flash 8248 + * Linear address field in Flash Address. This probably needs to 8249 + * be calculated here based off the on-chip segment size and the 8250 + * software segment size assumed (4K) */ 8251 + /* TBD */ 8252 + flash_linear_address = segment * sector_size + j * seg_size; 8253 + flash_linear_address &= ICH8_FLASH_LINEAR_ADDR_MASK; 8254 + flash_linear_address += hw->flash_base_addr; 8255 + 8256 + E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8257 + 8258 + error = e1000_ich8_flash_cycle(hw, 1000000); 8259 + /* Check if FCERR is set to 1. If 1, clear it and try the whole 8260 + * sequence a few more times else Done */ 8261 + if (error == E1000_SUCCESS) { 8262 + break; 8263 + } else { 8264 + hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8265 + if (hsfsts.hsf_status.flcerr == 1) { 8266 + /* repeat for some time before giving up */ 8267 + continue; 8268 + } else if (hsfsts.hsf_status.flcdone == 0) { 8269 + error_flag = 1; 8270 + break; 8271 + } 8272 + } 8273 + } while ((count < ICH8_FLASH_CYCLE_REPEAT_COUNT) && !error_flag); 8274 + if (error_flag == 1) 8275 + break; 8276 + } 8277 + if (error_flag != 1) 8278 + error = E1000_SUCCESS; 8279 + return error; 8280 + } 8281 + 8282 + /****************************************************************************** 8283 + * 8284 + * Reverse duplex setting without breaking the link. 8285 + * 8286 + * hw: Struct containing variables accessed by shared code 8287 + * 8288 + *****************************************************************************/ 8289 + int32_t 8290 + e1000_duplex_reversal(struct e1000_hw *hw) 8291 + { 8292 + int32_t ret_val; 8293 + uint16_t phy_data; 8294 + 8295 + if (hw->phy_type != e1000_phy_igp_3) 8296 + return E1000_SUCCESS; 8297 + 8298 + ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data); 8299 + if (ret_val) 8300 + return ret_val; 8301 + 8302 + phy_data ^= MII_CR_FULL_DUPLEX; 8303 + 8304 + ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data); 8305 + if (ret_val) 8306 + return ret_val; 8307 + 8308 + ret_val = e1000_read_phy_reg(hw, IGP3E1000_PHY_MISC_CTRL, &phy_data); 8309 + if (ret_val) 8310 + return ret_val; 8311 + 8312 + phy_data |= IGP3_PHY_MISC_DUPLEX_MANUAL_SET; 8313 + ret_val = e1000_write_phy_reg(hw, IGP3E1000_PHY_MISC_CTRL, phy_data); 8314 + 8315 + return ret_val; 8316 + } 8317 + 8318 + int32_t 8319 + e1000_init_lcd_from_nvm_config_region(struct e1000_hw *hw, 8320 + uint32_t cnf_base_addr, uint32_t cnf_size) 8321 + { 8322 + uint32_t ret_val = E1000_SUCCESS; 8323 + uint16_t word_addr, reg_data, reg_addr; 8324 + uint16_t i; 8325 + 8326 + /* cnf_base_addr is in DWORD */ 8327 + word_addr = (uint16_t)(cnf_base_addr << 1); 8328 + 8329 + /* cnf_size is returned in size of dwords */ 8330 + for (i = 0; i < cnf_size; i++) { 8331 + ret_val = e1000_read_eeprom(hw, (word_addr + i*2), 1, &reg_data); 8332 + if (ret_val) 8333 + return ret_val; 8334 + 8335 + ret_val = e1000_read_eeprom(hw, (word_addr + i*2 + 1), 1, &reg_addr); 8336 + if (ret_val) 8337 + return ret_val; 8338 + 8339 + ret_val = e1000_get_software_flag(hw); 8340 + if (ret_val != E1000_SUCCESS) 8341 + return ret_val; 8342 + 8343 + ret_val = e1000_write_phy_reg_ex(hw, (uint32_t)reg_addr, reg_data); 8344 + 8345 + e1000_release_software_flag(hw); 8346 + } 8347 + 8348 + return ret_val; 8349 + } 8350 + 8351 + 8352 + int32_t 8353 + e1000_init_lcd_from_nvm(struct e1000_hw *hw) 8354 + { 8355 + uint32_t reg_data, cnf_base_addr, cnf_size, ret_val, loop; 8356 + 8357 + if (hw->phy_type != e1000_phy_igp_3) 8358 + return E1000_SUCCESS; 8359 + 8360 + /* Check if SW needs configure the PHY */ 8361 + reg_data = E1000_READ_REG(hw, FEXTNVM); 8362 + if (!(reg_data & FEXTNVM_SW_CONFIG)) 8363 + return E1000_SUCCESS; 8364 + 8365 + /* Wait for basic configuration completes before proceeding*/ 8366 + loop = 0; 8367 + do { 8368 + reg_data = E1000_READ_REG(hw, STATUS) & E1000_STATUS_LAN_INIT_DONE; 8369 + udelay(100); 8370 + loop++; 8371 + } while ((!reg_data) && (loop < 50)); 8372 + 8373 + /* Clear the Init Done bit for the next init event */ 8374 + reg_data = E1000_READ_REG(hw, STATUS); 8375 + reg_data &= ~E1000_STATUS_LAN_INIT_DONE; 8376 + E1000_WRITE_REG(hw, STATUS, reg_data); 8377 + 8378 + /* Make sure HW does not configure LCD from PHY extended configuration 8379 + before SW configuration */ 8380 + reg_data = E1000_READ_REG(hw, EXTCNF_CTRL); 8381 + if ((reg_data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) == 0x0000) { 8382 + reg_data = E1000_READ_REG(hw, EXTCNF_SIZE); 8383 + cnf_size = reg_data & E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH; 8384 + cnf_size >>= 16; 8385 + if (cnf_size) { 8386 + reg_data = E1000_READ_REG(hw, EXTCNF_CTRL); 8387 + cnf_base_addr = reg_data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER; 8388 + /* cnf_base_addr is in DWORD */ 8389 + cnf_base_addr >>= 16; 8390 + 8391 + /* Configure LCD from extended configuration region. */ 8392 + ret_val = e1000_init_lcd_from_nvm_config_region(hw, cnf_base_addr, 8393 + cnf_size); 8394 + if (ret_val) 8395 + return ret_val; 8396 + } 8397 + } 8398 + 8399 + return E1000_SUCCESS; 8254 8400 } 8255 8401 8256 8402
+392 -6
drivers/net/e1000/e1000_hw.h
··· 62 62 e1000_82572, 63 63 e1000_82573, 64 64 e1000_80003es2lan, 65 + e1000_ich8lan, 65 66 e1000_num_macs 66 67 } e1000_mac_type; 67 68 ··· 71 70 e1000_eeprom_spi, 72 71 e1000_eeprom_microwire, 73 72 e1000_eeprom_flash, 73 + e1000_eeprom_ich8, 74 74 e1000_eeprom_none, /* No NVM support */ 75 75 e1000_num_eeprom_types 76 76 } e1000_eeprom_type; ··· 99 97 e1000_fc_full = 3, 100 98 e1000_fc_default = 0xFF 101 99 } e1000_fc_type; 100 + 101 + struct e1000_shadow_ram { 102 + uint16_t eeprom_word; 103 + boolean_t modified; 104 + }; 102 105 103 106 /* PCI bus types */ 104 107 typedef enum { ··· 225 218 e1000_phy_igp, 226 219 e1000_phy_igp_2, 227 220 e1000_phy_gg82563, 221 + e1000_phy_igp_3, 222 + e1000_phy_ife, 228 223 e1000_phy_undefined = 0xFF 229 224 } e1000_phy_type; 230 225 ··· 322 313 int32_t e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data); 323 314 int32_t e1000_phy_hw_reset(struct e1000_hw *hw); 324 315 int32_t e1000_phy_reset(struct e1000_hw *hw); 316 + void e1000_phy_powerdown_workaround(struct e1000_hw *hw); 317 + int32_t e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw); 318 + int32_t e1000_init_lcd_from_nvm_config_region(struct e1000_hw *hw, uint32_t cnf_base_addr, uint32_t cnf_size); 319 + int32_t e1000_init_lcd_from_nvm(struct e1000_hw *hw); 325 320 int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); 326 321 int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); 327 322 int32_t e1000_read_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *data); ··· 344 331 #define E1000_MNG_DHCP_COOKIE_OFFSET 0x6F0 /* Cookie offset */ 345 332 #define E1000_MNG_DHCP_COOKIE_LENGTH 0x10 /* Cookie length */ 346 333 #define E1000_MNG_IAMT_MODE 0x3 334 + #define E1000_MNG_ICH_IAMT_MODE 0x2 347 335 #define E1000_IAMT_SIGNATURE 0x544D4149 /* Intel(R) Active Management Technology signature */ 348 336 349 337 #define E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT 0x1 /* DHCP parsing enabled */ ··· 402 388 int32_t e1000_read_mac_addr(struct e1000_hw * hw); 403 389 int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask); 404 390 void e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask); 391 + void e1000_release_software_flag(struct e1000_hw *hw); 392 + int32_t e1000_get_software_flag(struct e1000_hw *hw); 405 393 406 394 /* Filters (multicast, vlan, receive) */ 407 395 void e1000_mc_addr_list_update(struct e1000_hw *hw, uint8_t * mc_addr_list, uint32_t mc_addr_count, uint32_t pad, uint32_t rar_used_count); ··· 417 401 int32_t e1000_cleanup_led(struct e1000_hw *hw); 418 402 int32_t e1000_led_on(struct e1000_hw *hw); 419 403 int32_t e1000_led_off(struct e1000_hw *hw); 404 + int32_t e1000_blink_led_start(struct e1000_hw *hw); 420 405 421 406 /* Adaptive IFS Functions */ 422 407 ··· 439 422 int32_t e1000_get_software_semaphore(struct e1000_hw *hw); 440 423 void e1000_release_software_semaphore(struct e1000_hw *hw); 441 424 int32_t e1000_check_phy_reset_block(struct e1000_hw *hw); 425 + int32_t e1000_set_pci_ex_no_snoop(struct e1000_hw *hw, uint32_t no_snoop); 426 + 427 + int32_t e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index, 428 + uint8_t *data); 429 + int32_t e1000_verify_write_ich8_byte(struct e1000_hw *hw, uint32_t index, 430 + uint8_t byte); 431 + int32_t e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index, 432 + uint8_t byte); 433 + int32_t e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, 434 + uint16_t *data); 435 + int32_t e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index, 436 + uint32_t size, uint16_t *data); 437 + int32_t e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, 438 + uint16_t words, uint16_t *data); 439 + int32_t e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, 440 + uint16_t words, uint16_t *data); 441 + int32_t e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t segment); 442 + 443 + 444 + #define E1000_READ_REG_IO(a, reg) \ 445 + e1000_read_reg_io((a), E1000_##reg) 446 + #define E1000_WRITE_REG_IO(a, reg, val) \ 447 + e1000_write_reg_io((a), E1000_##reg, val) 442 448 443 449 /* PCI Device IDs */ 444 450 #define E1000_DEV_ID_82542 0x1000 ··· 486 446 #define E1000_DEV_ID_82546EB_QUAD_COPPER 0x101D 487 447 #define E1000_DEV_ID_82541EI 0x1013 488 448 #define E1000_DEV_ID_82541EI_MOBILE 0x1018 449 + #define E1000_DEV_ID_82541ER_LOM 0x1014 489 450 #define E1000_DEV_ID_82541ER 0x1078 490 451 #define E1000_DEV_ID_82547GI 0x1075 491 452 #define E1000_DEV_ID_82541GI 0x1076 ··· 498 457 #define E1000_DEV_ID_82546GB_PCIE 0x108A 499 458 #define E1000_DEV_ID_82546GB_QUAD_COPPER 0x1099 500 459 #define E1000_DEV_ID_82547EI 0x1019 460 + #define E1000_DEV_ID_82547EI_MOBILE 0x101A 501 461 #define E1000_DEV_ID_82571EB_COPPER 0x105E 502 462 #define E1000_DEV_ID_82571EB_FIBER 0x105F 503 463 #define E1000_DEV_ID_82571EB_SERDES 0x1060 504 464 #define E1000_DEV_ID_82572EI_COPPER 0x107D 505 465 #define E1000_DEV_ID_82572EI_FIBER 0x107E 506 466 #define E1000_DEV_ID_82572EI_SERDES 0x107F 467 + #define E1000_DEV_ID_82572EI 0x10B9 507 468 #define E1000_DEV_ID_82573E 0x108B 508 469 #define E1000_DEV_ID_82573E_IAMT 0x108C 509 470 #define E1000_DEV_ID_82573L 0x109A 510 471 #define E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3 0x10B5 511 472 #define E1000_DEV_ID_80003ES2LAN_COPPER_DPT 0x1096 512 473 #define E1000_DEV_ID_80003ES2LAN_SERDES_DPT 0x1098 474 + #define E1000_DEV_ID_80003ES2LAN_COPPER_SPT 0x10BA 475 + #define E1000_DEV_ID_80003ES2LAN_SERDES_SPT 0x10BB 476 + 477 + #define E1000_DEV_ID_ICH8_IGP_M_AMT 0x1049 478 + #define E1000_DEV_ID_ICH8_IGP_AMT 0x104A 479 + #define E1000_DEV_ID_ICH8_IGP_C 0x104B 480 + #define E1000_DEV_ID_ICH8_IFE 0x104C 481 + #define E1000_DEV_ID_ICH8_IGP_M 0x104D 513 482 514 483 515 484 #define NODE_ADDRESS_SIZE 6 ··· 590 539 E1000_IMS_RXSEQ | \ 591 540 E1000_IMS_LSC) 592 541 542 + /* Additional interrupts need to be handled for e1000_ich8lan: 543 + DSW = The FW changed the status of the DISSW bit in FWSM 544 + PHYINT = The LAN connected device generates an interrupt 545 + EPRST = Manageability reset event */ 546 + #define IMS_ICH8LAN_ENABLE_MASK (\ 547 + E1000_IMS_DSW | \ 548 + E1000_IMS_PHYINT | \ 549 + E1000_IMS_EPRST) 593 550 594 551 /* Number of high/low register pairs in the RAR. The RAR (Receive Address 595 552 * Registers) holds the directed and multicast addresses that we monitor. We ··· 605 546 * E1000_RAR_ENTRIES - 1 multicast addresses. 606 547 */ 607 548 #define E1000_RAR_ENTRIES 15 549 + #define E1000_RAR_ENTRIES_ICH8LAN 7 608 550 609 551 #define MIN_NUMBER_OF_DESCRIPTORS 8 610 552 #define MAX_NUMBER_OF_DESCRIPTORS 0xFFF8 ··· 827 767 #define E1000_MC_TBL_SIZE 128 /* Multicast Filter Table (4096 bits) */ 828 768 #define E1000_VLAN_FILTER_TBL_SIZE 128 /* VLAN Filter Table (4096 bits) */ 829 769 770 + #define E1000_NUM_UNICAST_ICH8LAN 7 771 + #define E1000_MC_TBL_SIZE_ICH8LAN 32 772 + 830 773 831 774 /* Receive Address Register */ 832 775 struct e1000_rar { ··· 839 776 840 777 /* Number of entries in the Multicast Table Array (MTA). */ 841 778 #define E1000_NUM_MTA_REGISTERS 128 779 + #define E1000_NUM_MTA_REGISTERS_ICH8LAN 32 842 780 843 781 /* IPv4 Address Table Entry */ 844 782 struct e1000_ipv4_at_entry { ··· 850 786 /* Four wakeup IP addresses are supported */ 851 787 #define E1000_WAKEUP_IP_ADDRESS_COUNT_MAX 4 852 788 #define E1000_IP4AT_SIZE E1000_WAKEUP_IP_ADDRESS_COUNT_MAX 789 + #define E1000_IP4AT_SIZE_ICH8LAN 3 853 790 #define E1000_IP6AT_SIZE 1 854 791 855 792 /* IPv6 Address Table Entry */ ··· 909 844 #define E1000_FLA 0x0001C /* Flash Access - RW */ 910 845 #define E1000_MDIC 0x00020 /* MDI Control - RW */ 911 846 #define E1000_SCTL 0x00024 /* SerDes Control - RW */ 847 + #define E1000_FEXTNVM 0x00028 /* Future Extended NVM register */ 912 848 #define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */ 913 849 #define E1000_FCAH 0x0002C /* Flow Control Address High -RW */ 914 850 #define E1000_FCT 0x00030 /* Flow Control Type - RW */ ··· 938 872 #define E1000_LEDCTL 0x00E00 /* LED Control - RW */ 939 873 #define E1000_EXTCNF_CTRL 0x00F00 /* Extended Configuration Control */ 940 874 #define E1000_EXTCNF_SIZE 0x00F08 /* Extended Configuration Size */ 875 + #define E1000_PHY_CTRL 0x00F10 /* PHY Control Register in CSR */ 876 + #define FEXTNVM_SW_CONFIG 0x0001 941 877 #define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ 942 878 #define E1000_PBS 0x01008 /* Packet Buffer Size */ 943 879 #define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ ··· 967 899 #define E1000_RDH0 E1000_RDH /* RX Desc Head (0) - RW */ 968 900 #define E1000_RDT0 E1000_RDT /* RX Desc Tail (0) - RW */ 969 901 #define E1000_RDTR0 E1000_RDTR /* RX Delay Timer (0) - RW */ 970 - #define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */ 902 + #define E1000_RXDCTL 0x02828 /* RX Descriptor Control queue 0 - RW */ 903 + #define E1000_RXDCTL1 0x02928 /* RX Descriptor Control queue 1 - RW */ 971 904 #define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */ 972 905 #define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */ 973 906 #define E1000_RAID 0x02C08 /* Receive Ack Interrupt Delay - RW */ 974 907 #define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */ 908 + #define E1000_KABGTXD 0x03004 /* AFE Band Gap Transmit Ref Data */ 975 909 #define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */ 976 910 #define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */ 977 911 #define E1000_TDFHS 0x03420 /* TX Data FIFO Head Saved - RW */ ··· 1120 1050 #define E1000_82542_FLA E1000_FLA 1121 1051 #define E1000_82542_MDIC E1000_MDIC 1122 1052 #define E1000_82542_SCTL E1000_SCTL 1053 + #define E1000_82542_FEXTNVM E1000_FEXTNVM 1123 1054 #define E1000_82542_FCAL E1000_FCAL 1124 1055 #define E1000_82542_FCAH E1000_FCAH 1125 1056 #define E1000_82542_FCT E1000_FCT ··· 1144 1073 #define E1000_82542_RDLEN0 E1000_82542_RDLEN 1145 1074 #define E1000_82542_RDH0 E1000_82542_RDH 1146 1075 #define E1000_82542_RDT0 E1000_82542_RDT 1076 + #define E1000_82542_SRRCTL(_n) (0x280C + ((_n) << 8)) /* Split and Replication 1077 + * RX Control - RW */ 1078 + #define E1000_82542_DCA_RXCTRL(_n) (0x02814 + ((_n) << 8)) 1079 + #define E1000_82542_RDBAH3 0x02B04 /* RX Desc Base High Queue 3 - RW */ 1080 + #define E1000_82542_RDBAL3 0x02B00 /* RX Desc Low Queue 3 - RW */ 1081 + #define E1000_82542_RDLEN3 0x02B08 /* RX Desc Length Queue 3 - RW */ 1082 + #define E1000_82542_RDH3 0x02B10 /* RX Desc Head Queue 3 - RW */ 1083 + #define E1000_82542_RDT3 0x02B18 /* RX Desc Tail Queue 3 - RW */ 1084 + #define E1000_82542_RDBAL2 0x02A00 /* RX Desc Base Low Queue 2 - RW */ 1085 + #define E1000_82542_RDBAH2 0x02A04 /* RX Desc Base High Queue 2 - RW */ 1086 + #define E1000_82542_RDLEN2 0x02A08 /* RX Desc Length Queue 2 - RW */ 1087 + #define E1000_82542_RDH2 0x02A10 /* RX Desc Head Queue 2 - RW */ 1088 + #define E1000_82542_RDT2 0x02A18 /* RX Desc Tail Queue 2 - RW */ 1147 1089 #define E1000_82542_RDTR1 0x00130 1148 1090 #define E1000_82542_RDBAL1 0x00138 1149 1091 #define E1000_82542_RDBAH1 0x0013C ··· 1194 1110 #define E1000_82542_FLOP E1000_FLOP 1195 1111 #define E1000_82542_EXTCNF_CTRL E1000_EXTCNF_CTRL 1196 1112 #define E1000_82542_EXTCNF_SIZE E1000_EXTCNF_SIZE 1113 + #define E1000_82542_PHY_CTRL E1000_PHY_CTRL 1197 1114 #define E1000_82542_ERT E1000_ERT 1198 1115 #define E1000_82542_RXDCTL E1000_RXDCTL 1116 + #define E1000_82542_RXDCTL1 E1000_RXDCTL1 1199 1117 #define E1000_82542_RADV E1000_RADV 1200 1118 #define E1000_82542_RSRPD E1000_RSRPD 1201 1119 #define E1000_82542_TXDMAC E1000_TXDMAC 1120 + #define E1000_82542_KABGTXD E1000_KABGTXD 1202 1121 #define E1000_82542_TDFHS E1000_TDFHS 1203 1122 #define E1000_82542_TDFTS E1000_TDFTS 1204 1123 #define E1000_82542_TDFPC E1000_TDFPC ··· 1397 1310 1398 1311 /* Structure containing variables used by the shared code (e1000_hw.c) */ 1399 1312 struct e1000_hw { 1400 - uint8_t __iomem *hw_addr; 1313 + uint8_t *hw_addr; 1401 1314 uint8_t *flash_address; 1402 1315 e1000_mac_type mac_type; 1403 1316 e1000_phy_type phy_type; 1404 1317 uint32_t phy_init_script; 1405 1318 e1000_media_type media_type; 1406 1319 void *back; 1320 + struct e1000_shadow_ram *eeprom_shadow_ram; 1321 + uint32_t flash_bank_size; 1322 + uint32_t flash_base_addr; 1407 1323 e1000_fc_type fc; 1408 1324 e1000_bus_speed bus_speed; 1409 1325 e1000_bus_width bus_width; ··· 1418 1328 uint32_t asf_firmware_present; 1419 1329 uint32_t eeprom_semaphore_present; 1420 1330 uint32_t swfw_sync_present; 1331 + uint32_t swfwhw_semaphore_present; 1421 1332 unsigned long io_base; 1422 1333 uint32_t phy_id; 1423 1334 uint32_t phy_revision; ··· 1478 1387 boolean_t in_ifs_mode; 1479 1388 boolean_t mng_reg_access_disabled; 1480 1389 boolean_t leave_av_bit_off; 1390 + boolean_t kmrn_lock_loss_workaround_disabled; 1481 1391 }; 1482 1392 1483 1393 ··· 1527 1435 #define E1000_CTRL_RTE 0x20000000 /* Routing tag enable */ 1528 1436 #define E1000_CTRL_VME 0x40000000 /* IEEE VLAN mode enable */ 1529 1437 #define E1000_CTRL_PHY_RST 0x80000000 /* PHY Reset */ 1438 + #define E1000_CTRL_SW2FW_INT 0x02000000 /* Initiate an interrupt to manageability engine */ 1530 1439 1531 1440 /* Device Status */ 1532 1441 #define E1000_STATUS_FD 0x00000001 /* Full duplex.0=half,1=full */ ··· 1542 1449 #define E1000_STATUS_SPEED_10 0x00000000 /* Speed 10Mb/s */ 1543 1450 #define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */ 1544 1451 #define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */ 1452 + #define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion 1453 + by EEPROM/Flash */ 1545 1454 #define E1000_STATUS_ASDV 0x00000300 /* Auto speed detect value */ 1546 1455 #define E1000_STATUS_DOCK_CI 0x00000800 /* Change in Dock/Undock state. Clear on write '0'. */ 1547 1456 #define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */ ··· 1601 1506 #define E1000_STM_OPCODE 0xDB00 1602 1507 #define E1000_HICR_FW_RESET 0xC0 1603 1508 1509 + #define E1000_SHADOW_RAM_WORDS 2048 1510 + #define E1000_ICH8_NVM_SIG_WORD 0x13 1511 + #define E1000_ICH8_NVM_SIG_MASK 0xC0 1512 + 1604 1513 /* EEPROM Read */ 1605 1514 #define E1000_EERD_START 0x00000001 /* Start Read */ 1606 1515 #define E1000_EERD_DONE 0x00000010 /* Read Done */ ··· 1650 1551 #define E1000_CTRL_EXT_WR_WMARK_320 0x01000000 1651 1552 #define E1000_CTRL_EXT_WR_WMARK_384 0x02000000 1652 1553 #define E1000_CTRL_EXT_WR_WMARK_448 0x03000000 1653 - #define E1000_CTRL_EXT_CANC 0x04000000 /* Interrupt delay cancellation */ 1654 1554 #define E1000_CTRL_EXT_DRV_LOAD 0x10000000 /* Driver loaded bit for FW */ 1655 1555 #define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */ 1656 1556 #define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */ ··· 1689 1591 #define E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS 0x00000800 1690 1592 1691 1593 /* In-Band Control */ 1594 + #define E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT 0x00000500 1692 1595 #define E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING 0x00000010 1693 1596 1694 1597 /* Half-Duplex Control */ 1695 1598 #define E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT 0x00000004 1696 1599 #define E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT 0x00000000 1600 + 1601 + #define E1000_KUMCTRLSTA_OFFSET_K0S_CTRL 0x0000001E 1602 + 1603 + #define E1000_KUMCTRLSTA_DIAG_FELPBK 0x2000 1604 + #define E1000_KUMCTRLSTA_DIAG_NELPBK 0x1000 1605 + 1606 + #define E1000_KUMCTRLSTA_K0S_100_EN 0x2000 1607 + #define E1000_KUMCTRLSTA_K0S_GBE_EN 0x1000 1608 + #define E1000_KUMCTRLSTA_K0S_ENTRY_LATENCY_MASK 0x0003 1609 + 1610 + #define E1000_KABGTXD_BGSQLBIAS 0x00050000 1611 + 1612 + #define E1000_PHY_CTRL_SPD_EN 0x00000001 1613 + #define E1000_PHY_CTRL_D0A_LPLU 0x00000002 1614 + #define E1000_PHY_CTRL_NOND0A_LPLU 0x00000004 1615 + #define E1000_PHY_CTRL_NOND0A_GBE_DISABLE 0x00000008 1616 + #define E1000_PHY_CTRL_GBE_DISABLE 0x00000040 1617 + #define E1000_PHY_CTRL_B2B_EN 0x00000080 1697 1618 1698 1619 /* LED Control */ 1699 1620 #define E1000_LEDCTL_LED0_MODE_MASK 0x0000000F ··· 1783 1666 #define E1000_ICR_RXD_FIFO_PAR1 0x01000000 /* queue 1 Rx descriptor FIFO parity error */ 1784 1667 #define E1000_ICR_TXD_FIFO_PAR1 0x02000000 /* queue 1 Tx descriptor FIFO parity error */ 1785 1668 #define E1000_ICR_ALL_PARITY 0x03F00000 /* all parity error bits */ 1669 + #define E1000_ICR_DSW 0x00000020 /* FW changed the status of DISSW bit in the FWSM */ 1670 + #define E1000_ICR_PHYINT 0x00001000 /* LAN connected device generates an interrupt */ 1671 + #define E1000_ICR_EPRST 0x00100000 /* ME handware reset occurs */ 1786 1672 1787 1673 /* Interrupt Cause Set */ 1788 1674 #define E1000_ICS_TXDW E1000_ICR_TXDW /* Transmit desc written back */ ··· 1812 1692 #define E1000_ICS_PB_PAR E1000_ICR_PB_PAR /* packet buffer parity error */ 1813 1693 #define E1000_ICS_RXD_FIFO_PAR1 E1000_ICR_RXD_FIFO_PAR1 /* queue 1 Rx descriptor FIFO parity error */ 1814 1694 #define E1000_ICS_TXD_FIFO_PAR1 E1000_ICR_TXD_FIFO_PAR1 /* queue 1 Tx descriptor FIFO parity error */ 1695 + #define E1000_ICS_DSW E1000_ICR_DSW 1696 + #define E1000_ICS_PHYINT E1000_ICR_PHYINT 1697 + #define E1000_ICS_EPRST E1000_ICR_EPRST 1815 1698 1816 1699 /* Interrupt Mask Set */ 1817 1700 #define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */ ··· 1841 1718 #define E1000_IMS_PB_PAR E1000_ICR_PB_PAR /* packet buffer parity error */ 1842 1719 #define E1000_IMS_RXD_FIFO_PAR1 E1000_ICR_RXD_FIFO_PAR1 /* queue 1 Rx descriptor FIFO parity error */ 1843 1720 #define E1000_IMS_TXD_FIFO_PAR1 E1000_ICR_TXD_FIFO_PAR1 /* queue 1 Tx descriptor FIFO parity error */ 1721 + #define E1000_IMS_DSW E1000_ICR_DSW 1722 + #define E1000_IMS_PHYINT E1000_ICR_PHYINT 1723 + #define E1000_IMS_EPRST E1000_ICR_EPRST 1844 1724 1845 1725 /* Interrupt Mask Clear */ 1846 1726 #define E1000_IMC_TXDW E1000_ICR_TXDW /* Transmit desc written back */ ··· 1870 1744 #define E1000_IMC_PB_PAR E1000_ICR_PB_PAR /* packet buffer parity error */ 1871 1745 #define E1000_IMC_RXD_FIFO_PAR1 E1000_ICR_RXD_FIFO_PAR1 /* queue 1 Rx descriptor FIFO parity error */ 1872 1746 #define E1000_IMC_TXD_FIFO_PAR1 E1000_ICR_TXD_FIFO_PAR1 /* queue 1 Tx descriptor FIFO parity error */ 1747 + #define E1000_IMC_DSW E1000_ICR_DSW 1748 + #define E1000_IMC_PHYINT E1000_ICR_PHYINT 1749 + #define E1000_IMC_EPRST E1000_ICR_EPRST 1873 1750 1874 1751 /* Receive Control */ 1875 1752 #define E1000_RCTL_RST 0x00000001 /* Software reset */ ··· 2047 1918 #define E1000_MRQC_RSS_FIELD_MASK 0xFFFF0000 2048 1919 #define E1000_MRQC_RSS_FIELD_IPV4_TCP 0x00010000 2049 1920 #define E1000_MRQC_RSS_FIELD_IPV4 0x00020000 2050 - #define E1000_MRQC_RSS_FIELD_IPV6_TCP 0x00040000 1921 + #define E1000_MRQC_RSS_FIELD_IPV6_TCP_EX 0x00040000 2051 1922 #define E1000_MRQC_RSS_FIELD_IPV6_EX 0x00080000 2052 1923 #define E1000_MRQC_RSS_FIELD_IPV6 0x00100000 1924 + #define E1000_MRQC_RSS_FIELD_IPV6_TCP 0x00200000 2053 1925 2054 1926 /* Definitions for power management and wakeup registers */ 2055 1927 /* Wake Up Control */ ··· 2140 2010 #define E1000_FWSM_MODE_SHIFT 1 2141 2011 #define E1000_FWSM_FW_VALID 0x00008000 /* FW established a valid mode */ 2142 2012 2013 + #define E1000_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI reset */ 2014 + #define E1000_FWSM_DISSW 0x10000000 /* FW disable SW Write Access */ 2015 + #define E1000_FWSM_SKUSEL_MASK 0x60000000 /* LAN SKU select */ 2016 + #define E1000_FWSM_SKUEL_SHIFT 29 2017 + #define E1000_FWSM_SKUSEL_EMB 0x0 /* Embedded SKU */ 2018 + #define E1000_FWSM_SKUSEL_CONS 0x1 /* Consumer SKU */ 2019 + #define E1000_FWSM_SKUSEL_PERF_100 0x2 /* Perf & Corp 10/100 SKU */ 2020 + #define E1000_FWSM_SKUSEL_PERF_GBE 0x3 /* Perf & Copr GbE SKU */ 2021 + 2143 2022 /* FFLT Debug Register */ 2144 2023 #define E1000_FFLT_DBG_INVC 0x00100000 /* Invalid /C/ code handling */ 2145 2024 ··· 2221 2082 E1000_GCR_TXDSCW_NO_SNOOP | \ 2222 2083 E1000_GCR_TXDSCR_NO_SNOOP) 2223 2084 2085 + #define PCI_EX_82566_SNOOP_ALL PCI_EX_NO_SNOOP_ALL 2086 + 2224 2087 #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 2225 2088 /* Function Active and Power State to MNG */ 2226 2089 #define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003 ··· 2281 2140 #define EEPROM_PHY_CLASS_WORD 0x0007 2282 2141 #define EEPROM_INIT_CONTROL1_REG 0x000A 2283 2142 #define EEPROM_INIT_CONTROL2_REG 0x000F 2143 + #define EEPROM_SWDEF_PINS_CTRL_PORT_1 0x0010 2284 2144 #define EEPROM_INIT_CONTROL3_PORT_B 0x0014 2285 2145 #define EEPROM_INIT_3GIO_3 0x001A 2146 + #define EEPROM_SWDEF_PINS_CTRL_PORT_0 0x0020 2286 2147 #define EEPROM_INIT_CONTROL3_PORT_A 0x0024 2287 2148 #define EEPROM_CFG 0x0012 2288 2149 #define EEPROM_FLASH_VERSION 0x0032 ··· 2296 2153 /* Word definitions for ID LED Settings */ 2297 2154 #define ID_LED_RESERVED_0000 0x0000 2298 2155 #define ID_LED_RESERVED_FFFF 0xFFFF 2156 + #define ID_LED_RESERVED_82573 0xF746 2157 + #define ID_LED_DEFAULT_82573 0x1811 2299 2158 #define ID_LED_DEFAULT ((ID_LED_OFF1_ON2 << 12) | \ 2300 2159 (ID_LED_OFF1_OFF2 << 8) | \ 2301 2160 (ID_LED_DEF1_DEF2 << 4) | \ 2302 2161 (ID_LED_DEF1_DEF2)) 2162 + #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \ 2163 + (ID_LED_DEF1_OFF2 << 8) | \ 2164 + (ID_LED_DEF1_ON2 << 4) | \ 2165 + (ID_LED_DEF1_DEF2)) 2303 2166 #define ID_LED_DEF1_DEF2 0x1 2304 2167 #define ID_LED_DEF1_ON2 0x2 2305 2168 #define ID_LED_DEF1_OFF2 0x3 ··· 2340 2191 #define EEPROM_WORD0F_ASM_DIR 0x2000 2341 2192 #define EEPROM_WORD0F_ANE 0x0800 2342 2193 #define EEPROM_WORD0F_SWPDIO_EXT 0x00F0 2194 + #define EEPROM_WORD0F_LPLU 0x0001 2195 + 2196 + /* Mask bits for fields in Word 0x10/0x20 of the EEPROM */ 2197 + #define EEPROM_WORD1020_GIGA_DISABLE 0x0010 2198 + #define EEPROM_WORD1020_GIGA_DISABLE_NON_D0A 0x0008 2343 2199 2344 2200 /* Mask bits for fields in Word 0x1a of the EEPROM */ 2345 2201 #define EEPROM_WORD1A_ASPM_MASK 0x000C ··· 2419 2265 #define E1000_EXTCNF_CTRL_D_UD_OWNER 0x00000010 2420 2266 #define E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP 0x00000020 2421 2267 #define E1000_EXTCNF_CTRL_MDIO_HW_OWNERSHIP 0x00000040 2422 - #define E1000_EXTCNF_CTRL_EXT_CNF_POINTER 0x1FFF0000 2268 + #define E1000_EXTCNF_CTRL_EXT_CNF_POINTER 0x0FFF0000 2423 2269 2424 2270 #define E1000_EXTCNF_SIZE_EXT_PHY_LENGTH 0x000000FF 2425 2271 #define E1000_EXTCNF_SIZE_EXT_DOCK_LENGTH 0x0000FF00 2426 2272 #define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH 0x00FF0000 2273 + #define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE 0x00000001 2274 + #define E1000_EXTCNF_CTRL_SWFLAG 0x00000020 2427 2275 2428 2276 /* PBA constants */ 2277 + #define E1000_PBA_8K 0x0008 /* 8KB, default Rx allocation */ 2429 2278 #define E1000_PBA_12K 0x000C /* 12KB, default Rx allocation */ 2430 2279 #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */ 2431 2280 #define E1000_PBA_22K 0x0016 2432 2281 #define E1000_PBA_24K 0x0018 2433 2282 #define E1000_PBA_30K 0x001E 2434 2283 #define E1000_PBA_32K 0x0020 2284 + #define E1000_PBA_34K 0x0022 2435 2285 #define E1000_PBA_38K 0x0026 2436 2286 #define E1000_PBA_40K 0x0028 2437 2287 #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */ 2288 + 2289 + #define E1000_PBS_16K E1000_PBA_16K 2438 2290 2439 2291 /* Flow Control Constants */ 2440 2292 #define FLOW_CONTROL_ADDRESS_LOW 0x00C28001 ··· 2496 2336 /* Number of milliseconds we wait for Eeprom auto read bit done after MAC reset */ 2497 2337 #define AUTO_READ_DONE_TIMEOUT 10 2498 2338 /* Number of milliseconds we wait for PHY configuration done after MAC reset */ 2499 - #define PHY_CFG_TIMEOUT 40 2339 + #define PHY_CFG_TIMEOUT 100 2500 2340 2501 2341 #define E1000_TX_BUFFER_SIZE ((uint32_t)1514) 2502 2342 ··· 2924 2764 #define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */ 2925 2765 #define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */ 2926 2766 2767 + /* M88EC018 Rev 2 specific DownShift settings */ 2768 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK 0x0E00 2769 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_1X 0x0000 2770 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_2X 0x0200 2771 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_3X 0x0400 2772 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_4X 0x0600 2773 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X 0x0800 2774 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_6X 0x0A00 2775 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_7X 0x0C00 2776 + #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_8X 0x0E00 2777 + 2927 2778 /* IGP01E1000 Specific Port Config Register - R/W */ 2928 2779 #define IGP01E1000_PSCFR_AUTO_MDIX_PAR_DETECT 0x0010 2929 2780 #define IGP01E1000_PSCFR_PRE_EN 0x0020 ··· 3160 2989 #define M88E1111_I_PHY_ID 0x01410CC0 3161 2990 #define L1LXT971A_PHY_ID 0x001378E0 3162 2991 #define GG82563_E_PHY_ID 0x01410CA0 2992 + 2993 + 2994 + /* Bits... 2995 + * 15-5: page 2996 + * 4-0: register offset 2997 + */ 2998 + #define PHY_PAGE_SHIFT 5 2999 + #define PHY_REG(page, reg) \ 3000 + (((page) << PHY_PAGE_SHIFT) | ((reg) & MAX_PHY_REG_ADDRESS)) 3001 + 3002 + #define IGP3_PHY_PORT_CTRL \ 3003 + PHY_REG(769, 17) /* Port General Configuration */ 3004 + #define IGP3_PHY_RATE_ADAPT_CTRL \ 3005 + PHY_REG(769, 25) /* Rate Adapter Control Register */ 3006 + 3007 + #define IGP3_KMRN_FIFO_CTRL_STATS \ 3008 + PHY_REG(770, 16) /* KMRN FIFO's control/status register */ 3009 + #define IGP3_KMRN_POWER_MNG_CTRL \ 3010 + PHY_REG(770, 17) /* KMRN Power Management Control Register */ 3011 + #define IGP3_KMRN_INBAND_CTRL \ 3012 + PHY_REG(770, 18) /* KMRN Inband Control Register */ 3013 + #define IGP3_KMRN_DIAG \ 3014 + PHY_REG(770, 19) /* KMRN Diagnostic register */ 3015 + #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002 /* RX PCS is not synced */ 3016 + #define IGP3_KMRN_ACK_TIMEOUT \ 3017 + PHY_REG(770, 20) /* KMRN Acknowledge Timeouts register */ 3018 + 3019 + #define IGP3_VR_CTRL \ 3020 + PHY_REG(776, 18) /* Voltage regulator control register */ 3021 + #define IGP3_VR_CTRL_MODE_SHUT 0x0200 /* Enter powerdown, shutdown VRs */ 3022 + 3023 + #define IGP3_CAPABILITY \ 3024 + PHY_REG(776, 19) /* IGP3 Capability Register */ 3025 + 3026 + /* Capabilities for SKU Control */ 3027 + #define IGP3_CAP_INITIATE_TEAM 0x0001 /* Able to initiate a team */ 3028 + #define IGP3_CAP_WFM 0x0002 /* Support WoL and PXE */ 3029 + #define IGP3_CAP_ASF 0x0004 /* Support ASF */ 3030 + #define IGP3_CAP_LPLU 0x0008 /* Support Low Power Link Up */ 3031 + #define IGP3_CAP_DC_AUTO_SPEED 0x0010 /* Support AC/DC Auto Link Speed */ 3032 + #define IGP3_CAP_SPD 0x0020 /* Support Smart Power Down */ 3033 + #define IGP3_CAP_MULT_QUEUE 0x0040 /* Support 2 tx & 2 rx queues */ 3034 + #define IGP3_CAP_RSS 0x0080 /* Support RSS */ 3035 + #define IGP3_CAP_8021PQ 0x0100 /* Support 802.1Q & 802.1p */ 3036 + #define IGP3_CAP_AMT_CB 0x0200 /* Support active manageability and circuit breaker */ 3037 + 3038 + #define IGP3_PPC_JORDAN_EN 0x0001 3039 + #define IGP3_PPC_JORDAN_GIGA_SPEED 0x0002 3040 + 3041 + #define IGP3_KMRN_PMC_EE_IDLE_LINK_DIS 0x0001 3042 + #define IGP3_KMRN_PMC_K0S_ENTRY_LATENCY_MASK 0x001E 3043 + #define IGP3_KMRN_PMC_K0S_MODE1_EN_GIGA 0x0020 3044 + #define IGP3_KMRN_PMC_K0S_MODE1_EN_100 0x0040 3045 + 3046 + #define IGP3E1000_PHY_MISC_CTRL 0x1B /* Misc. Ctrl register */ 3047 + #define IGP3_PHY_MISC_DUPLEX_MANUAL_SET 0x1000 /* Duplex Manual Set */ 3048 + 3049 + #define IGP3_KMRN_EXT_CTRL PHY_REG(770, 18) 3050 + #define IGP3_KMRN_EC_DIS_INBAND 0x0080 3051 + 3052 + #define IGP03E1000_E_PHY_ID 0x02A80390 3053 + #define IFE_E_PHY_ID 0x02A80330 /* 10/100 PHY */ 3054 + #define IFE_PLUS_E_PHY_ID 0x02A80320 3055 + #define IFE_C_E_PHY_ID 0x02A80310 3056 + 3057 + #define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10 /* 100BaseTx Extended Status, Control and Address */ 3058 + #define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY special control register */ 3059 + #define IFE_PHY_RCV_FALSE_CARRIER 0x13 /* 100BaseTx Receive False Carrier Counter */ 3060 + #define IFE_PHY_RCV_DISCONNECT 0x14 /* 100BaseTx Receive Disconnet Counter */ 3061 + #define IFE_PHY_RCV_ERROT_FRAME 0x15 /* 100BaseTx Receive Error Frame Counter */ 3062 + #define IFE_PHY_RCV_SYMBOL_ERR 0x16 /* Receive Symbol Error Counter */ 3063 + #define IFE_PHY_PREM_EOF_ERR 0x17 /* 100BaseTx Receive Premature End Of Frame Error Counter */ 3064 + #define IFE_PHY_RCV_EOF_ERR 0x18 /* 10BaseT Receive End Of Frame Error Counter */ 3065 + #define IFE_PHY_TX_JABBER_DETECT 0x19 /* 10BaseT Transmit Jabber Detect Counter */ 3066 + #define IFE_PHY_EQUALIZER 0x1A /* PHY Equalizer Control and Status */ 3067 + #define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY special control and LED configuration */ 3068 + #define IFE_PHY_MDIX_CONTROL 0x1C /* MDI/MDI-X Control register */ 3069 + #define IFE_PHY_HWI_CONTROL 0x1D /* Hardware Integrity Control (HWI) */ 3070 + 3071 + #define IFE_PESC_REDUCED_POWER_DOWN_DISABLE 0x2000 /* Defaut 1 = Disable auto reduced power down */ 3072 + #define IFE_PESC_100BTX_POWER_DOWN 0x0400 /* Indicates the power state of 100BASE-TX */ 3073 + #define IFE_PESC_10BTX_POWER_DOWN 0x0200 /* Indicates the power state of 10BASE-T */ 3074 + #define IFE_PESC_POLARITY_REVERSED 0x0100 /* Indicates 10BASE-T polarity */ 3075 + #define IFE_PESC_PHY_ADDR_MASK 0x007C /* Bit 6:2 for sampled PHY address */ 3076 + #define IFE_PESC_SPEED 0x0002 /* Auto-negotiation speed result 1=100Mbs, 0=10Mbs */ 3077 + #define IFE_PESC_DUPLEX 0x0001 /* Auto-negotiation duplex result 1=Full, 0=Half */ 3078 + #define IFE_PESC_POLARITY_REVERSED_SHIFT 8 3079 + 3080 + #define IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN 0x0100 /* 1 = Dyanmic Power Down disabled */ 3081 + #define IFE_PSC_FORCE_POLARITY 0x0020 /* 1=Reversed Polarity, 0=Normal */ 3082 + #define IFE_PSC_AUTO_POLARITY_DISABLE 0x0010 /* 1=Auto Polarity Disabled, 0=Enabled */ 3083 + #define IFE_PSC_JABBER_FUNC_DISABLE 0x0001 /* 1=Jabber Disabled, 0=Normal Jabber Operation */ 3084 + #define IFE_PSC_FORCE_POLARITY_SHIFT 5 3085 + #define IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT 4 3086 + 3087 + #define IFE_PMC_AUTO_MDIX 0x0080 /* 1=enable MDI/MDI-X feature, default 0=disabled */ 3088 + #define IFE_PMC_FORCE_MDIX 0x0040 /* 1=force MDIX-X, 0=force MDI */ 3089 + #define IFE_PMC_MDIX_STATUS 0x0020 /* 1=MDI-X, 0=MDI */ 3090 + #define IFE_PMC_AUTO_MDIX_COMPLETE 0x0010 /* Resolution algorthm is completed */ 3091 + #define IFE_PMC_MDIX_MODE_SHIFT 6 3092 + #define IFE_PHC_MDIX_RESET_ALL_MASK 0x0000 /* Disable auto MDI-X */ 3093 + 3094 + #define IFE_PHC_HWI_ENABLE 0x8000 /* Enable the HWI feature */ 3095 + #define IFE_PHC_ABILITY_CHECK 0x4000 /* 1= Test Passed, 0=failed */ 3096 + #define IFE_PHC_TEST_EXEC 0x2000 /* PHY launch test pulses on the wire */ 3097 + #define IFE_PHC_HIGHZ 0x0200 /* 1 = Open Circuit */ 3098 + #define IFE_PHC_LOWZ 0x0400 /* 1 = Short Circuit */ 3099 + #define IFE_PHC_LOW_HIGH_Z_MASK 0x0600 /* Mask for indication type of problem on the line */ 3100 + #define IFE_PHC_DISTANCE_MASK 0x01FF /* Mask for distance to the cable problem, in 80cm granularity */ 3101 + #define IFE_PHC_RESET_ALL_MASK 0x0000 /* Disable HWI */ 3102 + #define IFE_PSCL_PROBE_MODE 0x0020 /* LED Probe mode */ 3103 + #define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */ 3104 + #define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */ 3105 + 3106 + #define ICH8_FLASH_COMMAND_TIMEOUT 500 /* 500 ms , should be adjusted */ 3107 + #define ICH8_FLASH_CYCLE_REPEAT_COUNT 10 /* 10 cycles , should be adjusted */ 3108 + #define ICH8_FLASH_SEG_SIZE_256 256 3109 + #define ICH8_FLASH_SEG_SIZE_4K 4096 3110 + #define ICH8_FLASH_SEG_SIZE_64K 65536 3111 + 3112 + #define ICH8_CYCLE_READ 0x0 3113 + #define ICH8_CYCLE_RESERVED 0x1 3114 + #define ICH8_CYCLE_WRITE 0x2 3115 + #define ICH8_CYCLE_ERASE 0x3 3116 + 3117 + #define ICH8_FLASH_GFPREG 0x0000 3118 + #define ICH8_FLASH_HSFSTS 0x0004 3119 + #define ICH8_FLASH_HSFCTL 0x0006 3120 + #define ICH8_FLASH_FADDR 0x0008 3121 + #define ICH8_FLASH_FDATA0 0x0010 3122 + #define ICH8_FLASH_FRACC 0x0050 3123 + #define ICH8_FLASH_FREG0 0x0054 3124 + #define ICH8_FLASH_FREG1 0x0058 3125 + #define ICH8_FLASH_FREG2 0x005C 3126 + #define ICH8_FLASH_FREG3 0x0060 3127 + #define ICH8_FLASH_FPR0 0x0074 3128 + #define ICH8_FLASH_FPR1 0x0078 3129 + #define ICH8_FLASH_SSFSTS 0x0090 3130 + #define ICH8_FLASH_SSFCTL 0x0092 3131 + #define ICH8_FLASH_PREOP 0x0094 3132 + #define ICH8_FLASH_OPTYPE 0x0096 3133 + #define ICH8_FLASH_OPMENU 0x0098 3134 + 3135 + #define ICH8_FLASH_REG_MAPSIZE 0x00A0 3136 + #define ICH8_FLASH_SECTOR_SIZE 4096 3137 + #define ICH8_GFPREG_BASE_MASK 0x1FFF 3138 + #define ICH8_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF 3139 + 3140 + /* ICH8 GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 3141 + /* Offset 04h HSFSTS */ 3142 + union ich8_hws_flash_status { 3143 + struct ich8_hsfsts { 3144 + #ifdef E1000_BIG_ENDIAN 3145 + uint16_t reserved2 :6; 3146 + uint16_t fldesvalid :1; 3147 + uint16_t flockdn :1; 3148 + uint16_t flcdone :1; 3149 + uint16_t flcerr :1; 3150 + uint16_t dael :1; 3151 + uint16_t berasesz :2; 3152 + uint16_t flcinprog :1; 3153 + uint16_t reserved1 :2; 3154 + #else 3155 + uint16_t flcdone :1; /* bit 0 Flash Cycle Done */ 3156 + uint16_t flcerr :1; /* bit 1 Flash Cycle Error */ 3157 + uint16_t dael :1; /* bit 2 Direct Access error Log */ 3158 + uint16_t berasesz :2; /* bit 4:3 Block/Sector Erase Size */ 3159 + uint16_t flcinprog :1; /* bit 5 flash SPI cycle in Progress */ 3160 + uint16_t reserved1 :2; /* bit 13:6 Reserved */ 3161 + uint16_t reserved2 :6; /* bit 13:6 Reserved */ 3162 + uint16_t fldesvalid :1; /* bit 14 Flash Descriptor Valid */ 3163 + uint16_t flockdn :1; /* bit 15 Flash Configuration Lock-Down */ 3164 + #endif 3165 + } hsf_status; 3166 + uint16_t regval; 3167 + }; 3168 + 3169 + /* ICH8 GbE Flash Hardware Sequencing Flash control Register bit breakdown */ 3170 + /* Offset 06h FLCTL */ 3171 + union ich8_hws_flash_ctrl { 3172 + struct ich8_hsflctl { 3173 + #ifdef E1000_BIG_ENDIAN 3174 + uint16_t fldbcount :2; 3175 + uint16_t flockdn :6; 3176 + uint16_t flcgo :1; 3177 + uint16_t flcycle :2; 3178 + uint16_t reserved :5; 3179 + #else 3180 + uint16_t flcgo :1; /* 0 Flash Cycle Go */ 3181 + uint16_t flcycle :2; /* 2:1 Flash Cycle */ 3182 + uint16_t reserved :5; /* 7:3 Reserved */ 3183 + uint16_t fldbcount :2; /* 9:8 Flash Data Byte Count */ 3184 + uint16_t flockdn :6; /* 15:10 Reserved */ 3185 + #endif 3186 + } hsf_ctrl; 3187 + uint16_t regval; 3188 + }; 3189 + 3190 + /* ICH8 Flash Region Access Permissions */ 3191 + union ich8_hws_flash_regacc { 3192 + struct ich8_flracc { 3193 + #ifdef E1000_BIG_ENDIAN 3194 + uint32_t gmwag :8; 3195 + uint32_t gmrag :8; 3196 + uint32_t grwa :8; 3197 + uint32_t grra :8; 3198 + #else 3199 + uint32_t grra :8; /* 0:7 GbE region Read Access */ 3200 + uint32_t grwa :8; /* 8:15 GbE region Write Access */ 3201 + uint32_t gmrag :8; /* 23:16 GbE Master Read Access Grant */ 3202 + uint32_t gmwag :8; /* 31:24 GbE Master Write Access Grant */ 3203 + #endif 3204 + } hsf_flregacc; 3205 + uint16_t regval; 3206 + }; 3163 3207 3164 3208 /* Miscellaneous PHY bit definitions. */ 3165 3209 #define PHY_PREAMBLE 0xFFFFFFFF
+264 -112
drivers/net/e1000/e1000_main.c
··· 36 36 #else 37 37 #define DRIVERNAPI "-NAPI" 38 38 #endif 39 - #define DRV_VERSION "7.0.38-k4"DRIVERNAPI 39 + #define DRV_VERSION "7.1.9-k2"DRIVERNAPI 40 40 char e1000_driver_version[] = DRV_VERSION; 41 41 static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 42 42 ··· 73 73 INTEL_E1000_ETHERNET_DEVICE(0x1026), 74 74 INTEL_E1000_ETHERNET_DEVICE(0x1027), 75 75 INTEL_E1000_ETHERNET_DEVICE(0x1028), 76 + INTEL_E1000_ETHERNET_DEVICE(0x1049), 77 + INTEL_E1000_ETHERNET_DEVICE(0x104A), 78 + INTEL_E1000_ETHERNET_DEVICE(0x104B), 79 + INTEL_E1000_ETHERNET_DEVICE(0x104C), 80 + INTEL_E1000_ETHERNET_DEVICE(0x104D), 76 81 INTEL_E1000_ETHERNET_DEVICE(0x105E), 77 82 INTEL_E1000_ETHERNET_DEVICE(0x105F), 78 83 INTEL_E1000_ETHERNET_DEVICE(0x1060), ··· 101 96 INTEL_E1000_ETHERNET_DEVICE(0x109A), 102 97 INTEL_E1000_ETHERNET_DEVICE(0x10B5), 103 98 INTEL_E1000_ETHERNET_DEVICE(0x10B9), 99 + INTEL_E1000_ETHERNET_DEVICE(0x10BA), 100 + INTEL_E1000_ETHERNET_DEVICE(0x10BB), 104 101 /* required last entry */ 105 102 {0,} 106 103 }; ··· 140 133 static void e1000_set_multi(struct net_device *netdev); 141 134 static void e1000_update_phy_info(unsigned long data); 142 135 static void e1000_watchdog(unsigned long data); 143 - static void e1000_watchdog_task(struct e1000_adapter *adapter); 144 136 static void e1000_82547_tx_fifo_stall(unsigned long data); 145 137 static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev); 146 138 static struct net_device_stats * e1000_get_stats(struct net_device *netdev); ··· 184 178 static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); 185 179 static void e1000_restore_vlan(struct e1000_adapter *adapter); 186 180 187 - #ifdef CONFIG_PM 188 181 static int e1000_suspend(struct pci_dev *pdev, pm_message_t state); 182 + #ifdef CONFIG_PM 189 183 static int e1000_resume(struct pci_dev *pdev); 190 184 #endif 191 185 static void e1000_shutdown(struct pci_dev *pdev); ··· 212 206 .probe = e1000_probe, 213 207 .remove = __devexit_p(e1000_remove), 214 208 /* Power Managment Hooks */ 215 - #ifdef CONFIG_PM 216 209 .suspend = e1000_suspend, 210 + #ifdef CONFIG_PM 217 211 .resume = e1000_resume, 218 212 #endif 219 213 .shutdown = e1000_shutdown, ··· 266 260 } 267 261 268 262 module_exit(e1000_exit_module); 263 + 264 + static int e1000_request_irq(struct e1000_adapter *adapter) 265 + { 266 + struct net_device *netdev = adapter->netdev; 267 + int flags, err = 0; 268 + 269 + flags = IRQF_SHARED; 270 + #ifdef CONFIG_PCI_MSI 271 + if (adapter->hw.mac_type > e1000_82547_rev_2) { 272 + adapter->have_msi = TRUE; 273 + if ((err = pci_enable_msi(adapter->pdev))) { 274 + DPRINTK(PROBE, ERR, 275 + "Unable to allocate MSI interrupt Error: %d\n", err); 276 + adapter->have_msi = FALSE; 277 + } 278 + } 279 + if (adapter->have_msi) 280 + flags &= ~SA_SHIRQ; 281 + #endif 282 + if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags, 283 + netdev->name, netdev))) 284 + DPRINTK(PROBE, ERR, 285 + "Unable to allocate interrupt Error: %d\n", err); 286 + 287 + return err; 288 + } 289 + 290 + static void e1000_free_irq(struct e1000_adapter *adapter) 291 + { 292 + struct net_device *netdev = adapter->netdev; 293 + 294 + free_irq(adapter->pdev->irq, netdev); 295 + 296 + #ifdef CONFIG_PCI_MSI 297 + if (adapter->have_msi) 298 + pci_disable_msi(adapter->pdev); 299 + #endif 300 + } 269 301 270 302 /** 271 303 * e1000_irq_disable - Mask off interrupt generation on the NIC ··· 373 329 { 374 330 uint32_t ctrl_ext; 375 331 uint32_t swsm; 332 + uint32_t extcnf; 376 333 377 334 /* Let firmware taken over control of h/w */ 378 335 switch (adapter->hw.mac_type) { ··· 388 343 swsm = E1000_READ_REG(&adapter->hw, SWSM); 389 344 E1000_WRITE_REG(&adapter->hw, SWSM, 390 345 swsm & ~E1000_SWSM_DRV_LOAD); 346 + case e1000_ich8lan: 347 + extcnf = E1000_READ_REG(&adapter->hw, CTRL_EXT); 348 + E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 349 + extcnf & ~E1000_CTRL_EXT_DRV_LOAD); 350 + break; 391 351 default: 392 352 break; 393 353 } ··· 414 364 { 415 365 uint32_t ctrl_ext; 416 366 uint32_t swsm; 367 + uint32_t extcnf; 417 368 /* Let firmware know the driver has taken over */ 418 369 switch (adapter->hw.mac_type) { 419 370 case e1000_82571: ··· 429 378 E1000_WRITE_REG(&adapter->hw, SWSM, 430 379 swsm | E1000_SWSM_DRV_LOAD); 431 380 break; 381 + case e1000_ich8lan: 382 + extcnf = E1000_READ_REG(&adapter->hw, EXTCNF_CTRL); 383 + E1000_WRITE_REG(&adapter->hw, EXTCNF_CTRL, 384 + extcnf | E1000_EXTCNF_CTRL_SWFLAG); 385 + break; 432 386 default: 433 387 break; 434 388 } ··· 443 387 e1000_up(struct e1000_adapter *adapter) 444 388 { 445 389 struct net_device *netdev = adapter->netdev; 446 - int i, err; 390 + int i; 447 391 448 392 /* hardware has been reset, we need to reload some things */ 449 - 450 - /* Reset the PHY if it was previously powered down */ 451 - if (adapter->hw.media_type == e1000_media_type_copper) { 452 - uint16_t mii_reg; 453 - e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 454 - if (mii_reg & MII_CR_POWER_DOWN) 455 - e1000_phy_hw_reset(&adapter->hw); 456 - } 457 393 458 394 e1000_set_multi(netdev); 459 395 ··· 463 415 E1000_DESC_UNUSED(ring)); 464 416 } 465 417 466 - #ifdef CONFIG_PCI_MSI 467 - if (adapter->hw.mac_type > e1000_82547_rev_2) { 468 - adapter->have_msi = TRUE; 469 - if ((err = pci_enable_msi(adapter->pdev))) { 470 - DPRINTK(PROBE, ERR, 471 - "Unable to allocate MSI interrupt Error: %d\n", err); 472 - adapter->have_msi = FALSE; 473 - } 474 - } 475 - #endif 476 - if ((err = request_irq(adapter->pdev->irq, &e1000_intr, 477 - IRQF_SHARED | IRQF_SAMPLE_RANDOM, 478 - netdev->name, netdev))) { 479 - DPRINTK(PROBE, ERR, 480 - "Unable to allocate interrupt Error: %d\n", err); 481 - return err; 482 - } 483 - 484 418 adapter->tx_queue_len = netdev->tx_queue_len; 485 419 486 420 mod_timer(&adapter->watchdog_timer, jiffies); ··· 475 445 return 0; 476 446 } 477 447 448 + /** 449 + * e1000_power_up_phy - restore link in case the phy was powered down 450 + * @adapter: address of board private structure 451 + * 452 + * The phy may be powered down to save power and turn off link when the 453 + * driver is unloaded and wake on lan is not enabled (among others) 454 + * *** this routine MUST be followed by a call to e1000_reset *** 455 + * 456 + **/ 457 + 458 + static void e1000_power_up_phy(struct e1000_adapter *adapter) 459 + { 460 + uint16_t mii_reg = 0; 461 + 462 + /* Just clear the power down bit to wake the phy back up */ 463 + if (adapter->hw.media_type == e1000_media_type_copper) { 464 + /* according to the manual, the phy will retain its 465 + * settings across a power-down/up cycle */ 466 + e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 467 + mii_reg &= ~MII_CR_POWER_DOWN; 468 + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 469 + } 470 + } 471 + 472 + static void e1000_power_down_phy(struct e1000_adapter *adapter) 473 + { 474 + boolean_t mng_mode_enabled = (adapter->hw.mac_type >= e1000_82571) && 475 + e1000_check_mng_mode(&adapter->hw); 476 + /* Power down the PHY so no link is implied when interface is down 477 + * The PHY cannot be powered down if any of the following is TRUE 478 + * (a) WoL is enabled 479 + * (b) AMT is active 480 + * (c) SoL/IDER session is active */ 481 + if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && 482 + adapter->hw.mac_type != e1000_ich8lan && 483 + adapter->hw.media_type == e1000_media_type_copper && 484 + !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN) && 485 + !mng_mode_enabled && 486 + !e1000_check_phy_reset_block(&adapter->hw)) { 487 + uint16_t mii_reg = 0; 488 + e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 489 + mii_reg |= MII_CR_POWER_DOWN; 490 + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 491 + mdelay(1); 492 + } 493 + } 494 + 478 495 void 479 496 e1000_down(struct e1000_adapter *adapter) 480 497 { 481 498 struct net_device *netdev = adapter->netdev; 482 - boolean_t mng_mode_enabled = (adapter->hw.mac_type >= e1000_82571) && 483 - e1000_check_mng_mode(&adapter->hw); 484 499 485 500 e1000_irq_disable(adapter); 486 501 487 - free_irq(adapter->pdev->irq, netdev); 488 - #ifdef CONFIG_PCI_MSI 489 - if (adapter->hw.mac_type > e1000_82547_rev_2 && 490 - adapter->have_msi == TRUE) 491 - pci_disable_msi(adapter->pdev); 492 - #endif 493 502 del_timer_sync(&adapter->tx_fifo_stall_timer); 494 503 del_timer_sync(&adapter->watchdog_timer); 495 504 del_timer_sync(&adapter->phy_info_timer); ··· 545 476 e1000_reset(adapter); 546 477 e1000_clean_all_tx_rings(adapter); 547 478 e1000_clean_all_rx_rings(adapter); 479 + } 548 480 549 - /* Power down the PHY so no link is implied when interface is down * 550 - * The PHY cannot be powered down if any of the following is TRUE * 551 - * (a) WoL is enabled 552 - * (b) AMT is active 553 - * (c) SoL/IDER session is active */ 554 - if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && 555 - adapter->hw.media_type == e1000_media_type_copper && 556 - !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN) && 557 - !mng_mode_enabled && 558 - !e1000_check_phy_reset_block(&adapter->hw)) { 559 - uint16_t mii_reg; 560 - e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 561 - mii_reg |= MII_CR_POWER_DOWN; 562 - e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 563 - mdelay(1); 564 - } 481 + void 482 + e1000_reinit_locked(struct e1000_adapter *adapter) 483 + { 484 + WARN_ON(in_interrupt()); 485 + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) 486 + msleep(1); 487 + e1000_down(adapter); 488 + e1000_up(adapter); 489 + clear_bit(__E1000_RESETTING, &adapter->flags); 565 490 } 566 491 567 492 void ··· 581 518 case e1000_82573: 582 519 pba = E1000_PBA_12K; 583 520 break; 521 + case e1000_ich8lan: 522 + pba = E1000_PBA_8K; 523 + break; 584 524 default: 585 525 pba = E1000_PBA_48K; 586 526 break; ··· 608 542 /* Set the FC high water mark to 90% of the FIFO size. 609 543 * Required to clear last 3 LSB */ 610 544 fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8; 545 + /* We can't use 90% on small FIFOs because the remainder 546 + * would be less than 1 full frame. In this case, we size 547 + * it to allow at least a full frame above the high water 548 + * mark. */ 549 + if (pba < E1000_PBA_16K) 550 + fc_high_water_mark = (pba * 1024) - 1600; 611 551 612 552 adapter->hw.fc_high_water = fc_high_water_mark; 613 553 adapter->hw.fc_low_water = fc_high_water_mark - 8; ··· 636 564 637 565 e1000_reset_adaptive(&adapter->hw); 638 566 e1000_phy_get_info(&adapter->hw, &adapter->phy_info); 567 + 568 + if (!adapter->smart_power_down && 569 + (adapter->hw.mac_type == e1000_82571 || 570 + adapter->hw.mac_type == e1000_82572)) { 571 + uint16_t phy_data = 0; 572 + /* speed up time to link by disabling smart power down, ignore 573 + * the return value of this function because there is nothing 574 + * different we would do if it failed */ 575 + e1000_read_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT, 576 + &phy_data); 577 + phy_data &= ~IGP02E1000_PM_SPD; 578 + e1000_write_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT, 579 + phy_data); 580 + } 581 + 582 + if (adapter->hw.mac_type < e1000_ich8lan) 583 + /* FIXME: this code is duplicate and wrong for PCI Express */ 639 584 if (adapter->en_mng_pt) { 640 585 manc = E1000_READ_REG(&adapter->hw, MANC); 641 586 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST); ··· 679 590 struct net_device *netdev; 680 591 struct e1000_adapter *adapter; 681 592 unsigned long mmio_start, mmio_len; 593 + unsigned long flash_start, flash_len; 682 594 683 595 static int cards_found = 0; 684 596 static int e1000_ksp3_port_a = 0; /* global ksp3 port a indication */ ··· 689 599 if ((err = pci_enable_device(pdev))) 690 600 return err; 691 601 692 - if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) { 602 + if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) && 603 + !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) { 693 604 pci_using_dac = 1; 694 605 } else { 695 - if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) { 606 + if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) && 607 + (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) { 696 608 E1000_ERR("No usable DMA configuration, aborting\n"); 697 609 return err; 698 610 } ··· 774 682 if ((err = e1000_sw_init(adapter))) 775 683 goto err_sw_init; 776 684 685 + /* Flash BAR mapping must happen after e1000_sw_init 686 + * because it depends on mac_type */ 687 + if ((adapter->hw.mac_type == e1000_ich8lan) && 688 + (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { 689 + flash_start = pci_resource_start(pdev, 1); 690 + flash_len = pci_resource_len(pdev, 1); 691 + adapter->hw.flash_address = ioremap(flash_start, flash_len); 692 + if (!adapter->hw.flash_address) { 693 + err = -EIO; 694 + goto err_flashmap; 695 + } 696 + } 697 + 777 698 if ((err = e1000_check_phy_reset_block(&adapter->hw))) 778 699 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n"); 779 700 ··· 805 700 NETIF_F_HW_VLAN_TX | 806 701 NETIF_F_HW_VLAN_RX | 807 702 NETIF_F_HW_VLAN_FILTER; 703 + if (adapter->hw.mac_type == e1000_ich8lan) 704 + netdev->features &= ~NETIF_F_HW_VLAN_FILTER; 808 705 } 809 706 810 707 #ifdef NETIF_F_TSO ··· 822 715 if (pci_using_dac) 823 716 netdev->features |= NETIF_F_HIGHDMA; 824 717 825 - /* hard_start_xmit is safe against parallel locking */ 826 718 netdev->features |= NETIF_F_LLTX; 827 719 828 720 adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw); 721 + 722 + /* initialize eeprom parameters */ 723 + 724 + if (e1000_init_eeprom_params(&adapter->hw)) { 725 + E1000_ERR("EEPROM initialization failed\n"); 726 + return -EIO; 727 + } 829 728 830 729 /* before reading the EEPROM, reset the controller to 831 730 * put the device in a known good starting state */ ··· 871 758 adapter->watchdog_timer.function = &e1000_watchdog; 872 759 adapter->watchdog_timer.data = (unsigned long) adapter; 873 760 874 - INIT_WORK(&adapter->watchdog_task, 875 - (void (*)(void *))e1000_watchdog_task, adapter); 876 - 877 761 init_timer(&adapter->phy_info_timer); 878 762 adapter->phy_info_timer.function = &e1000_update_phy_info; 879 763 adapter->phy_info_timer.data = (unsigned long) adapter; ··· 899 789 e1000_read_eeprom(&adapter->hw, 900 790 EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data); 901 791 eeprom_apme_mask = E1000_EEPROM_82544_APM; 792 + break; 793 + case e1000_ich8lan: 794 + e1000_read_eeprom(&adapter->hw, 795 + EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data); 796 + eeprom_apme_mask = E1000_EEPROM_ICH8_APME; 902 797 break; 903 798 case e1000_82546: 904 799 case e1000_82546_rev_3: ··· 964 849 return 0; 965 850 966 851 err_register: 852 + if (adapter->hw.flash_address) 853 + iounmap(adapter->hw.flash_address); 854 + err_flashmap: 967 855 err_sw_init: 968 856 err_eeprom: 969 857 iounmap(adapter->hw.hw_addr); ··· 1000 882 flush_scheduled_work(); 1001 883 1002 884 if (adapter->hw.mac_type >= e1000_82540 && 885 + adapter->hw.mac_type != e1000_ich8lan && 1003 886 adapter->hw.media_type == e1000_media_type_copper) { 1004 887 manc = E1000_READ_REG(&adapter->hw, MANC); 1005 888 if (manc & E1000_MANC_SMBUS_EN) { ··· 1029 910 #endif 1030 911 1031 912 iounmap(adapter->hw.hw_addr); 913 + if (adapter->hw.flash_address) 914 + iounmap(adapter->hw.flash_address); 1032 915 pci_release_regions(pdev); 1033 916 1034 917 free_netdev(netdev); ··· 1078 957 1079 958 if (e1000_set_mac_type(hw)) { 1080 959 DPRINTK(PROBE, ERR, "Unknown MAC Type\n"); 1081 - return -EIO; 1082 - } 1083 - 1084 - /* initialize eeprom parameters */ 1085 - 1086 - if (e1000_init_eeprom_params(hw)) { 1087 - E1000_ERR("EEPROM initialization failed\n"); 1088 960 return -EIO; 1089 961 } 1090 962 ··· 1192 1078 struct e1000_adapter *adapter = netdev_priv(netdev); 1193 1079 int err; 1194 1080 1081 + /* disallow open during test */ 1082 + if (test_bit(__E1000_DRIVER_TESTING, &adapter->flags)) 1083 + return -EBUSY; 1084 + 1195 1085 /* allocate transmit descriptors */ 1196 1086 1197 1087 if ((err = e1000_setup_all_tx_resources(adapter))) ··· 1205 1087 1206 1088 if ((err = e1000_setup_all_rx_resources(adapter))) 1207 1089 goto err_setup_rx; 1090 + 1091 + err = e1000_request_irq(adapter); 1092 + if (err) 1093 + goto err_up; 1094 + 1095 + e1000_power_up_phy(adapter); 1208 1096 1209 1097 if ((err = e1000_up(adapter))) 1210 1098 goto err_up; ··· 1255 1131 { 1256 1132 struct e1000_adapter *adapter = netdev_priv(netdev); 1257 1133 1134 + WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); 1258 1135 e1000_down(adapter); 1136 + e1000_power_down_phy(adapter); 1137 + e1000_free_irq(adapter); 1259 1138 1260 1139 e1000_free_all_tx_resources(adapter); 1261 1140 e1000_free_all_rx_resources(adapter); ··· 1316 1189 int size; 1317 1190 1318 1191 size = sizeof(struct e1000_buffer) * txdr->count; 1319 - 1320 - txdr->buffer_info = vmalloc_node(size, pcibus_to_node(pdev->bus)); 1192 + txdr->buffer_info = vmalloc(size); 1321 1193 if (!txdr->buffer_info) { 1322 1194 DPRINTK(PROBE, ERR, 1323 1195 "Unable to allocate memory for the transmit descriptor ring\n"); ··· 1428 1302 tdba = adapter->tx_ring[0].dma; 1429 1303 tdlen = adapter->tx_ring[0].count * 1430 1304 sizeof(struct e1000_tx_desc); 1431 - E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL)); 1432 - E1000_WRITE_REG(hw, TDBAH, (tdba >> 32)); 1433 1305 E1000_WRITE_REG(hw, TDLEN, tdlen); 1434 - E1000_WRITE_REG(hw, TDH, 0); 1306 + E1000_WRITE_REG(hw, TDBAH, (tdba >> 32)); 1307 + E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL)); 1435 1308 E1000_WRITE_REG(hw, TDT, 0); 1309 + E1000_WRITE_REG(hw, TDH, 0); 1436 1310 adapter->tx_ring[0].tdh = E1000_TDH; 1437 1311 adapter->tx_ring[0].tdt = E1000_TDT; 1438 1312 break; ··· 1544 1418 int size, desc_len; 1545 1419 1546 1420 size = sizeof(struct e1000_buffer) * rxdr->count; 1547 - rxdr->buffer_info = vmalloc_node(size, pcibus_to_node(pdev->bus)); 1421 + rxdr->buffer_info = vmalloc(size); 1548 1422 if (!rxdr->buffer_info) { 1549 1423 DPRINTK(PROBE, ERR, 1550 1424 "Unable to allocate memory for the receive descriptor ring\n"); ··· 1686 1560 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | 1687 1561 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); 1688 1562 1689 - if (adapter->hw.mac_type > e1000_82543) 1690 - rctl |= E1000_RCTL_SECRC; 1691 - 1692 1563 if (adapter->hw.tbi_compatibility_on == 1) 1693 1564 rctl |= E1000_RCTL_SBP; 1694 1565 else ··· 1751 1628 rfctl |= E1000_RFCTL_IPV6_DIS; 1752 1629 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl); 1753 1630 1754 - rctl |= E1000_RCTL_DTYP_PS | E1000_RCTL_SECRC; 1631 + rctl |= E1000_RCTL_DTYP_PS; 1755 1632 1756 1633 psrctl |= adapter->rx_ps_bsize0 >> 1757 1634 E1000_PSRCTL_BSIZE0_SHIFT; ··· 1835 1712 case 1: 1836 1713 default: 1837 1714 rdba = adapter->rx_ring[0].dma; 1838 - E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL)); 1839 - E1000_WRITE_REG(hw, RDBAH, (rdba >> 32)); 1840 1715 E1000_WRITE_REG(hw, RDLEN, rdlen); 1841 - E1000_WRITE_REG(hw, RDH, 0); 1716 + E1000_WRITE_REG(hw, RDBAH, (rdba >> 32)); 1717 + E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL)); 1842 1718 E1000_WRITE_REG(hw, RDT, 0); 1719 + E1000_WRITE_REG(hw, RDH, 0); 1843 1720 adapter->rx_ring[0].rdh = E1000_RDH; 1844 1721 adapter->rx_ring[0].rdt = E1000_RDT; 1845 1722 break; ··· 1863 1740 } 1864 1741 E1000_WRITE_REG(hw, RXCSUM, rxcsum); 1865 1742 } 1866 - 1867 - if (hw->mac_type == e1000_82573) 1868 - E1000_WRITE_REG(hw, ERT, 0x0100); 1869 1743 1870 1744 /* Enable Receives */ 1871 1745 E1000_WRITE_REG(hw, RCTL, rctl); ··· 2203 2083 uint32_t rctl; 2204 2084 uint32_t hash_value; 2205 2085 int i, rar_entries = E1000_RAR_ENTRIES; 2086 + int mta_reg_count = (hw->mac_type == e1000_ich8lan) ? 2087 + E1000_NUM_MTA_REGISTERS_ICH8LAN : 2088 + E1000_NUM_MTA_REGISTERS; 2089 + 2090 + if (adapter->hw.mac_type == e1000_ich8lan) 2091 + rar_entries = E1000_RAR_ENTRIES_ICH8LAN; 2206 2092 2207 2093 /* reserve RAR[14] for LAA over-write work-around */ 2208 2094 if (adapter->hw.mac_type == e1000_82571) ··· 2247 2121 mc_ptr = mc_ptr->next; 2248 2122 } else { 2249 2123 E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0); 2124 + E1000_WRITE_FLUSH(hw); 2250 2125 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0); 2126 + E1000_WRITE_FLUSH(hw); 2251 2127 } 2252 2128 } 2253 2129 2254 2130 /* clear the old settings from the multicast hash table */ 2255 2131 2256 - for (i = 0; i < E1000_NUM_MTA_REGISTERS; i++) 2132 + for (i = 0; i < mta_reg_count; i++) { 2257 2133 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 2134 + E1000_WRITE_FLUSH(hw); 2135 + } 2258 2136 2259 2137 /* load any remaining addresses into the hash table */ 2260 2138 ··· 2331 2201 e1000_watchdog(unsigned long data) 2332 2202 { 2333 2203 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 2334 - 2335 - /* Do the rest outside of interrupt context */ 2336 - schedule_work(&adapter->watchdog_task); 2337 - } 2338 - 2339 - static void 2340 - e1000_watchdog_task(struct e1000_adapter *adapter) 2341 - { 2342 2204 struct net_device *netdev = adapter->netdev; 2343 2205 struct e1000_tx_ring *txdr = adapter->tx_ring; 2344 2206 uint32_t link, tctl; 2207 + int32_t ret_val; 2345 2208 2346 - e1000_check_for_link(&adapter->hw); 2209 + ret_val = e1000_check_for_link(&adapter->hw); 2210 + if ((ret_val == E1000_ERR_PHY) && 2211 + (adapter->hw.phy_type == e1000_phy_igp_3) && 2212 + (E1000_READ_REG(&adapter->hw, CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) { 2213 + /* See e1000_kumeran_lock_loss_workaround() */ 2214 + DPRINTK(LINK, INFO, 2215 + "Gigabit has been disabled, downgrading speed\n"); 2216 + } 2347 2217 if (adapter->hw.mac_type == e1000_82573) { 2348 2218 e1000_enable_tx_pkt_filtering(&adapter->hw); 2349 2219 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) ··· 2909 2779 case e1000_82571: 2910 2780 case e1000_82572: 2911 2781 case e1000_82573: 2782 + case e1000_ich8lan: 2912 2783 pull_size = min((unsigned int)4, skb->data_len); 2913 2784 if (!__pskb_pull_tail(skb, pull_size)) { 2914 - printk(KERN_ERR 2785 + DPRINTK(DRV, ERR, 2915 2786 "__pskb_pull_tail failed.\n"); 2916 2787 dev_kfree_skb_any(skb); 2917 2788 return NETDEV_TX_OK; ··· 3050 2919 { 3051 2920 struct e1000_adapter *adapter = netdev_priv(netdev); 3052 2921 3053 - e1000_down(adapter); 3054 - e1000_up(adapter); 2922 + e1000_reinit_locked(adapter); 3055 2923 } 3056 2924 3057 2925 /** ··· 3094 2964 /* Adapter-specific max frame size limits. */ 3095 2965 switch (adapter->hw.mac_type) { 3096 2966 case e1000_undefined ... e1000_82542_rev2_1: 2967 + case e1000_ich8lan: 3097 2968 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3098 2969 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); 3099 2970 return -EINVAL; ··· 3157 3026 3158 3027 netdev->mtu = new_mtu; 3159 3028 3160 - if (netif_running(netdev)) { 3161 - e1000_down(adapter); 3162 - e1000_up(adapter); 3163 - } 3029 + if (netif_running(netdev)) 3030 + e1000_reinit_locked(adapter); 3164 3031 3165 3032 adapter->hw.max_frame_size = max_frame; 3166 3033 ··· 3203 3074 adapter->stats.bprc += E1000_READ_REG(hw, BPRC); 3204 3075 adapter->stats.mprc += E1000_READ_REG(hw, MPRC); 3205 3076 adapter->stats.roc += E1000_READ_REG(hw, ROC); 3077 + 3078 + if (adapter->hw.mac_type != e1000_ich8lan) { 3206 3079 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64); 3207 3080 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127); 3208 3081 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255); 3209 3082 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511); 3210 3083 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023); 3211 3084 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522); 3085 + } 3212 3086 3213 3087 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS); 3214 3088 adapter->stats.mpc += E1000_READ_REG(hw, MPC); ··· 3239 3107 adapter->stats.totl += E1000_READ_REG(hw, TOTL); 3240 3108 adapter->stats.toth += E1000_READ_REG(hw, TOTH); 3241 3109 adapter->stats.tpr += E1000_READ_REG(hw, TPR); 3110 + 3111 + if (adapter->hw.mac_type != e1000_ich8lan) { 3242 3112 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64); 3243 3113 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127); 3244 3114 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255); 3245 3115 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511); 3246 3116 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023); 3247 3117 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522); 3118 + } 3119 + 3248 3120 adapter->stats.mptc += E1000_READ_REG(hw, MPTC); 3249 3121 adapter->stats.bptc += E1000_READ_REG(hw, BPTC); 3250 3122 ··· 3270 3134 if (hw->mac_type > e1000_82547_rev_2) { 3271 3135 adapter->stats.iac += E1000_READ_REG(hw, IAC); 3272 3136 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC); 3137 + 3138 + if (adapter->hw.mac_type != e1000_ich8lan) { 3273 3139 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC); 3274 3140 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC); 3275 3141 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC); ··· 3279 3141 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC); 3280 3142 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC); 3281 3143 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC); 3144 + } 3282 3145 } 3283 3146 3284 3147 /* Fill out the OS statistics structure */ ··· 3686 3547 /* All receives must fit into a single buffer */ 3687 3548 E1000_DBG("%s: Receive packet consumed multiple" 3688 3549 " buffers\n", netdev->name); 3689 - dev_kfree_skb_irq(skb); 3550 + /* recycle */ 3551 + buffer_info-> skb = skb; 3690 3552 goto next_desc; 3691 3553 } 3692 3554 ··· 3815 3675 buffer_info = &rx_ring->buffer_info[i]; 3816 3676 3817 3677 while (staterr & E1000_RXD_STAT_DD) { 3818 - buffer_info = &rx_ring->buffer_info[i]; 3819 3678 ps_page = &rx_ring->ps_page[i]; 3820 3679 ps_page_dma = &rx_ring->ps_page_dma[i]; 3821 3680 #ifdef CONFIG_E1000_NAPI ··· 4319 4180 return retval; 4320 4181 } 4321 4182 } 4322 - if (netif_running(adapter->netdev)) { 4323 - e1000_down(adapter); 4324 - e1000_up(adapter); 4325 - } else 4183 + if (netif_running(adapter->netdev)) 4184 + e1000_reinit_locked(adapter); 4185 + else 4326 4186 e1000_reset(adapter); 4327 4187 break; 4328 4188 case M88E1000_PHY_SPEC_CTRL: ··· 4338 4200 case PHY_CTRL: 4339 4201 if (mii_reg & MII_CR_POWER_DOWN) 4340 4202 break; 4341 - if (netif_running(adapter->netdev)) { 4342 - e1000_down(adapter); 4343 - e1000_up(adapter); 4344 - } else 4203 + if (netif_running(adapter->netdev)) 4204 + e1000_reinit_locked(adapter); 4205 + else 4345 4206 e1000_reset(adapter); 4346 4207 break; 4347 4208 } ··· 4414 4277 ctrl |= E1000_CTRL_VME; 4415 4278 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4416 4279 4280 + if (adapter->hw.mac_type != e1000_ich8lan) { 4417 4281 /* enable VLAN receive filtering */ 4418 4282 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4419 4283 rctl |= E1000_RCTL_VFE; 4420 4284 rctl &= ~E1000_RCTL_CFIEN; 4421 4285 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4422 4286 e1000_update_mng_vlan(adapter); 4287 + } 4423 4288 } else { 4424 4289 /* disable VLAN tag insert/strip */ 4425 4290 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 4426 4291 ctrl &= ~E1000_CTRL_VME; 4427 4292 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4428 4293 4294 + if (adapter->hw.mac_type != e1000_ich8lan) { 4429 4295 /* disable VLAN filtering */ 4430 4296 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4431 4297 rctl &= ~E1000_RCTL_VFE; ··· 4436 4296 if (adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) { 4437 4297 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 4438 4298 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 4299 + } 4439 4300 } 4440 4301 } 4441 4302 ··· 4599 4458 struct e1000_adapter *adapter = netdev_priv(netdev); 4600 4459 uint32_t ctrl, ctrl_ext, rctl, manc, status; 4601 4460 uint32_t wufc = adapter->wol; 4461 + #ifdef CONFIG_PM 4602 4462 int retval = 0; 4463 + #endif 4603 4464 4604 4465 netif_device_detach(netdev); 4605 4466 4606 - if (netif_running(netdev)) 4467 + if (netif_running(netdev)) { 4468 + WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); 4607 4469 e1000_down(adapter); 4470 + } 4608 4471 4609 4472 #ifdef CONFIG_PM 4610 4473 /* Implement our own version of pci_save_state(pdev) because pci- ··· 4666 4521 pci_enable_wake(pdev, PCI_D3cold, 0); 4667 4522 } 4668 4523 4524 + /* FIXME: this code is incorrect for PCI Express */ 4669 4525 if (adapter->hw.mac_type >= e1000_82540 && 4526 + adapter->hw.mac_type != e1000_ich8lan && 4670 4527 adapter->hw.media_type == e1000_media_type_copper) { 4671 4528 manc = E1000_READ_REG(&adapter->hw, MANC); 4672 4529 if (manc & E1000_MANC_SMBUS_EN) { ··· 4678 4531 pci_enable_wake(pdev, PCI_D3cold, 1); 4679 4532 } 4680 4533 } 4534 + 4535 + if (adapter->hw.phy_type == e1000_phy_igp_3) 4536 + e1000_phy_powerdown_workaround(&adapter->hw); 4681 4537 4682 4538 /* Release control of h/w to f/w. If f/w is AMT enabled, this 4683 4539 * would have already happened in close and is redundant. */ ··· 4717 4567 4718 4568 netif_device_attach(netdev); 4719 4569 4570 + /* FIXME: this code is incorrect for PCI Express */ 4720 4571 if (adapter->hw.mac_type >= e1000_82540 && 4572 + adapter->hw.mac_type != e1000_ich8lan && 4721 4573 adapter->hw.media_type == e1000_media_type_copper) { 4722 4574 manc = E1000_READ_REG(&adapter->hw, MANC); 4723 4575 manc &= ~(E1000_MANC_ARP_EN);
+13
drivers/net/e1000/e1000_osdep.h
··· 127 127 128 128 #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS) 129 129 130 + #define E1000_WRITE_ICH8_REG(a, reg, value) ( \ 131 + writel((value), ((a)->flash_address + reg))) 132 + 133 + #define E1000_READ_ICH8_REG(a, reg) ( \ 134 + readl((a)->flash_address + reg)) 135 + 136 + #define E1000_WRITE_ICH8_REG16(a, reg, value) ( \ 137 + writew((value), ((a)->flash_address + reg))) 138 + 139 + #define E1000_READ_ICH8_REG16(a, reg) ( \ 140 + readw((a)->flash_address + reg)) 141 + 142 + 130 143 #endif /* _E1000_OSDEP_H_ */
+100 -99
drivers/net/e1000/e1000_param.c
··· 45 45 */ 46 46 47 47 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } 48 + /* Module Parameters are always initialized to -1, so that the driver 49 + * can tell the difference between no user specified value or the 50 + * user asking for the default value. 51 + * The true default values are loaded in when e1000_check_options is called. 52 + * 53 + * This is a GCC extension to ANSI C. 54 + * See the item "Labeled Elements in Initializers" in the section 55 + * "Extensions to the C Language Family" of the GCC documentation. 56 + */ 57 + 48 58 #define E1000_PARAM(X, desc) \ 49 59 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ 50 60 static int num_##X = 0; \ ··· 193 183 194 184 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); 195 185 186 + /* Enable Smart Power Down of the PHY 187 + * 188 + * Valid Range: 0, 1 189 + * 190 + * Default Value: 0 (disabled) 191 + */ 192 + 193 + E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); 194 + 195 + /* Enable Kumeran Lock Loss workaround 196 + * 197 + * Valid Range: 0, 1 198 + * 199 + * Default Value: 1 (enabled) 200 + */ 201 + 202 + E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); 203 + 196 204 #define AUTONEG_ADV_DEFAULT 0x2F 197 205 #define AUTONEG_ADV_MASK 0x2F 198 206 #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL ··· 324 296 DPRINTK(PROBE, NOTICE, 325 297 "Warning: no configuration for board #%i\n", bd); 326 298 DPRINTK(PROBE, NOTICE, "Using defaults for all values\n"); 299 + bd = E1000_MAX_NIC; 327 300 } 328 301 329 302 { /* Transmit Descriptor Count */ ··· 342 313 opt.arg.r.max = mac_type < e1000_82544 ? 343 314 E1000_MAX_TXD : E1000_MAX_82544_TXD; 344 315 345 - if (num_TxDescriptors > bd) { 346 - tx_ring->count = TxDescriptors[bd]; 347 - e1000_validate_option(&tx_ring->count, &opt, adapter); 348 - E1000_ROUNDUP(tx_ring->count, 349 - REQ_TX_DESCRIPTOR_MULTIPLE); 350 - } else { 351 - tx_ring->count = opt.def; 352 - } 316 + tx_ring->count = TxDescriptors[bd]; 317 + e1000_validate_option(&tx_ring->count, &opt, adapter); 318 + E1000_ROUNDUP(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE); 353 319 for (i = 0; i < adapter->num_tx_queues; i++) 354 320 tx_ring[i].count = tx_ring->count; 355 321 } ··· 363 339 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : 364 340 E1000_MAX_82544_RXD; 365 341 366 - if (num_RxDescriptors > bd) { 367 - rx_ring->count = RxDescriptors[bd]; 368 - e1000_validate_option(&rx_ring->count, &opt, adapter); 369 - E1000_ROUNDUP(rx_ring->count, 370 - REQ_RX_DESCRIPTOR_MULTIPLE); 371 - } else { 372 - rx_ring->count = opt.def; 373 - } 342 + rx_ring->count = RxDescriptors[bd]; 343 + e1000_validate_option(&rx_ring->count, &opt, adapter); 344 + E1000_ROUNDUP(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); 374 345 for (i = 0; i < adapter->num_rx_queues; i++) 375 346 rx_ring[i].count = rx_ring->count; 376 347 } ··· 377 358 .def = OPTION_ENABLED 378 359 }; 379 360 380 - if (num_XsumRX > bd) { 381 - int rx_csum = XsumRX[bd]; 382 - e1000_validate_option(&rx_csum, &opt, adapter); 383 - adapter->rx_csum = rx_csum; 384 - } else { 385 - adapter->rx_csum = opt.def; 386 - } 361 + int rx_csum = XsumRX[bd]; 362 + e1000_validate_option(&rx_csum, &opt, adapter); 363 + adapter->rx_csum = rx_csum; 387 364 } 388 365 { /* Flow Control */ 389 366 ··· 399 384 .p = fc_list }} 400 385 }; 401 386 402 - if (num_FlowControl > bd) { 403 - int fc = FlowControl[bd]; 404 - e1000_validate_option(&fc, &opt, adapter); 405 - adapter->hw.fc = adapter->hw.original_fc = fc; 406 - } else { 407 - adapter->hw.fc = adapter->hw.original_fc = opt.def; 408 - } 387 + int fc = FlowControl[bd]; 388 + e1000_validate_option(&fc, &opt, adapter); 389 + adapter->hw.fc = adapter->hw.original_fc = fc; 409 390 } 410 391 { /* Transmit Interrupt Delay */ 411 392 struct e1000_option opt = { ··· 413 402 .max = MAX_TXDELAY }} 414 403 }; 415 404 416 - if (num_TxIntDelay > bd) { 417 - adapter->tx_int_delay = TxIntDelay[bd]; 418 - e1000_validate_option(&adapter->tx_int_delay, &opt, 419 - adapter); 420 - } else { 421 - adapter->tx_int_delay = opt.def; 422 - } 405 + adapter->tx_int_delay = TxIntDelay[bd]; 406 + e1000_validate_option(&adapter->tx_int_delay, &opt, adapter); 423 407 } 424 408 { /* Transmit Absolute Interrupt Delay */ 425 409 struct e1000_option opt = { ··· 426 420 .max = MAX_TXABSDELAY }} 427 421 }; 428 422 429 - if (num_TxAbsIntDelay > bd) { 430 - adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; 431 - e1000_validate_option(&adapter->tx_abs_int_delay, &opt, 432 - adapter); 433 - } else { 434 - adapter->tx_abs_int_delay = opt.def; 435 - } 423 + adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; 424 + e1000_validate_option(&adapter->tx_abs_int_delay, &opt, 425 + adapter); 436 426 } 437 427 { /* Receive Interrupt Delay */ 438 428 struct e1000_option opt = { ··· 440 438 .max = MAX_RXDELAY }} 441 439 }; 442 440 443 - if (num_RxIntDelay > bd) { 444 - adapter->rx_int_delay = RxIntDelay[bd]; 445 - e1000_validate_option(&adapter->rx_int_delay, &opt, 446 - adapter); 447 - } else { 448 - adapter->rx_int_delay = opt.def; 449 - } 441 + adapter->rx_int_delay = RxIntDelay[bd]; 442 + e1000_validate_option(&adapter->rx_int_delay, &opt, adapter); 450 443 } 451 444 { /* Receive Absolute Interrupt Delay */ 452 445 struct e1000_option opt = { ··· 453 456 .max = MAX_RXABSDELAY }} 454 457 }; 455 458 456 - if (num_RxAbsIntDelay > bd) { 457 - adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; 458 - e1000_validate_option(&adapter->rx_abs_int_delay, &opt, 459 - adapter); 460 - } else { 461 - adapter->rx_abs_int_delay = opt.def; 462 - } 459 + adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; 460 + e1000_validate_option(&adapter->rx_abs_int_delay, &opt, 461 + adapter); 463 462 } 464 463 { /* Interrupt Throttling Rate */ 465 464 struct e1000_option opt = { ··· 467 474 .max = MAX_ITR }} 468 475 }; 469 476 470 - if (num_InterruptThrottleRate > bd) { 471 - adapter->itr = InterruptThrottleRate[bd]; 472 - switch (adapter->itr) { 473 - case 0: 474 - DPRINTK(PROBE, INFO, "%s turned off\n", 475 - opt.name); 476 - break; 477 - case 1: 478 - DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 479 - opt.name); 480 - break; 481 - default: 482 - e1000_validate_option(&adapter->itr, &opt, 483 - adapter); 484 - break; 485 - } 486 - } else { 487 - adapter->itr = opt.def; 477 + adapter->itr = InterruptThrottleRate[bd]; 478 + switch (adapter->itr) { 479 + case 0: 480 + DPRINTK(PROBE, INFO, "%s turned off\n", opt.name); 481 + break; 482 + case 1: 483 + DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 484 + opt.name); 485 + break; 486 + default: 487 + e1000_validate_option(&adapter->itr, &opt, adapter); 488 + break; 488 489 } 490 + } 491 + { /* Smart Power Down */ 492 + struct e1000_option opt = { 493 + .type = enable_option, 494 + .name = "PHY Smart Power Down", 495 + .err = "defaulting to Disabled", 496 + .def = OPTION_DISABLED 497 + }; 498 + 499 + int spd = SmartPowerDownEnable[bd]; 500 + e1000_validate_option(&spd, &opt, adapter); 501 + adapter->smart_power_down = spd; 502 + } 503 + { /* Kumeran Lock Loss Workaround */ 504 + struct e1000_option opt = { 505 + .type = enable_option, 506 + .name = "Kumeran Lock Loss Workaround", 507 + .err = "defaulting to Enabled", 508 + .def = OPTION_ENABLED 509 + }; 510 + 511 + int kmrn_lock_loss = KumeranLockLoss[bd]; 512 + e1000_validate_option(&kmrn_lock_loss, &opt, adapter); 513 + adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; 489 514 } 490 515 491 516 switch (adapter->hw.media_type) { ··· 530 519 e1000_check_fiber_options(struct e1000_adapter *adapter) 531 520 { 532 521 int bd = adapter->bd_number; 533 - if (num_Speed > bd) { 522 + bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd; 523 + if ((Speed[bd] != OPTION_UNSET)) { 534 524 DPRINTK(PROBE, INFO, "Speed not valid for fiber adapters, " 535 525 "parameter ignored\n"); 536 526 } 537 527 538 - if (num_Duplex > bd) { 528 + if ((Duplex[bd] != OPTION_UNSET)) { 539 529 DPRINTK(PROBE, INFO, "Duplex not valid for fiber adapters, " 540 530 "parameter ignored\n"); 541 531 } 542 532 543 - if ((num_AutoNeg > bd) && (AutoNeg[bd] != 0x20)) { 533 + if ((AutoNeg[bd] != OPTION_UNSET) && (AutoNeg[bd] != 0x20)) { 544 534 DPRINTK(PROBE, INFO, "AutoNeg other than 1000/Full is " 545 535 "not valid for fiber adapters, " 546 536 "parameter ignored\n"); ··· 560 548 { 561 549 int speed, dplx, an; 562 550 int bd = adapter->bd_number; 551 + bd = bd > E1000_MAX_NIC ? E1000_MAX_NIC : bd; 563 552 564 553 { /* Speed */ 565 554 struct e1000_opt_list speed_list[] = {{ 0, "" }, ··· 577 564 .p = speed_list }} 578 565 }; 579 566 580 - if (num_Speed > bd) { 581 - speed = Speed[bd]; 582 - e1000_validate_option(&speed, &opt, adapter); 583 - } else { 584 - speed = opt.def; 585 - } 567 + speed = Speed[bd]; 568 + e1000_validate_option(&speed, &opt, adapter); 586 569 } 587 570 { /* Duplex */ 588 571 struct e1000_opt_list dplx_list[] = {{ 0, "" }, ··· 600 591 "Speed/Duplex/AutoNeg parameter ignored.\n"); 601 592 return; 602 593 } 603 - if (num_Duplex > bd) { 604 - dplx = Duplex[bd]; 605 - e1000_validate_option(&dplx, &opt, adapter); 606 - } else { 607 - dplx = opt.def; 608 - } 594 + dplx = Duplex[bd]; 595 + e1000_validate_option(&dplx, &opt, adapter); 609 596 } 610 597 611 - if ((num_AutoNeg > bd) && (speed != 0 || dplx != 0)) { 598 + if (AutoNeg[bd] != OPTION_UNSET && (speed != 0 || dplx != 0)) { 612 599 DPRINTK(PROBE, INFO, 613 600 "AutoNeg specified along with Speed or Duplex, " 614 601 "parameter ignored\n"); ··· 653 648 .p = an_list }} 654 649 }; 655 650 656 - if (num_AutoNeg > bd) { 657 - an = AutoNeg[bd]; 658 - e1000_validate_option(&an, &opt, adapter); 659 - } else { 660 - an = opt.def; 661 - } 651 + an = AutoNeg[bd]; 652 + e1000_validate_option(&an, &opt, adapter); 662 653 adapter->hw.autoneg_advertised = an; 663 654 } 664 655 665 656 switch (speed + dplx) { 666 657 case 0: 667 658 adapter->hw.autoneg = adapter->fc_autoneg = 1; 668 - if ((num_Speed > bd) && (speed != 0 || dplx != 0)) 659 + if (Speed[bd] != OPTION_UNSET || Duplex[bd] != OPTION_UNSET) 669 660 DPRINTK(PROBE, INFO, 670 661 "Speed and duplex autonegotiation enabled\n"); 671 662 break;