You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

e1000.c 116KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746
  1. /**************************************************************************
  2. Etherboot - BOOTP/TFTP Bootstrap Program
  3. Inter Pro 1000 for Etherboot
  4. Drivers are port from Intel's Linux driver e1000-4.3.15
  5. ***************************************************************************/
  6. /*******************************************************************************
  7. Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
  8. This program is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your option)
  11. any later version.
  12. This program is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. more details.
  16. You should have received a copy of the GNU General Public License along with
  17. this program; if not, write to the Free Software Foundation, Inc., 59
  18. Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. The full GNU General Public License is included in this distribution in the
  20. file called LICENSE.
  21. Contact Information:
  22. Linux NICS <linux.nics@intel.com>
  23. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *******************************************************************************/
  25. /*
  26. * Copyright (C) Archway Digital Solutions.
  27. *
  28. * written by Chrsitopher Li <cli at arcyway dot com> or <chrisl at gnuchina dot org>
  29. * 2/9/2002
  30. *
  31. * Copyright (C) Linux Networx.
  32. * Massive upgrade to work with the new intel gigabit NICs.
  33. * <ebiederman at lnxi dot com>
  34. *
  35. * Support for 82541ei & 82547ei chips from Intel's Linux driver 5.1.13 added by
  36. * Georg Baum <gbaum@users.sf.net>, sponsored by PetaMem GmbH and linkLINE Communications, Inc.
  37. *
  38. * 01/2004: Updated to Linux driver 5.2.22 by Georg Baum <gbaum@users.sf.net>
  39. */
  40. /* to get some global routines like printf */
  41. #include "etherboot.h"
  42. /* to get the interface to the body of the program */
  43. #include "nic.h"
  44. /* to get the PCI support functions, if this is a PCI NIC */
  45. #include <gpxe/pci.h>
  46. #include "timer.h"
  47. typedef unsigned char *dma_addr_t;
  48. typedef enum {
  49. FALSE = 0,
  50. TRUE = 1
  51. } boolean_t;
  52. #define DEBUG 0
  53. /* Some pieces of code are disabled with #if 0 ... #endif.
  54. * They are not deleted to show where the etherboot driver differs
  55. * from the linux driver below the function level.
  56. * Some member variables of the hw struct have been eliminated
  57. * and the corresponding inplace checks inserted instead.
  58. * Pieces such as LED handling that we definitely don't need are deleted.
  59. *
  60. * Please keep the function ordering so that it is easy to produce diffs
  61. * against the linux driver.
  62. *
  63. * The following defines should not be needed normally,
  64. * but may be helpful for debugging purposes. */
  65. /* Define this if you want to program the transmission control register
  66. * the way the Linux driver does it. */
  67. #undef LINUX_DRIVER_TCTL
  68. /* Define this to behave more like the Linux driver. */
  69. #undef LINUX_DRIVER
  70. #include "e1000_hw.h"
  71. /* NIC specific static variables go here */
  72. static struct nic_operations e1000_operations;
  73. static struct pci_driver e1000_driver;
  74. static struct e1000_hw hw;
  75. struct {
  76. char tx_pool[128 + 16];
  77. char rx_pool[128 + 16];
  78. char packet[2096];
  79. } e1000_bufs __shared;
  80. static struct e1000_tx_desc *tx_base;
  81. static struct e1000_rx_desc *rx_base;
  82. static int tx_tail;
  83. static int rx_tail, rx_last;
  84. /* Function forward declarations */
  85. static int e1000_setup_link(struct e1000_hw *hw);
  86. static int e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
  87. static int e1000_setup_copper_link(struct e1000_hw *hw);
  88. static int e1000_phy_setup_autoneg(struct e1000_hw *hw);
  89. static void e1000_config_collision_dist(struct e1000_hw *hw);
  90. static int e1000_config_mac_to_phy(struct e1000_hw *hw);
  91. static int e1000_config_fc_after_link_up(struct e1000_hw *hw);
  92. static int e1000_check_for_link(struct e1000_hw *hw);
  93. static int e1000_wait_autoneg(struct e1000_hw *hw);
  94. static void e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t *speed, uint16_t *duplex);
  95. static int e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  96. static int e1000_read_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  97. static int e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  98. static int e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  99. static void e1000_phy_hw_reset(struct e1000_hw *hw);
  100. static int e1000_phy_reset(struct e1000_hw *hw);
  101. static int e1000_detect_gig_phy(struct e1000_hw *hw);
  102. static int e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
  103. static void e1000_init_rx_addrs(struct e1000_hw *hw);
  104. static void e1000_clear_vfta(struct e1000_hw *hw);
  105. /* Printing macros... */
  106. #define E1000_ERR(args...) printf("e1000: " args)
  107. #if DEBUG >= 3
  108. #define E1000_DBG(args...) printf("e1000: " args)
  109. #else
  110. #define E1000_DBG(args...)
  111. #endif
  112. #define MSGOUT(S, A, B) printk(S "\n", A, B)
  113. #if DEBUG >= 2
  114. #define DEBUGFUNC(F) DEBUGOUT(F "\n");
  115. #else
  116. #define DEBUGFUNC(F)
  117. #endif
  118. #if DEBUG >= 1
  119. #define DEBUGOUT(S) printf(S)
  120. #define DEBUGOUT1(S,A) printf(S,A)
  121. #define DEBUGOUT2(S,A,B) printf(S,A,B)
  122. #define DEBUGOUT3(S,A,B,C) printf(S,A,B,C)
  123. #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S,A,B,C,D,E,F,G)
  124. #else
  125. #define DEBUGOUT(S)
  126. #define DEBUGOUT1(S,A)
  127. #define DEBUGOUT2(S,A,B)
  128. #define DEBUGOUT3(S,A,B,C)
  129. #define DEBUGOUT7(S,A,B,C,D,E,F,G)
  130. #endif
  131. #define E1000_WRITE_REG(a, reg, value) ( \
  132. ((a)->mac_type >= e1000_82543) ? \
  133. (writel((value), ((a)->hw_addr + E1000_##reg))) : \
  134. (writel((value), ((a)->hw_addr + E1000_82542_##reg))))
  135. #define E1000_READ_REG(a, reg) ( \
  136. ((a)->mac_type >= e1000_82543) ? \
  137. readl((a)->hw_addr + E1000_##reg) : \
  138. readl((a)->hw_addr + E1000_82542_##reg))
  139. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  140. ((a)->mac_type >= e1000_82543) ? \
  141. writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))) : \
  142. writel((value), ((a)->hw_addr + E1000_82542_##reg + ((offset) << 2))))
  143. #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  144. ((a)->mac_type >= e1000_82543) ? \
  145. readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \
  146. readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))
  147. #define E1000_WRITE_FLUSH(a) {uint32_t x; x = E1000_READ_REG(a, STATUS);}
  148. /******************************************************************************
  149. * Inline functions from e1000_main.c of the linux driver
  150. ******************************************************************************/
  151. #if 0
  152. static inline uint32_t
  153. e1000_io_read(struct e1000_hw *hw __unused, uint32_t port)
  154. {
  155. return inl(port);
  156. }
  157. #endif
  158. static inline void
  159. e1000_io_write(struct e1000_hw *hw __unused, uint32_t port, uint32_t value)
  160. {
  161. outl(value, port);
  162. }
  163. static inline void e1000_pci_set_mwi(struct e1000_hw *hw)
  164. {
  165. pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word);
  166. }
  167. static inline void e1000_pci_clear_mwi(struct e1000_hw *hw)
  168. {
  169. pci_write_config_word(hw->pdev, PCI_COMMAND,
  170. hw->pci_cmd_word & ~PCI_COMMAND_INVALIDATE);
  171. }
  172. /******************************************************************************
  173. * Inline functions from e1000_hw.c of the linux driver
  174. ******************************************************************************/
  175. /******************************************************************************
  176. * Writes a value to one of the devices registers using port I/O (as opposed to
  177. * memory mapped I/O). Only 82544 and newer devices support port I/O. *
  178. * hw - Struct containing variables accessed by shared code
  179. * offset - offset to write to * value - value to write
  180. *****************************************************************************/
  181. static inline void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset,
  182. uint32_t value){
  183. e1000_io_write(hw, hw->io_base, offset);
  184. e1000_io_write(hw, hw->io_base + 4, value);
  185. }
  186. /******************************************************************************
  187. * Functions from e1000_hw.c of the linux driver
  188. ******************************************************************************/
  189. /******************************************************************************
  190. * Set the phy type member in the hw struct.
  191. *
  192. * hw - Struct containing variables accessed by shared code
  193. *****************************************************************************/
  194. static int32_t
  195. e1000_set_phy_type(struct e1000_hw *hw)
  196. {
  197. DEBUGFUNC("e1000_set_phy_type");
  198. switch(hw->phy_id) {
  199. case M88E1000_E_PHY_ID:
  200. case M88E1000_I_PHY_ID:
  201. case M88E1011_I_PHY_ID:
  202. hw->phy_type = e1000_phy_m88;
  203. break;
  204. case IGP01E1000_I_PHY_ID:
  205. hw->phy_type = e1000_phy_igp;
  206. break;
  207. default:
  208. /* Should never have loaded on this device */
  209. hw->phy_type = e1000_phy_undefined;
  210. return -E1000_ERR_PHY_TYPE;
  211. }
  212. return E1000_SUCCESS;
  213. }
  214. /******************************************************************************
  215. * IGP phy init script - initializes the GbE PHY
  216. *
  217. * hw - Struct containing variables accessed by shared code
  218. *****************************************************************************/
  219. static void
  220. e1000_phy_init_script(struct e1000_hw *hw)
  221. {
  222. DEBUGFUNC("e1000_phy_init_script");
  223. #if 0
  224. /* See e1000_sw_init() of the Linux driver */
  225. if(hw->phy_init_script) {
  226. #else
  227. if((hw->mac_type == e1000_82541) ||
  228. (hw->mac_type == e1000_82547) ||
  229. (hw->mac_type == e1000_82541_rev_2) ||
  230. (hw->mac_type == e1000_82547_rev_2)) {
  231. #endif
  232. mdelay(20);
  233. e1000_write_phy_reg(hw,0x0000,0x0140);
  234. mdelay(5);
  235. if(hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547) {
  236. e1000_write_phy_reg(hw, 0x1F95, 0x0001);
  237. e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
  238. e1000_write_phy_reg(hw, 0x1F79, 0x0018);
  239. e1000_write_phy_reg(hw, 0x1F30, 0x1600);
  240. e1000_write_phy_reg(hw, 0x1F31, 0x0014);
  241. e1000_write_phy_reg(hw, 0x1F32, 0x161C);
  242. e1000_write_phy_reg(hw, 0x1F94, 0x0003);
  243. e1000_write_phy_reg(hw, 0x1F96, 0x003F);
  244. e1000_write_phy_reg(hw, 0x2010, 0x0008);
  245. } else {
  246. e1000_write_phy_reg(hw, 0x1F73, 0x0099);
  247. }
  248. e1000_write_phy_reg(hw, 0x0000, 0x3300);
  249. if(hw->mac_type == e1000_82547) {
  250. uint16_t fused, fine, coarse;
  251. /* Move to analog registers page */
  252. e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
  253. if(!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
  254. e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
  255. fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
  256. coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
  257. if(coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
  258. coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
  259. fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
  260. } else if(coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
  261. fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
  262. fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
  263. (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
  264. (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
  265. e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
  266. e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
  267. IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
  268. }
  269. }
  270. }
  271. }
  272. /******************************************************************************
  273. * Set the mac type member in the hw struct.
  274. *
  275. * hw - Struct containing variables accessed by shared code
  276. *****************************************************************************/
  277. static int
  278. e1000_set_mac_type(struct e1000_hw *hw)
  279. {
  280. DEBUGFUNC("e1000_set_mac_type");
  281. switch (hw->device_id) {
  282. case E1000_DEV_ID_82542:
  283. switch (hw->revision_id) {
  284. case E1000_82542_2_0_REV_ID:
  285. hw->mac_type = e1000_82542_rev2_0;
  286. break;
  287. case E1000_82542_2_1_REV_ID:
  288. hw->mac_type = e1000_82542_rev2_1;
  289. break;
  290. default:
  291. /* Invalid 82542 revision ID */
  292. return -E1000_ERR_MAC_TYPE;
  293. }
  294. break;
  295. case E1000_DEV_ID_82543GC_FIBER:
  296. case E1000_DEV_ID_82543GC_COPPER:
  297. hw->mac_type = e1000_82543;
  298. break;
  299. case E1000_DEV_ID_82544EI_COPPER:
  300. case E1000_DEV_ID_82544EI_FIBER:
  301. case E1000_DEV_ID_82544GC_COPPER:
  302. case E1000_DEV_ID_82544GC_LOM:
  303. hw->mac_type = e1000_82544;
  304. break;
  305. case E1000_DEV_ID_82540EM:
  306. case E1000_DEV_ID_82540EM_LOM:
  307. case E1000_DEV_ID_82540EP:
  308. case E1000_DEV_ID_82540EP_LOM:
  309. case E1000_DEV_ID_82540EP_LP:
  310. hw->mac_type = e1000_82540;
  311. break;
  312. case E1000_DEV_ID_82545EM_COPPER:
  313. case E1000_DEV_ID_82545EM_FIBER:
  314. hw->mac_type = e1000_82545;
  315. break;
  316. case E1000_DEV_ID_82545GM_COPPER:
  317. case E1000_DEV_ID_82545GM_FIBER:
  318. case E1000_DEV_ID_82545GM_SERDES:
  319. hw->mac_type = e1000_82545_rev_3;
  320. break;
  321. case E1000_DEV_ID_82546EB_COPPER:
  322. case E1000_DEV_ID_82546EB_FIBER:
  323. case E1000_DEV_ID_82546EB_QUAD_COPPER:
  324. hw->mac_type = e1000_82546;
  325. break;
  326. case E1000_DEV_ID_82546GB_COPPER:
  327. case E1000_DEV_ID_82546GB_FIBER:
  328. case E1000_DEV_ID_82546GB_SERDES:
  329. hw->mac_type = e1000_82546_rev_3;
  330. break;
  331. case E1000_DEV_ID_82541EI:
  332. case E1000_DEV_ID_82541EI_MOBILE:
  333. hw->mac_type = e1000_82541;
  334. break;
  335. case E1000_DEV_ID_82541ER:
  336. case E1000_DEV_ID_82541GI:
  337. case E1000_DEV_ID_82541GI_MOBILE:
  338. hw->mac_type = e1000_82541_rev_2;
  339. break;
  340. case E1000_DEV_ID_82547EI:
  341. hw->mac_type = e1000_82547;
  342. break;
  343. case E1000_DEV_ID_82547GI:
  344. hw->mac_type = e1000_82547_rev_2;
  345. break;
  346. default:
  347. /* Should never have loaded on this device */
  348. return -E1000_ERR_MAC_TYPE;
  349. }
  350. return E1000_SUCCESS;
  351. }
  352. /*****************************************************************************
  353. * Set media type and TBI compatibility.
  354. *
  355. * hw - Struct containing variables accessed by shared code
  356. * **************************************************************************/
  357. static void
  358. e1000_set_media_type(struct e1000_hw *hw)
  359. {
  360. uint32_t status;
  361. DEBUGFUNC("e1000_set_media_type");
  362. if(hw->mac_type != e1000_82543) {
  363. /* tbi_compatibility is only valid on 82543 */
  364. hw->tbi_compatibility_en = FALSE;
  365. }
  366. switch (hw->device_id) {
  367. case E1000_DEV_ID_82545GM_SERDES:
  368. case E1000_DEV_ID_82546GB_SERDES:
  369. hw->media_type = e1000_media_type_internal_serdes;
  370. break;
  371. default:
  372. if(hw->mac_type >= e1000_82543) {
  373. status = E1000_READ_REG(hw, STATUS);
  374. if(status & E1000_STATUS_TBIMODE) {
  375. hw->media_type = e1000_media_type_fiber;
  376. /* tbi_compatibility not valid on fiber */
  377. hw->tbi_compatibility_en = FALSE;
  378. } else {
  379. hw->media_type = e1000_media_type_copper;
  380. }
  381. } else {
  382. /* This is an 82542 (fiber only) */
  383. hw->media_type = e1000_media_type_fiber;
  384. }
  385. }
  386. }
  387. /******************************************************************************
  388. * Reset the transmit and receive units; mask and clear all interrupts.
  389. *
  390. * hw - Struct containing variables accessed by shared code
  391. *****************************************************************************/
  392. static void
  393. e1000_reset_hw(struct e1000_hw *hw)
  394. {
  395. uint32_t ctrl;
  396. uint32_t ctrl_ext;
  397. uint32_t icr;
  398. uint32_t manc;
  399. DEBUGFUNC("e1000_reset_hw");
  400. /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
  401. if(hw->mac_type == e1000_82542_rev2_0) {
  402. DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  403. e1000_pci_clear_mwi(hw);
  404. }
  405. /* Clear interrupt mask to stop board from generating interrupts */
  406. DEBUGOUT("Masking off all interrupts\n");
  407. E1000_WRITE_REG(hw, IMC, 0xffffffff);
  408. /* Disable the Transmit and Receive units. Then delay to allow
  409. * any pending transactions to complete before we hit the MAC with
  410. * the global reset.
  411. */
  412. E1000_WRITE_REG(hw, RCTL, 0);
  413. E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
  414. E1000_WRITE_FLUSH(hw);
  415. /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
  416. hw->tbi_compatibility_on = FALSE;
  417. /* Delay to allow any outstanding PCI transactions to complete before
  418. * resetting the device
  419. */
  420. mdelay(10);
  421. ctrl = E1000_READ_REG(hw, CTRL);
  422. /* Must reset the PHY before resetting the MAC */
  423. if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  424. E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
  425. mdelay(5);
  426. }
  427. /* Issue a global reset to the MAC. This will reset the chip's
  428. * transmit, receive, DMA, and link units. It will not effect
  429. * the current PCI configuration. The global reset bit is self-
  430. * clearing, and should clear within a microsecond.
  431. */
  432. DEBUGOUT("Issuing a global reset to MAC\n");
  433. switch(hw->mac_type) {
  434. case e1000_82544:
  435. case e1000_82540:
  436. case e1000_82545:
  437. case e1000_82546:
  438. case e1000_82541:
  439. case e1000_82541_rev_2:
  440. /* These controllers can't ack the 64-bit write when issuing the
  441. * reset, so use IO-mapping as a workaround to issue the reset */
  442. E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
  443. break;
  444. case e1000_82545_rev_3:
  445. case e1000_82546_rev_3:
  446. /* Reset is performed on a shadow of the control register */
  447. E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
  448. break;
  449. default:
  450. E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
  451. break;
  452. }
  453. /* After MAC reset, force reload of EEPROM to restore power-on settings to
  454. * device. Later controllers reload the EEPROM automatically, so just wait
  455. * for reload to complete.
  456. */
  457. switch(hw->mac_type) {
  458. case e1000_82542_rev2_0:
  459. case e1000_82542_rev2_1:
  460. case e1000_82543:
  461. case e1000_82544:
  462. /* Wait for reset to complete */
  463. udelay(10);
  464. ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  465. ctrl_ext |= E1000_CTRL_EXT_EE_RST;
  466. E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  467. E1000_WRITE_FLUSH(hw);
  468. /* Wait for EEPROM reload */
  469. mdelay(2);
  470. break;
  471. case e1000_82541:
  472. case e1000_82541_rev_2:
  473. case e1000_82547:
  474. case e1000_82547_rev_2:
  475. /* Wait for EEPROM reload */
  476. mdelay(20);
  477. break;
  478. default:
  479. /* Wait for EEPROM reload (it happens automatically) */
  480. mdelay(5);
  481. break;
  482. }
  483. /* Disable HW ARPs on ASF enabled adapters */
  484. if(hw->mac_type >= e1000_82540) {
  485. manc = E1000_READ_REG(hw, MANC);
  486. manc &= ~(E1000_MANC_ARP_EN);
  487. E1000_WRITE_REG(hw, MANC, manc);
  488. }
  489. if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  490. e1000_phy_init_script(hw);
  491. }
  492. /* Clear interrupt mask to stop board from generating interrupts */
  493. DEBUGOUT("Masking off all interrupts\n");
  494. E1000_WRITE_REG(hw, IMC, 0xffffffff);
  495. /* Clear any pending interrupt events. */
  496. icr = E1000_READ_REG(hw, ICR);
  497. /* If MWI was previously enabled, reenable it. */
  498. if(hw->mac_type == e1000_82542_rev2_0) {
  499. #ifdef LINUX_DRIVER
  500. if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  501. #endif
  502. e1000_pci_set_mwi(hw);
  503. }
  504. }
  505. /******************************************************************************
  506. * Performs basic configuration of the adapter.
  507. *
  508. * hw - Struct containing variables accessed by shared code
  509. *
  510. * Assumes that the controller has previously been reset and is in a
  511. * post-reset uninitialized state. Initializes the receive address registers,
  512. * multicast table, and VLAN filter table. Calls routines to setup link
  513. * configuration and flow control settings. Clears all on-chip counters. Leaves
  514. * the transmit and receive units disabled and uninitialized.
  515. *****************************************************************************/
  516. static int
  517. e1000_init_hw(struct e1000_hw *hw)
  518. {
  519. uint32_t ctrl, status;
  520. uint32_t i;
  521. int32_t ret_val;
  522. uint16_t pcix_cmd_word;
  523. uint16_t pcix_stat_hi_word;
  524. uint16_t cmd_mmrbc;
  525. uint16_t stat_mmrbc;
  526. e1000_bus_type bus_type = e1000_bus_type_unknown;
  527. DEBUGFUNC("e1000_init_hw");
  528. /* Set the media type and TBI compatibility */
  529. e1000_set_media_type(hw);
  530. /* Disabling VLAN filtering. */
  531. DEBUGOUT("Initializing the IEEE VLAN\n");
  532. E1000_WRITE_REG(hw, VET, 0);
  533. e1000_clear_vfta(hw);
  534. /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
  535. if(hw->mac_type == e1000_82542_rev2_0) {
  536. DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  537. e1000_pci_clear_mwi(hw);
  538. E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
  539. E1000_WRITE_FLUSH(hw);
  540. mdelay(5);
  541. }
  542. /* Setup the receive address. This involves initializing all of the Receive
  543. * Address Registers (RARs 0 - 15).
  544. */
  545. e1000_init_rx_addrs(hw);
  546. /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
  547. if(hw->mac_type == e1000_82542_rev2_0) {
  548. E1000_WRITE_REG(hw, RCTL, 0);
  549. E1000_WRITE_FLUSH(hw);
  550. mdelay(1);
  551. #ifdef LINUX_DRIVER
  552. if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  553. #endif
  554. e1000_pci_set_mwi(hw);
  555. }
  556. /* Zero out the Multicast HASH table */
  557. DEBUGOUT("Zeroing the MTA\n");
  558. for(i = 0; i < E1000_MC_TBL_SIZE; i++)
  559. E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
  560. #if 0
  561. /* Set the PCI priority bit correctly in the CTRL register. This
  562. * determines if the adapter gives priority to receives, or if it
  563. * gives equal priority to transmits and receives.
  564. */
  565. if(hw->dma_fairness) {
  566. ctrl = E1000_READ_REG(hw, CTRL);
  567. E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
  568. }
  569. #endif
  570. switch(hw->mac_type) {
  571. case e1000_82545_rev_3:
  572. case e1000_82546_rev_3:
  573. break;
  574. default:
  575. if (hw->mac_type >= e1000_82543) {
  576. /* See e1000_get_bus_info() of the Linux driver */
  577. status = E1000_READ_REG(hw, STATUS);
  578. bus_type = (status & E1000_STATUS_PCIX_MODE) ?
  579. e1000_bus_type_pcix : e1000_bus_type_pci;
  580. }
  581. /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
  582. if(bus_type == e1000_bus_type_pcix) {
  583. pci_read_config_word(hw->pdev, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
  584. pci_read_config_word(hw->pdev, PCIX_STATUS_REGISTER_HI, &pcix_stat_hi_word);
  585. cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
  586. PCIX_COMMAND_MMRBC_SHIFT;
  587. stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
  588. PCIX_STATUS_HI_MMRBC_SHIFT;
  589. if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
  590. stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
  591. if(cmd_mmrbc > stat_mmrbc) {
  592. pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
  593. pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
  594. pci_write_config_word(hw->pdev, PCIX_COMMAND_REGISTER, pcix_cmd_word);
  595. }
  596. }
  597. break;
  598. }
  599. /* Call a subroutine to configure the link and setup flow control. */
  600. ret_val = e1000_setup_link(hw);
  601. /* Set the transmit descriptor write-back policy */
  602. if(hw->mac_type > e1000_82544) {
  603. ctrl = E1000_READ_REG(hw, TXDCTL);
  604. ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
  605. E1000_WRITE_REG(hw, TXDCTL, ctrl);
  606. }
  607. #if 0
  608. /* Clear all of the statistics registers (clear on read). It is
  609. * important that we do this after we have tried to establish link
  610. * because the symbol error count will increment wildly if there
  611. * is no link.
  612. */
  613. e1000_clear_hw_cntrs(hw);
  614. #endif
  615. return ret_val;
  616. }
  617. /******************************************************************************
  618. * Adjust SERDES output amplitude based on EEPROM setting.
  619. *
  620. * hw - Struct containing variables accessed by shared code.
  621. *****************************************************************************/
  622. static int32_t
  623. e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
  624. {
  625. uint16_t eeprom_data;
  626. int32_t ret_val;
  627. DEBUGFUNC("e1000_adjust_serdes_amplitude");
  628. if(hw->media_type != e1000_media_type_internal_serdes)
  629. return E1000_SUCCESS;
  630. switch(hw->mac_type) {
  631. case e1000_82545_rev_3:
  632. case e1000_82546_rev_3:
  633. break;
  634. default:
  635. return E1000_SUCCESS;
  636. }
  637. if ((ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1,
  638. &eeprom_data))) {
  639. return ret_val;
  640. }
  641. if(eeprom_data != EEPROM_RESERVED_WORD) {
  642. /* Adjust SERDES output amplitude only. */
  643. eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
  644. if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL,
  645. eeprom_data)))
  646. return ret_val;
  647. }
  648. return E1000_SUCCESS;
  649. }
  650. /******************************************************************************
  651. * Configures flow control and link settings.
  652. *
  653. * hw - Struct containing variables accessed by shared code
  654. *
  655. * Determines which flow control settings to use. Calls the apropriate media-
  656. * specific link configuration function. Configures the flow control settings.
  657. * Assuming the adapter has a valid link partner, a valid link should be
  658. * established. Assumes the hardware has previously been reset and the
  659. * transmitter and receiver are not enabled.
  660. *****************************************************************************/
  661. static int
  662. e1000_setup_link(struct e1000_hw *hw)
  663. {
  664. uint32_t ctrl_ext;
  665. int32_t ret_val;
  666. uint16_t eeprom_data;
  667. DEBUGFUNC("e1000_setup_link");
  668. /* Read and store word 0x0F of the EEPROM. This word contains bits
  669. * that determine the hardware's default PAUSE (flow control) mode,
  670. * a bit that determines whether the HW defaults to enabling or
  671. * disabling auto-negotiation, and the direction of the
  672. * SW defined pins. If there is no SW over-ride of the flow
  673. * control setting, then the variable hw->fc will
  674. * be initialized based on a value in the EEPROM.
  675. */
  676. if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data) < 0) {
  677. DEBUGOUT("EEPROM Read Error\n");
  678. return -E1000_ERR_EEPROM;
  679. }
  680. if(hw->fc == e1000_fc_default) {
  681. if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
  682. hw->fc = e1000_fc_none;
  683. else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
  684. EEPROM_WORD0F_ASM_DIR)
  685. hw->fc = e1000_fc_tx_pause;
  686. else
  687. hw->fc = e1000_fc_full;
  688. }
  689. /* We want to save off the original Flow Control configuration just
  690. * in case we get disconnected and then reconnected into a different
  691. * hub or switch with different Flow Control capabilities.
  692. */
  693. if(hw->mac_type == e1000_82542_rev2_0)
  694. hw->fc &= (~e1000_fc_tx_pause);
  695. #if 0
  696. /* See e1000_sw_init() of the Linux driver */
  697. if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
  698. #else
  699. if((hw->mac_type < e1000_82543) && (hw->mac_type >= e1000_82543))
  700. #endif
  701. hw->fc &= (~e1000_fc_rx_pause);
  702. #if 0
  703. hw->original_fc = hw->fc;
  704. #endif
  705. DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
  706. /* Take the 4 bits from EEPROM word 0x0F that determine the initial
  707. * polarity value for the SW controlled pins, and setup the
  708. * Extended Device Control reg with that info.
  709. * This is needed because one of the SW controlled pins is used for
  710. * signal detection. So this should be done before e1000_setup_pcs_link()
  711. * or e1000_phy_setup() is called.
  712. */
  713. if(hw->mac_type == e1000_82543) {
  714. ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
  715. SWDPIO__EXT_SHIFT);
  716. E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  717. }
  718. /* Call the necessary subroutine to configure the link. */
  719. ret_val = (hw->media_type == e1000_media_type_copper) ?
  720. e1000_setup_copper_link(hw) :
  721. e1000_setup_fiber_serdes_link(hw);
  722. if (ret_val < 0) {
  723. return ret_val;
  724. }
  725. /* Initialize the flow control address, type, and PAUSE timer
  726. * registers to their default values. This is done even if flow
  727. * control is disabled, because it does not hurt anything to
  728. * initialize these registers.
  729. */
  730. DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
  731. E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
  732. E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
  733. E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
  734. #if 0
  735. E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
  736. #else
  737. E1000_WRITE_REG(hw, FCTTV, FC_DEFAULT_TX_TIMER);
  738. #endif
  739. /* Set the flow control receive threshold registers. Normally,
  740. * these registers will be set to a default threshold that may be
  741. * adjusted later by the driver's runtime code. However, if the
  742. * ability to transmit pause frames in not enabled, then these
  743. * registers will be set to 0.
  744. */
  745. if(!(hw->fc & e1000_fc_tx_pause)) {
  746. E1000_WRITE_REG(hw, FCRTL, 0);
  747. E1000_WRITE_REG(hw, FCRTH, 0);
  748. } else {
  749. /* We need to set up the Receive Threshold high and low water marks
  750. * as well as (optionally) enabling the transmission of XON frames.
  751. */
  752. #if 0
  753. if(hw->fc_send_xon) {
  754. E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
  755. E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  756. } else {
  757. E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
  758. E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  759. }
  760. #else
  761. E1000_WRITE_REG(hw, FCRTL, (FC_DEFAULT_LO_THRESH | E1000_FCRTL_XONE));
  762. E1000_WRITE_REG(hw, FCRTH, FC_DEFAULT_HI_THRESH);
  763. #endif
  764. }
  765. return ret_val;
  766. }
  767. /******************************************************************************
  768. * Sets up link for a fiber based or serdes based adapter
  769. *
  770. * hw - Struct containing variables accessed by shared code
  771. *
  772. * Manipulates Physical Coding Sublayer functions in order to configure
  773. * link. Assumes the hardware has been previously reset and the transmitter
  774. * and receiver are not enabled.
  775. *****************************************************************************/
  776. static int
  777. e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
  778. {
  779. uint32_t ctrl;
  780. uint32_t status;
  781. uint32_t txcw = 0;
  782. uint32_t i;
  783. uint32_t signal = 0;
  784. int32_t ret_val;
  785. DEBUGFUNC("e1000_setup_fiber_serdes_link");
  786. /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  787. * set when the optics detect a signal. On older adapters, it will be
  788. * cleared when there is a signal. This applies to fiber media only.
  789. * If we're on serdes media, adjust the output amplitude to value set in
  790. * the EEPROM.
  791. */
  792. ctrl = E1000_READ_REG(hw, CTRL);
  793. if(hw->media_type == e1000_media_type_fiber)
  794. signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  795. if((ret_val = e1000_adjust_serdes_amplitude(hw)))
  796. return ret_val;
  797. /* Take the link out of reset */
  798. ctrl &= ~(E1000_CTRL_LRST);
  799. #if 0
  800. /* Adjust VCO speed to improve BER performance */
  801. if((ret_val = e1000_set_vco_speed(hw)))
  802. return ret_val;
  803. #endif
  804. e1000_config_collision_dist(hw);
  805. /* Check for a software override of the flow control settings, and setup
  806. * the device accordingly. If auto-negotiation is enabled, then software
  807. * will have to set the "PAUSE" bits to the correct value in the Tranmsit
  808. * Config Word Register (TXCW) and re-start auto-negotiation. However, if
  809. * auto-negotiation is disabled, then software will have to manually
  810. * configure the two flow control enable bits in the CTRL register.
  811. *
  812. * The possible values of the "fc" parameter are:
  813. * 0: Flow control is completely disabled
  814. * 1: Rx flow control is enabled (we can receive pause frames, but
  815. * not send pause frames).
  816. * 2: Tx flow control is enabled (we can send pause frames but we do
  817. * not support receiving pause frames).
  818. * 3: Both Rx and TX flow control (symmetric) are enabled.
  819. */
  820. switch (hw->fc) {
  821. case e1000_fc_none:
  822. /* Flow control is completely disabled by a software over-ride. */
  823. txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
  824. break;
  825. case e1000_fc_rx_pause:
  826. /* RX Flow control is enabled and TX Flow control is disabled by a
  827. * software over-ride. Since there really isn't a way to advertise
  828. * that we are capable of RX Pause ONLY, we will advertise that we
  829. * support both symmetric and asymmetric RX PAUSE. Later, we will
  830. * disable the adapter's ability to send PAUSE frames.
  831. */
  832. txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  833. break;
  834. case e1000_fc_tx_pause:
  835. /* TX Flow control is enabled, and RX Flow control is disabled, by a
  836. * software over-ride.
  837. */
  838. txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
  839. break;
  840. case e1000_fc_full:
  841. /* Flow control (both RX and TX) is enabled by a software over-ride. */
  842. txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  843. break;
  844. default:
  845. DEBUGOUT("Flow control param set incorrectly\n");
  846. return -E1000_ERR_CONFIG;
  847. break;
  848. }
  849. /* Since auto-negotiation is enabled, take the link out of reset (the link
  850. * will be in reset, because we previously reset the chip). This will
  851. * restart auto-negotiation. If auto-neogtiation is successful then the
  852. * link-up status bit will be set and the flow control enable bits (RFCE
  853. * and TFCE) will be set according to their negotiated value.
  854. */
  855. DEBUGOUT("Auto-negotiation enabled\n");
  856. E1000_WRITE_REG(hw, TXCW, txcw);
  857. E1000_WRITE_REG(hw, CTRL, ctrl);
  858. E1000_WRITE_FLUSH(hw);
  859. hw->txcw = txcw;
  860. mdelay(1);
  861. /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
  862. * indication in the Device Status Register. Time-out if a link isn't
  863. * seen in 500 milliseconds seconds (Auto-negotiation should complete in
  864. * less than 500 milliseconds even if the other end is doing it in SW).
  865. * For internal serdes, we just assume a signal is present, then poll.
  866. */
  867. if(hw->media_type == e1000_media_type_internal_serdes ||
  868. (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
  869. DEBUGOUT("Looking for Link\n");
  870. for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
  871. mdelay(10);
  872. status = E1000_READ_REG(hw, STATUS);
  873. if(status & E1000_STATUS_LU) break;
  874. }
  875. if(i == (LINK_UP_TIMEOUT / 10)) {
  876. DEBUGOUT("Never got a valid link from auto-neg!!!\n");
  877. hw->autoneg_failed = 1;
  878. /* AutoNeg failed to achieve a link, so we'll call
  879. * e1000_check_for_link. This routine will force the link up if
  880. * we detect a signal. This will allow us to communicate with
  881. * non-autonegotiating link partners.
  882. */
  883. if((ret_val = e1000_check_for_link(hw))) {
  884. DEBUGOUT("Error while checking for link\n");
  885. return ret_val;
  886. }
  887. hw->autoneg_failed = 0;
  888. } else {
  889. hw->autoneg_failed = 0;
  890. DEBUGOUT("Valid Link Found\n");
  891. }
  892. } else {
  893. DEBUGOUT("No Signal Detected\n");
  894. }
  895. return E1000_SUCCESS;
  896. }
  897. /******************************************************************************
  898. * Detects which PHY is present and the speed and duplex
  899. *
  900. * hw - Struct containing variables accessed by shared code
  901. ******************************************************************************/
  902. static int
  903. e1000_setup_copper_link(struct e1000_hw *hw)
  904. {
  905. uint32_t ctrl;
  906. int32_t ret_val;
  907. uint16_t i;
  908. uint16_t phy_data;
  909. DEBUGFUNC("e1000_setup_copper_link");
  910. ctrl = E1000_READ_REG(hw, CTRL);
  911. /* With 82543, we need to force speed and duplex on the MAC equal to what
  912. * the PHY speed and duplex configuration is. In addition, we need to
  913. * perform a hardware reset on the PHY to take it out of reset.
  914. */
  915. if(hw->mac_type > e1000_82543) {
  916. ctrl |= E1000_CTRL_SLU;
  917. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  918. E1000_WRITE_REG(hw, CTRL, ctrl);
  919. } else {
  920. ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
  921. E1000_WRITE_REG(hw, CTRL, ctrl);
  922. e1000_phy_hw_reset(hw);
  923. }
  924. /* Make sure we have a valid PHY */
  925. if((ret_val = e1000_detect_gig_phy(hw))) {
  926. DEBUGOUT("Error, did not detect valid phy.\n");
  927. return ret_val;
  928. }
  929. DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
  930. if(hw->mac_type <= e1000_82543 ||
  931. hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
  932. #if 0
  933. hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
  934. hw->phy_reset_disable = FALSE;
  935. if(!hw->phy_reset_disable) {
  936. #else
  937. hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
  938. #endif
  939. if (hw->phy_type == e1000_phy_igp) {
  940. if((ret_val = e1000_phy_reset(hw))) {
  941. DEBUGOUT("Error Resetting the PHY\n");
  942. return ret_val;
  943. }
  944. /* Wait 10ms for MAC to configure PHY from eeprom settings */
  945. mdelay(15);
  946. #if 0
  947. /* disable lplu d3 during driver init */
  948. if((ret_val = e1000_set_d3_lplu_state(hw, FALSE))) {
  949. DEBUGOUT("Error Disabling LPLU D3\n");
  950. return ret_val;
  951. }
  952. /* Configure mdi-mdix settings */
  953. if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  954. &phy_data)))
  955. return ret_val;
  956. if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  957. hw->dsp_config_state = e1000_dsp_config_disabled;
  958. /* Force MDI for IGP B-0 PHY */
  959. phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX |
  960. IGP01E1000_PSCR_FORCE_MDI_MDIX);
  961. hw->mdix = 1;
  962. } else {
  963. hw->dsp_config_state = e1000_dsp_config_enabled;
  964. phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  965. switch (hw->mdix) {
  966. case 1:
  967. phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  968. break;
  969. case 2:
  970. phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
  971. break;
  972. case 0:
  973. default:
  974. phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
  975. break;
  976. }
  977. }
  978. if((ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  979. phy_data)))
  980. return ret_val;
  981. /* set auto-master slave resolution settings */
  982. e1000_ms_type phy_ms_setting = hw->master_slave;
  983. if(hw->ffe_config_state == e1000_ffe_config_active)
  984. hw->ffe_config_state = e1000_ffe_config_enabled;
  985. if(hw->dsp_config_state == e1000_dsp_config_activated)
  986. hw->dsp_config_state = e1000_dsp_config_enabled;
  987. #endif
  988. /* when autonegotiation advertisment is only 1000Mbps then we
  989. * should disable SmartSpeed and enable Auto MasterSlave
  990. * resolution as hardware default. */
  991. if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
  992. /* Disable SmartSpeed */
  993. if((ret_val = e1000_read_phy_reg(hw,
  994. IGP01E1000_PHY_PORT_CONFIG,
  995. &phy_data)))
  996. return ret_val;
  997. phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  998. if((ret_val = e1000_write_phy_reg(hw,
  999. IGP01E1000_PHY_PORT_CONFIG,
  1000. phy_data)))
  1001. return ret_val;
  1002. /* Set auto Master/Slave resolution process */
  1003. if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  1004. &phy_data)))
  1005. return ret_val;
  1006. phy_data &= ~CR_1000T_MS_ENABLE;
  1007. if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  1008. phy_data)))
  1009. return ret_val;
  1010. }
  1011. if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  1012. &phy_data)))
  1013. return ret_val;
  1014. #if 0
  1015. /* load defaults for future use */
  1016. hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
  1017. ((phy_data & CR_1000T_MS_VALUE) ?
  1018. e1000_ms_force_master :
  1019. e1000_ms_force_slave) :
  1020. e1000_ms_auto;
  1021. switch (phy_ms_setting) {
  1022. case e1000_ms_force_master:
  1023. phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
  1024. break;
  1025. case e1000_ms_force_slave:
  1026. phy_data |= CR_1000T_MS_ENABLE;
  1027. phy_data &= ~(CR_1000T_MS_VALUE);
  1028. break;
  1029. case e1000_ms_auto:
  1030. phy_data &= ~CR_1000T_MS_ENABLE;
  1031. default:
  1032. break;
  1033. }
  1034. #endif
  1035. if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  1036. phy_data)))
  1037. return ret_val;
  1038. } else {
  1039. /* Enable CRS on TX. This must be set for half-duplex operation. */
  1040. if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  1041. &phy_data)))
  1042. return ret_val;
  1043. phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  1044. /* Options:
  1045. * MDI/MDI-X = 0 (default)
  1046. * 0 - Auto for all speeds
  1047. * 1 - MDI mode
  1048. * 2 - MDI-X mode
  1049. * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  1050. */
  1051. #if 0
  1052. phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  1053. switch (hw->mdix) {
  1054. case 1:
  1055. phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
  1056. break;
  1057. case 2:
  1058. phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
  1059. break;
  1060. case 3:
  1061. phy_data |= M88E1000_PSCR_AUTO_X_1000T;
  1062. break;
  1063. case 0:
  1064. default:
  1065. #endif
  1066. phy_data |= M88E1000_PSCR_AUTO_X_MODE;
  1067. #if 0
  1068. break;
  1069. }
  1070. #endif
  1071. /* Options:
  1072. * disable_polarity_correction = 0 (default)
  1073. * Automatic Correction for Reversed Cable Polarity
  1074. * 0 - Disabled
  1075. * 1 - Enabled
  1076. */
  1077. phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
  1078. if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  1079. phy_data)))
  1080. return ret_val;
  1081. /* Force TX_CLK in the Extended PHY Specific Control Register
  1082. * to 25MHz clock.
  1083. */
  1084. if((ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
  1085. &phy_data)))
  1086. return ret_val;
  1087. phy_data |= M88E1000_EPSCR_TX_CLK_25;
  1088. #ifdef LINUX_DRIVER
  1089. if (hw->phy_revision < M88E1011_I_REV_4) {
  1090. #endif
  1091. /* Configure Master and Slave downshift values */
  1092. phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
  1093. M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
  1094. phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
  1095. M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
  1096. if((ret_val = e1000_write_phy_reg(hw,
  1097. M88E1000_EXT_PHY_SPEC_CTRL,
  1098. phy_data)))
  1099. return ret_val;
  1100. }
  1101. /* SW Reset the PHY so all changes take effect */
  1102. if((ret_val = e1000_phy_reset(hw))) {
  1103. DEBUGOUT("Error Resetting the PHY\n");
  1104. return ret_val;
  1105. #ifdef LINUX_DRIVER
  1106. }
  1107. #endif
  1108. }
  1109. /* Options:
  1110. * autoneg = 1 (default)
  1111. * PHY will advertise value(s) parsed from
  1112. * autoneg_advertised and fc
  1113. * autoneg = 0
  1114. * PHY will be set to 10H, 10F, 100H, or 100F
  1115. * depending on value parsed from forced_speed_duplex.
  1116. */
  1117. /* Is autoneg enabled? This is enabled by default or by software
  1118. * override. If so, call e1000_phy_setup_autoneg routine to parse the
  1119. * autoneg_advertised and fc options. If autoneg is NOT enabled, then
  1120. * the user should have provided a speed/duplex override. If so, then
  1121. * call e1000_phy_force_speed_duplex to parse and set this up.
  1122. */
  1123. /* Perform some bounds checking on the hw->autoneg_advertised
  1124. * parameter. If this variable is zero, then set it to the default.
  1125. */
  1126. hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
  1127. /* If autoneg_advertised is zero, we assume it was not defaulted
  1128. * by the calling code so we set to advertise full capability.
  1129. */
  1130. if(hw->autoneg_advertised == 0)
  1131. hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  1132. DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
  1133. if((ret_val = e1000_phy_setup_autoneg(hw))) {
  1134. DEBUGOUT("Error Setting up Auto-Negotiation\n");
  1135. return ret_val;
  1136. }
  1137. DEBUGOUT("Restarting Auto-Neg\n");
  1138. /* Restart auto-negotiation by setting the Auto Neg Enable bit and
  1139. * the Auto Neg Restart bit in the PHY control register.
  1140. */
  1141. if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  1142. return ret_val;
  1143. phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
  1144. if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  1145. return ret_val;
  1146. #if 0
  1147. /* Does the user want to wait for Auto-Neg to complete here, or
  1148. * check at a later time (for example, callback routine).
  1149. */
  1150. if(hw->wait_autoneg_complete) {
  1151. if((ret_val = e1000_wait_autoneg(hw))) {
  1152. DEBUGOUT("Error while waiting for autoneg to complete\n");
  1153. return ret_val;
  1154. }
  1155. }
  1156. #else
  1157. /* If we do not wait for autonegotiation to complete I
  1158. * do not see a valid link status.
  1159. */
  1160. if((ret_val = e1000_wait_autoneg(hw))) {
  1161. DEBUGOUT("Error while waiting for autoneg to complete\n");
  1162. return ret_val;
  1163. }
  1164. #endif
  1165. } /* !hw->phy_reset_disable */
  1166. /* Check link status. Wait up to 100 microseconds for link to become
  1167. * valid.
  1168. */
  1169. for(i = 0; i < 10; i++) {
  1170. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1171. return ret_val;
  1172. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1173. return ret_val;
  1174. if(phy_data & MII_SR_LINK_STATUS) {
  1175. /* We have link, so we need to finish the config process:
  1176. * 1) Set up the MAC to the current PHY speed/duplex
  1177. * if we are on 82543. If we
  1178. * are on newer silicon, we only need to configure
  1179. * collision distance in the Transmit Control Register.
  1180. * 2) Set up flow control on the MAC to that established with
  1181. * the link partner.
  1182. */
  1183. if(hw->mac_type >= e1000_82544) {
  1184. e1000_config_collision_dist(hw);
  1185. } else {
  1186. if((ret_val = e1000_config_mac_to_phy(hw))) {
  1187. DEBUGOUT("Error configuring MAC to PHY settings\n");
  1188. return ret_val;
  1189. }
  1190. }
  1191. if((ret_val = e1000_config_fc_after_link_up(hw))) {
  1192. DEBUGOUT("Error Configuring Flow Control\n");
  1193. return ret_val;
  1194. }
  1195. #if 0
  1196. if(hw->phy_type == e1000_phy_igp) {
  1197. if((ret_val = e1000_config_dsp_after_link_change(hw, TRUE))) {
  1198. DEBUGOUT("Error Configuring DSP after link up\n");
  1199. return ret_val;
  1200. }
  1201. }
  1202. #endif
  1203. DEBUGOUT("Valid link established!!!\n");
  1204. return E1000_SUCCESS;
  1205. }
  1206. udelay(10);
  1207. }
  1208. DEBUGOUT("Unable to establish link!!!\n");
  1209. return -E1000_ERR_NOLINK;
  1210. }
  1211. /******************************************************************************
  1212. * Configures PHY autoneg and flow control advertisement settings
  1213. *
  1214. * hw - Struct containing variables accessed by shared code
  1215. ******************************************************************************/
  1216. static int
  1217. e1000_phy_setup_autoneg(struct e1000_hw *hw)
  1218. {
  1219. int32_t ret_val;
  1220. uint16_t mii_autoneg_adv_reg;
  1221. uint16_t mii_1000t_ctrl_reg;
  1222. DEBUGFUNC("e1000_phy_setup_autoneg");
  1223. /* Read the MII Auto-Neg Advertisement Register (Address 4). */
  1224. if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  1225. &mii_autoneg_adv_reg)))
  1226. return ret_val;
  1227. /* Read the MII 1000Base-T Control Register (Address 9). */
  1228. if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg)))
  1229. return ret_val;
  1230. /* Need to parse both autoneg_advertised and fc and set up
  1231. * the appropriate PHY registers. First we will parse for
  1232. * autoneg_advertised software override. Since we can advertise
  1233. * a plethora of combinations, we need to check each bit
  1234. * individually.
  1235. */
  1236. /* First we clear all the 10/100 mb speed bits in the Auto-Neg
  1237. * Advertisement Register (Address 4) and the 1000 mb speed bits in
  1238. * the 1000Base-T Control Register (Address 9).
  1239. */
  1240. mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
  1241. mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
  1242. DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
  1243. /* Do we want to advertise 10 Mb Half Duplex? */
  1244. if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
  1245. DEBUGOUT("Advertise 10mb Half duplex\n");
  1246. mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
  1247. }
  1248. /* Do we want to advertise 10 Mb Full Duplex? */
  1249. if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
  1250. DEBUGOUT("Advertise 10mb Full duplex\n");
  1251. mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
  1252. }
  1253. /* Do we want to advertise 100 Mb Half Duplex? */
  1254. if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
  1255. DEBUGOUT("Advertise 100mb Half duplex\n");
  1256. mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
  1257. }
  1258. /* Do we want to advertise 100 Mb Full Duplex? */
  1259. if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
  1260. DEBUGOUT("Advertise 100mb Full duplex\n");
  1261. mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
  1262. }
  1263. /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
  1264. if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
  1265. DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
  1266. }
  1267. /* Do we want to advertise 1000 Mb Full Duplex? */
  1268. if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
  1269. DEBUGOUT("Advertise 1000mb Full duplex\n");
  1270. mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
  1271. }
  1272. /* Check for a software override of the flow control settings, and
  1273. * setup the PHY advertisement registers accordingly. If
  1274. * auto-negotiation is enabled, then software will have to set the
  1275. * "PAUSE" bits to the correct value in the Auto-Negotiation
  1276. * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
  1277. *
  1278. * The possible values of the "fc" parameter are:
  1279. * 0: Flow control is completely disabled
  1280. * 1: Rx flow control is enabled (we can receive pause frames
  1281. * but not send pause frames).
  1282. * 2: Tx flow control is enabled (we can send pause frames
  1283. * but we do not support receiving pause frames).
  1284. * 3: Both Rx and TX flow control (symmetric) are enabled.
  1285. * other: No software override. The flow control configuration
  1286. * in the EEPROM is used.
  1287. */
  1288. switch (hw->fc) {
  1289. case e1000_fc_none: /* 0 */
  1290. /* Flow control (RX & TX) is completely disabled by a
  1291. * software over-ride.
  1292. */
  1293. mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  1294. break;
  1295. case e1000_fc_rx_pause: /* 1 */
  1296. /* RX Flow control is enabled, and TX Flow control is
  1297. * disabled, by a software over-ride.
  1298. */
  1299. /* Since there really isn't a way to advertise that we are
  1300. * capable of RX Pause ONLY, we will advertise that we
  1301. * support both symmetric and asymmetric RX PAUSE. Later
  1302. * (in e1000_config_fc_after_link_up) we will disable the
  1303. *hw's ability to send PAUSE frames.
  1304. */
  1305. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  1306. break;
  1307. case e1000_fc_tx_pause: /* 2 */
  1308. /* TX Flow control is enabled, and RX Flow control is
  1309. * disabled, by a software over-ride.
  1310. */
  1311. mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
  1312. mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
  1313. break;
  1314. case e1000_fc_full: /* 3 */
  1315. /* Flow control (both RX and TX) is enabled by a software
  1316. * over-ride.
  1317. */
  1318. mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  1319. break;
  1320. default:
  1321. DEBUGOUT("Flow control param set incorrectly\n");
  1322. return -E1000_ERR_CONFIG;
  1323. }
  1324. if((ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV,
  1325. mii_autoneg_adv_reg)))
  1326. return ret_val;
  1327. DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
  1328. if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg)))
  1329. return ret_val;
  1330. return E1000_SUCCESS;
  1331. }
  1332. /******************************************************************************
  1333. * Sets the collision distance in the Transmit Control register
  1334. *
  1335. * hw - Struct containing variables accessed by shared code
  1336. *
  1337. * Link should have been established previously. Reads the speed and duplex
  1338. * information from the Device Status register.
  1339. ******************************************************************************/
  1340. static void
  1341. e1000_config_collision_dist(struct e1000_hw *hw)
  1342. {
  1343. uint32_t tctl;
  1344. tctl = E1000_READ_REG(hw, TCTL);
  1345. tctl &= ~E1000_TCTL_COLD;
  1346. tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
  1347. E1000_WRITE_REG(hw, TCTL, tctl);
  1348. E1000_WRITE_FLUSH(hw);
  1349. }
  1350. /******************************************************************************
  1351. * Sets MAC speed and duplex settings to reflect the those in the PHY
  1352. *
  1353. * hw - Struct containing variables accessed by shared code
  1354. * mii_reg - data to write to the MII control register
  1355. *
  1356. * The contents of the PHY register containing the needed information need to
  1357. * be passed in.
  1358. ******************************************************************************/
  1359. static int
  1360. e1000_config_mac_to_phy(struct e1000_hw *hw)
  1361. {
  1362. uint32_t ctrl;
  1363. int32_t ret_val;
  1364. uint16_t phy_data;
  1365. DEBUGFUNC("e1000_config_mac_to_phy");
  1366. /* Read the Device Control Register and set the bits to Force Speed
  1367. * and Duplex.
  1368. */
  1369. ctrl = E1000_READ_REG(hw, CTRL);
  1370. ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  1371. ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
  1372. /* Set up duplex in the Device Control and Transmit Control
  1373. * registers depending on negotiated values.
  1374. */
  1375. if (hw->phy_type == e1000_phy_igp) {
  1376. if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
  1377. &phy_data)))
  1378. return ret_val;
  1379. if(phy_data & IGP01E1000_PSSR_FULL_DUPLEX) ctrl |= E1000_CTRL_FD;
  1380. else ctrl &= ~E1000_CTRL_FD;
  1381. e1000_config_collision_dist(hw);
  1382. /* Set up speed in the Device Control register depending on
  1383. * negotiated values.
  1384. */
  1385. if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  1386. IGP01E1000_PSSR_SPEED_1000MBPS)
  1387. ctrl |= E1000_CTRL_SPD_1000;
  1388. else if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  1389. IGP01E1000_PSSR_SPEED_100MBPS)
  1390. ctrl |= E1000_CTRL_SPD_100;
  1391. } else {
  1392. if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
  1393. &phy_data)))
  1394. return ret_val;
  1395. if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD;
  1396. else ctrl &= ~E1000_CTRL_FD;
  1397. e1000_config_collision_dist(hw);
  1398. /* Set up speed in the Device Control register depending on
  1399. * negotiated values.
  1400. */
  1401. if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
  1402. ctrl |= E1000_CTRL_SPD_1000;
  1403. else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
  1404. ctrl |= E1000_CTRL_SPD_100;
  1405. }
  1406. /* Write the configured values back to the Device Control Reg. */
  1407. E1000_WRITE_REG(hw, CTRL, ctrl);
  1408. return E1000_SUCCESS;
  1409. }
  1410. /******************************************************************************
  1411. * Forces the MAC's flow control settings.
  1412. *
  1413. * hw - Struct containing variables accessed by shared code
  1414. *
  1415. * Sets the TFCE and RFCE bits in the device control register to reflect
  1416. * the adapter settings. TFCE and RFCE need to be explicitly set by
  1417. * software when a Copper PHY is used because autonegotiation is managed
  1418. * by the PHY rather than the MAC. Software must also configure these
  1419. * bits when link is forced on a fiber connection.
  1420. *****************************************************************************/
  1421. static int
  1422. e1000_force_mac_fc(struct e1000_hw *hw)
  1423. {
  1424. uint32_t ctrl;
  1425. DEBUGFUNC("e1000_force_mac_fc");
  1426. /* Get the current configuration of the Device Control Register */
  1427. ctrl = E1000_READ_REG(hw, CTRL);
  1428. /* Because we didn't get link via the internal auto-negotiation
  1429. * mechanism (we either forced link or we got link via PHY
  1430. * auto-neg), we have to manually enable/disable transmit an
  1431. * receive flow control.
  1432. *
  1433. * The "Case" statement below enables/disable flow control
  1434. * according to the "hw->fc" parameter.
  1435. *
  1436. * The possible values of the "fc" parameter are:
  1437. * 0: Flow control is completely disabled
  1438. * 1: Rx flow control is enabled (we can receive pause
  1439. * frames but not send pause frames).
  1440. * 2: Tx flow control is enabled (we can send pause frames
  1441. * frames but we do not receive pause frames).
  1442. * 3: Both Rx and TX flow control (symmetric) is enabled.
  1443. * other: No other values should be possible at this point.
  1444. */
  1445. switch (hw->fc) {
  1446. case e1000_fc_none:
  1447. ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
  1448. break;
  1449. case e1000_fc_rx_pause:
  1450. ctrl &= (~E1000_CTRL_TFCE);
  1451. ctrl |= E1000_CTRL_RFCE;
  1452. break;
  1453. case e1000_fc_tx_pause:
  1454. ctrl &= (~E1000_CTRL_RFCE);
  1455. ctrl |= E1000_CTRL_TFCE;
  1456. break;
  1457. case e1000_fc_full:
  1458. ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
  1459. break;
  1460. default:
  1461. DEBUGOUT("Flow control param set incorrectly\n");
  1462. return -E1000_ERR_CONFIG;
  1463. }
  1464. /* Disable TX Flow Control for 82542 (rev 2.0) */
  1465. if(hw->mac_type == e1000_82542_rev2_0)
  1466. ctrl &= (~E1000_CTRL_TFCE);
  1467. E1000_WRITE_REG(hw, CTRL, ctrl);
  1468. return E1000_SUCCESS;
  1469. }
  1470. /******************************************************************************
  1471. * Configures flow control settings after link is established
  1472. *
  1473. * hw - Struct containing variables accessed by shared code
  1474. *
  1475. * Should be called immediately after a valid link has been established.
  1476. * Forces MAC flow control settings if link was forced. When in MII/GMII mode
  1477. * and autonegotiation is enabled, the MAC flow control settings will be set
  1478. * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
  1479. * and RFCE bits will be automaticaly set to the negotiated flow control mode.
  1480. *****************************************************************************/
  1481. static int
  1482. e1000_config_fc_after_link_up(struct e1000_hw *hw)
  1483. {
  1484. int32_t ret_val;
  1485. uint16_t mii_status_reg;
  1486. uint16_t mii_nway_adv_reg;
  1487. uint16_t mii_nway_lp_ability_reg;
  1488. uint16_t speed;
  1489. uint16_t duplex;
  1490. DEBUGFUNC("e1000_config_fc_after_link_up");
  1491. /* Check for the case where we have fiber media and auto-neg failed
  1492. * so we had to force link. In this case, we need to force the
  1493. * configuration of the MAC to match the "fc" parameter.
  1494. */
  1495. if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
  1496. ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed))) {
  1497. if((ret_val = e1000_force_mac_fc(hw))) {
  1498. DEBUGOUT("Error forcing flow control settings\n");
  1499. return ret_val;
  1500. }
  1501. }
  1502. /* Check for the case where we have copper media and auto-neg is
  1503. * enabled. In this case, we need to check and see if Auto-Neg
  1504. * has completed, and if so, how the PHY and link partner has
  1505. * flow control configured.
  1506. */
  1507. if(hw->media_type == e1000_media_type_copper) {
  1508. /* Read the MII Status Register and check to see if AutoNeg
  1509. * has completed. We read this twice because this reg has
  1510. * some "sticky" (latched) bits.
  1511. */
  1512. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  1513. return ret_val;
  1514. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  1515. return ret_val;
  1516. if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
  1517. /* The AutoNeg process has completed, so we now need to
  1518. * read both the Auto Negotiation Advertisement Register
  1519. * (Address 4) and the Auto_Negotiation Base Page Ability
  1520. * Register (Address 5) to determine how flow control was
  1521. * negotiated.
  1522. */
  1523. if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  1524. &mii_nway_adv_reg)))
  1525. return ret_val;
  1526. if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  1527. &mii_nway_lp_ability_reg)))
  1528. return ret_val;
  1529. /* Two bits in the Auto Negotiation Advertisement Register
  1530. * (Address 4) and two bits in the Auto Negotiation Base
  1531. * Page Ability Register (Address 5) determine flow control
  1532. * for both the PHY and the link partner. The following
  1533. * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
  1534. * 1999, describes these PAUSE resolution bits and how flow
  1535. * control is determined based upon these settings.
  1536. * NOTE: DC = Don't Care
  1537. *
  1538. * LOCAL DEVICE | LINK PARTNER
  1539. * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
  1540. *-------|---------|-------|---------|--------------------
  1541. * 0 | 0 | DC | DC | e1000_fc_none
  1542. * 0 | 1 | 0 | DC | e1000_fc_none
  1543. * 0 | 1 | 1 | 0 | e1000_fc_none
  1544. * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  1545. * 1 | 0 | 0 | DC | e1000_fc_none
  1546. * 1 | DC | 1 | DC | e1000_fc_full
  1547. * 1 | 1 | 0 | 0 | e1000_fc_none
  1548. * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  1549. *
  1550. */
  1551. /* Are both PAUSE bits set to 1? If so, this implies
  1552. * Symmetric Flow Control is enabled at both ends. The
  1553. * ASM_DIR bits are irrelevant per the spec.
  1554. *
  1555. * For Symmetric Flow Control:
  1556. *
  1557. * LOCAL DEVICE | LINK PARTNER
  1558. * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  1559. *-------|---------|-------|---------|--------------------
  1560. * 1 | DC | 1 | DC | e1000_fc_full
  1561. *
  1562. */
  1563. if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  1564. (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
  1565. /* Now we need to check if the user selected RX ONLY
  1566. * of pause frames. In this case, we had to advertise
  1567. * FULL flow control because we could not advertise RX
  1568. * ONLY. Hence, we must now check to see if we need to
  1569. * turn OFF the TRANSMISSION of PAUSE frames.
  1570. */
  1571. #if 0
  1572. if(hw->original_fc == e1000_fc_full) {
  1573. hw->fc = e1000_fc_full;
  1574. #else
  1575. if(hw->fc == e1000_fc_full) {
  1576. #endif
  1577. DEBUGOUT("Flow Control = FULL.\r\n");
  1578. } else {
  1579. hw->fc = e1000_fc_rx_pause;
  1580. DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  1581. }
  1582. }
  1583. /* For receiving PAUSE frames ONLY.
  1584. *
  1585. * LOCAL DEVICE | LINK PARTNER
  1586. * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  1587. *-------|---------|-------|---------|--------------------
  1588. * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  1589. *
  1590. */
  1591. else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  1592. (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  1593. (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  1594. (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  1595. hw->fc = e1000_fc_tx_pause;
  1596. DEBUGOUT("Flow Control = TX PAUSE frames only.\r\n");
  1597. }
  1598. /* For transmitting PAUSE frames ONLY.
  1599. *
  1600. * LOCAL DEVICE | LINK PARTNER
  1601. * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  1602. *-------|---------|-------|---------|--------------------
  1603. * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  1604. *
  1605. */
  1606. else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  1607. (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  1608. !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  1609. (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  1610. hw->fc = e1000_fc_rx_pause;
  1611. DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  1612. }
  1613. /* Per the IEEE spec, at this point flow control should be
  1614. * disabled. However, we want to consider that we could
  1615. * be connected to a legacy switch that doesn't advertise
  1616. * desired flow control, but can be forced on the link
  1617. * partner. So if we advertised no flow control, that is
  1618. * what we will resolve to. If we advertised some kind of
  1619. * receive capability (Rx Pause Only or Full Flow Control)
  1620. * and the link partner advertised none, we will configure
  1621. * ourselves to enable Rx Flow Control only. We can do
  1622. * this safely for two reasons: If the link partner really
  1623. * didn't want flow control enabled, and we enable Rx, no
  1624. * harm done since we won't be receiving any PAUSE frames
  1625. * anyway. If the intent on the link partner was to have
  1626. * flow control enabled, then by us enabling RX only, we
  1627. * can at least receive pause frames and process them.
  1628. * This is a good idea because in most cases, since we are
  1629. * predominantly a server NIC, more times than not we will
  1630. * be asked to delay transmission of packets than asking
  1631. * our link partner to pause transmission of frames.
  1632. */
  1633. #if 0
  1634. else if(hw->original_fc == e1000_fc_none ||
  1635. hw->original_fc == e1000_fc_tx_pause) {
  1636. #else
  1637. else if(hw->fc == e1000_fc_none)
  1638. DEBUGOUT("Flow Control = NONE.\r\n");
  1639. else if(hw->fc == e1000_fc_tx_pause) {
  1640. #endif
  1641. hw->fc = e1000_fc_none;
  1642. DEBUGOUT("Flow Control = NONE.\r\n");
  1643. } else {
  1644. hw->fc = e1000_fc_rx_pause;
  1645. DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  1646. }
  1647. /* Now we need to do one last check... If we auto-
  1648. * negotiated to HALF DUPLEX, flow control should not be
  1649. * enabled per IEEE 802.3 spec.
  1650. */
  1651. e1000_get_speed_and_duplex(hw, &speed, &duplex);
  1652. if(duplex == HALF_DUPLEX)
  1653. hw->fc = e1000_fc_none;
  1654. /* Now we call a subroutine to actually force the MAC
  1655. * controller to use the correct flow control settings.
  1656. */
  1657. if((ret_val = e1000_force_mac_fc(hw))) {
  1658. DEBUGOUT("Error forcing flow control settings\n");
  1659. return ret_val;
  1660. }
  1661. } else {
  1662. DEBUGOUT("Copper PHY and Auto Neg has not completed.\r\n");
  1663. }
  1664. }
  1665. return E1000_SUCCESS;
  1666. }
  1667. /******************************************************************************
  1668. * Checks to see if the link status of the hardware has changed.
  1669. *
  1670. * hw - Struct containing variables accessed by shared code
  1671. *
  1672. * Called by any function that needs to check the link status of the adapter.
  1673. *****************************************************************************/
  1674. static int
  1675. e1000_check_for_link(struct e1000_hw *hw)
  1676. {
  1677. uint32_t rxcw;
  1678. uint32_t ctrl;
  1679. uint32_t status;
  1680. uint32_t rctl;
  1681. uint32_t signal = 0;
  1682. int32_t ret_val;
  1683. uint16_t phy_data;
  1684. uint16_t lp_capability;
  1685. DEBUGFUNC("e1000_check_for_link");
  1686. /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  1687. * set when the optics detect a signal. On older adapters, it will be
  1688. * cleared when there is a signal. This applies to fiber media only.
  1689. */
  1690. if(hw->media_type == e1000_media_type_fiber)
  1691. signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  1692. ctrl = E1000_READ_REG(hw, CTRL);
  1693. status = E1000_READ_REG(hw, STATUS);
  1694. rxcw = E1000_READ_REG(hw, RXCW);
  1695. /* If we have a copper PHY then we only want to go out to the PHY
  1696. * registers to see if Auto-Neg has completed and/or if our link
  1697. * status has changed. The get_link_status flag will be set if we
  1698. * receive a Link Status Change interrupt or we have Rx Sequence
  1699. * Errors.
  1700. */
  1701. #if 0
  1702. if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
  1703. #else
  1704. if(hw->media_type == e1000_media_type_copper) {
  1705. #endif
  1706. /* First we want to see if the MII Status Register reports
  1707. * link. If so, then we want to get the current speed/duplex
  1708. * of the PHY.
  1709. * Read the register twice since the link bit is sticky.
  1710. */
  1711. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1712. return ret_val;
  1713. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1714. return ret_val;
  1715. if(phy_data & MII_SR_LINK_STATUS) {
  1716. #if 0
  1717. hw->get_link_status = FALSE;
  1718. #endif
  1719. } else {
  1720. /* No link detected */
  1721. return -E1000_ERR_NOLINK;
  1722. }
  1723. /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
  1724. * have Si on board that is 82544 or newer, Auto
  1725. * Speed Detection takes care of MAC speed/duplex
  1726. * configuration. So we only need to configure Collision
  1727. * Distance in the MAC. Otherwise, we need to force
  1728. * speed/duplex on the MAC to the current PHY speed/duplex
  1729. * settings.
  1730. */
  1731. if(hw->mac_type >= e1000_82544)
  1732. e1000_config_collision_dist(hw);
  1733. else {
  1734. if((ret_val = e1000_config_mac_to_phy(hw))) {
  1735. DEBUGOUT("Error configuring MAC to PHY settings\n");
  1736. return ret_val;
  1737. }
  1738. }
  1739. /* Configure Flow Control now that Auto-Neg has completed. First, we
  1740. * need to restore the desired flow control settings because we may
  1741. * have had to re-autoneg with a different link partner.
  1742. */
  1743. if((ret_val = e1000_config_fc_after_link_up(hw))) {
  1744. DEBUGOUT("Error configuring flow control\n");
  1745. return ret_val;
  1746. }
  1747. /* At this point we know that we are on copper and we have
  1748. * auto-negotiated link. These are conditions for checking the link
  1749. * parter capability register. We use the link partner capability to
  1750. * determine if TBI Compatibility needs to be turned on or off. If
  1751. * the link partner advertises any speed in addition to Gigabit, then
  1752. * we assume that they are GMII-based, and TBI compatibility is not
  1753. * needed. If no other speeds are advertised, we assume the link
  1754. * partner is TBI-based, and we turn on TBI Compatibility.
  1755. */
  1756. if(hw->tbi_compatibility_en) {
  1757. if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  1758. &lp_capability)))
  1759. return ret_val;
  1760. if(lp_capability & (NWAY_LPAR_10T_HD_CAPS |
  1761. NWAY_LPAR_10T_FD_CAPS |
  1762. NWAY_LPAR_100TX_HD_CAPS |
  1763. NWAY_LPAR_100TX_FD_CAPS |
  1764. NWAY_LPAR_100T4_CAPS)) {
  1765. /* If our link partner advertises anything in addition to
  1766. * gigabit, we do not need to enable TBI compatibility.
  1767. */
  1768. if(hw->tbi_compatibility_on) {
  1769. /* If we previously were in the mode, turn it off. */
  1770. rctl = E1000_READ_REG(hw, RCTL);
  1771. rctl &= ~E1000_RCTL_SBP;
  1772. E1000_WRITE_REG(hw, RCTL, rctl);
  1773. hw->tbi_compatibility_on = FALSE;
  1774. }
  1775. } else {
  1776. /* If TBI compatibility is was previously off, turn it on. For
  1777. * compatibility with a TBI link partner, we will store bad
  1778. * packets. Some frames have an additional byte on the end and
  1779. * will look like CRC errors to to the hardware.
  1780. */
  1781. if(!hw->tbi_compatibility_on) {
  1782. hw->tbi_compatibility_on = TRUE;
  1783. rctl = E1000_READ_REG(hw, RCTL);
  1784. rctl |= E1000_RCTL_SBP;
  1785. E1000_WRITE_REG(hw, RCTL, rctl);
  1786. }
  1787. }
  1788. }
  1789. }
  1790. /* If we don't have link (auto-negotiation failed or link partner cannot
  1791. * auto-negotiate), the cable is plugged in (we have signal), and our
  1792. * link partner is not trying to auto-negotiate with us (we are receiving
  1793. * idles or data), we need to force link up. We also need to give
  1794. * auto-negotiation time to complete, in case the cable was just plugged
  1795. * in. The autoneg_failed flag does this.
  1796. */
  1797. else if((((hw->media_type == e1000_media_type_fiber) &&
  1798. ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
  1799. (hw->media_type == e1000_media_type_internal_serdes)) &&
  1800. (!(status & E1000_STATUS_LU)) &&
  1801. (!(rxcw & E1000_RXCW_C))) {
  1802. if(hw->autoneg_failed == 0) {
  1803. hw->autoneg_failed = 1;
  1804. return 0;
  1805. }
  1806. DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
  1807. /* Disable auto-negotiation in the TXCW register */
  1808. E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
  1809. /* Force link-up and also force full-duplex. */
  1810. ctrl = E1000_READ_REG(hw, CTRL);
  1811. ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
  1812. E1000_WRITE_REG(hw, CTRL, ctrl);
  1813. /* Configure Flow Control after forcing link up. */
  1814. if((ret_val = e1000_config_fc_after_link_up(hw))) {
  1815. DEBUGOUT("Error configuring flow control\n");
  1816. return ret_val;
  1817. }
  1818. }
  1819. /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
  1820. * auto-negotiation in the TXCW register and disable forced link in the
  1821. * Device Control register in an attempt to auto-negotiate with our link
  1822. * partner.
  1823. */
  1824. else if(((hw->media_type == e1000_media_type_fiber) ||
  1825. (hw->media_type == e1000_media_type_internal_serdes)) &&
  1826. (ctrl & E1000_CTRL_SLU) &&
  1827. (rxcw & E1000_RXCW_C)) {
  1828. DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\r\n");
  1829. E1000_WRITE_REG(hw, TXCW, hw->txcw);
  1830. E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
  1831. }
  1832. #if 0
  1833. /* If we force link for non-auto-negotiation switch, check link status
  1834. * based on MAC synchronization for internal serdes media type.
  1835. */
  1836. else if((hw->media_type == e1000_media_type_internal_serdes) &&
  1837. !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
  1838. /* SYNCH bit and IV bit are sticky. */
  1839. udelay(10);
  1840. if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
  1841. if(!(rxcw & E1000_RXCW_IV)) {
  1842. hw->serdes_link_down = FALSE;
  1843. DEBUGOUT("SERDES: Link is up.\n");
  1844. }
  1845. } else {
  1846. hw->serdes_link_down = TRUE;
  1847. DEBUGOUT("SERDES: Link is down.\n");
  1848. }
  1849. }
  1850. #endif
  1851. return E1000_SUCCESS;
  1852. }
  1853. /******************************************************************************
  1854. * Detects the current speed and duplex settings of the hardware.
  1855. *
  1856. * hw - Struct containing variables accessed by shared code
  1857. * speed - Speed of the connection
  1858. * duplex - Duplex setting of the connection
  1859. *****************************************************************************/
  1860. static void
  1861. e1000_get_speed_and_duplex(struct e1000_hw *hw,
  1862. uint16_t *speed,
  1863. uint16_t *duplex)
  1864. {
  1865. uint32_t status;
  1866. DEBUGFUNC("e1000_get_speed_and_duplex");
  1867. if(hw->mac_type >= e1000_82543) {
  1868. status = E1000_READ_REG(hw, STATUS);
  1869. if(status & E1000_STATUS_SPEED_1000) {
  1870. *speed = SPEED_1000;
  1871. DEBUGOUT("1000 Mbs, ");
  1872. } else if(status & E1000_STATUS_SPEED_100) {
  1873. *speed = SPEED_100;
  1874. DEBUGOUT("100 Mbs, ");
  1875. } else {
  1876. *speed = SPEED_10;
  1877. DEBUGOUT("10 Mbs, ");
  1878. }
  1879. if(status & E1000_STATUS_FD) {
  1880. *duplex = FULL_DUPLEX;
  1881. DEBUGOUT("Full Duplex\r\n");
  1882. } else {
  1883. *duplex = HALF_DUPLEX;
  1884. DEBUGOUT(" Half Duplex\r\n");
  1885. }
  1886. } else {
  1887. DEBUGOUT("1000 Mbs, Full Duplex\r\n");
  1888. *speed = SPEED_1000;
  1889. *duplex = FULL_DUPLEX;
  1890. }
  1891. }
  1892. /******************************************************************************
  1893. * Blocks until autoneg completes or times out (~4.5 seconds)
  1894. *
  1895. * hw - Struct containing variables accessed by shared code
  1896. ******************************************************************************/
  1897. static int
  1898. e1000_wait_autoneg(struct e1000_hw *hw)
  1899. {
  1900. int32_t ret_val;
  1901. uint16_t i;
  1902. uint16_t phy_data;
  1903. DEBUGFUNC("e1000_wait_autoneg");
  1904. DEBUGOUT("Waiting for Auto-Neg to complete.\n");
  1905. /* We will wait for autoneg to complete or 4.5 seconds to expire. */
  1906. for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
  1907. /* Read the MII Status Register and wait for Auto-Neg
  1908. * Complete bit to be set.
  1909. */
  1910. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1911. return ret_val;
  1912. if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  1913. return ret_val;
  1914. if(phy_data & MII_SR_AUTONEG_COMPLETE) {
  1915. DEBUGOUT("Auto-Neg complete.\n");
  1916. return E1000_SUCCESS;
  1917. }
  1918. mdelay(100);
  1919. }
  1920. DEBUGOUT("Auto-Neg timedout.\n");
  1921. return -E1000_ERR_TIMEOUT;
  1922. }
  1923. /******************************************************************************
  1924. * Raises the Management Data Clock
  1925. *
  1926. * hw - Struct containing variables accessed by shared code
  1927. * ctrl - Device control register's current value
  1928. ******************************************************************************/
  1929. static void
  1930. e1000_raise_mdi_clk(struct e1000_hw *hw,
  1931. uint32_t *ctrl)
  1932. {
  1933. /* Raise the clock input to the Management Data Clock (by setting the MDC
  1934. * bit), and then delay 10 microseconds.
  1935. */
  1936. E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
  1937. E1000_WRITE_FLUSH(hw);
  1938. udelay(10);
  1939. }
  1940. /******************************************************************************
  1941. * Lowers the Management Data Clock
  1942. *
  1943. * hw - Struct containing variables accessed by shared code
  1944. * ctrl - Device control register's current value
  1945. ******************************************************************************/
  1946. static void
  1947. e1000_lower_mdi_clk(struct e1000_hw *hw,
  1948. uint32_t *ctrl)
  1949. {
  1950. /* Lower the clock input to the Management Data Clock (by clearing the MDC
  1951. * bit), and then delay 10 microseconds.
  1952. */
  1953. E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
  1954. E1000_WRITE_FLUSH(hw);
  1955. udelay(10);
  1956. }
  1957. /******************************************************************************
  1958. * Shifts data bits out to the PHY
  1959. *
  1960. * hw - Struct containing variables accessed by shared code
  1961. * data - Data to send out to the PHY
  1962. * count - Number of bits to shift out
  1963. *
  1964. * Bits are shifted out in MSB to LSB order.
  1965. ******************************************************************************/
  1966. static void
  1967. e1000_shift_out_mdi_bits(struct e1000_hw *hw,
  1968. uint32_t data,
  1969. uint16_t count)
  1970. {
  1971. uint32_t ctrl;
  1972. uint32_t mask;
  1973. /* We need to shift "count" number of bits out to the PHY. So, the value
  1974. * in the "data" parameter will be shifted out to the PHY one bit at a
  1975. * time. In order to do this, "data" must be broken down into bits.
  1976. */
  1977. mask = 0x01;
  1978. mask <<= (count - 1);
  1979. ctrl = E1000_READ_REG(hw, CTRL);
  1980. /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
  1981. ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
  1982. while(mask) {
  1983. /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
  1984. * then raising and lowering the Management Data Clock. A "0" is
  1985. * shifted out to the PHY by setting the MDIO bit to "0" and then
  1986. * raising and lowering the clock.
  1987. */
  1988. if(data & mask) ctrl |= E1000_CTRL_MDIO;
  1989. else ctrl &= ~E1000_CTRL_MDIO;
  1990. E1000_WRITE_REG(hw, CTRL, ctrl);
  1991. E1000_WRITE_FLUSH(hw);
  1992. udelay(10);
  1993. e1000_raise_mdi_clk(hw, &ctrl);
  1994. e1000_lower_mdi_clk(hw, &ctrl);
  1995. mask = mask >> 1;
  1996. }
  1997. }
  1998. /******************************************************************************
  1999. * Shifts data bits in from the PHY
  2000. *
  2001. * hw - Struct containing variables accessed by shared code
  2002. *
  2003. * Bits are shifted in in MSB to LSB order.
  2004. ******************************************************************************/
  2005. static uint16_t
  2006. e1000_shift_in_mdi_bits(struct e1000_hw *hw)
  2007. {
  2008. uint32_t ctrl;
  2009. uint16_t data = 0;
  2010. uint8_t i;
  2011. /* In order to read a register from the PHY, we need to shift in a total
  2012. * of 18 bits from the PHY. The first two bit (turnaround) times are used
  2013. * to avoid contention on the MDIO pin when a read operation is performed.
  2014. * These two bits are ignored by us and thrown away. Bits are "shifted in"
  2015. * by raising the input to the Management Data Clock (setting the MDC bit),
  2016. * and then reading the value of the MDIO bit.
  2017. */
  2018. ctrl = E1000_READ_REG(hw, CTRL);
  2019. /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
  2020. ctrl &= ~E1000_CTRL_MDIO_DIR;
  2021. ctrl &= ~E1000_CTRL_MDIO;
  2022. E1000_WRITE_REG(hw, CTRL, ctrl);
  2023. E1000_WRITE_FLUSH(hw);
  2024. /* Raise and Lower the clock before reading in the data. This accounts for
  2025. * the turnaround bits. The first clock occurred when we clocked out the
  2026. * last bit of the Register Address.
  2027. */
  2028. e1000_raise_mdi_clk(hw, &ctrl);
  2029. e1000_lower_mdi_clk(hw, &ctrl);
  2030. for(data = 0, i = 0; i < 16; i++) {
  2031. data = data << 1;
  2032. e1000_raise_mdi_clk(hw, &ctrl);
  2033. ctrl = E1000_READ_REG(hw, CTRL);
  2034. /* Check to see if we shifted in a "1". */
  2035. if(ctrl & E1000_CTRL_MDIO) data |= 1;
  2036. e1000_lower_mdi_clk(hw, &ctrl);
  2037. }
  2038. e1000_raise_mdi_clk(hw, &ctrl);
  2039. e1000_lower_mdi_clk(hw, &ctrl);
  2040. return data;
  2041. }
  2042. /*****************************************************************************
  2043. * Reads the value from a PHY register, if the value is on a specific non zero
  2044. * page, sets the page first.
  2045. *
  2046. * hw - Struct containing variables accessed by shared code
  2047. * reg_addr - address of the PHY register to read
  2048. ******************************************************************************/
  2049. static int
  2050. e1000_read_phy_reg(struct e1000_hw *hw,
  2051. uint32_t reg_addr,
  2052. uint16_t *phy_data)
  2053. {
  2054. uint32_t ret_val;
  2055. DEBUGFUNC("e1000_read_phy_reg");
  2056. if(hw->phy_type == e1000_phy_igp &&
  2057. (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  2058. if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  2059. (uint16_t)reg_addr)))
  2060. return ret_val;
  2061. }
  2062. ret_val = e1000_read_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  2063. phy_data);
  2064. return ret_val;
  2065. }
  2066. static int
  2067. e1000_read_phy_reg_ex(struct e1000_hw *hw,
  2068. uint32_t reg_addr,
  2069. uint16_t *phy_data)
  2070. {
  2071. uint32_t i;
  2072. uint32_t mdic = 0;
  2073. const uint32_t phy_addr = 1;
  2074. DEBUGFUNC("e1000_read_phy_reg_ex");
  2075. if(reg_addr > MAX_PHY_REG_ADDRESS) {
  2076. DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  2077. return -E1000_ERR_PARAM;
  2078. }
  2079. if(hw->mac_type > e1000_82543) {
  2080. /* Set up Op-code, Phy Address, and register address in the MDI
  2081. * Control register. The MAC will take care of interfacing with the
  2082. * PHY to retrieve the desired data.
  2083. */
  2084. mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) |
  2085. (phy_addr << E1000_MDIC_PHY_SHIFT) |
  2086. (E1000_MDIC_OP_READ));
  2087. E1000_WRITE_REG(hw, MDIC, mdic);
  2088. /* Poll the ready bit to see if the MDI read completed */
  2089. for(i = 0; i < 64; i++) {
  2090. udelay(50);
  2091. mdic = E1000_READ_REG(hw, MDIC);
  2092. if(mdic & E1000_MDIC_READY) break;
  2093. }
  2094. if(!(mdic & E1000_MDIC_READY)) {
  2095. DEBUGOUT("MDI Read did not complete\n");
  2096. return -E1000_ERR_PHY;
  2097. }
  2098. if(mdic & E1000_MDIC_ERROR) {
  2099. DEBUGOUT("MDI Error\n");
  2100. return -E1000_ERR_PHY;
  2101. }
  2102. *phy_data = (uint16_t) mdic;
  2103. } else {
  2104. /* We must first send a preamble through the MDIO pin to signal the
  2105. * beginning of an MII instruction. This is done by sending 32
  2106. * consecutive "1" bits.
  2107. */
  2108. e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  2109. /* Now combine the next few fields that are required for a read
  2110. * operation. We use this method instead of calling the
  2111. * e1000_shift_out_mdi_bits routine five different times. The format of
  2112. * a MII read instruction consists of a shift out of 14 bits and is
  2113. * defined as follows:
  2114. * <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
  2115. * followed by a shift in of 18 bits. This first two bits shifted in
  2116. * are TurnAround bits used to avoid contention on the MDIO pin when a
  2117. * READ operation is performed. These two bits are thrown away
  2118. * followed by a shift in of 16 bits which contains the desired data.
  2119. */
  2120. mdic = ((reg_addr) | (phy_addr << 5) |
  2121. (PHY_OP_READ << 10) | (PHY_SOF << 12));
  2122. e1000_shift_out_mdi_bits(hw, mdic, 14);
  2123. /* Now that we've shifted out the read command to the MII, we need to
  2124. * "shift in" the 16-bit value (18 total bits) of the requested PHY
  2125. * register address.
  2126. */
  2127. *phy_data = e1000_shift_in_mdi_bits(hw);
  2128. }
  2129. return E1000_SUCCESS;
  2130. }
  2131. /******************************************************************************
  2132. * Writes a value to a PHY register
  2133. *
  2134. * hw - Struct containing variables accessed by shared code
  2135. * reg_addr - address of the PHY register to write
  2136. * data - data to write to the PHY
  2137. ******************************************************************************/
  2138. static int
  2139. e1000_write_phy_reg(struct e1000_hw *hw,
  2140. uint32_t reg_addr,
  2141. uint16_t phy_data)
  2142. {
  2143. uint32_t ret_val;
  2144. DEBUGFUNC("e1000_write_phy_reg");
  2145. if(hw->phy_type == e1000_phy_igp &&
  2146. (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  2147. if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  2148. (uint16_t)reg_addr)))
  2149. return ret_val;
  2150. }
  2151. ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  2152. phy_data);
  2153. return ret_val;
  2154. }
  2155. static int
  2156. e1000_write_phy_reg_ex(struct e1000_hw *hw,
  2157. uint32_t reg_addr,
  2158. uint16_t phy_data)
  2159. {
  2160. uint32_t i;
  2161. uint32_t mdic = 0;
  2162. const uint32_t phy_addr = 1;
  2163. DEBUGFUNC("e1000_write_phy_reg_ex");
  2164. if(reg_addr > MAX_PHY_REG_ADDRESS) {
  2165. DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  2166. return -E1000_ERR_PARAM;
  2167. }
  2168. if(hw->mac_type > e1000_82543) {
  2169. /* Set up Op-code, Phy Address, register address, and data intended
  2170. * for the PHY register in the MDI Control register. The MAC will take
  2171. * care of interfacing with the PHY to send the desired data.
  2172. */
  2173. mdic = (((uint32_t) phy_data) |
  2174. (reg_addr << E1000_MDIC_REG_SHIFT) |
  2175. (phy_addr << E1000_MDIC_PHY_SHIFT) |
  2176. (E1000_MDIC_OP_WRITE));
  2177. E1000_WRITE_REG(hw, MDIC, mdic);
  2178. /* Poll the ready bit to see if the MDI read completed */
  2179. for(i = 0; i < 640; i++) {
  2180. udelay(5);
  2181. mdic = E1000_READ_REG(hw, MDIC);
  2182. if(mdic & E1000_MDIC_READY) break;
  2183. }
  2184. if(!(mdic & E1000_MDIC_READY)) {
  2185. DEBUGOUT("MDI Write did not complete\n");
  2186. return -E1000_ERR_PHY;
  2187. }
  2188. } else {
  2189. /* We'll need to use the SW defined pins to shift the write command
  2190. * out to the PHY. We first send a preamble to the PHY to signal the
  2191. * beginning of the MII instruction. This is done by sending 32
  2192. * consecutive "1" bits.
  2193. */
  2194. e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  2195. /* Now combine the remaining required fields that will indicate a
  2196. * write operation. We use this method instead of calling the
  2197. * e1000_shift_out_mdi_bits routine for each field in the command. The
  2198. * format of a MII write instruction is as follows:
  2199. * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
  2200. */
  2201. mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |
  2202. (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
  2203. mdic <<= 16;
  2204. mdic |= (uint32_t) phy_data;
  2205. e1000_shift_out_mdi_bits(hw, mdic, 32);
  2206. }
  2207. return E1000_SUCCESS;
  2208. }
  2209. /******************************************************************************
  2210. * Returns the PHY to the power-on reset state
  2211. *
  2212. * hw - Struct containing variables accessed by shared code
  2213. ******************************************************************************/
  2214. static void
  2215. e1000_phy_hw_reset(struct e1000_hw *hw)
  2216. {
  2217. uint32_t ctrl, ctrl_ext;
  2218. DEBUGFUNC("e1000_phy_hw_reset");
  2219. DEBUGOUT("Resetting Phy...\n");
  2220. if(hw->mac_type > e1000_82543) {
  2221. /* Read the device control register and assert the E1000_CTRL_PHY_RST
  2222. * bit. Then, take it out of reset.
  2223. */
  2224. ctrl = E1000_READ_REG(hw, CTRL);
  2225. E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
  2226. E1000_WRITE_FLUSH(hw);
  2227. mdelay(10);
  2228. E1000_WRITE_REG(hw, CTRL, ctrl);
  2229. E1000_WRITE_FLUSH(hw);
  2230. } else {
  2231. /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
  2232. * bit to put the PHY into reset. Then, take it out of reset.
  2233. */
  2234. ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  2235. ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
  2236. ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
  2237. E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  2238. E1000_WRITE_FLUSH(hw);
  2239. mdelay(10);
  2240. ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
  2241. E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  2242. E1000_WRITE_FLUSH(hw);
  2243. }
  2244. udelay(150);
  2245. }
  2246. /******************************************************************************
  2247. * Resets the PHY
  2248. *
  2249. * hw - Struct containing variables accessed by shared code
  2250. *
  2251. * Sets bit 15 of the MII Control regiser
  2252. ******************************************************************************/
  2253. static int
  2254. e1000_phy_reset(struct e1000_hw *hw)
  2255. {
  2256. int32_t ret_val;
  2257. uint16_t phy_data;
  2258. DEBUGFUNC("e1000_phy_reset");
  2259. if(hw->mac_type != e1000_82541_rev_2) {
  2260. if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  2261. return ret_val;
  2262. phy_data |= MII_CR_RESET;
  2263. if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  2264. return ret_val;
  2265. udelay(1);
  2266. } else e1000_phy_hw_reset(hw);
  2267. if(hw->phy_type == e1000_phy_igp)
  2268. e1000_phy_init_script(hw);
  2269. return E1000_SUCCESS;
  2270. }
  2271. /******************************************************************************
  2272. * Probes the expected PHY address for known PHY IDs
  2273. *
  2274. * hw - Struct containing variables accessed by shared code
  2275. ******************************************************************************/
  2276. static int
  2277. e1000_detect_gig_phy(struct e1000_hw *hw)
  2278. {
  2279. int32_t phy_init_status, ret_val;
  2280. uint16_t phy_id_high, phy_id_low;
  2281. boolean_t match = FALSE;
  2282. DEBUGFUNC("e1000_detect_gig_phy");
  2283. /* Read the PHY ID Registers to identify which PHY is onboard. */
  2284. if((ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high)))
  2285. return ret_val;
  2286. hw->phy_id = (uint32_t) (phy_id_high << 16);
  2287. udelay(20);
  2288. if((ret_val = e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low)))
  2289. return ret_val;
  2290. hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
  2291. #ifdef LINUX_DRIVER
  2292. hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
  2293. #endif
  2294. switch(hw->mac_type) {
  2295. case e1000_82543:
  2296. if(hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
  2297. break;
  2298. case e1000_82544:
  2299. if(hw->phy_id == M88E1000_I_PHY_ID) match = TRUE;
  2300. break;
  2301. case e1000_82540:
  2302. case e1000_82545:
  2303. case e1000_82545_rev_3:
  2304. case e1000_82546:
  2305. case e1000_82546_rev_3:
  2306. if(hw->phy_id == M88E1011_I_PHY_ID) match = TRUE;
  2307. break;
  2308. case e1000_82541:
  2309. case e1000_82541_rev_2:
  2310. case e1000_82547:
  2311. case e1000_82547_rev_2:
  2312. if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
  2313. break;
  2314. default:
  2315. DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
  2316. return -E1000_ERR_CONFIG;
  2317. }
  2318. phy_init_status = e1000_set_phy_type(hw);
  2319. if ((match) && (phy_init_status == E1000_SUCCESS)) {
  2320. DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id);
  2321. return E1000_SUCCESS;
  2322. }
  2323. DEBUGOUT1("Invalid PHY ID 0x%X\n", hw->phy_id);
  2324. return -E1000_ERR_PHY;
  2325. }
  2326. /******************************************************************************
  2327. * Sets up eeprom variables in the hw struct. Must be called after mac_type
  2328. * is configured.
  2329. *
  2330. * hw - Struct containing variables accessed by shared code
  2331. *****************************************************************************/
  2332. static void
  2333. e1000_init_eeprom_params(struct e1000_hw *hw)
  2334. {
  2335. struct e1000_eeprom_info *eeprom = &hw->eeprom;
  2336. uint32_t eecd = E1000_READ_REG(hw, EECD);
  2337. uint16_t eeprom_size;
  2338. DEBUGFUNC("e1000_init_eeprom_params");
  2339. switch (hw->mac_type) {
  2340. case e1000_82542_rev2_0:
  2341. case e1000_82542_rev2_1:
  2342. case e1000_82543:
  2343. case e1000_82544:
  2344. eeprom->type = e1000_eeprom_microwire;
  2345. eeprom->word_size = 64;
  2346. eeprom->opcode_bits = 3;
  2347. eeprom->address_bits = 6;
  2348. eeprom->delay_usec = 50;
  2349. break;
  2350. case e1000_82540:
  2351. case e1000_82545:
  2352. case e1000_82545_rev_3:
  2353. case e1000_82546:
  2354. case e1000_82546_rev_3:
  2355. eeprom->type = e1000_eeprom_microwire;
  2356. eeprom->opcode_bits = 3;
  2357. eeprom->delay_usec = 50;
  2358. if(eecd & E1000_EECD_SIZE) {
  2359. eeprom->word_size = 256;
  2360. eeprom->address_bits = 8;
  2361. } else {
  2362. eeprom->word_size = 64;
  2363. eeprom->address_bits = 6;
  2364. }
  2365. break;
  2366. case e1000_82541:
  2367. case e1000_82541_rev_2:
  2368. case e1000_82547:
  2369. case e1000_82547_rev_2:
  2370. if (eecd & E1000_EECD_TYPE) {
  2371. eeprom->type = e1000_eeprom_spi;
  2372. if (eecd & E1000_EECD_ADDR_BITS) {
  2373. eeprom->page_size = 32;
  2374. eeprom->address_bits = 16;
  2375. } else {
  2376. eeprom->page_size = 8;
  2377. eeprom->address_bits = 8;
  2378. }
  2379. } else {
  2380. eeprom->type = e1000_eeprom_microwire;
  2381. eeprom->opcode_bits = 3;
  2382. eeprom->delay_usec = 50;
  2383. if (eecd & E1000_EECD_ADDR_BITS) {
  2384. eeprom->word_size = 256;
  2385. eeprom->address_bits = 8;
  2386. } else {
  2387. eeprom->word_size = 64;
  2388. eeprom->address_bits = 6;
  2389. }
  2390. }
  2391. break;
  2392. default:
  2393. eeprom->type = e1000_eeprom_spi;
  2394. if (eecd & E1000_EECD_ADDR_BITS) {
  2395. eeprom->page_size = 32;
  2396. eeprom->address_bits = 16;
  2397. } else {
  2398. eeprom->page_size = 8;
  2399. eeprom->address_bits = 8;
  2400. }
  2401. break;
  2402. }
  2403. if (eeprom->type == e1000_eeprom_spi) {
  2404. eeprom->opcode_bits = 8;
  2405. eeprom->delay_usec = 1;
  2406. eeprom->word_size = 64;
  2407. if (e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size) == 0) {
  2408. eeprom_size &= EEPROM_SIZE_MASK;
  2409. switch (eeprom_size) {
  2410. case EEPROM_SIZE_16KB:
  2411. eeprom->word_size = 8192;
  2412. break;
  2413. case EEPROM_SIZE_8KB:
  2414. eeprom->word_size = 4096;
  2415. break;
  2416. case EEPROM_SIZE_4KB:
  2417. eeprom->word_size = 2048;
  2418. break;
  2419. case EEPROM_SIZE_2KB:
  2420. eeprom->word_size = 1024;
  2421. break;
  2422. case EEPROM_SIZE_1KB:
  2423. eeprom->word_size = 512;
  2424. break;
  2425. case EEPROM_SIZE_512B:
  2426. eeprom->word_size = 256;
  2427. break;
  2428. case EEPROM_SIZE_128B:
  2429. default:
  2430. break;
  2431. }
  2432. }
  2433. }
  2434. }
  2435. /******************************************************************************
  2436. * Raises the EEPROM's clock input.
  2437. *
  2438. * hw - Struct containing variables accessed by shared code
  2439. * eecd - EECD's current value
  2440. *****************************************************************************/
  2441. static void
  2442. e1000_raise_ee_clk(struct e1000_hw *hw,
  2443. uint32_t *eecd)
  2444. {
  2445. /* Raise the clock input to the EEPROM (by setting the SK bit), and then
  2446. * wait <delay> microseconds.
  2447. */
  2448. *eecd = *eecd | E1000_EECD_SK;
  2449. E1000_WRITE_REG(hw, EECD, *eecd);
  2450. E1000_WRITE_FLUSH(hw);
  2451. udelay(hw->eeprom.delay_usec);
  2452. }
  2453. /******************************************************************************
  2454. * Lowers the EEPROM's clock input.
  2455. *
  2456. * hw - Struct containing variables accessed by shared code
  2457. * eecd - EECD's current value
  2458. *****************************************************************************/
  2459. static void
  2460. e1000_lower_ee_clk(struct e1000_hw *hw,
  2461. uint32_t *eecd)
  2462. {
  2463. /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
  2464. * wait 50 microseconds.
  2465. */
  2466. *eecd = *eecd & ~E1000_EECD_SK;
  2467. E1000_WRITE_REG(hw, EECD, *eecd);
  2468. E1000_WRITE_FLUSH(hw);
  2469. udelay(hw->eeprom.delay_usec);
  2470. }
  2471. /******************************************************************************
  2472. * Shift data bits out to the EEPROM.
  2473. *
  2474. * hw - Struct containing variables accessed by shared code
  2475. * data - data to send to the EEPROM
  2476. * count - number of bits to shift out
  2477. *****************************************************************************/
  2478. static void
  2479. e1000_shift_out_ee_bits(struct e1000_hw *hw,
  2480. uint16_t data,
  2481. uint16_t count)
  2482. {
  2483. struct e1000_eeprom_info *eeprom = &hw->eeprom;
  2484. uint32_t eecd;
  2485. uint32_t mask;
  2486. /* We need to shift "count" bits out to the EEPROM. So, value in the
  2487. * "data" parameter will be shifted out to the EEPROM one bit at a time.
  2488. * In order to do this, "data" must be broken down into bits.
  2489. */
  2490. mask = 0x01 << (count - 1);
  2491. eecd = E1000_READ_REG(hw, EECD);
  2492. if (eeprom->type == e1000_eeprom_microwire) {
  2493. eecd &= ~E1000_EECD_DO;
  2494. } else if (eeprom->type == e1000_eeprom_spi) {
  2495. eecd |= E1000_EECD_DO;
  2496. }
  2497. do {
  2498. /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
  2499. * and then raising and then lowering the clock (the SK bit controls
  2500. * the clock input to the EEPROM). A "0" is shifted out to the EEPROM
  2501. * by setting "DI" to "0" and then raising and then lowering the clock.
  2502. */
  2503. eecd &= ~E1000_EECD_DI;
  2504. if(data & mask)
  2505. eecd |= E1000_EECD_DI;
  2506. E1000_WRITE_REG(hw, EECD, eecd);
  2507. E1000_WRITE_FLUSH(hw);
  2508. udelay(eeprom->delay_usec);
  2509. e1000_raise_ee_clk(hw, &eecd);
  2510. e1000_lower_ee_clk(hw, &eecd);
  2511. mask = mask >> 1;
  2512. } while(mask);
  2513. /* We leave the "DI" bit set to "0" when we leave this routine. */
  2514. eecd &= ~E1000_EECD_DI;
  2515. E1000_WRITE_REG(hw, EECD, eecd);
  2516. }
  2517. /******************************************************************************
  2518. * Shift data bits in from the EEPROM
  2519. *
  2520. * hw - Struct containing variables accessed by shared code
  2521. *****************************************************************************/
  2522. static uint16_t
  2523. e1000_shift_in_ee_bits(struct e1000_hw *hw,
  2524. uint16_t count)
  2525. {
  2526. uint32_t eecd;
  2527. uint32_t i;
  2528. uint16_t data;
  2529. /* In order to read a register from the EEPROM, we need to shift 'count'
  2530. * bits in from the EEPROM. Bits are "shifted in" by raising the clock
  2531. * input to the EEPROM (setting the SK bit), and then reading the value of
  2532. * the "DO" bit. During this "shifting in" process the "DI" bit should
  2533. * always be clear.
  2534. */
  2535. eecd = E1000_READ_REG(hw, EECD);
  2536. eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
  2537. data = 0;
  2538. for(i = 0; i < count; i++) {
  2539. data = data << 1;
  2540. e1000_raise_ee_clk(hw, &eecd);
  2541. eecd = E1000_READ_REG(hw, EECD);
  2542. eecd &= ~(E1000_EECD_DI);
  2543. if(eecd & E1000_EECD_DO)
  2544. data |= 1;
  2545. e1000_lower_ee_clk(hw, &eecd);
  2546. }
  2547. return data;
  2548. }
  2549. /******************************************************************************
  2550. * Prepares EEPROM for access
  2551. *
  2552. * hw - Struct containing variables accessed by shared code
  2553. *
  2554. * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
  2555. * function should be called before issuing a command to the EEPROM.
  2556. *****************************************************************************/
  2557. static int32_t
  2558. e1000_acquire_eeprom(struct e1000_hw *hw)
  2559. {
  2560. struct e1000_eeprom_info *eeprom = &hw->eeprom;
  2561. uint32_t eecd, i=0;
  2562. eecd = E1000_READ_REG(hw, EECD);
  2563. /* Request EEPROM Access */
  2564. if(hw->mac_type > e1000_82544) {
  2565. eecd |= E1000_EECD_REQ;
  2566. E1000_WRITE_REG(hw, EECD, eecd);
  2567. eecd = E1000_READ_REG(hw, EECD);
  2568. while((!(eecd & E1000_EECD_GNT)) &&
  2569. (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
  2570. i++;
  2571. udelay(5);
  2572. eecd = E1000_READ_REG(hw, EECD);
  2573. }
  2574. if(!(eecd & E1000_EECD_GNT)) {
  2575. eecd &= ~E1000_EECD_REQ;
  2576. E1000_WRITE_REG(hw, EECD, eecd);
  2577. DEBUGOUT("Could not acquire EEPROM grant\n");
  2578. return -E1000_ERR_EEPROM;
  2579. }
  2580. }
  2581. /* Setup EEPROM for Read/Write */
  2582. if (eeprom->type == e1000_eeprom_microwire) {
  2583. /* Clear SK and DI */
  2584. eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
  2585. E1000_WRITE_REG(hw, EECD, eecd);
  2586. /* Set CS */
  2587. eecd |= E1000_EECD_CS;
  2588. E1000_WRITE_REG(hw, EECD, eecd);
  2589. } else if (eeprom->type == e1000_eeprom_spi) {
  2590. /* Clear SK and CS */
  2591. eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  2592. E1000_WRITE_REG(hw, EECD, eecd);
  2593. udelay(1);
  2594. }
  2595. return E1000_SUCCESS;
  2596. }
  2597. /******************************************************************************
  2598. * Returns EEPROM to a "standby" state
  2599. *
  2600. * hw - Struct containing variables accessed by shared code
  2601. *****************************************************************************/
  2602. static void
  2603. e1000_standby_eeprom(struct e1000_hw *hw)
  2604. {
  2605. struct e1000_eeprom_info *eeprom = &hw->eeprom;
  2606. uint32_t eecd;
  2607. eecd = E1000_READ_REG(hw, EECD);
  2608. if(eeprom->type == e1000_eeprom_microwire) {
  2609. /* Deselect EEPROM */
  2610. eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  2611. E1000_WRITE_REG(hw, EECD, eecd);
  2612. E1000_WRITE_FLUSH(hw);
  2613. udelay(eeprom->delay_usec);
  2614. /* Clock high */
  2615. eecd |= E1000_EECD_SK;
  2616. E1000_WRITE_REG(hw, EECD, eecd);
  2617. E1000_WRITE_FLUSH(hw);
  2618. udelay(eeprom->delay_usec);
  2619. /* Select EEPROM */
  2620. eecd |= E1000_EECD_CS;
  2621. E1000_WRITE_REG(hw, EECD, eecd);
  2622. E1000_WRITE_FLUSH(hw);
  2623. udelay(eeprom->delay_usec);
  2624. /* Clock low */
  2625. eecd &= ~E1000_EECD_SK;
  2626. E1000_WRITE_REG(hw, EECD, eecd);
  2627. E1000_WRITE_FLUSH(hw);
  2628. udelay(eeprom->delay_usec);
  2629. } else if(eeprom->type == e1000_eeprom_spi) {
  2630. /* Toggle CS to flush commands */
  2631. eecd |= E1000_EECD_CS;
  2632. E1000_WRITE_REG(hw, EECD, eecd);
  2633. E1000_WRITE_FLUSH(hw);
  2634. udelay(eeprom->delay_usec);
  2635. eecd &= ~E1000_EECD_CS;
  2636. E1000_WRITE_REG(hw, EECD, eecd);
  2637. E1000_WRITE_FLUSH(hw);
  2638. udelay(eeprom->delay_usec);
  2639. }
  2640. }
  2641. /******************************************************************************
  2642. * Terminates a command by inverting the EEPROM's chip select pin
  2643. *
  2644. * hw - Struct containing variables accessed by shared code
  2645. *****************************************************************************/
  2646. static void
  2647. e1000_release_eeprom(struct e1000_hw *hw)
  2648. {
  2649. uint32_t eecd;
  2650. eecd = E1000_READ_REG(hw, EECD);
  2651. if (hw->eeprom.type == e1000_eeprom_spi) {
  2652. eecd |= E1000_EECD_CS; /* Pull CS high */
  2653. eecd &= ~E1000_EECD_SK; /* Lower SCK */
  2654. E1000_WRITE_REG(hw, EECD, eecd);
  2655. udelay(hw->eeprom.delay_usec);
  2656. } else if(hw->eeprom.type == e1000_eeprom_microwire) {
  2657. /* cleanup eeprom */
  2658. /* CS on Microwire is active-high */
  2659. eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
  2660. E1000_WRITE_REG(hw, EECD, eecd);
  2661. /* Rising edge of clock */
  2662. eecd |= E1000_EECD_SK;
  2663. E1000_WRITE_REG(hw, EECD, eecd);
  2664. E1000_WRITE_FLUSH(hw);
  2665. udelay(hw->eeprom.delay_usec);
  2666. /* Falling edge of clock */
  2667. eecd &= ~E1000_EECD_SK;
  2668. E1000_WRITE_REG(hw, EECD, eecd);
  2669. E1000_WRITE_FLUSH(hw);
  2670. udelay(hw->eeprom.delay_usec);
  2671. }
  2672. /* Stop requesting EEPROM access */
  2673. if(hw->mac_type > e1000_82544) {
  2674. eecd &= ~E1000_EECD_REQ;
  2675. E1000_WRITE_REG(hw, EECD, eecd);
  2676. }
  2677. }
  2678. /******************************************************************************
  2679. * Reads a 16 bit word from the EEPROM.
  2680. *
  2681. * hw - Struct containing variables accessed by shared code
  2682. *****************************************************************************/
  2683. static int32_t
  2684. e1000_spi_eeprom_ready(struct e1000_hw *hw)
  2685. {
  2686. uint16_t retry_count = 0;
  2687. uint8_t spi_stat_reg;
  2688. /* Read "Status Register" repeatedly until the LSB is cleared. The
  2689. * EEPROM will signal that the command has been completed by clearing
  2690. * bit 0 of the internal status register. If it's not cleared within
  2691. * 5 milliseconds, then error out.
  2692. */
  2693. retry_count = 0;
  2694. do {
  2695. e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI,
  2696. hw->eeprom.opcode_bits);
  2697. spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8);
  2698. if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI))
  2699. break;
  2700. udelay(5);
  2701. retry_count += 5;
  2702. } while(retry_count < EEPROM_MAX_RETRY_SPI);
  2703. /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
  2704. * only 0-5mSec on 5V devices)
  2705. */
  2706. if(retry_count >= EEPROM_MAX_RETRY_SPI) {
  2707. DEBUGOUT("SPI EEPROM Status error\n");
  2708. return -E1000_ERR_EEPROM;
  2709. }
  2710. return E1000_SUCCESS;
  2711. }
  2712. /******************************************************************************
  2713. * Reads a 16 bit word from the EEPROM.
  2714. *
  2715. * hw - Struct containing variables accessed by shared code
  2716. * offset - offset of word in the EEPROM to read
  2717. * data - word read from the EEPROM
  2718. * words - number of words to read
  2719. *****************************************************************************/
  2720. static int
  2721. e1000_read_eeprom(struct e1000_hw *hw,
  2722. uint16_t offset,
  2723. uint16_t words,
  2724. uint16_t *data)
  2725. {
  2726. struct e1000_eeprom_info *eeprom = &hw->eeprom;
  2727. uint32_t i = 0;
  2728. DEBUGFUNC("e1000_read_eeprom");
  2729. /* A check for invalid values: offset too large, too many words, and not
  2730. * enough words.
  2731. */
  2732. if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) ||
  2733. (words == 0)) {
  2734. DEBUGOUT("\"words\" parameter out of bounds\n");
  2735. return -E1000_ERR_EEPROM;
  2736. }
  2737. /* Prepare the EEPROM for reading */
  2738. if(e1000_acquire_eeprom(hw) != E1000_SUCCESS)
  2739. return -E1000_ERR_EEPROM;
  2740. if(eeprom->type == e1000_eeprom_spi) {
  2741. uint16_t word_in;
  2742. uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;
  2743. if(e1000_spi_eeprom_ready(hw)) {
  2744. e1000_release_eeprom(hw);
  2745. return -E1000_ERR_EEPROM;
  2746. }
  2747. e1000_standby_eeprom(hw);
  2748. /* Some SPI eeproms use the 8th address bit embedded in the opcode */
  2749. if((eeprom->address_bits == 8) && (offset >= 128))
  2750. read_opcode |= EEPROM_A8_OPCODE_SPI;
  2751. /* Send the READ command (opcode + addr) */
  2752. e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);
  2753. e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);
  2754. /* Read the data. The address of the eeprom internally increments with
  2755. * each byte (spi) being read, saving on the overhead of eeprom setup
  2756. * and tear-down. The address counter will roll over if reading beyond
  2757. * the size of the eeprom, thus allowing the entire memory to be read
  2758. * starting from any offset. */
  2759. for (i = 0; i < words; i++) {
  2760. word_in = e1000_shift_in_ee_bits(hw, 16);
  2761. data[i] = (word_in >> 8) | (word_in << 8);
  2762. }
  2763. } else if(eeprom->type == e1000_eeprom_microwire) {
  2764. for (i = 0; i < words; i++) {
  2765. /* Send the READ command (opcode + addr) */
  2766. e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,
  2767. eeprom->opcode_bits);
  2768. e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),
  2769. eeprom->address_bits);
  2770. /* Read the data. For microwire, each word requires the overhead
  2771. * of eeprom setup and tear-down. */
  2772. data[i] = e1000_shift_in_ee_bits(hw, 16);
  2773. e1000_standby_eeprom(hw);
  2774. }
  2775. }
  2776. /* End this read operation */
  2777. e1000_release_eeprom(hw);
  2778. return E1000_SUCCESS;
  2779. }
  2780. /******************************************************************************
  2781. * Verifies that the EEPROM has a valid checksum
  2782. *
  2783. * hw - Struct containing variables accessed by shared code
  2784. *
  2785. * Reads the first 64 16 bit words of the EEPROM and sums the values read.
  2786. * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
  2787. * valid.
  2788. *****************************************************************************/
  2789. static int
  2790. e1000_validate_eeprom_checksum(struct e1000_hw *hw)
  2791. {
  2792. uint16_t checksum = 0;
  2793. uint16_t i, eeprom_data;
  2794. DEBUGFUNC("e1000_validate_eeprom_checksum");
  2795. for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
  2796. if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
  2797. DEBUGOUT("EEPROM Read Error\n");
  2798. return -E1000_ERR_EEPROM;
  2799. }
  2800. checksum += eeprom_data;
  2801. }
  2802. if(checksum == (uint16_t) EEPROM_SUM)
  2803. return E1000_SUCCESS;
  2804. else {
  2805. DEBUGOUT("EEPROM Checksum Invalid\n");
  2806. return -E1000_ERR_EEPROM;
  2807. }
  2808. }
  2809. /******************************************************************************
  2810. * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
  2811. * second function of dual function devices
  2812. *
  2813. * hw - Struct containing variables accessed by shared code
  2814. *****************************************************************************/
  2815. static int
  2816. e1000_read_mac_addr(struct e1000_hw *hw)
  2817. {
  2818. uint16_t offset;
  2819. uint16_t eeprom_data;
  2820. int i;
  2821. DEBUGFUNC("e1000_read_mac_addr");
  2822. for(i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
  2823. offset = i >> 1;
  2824. if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
  2825. DEBUGOUT("EEPROM Read Error\n");
  2826. return -E1000_ERR_EEPROM;
  2827. }
  2828. hw->mac_addr[i] = eeprom_data & 0xff;
  2829. hw->mac_addr[i+1] = (eeprom_data >> 8) & 0xff;
  2830. }
  2831. if(((hw->mac_type == e1000_82546) || (hw->mac_type == e1000_82546_rev_3)) &&
  2832. (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1))
  2833. /* Invert the last bit if this is the second device */
  2834. hw->mac_addr[5] ^= 1;
  2835. return E1000_SUCCESS;
  2836. }
  2837. /******************************************************************************
  2838. * Initializes receive address filters.
  2839. *
  2840. * hw - Struct containing variables accessed by shared code
  2841. *
  2842. * Places the MAC address in receive address register 0 and clears the rest
  2843. * of the receive addresss registers. Clears the multicast table. Assumes
  2844. * the receiver is in reset when the routine is called.
  2845. *****************************************************************************/
  2846. static void
  2847. e1000_init_rx_addrs(struct e1000_hw *hw)
  2848. {
  2849. uint32_t i;
  2850. uint32_t addr_low;
  2851. uint32_t addr_high;
  2852. DEBUGFUNC("e1000_init_rx_addrs");
  2853. /* Setup the receive address. */
  2854. DEBUGOUT("Programming MAC Address into RAR[0]\n");
  2855. addr_low = (hw->mac_addr[0] |
  2856. (hw->mac_addr[1] << 8) |
  2857. (hw->mac_addr[2] << 16) | (hw->mac_addr[3] << 24));
  2858. addr_high = (hw->mac_addr[4] |
  2859. (hw->mac_addr[5] << 8) | E1000_RAH_AV);
  2860. E1000_WRITE_REG_ARRAY(hw, RA, 0, addr_low);
  2861. E1000_WRITE_REG_ARRAY(hw, RA, 1, addr_high);
  2862. /* Zero out the other 15 receive addresses. */
  2863. DEBUGOUT("Clearing RAR[1-15]\n");
  2864. for(i = 1; i < E1000_RAR_ENTRIES; i++) {
  2865. E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
  2866. E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
  2867. }
  2868. }
  2869. /******************************************************************************
  2870. * Clears the VLAN filer table
  2871. *
  2872. * hw - Struct containing variables accessed by shared code
  2873. *****************************************************************************/
  2874. static void
  2875. e1000_clear_vfta(struct e1000_hw *hw)
  2876. {
  2877. uint32_t offset;
  2878. for(offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++)
  2879. E1000_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
  2880. }
  2881. /******************************************************************************
  2882. * Functions from e1000_main.c of the linux driver
  2883. ******************************************************************************/
  2884. /**
  2885. * e1000_reset - Reset the adapter
  2886. */
  2887. static int
  2888. e1000_reset(struct e1000_hw *hw)
  2889. {
  2890. uint32_t pba;
  2891. /* Repartition Pba for greater than 9k mtu
  2892. * To take effect CTRL.RST is required.
  2893. */
  2894. if(hw->mac_type < e1000_82547) {
  2895. pba = E1000_PBA_48K;
  2896. } else {
  2897. pba = E1000_PBA_30K;
  2898. }
  2899. E1000_WRITE_REG(hw, PBA, pba);
  2900. /* flow control settings */
  2901. #if 0
  2902. hw->fc_high_water = FC_DEFAULT_HI_THRESH;
  2903. hw->fc_low_water = FC_DEFAULT_LO_THRESH;
  2904. hw->fc_pause_time = FC_DEFAULT_TX_TIMER;
  2905. hw->fc_send_xon = 1;
  2906. hw->fc = hw->original_fc;
  2907. #endif
  2908. e1000_reset_hw(hw);
  2909. if(hw->mac_type >= e1000_82544)
  2910. E1000_WRITE_REG(hw, WUC, 0);
  2911. return e1000_init_hw(hw);
  2912. }
  2913. /**
  2914. * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
  2915. * @adapter: board private structure to initialize
  2916. *
  2917. * e1000_sw_init initializes the Adapter private data structure.
  2918. * Fields are initialized based on PCI device information and
  2919. * OS network device settings (MTU size).
  2920. **/
  2921. static int
  2922. e1000_sw_init(struct pci_device *pdev, struct e1000_hw *hw)
  2923. {
  2924. int result;
  2925. /* PCI config space info */
  2926. pci_read_config_word(pdev, PCI_VENDOR_ID, &hw->vendor_id);
  2927. pci_read_config_word(pdev, PCI_DEVICE_ID, &hw->device_id);
  2928. pci_read_config_byte(pdev, PCI_REVISION, &hw->revision_id);
  2929. #if 0
  2930. pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID,
  2931. &hw->subsystem_vendor_id);
  2932. pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_id);
  2933. #endif
  2934. pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
  2935. /* identify the MAC */
  2936. result = e1000_set_mac_type(hw);
  2937. if (result) {
  2938. E1000_ERR("Unknown MAC Type\n");
  2939. return result;
  2940. }
  2941. /* initialize eeprom parameters */
  2942. e1000_init_eeprom_params(hw);
  2943. #if 0
  2944. if((hw->mac_type == e1000_82541) ||
  2945. (hw->mac_type == e1000_82547) ||
  2946. (hw->mac_type == e1000_82541_rev_2) ||
  2947. (hw->mac_type == e1000_82547_rev_2))
  2948. hw->phy_init_script = 1;
  2949. #endif
  2950. e1000_set_media_type(hw);
  2951. #if 0
  2952. if(hw->mac_type < e1000_82543)
  2953. hw->report_tx_early = 0;
  2954. else
  2955. hw->report_tx_early = 1;
  2956. hw->wait_autoneg_complete = FALSE;
  2957. #endif
  2958. hw->tbi_compatibility_en = TRUE;
  2959. #if 0
  2960. hw->adaptive_ifs = TRUE;
  2961. /* Copper options */
  2962. if(hw->media_type == e1000_media_type_copper) {
  2963. hw->mdix = AUTO_ALL_MODES;
  2964. hw->disable_polarity_correction = FALSE;
  2965. hw->master_slave = E1000_MASTER_SLAVE;
  2966. }
  2967. #endif
  2968. return E1000_SUCCESS;
  2969. }
  2970. /******************************************************************************
  2971. * Functions not present in the linux driver
  2972. ******************************************************************************/
  2973. static void fill_rx (void)
  2974. {
  2975. struct e1000_rx_desc *rd;
  2976. rx_last = rx_tail;
  2977. rd = rx_base + rx_tail;
  2978. rx_tail = (rx_tail + 1) % 8;
  2979. memset (rd, 0, 16);
  2980. rd->buffer_addr = virt_to_bus(&e1000_bufs.packet);
  2981. E1000_WRITE_REG (&hw, RDT, rx_tail);
  2982. }
  2983. static void init_descriptor (void)
  2984. {
  2985. unsigned long ptr;
  2986. unsigned long tctl;
  2987. ptr = virt_to_phys(e1000_bufs.tx_pool);
  2988. if (ptr & 0xf)
  2989. ptr = (ptr + 0x10) & (~0xf);
  2990. tx_base = phys_to_virt(ptr);
  2991. E1000_WRITE_REG (&hw, TDBAL, virt_to_bus(tx_base));
  2992. E1000_WRITE_REG (&hw, TDBAH, 0);
  2993. E1000_WRITE_REG (&hw, TDLEN, 128);
  2994. /* Setup the HW Tx Head and Tail descriptor pointers */
  2995. E1000_WRITE_REG (&hw, TDH, 0);
  2996. E1000_WRITE_REG (&hw, TDT, 0);
  2997. tx_tail = 0;
  2998. /* Program the Transmit Control Register */
  2999. #ifdef LINUX_DRIVER_TCTL
  3000. tctl = E1000_READ_REG(&hw, TCTL);
  3001. tctl &= ~E1000_TCTL_CT;
  3002. tctl |= E1000_TCTL_EN | E1000_TCTL_PSP |
  3003. (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
  3004. #else
  3005. tctl = E1000_TCTL_PSP | E1000_TCTL_EN |
  3006. (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT) |
  3007. (E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
  3008. #endif
  3009. E1000_WRITE_REG (&hw, TCTL, tctl);
  3010. e1000_config_collision_dist(&hw);
  3011. rx_tail = 0;
  3012. /* disable receive */
  3013. E1000_WRITE_REG (&hw, RCTL, 0);
  3014. ptr = virt_to_phys(e1000_bufs.rx_pool);
  3015. if (ptr & 0xf)
  3016. ptr = (ptr + 0x10) & (~0xf);
  3017. rx_base = phys_to_virt(ptr);
  3018. /* Setup the Base and Length of the Rx Descriptor Ring */
  3019. E1000_WRITE_REG (&hw, RDBAL, virt_to_bus(rx_base));
  3020. E1000_WRITE_REG (&hw, RDBAH, 0);
  3021. E1000_WRITE_REG (&hw, RDLEN, 128);
  3022. /* Setup the HW Rx Head and Tail Descriptor Pointers */
  3023. E1000_WRITE_REG (&hw, RDH, 0);
  3024. E1000_WRITE_REG (&hw, RDT, 0);
  3025. E1000_WRITE_REG (&hw, RCTL,
  3026. E1000_RCTL_EN |
  3027. E1000_RCTL_BAM |
  3028. E1000_RCTL_SZ_2048 |
  3029. E1000_RCTL_MPE);
  3030. fill_rx();
  3031. }
  3032. /**************************************************************************
  3033. POLL - Wait for a frame
  3034. ***************************************************************************/
  3035. static int
  3036. e1000_poll (struct nic *nic, int retrieve)
  3037. {
  3038. /* return true if there's an ethernet packet ready to read */
  3039. /* nic->packet should contain data on return */
  3040. /* nic->packetlen should contain length of data */
  3041. struct e1000_rx_desc *rd;
  3042. uint32_t icr;
  3043. rd = rx_base + rx_last;
  3044. if (!rd->status & E1000_RXD_STAT_DD)
  3045. return 0;
  3046. if ( ! retrieve ) return 1;
  3047. // printf("recv: packet %! -> %! len=%d \n", packet+6, packet,rd->Length);
  3048. memcpy (nic->packet, e1000_bufs.packet, rd->length);
  3049. nic->packetlen = rd->length;
  3050. fill_rx ();
  3051. /* Acknowledge interrupt. */
  3052. icr = E1000_READ_REG(&hw, ICR);
  3053. return 1;
  3054. }
  3055. /**************************************************************************
  3056. TRANSMIT - Transmit a frame
  3057. ***************************************************************************/
  3058. static void
  3059. e1000_transmit (struct nic *nic, const char *d, /* Destination */
  3060. unsigned int type, /* Type */
  3061. unsigned int size, /* size */
  3062. const char *p) /* Packet */
  3063. {
  3064. /* send the packet to destination */
  3065. struct eth_hdr {
  3066. unsigned char dst_addr[ETH_ALEN];
  3067. unsigned char src_addr[ETH_ALEN];
  3068. unsigned short type;
  3069. } hdr;
  3070. struct e1000_tx_desc *txhd; /* header */
  3071. struct e1000_tx_desc *txp; /* payload */
  3072. DEBUGFUNC("send");
  3073. memcpy (&hdr.dst_addr, d, ETH_ALEN);
  3074. memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  3075. hdr.type = htons (type);
  3076. txhd = tx_base + tx_tail;
  3077. tx_tail = (tx_tail + 1) % 8;
  3078. txp = tx_base + tx_tail;
  3079. tx_tail = (tx_tail + 1) % 8;
  3080. txhd->buffer_addr = virt_to_bus (&hdr);
  3081. txhd->lower.data = sizeof (hdr);
  3082. txhd->upper.data = 0;
  3083. txp->buffer_addr = virt_to_bus(p);
  3084. txp->lower.data = E1000_TXD_CMD_RPS | E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS | size;
  3085. txp->upper.data = 0;
  3086. E1000_WRITE_REG (&hw, TDT, tx_tail);
  3087. while (!(txp->upper.data & E1000_TXD_STAT_DD)) {
  3088. udelay(10); /* give the nic a chance to write to the register */
  3089. poll_interruptions();
  3090. }
  3091. DEBUGFUNC("send end");
  3092. }
  3093. /**************************************************************************
  3094. DISABLE - Turn off ethernet interface
  3095. ***************************************************************************/
  3096. static void e1000_disable ( struct nic *nic __unused ) {
  3097. /* Clear the transmit ring */
  3098. E1000_WRITE_REG (&hw, TDH, 0);
  3099. E1000_WRITE_REG (&hw, TDT, 0);
  3100. /* Clear the receive ring */
  3101. E1000_WRITE_REG (&hw, RDH, 0);
  3102. E1000_WRITE_REG (&hw, RDT, 0);
  3103. /* put the card in its initial state */
  3104. switch(hw.mac_type) {
  3105. case e1000_82544:
  3106. case e1000_82540:
  3107. case e1000_82545:
  3108. case e1000_82546:
  3109. case e1000_82541:
  3110. case e1000_82541_rev_2:
  3111. /* These controllers can't ack the 64-bit write when issuing the
  3112. * reset, so use IO-mapping as a workaround to issue the reset */
  3113. E1000_WRITE_REG_IO(&hw, CTRL, E1000_CTRL_RST);
  3114. break;
  3115. case e1000_82545_rev_3:
  3116. case e1000_82546_rev_3:
  3117. /* Reset is performed on a shadow of the control register */
  3118. E1000_WRITE_REG(&hw, CTRL_DUP, E1000_CTRL_RST);
  3119. break;
  3120. default:
  3121. E1000_WRITE_REG(&hw, CTRL, E1000_CTRL_RST);
  3122. break;
  3123. }
  3124. /* Turn off the ethernet interface */
  3125. E1000_WRITE_REG (&hw, RCTL, 0);
  3126. E1000_WRITE_REG (&hw, TCTL, 0);
  3127. mdelay (10);
  3128. /* Unmap my window to the device */
  3129. iounmap(hw.hw_addr);
  3130. }
  3131. /**************************************************************************
  3132. IRQ - Enable, Disable, or Force interrupts
  3133. ***************************************************************************/
  3134. static void e1000_irq(struct nic *nic __unused, irq_action_t action)
  3135. {
  3136. switch ( action ) {
  3137. case DISABLE :
  3138. E1000_WRITE_REG(&hw, IMC, ~0);
  3139. E1000_WRITE_FLUSH(&hw);
  3140. break;
  3141. case ENABLE :
  3142. E1000_WRITE_REG(&hw, IMS,
  3143. E1000_IMS_RXT0 | E1000_IMS_RXSEQ);
  3144. E1000_WRITE_FLUSH(&hw);
  3145. break;
  3146. case FORCE :
  3147. E1000_WRITE_REG(&hw, ICS, E1000_ICS_RXT0);
  3148. break;
  3149. }
  3150. }
  3151. #define IORESOURCE_IO 0x00000100 /* Resource type */
  3152. #define BAR_0 0
  3153. #define BAR_1 1
  3154. #define BAR_5 5
  3155. /**************************************************************************
  3156. PROBE - Look for an adapter, this routine's visible to the outside
  3157. You should omit the last argument struct pci_device * for a non-PCI NIC
  3158. ***************************************************************************/
  3159. static int e1000_probe ( struct nic *nic, struct pci_device *p ) {
  3160. unsigned long mmio_start, mmio_len;
  3161. int ret_val, i;
  3162. /* Initialize hw with default values */
  3163. memset(&hw, 0, sizeof(hw));
  3164. hw.pdev = p;
  3165. #if 1
  3166. /* Are these variables needed? */
  3167. hw.fc = e1000_fc_none;
  3168. #if 0
  3169. hw.original_fc = e1000_fc_none;
  3170. #endif
  3171. hw.autoneg_failed = 0;
  3172. #if 0
  3173. hw.get_link_status = TRUE;
  3174. #endif
  3175. #endif
  3176. mmio_start = pci_bar_start(p, PCI_BASE_ADDRESS_0);
  3177. mmio_len = pci_bar_size(p, PCI_BASE_ADDRESS_0);
  3178. hw.hw_addr = ioremap(mmio_start, mmio_len);
  3179. for(i = BAR_1; i <= BAR_5; i++) {
  3180. if(pci_bar_size(p, i) == 0)
  3181. continue;
  3182. if(pci_find_capability(p, i) & IORESOURCE_IO) {
  3183. hw.io_base = pci_bar_start(p, i);
  3184. break;
  3185. }
  3186. }
  3187. adjust_pci_device(p);
  3188. pci_fill_nic ( nic, p );
  3189. /* From Matt Hortman <mbhortman@acpthinclient.com> */
  3190. /* MAC and Phy settings */
  3191. /* setup the private structure */
  3192. if (e1000_sw_init(p, &hw) < 0) {
  3193. iounmap(hw.hw_addr);
  3194. return 0;
  3195. }
  3196. /* make sure the EEPROM is good */
  3197. if (e1000_validate_eeprom_checksum(&hw) < 0) {
  3198. printf ("The EEPROM Checksum Is Not Valid\n");
  3199. iounmap(hw.hw_addr);
  3200. return 0;
  3201. }
  3202. /* copy the MAC address out of the EEPROM */
  3203. e1000_read_mac_addr(&hw);
  3204. memcpy (nic->node_addr, hw.mac_addr, ETH_ALEN);
  3205. printf("Ethernet addr: %!\n", nic->node_addr);
  3206. /* reset the hardware with the new settings */
  3207. ret_val = e1000_reset(&hw);
  3208. if (ret_val < 0) {
  3209. if ((ret_val == -E1000_ERR_NOLINK) ||
  3210. (ret_val == -E1000_ERR_TIMEOUT)) {
  3211. E1000_ERR("Valid Link not detected\n");
  3212. } else {
  3213. E1000_ERR("Hardware Initialization Failed\n");
  3214. }
  3215. iounmap(hw.hw_addr);
  3216. return 0;
  3217. }
  3218. init_descriptor();
  3219. /* point to NIC specific routines */
  3220. nic->nic_op = &e1000_operations;
  3221. return 1;
  3222. }
  3223. static struct nic_operations e1000_operations = {
  3224. .connect = dummy_connect,
  3225. .poll = e1000_poll,
  3226. .transmit = e1000_transmit,
  3227. .irq = e1000_irq,
  3228. };
  3229. static struct pci_device_id e1000_nics[] = {
  3230. PCI_ROM(0x8086, 0x1000, "e1000-82542", "Intel EtherExpressPro1000"),
  3231. PCI_ROM(0x8086, 0x1001, "e1000-82543gc-fiber", "Intel EtherExpressPro1000 82543GC Fiber"),
  3232. PCI_ROM(0x8086, 0x1004, "e1000-82543gc-copper", "Intel EtherExpressPro1000 82543GC Copper"),
  3233. PCI_ROM(0x8086, 0x1008, "e1000-82544ei-copper", "Intel EtherExpressPro1000 82544EI Copper"),
  3234. PCI_ROM(0x8086, 0x1009, "e1000-82544ei-fiber", "Intel EtherExpressPro1000 82544EI Fiber"),
  3235. PCI_ROM(0x8086, 0x100C, "e1000-82544gc-copper", "Intel EtherExpressPro1000 82544GC Copper"),
  3236. PCI_ROM(0x8086, 0x100D, "e1000-82544gc-lom", "Intel EtherExpressPro1000 82544GC LOM"),
  3237. PCI_ROM(0x8086, 0x100E, "e1000-82540em", "Intel EtherExpressPro1000 82540EM"),
  3238. PCI_ROM(0x8086, 0x100F, "e1000-82545em-copper", "Intel EtherExpressPro1000 82545EM Copper"),
  3239. PCI_ROM(0x8086, 0x1010, "e1000-82546eb-copper", "Intel EtherExpressPro1000 82546EB Copper"),
  3240. PCI_ROM(0x8086, 0x1011, "e1000-82545em-fiber", "Intel EtherExpressPro1000 82545EM Fiber"),
  3241. PCI_ROM(0x8086, 0x1012, "e1000-82546eb-fiber", "Intel EtherExpressPro1000 82546EB Copper"),
  3242. PCI_ROM(0x8086, 0x1013, "e1000-82541ei", "Intel EtherExpressPro1000 82541EI"),
  3243. PCI_ROM(0x8086, 0x1015, "e1000-82540em-lom", "Intel EtherExpressPro1000 82540EM LOM"),
  3244. PCI_ROM(0x8086, 0x1016, "e1000-82540ep-lom", "Intel EtherExpressPro1000 82540EP LOM"),
  3245. PCI_ROM(0x8086, 0x1017, "e1000-82540ep", "Intel EtherExpressPro1000 82540EP"),
  3246. PCI_ROM(0x8086, 0x1018, "e1000-82541ep", "Intel EtherExpressPro1000 82541EP"),
  3247. PCI_ROM(0x8086, 0x1019, "e1000-82547ei", "Intel EtherExpressPro1000 82547EI"),
  3248. PCI_ROM(0x8086, 0x101d, "e1000-82546eb-quad-copper", "Intel EtherExpressPro1000 82546EB Quad Copper"),
  3249. PCI_ROM(0x8086, 0x101e, "e1000-82540ep-lp", "Intel EtherExpressPro1000 82540EP LP"),
  3250. PCI_ROM(0x8086, 0x1026, "e1000-82545gm-copper", "Intel EtherExpressPro1000 82545GM Copper"),
  3251. PCI_ROM(0x8086, 0x1027, "e1000-82545gm-fiber", "Intel EtherExpressPro1000 82545GM Fiber"),
  3252. PCI_ROM(0x8086, 0x1028, "e1000-82545gm-serdes", "Intel EtherExpressPro1000 82545GM SERDES"),
  3253. PCI_ROM(0x8086, 0x1075, "e1000-82547gi", "Intel EtherExpressPro1000 82547GI"),
  3254. PCI_ROM(0x8086, 0x1076, "e1000-82541gi", "Intel EtherExpressPro1000 82541GI"),
  3255. PCI_ROM(0x8086, 0x1077, "e1000-82541gi-mobile", "Intel EtherExpressPro1000 82541GI Mobile"),
  3256. PCI_ROM(0x8086, 0x1078, "e1000-82541er", "Intel EtherExpressPro1000 82541ER"),
  3257. PCI_ROM(0x8086, 0x1079, "e1000-82546gb-copper", "Intel EtherExpressPro1000 82546GB Copper"),
  3258. PCI_ROM(0x8086, 0x107a, "e1000-82546gb-fiber", "Intel EtherExpressPro1000 82546GB Fiber"),
  3259. PCI_ROM(0x8086, 0x107b, "e1000-82546gb-serdes", "Intel EtherExpressPro1000 82546GB SERDES"),
  3260. };
  3261. PCI_DRIVER ( e1000_driver, e1000_nics, PCI_NO_CLASS );
  3262. DRIVER ( "E1000", nic_driver, pci_driver, e1000_driver,
  3263. e1000_probe, e1000_disable );