e1000_82575.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. /*******************************************************************************
  2. Intel(R) Gigabit Ethernet Linux driver
  3. Copyright(c) 2007 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. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. /* e1000_82575
  21. * e1000_82576
  22. */
  23. #include <linux/types.h>
  24. #include <linux/slab.h>
  25. #include "e1000_mac.h"
  26. #include "e1000_82575.h"
  27. static s32 igb_get_invariants_82575(struct e1000_hw *);
  28. static s32 igb_acquire_phy_82575(struct e1000_hw *);
  29. static void igb_release_phy_82575(struct e1000_hw *);
  30. static s32 igb_acquire_nvm_82575(struct e1000_hw *);
  31. static void igb_release_nvm_82575(struct e1000_hw *);
  32. static s32 igb_check_for_link_82575(struct e1000_hw *);
  33. static s32 igb_get_cfg_done_82575(struct e1000_hw *);
  34. static s32 igb_init_hw_82575(struct e1000_hw *);
  35. static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *);
  36. static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *);
  37. static void igb_rar_set_82575(struct e1000_hw *, u8 *, u32);
  38. static s32 igb_reset_hw_82575(struct e1000_hw *);
  39. static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
  40. static s32 igb_setup_copper_link_82575(struct e1000_hw *);
  41. static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *);
  42. static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16);
  43. static void igb_clear_hw_cntrs_82575(struct e1000_hw *);
  44. static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16);
  45. static s32 igb_configure_pcs_link_82575(struct e1000_hw *);
  46. static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *,
  47. u16 *);
  48. static s32 igb_get_phy_id_82575(struct e1000_hw *);
  49. static void igb_release_swfw_sync_82575(struct e1000_hw *, u16);
  50. static bool igb_sgmii_active_82575(struct e1000_hw *);
  51. static s32 igb_reset_init_script_82575(struct e1000_hw *);
  52. static s32 igb_read_mac_addr_82575(struct e1000_hw *);
  53. struct e1000_dev_spec_82575 {
  54. bool sgmii_active;
  55. };
  56. static s32 igb_get_invariants_82575(struct e1000_hw *hw)
  57. {
  58. struct e1000_phy_info *phy = &hw->phy;
  59. struct e1000_nvm_info *nvm = &hw->nvm;
  60. struct e1000_mac_info *mac = &hw->mac;
  61. struct e1000_dev_spec_82575 *dev_spec;
  62. u32 eecd;
  63. s32 ret_val;
  64. u16 size;
  65. u32 ctrl_ext = 0;
  66. switch (hw->device_id) {
  67. case E1000_DEV_ID_82575EB_COPPER:
  68. case E1000_DEV_ID_82575EB_FIBER_SERDES:
  69. case E1000_DEV_ID_82575GB_QUAD_COPPER:
  70. mac->type = e1000_82575;
  71. break;
  72. default:
  73. return -E1000_ERR_MAC_INIT;
  74. break;
  75. }
  76. /* MAC initialization */
  77. hw->dev_spec_size = sizeof(struct e1000_dev_spec_82575);
  78. /* Device-specific structure allocation */
  79. hw->dev_spec = kzalloc(hw->dev_spec_size, GFP_KERNEL);
  80. if (!hw->dev_spec)
  81. return -ENOMEM;
  82. dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
  83. /* Set media type */
  84. /*
  85. * The 82575 uses bits 22:23 for link mode. The mode can be changed
  86. * based on the EEPROM. We cannot rely upon device ID. There
  87. * is no distinguishable difference between fiber and internal
  88. * SerDes mode on the 82575. There can be an external PHY attached
  89. * on the SGMII interface. For this, we'll set sgmii_active to true.
  90. */
  91. phy->media_type = e1000_media_type_copper;
  92. dev_spec->sgmii_active = false;
  93. ctrl_ext = rd32(E1000_CTRL_EXT);
  94. if ((ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) ==
  95. E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES) {
  96. hw->phy.media_type = e1000_media_type_internal_serdes;
  97. ctrl_ext |= E1000_CTRL_I2C_ENA;
  98. } else if (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_SGMII) {
  99. dev_spec->sgmii_active = true;
  100. ctrl_ext |= E1000_CTRL_I2C_ENA;
  101. } else {
  102. ctrl_ext &= ~E1000_CTRL_I2C_ENA;
  103. }
  104. wr32(E1000_CTRL_EXT, ctrl_ext);
  105. /* Set mta register count */
  106. mac->mta_reg_count = 128;
  107. /* Set rar entry count */
  108. mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
  109. /* Set if part includes ASF firmware */
  110. mac->asf_firmware_present = true;
  111. /* Set if manageability features are enabled. */
  112. mac->arc_subsystem_valid =
  113. (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK)
  114. ? true : false;
  115. /* physical interface link setup */
  116. mac->ops.setup_physical_interface =
  117. (hw->phy.media_type == e1000_media_type_copper)
  118. ? igb_setup_copper_link_82575
  119. : igb_setup_fiber_serdes_link_82575;
  120. /* NVM initialization */
  121. eecd = rd32(E1000_EECD);
  122. nvm->opcode_bits = 8;
  123. nvm->delay_usec = 1;
  124. switch (nvm->override) {
  125. case e1000_nvm_override_spi_large:
  126. nvm->page_size = 32;
  127. nvm->address_bits = 16;
  128. break;
  129. case e1000_nvm_override_spi_small:
  130. nvm->page_size = 8;
  131. nvm->address_bits = 8;
  132. break;
  133. default:
  134. nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
  135. nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
  136. break;
  137. }
  138. nvm->type = e1000_nvm_eeprom_spi;
  139. size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
  140. E1000_EECD_SIZE_EX_SHIFT);
  141. /*
  142. * Added to a constant, "size" becomes the left-shift value
  143. * for setting word_size.
  144. */
  145. size += NVM_WORD_SIZE_BASE_SHIFT;
  146. nvm->word_size = 1 << size;
  147. /* setup PHY parameters */
  148. if (phy->media_type != e1000_media_type_copper) {
  149. phy->type = e1000_phy_none;
  150. return 0;
  151. }
  152. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  153. phy->reset_delay_us = 100;
  154. /* PHY function pointers */
  155. if (igb_sgmii_active_82575(hw)) {
  156. phy->ops.reset_phy = igb_phy_hw_reset_sgmii_82575;
  157. phy->ops.read_phy_reg = igb_read_phy_reg_sgmii_82575;
  158. phy->ops.write_phy_reg = igb_write_phy_reg_sgmii_82575;
  159. } else {
  160. phy->ops.reset_phy = igb_phy_hw_reset;
  161. phy->ops.read_phy_reg = igb_read_phy_reg_igp;
  162. phy->ops.write_phy_reg = igb_write_phy_reg_igp;
  163. }
  164. /* Set phy->phy_addr and phy->id. */
  165. ret_val = igb_get_phy_id_82575(hw);
  166. if (ret_val)
  167. return ret_val;
  168. /* Verify phy id and set remaining function pointers */
  169. switch (phy->id) {
  170. case M88E1111_I_PHY_ID:
  171. phy->type = e1000_phy_m88;
  172. phy->ops.get_phy_info = igb_get_phy_info_m88;
  173. phy->ops.get_cable_length = igb_get_cable_length_m88;
  174. phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;
  175. break;
  176. case IGP03E1000_E_PHY_ID:
  177. phy->type = e1000_phy_igp_3;
  178. phy->ops.get_phy_info = igb_get_phy_info_igp;
  179. phy->ops.get_cable_length = igb_get_cable_length_igp_2;
  180. phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp;
  181. phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575;
  182. phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;
  183. break;
  184. default:
  185. return -E1000_ERR_PHY;
  186. }
  187. return 0;
  188. }
  189. /**
  190. * e1000_acquire_phy_82575 - Acquire rights to access PHY
  191. * @hw: pointer to the HW structure
  192. *
  193. * Acquire access rights to the correct PHY. This is a
  194. * function pointer entry point called by the api module.
  195. **/
  196. static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
  197. {
  198. u16 mask;
  199. mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
  200. return igb_acquire_swfw_sync_82575(hw, mask);
  201. }
  202. /**
  203. * e1000_release_phy_82575 - Release rights to access PHY
  204. * @hw: pointer to the HW structure
  205. *
  206. * A wrapper to release access rights to the correct PHY. This is a
  207. * function pointer entry point called by the api module.
  208. **/
  209. static void igb_release_phy_82575(struct e1000_hw *hw)
  210. {
  211. u16 mask;
  212. mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
  213. igb_release_swfw_sync_82575(hw, mask);
  214. }
  215. /**
  216. * e1000_read_phy_reg_sgmii_82575 - Read PHY register using sgmii
  217. * @hw: pointer to the HW structure
  218. * @offset: register offset to be read
  219. * @data: pointer to the read data
  220. *
  221. * Reads the PHY register at offset using the serial gigabit media independent
  222. * interface and stores the retrieved information in data.
  223. **/
  224. static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
  225. u16 *data)
  226. {
  227. struct e1000_phy_info *phy = &hw->phy;
  228. u32 i, i2ccmd = 0;
  229. if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
  230. hw_dbg(hw, "PHY Address %u is out of range\n", offset);
  231. return -E1000_ERR_PARAM;
  232. }
  233. /*
  234. * Set up Op-code, Phy Address, and register address in the I2CCMD
  235. * register. The MAC will take care of interfacing with the
  236. * PHY to retrieve the desired data.
  237. */
  238. i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
  239. (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
  240. (E1000_I2CCMD_OPCODE_READ));
  241. wr32(E1000_I2CCMD, i2ccmd);
  242. /* Poll the ready bit to see if the I2C read completed */
  243. for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
  244. udelay(50);
  245. i2ccmd = rd32(E1000_I2CCMD);
  246. if (i2ccmd & E1000_I2CCMD_READY)
  247. break;
  248. }
  249. if (!(i2ccmd & E1000_I2CCMD_READY)) {
  250. hw_dbg(hw, "I2CCMD Read did not complete\n");
  251. return -E1000_ERR_PHY;
  252. }
  253. if (i2ccmd & E1000_I2CCMD_ERROR) {
  254. hw_dbg(hw, "I2CCMD Error bit set\n");
  255. return -E1000_ERR_PHY;
  256. }
  257. /* Need to byte-swap the 16-bit value. */
  258. *data = ((i2ccmd >> 8) & 0x00FF) | ((i2ccmd << 8) & 0xFF00);
  259. return 0;
  260. }
  261. /**
  262. * e1000_write_phy_reg_sgmii_82575 - Write PHY register using sgmii
  263. * @hw: pointer to the HW structure
  264. * @offset: register offset to write to
  265. * @data: data to write at register offset
  266. *
  267. * Writes the data to PHY register at the offset using the serial gigabit
  268. * media independent interface.
  269. **/
  270. static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
  271. u16 data)
  272. {
  273. struct e1000_phy_info *phy = &hw->phy;
  274. u32 i, i2ccmd = 0;
  275. u16 phy_data_swapped;
  276. if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
  277. hw_dbg(hw, "PHY Address %d is out of range\n", offset);
  278. return -E1000_ERR_PARAM;
  279. }
  280. /* Swap the data bytes for the I2C interface */
  281. phy_data_swapped = ((data >> 8) & 0x00FF) | ((data << 8) & 0xFF00);
  282. /*
  283. * Set up Op-code, Phy Address, and register address in the I2CCMD
  284. * register. The MAC will take care of interfacing with the
  285. * PHY to retrieve the desired data.
  286. */
  287. i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
  288. (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
  289. E1000_I2CCMD_OPCODE_WRITE |
  290. phy_data_swapped);
  291. wr32(E1000_I2CCMD, i2ccmd);
  292. /* Poll the ready bit to see if the I2C read completed */
  293. for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
  294. udelay(50);
  295. i2ccmd = rd32(E1000_I2CCMD);
  296. if (i2ccmd & E1000_I2CCMD_READY)
  297. break;
  298. }
  299. if (!(i2ccmd & E1000_I2CCMD_READY)) {
  300. hw_dbg(hw, "I2CCMD Write did not complete\n");
  301. return -E1000_ERR_PHY;
  302. }
  303. if (i2ccmd & E1000_I2CCMD_ERROR) {
  304. hw_dbg(hw, "I2CCMD Error bit set\n");
  305. return -E1000_ERR_PHY;
  306. }
  307. return 0;
  308. }
  309. /**
  310. * e1000_get_phy_id_82575 - Retreive PHY addr and id
  311. * @hw: pointer to the HW structure
  312. *
  313. * Retreives the PHY address and ID for both PHY's which do and do not use
  314. * sgmi interface.
  315. **/
  316. static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
  317. {
  318. struct e1000_phy_info *phy = &hw->phy;
  319. s32 ret_val = 0;
  320. u16 phy_id;
  321. /*
  322. * For SGMII PHYs, we try the list of possible addresses until
  323. * we find one that works. For non-SGMII PHYs
  324. * (e.g. integrated copper PHYs), an address of 1 should
  325. * work. The result of this function should mean phy->phy_addr
  326. * and phy->id are set correctly.
  327. */
  328. if (!(igb_sgmii_active_82575(hw))) {
  329. phy->addr = 1;
  330. ret_val = igb_get_phy_id(hw);
  331. goto out;
  332. }
  333. /*
  334. * The address field in the I2CCMD register is 3 bits and 0 is invalid.
  335. * Therefore, we need to test 1-7
  336. */
  337. for (phy->addr = 1; phy->addr < 8; phy->addr++) {
  338. ret_val = igb_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
  339. if (ret_val == 0) {
  340. hw_dbg(hw, "Vendor ID 0x%08X read at address %u\n",
  341. phy_id,
  342. phy->addr);
  343. /*
  344. * At the time of this writing, The M88 part is
  345. * the only supported SGMII PHY product.
  346. */
  347. if (phy_id == M88_VENDOR)
  348. break;
  349. } else {
  350. hw_dbg(hw, "PHY address %u was unreadable\n",
  351. phy->addr);
  352. }
  353. }
  354. /* A valid PHY type couldn't be found. */
  355. if (phy->addr == 8) {
  356. phy->addr = 0;
  357. ret_val = -E1000_ERR_PHY;
  358. goto out;
  359. }
  360. ret_val = igb_get_phy_id(hw);
  361. out:
  362. return ret_val;
  363. }
  364. /**
  365. * e1000_phy_hw_reset_sgmii_82575 - Performs a PHY reset
  366. * @hw: pointer to the HW structure
  367. *
  368. * Resets the PHY using the serial gigabit media independent interface.
  369. **/
  370. static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
  371. {
  372. s32 ret_val;
  373. /*
  374. * This isn't a true "hard" reset, but is the only reset
  375. * available to us at this time.
  376. */
  377. hw_dbg(hw, "Soft resetting SGMII attached PHY...\n");
  378. /*
  379. * SFP documentation requires the following to configure the SPF module
  380. * to work on SGMII. No further documentation is given.
  381. */
  382. ret_val = hw->phy.ops.write_phy_reg(hw, 0x1B, 0x8084);
  383. if (ret_val)
  384. goto out;
  385. ret_val = igb_phy_sw_reset(hw);
  386. out:
  387. return ret_val;
  388. }
  389. /**
  390. * e1000_set_d0_lplu_state_82575 - Set Low Power Linkup D0 state
  391. * @hw: pointer to the HW structure
  392. * @active: true to enable LPLU, false to disable
  393. *
  394. * Sets the LPLU D0 state according to the active flag. When
  395. * activating LPLU this function also disables smart speed
  396. * and vice versa. LPLU will not be activated unless the
  397. * device autonegotiation advertisement meets standards of
  398. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  399. * This is a function pointer entry point only called by
  400. * PHY setup routines.
  401. **/
  402. static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
  403. {
  404. struct e1000_phy_info *phy = &hw->phy;
  405. s32 ret_val;
  406. u16 data;
  407. ret_val = hw->phy.ops.read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
  408. &data);
  409. if (ret_val)
  410. goto out;
  411. if (active) {
  412. data |= IGP02E1000_PM_D0_LPLU;
  413. ret_val = hw->phy.ops.write_phy_reg(hw,
  414. IGP02E1000_PHY_POWER_MGMT,
  415. data);
  416. if (ret_val)
  417. goto out;
  418. /* When LPLU is enabled, we should disable SmartSpeed */
  419. ret_val = hw->phy.ops.read_phy_reg(hw,
  420. IGP01E1000_PHY_PORT_CONFIG,
  421. &data);
  422. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  423. ret_val = hw->phy.ops.write_phy_reg(hw,
  424. IGP01E1000_PHY_PORT_CONFIG,
  425. data);
  426. if (ret_val)
  427. goto out;
  428. } else {
  429. data &= ~IGP02E1000_PM_D0_LPLU;
  430. ret_val = hw->phy.ops.write_phy_reg(hw,
  431. IGP02E1000_PHY_POWER_MGMT,
  432. data);
  433. /*
  434. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  435. * during Dx states where the power conservation is most
  436. * important. During driver activity we should enable
  437. * SmartSpeed, so performance is maintained.
  438. */
  439. if (phy->smart_speed == e1000_smart_speed_on) {
  440. ret_val = hw->phy.ops.read_phy_reg(hw,
  441. IGP01E1000_PHY_PORT_CONFIG,
  442. &data);
  443. if (ret_val)
  444. goto out;
  445. data |= IGP01E1000_PSCFR_SMART_SPEED;
  446. ret_val = hw->phy.ops.write_phy_reg(hw,
  447. IGP01E1000_PHY_PORT_CONFIG,
  448. data);
  449. if (ret_val)
  450. goto out;
  451. } else if (phy->smart_speed == e1000_smart_speed_off) {
  452. ret_val = hw->phy.ops.read_phy_reg(hw,
  453. IGP01E1000_PHY_PORT_CONFIG,
  454. &data);
  455. if (ret_val)
  456. goto out;
  457. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  458. ret_val = hw->phy.ops.write_phy_reg(hw,
  459. IGP01E1000_PHY_PORT_CONFIG,
  460. data);
  461. if (ret_val)
  462. goto out;
  463. }
  464. }
  465. out:
  466. return ret_val;
  467. }
  468. /**
  469. * e1000_acquire_nvm_82575 - Request for access to EEPROM
  470. * @hw: pointer to the HW structure
  471. *
  472. * Acquire the necessary semaphores for exclussive access to the EEPROM.
  473. * Set the EEPROM access request bit and wait for EEPROM access grant bit.
  474. * Return successful if access grant bit set, else clear the request for
  475. * EEPROM access and return -E1000_ERR_NVM (-1).
  476. **/
  477. static s32 igb_acquire_nvm_82575(struct e1000_hw *hw)
  478. {
  479. s32 ret_val;
  480. ret_val = igb_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  481. if (ret_val)
  482. goto out;
  483. ret_val = igb_acquire_nvm(hw);
  484. if (ret_val)
  485. igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  486. out:
  487. return ret_val;
  488. }
  489. /**
  490. * e1000_release_nvm_82575 - Release exclusive access to EEPROM
  491. * @hw: pointer to the HW structure
  492. *
  493. * Stop any current commands to the EEPROM and clear the EEPROM request bit,
  494. * then release the semaphores acquired.
  495. **/
  496. static void igb_release_nvm_82575(struct e1000_hw *hw)
  497. {
  498. igb_release_nvm(hw);
  499. igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  500. }
  501. /**
  502. * e1000_acquire_swfw_sync_82575 - Acquire SW/FW semaphore
  503. * @hw: pointer to the HW structure
  504. * @mask: specifies which semaphore to acquire
  505. *
  506. * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
  507. * will also specify which port we're acquiring the lock for.
  508. **/
  509. static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
  510. {
  511. u32 swfw_sync;
  512. u32 swmask = mask;
  513. u32 fwmask = mask << 16;
  514. s32 ret_val = 0;
  515. s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
  516. while (i < timeout) {
  517. if (igb_get_hw_semaphore(hw)) {
  518. ret_val = -E1000_ERR_SWFW_SYNC;
  519. goto out;
  520. }
  521. swfw_sync = rd32(E1000_SW_FW_SYNC);
  522. if (!(swfw_sync & (fwmask | swmask)))
  523. break;
  524. /*
  525. * Firmware currently using resource (fwmask)
  526. * or other software thread using resource (swmask)
  527. */
  528. igb_put_hw_semaphore(hw);
  529. mdelay(5);
  530. i++;
  531. }
  532. if (i == timeout) {
  533. hw_dbg(hw, "Can't access resource, SW_FW_SYNC timeout.\n");
  534. ret_val = -E1000_ERR_SWFW_SYNC;
  535. goto out;
  536. }
  537. swfw_sync |= swmask;
  538. wr32(E1000_SW_FW_SYNC, swfw_sync);
  539. igb_put_hw_semaphore(hw);
  540. out:
  541. return ret_val;
  542. }
  543. /**
  544. * e1000_release_swfw_sync_82575 - Release SW/FW semaphore
  545. * @hw: pointer to the HW structure
  546. * @mask: specifies which semaphore to acquire
  547. *
  548. * Release the SW/FW semaphore used to access the PHY or NVM. The mask
  549. * will also specify which port we're releasing the lock for.
  550. **/
  551. static void igb_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
  552. {
  553. u32 swfw_sync;
  554. while (igb_get_hw_semaphore(hw) != 0);
  555. /* Empty */
  556. swfw_sync = rd32(E1000_SW_FW_SYNC);
  557. swfw_sync &= ~mask;
  558. wr32(E1000_SW_FW_SYNC, swfw_sync);
  559. igb_put_hw_semaphore(hw);
  560. }
  561. /**
  562. * e1000_get_cfg_done_82575 - Read config done bit
  563. * @hw: pointer to the HW structure
  564. *
  565. * Read the management control register for the config done bit for
  566. * completion status. NOTE: silicon which is EEPROM-less will fail trying
  567. * to read the config done bit, so an error is *ONLY* logged and returns
  568. * 0. If we were to return with error, EEPROM-less silicon
  569. * would not be able to be reset or change link.
  570. **/
  571. static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
  572. {
  573. s32 timeout = PHY_CFG_TIMEOUT;
  574. s32 ret_val = 0;
  575. u32 mask = E1000_NVM_CFG_DONE_PORT_0;
  576. if (hw->bus.func == 1)
  577. mask = E1000_NVM_CFG_DONE_PORT_1;
  578. while (timeout) {
  579. if (rd32(E1000_EEMNGCTL) & mask)
  580. break;
  581. msleep(1);
  582. timeout--;
  583. }
  584. if (!timeout)
  585. hw_dbg(hw, "MNG configuration cycle has not completed.\n");
  586. /* If EEPROM is not marked present, init the PHY manually */
  587. if (((rd32(E1000_EECD) & E1000_EECD_PRES) == 0) &&
  588. (hw->phy.type == e1000_phy_igp_3))
  589. igb_phy_init_script_igp3(hw);
  590. return ret_val;
  591. }
  592. /**
  593. * e1000_check_for_link_82575 - Check for link
  594. * @hw: pointer to the HW structure
  595. *
  596. * If sgmii is enabled, then use the pcs register to determine link, otherwise
  597. * use the generic interface for determining link.
  598. **/
  599. static s32 igb_check_for_link_82575(struct e1000_hw *hw)
  600. {
  601. s32 ret_val;
  602. u16 speed, duplex;
  603. /* SGMII link check is done through the PCS register. */
  604. if ((hw->phy.media_type != e1000_media_type_copper) ||
  605. (igb_sgmii_active_82575(hw)))
  606. ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
  607. &duplex);
  608. else
  609. ret_val = igb_check_for_copper_link(hw);
  610. return ret_val;
  611. }
  612. /**
  613. * e1000_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
  614. * @hw: pointer to the HW structure
  615. * @speed: stores the current speed
  616. * @duplex: stores the current duplex
  617. *
  618. * Using the physical coding sub-layer (PCS), retreive the current speed and
  619. * duplex, then store the values in the pointers provided.
  620. **/
  621. static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
  622. u16 *duplex)
  623. {
  624. struct e1000_mac_info *mac = &hw->mac;
  625. u32 pcs;
  626. /* Set up defaults for the return values of this function */
  627. mac->serdes_has_link = false;
  628. *speed = 0;
  629. *duplex = 0;
  630. /*
  631. * Read the PCS Status register for link state. For non-copper mode,
  632. * the status register is not accurate. The PCS status register is
  633. * used instead.
  634. */
  635. pcs = rd32(E1000_PCS_LSTAT);
  636. /*
  637. * The link up bit determines when link is up on autoneg. The sync ok
  638. * gets set once both sides sync up and agree upon link. Stable link
  639. * can be determined by checking for both link up and link sync ok
  640. */
  641. if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) {
  642. mac->serdes_has_link = true;
  643. /* Detect and store PCS speed */
  644. if (pcs & E1000_PCS_LSTS_SPEED_1000) {
  645. *speed = SPEED_1000;
  646. } else if (pcs & E1000_PCS_LSTS_SPEED_100) {
  647. *speed = SPEED_100;
  648. } else {
  649. *speed = SPEED_10;
  650. }
  651. /* Detect and store PCS duplex */
  652. if (pcs & E1000_PCS_LSTS_DUPLEX_FULL) {
  653. *duplex = FULL_DUPLEX;
  654. } else {
  655. *duplex = HALF_DUPLEX;
  656. }
  657. }
  658. return 0;
  659. }
  660. /**
  661. * e1000_rar_set_82575 - Set receive address register
  662. * @hw: pointer to the HW structure
  663. * @addr: pointer to the receive address
  664. * @index: receive address array register
  665. *
  666. * Sets the receive address array register at index to the address passed
  667. * in by addr.
  668. **/
  669. static void igb_rar_set_82575(struct e1000_hw *hw, u8 *addr, u32 index)
  670. {
  671. if (index < E1000_RAR_ENTRIES_82575)
  672. igb_rar_set(hw, addr, index);
  673. return;
  674. }
  675. /**
  676. * e1000_reset_hw_82575 - Reset hardware
  677. * @hw: pointer to the HW structure
  678. *
  679. * This resets the hardware into a known state. This is a
  680. * function pointer entry point called by the api module.
  681. **/
  682. static s32 igb_reset_hw_82575(struct e1000_hw *hw)
  683. {
  684. u32 ctrl, icr;
  685. s32 ret_val;
  686. /*
  687. * Prevent the PCI-E bus from sticking if there is no TLP connection
  688. * on the last TLP read/write transaction when MAC is reset.
  689. */
  690. ret_val = igb_disable_pcie_master(hw);
  691. if (ret_val)
  692. hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
  693. hw_dbg(hw, "Masking off all interrupts\n");
  694. wr32(E1000_IMC, 0xffffffff);
  695. wr32(E1000_RCTL, 0);
  696. wr32(E1000_TCTL, E1000_TCTL_PSP);
  697. wrfl();
  698. msleep(10);
  699. ctrl = rd32(E1000_CTRL);
  700. hw_dbg(hw, "Issuing a global reset to MAC\n");
  701. wr32(E1000_CTRL, ctrl | E1000_CTRL_RST);
  702. ret_val = igb_get_auto_rd_done(hw);
  703. if (ret_val) {
  704. /*
  705. * When auto config read does not complete, do not
  706. * return with an error. This can happen in situations
  707. * where there is no eeprom and prevents getting link.
  708. */
  709. hw_dbg(hw, "Auto Read Done did not complete\n");
  710. }
  711. /* If EEPROM is not present, run manual init scripts */
  712. if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
  713. igb_reset_init_script_82575(hw);
  714. /* Clear any pending interrupt events. */
  715. wr32(E1000_IMC, 0xffffffff);
  716. icr = rd32(E1000_ICR);
  717. igb_check_alt_mac_addr(hw);
  718. return ret_val;
  719. }
  720. /**
  721. * e1000_init_hw_82575 - Initialize hardware
  722. * @hw: pointer to the HW structure
  723. *
  724. * This inits the hardware readying it for operation.
  725. **/
  726. static s32 igb_init_hw_82575(struct e1000_hw *hw)
  727. {
  728. struct e1000_mac_info *mac = &hw->mac;
  729. s32 ret_val;
  730. u16 i, rar_count = mac->rar_entry_count;
  731. /* Initialize identification LED */
  732. ret_val = igb_id_led_init(hw);
  733. if (ret_val) {
  734. hw_dbg(hw, "Error initializing identification LED\n");
  735. /* This is not fatal and we should not stop init due to this */
  736. }
  737. /* Disabling VLAN filtering */
  738. hw_dbg(hw, "Initializing the IEEE VLAN\n");
  739. igb_clear_vfta(hw);
  740. /* Setup the receive address */
  741. igb_init_rx_addrs(hw, rar_count);
  742. /* Zero out the Multicast HASH table */
  743. hw_dbg(hw, "Zeroing the MTA\n");
  744. for (i = 0; i < mac->mta_reg_count; i++)
  745. array_wr32(E1000_MTA, i, 0);
  746. /* Setup link and flow control */
  747. ret_val = igb_setup_link(hw);
  748. /*
  749. * Clear all of the statistics registers (clear on read). It is
  750. * important that we do this after we have tried to establish link
  751. * because the symbol error count will increment wildly if there
  752. * is no link.
  753. */
  754. igb_clear_hw_cntrs_82575(hw);
  755. return ret_val;
  756. }
  757. /**
  758. * e1000_setup_copper_link_82575 - Configure copper link settings
  759. * @hw: pointer to the HW structure
  760. *
  761. * Configures the link for auto-neg or forced speed and duplex. Then we check
  762. * for link, once link is established calls to configure collision distance
  763. * and flow control are called.
  764. **/
  765. static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
  766. {
  767. u32 ctrl, led_ctrl;
  768. s32 ret_val;
  769. bool link;
  770. ctrl = rd32(E1000_CTRL);
  771. ctrl |= E1000_CTRL_SLU;
  772. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  773. wr32(E1000_CTRL, ctrl);
  774. switch (hw->phy.type) {
  775. case e1000_phy_m88:
  776. ret_val = igb_copper_link_setup_m88(hw);
  777. break;
  778. case e1000_phy_igp_3:
  779. ret_val = igb_copper_link_setup_igp(hw);
  780. /* Setup activity LED */
  781. led_ctrl = rd32(E1000_LEDCTL);
  782. led_ctrl &= IGP_ACTIVITY_LED_MASK;
  783. led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
  784. wr32(E1000_LEDCTL, led_ctrl);
  785. break;
  786. default:
  787. ret_val = -E1000_ERR_PHY;
  788. break;
  789. }
  790. if (ret_val)
  791. goto out;
  792. if (hw->mac.autoneg) {
  793. /*
  794. * Setup autoneg and flow control advertisement
  795. * and perform autonegotiation.
  796. */
  797. ret_val = igb_copper_link_autoneg(hw);
  798. if (ret_val)
  799. goto out;
  800. } else {
  801. /*
  802. * PHY will be set to 10H, 10F, 100H or 100F
  803. * depending on user settings.
  804. */
  805. hw_dbg(hw, "Forcing Speed and Duplex\n");
  806. ret_val = igb_phy_force_speed_duplex(hw);
  807. if (ret_val) {
  808. hw_dbg(hw, "Error Forcing Speed and Duplex\n");
  809. goto out;
  810. }
  811. }
  812. ret_val = igb_configure_pcs_link_82575(hw);
  813. if (ret_val)
  814. goto out;
  815. /*
  816. * Check link status. Wait up to 100 microseconds for link to become
  817. * valid.
  818. */
  819. ret_val = igb_phy_has_link(hw,
  820. COPPER_LINK_UP_LIMIT,
  821. 10,
  822. &link);
  823. if (ret_val)
  824. goto out;
  825. if (link) {
  826. hw_dbg(hw, "Valid link established!!!\n");
  827. /* Config the MAC and PHY after link is up */
  828. igb_config_collision_dist(hw);
  829. ret_val = igb_config_fc_after_link_up(hw);
  830. } else {
  831. hw_dbg(hw, "Unable to establish link!!!\n");
  832. }
  833. out:
  834. return ret_val;
  835. }
  836. /**
  837. * e1000_setup_fiber_serdes_link_82575 - Setup link for fiber/serdes
  838. * @hw: pointer to the HW structure
  839. *
  840. * Configures speed and duplex for fiber and serdes links.
  841. **/
  842. static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
  843. {
  844. u32 reg;
  845. /*
  846. * On the 82575, SerDes loopback mode persists until it is
  847. * explicitly turned off or a power cycle is performed. A read to
  848. * the register does not indicate its status. Therefore, we ensure
  849. * loopback mode is disabled during initialization.
  850. */
  851. wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
  852. /* Force link up, set 1gb, set both sw defined pins */
  853. reg = rd32(E1000_CTRL);
  854. reg |= E1000_CTRL_SLU |
  855. E1000_CTRL_SPD_1000 |
  856. E1000_CTRL_FRCSPD |
  857. E1000_CTRL_SWDPIN0 |
  858. E1000_CTRL_SWDPIN1;
  859. wr32(E1000_CTRL, reg);
  860. /* Set switch control to serdes energy detect */
  861. reg = rd32(E1000_CONNSW);
  862. reg |= E1000_CONNSW_ENRGSRC;
  863. wr32(E1000_CONNSW, reg);
  864. /*
  865. * New SerDes mode allows for forcing speed or autonegotiating speed
  866. * at 1gb. Autoneg should be default set by most drivers. This is the
  867. * mode that will be compatible with older link partners and switches.
  868. * However, both are supported by the hardware and some drivers/tools.
  869. */
  870. reg = rd32(E1000_PCS_LCTL);
  871. reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
  872. E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
  873. if (hw->mac.autoneg) {
  874. /* Set PCS register for autoneg */
  875. reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
  876. E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
  877. E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
  878. E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
  879. hw_dbg(hw, "Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
  880. } else {
  881. /* Set PCS register for forced speed */
  882. reg |= E1000_PCS_LCTL_FLV_LINK_UP | /* Force link up */
  883. E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
  884. E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
  885. E1000_PCS_LCTL_FSD | /* Force Speed */
  886. E1000_PCS_LCTL_FORCE_LINK; /* Force Link */
  887. hw_dbg(hw, "Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
  888. }
  889. wr32(E1000_PCS_LCTL, reg);
  890. return 0;
  891. }
  892. /**
  893. * e1000_configure_pcs_link_82575 - Configure PCS link
  894. * @hw: pointer to the HW structure
  895. *
  896. * Configure the physical coding sub-layer (PCS) link. The PCS link is
  897. * only used on copper connections where the serialized gigabit media
  898. * independent interface (sgmii) is being used. Configures the link
  899. * for auto-negotiation or forces speed/duplex.
  900. **/
  901. static s32 igb_configure_pcs_link_82575(struct e1000_hw *hw)
  902. {
  903. struct e1000_mac_info *mac = &hw->mac;
  904. u32 reg = 0;
  905. if (hw->phy.media_type != e1000_media_type_copper ||
  906. !(igb_sgmii_active_82575(hw)))
  907. goto out;
  908. /* For SGMII, we need to issue a PCS autoneg restart */
  909. reg = rd32(E1000_PCS_LCTL);
  910. /* AN time out should be disabled for SGMII mode */
  911. reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
  912. if (mac->autoneg) {
  913. /* Make sure forced speed and force link are not set */
  914. reg &= ~(E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
  915. /*
  916. * The PHY should be setup prior to calling this function.
  917. * All we need to do is restart autoneg and enable autoneg.
  918. */
  919. reg |= E1000_PCS_LCTL_AN_RESTART | E1000_PCS_LCTL_AN_ENABLE;
  920. } else {
  921. /* Set PCS regiseter for forced speed */
  922. /* Turn off bits for full duplex, speed, and autoneg */
  923. reg &= ~(E1000_PCS_LCTL_FSV_1000 |
  924. E1000_PCS_LCTL_FSV_100 |
  925. E1000_PCS_LCTL_FDV_FULL |
  926. E1000_PCS_LCTL_AN_ENABLE);
  927. /* Check for duplex first */
  928. if (mac->forced_speed_duplex & E1000_ALL_FULL_DUPLEX)
  929. reg |= E1000_PCS_LCTL_FDV_FULL;
  930. /* Now set speed */
  931. if (mac->forced_speed_duplex & E1000_ALL_100_SPEED)
  932. reg |= E1000_PCS_LCTL_FSV_100;
  933. /* Force speed and force link */
  934. reg |= E1000_PCS_LCTL_FSD |
  935. E1000_PCS_LCTL_FORCE_LINK |
  936. E1000_PCS_LCTL_FLV_LINK_UP;
  937. hw_dbg(hw,
  938. "Wrote 0x%08X to PCS_LCTL to configure forced link\n",
  939. reg);
  940. }
  941. wr32(E1000_PCS_LCTL, reg);
  942. out:
  943. return 0;
  944. }
  945. /**
  946. * e1000_sgmii_active_82575 - Return sgmii state
  947. * @hw: pointer to the HW structure
  948. *
  949. * 82575 silicon has a serialized gigabit media independent interface (sgmii)
  950. * which can be enabled for use in the embedded applications. Simply
  951. * return the current state of the sgmii interface.
  952. **/
  953. static bool igb_sgmii_active_82575(struct e1000_hw *hw)
  954. {
  955. struct e1000_dev_spec_82575 *dev_spec;
  956. bool ret_val;
  957. if (hw->mac.type != e1000_82575) {
  958. ret_val = false;
  959. goto out;
  960. }
  961. dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
  962. ret_val = dev_spec->sgmii_active;
  963. out:
  964. return ret_val;
  965. }
  966. /**
  967. * e1000_reset_init_script_82575 - Inits HW defaults after reset
  968. * @hw: pointer to the HW structure
  969. *
  970. * Inits recommended HW defaults after a reset when there is no EEPROM
  971. * detected. This is only for the 82575.
  972. **/
  973. static s32 igb_reset_init_script_82575(struct e1000_hw *hw)
  974. {
  975. if (hw->mac.type == e1000_82575) {
  976. hw_dbg(hw, "Running reset init script for 82575\n");
  977. /* SerDes configuration via SERDESCTRL */
  978. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x00, 0x0C);
  979. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x01, 0x78);
  980. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x1B, 0x23);
  981. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x23, 0x15);
  982. /* CCM configuration via CCMCTL register */
  983. igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x14, 0x00);
  984. igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x10, 0x00);
  985. /* PCIe lanes configuration */
  986. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x00, 0xEC);
  987. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x61, 0xDF);
  988. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x34, 0x05);
  989. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x2F, 0x81);
  990. /* PCIe PLL Configuration */
  991. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x02, 0x47);
  992. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x14, 0x00);
  993. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x10, 0x00);
  994. }
  995. return 0;
  996. }
  997. /**
  998. * e1000_read_mac_addr_82575 - Read device MAC address
  999. * @hw: pointer to the HW structure
  1000. **/
  1001. static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
  1002. {
  1003. s32 ret_val = 0;
  1004. if (igb_check_alt_mac_addr(hw))
  1005. ret_val = igb_read_mac_addr(hw);
  1006. return ret_val;
  1007. }
  1008. /**
  1009. * e1000_clear_hw_cntrs_82575 - Clear device specific hardware counters
  1010. * @hw: pointer to the HW structure
  1011. *
  1012. * Clears the hardware counters by reading the counter registers.
  1013. **/
  1014. static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
  1015. {
  1016. u32 temp;
  1017. igb_clear_hw_cntrs_base(hw);
  1018. temp = rd32(E1000_PRC64);
  1019. temp = rd32(E1000_PRC127);
  1020. temp = rd32(E1000_PRC255);
  1021. temp = rd32(E1000_PRC511);
  1022. temp = rd32(E1000_PRC1023);
  1023. temp = rd32(E1000_PRC1522);
  1024. temp = rd32(E1000_PTC64);
  1025. temp = rd32(E1000_PTC127);
  1026. temp = rd32(E1000_PTC255);
  1027. temp = rd32(E1000_PTC511);
  1028. temp = rd32(E1000_PTC1023);
  1029. temp = rd32(E1000_PTC1522);
  1030. temp = rd32(E1000_ALGNERRC);
  1031. temp = rd32(E1000_RXERRC);
  1032. temp = rd32(E1000_TNCRS);
  1033. temp = rd32(E1000_CEXTERR);
  1034. temp = rd32(E1000_TSCTC);
  1035. temp = rd32(E1000_TSCTFC);
  1036. temp = rd32(E1000_MGTPRC);
  1037. temp = rd32(E1000_MGTPDC);
  1038. temp = rd32(E1000_MGTPTC);
  1039. temp = rd32(E1000_IAC);
  1040. temp = rd32(E1000_ICRXOC);
  1041. temp = rd32(E1000_ICRXPTC);
  1042. temp = rd32(E1000_ICRXATC);
  1043. temp = rd32(E1000_ICTXPTC);
  1044. temp = rd32(E1000_ICTXATC);
  1045. temp = rd32(E1000_ICTXQEC);
  1046. temp = rd32(E1000_ICTXQMTC);
  1047. temp = rd32(E1000_ICRXDMTC);
  1048. temp = rd32(E1000_CBTMPC);
  1049. temp = rd32(E1000_HTDPMC);
  1050. temp = rd32(E1000_CBRMPC);
  1051. temp = rd32(E1000_RPTHC);
  1052. temp = rd32(E1000_HGPTC);
  1053. temp = rd32(E1000_HTCBDPC);
  1054. temp = rd32(E1000_HGORCL);
  1055. temp = rd32(E1000_HGORCH);
  1056. temp = rd32(E1000_HGOTCL);
  1057. temp = rd32(E1000_HGOTCH);
  1058. temp = rd32(E1000_LENERRS);
  1059. /* This register should not be read in copper configurations */
  1060. if (hw->phy.media_type == e1000_media_type_internal_serdes)
  1061. temp = rd32(E1000_SCVPC);
  1062. }
  1063. static struct e1000_mac_operations e1000_mac_ops_82575 = {
  1064. .reset_hw = igb_reset_hw_82575,
  1065. .init_hw = igb_init_hw_82575,
  1066. .check_for_link = igb_check_for_link_82575,
  1067. .rar_set = igb_rar_set_82575,
  1068. .read_mac_addr = igb_read_mac_addr_82575,
  1069. .get_speed_and_duplex = igb_get_speed_and_duplex_copper,
  1070. };
  1071. static struct e1000_phy_operations e1000_phy_ops_82575 = {
  1072. .acquire_phy = igb_acquire_phy_82575,
  1073. .get_cfg_done = igb_get_cfg_done_82575,
  1074. .release_phy = igb_release_phy_82575,
  1075. };
  1076. static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
  1077. .acquire_nvm = igb_acquire_nvm_82575,
  1078. .read_nvm = igb_read_nvm_eerd,
  1079. .release_nvm = igb_release_nvm_82575,
  1080. .write_nvm = igb_write_nvm_spi,
  1081. };
  1082. const struct e1000_info e1000_82575_info = {
  1083. .get_invariants = igb_get_invariants_82575,
  1084. .mac_ops = &e1000_mac_ops_82575,
  1085. .phy_ops = &e1000_phy_ops_82575,
  1086. .nvm_ops = &e1000_nvm_ops_82575,
  1087. };