82571.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2010 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 (Copper)
  24. * 82571EB Gigabit Ethernet Controller (Fiber)
  25. * 82571EB Dual Port Gigabit Mezzanine Adapter
  26. * 82571EB Quad Port Gigabit Mezzanine Adapter
  27. * 82571PT Gigabit PT Quad Port Server ExpressModule
  28. * 82572EI Gigabit Ethernet Controller (Copper)
  29. * 82572EI Gigabit Ethernet Controller (Fiber)
  30. * 82572EI Gigabit Ethernet Controller
  31. * 82573V Gigabit Ethernet Controller (Copper)
  32. * 82573E Gigabit Ethernet Controller (Copper)
  33. * 82573L Gigabit Ethernet Controller
  34. * 82574L Gigabit Network Connection
  35. * 82583V Gigabit Network Connection
  36. */
  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. #define E1000_BASE1000T_STATUS 10
  45. #define E1000_IDLE_ERROR_COUNT_MASK 0xFF
  46. #define E1000_RECEIVE_ERROR_COUNTER 21
  47. #define E1000_RECEIVE_ERROR_MAX 0xFFFF
  48. #define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
  49. static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
  50. static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
  51. static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
  52. static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw);
  53. static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
  54. u16 words, u16 *data);
  55. static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
  56. static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
  57. static s32 e1000_setup_link_82571(struct e1000_hw *hw);
  58. static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
  59. static void e1000_clear_vfta_82571(struct e1000_hw *hw);
  60. static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
  61. static s32 e1000_led_on_82574(struct e1000_hw *hw);
  62. static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
  63. static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
  64. static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
  65. static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
  66. static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
  67. /**
  68. * e1000_init_phy_params_82571 - Init PHY func ptrs.
  69. * @hw: pointer to the HW structure
  70. **/
  71. static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
  72. {
  73. struct e1000_phy_info *phy = &hw->phy;
  74. s32 ret_val;
  75. if (hw->phy.media_type != e1000_media_type_copper) {
  76. phy->type = e1000_phy_none;
  77. return 0;
  78. }
  79. phy->addr = 1;
  80. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  81. phy->reset_delay_us = 100;
  82. phy->ops.power_up = e1000_power_up_phy_copper;
  83. phy->ops.power_down = e1000_power_down_phy_copper_82571;
  84. switch (hw->mac.type) {
  85. case e1000_82571:
  86. case e1000_82572:
  87. phy->type = e1000_phy_igp_2;
  88. break;
  89. case e1000_82573:
  90. phy->type = e1000_phy_m88;
  91. break;
  92. case e1000_82574:
  93. case e1000_82583:
  94. phy->type = e1000_phy_bm;
  95. phy->ops.acquire = e1000_get_hw_semaphore_82574;
  96. phy->ops.release = e1000_put_hw_semaphore_82574;
  97. break;
  98. default:
  99. return -E1000_ERR_PHY;
  100. break;
  101. }
  102. /* This can only be done after all function pointers are setup. */
  103. ret_val = e1000_get_phy_id_82571(hw);
  104. /* Verify phy id */
  105. switch (hw->mac.type) {
  106. case e1000_82571:
  107. case e1000_82572:
  108. if (phy->id != IGP01E1000_I_PHY_ID)
  109. return -E1000_ERR_PHY;
  110. break;
  111. case e1000_82573:
  112. if (phy->id != M88E1111_I_PHY_ID)
  113. return -E1000_ERR_PHY;
  114. break;
  115. case e1000_82574:
  116. case e1000_82583:
  117. if (phy->id != BME1000_E_PHY_ID_R2)
  118. return -E1000_ERR_PHY;
  119. break;
  120. default:
  121. return -E1000_ERR_PHY;
  122. break;
  123. }
  124. return 0;
  125. }
  126. /**
  127. * e1000_init_nvm_params_82571 - Init NVM func ptrs.
  128. * @hw: pointer to the HW structure
  129. **/
  130. static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
  131. {
  132. struct e1000_nvm_info *nvm = &hw->nvm;
  133. u32 eecd = er32(EECD);
  134. u16 size;
  135. nvm->opcode_bits = 8;
  136. nvm->delay_usec = 1;
  137. switch (nvm->override) {
  138. case e1000_nvm_override_spi_large:
  139. nvm->page_size = 32;
  140. nvm->address_bits = 16;
  141. break;
  142. case e1000_nvm_override_spi_small:
  143. nvm->page_size = 8;
  144. nvm->address_bits = 8;
  145. break;
  146. default:
  147. nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
  148. nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
  149. break;
  150. }
  151. switch (hw->mac.type) {
  152. case e1000_82573:
  153. case e1000_82574:
  154. case e1000_82583:
  155. if (((eecd >> 15) & 0x3) == 0x3) {
  156. nvm->type = e1000_nvm_flash_hw;
  157. nvm->word_size = 2048;
  158. /*
  159. * Autonomous Flash update bit must be cleared due
  160. * to Flash update issue.
  161. */
  162. eecd &= ~E1000_EECD_AUPDEN;
  163. ew32(EECD, eecd);
  164. break;
  165. }
  166. /* Fall Through */
  167. default:
  168. nvm->type = e1000_nvm_eeprom_spi;
  169. size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
  170. E1000_EECD_SIZE_EX_SHIFT);
  171. /*
  172. * Added to a constant, "size" becomes the left-shift value
  173. * for setting word_size.
  174. */
  175. size += NVM_WORD_SIZE_BASE_SHIFT;
  176. /* EEPROM access above 16k is unsupported */
  177. if (size > 14)
  178. size = 14;
  179. nvm->word_size = 1 << size;
  180. break;
  181. }
  182. /* Function Pointers */
  183. switch (hw->mac.type) {
  184. case e1000_82574:
  185. case e1000_82583:
  186. nvm->ops.acquire = e1000_get_hw_semaphore_82574;
  187. nvm->ops.release = e1000_put_hw_semaphore_82574;
  188. break;
  189. default:
  190. break;
  191. }
  192. return 0;
  193. }
  194. /**
  195. * e1000_init_mac_params_82571 - Init MAC func ptrs.
  196. * @hw: pointer to the HW structure
  197. **/
  198. static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
  199. {
  200. struct e1000_hw *hw = &adapter->hw;
  201. struct e1000_mac_info *mac = &hw->mac;
  202. struct e1000_mac_operations *func = &mac->ops;
  203. u32 swsm = 0;
  204. u32 swsm2 = 0;
  205. bool force_clear_smbi = false;
  206. /* Set media type */
  207. switch (adapter->pdev->device) {
  208. case E1000_DEV_ID_82571EB_FIBER:
  209. case E1000_DEV_ID_82572EI_FIBER:
  210. case E1000_DEV_ID_82571EB_QUAD_FIBER:
  211. hw->phy.media_type = e1000_media_type_fiber;
  212. break;
  213. case E1000_DEV_ID_82571EB_SERDES:
  214. case E1000_DEV_ID_82572EI_SERDES:
  215. case E1000_DEV_ID_82571EB_SERDES_DUAL:
  216. case E1000_DEV_ID_82571EB_SERDES_QUAD:
  217. hw->phy.media_type = e1000_media_type_internal_serdes;
  218. break;
  219. default:
  220. hw->phy.media_type = e1000_media_type_copper;
  221. break;
  222. }
  223. /* Set mta register count */
  224. mac->mta_reg_count = 128;
  225. /* Set rar entry count */
  226. mac->rar_entry_count = E1000_RAR_ENTRIES;
  227. /* Adaptive IFS supported */
  228. mac->adaptive_ifs = true;
  229. /* check for link */
  230. switch (hw->phy.media_type) {
  231. case e1000_media_type_copper:
  232. func->setup_physical_interface = e1000_setup_copper_link_82571;
  233. func->check_for_link = e1000e_check_for_copper_link;
  234. func->get_link_up_info = e1000e_get_speed_and_duplex_copper;
  235. break;
  236. case e1000_media_type_fiber:
  237. func->setup_physical_interface =
  238. e1000_setup_fiber_serdes_link_82571;
  239. func->check_for_link = e1000e_check_for_fiber_link;
  240. func->get_link_up_info =
  241. e1000e_get_speed_and_duplex_fiber_serdes;
  242. break;
  243. case e1000_media_type_internal_serdes:
  244. func->setup_physical_interface =
  245. e1000_setup_fiber_serdes_link_82571;
  246. func->check_for_link = e1000_check_for_serdes_link_82571;
  247. func->get_link_up_info =
  248. e1000e_get_speed_and_duplex_fiber_serdes;
  249. break;
  250. default:
  251. return -E1000_ERR_CONFIG;
  252. break;
  253. }
  254. switch (hw->mac.type) {
  255. case e1000_82573:
  256. func->set_lan_id = e1000_set_lan_id_single_port;
  257. func->check_mng_mode = e1000e_check_mng_mode_generic;
  258. func->led_on = e1000e_led_on_generic;
  259. /* FWSM register */
  260. mac->has_fwsm = true;
  261. /*
  262. * ARC supported; valid only if manageability features are
  263. * enabled.
  264. */
  265. mac->arc_subsystem_valid =
  266. (er32(FWSM) & E1000_FWSM_MODE_MASK)
  267. ? true : false;
  268. break;
  269. case e1000_82574:
  270. case e1000_82583:
  271. func->set_lan_id = e1000_set_lan_id_single_port;
  272. func->check_mng_mode = e1000_check_mng_mode_82574;
  273. func->led_on = e1000_led_on_82574;
  274. break;
  275. default:
  276. func->check_mng_mode = e1000e_check_mng_mode_generic;
  277. func->led_on = e1000e_led_on_generic;
  278. /* FWSM register */
  279. mac->has_fwsm = true;
  280. break;
  281. }
  282. /*
  283. * Ensure that the inter-port SWSM.SMBI lock bit is clear before
  284. * first NVM or PHY acess. This should be done for single-port
  285. * devices, and for one port only on dual-port devices so that
  286. * for those devices we can still use the SMBI lock to synchronize
  287. * inter-port accesses to the PHY & NVM.
  288. */
  289. switch (hw->mac.type) {
  290. case e1000_82571:
  291. case e1000_82572:
  292. swsm2 = er32(SWSM2);
  293. if (!(swsm2 & E1000_SWSM2_LOCK)) {
  294. /* Only do this for the first interface on this card */
  295. ew32(SWSM2,
  296. swsm2 | E1000_SWSM2_LOCK);
  297. force_clear_smbi = true;
  298. } else
  299. force_clear_smbi = false;
  300. break;
  301. default:
  302. force_clear_smbi = true;
  303. break;
  304. }
  305. if (force_clear_smbi) {
  306. /* Make sure SWSM.SMBI is clear */
  307. swsm = er32(SWSM);
  308. if (swsm & E1000_SWSM_SMBI) {
  309. /* This bit should not be set on a first interface, and
  310. * indicates that the bootagent or EFI code has
  311. * improperly left this bit enabled
  312. */
  313. e_dbg("Please update your 82571 Bootagent\n");
  314. }
  315. ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
  316. }
  317. /*
  318. * Initialize device specific counter of SMBI acquisition
  319. * timeouts.
  320. */
  321. hw->dev_spec.e82571.smb_counter = 0;
  322. return 0;
  323. }
  324. static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
  325. {
  326. struct e1000_hw *hw = &adapter->hw;
  327. static int global_quad_port_a; /* global port a indication */
  328. struct pci_dev *pdev = adapter->pdev;
  329. int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
  330. s32 rc;
  331. rc = e1000_init_mac_params_82571(adapter);
  332. if (rc)
  333. return rc;
  334. rc = e1000_init_nvm_params_82571(hw);
  335. if (rc)
  336. return rc;
  337. rc = e1000_init_phy_params_82571(hw);
  338. if (rc)
  339. return rc;
  340. /* tag quad port adapters first, it's used below */
  341. switch (pdev->device) {
  342. case E1000_DEV_ID_82571EB_QUAD_COPPER:
  343. case E1000_DEV_ID_82571EB_QUAD_FIBER:
  344. case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
  345. case E1000_DEV_ID_82571PT_QUAD_COPPER:
  346. adapter->flags |= FLAG_IS_QUAD_PORT;
  347. /* mark the first port */
  348. if (global_quad_port_a == 0)
  349. adapter->flags |= FLAG_IS_QUAD_PORT_A;
  350. /* Reset for multiple quad port adapters */
  351. global_quad_port_a++;
  352. if (global_quad_port_a == 4)
  353. global_quad_port_a = 0;
  354. break;
  355. default:
  356. break;
  357. }
  358. switch (adapter->hw.mac.type) {
  359. case e1000_82571:
  360. /* these dual ports don't have WoL on port B at all */
  361. if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
  362. (pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
  363. (pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
  364. (is_port_b))
  365. adapter->flags &= ~FLAG_HAS_WOL;
  366. /* quad ports only support WoL on port A */
  367. if (adapter->flags & FLAG_IS_QUAD_PORT &&
  368. (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
  369. adapter->flags &= ~FLAG_HAS_WOL;
  370. /* Does not support WoL on any port */
  371. if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
  372. adapter->flags &= ~FLAG_HAS_WOL;
  373. break;
  374. case e1000_82573:
  375. case e1000_82574:
  376. case e1000_82583:
  377. /* Disable ASPM L0s due to hardware errata */
  378. e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
  379. if (pdev->device == E1000_DEV_ID_82573L) {
  380. adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
  381. adapter->max_hw_frame_size = DEFAULT_JUMBO;
  382. }
  383. break;
  384. default:
  385. break;
  386. }
  387. return 0;
  388. }
  389. /**
  390. * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
  391. * @hw: pointer to the HW structure
  392. *
  393. * Reads the PHY registers and stores the PHY ID and possibly the PHY
  394. * revision in the hardware structure.
  395. **/
  396. static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
  397. {
  398. struct e1000_phy_info *phy = &hw->phy;
  399. s32 ret_val;
  400. u16 phy_id = 0;
  401. switch (hw->mac.type) {
  402. case e1000_82571:
  403. case e1000_82572:
  404. /*
  405. * The 82571 firmware may still be configuring the PHY.
  406. * In this case, we cannot access the PHY until the
  407. * configuration is done. So we explicitly set the
  408. * PHY ID.
  409. */
  410. phy->id = IGP01E1000_I_PHY_ID;
  411. break;
  412. case e1000_82573:
  413. return e1000e_get_phy_id(hw);
  414. break;
  415. case e1000_82574:
  416. case e1000_82583:
  417. ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
  418. if (ret_val)
  419. return ret_val;
  420. phy->id = (u32)(phy_id << 16);
  421. udelay(20);
  422. ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
  423. if (ret_val)
  424. return ret_val;
  425. phy->id |= (u32)(phy_id);
  426. phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
  427. break;
  428. default:
  429. return -E1000_ERR_PHY;
  430. break;
  431. }
  432. return 0;
  433. }
  434. /**
  435. * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
  436. * @hw: pointer to the HW structure
  437. *
  438. * Acquire the HW semaphore to access the PHY or NVM
  439. **/
  440. static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
  441. {
  442. u32 swsm;
  443. s32 sw_timeout = hw->nvm.word_size + 1;
  444. s32 fw_timeout = hw->nvm.word_size + 1;
  445. s32 i = 0;
  446. /*
  447. * If we have timedout 3 times on trying to acquire
  448. * the inter-port SMBI semaphore, there is old code
  449. * operating on the other port, and it is not
  450. * releasing SMBI. Modify the number of times that
  451. * we try for the semaphore to interwork with this
  452. * older code.
  453. */
  454. if (hw->dev_spec.e82571.smb_counter > 2)
  455. sw_timeout = 1;
  456. /* Get the SW semaphore */
  457. while (i < sw_timeout) {
  458. swsm = er32(SWSM);
  459. if (!(swsm & E1000_SWSM_SMBI))
  460. break;
  461. udelay(50);
  462. i++;
  463. }
  464. if (i == sw_timeout) {
  465. e_dbg("Driver can't access device - SMBI bit is set.\n");
  466. hw->dev_spec.e82571.smb_counter++;
  467. }
  468. /* Get the FW semaphore. */
  469. for (i = 0; i < fw_timeout; i++) {
  470. swsm = er32(SWSM);
  471. ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
  472. /* Semaphore acquired if bit latched */
  473. if (er32(SWSM) & E1000_SWSM_SWESMBI)
  474. break;
  475. udelay(50);
  476. }
  477. if (i == fw_timeout) {
  478. /* Release semaphores */
  479. e1000_put_hw_semaphore_82571(hw);
  480. e_dbg("Driver can't access the NVM\n");
  481. return -E1000_ERR_NVM;
  482. }
  483. return 0;
  484. }
  485. /**
  486. * e1000_put_hw_semaphore_82571 - Release hardware semaphore
  487. * @hw: pointer to the HW structure
  488. *
  489. * Release hardware semaphore used to access the PHY or NVM
  490. **/
  491. static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
  492. {
  493. u32 swsm;
  494. swsm = er32(SWSM);
  495. swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
  496. ew32(SWSM, swsm);
  497. }
  498. /**
  499. * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
  500. * @hw: pointer to the HW structure
  501. *
  502. * Acquire the HW semaphore during reset.
  503. *
  504. **/
  505. static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
  506. {
  507. u32 extcnf_ctrl;
  508. s32 ret_val = 0;
  509. s32 i = 0;
  510. extcnf_ctrl = er32(EXTCNF_CTRL);
  511. extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
  512. do {
  513. ew32(EXTCNF_CTRL, extcnf_ctrl);
  514. extcnf_ctrl = er32(EXTCNF_CTRL);
  515. if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
  516. break;
  517. extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
  518. msleep(2);
  519. i++;
  520. } while (i < MDIO_OWNERSHIP_TIMEOUT);
  521. if (i == MDIO_OWNERSHIP_TIMEOUT) {
  522. /* Release semaphores */
  523. e1000_put_hw_semaphore_82573(hw);
  524. e_dbg("Driver can't access the PHY\n");
  525. ret_val = -E1000_ERR_PHY;
  526. goto out;
  527. }
  528. out:
  529. return ret_val;
  530. }
  531. /**
  532. * e1000_put_hw_semaphore_82573 - Release hardware semaphore
  533. * @hw: pointer to the HW structure
  534. *
  535. * Release hardware semaphore used during reset.
  536. *
  537. **/
  538. static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
  539. {
  540. u32 extcnf_ctrl;
  541. extcnf_ctrl = er32(EXTCNF_CTRL);
  542. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
  543. ew32(EXTCNF_CTRL, extcnf_ctrl);
  544. }
  545. static DEFINE_MUTEX(swflag_mutex);
  546. /**
  547. * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
  548. * @hw: pointer to the HW structure
  549. *
  550. * Acquire the HW semaphore to access the PHY or NVM.
  551. *
  552. **/
  553. static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
  554. {
  555. s32 ret_val;
  556. mutex_lock(&swflag_mutex);
  557. ret_val = e1000_get_hw_semaphore_82573(hw);
  558. if (ret_val)
  559. mutex_unlock(&swflag_mutex);
  560. return ret_val;
  561. }
  562. /**
  563. * e1000_put_hw_semaphore_82574 - Release hardware semaphore
  564. * @hw: pointer to the HW structure
  565. *
  566. * Release hardware semaphore used to access the PHY or NVM
  567. *
  568. **/
  569. static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
  570. {
  571. e1000_put_hw_semaphore_82573(hw);
  572. mutex_unlock(&swflag_mutex);
  573. }
  574. /**
  575. * e1000_acquire_nvm_82571 - Request for access to the EEPROM
  576. * @hw: pointer to the HW structure
  577. *
  578. * To gain access to the EEPROM, first we must obtain a hardware semaphore.
  579. * Then for non-82573 hardware, set the EEPROM access request bit and wait
  580. * for EEPROM access grant bit. If the access grant bit is not set, release
  581. * hardware semaphore.
  582. **/
  583. static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
  584. {
  585. s32 ret_val;
  586. ret_val = e1000_get_hw_semaphore_82571(hw);
  587. if (ret_val)
  588. return ret_val;
  589. switch (hw->mac.type) {
  590. case e1000_82573:
  591. break;
  592. default:
  593. ret_val = e1000e_acquire_nvm(hw);
  594. break;
  595. }
  596. if (ret_val)
  597. e1000_put_hw_semaphore_82571(hw);
  598. return ret_val;
  599. }
  600. /**
  601. * e1000_release_nvm_82571 - Release exclusive access to EEPROM
  602. * @hw: pointer to the HW structure
  603. *
  604. * Stop any current commands to the EEPROM and clear the EEPROM request bit.
  605. **/
  606. static void e1000_release_nvm_82571(struct e1000_hw *hw)
  607. {
  608. e1000e_release_nvm(hw);
  609. e1000_put_hw_semaphore_82571(hw);
  610. }
  611. /**
  612. * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
  613. * @hw: pointer to the HW structure
  614. * @offset: offset within the EEPROM to be written to
  615. * @words: number of words to write
  616. * @data: 16 bit word(s) to be written to the EEPROM
  617. *
  618. * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
  619. *
  620. * If e1000e_update_nvm_checksum is not called after this function, the
  621. * EEPROM will most likely contain an invalid checksum.
  622. **/
  623. static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
  624. u16 *data)
  625. {
  626. s32 ret_val;
  627. switch (hw->mac.type) {
  628. case e1000_82573:
  629. case e1000_82574:
  630. case e1000_82583:
  631. ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
  632. break;
  633. case e1000_82571:
  634. case e1000_82572:
  635. ret_val = e1000e_write_nvm_spi(hw, offset, words, data);
  636. break;
  637. default:
  638. ret_val = -E1000_ERR_NVM;
  639. break;
  640. }
  641. return ret_val;
  642. }
  643. /**
  644. * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
  645. * @hw: pointer to the HW structure
  646. *
  647. * Updates the EEPROM checksum by reading/adding each word of the EEPROM
  648. * up to the checksum. Then calculates the EEPROM checksum and writes the
  649. * value to the EEPROM.
  650. **/
  651. static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
  652. {
  653. u32 eecd;
  654. s32 ret_val;
  655. u16 i;
  656. ret_val = e1000e_update_nvm_checksum_generic(hw);
  657. if (ret_val)
  658. return ret_val;
  659. /*
  660. * If our nvm is an EEPROM, then we're done
  661. * otherwise, commit the checksum to the flash NVM.
  662. */
  663. if (hw->nvm.type != e1000_nvm_flash_hw)
  664. return ret_val;
  665. /* Check for pending operations. */
  666. for (i = 0; i < E1000_FLASH_UPDATES; i++) {
  667. msleep(1);
  668. if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
  669. break;
  670. }
  671. if (i == E1000_FLASH_UPDATES)
  672. return -E1000_ERR_NVM;
  673. /* Reset the firmware if using STM opcode. */
  674. if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) {
  675. /*
  676. * The enabling of and the actual reset must be done
  677. * in two write cycles.
  678. */
  679. ew32(HICR, E1000_HICR_FW_RESET_ENABLE);
  680. e1e_flush();
  681. ew32(HICR, E1000_HICR_FW_RESET);
  682. }
  683. /* Commit the write to flash */
  684. eecd = er32(EECD) | E1000_EECD_FLUPD;
  685. ew32(EECD, eecd);
  686. for (i = 0; i < E1000_FLASH_UPDATES; i++) {
  687. msleep(1);
  688. if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
  689. break;
  690. }
  691. if (i == E1000_FLASH_UPDATES)
  692. return -E1000_ERR_NVM;
  693. return 0;
  694. }
  695. /**
  696. * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
  697. * @hw: pointer to the HW structure
  698. *
  699. * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
  700. * and then verifies that the sum of the EEPROM is equal to 0xBABA.
  701. **/
  702. static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
  703. {
  704. if (hw->nvm.type == e1000_nvm_flash_hw)
  705. e1000_fix_nvm_checksum_82571(hw);
  706. return e1000e_validate_nvm_checksum_generic(hw);
  707. }
  708. /**
  709. * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
  710. * @hw: pointer to the HW structure
  711. * @offset: offset within the EEPROM to be written to
  712. * @words: number of words to write
  713. * @data: 16 bit word(s) to be written to the EEPROM
  714. *
  715. * After checking for invalid values, poll the EEPROM to ensure the previous
  716. * command has completed before trying to write the next word. After write
  717. * poll for completion.
  718. *
  719. * If e1000e_update_nvm_checksum is not called after this function, the
  720. * EEPROM will most likely contain an invalid checksum.
  721. **/
  722. static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
  723. u16 words, u16 *data)
  724. {
  725. struct e1000_nvm_info *nvm = &hw->nvm;
  726. u32 i, eewr = 0;
  727. s32 ret_val = 0;
  728. /*
  729. * A check for invalid values: offset too large, too many words,
  730. * and not enough words.
  731. */
  732. if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
  733. (words == 0)) {
  734. e_dbg("nvm parameter(s) out of bounds\n");
  735. return -E1000_ERR_NVM;
  736. }
  737. for (i = 0; i < words; i++) {
  738. eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
  739. ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
  740. E1000_NVM_RW_REG_START;
  741. ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
  742. if (ret_val)
  743. break;
  744. ew32(EEWR, eewr);
  745. ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
  746. if (ret_val)
  747. break;
  748. }
  749. return ret_val;
  750. }
  751. /**
  752. * e1000_get_cfg_done_82571 - Poll for configuration done
  753. * @hw: pointer to the HW structure
  754. *
  755. * Reads the management control register for the config done bit to be set.
  756. **/
  757. static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
  758. {
  759. s32 timeout = PHY_CFG_TIMEOUT;
  760. while (timeout) {
  761. if (er32(EEMNGCTL) &
  762. E1000_NVM_CFG_DONE_PORT_0)
  763. break;
  764. msleep(1);
  765. timeout--;
  766. }
  767. if (!timeout) {
  768. e_dbg("MNG configuration cycle has not completed.\n");
  769. return -E1000_ERR_RESET;
  770. }
  771. return 0;
  772. }
  773. /**
  774. * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
  775. * @hw: pointer to the HW structure
  776. * @active: true to enable LPLU, false to disable
  777. *
  778. * Sets the LPLU D0 state according to the active flag. When activating LPLU
  779. * this function also disables smart speed and vice versa. LPLU will not be
  780. * activated unless the device autonegotiation advertisement meets standards
  781. * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
  782. * pointer entry point only called by PHY setup routines.
  783. **/
  784. static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
  785. {
  786. struct e1000_phy_info *phy = &hw->phy;
  787. s32 ret_val;
  788. u16 data;
  789. ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
  790. if (ret_val)
  791. return ret_val;
  792. if (active) {
  793. data |= IGP02E1000_PM_D0_LPLU;
  794. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  795. if (ret_val)
  796. return ret_val;
  797. /* When LPLU is enabled, we should disable SmartSpeed */
  798. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  799. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  800. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  801. if (ret_val)
  802. return ret_val;
  803. } else {
  804. data &= ~IGP02E1000_PM_D0_LPLU;
  805. ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
  806. /*
  807. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  808. * during Dx states where the power conservation is most
  809. * important. During driver activity we should enable
  810. * SmartSpeed, so performance is maintained.
  811. */
  812. if (phy->smart_speed == e1000_smart_speed_on) {
  813. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  814. &data);
  815. if (ret_val)
  816. return ret_val;
  817. data |= IGP01E1000_PSCFR_SMART_SPEED;
  818. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  819. data);
  820. if (ret_val)
  821. return ret_val;
  822. } else if (phy->smart_speed == e1000_smart_speed_off) {
  823. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  824. &data);
  825. if (ret_val)
  826. return ret_val;
  827. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  828. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  829. data);
  830. if (ret_val)
  831. return ret_val;
  832. }
  833. }
  834. return 0;
  835. }
  836. /**
  837. * e1000_reset_hw_82571 - Reset hardware
  838. * @hw: pointer to the HW structure
  839. *
  840. * This resets the hardware into a known state.
  841. **/
  842. static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
  843. {
  844. u32 ctrl, ctrl_ext, icr;
  845. s32 ret_val;
  846. /*
  847. * Prevent the PCI-E bus from sticking if there is no TLP connection
  848. * on the last TLP read/write transaction when MAC is reset.
  849. */
  850. ret_val = e1000e_disable_pcie_master(hw);
  851. if (ret_val)
  852. e_dbg("PCI-E Master disable polling has failed.\n");
  853. e_dbg("Masking off all interrupts\n");
  854. ew32(IMC, 0xffffffff);
  855. ew32(RCTL, 0);
  856. ew32(TCTL, E1000_TCTL_PSP);
  857. e1e_flush();
  858. msleep(10);
  859. /*
  860. * Must acquire the MDIO ownership before MAC reset.
  861. * Ownership defaults to firmware after a reset.
  862. */
  863. switch (hw->mac.type) {
  864. case e1000_82573:
  865. ret_val = e1000_get_hw_semaphore_82573(hw);
  866. break;
  867. case e1000_82574:
  868. case e1000_82583:
  869. ret_val = e1000_get_hw_semaphore_82574(hw);
  870. break;
  871. default:
  872. break;
  873. }
  874. if (ret_val)
  875. e_dbg("Cannot acquire MDIO ownership\n");
  876. ctrl = er32(CTRL);
  877. e_dbg("Issuing a global reset to MAC\n");
  878. ew32(CTRL, ctrl | E1000_CTRL_RST);
  879. /* Must release MDIO ownership and mutex after MAC reset. */
  880. switch (hw->mac.type) {
  881. case e1000_82574:
  882. case e1000_82583:
  883. e1000_put_hw_semaphore_82574(hw);
  884. break;
  885. default:
  886. break;
  887. }
  888. if (hw->nvm.type == e1000_nvm_flash_hw) {
  889. udelay(10);
  890. ctrl_ext = er32(CTRL_EXT);
  891. ctrl_ext |= E1000_CTRL_EXT_EE_RST;
  892. ew32(CTRL_EXT, ctrl_ext);
  893. e1e_flush();
  894. }
  895. ret_val = e1000e_get_auto_rd_done(hw);
  896. if (ret_val)
  897. /* We don't want to continue accessing MAC registers. */
  898. return ret_val;
  899. /*
  900. * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
  901. * Need to wait for Phy configuration completion before accessing
  902. * NVM and Phy.
  903. */
  904. switch (hw->mac.type) {
  905. case e1000_82573:
  906. case e1000_82574:
  907. case e1000_82583:
  908. msleep(25);
  909. break;
  910. default:
  911. break;
  912. }
  913. /* Clear any pending interrupt events. */
  914. ew32(IMC, 0xffffffff);
  915. icr = er32(ICR);
  916. if (hw->mac.type == e1000_82571) {
  917. /* Install any alternate MAC address into RAR0 */
  918. ret_val = e1000_check_alt_mac_addr_generic(hw);
  919. if (ret_val)
  920. return ret_val;
  921. e1000e_set_laa_state_82571(hw, true);
  922. }
  923. /* Reinitialize the 82571 serdes link state machine */
  924. if (hw->phy.media_type == e1000_media_type_internal_serdes)
  925. hw->mac.serdes_link_state = e1000_serdes_link_down;
  926. return 0;
  927. }
  928. /**
  929. * e1000_init_hw_82571 - Initialize hardware
  930. * @hw: pointer to the HW structure
  931. *
  932. * This inits the hardware readying it for operation.
  933. **/
  934. static s32 e1000_init_hw_82571(struct e1000_hw *hw)
  935. {
  936. struct e1000_mac_info *mac = &hw->mac;
  937. u32 reg_data;
  938. s32 ret_val;
  939. u16 i, rar_count = mac->rar_entry_count;
  940. e1000_initialize_hw_bits_82571(hw);
  941. /* Initialize identification LED */
  942. ret_val = e1000e_id_led_init(hw);
  943. if (ret_val)
  944. e_dbg("Error initializing identification LED\n");
  945. /* This is not fatal and we should not stop init due to this */
  946. /* Disabling VLAN filtering */
  947. e_dbg("Initializing the IEEE VLAN\n");
  948. mac->ops.clear_vfta(hw);
  949. /* Setup the receive address. */
  950. /*
  951. * If, however, a locally administered address was assigned to the
  952. * 82571, we must reserve a RAR for it to work around an issue where
  953. * resetting one port will reload the MAC on the other port.
  954. */
  955. if (e1000e_get_laa_state_82571(hw))
  956. rar_count--;
  957. e1000e_init_rx_addrs(hw, rar_count);
  958. /* Zero out the Multicast HASH table */
  959. e_dbg("Zeroing the MTA\n");
  960. for (i = 0; i < mac->mta_reg_count; i++)
  961. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  962. /* Setup link and flow control */
  963. ret_val = e1000_setup_link_82571(hw);
  964. /* Set the transmit descriptor write-back policy */
  965. reg_data = er32(TXDCTL(0));
  966. reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
  967. E1000_TXDCTL_FULL_TX_DESC_WB |
  968. E1000_TXDCTL_COUNT_DESC;
  969. ew32(TXDCTL(0), reg_data);
  970. /* ...for both queues. */
  971. switch (mac->type) {
  972. case e1000_82573:
  973. e1000e_enable_tx_pkt_filtering(hw);
  974. /* fall through */
  975. case e1000_82574:
  976. case e1000_82583:
  977. reg_data = er32(GCR);
  978. reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
  979. ew32(GCR, reg_data);
  980. break;
  981. default:
  982. reg_data = er32(TXDCTL(1));
  983. reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
  984. E1000_TXDCTL_FULL_TX_DESC_WB |
  985. E1000_TXDCTL_COUNT_DESC;
  986. ew32(TXDCTL(1), reg_data);
  987. break;
  988. }
  989. /*
  990. * Clear all of the statistics registers (clear on read). It is
  991. * important that we do this after we have tried to establish link
  992. * because the symbol error count will increment wildly if there
  993. * is no link.
  994. */
  995. e1000_clear_hw_cntrs_82571(hw);
  996. return ret_val;
  997. }
  998. /**
  999. * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
  1000. * @hw: pointer to the HW structure
  1001. *
  1002. * Initializes required hardware-dependent bits needed for normal operation.
  1003. **/
  1004. static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
  1005. {
  1006. u32 reg;
  1007. /* Transmit Descriptor Control 0 */
  1008. reg = er32(TXDCTL(0));
  1009. reg |= (1 << 22);
  1010. ew32(TXDCTL(0), reg);
  1011. /* Transmit Descriptor Control 1 */
  1012. reg = er32(TXDCTL(1));
  1013. reg |= (1 << 22);
  1014. ew32(TXDCTL(1), reg);
  1015. /* Transmit Arbitration Control 0 */
  1016. reg = er32(TARC(0));
  1017. reg &= ~(0xF << 27); /* 30:27 */
  1018. switch (hw->mac.type) {
  1019. case e1000_82571:
  1020. case e1000_82572:
  1021. reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
  1022. break;
  1023. default:
  1024. break;
  1025. }
  1026. ew32(TARC(0), reg);
  1027. /* Transmit Arbitration Control 1 */
  1028. reg = er32(TARC(1));
  1029. switch (hw->mac.type) {
  1030. case e1000_82571:
  1031. case e1000_82572:
  1032. reg &= ~((1 << 29) | (1 << 30));
  1033. reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
  1034. if (er32(TCTL) & E1000_TCTL_MULR)
  1035. reg &= ~(1 << 28);
  1036. else
  1037. reg |= (1 << 28);
  1038. ew32(TARC(1), reg);
  1039. break;
  1040. default:
  1041. break;
  1042. }
  1043. /* Device Control */
  1044. switch (hw->mac.type) {
  1045. case e1000_82573:
  1046. case e1000_82574:
  1047. case e1000_82583:
  1048. reg = er32(CTRL);
  1049. reg &= ~(1 << 29);
  1050. ew32(CTRL, reg);
  1051. break;
  1052. default:
  1053. break;
  1054. }
  1055. /* Extended Device Control */
  1056. switch (hw->mac.type) {
  1057. case e1000_82573:
  1058. case e1000_82574:
  1059. case e1000_82583:
  1060. reg = er32(CTRL_EXT);
  1061. reg &= ~(1 << 23);
  1062. reg |= (1 << 22);
  1063. ew32(CTRL_EXT, reg);
  1064. break;
  1065. default:
  1066. break;
  1067. }
  1068. if (hw->mac.type == e1000_82571) {
  1069. reg = er32(PBA_ECC);
  1070. reg |= E1000_PBA_ECC_CORR_EN;
  1071. ew32(PBA_ECC, reg);
  1072. }
  1073. /*
  1074. * Workaround for hardware errata.
  1075. * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
  1076. */
  1077. if ((hw->mac.type == e1000_82571) ||
  1078. (hw->mac.type == e1000_82572)) {
  1079. reg = er32(CTRL_EXT);
  1080. reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
  1081. ew32(CTRL_EXT, reg);
  1082. }
  1083. /* PCI-Ex Control Registers */
  1084. switch (hw->mac.type) {
  1085. case e1000_82574:
  1086. case e1000_82583:
  1087. reg = er32(GCR);
  1088. reg |= (1 << 22);
  1089. ew32(GCR, reg);
  1090. /*
  1091. * Workaround for hardware errata.
  1092. * apply workaround for hardware errata documented in errata
  1093. * docs Fixes issue where some error prone or unreliable PCIe
  1094. * completions are occurring, particularly with ASPM enabled.
  1095. * Without fix, issue can cause tx timeouts.
  1096. */
  1097. reg = er32(GCR2);
  1098. reg |= 1;
  1099. ew32(GCR2, reg);
  1100. break;
  1101. default:
  1102. break;
  1103. }
  1104. }
  1105. /**
  1106. * e1000_clear_vfta_82571 - Clear VLAN filter table
  1107. * @hw: pointer to the HW structure
  1108. *
  1109. * Clears the register array which contains the VLAN filter table by
  1110. * setting all the values to 0.
  1111. **/
  1112. static void e1000_clear_vfta_82571(struct e1000_hw *hw)
  1113. {
  1114. u32 offset;
  1115. u32 vfta_value = 0;
  1116. u32 vfta_offset = 0;
  1117. u32 vfta_bit_in_reg = 0;
  1118. switch (hw->mac.type) {
  1119. case e1000_82573:
  1120. case e1000_82574:
  1121. case e1000_82583:
  1122. if (hw->mng_cookie.vlan_id != 0) {
  1123. /*
  1124. * The VFTA is a 4096b bit-field, each identifying
  1125. * a single VLAN ID. The following operations
  1126. * determine which 32b entry (i.e. offset) into the
  1127. * array we want to set the VLAN ID (i.e. bit) of
  1128. * the manageability unit.
  1129. */
  1130. vfta_offset = (hw->mng_cookie.vlan_id >>
  1131. E1000_VFTA_ENTRY_SHIFT) &
  1132. E1000_VFTA_ENTRY_MASK;
  1133. vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
  1134. E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
  1135. }
  1136. break;
  1137. default:
  1138. break;
  1139. }
  1140. for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
  1141. /*
  1142. * If the offset we want to clear is the same offset of the
  1143. * manageability VLAN ID, then clear all bits except that of
  1144. * the manageability unit.
  1145. */
  1146. vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
  1147. E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
  1148. e1e_flush();
  1149. }
  1150. }
  1151. /**
  1152. * e1000_check_mng_mode_82574 - Check manageability is enabled
  1153. * @hw: pointer to the HW structure
  1154. *
  1155. * Reads the NVM Initialization Control Word 2 and returns true
  1156. * (>0) if any manageability is enabled, else false (0).
  1157. **/
  1158. static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
  1159. {
  1160. u16 data;
  1161. e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
  1162. return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
  1163. }
  1164. /**
  1165. * e1000_led_on_82574 - Turn LED on
  1166. * @hw: pointer to the HW structure
  1167. *
  1168. * Turn LED on.
  1169. **/
  1170. static s32 e1000_led_on_82574(struct e1000_hw *hw)
  1171. {
  1172. u32 ctrl;
  1173. u32 i;
  1174. ctrl = hw->mac.ledctl_mode2;
  1175. if (!(E1000_STATUS_LU & er32(STATUS))) {
  1176. /*
  1177. * If no link, then turn LED on by setting the invert bit
  1178. * for each LED that's "on" (0x0E) in ledctl_mode2.
  1179. */
  1180. for (i = 0; i < 4; i++)
  1181. if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
  1182. E1000_LEDCTL_MODE_LED_ON)
  1183. ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
  1184. }
  1185. ew32(LEDCTL, ctrl);
  1186. return 0;
  1187. }
  1188. /**
  1189. * e1000_check_phy_82574 - check 82574 phy hung state
  1190. * @hw: pointer to the HW structure
  1191. *
  1192. * Returns whether phy is hung or not
  1193. **/
  1194. bool e1000_check_phy_82574(struct e1000_hw *hw)
  1195. {
  1196. u16 status_1kbt = 0;
  1197. u16 receive_errors = 0;
  1198. bool phy_hung = false;
  1199. s32 ret_val = 0;
  1200. /*
  1201. * Read PHY Receive Error counter first, if its is max - all F's then
  1202. * read the Base1000T status register If both are max then PHY is hung.
  1203. */
  1204. ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
  1205. if (ret_val)
  1206. goto out;
  1207. if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
  1208. ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
  1209. if (ret_val)
  1210. goto out;
  1211. if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
  1212. E1000_IDLE_ERROR_COUNT_MASK)
  1213. phy_hung = true;
  1214. }
  1215. out:
  1216. return phy_hung;
  1217. }
  1218. /**
  1219. * e1000_setup_link_82571 - Setup flow control and link settings
  1220. * @hw: pointer to the HW structure
  1221. *
  1222. * Determines which flow control settings to use, then configures flow
  1223. * control. Calls the appropriate media-specific link configuration
  1224. * function. Assuming the adapter has a valid link partner, a valid link
  1225. * should be established. Assumes the hardware has previously been reset
  1226. * and the transmitter and receiver are not enabled.
  1227. **/
  1228. static s32 e1000_setup_link_82571(struct e1000_hw *hw)
  1229. {
  1230. /*
  1231. * 82573 does not have a word in the NVM to determine
  1232. * the default flow control setting, so we explicitly
  1233. * set it to full.
  1234. */
  1235. switch (hw->mac.type) {
  1236. case e1000_82573:
  1237. case e1000_82574:
  1238. case e1000_82583:
  1239. if (hw->fc.requested_mode == e1000_fc_default)
  1240. hw->fc.requested_mode = e1000_fc_full;
  1241. break;
  1242. default:
  1243. break;
  1244. }
  1245. return e1000e_setup_link(hw);
  1246. }
  1247. /**
  1248. * e1000_setup_copper_link_82571 - Configure copper link settings
  1249. * @hw: pointer to the HW structure
  1250. *
  1251. * Configures the link for auto-neg or forced speed and duplex. Then we check
  1252. * for link, once link is established calls to configure collision distance
  1253. * and flow control are called.
  1254. **/
  1255. static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
  1256. {
  1257. u32 ctrl;
  1258. s32 ret_val;
  1259. ctrl = er32(CTRL);
  1260. ctrl |= E1000_CTRL_SLU;
  1261. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  1262. ew32(CTRL, ctrl);
  1263. switch (hw->phy.type) {
  1264. case e1000_phy_m88:
  1265. case e1000_phy_bm:
  1266. ret_val = e1000e_copper_link_setup_m88(hw);
  1267. break;
  1268. case e1000_phy_igp_2:
  1269. ret_val = e1000e_copper_link_setup_igp(hw);
  1270. break;
  1271. default:
  1272. return -E1000_ERR_PHY;
  1273. break;
  1274. }
  1275. if (ret_val)
  1276. return ret_val;
  1277. ret_val = e1000e_setup_copper_link(hw);
  1278. return ret_val;
  1279. }
  1280. /**
  1281. * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
  1282. * @hw: pointer to the HW structure
  1283. *
  1284. * Configures collision distance and flow control for fiber and serdes links.
  1285. * Upon successful setup, poll for link.
  1286. **/
  1287. static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
  1288. {
  1289. switch (hw->mac.type) {
  1290. case e1000_82571:
  1291. case e1000_82572:
  1292. /*
  1293. * If SerDes loopback mode is entered, there is no form
  1294. * of reset to take the adapter out of that mode. So we
  1295. * have to explicitly take the adapter out of loopback
  1296. * mode. This prevents drivers from twiddling their thumbs
  1297. * if another tool failed to take it out of loopback mode.
  1298. */
  1299. ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
  1300. break;
  1301. default:
  1302. break;
  1303. }
  1304. return e1000e_setup_fiber_serdes_link(hw);
  1305. }
  1306. /**
  1307. * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
  1308. * @hw: pointer to the HW structure
  1309. *
  1310. * Reports the link state as up or down.
  1311. *
  1312. * If autonegotiation is supported by the link partner, the link state is
  1313. * determined by the result of autonegotiation. This is the most likely case.
  1314. * If autonegotiation is not supported by the link partner, and the link
  1315. * has a valid signal, force the link up.
  1316. *
  1317. * The link state is represented internally here by 4 states:
  1318. *
  1319. * 1) down
  1320. * 2) autoneg_progress
  1321. * 3) autoneg_complete (the link successfully autonegotiated)
  1322. * 4) forced_up (the link has been forced up, it did not autonegotiate)
  1323. *
  1324. **/
  1325. static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
  1326. {
  1327. struct e1000_mac_info *mac = &hw->mac;
  1328. u32 rxcw;
  1329. u32 ctrl;
  1330. u32 status;
  1331. s32 ret_val = 0;
  1332. ctrl = er32(CTRL);
  1333. status = er32(STATUS);
  1334. rxcw = er32(RXCW);
  1335. if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
  1336. /* Receiver is synchronized with no invalid bits. */
  1337. switch (mac->serdes_link_state) {
  1338. case e1000_serdes_link_autoneg_complete:
  1339. if (!(status & E1000_STATUS_LU)) {
  1340. /*
  1341. * We have lost link, retry autoneg before
  1342. * reporting link failure
  1343. */
  1344. mac->serdes_link_state =
  1345. e1000_serdes_link_autoneg_progress;
  1346. mac->serdes_has_link = false;
  1347. e_dbg("AN_UP -> AN_PROG\n");
  1348. } else {
  1349. mac->serdes_has_link = true;
  1350. }
  1351. break;
  1352. case e1000_serdes_link_forced_up:
  1353. /*
  1354. * If we are receiving /C/ ordered sets, re-enable
  1355. * auto-negotiation in the TXCW register and disable
  1356. * forced link in the Device Control register in an
  1357. * attempt to auto-negotiate with our link partner.
  1358. * If the partner code word is null, stop forcing
  1359. * and restart auto negotiation.
  1360. */
  1361. if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
  1362. /* Enable autoneg, and unforce link up */
  1363. ew32(TXCW, mac->txcw);
  1364. ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
  1365. mac->serdes_link_state =
  1366. e1000_serdes_link_autoneg_progress;
  1367. mac->serdes_has_link = false;
  1368. e_dbg("FORCED_UP -> AN_PROG\n");
  1369. } else {
  1370. mac->serdes_has_link = true;
  1371. }
  1372. break;
  1373. case e1000_serdes_link_autoneg_progress:
  1374. if (rxcw & E1000_RXCW_C) {
  1375. /*
  1376. * We received /C/ ordered sets, meaning the
  1377. * link partner has autonegotiated, and we can
  1378. * trust the Link Up (LU) status bit.
  1379. */
  1380. if (status & E1000_STATUS_LU) {
  1381. mac->serdes_link_state =
  1382. e1000_serdes_link_autoneg_complete;
  1383. e_dbg("AN_PROG -> AN_UP\n");
  1384. mac->serdes_has_link = true;
  1385. } else {
  1386. /* Autoneg completed, but failed. */
  1387. mac->serdes_link_state =
  1388. e1000_serdes_link_down;
  1389. e_dbg("AN_PROG -> DOWN\n");
  1390. }
  1391. } else {
  1392. /*
  1393. * The link partner did not autoneg.
  1394. * Force link up and full duplex, and change
  1395. * state to forced.
  1396. */
  1397. ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
  1398. ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
  1399. ew32(CTRL, ctrl);
  1400. /* Configure Flow Control after link up. */
  1401. ret_val = e1000e_config_fc_after_link_up(hw);
  1402. if (ret_val) {
  1403. e_dbg("Error config flow control\n");
  1404. break;
  1405. }
  1406. mac->serdes_link_state =
  1407. e1000_serdes_link_forced_up;
  1408. mac->serdes_has_link = true;
  1409. e_dbg("AN_PROG -> FORCED_UP\n");
  1410. }
  1411. break;
  1412. case e1000_serdes_link_down:
  1413. default:
  1414. /*
  1415. * The link was down but the receiver has now gained
  1416. * valid sync, so lets see if we can bring the link
  1417. * up.
  1418. */
  1419. ew32(TXCW, mac->txcw);
  1420. ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
  1421. mac->serdes_link_state =
  1422. e1000_serdes_link_autoneg_progress;
  1423. mac->serdes_has_link = false;
  1424. e_dbg("DOWN -> AN_PROG\n");
  1425. break;
  1426. }
  1427. } else {
  1428. if (!(rxcw & E1000_RXCW_SYNCH)) {
  1429. mac->serdes_has_link = false;
  1430. mac->serdes_link_state = e1000_serdes_link_down;
  1431. e_dbg("ANYSTATE -> DOWN\n");
  1432. } else {
  1433. /*
  1434. * We have sync, and can tolerate one invalid (IV)
  1435. * codeword before declaring link down, so reread
  1436. * to look again.
  1437. */
  1438. udelay(10);
  1439. rxcw = er32(RXCW);
  1440. if (rxcw & E1000_RXCW_IV) {
  1441. mac->serdes_link_state = e1000_serdes_link_down;
  1442. mac->serdes_has_link = false;
  1443. e_dbg("ANYSTATE -> DOWN\n");
  1444. }
  1445. }
  1446. }
  1447. return ret_val;
  1448. }
  1449. /**
  1450. * e1000_valid_led_default_82571 - Verify a valid default LED config
  1451. * @hw: pointer to the HW structure
  1452. * @data: pointer to the NVM (EEPROM)
  1453. *
  1454. * Read the EEPROM for the current default LED configuration. If the
  1455. * LED configuration is not valid, set to a valid LED configuration.
  1456. **/
  1457. static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
  1458. {
  1459. s32 ret_val;
  1460. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  1461. if (ret_val) {
  1462. e_dbg("NVM Read Error\n");
  1463. return ret_val;
  1464. }
  1465. switch (hw->mac.type) {
  1466. case e1000_82573:
  1467. case e1000_82574:
  1468. case e1000_82583:
  1469. if (*data == ID_LED_RESERVED_F746)
  1470. *data = ID_LED_DEFAULT_82573;
  1471. break;
  1472. default:
  1473. if (*data == ID_LED_RESERVED_0000 ||
  1474. *data == ID_LED_RESERVED_FFFF)
  1475. *data = ID_LED_DEFAULT;
  1476. break;
  1477. }
  1478. return 0;
  1479. }
  1480. /**
  1481. * e1000e_get_laa_state_82571 - Get locally administered address state
  1482. * @hw: pointer to the HW structure
  1483. *
  1484. * Retrieve and return the current locally administered address state.
  1485. **/
  1486. bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
  1487. {
  1488. if (hw->mac.type != e1000_82571)
  1489. return false;
  1490. return hw->dev_spec.e82571.laa_is_present;
  1491. }
  1492. /**
  1493. * e1000e_set_laa_state_82571 - Set locally administered address state
  1494. * @hw: pointer to the HW structure
  1495. * @state: enable/disable locally administered address
  1496. *
  1497. * Enable/Disable the current locally administered address state.
  1498. **/
  1499. void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
  1500. {
  1501. if (hw->mac.type != e1000_82571)
  1502. return;
  1503. hw->dev_spec.e82571.laa_is_present = state;
  1504. /* If workaround is activated... */
  1505. if (state)
  1506. /*
  1507. * Hold a copy of the LAA in RAR[14] This is done so that
  1508. * between the time RAR[0] gets clobbered and the time it
  1509. * gets fixed, the actual LAA is in one of the RARs and no
  1510. * incoming packets directed to this port are dropped.
  1511. * Eventually the LAA will be in RAR[0] and RAR[14].
  1512. */
  1513. e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1);
  1514. }
  1515. /**
  1516. * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
  1517. * @hw: pointer to the HW structure
  1518. *
  1519. * Verifies that the EEPROM has completed the update. After updating the
  1520. * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
  1521. * the checksum fix is not implemented, we need to set the bit and update
  1522. * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
  1523. * we need to return bad checksum.
  1524. **/
  1525. static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
  1526. {
  1527. struct e1000_nvm_info *nvm = &hw->nvm;
  1528. s32 ret_val;
  1529. u16 data;
  1530. if (nvm->type != e1000_nvm_flash_hw)
  1531. return 0;
  1532. /*
  1533. * Check bit 4 of word 10h. If it is 0, firmware is done updating
  1534. * 10h-12h. Checksum may need to be fixed.
  1535. */
  1536. ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
  1537. if (ret_val)
  1538. return ret_val;
  1539. if (!(data & 0x10)) {
  1540. /*
  1541. * Read 0x23 and check bit 15. This bit is a 1
  1542. * when the checksum has already been fixed. If
  1543. * the checksum is still wrong and this bit is a
  1544. * 1, we need to return bad checksum. Otherwise,
  1545. * we need to set this bit to a 1 and update the
  1546. * checksum.
  1547. */
  1548. ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
  1549. if (ret_val)
  1550. return ret_val;
  1551. if (!(data & 0x8000)) {
  1552. data |= 0x8000;
  1553. ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
  1554. if (ret_val)
  1555. return ret_val;
  1556. ret_val = e1000e_update_nvm_checksum(hw);
  1557. }
  1558. }
  1559. return 0;
  1560. }
  1561. /**
  1562. * e1000_read_mac_addr_82571 - Read device MAC address
  1563. * @hw: pointer to the HW structure
  1564. **/
  1565. static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
  1566. {
  1567. s32 ret_val = 0;
  1568. if (hw->mac.type == e1000_82571) {
  1569. /*
  1570. * If there's an alternate MAC address place it in RAR0
  1571. * so that it will override the Si installed default perm
  1572. * address.
  1573. */
  1574. ret_val = e1000_check_alt_mac_addr_generic(hw);
  1575. if (ret_val)
  1576. goto out;
  1577. }
  1578. ret_val = e1000_read_mac_addr_generic(hw);
  1579. out:
  1580. return ret_val;
  1581. }
  1582. /**
  1583. * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
  1584. * @hw: pointer to the HW structure
  1585. *
  1586. * In the case of a PHY power down to save power, or to turn off link during a
  1587. * driver unload, or wake on lan is not enabled, remove the link.
  1588. **/
  1589. static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
  1590. {
  1591. struct e1000_phy_info *phy = &hw->phy;
  1592. struct e1000_mac_info *mac = &hw->mac;
  1593. if (!(phy->ops.check_reset_block))
  1594. return;
  1595. /* If the management interface is not enabled, then power down */
  1596. if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
  1597. e1000_power_down_phy_copper(hw);
  1598. }
  1599. /**
  1600. * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
  1601. * @hw: pointer to the HW structure
  1602. *
  1603. * Clears the hardware counters by reading the counter registers.
  1604. **/
  1605. static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
  1606. {
  1607. e1000e_clear_hw_cntrs_base(hw);
  1608. er32(PRC64);
  1609. er32(PRC127);
  1610. er32(PRC255);
  1611. er32(PRC511);
  1612. er32(PRC1023);
  1613. er32(PRC1522);
  1614. er32(PTC64);
  1615. er32(PTC127);
  1616. er32(PTC255);
  1617. er32(PTC511);
  1618. er32(PTC1023);
  1619. er32(PTC1522);
  1620. er32(ALGNERRC);
  1621. er32(RXERRC);
  1622. er32(TNCRS);
  1623. er32(CEXTERR);
  1624. er32(TSCTC);
  1625. er32(TSCTFC);
  1626. er32(MGTPRC);
  1627. er32(MGTPDC);
  1628. er32(MGTPTC);
  1629. er32(IAC);
  1630. er32(ICRXOC);
  1631. er32(ICRXPTC);
  1632. er32(ICRXATC);
  1633. er32(ICTXPTC);
  1634. er32(ICTXATC);
  1635. er32(ICTXQEC);
  1636. er32(ICTXQMTC);
  1637. er32(ICRXDMTC);
  1638. }
  1639. static struct e1000_mac_operations e82571_mac_ops = {
  1640. /* .check_mng_mode: mac type dependent */
  1641. /* .check_for_link: media type dependent */
  1642. .id_led_init = e1000e_id_led_init,
  1643. .cleanup_led = e1000e_cleanup_led_generic,
  1644. .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
  1645. .get_bus_info = e1000e_get_bus_info_pcie,
  1646. .set_lan_id = e1000_set_lan_id_multi_port_pcie,
  1647. /* .get_link_up_info: media type dependent */
  1648. /* .led_on: mac type dependent */
  1649. .led_off = e1000e_led_off_generic,
  1650. .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
  1651. .write_vfta = e1000_write_vfta_generic,
  1652. .clear_vfta = e1000_clear_vfta_82571,
  1653. .reset_hw = e1000_reset_hw_82571,
  1654. .init_hw = e1000_init_hw_82571,
  1655. .setup_link = e1000_setup_link_82571,
  1656. /* .setup_physical_interface: media type dependent */
  1657. .setup_led = e1000e_setup_led_generic,
  1658. .read_mac_addr = e1000_read_mac_addr_82571,
  1659. };
  1660. static struct e1000_phy_operations e82_phy_ops_igp = {
  1661. .acquire = e1000_get_hw_semaphore_82571,
  1662. .check_polarity = e1000_check_polarity_igp,
  1663. .check_reset_block = e1000e_check_reset_block_generic,
  1664. .commit = NULL,
  1665. .force_speed_duplex = e1000e_phy_force_speed_duplex_igp,
  1666. .get_cfg_done = e1000_get_cfg_done_82571,
  1667. .get_cable_length = e1000e_get_cable_length_igp_2,
  1668. .get_info = e1000e_get_phy_info_igp,
  1669. .read_reg = e1000e_read_phy_reg_igp,
  1670. .release = e1000_put_hw_semaphore_82571,
  1671. .reset = e1000e_phy_hw_reset_generic,
  1672. .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
  1673. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1674. .write_reg = e1000e_write_phy_reg_igp,
  1675. .cfg_on_link_up = NULL,
  1676. };
  1677. static struct e1000_phy_operations e82_phy_ops_m88 = {
  1678. .acquire = e1000_get_hw_semaphore_82571,
  1679. .check_polarity = e1000_check_polarity_m88,
  1680. .check_reset_block = e1000e_check_reset_block_generic,
  1681. .commit = e1000e_phy_sw_reset,
  1682. .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
  1683. .get_cfg_done = e1000e_get_cfg_done,
  1684. .get_cable_length = e1000e_get_cable_length_m88,
  1685. .get_info = e1000e_get_phy_info_m88,
  1686. .read_reg = e1000e_read_phy_reg_m88,
  1687. .release = e1000_put_hw_semaphore_82571,
  1688. .reset = e1000e_phy_hw_reset_generic,
  1689. .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
  1690. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1691. .write_reg = e1000e_write_phy_reg_m88,
  1692. .cfg_on_link_up = NULL,
  1693. };
  1694. static struct e1000_phy_operations e82_phy_ops_bm = {
  1695. .acquire = e1000_get_hw_semaphore_82571,
  1696. .check_polarity = e1000_check_polarity_m88,
  1697. .check_reset_block = e1000e_check_reset_block_generic,
  1698. .commit = e1000e_phy_sw_reset,
  1699. .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
  1700. .get_cfg_done = e1000e_get_cfg_done,
  1701. .get_cable_length = e1000e_get_cable_length_m88,
  1702. .get_info = e1000e_get_phy_info_m88,
  1703. .read_reg = e1000e_read_phy_reg_bm2,
  1704. .release = e1000_put_hw_semaphore_82571,
  1705. .reset = e1000e_phy_hw_reset_generic,
  1706. .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
  1707. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1708. .write_reg = e1000e_write_phy_reg_bm2,
  1709. .cfg_on_link_up = NULL,
  1710. };
  1711. static struct e1000_nvm_operations e82571_nvm_ops = {
  1712. .acquire = e1000_acquire_nvm_82571,
  1713. .read = e1000e_read_nvm_eerd,
  1714. .release = e1000_release_nvm_82571,
  1715. .update = e1000_update_nvm_checksum_82571,
  1716. .valid_led_default = e1000_valid_led_default_82571,
  1717. .validate = e1000_validate_nvm_checksum_82571,
  1718. .write = e1000_write_nvm_82571,
  1719. };
  1720. struct e1000_info e1000_82571_info = {
  1721. .mac = e1000_82571,
  1722. .flags = FLAG_HAS_HW_VLAN_FILTER
  1723. | FLAG_HAS_JUMBO_FRAMES
  1724. | FLAG_HAS_WOL
  1725. | FLAG_APME_IN_CTRL3
  1726. | FLAG_RX_CSUM_ENABLED
  1727. | FLAG_HAS_CTRLEXT_ON_LOAD
  1728. | FLAG_HAS_SMART_POWER_DOWN
  1729. | FLAG_RESET_OVERWRITES_LAA /* errata */
  1730. | FLAG_TARC_SPEED_MODE_BIT /* errata */
  1731. | FLAG_APME_CHECK_PORT_B,
  1732. .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
  1733. | FLAG2_DMA_BURST,
  1734. .pba = 38,
  1735. .max_hw_frame_size = DEFAULT_JUMBO,
  1736. .get_variants = e1000_get_variants_82571,
  1737. .mac_ops = &e82571_mac_ops,
  1738. .phy_ops = &e82_phy_ops_igp,
  1739. .nvm_ops = &e82571_nvm_ops,
  1740. };
  1741. struct e1000_info e1000_82572_info = {
  1742. .mac = e1000_82572,
  1743. .flags = FLAG_HAS_HW_VLAN_FILTER
  1744. | FLAG_HAS_JUMBO_FRAMES
  1745. | FLAG_HAS_WOL
  1746. | FLAG_APME_IN_CTRL3
  1747. | FLAG_RX_CSUM_ENABLED
  1748. | FLAG_HAS_CTRLEXT_ON_LOAD
  1749. | FLAG_TARC_SPEED_MODE_BIT, /* errata */
  1750. .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
  1751. | FLAG2_DMA_BURST,
  1752. .pba = 38,
  1753. .max_hw_frame_size = DEFAULT_JUMBO,
  1754. .get_variants = e1000_get_variants_82571,
  1755. .mac_ops = &e82571_mac_ops,
  1756. .phy_ops = &e82_phy_ops_igp,
  1757. .nvm_ops = &e82571_nvm_ops,
  1758. };
  1759. struct e1000_info e1000_82573_info = {
  1760. .mac = e1000_82573,
  1761. .flags = FLAG_HAS_HW_VLAN_FILTER
  1762. | FLAG_HAS_WOL
  1763. | FLAG_APME_IN_CTRL3
  1764. | FLAG_RX_CSUM_ENABLED
  1765. | FLAG_HAS_SMART_POWER_DOWN
  1766. | FLAG_HAS_AMT
  1767. | FLAG_HAS_SWSM_ON_LOAD,
  1768. .flags2 = FLAG2_DISABLE_ASPM_L1,
  1769. .pba = 20,
  1770. .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
  1771. .get_variants = e1000_get_variants_82571,
  1772. .mac_ops = &e82571_mac_ops,
  1773. .phy_ops = &e82_phy_ops_m88,
  1774. .nvm_ops = &e82571_nvm_ops,
  1775. };
  1776. struct e1000_info e1000_82574_info = {
  1777. .mac = e1000_82574,
  1778. .flags = FLAG_HAS_HW_VLAN_FILTER
  1779. | FLAG_HAS_MSIX
  1780. | FLAG_HAS_JUMBO_FRAMES
  1781. | FLAG_HAS_WOL
  1782. | FLAG_APME_IN_CTRL3
  1783. | FLAG_RX_CSUM_ENABLED
  1784. | FLAG_HAS_SMART_POWER_DOWN
  1785. | FLAG_HAS_AMT
  1786. | FLAG_HAS_CTRLEXT_ON_LOAD,
  1787. .flags2 = FLAG2_CHECK_PHY_HANG,
  1788. .pba = 36,
  1789. .max_hw_frame_size = DEFAULT_JUMBO,
  1790. .get_variants = e1000_get_variants_82571,
  1791. .mac_ops = &e82571_mac_ops,
  1792. .phy_ops = &e82_phy_ops_bm,
  1793. .nvm_ops = &e82571_nvm_ops,
  1794. };
  1795. struct e1000_info e1000_82583_info = {
  1796. .mac = e1000_82583,
  1797. .flags = FLAG_HAS_HW_VLAN_FILTER
  1798. | FLAG_HAS_WOL
  1799. | FLAG_APME_IN_CTRL3
  1800. | FLAG_RX_CSUM_ENABLED
  1801. | FLAG_HAS_SMART_POWER_DOWN
  1802. | FLAG_HAS_AMT
  1803. | FLAG_HAS_CTRLEXT_ON_LOAD,
  1804. .pba = 36,
  1805. .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
  1806. .get_variants = e1000_get_variants_82571,
  1807. .mac_ops = &e82571_mac_ops,
  1808. .phy_ops = &e82_phy_ops_bm,
  1809. .nvm_ops = &e82571_nvm_ops,
  1810. };