ich8lan.c 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2011 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. /*
  22. * 82562G 10/100 Network Connection
  23. * 82562G-2 10/100 Network Connection
  24. * 82562GT 10/100 Network Connection
  25. * 82562GT-2 10/100 Network Connection
  26. * 82562V 10/100 Network Connection
  27. * 82562V-2 10/100 Network Connection
  28. * 82566DC-2 Gigabit Network Connection
  29. * 82566DC Gigabit Network Connection
  30. * 82566DM-2 Gigabit Network Connection
  31. * 82566DM Gigabit Network Connection
  32. * 82566MC Gigabit Network Connection
  33. * 82566MM Gigabit Network Connection
  34. * 82567LM Gigabit Network Connection
  35. * 82567LF Gigabit Network Connection
  36. * 82567V Gigabit Network Connection
  37. * 82567LM-2 Gigabit Network Connection
  38. * 82567LF-2 Gigabit Network Connection
  39. * 82567V-2 Gigabit Network Connection
  40. * 82567LF-3 Gigabit Network Connection
  41. * 82567LM-3 Gigabit Network Connection
  42. * 82567LM-4 Gigabit Network Connection
  43. * 82577LM Gigabit Network Connection
  44. * 82577LC Gigabit Network Connection
  45. * 82578DM Gigabit Network Connection
  46. * 82578DC Gigabit Network Connection
  47. * 82579LM Gigabit Network Connection
  48. * 82579V Gigabit Network Connection
  49. */
  50. #include "e1000.h"
  51. #define ICH_FLASH_GFPREG 0x0000
  52. #define ICH_FLASH_HSFSTS 0x0004
  53. #define ICH_FLASH_HSFCTL 0x0006
  54. #define ICH_FLASH_FADDR 0x0008
  55. #define ICH_FLASH_FDATA0 0x0010
  56. #define ICH_FLASH_PR0 0x0074
  57. #define ICH_FLASH_READ_COMMAND_TIMEOUT 500
  58. #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
  59. #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
  60. #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
  61. #define ICH_FLASH_CYCLE_REPEAT_COUNT 10
  62. #define ICH_CYCLE_READ 0
  63. #define ICH_CYCLE_WRITE 2
  64. #define ICH_CYCLE_ERASE 3
  65. #define FLASH_GFPREG_BASE_MASK 0x1FFF
  66. #define FLASH_SECTOR_ADDR_SHIFT 12
  67. #define ICH_FLASH_SEG_SIZE_256 256
  68. #define ICH_FLASH_SEG_SIZE_4K 4096
  69. #define ICH_FLASH_SEG_SIZE_8K 8192
  70. #define ICH_FLASH_SEG_SIZE_64K 65536
  71. #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
  72. /* FW established a valid mode */
  73. #define E1000_ICH_FWSM_FW_VALID 0x00008000
  74. #define E1000_ICH_MNG_IAMT_MODE 0x2
  75. #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
  76. (ID_LED_DEF1_OFF2 << 8) | \
  77. (ID_LED_DEF1_ON2 << 4) | \
  78. (ID_LED_DEF1_DEF2))
  79. #define E1000_ICH_NVM_SIG_WORD 0x13
  80. #define E1000_ICH_NVM_SIG_MASK 0xC000
  81. #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
  82. #define E1000_ICH_NVM_SIG_VALUE 0x80
  83. #define E1000_ICH8_LAN_INIT_TIMEOUT 1500
  84. #define E1000_FEXTNVM_SW_CONFIG 1
  85. #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
  86. #define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7
  87. #define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7
  88. #define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3
  89. #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
  90. #define E1000_ICH_RAR_ENTRIES 7
  91. #define PHY_PAGE_SHIFT 5
  92. #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
  93. ((reg) & MAX_PHY_REG_ADDRESS))
  94. #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
  95. #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
  96. #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
  97. #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
  98. #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
  99. #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
  100. #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
  101. /* SMBus Address Phy Register */
  102. #define HV_SMB_ADDR PHY_REG(768, 26)
  103. #define HV_SMB_ADDR_MASK 0x007F
  104. #define HV_SMB_ADDR_PEC_EN 0x0200
  105. #define HV_SMB_ADDR_VALID 0x0080
  106. /* PHY Power Management Control */
  107. #define HV_PM_CTRL PHY_REG(770, 17)
  108. /* PHY Low Power Idle Control */
  109. #define I82579_LPI_CTRL PHY_REG(772, 20)
  110. #define I82579_LPI_CTRL_ENABLE_MASK 0x6000
  111. /* Strapping Option Register - RO */
  112. #define E1000_STRAP 0x0000C
  113. #define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
  114. #define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
  115. /* OEM Bits Phy Register */
  116. #define HV_OEM_BITS PHY_REG(768, 25)
  117. #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
  118. #define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
  119. #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
  120. #define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
  121. #define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
  122. /* KMRN Mode Control */
  123. #define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
  124. #define HV_KMRN_MDIO_SLOW 0x0400
  125. /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
  126. /* Offset 04h HSFSTS */
  127. union ich8_hws_flash_status {
  128. struct ich8_hsfsts {
  129. u16 flcdone :1; /* bit 0 Flash Cycle Done */
  130. u16 flcerr :1; /* bit 1 Flash Cycle Error */
  131. u16 dael :1; /* bit 2 Direct Access error Log */
  132. u16 berasesz :2; /* bit 4:3 Sector Erase Size */
  133. u16 flcinprog :1; /* bit 5 flash cycle in Progress */
  134. u16 reserved1 :2; /* bit 13:6 Reserved */
  135. u16 reserved2 :6; /* bit 13:6 Reserved */
  136. u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
  137. u16 flockdn :1; /* bit 15 Flash Config Lock-Down */
  138. } hsf_status;
  139. u16 regval;
  140. };
  141. /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
  142. /* Offset 06h FLCTL */
  143. union ich8_hws_flash_ctrl {
  144. struct ich8_hsflctl {
  145. u16 flcgo :1; /* 0 Flash Cycle Go */
  146. u16 flcycle :2; /* 2:1 Flash Cycle */
  147. u16 reserved :5; /* 7:3 Reserved */
  148. u16 fldbcount :2; /* 9:8 Flash Data Byte Count */
  149. u16 flockdn :6; /* 15:10 Reserved */
  150. } hsf_ctrl;
  151. u16 regval;
  152. };
  153. /* ICH Flash Region Access Permissions */
  154. union ich8_hws_flash_regacc {
  155. struct ich8_flracc {
  156. u32 grra :8; /* 0:7 GbE region Read Access */
  157. u32 grwa :8; /* 8:15 GbE region Write Access */
  158. u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */
  159. u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */
  160. } hsf_flregacc;
  161. u16 regval;
  162. };
  163. /* ICH Flash Protected Region */
  164. union ich8_flash_protected_range {
  165. struct ich8_pr {
  166. u32 base:13; /* 0:12 Protected Range Base */
  167. u32 reserved1:2; /* 13:14 Reserved */
  168. u32 rpe:1; /* 15 Read Protection Enable */
  169. u32 limit:13; /* 16:28 Protected Range Limit */
  170. u32 reserved2:2; /* 29:30 Reserved */
  171. u32 wpe:1; /* 31 Write Protection Enable */
  172. } range;
  173. u32 regval;
  174. };
  175. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
  176. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
  177. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
  178. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
  179. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  180. u32 offset, u8 byte);
  181. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  182. u8 *data);
  183. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  184. u16 *data);
  185. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  186. u8 size, u16 *data);
  187. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
  188. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
  189. static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
  190. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
  191. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
  192. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
  193. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
  194. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
  195. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
  196. static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
  197. static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
  198. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
  199. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
  200. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
  201. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
  202. static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
  203. static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
  204. static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
  205. static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
  206. static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
  207. static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
  208. {
  209. return readw(hw->flash_address + reg);
  210. }
  211. static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
  212. {
  213. return readl(hw->flash_address + reg);
  214. }
  215. static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
  216. {
  217. writew(val, hw->flash_address + reg);
  218. }
  219. static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
  220. {
  221. writel(val, hw->flash_address + reg);
  222. }
  223. #define er16flash(reg) __er16flash(hw, (reg))
  224. #define er32flash(reg) __er32flash(hw, (reg))
  225. #define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
  226. #define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
  227. /**
  228. * e1000_init_phy_params_pchlan - Initialize PHY function pointers
  229. * @hw: pointer to the HW structure
  230. *
  231. * Initialize family-specific PHY parameters and function pointers.
  232. **/
  233. static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
  234. {
  235. struct e1000_phy_info *phy = &hw->phy;
  236. u32 ctrl, fwsm;
  237. s32 ret_val = 0;
  238. phy->addr = 1;
  239. phy->reset_delay_us = 100;
  240. phy->ops.read_reg = e1000_read_phy_reg_hv;
  241. phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
  242. phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
  243. phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
  244. phy->ops.write_reg = e1000_write_phy_reg_hv;
  245. phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
  246. phy->ops.power_up = e1000_power_up_phy_copper;
  247. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  248. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  249. /*
  250. * The MAC-PHY interconnect may still be in SMBus mode
  251. * after Sx->S0. If the manageability engine (ME) is
  252. * disabled, then toggle the LANPHYPC Value bit to force
  253. * the interconnect to PCIe mode.
  254. */
  255. fwsm = er32(FWSM);
  256. if (!(fwsm & E1000_ICH_FWSM_FW_VALID)) {
  257. ctrl = er32(CTRL);
  258. ctrl |= E1000_CTRL_LANPHYPC_OVERRIDE;
  259. ctrl &= ~E1000_CTRL_LANPHYPC_VALUE;
  260. ew32(CTRL, ctrl);
  261. udelay(10);
  262. ctrl &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
  263. ew32(CTRL, ctrl);
  264. msleep(50);
  265. /*
  266. * Gate automatic PHY configuration by hardware on
  267. * non-managed 82579
  268. */
  269. if (hw->mac.type == e1000_pch2lan)
  270. e1000_gate_hw_phy_config_ich8lan(hw, true);
  271. }
  272. /*
  273. * Reset the PHY before any access to it. Doing so, ensures that
  274. * the PHY is in a known good state before we read/write PHY registers.
  275. * The generic reset is sufficient here, because we haven't determined
  276. * the PHY type yet.
  277. */
  278. ret_val = e1000e_phy_hw_reset_generic(hw);
  279. if (ret_val)
  280. goto out;
  281. /* Ungate automatic PHY configuration on non-managed 82579 */
  282. if ((hw->mac.type == e1000_pch2lan) &&
  283. !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
  284. msleep(10);
  285. e1000_gate_hw_phy_config_ich8lan(hw, false);
  286. }
  287. phy->id = e1000_phy_unknown;
  288. switch (hw->mac.type) {
  289. default:
  290. ret_val = e1000e_get_phy_id(hw);
  291. if (ret_val)
  292. goto out;
  293. if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
  294. break;
  295. /* fall-through */
  296. case e1000_pch2lan:
  297. /*
  298. * In case the PHY needs to be in mdio slow mode,
  299. * set slow mode and try to get the PHY id again.
  300. */
  301. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  302. if (ret_val)
  303. goto out;
  304. ret_val = e1000e_get_phy_id(hw);
  305. if (ret_val)
  306. goto out;
  307. break;
  308. }
  309. phy->type = e1000e_get_phy_type_from_id(phy->id);
  310. switch (phy->type) {
  311. case e1000_phy_82577:
  312. case e1000_phy_82579:
  313. phy->ops.check_polarity = e1000_check_polarity_82577;
  314. phy->ops.force_speed_duplex =
  315. e1000_phy_force_speed_duplex_82577;
  316. phy->ops.get_cable_length = e1000_get_cable_length_82577;
  317. phy->ops.get_info = e1000_get_phy_info_82577;
  318. phy->ops.commit = e1000e_phy_sw_reset;
  319. break;
  320. case e1000_phy_82578:
  321. phy->ops.check_polarity = e1000_check_polarity_m88;
  322. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  323. phy->ops.get_cable_length = e1000e_get_cable_length_m88;
  324. phy->ops.get_info = e1000e_get_phy_info_m88;
  325. break;
  326. default:
  327. ret_val = -E1000_ERR_PHY;
  328. break;
  329. }
  330. out:
  331. return ret_val;
  332. }
  333. /**
  334. * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
  335. * @hw: pointer to the HW structure
  336. *
  337. * Initialize family-specific PHY parameters and function pointers.
  338. **/
  339. static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
  340. {
  341. struct e1000_phy_info *phy = &hw->phy;
  342. s32 ret_val;
  343. u16 i = 0;
  344. phy->addr = 1;
  345. phy->reset_delay_us = 100;
  346. phy->ops.power_up = e1000_power_up_phy_copper;
  347. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  348. /*
  349. * We may need to do this twice - once for IGP and if that fails,
  350. * we'll set BM func pointers and try again
  351. */
  352. ret_val = e1000e_determine_phy_address(hw);
  353. if (ret_val) {
  354. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  355. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  356. ret_val = e1000e_determine_phy_address(hw);
  357. if (ret_val) {
  358. e_dbg("Cannot determine PHY addr. Erroring out\n");
  359. return ret_val;
  360. }
  361. }
  362. phy->id = 0;
  363. while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
  364. (i++ < 100)) {
  365. msleep(1);
  366. ret_val = e1000e_get_phy_id(hw);
  367. if (ret_val)
  368. return ret_val;
  369. }
  370. /* Verify phy id */
  371. switch (phy->id) {
  372. case IGP03E1000_E_PHY_ID:
  373. phy->type = e1000_phy_igp_3;
  374. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  375. phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
  376. phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
  377. phy->ops.get_info = e1000e_get_phy_info_igp;
  378. phy->ops.check_polarity = e1000_check_polarity_igp;
  379. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
  380. break;
  381. case IFE_E_PHY_ID:
  382. case IFE_PLUS_E_PHY_ID:
  383. case IFE_C_E_PHY_ID:
  384. phy->type = e1000_phy_ife;
  385. phy->autoneg_mask = E1000_ALL_NOT_GIG;
  386. phy->ops.get_info = e1000_get_phy_info_ife;
  387. phy->ops.check_polarity = e1000_check_polarity_ife;
  388. phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
  389. break;
  390. case BME1000_E_PHY_ID:
  391. phy->type = e1000_phy_bm;
  392. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  393. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  394. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  395. phy->ops.commit = e1000e_phy_sw_reset;
  396. phy->ops.get_info = e1000e_get_phy_info_m88;
  397. phy->ops.check_polarity = e1000_check_polarity_m88;
  398. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  399. break;
  400. default:
  401. return -E1000_ERR_PHY;
  402. break;
  403. }
  404. return 0;
  405. }
  406. /**
  407. * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
  408. * @hw: pointer to the HW structure
  409. *
  410. * Initialize family-specific NVM parameters and function
  411. * pointers.
  412. **/
  413. static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
  414. {
  415. struct e1000_nvm_info *nvm = &hw->nvm;
  416. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  417. u32 gfpreg, sector_base_addr, sector_end_addr;
  418. u16 i;
  419. /* Can't read flash registers if the register set isn't mapped. */
  420. if (!hw->flash_address) {
  421. e_dbg("ERROR: Flash registers not mapped\n");
  422. return -E1000_ERR_CONFIG;
  423. }
  424. nvm->type = e1000_nvm_flash_sw;
  425. gfpreg = er32flash(ICH_FLASH_GFPREG);
  426. /*
  427. * sector_X_addr is a "sector"-aligned address (4096 bytes)
  428. * Add 1 to sector_end_addr since this sector is included in
  429. * the overall size.
  430. */
  431. sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
  432. sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
  433. /* flash_base_addr is byte-aligned */
  434. nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
  435. /*
  436. * find total size of the NVM, then cut in half since the total
  437. * size represents two separate NVM banks.
  438. */
  439. nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
  440. << FLASH_SECTOR_ADDR_SHIFT;
  441. nvm->flash_bank_size /= 2;
  442. /* Adjust to word count */
  443. nvm->flash_bank_size /= sizeof(u16);
  444. nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
  445. /* Clear shadow ram */
  446. for (i = 0; i < nvm->word_size; i++) {
  447. dev_spec->shadow_ram[i].modified = false;
  448. dev_spec->shadow_ram[i].value = 0xFFFF;
  449. }
  450. return 0;
  451. }
  452. /**
  453. * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
  454. * @hw: pointer to the HW structure
  455. *
  456. * Initialize family-specific MAC parameters and function
  457. * pointers.
  458. **/
  459. static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
  460. {
  461. struct e1000_hw *hw = &adapter->hw;
  462. struct e1000_mac_info *mac = &hw->mac;
  463. /* Set media type function pointer */
  464. hw->phy.media_type = e1000_media_type_copper;
  465. /* Set mta register count */
  466. mac->mta_reg_count = 32;
  467. /* Set rar entry count */
  468. mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
  469. if (mac->type == e1000_ich8lan)
  470. mac->rar_entry_count--;
  471. /* FWSM register */
  472. mac->has_fwsm = true;
  473. /* ARC subsystem not supported */
  474. mac->arc_subsystem_valid = false;
  475. /* Adaptive IFS supported */
  476. mac->adaptive_ifs = true;
  477. /* LED operations */
  478. switch (mac->type) {
  479. case e1000_ich8lan:
  480. case e1000_ich9lan:
  481. case e1000_ich10lan:
  482. /* check management mode */
  483. mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
  484. /* ID LED init */
  485. mac->ops.id_led_init = e1000e_id_led_init;
  486. /* setup LED */
  487. mac->ops.setup_led = e1000e_setup_led_generic;
  488. /* cleanup LED */
  489. mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
  490. /* turn on/off LED */
  491. mac->ops.led_on = e1000_led_on_ich8lan;
  492. mac->ops.led_off = e1000_led_off_ich8lan;
  493. break;
  494. case e1000_pchlan:
  495. case e1000_pch2lan:
  496. /* check management mode */
  497. mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
  498. /* ID LED init */
  499. mac->ops.id_led_init = e1000_id_led_init_pchlan;
  500. /* setup LED */
  501. mac->ops.setup_led = e1000_setup_led_pchlan;
  502. /* cleanup LED */
  503. mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
  504. /* turn on/off LED */
  505. mac->ops.led_on = e1000_led_on_pchlan;
  506. mac->ops.led_off = e1000_led_off_pchlan;
  507. break;
  508. default:
  509. break;
  510. }
  511. /* Enable PCS Lock-loss workaround for ICH8 */
  512. if (mac->type == e1000_ich8lan)
  513. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
  514. /* Gate automatic PHY configuration by hardware on managed 82579 */
  515. if ((mac->type == e1000_pch2lan) &&
  516. (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  517. e1000_gate_hw_phy_config_ich8lan(hw, true);
  518. return 0;
  519. }
  520. /**
  521. * e1000_set_eee_pchlan - Enable/disable EEE support
  522. * @hw: pointer to the HW structure
  523. *
  524. * Enable/disable EEE based on setting in dev_spec structure. The bits in
  525. * the LPI Control register will remain set only if/when link is up.
  526. **/
  527. static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
  528. {
  529. s32 ret_val = 0;
  530. u16 phy_reg;
  531. if (hw->phy.type != e1000_phy_82579)
  532. goto out;
  533. ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
  534. if (ret_val)
  535. goto out;
  536. if (hw->dev_spec.ich8lan.eee_disable)
  537. phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
  538. else
  539. phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
  540. ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
  541. out:
  542. return ret_val;
  543. }
  544. /**
  545. * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
  546. * @hw: pointer to the HW structure
  547. *
  548. * Checks to see of the link status of the hardware has changed. If a
  549. * change in link status has been detected, then we read the PHY registers
  550. * to get the current speed/duplex if link exists.
  551. **/
  552. static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
  553. {
  554. struct e1000_mac_info *mac = &hw->mac;
  555. s32 ret_val;
  556. bool link;
  557. /*
  558. * We only want to go out to the PHY registers to see if Auto-Neg
  559. * has completed and/or if our link status has changed. The
  560. * get_link_status flag is set upon receiving a Link Status
  561. * Change or Rx Sequence Error interrupt.
  562. */
  563. if (!mac->get_link_status) {
  564. ret_val = 0;
  565. goto out;
  566. }
  567. /*
  568. * First we want to see if the MII Status Register reports
  569. * link. If so, then we want to get the current speed/duplex
  570. * of the PHY.
  571. */
  572. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  573. if (ret_val)
  574. goto out;
  575. if (hw->mac.type == e1000_pchlan) {
  576. ret_val = e1000_k1_gig_workaround_hv(hw, link);
  577. if (ret_val)
  578. goto out;
  579. }
  580. if (!link)
  581. goto out; /* No link detected */
  582. mac->get_link_status = false;
  583. if (hw->phy.type == e1000_phy_82578) {
  584. ret_val = e1000_link_stall_workaround_hv(hw);
  585. if (ret_val)
  586. goto out;
  587. }
  588. if (hw->mac.type == e1000_pch2lan) {
  589. ret_val = e1000_k1_workaround_lv(hw);
  590. if (ret_val)
  591. goto out;
  592. }
  593. /*
  594. * Check if there was DownShift, must be checked
  595. * immediately after link-up
  596. */
  597. e1000e_check_downshift(hw);
  598. /* Enable/Disable EEE after link up */
  599. ret_val = e1000_set_eee_pchlan(hw);
  600. if (ret_val)
  601. goto out;
  602. /*
  603. * If we are forcing speed/duplex, then we simply return since
  604. * we have already determined whether we have link or not.
  605. */
  606. if (!mac->autoneg) {
  607. ret_val = -E1000_ERR_CONFIG;
  608. goto out;
  609. }
  610. /*
  611. * Auto-Neg is enabled. Auto Speed Detection takes care
  612. * of MAC speed/duplex configuration. So we only need to
  613. * configure Collision Distance in the MAC.
  614. */
  615. e1000e_config_collision_dist(hw);
  616. /*
  617. * Configure Flow Control now that Auto-Neg has completed.
  618. * First, we need to restore the desired flow control
  619. * settings because we may have had to re-autoneg with a
  620. * different link partner.
  621. */
  622. ret_val = e1000e_config_fc_after_link_up(hw);
  623. if (ret_val)
  624. e_dbg("Error configuring flow control\n");
  625. out:
  626. return ret_val;
  627. }
  628. static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
  629. {
  630. struct e1000_hw *hw = &adapter->hw;
  631. s32 rc;
  632. rc = e1000_init_mac_params_ich8lan(adapter);
  633. if (rc)
  634. return rc;
  635. rc = e1000_init_nvm_params_ich8lan(hw);
  636. if (rc)
  637. return rc;
  638. switch (hw->mac.type) {
  639. case e1000_ich8lan:
  640. case e1000_ich9lan:
  641. case e1000_ich10lan:
  642. rc = e1000_init_phy_params_ich8lan(hw);
  643. break;
  644. case e1000_pchlan:
  645. case e1000_pch2lan:
  646. rc = e1000_init_phy_params_pchlan(hw);
  647. break;
  648. default:
  649. break;
  650. }
  651. if (rc)
  652. return rc;
  653. if (adapter->hw.phy.type == e1000_phy_ife) {
  654. adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
  655. adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
  656. }
  657. if ((adapter->hw.mac.type == e1000_ich8lan) &&
  658. (adapter->hw.phy.type == e1000_phy_igp_3))
  659. adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
  660. /* Disable EEE by default until IEEE802.3az spec is finalized */
  661. if (adapter->flags2 & FLAG2_HAS_EEE)
  662. adapter->hw.dev_spec.ich8lan.eee_disable = true;
  663. return 0;
  664. }
  665. static DEFINE_MUTEX(nvm_mutex);
  666. /**
  667. * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
  668. * @hw: pointer to the HW structure
  669. *
  670. * Acquires the mutex for performing NVM operations.
  671. **/
  672. static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
  673. {
  674. mutex_lock(&nvm_mutex);
  675. return 0;
  676. }
  677. /**
  678. * e1000_release_nvm_ich8lan - Release NVM mutex
  679. * @hw: pointer to the HW structure
  680. *
  681. * Releases the mutex used while performing NVM operations.
  682. **/
  683. static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
  684. {
  685. mutex_unlock(&nvm_mutex);
  686. }
  687. static DEFINE_MUTEX(swflag_mutex);
  688. /**
  689. * e1000_acquire_swflag_ich8lan - Acquire software control flag
  690. * @hw: pointer to the HW structure
  691. *
  692. * Acquires the software control flag for performing PHY and select
  693. * MAC CSR accesses.
  694. **/
  695. static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
  696. {
  697. u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
  698. s32 ret_val = 0;
  699. mutex_lock(&swflag_mutex);
  700. while (timeout) {
  701. extcnf_ctrl = er32(EXTCNF_CTRL);
  702. if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
  703. break;
  704. mdelay(1);
  705. timeout--;
  706. }
  707. if (!timeout) {
  708. e_dbg("SW/FW/HW has locked the resource for too long.\n");
  709. ret_val = -E1000_ERR_CONFIG;
  710. goto out;
  711. }
  712. timeout = SW_FLAG_TIMEOUT;
  713. extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
  714. ew32(EXTCNF_CTRL, extcnf_ctrl);
  715. while (timeout) {
  716. extcnf_ctrl = er32(EXTCNF_CTRL);
  717. if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
  718. break;
  719. mdelay(1);
  720. timeout--;
  721. }
  722. if (!timeout) {
  723. e_dbg("Failed to acquire the semaphore.\n");
  724. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  725. ew32(EXTCNF_CTRL, extcnf_ctrl);
  726. ret_val = -E1000_ERR_CONFIG;
  727. goto out;
  728. }
  729. out:
  730. if (ret_val)
  731. mutex_unlock(&swflag_mutex);
  732. return ret_val;
  733. }
  734. /**
  735. * e1000_release_swflag_ich8lan - Release software control flag
  736. * @hw: pointer to the HW structure
  737. *
  738. * Releases the software control flag for performing PHY and select
  739. * MAC CSR accesses.
  740. **/
  741. static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
  742. {
  743. u32 extcnf_ctrl;
  744. extcnf_ctrl = er32(EXTCNF_CTRL);
  745. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  746. ew32(EXTCNF_CTRL, extcnf_ctrl);
  747. mutex_unlock(&swflag_mutex);
  748. }
  749. /**
  750. * e1000_check_mng_mode_ich8lan - Checks management mode
  751. * @hw: pointer to the HW structure
  752. *
  753. * This checks if the adapter has any manageability enabled.
  754. * This is a function pointer entry point only called by read/write
  755. * routines for the PHY and NVM parts.
  756. **/
  757. static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
  758. {
  759. u32 fwsm;
  760. fwsm = er32(FWSM);
  761. return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
  762. ((fwsm & E1000_FWSM_MODE_MASK) ==
  763. (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
  764. }
  765. /**
  766. * e1000_check_mng_mode_pchlan - Checks management mode
  767. * @hw: pointer to the HW structure
  768. *
  769. * This checks if the adapter has iAMT enabled.
  770. * This is a function pointer entry point only called by read/write
  771. * routines for the PHY and NVM parts.
  772. **/
  773. static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
  774. {
  775. u32 fwsm;
  776. fwsm = er32(FWSM);
  777. return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
  778. (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
  779. }
  780. /**
  781. * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
  782. * @hw: pointer to the HW structure
  783. *
  784. * Checks if firmware is blocking the reset of the PHY.
  785. * This is a function pointer entry point only called by
  786. * reset routines.
  787. **/
  788. static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
  789. {
  790. u32 fwsm;
  791. fwsm = er32(FWSM);
  792. return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
  793. }
  794. /**
  795. * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
  796. * @hw: pointer to the HW structure
  797. *
  798. * Assumes semaphore already acquired.
  799. *
  800. **/
  801. static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
  802. {
  803. u16 phy_data;
  804. u32 strap = er32(STRAP);
  805. s32 ret_val = 0;
  806. strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
  807. ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
  808. if (ret_val)
  809. goto out;
  810. phy_data &= ~HV_SMB_ADDR_MASK;
  811. phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
  812. phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
  813. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
  814. out:
  815. return ret_val;
  816. }
  817. /**
  818. * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
  819. * @hw: pointer to the HW structure
  820. *
  821. * SW should configure the LCD from the NVM extended configuration region
  822. * as a workaround for certain parts.
  823. **/
  824. static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
  825. {
  826. struct e1000_phy_info *phy = &hw->phy;
  827. u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
  828. s32 ret_val = 0;
  829. u16 word_addr, reg_data, reg_addr, phy_page = 0;
  830. /*
  831. * Initialize the PHY from the NVM on ICH platforms. This
  832. * is needed due to an issue where the NVM configuration is
  833. * not properly autoloaded after power transitions.
  834. * Therefore, after each PHY reset, we will load the
  835. * configuration data out of the NVM manually.
  836. */
  837. switch (hw->mac.type) {
  838. case e1000_ich8lan:
  839. if (phy->type != e1000_phy_igp_3)
  840. return ret_val;
  841. if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
  842. (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
  843. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
  844. break;
  845. }
  846. /* Fall-thru */
  847. case e1000_pchlan:
  848. case e1000_pch2lan:
  849. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
  850. break;
  851. default:
  852. return ret_val;
  853. }
  854. ret_val = hw->phy.ops.acquire(hw);
  855. if (ret_val)
  856. return ret_val;
  857. data = er32(FEXTNVM);
  858. if (!(data & sw_cfg_mask))
  859. goto out;
  860. /*
  861. * Make sure HW does not configure LCD from PHY
  862. * extended configuration before SW configuration
  863. */
  864. data = er32(EXTCNF_CTRL);
  865. if (!(hw->mac.type == e1000_pch2lan)) {
  866. if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
  867. goto out;
  868. }
  869. cnf_size = er32(EXTCNF_SIZE);
  870. cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
  871. cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
  872. if (!cnf_size)
  873. goto out;
  874. cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
  875. cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
  876. if ((!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
  877. (hw->mac.type == e1000_pchlan)) ||
  878. (hw->mac.type == e1000_pch2lan)) {
  879. /*
  880. * HW configures the SMBus address and LEDs when the
  881. * OEM and LCD Write Enable bits are set in the NVM.
  882. * When both NVM bits are cleared, SW will configure
  883. * them instead.
  884. */
  885. ret_val = e1000_write_smbus_addr(hw);
  886. if (ret_val)
  887. goto out;
  888. data = er32(LEDCTL);
  889. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
  890. (u16)data);
  891. if (ret_val)
  892. goto out;
  893. }
  894. /* Configure LCD from extended configuration region. */
  895. /* cnf_base_addr is in DWORD */
  896. word_addr = (u16)(cnf_base_addr << 1);
  897. for (i = 0; i < cnf_size; i++) {
  898. ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
  899. &reg_data);
  900. if (ret_val)
  901. goto out;
  902. ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
  903. 1, &reg_addr);
  904. if (ret_val)
  905. goto out;
  906. /* Save off the PHY page for future writes. */
  907. if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
  908. phy_page = reg_data;
  909. continue;
  910. }
  911. reg_addr &= PHY_REG_MASK;
  912. reg_addr |= phy_page;
  913. ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
  914. reg_data);
  915. if (ret_val)
  916. goto out;
  917. }
  918. out:
  919. hw->phy.ops.release(hw);
  920. return ret_val;
  921. }
  922. /**
  923. * e1000_k1_gig_workaround_hv - K1 Si workaround
  924. * @hw: pointer to the HW structure
  925. * @link: link up bool flag
  926. *
  927. * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
  928. * from a lower speed. This workaround disables K1 whenever link is at 1Gig
  929. * If link is down, the function will restore the default K1 setting located
  930. * in the NVM.
  931. **/
  932. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
  933. {
  934. s32 ret_val = 0;
  935. u16 status_reg = 0;
  936. bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
  937. if (hw->mac.type != e1000_pchlan)
  938. goto out;
  939. /* Wrap the whole flow with the sw flag */
  940. ret_val = hw->phy.ops.acquire(hw);
  941. if (ret_val)
  942. goto out;
  943. /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
  944. if (link) {
  945. if (hw->phy.type == e1000_phy_82578) {
  946. ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
  947. &status_reg);
  948. if (ret_val)
  949. goto release;
  950. status_reg &= BM_CS_STATUS_LINK_UP |
  951. BM_CS_STATUS_RESOLVED |
  952. BM_CS_STATUS_SPEED_MASK;
  953. if (status_reg == (BM_CS_STATUS_LINK_UP |
  954. BM_CS_STATUS_RESOLVED |
  955. BM_CS_STATUS_SPEED_1000))
  956. k1_enable = false;
  957. }
  958. if (hw->phy.type == e1000_phy_82577) {
  959. ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
  960. &status_reg);
  961. if (ret_val)
  962. goto release;
  963. status_reg &= HV_M_STATUS_LINK_UP |
  964. HV_M_STATUS_AUTONEG_COMPLETE |
  965. HV_M_STATUS_SPEED_MASK;
  966. if (status_reg == (HV_M_STATUS_LINK_UP |
  967. HV_M_STATUS_AUTONEG_COMPLETE |
  968. HV_M_STATUS_SPEED_1000))
  969. k1_enable = false;
  970. }
  971. /* Link stall fix for link up */
  972. ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
  973. 0x0100);
  974. if (ret_val)
  975. goto release;
  976. } else {
  977. /* Link stall fix for link down */
  978. ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
  979. 0x4100);
  980. if (ret_val)
  981. goto release;
  982. }
  983. ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
  984. release:
  985. hw->phy.ops.release(hw);
  986. out:
  987. return ret_val;
  988. }
  989. /**
  990. * e1000_configure_k1_ich8lan - Configure K1 power state
  991. * @hw: pointer to the HW structure
  992. * @enable: K1 state to configure
  993. *
  994. * Configure the K1 power state based on the provided parameter.
  995. * Assumes semaphore already acquired.
  996. *
  997. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  998. **/
  999. s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
  1000. {
  1001. s32 ret_val = 0;
  1002. u32 ctrl_reg = 0;
  1003. u32 ctrl_ext = 0;
  1004. u32 reg = 0;
  1005. u16 kmrn_reg = 0;
  1006. ret_val = e1000e_read_kmrn_reg_locked(hw,
  1007. E1000_KMRNCTRLSTA_K1_CONFIG,
  1008. &kmrn_reg);
  1009. if (ret_val)
  1010. goto out;
  1011. if (k1_enable)
  1012. kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
  1013. else
  1014. kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
  1015. ret_val = e1000e_write_kmrn_reg_locked(hw,
  1016. E1000_KMRNCTRLSTA_K1_CONFIG,
  1017. kmrn_reg);
  1018. if (ret_val)
  1019. goto out;
  1020. udelay(20);
  1021. ctrl_ext = er32(CTRL_EXT);
  1022. ctrl_reg = er32(CTRL);
  1023. reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
  1024. reg |= E1000_CTRL_FRCSPD;
  1025. ew32(CTRL, reg);
  1026. ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
  1027. udelay(20);
  1028. ew32(CTRL, ctrl_reg);
  1029. ew32(CTRL_EXT, ctrl_ext);
  1030. udelay(20);
  1031. out:
  1032. return ret_val;
  1033. }
  1034. /**
  1035. * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
  1036. * @hw: pointer to the HW structure
  1037. * @d0_state: boolean if entering d0 or d3 device state
  1038. *
  1039. * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
  1040. * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
  1041. * in NVM determines whether HW should configure LPLU and Gbe Disable.
  1042. **/
  1043. static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
  1044. {
  1045. s32 ret_val = 0;
  1046. u32 mac_reg;
  1047. u16 oem_reg;
  1048. if ((hw->mac.type != e1000_pch2lan) && (hw->mac.type != e1000_pchlan))
  1049. return ret_val;
  1050. ret_val = hw->phy.ops.acquire(hw);
  1051. if (ret_val)
  1052. return ret_val;
  1053. if (!(hw->mac.type == e1000_pch2lan)) {
  1054. mac_reg = er32(EXTCNF_CTRL);
  1055. if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
  1056. goto out;
  1057. }
  1058. mac_reg = er32(FEXTNVM);
  1059. if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
  1060. goto out;
  1061. mac_reg = er32(PHY_CTRL);
  1062. ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
  1063. if (ret_val)
  1064. goto out;
  1065. oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
  1066. if (d0_state) {
  1067. if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
  1068. oem_reg |= HV_OEM_BITS_GBE_DIS;
  1069. if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
  1070. oem_reg |= HV_OEM_BITS_LPLU;
  1071. } else {
  1072. if (mac_reg & E1000_PHY_CTRL_NOND0A_GBE_DISABLE)
  1073. oem_reg |= HV_OEM_BITS_GBE_DIS;
  1074. if (mac_reg & E1000_PHY_CTRL_NOND0A_LPLU)
  1075. oem_reg |= HV_OEM_BITS_LPLU;
  1076. }
  1077. /* Restart auto-neg to activate the bits */
  1078. if (!e1000_check_reset_block(hw))
  1079. oem_reg |= HV_OEM_BITS_RESTART_AN;
  1080. ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
  1081. out:
  1082. hw->phy.ops.release(hw);
  1083. return ret_val;
  1084. }
  1085. /**
  1086. * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
  1087. * @hw: pointer to the HW structure
  1088. **/
  1089. static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
  1090. {
  1091. s32 ret_val;
  1092. u16 data;
  1093. ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
  1094. if (ret_val)
  1095. return ret_val;
  1096. data |= HV_KMRN_MDIO_SLOW;
  1097. ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
  1098. return ret_val;
  1099. }
  1100. /**
  1101. * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  1102. * done after every PHY reset.
  1103. **/
  1104. static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
  1105. {
  1106. s32 ret_val = 0;
  1107. u16 phy_data;
  1108. if (hw->mac.type != e1000_pchlan)
  1109. return ret_val;
  1110. /* Set MDIO slow mode before any other MDIO access */
  1111. if (hw->phy.type == e1000_phy_82577) {
  1112. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  1113. if (ret_val)
  1114. goto out;
  1115. }
  1116. if (((hw->phy.type == e1000_phy_82577) &&
  1117. ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
  1118. ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
  1119. /* Disable generation of early preamble */
  1120. ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
  1121. if (ret_val)
  1122. return ret_val;
  1123. /* Preamble tuning for SSC */
  1124. ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204);
  1125. if (ret_val)
  1126. return ret_val;
  1127. }
  1128. if (hw->phy.type == e1000_phy_82578) {
  1129. /*
  1130. * Return registers to default by doing a soft reset then
  1131. * writing 0x3140 to the control register.
  1132. */
  1133. if (hw->phy.revision < 2) {
  1134. e1000e_phy_sw_reset(hw);
  1135. ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
  1136. }
  1137. }
  1138. /* Select page 0 */
  1139. ret_val = hw->phy.ops.acquire(hw);
  1140. if (ret_val)
  1141. return ret_val;
  1142. hw->phy.addr = 1;
  1143. ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
  1144. hw->phy.ops.release(hw);
  1145. if (ret_val)
  1146. goto out;
  1147. /*
  1148. * Configure the K1 Si workaround during phy reset assuming there is
  1149. * link so that it disables K1 if link is in 1Gbps.
  1150. */
  1151. ret_val = e1000_k1_gig_workaround_hv(hw, true);
  1152. if (ret_val)
  1153. goto out;
  1154. /* Workaround for link disconnects on a busy hub in half duplex */
  1155. ret_val = hw->phy.ops.acquire(hw);
  1156. if (ret_val)
  1157. goto out;
  1158. ret_val = hw->phy.ops.read_reg_locked(hw,
  1159. PHY_REG(BM_PORT_CTRL_PAGE, 17),
  1160. &phy_data);
  1161. if (ret_val)
  1162. goto release;
  1163. ret_val = hw->phy.ops.write_reg_locked(hw,
  1164. PHY_REG(BM_PORT_CTRL_PAGE, 17),
  1165. phy_data & 0x00FF);
  1166. release:
  1167. hw->phy.ops.release(hw);
  1168. out:
  1169. return ret_val;
  1170. }
  1171. /**
  1172. * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
  1173. * @hw: pointer to the HW structure
  1174. **/
  1175. void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
  1176. {
  1177. u32 mac_reg;
  1178. u16 i;
  1179. /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
  1180. for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
  1181. mac_reg = er32(RAL(i));
  1182. e1e_wphy(hw, BM_RAR_L(i), (u16)(mac_reg & 0xFFFF));
  1183. e1e_wphy(hw, BM_RAR_M(i), (u16)((mac_reg >> 16) & 0xFFFF));
  1184. mac_reg = er32(RAH(i));
  1185. e1e_wphy(hw, BM_RAR_H(i), (u16)(mac_reg & 0xFFFF));
  1186. e1e_wphy(hw, BM_RAR_CTRL(i), (u16)((mac_reg >> 16) & 0x8000));
  1187. }
  1188. }
  1189. /**
  1190. * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
  1191. * with 82579 PHY
  1192. * @hw: pointer to the HW structure
  1193. * @enable: flag to enable/disable workaround when enabling/disabling jumbos
  1194. **/
  1195. s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
  1196. {
  1197. s32 ret_val = 0;
  1198. u16 phy_reg, data;
  1199. u32 mac_reg;
  1200. u16 i;
  1201. if (hw->mac.type != e1000_pch2lan)
  1202. goto out;
  1203. /* disable Rx path while enabling/disabling workaround */
  1204. e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
  1205. ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
  1206. if (ret_val)
  1207. goto out;
  1208. if (enable) {
  1209. /*
  1210. * Write Rx addresses (rar_entry_count for RAL/H, +4 for
  1211. * SHRAL/H) and initial CRC values to the MAC
  1212. */
  1213. for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
  1214. u8 mac_addr[ETH_ALEN] = {0};
  1215. u32 addr_high, addr_low;
  1216. addr_high = er32(RAH(i));
  1217. if (!(addr_high & E1000_RAH_AV))
  1218. continue;
  1219. addr_low = er32(RAL(i));
  1220. mac_addr[0] = (addr_low & 0xFF);
  1221. mac_addr[1] = ((addr_low >> 8) & 0xFF);
  1222. mac_addr[2] = ((addr_low >> 16) & 0xFF);
  1223. mac_addr[3] = ((addr_low >> 24) & 0xFF);
  1224. mac_addr[4] = (addr_high & 0xFF);
  1225. mac_addr[5] = ((addr_high >> 8) & 0xFF);
  1226. ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
  1227. }
  1228. /* Write Rx addresses to the PHY */
  1229. e1000_copy_rx_addrs_to_phy_ich8lan(hw);
  1230. /* Enable jumbo frame workaround in the MAC */
  1231. mac_reg = er32(FFLT_DBG);
  1232. mac_reg &= ~(1 << 14);
  1233. mac_reg |= (7 << 15);
  1234. ew32(FFLT_DBG, mac_reg);
  1235. mac_reg = er32(RCTL);
  1236. mac_reg |= E1000_RCTL_SECRC;
  1237. ew32(RCTL, mac_reg);
  1238. ret_val = e1000e_read_kmrn_reg(hw,
  1239. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  1240. &data);
  1241. if (ret_val)
  1242. goto out;
  1243. ret_val = e1000e_write_kmrn_reg(hw,
  1244. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  1245. data | (1 << 0));
  1246. if (ret_val)
  1247. goto out;
  1248. ret_val = e1000e_read_kmrn_reg(hw,
  1249. E1000_KMRNCTRLSTA_HD_CTRL,
  1250. &data);
  1251. if (ret_val)
  1252. goto out;
  1253. data &= ~(0xF << 8);
  1254. data |= (0xB << 8);
  1255. ret_val = e1000e_write_kmrn_reg(hw,
  1256. E1000_KMRNCTRLSTA_HD_CTRL,
  1257. data);
  1258. if (ret_val)
  1259. goto out;
  1260. /* Enable jumbo frame workaround in the PHY */
  1261. e1e_rphy(hw, PHY_REG(769, 23), &data);
  1262. data &= ~(0x7F << 5);
  1263. data |= (0x37 << 5);
  1264. ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
  1265. if (ret_val)
  1266. goto out;
  1267. e1e_rphy(hw, PHY_REG(769, 16), &data);
  1268. data &= ~(1 << 13);
  1269. ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
  1270. if (ret_val)
  1271. goto out;
  1272. e1e_rphy(hw, PHY_REG(776, 20), &data);
  1273. data &= ~(0x3FF << 2);
  1274. data |= (0x1A << 2);
  1275. ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
  1276. if (ret_val)
  1277. goto out;
  1278. ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xFE00);
  1279. if (ret_val)
  1280. goto out;
  1281. e1e_rphy(hw, HV_PM_CTRL, &data);
  1282. ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
  1283. if (ret_val)
  1284. goto out;
  1285. } else {
  1286. /* Write MAC register values back to h/w defaults */
  1287. mac_reg = er32(FFLT_DBG);
  1288. mac_reg &= ~(0xF << 14);
  1289. ew32(FFLT_DBG, mac_reg);
  1290. mac_reg = er32(RCTL);
  1291. mac_reg &= ~E1000_RCTL_SECRC;
  1292. ew32(RCTL, mac_reg);
  1293. ret_val = e1000e_read_kmrn_reg(hw,
  1294. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  1295. &data);
  1296. if (ret_val)
  1297. goto out;
  1298. ret_val = e1000e_write_kmrn_reg(hw,
  1299. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  1300. data & ~(1 << 0));
  1301. if (ret_val)
  1302. goto out;
  1303. ret_val = e1000e_read_kmrn_reg(hw,
  1304. E1000_KMRNCTRLSTA_HD_CTRL,
  1305. &data);
  1306. if (ret_val)
  1307. goto out;
  1308. data &= ~(0xF << 8);
  1309. data |= (0xB << 8);
  1310. ret_val = e1000e_write_kmrn_reg(hw,
  1311. E1000_KMRNCTRLSTA_HD_CTRL,
  1312. data);
  1313. if (ret_val)
  1314. goto out;
  1315. /* Write PHY register values back to h/w defaults */
  1316. e1e_rphy(hw, PHY_REG(769, 23), &data);
  1317. data &= ~(0x7F << 5);
  1318. ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
  1319. if (ret_val)
  1320. goto out;
  1321. e1e_rphy(hw, PHY_REG(769, 16), &data);
  1322. data |= (1 << 13);
  1323. ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
  1324. if (ret_val)
  1325. goto out;
  1326. e1e_rphy(hw, PHY_REG(776, 20), &data);
  1327. data &= ~(0x3FF << 2);
  1328. data |= (0x8 << 2);
  1329. ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
  1330. if (ret_val)
  1331. goto out;
  1332. ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
  1333. if (ret_val)
  1334. goto out;
  1335. e1e_rphy(hw, HV_PM_CTRL, &data);
  1336. ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
  1337. if (ret_val)
  1338. goto out;
  1339. }
  1340. /* re-enable Rx path after enabling/disabling workaround */
  1341. ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
  1342. out:
  1343. return ret_val;
  1344. }
  1345. /**
  1346. * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  1347. * done after every PHY reset.
  1348. **/
  1349. static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
  1350. {
  1351. s32 ret_val = 0;
  1352. if (hw->mac.type != e1000_pch2lan)
  1353. goto out;
  1354. /* Set MDIO slow mode before any other MDIO access */
  1355. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  1356. out:
  1357. return ret_val;
  1358. }
  1359. /**
  1360. * e1000_k1_gig_workaround_lv - K1 Si workaround
  1361. * @hw: pointer to the HW structure
  1362. *
  1363. * Workaround to set the K1 beacon duration for 82579 parts
  1364. **/
  1365. static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
  1366. {
  1367. s32 ret_val = 0;
  1368. u16 status_reg = 0;
  1369. u32 mac_reg;
  1370. if (hw->mac.type != e1000_pch2lan)
  1371. goto out;
  1372. /* Set K1 beacon duration based on 1Gbps speed or otherwise */
  1373. ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
  1374. if (ret_val)
  1375. goto out;
  1376. if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
  1377. == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
  1378. mac_reg = er32(FEXTNVM4);
  1379. mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
  1380. if (status_reg & HV_M_STATUS_SPEED_1000)
  1381. mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
  1382. else
  1383. mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
  1384. ew32(FEXTNVM4, mac_reg);
  1385. }
  1386. out:
  1387. return ret_val;
  1388. }
  1389. /**
  1390. * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
  1391. * @hw: pointer to the HW structure
  1392. * @gate: boolean set to true to gate, false to ungate
  1393. *
  1394. * Gate/ungate the automatic PHY configuration via hardware; perform
  1395. * the configuration via software instead.
  1396. **/
  1397. static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
  1398. {
  1399. u32 extcnf_ctrl;
  1400. if (hw->mac.type != e1000_pch2lan)
  1401. return;
  1402. extcnf_ctrl = er32(EXTCNF_CTRL);
  1403. if (gate)
  1404. extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
  1405. else
  1406. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
  1407. ew32(EXTCNF_CTRL, extcnf_ctrl);
  1408. return;
  1409. }
  1410. /**
  1411. * e1000_lan_init_done_ich8lan - Check for PHY config completion
  1412. * @hw: pointer to the HW structure
  1413. *
  1414. * Check the appropriate indication the MAC has finished configuring the
  1415. * PHY after a software reset.
  1416. **/
  1417. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
  1418. {
  1419. u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
  1420. /* Wait for basic configuration completes before proceeding */
  1421. do {
  1422. data = er32(STATUS);
  1423. data &= E1000_STATUS_LAN_INIT_DONE;
  1424. udelay(100);
  1425. } while ((!data) && --loop);
  1426. /*
  1427. * If basic configuration is incomplete before the above loop
  1428. * count reaches 0, loading the configuration from NVM will
  1429. * leave the PHY in a bad state possibly resulting in no link.
  1430. */
  1431. if (loop == 0)
  1432. e_dbg("LAN_INIT_DONE not set, increase timeout\n");
  1433. /* Clear the Init Done bit for the next init event */
  1434. data = er32(STATUS);
  1435. data &= ~E1000_STATUS_LAN_INIT_DONE;
  1436. ew32(STATUS, data);
  1437. }
  1438. /**
  1439. * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
  1440. * @hw: pointer to the HW structure
  1441. **/
  1442. static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
  1443. {
  1444. s32 ret_val = 0;
  1445. u16 reg;
  1446. if (e1000_check_reset_block(hw))
  1447. goto out;
  1448. /* Allow time for h/w to get to quiescent state after reset */
  1449. msleep(10);
  1450. /* Perform any necessary post-reset workarounds */
  1451. switch (hw->mac.type) {
  1452. case e1000_pchlan:
  1453. ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
  1454. if (ret_val)
  1455. goto out;
  1456. break;
  1457. case e1000_pch2lan:
  1458. ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
  1459. if (ret_val)
  1460. goto out;
  1461. break;
  1462. default:
  1463. break;
  1464. }
  1465. /* Dummy read to clear the phy wakeup bit after lcd reset */
  1466. if (hw->mac.type >= e1000_pchlan)
  1467. e1e_rphy(hw, BM_WUC, &reg);
  1468. /* Configure the LCD with the extended configuration region in NVM */
  1469. ret_val = e1000_sw_lcd_config_ich8lan(hw);
  1470. if (ret_val)
  1471. goto out;
  1472. /* Configure the LCD with the OEM bits in NVM */
  1473. ret_val = e1000_oem_bits_config_ich8lan(hw, true);
  1474. /* Ungate automatic PHY configuration on non-managed 82579 */
  1475. if ((hw->mac.type == e1000_pch2lan) &&
  1476. !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
  1477. msleep(10);
  1478. e1000_gate_hw_phy_config_ich8lan(hw, false);
  1479. }
  1480. out:
  1481. return ret_val;
  1482. }
  1483. /**
  1484. * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
  1485. * @hw: pointer to the HW structure
  1486. *
  1487. * Resets the PHY
  1488. * This is a function pointer entry point called by drivers
  1489. * or other shared routines.
  1490. **/
  1491. static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  1492. {
  1493. s32 ret_val = 0;
  1494. /* Gate automatic PHY configuration by hardware on non-managed 82579 */
  1495. if ((hw->mac.type == e1000_pch2lan) &&
  1496. !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  1497. e1000_gate_hw_phy_config_ich8lan(hw, true);
  1498. ret_val = e1000e_phy_hw_reset_generic(hw);
  1499. if (ret_val)
  1500. goto out;
  1501. ret_val = e1000_post_phy_reset_ich8lan(hw);
  1502. out:
  1503. return ret_val;
  1504. }
  1505. /**
  1506. * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
  1507. * @hw: pointer to the HW structure
  1508. * @active: true to enable LPLU, false to disable
  1509. *
  1510. * Sets the LPLU state according to the active flag. For PCH, if OEM write
  1511. * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
  1512. * the phy speed. This function will manually set the LPLU bit and restart
  1513. * auto-neg as hw would do. D3 and D0 LPLU will call the same function
  1514. * since it configures the same bit.
  1515. **/
  1516. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
  1517. {
  1518. s32 ret_val = 0;
  1519. u16 oem_reg;
  1520. ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
  1521. if (ret_val)
  1522. goto out;
  1523. if (active)
  1524. oem_reg |= HV_OEM_BITS_LPLU;
  1525. else
  1526. oem_reg &= ~HV_OEM_BITS_LPLU;
  1527. oem_reg |= HV_OEM_BITS_RESTART_AN;
  1528. ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg);
  1529. out:
  1530. return ret_val;
  1531. }
  1532. /**
  1533. * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
  1534. * @hw: pointer to the HW structure
  1535. * @active: true to enable LPLU, false to disable
  1536. *
  1537. * Sets the LPLU D0 state according to the active flag. When
  1538. * activating LPLU this function also disables smart speed
  1539. * and vice versa. LPLU will not be activated unless the
  1540. * device autonegotiation advertisement meets standards of
  1541. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  1542. * This is a function pointer entry point only called by
  1543. * PHY setup routines.
  1544. **/
  1545. static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  1546. {
  1547. struct e1000_phy_info *phy = &hw->phy;
  1548. u32 phy_ctrl;
  1549. s32 ret_val = 0;
  1550. u16 data;
  1551. if (phy->type == e1000_phy_ife)
  1552. return ret_val;
  1553. phy_ctrl = er32(PHY_CTRL);
  1554. if (active) {
  1555. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
  1556. ew32(PHY_CTRL, phy_ctrl);
  1557. if (phy->type != e1000_phy_igp_3)
  1558. return 0;
  1559. /*
  1560. * Call gig speed drop workaround on LPLU before accessing
  1561. * any PHY registers
  1562. */
  1563. if (hw->mac.type == e1000_ich8lan)
  1564. e1000e_gig_downshift_workaround_ich8lan(hw);
  1565. /* When LPLU is enabled, we should disable SmartSpeed */
  1566. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  1567. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1568. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  1569. if (ret_val)
  1570. return ret_val;
  1571. } else {
  1572. phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
  1573. ew32(PHY_CTRL, phy_ctrl);
  1574. if (phy->type != e1000_phy_igp_3)
  1575. return 0;
  1576. /*
  1577. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  1578. * during Dx states where the power conservation is most
  1579. * important. During driver activity we should enable
  1580. * SmartSpeed, so performance is maintained.
  1581. */
  1582. if (phy->smart_speed == e1000_smart_speed_on) {
  1583. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1584. &data);
  1585. if (ret_val)
  1586. return ret_val;
  1587. data |= IGP01E1000_PSCFR_SMART_SPEED;
  1588. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1589. data);
  1590. if (ret_val)
  1591. return ret_val;
  1592. } else if (phy->smart_speed == e1000_smart_speed_off) {
  1593. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1594. &data);
  1595. if (ret_val)
  1596. return ret_val;
  1597. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1598. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1599. data);
  1600. if (ret_val)
  1601. return ret_val;
  1602. }
  1603. }
  1604. return 0;
  1605. }
  1606. /**
  1607. * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
  1608. * @hw: pointer to the HW structure
  1609. * @active: true to enable LPLU, false to disable
  1610. *
  1611. * Sets the LPLU D3 state according to the active flag. When
  1612. * activating LPLU this function also disables smart speed
  1613. * and vice versa. LPLU will not be activated unless the
  1614. * device autonegotiation advertisement meets standards of
  1615. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  1616. * This is a function pointer entry point only called by
  1617. * PHY setup routines.
  1618. **/
  1619. static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  1620. {
  1621. struct e1000_phy_info *phy = &hw->phy;
  1622. u32 phy_ctrl;
  1623. s32 ret_val;
  1624. u16 data;
  1625. phy_ctrl = er32(PHY_CTRL);
  1626. if (!active) {
  1627. phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
  1628. ew32(PHY_CTRL, phy_ctrl);
  1629. if (phy->type != e1000_phy_igp_3)
  1630. return 0;
  1631. /*
  1632. * LPLU and SmartSpeed are mutually exclusive. LPLU is used
  1633. * during Dx states where the power conservation is most
  1634. * important. During driver activity we should enable
  1635. * SmartSpeed, so performance is maintained.
  1636. */
  1637. if (phy->smart_speed == e1000_smart_speed_on) {
  1638. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1639. &data);
  1640. if (ret_val)
  1641. return ret_val;
  1642. data |= IGP01E1000_PSCFR_SMART_SPEED;
  1643. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1644. data);
  1645. if (ret_val)
  1646. return ret_val;
  1647. } else if (phy->smart_speed == e1000_smart_speed_off) {
  1648. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1649. &data);
  1650. if (ret_val)
  1651. return ret_val;
  1652. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1653. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  1654. data);
  1655. if (ret_val)
  1656. return ret_val;
  1657. }
  1658. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  1659. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  1660. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  1661. phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
  1662. ew32(PHY_CTRL, phy_ctrl);
  1663. if (phy->type != e1000_phy_igp_3)
  1664. return 0;
  1665. /*
  1666. * Call gig speed drop workaround on LPLU before accessing
  1667. * any PHY registers
  1668. */
  1669. if (hw->mac.type == e1000_ich8lan)
  1670. e1000e_gig_downshift_workaround_ich8lan(hw);
  1671. /* When LPLU is enabled, we should disable SmartSpeed */
  1672. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  1673. if (ret_val)
  1674. return ret_val;
  1675. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  1676. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  1677. }
  1678. return 0;
  1679. }
  1680. /**
  1681. * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
  1682. * @hw: pointer to the HW structure
  1683. * @bank: pointer to the variable that returns the active bank
  1684. *
  1685. * Reads signature byte from the NVM using the flash access registers.
  1686. * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
  1687. **/
  1688. static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
  1689. {
  1690. u32 eecd;
  1691. struct e1000_nvm_info *nvm = &hw->nvm;
  1692. u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
  1693. u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
  1694. u8 sig_byte = 0;
  1695. s32 ret_val = 0;
  1696. switch (hw->mac.type) {
  1697. case e1000_ich8lan:
  1698. case e1000_ich9lan:
  1699. eecd = er32(EECD);
  1700. if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
  1701. E1000_EECD_SEC1VAL_VALID_MASK) {
  1702. if (eecd & E1000_EECD_SEC1VAL)
  1703. *bank = 1;
  1704. else
  1705. *bank = 0;
  1706. return 0;
  1707. }
  1708. e_dbg("Unable to determine valid NVM bank via EEC - "
  1709. "reading flash signature\n");
  1710. /* fall-thru */
  1711. default:
  1712. /* set bank to 0 in case flash read fails */
  1713. *bank = 0;
  1714. /* Check bank 0 */
  1715. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
  1716. &sig_byte);
  1717. if (ret_val)
  1718. return ret_val;
  1719. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  1720. E1000_ICH_NVM_SIG_VALUE) {
  1721. *bank = 0;
  1722. return 0;
  1723. }
  1724. /* Check bank 1 */
  1725. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
  1726. bank1_offset,
  1727. &sig_byte);
  1728. if (ret_val)
  1729. return ret_val;
  1730. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  1731. E1000_ICH_NVM_SIG_VALUE) {
  1732. *bank = 1;
  1733. return 0;
  1734. }
  1735. e_dbg("ERROR: No valid NVM bank present\n");
  1736. return -E1000_ERR_NVM;
  1737. }
  1738. return 0;
  1739. }
  1740. /**
  1741. * e1000_read_nvm_ich8lan - Read word(s) from the NVM
  1742. * @hw: pointer to the HW structure
  1743. * @offset: The offset (in bytes) of the word(s) to read.
  1744. * @words: Size of data to read in words
  1745. * @data: Pointer to the word(s) to read at offset.
  1746. *
  1747. * Reads a word(s) from the NVM using the flash access registers.
  1748. **/
  1749. static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  1750. u16 *data)
  1751. {
  1752. struct e1000_nvm_info *nvm = &hw->nvm;
  1753. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  1754. u32 act_offset;
  1755. s32 ret_val = 0;
  1756. u32 bank = 0;
  1757. u16 i, word;
  1758. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  1759. (words == 0)) {
  1760. e_dbg("nvm parameter(s) out of bounds\n");
  1761. ret_val = -E1000_ERR_NVM;
  1762. goto out;
  1763. }
  1764. nvm->ops.acquire(hw);
  1765. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  1766. if (ret_val) {
  1767. e_dbg("Could not detect valid bank, assuming bank 0\n");
  1768. bank = 0;
  1769. }
  1770. act_offset = (bank) ? nvm->flash_bank_size : 0;
  1771. act_offset += offset;
  1772. ret_val = 0;
  1773. for (i = 0; i < words; i++) {
  1774. if ((dev_spec->shadow_ram) &&
  1775. (dev_spec->shadow_ram[offset+i].modified)) {
  1776. data[i] = dev_spec->shadow_ram[offset+i].value;
  1777. } else {
  1778. ret_val = e1000_read_flash_word_ich8lan(hw,
  1779. act_offset + i,
  1780. &word);
  1781. if (ret_val)
  1782. break;
  1783. data[i] = word;
  1784. }
  1785. }
  1786. nvm->ops.release(hw);
  1787. out:
  1788. if (ret_val)
  1789. e_dbg("NVM read error: %d\n", ret_val);
  1790. return ret_val;
  1791. }
  1792. /**
  1793. * e1000_flash_cycle_init_ich8lan - Initialize flash
  1794. * @hw: pointer to the HW structure
  1795. *
  1796. * This function does initial flash setup so that a new read/write/erase cycle
  1797. * can be started.
  1798. **/
  1799. static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
  1800. {
  1801. union ich8_hws_flash_status hsfsts;
  1802. s32 ret_val = -E1000_ERR_NVM;
  1803. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1804. /* Check if the flash descriptor is valid */
  1805. if (hsfsts.hsf_status.fldesvalid == 0) {
  1806. e_dbg("Flash descriptor invalid. "
  1807. "SW Sequencing must be used.\n");
  1808. return -E1000_ERR_NVM;
  1809. }
  1810. /* Clear FCERR and DAEL in hw status by writing 1 */
  1811. hsfsts.hsf_status.flcerr = 1;
  1812. hsfsts.hsf_status.dael = 1;
  1813. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1814. /*
  1815. * Either we should have a hardware SPI cycle in progress
  1816. * bit to check against, in order to start a new cycle or
  1817. * FDONE bit should be changed in the hardware so that it
  1818. * is 1 after hardware reset, which can then be used as an
  1819. * indication whether a cycle is in progress or has been
  1820. * completed.
  1821. */
  1822. if (hsfsts.hsf_status.flcinprog == 0) {
  1823. /*
  1824. * There is no cycle running at present,
  1825. * so we can start a cycle.
  1826. * Begin by setting Flash Cycle Done.
  1827. */
  1828. hsfsts.hsf_status.flcdone = 1;
  1829. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1830. ret_val = 0;
  1831. } else {
  1832. s32 i = 0;
  1833. /*
  1834. * Otherwise poll for sometime so the current
  1835. * cycle has a chance to end before giving up.
  1836. */
  1837. for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
  1838. hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
  1839. if (hsfsts.hsf_status.flcinprog == 0) {
  1840. ret_val = 0;
  1841. break;
  1842. }
  1843. udelay(1);
  1844. }
  1845. if (ret_val == 0) {
  1846. /*
  1847. * Successful in waiting for previous cycle to timeout,
  1848. * now set the Flash Cycle Done.
  1849. */
  1850. hsfsts.hsf_status.flcdone = 1;
  1851. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  1852. } else {
  1853. e_dbg("Flash controller busy, cannot get access\n");
  1854. }
  1855. }
  1856. return ret_val;
  1857. }
  1858. /**
  1859. * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
  1860. * @hw: pointer to the HW structure
  1861. * @timeout: maximum time to wait for completion
  1862. *
  1863. * This function starts a flash cycle and waits for its completion.
  1864. **/
  1865. static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
  1866. {
  1867. union ich8_hws_flash_ctrl hsflctl;
  1868. union ich8_hws_flash_status hsfsts;
  1869. s32 ret_val = -E1000_ERR_NVM;
  1870. u32 i = 0;
  1871. /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
  1872. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1873. hsflctl.hsf_ctrl.flcgo = 1;
  1874. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1875. /* wait till FDONE bit is set to 1 */
  1876. do {
  1877. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1878. if (hsfsts.hsf_status.flcdone == 1)
  1879. break;
  1880. udelay(1);
  1881. } while (i++ < timeout);
  1882. if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
  1883. return 0;
  1884. return ret_val;
  1885. }
  1886. /**
  1887. * e1000_read_flash_word_ich8lan - Read word from flash
  1888. * @hw: pointer to the HW structure
  1889. * @offset: offset to data location
  1890. * @data: pointer to the location for storing the data
  1891. *
  1892. * Reads the flash word at offset into data. Offset is converted
  1893. * to bytes before read.
  1894. **/
  1895. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  1896. u16 *data)
  1897. {
  1898. /* Must convert offset into bytes. */
  1899. offset <<= 1;
  1900. return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
  1901. }
  1902. /**
  1903. * e1000_read_flash_byte_ich8lan - Read byte from flash
  1904. * @hw: pointer to the HW structure
  1905. * @offset: The offset of the byte to read.
  1906. * @data: Pointer to a byte to store the value read.
  1907. *
  1908. * Reads a single byte from the NVM using the flash access registers.
  1909. **/
  1910. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  1911. u8 *data)
  1912. {
  1913. s32 ret_val;
  1914. u16 word = 0;
  1915. ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
  1916. if (ret_val)
  1917. return ret_val;
  1918. *data = (u8)word;
  1919. return 0;
  1920. }
  1921. /**
  1922. * e1000_read_flash_data_ich8lan - Read byte or word from NVM
  1923. * @hw: pointer to the HW structure
  1924. * @offset: The offset (in bytes) of the byte or word to read.
  1925. * @size: Size of data to read, 1=byte 2=word
  1926. * @data: Pointer to the word to store the value read.
  1927. *
  1928. * Reads a byte or word from the NVM using the flash access registers.
  1929. **/
  1930. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  1931. u8 size, u16 *data)
  1932. {
  1933. union ich8_hws_flash_status hsfsts;
  1934. union ich8_hws_flash_ctrl hsflctl;
  1935. u32 flash_linear_addr;
  1936. u32 flash_data = 0;
  1937. s32 ret_val = -E1000_ERR_NVM;
  1938. u8 count = 0;
  1939. if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  1940. return -E1000_ERR_NVM;
  1941. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  1942. hw->nvm.flash_base_addr;
  1943. do {
  1944. udelay(1);
  1945. /* Steps */
  1946. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  1947. if (ret_val != 0)
  1948. break;
  1949. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  1950. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  1951. hsflctl.hsf_ctrl.fldbcount = size - 1;
  1952. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
  1953. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  1954. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  1955. ret_val = e1000_flash_cycle_ich8lan(hw,
  1956. ICH_FLASH_READ_COMMAND_TIMEOUT);
  1957. /*
  1958. * Check if FCERR is set to 1, if set to 1, clear it
  1959. * and try the whole sequence a few more times, else
  1960. * read in (shift in) the Flash Data0, the order is
  1961. * least significant byte first msb to lsb
  1962. */
  1963. if (ret_val == 0) {
  1964. flash_data = er32flash(ICH_FLASH_FDATA0);
  1965. if (size == 1)
  1966. *data = (u8)(flash_data & 0x000000FF);
  1967. else if (size == 2)
  1968. *data = (u16)(flash_data & 0x0000FFFF);
  1969. break;
  1970. } else {
  1971. /*
  1972. * If we've gotten here, then things are probably
  1973. * completely hosed, but if the error condition is
  1974. * detected, it won't hurt to give it another try...
  1975. * ICH_FLASH_CYCLE_REPEAT_COUNT times.
  1976. */
  1977. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  1978. if (hsfsts.hsf_status.flcerr == 1) {
  1979. /* Repeat for some time before giving up. */
  1980. continue;
  1981. } else if (hsfsts.hsf_status.flcdone == 0) {
  1982. e_dbg("Timeout error - flash cycle "
  1983. "did not complete.\n");
  1984. break;
  1985. }
  1986. }
  1987. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  1988. return ret_val;
  1989. }
  1990. /**
  1991. * e1000_write_nvm_ich8lan - Write word(s) to the NVM
  1992. * @hw: pointer to the HW structure
  1993. * @offset: The offset (in bytes) of the word(s) to write.
  1994. * @words: Size of data to write in words
  1995. * @data: Pointer to the word(s) to write at offset.
  1996. *
  1997. * Writes a byte or word to the NVM using the flash access registers.
  1998. **/
  1999. static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  2000. u16 *data)
  2001. {
  2002. struct e1000_nvm_info *nvm = &hw->nvm;
  2003. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2004. u16 i;
  2005. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  2006. (words == 0)) {
  2007. e_dbg("nvm parameter(s) out of bounds\n");
  2008. return -E1000_ERR_NVM;
  2009. }
  2010. nvm->ops.acquire(hw);
  2011. for (i = 0; i < words; i++) {
  2012. dev_spec->shadow_ram[offset+i].modified = true;
  2013. dev_spec->shadow_ram[offset+i].value = data[i];
  2014. }
  2015. nvm->ops.release(hw);
  2016. return 0;
  2017. }
  2018. /**
  2019. * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
  2020. * @hw: pointer to the HW structure
  2021. *
  2022. * The NVM checksum is updated by calling the generic update_nvm_checksum,
  2023. * which writes the checksum to the shadow ram. The changes in the shadow
  2024. * ram are then committed to the EEPROM by processing each bank at a time
  2025. * checking for the modified bit and writing only the pending changes.
  2026. * After a successful commit, the shadow ram is cleared and is ready for
  2027. * future writes.
  2028. **/
  2029. static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
  2030. {
  2031. struct e1000_nvm_info *nvm = &hw->nvm;
  2032. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2033. u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
  2034. s32 ret_val;
  2035. u16 data;
  2036. ret_val = e1000e_update_nvm_checksum_generic(hw);
  2037. if (ret_val)
  2038. goto out;
  2039. if (nvm->type != e1000_nvm_flash_sw)
  2040. goto out;
  2041. nvm->ops.acquire(hw);
  2042. /*
  2043. * We're writing to the opposite bank so if we're on bank 1,
  2044. * write to bank 0 etc. We also need to erase the segment that
  2045. * is going to be written
  2046. */
  2047. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  2048. if (ret_val) {
  2049. e_dbg("Could not detect valid bank, assuming bank 0\n");
  2050. bank = 0;
  2051. }
  2052. if (bank == 0) {
  2053. new_bank_offset = nvm->flash_bank_size;
  2054. old_bank_offset = 0;
  2055. ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
  2056. if (ret_val)
  2057. goto release;
  2058. } else {
  2059. old_bank_offset = nvm->flash_bank_size;
  2060. new_bank_offset = 0;
  2061. ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
  2062. if (ret_val)
  2063. goto release;
  2064. }
  2065. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  2066. /*
  2067. * Determine whether to write the value stored
  2068. * in the other NVM bank or a modified value stored
  2069. * in the shadow RAM
  2070. */
  2071. if (dev_spec->shadow_ram[i].modified) {
  2072. data = dev_spec->shadow_ram[i].value;
  2073. } else {
  2074. ret_val = e1000_read_flash_word_ich8lan(hw, i +
  2075. old_bank_offset,
  2076. &data);
  2077. if (ret_val)
  2078. break;
  2079. }
  2080. /*
  2081. * If the word is 0x13, then make sure the signature bits
  2082. * (15:14) are 11b until the commit has completed.
  2083. * This will allow us to write 10b which indicates the
  2084. * signature is valid. We want to do this after the write
  2085. * has completed so that we don't mark the segment valid
  2086. * while the write is still in progress
  2087. */
  2088. if (i == E1000_ICH_NVM_SIG_WORD)
  2089. data |= E1000_ICH_NVM_SIG_MASK;
  2090. /* Convert offset to bytes. */
  2091. act_offset = (i + new_bank_offset) << 1;
  2092. udelay(100);
  2093. /* Write the bytes to the new bank. */
  2094. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  2095. act_offset,
  2096. (u8)data);
  2097. if (ret_val)
  2098. break;
  2099. udelay(100);
  2100. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  2101. act_offset + 1,
  2102. (u8)(data >> 8));
  2103. if (ret_val)
  2104. break;
  2105. }
  2106. /*
  2107. * Don't bother writing the segment valid bits if sector
  2108. * programming failed.
  2109. */
  2110. if (ret_val) {
  2111. /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
  2112. e_dbg("Flash commit failed.\n");
  2113. goto release;
  2114. }
  2115. /*
  2116. * Finally validate the new segment by setting bit 15:14
  2117. * to 10b in word 0x13 , this can be done without an
  2118. * erase as well since these bits are 11 to start with
  2119. * and we need to change bit 14 to 0b
  2120. */
  2121. act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
  2122. ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
  2123. if (ret_val)
  2124. goto release;
  2125. data &= 0xBFFF;
  2126. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  2127. act_offset * 2 + 1,
  2128. (u8)(data >> 8));
  2129. if (ret_val)
  2130. goto release;
  2131. /*
  2132. * And invalidate the previously valid segment by setting
  2133. * its signature word (0x13) high_byte to 0b. This can be
  2134. * done without an erase because flash erase sets all bits
  2135. * to 1's. We can write 1's to 0's without an erase
  2136. */
  2137. act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
  2138. ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
  2139. if (ret_val)
  2140. goto release;
  2141. /* Great! Everything worked, we can now clear the cached entries. */
  2142. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  2143. dev_spec->shadow_ram[i].modified = false;
  2144. dev_spec->shadow_ram[i].value = 0xFFFF;
  2145. }
  2146. release:
  2147. nvm->ops.release(hw);
  2148. /*
  2149. * Reload the EEPROM, or else modifications will not appear
  2150. * until after the next adapter reset.
  2151. */
  2152. if (!ret_val) {
  2153. e1000e_reload_nvm(hw);
  2154. msleep(10);
  2155. }
  2156. out:
  2157. if (ret_val)
  2158. e_dbg("NVM update error: %d\n", ret_val);
  2159. return ret_val;
  2160. }
  2161. /**
  2162. * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
  2163. * @hw: pointer to the HW structure
  2164. *
  2165. * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
  2166. * If the bit is 0, that the EEPROM had been modified, but the checksum was not
  2167. * calculated, in which case we need to calculate the checksum and set bit 6.
  2168. **/
  2169. static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
  2170. {
  2171. s32 ret_val;
  2172. u16 data;
  2173. /*
  2174. * Read 0x19 and check bit 6. If this bit is 0, the checksum
  2175. * needs to be fixed. This bit is an indication that the NVM
  2176. * was prepared by OEM software and did not calculate the
  2177. * checksum...a likely scenario.
  2178. */
  2179. ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
  2180. if (ret_val)
  2181. return ret_val;
  2182. if ((data & 0x40) == 0) {
  2183. data |= 0x40;
  2184. ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
  2185. if (ret_val)
  2186. return ret_val;
  2187. ret_val = e1000e_update_nvm_checksum(hw);
  2188. if (ret_val)
  2189. return ret_val;
  2190. }
  2191. return e1000e_validate_nvm_checksum_generic(hw);
  2192. }
  2193. /**
  2194. * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
  2195. * @hw: pointer to the HW structure
  2196. *
  2197. * To prevent malicious write/erase of the NVM, set it to be read-only
  2198. * so that the hardware ignores all write/erase cycles of the NVM via
  2199. * the flash control registers. The shadow-ram copy of the NVM will
  2200. * still be updated, however any updates to this copy will not stick
  2201. * across driver reloads.
  2202. **/
  2203. void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
  2204. {
  2205. struct e1000_nvm_info *nvm = &hw->nvm;
  2206. union ich8_flash_protected_range pr0;
  2207. union ich8_hws_flash_status hsfsts;
  2208. u32 gfpreg;
  2209. nvm->ops.acquire(hw);
  2210. gfpreg = er32flash(ICH_FLASH_GFPREG);
  2211. /* Write-protect GbE Sector of NVM */
  2212. pr0.regval = er32flash(ICH_FLASH_PR0);
  2213. pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
  2214. pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
  2215. pr0.range.wpe = true;
  2216. ew32flash(ICH_FLASH_PR0, pr0.regval);
  2217. /*
  2218. * Lock down a subset of GbE Flash Control Registers, e.g.
  2219. * PR0 to prevent the write-protection from being lifted.
  2220. * Once FLOCKDN is set, the registers protected by it cannot
  2221. * be written until FLOCKDN is cleared by a hardware reset.
  2222. */
  2223. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2224. hsfsts.hsf_status.flockdn = true;
  2225. ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  2226. nvm->ops.release(hw);
  2227. }
  2228. /**
  2229. * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
  2230. * @hw: pointer to the HW structure
  2231. * @offset: The offset (in bytes) of the byte/word to read.
  2232. * @size: Size of data to read, 1=byte 2=word
  2233. * @data: The byte(s) to write to the NVM.
  2234. *
  2235. * Writes one/two bytes to the NVM using the flash access registers.
  2236. **/
  2237. static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  2238. u8 size, u16 data)
  2239. {
  2240. union ich8_hws_flash_status hsfsts;
  2241. union ich8_hws_flash_ctrl hsflctl;
  2242. u32 flash_linear_addr;
  2243. u32 flash_data = 0;
  2244. s32 ret_val;
  2245. u8 count = 0;
  2246. if (size < 1 || size > 2 || data > size * 0xff ||
  2247. offset > ICH_FLASH_LINEAR_ADDR_MASK)
  2248. return -E1000_ERR_NVM;
  2249. flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  2250. hw->nvm.flash_base_addr;
  2251. do {
  2252. udelay(1);
  2253. /* Steps */
  2254. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  2255. if (ret_val)
  2256. break;
  2257. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  2258. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  2259. hsflctl.hsf_ctrl.fldbcount = size -1;
  2260. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
  2261. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  2262. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  2263. if (size == 1)
  2264. flash_data = (u32)data & 0x00FF;
  2265. else
  2266. flash_data = (u32)data;
  2267. ew32flash(ICH_FLASH_FDATA0, flash_data);
  2268. /*
  2269. * check if FCERR is set to 1 , if set to 1, clear it
  2270. * and try the whole sequence a few more times else done
  2271. */
  2272. ret_val = e1000_flash_cycle_ich8lan(hw,
  2273. ICH_FLASH_WRITE_COMMAND_TIMEOUT);
  2274. if (!ret_val)
  2275. break;
  2276. /*
  2277. * If we're here, then things are most likely
  2278. * completely hosed, but if the error condition
  2279. * is detected, it won't hurt to give it another
  2280. * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
  2281. */
  2282. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2283. if (hsfsts.hsf_status.flcerr == 1)
  2284. /* Repeat for some time before giving up. */
  2285. continue;
  2286. if (hsfsts.hsf_status.flcdone == 0) {
  2287. e_dbg("Timeout error - flash cycle "
  2288. "did not complete.");
  2289. break;
  2290. }
  2291. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  2292. return ret_val;
  2293. }
  2294. /**
  2295. * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
  2296. * @hw: pointer to the HW structure
  2297. * @offset: The index of the byte to read.
  2298. * @data: The byte to write to the NVM.
  2299. *
  2300. * Writes a single byte to the NVM using the flash access registers.
  2301. **/
  2302. static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  2303. u8 data)
  2304. {
  2305. u16 word = (u16)data;
  2306. return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
  2307. }
  2308. /**
  2309. * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
  2310. * @hw: pointer to the HW structure
  2311. * @offset: The offset of the byte to write.
  2312. * @byte: The byte to write to the NVM.
  2313. *
  2314. * Writes a single byte to the NVM using the flash access registers.
  2315. * Goes through a retry algorithm before giving up.
  2316. **/
  2317. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  2318. u32 offset, u8 byte)
  2319. {
  2320. s32 ret_val;
  2321. u16 program_retries;
  2322. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  2323. if (!ret_val)
  2324. return ret_val;
  2325. for (program_retries = 0; program_retries < 100; program_retries++) {
  2326. e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
  2327. udelay(100);
  2328. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  2329. if (!ret_val)
  2330. break;
  2331. }
  2332. if (program_retries == 100)
  2333. return -E1000_ERR_NVM;
  2334. return 0;
  2335. }
  2336. /**
  2337. * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
  2338. * @hw: pointer to the HW structure
  2339. * @bank: 0 for first bank, 1 for second bank, etc.
  2340. *
  2341. * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
  2342. * bank N is 4096 * N + flash_reg_addr.
  2343. **/
  2344. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
  2345. {
  2346. struct e1000_nvm_info *nvm = &hw->nvm;
  2347. union ich8_hws_flash_status hsfsts;
  2348. union ich8_hws_flash_ctrl hsflctl;
  2349. u32 flash_linear_addr;
  2350. /* bank size is in 16bit words - adjust to bytes */
  2351. u32 flash_bank_size = nvm->flash_bank_size * 2;
  2352. s32 ret_val;
  2353. s32 count = 0;
  2354. s32 j, iteration, sector_size;
  2355. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2356. /*
  2357. * Determine HW Sector size: Read BERASE bits of hw flash status
  2358. * register
  2359. * 00: The Hw sector is 256 bytes, hence we need to erase 16
  2360. * consecutive sectors. The start index for the nth Hw sector
  2361. * can be calculated as = bank * 4096 + n * 256
  2362. * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
  2363. * The start index for the nth Hw sector can be calculated
  2364. * as = bank * 4096
  2365. * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
  2366. * (ich9 only, otherwise error condition)
  2367. * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
  2368. */
  2369. switch (hsfsts.hsf_status.berasesz) {
  2370. case 0:
  2371. /* Hw sector size 256 */
  2372. sector_size = ICH_FLASH_SEG_SIZE_256;
  2373. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
  2374. break;
  2375. case 1:
  2376. sector_size = ICH_FLASH_SEG_SIZE_4K;
  2377. iteration = 1;
  2378. break;
  2379. case 2:
  2380. sector_size = ICH_FLASH_SEG_SIZE_8K;
  2381. iteration = 1;
  2382. break;
  2383. case 3:
  2384. sector_size = ICH_FLASH_SEG_SIZE_64K;
  2385. iteration = 1;
  2386. break;
  2387. default:
  2388. return -E1000_ERR_NVM;
  2389. }
  2390. /* Start with the base address, then add the sector offset. */
  2391. flash_linear_addr = hw->nvm.flash_base_addr;
  2392. flash_linear_addr += (bank) ? flash_bank_size : 0;
  2393. for (j = 0; j < iteration ; j++) {
  2394. do {
  2395. /* Steps */
  2396. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  2397. if (ret_val)
  2398. return ret_val;
  2399. /*
  2400. * Write a value 11 (block Erase) in Flash
  2401. * Cycle field in hw flash control
  2402. */
  2403. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  2404. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
  2405. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  2406. /*
  2407. * Write the last 24 bits of an index within the
  2408. * block into Flash Linear address field in Flash
  2409. * Address.
  2410. */
  2411. flash_linear_addr += (j * sector_size);
  2412. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  2413. ret_val = e1000_flash_cycle_ich8lan(hw,
  2414. ICH_FLASH_ERASE_COMMAND_TIMEOUT);
  2415. if (ret_val == 0)
  2416. break;
  2417. /*
  2418. * Check if FCERR is set to 1. If 1,
  2419. * clear it and try the whole sequence
  2420. * a few more times else Done
  2421. */
  2422. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2423. if (hsfsts.hsf_status.flcerr == 1)
  2424. /* repeat for some time before giving up */
  2425. continue;
  2426. else if (hsfsts.hsf_status.flcdone == 0)
  2427. return ret_val;
  2428. } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
  2429. }
  2430. return 0;
  2431. }
  2432. /**
  2433. * e1000_valid_led_default_ich8lan - Set the default LED settings
  2434. * @hw: pointer to the HW structure
  2435. * @data: Pointer to the LED settings
  2436. *
  2437. * Reads the LED default settings from the NVM to data. If the NVM LED
  2438. * settings is all 0's or F's, set the LED default to a valid LED default
  2439. * setting.
  2440. **/
  2441. static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
  2442. {
  2443. s32 ret_val;
  2444. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  2445. if (ret_val) {
  2446. e_dbg("NVM Read Error\n");
  2447. return ret_val;
  2448. }
  2449. if (*data == ID_LED_RESERVED_0000 ||
  2450. *data == ID_LED_RESERVED_FFFF)
  2451. *data = ID_LED_DEFAULT_ICH8LAN;
  2452. return 0;
  2453. }
  2454. /**
  2455. * e1000_id_led_init_pchlan - store LED configurations
  2456. * @hw: pointer to the HW structure
  2457. *
  2458. * PCH does not control LEDs via the LEDCTL register, rather it uses
  2459. * the PHY LED configuration register.
  2460. *
  2461. * PCH also does not have an "always on" or "always off" mode which
  2462. * complicates the ID feature. Instead of using the "on" mode to indicate
  2463. * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
  2464. * use "link_up" mode. The LEDs will still ID on request if there is no
  2465. * link based on logic in e1000_led_[on|off]_pchlan().
  2466. **/
  2467. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
  2468. {
  2469. struct e1000_mac_info *mac = &hw->mac;
  2470. s32 ret_val;
  2471. const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
  2472. const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
  2473. u16 data, i, temp, shift;
  2474. /* Get default ID LED modes */
  2475. ret_val = hw->nvm.ops.valid_led_default(hw, &data);
  2476. if (ret_val)
  2477. goto out;
  2478. mac->ledctl_default = er32(LEDCTL);
  2479. mac->ledctl_mode1 = mac->ledctl_default;
  2480. mac->ledctl_mode2 = mac->ledctl_default;
  2481. for (i = 0; i < 4; i++) {
  2482. temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
  2483. shift = (i * 5);
  2484. switch (temp) {
  2485. case ID_LED_ON1_DEF2:
  2486. case ID_LED_ON1_ON2:
  2487. case ID_LED_ON1_OFF2:
  2488. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  2489. mac->ledctl_mode1 |= (ledctl_on << shift);
  2490. break;
  2491. case ID_LED_OFF1_DEF2:
  2492. case ID_LED_OFF1_ON2:
  2493. case ID_LED_OFF1_OFF2:
  2494. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  2495. mac->ledctl_mode1 |= (ledctl_off << shift);
  2496. break;
  2497. default:
  2498. /* Do nothing */
  2499. break;
  2500. }
  2501. switch (temp) {
  2502. case ID_LED_DEF1_ON2:
  2503. case ID_LED_ON1_ON2:
  2504. case ID_LED_OFF1_ON2:
  2505. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  2506. mac->ledctl_mode2 |= (ledctl_on << shift);
  2507. break;
  2508. case ID_LED_DEF1_OFF2:
  2509. case ID_LED_ON1_OFF2:
  2510. case ID_LED_OFF1_OFF2:
  2511. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  2512. mac->ledctl_mode2 |= (ledctl_off << shift);
  2513. break;
  2514. default:
  2515. /* Do nothing */
  2516. break;
  2517. }
  2518. }
  2519. out:
  2520. return ret_val;
  2521. }
  2522. /**
  2523. * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
  2524. * @hw: pointer to the HW structure
  2525. *
  2526. * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
  2527. * register, so the the bus width is hard coded.
  2528. **/
  2529. static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
  2530. {
  2531. struct e1000_bus_info *bus = &hw->bus;
  2532. s32 ret_val;
  2533. ret_val = e1000e_get_bus_info_pcie(hw);
  2534. /*
  2535. * ICH devices are "PCI Express"-ish. They have
  2536. * a configuration space, but do not contain
  2537. * PCI Express Capability registers, so bus width
  2538. * must be hardcoded.
  2539. */
  2540. if (bus->width == e1000_bus_width_unknown)
  2541. bus->width = e1000_bus_width_pcie_x1;
  2542. return ret_val;
  2543. }
  2544. /**
  2545. * e1000_reset_hw_ich8lan - Reset the hardware
  2546. * @hw: pointer to the HW structure
  2547. *
  2548. * Does a full reset of the hardware which includes a reset of the PHY and
  2549. * MAC.
  2550. **/
  2551. static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
  2552. {
  2553. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2554. u16 reg;
  2555. u32 ctrl, kab;
  2556. s32 ret_val;
  2557. /*
  2558. * Prevent the PCI-E bus from sticking if there is no TLP connection
  2559. * on the last TLP read/write transaction when MAC is reset.
  2560. */
  2561. ret_val = e1000e_disable_pcie_master(hw);
  2562. if (ret_val)
  2563. e_dbg("PCI-E Master disable polling has failed.\n");
  2564. e_dbg("Masking off all interrupts\n");
  2565. ew32(IMC, 0xffffffff);
  2566. /*
  2567. * Disable the Transmit and Receive units. Then delay to allow
  2568. * any pending transactions to complete before we hit the MAC
  2569. * with the global reset.
  2570. */
  2571. ew32(RCTL, 0);
  2572. ew32(TCTL, E1000_TCTL_PSP);
  2573. e1e_flush();
  2574. msleep(10);
  2575. /* Workaround for ICH8 bit corruption issue in FIFO memory */
  2576. if (hw->mac.type == e1000_ich8lan) {
  2577. /* Set Tx and Rx buffer allocation to 8k apiece. */
  2578. ew32(PBA, E1000_PBA_8K);
  2579. /* Set Packet Buffer Size to 16k. */
  2580. ew32(PBS, E1000_PBS_16K);
  2581. }
  2582. if (hw->mac.type == e1000_pchlan) {
  2583. /* Save the NVM K1 bit setting*/
  2584. ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &reg);
  2585. if (ret_val)
  2586. return ret_val;
  2587. if (reg & E1000_NVM_K1_ENABLE)
  2588. dev_spec->nvm_k1_enabled = true;
  2589. else
  2590. dev_spec->nvm_k1_enabled = false;
  2591. }
  2592. ctrl = er32(CTRL);
  2593. if (!e1000_check_reset_block(hw)) {
  2594. /*
  2595. * Full-chip reset requires MAC and PHY reset at the same
  2596. * time to make sure the interface between MAC and the
  2597. * external PHY is reset.
  2598. */
  2599. ctrl |= E1000_CTRL_PHY_RST;
  2600. /*
  2601. * Gate automatic PHY configuration by hardware on
  2602. * non-managed 82579
  2603. */
  2604. if ((hw->mac.type == e1000_pch2lan) &&
  2605. !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  2606. e1000_gate_hw_phy_config_ich8lan(hw, true);
  2607. }
  2608. ret_val = e1000_acquire_swflag_ich8lan(hw);
  2609. e_dbg("Issuing a global reset to ich8lan\n");
  2610. ew32(CTRL, (ctrl | E1000_CTRL_RST));
  2611. msleep(20);
  2612. if (!ret_val)
  2613. e1000_release_swflag_ich8lan(hw);
  2614. if (ctrl & E1000_CTRL_PHY_RST) {
  2615. ret_val = hw->phy.ops.get_cfg_done(hw);
  2616. if (ret_val)
  2617. goto out;
  2618. ret_val = e1000_post_phy_reset_ich8lan(hw);
  2619. if (ret_val)
  2620. goto out;
  2621. }
  2622. /*
  2623. * For PCH, this write will make sure that any noise
  2624. * will be detected as a CRC error and be dropped rather than show up
  2625. * as a bad packet to the DMA engine.
  2626. */
  2627. if (hw->mac.type == e1000_pchlan)
  2628. ew32(CRC_OFFSET, 0x65656565);
  2629. ew32(IMC, 0xffffffff);
  2630. er32(ICR);
  2631. kab = er32(KABGTXD);
  2632. kab |= E1000_KABGTXD_BGSQLBIAS;
  2633. ew32(KABGTXD, kab);
  2634. out:
  2635. return ret_val;
  2636. }
  2637. /**
  2638. * e1000_init_hw_ich8lan - Initialize the hardware
  2639. * @hw: pointer to the HW structure
  2640. *
  2641. * Prepares the hardware for transmit and receive by doing the following:
  2642. * - initialize hardware bits
  2643. * - initialize LED identification
  2644. * - setup receive address registers
  2645. * - setup flow control
  2646. * - setup transmit descriptors
  2647. * - clear statistics
  2648. **/
  2649. static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
  2650. {
  2651. struct e1000_mac_info *mac = &hw->mac;
  2652. u32 ctrl_ext, txdctl, snoop;
  2653. s32 ret_val;
  2654. u16 i;
  2655. e1000_initialize_hw_bits_ich8lan(hw);
  2656. /* Initialize identification LED */
  2657. ret_val = mac->ops.id_led_init(hw);
  2658. if (ret_val)
  2659. e_dbg("Error initializing identification LED\n");
  2660. /* This is not fatal and we should not stop init due to this */
  2661. /* Setup the receive address. */
  2662. e1000e_init_rx_addrs(hw, mac->rar_entry_count);
  2663. /* Zero out the Multicast HASH table */
  2664. e_dbg("Zeroing the MTA\n");
  2665. for (i = 0; i < mac->mta_reg_count; i++)
  2666. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  2667. /*
  2668. * The 82578 Rx buffer will stall if wakeup is enabled in host and
  2669. * the ME. Reading the BM_WUC register will clear the host wakeup bit.
  2670. * Reset the phy after disabling host wakeup to reset the Rx buffer.
  2671. */
  2672. if (hw->phy.type == e1000_phy_82578) {
  2673. e1e_rphy(hw, BM_WUC, &i);
  2674. ret_val = e1000_phy_hw_reset_ich8lan(hw);
  2675. if (ret_val)
  2676. return ret_val;
  2677. }
  2678. /* Setup link and flow control */
  2679. ret_val = e1000_setup_link_ich8lan(hw);
  2680. /* Set the transmit descriptor write-back policy for both queues */
  2681. txdctl = er32(TXDCTL(0));
  2682. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  2683. E1000_TXDCTL_FULL_TX_DESC_WB;
  2684. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  2685. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  2686. ew32(TXDCTL(0), txdctl);
  2687. txdctl = er32(TXDCTL(1));
  2688. txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
  2689. E1000_TXDCTL_FULL_TX_DESC_WB;
  2690. txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
  2691. E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
  2692. ew32(TXDCTL(1), txdctl);
  2693. /*
  2694. * ICH8 has opposite polarity of no_snoop bits.
  2695. * By default, we should use snoop behavior.
  2696. */
  2697. if (mac->type == e1000_ich8lan)
  2698. snoop = PCIE_ICH8_SNOOP_ALL;
  2699. else
  2700. snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
  2701. e1000e_set_pcie_no_snoop(hw, snoop);
  2702. ctrl_ext = er32(CTRL_EXT);
  2703. ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
  2704. ew32(CTRL_EXT, ctrl_ext);
  2705. /*
  2706. * Clear all of the statistics registers (clear on read). It is
  2707. * important that we do this after we have tried to establish link
  2708. * because the symbol error count will increment wildly if there
  2709. * is no link.
  2710. */
  2711. e1000_clear_hw_cntrs_ich8lan(hw);
  2712. return 0;
  2713. }
  2714. /**
  2715. * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
  2716. * @hw: pointer to the HW structure
  2717. *
  2718. * Sets/Clears required hardware bits necessary for correctly setting up the
  2719. * hardware for transmit and receive.
  2720. **/
  2721. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
  2722. {
  2723. u32 reg;
  2724. /* Extended Device Control */
  2725. reg = er32(CTRL_EXT);
  2726. reg |= (1 << 22);
  2727. /* Enable PHY low-power state when MAC is at D3 w/o WoL */
  2728. if (hw->mac.type >= e1000_pchlan)
  2729. reg |= E1000_CTRL_EXT_PHYPDEN;
  2730. ew32(CTRL_EXT, reg);
  2731. /* Transmit Descriptor Control 0 */
  2732. reg = er32(TXDCTL(0));
  2733. reg |= (1 << 22);
  2734. ew32(TXDCTL(0), reg);
  2735. /* Transmit Descriptor Control 1 */
  2736. reg = er32(TXDCTL(1));
  2737. reg |= (1 << 22);
  2738. ew32(TXDCTL(1), reg);
  2739. /* Transmit Arbitration Control 0 */
  2740. reg = er32(TARC(0));
  2741. if (hw->mac.type == e1000_ich8lan)
  2742. reg |= (1 << 28) | (1 << 29);
  2743. reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
  2744. ew32(TARC(0), reg);
  2745. /* Transmit Arbitration Control 1 */
  2746. reg = er32(TARC(1));
  2747. if (er32(TCTL) & E1000_TCTL_MULR)
  2748. reg &= ~(1 << 28);
  2749. else
  2750. reg |= (1 << 28);
  2751. reg |= (1 << 24) | (1 << 26) | (1 << 30);
  2752. ew32(TARC(1), reg);
  2753. /* Device Status */
  2754. if (hw->mac.type == e1000_ich8lan) {
  2755. reg = er32(STATUS);
  2756. reg &= ~(1 << 31);
  2757. ew32(STATUS, reg);
  2758. }
  2759. /*
  2760. * work-around descriptor data corruption issue during nfs v2 udp
  2761. * traffic, just disable the nfs filtering capability
  2762. */
  2763. reg = er32(RFCTL);
  2764. reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
  2765. ew32(RFCTL, reg);
  2766. }
  2767. /**
  2768. * e1000_setup_link_ich8lan - Setup flow control and link settings
  2769. * @hw: pointer to the HW structure
  2770. *
  2771. * Determines which flow control settings to use, then configures flow
  2772. * control. Calls the appropriate media-specific link configuration
  2773. * function. Assuming the adapter has a valid link partner, a valid link
  2774. * should be established. Assumes the hardware has previously been reset
  2775. * and the transmitter and receiver are not enabled.
  2776. **/
  2777. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
  2778. {
  2779. s32 ret_val;
  2780. if (e1000_check_reset_block(hw))
  2781. return 0;
  2782. /*
  2783. * ICH parts do not have a word in the NVM to determine
  2784. * the default flow control setting, so we explicitly
  2785. * set it to full.
  2786. */
  2787. if (hw->fc.requested_mode == e1000_fc_default) {
  2788. /* Workaround h/w hang when Tx flow control enabled */
  2789. if (hw->mac.type == e1000_pchlan)
  2790. hw->fc.requested_mode = e1000_fc_rx_pause;
  2791. else
  2792. hw->fc.requested_mode = e1000_fc_full;
  2793. }
  2794. /*
  2795. * Save off the requested flow control mode for use later. Depending
  2796. * on the link partner's capabilities, we may or may not use this mode.
  2797. */
  2798. hw->fc.current_mode = hw->fc.requested_mode;
  2799. e_dbg("After fix-ups FlowControl is now = %x\n",
  2800. hw->fc.current_mode);
  2801. /* Continue to configure the copper link. */
  2802. ret_val = e1000_setup_copper_link_ich8lan(hw);
  2803. if (ret_val)
  2804. return ret_val;
  2805. ew32(FCTTV, hw->fc.pause_time);
  2806. if ((hw->phy.type == e1000_phy_82578) ||
  2807. (hw->phy.type == e1000_phy_82579) ||
  2808. (hw->phy.type == e1000_phy_82577)) {
  2809. ew32(FCRTV_PCH, hw->fc.refresh_time);
  2810. ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
  2811. hw->fc.pause_time);
  2812. if (ret_val)
  2813. return ret_val;
  2814. }
  2815. return e1000e_set_fc_watermarks(hw);
  2816. }
  2817. /**
  2818. * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
  2819. * @hw: pointer to the HW structure
  2820. *
  2821. * Configures the kumeran interface to the PHY to wait the appropriate time
  2822. * when polling the PHY, then call the generic setup_copper_link to finish
  2823. * configuring the copper link.
  2824. **/
  2825. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
  2826. {
  2827. u32 ctrl;
  2828. s32 ret_val;
  2829. u16 reg_data;
  2830. ctrl = er32(CTRL);
  2831. ctrl |= E1000_CTRL_SLU;
  2832. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  2833. ew32(CTRL, ctrl);
  2834. /*
  2835. * Set the mac to wait the maximum time between each iteration
  2836. * and increase the max iterations when polling the phy;
  2837. * this fixes erroneous timeouts at 10Mbps.
  2838. */
  2839. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
  2840. if (ret_val)
  2841. return ret_val;
  2842. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  2843. &reg_data);
  2844. if (ret_val)
  2845. return ret_val;
  2846. reg_data |= 0x3F;
  2847. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  2848. reg_data);
  2849. if (ret_val)
  2850. return ret_val;
  2851. switch (hw->phy.type) {
  2852. case e1000_phy_igp_3:
  2853. ret_val = e1000e_copper_link_setup_igp(hw);
  2854. if (ret_val)
  2855. return ret_val;
  2856. break;
  2857. case e1000_phy_bm:
  2858. case e1000_phy_82578:
  2859. ret_val = e1000e_copper_link_setup_m88(hw);
  2860. if (ret_val)
  2861. return ret_val;
  2862. break;
  2863. case e1000_phy_82577:
  2864. case e1000_phy_82579:
  2865. ret_val = e1000_copper_link_setup_82577(hw);
  2866. if (ret_val)
  2867. return ret_val;
  2868. break;
  2869. case e1000_phy_ife:
  2870. ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
  2871. if (ret_val)
  2872. return ret_val;
  2873. reg_data &= ~IFE_PMC_AUTO_MDIX;
  2874. switch (hw->phy.mdix) {
  2875. case 1:
  2876. reg_data &= ~IFE_PMC_FORCE_MDIX;
  2877. break;
  2878. case 2:
  2879. reg_data |= IFE_PMC_FORCE_MDIX;
  2880. break;
  2881. case 0:
  2882. default:
  2883. reg_data |= IFE_PMC_AUTO_MDIX;
  2884. break;
  2885. }
  2886. ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
  2887. if (ret_val)
  2888. return ret_val;
  2889. break;
  2890. default:
  2891. break;
  2892. }
  2893. return e1000e_setup_copper_link(hw);
  2894. }
  2895. /**
  2896. * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
  2897. * @hw: pointer to the HW structure
  2898. * @speed: pointer to store current link speed
  2899. * @duplex: pointer to store the current link duplex
  2900. *
  2901. * Calls the generic get_speed_and_duplex to retrieve the current link
  2902. * information and then calls the Kumeran lock loss workaround for links at
  2903. * gigabit speeds.
  2904. **/
  2905. static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
  2906. u16 *duplex)
  2907. {
  2908. s32 ret_val;
  2909. ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
  2910. if (ret_val)
  2911. return ret_val;
  2912. if ((hw->mac.type == e1000_ich8lan) &&
  2913. (hw->phy.type == e1000_phy_igp_3) &&
  2914. (*speed == SPEED_1000)) {
  2915. ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
  2916. }
  2917. return ret_val;
  2918. }
  2919. /**
  2920. * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
  2921. * @hw: pointer to the HW structure
  2922. *
  2923. * Work-around for 82566 Kumeran PCS lock loss:
  2924. * On link status change (i.e. PCI reset, speed change) and link is up and
  2925. * speed is gigabit-
  2926. * 0) if workaround is optionally disabled do nothing
  2927. * 1) wait 1ms for Kumeran link to come up
  2928. * 2) check Kumeran Diagnostic register PCS lock loss bit
  2929. * 3) if not set the link is locked (all is good), otherwise...
  2930. * 4) reset the PHY
  2931. * 5) repeat up to 10 times
  2932. * Note: this is only called for IGP3 copper when speed is 1gb.
  2933. **/
  2934. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
  2935. {
  2936. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2937. u32 phy_ctrl;
  2938. s32 ret_val;
  2939. u16 i, data;
  2940. bool link;
  2941. if (!dev_spec->kmrn_lock_loss_workaround_enabled)
  2942. return 0;
  2943. /*
  2944. * Make sure link is up before proceeding. If not just return.
  2945. * Attempting this while link is negotiating fouled up link
  2946. * stability
  2947. */
  2948. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  2949. if (!link)
  2950. return 0;
  2951. for (i = 0; i < 10; i++) {
  2952. /* read once to clear */
  2953. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  2954. if (ret_val)
  2955. return ret_val;
  2956. /* and again to get new status */
  2957. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  2958. if (ret_val)
  2959. return ret_val;
  2960. /* check for PCS lock */
  2961. if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
  2962. return 0;
  2963. /* Issue PHY reset */
  2964. e1000_phy_hw_reset(hw);
  2965. mdelay(5);
  2966. }
  2967. /* Disable GigE link negotiation */
  2968. phy_ctrl = er32(PHY_CTRL);
  2969. phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
  2970. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  2971. ew32(PHY_CTRL, phy_ctrl);
  2972. /*
  2973. * Call gig speed drop workaround on Gig disable before accessing
  2974. * any PHY registers
  2975. */
  2976. e1000e_gig_downshift_workaround_ich8lan(hw);
  2977. /* unable to acquire PCS lock */
  2978. return -E1000_ERR_PHY;
  2979. }
  2980. /**
  2981. * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
  2982. * @hw: pointer to the HW structure
  2983. * @state: boolean value used to set the current Kumeran workaround state
  2984. *
  2985. * If ICH8, set the current Kumeran workaround state (enabled - true
  2986. * /disabled - false).
  2987. **/
  2988. void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
  2989. bool state)
  2990. {
  2991. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2992. if (hw->mac.type != e1000_ich8lan) {
  2993. e_dbg("Workaround applies to ICH8 only.\n");
  2994. return;
  2995. }
  2996. dev_spec->kmrn_lock_loss_workaround_enabled = state;
  2997. }
  2998. /**
  2999. * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
  3000. * @hw: pointer to the HW structure
  3001. *
  3002. * Workaround for 82566 power-down on D3 entry:
  3003. * 1) disable gigabit link
  3004. * 2) write VR power-down enable
  3005. * 3) read it back
  3006. * Continue if successful, else issue LCD reset and repeat
  3007. **/
  3008. void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
  3009. {
  3010. u32 reg;
  3011. u16 data;
  3012. u8 retry = 0;
  3013. if (hw->phy.type != e1000_phy_igp_3)
  3014. return;
  3015. /* Try the workaround twice (if needed) */
  3016. do {
  3017. /* Disable link */
  3018. reg = er32(PHY_CTRL);
  3019. reg |= (E1000_PHY_CTRL_GBE_DISABLE |
  3020. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  3021. ew32(PHY_CTRL, reg);
  3022. /*
  3023. * Call gig speed drop workaround on Gig disable before
  3024. * accessing any PHY registers
  3025. */
  3026. if (hw->mac.type == e1000_ich8lan)
  3027. e1000e_gig_downshift_workaround_ich8lan(hw);
  3028. /* Write VR power-down enable */
  3029. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  3030. data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  3031. e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
  3032. /* Read it back and test */
  3033. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  3034. data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  3035. if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
  3036. break;
  3037. /* Issue PHY reset and repeat at most one more time */
  3038. reg = er32(CTRL);
  3039. ew32(CTRL, reg | E1000_CTRL_PHY_RST);
  3040. retry++;
  3041. } while (retry);
  3042. }
  3043. /**
  3044. * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
  3045. * @hw: pointer to the HW structure
  3046. *
  3047. * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
  3048. * LPLU, Gig disable, MDIC PHY reset):
  3049. * 1) Set Kumeran Near-end loopback
  3050. * 2) Clear Kumeran Near-end loopback
  3051. * Should only be called for ICH8[m] devices with IGP_3 Phy.
  3052. **/
  3053. void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
  3054. {
  3055. s32 ret_val;
  3056. u16 reg_data;
  3057. if ((hw->mac.type != e1000_ich8lan) ||
  3058. (hw->phy.type != e1000_phy_igp_3))
  3059. return;
  3060. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  3061. &reg_data);
  3062. if (ret_val)
  3063. return;
  3064. reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
  3065. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  3066. reg_data);
  3067. if (ret_val)
  3068. return;
  3069. reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
  3070. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  3071. reg_data);
  3072. }
  3073. /**
  3074. * e1000e_disable_gig_wol_ich8lan - disable gig during WoL
  3075. * @hw: pointer to the HW structure
  3076. *
  3077. * During S0 to Sx transition, it is possible the link remains at gig
  3078. * instead of negotiating to a lower speed. Before going to Sx, set
  3079. * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
  3080. * to a lower speed.
  3081. *
  3082. * Should only be called for applicable parts.
  3083. **/
  3084. void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
  3085. {
  3086. u32 phy_ctrl;
  3087. s32 ret_val;
  3088. phy_ctrl = er32(PHY_CTRL);
  3089. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | E1000_PHY_CTRL_GBE_DISABLE;
  3090. ew32(PHY_CTRL, phy_ctrl);
  3091. if (hw->mac.type >= e1000_pchlan) {
  3092. e1000_oem_bits_config_ich8lan(hw, false);
  3093. ret_val = hw->phy.ops.acquire(hw);
  3094. if (ret_val)
  3095. return;
  3096. e1000_write_smbus_addr(hw);
  3097. hw->phy.ops.release(hw);
  3098. }
  3099. }
  3100. /**
  3101. * e1000_cleanup_led_ich8lan - Restore the default LED operation
  3102. * @hw: pointer to the HW structure
  3103. *
  3104. * Return the LED back to the default configuration.
  3105. **/
  3106. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
  3107. {
  3108. if (hw->phy.type == e1000_phy_ife)
  3109. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
  3110. ew32(LEDCTL, hw->mac.ledctl_default);
  3111. return 0;
  3112. }
  3113. /**
  3114. * e1000_led_on_ich8lan - Turn LEDs on
  3115. * @hw: pointer to the HW structure
  3116. *
  3117. * Turn on the LEDs.
  3118. **/
  3119. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
  3120. {
  3121. if (hw->phy.type == e1000_phy_ife)
  3122. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  3123. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
  3124. ew32(LEDCTL, hw->mac.ledctl_mode2);
  3125. return 0;
  3126. }
  3127. /**
  3128. * e1000_led_off_ich8lan - Turn LEDs off
  3129. * @hw: pointer to the HW structure
  3130. *
  3131. * Turn off the LEDs.
  3132. **/
  3133. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
  3134. {
  3135. if (hw->phy.type == e1000_phy_ife)
  3136. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  3137. (IFE_PSCL_PROBE_MODE |
  3138. IFE_PSCL_PROBE_LEDS_OFF));
  3139. ew32(LEDCTL, hw->mac.ledctl_mode1);
  3140. return 0;
  3141. }
  3142. /**
  3143. * e1000_setup_led_pchlan - Configures SW controllable LED
  3144. * @hw: pointer to the HW structure
  3145. *
  3146. * This prepares the SW controllable LED for use.
  3147. **/
  3148. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
  3149. {
  3150. return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
  3151. }
  3152. /**
  3153. * e1000_cleanup_led_pchlan - Restore the default LED operation
  3154. * @hw: pointer to the HW structure
  3155. *
  3156. * Return the LED back to the default configuration.
  3157. **/
  3158. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
  3159. {
  3160. return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
  3161. }
  3162. /**
  3163. * e1000_led_on_pchlan - Turn LEDs on
  3164. * @hw: pointer to the HW structure
  3165. *
  3166. * Turn on the LEDs.
  3167. **/
  3168. static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
  3169. {
  3170. u16 data = (u16)hw->mac.ledctl_mode2;
  3171. u32 i, led;
  3172. /*
  3173. * If no link, then turn LED on by setting the invert bit
  3174. * for each LED that's mode is "link_up" in ledctl_mode2.
  3175. */
  3176. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  3177. for (i = 0; i < 3; i++) {
  3178. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  3179. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  3180. E1000_LEDCTL_MODE_LINK_UP)
  3181. continue;
  3182. if (led & E1000_PHY_LED0_IVRT)
  3183. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  3184. else
  3185. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  3186. }
  3187. }
  3188. return e1e_wphy(hw, HV_LED_CONFIG, data);
  3189. }
  3190. /**
  3191. * e1000_led_off_pchlan - Turn LEDs off
  3192. * @hw: pointer to the HW structure
  3193. *
  3194. * Turn off the LEDs.
  3195. **/
  3196. static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
  3197. {
  3198. u16 data = (u16)hw->mac.ledctl_mode1;
  3199. u32 i, led;
  3200. /*
  3201. * If no link, then turn LED off by clearing the invert bit
  3202. * for each LED that's mode is "link_up" in ledctl_mode1.
  3203. */
  3204. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  3205. for (i = 0; i < 3; i++) {
  3206. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  3207. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  3208. E1000_LEDCTL_MODE_LINK_UP)
  3209. continue;
  3210. if (led & E1000_PHY_LED0_IVRT)
  3211. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  3212. else
  3213. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  3214. }
  3215. }
  3216. return e1e_wphy(hw, HV_LED_CONFIG, data);
  3217. }
  3218. /**
  3219. * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
  3220. * @hw: pointer to the HW structure
  3221. *
  3222. * Read appropriate register for the config done bit for completion status
  3223. * and configure the PHY through s/w for EEPROM-less parts.
  3224. *
  3225. * NOTE: some silicon which is EEPROM-less will fail trying to read the
  3226. * config done bit, so only an error is logged and continues. If we were
  3227. * to return with error, EEPROM-less silicon would not be able to be reset
  3228. * or change link.
  3229. **/
  3230. static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
  3231. {
  3232. s32 ret_val = 0;
  3233. u32 bank = 0;
  3234. u32 status;
  3235. e1000e_get_cfg_done(hw);
  3236. /* Wait for indication from h/w that it has completed basic config */
  3237. if (hw->mac.type >= e1000_ich10lan) {
  3238. e1000_lan_init_done_ich8lan(hw);
  3239. } else {
  3240. ret_val = e1000e_get_auto_rd_done(hw);
  3241. if (ret_val) {
  3242. /*
  3243. * When auto config read does not complete, do not
  3244. * return with an error. This can happen in situations
  3245. * where there is no eeprom and prevents getting link.
  3246. */
  3247. e_dbg("Auto Read Done did not complete\n");
  3248. ret_val = 0;
  3249. }
  3250. }
  3251. /* Clear PHY Reset Asserted bit */
  3252. status = er32(STATUS);
  3253. if (status & E1000_STATUS_PHYRA)
  3254. ew32(STATUS, status & ~E1000_STATUS_PHYRA);
  3255. else
  3256. e_dbg("PHY Reset Asserted not set - needs delay\n");
  3257. /* If EEPROM is not marked present, init the IGP 3 PHY manually */
  3258. if (hw->mac.type <= e1000_ich9lan) {
  3259. if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
  3260. (hw->phy.type == e1000_phy_igp_3)) {
  3261. e1000e_phy_init_script_igp3(hw);
  3262. }
  3263. } else {
  3264. if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
  3265. /* Maybe we should do a basic PHY config */
  3266. e_dbg("EEPROM not present\n");
  3267. ret_val = -E1000_ERR_CONFIG;
  3268. }
  3269. }
  3270. return ret_val;
  3271. }
  3272. /**
  3273. * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
  3274. * @hw: pointer to the HW structure
  3275. *
  3276. * In the case of a PHY power down to save power, or to turn off link during a
  3277. * driver unload, or wake on lan is not enabled, remove the link.
  3278. **/
  3279. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
  3280. {
  3281. /* If the management interface is not enabled, then power down */
  3282. if (!(hw->mac.ops.check_mng_mode(hw) ||
  3283. hw->phy.ops.check_reset_block(hw)))
  3284. e1000_power_down_phy_copper(hw);
  3285. }
  3286. /**
  3287. * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
  3288. * @hw: pointer to the HW structure
  3289. *
  3290. * Clears hardware counters specific to the silicon family and calls
  3291. * clear_hw_cntrs_generic to clear all general purpose counters.
  3292. **/
  3293. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
  3294. {
  3295. u16 phy_data;
  3296. e1000e_clear_hw_cntrs_base(hw);
  3297. er32(ALGNERRC);
  3298. er32(RXERRC);
  3299. er32(TNCRS);
  3300. er32(CEXTERR);
  3301. er32(TSCTC);
  3302. er32(TSCTFC);
  3303. er32(MGTPRC);
  3304. er32(MGTPDC);
  3305. er32(MGTPTC);
  3306. er32(IAC);
  3307. er32(ICRXOC);
  3308. /* Clear PHY statistics registers */
  3309. if ((hw->phy.type == e1000_phy_82578) ||
  3310. (hw->phy.type == e1000_phy_82579) ||
  3311. (hw->phy.type == e1000_phy_82577)) {
  3312. e1e_rphy(hw, HV_SCC_UPPER, &phy_data);
  3313. e1e_rphy(hw, HV_SCC_LOWER, &phy_data);
  3314. e1e_rphy(hw, HV_ECOL_UPPER, &phy_data);
  3315. e1e_rphy(hw, HV_ECOL_LOWER, &phy_data);
  3316. e1e_rphy(hw, HV_MCC_UPPER, &phy_data);
  3317. e1e_rphy(hw, HV_MCC_LOWER, &phy_data);
  3318. e1e_rphy(hw, HV_LATECOL_UPPER, &phy_data);
  3319. e1e_rphy(hw, HV_LATECOL_LOWER, &phy_data);
  3320. e1e_rphy(hw, HV_COLC_UPPER, &phy_data);
  3321. e1e_rphy(hw, HV_COLC_LOWER, &phy_data);
  3322. e1e_rphy(hw, HV_DC_UPPER, &phy_data);
  3323. e1e_rphy(hw, HV_DC_LOWER, &phy_data);
  3324. e1e_rphy(hw, HV_TNCRS_UPPER, &phy_data);
  3325. e1e_rphy(hw, HV_TNCRS_LOWER, &phy_data);
  3326. }
  3327. }
  3328. static struct e1000_mac_operations ich8_mac_ops = {
  3329. .id_led_init = e1000e_id_led_init,
  3330. /* check_mng_mode dependent on mac type */
  3331. .check_for_link = e1000_check_for_copper_link_ich8lan,
  3332. /* cleanup_led dependent on mac type */
  3333. .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
  3334. .get_bus_info = e1000_get_bus_info_ich8lan,
  3335. .set_lan_id = e1000_set_lan_id_single_port,
  3336. .get_link_up_info = e1000_get_link_up_info_ich8lan,
  3337. /* led_on dependent on mac type */
  3338. /* led_off dependent on mac type */
  3339. .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
  3340. .reset_hw = e1000_reset_hw_ich8lan,
  3341. .init_hw = e1000_init_hw_ich8lan,
  3342. .setup_link = e1000_setup_link_ich8lan,
  3343. .setup_physical_interface= e1000_setup_copper_link_ich8lan,
  3344. /* id_led_init dependent on mac type */
  3345. };
  3346. static struct e1000_phy_operations ich8_phy_ops = {
  3347. .acquire = e1000_acquire_swflag_ich8lan,
  3348. .check_reset_block = e1000_check_reset_block_ich8lan,
  3349. .commit = NULL,
  3350. .get_cfg_done = e1000_get_cfg_done_ich8lan,
  3351. .get_cable_length = e1000e_get_cable_length_igp_2,
  3352. .read_reg = e1000e_read_phy_reg_igp,
  3353. .release = e1000_release_swflag_ich8lan,
  3354. .reset = e1000_phy_hw_reset_ich8lan,
  3355. .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
  3356. .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
  3357. .write_reg = e1000e_write_phy_reg_igp,
  3358. };
  3359. static struct e1000_nvm_operations ich8_nvm_ops = {
  3360. .acquire = e1000_acquire_nvm_ich8lan,
  3361. .read = e1000_read_nvm_ich8lan,
  3362. .release = e1000_release_nvm_ich8lan,
  3363. .update = e1000_update_nvm_checksum_ich8lan,
  3364. .valid_led_default = e1000_valid_led_default_ich8lan,
  3365. .validate = e1000_validate_nvm_checksum_ich8lan,
  3366. .write = e1000_write_nvm_ich8lan,
  3367. };
  3368. struct e1000_info e1000_ich8_info = {
  3369. .mac = e1000_ich8lan,
  3370. .flags = FLAG_HAS_WOL
  3371. | FLAG_IS_ICH
  3372. | FLAG_RX_CSUM_ENABLED
  3373. | FLAG_HAS_CTRLEXT_ON_LOAD
  3374. | FLAG_HAS_AMT
  3375. | FLAG_HAS_FLASH
  3376. | FLAG_APME_IN_WUC,
  3377. .pba = 8,
  3378. .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
  3379. .get_variants = e1000_get_variants_ich8lan,
  3380. .mac_ops = &ich8_mac_ops,
  3381. .phy_ops = &ich8_phy_ops,
  3382. .nvm_ops = &ich8_nvm_ops,
  3383. };
  3384. struct e1000_info e1000_ich9_info = {
  3385. .mac = e1000_ich9lan,
  3386. .flags = FLAG_HAS_JUMBO_FRAMES
  3387. | FLAG_IS_ICH
  3388. | FLAG_HAS_WOL
  3389. | FLAG_RX_CSUM_ENABLED
  3390. | FLAG_HAS_CTRLEXT_ON_LOAD
  3391. | FLAG_HAS_AMT
  3392. | FLAG_HAS_ERT
  3393. | FLAG_HAS_FLASH
  3394. | FLAG_APME_IN_WUC,
  3395. .pba = 10,
  3396. .max_hw_frame_size = DEFAULT_JUMBO,
  3397. .get_variants = e1000_get_variants_ich8lan,
  3398. .mac_ops = &ich8_mac_ops,
  3399. .phy_ops = &ich8_phy_ops,
  3400. .nvm_ops = &ich8_nvm_ops,
  3401. };
  3402. struct e1000_info e1000_ich10_info = {
  3403. .mac = e1000_ich10lan,
  3404. .flags = FLAG_HAS_JUMBO_FRAMES
  3405. | FLAG_IS_ICH
  3406. | FLAG_HAS_WOL
  3407. | FLAG_RX_CSUM_ENABLED
  3408. | FLAG_HAS_CTRLEXT_ON_LOAD
  3409. | FLAG_HAS_AMT
  3410. | FLAG_HAS_ERT
  3411. | FLAG_HAS_FLASH
  3412. | FLAG_APME_IN_WUC,
  3413. .pba = 10,
  3414. .max_hw_frame_size = DEFAULT_JUMBO,
  3415. .get_variants = e1000_get_variants_ich8lan,
  3416. .mac_ops = &ich8_mac_ops,
  3417. .phy_ops = &ich8_phy_ops,
  3418. .nvm_ops = &ich8_nvm_ops,
  3419. };
  3420. struct e1000_info e1000_pch_info = {
  3421. .mac = e1000_pchlan,
  3422. .flags = FLAG_IS_ICH
  3423. | FLAG_HAS_WOL
  3424. | FLAG_RX_CSUM_ENABLED
  3425. | FLAG_HAS_CTRLEXT_ON_LOAD
  3426. | FLAG_HAS_AMT
  3427. | FLAG_HAS_FLASH
  3428. | FLAG_HAS_JUMBO_FRAMES
  3429. | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
  3430. | FLAG_APME_IN_WUC,
  3431. .flags2 = FLAG2_HAS_PHY_STATS,
  3432. .pba = 26,
  3433. .max_hw_frame_size = 4096,
  3434. .get_variants = e1000_get_variants_ich8lan,
  3435. .mac_ops = &ich8_mac_ops,
  3436. .phy_ops = &ich8_phy_ops,
  3437. .nvm_ops = &ich8_nvm_ops,
  3438. };
  3439. struct e1000_info e1000_pch2_info = {
  3440. .mac = e1000_pch2lan,
  3441. .flags = FLAG_IS_ICH
  3442. | FLAG_HAS_WOL
  3443. | FLAG_RX_CSUM_ENABLED
  3444. | FLAG_HAS_CTRLEXT_ON_LOAD
  3445. | FLAG_HAS_AMT
  3446. | FLAG_HAS_FLASH
  3447. | FLAG_HAS_JUMBO_FRAMES
  3448. | FLAG_APME_IN_WUC,
  3449. .flags2 = FLAG2_HAS_PHY_STATS
  3450. | FLAG2_HAS_EEE,
  3451. .pba = 26,
  3452. .max_hw_frame_size = DEFAULT_JUMBO,
  3453. .get_variants = e1000_get_variants_ich8lan,
  3454. .mac_ops = &ich8_mac_ops,
  3455. .phy_ops = &ich8_phy_ops,
  3456. .nvm_ops = &ich8_nvm_ops,
  3457. };