e1000_82575.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  1. /*******************************************************************************
  2. Intel(R) Gigabit Ethernet Linux driver
  3. Copyright(c) 2007-2009 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/if_ether.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 s32 igb_read_phy_reg_82580(struct e1000_hw *, u32, u16 *);
  38. static s32 igb_write_phy_reg_82580(struct e1000_hw *, u32, u16);
  39. static s32 igb_reset_hw_82575(struct e1000_hw *);
  40. static s32 igb_reset_hw_82580(struct e1000_hw *);
  41. static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
  42. static s32 igb_setup_copper_link_82575(struct e1000_hw *);
  43. static s32 igb_setup_serdes_link_82575(struct e1000_hw *);
  44. static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16);
  45. static void igb_clear_hw_cntrs_82575(struct e1000_hw *);
  46. static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16);
  47. static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *,
  48. u16 *);
  49. static s32 igb_get_phy_id_82575(struct e1000_hw *);
  50. static void igb_release_swfw_sync_82575(struct e1000_hw *, u16);
  51. static bool igb_sgmii_active_82575(struct e1000_hw *);
  52. static s32 igb_reset_init_script_82575(struct e1000_hw *);
  53. static s32 igb_read_mac_addr_82575(struct e1000_hw *);
  54. static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw);
  55. static s32 igb_reset_mdicnfg_82580(struct e1000_hw *hw);
  56. static const u16 e1000_82580_rxpbs_table[] =
  57. { 36, 72, 144, 1, 2, 4, 8, 16,
  58. 35, 70, 140 };
  59. #define E1000_82580_RXPBS_TABLE_SIZE \
  60. (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
  61. /**
  62. * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO
  63. * @hw: pointer to the HW structure
  64. *
  65. * Called to determine if the I2C pins are being used for I2C or as an
  66. * external MDIO interface since the two options are mutually exclusive.
  67. **/
  68. static bool igb_sgmii_uses_mdio_82575(struct e1000_hw *hw)
  69. {
  70. u32 reg = 0;
  71. bool ext_mdio = false;
  72. switch (hw->mac.type) {
  73. case e1000_82575:
  74. case e1000_82576:
  75. reg = rd32(E1000_MDIC);
  76. ext_mdio = !!(reg & E1000_MDIC_DEST);
  77. break;
  78. case e1000_82580:
  79. case e1000_i350:
  80. reg = rd32(E1000_MDICNFG);
  81. ext_mdio = !!(reg & E1000_MDICNFG_EXT_MDIO);
  82. break;
  83. default:
  84. break;
  85. }
  86. return ext_mdio;
  87. }
  88. static s32 igb_get_invariants_82575(struct e1000_hw *hw)
  89. {
  90. struct e1000_phy_info *phy = &hw->phy;
  91. struct e1000_nvm_info *nvm = &hw->nvm;
  92. struct e1000_mac_info *mac = &hw->mac;
  93. struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575;
  94. u32 eecd;
  95. s32 ret_val;
  96. u16 size;
  97. u32 ctrl_ext = 0;
  98. switch (hw->device_id) {
  99. case E1000_DEV_ID_82575EB_COPPER:
  100. case E1000_DEV_ID_82575EB_FIBER_SERDES:
  101. case E1000_DEV_ID_82575GB_QUAD_COPPER:
  102. mac->type = e1000_82575;
  103. break;
  104. case E1000_DEV_ID_82576:
  105. case E1000_DEV_ID_82576_NS:
  106. case E1000_DEV_ID_82576_NS_SERDES:
  107. case E1000_DEV_ID_82576_FIBER:
  108. case E1000_DEV_ID_82576_SERDES:
  109. case E1000_DEV_ID_82576_QUAD_COPPER:
  110. case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
  111. case E1000_DEV_ID_82576_SERDES_QUAD:
  112. mac->type = e1000_82576;
  113. break;
  114. case E1000_DEV_ID_82580_COPPER:
  115. case E1000_DEV_ID_82580_FIBER:
  116. case E1000_DEV_ID_82580_SERDES:
  117. case E1000_DEV_ID_82580_SGMII:
  118. case E1000_DEV_ID_82580_COPPER_DUAL:
  119. case E1000_DEV_ID_DH89XXCC_SGMII:
  120. case E1000_DEV_ID_DH89XXCC_SERDES:
  121. case E1000_DEV_ID_DH89XXCC_BACKPLANE:
  122. case E1000_DEV_ID_DH89XXCC_SFP:
  123. mac->type = e1000_82580;
  124. break;
  125. case E1000_DEV_ID_I350_COPPER:
  126. case E1000_DEV_ID_I350_FIBER:
  127. case E1000_DEV_ID_I350_SERDES:
  128. case E1000_DEV_ID_I350_SGMII:
  129. mac->type = e1000_i350;
  130. break;
  131. default:
  132. return -E1000_ERR_MAC_INIT;
  133. break;
  134. }
  135. /* Set media type */
  136. /*
  137. * The 82575 uses bits 22:23 for link mode. The mode can be changed
  138. * based on the EEPROM. We cannot rely upon device ID. There
  139. * is no distinguishable difference between fiber and internal
  140. * SerDes mode on the 82575. There can be an external PHY attached
  141. * on the SGMII interface. For this, we'll set sgmii_active to true.
  142. */
  143. phy->media_type = e1000_media_type_copper;
  144. dev_spec->sgmii_active = false;
  145. ctrl_ext = rd32(E1000_CTRL_EXT);
  146. switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
  147. case E1000_CTRL_EXT_LINK_MODE_SGMII:
  148. dev_spec->sgmii_active = true;
  149. break;
  150. case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
  151. case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
  152. hw->phy.media_type = e1000_media_type_internal_serdes;
  153. break;
  154. default:
  155. break;
  156. }
  157. /* Set mta register count */
  158. mac->mta_reg_count = 128;
  159. /* Set rar entry count */
  160. mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
  161. if (mac->type == e1000_82576)
  162. mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
  163. if (mac->type == e1000_82580)
  164. mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
  165. if (mac->type == e1000_i350)
  166. mac->rar_entry_count = E1000_RAR_ENTRIES_I350;
  167. /* reset */
  168. if (mac->type >= e1000_82580)
  169. mac->ops.reset_hw = igb_reset_hw_82580;
  170. else
  171. mac->ops.reset_hw = igb_reset_hw_82575;
  172. /* Set if part includes ASF firmware */
  173. mac->asf_firmware_present = true;
  174. /* Set if manageability features are enabled. */
  175. mac->arc_subsystem_valid =
  176. (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK)
  177. ? true : false;
  178. /* physical interface link setup */
  179. mac->ops.setup_physical_interface =
  180. (hw->phy.media_type == e1000_media_type_copper)
  181. ? igb_setup_copper_link_82575
  182. : igb_setup_serdes_link_82575;
  183. /* NVM initialization */
  184. eecd = rd32(E1000_EECD);
  185. nvm->opcode_bits = 8;
  186. nvm->delay_usec = 1;
  187. switch (nvm->override) {
  188. case e1000_nvm_override_spi_large:
  189. nvm->page_size = 32;
  190. nvm->address_bits = 16;
  191. break;
  192. case e1000_nvm_override_spi_small:
  193. nvm->page_size = 8;
  194. nvm->address_bits = 8;
  195. break;
  196. default:
  197. nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
  198. nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
  199. break;
  200. }
  201. nvm->type = e1000_nvm_eeprom_spi;
  202. size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
  203. E1000_EECD_SIZE_EX_SHIFT);
  204. /*
  205. * Added to a constant, "size" becomes the left-shift value
  206. * for setting word_size.
  207. */
  208. size += NVM_WORD_SIZE_BASE_SHIFT;
  209. /* EEPROM access above 16k is unsupported */
  210. if (size > 14)
  211. size = 14;
  212. nvm->word_size = 1 << size;
  213. /* if 82576 then initialize mailbox parameters */
  214. if (mac->type == e1000_82576)
  215. igb_init_mbx_params_pf(hw);
  216. /* setup PHY parameters */
  217. if (phy->media_type != e1000_media_type_copper) {
  218. phy->type = e1000_phy_none;
  219. return 0;
  220. }
  221. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  222. phy->reset_delay_us = 100;
  223. ctrl_ext = rd32(E1000_CTRL_EXT);
  224. /* PHY function pointers */
  225. if (igb_sgmii_active_82575(hw)) {
  226. phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
  227. ctrl_ext |= E1000_CTRL_I2C_ENA;
  228. } else {
  229. phy->ops.reset = igb_phy_hw_reset;
  230. ctrl_ext &= ~E1000_CTRL_I2C_ENA;
  231. }
  232. wr32(E1000_CTRL_EXT, ctrl_ext);
  233. igb_reset_mdicnfg_82580(hw);
  234. if (igb_sgmii_active_82575(hw) && !igb_sgmii_uses_mdio_82575(hw)) {
  235. phy->ops.read_reg = igb_read_phy_reg_sgmii_82575;
  236. phy->ops.write_reg = igb_write_phy_reg_sgmii_82575;
  237. } else if (hw->mac.type >= e1000_82580) {
  238. phy->ops.read_reg = igb_read_phy_reg_82580;
  239. phy->ops.write_reg = igb_write_phy_reg_82580;
  240. } else {
  241. phy->ops.read_reg = igb_read_phy_reg_igp;
  242. phy->ops.write_reg = igb_write_phy_reg_igp;
  243. }
  244. /* set lan id */
  245. hw->bus.func = (rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) >>
  246. E1000_STATUS_FUNC_SHIFT;
  247. /* Set phy->phy_addr and phy->id. */
  248. ret_val = igb_get_phy_id_82575(hw);
  249. if (ret_val)
  250. return ret_val;
  251. /* Verify phy id and set remaining function pointers */
  252. switch (phy->id) {
  253. case I347AT4_E_PHY_ID:
  254. case M88E1112_E_PHY_ID:
  255. case M88E1111_I_PHY_ID:
  256. phy->type = e1000_phy_m88;
  257. phy->ops.get_phy_info = igb_get_phy_info_m88;
  258. if (phy->id == I347AT4_E_PHY_ID ||
  259. phy->id == M88E1112_E_PHY_ID)
  260. phy->ops.get_cable_length = igb_get_cable_length_m88_gen2;
  261. else
  262. phy->ops.get_cable_length = igb_get_cable_length_m88;
  263. phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;
  264. break;
  265. case IGP03E1000_E_PHY_ID:
  266. phy->type = e1000_phy_igp_3;
  267. phy->ops.get_phy_info = igb_get_phy_info_igp;
  268. phy->ops.get_cable_length = igb_get_cable_length_igp_2;
  269. phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp;
  270. phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575;
  271. phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;
  272. break;
  273. case I82580_I_PHY_ID:
  274. case I350_I_PHY_ID:
  275. phy->type = e1000_phy_82580;
  276. phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580;
  277. phy->ops.get_cable_length = igb_get_cable_length_82580;
  278. phy->ops.get_phy_info = igb_get_phy_info_82580;
  279. break;
  280. default:
  281. return -E1000_ERR_PHY;
  282. }
  283. return 0;
  284. }
  285. /**
  286. * igb_acquire_phy_82575 - Acquire rights to access PHY
  287. * @hw: pointer to the HW structure
  288. *
  289. * Acquire access rights to the correct PHY. This is a
  290. * function pointer entry point called by the api module.
  291. **/
  292. static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
  293. {
  294. u16 mask = E1000_SWFW_PHY0_SM;
  295. if (hw->bus.func == E1000_FUNC_1)
  296. mask = E1000_SWFW_PHY1_SM;
  297. else if (hw->bus.func == E1000_FUNC_2)
  298. mask = E1000_SWFW_PHY2_SM;
  299. else if (hw->bus.func == E1000_FUNC_3)
  300. mask = E1000_SWFW_PHY3_SM;
  301. return igb_acquire_swfw_sync_82575(hw, mask);
  302. }
  303. /**
  304. * igb_release_phy_82575 - Release rights to access PHY
  305. * @hw: pointer to the HW structure
  306. *
  307. * A wrapper to release access rights to the correct PHY. This is a
  308. * function pointer entry point called by the api module.
  309. **/
  310. static void igb_release_phy_82575(struct e1000_hw *hw)
  311. {
  312. u16 mask = E1000_SWFW_PHY0_SM;
  313. if (hw->bus.func == E1000_FUNC_1)
  314. mask = E1000_SWFW_PHY1_SM;
  315. else if (hw->bus.func == E1000_FUNC_2)
  316. mask = E1000_SWFW_PHY2_SM;
  317. else if (hw->bus.func == E1000_FUNC_3)
  318. mask = E1000_SWFW_PHY3_SM;
  319. igb_release_swfw_sync_82575(hw, mask);
  320. }
  321. /**
  322. * igb_read_phy_reg_sgmii_82575 - Read PHY register using sgmii
  323. * @hw: pointer to the HW structure
  324. * @offset: register offset to be read
  325. * @data: pointer to the read data
  326. *
  327. * Reads the PHY register at offset using the serial gigabit media independent
  328. * interface and stores the retrieved information in data.
  329. **/
  330. static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
  331. u16 *data)
  332. {
  333. s32 ret_val = -E1000_ERR_PARAM;
  334. if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
  335. hw_dbg("PHY Address %u is out of range\n", offset);
  336. goto out;
  337. }
  338. ret_val = hw->phy.ops.acquire(hw);
  339. if (ret_val)
  340. goto out;
  341. ret_val = igb_read_phy_reg_i2c(hw, offset, data);
  342. hw->phy.ops.release(hw);
  343. out:
  344. return ret_val;
  345. }
  346. /**
  347. * igb_write_phy_reg_sgmii_82575 - Write PHY register using sgmii
  348. * @hw: pointer to the HW structure
  349. * @offset: register offset to write to
  350. * @data: data to write at register offset
  351. *
  352. * Writes the data to PHY register at the offset using the serial gigabit
  353. * media independent interface.
  354. **/
  355. static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
  356. u16 data)
  357. {
  358. s32 ret_val = -E1000_ERR_PARAM;
  359. if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
  360. hw_dbg("PHY Address %d is out of range\n", offset);
  361. goto out;
  362. }
  363. ret_val = hw->phy.ops.acquire(hw);
  364. if (ret_val)
  365. goto out;
  366. ret_val = igb_write_phy_reg_i2c(hw, offset, data);
  367. hw->phy.ops.release(hw);
  368. out:
  369. return ret_val;
  370. }
  371. /**
  372. * igb_get_phy_id_82575 - Retrieve PHY addr and id
  373. * @hw: pointer to the HW structure
  374. *
  375. * Retrieves the PHY address and ID for both PHY's which do and do not use
  376. * sgmi interface.
  377. **/
  378. static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
  379. {
  380. struct e1000_phy_info *phy = &hw->phy;
  381. s32 ret_val = 0;
  382. u16 phy_id;
  383. u32 ctrl_ext;
  384. u32 mdic;
  385. /*
  386. * For SGMII PHYs, we try the list of possible addresses until
  387. * we find one that works. For non-SGMII PHYs
  388. * (e.g. integrated copper PHYs), an address of 1 should
  389. * work. The result of this function should mean phy->phy_addr
  390. * and phy->id are set correctly.
  391. */
  392. if (!(igb_sgmii_active_82575(hw))) {
  393. phy->addr = 1;
  394. ret_val = igb_get_phy_id(hw);
  395. goto out;
  396. }
  397. if (igb_sgmii_uses_mdio_82575(hw)) {
  398. switch (hw->mac.type) {
  399. case e1000_82575:
  400. case e1000_82576:
  401. mdic = rd32(E1000_MDIC);
  402. mdic &= E1000_MDIC_PHY_MASK;
  403. phy->addr = mdic >> E1000_MDIC_PHY_SHIFT;
  404. break;
  405. case e1000_82580:
  406. case e1000_i350:
  407. mdic = rd32(E1000_MDICNFG);
  408. mdic &= E1000_MDICNFG_PHY_MASK;
  409. phy->addr = mdic >> E1000_MDICNFG_PHY_SHIFT;
  410. break;
  411. default:
  412. ret_val = -E1000_ERR_PHY;
  413. goto out;
  414. break;
  415. }
  416. ret_val = igb_get_phy_id(hw);
  417. goto out;
  418. }
  419. /* Power on sgmii phy if it is disabled */
  420. ctrl_ext = rd32(E1000_CTRL_EXT);
  421. wr32(E1000_CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
  422. wrfl();
  423. msleep(300);
  424. /*
  425. * The address field in the I2CCMD register is 3 bits and 0 is invalid.
  426. * Therefore, we need to test 1-7
  427. */
  428. for (phy->addr = 1; phy->addr < 8; phy->addr++) {
  429. ret_val = igb_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
  430. if (ret_val == 0) {
  431. hw_dbg("Vendor ID 0x%08X read at address %u\n",
  432. phy_id, phy->addr);
  433. /*
  434. * At the time of this writing, The M88 part is
  435. * the only supported SGMII PHY product.
  436. */
  437. if (phy_id == M88_VENDOR)
  438. break;
  439. } else {
  440. hw_dbg("PHY address %u was unreadable\n", phy->addr);
  441. }
  442. }
  443. /* A valid PHY type couldn't be found. */
  444. if (phy->addr == 8) {
  445. phy->addr = 0;
  446. ret_val = -E1000_ERR_PHY;
  447. goto out;
  448. } else {
  449. ret_val = igb_get_phy_id(hw);
  450. }
  451. /* restore previous sfp cage power state */
  452. wr32(E1000_CTRL_EXT, ctrl_ext);
  453. out:
  454. return ret_val;
  455. }
  456. /**
  457. * igb_phy_hw_reset_sgmii_82575 - Performs a PHY reset
  458. * @hw: pointer to the HW structure
  459. *
  460. * Resets the PHY using the serial gigabit media independent interface.
  461. **/
  462. static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
  463. {
  464. s32 ret_val;
  465. /*
  466. * This isn't a true "hard" reset, but is the only reset
  467. * available to us at this time.
  468. */
  469. hw_dbg("Soft resetting SGMII attached PHY...\n");
  470. /*
  471. * SFP documentation requires the following to configure the SPF module
  472. * to work on SGMII. No further documentation is given.
  473. */
  474. ret_val = hw->phy.ops.write_reg(hw, 0x1B, 0x8084);
  475. if (ret_val)
  476. goto out;
  477. ret_val = igb_phy_sw_reset(hw);
  478. out:
  479. return ret_val;
  480. }
  481. /**
  482. * igb_set_d0_lplu_state_82575 - Set Low Power Linkup D0 state
  483. * @hw: pointer to the HW structure
  484. * @active: true to enable LPLU, false to disable
  485. *
  486. * Sets the LPLU D0 state according to the active flag. When
  487. * activating LPLU this function also disables smart speed
  488. * and vice versa. LPLU will not be activated unless the
  489. * device autonegotiation advertisement meets standards of
  490. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  491. * This is a function pointer entry point only called by
  492. * PHY setup routines.
  493. **/
  494. static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
  495. {
  496. struct e1000_phy_info *phy = &hw->phy;
  497. s32 ret_val;
  498. u16 data;
  499. ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
  500. if (ret_val)
  501. goto out;
  502. if (active) {
  503. data |= IGP02E1000_PM_D0_LPLU;
  504. ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
  505. data);
  506. if (ret_val)
  507. goto out;
  508. /* When LPLU is enabled, we should disable SmartSpeed */
  509. ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
  510. &data);
  511. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  512. ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
  513. data);
  514. if (ret_val)
  515. goto out;
  516. } else {
  517. data &= ~IGP02E1000_PM_D0_LPLU;
  518. ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
  519. data);
  520. /*
  521. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  522. * during Dx states where the power conservation is most
  523. * important. During driver activity we should enable
  524. * SmartSpeed, so performance is maintained.
  525. */
  526. if (phy->smart_speed == e1000_smart_speed_on) {
  527. ret_val = phy->ops.read_reg(hw,
  528. IGP01E1000_PHY_PORT_CONFIG, &data);
  529. if (ret_val)
  530. goto out;
  531. data |= IGP01E1000_PSCFR_SMART_SPEED;
  532. ret_val = phy->ops.write_reg(hw,
  533. IGP01E1000_PHY_PORT_CONFIG, data);
  534. if (ret_val)
  535. goto out;
  536. } else if (phy->smart_speed == e1000_smart_speed_off) {
  537. ret_val = phy->ops.read_reg(hw,
  538. IGP01E1000_PHY_PORT_CONFIG, &data);
  539. if (ret_val)
  540. goto out;
  541. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  542. ret_val = phy->ops.write_reg(hw,
  543. IGP01E1000_PHY_PORT_CONFIG, data);
  544. if (ret_val)
  545. goto out;
  546. }
  547. }
  548. out:
  549. return ret_val;
  550. }
  551. /**
  552. * igb_acquire_nvm_82575 - Request for access to EEPROM
  553. * @hw: pointer to the HW structure
  554. *
  555. * Acquire the necessary semaphores for exclusive access to the EEPROM.
  556. * Set the EEPROM access request bit and wait for EEPROM access grant bit.
  557. * Return successful if access grant bit set, else clear the request for
  558. * EEPROM access and return -E1000_ERR_NVM (-1).
  559. **/
  560. static s32 igb_acquire_nvm_82575(struct e1000_hw *hw)
  561. {
  562. s32 ret_val;
  563. ret_val = igb_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  564. if (ret_val)
  565. goto out;
  566. ret_val = igb_acquire_nvm(hw);
  567. if (ret_val)
  568. igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  569. out:
  570. return ret_val;
  571. }
  572. /**
  573. * igb_release_nvm_82575 - Release exclusive access to EEPROM
  574. * @hw: pointer to the HW structure
  575. *
  576. * Stop any current commands to the EEPROM and clear the EEPROM request bit,
  577. * then release the semaphores acquired.
  578. **/
  579. static void igb_release_nvm_82575(struct e1000_hw *hw)
  580. {
  581. igb_release_nvm(hw);
  582. igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
  583. }
  584. /**
  585. * igb_acquire_swfw_sync_82575 - Acquire SW/FW semaphore
  586. * @hw: pointer to the HW structure
  587. * @mask: specifies which semaphore to acquire
  588. *
  589. * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
  590. * will also specify which port we're acquiring the lock for.
  591. **/
  592. static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
  593. {
  594. u32 swfw_sync;
  595. u32 swmask = mask;
  596. u32 fwmask = mask << 16;
  597. s32 ret_val = 0;
  598. s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
  599. while (i < timeout) {
  600. if (igb_get_hw_semaphore(hw)) {
  601. ret_val = -E1000_ERR_SWFW_SYNC;
  602. goto out;
  603. }
  604. swfw_sync = rd32(E1000_SW_FW_SYNC);
  605. if (!(swfw_sync & (fwmask | swmask)))
  606. break;
  607. /*
  608. * Firmware currently using resource (fwmask)
  609. * or other software thread using resource (swmask)
  610. */
  611. igb_put_hw_semaphore(hw);
  612. mdelay(5);
  613. i++;
  614. }
  615. if (i == timeout) {
  616. hw_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
  617. ret_val = -E1000_ERR_SWFW_SYNC;
  618. goto out;
  619. }
  620. swfw_sync |= swmask;
  621. wr32(E1000_SW_FW_SYNC, swfw_sync);
  622. igb_put_hw_semaphore(hw);
  623. out:
  624. return ret_val;
  625. }
  626. /**
  627. * igb_release_swfw_sync_82575 - Release SW/FW semaphore
  628. * @hw: pointer to the HW structure
  629. * @mask: specifies which semaphore to acquire
  630. *
  631. * Release the SW/FW semaphore used to access the PHY or NVM. The mask
  632. * will also specify which port we're releasing the lock for.
  633. **/
  634. static void igb_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
  635. {
  636. u32 swfw_sync;
  637. while (igb_get_hw_semaphore(hw) != 0);
  638. /* Empty */
  639. swfw_sync = rd32(E1000_SW_FW_SYNC);
  640. swfw_sync &= ~mask;
  641. wr32(E1000_SW_FW_SYNC, swfw_sync);
  642. igb_put_hw_semaphore(hw);
  643. }
  644. /**
  645. * igb_get_cfg_done_82575 - Read config done bit
  646. * @hw: pointer to the HW structure
  647. *
  648. * Read the management control register for the config done bit for
  649. * completion status. NOTE: silicon which is EEPROM-less will fail trying
  650. * to read the config done bit, so an error is *ONLY* logged and returns
  651. * 0. If we were to return with error, EEPROM-less silicon
  652. * would not be able to be reset or change link.
  653. **/
  654. static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
  655. {
  656. s32 timeout = PHY_CFG_TIMEOUT;
  657. s32 ret_val = 0;
  658. u32 mask = E1000_NVM_CFG_DONE_PORT_0;
  659. if (hw->bus.func == 1)
  660. mask = E1000_NVM_CFG_DONE_PORT_1;
  661. else if (hw->bus.func == E1000_FUNC_2)
  662. mask = E1000_NVM_CFG_DONE_PORT_2;
  663. else if (hw->bus.func == E1000_FUNC_3)
  664. mask = E1000_NVM_CFG_DONE_PORT_3;
  665. while (timeout) {
  666. if (rd32(E1000_EEMNGCTL) & mask)
  667. break;
  668. msleep(1);
  669. timeout--;
  670. }
  671. if (!timeout)
  672. hw_dbg("MNG configuration cycle has not completed.\n");
  673. /* If EEPROM is not marked present, init the PHY manually */
  674. if (((rd32(E1000_EECD) & E1000_EECD_PRES) == 0) &&
  675. (hw->phy.type == e1000_phy_igp_3))
  676. igb_phy_init_script_igp3(hw);
  677. return ret_val;
  678. }
  679. /**
  680. * igb_check_for_link_82575 - Check for link
  681. * @hw: pointer to the HW structure
  682. *
  683. * If sgmii is enabled, then use the pcs register to determine link, otherwise
  684. * use the generic interface for determining link.
  685. **/
  686. static s32 igb_check_for_link_82575(struct e1000_hw *hw)
  687. {
  688. s32 ret_val;
  689. u16 speed, duplex;
  690. if (hw->phy.media_type != e1000_media_type_copper) {
  691. ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
  692. &duplex);
  693. /*
  694. * Use this flag to determine if link needs to be checked or
  695. * not. If we have link clear the flag so that we do not
  696. * continue to check for link.
  697. */
  698. hw->mac.get_link_status = !hw->mac.serdes_has_link;
  699. } else {
  700. ret_val = igb_check_for_copper_link(hw);
  701. }
  702. return ret_val;
  703. }
  704. /**
  705. * igb_power_up_serdes_link_82575 - Power up the serdes link after shutdown
  706. * @hw: pointer to the HW structure
  707. **/
  708. void igb_power_up_serdes_link_82575(struct e1000_hw *hw)
  709. {
  710. u32 reg;
  711. if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
  712. !igb_sgmii_active_82575(hw))
  713. return;
  714. /* Enable PCS to turn on link */
  715. reg = rd32(E1000_PCS_CFG0);
  716. reg |= E1000_PCS_CFG_PCS_EN;
  717. wr32(E1000_PCS_CFG0, reg);
  718. /* Power up the laser */
  719. reg = rd32(E1000_CTRL_EXT);
  720. reg &= ~E1000_CTRL_EXT_SDP3_DATA;
  721. wr32(E1000_CTRL_EXT, reg);
  722. /* flush the write to verify completion */
  723. wrfl();
  724. msleep(1);
  725. }
  726. /**
  727. * igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
  728. * @hw: pointer to the HW structure
  729. * @speed: stores the current speed
  730. * @duplex: stores the current duplex
  731. *
  732. * Using the physical coding sub-layer (PCS), retrieve the current speed and
  733. * duplex, then store the values in the pointers provided.
  734. **/
  735. static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
  736. u16 *duplex)
  737. {
  738. struct e1000_mac_info *mac = &hw->mac;
  739. u32 pcs;
  740. /* Set up defaults for the return values of this function */
  741. mac->serdes_has_link = false;
  742. *speed = 0;
  743. *duplex = 0;
  744. /*
  745. * Read the PCS Status register for link state. For non-copper mode,
  746. * the status register is not accurate. The PCS status register is
  747. * used instead.
  748. */
  749. pcs = rd32(E1000_PCS_LSTAT);
  750. /*
  751. * The link up bit determines when link is up on autoneg. The sync ok
  752. * gets set once both sides sync up and agree upon link. Stable link
  753. * can be determined by checking for both link up and link sync ok
  754. */
  755. if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) {
  756. mac->serdes_has_link = true;
  757. /* Detect and store PCS speed */
  758. if (pcs & E1000_PCS_LSTS_SPEED_1000) {
  759. *speed = SPEED_1000;
  760. } else if (pcs & E1000_PCS_LSTS_SPEED_100) {
  761. *speed = SPEED_100;
  762. } else {
  763. *speed = SPEED_10;
  764. }
  765. /* Detect and store PCS duplex */
  766. if (pcs & E1000_PCS_LSTS_DUPLEX_FULL) {
  767. *duplex = FULL_DUPLEX;
  768. } else {
  769. *duplex = HALF_DUPLEX;
  770. }
  771. }
  772. return 0;
  773. }
  774. /**
  775. * igb_shutdown_serdes_link_82575 - Remove link during power down
  776. * @hw: pointer to the HW structure
  777. *
  778. * In the case of fiber serdes, shut down optics and PCS on driver unload
  779. * when management pass thru is not enabled.
  780. **/
  781. void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
  782. {
  783. u32 reg;
  784. if (hw->phy.media_type != e1000_media_type_internal_serdes &&
  785. igb_sgmii_active_82575(hw))
  786. return;
  787. if (!igb_enable_mng_pass_thru(hw)) {
  788. /* Disable PCS to turn off link */
  789. reg = rd32(E1000_PCS_CFG0);
  790. reg &= ~E1000_PCS_CFG_PCS_EN;
  791. wr32(E1000_PCS_CFG0, reg);
  792. /* shutdown the laser */
  793. reg = rd32(E1000_CTRL_EXT);
  794. reg |= E1000_CTRL_EXT_SDP3_DATA;
  795. wr32(E1000_CTRL_EXT, reg);
  796. /* flush the write to verify completion */
  797. wrfl();
  798. msleep(1);
  799. }
  800. }
  801. /**
  802. * igb_reset_hw_82575 - Reset hardware
  803. * @hw: pointer to the HW structure
  804. *
  805. * This resets the hardware into a known state. This is a
  806. * function pointer entry point called by the api module.
  807. **/
  808. static s32 igb_reset_hw_82575(struct e1000_hw *hw)
  809. {
  810. u32 ctrl, icr;
  811. s32 ret_val;
  812. /*
  813. * Prevent the PCI-E bus from sticking if there is no TLP connection
  814. * on the last TLP read/write transaction when MAC is reset.
  815. */
  816. ret_val = igb_disable_pcie_master(hw);
  817. if (ret_val)
  818. hw_dbg("PCI-E Master disable polling has failed.\n");
  819. /* set the completion timeout for interface */
  820. ret_val = igb_set_pcie_completion_timeout(hw);
  821. if (ret_val) {
  822. hw_dbg("PCI-E Set completion timeout has failed.\n");
  823. }
  824. hw_dbg("Masking off all interrupts\n");
  825. wr32(E1000_IMC, 0xffffffff);
  826. wr32(E1000_RCTL, 0);
  827. wr32(E1000_TCTL, E1000_TCTL_PSP);
  828. wrfl();
  829. msleep(10);
  830. ctrl = rd32(E1000_CTRL);
  831. hw_dbg("Issuing a global reset to MAC\n");
  832. wr32(E1000_CTRL, ctrl | E1000_CTRL_RST);
  833. ret_val = igb_get_auto_rd_done(hw);
  834. if (ret_val) {
  835. /*
  836. * When auto config read does not complete, do not
  837. * return with an error. This can happen in situations
  838. * where there is no eeprom and prevents getting link.
  839. */
  840. hw_dbg("Auto Read Done did not complete\n");
  841. }
  842. /* If EEPROM is not present, run manual init scripts */
  843. if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
  844. igb_reset_init_script_82575(hw);
  845. /* Clear any pending interrupt events. */
  846. wr32(E1000_IMC, 0xffffffff);
  847. icr = rd32(E1000_ICR);
  848. /* Install any alternate MAC address into RAR0 */
  849. ret_val = igb_check_alt_mac_addr(hw);
  850. return ret_val;
  851. }
  852. /**
  853. * igb_init_hw_82575 - Initialize hardware
  854. * @hw: pointer to the HW structure
  855. *
  856. * This inits the hardware readying it for operation.
  857. **/
  858. static s32 igb_init_hw_82575(struct e1000_hw *hw)
  859. {
  860. struct e1000_mac_info *mac = &hw->mac;
  861. s32 ret_val;
  862. u16 i, rar_count = mac->rar_entry_count;
  863. /* Initialize identification LED */
  864. ret_val = igb_id_led_init(hw);
  865. if (ret_val) {
  866. hw_dbg("Error initializing identification LED\n");
  867. /* This is not fatal and we should not stop init due to this */
  868. }
  869. /* Disabling VLAN filtering */
  870. hw_dbg("Initializing the IEEE VLAN\n");
  871. igb_clear_vfta(hw);
  872. /* Setup the receive address */
  873. igb_init_rx_addrs(hw, rar_count);
  874. /* Zero out the Multicast HASH table */
  875. hw_dbg("Zeroing the MTA\n");
  876. for (i = 0; i < mac->mta_reg_count; i++)
  877. array_wr32(E1000_MTA, i, 0);
  878. /* Zero out the Unicast HASH table */
  879. hw_dbg("Zeroing the UTA\n");
  880. for (i = 0; i < mac->uta_reg_count; i++)
  881. array_wr32(E1000_UTA, i, 0);
  882. /* Setup link and flow control */
  883. ret_val = igb_setup_link(hw);
  884. /*
  885. * Clear all of the statistics registers (clear on read). It is
  886. * important that we do this after we have tried to establish link
  887. * because the symbol error count will increment wildly if there
  888. * is no link.
  889. */
  890. igb_clear_hw_cntrs_82575(hw);
  891. return ret_val;
  892. }
  893. /**
  894. * igb_setup_copper_link_82575 - Configure copper link settings
  895. * @hw: pointer to the HW structure
  896. *
  897. * Configures the link for auto-neg or forced speed and duplex. Then we check
  898. * for link, once link is established calls to configure collision distance
  899. * and flow control are called.
  900. **/
  901. static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
  902. {
  903. u32 ctrl;
  904. s32 ret_val;
  905. ctrl = rd32(E1000_CTRL);
  906. ctrl |= E1000_CTRL_SLU;
  907. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  908. wr32(E1000_CTRL, ctrl);
  909. ret_val = igb_setup_serdes_link_82575(hw);
  910. if (ret_val)
  911. goto out;
  912. if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
  913. /* allow time for SFP cage time to power up phy */
  914. msleep(300);
  915. ret_val = hw->phy.ops.reset(hw);
  916. if (ret_val) {
  917. hw_dbg("Error resetting the PHY.\n");
  918. goto out;
  919. }
  920. }
  921. switch (hw->phy.type) {
  922. case e1000_phy_m88:
  923. if (hw->phy.id == I347AT4_E_PHY_ID ||
  924. hw->phy.id == M88E1112_E_PHY_ID)
  925. ret_val = igb_copper_link_setup_m88_gen2(hw);
  926. else
  927. ret_val = igb_copper_link_setup_m88(hw);
  928. break;
  929. case e1000_phy_igp_3:
  930. ret_val = igb_copper_link_setup_igp(hw);
  931. break;
  932. case e1000_phy_82580:
  933. ret_val = igb_copper_link_setup_82580(hw);
  934. break;
  935. default:
  936. ret_val = -E1000_ERR_PHY;
  937. break;
  938. }
  939. if (ret_val)
  940. goto out;
  941. ret_val = igb_setup_copper_link(hw);
  942. out:
  943. return ret_val;
  944. }
  945. /**
  946. * igb_setup_serdes_link_82575 - Setup link for serdes
  947. * @hw: pointer to the HW structure
  948. *
  949. * Configure the physical coding sub-layer (PCS) link. The PCS link is
  950. * used on copper connections where the serialized gigabit media independent
  951. * interface (sgmii), or serdes fiber is being used. Configures the link
  952. * for auto-negotiation or forces speed/duplex.
  953. **/
  954. static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
  955. {
  956. u32 ctrl_ext, ctrl_reg, reg;
  957. bool pcs_autoneg;
  958. if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
  959. !igb_sgmii_active_82575(hw))
  960. return 0;
  961. /*
  962. * On the 82575, SerDes loopback mode persists until it is
  963. * explicitly turned off or a power cycle is performed. A read to
  964. * the register does not indicate its status. Therefore, we ensure
  965. * loopback mode is disabled during initialization.
  966. */
  967. wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
  968. /* power on the sfp cage if present */
  969. ctrl_ext = rd32(E1000_CTRL_EXT);
  970. ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA;
  971. wr32(E1000_CTRL_EXT, ctrl_ext);
  972. ctrl_reg = rd32(E1000_CTRL);
  973. ctrl_reg |= E1000_CTRL_SLU;
  974. if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576) {
  975. /* set both sw defined pins */
  976. ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1;
  977. /* Set switch control to serdes energy detect */
  978. reg = rd32(E1000_CONNSW);
  979. reg |= E1000_CONNSW_ENRGSRC;
  980. wr32(E1000_CONNSW, reg);
  981. }
  982. reg = rd32(E1000_PCS_LCTL);
  983. /* default pcs_autoneg to the same setting as mac autoneg */
  984. pcs_autoneg = hw->mac.autoneg;
  985. switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
  986. case E1000_CTRL_EXT_LINK_MODE_SGMII:
  987. /* sgmii mode lets the phy handle forcing speed/duplex */
  988. pcs_autoneg = true;
  989. /* autoneg time out should be disabled for SGMII mode */
  990. reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
  991. break;
  992. case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
  993. /* disable PCS autoneg and support parallel detect only */
  994. pcs_autoneg = false;
  995. default:
  996. /*
  997. * non-SGMII modes only supports a speed of 1000/Full for the
  998. * link so it is best to just force the MAC and let the pcs
  999. * link either autoneg or be forced to 1000/Full
  1000. */
  1001. ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
  1002. E1000_CTRL_FD | E1000_CTRL_FRCDPX;
  1003. /* set speed of 1000/Full if speed/duplex is forced */
  1004. reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL;
  1005. break;
  1006. }
  1007. wr32(E1000_CTRL, ctrl_reg);
  1008. /*
  1009. * New SerDes mode allows for forcing speed or autonegotiating speed
  1010. * at 1gb. Autoneg should be default set by most drivers. This is the
  1011. * mode that will be compatible with older link partners and switches.
  1012. * However, both are supported by the hardware and some drivers/tools.
  1013. */
  1014. reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
  1015. E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
  1016. /*
  1017. * We force flow control to prevent the CTRL register values from being
  1018. * overwritten by the autonegotiated flow control values
  1019. */
  1020. reg |= E1000_PCS_LCTL_FORCE_FCTRL;
  1021. if (pcs_autoneg) {
  1022. /* Set PCS register for autoneg */
  1023. reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
  1024. E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
  1025. hw_dbg("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
  1026. } else {
  1027. /* Set PCS register for forced link */
  1028. reg |= E1000_PCS_LCTL_FSD; /* Force Speed */
  1029. hw_dbg("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
  1030. }
  1031. wr32(E1000_PCS_LCTL, reg);
  1032. if (!igb_sgmii_active_82575(hw))
  1033. igb_force_mac_fc(hw);
  1034. return 0;
  1035. }
  1036. /**
  1037. * igb_sgmii_active_82575 - Return sgmii state
  1038. * @hw: pointer to the HW structure
  1039. *
  1040. * 82575 silicon has a serialized gigabit media independent interface (sgmii)
  1041. * which can be enabled for use in the embedded applications. Simply
  1042. * return the current state of the sgmii interface.
  1043. **/
  1044. static bool igb_sgmii_active_82575(struct e1000_hw *hw)
  1045. {
  1046. struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
  1047. return dev_spec->sgmii_active;
  1048. }
  1049. /**
  1050. * igb_reset_init_script_82575 - Inits HW defaults after reset
  1051. * @hw: pointer to the HW structure
  1052. *
  1053. * Inits recommended HW defaults after a reset when there is no EEPROM
  1054. * detected. This is only for the 82575.
  1055. **/
  1056. static s32 igb_reset_init_script_82575(struct e1000_hw *hw)
  1057. {
  1058. if (hw->mac.type == e1000_82575) {
  1059. hw_dbg("Running reset init script for 82575\n");
  1060. /* SerDes configuration via SERDESCTRL */
  1061. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x00, 0x0C);
  1062. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x01, 0x78);
  1063. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x1B, 0x23);
  1064. igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x23, 0x15);
  1065. /* CCM configuration via CCMCTL register */
  1066. igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x14, 0x00);
  1067. igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x10, 0x00);
  1068. /* PCIe lanes configuration */
  1069. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x00, 0xEC);
  1070. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x61, 0xDF);
  1071. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x34, 0x05);
  1072. igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x2F, 0x81);
  1073. /* PCIe PLL Configuration */
  1074. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x02, 0x47);
  1075. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x14, 0x00);
  1076. igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x10, 0x00);
  1077. }
  1078. return 0;
  1079. }
  1080. /**
  1081. * igb_read_mac_addr_82575 - Read device MAC address
  1082. * @hw: pointer to the HW structure
  1083. **/
  1084. static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
  1085. {
  1086. s32 ret_val = 0;
  1087. /*
  1088. * If there's an alternate MAC address place it in RAR0
  1089. * so that it will override the Si installed default perm
  1090. * address.
  1091. */
  1092. ret_val = igb_check_alt_mac_addr(hw);
  1093. if (ret_val)
  1094. goto out;
  1095. ret_val = igb_read_mac_addr(hw);
  1096. out:
  1097. return ret_val;
  1098. }
  1099. /**
  1100. * igb_power_down_phy_copper_82575 - Remove link during PHY power down
  1101. * @hw: pointer to the HW structure
  1102. *
  1103. * In the case of a PHY power down to save power, or to turn off link during a
  1104. * driver unload, or wake on lan is not enabled, remove the link.
  1105. **/
  1106. void igb_power_down_phy_copper_82575(struct e1000_hw *hw)
  1107. {
  1108. /* If the management interface is not enabled, then power down */
  1109. if (!(igb_enable_mng_pass_thru(hw) || igb_check_reset_block(hw)))
  1110. igb_power_down_phy_copper(hw);
  1111. }
  1112. /**
  1113. * igb_clear_hw_cntrs_82575 - Clear device specific hardware counters
  1114. * @hw: pointer to the HW structure
  1115. *
  1116. * Clears the hardware counters by reading the counter registers.
  1117. **/
  1118. static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
  1119. {
  1120. igb_clear_hw_cntrs_base(hw);
  1121. rd32(E1000_PRC64);
  1122. rd32(E1000_PRC127);
  1123. rd32(E1000_PRC255);
  1124. rd32(E1000_PRC511);
  1125. rd32(E1000_PRC1023);
  1126. rd32(E1000_PRC1522);
  1127. rd32(E1000_PTC64);
  1128. rd32(E1000_PTC127);
  1129. rd32(E1000_PTC255);
  1130. rd32(E1000_PTC511);
  1131. rd32(E1000_PTC1023);
  1132. rd32(E1000_PTC1522);
  1133. rd32(E1000_ALGNERRC);
  1134. rd32(E1000_RXERRC);
  1135. rd32(E1000_TNCRS);
  1136. rd32(E1000_CEXTERR);
  1137. rd32(E1000_TSCTC);
  1138. rd32(E1000_TSCTFC);
  1139. rd32(E1000_MGTPRC);
  1140. rd32(E1000_MGTPDC);
  1141. rd32(E1000_MGTPTC);
  1142. rd32(E1000_IAC);
  1143. rd32(E1000_ICRXOC);
  1144. rd32(E1000_ICRXPTC);
  1145. rd32(E1000_ICRXATC);
  1146. rd32(E1000_ICTXPTC);
  1147. rd32(E1000_ICTXATC);
  1148. rd32(E1000_ICTXQEC);
  1149. rd32(E1000_ICTXQMTC);
  1150. rd32(E1000_ICRXDMTC);
  1151. rd32(E1000_CBTMPC);
  1152. rd32(E1000_HTDPMC);
  1153. rd32(E1000_CBRMPC);
  1154. rd32(E1000_RPTHC);
  1155. rd32(E1000_HGPTC);
  1156. rd32(E1000_HTCBDPC);
  1157. rd32(E1000_HGORCL);
  1158. rd32(E1000_HGORCH);
  1159. rd32(E1000_HGOTCL);
  1160. rd32(E1000_HGOTCH);
  1161. rd32(E1000_LENERRS);
  1162. /* This register should not be read in copper configurations */
  1163. if (hw->phy.media_type == e1000_media_type_internal_serdes ||
  1164. igb_sgmii_active_82575(hw))
  1165. rd32(E1000_SCVPC);
  1166. }
  1167. /**
  1168. * igb_rx_fifo_flush_82575 - Clean rx fifo after RX enable
  1169. * @hw: pointer to the HW structure
  1170. *
  1171. * After rx enable if managability is enabled then there is likely some
  1172. * bad data at the start of the fifo and possibly in the DMA fifo. This
  1173. * function clears the fifos and flushes any packets that came in as rx was
  1174. * being enabled.
  1175. **/
  1176. void igb_rx_fifo_flush_82575(struct e1000_hw *hw)
  1177. {
  1178. u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
  1179. int i, ms_wait;
  1180. if (hw->mac.type != e1000_82575 ||
  1181. !(rd32(E1000_MANC) & E1000_MANC_RCV_TCO_EN))
  1182. return;
  1183. /* Disable all RX queues */
  1184. for (i = 0; i < 4; i++) {
  1185. rxdctl[i] = rd32(E1000_RXDCTL(i));
  1186. wr32(E1000_RXDCTL(i),
  1187. rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
  1188. }
  1189. /* Poll all queues to verify they have shut down */
  1190. for (ms_wait = 0; ms_wait < 10; ms_wait++) {
  1191. msleep(1);
  1192. rx_enabled = 0;
  1193. for (i = 0; i < 4; i++)
  1194. rx_enabled |= rd32(E1000_RXDCTL(i));
  1195. if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
  1196. break;
  1197. }
  1198. if (ms_wait == 10)
  1199. hw_dbg("Queue disable timed out after 10ms\n");
  1200. /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all
  1201. * incoming packets are rejected. Set enable and wait 2ms so that
  1202. * any packet that was coming in as RCTL.EN was set is flushed
  1203. */
  1204. rfctl = rd32(E1000_RFCTL);
  1205. wr32(E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
  1206. rlpml = rd32(E1000_RLPML);
  1207. wr32(E1000_RLPML, 0);
  1208. rctl = rd32(E1000_RCTL);
  1209. temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
  1210. temp_rctl |= E1000_RCTL_LPE;
  1211. wr32(E1000_RCTL, temp_rctl);
  1212. wr32(E1000_RCTL, temp_rctl | E1000_RCTL_EN);
  1213. wrfl();
  1214. msleep(2);
  1215. /* Enable RX queues that were previously enabled and restore our
  1216. * previous state
  1217. */
  1218. for (i = 0; i < 4; i++)
  1219. wr32(E1000_RXDCTL(i), rxdctl[i]);
  1220. wr32(E1000_RCTL, rctl);
  1221. wrfl();
  1222. wr32(E1000_RLPML, rlpml);
  1223. wr32(E1000_RFCTL, rfctl);
  1224. /* Flush receive errors generated by workaround */
  1225. rd32(E1000_ROC);
  1226. rd32(E1000_RNBC);
  1227. rd32(E1000_MPC);
  1228. }
  1229. /**
  1230. * igb_set_pcie_completion_timeout - set pci-e completion timeout
  1231. * @hw: pointer to the HW structure
  1232. *
  1233. * The defaults for 82575 and 82576 should be in the range of 50us to 50ms,
  1234. * however the hardware default for these parts is 500us to 1ms which is less
  1235. * than the 10ms recommended by the pci-e spec. To address this we need to
  1236. * increase the value to either 10ms to 200ms for capability version 1 config,
  1237. * or 16ms to 55ms for version 2.
  1238. **/
  1239. static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw)
  1240. {
  1241. u32 gcr = rd32(E1000_GCR);
  1242. s32 ret_val = 0;
  1243. u16 pcie_devctl2;
  1244. /* only take action if timeout value is defaulted to 0 */
  1245. if (gcr & E1000_GCR_CMPL_TMOUT_MASK)
  1246. goto out;
  1247. /*
  1248. * if capababilities version is type 1 we can write the
  1249. * timeout of 10ms to 200ms through the GCR register
  1250. */
  1251. if (!(gcr & E1000_GCR_CAP_VER2)) {
  1252. gcr |= E1000_GCR_CMPL_TMOUT_10ms;
  1253. goto out;
  1254. }
  1255. /*
  1256. * for version 2 capabilities we need to write the config space
  1257. * directly in order to set the completion timeout value for
  1258. * 16ms to 55ms
  1259. */
  1260. ret_val = igb_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
  1261. &pcie_devctl2);
  1262. if (ret_val)
  1263. goto out;
  1264. pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
  1265. ret_val = igb_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
  1266. &pcie_devctl2);
  1267. out:
  1268. /* disable completion timeout resend */
  1269. gcr &= ~E1000_GCR_CMPL_TMOUT_RESEND;
  1270. wr32(E1000_GCR, gcr);
  1271. return ret_val;
  1272. }
  1273. /**
  1274. * igb_vmdq_set_anti_spoofing_pf - enable or disable anti-spoofing
  1275. * @hw: pointer to the hardware struct
  1276. * @enable: state to enter, either enabled or disabled
  1277. * @pf: Physical Function pool - do not set anti-spoofing for the PF
  1278. *
  1279. * enables/disables L2 switch anti-spoofing functionality.
  1280. **/
  1281. void igb_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf)
  1282. {
  1283. u32 dtxswc;
  1284. switch (hw->mac.type) {
  1285. case e1000_82576:
  1286. case e1000_i350:
  1287. dtxswc = rd32(E1000_DTXSWC);
  1288. if (enable) {
  1289. dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
  1290. E1000_DTXSWC_VLAN_SPOOF_MASK);
  1291. /* The PF can spoof - it has to in order to
  1292. * support emulation mode NICs */
  1293. dtxswc ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
  1294. } else {
  1295. dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
  1296. E1000_DTXSWC_VLAN_SPOOF_MASK);
  1297. }
  1298. wr32(E1000_DTXSWC, dtxswc);
  1299. break;
  1300. default:
  1301. break;
  1302. }
  1303. }
  1304. /**
  1305. * igb_vmdq_set_loopback_pf - enable or disable vmdq loopback
  1306. * @hw: pointer to the hardware struct
  1307. * @enable: state to enter, either enabled or disabled
  1308. *
  1309. * enables/disables L2 switch loopback functionality.
  1310. **/
  1311. void igb_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
  1312. {
  1313. u32 dtxswc = rd32(E1000_DTXSWC);
  1314. if (enable)
  1315. dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
  1316. else
  1317. dtxswc &= ~E1000_DTXSWC_VMDQ_LOOPBACK_EN;
  1318. wr32(E1000_DTXSWC, dtxswc);
  1319. }
  1320. /**
  1321. * igb_vmdq_set_replication_pf - enable or disable vmdq replication
  1322. * @hw: pointer to the hardware struct
  1323. * @enable: state to enter, either enabled or disabled
  1324. *
  1325. * enables/disables replication of packets across multiple pools.
  1326. **/
  1327. void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
  1328. {
  1329. u32 vt_ctl = rd32(E1000_VT_CTL);
  1330. if (enable)
  1331. vt_ctl |= E1000_VT_CTL_VM_REPL_EN;
  1332. else
  1333. vt_ctl &= ~E1000_VT_CTL_VM_REPL_EN;
  1334. wr32(E1000_VT_CTL, vt_ctl);
  1335. }
  1336. /**
  1337. * igb_read_phy_reg_82580 - Read 82580 MDI control register
  1338. * @hw: pointer to the HW structure
  1339. * @offset: register offset to be read
  1340. * @data: pointer to the read data
  1341. *
  1342. * Reads the MDI control register in the PHY at offset and stores the
  1343. * information read to data.
  1344. **/
  1345. static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
  1346. {
  1347. s32 ret_val;
  1348. ret_val = hw->phy.ops.acquire(hw);
  1349. if (ret_val)
  1350. goto out;
  1351. ret_val = igb_read_phy_reg_mdic(hw, offset, data);
  1352. hw->phy.ops.release(hw);
  1353. out:
  1354. return ret_val;
  1355. }
  1356. /**
  1357. * igb_write_phy_reg_82580 - Write 82580 MDI control register
  1358. * @hw: pointer to the HW structure
  1359. * @offset: register offset to write to
  1360. * @data: data to write to register at offset
  1361. *
  1362. * Writes data to MDI control register in the PHY at offset.
  1363. **/
  1364. static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
  1365. {
  1366. s32 ret_val;
  1367. ret_val = hw->phy.ops.acquire(hw);
  1368. if (ret_val)
  1369. goto out;
  1370. ret_val = igb_write_phy_reg_mdic(hw, offset, data);
  1371. hw->phy.ops.release(hw);
  1372. out:
  1373. return ret_val;
  1374. }
  1375. /**
  1376. * igb_reset_mdicnfg_82580 - Reset MDICNFG destination and com_mdio bits
  1377. * @hw: pointer to the HW structure
  1378. *
  1379. * This resets the the MDICNFG.Destination and MDICNFG.Com_MDIO bits based on
  1380. * the values found in the EEPROM. This addresses an issue in which these
  1381. * bits are not restored from EEPROM after reset.
  1382. **/
  1383. static s32 igb_reset_mdicnfg_82580(struct e1000_hw *hw)
  1384. {
  1385. s32 ret_val = 0;
  1386. u32 mdicnfg;
  1387. u16 nvm_data = 0;
  1388. if (hw->mac.type != e1000_82580)
  1389. goto out;
  1390. if (!igb_sgmii_active_82575(hw))
  1391. goto out;
  1392. ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
  1393. NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
  1394. &nvm_data);
  1395. if (ret_val) {
  1396. hw_dbg("NVM Read Error\n");
  1397. goto out;
  1398. }
  1399. mdicnfg = rd32(E1000_MDICNFG);
  1400. if (nvm_data & NVM_WORD24_EXT_MDIO)
  1401. mdicnfg |= E1000_MDICNFG_EXT_MDIO;
  1402. if (nvm_data & NVM_WORD24_COM_MDIO)
  1403. mdicnfg |= E1000_MDICNFG_COM_MDIO;
  1404. wr32(E1000_MDICNFG, mdicnfg);
  1405. out:
  1406. return ret_val;
  1407. }
  1408. /**
  1409. * igb_reset_hw_82580 - Reset hardware
  1410. * @hw: pointer to the HW structure
  1411. *
  1412. * This resets function or entire device (all ports, etc.)
  1413. * to a known state.
  1414. **/
  1415. static s32 igb_reset_hw_82580(struct e1000_hw *hw)
  1416. {
  1417. s32 ret_val = 0;
  1418. /* BH SW mailbox bit in SW_FW_SYNC */
  1419. u16 swmbsw_mask = E1000_SW_SYNCH_MB;
  1420. u32 ctrl, icr;
  1421. bool global_device_reset = hw->dev_spec._82575.global_device_reset;
  1422. hw->dev_spec._82575.global_device_reset = false;
  1423. /* Get current control state. */
  1424. ctrl = rd32(E1000_CTRL);
  1425. /*
  1426. * Prevent the PCI-E bus from sticking if there is no TLP connection
  1427. * on the last TLP read/write transaction when MAC is reset.
  1428. */
  1429. ret_val = igb_disable_pcie_master(hw);
  1430. if (ret_val)
  1431. hw_dbg("PCI-E Master disable polling has failed.\n");
  1432. hw_dbg("Masking off all interrupts\n");
  1433. wr32(E1000_IMC, 0xffffffff);
  1434. wr32(E1000_RCTL, 0);
  1435. wr32(E1000_TCTL, E1000_TCTL_PSP);
  1436. wrfl();
  1437. msleep(10);
  1438. /* Determine whether or not a global dev reset is requested */
  1439. if (global_device_reset &&
  1440. igb_acquire_swfw_sync_82575(hw, swmbsw_mask))
  1441. global_device_reset = false;
  1442. if (global_device_reset &&
  1443. !(rd32(E1000_STATUS) & E1000_STAT_DEV_RST_SET))
  1444. ctrl |= E1000_CTRL_DEV_RST;
  1445. else
  1446. ctrl |= E1000_CTRL_RST;
  1447. wr32(E1000_CTRL, ctrl);
  1448. /* Add delay to insure DEV_RST has time to complete */
  1449. if (global_device_reset)
  1450. msleep(5);
  1451. ret_val = igb_get_auto_rd_done(hw);
  1452. if (ret_val) {
  1453. /*
  1454. * When auto config read does not complete, do not
  1455. * return with an error. This can happen in situations
  1456. * where there is no eeprom and prevents getting link.
  1457. */
  1458. hw_dbg("Auto Read Done did not complete\n");
  1459. }
  1460. /* If EEPROM is not present, run manual init scripts */
  1461. if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
  1462. igb_reset_init_script_82575(hw);
  1463. /* clear global device reset status bit */
  1464. wr32(E1000_STATUS, E1000_STAT_DEV_RST_SET);
  1465. /* Clear any pending interrupt events. */
  1466. wr32(E1000_IMC, 0xffffffff);
  1467. icr = rd32(E1000_ICR);
  1468. ret_val = igb_reset_mdicnfg_82580(hw);
  1469. if (ret_val)
  1470. hw_dbg("Could not reset MDICNFG based on EEPROM\n");
  1471. /* Install any alternate MAC address into RAR0 */
  1472. ret_val = igb_check_alt_mac_addr(hw);
  1473. /* Release semaphore */
  1474. if (global_device_reset)
  1475. igb_release_swfw_sync_82575(hw, swmbsw_mask);
  1476. return ret_val;
  1477. }
  1478. /**
  1479. * igb_rxpbs_adjust_82580 - adjust RXPBS value to reflect actual RX PBA size
  1480. * @data: data received by reading RXPBS register
  1481. *
  1482. * The 82580 uses a table based approach for packet buffer allocation sizes.
  1483. * This function converts the retrieved value into the correct table value
  1484. * 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7
  1485. * 0x0 36 72 144 1 2 4 8 16
  1486. * 0x8 35 70 140 rsv rsv rsv rsv rsv
  1487. */
  1488. u16 igb_rxpbs_adjust_82580(u32 data)
  1489. {
  1490. u16 ret_val = 0;
  1491. if (data < E1000_82580_RXPBS_TABLE_SIZE)
  1492. ret_val = e1000_82580_rxpbs_table[data];
  1493. return ret_val;
  1494. }
  1495. static struct e1000_mac_operations e1000_mac_ops_82575 = {
  1496. .init_hw = igb_init_hw_82575,
  1497. .check_for_link = igb_check_for_link_82575,
  1498. .rar_set = igb_rar_set,
  1499. .read_mac_addr = igb_read_mac_addr_82575,
  1500. .get_speed_and_duplex = igb_get_speed_and_duplex_copper,
  1501. };
  1502. static struct e1000_phy_operations e1000_phy_ops_82575 = {
  1503. .acquire = igb_acquire_phy_82575,
  1504. .get_cfg_done = igb_get_cfg_done_82575,
  1505. .release = igb_release_phy_82575,
  1506. };
  1507. static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
  1508. .acquire = igb_acquire_nvm_82575,
  1509. .read = igb_read_nvm_eerd,
  1510. .release = igb_release_nvm_82575,
  1511. .write = igb_write_nvm_spi,
  1512. };
  1513. const struct e1000_info e1000_82575_info = {
  1514. .get_invariants = igb_get_invariants_82575,
  1515. .mac_ops = &e1000_mac_ops_82575,
  1516. .phy_ops = &e1000_phy_ops_82575,
  1517. .nvm_ops = &e1000_nvm_ops_82575,
  1518. };