es2lan.c 35 KB

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