80003es2lan.c 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2013 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. /* 80003ES2LAN Gigabit Ethernet Controller (Copper)
  22. * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
  23. */
  24. #include "e1000.h"
  25. /* A table for the GG82563 cable length where the range is defined
  26. * with a lower bound at "index" and the upper bound at
  27. * "index + 5".
  28. */
  29. static const u16 e1000_gg82563_cable_length_table[] = {
  30. 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF
  31. };
  32. #define GG82563_CABLE_LENGTH_TABLE_SIZE \
  33. ARRAY_SIZE(e1000_gg82563_cable_length_table)
  34. static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
  35. static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
  36. static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
  37. static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
  38. static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
  39. static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
  40. static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
  41. static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  42. u16 *data);
  43. static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  44. u16 data);
  45. static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
  46. /**
  47. * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
  48. * @hw: pointer to the HW structure
  49. **/
  50. static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
  51. {
  52. struct e1000_phy_info *phy = &hw->phy;
  53. s32 ret_val;
  54. if (hw->phy.media_type != e1000_media_type_copper) {
  55. phy->type = e1000_phy_none;
  56. return 0;
  57. } else {
  58. phy->ops.power_up = e1000_power_up_phy_copper;
  59. phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
  60. }
  61. phy->addr = 1;
  62. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  63. phy->reset_delay_us = 100;
  64. phy->type = e1000_phy_gg82563;
  65. /* This can only be done after all function pointers are setup. */
  66. ret_val = e1000e_get_phy_id(hw);
  67. /* Verify phy id */
  68. if (phy->id != GG82563_E_PHY_ID)
  69. return -E1000_ERR_PHY;
  70. return ret_val;
  71. }
  72. /**
  73. * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
  74. * @hw: pointer to the HW structure
  75. **/
  76. static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
  77. {
  78. struct e1000_nvm_info *nvm = &hw->nvm;
  79. u32 eecd = er32(EECD);
  80. u16 size;
  81. nvm->opcode_bits = 8;
  82. nvm->delay_usec = 1;
  83. switch (nvm->override) {
  84. case e1000_nvm_override_spi_large:
  85. nvm->page_size = 32;
  86. nvm->address_bits = 16;
  87. break;
  88. case e1000_nvm_override_spi_small:
  89. nvm->page_size = 8;
  90. nvm->address_bits = 8;
  91. break;
  92. default:
  93. nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
  94. nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
  95. break;
  96. }
  97. nvm->type = e1000_nvm_eeprom_spi;
  98. size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
  99. E1000_EECD_SIZE_EX_SHIFT);
  100. /* Added to a constant, "size" becomes the left-shift value
  101. * for setting word_size.
  102. */
  103. size += NVM_WORD_SIZE_BASE_SHIFT;
  104. /* EEPROM access above 16k is unsupported */
  105. if (size > 14)
  106. size = 14;
  107. nvm->word_size = 1 << size;
  108. return 0;
  109. }
  110. /**
  111. * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
  112. * @hw: pointer to the HW structure
  113. **/
  114. static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
  115. {
  116. struct e1000_mac_info *mac = &hw->mac;
  117. /* Set media type and media-dependent function pointers */
  118. switch (hw->adapter->pdev->device) {
  119. case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
  120. hw->phy.media_type = e1000_media_type_internal_serdes;
  121. mac->ops.check_for_link = e1000e_check_for_serdes_link;
  122. mac->ops.setup_physical_interface =
  123. e1000e_setup_fiber_serdes_link;
  124. break;
  125. default:
  126. hw->phy.media_type = e1000_media_type_copper;
  127. mac->ops.check_for_link = e1000e_check_for_copper_link;
  128. mac->ops.setup_physical_interface =
  129. e1000_setup_copper_link_80003es2lan;
  130. break;
  131. }
  132. /* Set mta register count */
  133. mac->mta_reg_count = 128;
  134. /* Set rar entry count */
  135. mac->rar_entry_count = E1000_RAR_ENTRIES;
  136. /* FWSM register */
  137. mac->has_fwsm = true;
  138. /* ARC supported; valid only if manageability features are enabled. */
  139. mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
  140. /* Adaptive IFS not supported */
  141. mac->adaptive_ifs = false;
  142. /* set lan id for port to determine which phy lock to use */
  143. hw->mac.ops.set_lan_id(hw);
  144. return 0;
  145. }
  146. static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
  147. {
  148. struct e1000_hw *hw = &adapter->hw;
  149. s32 rc;
  150. rc = e1000_init_mac_params_80003es2lan(hw);
  151. if (rc)
  152. return rc;
  153. rc = e1000_init_nvm_params_80003es2lan(hw);
  154. if (rc)
  155. return rc;
  156. rc = e1000_init_phy_params_80003es2lan(hw);
  157. if (rc)
  158. return rc;
  159. return 0;
  160. }
  161. /**
  162. * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
  163. * @hw: pointer to the HW structure
  164. *
  165. * A wrapper to acquire access rights to the correct PHY.
  166. **/
  167. static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
  168. {
  169. u16 mask;
  170. mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
  171. return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
  172. }
  173. /**
  174. * e1000_release_phy_80003es2lan - Release rights to access PHY
  175. * @hw: pointer to the HW structure
  176. *
  177. * A wrapper to release access rights to the correct PHY.
  178. **/
  179. static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
  180. {
  181. u16 mask;
  182. mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
  183. e1000_release_swfw_sync_80003es2lan(hw, mask);
  184. }
  185. /**
  186. * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
  187. * @hw: pointer to the HW structure
  188. *
  189. * Acquire the semaphore to access the Kumeran interface.
  190. *
  191. **/
  192. static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
  193. {
  194. u16 mask;
  195. mask = E1000_SWFW_CSR_SM;
  196. return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
  197. }
  198. /**
  199. * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
  200. * @hw: pointer to the HW structure
  201. *
  202. * Release the semaphore used to access the Kumeran interface
  203. **/
  204. static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
  205. {
  206. u16 mask;
  207. mask = E1000_SWFW_CSR_SM;
  208. e1000_release_swfw_sync_80003es2lan(hw, mask);
  209. }
  210. /**
  211. * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
  212. * @hw: pointer to the HW structure
  213. *
  214. * Acquire the semaphore to access the EEPROM.
  215. **/
  216. static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
  217. {
  218. s32 ret_val;
  219. ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
  220. if (ret_val)
  221. return ret_val;
  222. ret_val = e1000e_acquire_nvm(hw);
  223. if (ret_val)
  224. e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
  225. return ret_val;
  226. }
  227. /**
  228. * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
  229. * @hw: pointer to the HW structure
  230. *
  231. * Release the semaphore used to access the EEPROM.
  232. **/
  233. static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
  234. {
  235. e1000e_release_nvm(hw);
  236. e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
  237. }
  238. /**
  239. * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
  240. * @hw: pointer to the HW structure
  241. * @mask: specifies which semaphore to acquire
  242. *
  243. * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
  244. * will also specify which port we're acquiring the lock for.
  245. **/
  246. static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
  247. {
  248. u32 swfw_sync;
  249. u32 swmask = mask;
  250. u32 fwmask = mask << 16;
  251. s32 i = 0;
  252. s32 timeout = 50;
  253. while (i < timeout) {
  254. if (e1000e_get_hw_semaphore(hw))
  255. return -E1000_ERR_SWFW_SYNC;
  256. swfw_sync = er32(SW_FW_SYNC);
  257. if (!(swfw_sync & (fwmask | swmask)))
  258. break;
  259. /* Firmware currently using resource (fwmask)
  260. * or other software thread using resource (swmask)
  261. */
  262. e1000e_put_hw_semaphore(hw);
  263. mdelay(5);
  264. i++;
  265. }
  266. if (i == timeout) {
  267. e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
  268. return -E1000_ERR_SWFW_SYNC;
  269. }
  270. swfw_sync |= swmask;
  271. ew32(SW_FW_SYNC, swfw_sync);
  272. e1000e_put_hw_semaphore(hw);
  273. return 0;
  274. }
  275. /**
  276. * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
  277. * @hw: pointer to the HW structure
  278. * @mask: specifies which semaphore to acquire
  279. *
  280. * Release the SW/FW semaphore used to access the PHY or NVM. The mask
  281. * will also specify which port we're releasing the lock for.
  282. **/
  283. static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
  284. {
  285. u32 swfw_sync;
  286. while (e1000e_get_hw_semaphore(hw) != 0)
  287. ; /* Empty */
  288. swfw_sync = er32(SW_FW_SYNC);
  289. swfw_sync &= ~mask;
  290. ew32(SW_FW_SYNC, swfw_sync);
  291. e1000e_put_hw_semaphore(hw);
  292. }
  293. /**
  294. * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
  295. * @hw: pointer to the HW structure
  296. * @offset: offset of the register to read
  297. * @data: pointer to the data returned from the operation
  298. *
  299. * Read the GG82563 PHY register.
  300. **/
  301. static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
  302. u32 offset, u16 *data)
  303. {
  304. s32 ret_val;
  305. u32 page_select;
  306. u16 temp;
  307. ret_val = e1000_acquire_phy_80003es2lan(hw);
  308. if (ret_val)
  309. return ret_val;
  310. /* Select Configuration Page */
  311. if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
  312. page_select = GG82563_PHY_PAGE_SELECT;
  313. } else {
  314. /* Use Alternative Page Select register to access
  315. * registers 30 and 31
  316. */
  317. page_select = GG82563_PHY_PAGE_SELECT_ALT;
  318. }
  319. temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
  320. ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
  321. if (ret_val) {
  322. e1000_release_phy_80003es2lan(hw);
  323. return ret_val;
  324. }
  325. if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
  326. /* The "ready" bit in the MDIC register may be incorrectly set
  327. * before the device has completed the "Page Select" MDI
  328. * transaction. So we wait 200us after each MDI command...
  329. */
  330. usleep_range(200, 400);
  331. /* ...and verify the command was successful. */
  332. ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
  333. if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
  334. e1000_release_phy_80003es2lan(hw);
  335. return -E1000_ERR_PHY;
  336. }
  337. usleep_range(200, 400);
  338. ret_val = e1000e_read_phy_reg_mdic(hw,
  339. MAX_PHY_REG_ADDRESS & offset,
  340. data);
  341. usleep_range(200, 400);
  342. } else {
  343. ret_val = e1000e_read_phy_reg_mdic(hw,
  344. MAX_PHY_REG_ADDRESS & offset,
  345. data);
  346. }
  347. e1000_release_phy_80003es2lan(hw);
  348. return ret_val;
  349. }
  350. /**
  351. * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
  352. * @hw: pointer to the HW structure
  353. * @offset: offset of the register to read
  354. * @data: value to write to the register
  355. *
  356. * Write to the GG82563 PHY register.
  357. **/
  358. static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
  359. u32 offset, u16 data)
  360. {
  361. s32 ret_val;
  362. u32 page_select;
  363. u16 temp;
  364. ret_val = e1000_acquire_phy_80003es2lan(hw);
  365. if (ret_val)
  366. return ret_val;
  367. /* Select Configuration Page */
  368. if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
  369. page_select = GG82563_PHY_PAGE_SELECT;
  370. } else {
  371. /* Use Alternative Page Select register to access
  372. * registers 30 and 31
  373. */
  374. page_select = GG82563_PHY_PAGE_SELECT_ALT;
  375. }
  376. temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
  377. ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
  378. if (ret_val) {
  379. e1000_release_phy_80003es2lan(hw);
  380. return ret_val;
  381. }
  382. if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
  383. /* The "ready" bit in the MDIC register may be incorrectly set
  384. * before the device has completed the "Page Select" MDI
  385. * transaction. So we wait 200us after each MDI command...
  386. */
  387. usleep_range(200, 400);
  388. /* ...and verify the command was successful. */
  389. ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
  390. if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
  391. e1000_release_phy_80003es2lan(hw);
  392. return -E1000_ERR_PHY;
  393. }
  394. usleep_range(200, 400);
  395. ret_val = e1000e_write_phy_reg_mdic(hw,
  396. MAX_PHY_REG_ADDRESS &
  397. offset, data);
  398. usleep_range(200, 400);
  399. } else {
  400. ret_val = e1000e_write_phy_reg_mdic(hw,
  401. MAX_PHY_REG_ADDRESS &
  402. offset, data);
  403. }
  404. e1000_release_phy_80003es2lan(hw);
  405. return ret_val;
  406. }
  407. /**
  408. * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
  409. * @hw: pointer to the HW structure
  410. * @offset: offset of the register to read
  411. * @words: number of words to write
  412. * @data: buffer of data to write to the NVM
  413. *
  414. * Write "words" of data to the ESB2 NVM.
  415. **/
  416. static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
  417. u16 words, u16 *data)
  418. {
  419. return e1000e_write_nvm_spi(hw, offset, words, data);
  420. }
  421. /**
  422. * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
  423. * @hw: pointer to the HW structure
  424. *
  425. * Wait a specific amount of time for manageability processes to complete.
  426. * This is a function pointer entry point called by the phy module.
  427. **/
  428. static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
  429. {
  430. s32 timeout = PHY_CFG_TIMEOUT;
  431. u32 mask = E1000_NVM_CFG_DONE_PORT_0;
  432. if (hw->bus.func == 1)
  433. mask = E1000_NVM_CFG_DONE_PORT_1;
  434. while (timeout) {
  435. if (er32(EEMNGCTL) & mask)
  436. break;
  437. usleep_range(1000, 2000);
  438. timeout--;
  439. }
  440. if (!timeout) {
  441. e_dbg("MNG configuration cycle has not completed.\n");
  442. return -E1000_ERR_RESET;
  443. }
  444. return 0;
  445. }
  446. /**
  447. * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
  448. * @hw: pointer to the HW structure
  449. *
  450. * Force the speed and duplex settings onto the PHY. This is a
  451. * function pointer entry point called by the phy module.
  452. **/
  453. static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
  454. {
  455. s32 ret_val;
  456. u16 phy_data;
  457. bool link;
  458. /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
  459. * forced whenever speed and duplex are forced.
  460. */
  461. ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
  462. if (ret_val)
  463. return ret_val;
  464. phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
  465. ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
  466. if (ret_val)
  467. return ret_val;
  468. e_dbg("GG82563 PSCR: %X\n", phy_data);
  469. ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);
  470. if (ret_val)
  471. return ret_val;
  472. e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
  473. /* Reset the phy to commit changes. */
  474. phy_data |= BMCR_RESET;
  475. ret_val = e1e_wphy(hw, MII_BMCR, phy_data);
  476. if (ret_val)
  477. return ret_val;
  478. udelay(1);
  479. if (hw->phy.autoneg_wait_to_complete) {
  480. e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
  481. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  482. 100000, &link);
  483. if (ret_val)
  484. return ret_val;
  485. if (!link) {
  486. /* We didn't get link.
  487. * Reset the DSP and cross our fingers.
  488. */
  489. ret_val = e1000e_phy_reset_dsp(hw);
  490. if (ret_val)
  491. return ret_val;
  492. }
  493. /* Try once more */
  494. ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
  495. 100000, &link);
  496. if (ret_val)
  497. return ret_val;
  498. }
  499. ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
  500. if (ret_val)
  501. return ret_val;
  502. /* Resetting the phy means we need to verify the TX_CLK corresponds
  503. * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
  504. */
  505. phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
  506. if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
  507. phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
  508. else
  509. phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
  510. /* In addition, we must re-enable CRS on Tx for both half and full
  511. * duplex.
  512. */
  513. phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
  514. ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
  515. return ret_val;
  516. }
  517. /**
  518. * e1000_get_cable_length_80003es2lan - Set approximate cable length
  519. * @hw: pointer to the HW structure
  520. *
  521. * Find the approximate cable length as measured by the GG82563 PHY.
  522. * This is a function pointer entry point called by the phy module.
  523. **/
  524. static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
  525. {
  526. struct e1000_phy_info *phy = &hw->phy;
  527. s32 ret_val;
  528. u16 phy_data, index;
  529. ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
  530. if (ret_val)
  531. return ret_val;
  532. index = phy_data & GG82563_DSPD_CABLE_LENGTH;
  533. if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
  534. return -E1000_ERR_PHY;
  535. phy->min_cable_length = e1000_gg82563_cable_length_table[index];
  536. phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
  537. phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
  538. return 0;
  539. }
  540. /**
  541. * e1000_get_link_up_info_80003es2lan - Report speed and duplex
  542. * @hw: pointer to the HW structure
  543. * @speed: pointer to speed buffer
  544. * @duplex: pointer to duplex buffer
  545. *
  546. * Retrieve the current speed and duplex configuration.
  547. **/
  548. static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
  549. u16 *duplex)
  550. {
  551. s32 ret_val;
  552. if (hw->phy.media_type == e1000_media_type_copper) {
  553. ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
  554. hw->phy.ops.cfg_on_link_up(hw);
  555. } else {
  556. ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
  557. speed,
  558. duplex);
  559. }
  560. return ret_val;
  561. }
  562. /**
  563. * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
  564. * @hw: pointer to the HW structure
  565. *
  566. * Perform a global reset to the ESB2 controller.
  567. **/
  568. static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
  569. {
  570. u32 ctrl;
  571. s32 ret_val;
  572. u16 kum_reg_data;
  573. /* Prevent the PCI-E bus from sticking if there is no TLP connection
  574. * on the last TLP read/write transaction when MAC is reset.
  575. */
  576. ret_val = e1000e_disable_pcie_master(hw);
  577. if (ret_val)
  578. e_dbg("PCI-E Master disable polling has failed.\n");
  579. e_dbg("Masking off all interrupts\n");
  580. ew32(IMC, 0xffffffff);
  581. ew32(RCTL, 0);
  582. ew32(TCTL, E1000_TCTL_PSP);
  583. e1e_flush();
  584. usleep_range(10000, 20000);
  585. ctrl = er32(CTRL);
  586. ret_val = e1000_acquire_phy_80003es2lan(hw);
  587. if (ret_val)
  588. return ret_val;
  589. e_dbg("Issuing a global reset to MAC\n");
  590. ew32(CTRL, ctrl | E1000_CTRL_RST);
  591. e1000_release_phy_80003es2lan(hw);
  592. /* Disable IBIST slave mode (far-end loopback) */
  593. e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  594. &kum_reg_data);
  595. kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
  596. e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  597. kum_reg_data);
  598. ret_val = e1000e_get_auto_rd_done(hw);
  599. if (ret_val)
  600. /* We don't want to continue accessing MAC registers. */
  601. return ret_val;
  602. /* Clear any pending interrupt events. */
  603. ew32(IMC, 0xffffffff);
  604. er32(ICR);
  605. return e1000_check_alt_mac_addr_generic(hw);
  606. }
  607. /**
  608. * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
  609. * @hw: pointer to the HW structure
  610. *
  611. * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
  612. **/
  613. static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
  614. {
  615. struct e1000_mac_info *mac = &hw->mac;
  616. u32 reg_data;
  617. s32 ret_val;
  618. u16 kum_reg_data;
  619. u16 i;
  620. e1000_initialize_hw_bits_80003es2lan(hw);
  621. /* Initialize identification LED */
  622. ret_val = mac->ops.id_led_init(hw);
  623. /* An error is not fatal and we should not stop init due to this */
  624. if (ret_val)
  625. e_dbg("Error initializing identification LED\n");
  626. /* Disabling VLAN filtering */
  627. e_dbg("Initializing the IEEE VLAN\n");
  628. mac->ops.clear_vfta(hw);
  629. /* Setup the receive address. */
  630. e1000e_init_rx_addrs(hw, mac->rar_entry_count);
  631. /* Zero out the Multicast HASH table */
  632. e_dbg("Zeroing the MTA\n");
  633. for (i = 0; i < mac->mta_reg_count; i++)
  634. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  635. /* Setup link and flow control */
  636. ret_val = mac->ops.setup_link(hw);
  637. if (ret_val)
  638. return ret_val;
  639. /* Disable IBIST slave mode (far-end loopback) */
  640. e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  641. &kum_reg_data);
  642. kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
  643. e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  644. kum_reg_data);
  645. /* Set the transmit descriptor write-back policy */
  646. reg_data = er32(TXDCTL(0));
  647. reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
  648. E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
  649. ew32(TXDCTL(0), reg_data);
  650. /* ...for both queues. */
  651. reg_data = er32(TXDCTL(1));
  652. reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
  653. E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
  654. ew32(TXDCTL(1), reg_data);
  655. /* Enable retransmit on late collisions */
  656. reg_data = er32(TCTL);
  657. reg_data |= E1000_TCTL_RTLC;
  658. ew32(TCTL, reg_data);
  659. /* Configure Gigabit Carry Extend Padding */
  660. reg_data = er32(TCTL_EXT);
  661. reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
  662. reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
  663. ew32(TCTL_EXT, reg_data);
  664. /* Configure Transmit Inter-Packet Gap */
  665. reg_data = er32(TIPG);
  666. reg_data &= ~E1000_TIPG_IPGT_MASK;
  667. reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
  668. ew32(TIPG, reg_data);
  669. reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
  670. reg_data &= ~0x00100000;
  671. E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
  672. /* default to true to enable the MDIC W/A */
  673. hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
  674. ret_val =
  675. e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
  676. E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
  677. if (!ret_val) {
  678. if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
  679. E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
  680. hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
  681. }
  682. /* Clear all of the statistics registers (clear on read). It is
  683. * important that we do this after we have tried to establish link
  684. * because the symbol error count will increment wildly if there
  685. * is no link.
  686. */
  687. e1000_clear_hw_cntrs_80003es2lan(hw);
  688. return ret_val;
  689. }
  690. /**
  691. * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
  692. * @hw: pointer to the HW structure
  693. *
  694. * Initializes required hardware-dependent bits needed for normal operation.
  695. **/
  696. static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
  697. {
  698. u32 reg;
  699. /* Transmit Descriptor Control 0 */
  700. reg = er32(TXDCTL(0));
  701. reg |= (1 << 22);
  702. ew32(TXDCTL(0), reg);
  703. /* Transmit Descriptor Control 1 */
  704. reg = er32(TXDCTL(1));
  705. reg |= (1 << 22);
  706. ew32(TXDCTL(1), reg);
  707. /* Transmit Arbitration Control 0 */
  708. reg = er32(TARC(0));
  709. reg &= ~(0xF << 27); /* 30:27 */
  710. if (hw->phy.media_type != e1000_media_type_copper)
  711. reg &= ~(1 << 20);
  712. ew32(TARC(0), reg);
  713. /* Transmit Arbitration Control 1 */
  714. reg = er32(TARC(1));
  715. if (er32(TCTL) & E1000_TCTL_MULR)
  716. reg &= ~(1 << 28);
  717. else
  718. reg |= (1 << 28);
  719. ew32(TARC(1), reg);
  720. /* Disable IPv6 extension header parsing because some malformed
  721. * IPv6 headers can hang the Rx.
  722. */
  723. reg = er32(RFCTL);
  724. reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
  725. ew32(RFCTL, reg);
  726. }
  727. /**
  728. * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
  729. * @hw: pointer to the HW structure
  730. *
  731. * Setup some GG82563 PHY registers for obtaining link
  732. **/
  733. static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
  734. {
  735. struct e1000_phy_info *phy = &hw->phy;
  736. s32 ret_val;
  737. u32 reg;
  738. u16 data;
  739. ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
  740. if (ret_val)
  741. return ret_val;
  742. data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
  743. /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
  744. data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
  745. ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
  746. if (ret_val)
  747. return ret_val;
  748. /* Options:
  749. * MDI/MDI-X = 0 (default)
  750. * 0 - Auto for all speeds
  751. * 1 - MDI mode
  752. * 2 - MDI-X mode
  753. * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  754. */
  755. ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
  756. if (ret_val)
  757. return ret_val;
  758. data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
  759. switch (phy->mdix) {
  760. case 1:
  761. data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
  762. break;
  763. case 2:
  764. data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
  765. break;
  766. case 0:
  767. default:
  768. data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
  769. break;
  770. }
  771. /* Options:
  772. * disable_polarity_correction = 0 (default)
  773. * Automatic Correction for Reversed Cable Polarity
  774. * 0 - Disabled
  775. * 1 - Enabled
  776. */
  777. data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
  778. if (phy->disable_polarity_correction)
  779. data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
  780. ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
  781. if (ret_val)
  782. return ret_val;
  783. /* SW Reset the PHY so all changes take effect */
  784. ret_val = hw->phy.ops.commit(hw);
  785. if (ret_val) {
  786. e_dbg("Error Resetting the PHY\n");
  787. return ret_val;
  788. }
  789. /* Bypass Rx and Tx FIFO's */
  790. reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
  791. data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
  792. E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
  793. ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
  794. if (ret_val)
  795. return ret_val;
  796. reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
  797. ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
  798. if (ret_val)
  799. return ret_val;
  800. data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
  801. ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
  802. if (ret_val)
  803. return ret_val;
  804. ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
  805. if (ret_val)
  806. return ret_val;
  807. data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
  808. ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
  809. if (ret_val)
  810. return ret_val;
  811. reg = er32(CTRL_EXT);
  812. reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
  813. ew32(CTRL_EXT, reg);
  814. ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
  815. if (ret_val)
  816. return ret_val;
  817. /* Do not init these registers when the HW is in IAMT mode, since the
  818. * firmware will have already initialized them. We only initialize
  819. * them if the HW is not in IAMT mode.
  820. */
  821. if (!hw->mac.ops.check_mng_mode(hw)) {
  822. /* Enable Electrical Idle on the PHY */
  823. data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
  824. ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
  825. if (ret_val)
  826. return ret_val;
  827. ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
  828. if (ret_val)
  829. return ret_val;
  830. data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
  831. ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
  832. if (ret_val)
  833. return ret_val;
  834. }
  835. /* Workaround: Disable padding in Kumeran interface in the MAC
  836. * and in the PHY to avoid CRC errors.
  837. */
  838. ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
  839. if (ret_val)
  840. return ret_val;
  841. data |= GG82563_ICR_DIS_PADDING;
  842. ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
  843. if (ret_val)
  844. return ret_val;
  845. return 0;
  846. }
  847. /**
  848. * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
  849. * @hw: pointer to the HW structure
  850. *
  851. * Essentially a wrapper for setting up all things "copper" related.
  852. * This is a function pointer entry point called by the mac module.
  853. **/
  854. static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
  855. {
  856. u32 ctrl;
  857. s32 ret_val;
  858. u16 reg_data;
  859. ctrl = er32(CTRL);
  860. ctrl |= E1000_CTRL_SLU;
  861. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  862. ew32(CTRL, ctrl);
  863. /* Set the mac to wait the maximum time between each
  864. * iteration and increase the max iterations when
  865. * polling the phy; this fixes erroneous timeouts at 10Mbps.
  866. */
  867. ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
  868. 0xFFFF);
  869. if (ret_val)
  870. return ret_val;
  871. ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
  872. &reg_data);
  873. if (ret_val)
  874. return ret_val;
  875. reg_data |= 0x3F;
  876. ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
  877. reg_data);
  878. if (ret_val)
  879. return ret_val;
  880. ret_val =
  881. e1000_read_kmrn_reg_80003es2lan(hw,
  882. E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
  883. &reg_data);
  884. if (ret_val)
  885. return ret_val;
  886. reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
  887. ret_val =
  888. e1000_write_kmrn_reg_80003es2lan(hw,
  889. E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
  890. reg_data);
  891. if (ret_val)
  892. return ret_val;
  893. ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
  894. if (ret_val)
  895. return ret_val;
  896. return e1000e_setup_copper_link(hw);
  897. }
  898. /**
  899. * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
  900. * @hw: pointer to the HW structure
  901. * @duplex: current duplex setting
  902. *
  903. * Configure the KMRN interface by applying last minute quirks for
  904. * 10/100 operation.
  905. **/
  906. static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
  907. {
  908. s32 ret_val = 0;
  909. u16 speed;
  910. u16 duplex;
  911. if (hw->phy.media_type == e1000_media_type_copper) {
  912. ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
  913. &duplex);
  914. if (ret_val)
  915. return ret_val;
  916. if (speed == SPEED_1000)
  917. ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
  918. else
  919. ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
  920. }
  921. return ret_val;
  922. }
  923. /**
  924. * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
  925. * @hw: pointer to the HW structure
  926. * @duplex: current duplex setting
  927. *
  928. * Configure the KMRN interface by applying last minute quirks for
  929. * 10/100 operation.
  930. **/
  931. static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
  932. {
  933. s32 ret_val;
  934. u32 tipg;
  935. u32 i = 0;
  936. u16 reg_data, reg_data2;
  937. reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
  938. ret_val =
  939. e1000_write_kmrn_reg_80003es2lan(hw,
  940. E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
  941. reg_data);
  942. if (ret_val)
  943. return ret_val;
  944. /* Configure Transmit Inter-Packet Gap */
  945. tipg = er32(TIPG);
  946. tipg &= ~E1000_TIPG_IPGT_MASK;
  947. tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
  948. ew32(TIPG, tipg);
  949. do {
  950. ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
  951. if (ret_val)
  952. return ret_val;
  953. ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
  954. if (ret_val)
  955. return ret_val;
  956. i++;
  957. } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
  958. if (duplex == HALF_DUPLEX)
  959. reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
  960. else
  961. reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
  962. return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
  963. }
  964. /**
  965. * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
  966. * @hw: pointer to the HW structure
  967. *
  968. * Configure the KMRN interface by applying last minute quirks for
  969. * gigabit operation.
  970. **/
  971. static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
  972. {
  973. s32 ret_val;
  974. u16 reg_data, reg_data2;
  975. u32 tipg;
  976. u32 i = 0;
  977. reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
  978. ret_val =
  979. e1000_write_kmrn_reg_80003es2lan(hw,
  980. E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
  981. reg_data);
  982. if (ret_val)
  983. return ret_val;
  984. /* Configure Transmit Inter-Packet Gap */
  985. tipg = er32(TIPG);
  986. tipg &= ~E1000_TIPG_IPGT_MASK;
  987. tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
  988. ew32(TIPG, tipg);
  989. do {
  990. ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
  991. if (ret_val)
  992. return ret_val;
  993. ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
  994. if (ret_val)
  995. return ret_val;
  996. i++;
  997. } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
  998. reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
  999. return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
  1000. }
  1001. /**
  1002. * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
  1003. * @hw: pointer to the HW structure
  1004. * @offset: register offset to be read
  1005. * @data: pointer to the read data
  1006. *
  1007. * Acquire semaphore, then read the PHY register at offset
  1008. * using the kumeran interface. The information retrieved is stored in data.
  1009. * Release the semaphore before exiting.
  1010. **/
  1011. static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  1012. u16 *data)
  1013. {
  1014. u32 kmrnctrlsta;
  1015. s32 ret_val;
  1016. ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
  1017. if (ret_val)
  1018. return ret_val;
  1019. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  1020. E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
  1021. ew32(KMRNCTRLSTA, kmrnctrlsta);
  1022. e1e_flush();
  1023. udelay(2);
  1024. kmrnctrlsta = er32(KMRNCTRLSTA);
  1025. *data = (u16)kmrnctrlsta;
  1026. e1000_release_mac_csr_80003es2lan(hw);
  1027. return ret_val;
  1028. }
  1029. /**
  1030. * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
  1031. * @hw: pointer to the HW structure
  1032. * @offset: register offset to write to
  1033. * @data: data to write at register offset
  1034. *
  1035. * Acquire semaphore, then write the data to PHY register
  1036. * at the offset using the kumeran interface. Release semaphore
  1037. * before exiting.
  1038. **/
  1039. static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  1040. u16 data)
  1041. {
  1042. u32 kmrnctrlsta;
  1043. s32 ret_val;
  1044. ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
  1045. if (ret_val)
  1046. return ret_val;
  1047. kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
  1048. E1000_KMRNCTRLSTA_OFFSET) | data;
  1049. ew32(KMRNCTRLSTA, kmrnctrlsta);
  1050. e1e_flush();
  1051. udelay(2);
  1052. e1000_release_mac_csr_80003es2lan(hw);
  1053. return ret_val;
  1054. }
  1055. /**
  1056. * e1000_read_mac_addr_80003es2lan - Read device MAC address
  1057. * @hw: pointer to the HW structure
  1058. **/
  1059. static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
  1060. {
  1061. s32 ret_val;
  1062. /* If there's an alternate MAC address place it in RAR0
  1063. * so that it will override the Si installed default perm
  1064. * address.
  1065. */
  1066. ret_val = e1000_check_alt_mac_addr_generic(hw);
  1067. if (ret_val)
  1068. return ret_val;
  1069. return e1000_read_mac_addr_generic(hw);
  1070. }
  1071. /**
  1072. * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
  1073. * @hw: pointer to the HW structure
  1074. *
  1075. * In the case of a PHY power down to save power, or to turn off link during a
  1076. * driver unload, or wake on lan is not enabled, remove the link.
  1077. **/
  1078. static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
  1079. {
  1080. /* If the management interface is not enabled, then power down */
  1081. if (!(hw->mac.ops.check_mng_mode(hw) ||
  1082. hw->phy.ops.check_reset_block(hw)))
  1083. e1000_power_down_phy_copper(hw);
  1084. }
  1085. /**
  1086. * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
  1087. * @hw: pointer to the HW structure
  1088. *
  1089. * Clears the hardware counters by reading the counter registers.
  1090. **/
  1091. static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
  1092. {
  1093. e1000e_clear_hw_cntrs_base(hw);
  1094. er32(PRC64);
  1095. er32(PRC127);
  1096. er32(PRC255);
  1097. er32(PRC511);
  1098. er32(PRC1023);
  1099. er32(PRC1522);
  1100. er32(PTC64);
  1101. er32(PTC127);
  1102. er32(PTC255);
  1103. er32(PTC511);
  1104. er32(PTC1023);
  1105. er32(PTC1522);
  1106. er32(ALGNERRC);
  1107. er32(RXERRC);
  1108. er32(TNCRS);
  1109. er32(CEXTERR);
  1110. er32(TSCTC);
  1111. er32(TSCTFC);
  1112. er32(MGTPRC);
  1113. er32(MGTPDC);
  1114. er32(MGTPTC);
  1115. er32(IAC);
  1116. er32(ICRXOC);
  1117. er32(ICRXPTC);
  1118. er32(ICRXATC);
  1119. er32(ICTXPTC);
  1120. er32(ICTXATC);
  1121. er32(ICTXQEC);
  1122. er32(ICTXQMTC);
  1123. er32(ICRXDMTC);
  1124. }
  1125. static const struct e1000_mac_operations es2_mac_ops = {
  1126. .read_mac_addr = e1000_read_mac_addr_80003es2lan,
  1127. .id_led_init = e1000e_id_led_init_generic,
  1128. .blink_led = e1000e_blink_led_generic,
  1129. .check_mng_mode = e1000e_check_mng_mode_generic,
  1130. /* check_for_link dependent on media type */
  1131. .cleanup_led = e1000e_cleanup_led_generic,
  1132. .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
  1133. .get_bus_info = e1000e_get_bus_info_pcie,
  1134. .set_lan_id = e1000_set_lan_id_multi_port_pcie,
  1135. .get_link_up_info = e1000_get_link_up_info_80003es2lan,
  1136. .led_on = e1000e_led_on_generic,
  1137. .led_off = e1000e_led_off_generic,
  1138. .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
  1139. .write_vfta = e1000_write_vfta_generic,
  1140. .clear_vfta = e1000_clear_vfta_generic,
  1141. .reset_hw = e1000_reset_hw_80003es2lan,
  1142. .init_hw = e1000_init_hw_80003es2lan,
  1143. .setup_link = e1000e_setup_link_generic,
  1144. /* setup_physical_interface dependent on media type */
  1145. .setup_led = e1000e_setup_led_generic,
  1146. .config_collision_dist = e1000e_config_collision_dist_generic,
  1147. .rar_set = e1000e_rar_set_generic,
  1148. };
  1149. static const struct e1000_phy_operations es2_phy_ops = {
  1150. .acquire = e1000_acquire_phy_80003es2lan,
  1151. .check_polarity = e1000_check_polarity_m88,
  1152. .check_reset_block = e1000e_check_reset_block_generic,
  1153. .commit = e1000e_phy_sw_reset,
  1154. .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
  1155. .get_cfg_done = e1000_get_cfg_done_80003es2lan,
  1156. .get_cable_length = e1000_get_cable_length_80003es2lan,
  1157. .get_info = e1000e_get_phy_info_m88,
  1158. .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
  1159. .release = e1000_release_phy_80003es2lan,
  1160. .reset = e1000e_phy_hw_reset_generic,
  1161. .set_d0_lplu_state = NULL,
  1162. .set_d3_lplu_state = e1000e_set_d3_lplu_state,
  1163. .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
  1164. .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
  1165. };
  1166. static const struct e1000_nvm_operations es2_nvm_ops = {
  1167. .acquire = e1000_acquire_nvm_80003es2lan,
  1168. .read = e1000e_read_nvm_eerd,
  1169. .release = e1000_release_nvm_80003es2lan,
  1170. .reload = e1000e_reload_nvm_generic,
  1171. .update = e1000e_update_nvm_checksum_generic,
  1172. .valid_led_default = e1000e_valid_led_default,
  1173. .validate = e1000e_validate_nvm_checksum_generic,
  1174. .write = e1000_write_nvm_80003es2lan,
  1175. };
  1176. const struct e1000_info e1000_es2_info = {
  1177. .mac = e1000_80003es2lan,
  1178. .flags = FLAG_HAS_HW_VLAN_FILTER
  1179. | FLAG_HAS_JUMBO_FRAMES
  1180. | FLAG_HAS_WOL
  1181. | FLAG_APME_IN_CTRL3
  1182. | FLAG_HAS_CTRLEXT_ON_LOAD
  1183. | FLAG_RX_NEEDS_RESTART /* errata */
  1184. | FLAG_TARC_SET_BIT_ZERO /* errata */
  1185. | FLAG_APME_CHECK_PORT_B
  1186. | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
  1187. .flags2 = FLAG2_DMA_BURST,
  1188. .pba = 38,
  1189. .max_hw_frame_size = DEFAULT_JUMBO,
  1190. .get_variants = e1000_get_variants_80003es2lan,
  1191. .mac_ops = &es2_mac_ops,
  1192. .phy_ops = &es2_phy_ops,
  1193. .nvm_ops = &es2_nvm_ops,
  1194. };