80003es2lan.c 38 KB

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