82571.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2008 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. /*
  22. * 82571EB Gigabit Ethernet Controller
  23. * 82571EB Gigabit Ethernet Controller (Fiber)
  24. * 82571EB Dual Port Gigabit Mezzanine Adapter
  25. * 82571EB Quad Port Gigabit Mezzanine Adapter
  26. * 82571PT Gigabit PT Quad Port Server ExpressModule
  27. * 82572EI Gigabit Ethernet Controller (Copper)
  28. * 82572EI Gigabit Ethernet Controller (Fiber)
  29. * 82572EI Gigabit Ethernet Controller
  30. * 82573V Gigabit Ethernet Controller (Copper)
  31. * 82573E Gigabit Ethernet Controller (Copper)
  32. * 82573L Gigabit Ethernet Controller
  33. */
  34. #include <linux/netdevice.h>
  35. #include <linux/delay.h>
  36. #include <linux/pci.h>
  37. #include "e1000.h"
  38. #define ID_LED_RESERVED_F746 0xF746
  39. #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \
  40. (ID_LED_OFF1_ON2 << 8) | \
  41. (ID_LED_DEF1_DEF2 << 4) | \
  42. (ID_LED_DEF1_DEF2))
  43. #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
  44. static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
  45. static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
  46. static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
  47. static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
  48. u16 words, u16 *data);
  49. static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
  50. static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
  51. static s32 e1000_setup_link_82571(struct e1000_hw *hw);
  52. static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
  53. /**
  54. * e1000_init_phy_params_82571 - Init PHY func ptrs.
  55. * @hw: pointer to the HW structure
  56. *
  57. * This is a function pointer entry point called by the api module.
  58. **/
  59. static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
  60. {
  61. struct e1000_phy_info *phy = &hw->phy;
  62. s32 ret_val;
  63. if (hw->phy.media_type != e1000_media_type_copper) {
  64. phy->type = e1000_phy_none;
  65. return 0;
  66. }
  67. phy->addr = 1;
  68. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  69. phy->reset_delay_us = 100;
  70. switch (hw->mac.type) {
  71. case e1000_82571:
  72. case e1000_82572:
  73. phy->type = e1000_phy_igp_2;
  74. break;
  75. case e1000_82573:
  76. phy->type = e1000_phy_m88;
  77. break;
  78. default:
  79. return -E1000_ERR_PHY;
  80. break;
  81. }
  82. /* This can only be done after all function pointers are setup. */
  83. ret_val = e1000_get_phy_id_82571(hw);
  84. /* Verify phy id */
  85. switch (hw->mac.type) {
  86. case e1000_82571:
  87. case e1000_82572:
  88. if (phy->id != IGP01E1000_I_PHY_ID)
  89. return -E1000_ERR_PHY;
  90. break;
  91. case e1000_82573:
  92. if (phy->id != M88E1111_I_PHY_ID)
  93. return -E1000_ERR_PHY;
  94. break;
  95. default:
  96. return -E1000_ERR_PHY;
  97. break;
  98. }
  99. return 0;
  100. }
  101. /**
  102. * e1000_init_nvm_params_82571 - Init NVM func ptrs.
  103. * @hw: pointer to the HW structure
  104. *
  105. * This is a function pointer entry point called by the api module.
  106. **/
  107. static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
  108. {
  109. struct e1000_nvm_info *nvm = &hw->nvm;
  110. u32 eecd = er32(EECD);
  111. u16 size;
  112. nvm->opcode_bits = 8;
  113. nvm->delay_usec = 1;
  114. switch (nvm->override) {
  115. case e1000_nvm_override_spi_large:
  116. nvm->page_size = 32;
  117. nvm->address_bits = 16;
  118. break;
  119. case e1000_nvm_override_spi_small:
  120. nvm->page_size = 8;
  121. nvm->address_bits = 8;
  122. break;
  123. default:
  124. nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
  125. nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
  126. break;
  127. }
  128. switch (hw->mac.type) {
  129. case e1000_82573:
  130. if (((eecd >> 15) & 0x3) == 0x3) {
  131. nvm->type = e1000_nvm_flash_hw;
  132. nvm->word_size = 2048;
  133. /*
  134. * Autonomous Flash update bit must be cleared due
  135. * to Flash update issue.
  136. */
  137. eecd &= ~E1000_EECD_AUPDEN;
  138. ew32(EECD, eecd);
  139. break;
  140. }
  141. /* Fall Through */
  142. default:
  143. nvm->type = e1000_nvm_eeprom_spi;
  144. size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
  145. E1000_EECD_SIZE_EX_SHIFT);
  146. /*
  147. * Added to a constant, "size" becomes the left-shift value
  148. * for setting word_size.
  149. */
  150. size += NVM_WORD_SIZE_BASE_SHIFT;
  151. nvm->word_size = 1 << size;
  152. break;
  153. }
  154. return 0;
  155. }
  156. /**
  157. * e1000_init_mac_params_82571 - Init MAC func ptrs.
  158. * @hw: pointer to the HW structure
  159. *
  160. * This is a function pointer entry point called by the api module.
  161. **/
  162. static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
  163. {
  164. struct e1000_hw *hw = &adapter->hw;
  165. struct e1000_mac_info *mac = &hw->mac;
  166. struct e1000_mac_operations *func = &mac->ops;
  167. /* Set media type */
  168. switch (adapter->pdev->device) {
  169. case E1000_DEV_ID_82571EB_FIBER:
  170. case E1000_DEV_ID_82572EI_FIBER:
  171. case E1000_DEV_ID_82571EB_QUAD_FIBER:
  172. hw->phy.media_type = e1000_media_type_fiber;
  173. break;
  174. case E1000_DEV_ID_82571EB_SERDES:
  175. case E1000_DEV_ID_82572EI_SERDES:
  176. case E1000_DEV_ID_82571EB_SERDES_DUAL:
  177. case E1000_DEV_ID_82571EB_SERDES_QUAD:
  178. hw->phy.media_type = e1000_media_type_internal_serdes;
  179. break;
  180. default:
  181. hw->phy.media_type = e1000_media_type_copper;
  182. break;
  183. }
  184. /* Set mta register count */
  185. mac->mta_reg_count = 128;
  186. /* Set rar entry count */
  187. mac->rar_entry_count = E1000_RAR_ENTRIES;
  188. /* Set if manageability features are enabled. */
  189. mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) ? 1 : 0;
  190. /* check for link */
  191. switch (hw->phy.media_type) {
  192. case e1000_media_type_copper:
  193. func->setup_physical_interface = e1000_setup_copper_link_82571;
  194. func->check_for_link = e1000e_check_for_copper_link;
  195. func->get_link_up_info = e1000e_get_speed_and_duplex_copper;
  196. break;
  197. case e1000_media_type_fiber:
  198. func->setup_physical_interface =
  199. e1000_setup_fiber_serdes_link_82571;
  200. func->check_for_link = e1000e_check_for_fiber_link;
  201. func->get_link_up_info =
  202. e1000e_get_speed_and_duplex_fiber_serdes;
  203. break;
  204. case e1000_media_type_internal_serdes:
  205. func->setup_physical_interface =
  206. e1000_setup_fiber_serdes_link_82571;
  207. func->check_for_link = e1000e_check_for_serdes_link;
  208. func->get_link_up_info =
  209. e1000e_get_speed_and_duplex_fiber_serdes;
  210. break;
  211. default:
  212. return -E1000_ERR_CONFIG;
  213. break;
  214. }
  215. return 0;
  216. }
  217. static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter)
  218. {
  219. struct e1000_hw *hw = &adapter->hw;
  220. static int global_quad_port_a; /* global port a indication */
  221. struct pci_dev *pdev = adapter->pdev;
  222. u16 eeprom_data = 0;
  223. int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
  224. s32 rc;
  225. rc = e1000_init_mac_params_82571(adapter);
  226. if (rc)
  227. return rc;
  228. rc = e1000_init_nvm_params_82571(hw);
  229. if (rc)
  230. return rc;
  231. rc = e1000_init_phy_params_82571(hw);
  232. if (rc)
  233. return rc;
  234. /* tag quad port adapters first, it's used below */
  235. switch (pdev->device) {
  236. case E1000_DEV_ID_82571EB_QUAD_COPPER:
  237. case E1000_DEV_ID_82571EB_QUAD_FIBER:
  238. case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
  239. case E1000_DEV_ID_82571PT_QUAD_COPPER:
  240. adapter->flags |= FLAG_IS_QUAD_PORT;
  241. /* mark the first port */
  242. if (global_quad_port_a == 0)
  243. adapter->flags |= FLAG_IS_QUAD_PORT_A;
  244. /* Reset for multiple quad port adapters */
  245. global_quad_port_a++;
  246. if (global_quad_port_a == 4)
  247. global_quad_port_a = 0;
  248. break;
  249. default:
  250. break;
  251. }
  252. switch (adapter->hw.mac.type) {
  253. case e1000_82571:
  254. /* these dual ports don't have WoL on port B at all */
  255. if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
  256. (pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
  257. (pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
  258. (is_port_b))
  259. adapter->flags &= ~FLAG_HAS_WOL;
  260. /* quad ports only support WoL on port A */
  261. if (adapter->flags & FLAG_IS_QUAD_PORT &&
  262. (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
  263. adapter->flags &= ~FLAG_HAS_WOL;
  264. /* Does not support WoL on any port */
  265. if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
  266. adapter->flags &= ~FLAG_HAS_WOL;
  267. break;
  268. case e1000_82573:
  269. if (pdev->device == E1000_DEV_ID_82573L) {
  270. e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1,
  271. &eeprom_data);
  272. if (eeprom_data & NVM_WORD1A_ASPM_MASK)
  273. adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
  274. }
  275. break;
  276. default:
  277. break;
  278. }
  279. return 0;
  280. }
  281. /**
  282. * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
  283. * @hw: pointer to the HW structure
  284. *
  285. * Reads the PHY registers and stores the PHY ID and possibly the PHY
  286. * revision in the hardware structure.
  287. **/
  288. static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
  289. {
  290. struct e1000_phy_info *phy = &hw->phy;
  291. switch (hw->mac.type) {
  292. case e1000_82571:
  293. case e1000_82572:
  294. /*
  295. * The 82571 firmware may still be configuring the PHY.
  296. * In this case, we cannot access the PHY until the
  297. * configuration is done. So we explicitly set the
  298. * PHY ID.
  299. */
  300. phy->id = IGP01E1000_I_PHY_ID;
  301. break;
  302. case e1000_82573:
  303. return e1000e_get_phy_id(hw);
  304. break;
  305. default:
  306. return -E1000_ERR_PHY;
  307. break;
  308. }
  309. return 0;
  310. }
  311. /**
  312. * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
  313. * @hw: pointer to the HW structure
  314. *
  315. * Acquire the HW semaphore to access the PHY or NVM
  316. **/
  317. static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
  318. {
  319. u32 swsm;
  320. s32 timeout = hw->nvm.word_size + 1;
  321. s32 i = 0;
  322. /* Get the FW semaphore. */
  323. for (i = 0; i < timeout; i++) {
  324. swsm = er32(SWSM);
  325. ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
  326. /* Semaphore acquired if bit latched */
  327. if (er32(SWSM) & E1000_SWSM_SWESMBI)
  328. break;
  329. udelay(50);
  330. }
  331. if (i == timeout) {
  332. /* Release semaphores */
  333. e1000e_put_hw_semaphore(hw);
  334. hw_dbg(hw, "Driver can't access the NVM\n");
  335. return -E1000_ERR_NVM;
  336. }
  337. return 0;
  338. }
  339. /**
  340. * e1000_put_hw_semaphore_82571 - Release hardware semaphore
  341. * @hw: pointer to the HW structure
  342. *
  343. * Release hardware semaphore used to access the PHY or NVM
  344. **/
  345. static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
  346. {
  347. u32 swsm;
  348. swsm = er32(SWSM);
  349. swsm &= ~E1000_SWSM_SWESMBI;
  350. ew32(SWSM, swsm);
  351. }
  352. /**
  353. * e1000_acquire_nvm_82571 - Request for access to the EEPROM
  354. * @hw: pointer to the HW structure
  355. *
  356. * To gain access to the EEPROM, first we must obtain a hardware semaphore.
  357. * Then for non-82573 hardware, set the EEPROM access request bit and wait
  358. * for EEPROM access grant bit. If the access grant bit is not set, release
  359. * hardware semaphore.
  360. **/
  361. static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
  362. {
  363. s32 ret_val;
  364. ret_val = e1000_get_hw_semaphore_82571(hw);
  365. if (ret_val)
  366. return ret_val;
  367. if (hw->mac.type != e1000_82573)
  368. ret_val = e1000e_acquire_nvm(hw);
  369. if (ret_val)
  370. e1000_put_hw_semaphore_82571(hw);
  371. return ret_val;
  372. }
  373. /**
  374. * e1000_release_nvm_82571 - Release exclusive access to EEPROM
  375. * @hw: pointer to the HW structure
  376. *
  377. * Stop any current commands to the EEPROM and clear the EEPROM request bit.
  378. **/
  379. static void e1000_release_nvm_82571(struct e1000_hw *hw)
  380. {
  381. e1000e_release_nvm(hw);
  382. e1000_put_hw_semaphore_82571(hw);
  383. }
  384. /**
  385. * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
  386. * @hw: pointer to the HW structure
  387. * @offset: offset within the EEPROM to be written to
  388. * @words: number of words to write
  389. * @data: 16 bit word(s) to be written to the EEPROM
  390. *
  391. * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
  392. *
  393. * If e1000e_update_nvm_checksum is not called after this function, the
  394. * EEPROM will most likely contain an invalid checksum.
  395. **/
  396. static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
  397. u16 *data)
  398. {
  399. s32 ret_val;
  400. switch (hw->mac.type) {
  401. case e1000_82573:
  402. ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
  403. break;
  404. case e1000_82571:
  405. case e1000_82572:
  406. ret_val = e1000e_write_nvm_spi(hw, offset, words, data);
  407. break;
  408. default:
  409. ret_val = -E1000_ERR_NVM;
  410. break;
  411. }
  412. return ret_val;
  413. }
  414. /**
  415. * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
  416. * @hw: pointer to the HW structure
  417. *
  418. * Updates the EEPROM checksum by reading/adding each word of the EEPROM
  419. * up to the checksum. Then calculates the EEPROM checksum and writes the
  420. * value to the EEPROM.
  421. **/
  422. static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
  423. {
  424. u32 eecd;
  425. s32 ret_val;
  426. u16 i;
  427. ret_val = e1000e_update_nvm_checksum_generic(hw);
  428. if (ret_val)
  429. return ret_val;
  430. /*
  431. * If our nvm is an EEPROM, then we're done
  432. * otherwise, commit the checksum to the flash NVM.
  433. */
  434. if (hw->nvm.type != e1000_nvm_flash_hw)
  435. return ret_val;
  436. /* Check for pending operations. */
  437. for (i = 0; i < E1000_FLASH_UPDATES; i++) {
  438. msleep(1);
  439. if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
  440. break;
  441. }
  442. if (i == E1000_FLASH_UPDATES)
  443. return -E1000_ERR_NVM;
  444. /* Reset the firmware if using STM opcode. */
  445. if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) {
  446. /*
  447. * The enabling of and the actual reset must be done
  448. * in two write cycles.
  449. */
  450. ew32(HICR, E1000_HICR_FW_RESET_ENABLE);
  451. e1e_flush();
  452. ew32(HICR, E1000_HICR_FW_RESET);
  453. }
  454. /* Commit the write to flash */
  455. eecd = er32(EECD) | E1000_EECD_FLUPD;
  456. ew32(EECD, eecd);
  457. for (i = 0; i < E1000_FLASH_UPDATES; i++) {
  458. msleep(1);
  459. if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
  460. break;
  461. }
  462. if (i == E1000_FLASH_UPDATES)
  463. return -E1000_ERR_NVM;
  464. return 0;
  465. }
  466. /**
  467. * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
  468. * @hw: pointer to the HW structure
  469. *
  470. * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
  471. * and then verifies that the sum of the EEPROM is equal to 0xBABA.
  472. **/
  473. static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
  474. {
  475. if (hw->nvm.type == e1000_nvm_flash_hw)
  476. e1000_fix_nvm_checksum_82571(hw);
  477. return e1000e_validate_nvm_checksum_generic(hw);
  478. }
  479. /**
  480. * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
  481. * @hw: pointer to the HW structure
  482. * @offset: offset within the EEPROM to be written to
  483. * @words: number of words to write
  484. * @data: 16 bit word(s) to be written to the EEPROM
  485. *
  486. * After checking for invalid values, poll the EEPROM to ensure the previous
  487. * command has completed before trying to write the next word. After write
  488. * poll for completion.
  489. *
  490. * If e1000e_update_nvm_checksum is not called after this function, the
  491. * EEPROM will most likely contain an invalid checksum.
  492. **/
  493. static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
  494. u16 words, u16 *data)
  495. {
  496. struct e1000_nvm_info *nvm = &hw->nvm;
  497. u32 i;
  498. u32 eewr = 0;
  499. s32 ret_val = 0;
  500. /*
  501. * A check for invalid values: offset too large, too many words,
  502. * and not enough words.
  503. */
  504. if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
  505. (words == 0)) {
  506. hw_dbg(hw, "nvm parameter(s) out of bounds\n");
  507. return -E1000_ERR_NVM;
  508. }
  509. for (i = 0; i < words; i++) {
  510. eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
  511. ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
  512. E1000_NVM_RW_REG_START;
  513. ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
  514. if (ret_val)
  515. break;
  516. ew32(EEWR, eewr);
  517. ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
  518. if (ret_val)
  519. break;
  520. }
  521. return ret_val;
  522. }
  523. /**
  524. * e1000_get_cfg_done_82571 - Poll for configuration done
  525. * @hw: pointer to the HW structure
  526. *
  527. * Reads the management control register for the config done bit to be set.
  528. **/
  529. static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
  530. {
  531. s32 timeout = PHY_CFG_TIMEOUT;
  532. while (timeout) {
  533. if (er32(EEMNGCTL) &
  534. E1000_NVM_CFG_DONE_PORT_0)
  535. break;
  536. msleep(1);
  537. timeout--;
  538. }
  539. if (!timeout) {
  540. hw_dbg(hw, "MNG configuration cycle has not completed.\n");
  541. return -E1000_ERR_RESET;
  542. }
  543. return 0;
  544. }
  545. /**
  546. * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
  547. * @hw: pointer to the HW structure
  548. * @active: TRUE to enable LPLU, FALSE to disable
  549. *
  550. * Sets the LPLU D0 state according to the active flag. When activating LPLU
  551. * this function also disables smart speed and vice versa. LPLU will not be
  552. * activated unless the device autonegotiation advertisement meets standards
  553. * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
  554. * pointer entry point only called by PHY setup routines.
  555. **/
  556. static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
  557. {
  558. struct e1000_phy_info *phy = &hw->phy;
  559. s32 ret_val;
  560. u16 data;
  561. ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
  562. if (ret_val)
  563. return ret_val;
  564. if (active) {
  565. data |= IGP02E1000_PM_D0_LPLU;
  566. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  567. if (ret_val)
  568. return ret_val;
  569. /* When LPLU is enabled, we should disable SmartSpeed */
  570. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  571. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  572. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  573. if (ret_val)
  574. return ret_val;
  575. } else {
  576. data &= ~IGP02E1000_PM_D0_LPLU;
  577. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  578. /*
  579. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  580. * during Dx states where the power conservation is most
  581. * important. During driver activity we should enable
  582. * SmartSpeed, so performance is maintained.
  583. */
  584. if (phy->smart_speed == e1000_smart_speed_on) {
  585. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  586. &data);
  587. if (ret_val)
  588. return ret_val;
  589. data |= IGP01E1000_PSCFR_SMART_SPEED;
  590. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  591. data);
  592. if (ret_val)
  593. return ret_val;
  594. } else if (phy->smart_speed == e1000_smart_speed_off) {
  595. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  596. &data);
  597. if (ret_val)
  598. return ret_val;
  599. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  600. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  601. data);
  602. if (ret_val)
  603. return ret_val;
  604. }
  605. }
  606. return 0;
  607. }
  608. /**
  609. * e1000_reset_hw_82571 - Reset hardware
  610. * @hw: pointer to the HW structure
  611. *
  612. * This resets the hardware into a known state. This is a
  613. * function pointer entry point called by the api module.
  614. **/
  615. static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
  616. {
  617. u32 ctrl;
  618. u32 extcnf_ctrl;
  619. u32 ctrl_ext;
  620. u32 icr;
  621. s32 ret_val;
  622. u16 i = 0;
  623. /*
  624. * Prevent the PCI-E bus from sticking if there is no TLP connection
  625. * on the last TLP read/write transaction when MAC is reset.
  626. */
  627. ret_val = e1000e_disable_pcie_master(hw);
  628. if (ret_val)
  629. hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
  630. hw_dbg(hw, "Masking off all interrupts\n");
  631. ew32(IMC, 0xffffffff);
  632. ew32(RCTL, 0);
  633. ew32(TCTL, E1000_TCTL_PSP);
  634. e1e_flush();
  635. msleep(10);
  636. /*
  637. * Must acquire the MDIO ownership before MAC reset.
  638. * Ownership defaults to firmware after a reset.
  639. */
  640. if (hw->mac.type == e1000_82573) {
  641. extcnf_ctrl = er32(EXTCNF_CTRL);
  642. extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
  643. do {
  644. ew32(EXTCNF_CTRL, extcnf_ctrl);
  645. extcnf_ctrl = er32(EXTCNF_CTRL);
  646. if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
  647. break;
  648. extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
  649. msleep(2);
  650. i++;
  651. } while (i < MDIO_OWNERSHIP_TIMEOUT);
  652. }
  653. ctrl = er32(CTRL);
  654. hw_dbg(hw, "Issuing a global reset to MAC\n");
  655. ew32(CTRL, ctrl | E1000_CTRL_RST);
  656. if (hw->nvm.type == e1000_nvm_flash_hw) {
  657. udelay(10);
  658. ctrl_ext = er32(CTRL_EXT);
  659. ctrl_ext |= E1000_CTRL_EXT_EE_RST;
  660. ew32(CTRL_EXT, ctrl_ext);
  661. e1e_flush();
  662. }
  663. ret_val = e1000e_get_auto_rd_done(hw);
  664. if (ret_val)
  665. /* We don't want to continue accessing MAC registers. */
  666. return ret_val;
  667. /*
  668. * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
  669. * Need to wait for Phy configuration completion before accessing
  670. * NVM and Phy.
  671. */
  672. if (hw->mac.type == e1000_82573)
  673. msleep(25);
  674. /* Clear any pending interrupt events. */
  675. ew32(IMC, 0xffffffff);
  676. icr = er32(ICR);
  677. if (hw->mac.type == e1000_82571 &&
  678. hw->dev_spec.e82571.alt_mac_addr_is_present)
  679. e1000e_set_laa_state_82571(hw, true);
  680. return 0;
  681. }
  682. /**
  683. * e1000_init_hw_82571 - Initialize hardware
  684. * @hw: pointer to the HW structure
  685. *
  686. * This inits the hardware readying it for operation.
  687. **/
  688. static s32 e1000_init_hw_82571(struct e1000_hw *hw)
  689. {
  690. struct e1000_mac_info *mac = &hw->mac;
  691. u32 reg_data;
  692. s32 ret_val;
  693. u16 i;
  694. u16 rar_count = mac->rar_entry_count;
  695. e1000_initialize_hw_bits_82571(hw);
  696. /* Initialize identification LED */
  697. ret_val = e1000e_id_led_init(hw);
  698. if (ret_val) {
  699. hw_dbg(hw, "Error initializing identification LED\n");
  700. return ret_val;
  701. }
  702. /* Disabling VLAN filtering */
  703. hw_dbg(hw, "Initializing the IEEE VLAN\n");
  704. e1000e_clear_vfta(hw);
  705. /* Setup the receive address. */
  706. /*
  707. * If, however, a locally administered address was assigned to the
  708. * 82571, we must reserve a RAR for it to work around an issue where
  709. * resetting one port will reload the MAC on the other port.
  710. */
  711. if (e1000e_get_laa_state_82571(hw))
  712. rar_count--;
  713. e1000e_init_rx_addrs(hw, rar_count);
  714. /* Zero out the Multicast HASH table */
  715. hw_dbg(hw, "Zeroing the MTA\n");
  716. for (i = 0; i < mac->mta_reg_count; i++)
  717. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  718. /* Setup link and flow control */
  719. ret_val = e1000_setup_link_82571(hw);
  720. /* Set the transmit descriptor write-back policy */
  721. reg_data = er32(TXDCTL);
  722. reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
  723. E1000_TXDCTL_FULL_TX_DESC_WB |
  724. E1000_TXDCTL_COUNT_DESC;
  725. ew32(TXDCTL, reg_data);
  726. /* ...for both queues. */
  727. if (mac->type != e1000_82573) {
  728. reg_data = er32(TXDCTL1);
  729. reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
  730. E1000_TXDCTL_FULL_TX_DESC_WB |
  731. E1000_TXDCTL_COUNT_DESC;
  732. ew32(TXDCTL1, reg_data);
  733. } else {
  734. e1000e_enable_tx_pkt_filtering(hw);
  735. reg_data = er32(GCR);
  736. reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
  737. ew32(GCR, reg_data);
  738. }
  739. /*
  740. * Clear all of the statistics registers (clear on read). It is
  741. * important that we do this after we have tried to establish link
  742. * because the symbol error count will increment wildly if there
  743. * is no link.
  744. */
  745. e1000_clear_hw_cntrs_82571(hw);
  746. return ret_val;
  747. }
  748. /**
  749. * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
  750. * @hw: pointer to the HW structure
  751. *
  752. * Initializes required hardware-dependent bits needed for normal operation.
  753. **/
  754. static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
  755. {
  756. u32 reg;
  757. /* Transmit Descriptor Control 0 */
  758. reg = er32(TXDCTL);
  759. reg |= (1 << 22);
  760. ew32(TXDCTL, reg);
  761. /* Transmit Descriptor Control 1 */
  762. reg = er32(TXDCTL1);
  763. reg |= (1 << 22);
  764. ew32(TXDCTL1, reg);
  765. /* Transmit Arbitration Control 0 */
  766. reg = er32(TARC0);
  767. reg &= ~(0xF << 27); /* 30:27 */
  768. switch (hw->mac.type) {
  769. case e1000_82571:
  770. case e1000_82572:
  771. reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
  772. break;
  773. default:
  774. break;
  775. }
  776. ew32(TARC0, reg);
  777. /* Transmit Arbitration Control 1 */
  778. reg = er32(TARC1);
  779. switch (hw->mac.type) {
  780. case e1000_82571:
  781. case e1000_82572:
  782. reg &= ~((1 << 29) | (1 << 30));
  783. reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
  784. if (er32(TCTL) & E1000_TCTL_MULR)
  785. reg &= ~(1 << 28);
  786. else
  787. reg |= (1 << 28);
  788. ew32(TARC1, reg);
  789. break;
  790. default:
  791. break;
  792. }
  793. /* Device Control */
  794. if (hw->mac.type == e1000_82573) {
  795. reg = er32(CTRL);
  796. reg &= ~(1 << 29);
  797. ew32(CTRL, reg);
  798. }
  799. /* Extended Device Control */
  800. if (hw->mac.type == e1000_82573) {
  801. reg = er32(CTRL_EXT);
  802. reg &= ~(1 << 23);
  803. reg |= (1 << 22);
  804. ew32(CTRL_EXT, reg);
  805. }
  806. }
  807. /**
  808. * e1000e_clear_vfta - Clear VLAN filter table
  809. * @hw: pointer to the HW structure
  810. *
  811. * Clears the register array which contains the VLAN filter table by
  812. * setting all the values to 0.
  813. **/
  814. void e1000e_clear_vfta(struct e1000_hw *hw)
  815. {
  816. u32 offset;
  817. u32 vfta_value = 0;
  818. u32 vfta_offset = 0;
  819. u32 vfta_bit_in_reg = 0;
  820. if (hw->mac.type == e1000_82573) {
  821. if (hw->mng_cookie.vlan_id != 0) {
  822. /*
  823. * The VFTA is a 4096b bit-field, each identifying
  824. * a single VLAN ID. The following operations
  825. * determine which 32b entry (i.e. offset) into the
  826. * array we want to set the VLAN ID (i.e. bit) of
  827. * the manageability unit.
  828. */
  829. vfta_offset = (hw->mng_cookie.vlan_id >>
  830. E1000_VFTA_ENTRY_SHIFT) &
  831. E1000_VFTA_ENTRY_MASK;
  832. vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
  833. E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
  834. }
  835. }
  836. for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
  837. /*
  838. * If the offset we want to clear is the same offset of the
  839. * manageability VLAN ID, then clear all bits except that of
  840. * the manageability unit.
  841. */
  842. vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
  843. E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
  844. e1e_flush();
  845. }
  846. }
  847. /**
  848. * e1000_update_mc_addr_list_82571 - Update Multicast addresses
  849. * @hw: pointer to the HW structure
  850. * @mc_addr_list: array of multicast addresses to program
  851. * @mc_addr_count: number of multicast addresses to program
  852. * @rar_used_count: the first RAR register free to program
  853. * @rar_count: total number of supported Receive Address Registers
  854. *
  855. * Updates the Receive Address Registers and Multicast Table Array.
  856. * The caller must have a packed mc_addr_list of multicast addresses.
  857. * The parameter rar_count will usually be hw->mac.rar_entry_count
  858. * unless there are workarounds that change this.
  859. **/
  860. static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw,
  861. u8 *mc_addr_list,
  862. u32 mc_addr_count,
  863. u32 rar_used_count,
  864. u32 rar_count)
  865. {
  866. if (e1000e_get_laa_state_82571(hw))
  867. rar_count--;
  868. e1000e_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count,
  869. rar_used_count, rar_count);
  870. }
  871. /**
  872. * e1000_setup_link_82571 - Setup flow control and link settings
  873. * @hw: pointer to the HW structure
  874. *
  875. * Determines which flow control settings to use, then configures flow
  876. * control. Calls the appropriate media-specific link configuration
  877. * function. Assuming the adapter has a valid link partner, a valid link
  878. * should be established. Assumes the hardware has previously been reset
  879. * and the transmitter and receiver are not enabled.
  880. **/
  881. static s32 e1000_setup_link_82571(struct e1000_hw *hw)
  882. {
  883. /*
  884. * 82573 does not have a word in the NVM to determine
  885. * the default flow control setting, so we explicitly
  886. * set it to full.
  887. */
  888. if (hw->mac.type == e1000_82573)
  889. hw->fc.type = e1000_fc_full;
  890. return e1000e_setup_link(hw);
  891. }
  892. /**
  893. * e1000_setup_copper_link_82571 - Configure copper link settings
  894. * @hw: pointer to the HW structure
  895. *
  896. * Configures the link for auto-neg or forced speed and duplex. Then we check
  897. * for link, once link is established calls to configure collision distance
  898. * and flow control are called.
  899. **/
  900. static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
  901. {
  902. u32 ctrl;
  903. u32 led_ctrl;
  904. s32 ret_val;
  905. ctrl = er32(CTRL);
  906. ctrl |= E1000_CTRL_SLU;
  907. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  908. ew32(CTRL, ctrl);
  909. switch (hw->phy.type) {
  910. case e1000_phy_m88:
  911. ret_val = e1000e_copper_link_setup_m88(hw);
  912. break;
  913. case e1000_phy_igp_2:
  914. ret_val = e1000e_copper_link_setup_igp(hw);
  915. /* Setup activity LED */
  916. led_ctrl = er32(LEDCTL);
  917. led_ctrl &= IGP_ACTIVITY_LED_MASK;
  918. led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
  919. ew32(LEDCTL, led_ctrl);
  920. break;
  921. default:
  922. return -E1000_ERR_PHY;
  923. break;
  924. }
  925. if (ret_val)
  926. return ret_val;
  927. ret_val = e1000e_setup_copper_link(hw);
  928. return ret_val;
  929. }
  930. /**
  931. * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
  932. * @hw: pointer to the HW structure
  933. *
  934. * Configures collision distance and flow control for fiber and serdes links.
  935. * Upon successful setup, poll for link.
  936. **/
  937. static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
  938. {
  939. switch (hw->mac.type) {
  940. case e1000_82571:
  941. case e1000_82572:
  942. /*
  943. * If SerDes loopback mode is entered, there is no form
  944. * of reset to take the adapter out of that mode. So we
  945. * have to explicitly take the adapter out of loopback
  946. * mode. This prevents drivers from twiddling their thumbs
  947. * if another tool failed to take it out of loopback mode.
  948. */
  949. ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
  950. break;
  951. default:
  952. break;
  953. }
  954. return e1000e_setup_fiber_serdes_link(hw);
  955. }
  956. /**
  957. * e1000_valid_led_default_82571 - Verify a valid default LED config
  958. * @hw: pointer to the HW structure
  959. * @data: pointer to the NVM (EEPROM)
  960. *
  961. * Read the EEPROM for the current default LED configuration. If the
  962. * LED configuration is not valid, set to a valid LED configuration.
  963. **/
  964. static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
  965. {
  966. s32 ret_val;
  967. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  968. if (ret_val) {
  969. hw_dbg(hw, "NVM Read Error\n");
  970. return ret_val;
  971. }
  972. if (hw->mac.type == e1000_82573 &&
  973. *data == ID_LED_RESERVED_F746)
  974. *data = ID_LED_DEFAULT_82573;
  975. else if (*data == ID_LED_RESERVED_0000 ||
  976. *data == ID_LED_RESERVED_FFFF)
  977. *data = ID_LED_DEFAULT;
  978. return 0;
  979. }
  980. /**
  981. * e1000e_get_laa_state_82571 - Get locally administered address state
  982. * @hw: pointer to the HW structure
  983. *
  984. * Retrieve and return the current locally administered address state.
  985. **/
  986. bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
  987. {
  988. if (hw->mac.type != e1000_82571)
  989. return 0;
  990. return hw->dev_spec.e82571.laa_is_present;
  991. }
  992. /**
  993. * e1000e_set_laa_state_82571 - Set locally administered address state
  994. * @hw: pointer to the HW structure
  995. * @state: enable/disable locally administered address
  996. *
  997. * Enable/Disable the current locally administers address state.
  998. **/
  999. void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
  1000. {
  1001. if (hw->mac.type != e1000_82571)
  1002. return;
  1003. hw->dev_spec.e82571.laa_is_present = state;
  1004. /* If workaround is activated... */
  1005. if (state)
  1006. /*
  1007. * Hold a copy of the LAA in RAR[14] This is done so that
  1008. * between the time RAR[0] gets clobbered and the time it
  1009. * gets fixed, the actual LAA is in one of the RARs and no
  1010. * incoming packets directed to this port are dropped.
  1011. * Eventually the LAA will be in RAR[0] and RAR[14].
  1012. */
  1013. e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1);
  1014. }
  1015. /**
  1016. * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
  1017. * @hw: pointer to the HW structure
  1018. *
  1019. * Verifies that the EEPROM has completed the update. After updating the
  1020. * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
  1021. * the checksum fix is not implemented, we need to set the bit and update
  1022. * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
  1023. * we need to return bad checksum.
  1024. **/
  1025. static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
  1026. {
  1027. struct e1000_nvm_info *nvm = &hw->nvm;
  1028. s32 ret_val;
  1029. u16 data;
  1030. if (nvm->type != e1000_nvm_flash_hw)
  1031. return 0;
  1032. /*
  1033. * Check bit 4 of word 10h. If it is 0, firmware is done updating
  1034. * 10h-12h. Checksum may need to be fixed.
  1035. */
  1036. ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
  1037. if (ret_val)
  1038. return ret_val;
  1039. if (!(data & 0x10)) {
  1040. /*
  1041. * Read 0x23 and check bit 15. This bit is a 1
  1042. * when the checksum has already been fixed. If
  1043. * the checksum is still wrong and this bit is a
  1044. * 1, we need to return bad checksum. Otherwise,
  1045. * we need to set this bit to a 1 and update the
  1046. * checksum.
  1047. */
  1048. ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
  1049. if (ret_val)
  1050. return ret_val;
  1051. if (!(data & 0x8000)) {
  1052. data |= 0x8000;
  1053. ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
  1054. if (ret_val)
  1055. return ret_val;
  1056. ret_val = e1000e_update_nvm_checksum(hw);
  1057. }
  1058. }
  1059. return 0;
  1060. }
  1061. /**
  1062. * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
  1063. * @hw: pointer to the HW structure
  1064. *
  1065. * Clears the hardware counters by reading the counter registers.
  1066. **/
  1067. static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
  1068. {
  1069. u32 temp;
  1070. e1000e_clear_hw_cntrs_base(hw);
  1071. temp = er32(PRC64);
  1072. temp = er32(PRC127);
  1073. temp = er32(PRC255);
  1074. temp = er32(PRC511);
  1075. temp = er32(PRC1023);
  1076. temp = er32(PRC1522);
  1077. temp = er32(PTC64);
  1078. temp = er32(PTC127);
  1079. temp = er32(PTC255);
  1080. temp = er32(PTC511);
  1081. temp = er32(PTC1023);
  1082. temp = er32(PTC1522);
  1083. temp = er32(ALGNERRC);
  1084. temp = er32(RXERRC);
  1085. temp = er32(TNCRS);
  1086. temp = er32(CEXTERR);
  1087. temp = er32(TSCTC);
  1088. temp = er32(TSCTFC);
  1089. temp = er32(MGTPRC);
  1090. temp = er32(MGTPDC);
  1091. temp = er32(MGTPTC);
  1092. temp = er32(IAC);
  1093. temp = er32(ICRXOC);
  1094. temp = er32(ICRXPTC);
  1095. temp = er32(ICRXATC);
  1096. temp = er32(ICTXPTC);
  1097. temp = er32(ICTXATC);
  1098. temp = er32(ICTXQEC);
  1099. temp = er32(ICTXQMTC);
  1100. temp = er32(ICRXDMTC);
  1101. }
  1102. static struct e1000_mac_operations e82571_mac_ops = {
  1103. .mng_mode_enab = E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT,
  1104. /* .check_for_link: media type dependent */
  1105. .cleanup_led = e1000e_cleanup_led_generic,
  1106. .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
  1107. .get_bus_info = e1000e_get_bus_info_pcie,
  1108. /* .get_link_up_info: media type dependent */
  1109. .led_on = e1000e_led_on_generic,
  1110. .led_off = e1000e_led_off_generic,
  1111. .update_mc_addr_list = e1000_update_mc_addr_list_82571,
  1112. .reset_hw = e1000_reset_hw_82571,
  1113. .init_hw = e1000_init_hw_82571,
  1114. .setup_link = e1000_setup_link_82571,
  1115. /* .setup_physical_interface: media type dependent */
  1116. };
  1117. static struct e1000_phy_operations e82_phy_ops_igp = {
  1118. .acquire_phy = e1000_get_hw_semaphore_82571,
  1119. .check_reset_block = e1000e_check_reset_block_generic,
  1120. .commit_phy = NULL,
  1121. .force_speed_duplex = e1000e_phy_force_speed_duplex_igp,
  1122. .get_cfg_done = e1000_get_cfg_done_82571,
  1123. .get_cable_length = e1000e_get_cable_length_igp_2,
  1124. .get_phy_info = e1000e_get_phy_info_igp,
  1125. .read_phy_reg = e1000e_read_phy_reg_igp,
  1126. .release_phy = e1000_put_hw_semaphore_82571,
  1127. .reset_phy = e1000e_phy_hw_reset_generic,
  1128. .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
  1129. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1130. .write_phy_reg = e1000e_write_phy_reg_igp,
  1131. };
  1132. static struct e1000_phy_operations e82_phy_ops_m88 = {
  1133. .acquire_phy = e1000_get_hw_semaphore_82571,
  1134. .check_reset_block = e1000e_check_reset_block_generic,
  1135. .commit_phy = e1000e_phy_sw_reset,
  1136. .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
  1137. .get_cfg_done = e1000e_get_cfg_done,
  1138. .get_cable_length = e1000e_get_cable_length_m88,
  1139. .get_phy_info = e1000e_get_phy_info_m88,
  1140. .read_phy_reg = e1000e_read_phy_reg_m88,
  1141. .release_phy = e1000_put_hw_semaphore_82571,
  1142. .reset_phy = e1000e_phy_hw_reset_generic,
  1143. .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
  1144. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1145. .write_phy_reg = e1000e_write_phy_reg_m88,
  1146. };
  1147. static struct e1000_nvm_operations e82571_nvm_ops = {
  1148. .acquire_nvm = e1000_acquire_nvm_82571,
  1149. .read_nvm = e1000e_read_nvm_eerd,
  1150. .release_nvm = e1000_release_nvm_82571,
  1151. .update_nvm = e1000_update_nvm_checksum_82571,
  1152. .valid_led_default = e1000_valid_led_default_82571,
  1153. .validate_nvm = e1000_validate_nvm_checksum_82571,
  1154. .write_nvm = e1000_write_nvm_82571,
  1155. };
  1156. struct e1000_info e1000_82571_info = {
  1157. .mac = e1000_82571,
  1158. .flags = FLAG_HAS_HW_VLAN_FILTER
  1159. | FLAG_HAS_JUMBO_FRAMES
  1160. | FLAG_HAS_STATS_PTC_PRC
  1161. | FLAG_HAS_WOL
  1162. | FLAG_APME_IN_CTRL3
  1163. | FLAG_RX_CSUM_ENABLED
  1164. | FLAG_HAS_CTRLEXT_ON_LOAD
  1165. | FLAG_HAS_STATS_ICR_ICT
  1166. | FLAG_HAS_SMART_POWER_DOWN
  1167. | FLAG_RESET_OVERWRITES_LAA /* errata */
  1168. | FLAG_TARC_SPEED_MODE_BIT /* errata */
  1169. | FLAG_APME_CHECK_PORT_B,
  1170. .pba = 38,
  1171. .get_invariants = e1000_get_invariants_82571,
  1172. .mac_ops = &e82571_mac_ops,
  1173. .phy_ops = &e82_phy_ops_igp,
  1174. .nvm_ops = &e82571_nvm_ops,
  1175. };
  1176. struct e1000_info e1000_82572_info = {
  1177. .mac = e1000_82572,
  1178. .flags = FLAG_HAS_HW_VLAN_FILTER
  1179. | FLAG_HAS_JUMBO_FRAMES
  1180. | FLAG_HAS_STATS_PTC_PRC
  1181. | FLAG_HAS_WOL
  1182. | FLAG_APME_IN_CTRL3
  1183. | FLAG_RX_CSUM_ENABLED
  1184. | FLAG_HAS_CTRLEXT_ON_LOAD
  1185. | FLAG_HAS_STATS_ICR_ICT
  1186. | FLAG_TARC_SPEED_MODE_BIT, /* errata */
  1187. .pba = 38,
  1188. .get_invariants = e1000_get_invariants_82571,
  1189. .mac_ops = &e82571_mac_ops,
  1190. .phy_ops = &e82_phy_ops_igp,
  1191. .nvm_ops = &e82571_nvm_ops,
  1192. };
  1193. struct e1000_info e1000_82573_info = {
  1194. .mac = e1000_82573,
  1195. .flags = FLAG_HAS_HW_VLAN_FILTER
  1196. | FLAG_HAS_JUMBO_FRAMES
  1197. | FLAG_HAS_STATS_PTC_PRC
  1198. | FLAG_HAS_WOL
  1199. | FLAG_APME_IN_CTRL3
  1200. | FLAG_RX_CSUM_ENABLED
  1201. | FLAG_HAS_STATS_ICR_ICT
  1202. | FLAG_HAS_SMART_POWER_DOWN
  1203. | FLAG_HAS_AMT
  1204. | FLAG_HAS_ERT
  1205. | FLAG_HAS_SWSM_ON_LOAD,
  1206. .pba = 20,
  1207. .get_invariants = e1000_get_invariants_82571,
  1208. .mac_ops = &e82571_mac_ops,
  1209. .phy_ops = &e82_phy_ops_m88,
  1210. .nvm_ops = &e82571_nvm_ops,
  1211. };