82571.c 36 KB

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