e1000_82575.c 61 KB

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