ich8lan.c 162 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915
  1. /* Intel PRO/1000 Linux driver
  2. * Copyright(c) 1999 - 2015 Intel Corporation.
  3. *
  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. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * The full GNU General Public License is included in this distribution in
  14. * the file called "COPYING".
  15. *
  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. /* 82562G 10/100 Network Connection
  22. * 82562G-2 10/100 Network Connection
  23. * 82562GT 10/100 Network Connection
  24. * 82562GT-2 10/100 Network Connection
  25. * 82562V 10/100 Network Connection
  26. * 82562V-2 10/100 Network Connection
  27. * 82566DC-2 Gigabit Network Connection
  28. * 82566DC Gigabit Network Connection
  29. * 82566DM-2 Gigabit Network Connection
  30. * 82566DM Gigabit Network Connection
  31. * 82566MC Gigabit Network Connection
  32. * 82566MM Gigabit Network Connection
  33. * 82567LM Gigabit Network Connection
  34. * 82567LF Gigabit Network Connection
  35. * 82567V Gigabit Network Connection
  36. * 82567LM-2 Gigabit Network Connection
  37. * 82567LF-2 Gigabit Network Connection
  38. * 82567V-2 Gigabit Network Connection
  39. * 82567LF-3 Gigabit Network Connection
  40. * 82567LM-3 Gigabit Network Connection
  41. * 82567LM-4 Gigabit Network Connection
  42. * 82577LM Gigabit Network Connection
  43. * 82577LC Gigabit Network Connection
  44. * 82578DM Gigabit Network Connection
  45. * 82578DC Gigabit Network Connection
  46. * 82579LM Gigabit Network Connection
  47. * 82579V Gigabit Network Connection
  48. * Ethernet Connection I217-LM
  49. * Ethernet Connection I217-V
  50. * Ethernet Connection I218-V
  51. * Ethernet Connection I218-LM
  52. * Ethernet Connection (2) I218-LM
  53. * Ethernet Connection (2) I218-V
  54. * Ethernet Connection (3) I218-LM
  55. * Ethernet Connection (3) I218-V
  56. */
  57. #include "e1000.h"
  58. /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
  59. /* Offset 04h HSFSTS */
  60. union ich8_hws_flash_status {
  61. struct ich8_hsfsts {
  62. u16 flcdone:1; /* bit 0 Flash Cycle Done */
  63. u16 flcerr:1; /* bit 1 Flash Cycle Error */
  64. u16 dael:1; /* bit 2 Direct Access error Log */
  65. u16 berasesz:2; /* bit 4:3 Sector Erase Size */
  66. u16 flcinprog:1; /* bit 5 flash cycle in Progress */
  67. u16 reserved1:2; /* bit 13:6 Reserved */
  68. u16 reserved2:6; /* bit 13:6 Reserved */
  69. u16 fldesvalid:1; /* bit 14 Flash Descriptor Valid */
  70. u16 flockdn:1; /* bit 15 Flash Config Lock-Down */
  71. } hsf_status;
  72. u16 regval;
  73. };
  74. /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
  75. /* Offset 06h FLCTL */
  76. union ich8_hws_flash_ctrl {
  77. struct ich8_hsflctl {
  78. u16 flcgo:1; /* 0 Flash Cycle Go */
  79. u16 flcycle:2; /* 2:1 Flash Cycle */
  80. u16 reserved:5; /* 7:3 Reserved */
  81. u16 fldbcount:2; /* 9:8 Flash Data Byte Count */
  82. u16 flockdn:6; /* 15:10 Reserved */
  83. } hsf_ctrl;
  84. u16 regval;
  85. };
  86. /* ICH Flash Region Access Permissions */
  87. union ich8_hws_flash_regacc {
  88. struct ich8_flracc {
  89. u32 grra:8; /* 0:7 GbE region Read Access */
  90. u32 grwa:8; /* 8:15 GbE region Write Access */
  91. u32 gmrag:8; /* 23:16 GbE Master Read Access Grant */
  92. u32 gmwag:8; /* 31:24 GbE Master Write Access Grant */
  93. } hsf_flregacc;
  94. u16 regval;
  95. };
  96. /* ICH Flash Protected Region */
  97. union ich8_flash_protected_range {
  98. struct ich8_pr {
  99. u32 base:13; /* 0:12 Protected Range Base */
  100. u32 reserved1:2; /* 13:14 Reserved */
  101. u32 rpe:1; /* 15 Read Protection Enable */
  102. u32 limit:13; /* 16:28 Protected Range Limit */
  103. u32 reserved2:2; /* 29:30 Reserved */
  104. u32 wpe:1; /* 31 Write Protection Enable */
  105. } range;
  106. u32 regval;
  107. };
  108. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
  109. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
  110. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
  111. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  112. u32 offset, u8 byte);
  113. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  114. u8 *data);
  115. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  116. u16 *data);
  117. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  118. u8 size, u16 *data);
  119. static s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
  120. u32 *data);
  121. static s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw,
  122. u32 offset, u32 *data);
  123. static s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw,
  124. u32 offset, u32 data);
  125. static s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
  126. u32 offset, u32 dword);
  127. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
  128. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
  129. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
  130. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
  131. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
  132. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
  133. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
  134. static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
  135. static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
  136. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
  137. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
  138. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
  139. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
  140. static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
  141. static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
  142. static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
  143. static int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
  144. static int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
  145. static u32 e1000_rar_get_count_pch_lpt(struct e1000_hw *hw);
  146. static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
  147. static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
  148. static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force);
  149. static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
  150. static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
  151. static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
  152. {
  153. return readw(hw->flash_address + reg);
  154. }
  155. static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
  156. {
  157. return readl(hw->flash_address + reg);
  158. }
  159. static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
  160. {
  161. writew(val, hw->flash_address + reg);
  162. }
  163. static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
  164. {
  165. writel(val, hw->flash_address + reg);
  166. }
  167. #define er16flash(reg) __er16flash(hw, (reg))
  168. #define er32flash(reg) __er32flash(hw, (reg))
  169. #define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
  170. #define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
  171. /**
  172. * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
  173. * @hw: pointer to the HW structure
  174. *
  175. * Test access to the PHY registers by reading the PHY ID registers. If
  176. * the PHY ID is already known (e.g. resume path) compare it with known ID,
  177. * otherwise assume the read PHY ID is correct if it is valid.
  178. *
  179. * Assumes the sw/fw/hw semaphore is already acquired.
  180. **/
  181. static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
  182. {
  183. u16 phy_reg = 0;
  184. u32 phy_id = 0;
  185. s32 ret_val = 0;
  186. u16 retry_count;
  187. u32 mac_reg = 0;
  188. for (retry_count = 0; retry_count < 2; retry_count++) {
  189. ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);
  190. if (ret_val || (phy_reg == 0xFFFF))
  191. continue;
  192. phy_id = (u32)(phy_reg << 16);
  193. ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg);
  194. if (ret_val || (phy_reg == 0xFFFF)) {
  195. phy_id = 0;
  196. continue;
  197. }
  198. phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
  199. break;
  200. }
  201. if (hw->phy.id) {
  202. if (hw->phy.id == phy_id)
  203. goto out;
  204. } else if (phy_id) {
  205. hw->phy.id = phy_id;
  206. hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
  207. goto out;
  208. }
  209. /* In case the PHY needs to be in mdio slow mode,
  210. * set slow mode and try to get the PHY id again.
  211. */
  212. if (hw->mac.type < e1000_pch_lpt) {
  213. hw->phy.ops.release(hw);
  214. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  215. if (!ret_val)
  216. ret_val = e1000e_get_phy_id(hw);
  217. hw->phy.ops.acquire(hw);
  218. }
  219. if (ret_val)
  220. return false;
  221. out:
  222. if ((hw->mac.type == e1000_pch_lpt) || (hw->mac.type == e1000_pch_spt)) {
  223. /* Only unforce SMBus if ME is not active */
  224. if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
  225. /* Unforce SMBus mode in PHY */
  226. e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
  227. phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
  228. e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
  229. /* Unforce SMBus mode in MAC */
  230. mac_reg = er32(CTRL_EXT);
  231. mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
  232. ew32(CTRL_EXT, mac_reg);
  233. }
  234. }
  235. return true;
  236. }
  237. /**
  238. * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
  239. * @hw: pointer to the HW structure
  240. *
  241. * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
  242. * used to reset the PHY to a quiescent state when necessary.
  243. **/
  244. static void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
  245. {
  246. u32 mac_reg;
  247. /* Set Phy Config Counter to 50msec */
  248. mac_reg = er32(FEXTNVM3);
  249. mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
  250. mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
  251. ew32(FEXTNVM3, mac_reg);
  252. /* Toggle LANPHYPC Value bit */
  253. mac_reg = er32(CTRL);
  254. mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
  255. mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
  256. ew32(CTRL, mac_reg);
  257. e1e_flush();
  258. usleep_range(10, 20);
  259. mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
  260. ew32(CTRL, mac_reg);
  261. e1e_flush();
  262. if (hw->mac.type < e1000_pch_lpt) {
  263. msleep(50);
  264. } else {
  265. u16 count = 20;
  266. do {
  267. usleep_range(5000, 10000);
  268. } while (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LPCD) && count--);
  269. msleep(30);
  270. }
  271. }
  272. /**
  273. * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
  274. * @hw: pointer to the HW structure
  275. *
  276. * Workarounds/flow necessary for PHY initialization during driver load
  277. * and resume paths.
  278. **/
  279. static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
  280. {
  281. struct e1000_adapter *adapter = hw->adapter;
  282. u32 mac_reg, fwsm = er32(FWSM);
  283. s32 ret_val;
  284. /* Gate automatic PHY configuration by hardware on managed and
  285. * non-managed 82579 and newer adapters.
  286. */
  287. e1000_gate_hw_phy_config_ich8lan(hw, true);
  288. /* It is not possible to be certain of the current state of ULP
  289. * so forcibly disable it.
  290. */
  291. hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
  292. e1000_disable_ulp_lpt_lp(hw, true);
  293. ret_val = hw->phy.ops.acquire(hw);
  294. if (ret_val) {
  295. e_dbg("Failed to initialize PHY flow\n");
  296. goto out;
  297. }
  298. /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
  299. * inaccessible and resetting the PHY is not blocked, toggle the
  300. * LANPHYPC Value bit to force the interconnect to PCIe mode.
  301. */
  302. switch (hw->mac.type) {
  303. case e1000_pch_lpt:
  304. case e1000_pch_spt:
  305. if (e1000_phy_is_accessible_pchlan(hw))
  306. break;
  307. /* Before toggling LANPHYPC, see if PHY is accessible by
  308. * forcing MAC to SMBus mode first.
  309. */
  310. mac_reg = er32(CTRL_EXT);
  311. mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
  312. ew32(CTRL_EXT, mac_reg);
  313. /* Wait 50 milliseconds for MAC to finish any retries
  314. * that it might be trying to perform from previous
  315. * attempts to acknowledge any phy read requests.
  316. */
  317. msleep(50);
  318. /* fall-through */
  319. case e1000_pch2lan:
  320. if (e1000_phy_is_accessible_pchlan(hw))
  321. break;
  322. /* fall-through */
  323. case e1000_pchlan:
  324. if ((hw->mac.type == e1000_pchlan) &&
  325. (fwsm & E1000_ICH_FWSM_FW_VALID))
  326. break;
  327. if (hw->phy.ops.check_reset_block(hw)) {
  328. e_dbg("Required LANPHYPC toggle blocked by ME\n");
  329. ret_val = -E1000_ERR_PHY;
  330. break;
  331. }
  332. /* Toggle LANPHYPC Value bit */
  333. e1000_toggle_lanphypc_pch_lpt(hw);
  334. if (hw->mac.type >= e1000_pch_lpt) {
  335. if (e1000_phy_is_accessible_pchlan(hw))
  336. break;
  337. /* Toggling LANPHYPC brings the PHY out of SMBus mode
  338. * so ensure that the MAC is also out of SMBus mode
  339. */
  340. mac_reg = er32(CTRL_EXT);
  341. mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
  342. ew32(CTRL_EXT, mac_reg);
  343. if (e1000_phy_is_accessible_pchlan(hw))
  344. break;
  345. ret_val = -E1000_ERR_PHY;
  346. }
  347. break;
  348. default:
  349. break;
  350. }
  351. hw->phy.ops.release(hw);
  352. if (!ret_val) {
  353. /* Check to see if able to reset PHY. Print error if not */
  354. if (hw->phy.ops.check_reset_block(hw)) {
  355. e_err("Reset blocked by ME\n");
  356. goto out;
  357. }
  358. /* Reset the PHY before any access to it. Doing so, ensures
  359. * that the PHY is in a known good state before we read/write
  360. * PHY registers. The generic reset is sufficient here,
  361. * because we haven't determined the PHY type yet.
  362. */
  363. ret_val = e1000e_phy_hw_reset_generic(hw);
  364. if (ret_val)
  365. goto out;
  366. /* On a successful reset, possibly need to wait for the PHY
  367. * to quiesce to an accessible state before returning control
  368. * to the calling function. If the PHY does not quiesce, then
  369. * return E1000E_BLK_PHY_RESET, as this is the condition that
  370. * the PHY is in.
  371. */
  372. ret_val = hw->phy.ops.check_reset_block(hw);
  373. if (ret_val)
  374. e_err("ME blocked access to PHY after reset\n");
  375. }
  376. out:
  377. /* Ungate automatic PHY configuration on non-managed 82579 */
  378. if ((hw->mac.type == e1000_pch2lan) &&
  379. !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
  380. usleep_range(10000, 20000);
  381. e1000_gate_hw_phy_config_ich8lan(hw, false);
  382. }
  383. return ret_val;
  384. }
  385. /**
  386. * e1000_init_phy_params_pchlan - Initialize PHY function pointers
  387. * @hw: pointer to the HW structure
  388. *
  389. * Initialize family-specific PHY parameters and function pointers.
  390. **/
  391. static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
  392. {
  393. struct e1000_phy_info *phy = &hw->phy;
  394. s32 ret_val;
  395. phy->addr = 1;
  396. phy->reset_delay_us = 100;
  397. phy->ops.set_page = e1000_set_page_igp;
  398. phy->ops.read_reg = e1000_read_phy_reg_hv;
  399. phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
  400. phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
  401. phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
  402. phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
  403. phy->ops.write_reg = e1000_write_phy_reg_hv;
  404. phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
  405. phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
  406. phy->ops.power_up = e1000_power_up_phy_copper;
  407. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  408. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  409. phy->id = e1000_phy_unknown;
  410. ret_val = e1000_init_phy_workarounds_pchlan(hw);
  411. if (ret_val)
  412. return ret_val;
  413. if (phy->id == e1000_phy_unknown)
  414. switch (hw->mac.type) {
  415. default:
  416. ret_val = e1000e_get_phy_id(hw);
  417. if (ret_val)
  418. return ret_val;
  419. if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
  420. break;
  421. /* fall-through */
  422. case e1000_pch2lan:
  423. case e1000_pch_lpt:
  424. case e1000_pch_spt:
  425. /* In case the PHY needs to be in mdio slow mode,
  426. * set slow mode and try to get the PHY id again.
  427. */
  428. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  429. if (ret_val)
  430. return ret_val;
  431. ret_val = e1000e_get_phy_id(hw);
  432. if (ret_val)
  433. return ret_val;
  434. break;
  435. }
  436. phy->type = e1000e_get_phy_type_from_id(phy->id);
  437. switch (phy->type) {
  438. case e1000_phy_82577:
  439. case e1000_phy_82579:
  440. case e1000_phy_i217:
  441. phy->ops.check_polarity = e1000_check_polarity_82577;
  442. phy->ops.force_speed_duplex =
  443. e1000_phy_force_speed_duplex_82577;
  444. phy->ops.get_cable_length = e1000_get_cable_length_82577;
  445. phy->ops.get_info = e1000_get_phy_info_82577;
  446. phy->ops.commit = e1000e_phy_sw_reset;
  447. break;
  448. case e1000_phy_82578:
  449. phy->ops.check_polarity = e1000_check_polarity_m88;
  450. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  451. phy->ops.get_cable_length = e1000e_get_cable_length_m88;
  452. phy->ops.get_info = e1000e_get_phy_info_m88;
  453. break;
  454. default:
  455. ret_val = -E1000_ERR_PHY;
  456. break;
  457. }
  458. return ret_val;
  459. }
  460. /**
  461. * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
  462. * @hw: pointer to the HW structure
  463. *
  464. * Initialize family-specific PHY parameters and function pointers.
  465. **/
  466. static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
  467. {
  468. struct e1000_phy_info *phy = &hw->phy;
  469. s32 ret_val;
  470. u16 i = 0;
  471. phy->addr = 1;
  472. phy->reset_delay_us = 100;
  473. phy->ops.power_up = e1000_power_up_phy_copper;
  474. phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
  475. /* We may need to do this twice - once for IGP and if that fails,
  476. * we'll set BM func pointers and try again
  477. */
  478. ret_val = e1000e_determine_phy_address(hw);
  479. if (ret_val) {
  480. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  481. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  482. ret_val = e1000e_determine_phy_address(hw);
  483. if (ret_val) {
  484. e_dbg("Cannot determine PHY addr. Erroring out\n");
  485. return ret_val;
  486. }
  487. }
  488. phy->id = 0;
  489. while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
  490. (i++ < 100)) {
  491. usleep_range(1000, 2000);
  492. ret_val = e1000e_get_phy_id(hw);
  493. if (ret_val)
  494. return ret_val;
  495. }
  496. /* Verify phy id */
  497. switch (phy->id) {
  498. case IGP03E1000_E_PHY_ID:
  499. phy->type = e1000_phy_igp_3;
  500. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  501. phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
  502. phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
  503. phy->ops.get_info = e1000e_get_phy_info_igp;
  504. phy->ops.check_polarity = e1000_check_polarity_igp;
  505. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
  506. break;
  507. case IFE_E_PHY_ID:
  508. case IFE_PLUS_E_PHY_ID:
  509. case IFE_C_E_PHY_ID:
  510. phy->type = e1000_phy_ife;
  511. phy->autoneg_mask = E1000_ALL_NOT_GIG;
  512. phy->ops.get_info = e1000_get_phy_info_ife;
  513. phy->ops.check_polarity = e1000_check_polarity_ife;
  514. phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
  515. break;
  516. case BME1000_E_PHY_ID:
  517. phy->type = e1000_phy_bm;
  518. phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  519. phy->ops.read_reg = e1000e_read_phy_reg_bm;
  520. phy->ops.write_reg = e1000e_write_phy_reg_bm;
  521. phy->ops.commit = e1000e_phy_sw_reset;
  522. phy->ops.get_info = e1000e_get_phy_info_m88;
  523. phy->ops.check_polarity = e1000_check_polarity_m88;
  524. phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
  525. break;
  526. default:
  527. return -E1000_ERR_PHY;
  528. }
  529. return 0;
  530. }
  531. /**
  532. * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
  533. * @hw: pointer to the HW structure
  534. *
  535. * Initialize family-specific NVM parameters and function
  536. * pointers.
  537. **/
  538. static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
  539. {
  540. struct e1000_nvm_info *nvm = &hw->nvm;
  541. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  542. u32 gfpreg, sector_base_addr, sector_end_addr;
  543. u16 i;
  544. u32 nvm_size;
  545. nvm->type = e1000_nvm_flash_sw;
  546. if (hw->mac.type == e1000_pch_spt) {
  547. /* in SPT, gfpreg doesn't exist. NVM size is taken from the
  548. * STRAP register. This is because in SPT the GbE Flash region
  549. * is no longer accessed through the flash registers. Instead,
  550. * the mechanism has changed, and the Flash region access
  551. * registers are now implemented in GbE memory space.
  552. */
  553. nvm->flash_base_addr = 0;
  554. nvm_size = (((er32(STRAP) >> 1) & 0x1F) + 1)
  555. * NVM_SIZE_MULTIPLIER;
  556. nvm->flash_bank_size = nvm_size / 2;
  557. /* Adjust to word count */
  558. nvm->flash_bank_size /= sizeof(u16);
  559. /* Set the base address for flash register access */
  560. hw->flash_address = hw->hw_addr + E1000_FLASH_BASE_ADDR;
  561. } else {
  562. /* Can't read flash registers if register set isn't mapped. */
  563. if (!hw->flash_address) {
  564. e_dbg("ERROR: Flash registers not mapped\n");
  565. return -E1000_ERR_CONFIG;
  566. }
  567. gfpreg = er32flash(ICH_FLASH_GFPREG);
  568. /* sector_X_addr is a "sector"-aligned address (4096 bytes)
  569. * Add 1 to sector_end_addr since this sector is included in
  570. * the overall size.
  571. */
  572. sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
  573. sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
  574. /* flash_base_addr is byte-aligned */
  575. nvm->flash_base_addr = sector_base_addr
  576. << FLASH_SECTOR_ADDR_SHIFT;
  577. /* find total size of the NVM, then cut in half since the total
  578. * size represents two separate NVM banks.
  579. */
  580. nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
  581. << FLASH_SECTOR_ADDR_SHIFT);
  582. nvm->flash_bank_size /= 2;
  583. /* Adjust to word count */
  584. nvm->flash_bank_size /= sizeof(u16);
  585. }
  586. nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
  587. /* Clear shadow ram */
  588. for (i = 0; i < nvm->word_size; i++) {
  589. dev_spec->shadow_ram[i].modified = false;
  590. dev_spec->shadow_ram[i].value = 0xFFFF;
  591. }
  592. return 0;
  593. }
  594. /**
  595. * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
  596. * @hw: pointer to the HW structure
  597. *
  598. * Initialize family-specific MAC parameters and function
  599. * pointers.
  600. **/
  601. static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
  602. {
  603. struct e1000_mac_info *mac = &hw->mac;
  604. /* Set media type function pointer */
  605. hw->phy.media_type = e1000_media_type_copper;
  606. /* Set mta register count */
  607. mac->mta_reg_count = 32;
  608. /* Set rar entry count */
  609. mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
  610. if (mac->type == e1000_ich8lan)
  611. mac->rar_entry_count--;
  612. /* FWSM register */
  613. mac->has_fwsm = true;
  614. /* ARC subsystem not supported */
  615. mac->arc_subsystem_valid = false;
  616. /* Adaptive IFS supported */
  617. mac->adaptive_ifs = true;
  618. /* LED and other operations */
  619. switch (mac->type) {
  620. case e1000_ich8lan:
  621. case e1000_ich9lan:
  622. case e1000_ich10lan:
  623. /* check management mode */
  624. mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
  625. /* ID LED init */
  626. mac->ops.id_led_init = e1000e_id_led_init_generic;
  627. /* blink LED */
  628. mac->ops.blink_led = e1000e_blink_led_generic;
  629. /* setup LED */
  630. mac->ops.setup_led = e1000e_setup_led_generic;
  631. /* cleanup LED */
  632. mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
  633. /* turn on/off LED */
  634. mac->ops.led_on = e1000_led_on_ich8lan;
  635. mac->ops.led_off = e1000_led_off_ich8lan;
  636. break;
  637. case e1000_pch2lan:
  638. mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
  639. mac->ops.rar_set = e1000_rar_set_pch2lan;
  640. /* fall-through */
  641. case e1000_pch_lpt:
  642. case e1000_pch_spt:
  643. case e1000_pchlan:
  644. /* check management mode */
  645. mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
  646. /* ID LED init */
  647. mac->ops.id_led_init = e1000_id_led_init_pchlan;
  648. /* setup LED */
  649. mac->ops.setup_led = e1000_setup_led_pchlan;
  650. /* cleanup LED */
  651. mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
  652. /* turn on/off LED */
  653. mac->ops.led_on = e1000_led_on_pchlan;
  654. mac->ops.led_off = e1000_led_off_pchlan;
  655. break;
  656. default:
  657. break;
  658. }
  659. if ((mac->type == e1000_pch_lpt) || (mac->type == e1000_pch_spt)) {
  660. mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
  661. mac->ops.rar_set = e1000_rar_set_pch_lpt;
  662. mac->ops.setup_physical_interface =
  663. e1000_setup_copper_link_pch_lpt;
  664. mac->ops.rar_get_count = e1000_rar_get_count_pch_lpt;
  665. }
  666. /* Enable PCS Lock-loss workaround for ICH8 */
  667. if (mac->type == e1000_ich8lan)
  668. e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
  669. return 0;
  670. }
  671. /**
  672. * __e1000_access_emi_reg_locked - Read/write EMI register
  673. * @hw: pointer to the HW structure
  674. * @addr: EMI address to program
  675. * @data: pointer to value to read/write from/to the EMI address
  676. * @read: boolean flag to indicate read or write
  677. *
  678. * This helper function assumes the SW/FW/HW Semaphore is already acquired.
  679. **/
  680. static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
  681. u16 *data, bool read)
  682. {
  683. s32 ret_val;
  684. ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
  685. if (ret_val)
  686. return ret_val;
  687. if (read)
  688. ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data);
  689. else
  690. ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data);
  691. return ret_val;
  692. }
  693. /**
  694. * e1000_read_emi_reg_locked - Read Extended Management Interface register
  695. * @hw: pointer to the HW structure
  696. * @addr: EMI address to program
  697. * @data: value to be read from the EMI address
  698. *
  699. * Assumes the SW/FW/HW Semaphore is already acquired.
  700. **/
  701. s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
  702. {
  703. return __e1000_access_emi_reg_locked(hw, addr, data, true);
  704. }
  705. /**
  706. * e1000_write_emi_reg_locked - Write Extended Management Interface register
  707. * @hw: pointer to the HW structure
  708. * @addr: EMI address to program
  709. * @data: value to be written to the EMI address
  710. *
  711. * Assumes the SW/FW/HW Semaphore is already acquired.
  712. **/
  713. s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
  714. {
  715. return __e1000_access_emi_reg_locked(hw, addr, &data, false);
  716. }
  717. /**
  718. * e1000_set_eee_pchlan - Enable/disable EEE support
  719. * @hw: pointer to the HW structure
  720. *
  721. * Enable/disable EEE based on setting in dev_spec structure, the duplex of
  722. * the link and the EEE capabilities of the link partner. The LPI Control
  723. * register bits will remain set only if/when link is up.
  724. *
  725. * EEE LPI must not be asserted earlier than one second after link is up.
  726. * On 82579, EEE LPI should not be enabled until such time otherwise there
  727. * can be link issues with some switches. Other devices can have EEE LPI
  728. * enabled immediately upon link up since they have a timer in hardware which
  729. * prevents LPI from being asserted too early.
  730. **/
  731. s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
  732. {
  733. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  734. s32 ret_val;
  735. u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
  736. switch (hw->phy.type) {
  737. case e1000_phy_82579:
  738. lpa = I82579_EEE_LP_ABILITY;
  739. pcs_status = I82579_EEE_PCS_STATUS;
  740. adv_addr = I82579_EEE_ADVERTISEMENT;
  741. break;
  742. case e1000_phy_i217:
  743. lpa = I217_EEE_LP_ABILITY;
  744. pcs_status = I217_EEE_PCS_STATUS;
  745. adv_addr = I217_EEE_ADVERTISEMENT;
  746. break;
  747. default:
  748. return 0;
  749. }
  750. ret_val = hw->phy.ops.acquire(hw);
  751. if (ret_val)
  752. return ret_val;
  753. ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
  754. if (ret_val)
  755. goto release;
  756. /* Clear bits that enable EEE in various speeds */
  757. lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
  758. /* Enable EEE if not disabled by user */
  759. if (!dev_spec->eee_disable) {
  760. /* Save off link partner's EEE ability */
  761. ret_val = e1000_read_emi_reg_locked(hw, lpa,
  762. &dev_spec->eee_lp_ability);
  763. if (ret_val)
  764. goto release;
  765. /* Read EEE advertisement */
  766. ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
  767. if (ret_val)
  768. goto release;
  769. /* Enable EEE only for speeds in which the link partner is
  770. * EEE capable and for which we advertise EEE.
  771. */
  772. if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
  773. lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
  774. if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) {
  775. e1e_rphy_locked(hw, MII_LPA, &data);
  776. if (data & LPA_100FULL)
  777. lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
  778. else
  779. /* EEE is not supported in 100Half, so ignore
  780. * partner's EEE in 100 ability if full-duplex
  781. * is not advertised.
  782. */
  783. dev_spec->eee_lp_ability &=
  784. ~I82579_EEE_100_SUPPORTED;
  785. }
  786. }
  787. if (hw->phy.type == e1000_phy_82579) {
  788. ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
  789. &data);
  790. if (ret_val)
  791. goto release;
  792. data &= ~I82579_LPI_100_PLL_SHUT;
  793. ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
  794. data);
  795. }
  796. /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
  797. ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
  798. if (ret_val)
  799. goto release;
  800. ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
  801. release:
  802. hw->phy.ops.release(hw);
  803. return ret_val;
  804. }
  805. /**
  806. * e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
  807. * @hw: pointer to the HW structure
  808. * @link: link up bool flag
  809. *
  810. * When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
  811. * preventing further DMA write requests. Workaround the issue by disabling
  812. * the de-assertion of the clock request when in 1Gpbs mode.
  813. * Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
  814. * speeds in order to avoid Tx hangs.
  815. **/
  816. static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
  817. {
  818. u32 fextnvm6 = er32(FEXTNVM6);
  819. u32 status = er32(STATUS);
  820. s32 ret_val = 0;
  821. u16 reg;
  822. if (link && (status & E1000_STATUS_SPEED_1000)) {
  823. ret_val = hw->phy.ops.acquire(hw);
  824. if (ret_val)
  825. return ret_val;
  826. ret_val =
  827. e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
  828. &reg);
  829. if (ret_val)
  830. goto release;
  831. ret_val =
  832. e1000e_write_kmrn_reg_locked(hw,
  833. E1000_KMRNCTRLSTA_K1_CONFIG,
  834. reg &
  835. ~E1000_KMRNCTRLSTA_K1_ENABLE);
  836. if (ret_val)
  837. goto release;
  838. usleep_range(10, 20);
  839. ew32(FEXTNVM6, fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
  840. ret_val =
  841. e1000e_write_kmrn_reg_locked(hw,
  842. E1000_KMRNCTRLSTA_K1_CONFIG,
  843. reg);
  844. release:
  845. hw->phy.ops.release(hw);
  846. } else {
  847. /* clear FEXTNVM6 bit 8 on link down or 10/100 */
  848. fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
  849. if ((hw->phy.revision > 5) || !link ||
  850. ((status & E1000_STATUS_SPEED_100) &&
  851. (status & E1000_STATUS_FD)))
  852. goto update_fextnvm6;
  853. ret_val = e1e_rphy(hw, I217_INBAND_CTRL, &reg);
  854. if (ret_val)
  855. return ret_val;
  856. /* Clear link status transmit timeout */
  857. reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
  858. if (status & E1000_STATUS_SPEED_100) {
  859. /* Set inband Tx timeout to 5x10us for 100Half */
  860. reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
  861. /* Do not extend the K1 entry latency for 100Half */
  862. fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
  863. } else {
  864. /* Set inband Tx timeout to 50x10us for 10Full/Half */
  865. reg |= 50 <<
  866. I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
  867. /* Extend the K1 entry latency for 10 Mbps */
  868. fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
  869. }
  870. ret_val = e1e_wphy(hw, I217_INBAND_CTRL, reg);
  871. if (ret_val)
  872. return ret_val;
  873. update_fextnvm6:
  874. ew32(FEXTNVM6, fextnvm6);
  875. }
  876. return ret_val;
  877. }
  878. /**
  879. * e1000_platform_pm_pch_lpt - Set platform power management values
  880. * @hw: pointer to the HW structure
  881. * @link: bool indicating link status
  882. *
  883. * Set the Latency Tolerance Reporting (LTR) values for the "PCIe-like"
  884. * GbE MAC in the Lynx Point PCH based on Rx buffer size and link speed
  885. * when link is up (which must not exceed the maximum latency supported
  886. * by the platform), otherwise specify there is no LTR requirement.
  887. * Unlike true-PCIe devices which set the LTR maximum snoop/no-snoop
  888. * latencies in the LTR Extended Capability Structure in the PCIe Extended
  889. * Capability register set, on this device LTR is set by writing the
  890. * equivalent snoop/no-snoop latencies in the LTRV register in the MAC and
  891. * set the SEND bit to send an Intel On-chip System Fabric sideband (IOSF-SB)
  892. * message to the PMC.
  893. **/
  894. static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
  895. {
  896. u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
  897. link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
  898. u16 lat_enc = 0; /* latency encoded */
  899. if (link) {
  900. u16 speed, duplex, scale = 0;
  901. u16 max_snoop, max_nosnoop;
  902. u16 max_ltr_enc; /* max LTR latency encoded */
  903. u64 value;
  904. u32 rxa;
  905. if (!hw->adapter->max_frame_size) {
  906. e_dbg("max_frame_size not set.\n");
  907. return -E1000_ERR_CONFIG;
  908. }
  909. hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
  910. if (!speed) {
  911. e_dbg("Speed not set.\n");
  912. return -E1000_ERR_CONFIG;
  913. }
  914. /* Rx Packet Buffer Allocation size (KB) */
  915. rxa = er32(PBA) & E1000_PBA_RXA_MASK;
  916. /* Determine the maximum latency tolerated by the device.
  917. *
  918. * Per the PCIe spec, the tolerated latencies are encoded as
  919. * a 3-bit encoded scale (only 0-5 are valid) multiplied by
  920. * a 10-bit value (0-1023) to provide a range from 1 ns to
  921. * 2^25*(2^10-1) ns. The scale is encoded as 0=2^0ns,
  922. * 1=2^5ns, 2=2^10ns,...5=2^25ns.
  923. */
  924. rxa *= 512;
  925. value = (rxa > hw->adapter->max_frame_size) ?
  926. (rxa - hw->adapter->max_frame_size) * (16000 / speed) :
  927. 0;
  928. while (value > PCI_LTR_VALUE_MASK) {
  929. scale++;
  930. value = DIV_ROUND_UP(value, (1 << 5));
  931. }
  932. if (scale > E1000_LTRV_SCALE_MAX) {
  933. e_dbg("Invalid LTR latency scale %d\n", scale);
  934. return -E1000_ERR_CONFIG;
  935. }
  936. lat_enc = (u16)((scale << PCI_LTR_SCALE_SHIFT) | value);
  937. /* Determine the maximum latency tolerated by the platform */
  938. pci_read_config_word(hw->adapter->pdev, E1000_PCI_LTR_CAP_LPT,
  939. &max_snoop);
  940. pci_read_config_word(hw->adapter->pdev,
  941. E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);
  942. max_ltr_enc = max_t(u16, max_snoop, max_nosnoop);
  943. if (lat_enc > max_ltr_enc)
  944. lat_enc = max_ltr_enc;
  945. }
  946. /* Set Snoop and No-Snoop latencies the same */
  947. reg |= lat_enc | (lat_enc << E1000_LTRV_NOSNOOP_SHIFT);
  948. ew32(LTRV, reg);
  949. return 0;
  950. }
  951. /**
  952. * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
  953. * @hw: pointer to the HW structure
  954. * @to_sx: boolean indicating a system power state transition to Sx
  955. *
  956. * When link is down, configure ULP mode to significantly reduce the power
  957. * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
  958. * ME firmware to start the ULP configuration. If not on an ME enabled
  959. * system, configure the ULP mode by software.
  960. */
  961. s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
  962. {
  963. u32 mac_reg;
  964. s32 ret_val = 0;
  965. u16 phy_reg;
  966. u16 oem_reg = 0;
  967. if ((hw->mac.type < e1000_pch_lpt) ||
  968. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
  969. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
  970. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
  971. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
  972. (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
  973. return 0;
  974. if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
  975. /* Request ME configure ULP mode in the PHY */
  976. mac_reg = er32(H2ME);
  977. mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
  978. ew32(H2ME, mac_reg);
  979. goto out;
  980. }
  981. if (!to_sx) {
  982. int i = 0;
  983. /* Poll up to 5 seconds for Cable Disconnected indication */
  984. while (!(er32(FEXT) & E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
  985. /* Bail if link is re-acquired */
  986. if (er32(STATUS) & E1000_STATUS_LU)
  987. return -E1000_ERR_PHY;
  988. if (i++ == 100)
  989. break;
  990. msleep(50);
  991. }
  992. e_dbg("CABLE_DISCONNECTED %s set after %dmsec\n",
  993. (er32(FEXT) &
  994. E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not", i * 50);
  995. }
  996. ret_val = hw->phy.ops.acquire(hw);
  997. if (ret_val)
  998. goto out;
  999. /* Force SMBus mode in PHY */
  1000. ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
  1001. if (ret_val)
  1002. goto release;
  1003. phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
  1004. e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
  1005. /* Force SMBus mode in MAC */
  1006. mac_reg = er32(CTRL_EXT);
  1007. mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
  1008. ew32(CTRL_EXT, mac_reg);
  1009. /* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
  1010. * LPLU and disable Gig speed when entering ULP
  1011. */
  1012. if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6)) {
  1013. ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
  1014. &oem_reg);
  1015. if (ret_val)
  1016. goto release;
  1017. phy_reg = oem_reg;
  1018. phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
  1019. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
  1020. phy_reg);
  1021. if (ret_val)
  1022. goto release;
  1023. }
  1024. /* Set Inband ULP Exit, Reset to SMBus mode and
  1025. * Disable SMBus Release on PERST# in PHY
  1026. */
  1027. ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
  1028. if (ret_val)
  1029. goto release;
  1030. phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
  1031. I218_ULP_CONFIG1_DISABLE_SMB_PERST);
  1032. if (to_sx) {
  1033. if (er32(WUFC) & E1000_WUFC_LNKC)
  1034. phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
  1035. else
  1036. phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
  1037. phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
  1038. phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
  1039. } else {
  1040. phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
  1041. phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
  1042. phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
  1043. }
  1044. e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
  1045. /* Set Disable SMBus Release on PERST# in MAC */
  1046. mac_reg = er32(FEXTNVM7);
  1047. mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
  1048. ew32(FEXTNVM7, mac_reg);
  1049. /* Commit ULP changes in PHY by starting auto ULP configuration */
  1050. phy_reg |= I218_ULP_CONFIG1_START;
  1051. e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
  1052. if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
  1053. to_sx && (er32(STATUS) & E1000_STATUS_LU)) {
  1054. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
  1055. oem_reg);
  1056. if (ret_val)
  1057. goto release;
  1058. }
  1059. release:
  1060. hw->phy.ops.release(hw);
  1061. out:
  1062. if (ret_val)
  1063. e_dbg("Error in ULP enable flow: %d\n", ret_val);
  1064. else
  1065. hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
  1066. return ret_val;
  1067. }
  1068. /**
  1069. * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
  1070. * @hw: pointer to the HW structure
  1071. * @force: boolean indicating whether or not to force disabling ULP
  1072. *
  1073. * Un-configure ULP mode when link is up, the system is transitioned from
  1074. * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
  1075. * system, poll for an indication from ME that ULP has been un-configured.
  1076. * If not on an ME enabled system, un-configure the ULP mode by software.
  1077. *
  1078. * During nominal operation, this function is called when link is acquired
  1079. * to disable ULP mode (force=false); otherwise, for example when unloading
  1080. * the driver or during Sx->S0 transitions, this is called with force=true
  1081. * to forcibly disable ULP.
  1082. */
  1083. static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
  1084. {
  1085. s32 ret_val = 0;
  1086. u32 mac_reg;
  1087. u16 phy_reg;
  1088. int i = 0;
  1089. if ((hw->mac.type < e1000_pch_lpt) ||
  1090. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
  1091. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
  1092. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
  1093. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
  1094. (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
  1095. return 0;
  1096. if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
  1097. if (force) {
  1098. /* Request ME un-configure ULP mode in the PHY */
  1099. mac_reg = er32(H2ME);
  1100. mac_reg &= ~E1000_H2ME_ULP;
  1101. mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
  1102. ew32(H2ME, mac_reg);
  1103. }
  1104. /* Poll up to 300msec for ME to clear ULP_CFG_DONE. */
  1105. while (er32(FWSM) & E1000_FWSM_ULP_CFG_DONE) {
  1106. if (i++ == 30) {
  1107. ret_val = -E1000_ERR_PHY;
  1108. goto out;
  1109. }
  1110. usleep_range(10000, 20000);
  1111. }
  1112. e_dbg("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
  1113. if (force) {
  1114. mac_reg = er32(H2ME);
  1115. mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
  1116. ew32(H2ME, mac_reg);
  1117. } else {
  1118. /* Clear H2ME.ULP after ME ULP configuration */
  1119. mac_reg = er32(H2ME);
  1120. mac_reg &= ~E1000_H2ME_ULP;
  1121. ew32(H2ME, mac_reg);
  1122. }
  1123. goto out;
  1124. }
  1125. ret_val = hw->phy.ops.acquire(hw);
  1126. if (ret_val)
  1127. goto out;
  1128. if (force)
  1129. /* Toggle LANPHYPC Value bit */
  1130. e1000_toggle_lanphypc_pch_lpt(hw);
  1131. /* Unforce SMBus mode in PHY */
  1132. ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
  1133. if (ret_val) {
  1134. /* The MAC might be in PCIe mode, so temporarily force to
  1135. * SMBus mode in order to access the PHY.
  1136. */
  1137. mac_reg = er32(CTRL_EXT);
  1138. mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
  1139. ew32(CTRL_EXT, mac_reg);
  1140. msleep(50);
  1141. ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
  1142. &phy_reg);
  1143. if (ret_val)
  1144. goto release;
  1145. }
  1146. phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
  1147. e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
  1148. /* Unforce SMBus mode in MAC */
  1149. mac_reg = er32(CTRL_EXT);
  1150. mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
  1151. ew32(CTRL_EXT, mac_reg);
  1152. /* When ULP mode was previously entered, K1 was disabled by the
  1153. * hardware. Re-Enable K1 in the PHY when exiting ULP.
  1154. */
  1155. ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
  1156. if (ret_val)
  1157. goto release;
  1158. phy_reg |= HV_PM_CTRL_K1_ENABLE;
  1159. e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
  1160. /* Clear ULP enabled configuration */
  1161. ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
  1162. if (ret_val)
  1163. goto release;
  1164. phy_reg &= ~(I218_ULP_CONFIG1_IND |
  1165. I218_ULP_CONFIG1_STICKY_ULP |
  1166. I218_ULP_CONFIG1_RESET_TO_SMBUS |
  1167. I218_ULP_CONFIG1_WOL_HOST |
  1168. I218_ULP_CONFIG1_INBAND_EXIT |
  1169. I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
  1170. I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
  1171. I218_ULP_CONFIG1_DISABLE_SMB_PERST);
  1172. e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
  1173. /* Commit ULP changes by starting auto ULP configuration */
  1174. phy_reg |= I218_ULP_CONFIG1_START;
  1175. e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
  1176. /* Clear Disable SMBus Release on PERST# in MAC */
  1177. mac_reg = er32(FEXTNVM7);
  1178. mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
  1179. ew32(FEXTNVM7, mac_reg);
  1180. release:
  1181. hw->phy.ops.release(hw);
  1182. if (force) {
  1183. e1000_phy_hw_reset(hw);
  1184. msleep(50);
  1185. }
  1186. out:
  1187. if (ret_val)
  1188. e_dbg("Error in ULP disable flow: %d\n", ret_val);
  1189. else
  1190. hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
  1191. return ret_val;
  1192. }
  1193. /**
  1194. * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
  1195. * @hw: pointer to the HW structure
  1196. *
  1197. * Checks to see of the link status of the hardware has changed. If a
  1198. * change in link status has been detected, then we read the PHY registers
  1199. * to get the current speed/duplex if link exists.
  1200. **/
  1201. static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
  1202. {
  1203. struct e1000_mac_info *mac = &hw->mac;
  1204. s32 ret_val, tipg_reg = 0;
  1205. u16 emi_addr, emi_val = 0;
  1206. bool link;
  1207. u16 phy_reg;
  1208. /* We only want to go out to the PHY registers to see if Auto-Neg
  1209. * has completed and/or if our link status has changed. The
  1210. * get_link_status flag is set upon receiving a Link Status
  1211. * Change or Rx Sequence Error interrupt.
  1212. */
  1213. if (!mac->get_link_status)
  1214. return 0;
  1215. /* First we want to see if the MII Status Register reports
  1216. * link. If so, then we want to get the current speed/duplex
  1217. * of the PHY.
  1218. */
  1219. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  1220. if (ret_val)
  1221. return ret_val;
  1222. if (hw->mac.type == e1000_pchlan) {
  1223. ret_val = e1000_k1_gig_workaround_hv(hw, link);
  1224. if (ret_val)
  1225. return ret_val;
  1226. }
  1227. /* When connected at 10Mbps half-duplex, some parts are excessively
  1228. * aggressive resulting in many collisions. To avoid this, increase
  1229. * the IPG and reduce Rx latency in the PHY.
  1230. */
  1231. if (((hw->mac.type == e1000_pch2lan) ||
  1232. (hw->mac.type == e1000_pch_lpt) ||
  1233. (hw->mac.type == e1000_pch_spt)) && link) {
  1234. u16 speed, duplex;
  1235. e1000e_get_speed_and_duplex_copper(hw, &speed, &duplex);
  1236. tipg_reg = er32(TIPG);
  1237. tipg_reg &= ~E1000_TIPG_IPGT_MASK;
  1238. if (duplex == HALF_DUPLEX && speed == SPEED_10) {
  1239. tipg_reg |= 0xFF;
  1240. /* Reduce Rx latency in analog PHY */
  1241. emi_val = 0;
  1242. } else if (hw->mac.type == e1000_pch_spt &&
  1243. duplex == FULL_DUPLEX && speed != SPEED_1000) {
  1244. tipg_reg |= 0xC;
  1245. emi_val = 1;
  1246. } else {
  1247. /* Roll back the default values */
  1248. tipg_reg |= 0x08;
  1249. emi_val = 1;
  1250. }
  1251. ew32(TIPG, tipg_reg);
  1252. ret_val = hw->phy.ops.acquire(hw);
  1253. if (ret_val)
  1254. return ret_val;
  1255. if (hw->mac.type == e1000_pch2lan)
  1256. emi_addr = I82579_RX_CONFIG;
  1257. else
  1258. emi_addr = I217_RX_CONFIG;
  1259. ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
  1260. if (hw->mac.type == e1000_pch_lpt ||
  1261. hw->mac.type == e1000_pch_spt) {
  1262. u16 phy_reg;
  1263. e1e_rphy_locked(hw, I217_PLL_CLOCK_GATE_REG, &phy_reg);
  1264. phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
  1265. if (speed == SPEED_100 || speed == SPEED_10)
  1266. phy_reg |= 0x3E8;
  1267. else
  1268. phy_reg |= 0xFA;
  1269. e1e_wphy_locked(hw, I217_PLL_CLOCK_GATE_REG, phy_reg);
  1270. }
  1271. hw->phy.ops.release(hw);
  1272. if (ret_val)
  1273. return ret_val;
  1274. if (hw->mac.type == e1000_pch_spt) {
  1275. u16 data;
  1276. u16 ptr_gap;
  1277. if (speed == SPEED_1000) {
  1278. ret_val = hw->phy.ops.acquire(hw);
  1279. if (ret_val)
  1280. return ret_val;
  1281. ret_val = e1e_rphy_locked(hw,
  1282. PHY_REG(776, 20),
  1283. &data);
  1284. if (ret_val) {
  1285. hw->phy.ops.release(hw);
  1286. return ret_val;
  1287. }
  1288. ptr_gap = (data & (0x3FF << 2)) >> 2;
  1289. if (ptr_gap < 0x18) {
  1290. data &= ~(0x3FF << 2);
  1291. data |= (0x18 << 2);
  1292. ret_val =
  1293. e1e_wphy_locked(hw,
  1294. PHY_REG(776, 20),
  1295. data);
  1296. }
  1297. hw->phy.ops.release(hw);
  1298. if (ret_val)
  1299. return ret_val;
  1300. } else {
  1301. ret_val = hw->phy.ops.acquire(hw);
  1302. if (ret_val)
  1303. return ret_val;
  1304. ret_val = e1e_wphy_locked(hw,
  1305. PHY_REG(776, 20),
  1306. 0xC023);
  1307. hw->phy.ops.release(hw);
  1308. if (ret_val)
  1309. return ret_val;
  1310. }
  1311. }
  1312. }
  1313. /* I217 Packet Loss issue:
  1314. * ensure that FEXTNVM4 Beacon Duration is set correctly
  1315. * on power up.
  1316. * Set the Beacon Duration for I217 to 8 usec
  1317. */
  1318. if ((hw->mac.type == e1000_pch_lpt) || (hw->mac.type == e1000_pch_spt)) {
  1319. u32 mac_reg;
  1320. mac_reg = er32(FEXTNVM4);
  1321. mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
  1322. mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
  1323. ew32(FEXTNVM4, mac_reg);
  1324. }
  1325. /* Work-around I218 hang issue */
  1326. if ((hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
  1327. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
  1328. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM3) ||
  1329. (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V3)) {
  1330. ret_val = e1000_k1_workaround_lpt_lp(hw, link);
  1331. if (ret_val)
  1332. return ret_val;
  1333. }
  1334. if ((hw->mac.type == e1000_pch_lpt) ||
  1335. (hw->mac.type == e1000_pch_spt)) {
  1336. /* Set platform power management values for
  1337. * Latency Tolerance Reporting (LTR)
  1338. */
  1339. ret_val = e1000_platform_pm_pch_lpt(hw, link);
  1340. if (ret_val)
  1341. return ret_val;
  1342. }
  1343. /* Clear link partner's EEE ability */
  1344. hw->dev_spec.ich8lan.eee_lp_ability = 0;
  1345. /* FEXTNVM6 K1-off workaround */
  1346. if (hw->mac.type == e1000_pch_spt) {
  1347. u32 pcieanacfg = er32(PCIEANACFG);
  1348. u32 fextnvm6 = er32(FEXTNVM6);
  1349. if (pcieanacfg & E1000_FEXTNVM6_K1_OFF_ENABLE)
  1350. fextnvm6 |= E1000_FEXTNVM6_K1_OFF_ENABLE;
  1351. else
  1352. fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
  1353. ew32(FEXTNVM6, fextnvm6);
  1354. }
  1355. if (!link)
  1356. return 0; /* No link detected */
  1357. mac->get_link_status = false;
  1358. switch (hw->mac.type) {
  1359. case e1000_pch2lan:
  1360. ret_val = e1000_k1_workaround_lv(hw);
  1361. if (ret_val)
  1362. return ret_val;
  1363. /* fall-thru */
  1364. case e1000_pchlan:
  1365. if (hw->phy.type == e1000_phy_82578) {
  1366. ret_val = e1000_link_stall_workaround_hv(hw);
  1367. if (ret_val)
  1368. return ret_val;
  1369. }
  1370. /* Workaround for PCHx parts in half-duplex:
  1371. * Set the number of preambles removed from the packet
  1372. * when it is passed from the PHY to the MAC to prevent
  1373. * the MAC from misinterpreting the packet type.
  1374. */
  1375. e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
  1376. phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
  1377. if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
  1378. phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
  1379. e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
  1380. break;
  1381. default:
  1382. break;
  1383. }
  1384. /* Check if there was DownShift, must be checked
  1385. * immediately after link-up
  1386. */
  1387. e1000e_check_downshift(hw);
  1388. /* Enable/Disable EEE after link up */
  1389. if (hw->phy.type > e1000_phy_82579) {
  1390. ret_val = e1000_set_eee_pchlan(hw);
  1391. if (ret_val)
  1392. return ret_val;
  1393. }
  1394. /* If we are forcing speed/duplex, then we simply return since
  1395. * we have already determined whether we have link or not.
  1396. */
  1397. if (!mac->autoneg)
  1398. return -E1000_ERR_CONFIG;
  1399. /* Auto-Neg is enabled. Auto Speed Detection takes care
  1400. * of MAC speed/duplex configuration. So we only need to
  1401. * configure Collision Distance in the MAC.
  1402. */
  1403. mac->ops.config_collision_dist(hw);
  1404. /* Configure Flow Control now that Auto-Neg has completed.
  1405. * First, we need to restore the desired flow control
  1406. * settings because we may have had to re-autoneg with a
  1407. * different link partner.
  1408. */
  1409. ret_val = e1000e_config_fc_after_link_up(hw);
  1410. if (ret_val)
  1411. e_dbg("Error configuring flow control\n");
  1412. return ret_val;
  1413. }
  1414. static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
  1415. {
  1416. struct e1000_hw *hw = &adapter->hw;
  1417. s32 rc;
  1418. rc = e1000_init_mac_params_ich8lan(hw);
  1419. if (rc)
  1420. return rc;
  1421. rc = e1000_init_nvm_params_ich8lan(hw);
  1422. if (rc)
  1423. return rc;
  1424. switch (hw->mac.type) {
  1425. case e1000_ich8lan:
  1426. case e1000_ich9lan:
  1427. case e1000_ich10lan:
  1428. rc = e1000_init_phy_params_ich8lan(hw);
  1429. break;
  1430. case e1000_pchlan:
  1431. case e1000_pch2lan:
  1432. case e1000_pch_lpt:
  1433. case e1000_pch_spt:
  1434. rc = e1000_init_phy_params_pchlan(hw);
  1435. break;
  1436. default:
  1437. break;
  1438. }
  1439. if (rc)
  1440. return rc;
  1441. /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
  1442. * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
  1443. */
  1444. if ((adapter->hw.phy.type == e1000_phy_ife) ||
  1445. ((adapter->hw.mac.type >= e1000_pch2lan) &&
  1446. (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
  1447. adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
  1448. adapter->max_hw_frame_size = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
  1449. hw->mac.ops.blink_led = NULL;
  1450. }
  1451. if ((adapter->hw.mac.type == e1000_ich8lan) &&
  1452. (adapter->hw.phy.type != e1000_phy_ife))
  1453. adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
  1454. /* Enable workaround for 82579 w/ ME enabled */
  1455. if ((adapter->hw.mac.type == e1000_pch2lan) &&
  1456. (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  1457. adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
  1458. return 0;
  1459. }
  1460. static DEFINE_MUTEX(nvm_mutex);
  1461. /**
  1462. * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
  1463. * @hw: pointer to the HW structure
  1464. *
  1465. * Acquires the mutex for performing NVM operations.
  1466. **/
  1467. static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw)
  1468. {
  1469. mutex_lock(&nvm_mutex);
  1470. return 0;
  1471. }
  1472. /**
  1473. * e1000_release_nvm_ich8lan - Release NVM mutex
  1474. * @hw: pointer to the HW structure
  1475. *
  1476. * Releases the mutex used while performing NVM operations.
  1477. **/
  1478. static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw)
  1479. {
  1480. mutex_unlock(&nvm_mutex);
  1481. }
  1482. /**
  1483. * e1000_acquire_swflag_ich8lan - Acquire software control flag
  1484. * @hw: pointer to the HW structure
  1485. *
  1486. * Acquires the software control flag for performing PHY and select
  1487. * MAC CSR accesses.
  1488. **/
  1489. static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
  1490. {
  1491. u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
  1492. s32 ret_val = 0;
  1493. if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
  1494. &hw->adapter->state)) {
  1495. e_dbg("contention for Phy access\n");
  1496. return -E1000_ERR_PHY;
  1497. }
  1498. while (timeout) {
  1499. extcnf_ctrl = er32(EXTCNF_CTRL);
  1500. if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
  1501. break;
  1502. mdelay(1);
  1503. timeout--;
  1504. }
  1505. if (!timeout) {
  1506. e_dbg("SW has already locked the resource.\n");
  1507. ret_val = -E1000_ERR_CONFIG;
  1508. goto out;
  1509. }
  1510. timeout = SW_FLAG_TIMEOUT;
  1511. extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
  1512. ew32(EXTCNF_CTRL, extcnf_ctrl);
  1513. while (timeout) {
  1514. extcnf_ctrl = er32(EXTCNF_CTRL);
  1515. if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
  1516. break;
  1517. mdelay(1);
  1518. timeout--;
  1519. }
  1520. if (!timeout) {
  1521. e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
  1522. er32(FWSM), extcnf_ctrl);
  1523. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  1524. ew32(EXTCNF_CTRL, extcnf_ctrl);
  1525. ret_val = -E1000_ERR_CONFIG;
  1526. goto out;
  1527. }
  1528. out:
  1529. if (ret_val)
  1530. clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
  1531. return ret_val;
  1532. }
  1533. /**
  1534. * e1000_release_swflag_ich8lan - Release software control flag
  1535. * @hw: pointer to the HW structure
  1536. *
  1537. * Releases the software control flag for performing PHY and select
  1538. * MAC CSR accesses.
  1539. **/
  1540. static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
  1541. {
  1542. u32 extcnf_ctrl;
  1543. extcnf_ctrl = er32(EXTCNF_CTRL);
  1544. if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) {
  1545. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
  1546. ew32(EXTCNF_CTRL, extcnf_ctrl);
  1547. } else {
  1548. e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
  1549. }
  1550. clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
  1551. }
  1552. /**
  1553. * e1000_check_mng_mode_ich8lan - Checks management mode
  1554. * @hw: pointer to the HW structure
  1555. *
  1556. * This checks if the adapter has any manageability enabled.
  1557. * This is a function pointer entry point only called by read/write
  1558. * routines for the PHY and NVM parts.
  1559. **/
  1560. static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
  1561. {
  1562. u32 fwsm;
  1563. fwsm = er32(FWSM);
  1564. return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
  1565. ((fwsm & E1000_FWSM_MODE_MASK) ==
  1566. (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
  1567. }
  1568. /**
  1569. * e1000_check_mng_mode_pchlan - Checks management mode
  1570. * @hw: pointer to the HW structure
  1571. *
  1572. * This checks if the adapter has iAMT enabled.
  1573. * This is a function pointer entry point only called by read/write
  1574. * routines for the PHY and NVM parts.
  1575. **/
  1576. static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
  1577. {
  1578. u32 fwsm;
  1579. fwsm = er32(FWSM);
  1580. return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
  1581. (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
  1582. }
  1583. /**
  1584. * e1000_rar_set_pch2lan - Set receive address register
  1585. * @hw: pointer to the HW structure
  1586. * @addr: pointer to the receive address
  1587. * @index: receive address array register
  1588. *
  1589. * Sets the receive address array register at index to the address passed
  1590. * in by addr. For 82579, RAR[0] is the base address register that is to
  1591. * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
  1592. * Use SHRA[0-3] in place of those reserved for ME.
  1593. **/
  1594. static int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
  1595. {
  1596. u32 rar_low, rar_high;
  1597. /* HW expects these in little endian so we reverse the byte order
  1598. * from network order (big endian) to little endian
  1599. */
  1600. rar_low = ((u32)addr[0] |
  1601. ((u32)addr[1] << 8) |
  1602. ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
  1603. rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
  1604. /* If MAC address zero, no need to set the AV bit */
  1605. if (rar_low || rar_high)
  1606. rar_high |= E1000_RAH_AV;
  1607. if (index == 0) {
  1608. ew32(RAL(index), rar_low);
  1609. e1e_flush();
  1610. ew32(RAH(index), rar_high);
  1611. e1e_flush();
  1612. return 0;
  1613. }
  1614. /* RAR[1-6] are owned by manageability. Skip those and program the
  1615. * next address into the SHRA register array.
  1616. */
  1617. if (index < (u32)(hw->mac.rar_entry_count)) {
  1618. s32 ret_val;
  1619. ret_val = e1000_acquire_swflag_ich8lan(hw);
  1620. if (ret_val)
  1621. goto out;
  1622. ew32(SHRAL(index - 1), rar_low);
  1623. e1e_flush();
  1624. ew32(SHRAH(index - 1), rar_high);
  1625. e1e_flush();
  1626. e1000_release_swflag_ich8lan(hw);
  1627. /* verify the register updates */
  1628. if ((er32(SHRAL(index - 1)) == rar_low) &&
  1629. (er32(SHRAH(index - 1)) == rar_high))
  1630. return 0;
  1631. e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
  1632. (index - 1), er32(FWSM));
  1633. }
  1634. out:
  1635. e_dbg("Failed to write receive address at index %d\n", index);
  1636. return -E1000_ERR_CONFIG;
  1637. }
  1638. /**
  1639. * e1000_rar_get_count_pch_lpt - Get the number of available SHRA
  1640. * @hw: pointer to the HW structure
  1641. *
  1642. * Get the number of available receive registers that the Host can
  1643. * program. SHRA[0-10] are the shared receive address registers
  1644. * that are shared between the Host and manageability engine (ME).
  1645. * ME can reserve any number of addresses and the host needs to be
  1646. * able to tell how many available registers it has access to.
  1647. **/
  1648. static u32 e1000_rar_get_count_pch_lpt(struct e1000_hw *hw)
  1649. {
  1650. u32 wlock_mac;
  1651. u32 num_entries;
  1652. wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
  1653. wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
  1654. switch (wlock_mac) {
  1655. case 0:
  1656. /* All SHRA[0..10] and RAR[0] available */
  1657. num_entries = hw->mac.rar_entry_count;
  1658. break;
  1659. case 1:
  1660. /* Only RAR[0] available */
  1661. num_entries = 1;
  1662. break;
  1663. default:
  1664. /* SHRA[0..(wlock_mac - 1)] available + RAR[0] */
  1665. num_entries = wlock_mac + 1;
  1666. break;
  1667. }
  1668. return num_entries;
  1669. }
  1670. /**
  1671. * e1000_rar_set_pch_lpt - Set receive address registers
  1672. * @hw: pointer to the HW structure
  1673. * @addr: pointer to the receive address
  1674. * @index: receive address array register
  1675. *
  1676. * Sets the receive address register array at index to the address passed
  1677. * in by addr. For LPT, RAR[0] is the base address register that is to
  1678. * contain the MAC address. SHRA[0-10] are the shared receive address
  1679. * registers that are shared between the Host and manageability engine (ME).
  1680. **/
  1681. static int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
  1682. {
  1683. u32 rar_low, rar_high;
  1684. u32 wlock_mac;
  1685. /* HW expects these in little endian so we reverse the byte order
  1686. * from network order (big endian) to little endian
  1687. */
  1688. rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
  1689. ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
  1690. rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
  1691. /* If MAC address zero, no need to set the AV bit */
  1692. if (rar_low || rar_high)
  1693. rar_high |= E1000_RAH_AV;
  1694. if (index == 0) {
  1695. ew32(RAL(index), rar_low);
  1696. e1e_flush();
  1697. ew32(RAH(index), rar_high);
  1698. e1e_flush();
  1699. return 0;
  1700. }
  1701. /* The manageability engine (ME) can lock certain SHRAR registers that
  1702. * it is using - those registers are unavailable for use.
  1703. */
  1704. if (index < hw->mac.rar_entry_count) {
  1705. wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
  1706. wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
  1707. /* Check if all SHRAR registers are locked */
  1708. if (wlock_mac == 1)
  1709. goto out;
  1710. if ((wlock_mac == 0) || (index <= wlock_mac)) {
  1711. s32 ret_val;
  1712. ret_val = e1000_acquire_swflag_ich8lan(hw);
  1713. if (ret_val)
  1714. goto out;
  1715. ew32(SHRAL_PCH_LPT(index - 1), rar_low);
  1716. e1e_flush();
  1717. ew32(SHRAH_PCH_LPT(index - 1), rar_high);
  1718. e1e_flush();
  1719. e1000_release_swflag_ich8lan(hw);
  1720. /* verify the register updates */
  1721. if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) &&
  1722. (er32(SHRAH_PCH_LPT(index - 1)) == rar_high))
  1723. return 0;
  1724. }
  1725. }
  1726. out:
  1727. e_dbg("Failed to write receive address at index %d\n", index);
  1728. return -E1000_ERR_CONFIG;
  1729. }
  1730. /**
  1731. * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
  1732. * @hw: pointer to the HW structure
  1733. *
  1734. * Checks if firmware is blocking the reset of the PHY.
  1735. * This is a function pointer entry point only called by
  1736. * reset routines.
  1737. **/
  1738. static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
  1739. {
  1740. bool blocked = false;
  1741. int i = 0;
  1742. while ((blocked = !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) &&
  1743. (i++ < 30))
  1744. usleep_range(10000, 20000);
  1745. return blocked ? E1000_BLK_PHY_RESET : 0;
  1746. }
  1747. /**
  1748. * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
  1749. * @hw: pointer to the HW structure
  1750. *
  1751. * Assumes semaphore already acquired.
  1752. *
  1753. **/
  1754. static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
  1755. {
  1756. u16 phy_data;
  1757. u32 strap = er32(STRAP);
  1758. u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
  1759. E1000_STRAP_SMT_FREQ_SHIFT;
  1760. s32 ret_val;
  1761. strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
  1762. ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
  1763. if (ret_val)
  1764. return ret_val;
  1765. phy_data &= ~HV_SMB_ADDR_MASK;
  1766. phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
  1767. phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
  1768. if (hw->phy.type == e1000_phy_i217) {
  1769. /* Restore SMBus frequency */
  1770. if (freq--) {
  1771. phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
  1772. phy_data |= (freq & (1 << 0)) <<
  1773. HV_SMB_ADDR_FREQ_LOW_SHIFT;
  1774. phy_data |= (freq & (1 << 1)) <<
  1775. (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
  1776. } else {
  1777. e_dbg("Unsupported SMB frequency in PHY\n");
  1778. }
  1779. }
  1780. return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
  1781. }
  1782. /**
  1783. * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
  1784. * @hw: pointer to the HW structure
  1785. *
  1786. * SW should configure the LCD from the NVM extended configuration region
  1787. * as a workaround for certain parts.
  1788. **/
  1789. static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
  1790. {
  1791. struct e1000_phy_info *phy = &hw->phy;
  1792. u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
  1793. s32 ret_val = 0;
  1794. u16 word_addr, reg_data, reg_addr, phy_page = 0;
  1795. /* Initialize the PHY from the NVM on ICH platforms. This
  1796. * is needed due to an issue where the NVM configuration is
  1797. * not properly autoloaded after power transitions.
  1798. * Therefore, after each PHY reset, we will load the
  1799. * configuration data out of the NVM manually.
  1800. */
  1801. switch (hw->mac.type) {
  1802. case e1000_ich8lan:
  1803. if (phy->type != e1000_phy_igp_3)
  1804. return ret_val;
  1805. if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
  1806. (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
  1807. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
  1808. break;
  1809. }
  1810. /* Fall-thru */
  1811. case e1000_pchlan:
  1812. case e1000_pch2lan:
  1813. case e1000_pch_lpt:
  1814. case e1000_pch_spt:
  1815. sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
  1816. break;
  1817. default:
  1818. return ret_val;
  1819. }
  1820. ret_val = hw->phy.ops.acquire(hw);
  1821. if (ret_val)
  1822. return ret_val;
  1823. data = er32(FEXTNVM);
  1824. if (!(data & sw_cfg_mask))
  1825. goto release;
  1826. /* Make sure HW does not configure LCD from PHY
  1827. * extended configuration before SW configuration
  1828. */
  1829. data = er32(EXTCNF_CTRL);
  1830. if ((hw->mac.type < e1000_pch2lan) &&
  1831. (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
  1832. goto release;
  1833. cnf_size = er32(EXTCNF_SIZE);
  1834. cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
  1835. cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
  1836. if (!cnf_size)
  1837. goto release;
  1838. cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
  1839. cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
  1840. if (((hw->mac.type == e1000_pchlan) &&
  1841. !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
  1842. (hw->mac.type > e1000_pchlan)) {
  1843. /* HW configures the SMBus address and LEDs when the
  1844. * OEM and LCD Write Enable bits are set in the NVM.
  1845. * When both NVM bits are cleared, SW will configure
  1846. * them instead.
  1847. */
  1848. ret_val = e1000_write_smbus_addr(hw);
  1849. if (ret_val)
  1850. goto release;
  1851. data = er32(LEDCTL);
  1852. ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
  1853. (u16)data);
  1854. if (ret_val)
  1855. goto release;
  1856. }
  1857. /* Configure LCD from extended configuration region. */
  1858. /* cnf_base_addr is in DWORD */
  1859. word_addr = (u16)(cnf_base_addr << 1);
  1860. for (i = 0; i < cnf_size; i++) {
  1861. ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, &reg_data);
  1862. if (ret_val)
  1863. goto release;
  1864. ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
  1865. 1, &reg_addr);
  1866. if (ret_val)
  1867. goto release;
  1868. /* Save off the PHY page for future writes. */
  1869. if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
  1870. phy_page = reg_data;
  1871. continue;
  1872. }
  1873. reg_addr &= PHY_REG_MASK;
  1874. reg_addr |= phy_page;
  1875. ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data);
  1876. if (ret_val)
  1877. goto release;
  1878. }
  1879. release:
  1880. hw->phy.ops.release(hw);
  1881. return ret_val;
  1882. }
  1883. /**
  1884. * e1000_k1_gig_workaround_hv - K1 Si workaround
  1885. * @hw: pointer to the HW structure
  1886. * @link: link up bool flag
  1887. *
  1888. * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
  1889. * from a lower speed. This workaround disables K1 whenever link is at 1Gig
  1890. * If link is down, the function will restore the default K1 setting located
  1891. * in the NVM.
  1892. **/
  1893. static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
  1894. {
  1895. s32 ret_val = 0;
  1896. u16 status_reg = 0;
  1897. bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
  1898. if (hw->mac.type != e1000_pchlan)
  1899. return 0;
  1900. /* Wrap the whole flow with the sw flag */
  1901. ret_val = hw->phy.ops.acquire(hw);
  1902. if (ret_val)
  1903. return ret_val;
  1904. /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
  1905. if (link) {
  1906. if (hw->phy.type == e1000_phy_82578) {
  1907. ret_val = e1e_rphy_locked(hw, BM_CS_STATUS,
  1908. &status_reg);
  1909. if (ret_val)
  1910. goto release;
  1911. status_reg &= (BM_CS_STATUS_LINK_UP |
  1912. BM_CS_STATUS_RESOLVED |
  1913. BM_CS_STATUS_SPEED_MASK);
  1914. if (status_reg == (BM_CS_STATUS_LINK_UP |
  1915. BM_CS_STATUS_RESOLVED |
  1916. BM_CS_STATUS_SPEED_1000))
  1917. k1_enable = false;
  1918. }
  1919. if (hw->phy.type == e1000_phy_82577) {
  1920. ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg);
  1921. if (ret_val)
  1922. goto release;
  1923. status_reg &= (HV_M_STATUS_LINK_UP |
  1924. HV_M_STATUS_AUTONEG_COMPLETE |
  1925. HV_M_STATUS_SPEED_MASK);
  1926. if (status_reg == (HV_M_STATUS_LINK_UP |
  1927. HV_M_STATUS_AUTONEG_COMPLETE |
  1928. HV_M_STATUS_SPEED_1000))
  1929. k1_enable = false;
  1930. }
  1931. /* Link stall fix for link up */
  1932. ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100);
  1933. if (ret_val)
  1934. goto release;
  1935. } else {
  1936. /* Link stall fix for link down */
  1937. ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100);
  1938. if (ret_val)
  1939. goto release;
  1940. }
  1941. ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
  1942. release:
  1943. hw->phy.ops.release(hw);
  1944. return ret_val;
  1945. }
  1946. /**
  1947. * e1000_configure_k1_ich8lan - Configure K1 power state
  1948. * @hw: pointer to the HW structure
  1949. * @enable: K1 state to configure
  1950. *
  1951. * Configure the K1 power state based on the provided parameter.
  1952. * Assumes semaphore already acquired.
  1953. *
  1954. * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
  1955. **/
  1956. s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
  1957. {
  1958. s32 ret_val;
  1959. u32 ctrl_reg = 0;
  1960. u32 ctrl_ext = 0;
  1961. u32 reg = 0;
  1962. u16 kmrn_reg = 0;
  1963. ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
  1964. &kmrn_reg);
  1965. if (ret_val)
  1966. return ret_val;
  1967. if (k1_enable)
  1968. kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
  1969. else
  1970. kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
  1971. ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
  1972. kmrn_reg);
  1973. if (ret_val)
  1974. return ret_val;
  1975. usleep_range(20, 40);
  1976. ctrl_ext = er32(CTRL_EXT);
  1977. ctrl_reg = er32(CTRL);
  1978. reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
  1979. reg |= E1000_CTRL_FRCSPD;
  1980. ew32(CTRL, reg);
  1981. ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
  1982. e1e_flush();
  1983. usleep_range(20, 40);
  1984. ew32(CTRL, ctrl_reg);
  1985. ew32(CTRL_EXT, ctrl_ext);
  1986. e1e_flush();
  1987. usleep_range(20, 40);
  1988. return 0;
  1989. }
  1990. /**
  1991. * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
  1992. * @hw: pointer to the HW structure
  1993. * @d0_state: boolean if entering d0 or d3 device state
  1994. *
  1995. * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
  1996. * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
  1997. * in NVM determines whether HW should configure LPLU and Gbe Disable.
  1998. **/
  1999. static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
  2000. {
  2001. s32 ret_val = 0;
  2002. u32 mac_reg;
  2003. u16 oem_reg;
  2004. if (hw->mac.type < e1000_pchlan)
  2005. return ret_val;
  2006. ret_val = hw->phy.ops.acquire(hw);
  2007. if (ret_val)
  2008. return ret_val;
  2009. if (hw->mac.type == e1000_pchlan) {
  2010. mac_reg = er32(EXTCNF_CTRL);
  2011. if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
  2012. goto release;
  2013. }
  2014. mac_reg = er32(FEXTNVM);
  2015. if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
  2016. goto release;
  2017. mac_reg = er32(PHY_CTRL);
  2018. ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg);
  2019. if (ret_val)
  2020. goto release;
  2021. oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
  2022. if (d0_state) {
  2023. if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
  2024. oem_reg |= HV_OEM_BITS_GBE_DIS;
  2025. if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
  2026. oem_reg |= HV_OEM_BITS_LPLU;
  2027. } else {
  2028. if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
  2029. E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
  2030. oem_reg |= HV_OEM_BITS_GBE_DIS;
  2031. if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
  2032. E1000_PHY_CTRL_NOND0A_LPLU))
  2033. oem_reg |= HV_OEM_BITS_LPLU;
  2034. }
  2035. /* Set Restart auto-neg to activate the bits */
  2036. if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
  2037. !hw->phy.ops.check_reset_block(hw))
  2038. oem_reg |= HV_OEM_BITS_RESTART_AN;
  2039. ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg);
  2040. release:
  2041. hw->phy.ops.release(hw);
  2042. return ret_val;
  2043. }
  2044. /**
  2045. * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
  2046. * @hw: pointer to the HW structure
  2047. **/
  2048. static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
  2049. {
  2050. s32 ret_val;
  2051. u16 data;
  2052. ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
  2053. if (ret_val)
  2054. return ret_val;
  2055. data |= HV_KMRN_MDIO_SLOW;
  2056. ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
  2057. return ret_val;
  2058. }
  2059. /**
  2060. * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  2061. * done after every PHY reset.
  2062. **/
  2063. static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
  2064. {
  2065. s32 ret_val = 0;
  2066. u16 phy_data;
  2067. if (hw->mac.type != e1000_pchlan)
  2068. return 0;
  2069. /* Set MDIO slow mode before any other MDIO access */
  2070. if (hw->phy.type == e1000_phy_82577) {
  2071. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  2072. if (ret_val)
  2073. return ret_val;
  2074. }
  2075. if (((hw->phy.type == e1000_phy_82577) &&
  2076. ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
  2077. ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
  2078. /* Disable generation of early preamble */
  2079. ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
  2080. if (ret_val)
  2081. return ret_val;
  2082. /* Preamble tuning for SSC */
  2083. ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
  2084. if (ret_val)
  2085. return ret_val;
  2086. }
  2087. if (hw->phy.type == e1000_phy_82578) {
  2088. /* Return registers to default by doing a soft reset then
  2089. * writing 0x3140 to the control register.
  2090. */
  2091. if (hw->phy.revision < 2) {
  2092. e1000e_phy_sw_reset(hw);
  2093. ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
  2094. }
  2095. }
  2096. /* Select page 0 */
  2097. ret_val = hw->phy.ops.acquire(hw);
  2098. if (ret_val)
  2099. return ret_val;
  2100. hw->phy.addr = 1;
  2101. ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
  2102. hw->phy.ops.release(hw);
  2103. if (ret_val)
  2104. return ret_val;
  2105. /* Configure the K1 Si workaround during phy reset assuming there is
  2106. * link so that it disables K1 if link is in 1Gbps.
  2107. */
  2108. ret_val = e1000_k1_gig_workaround_hv(hw, true);
  2109. if (ret_val)
  2110. return ret_val;
  2111. /* Workaround for link disconnects on a busy hub in half duplex */
  2112. ret_val = hw->phy.ops.acquire(hw);
  2113. if (ret_val)
  2114. return ret_val;
  2115. ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data);
  2116. if (ret_val)
  2117. goto release;
  2118. ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF);
  2119. if (ret_val)
  2120. goto release;
  2121. /* set MSE higher to enable link to stay up when noise is high */
  2122. ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
  2123. release:
  2124. hw->phy.ops.release(hw);
  2125. return ret_val;
  2126. }
  2127. /**
  2128. * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
  2129. * @hw: pointer to the HW structure
  2130. **/
  2131. void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
  2132. {
  2133. u32 mac_reg;
  2134. u16 i, phy_reg = 0;
  2135. s32 ret_val;
  2136. ret_val = hw->phy.ops.acquire(hw);
  2137. if (ret_val)
  2138. return;
  2139. ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
  2140. if (ret_val)
  2141. goto release;
  2142. /* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
  2143. for (i = 0; i < (hw->mac.rar_entry_count); i++) {
  2144. mac_reg = er32(RAL(i));
  2145. hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
  2146. (u16)(mac_reg & 0xFFFF));
  2147. hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
  2148. (u16)((mac_reg >> 16) & 0xFFFF));
  2149. mac_reg = er32(RAH(i));
  2150. hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
  2151. (u16)(mac_reg & 0xFFFF));
  2152. hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
  2153. (u16)((mac_reg & E1000_RAH_AV)
  2154. >> 16));
  2155. }
  2156. e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
  2157. release:
  2158. hw->phy.ops.release(hw);
  2159. }
  2160. /**
  2161. * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
  2162. * with 82579 PHY
  2163. * @hw: pointer to the HW structure
  2164. * @enable: flag to enable/disable workaround when enabling/disabling jumbos
  2165. **/
  2166. s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
  2167. {
  2168. s32 ret_val = 0;
  2169. u16 phy_reg, data;
  2170. u32 mac_reg;
  2171. u16 i;
  2172. if (hw->mac.type < e1000_pch2lan)
  2173. return 0;
  2174. /* disable Rx path while enabling/disabling workaround */
  2175. e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
  2176. ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
  2177. if (ret_val)
  2178. return ret_val;
  2179. if (enable) {
  2180. /* Write Rx addresses (rar_entry_count for RAL/H, and
  2181. * SHRAL/H) and initial CRC values to the MAC
  2182. */
  2183. for (i = 0; i < hw->mac.rar_entry_count; i++) {
  2184. u8 mac_addr[ETH_ALEN] = { 0 };
  2185. u32 addr_high, addr_low;
  2186. addr_high = er32(RAH(i));
  2187. if (!(addr_high & E1000_RAH_AV))
  2188. continue;
  2189. addr_low = er32(RAL(i));
  2190. mac_addr[0] = (addr_low & 0xFF);
  2191. mac_addr[1] = ((addr_low >> 8) & 0xFF);
  2192. mac_addr[2] = ((addr_low >> 16) & 0xFF);
  2193. mac_addr[3] = ((addr_low >> 24) & 0xFF);
  2194. mac_addr[4] = (addr_high & 0xFF);
  2195. mac_addr[5] = ((addr_high >> 8) & 0xFF);
  2196. ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
  2197. }
  2198. /* Write Rx addresses to the PHY */
  2199. e1000_copy_rx_addrs_to_phy_ich8lan(hw);
  2200. /* Enable jumbo frame workaround in the MAC */
  2201. mac_reg = er32(FFLT_DBG);
  2202. mac_reg &= ~(1 << 14);
  2203. mac_reg |= (7 << 15);
  2204. ew32(FFLT_DBG, mac_reg);
  2205. mac_reg = er32(RCTL);
  2206. mac_reg |= E1000_RCTL_SECRC;
  2207. ew32(RCTL, mac_reg);
  2208. ret_val = e1000e_read_kmrn_reg(hw,
  2209. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  2210. &data);
  2211. if (ret_val)
  2212. return ret_val;
  2213. ret_val = e1000e_write_kmrn_reg(hw,
  2214. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  2215. data | (1 << 0));
  2216. if (ret_val)
  2217. return ret_val;
  2218. ret_val = e1000e_read_kmrn_reg(hw,
  2219. E1000_KMRNCTRLSTA_HD_CTRL,
  2220. &data);
  2221. if (ret_val)
  2222. return ret_val;
  2223. data &= ~(0xF << 8);
  2224. data |= (0xB << 8);
  2225. ret_val = e1000e_write_kmrn_reg(hw,
  2226. E1000_KMRNCTRLSTA_HD_CTRL,
  2227. data);
  2228. if (ret_val)
  2229. return ret_val;
  2230. /* Enable jumbo frame workaround in the PHY */
  2231. e1e_rphy(hw, PHY_REG(769, 23), &data);
  2232. data &= ~(0x7F << 5);
  2233. data |= (0x37 << 5);
  2234. ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
  2235. if (ret_val)
  2236. return ret_val;
  2237. e1e_rphy(hw, PHY_REG(769, 16), &data);
  2238. data &= ~(1 << 13);
  2239. ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
  2240. if (ret_val)
  2241. return ret_val;
  2242. e1e_rphy(hw, PHY_REG(776, 20), &data);
  2243. data &= ~(0x3FF << 2);
  2244. data |= (E1000_TX_PTR_GAP << 2);
  2245. ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
  2246. if (ret_val)
  2247. return ret_val;
  2248. ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
  2249. if (ret_val)
  2250. return ret_val;
  2251. e1e_rphy(hw, HV_PM_CTRL, &data);
  2252. ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
  2253. if (ret_val)
  2254. return ret_val;
  2255. } else {
  2256. /* Write MAC register values back to h/w defaults */
  2257. mac_reg = er32(FFLT_DBG);
  2258. mac_reg &= ~(0xF << 14);
  2259. ew32(FFLT_DBG, mac_reg);
  2260. mac_reg = er32(RCTL);
  2261. mac_reg &= ~E1000_RCTL_SECRC;
  2262. ew32(RCTL, mac_reg);
  2263. ret_val = e1000e_read_kmrn_reg(hw,
  2264. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  2265. &data);
  2266. if (ret_val)
  2267. return ret_val;
  2268. ret_val = e1000e_write_kmrn_reg(hw,
  2269. E1000_KMRNCTRLSTA_CTRL_OFFSET,
  2270. data & ~(1 << 0));
  2271. if (ret_val)
  2272. return ret_val;
  2273. ret_val = e1000e_read_kmrn_reg(hw,
  2274. E1000_KMRNCTRLSTA_HD_CTRL,
  2275. &data);
  2276. if (ret_val)
  2277. return ret_val;
  2278. data &= ~(0xF << 8);
  2279. data |= (0xB << 8);
  2280. ret_val = e1000e_write_kmrn_reg(hw,
  2281. E1000_KMRNCTRLSTA_HD_CTRL,
  2282. data);
  2283. if (ret_val)
  2284. return ret_val;
  2285. /* Write PHY register values back to h/w defaults */
  2286. e1e_rphy(hw, PHY_REG(769, 23), &data);
  2287. data &= ~(0x7F << 5);
  2288. ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
  2289. if (ret_val)
  2290. return ret_val;
  2291. e1e_rphy(hw, PHY_REG(769, 16), &data);
  2292. data |= (1 << 13);
  2293. ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
  2294. if (ret_val)
  2295. return ret_val;
  2296. e1e_rphy(hw, PHY_REG(776, 20), &data);
  2297. data &= ~(0x3FF << 2);
  2298. data |= (0x8 << 2);
  2299. ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
  2300. if (ret_val)
  2301. return ret_val;
  2302. ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
  2303. if (ret_val)
  2304. return ret_val;
  2305. e1e_rphy(hw, HV_PM_CTRL, &data);
  2306. ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
  2307. if (ret_val)
  2308. return ret_val;
  2309. }
  2310. /* re-enable Rx path after enabling/disabling workaround */
  2311. return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
  2312. }
  2313. /**
  2314. * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
  2315. * done after every PHY reset.
  2316. **/
  2317. static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
  2318. {
  2319. s32 ret_val = 0;
  2320. if (hw->mac.type != e1000_pch2lan)
  2321. return 0;
  2322. /* Set MDIO slow mode before any other MDIO access */
  2323. ret_val = e1000_set_mdio_slow_mode_hv(hw);
  2324. if (ret_val)
  2325. return ret_val;
  2326. ret_val = hw->phy.ops.acquire(hw);
  2327. if (ret_val)
  2328. return ret_val;
  2329. /* set MSE higher to enable link to stay up when noise is high */
  2330. ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
  2331. if (ret_val)
  2332. goto release;
  2333. /* drop link after 5 times MSE threshold was reached */
  2334. ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
  2335. release:
  2336. hw->phy.ops.release(hw);
  2337. return ret_val;
  2338. }
  2339. /**
  2340. * e1000_k1_gig_workaround_lv - K1 Si workaround
  2341. * @hw: pointer to the HW structure
  2342. *
  2343. * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
  2344. * Disable K1 in 1000Mbps and 100Mbps
  2345. **/
  2346. static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
  2347. {
  2348. s32 ret_val = 0;
  2349. u16 status_reg = 0;
  2350. if (hw->mac.type != e1000_pch2lan)
  2351. return 0;
  2352. /* Set K1 beacon duration based on 10Mbs speed */
  2353. ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
  2354. if (ret_val)
  2355. return ret_val;
  2356. if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
  2357. == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
  2358. if (status_reg &
  2359. (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
  2360. u16 pm_phy_reg;
  2361. /* LV 1G/100 Packet drop issue wa */
  2362. ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
  2363. if (ret_val)
  2364. return ret_val;
  2365. pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
  2366. ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
  2367. if (ret_val)
  2368. return ret_val;
  2369. } else {
  2370. u32 mac_reg;
  2371. mac_reg = er32(FEXTNVM4);
  2372. mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
  2373. mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
  2374. ew32(FEXTNVM4, mac_reg);
  2375. }
  2376. }
  2377. return ret_val;
  2378. }
  2379. /**
  2380. * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
  2381. * @hw: pointer to the HW structure
  2382. * @gate: boolean set to true to gate, false to ungate
  2383. *
  2384. * Gate/ungate the automatic PHY configuration via hardware; perform
  2385. * the configuration via software instead.
  2386. **/
  2387. static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
  2388. {
  2389. u32 extcnf_ctrl;
  2390. if (hw->mac.type < e1000_pch2lan)
  2391. return;
  2392. extcnf_ctrl = er32(EXTCNF_CTRL);
  2393. if (gate)
  2394. extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
  2395. else
  2396. extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
  2397. ew32(EXTCNF_CTRL, extcnf_ctrl);
  2398. }
  2399. /**
  2400. * e1000_lan_init_done_ich8lan - Check for PHY config completion
  2401. * @hw: pointer to the HW structure
  2402. *
  2403. * Check the appropriate indication the MAC has finished configuring the
  2404. * PHY after a software reset.
  2405. **/
  2406. static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
  2407. {
  2408. u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
  2409. /* Wait for basic configuration completes before proceeding */
  2410. do {
  2411. data = er32(STATUS);
  2412. data &= E1000_STATUS_LAN_INIT_DONE;
  2413. usleep_range(100, 200);
  2414. } while ((!data) && --loop);
  2415. /* If basic configuration is incomplete before the above loop
  2416. * count reaches 0, loading the configuration from NVM will
  2417. * leave the PHY in a bad state possibly resulting in no link.
  2418. */
  2419. if (loop == 0)
  2420. e_dbg("LAN_INIT_DONE not set, increase timeout\n");
  2421. /* Clear the Init Done bit for the next init event */
  2422. data = er32(STATUS);
  2423. data &= ~E1000_STATUS_LAN_INIT_DONE;
  2424. ew32(STATUS, data);
  2425. }
  2426. /**
  2427. * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
  2428. * @hw: pointer to the HW structure
  2429. **/
  2430. static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
  2431. {
  2432. s32 ret_val = 0;
  2433. u16 reg;
  2434. if (hw->phy.ops.check_reset_block(hw))
  2435. return 0;
  2436. /* Allow time for h/w to get to quiescent state after reset */
  2437. usleep_range(10000, 20000);
  2438. /* Perform any necessary post-reset workarounds */
  2439. switch (hw->mac.type) {
  2440. case e1000_pchlan:
  2441. ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
  2442. if (ret_val)
  2443. return ret_val;
  2444. break;
  2445. case e1000_pch2lan:
  2446. ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
  2447. if (ret_val)
  2448. return ret_val;
  2449. break;
  2450. default:
  2451. break;
  2452. }
  2453. /* Clear the host wakeup bit after lcd reset */
  2454. if (hw->mac.type >= e1000_pchlan) {
  2455. e1e_rphy(hw, BM_PORT_GEN_CFG, &reg);
  2456. reg &= ~BM_WUC_HOST_WU_BIT;
  2457. e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
  2458. }
  2459. /* Configure the LCD with the extended configuration region in NVM */
  2460. ret_val = e1000_sw_lcd_config_ich8lan(hw);
  2461. if (ret_val)
  2462. return ret_val;
  2463. /* Configure the LCD with the OEM bits in NVM */
  2464. ret_val = e1000_oem_bits_config_ich8lan(hw, true);
  2465. if (hw->mac.type == e1000_pch2lan) {
  2466. /* Ungate automatic PHY configuration on non-managed 82579 */
  2467. if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
  2468. usleep_range(10000, 20000);
  2469. e1000_gate_hw_phy_config_ich8lan(hw, false);
  2470. }
  2471. /* Set EEE LPI Update Timer to 200usec */
  2472. ret_val = hw->phy.ops.acquire(hw);
  2473. if (ret_val)
  2474. return ret_val;
  2475. ret_val = e1000_write_emi_reg_locked(hw,
  2476. I82579_LPI_UPDATE_TIMER,
  2477. 0x1387);
  2478. hw->phy.ops.release(hw);
  2479. }
  2480. return ret_val;
  2481. }
  2482. /**
  2483. * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
  2484. * @hw: pointer to the HW structure
  2485. *
  2486. * Resets the PHY
  2487. * This is a function pointer entry point called by drivers
  2488. * or other shared routines.
  2489. **/
  2490. static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  2491. {
  2492. s32 ret_val = 0;
  2493. /* Gate automatic PHY configuration by hardware on non-managed 82579 */
  2494. if ((hw->mac.type == e1000_pch2lan) &&
  2495. !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  2496. e1000_gate_hw_phy_config_ich8lan(hw, true);
  2497. ret_val = e1000e_phy_hw_reset_generic(hw);
  2498. if (ret_val)
  2499. return ret_val;
  2500. return e1000_post_phy_reset_ich8lan(hw);
  2501. }
  2502. /**
  2503. * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
  2504. * @hw: pointer to the HW structure
  2505. * @active: true to enable LPLU, false to disable
  2506. *
  2507. * Sets the LPLU state according to the active flag. For PCH, if OEM write
  2508. * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
  2509. * the phy speed. This function will manually set the LPLU bit and restart
  2510. * auto-neg as hw would do. D3 and D0 LPLU will call the same function
  2511. * since it configures the same bit.
  2512. **/
  2513. static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
  2514. {
  2515. s32 ret_val;
  2516. u16 oem_reg;
  2517. ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
  2518. if (ret_val)
  2519. return ret_val;
  2520. if (active)
  2521. oem_reg |= HV_OEM_BITS_LPLU;
  2522. else
  2523. oem_reg &= ~HV_OEM_BITS_LPLU;
  2524. if (!hw->phy.ops.check_reset_block(hw))
  2525. oem_reg |= HV_OEM_BITS_RESTART_AN;
  2526. return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
  2527. }
  2528. /**
  2529. * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
  2530. * @hw: pointer to the HW structure
  2531. * @active: true to enable LPLU, false to disable
  2532. *
  2533. * Sets the LPLU D0 state according to the active flag. When
  2534. * activating LPLU this function also disables smart speed
  2535. * and vice versa. LPLU will not be activated unless the
  2536. * device autonegotiation advertisement meets standards of
  2537. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  2538. * This is a function pointer entry point only called by
  2539. * PHY setup routines.
  2540. **/
  2541. static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  2542. {
  2543. struct e1000_phy_info *phy = &hw->phy;
  2544. u32 phy_ctrl;
  2545. s32 ret_val = 0;
  2546. u16 data;
  2547. if (phy->type == e1000_phy_ife)
  2548. return 0;
  2549. phy_ctrl = er32(PHY_CTRL);
  2550. if (active) {
  2551. phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
  2552. ew32(PHY_CTRL, phy_ctrl);
  2553. if (phy->type != e1000_phy_igp_3)
  2554. return 0;
  2555. /* Call gig speed drop workaround on LPLU before accessing
  2556. * any PHY registers
  2557. */
  2558. if (hw->mac.type == e1000_ich8lan)
  2559. e1000e_gig_downshift_workaround_ich8lan(hw);
  2560. /* When LPLU is enabled, we should disable SmartSpeed */
  2561. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  2562. if (ret_val)
  2563. return ret_val;
  2564. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  2565. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  2566. if (ret_val)
  2567. return ret_val;
  2568. } else {
  2569. phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
  2570. ew32(PHY_CTRL, phy_ctrl);
  2571. if (phy->type != e1000_phy_igp_3)
  2572. return 0;
  2573. /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
  2574. * during Dx states where the power conservation is most
  2575. * important. During driver activity we should enable
  2576. * SmartSpeed, so performance is maintained.
  2577. */
  2578. if (phy->smart_speed == e1000_smart_speed_on) {
  2579. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2580. &data);
  2581. if (ret_val)
  2582. return ret_val;
  2583. data |= IGP01E1000_PSCFR_SMART_SPEED;
  2584. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2585. data);
  2586. if (ret_val)
  2587. return ret_val;
  2588. } else if (phy->smart_speed == e1000_smart_speed_off) {
  2589. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2590. &data);
  2591. if (ret_val)
  2592. return ret_val;
  2593. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  2594. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2595. data);
  2596. if (ret_val)
  2597. return ret_val;
  2598. }
  2599. }
  2600. return 0;
  2601. }
  2602. /**
  2603. * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
  2604. * @hw: pointer to the HW structure
  2605. * @active: true to enable LPLU, false to disable
  2606. *
  2607. * Sets the LPLU D3 state according to the active flag. When
  2608. * activating LPLU this function also disables smart speed
  2609. * and vice versa. LPLU will not be activated unless the
  2610. * device autonegotiation advertisement meets standards of
  2611. * either 10 or 10/100 or 10/100/1000 at all duplexes.
  2612. * This is a function pointer entry point only called by
  2613. * PHY setup routines.
  2614. **/
  2615. static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
  2616. {
  2617. struct e1000_phy_info *phy = &hw->phy;
  2618. u32 phy_ctrl;
  2619. s32 ret_val = 0;
  2620. u16 data;
  2621. phy_ctrl = er32(PHY_CTRL);
  2622. if (!active) {
  2623. phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
  2624. ew32(PHY_CTRL, phy_ctrl);
  2625. if (phy->type != e1000_phy_igp_3)
  2626. return 0;
  2627. /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
  2628. * during Dx states where the power conservation is most
  2629. * important. During driver activity we should enable
  2630. * SmartSpeed, so performance is maintained.
  2631. */
  2632. if (phy->smart_speed == e1000_smart_speed_on) {
  2633. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2634. &data);
  2635. if (ret_val)
  2636. return ret_val;
  2637. data |= IGP01E1000_PSCFR_SMART_SPEED;
  2638. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2639. data);
  2640. if (ret_val)
  2641. return ret_val;
  2642. } else if (phy->smart_speed == e1000_smart_speed_off) {
  2643. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2644. &data);
  2645. if (ret_val)
  2646. return ret_val;
  2647. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  2648. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
  2649. data);
  2650. if (ret_val)
  2651. return ret_val;
  2652. }
  2653. } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
  2654. (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
  2655. (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
  2656. phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
  2657. ew32(PHY_CTRL, phy_ctrl);
  2658. if (phy->type != e1000_phy_igp_3)
  2659. return 0;
  2660. /* Call gig speed drop workaround on LPLU before accessing
  2661. * any PHY registers
  2662. */
  2663. if (hw->mac.type == e1000_ich8lan)
  2664. e1000e_gig_downshift_workaround_ich8lan(hw);
  2665. /* When LPLU is enabled, we should disable SmartSpeed */
  2666. ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
  2667. if (ret_val)
  2668. return ret_val;
  2669. data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  2670. ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
  2671. }
  2672. return ret_val;
  2673. }
  2674. /**
  2675. * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
  2676. * @hw: pointer to the HW structure
  2677. * @bank: pointer to the variable that returns the active bank
  2678. *
  2679. * Reads signature byte from the NVM using the flash access registers.
  2680. * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
  2681. **/
  2682. static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
  2683. {
  2684. u32 eecd;
  2685. struct e1000_nvm_info *nvm = &hw->nvm;
  2686. u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
  2687. u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
  2688. u32 nvm_dword = 0;
  2689. u8 sig_byte = 0;
  2690. s32 ret_val;
  2691. switch (hw->mac.type) {
  2692. case e1000_pch_spt:
  2693. bank1_offset = nvm->flash_bank_size;
  2694. act_offset = E1000_ICH_NVM_SIG_WORD;
  2695. /* set bank to 0 in case flash read fails */
  2696. *bank = 0;
  2697. /* Check bank 0 */
  2698. ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset,
  2699. &nvm_dword);
  2700. if (ret_val)
  2701. return ret_val;
  2702. sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
  2703. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  2704. E1000_ICH_NVM_SIG_VALUE) {
  2705. *bank = 0;
  2706. return 0;
  2707. }
  2708. /* Check bank 1 */
  2709. ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset +
  2710. bank1_offset,
  2711. &nvm_dword);
  2712. if (ret_val)
  2713. return ret_val;
  2714. sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
  2715. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  2716. E1000_ICH_NVM_SIG_VALUE) {
  2717. *bank = 1;
  2718. return 0;
  2719. }
  2720. e_dbg("ERROR: No valid NVM bank present\n");
  2721. return -E1000_ERR_NVM;
  2722. case e1000_ich8lan:
  2723. case e1000_ich9lan:
  2724. eecd = er32(EECD);
  2725. if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
  2726. E1000_EECD_SEC1VAL_VALID_MASK) {
  2727. if (eecd & E1000_EECD_SEC1VAL)
  2728. *bank = 1;
  2729. else
  2730. *bank = 0;
  2731. return 0;
  2732. }
  2733. e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
  2734. /* fall-thru */
  2735. default:
  2736. /* set bank to 0 in case flash read fails */
  2737. *bank = 0;
  2738. /* Check bank 0 */
  2739. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
  2740. &sig_byte);
  2741. if (ret_val)
  2742. return ret_val;
  2743. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  2744. E1000_ICH_NVM_SIG_VALUE) {
  2745. *bank = 0;
  2746. return 0;
  2747. }
  2748. /* Check bank 1 */
  2749. ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
  2750. bank1_offset,
  2751. &sig_byte);
  2752. if (ret_val)
  2753. return ret_val;
  2754. if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
  2755. E1000_ICH_NVM_SIG_VALUE) {
  2756. *bank = 1;
  2757. return 0;
  2758. }
  2759. e_dbg("ERROR: No valid NVM bank present\n");
  2760. return -E1000_ERR_NVM;
  2761. }
  2762. }
  2763. /**
  2764. * e1000_read_nvm_spt - NVM access for SPT
  2765. * @hw: pointer to the HW structure
  2766. * @offset: The offset (in bytes) of the word(s) to read.
  2767. * @words: Size of data to read in words.
  2768. * @data: pointer to the word(s) to read at offset.
  2769. *
  2770. * Reads a word(s) from the NVM
  2771. **/
  2772. static s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
  2773. u16 *data)
  2774. {
  2775. struct e1000_nvm_info *nvm = &hw->nvm;
  2776. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2777. u32 act_offset;
  2778. s32 ret_val = 0;
  2779. u32 bank = 0;
  2780. u32 dword = 0;
  2781. u16 offset_to_read;
  2782. u16 i;
  2783. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  2784. (words == 0)) {
  2785. e_dbg("nvm parameter(s) out of bounds\n");
  2786. ret_val = -E1000_ERR_NVM;
  2787. goto out;
  2788. }
  2789. nvm->ops.acquire(hw);
  2790. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  2791. if (ret_val) {
  2792. e_dbg("Could not detect valid bank, assuming bank 0\n");
  2793. bank = 0;
  2794. }
  2795. act_offset = (bank) ? nvm->flash_bank_size : 0;
  2796. act_offset += offset;
  2797. ret_val = 0;
  2798. for (i = 0; i < words; i += 2) {
  2799. if (words - i == 1) {
  2800. if (dev_spec->shadow_ram[offset + i].modified) {
  2801. data[i] =
  2802. dev_spec->shadow_ram[offset + i].value;
  2803. } else {
  2804. offset_to_read = act_offset + i -
  2805. ((act_offset + i) % 2);
  2806. ret_val =
  2807. e1000_read_flash_dword_ich8lan(hw,
  2808. offset_to_read,
  2809. &dword);
  2810. if (ret_val)
  2811. break;
  2812. if ((act_offset + i) % 2 == 0)
  2813. data[i] = (u16)(dword & 0xFFFF);
  2814. else
  2815. data[i] = (u16)((dword >> 16) & 0xFFFF);
  2816. }
  2817. } else {
  2818. offset_to_read = act_offset + i;
  2819. if (!(dev_spec->shadow_ram[offset + i].modified) ||
  2820. !(dev_spec->shadow_ram[offset + i + 1].modified)) {
  2821. ret_val =
  2822. e1000_read_flash_dword_ich8lan(hw,
  2823. offset_to_read,
  2824. &dword);
  2825. if (ret_val)
  2826. break;
  2827. }
  2828. if (dev_spec->shadow_ram[offset + i].modified)
  2829. data[i] =
  2830. dev_spec->shadow_ram[offset + i].value;
  2831. else
  2832. data[i] = (u16)(dword & 0xFFFF);
  2833. if (dev_spec->shadow_ram[offset + i].modified)
  2834. data[i + 1] =
  2835. dev_spec->shadow_ram[offset + i + 1].value;
  2836. else
  2837. data[i + 1] = (u16)(dword >> 16 & 0xFFFF);
  2838. }
  2839. }
  2840. nvm->ops.release(hw);
  2841. out:
  2842. if (ret_val)
  2843. e_dbg("NVM read error: %d\n", ret_val);
  2844. return ret_val;
  2845. }
  2846. /**
  2847. * e1000_read_nvm_ich8lan - Read word(s) from the NVM
  2848. * @hw: pointer to the HW structure
  2849. * @offset: The offset (in bytes) of the word(s) to read.
  2850. * @words: Size of data to read in words
  2851. * @data: Pointer to the word(s) to read at offset.
  2852. *
  2853. * Reads a word(s) from the NVM using the flash access registers.
  2854. **/
  2855. static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  2856. u16 *data)
  2857. {
  2858. struct e1000_nvm_info *nvm = &hw->nvm;
  2859. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  2860. u32 act_offset;
  2861. s32 ret_val = 0;
  2862. u32 bank = 0;
  2863. u16 i, word;
  2864. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  2865. (words == 0)) {
  2866. e_dbg("nvm parameter(s) out of bounds\n");
  2867. ret_val = -E1000_ERR_NVM;
  2868. goto out;
  2869. }
  2870. nvm->ops.acquire(hw);
  2871. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  2872. if (ret_val) {
  2873. e_dbg("Could not detect valid bank, assuming bank 0\n");
  2874. bank = 0;
  2875. }
  2876. act_offset = (bank) ? nvm->flash_bank_size : 0;
  2877. act_offset += offset;
  2878. ret_val = 0;
  2879. for (i = 0; i < words; i++) {
  2880. if (dev_spec->shadow_ram[offset + i].modified) {
  2881. data[i] = dev_spec->shadow_ram[offset + i].value;
  2882. } else {
  2883. ret_val = e1000_read_flash_word_ich8lan(hw,
  2884. act_offset + i,
  2885. &word);
  2886. if (ret_val)
  2887. break;
  2888. data[i] = word;
  2889. }
  2890. }
  2891. nvm->ops.release(hw);
  2892. out:
  2893. if (ret_val)
  2894. e_dbg("NVM read error: %d\n", ret_val);
  2895. return ret_val;
  2896. }
  2897. /**
  2898. * e1000_flash_cycle_init_ich8lan - Initialize flash
  2899. * @hw: pointer to the HW structure
  2900. *
  2901. * This function does initial flash setup so that a new read/write/erase cycle
  2902. * can be started.
  2903. **/
  2904. static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
  2905. {
  2906. union ich8_hws_flash_status hsfsts;
  2907. s32 ret_val = -E1000_ERR_NVM;
  2908. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2909. /* Check if the flash descriptor is valid */
  2910. if (!hsfsts.hsf_status.fldesvalid) {
  2911. e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
  2912. return -E1000_ERR_NVM;
  2913. }
  2914. /* Clear FCERR and DAEL in hw status by writing 1 */
  2915. hsfsts.hsf_status.flcerr = 1;
  2916. hsfsts.hsf_status.dael = 1;
  2917. if (hw->mac.type == e1000_pch_spt)
  2918. ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval & 0xFFFF);
  2919. else
  2920. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  2921. /* Either we should have a hardware SPI cycle in progress
  2922. * bit to check against, in order to start a new cycle or
  2923. * FDONE bit should be changed in the hardware so that it
  2924. * is 1 after hardware reset, which can then be used as an
  2925. * indication whether a cycle is in progress or has been
  2926. * completed.
  2927. */
  2928. if (!hsfsts.hsf_status.flcinprog) {
  2929. /* There is no cycle running at present,
  2930. * so we can start a cycle.
  2931. * Begin by setting Flash Cycle Done.
  2932. */
  2933. hsfsts.hsf_status.flcdone = 1;
  2934. if (hw->mac.type == e1000_pch_spt)
  2935. ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval & 0xFFFF);
  2936. else
  2937. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  2938. ret_val = 0;
  2939. } else {
  2940. s32 i;
  2941. /* Otherwise poll for sometime so the current
  2942. * cycle has a chance to end before giving up.
  2943. */
  2944. for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
  2945. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2946. if (!hsfsts.hsf_status.flcinprog) {
  2947. ret_val = 0;
  2948. break;
  2949. }
  2950. udelay(1);
  2951. }
  2952. if (!ret_val) {
  2953. /* Successful in waiting for previous cycle to timeout,
  2954. * now set the Flash Cycle Done.
  2955. */
  2956. hsfsts.hsf_status.flcdone = 1;
  2957. if (hw->mac.type == e1000_pch_spt)
  2958. ew32flash(ICH_FLASH_HSFSTS,
  2959. hsfsts.regval & 0xFFFF);
  2960. else
  2961. ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  2962. } else {
  2963. e_dbg("Flash controller busy, cannot get access\n");
  2964. }
  2965. }
  2966. return ret_val;
  2967. }
  2968. /**
  2969. * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
  2970. * @hw: pointer to the HW structure
  2971. * @timeout: maximum time to wait for completion
  2972. *
  2973. * This function starts a flash cycle and waits for its completion.
  2974. **/
  2975. static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
  2976. {
  2977. union ich8_hws_flash_ctrl hsflctl;
  2978. union ich8_hws_flash_status hsfsts;
  2979. u32 i = 0;
  2980. /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
  2981. if (hw->mac.type == e1000_pch_spt)
  2982. hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
  2983. else
  2984. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  2985. hsflctl.hsf_ctrl.flcgo = 1;
  2986. if (hw->mac.type == e1000_pch_spt)
  2987. ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
  2988. else
  2989. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  2990. /* wait till FDONE bit is set to 1 */
  2991. do {
  2992. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  2993. if (hsfsts.hsf_status.flcdone)
  2994. break;
  2995. udelay(1);
  2996. } while (i++ < timeout);
  2997. if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
  2998. return 0;
  2999. return -E1000_ERR_NVM;
  3000. }
  3001. /**
  3002. * e1000_read_flash_dword_ich8lan - Read dword from flash
  3003. * @hw: pointer to the HW structure
  3004. * @offset: offset to data location
  3005. * @data: pointer to the location for storing the data
  3006. *
  3007. * Reads the flash dword at offset into data. Offset is converted
  3008. * to bytes before read.
  3009. **/
  3010. static s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw, u32 offset,
  3011. u32 *data)
  3012. {
  3013. /* Must convert word offset into bytes. */
  3014. offset <<= 1;
  3015. return e1000_read_flash_data32_ich8lan(hw, offset, data);
  3016. }
  3017. /**
  3018. * e1000_read_flash_word_ich8lan - Read word from flash
  3019. * @hw: pointer to the HW structure
  3020. * @offset: offset to data location
  3021. * @data: pointer to the location for storing the data
  3022. *
  3023. * Reads the flash word at offset into data. Offset is converted
  3024. * to bytes before read.
  3025. **/
  3026. static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
  3027. u16 *data)
  3028. {
  3029. /* Must convert offset into bytes. */
  3030. offset <<= 1;
  3031. return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
  3032. }
  3033. /**
  3034. * e1000_read_flash_byte_ich8lan - Read byte from flash
  3035. * @hw: pointer to the HW structure
  3036. * @offset: The offset of the byte to read.
  3037. * @data: Pointer to a byte to store the value read.
  3038. *
  3039. * Reads a single byte from the NVM using the flash access registers.
  3040. **/
  3041. static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  3042. u8 *data)
  3043. {
  3044. s32 ret_val;
  3045. u16 word = 0;
  3046. /* In SPT, only 32 bits access is supported,
  3047. * so this function should not be called.
  3048. */
  3049. if (hw->mac.type == e1000_pch_spt)
  3050. return -E1000_ERR_NVM;
  3051. else
  3052. ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
  3053. if (ret_val)
  3054. return ret_val;
  3055. *data = (u8)word;
  3056. return 0;
  3057. }
  3058. /**
  3059. * e1000_read_flash_data_ich8lan - Read byte or word from NVM
  3060. * @hw: pointer to the HW structure
  3061. * @offset: The offset (in bytes) of the byte or word to read.
  3062. * @size: Size of data to read, 1=byte 2=word
  3063. * @data: Pointer to the word to store the value read.
  3064. *
  3065. * Reads a byte or word from the NVM using the flash access registers.
  3066. **/
  3067. static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  3068. u8 size, u16 *data)
  3069. {
  3070. union ich8_hws_flash_status hsfsts;
  3071. union ich8_hws_flash_ctrl hsflctl;
  3072. u32 flash_linear_addr;
  3073. u32 flash_data = 0;
  3074. s32 ret_val = -E1000_ERR_NVM;
  3075. u8 count = 0;
  3076. if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  3077. return -E1000_ERR_NVM;
  3078. flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  3079. hw->nvm.flash_base_addr);
  3080. do {
  3081. udelay(1);
  3082. /* Steps */
  3083. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  3084. if (ret_val)
  3085. break;
  3086. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  3087. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  3088. hsflctl.hsf_ctrl.fldbcount = size - 1;
  3089. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
  3090. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  3091. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  3092. ret_val =
  3093. e1000_flash_cycle_ich8lan(hw,
  3094. ICH_FLASH_READ_COMMAND_TIMEOUT);
  3095. /* Check if FCERR is set to 1, if set to 1, clear it
  3096. * and try the whole sequence a few more times, else
  3097. * read in (shift in) the Flash Data0, the order is
  3098. * least significant byte first msb to lsb
  3099. */
  3100. if (!ret_val) {
  3101. flash_data = er32flash(ICH_FLASH_FDATA0);
  3102. if (size == 1)
  3103. *data = (u8)(flash_data & 0x000000FF);
  3104. else if (size == 2)
  3105. *data = (u16)(flash_data & 0x0000FFFF);
  3106. break;
  3107. } else {
  3108. /* If we've gotten here, then things are probably
  3109. * completely hosed, but if the error condition is
  3110. * detected, it won't hurt to give it another try...
  3111. * ICH_FLASH_CYCLE_REPEAT_COUNT times.
  3112. */
  3113. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3114. if (hsfsts.hsf_status.flcerr) {
  3115. /* Repeat for some time before giving up. */
  3116. continue;
  3117. } else if (!hsfsts.hsf_status.flcdone) {
  3118. e_dbg("Timeout error - flash cycle did not complete.\n");
  3119. break;
  3120. }
  3121. }
  3122. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  3123. return ret_val;
  3124. }
  3125. /**
  3126. * e1000_read_flash_data32_ich8lan - Read dword from NVM
  3127. * @hw: pointer to the HW structure
  3128. * @offset: The offset (in bytes) of the dword to read.
  3129. * @data: Pointer to the dword to store the value read.
  3130. *
  3131. * Reads a byte or word from the NVM using the flash access registers.
  3132. **/
  3133. static s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
  3134. u32 *data)
  3135. {
  3136. union ich8_hws_flash_status hsfsts;
  3137. union ich8_hws_flash_ctrl hsflctl;
  3138. u32 flash_linear_addr;
  3139. s32 ret_val = -E1000_ERR_NVM;
  3140. u8 count = 0;
  3141. if (offset > ICH_FLASH_LINEAR_ADDR_MASK ||
  3142. hw->mac.type != e1000_pch_spt)
  3143. return -E1000_ERR_NVM;
  3144. flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  3145. hw->nvm.flash_base_addr);
  3146. do {
  3147. udelay(1);
  3148. /* Steps */
  3149. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  3150. if (ret_val)
  3151. break;
  3152. /* In SPT, This register is in Lan memory space, not flash.
  3153. * Therefore, only 32 bit access is supported
  3154. */
  3155. hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
  3156. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  3157. hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
  3158. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
  3159. /* In SPT, This register is in Lan memory space, not flash.
  3160. * Therefore, only 32 bit access is supported
  3161. */
  3162. ew32flash(ICH_FLASH_HSFSTS, (u32)hsflctl.regval << 16);
  3163. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  3164. ret_val =
  3165. e1000_flash_cycle_ich8lan(hw,
  3166. ICH_FLASH_READ_COMMAND_TIMEOUT);
  3167. /* Check if FCERR is set to 1, if set to 1, clear it
  3168. * and try the whole sequence a few more times, else
  3169. * read in (shift in) the Flash Data0, the order is
  3170. * least significant byte first msb to lsb
  3171. */
  3172. if (!ret_val) {
  3173. *data = er32flash(ICH_FLASH_FDATA0);
  3174. break;
  3175. } else {
  3176. /* If we've gotten here, then things are probably
  3177. * completely hosed, but if the error condition is
  3178. * detected, it won't hurt to give it another try...
  3179. * ICH_FLASH_CYCLE_REPEAT_COUNT times.
  3180. */
  3181. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3182. if (hsfsts.hsf_status.flcerr) {
  3183. /* Repeat for some time before giving up. */
  3184. continue;
  3185. } else if (!hsfsts.hsf_status.flcdone) {
  3186. e_dbg("Timeout error - flash cycle did not complete.\n");
  3187. break;
  3188. }
  3189. }
  3190. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  3191. return ret_val;
  3192. }
  3193. /**
  3194. * e1000_write_nvm_ich8lan - Write word(s) to the NVM
  3195. * @hw: pointer to the HW structure
  3196. * @offset: The offset (in bytes) of the word(s) to write.
  3197. * @words: Size of data to write in words
  3198. * @data: Pointer to the word(s) to write at offset.
  3199. *
  3200. * Writes a byte or word to the NVM using the flash access registers.
  3201. **/
  3202. static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
  3203. u16 *data)
  3204. {
  3205. struct e1000_nvm_info *nvm = &hw->nvm;
  3206. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  3207. u16 i;
  3208. if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
  3209. (words == 0)) {
  3210. e_dbg("nvm parameter(s) out of bounds\n");
  3211. return -E1000_ERR_NVM;
  3212. }
  3213. nvm->ops.acquire(hw);
  3214. for (i = 0; i < words; i++) {
  3215. dev_spec->shadow_ram[offset + i].modified = true;
  3216. dev_spec->shadow_ram[offset + i].value = data[i];
  3217. }
  3218. nvm->ops.release(hw);
  3219. return 0;
  3220. }
  3221. /**
  3222. * e1000_update_nvm_checksum_spt - Update the checksum for NVM
  3223. * @hw: pointer to the HW structure
  3224. *
  3225. * The NVM checksum is updated by calling the generic update_nvm_checksum,
  3226. * which writes the checksum to the shadow ram. The changes in the shadow
  3227. * ram are then committed to the EEPROM by processing each bank at a time
  3228. * checking for the modified bit and writing only the pending changes.
  3229. * After a successful commit, the shadow ram is cleared and is ready for
  3230. * future writes.
  3231. **/
  3232. static s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw)
  3233. {
  3234. struct e1000_nvm_info *nvm = &hw->nvm;
  3235. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  3236. u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
  3237. s32 ret_val;
  3238. u32 dword = 0;
  3239. ret_val = e1000e_update_nvm_checksum_generic(hw);
  3240. if (ret_val)
  3241. goto out;
  3242. if (nvm->type != e1000_nvm_flash_sw)
  3243. goto out;
  3244. nvm->ops.acquire(hw);
  3245. /* We're writing to the opposite bank so if we're on bank 1,
  3246. * write to bank 0 etc. We also need to erase the segment that
  3247. * is going to be written
  3248. */
  3249. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  3250. if (ret_val) {
  3251. e_dbg("Could not detect valid bank, assuming bank 0\n");
  3252. bank = 0;
  3253. }
  3254. if (bank == 0) {
  3255. new_bank_offset = nvm->flash_bank_size;
  3256. old_bank_offset = 0;
  3257. ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
  3258. if (ret_val)
  3259. goto release;
  3260. } else {
  3261. old_bank_offset = nvm->flash_bank_size;
  3262. new_bank_offset = 0;
  3263. ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
  3264. if (ret_val)
  3265. goto release;
  3266. }
  3267. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i += 2) {
  3268. /* Determine whether to write the value stored
  3269. * in the other NVM bank or a modified value stored
  3270. * in the shadow RAM
  3271. */
  3272. ret_val = e1000_read_flash_dword_ich8lan(hw,
  3273. i + old_bank_offset,
  3274. &dword);
  3275. if (dev_spec->shadow_ram[i].modified) {
  3276. dword &= 0xffff0000;
  3277. dword |= (dev_spec->shadow_ram[i].value & 0xffff);
  3278. }
  3279. if (dev_spec->shadow_ram[i + 1].modified) {
  3280. dword &= 0x0000ffff;
  3281. dword |= ((dev_spec->shadow_ram[i + 1].value & 0xffff)
  3282. << 16);
  3283. }
  3284. if (ret_val)
  3285. break;
  3286. /* If the word is 0x13, then make sure the signature bits
  3287. * (15:14) are 11b until the commit has completed.
  3288. * This will allow us to write 10b which indicates the
  3289. * signature is valid. We want to do this after the write
  3290. * has completed so that we don't mark the segment valid
  3291. * while the write is still in progress
  3292. */
  3293. if (i == E1000_ICH_NVM_SIG_WORD - 1)
  3294. dword |= E1000_ICH_NVM_SIG_MASK << 16;
  3295. /* Convert offset to bytes. */
  3296. act_offset = (i + new_bank_offset) << 1;
  3297. usleep_range(100, 200);
  3298. /* Write the data to the new bank. Offset in words */
  3299. act_offset = i + new_bank_offset;
  3300. ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset,
  3301. dword);
  3302. if (ret_val)
  3303. break;
  3304. }
  3305. /* Don't bother writing the segment valid bits if sector
  3306. * programming failed.
  3307. */
  3308. if (ret_val) {
  3309. /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
  3310. e_dbg("Flash commit failed.\n");
  3311. goto release;
  3312. }
  3313. /* Finally validate the new segment by setting bit 15:14
  3314. * to 10b in word 0x13 , this can be done without an
  3315. * erase as well since these bits are 11 to start with
  3316. * and we need to change bit 14 to 0b
  3317. */
  3318. act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
  3319. /*offset in words but we read dword */
  3320. --act_offset;
  3321. ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
  3322. if (ret_val)
  3323. goto release;
  3324. dword &= 0xBFFFFFFF;
  3325. ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
  3326. if (ret_val)
  3327. goto release;
  3328. /* And invalidate the previously valid segment by setting
  3329. * its signature word (0x13) high_byte to 0b. This can be
  3330. * done without an erase because flash erase sets all bits
  3331. * to 1's. We can write 1's to 0's without an erase
  3332. */
  3333. act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
  3334. /* offset in words but we read dword */
  3335. act_offset = old_bank_offset + E1000_ICH_NVM_SIG_WORD - 1;
  3336. ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
  3337. if (ret_val)
  3338. goto release;
  3339. dword &= 0x00FFFFFF;
  3340. ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
  3341. if (ret_val)
  3342. goto release;
  3343. /* Great! Everything worked, we can now clear the cached entries. */
  3344. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  3345. dev_spec->shadow_ram[i].modified = false;
  3346. dev_spec->shadow_ram[i].value = 0xFFFF;
  3347. }
  3348. release:
  3349. nvm->ops.release(hw);
  3350. /* Reload the EEPROM, or else modifications will not appear
  3351. * until after the next adapter reset.
  3352. */
  3353. if (!ret_val) {
  3354. nvm->ops.reload(hw);
  3355. usleep_range(10000, 20000);
  3356. }
  3357. out:
  3358. if (ret_val)
  3359. e_dbg("NVM update error: %d\n", ret_val);
  3360. return ret_val;
  3361. }
  3362. /**
  3363. * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
  3364. * @hw: pointer to the HW structure
  3365. *
  3366. * The NVM checksum is updated by calling the generic update_nvm_checksum,
  3367. * which writes the checksum to the shadow ram. The changes in the shadow
  3368. * ram are then committed to the EEPROM by processing each bank at a time
  3369. * checking for the modified bit and writing only the pending changes.
  3370. * After a successful commit, the shadow ram is cleared and is ready for
  3371. * future writes.
  3372. **/
  3373. static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
  3374. {
  3375. struct e1000_nvm_info *nvm = &hw->nvm;
  3376. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  3377. u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
  3378. s32 ret_val;
  3379. u16 data = 0;
  3380. ret_val = e1000e_update_nvm_checksum_generic(hw);
  3381. if (ret_val)
  3382. goto out;
  3383. if (nvm->type != e1000_nvm_flash_sw)
  3384. goto out;
  3385. nvm->ops.acquire(hw);
  3386. /* We're writing to the opposite bank so if we're on bank 1,
  3387. * write to bank 0 etc. We also need to erase the segment that
  3388. * is going to be written
  3389. */
  3390. ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
  3391. if (ret_val) {
  3392. e_dbg("Could not detect valid bank, assuming bank 0\n");
  3393. bank = 0;
  3394. }
  3395. if (bank == 0) {
  3396. new_bank_offset = nvm->flash_bank_size;
  3397. old_bank_offset = 0;
  3398. ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
  3399. if (ret_val)
  3400. goto release;
  3401. } else {
  3402. old_bank_offset = nvm->flash_bank_size;
  3403. new_bank_offset = 0;
  3404. ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
  3405. if (ret_val)
  3406. goto release;
  3407. }
  3408. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  3409. if (dev_spec->shadow_ram[i].modified) {
  3410. data = dev_spec->shadow_ram[i].value;
  3411. } else {
  3412. ret_val = e1000_read_flash_word_ich8lan(hw, i +
  3413. old_bank_offset,
  3414. &data);
  3415. if (ret_val)
  3416. break;
  3417. }
  3418. /* If the word is 0x13, then make sure the signature bits
  3419. * (15:14) are 11b until the commit has completed.
  3420. * This will allow us to write 10b which indicates the
  3421. * signature is valid. We want to do this after the write
  3422. * has completed so that we don't mark the segment valid
  3423. * while the write is still in progress
  3424. */
  3425. if (i == E1000_ICH_NVM_SIG_WORD)
  3426. data |= E1000_ICH_NVM_SIG_MASK;
  3427. /* Convert offset to bytes. */
  3428. act_offset = (i + new_bank_offset) << 1;
  3429. usleep_range(100, 200);
  3430. /* Write the bytes to the new bank. */
  3431. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  3432. act_offset,
  3433. (u8)data);
  3434. if (ret_val)
  3435. break;
  3436. usleep_range(100, 200);
  3437. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  3438. act_offset + 1,
  3439. (u8)(data >> 8));
  3440. if (ret_val)
  3441. break;
  3442. }
  3443. /* Don't bother writing the segment valid bits if sector
  3444. * programming failed.
  3445. */
  3446. if (ret_val) {
  3447. /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
  3448. e_dbg("Flash commit failed.\n");
  3449. goto release;
  3450. }
  3451. /* Finally validate the new segment by setting bit 15:14
  3452. * to 10b in word 0x13 , this can be done without an
  3453. * erase as well since these bits are 11 to start with
  3454. * and we need to change bit 14 to 0b
  3455. */
  3456. act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
  3457. ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
  3458. if (ret_val)
  3459. goto release;
  3460. data &= 0xBFFF;
  3461. ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
  3462. act_offset * 2 + 1,
  3463. (u8)(data >> 8));
  3464. if (ret_val)
  3465. goto release;
  3466. /* And invalidate the previously valid segment by setting
  3467. * its signature word (0x13) high_byte to 0b. This can be
  3468. * done without an erase because flash erase sets all bits
  3469. * to 1's. We can write 1's to 0's without an erase
  3470. */
  3471. act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
  3472. ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
  3473. if (ret_val)
  3474. goto release;
  3475. /* Great! Everything worked, we can now clear the cached entries. */
  3476. for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
  3477. dev_spec->shadow_ram[i].modified = false;
  3478. dev_spec->shadow_ram[i].value = 0xFFFF;
  3479. }
  3480. release:
  3481. nvm->ops.release(hw);
  3482. /* Reload the EEPROM, or else modifications will not appear
  3483. * until after the next adapter reset.
  3484. */
  3485. if (!ret_val) {
  3486. nvm->ops.reload(hw);
  3487. usleep_range(10000, 20000);
  3488. }
  3489. out:
  3490. if (ret_val)
  3491. e_dbg("NVM update error: %d\n", ret_val);
  3492. return ret_val;
  3493. }
  3494. /**
  3495. * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
  3496. * @hw: pointer to the HW structure
  3497. *
  3498. * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
  3499. * If the bit is 0, that the EEPROM had been modified, but the checksum was not
  3500. * calculated, in which case we need to calculate the checksum and set bit 6.
  3501. **/
  3502. static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
  3503. {
  3504. s32 ret_val;
  3505. u16 data;
  3506. u16 word;
  3507. u16 valid_csum_mask;
  3508. /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
  3509. * the checksum needs to be fixed. This bit is an indication that
  3510. * the NVM was prepared by OEM software and did not calculate
  3511. * the checksum...a likely scenario.
  3512. */
  3513. switch (hw->mac.type) {
  3514. case e1000_pch_lpt:
  3515. case e1000_pch_spt:
  3516. word = NVM_COMPAT;
  3517. valid_csum_mask = NVM_COMPAT_VALID_CSUM;
  3518. break;
  3519. default:
  3520. word = NVM_FUTURE_INIT_WORD1;
  3521. valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
  3522. break;
  3523. }
  3524. ret_val = e1000_read_nvm(hw, word, 1, &data);
  3525. if (ret_val)
  3526. return ret_val;
  3527. if (!(data & valid_csum_mask)) {
  3528. data |= valid_csum_mask;
  3529. ret_val = e1000_write_nvm(hw, word, 1, &data);
  3530. if (ret_val)
  3531. return ret_val;
  3532. ret_val = e1000e_update_nvm_checksum(hw);
  3533. if (ret_val)
  3534. return ret_val;
  3535. }
  3536. return e1000e_validate_nvm_checksum_generic(hw);
  3537. }
  3538. /**
  3539. * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
  3540. * @hw: pointer to the HW structure
  3541. *
  3542. * To prevent malicious write/erase of the NVM, set it to be read-only
  3543. * so that the hardware ignores all write/erase cycles of the NVM via
  3544. * the flash control registers. The shadow-ram copy of the NVM will
  3545. * still be updated, however any updates to this copy will not stick
  3546. * across driver reloads.
  3547. **/
  3548. void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
  3549. {
  3550. struct e1000_nvm_info *nvm = &hw->nvm;
  3551. union ich8_flash_protected_range pr0;
  3552. union ich8_hws_flash_status hsfsts;
  3553. u32 gfpreg;
  3554. nvm->ops.acquire(hw);
  3555. gfpreg = er32flash(ICH_FLASH_GFPREG);
  3556. /* Write-protect GbE Sector of NVM */
  3557. pr0.regval = er32flash(ICH_FLASH_PR0);
  3558. pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
  3559. pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
  3560. pr0.range.wpe = true;
  3561. ew32flash(ICH_FLASH_PR0, pr0.regval);
  3562. /* Lock down a subset of GbE Flash Control Registers, e.g.
  3563. * PR0 to prevent the write-protection from being lifted.
  3564. * Once FLOCKDN is set, the registers protected by it cannot
  3565. * be written until FLOCKDN is cleared by a hardware reset.
  3566. */
  3567. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3568. hsfsts.hsf_status.flockdn = true;
  3569. ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
  3570. nvm->ops.release(hw);
  3571. }
  3572. /**
  3573. * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
  3574. * @hw: pointer to the HW structure
  3575. * @offset: The offset (in bytes) of the byte/word to read.
  3576. * @size: Size of data to read, 1=byte 2=word
  3577. * @data: The byte(s) to write to the NVM.
  3578. *
  3579. * Writes one/two bytes to the NVM using the flash access registers.
  3580. **/
  3581. static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
  3582. u8 size, u16 data)
  3583. {
  3584. union ich8_hws_flash_status hsfsts;
  3585. union ich8_hws_flash_ctrl hsflctl;
  3586. u32 flash_linear_addr;
  3587. u32 flash_data = 0;
  3588. s32 ret_val;
  3589. u8 count = 0;
  3590. if (hw->mac.type == e1000_pch_spt) {
  3591. if (size != 4 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  3592. return -E1000_ERR_NVM;
  3593. } else {
  3594. if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
  3595. return -E1000_ERR_NVM;
  3596. }
  3597. flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  3598. hw->nvm.flash_base_addr);
  3599. do {
  3600. udelay(1);
  3601. /* Steps */
  3602. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  3603. if (ret_val)
  3604. break;
  3605. /* In SPT, This register is in Lan memory space, not
  3606. * flash. Therefore, only 32 bit access is supported
  3607. */
  3608. if (hw->mac.type == e1000_pch_spt)
  3609. hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
  3610. else
  3611. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  3612. /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
  3613. hsflctl.hsf_ctrl.fldbcount = size - 1;
  3614. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
  3615. /* In SPT, This register is in Lan memory space,
  3616. * not flash. Therefore, only 32 bit access is
  3617. * supported
  3618. */
  3619. if (hw->mac.type == e1000_pch_spt)
  3620. ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
  3621. else
  3622. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  3623. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  3624. if (size == 1)
  3625. flash_data = (u32)data & 0x00FF;
  3626. else
  3627. flash_data = (u32)data;
  3628. ew32flash(ICH_FLASH_FDATA0, flash_data);
  3629. /* check if FCERR is set to 1 , if set to 1, clear it
  3630. * and try the whole sequence a few more times else done
  3631. */
  3632. ret_val =
  3633. e1000_flash_cycle_ich8lan(hw,
  3634. ICH_FLASH_WRITE_COMMAND_TIMEOUT);
  3635. if (!ret_val)
  3636. break;
  3637. /* If we're here, then things are most likely
  3638. * completely hosed, but if the error condition
  3639. * is detected, it won't hurt to give it another
  3640. * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
  3641. */
  3642. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3643. if (hsfsts.hsf_status.flcerr)
  3644. /* Repeat for some time before giving up. */
  3645. continue;
  3646. if (!hsfsts.hsf_status.flcdone) {
  3647. e_dbg("Timeout error - flash cycle did not complete.\n");
  3648. break;
  3649. }
  3650. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  3651. return ret_val;
  3652. }
  3653. /**
  3654. * e1000_write_flash_data32_ich8lan - Writes 4 bytes to the NVM
  3655. * @hw: pointer to the HW structure
  3656. * @offset: The offset (in bytes) of the dwords to read.
  3657. * @data: The 4 bytes to write to the NVM.
  3658. *
  3659. * Writes one/two/four bytes to the NVM using the flash access registers.
  3660. **/
  3661. static s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
  3662. u32 data)
  3663. {
  3664. union ich8_hws_flash_status hsfsts;
  3665. union ich8_hws_flash_ctrl hsflctl;
  3666. u32 flash_linear_addr;
  3667. s32 ret_val;
  3668. u8 count = 0;
  3669. if (hw->mac.type == e1000_pch_spt) {
  3670. if (offset > ICH_FLASH_LINEAR_ADDR_MASK)
  3671. return -E1000_ERR_NVM;
  3672. }
  3673. flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
  3674. hw->nvm.flash_base_addr);
  3675. do {
  3676. udelay(1);
  3677. /* Steps */
  3678. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  3679. if (ret_val)
  3680. break;
  3681. /* In SPT, This register is in Lan memory space, not
  3682. * flash. Therefore, only 32 bit access is supported
  3683. */
  3684. if (hw->mac.type == e1000_pch_spt)
  3685. hsflctl.regval = er32flash(ICH_FLASH_HSFSTS)
  3686. >> 16;
  3687. else
  3688. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  3689. hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
  3690. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
  3691. /* In SPT, This register is in Lan memory space,
  3692. * not flash. Therefore, only 32 bit access is
  3693. * supported
  3694. */
  3695. if (hw->mac.type == e1000_pch_spt)
  3696. ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
  3697. else
  3698. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  3699. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  3700. ew32flash(ICH_FLASH_FDATA0, data);
  3701. /* check if FCERR is set to 1 , if set to 1, clear it
  3702. * and try the whole sequence a few more times else done
  3703. */
  3704. ret_val =
  3705. e1000_flash_cycle_ich8lan(hw,
  3706. ICH_FLASH_WRITE_COMMAND_TIMEOUT);
  3707. if (!ret_val)
  3708. break;
  3709. /* If we're here, then things are most likely
  3710. * completely hosed, but if the error condition
  3711. * is detected, it won't hurt to give it another
  3712. * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
  3713. */
  3714. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3715. if (hsfsts.hsf_status.flcerr)
  3716. /* Repeat for some time before giving up. */
  3717. continue;
  3718. if (!hsfsts.hsf_status.flcdone) {
  3719. e_dbg("Timeout error - flash cycle did not complete.\n");
  3720. break;
  3721. }
  3722. } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
  3723. return ret_val;
  3724. }
  3725. /**
  3726. * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
  3727. * @hw: pointer to the HW structure
  3728. * @offset: The index of the byte to read.
  3729. * @data: The byte to write to the NVM.
  3730. *
  3731. * Writes a single byte to the NVM using the flash access registers.
  3732. **/
  3733. static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
  3734. u8 data)
  3735. {
  3736. u16 word = (u16)data;
  3737. return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
  3738. }
  3739. /**
  3740. * e1000_retry_write_flash_dword_ich8lan - Writes a dword to NVM
  3741. * @hw: pointer to the HW structure
  3742. * @offset: The offset of the word to write.
  3743. * @dword: The dword to write to the NVM.
  3744. *
  3745. * Writes a single dword to the NVM using the flash access registers.
  3746. * Goes through a retry algorithm before giving up.
  3747. **/
  3748. static s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
  3749. u32 offset, u32 dword)
  3750. {
  3751. s32 ret_val;
  3752. u16 program_retries;
  3753. /* Must convert word offset into bytes. */
  3754. offset <<= 1;
  3755. ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
  3756. if (!ret_val)
  3757. return ret_val;
  3758. for (program_retries = 0; program_retries < 100; program_retries++) {
  3759. e_dbg("Retrying Byte %8.8X at offset %u\n", dword, offset);
  3760. usleep_range(100, 200);
  3761. ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
  3762. if (!ret_val)
  3763. break;
  3764. }
  3765. if (program_retries == 100)
  3766. return -E1000_ERR_NVM;
  3767. return 0;
  3768. }
  3769. /**
  3770. * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
  3771. * @hw: pointer to the HW structure
  3772. * @offset: The offset of the byte to write.
  3773. * @byte: The byte to write to the NVM.
  3774. *
  3775. * Writes a single byte to the NVM using the flash access registers.
  3776. * Goes through a retry algorithm before giving up.
  3777. **/
  3778. static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
  3779. u32 offset, u8 byte)
  3780. {
  3781. s32 ret_val;
  3782. u16 program_retries;
  3783. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  3784. if (!ret_val)
  3785. return ret_val;
  3786. for (program_retries = 0; program_retries < 100; program_retries++) {
  3787. e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
  3788. usleep_range(100, 200);
  3789. ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
  3790. if (!ret_val)
  3791. break;
  3792. }
  3793. if (program_retries == 100)
  3794. return -E1000_ERR_NVM;
  3795. return 0;
  3796. }
  3797. /**
  3798. * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
  3799. * @hw: pointer to the HW structure
  3800. * @bank: 0 for first bank, 1 for second bank, etc.
  3801. *
  3802. * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
  3803. * bank N is 4096 * N + flash_reg_addr.
  3804. **/
  3805. static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
  3806. {
  3807. struct e1000_nvm_info *nvm = &hw->nvm;
  3808. union ich8_hws_flash_status hsfsts;
  3809. union ich8_hws_flash_ctrl hsflctl;
  3810. u32 flash_linear_addr;
  3811. /* bank size is in 16bit words - adjust to bytes */
  3812. u32 flash_bank_size = nvm->flash_bank_size * 2;
  3813. s32 ret_val;
  3814. s32 count = 0;
  3815. s32 j, iteration, sector_size;
  3816. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3817. /* Determine HW Sector size: Read BERASE bits of hw flash status
  3818. * register
  3819. * 00: The Hw sector is 256 bytes, hence we need to erase 16
  3820. * consecutive sectors. The start index for the nth Hw sector
  3821. * can be calculated as = bank * 4096 + n * 256
  3822. * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
  3823. * The start index for the nth Hw sector can be calculated
  3824. * as = bank * 4096
  3825. * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
  3826. * (ich9 only, otherwise error condition)
  3827. * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
  3828. */
  3829. switch (hsfsts.hsf_status.berasesz) {
  3830. case 0:
  3831. /* Hw sector size 256 */
  3832. sector_size = ICH_FLASH_SEG_SIZE_256;
  3833. iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
  3834. break;
  3835. case 1:
  3836. sector_size = ICH_FLASH_SEG_SIZE_4K;
  3837. iteration = 1;
  3838. break;
  3839. case 2:
  3840. sector_size = ICH_FLASH_SEG_SIZE_8K;
  3841. iteration = 1;
  3842. break;
  3843. case 3:
  3844. sector_size = ICH_FLASH_SEG_SIZE_64K;
  3845. iteration = 1;
  3846. break;
  3847. default:
  3848. return -E1000_ERR_NVM;
  3849. }
  3850. /* Start with the base address, then add the sector offset. */
  3851. flash_linear_addr = hw->nvm.flash_base_addr;
  3852. flash_linear_addr += (bank) ? flash_bank_size : 0;
  3853. for (j = 0; j < iteration; j++) {
  3854. do {
  3855. u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
  3856. /* Steps */
  3857. ret_val = e1000_flash_cycle_init_ich8lan(hw);
  3858. if (ret_val)
  3859. return ret_val;
  3860. /* Write a value 11 (block Erase) in Flash
  3861. * Cycle field in hw flash control
  3862. */
  3863. if (hw->mac.type == e1000_pch_spt)
  3864. hsflctl.regval =
  3865. er32flash(ICH_FLASH_HSFSTS) >> 16;
  3866. else
  3867. hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
  3868. hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
  3869. if (hw->mac.type == e1000_pch_spt)
  3870. ew32flash(ICH_FLASH_HSFSTS,
  3871. hsflctl.regval << 16);
  3872. else
  3873. ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
  3874. /* Write the last 24 bits of an index within the
  3875. * block into Flash Linear address field in Flash
  3876. * Address.
  3877. */
  3878. flash_linear_addr += (j * sector_size);
  3879. ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
  3880. ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
  3881. if (!ret_val)
  3882. break;
  3883. /* Check if FCERR is set to 1. If 1,
  3884. * clear it and try the whole sequence
  3885. * a few more times else Done
  3886. */
  3887. hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
  3888. if (hsfsts.hsf_status.flcerr)
  3889. /* repeat for some time before giving up */
  3890. continue;
  3891. else if (!hsfsts.hsf_status.flcdone)
  3892. return ret_val;
  3893. } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
  3894. }
  3895. return 0;
  3896. }
  3897. /**
  3898. * e1000_valid_led_default_ich8lan - Set the default LED settings
  3899. * @hw: pointer to the HW structure
  3900. * @data: Pointer to the LED settings
  3901. *
  3902. * Reads the LED default settings from the NVM to data. If the NVM LED
  3903. * settings is all 0's or F's, set the LED default to a valid LED default
  3904. * setting.
  3905. **/
  3906. static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
  3907. {
  3908. s32 ret_val;
  3909. ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
  3910. if (ret_val) {
  3911. e_dbg("NVM Read Error\n");
  3912. return ret_val;
  3913. }
  3914. if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
  3915. *data = ID_LED_DEFAULT_ICH8LAN;
  3916. return 0;
  3917. }
  3918. /**
  3919. * e1000_id_led_init_pchlan - store LED configurations
  3920. * @hw: pointer to the HW structure
  3921. *
  3922. * PCH does not control LEDs via the LEDCTL register, rather it uses
  3923. * the PHY LED configuration register.
  3924. *
  3925. * PCH also does not have an "always on" or "always off" mode which
  3926. * complicates the ID feature. Instead of using the "on" mode to indicate
  3927. * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
  3928. * use "link_up" mode. The LEDs will still ID on request if there is no
  3929. * link based on logic in e1000_led_[on|off]_pchlan().
  3930. **/
  3931. static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
  3932. {
  3933. struct e1000_mac_info *mac = &hw->mac;
  3934. s32 ret_val;
  3935. const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
  3936. const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
  3937. u16 data, i, temp, shift;
  3938. /* Get default ID LED modes */
  3939. ret_val = hw->nvm.ops.valid_led_default(hw, &data);
  3940. if (ret_val)
  3941. return ret_val;
  3942. mac->ledctl_default = er32(LEDCTL);
  3943. mac->ledctl_mode1 = mac->ledctl_default;
  3944. mac->ledctl_mode2 = mac->ledctl_default;
  3945. for (i = 0; i < 4; i++) {
  3946. temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
  3947. shift = (i * 5);
  3948. switch (temp) {
  3949. case ID_LED_ON1_DEF2:
  3950. case ID_LED_ON1_ON2:
  3951. case ID_LED_ON1_OFF2:
  3952. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  3953. mac->ledctl_mode1 |= (ledctl_on << shift);
  3954. break;
  3955. case ID_LED_OFF1_DEF2:
  3956. case ID_LED_OFF1_ON2:
  3957. case ID_LED_OFF1_OFF2:
  3958. mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
  3959. mac->ledctl_mode1 |= (ledctl_off << shift);
  3960. break;
  3961. default:
  3962. /* Do nothing */
  3963. break;
  3964. }
  3965. switch (temp) {
  3966. case ID_LED_DEF1_ON2:
  3967. case ID_LED_ON1_ON2:
  3968. case ID_LED_OFF1_ON2:
  3969. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  3970. mac->ledctl_mode2 |= (ledctl_on << shift);
  3971. break;
  3972. case ID_LED_DEF1_OFF2:
  3973. case ID_LED_ON1_OFF2:
  3974. case ID_LED_OFF1_OFF2:
  3975. mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
  3976. mac->ledctl_mode2 |= (ledctl_off << shift);
  3977. break;
  3978. default:
  3979. /* Do nothing */
  3980. break;
  3981. }
  3982. }
  3983. return 0;
  3984. }
  3985. /**
  3986. * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
  3987. * @hw: pointer to the HW structure
  3988. *
  3989. * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
  3990. * register, so the the bus width is hard coded.
  3991. **/
  3992. static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
  3993. {
  3994. struct e1000_bus_info *bus = &hw->bus;
  3995. s32 ret_val;
  3996. ret_val = e1000e_get_bus_info_pcie(hw);
  3997. /* ICH devices are "PCI Express"-ish. They have
  3998. * a configuration space, but do not contain
  3999. * PCI Express Capability registers, so bus width
  4000. * must be hardcoded.
  4001. */
  4002. if (bus->width == e1000_bus_width_unknown)
  4003. bus->width = e1000_bus_width_pcie_x1;
  4004. return ret_val;
  4005. }
  4006. /**
  4007. * e1000_reset_hw_ich8lan - Reset the hardware
  4008. * @hw: pointer to the HW structure
  4009. *
  4010. * Does a full reset of the hardware which includes a reset of the PHY and
  4011. * MAC.
  4012. **/
  4013. static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
  4014. {
  4015. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  4016. u16 kum_cfg;
  4017. u32 ctrl, reg;
  4018. s32 ret_val;
  4019. /* Prevent the PCI-E bus from sticking if there is no TLP connection
  4020. * on the last TLP read/write transaction when MAC is reset.
  4021. */
  4022. ret_val = e1000e_disable_pcie_master(hw);
  4023. if (ret_val)
  4024. e_dbg("PCI-E Master disable polling has failed.\n");
  4025. e_dbg("Masking off all interrupts\n");
  4026. ew32(IMC, 0xffffffff);
  4027. /* Disable the Transmit and Receive units. Then delay to allow
  4028. * any pending transactions to complete before we hit the MAC
  4029. * with the global reset.
  4030. */
  4031. ew32(RCTL, 0);
  4032. ew32(TCTL, E1000_TCTL_PSP);
  4033. e1e_flush();
  4034. usleep_range(10000, 20000);
  4035. /* Workaround for ICH8 bit corruption issue in FIFO memory */
  4036. if (hw->mac.type == e1000_ich8lan) {
  4037. /* Set Tx and Rx buffer allocation to 8k apiece. */
  4038. ew32(PBA, E1000_PBA_8K);
  4039. /* Set Packet Buffer Size to 16k. */
  4040. ew32(PBS, E1000_PBS_16K);
  4041. }
  4042. if (hw->mac.type == e1000_pchlan) {
  4043. /* Save the NVM K1 bit setting */
  4044. ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
  4045. if (ret_val)
  4046. return ret_val;
  4047. if (kum_cfg & E1000_NVM_K1_ENABLE)
  4048. dev_spec->nvm_k1_enabled = true;
  4049. else
  4050. dev_spec->nvm_k1_enabled = false;
  4051. }
  4052. ctrl = er32(CTRL);
  4053. if (!hw->phy.ops.check_reset_block(hw)) {
  4054. /* Full-chip reset requires MAC and PHY reset at the same
  4055. * time to make sure the interface between MAC and the
  4056. * external PHY is reset.
  4057. */
  4058. ctrl |= E1000_CTRL_PHY_RST;
  4059. /* Gate automatic PHY configuration by hardware on
  4060. * non-managed 82579
  4061. */
  4062. if ((hw->mac.type == e1000_pch2lan) &&
  4063. !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
  4064. e1000_gate_hw_phy_config_ich8lan(hw, true);
  4065. }
  4066. ret_val = e1000_acquire_swflag_ich8lan(hw);
  4067. e_dbg("Issuing a global reset to ich8lan\n");
  4068. ew32(CTRL, (ctrl | E1000_CTRL_RST));
  4069. /* cannot issue a flush here because it hangs the hardware */
  4070. msleep(20);
  4071. /* Set Phy Config Counter to 50msec */
  4072. if (hw->mac.type == e1000_pch2lan) {
  4073. reg = er32(FEXTNVM3);
  4074. reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
  4075. reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
  4076. ew32(FEXTNVM3, reg);
  4077. }
  4078. if (!ret_val)
  4079. clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
  4080. if (ctrl & E1000_CTRL_PHY_RST) {
  4081. ret_val = hw->phy.ops.get_cfg_done(hw);
  4082. if (ret_val)
  4083. return ret_val;
  4084. ret_val = e1000_post_phy_reset_ich8lan(hw);
  4085. if (ret_val)
  4086. return ret_val;
  4087. }
  4088. /* For PCH, this write will make sure that any noise
  4089. * will be detected as a CRC error and be dropped rather than show up
  4090. * as a bad packet to the DMA engine.
  4091. */
  4092. if (hw->mac.type == e1000_pchlan)
  4093. ew32(CRC_OFFSET, 0x65656565);
  4094. ew32(IMC, 0xffffffff);
  4095. er32(ICR);
  4096. reg = er32(KABGTXD);
  4097. reg |= E1000_KABGTXD_BGSQLBIAS;
  4098. ew32(KABGTXD, reg);
  4099. return 0;
  4100. }
  4101. /**
  4102. * e1000_init_hw_ich8lan - Initialize the hardware
  4103. * @hw: pointer to the HW structure
  4104. *
  4105. * Prepares the hardware for transmit and receive by doing the following:
  4106. * - initialize hardware bits
  4107. * - initialize LED identification
  4108. * - setup receive address registers
  4109. * - setup flow control
  4110. * - setup transmit descriptors
  4111. * - clear statistics
  4112. **/
  4113. static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
  4114. {
  4115. struct e1000_mac_info *mac = &hw->mac;
  4116. u32 ctrl_ext, txdctl, snoop;
  4117. s32 ret_val;
  4118. u16 i;
  4119. e1000_initialize_hw_bits_ich8lan(hw);
  4120. /* Initialize identification LED */
  4121. ret_val = mac->ops.id_led_init(hw);
  4122. /* An error is not fatal and we should not stop init due to this */
  4123. if (ret_val)
  4124. e_dbg("Error initializing identification LED\n");
  4125. /* Setup the receive address. */
  4126. e1000e_init_rx_addrs(hw, mac->rar_entry_count);
  4127. /* Zero out the Multicast HASH table */
  4128. e_dbg("Zeroing the MTA\n");
  4129. for (i = 0; i < mac->mta_reg_count; i++)
  4130. E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
  4131. /* The 82578 Rx buffer will stall if wakeup is enabled in host and
  4132. * the ME. Disable wakeup by clearing the host wakeup bit.
  4133. * Reset the phy after disabling host wakeup to reset the Rx buffer.
  4134. */
  4135. if (hw->phy.type == e1000_phy_82578) {
  4136. e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
  4137. i &= ~BM_WUC_HOST_WU_BIT;
  4138. e1e_wphy(hw, BM_PORT_GEN_CFG, i);
  4139. ret_val = e1000_phy_hw_reset_ich8lan(hw);
  4140. if (ret_val)
  4141. return ret_val;
  4142. }
  4143. /* Setup link and flow control */
  4144. ret_val = mac->ops.setup_link(hw);
  4145. /* Set the transmit descriptor write-back policy for both queues */
  4146. txdctl = er32(TXDCTL(0));
  4147. txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
  4148. E1000_TXDCTL_FULL_TX_DESC_WB);
  4149. txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
  4150. E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
  4151. ew32(TXDCTL(0), txdctl);
  4152. txdctl = er32(TXDCTL(1));
  4153. txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
  4154. E1000_TXDCTL_FULL_TX_DESC_WB);
  4155. txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
  4156. E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
  4157. ew32(TXDCTL(1), txdctl);
  4158. /* ICH8 has opposite polarity of no_snoop bits.
  4159. * By default, we should use snoop behavior.
  4160. */
  4161. if (mac->type == e1000_ich8lan)
  4162. snoop = PCIE_ICH8_SNOOP_ALL;
  4163. else
  4164. snoop = (u32)~(PCIE_NO_SNOOP_ALL);
  4165. e1000e_set_pcie_no_snoop(hw, snoop);
  4166. ctrl_ext = er32(CTRL_EXT);
  4167. ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
  4168. ew32(CTRL_EXT, ctrl_ext);
  4169. /* Clear all of the statistics registers (clear on read). It is
  4170. * important that we do this after we have tried to establish link
  4171. * because the symbol error count will increment wildly if there
  4172. * is no link.
  4173. */
  4174. e1000_clear_hw_cntrs_ich8lan(hw);
  4175. return ret_val;
  4176. }
  4177. /**
  4178. * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
  4179. * @hw: pointer to the HW structure
  4180. *
  4181. * Sets/Clears required hardware bits necessary for correctly setting up the
  4182. * hardware for transmit and receive.
  4183. **/
  4184. static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
  4185. {
  4186. u32 reg;
  4187. /* Extended Device Control */
  4188. reg = er32(CTRL_EXT);
  4189. reg |= (1 << 22);
  4190. /* Enable PHY low-power state when MAC is at D3 w/o WoL */
  4191. if (hw->mac.type >= e1000_pchlan)
  4192. reg |= E1000_CTRL_EXT_PHYPDEN;
  4193. ew32(CTRL_EXT, reg);
  4194. /* Transmit Descriptor Control 0 */
  4195. reg = er32(TXDCTL(0));
  4196. reg |= (1 << 22);
  4197. ew32(TXDCTL(0), reg);
  4198. /* Transmit Descriptor Control 1 */
  4199. reg = er32(TXDCTL(1));
  4200. reg |= (1 << 22);
  4201. ew32(TXDCTL(1), reg);
  4202. /* Transmit Arbitration Control 0 */
  4203. reg = er32(TARC(0));
  4204. if (hw->mac.type == e1000_ich8lan)
  4205. reg |= (1 << 28) | (1 << 29);
  4206. reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
  4207. ew32(TARC(0), reg);
  4208. /* Transmit Arbitration Control 1 */
  4209. reg = er32(TARC(1));
  4210. if (er32(TCTL) & E1000_TCTL_MULR)
  4211. reg &= ~(1 << 28);
  4212. else
  4213. reg |= (1 << 28);
  4214. reg |= (1 << 24) | (1 << 26) | (1 << 30);
  4215. ew32(TARC(1), reg);
  4216. /* Device Status */
  4217. if (hw->mac.type == e1000_ich8lan) {
  4218. reg = er32(STATUS);
  4219. reg &= ~(1 << 31);
  4220. ew32(STATUS, reg);
  4221. }
  4222. /* work-around descriptor data corruption issue during nfs v2 udp
  4223. * traffic, just disable the nfs filtering capability
  4224. */
  4225. reg = er32(RFCTL);
  4226. reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
  4227. /* Disable IPv6 extension header parsing because some malformed
  4228. * IPv6 headers can hang the Rx.
  4229. */
  4230. if (hw->mac.type == e1000_ich8lan)
  4231. reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
  4232. ew32(RFCTL, reg);
  4233. /* Enable ECC on Lynxpoint */
  4234. if ((hw->mac.type == e1000_pch_lpt) ||
  4235. (hw->mac.type == e1000_pch_spt)) {
  4236. reg = er32(PBECCSTS);
  4237. reg |= E1000_PBECCSTS_ECC_ENABLE;
  4238. ew32(PBECCSTS, reg);
  4239. reg = er32(CTRL);
  4240. reg |= E1000_CTRL_MEHE;
  4241. ew32(CTRL, reg);
  4242. }
  4243. }
  4244. /**
  4245. * e1000_setup_link_ich8lan - Setup flow control and link settings
  4246. * @hw: pointer to the HW structure
  4247. *
  4248. * Determines which flow control settings to use, then configures flow
  4249. * control. Calls the appropriate media-specific link configuration
  4250. * function. Assuming the adapter has a valid link partner, a valid link
  4251. * should be established. Assumes the hardware has previously been reset
  4252. * and the transmitter and receiver are not enabled.
  4253. **/
  4254. static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
  4255. {
  4256. s32 ret_val;
  4257. if (hw->phy.ops.check_reset_block(hw))
  4258. return 0;
  4259. /* ICH parts do not have a word in the NVM to determine
  4260. * the default flow control setting, so we explicitly
  4261. * set it to full.
  4262. */
  4263. if (hw->fc.requested_mode == e1000_fc_default) {
  4264. /* Workaround h/w hang when Tx flow control enabled */
  4265. if (hw->mac.type == e1000_pchlan)
  4266. hw->fc.requested_mode = e1000_fc_rx_pause;
  4267. else
  4268. hw->fc.requested_mode = e1000_fc_full;
  4269. }
  4270. /* Save off the requested flow control mode for use later. Depending
  4271. * on the link partner's capabilities, we may or may not use this mode.
  4272. */
  4273. hw->fc.current_mode = hw->fc.requested_mode;
  4274. e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode);
  4275. /* Continue to configure the copper link. */
  4276. ret_val = hw->mac.ops.setup_physical_interface(hw);
  4277. if (ret_val)
  4278. return ret_val;
  4279. ew32(FCTTV, hw->fc.pause_time);
  4280. if ((hw->phy.type == e1000_phy_82578) ||
  4281. (hw->phy.type == e1000_phy_82579) ||
  4282. (hw->phy.type == e1000_phy_i217) ||
  4283. (hw->phy.type == e1000_phy_82577)) {
  4284. ew32(FCRTV_PCH, hw->fc.refresh_time);
  4285. ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
  4286. hw->fc.pause_time);
  4287. if (ret_val)
  4288. return ret_val;
  4289. }
  4290. return e1000e_set_fc_watermarks(hw);
  4291. }
  4292. /**
  4293. * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
  4294. * @hw: pointer to the HW structure
  4295. *
  4296. * Configures the kumeran interface to the PHY to wait the appropriate time
  4297. * when polling the PHY, then call the generic setup_copper_link to finish
  4298. * configuring the copper link.
  4299. **/
  4300. static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
  4301. {
  4302. u32 ctrl;
  4303. s32 ret_val;
  4304. u16 reg_data;
  4305. ctrl = er32(CTRL);
  4306. ctrl |= E1000_CTRL_SLU;
  4307. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  4308. ew32(CTRL, ctrl);
  4309. /* Set the mac to wait the maximum time between each iteration
  4310. * and increase the max iterations when polling the phy;
  4311. * this fixes erroneous timeouts at 10Mbps.
  4312. */
  4313. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
  4314. if (ret_val)
  4315. return ret_val;
  4316. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  4317. &reg_data);
  4318. if (ret_val)
  4319. return ret_val;
  4320. reg_data |= 0x3F;
  4321. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
  4322. reg_data);
  4323. if (ret_val)
  4324. return ret_val;
  4325. switch (hw->phy.type) {
  4326. case e1000_phy_igp_3:
  4327. ret_val = e1000e_copper_link_setup_igp(hw);
  4328. if (ret_val)
  4329. return ret_val;
  4330. break;
  4331. case e1000_phy_bm:
  4332. case e1000_phy_82578:
  4333. ret_val = e1000e_copper_link_setup_m88(hw);
  4334. if (ret_val)
  4335. return ret_val;
  4336. break;
  4337. case e1000_phy_82577:
  4338. case e1000_phy_82579:
  4339. ret_val = e1000_copper_link_setup_82577(hw);
  4340. if (ret_val)
  4341. return ret_val;
  4342. break;
  4343. case e1000_phy_ife:
  4344. ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
  4345. if (ret_val)
  4346. return ret_val;
  4347. reg_data &= ~IFE_PMC_AUTO_MDIX;
  4348. switch (hw->phy.mdix) {
  4349. case 1:
  4350. reg_data &= ~IFE_PMC_FORCE_MDIX;
  4351. break;
  4352. case 2:
  4353. reg_data |= IFE_PMC_FORCE_MDIX;
  4354. break;
  4355. case 0:
  4356. default:
  4357. reg_data |= IFE_PMC_AUTO_MDIX;
  4358. break;
  4359. }
  4360. ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
  4361. if (ret_val)
  4362. return ret_val;
  4363. break;
  4364. default:
  4365. break;
  4366. }
  4367. return e1000e_setup_copper_link(hw);
  4368. }
  4369. /**
  4370. * e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
  4371. * @hw: pointer to the HW structure
  4372. *
  4373. * Calls the PHY specific link setup function and then calls the
  4374. * generic setup_copper_link to finish configuring the link for
  4375. * Lynxpoint PCH devices
  4376. **/
  4377. static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
  4378. {
  4379. u32 ctrl;
  4380. s32 ret_val;
  4381. ctrl = er32(CTRL);
  4382. ctrl |= E1000_CTRL_SLU;
  4383. ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  4384. ew32(CTRL, ctrl);
  4385. ret_val = e1000_copper_link_setup_82577(hw);
  4386. if (ret_val)
  4387. return ret_val;
  4388. return e1000e_setup_copper_link(hw);
  4389. }
  4390. /**
  4391. * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
  4392. * @hw: pointer to the HW structure
  4393. * @speed: pointer to store current link speed
  4394. * @duplex: pointer to store the current link duplex
  4395. *
  4396. * Calls the generic get_speed_and_duplex to retrieve the current link
  4397. * information and then calls the Kumeran lock loss workaround for links at
  4398. * gigabit speeds.
  4399. **/
  4400. static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
  4401. u16 *duplex)
  4402. {
  4403. s32 ret_val;
  4404. ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
  4405. if (ret_val)
  4406. return ret_val;
  4407. if ((hw->mac.type == e1000_ich8lan) &&
  4408. (hw->phy.type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
  4409. ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
  4410. }
  4411. return ret_val;
  4412. }
  4413. /**
  4414. * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
  4415. * @hw: pointer to the HW structure
  4416. *
  4417. * Work-around for 82566 Kumeran PCS lock loss:
  4418. * On link status change (i.e. PCI reset, speed change) and link is up and
  4419. * speed is gigabit-
  4420. * 0) if workaround is optionally disabled do nothing
  4421. * 1) wait 1ms for Kumeran link to come up
  4422. * 2) check Kumeran Diagnostic register PCS lock loss bit
  4423. * 3) if not set the link is locked (all is good), otherwise...
  4424. * 4) reset the PHY
  4425. * 5) repeat up to 10 times
  4426. * Note: this is only called for IGP3 copper when speed is 1gb.
  4427. **/
  4428. static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
  4429. {
  4430. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  4431. u32 phy_ctrl;
  4432. s32 ret_val;
  4433. u16 i, data;
  4434. bool link;
  4435. if (!dev_spec->kmrn_lock_loss_workaround_enabled)
  4436. return 0;
  4437. /* Make sure link is up before proceeding. If not just return.
  4438. * Attempting this while link is negotiating fouled up link
  4439. * stability
  4440. */
  4441. ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
  4442. if (!link)
  4443. return 0;
  4444. for (i = 0; i < 10; i++) {
  4445. /* read once to clear */
  4446. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  4447. if (ret_val)
  4448. return ret_val;
  4449. /* and again to get new status */
  4450. ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
  4451. if (ret_val)
  4452. return ret_val;
  4453. /* check for PCS lock */
  4454. if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
  4455. return 0;
  4456. /* Issue PHY reset */
  4457. e1000_phy_hw_reset(hw);
  4458. mdelay(5);
  4459. }
  4460. /* Disable GigE link negotiation */
  4461. phy_ctrl = er32(PHY_CTRL);
  4462. phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
  4463. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  4464. ew32(PHY_CTRL, phy_ctrl);
  4465. /* Call gig speed drop workaround on Gig disable before accessing
  4466. * any PHY registers
  4467. */
  4468. e1000e_gig_downshift_workaround_ich8lan(hw);
  4469. /* unable to acquire PCS lock */
  4470. return -E1000_ERR_PHY;
  4471. }
  4472. /**
  4473. * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
  4474. * @hw: pointer to the HW structure
  4475. * @state: boolean value used to set the current Kumeran workaround state
  4476. *
  4477. * If ICH8, set the current Kumeran workaround state (enabled - true
  4478. * /disabled - false).
  4479. **/
  4480. void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
  4481. bool state)
  4482. {
  4483. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  4484. if (hw->mac.type != e1000_ich8lan) {
  4485. e_dbg("Workaround applies to ICH8 only.\n");
  4486. return;
  4487. }
  4488. dev_spec->kmrn_lock_loss_workaround_enabled = state;
  4489. }
  4490. /**
  4491. * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
  4492. * @hw: pointer to the HW structure
  4493. *
  4494. * Workaround for 82566 power-down on D3 entry:
  4495. * 1) disable gigabit link
  4496. * 2) write VR power-down enable
  4497. * 3) read it back
  4498. * Continue if successful, else issue LCD reset and repeat
  4499. **/
  4500. void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
  4501. {
  4502. u32 reg;
  4503. u16 data;
  4504. u8 retry = 0;
  4505. if (hw->phy.type != e1000_phy_igp_3)
  4506. return;
  4507. /* Try the workaround twice (if needed) */
  4508. do {
  4509. /* Disable link */
  4510. reg = er32(PHY_CTRL);
  4511. reg |= (E1000_PHY_CTRL_GBE_DISABLE |
  4512. E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
  4513. ew32(PHY_CTRL, reg);
  4514. /* Call gig speed drop workaround on Gig disable before
  4515. * accessing any PHY registers
  4516. */
  4517. if (hw->mac.type == e1000_ich8lan)
  4518. e1000e_gig_downshift_workaround_ich8lan(hw);
  4519. /* Write VR power-down enable */
  4520. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  4521. data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  4522. e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
  4523. /* Read it back and test */
  4524. e1e_rphy(hw, IGP3_VR_CTRL, &data);
  4525. data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
  4526. if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
  4527. break;
  4528. /* Issue PHY reset and repeat at most one more time */
  4529. reg = er32(CTRL);
  4530. ew32(CTRL, reg | E1000_CTRL_PHY_RST);
  4531. retry++;
  4532. } while (retry);
  4533. }
  4534. /**
  4535. * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
  4536. * @hw: pointer to the HW structure
  4537. *
  4538. * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
  4539. * LPLU, Gig disable, MDIC PHY reset):
  4540. * 1) Set Kumeran Near-end loopback
  4541. * 2) Clear Kumeran Near-end loopback
  4542. * Should only be called for ICH8[m] devices with any 1G Phy.
  4543. **/
  4544. void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
  4545. {
  4546. s32 ret_val;
  4547. u16 reg_data;
  4548. if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
  4549. return;
  4550. ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  4551. &reg_data);
  4552. if (ret_val)
  4553. return;
  4554. reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
  4555. ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
  4556. reg_data);
  4557. if (ret_val)
  4558. return;
  4559. reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
  4560. e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);
  4561. }
  4562. /**
  4563. * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
  4564. * @hw: pointer to the HW structure
  4565. *
  4566. * During S0 to Sx transition, it is possible the link remains at gig
  4567. * instead of negotiating to a lower speed. Before going to Sx, set
  4568. * 'Gig Disable' to force link speed negotiation to a lower speed based on
  4569. * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
  4570. * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
  4571. * needs to be written.
  4572. * Parts that support (and are linked to a partner which support) EEE in
  4573. * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
  4574. * than 10Mbps w/o EEE.
  4575. **/
  4576. void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
  4577. {
  4578. struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
  4579. u32 phy_ctrl;
  4580. s32 ret_val;
  4581. phy_ctrl = er32(PHY_CTRL);
  4582. phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
  4583. if (hw->phy.type == e1000_phy_i217) {
  4584. u16 phy_reg, device_id = hw->adapter->pdev->device;
  4585. if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
  4586. (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
  4587. (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
  4588. (device_id == E1000_DEV_ID_PCH_I218_V3) ||
  4589. (hw->mac.type == e1000_pch_spt)) {
  4590. u32 fextnvm6 = er32(FEXTNVM6);
  4591. ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
  4592. }
  4593. ret_val = hw->phy.ops.acquire(hw);
  4594. if (ret_val)
  4595. goto out;
  4596. if (!dev_spec->eee_disable) {
  4597. u16 eee_advert;
  4598. ret_val =
  4599. e1000_read_emi_reg_locked(hw,
  4600. I217_EEE_ADVERTISEMENT,
  4601. &eee_advert);
  4602. if (ret_val)
  4603. goto release;
  4604. /* Disable LPLU if both link partners support 100BaseT
  4605. * EEE and 100Full is advertised on both ends of the
  4606. * link, and enable Auto Enable LPI since there will
  4607. * be no driver to enable LPI while in Sx.
  4608. */
  4609. if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
  4610. (dev_spec->eee_lp_ability &
  4611. I82579_EEE_100_SUPPORTED) &&
  4612. (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) {
  4613. phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
  4614. E1000_PHY_CTRL_NOND0A_LPLU);
  4615. /* Set Auto Enable LPI after link up */
  4616. e1e_rphy_locked(hw,
  4617. I217_LPI_GPIO_CTRL, &phy_reg);
  4618. phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
  4619. e1e_wphy_locked(hw,
  4620. I217_LPI_GPIO_CTRL, phy_reg);
  4621. }
  4622. }
  4623. /* For i217 Intel Rapid Start Technology support,
  4624. * when the system is going into Sx and no manageability engine
  4625. * is present, the driver must configure proxy to reset only on
  4626. * power good. LPI (Low Power Idle) state must also reset only
  4627. * on power good, as well as the MTA (Multicast table array).
  4628. * The SMBus release must also be disabled on LCD reset.
  4629. */
  4630. if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
  4631. /* Enable proxy to reset only on power good. */
  4632. e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);
  4633. phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
  4634. e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg);
  4635. /* Set bit enable LPI (EEE) to reset only on
  4636. * power good.
  4637. */
  4638. e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg);
  4639. phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
  4640. e1e_wphy_locked(hw, I217_SxCTRL, phy_reg);
  4641. /* Disable the SMB release on LCD reset. */
  4642. e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
  4643. phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
  4644. e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
  4645. }
  4646. /* Enable MTA to reset for Intel Rapid Start Technology
  4647. * Support
  4648. */
  4649. e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
  4650. phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
  4651. e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
  4652. release:
  4653. hw->phy.ops.release(hw);
  4654. }
  4655. out:
  4656. ew32(PHY_CTRL, phy_ctrl);
  4657. if (hw->mac.type == e1000_ich8lan)
  4658. e1000e_gig_downshift_workaround_ich8lan(hw);
  4659. if (hw->mac.type >= e1000_pchlan) {
  4660. e1000_oem_bits_config_ich8lan(hw, false);
  4661. /* Reset PHY to activate OEM bits on 82577/8 */
  4662. if (hw->mac.type == e1000_pchlan)
  4663. e1000e_phy_hw_reset_generic(hw);
  4664. ret_val = hw->phy.ops.acquire(hw);
  4665. if (ret_val)
  4666. return;
  4667. e1000_write_smbus_addr(hw);
  4668. hw->phy.ops.release(hw);
  4669. }
  4670. }
  4671. /**
  4672. * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
  4673. * @hw: pointer to the HW structure
  4674. *
  4675. * During Sx to S0 transitions on non-managed devices or managed devices
  4676. * on which PHY resets are not blocked, if the PHY registers cannot be
  4677. * accessed properly by the s/w toggle the LANPHYPC value to power cycle
  4678. * the PHY.
  4679. * On i217, setup Intel Rapid Start Technology.
  4680. **/
  4681. void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
  4682. {
  4683. s32 ret_val;
  4684. if (hw->mac.type < e1000_pch2lan)
  4685. return;
  4686. ret_val = e1000_init_phy_workarounds_pchlan(hw);
  4687. if (ret_val) {
  4688. e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
  4689. return;
  4690. }
  4691. /* For i217 Intel Rapid Start Technology support when the system
  4692. * is transitioning from Sx and no manageability engine is present
  4693. * configure SMBus to restore on reset, disable proxy, and enable
  4694. * the reset on MTA (Multicast table array).
  4695. */
  4696. if (hw->phy.type == e1000_phy_i217) {
  4697. u16 phy_reg;
  4698. ret_val = hw->phy.ops.acquire(hw);
  4699. if (ret_val) {
  4700. e_dbg("Failed to setup iRST\n");
  4701. return;
  4702. }
  4703. /* Clear Auto Enable LPI after link up */
  4704. e1e_rphy_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
  4705. phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
  4706. e1e_wphy_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
  4707. if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
  4708. /* Restore clear on SMB if no manageability engine
  4709. * is present
  4710. */
  4711. ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
  4712. if (ret_val)
  4713. goto release;
  4714. phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
  4715. e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
  4716. /* Disable Proxy */
  4717. e1e_wphy_locked(hw, I217_PROXY_CTRL, 0);
  4718. }
  4719. /* Enable reset on MTA */
  4720. ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
  4721. if (ret_val)
  4722. goto release;
  4723. phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
  4724. e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
  4725. release:
  4726. if (ret_val)
  4727. e_dbg("Error %d in resume workarounds\n", ret_val);
  4728. hw->phy.ops.release(hw);
  4729. }
  4730. }
  4731. /**
  4732. * e1000_cleanup_led_ich8lan - Restore the default LED operation
  4733. * @hw: pointer to the HW structure
  4734. *
  4735. * Return the LED back to the default configuration.
  4736. **/
  4737. static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
  4738. {
  4739. if (hw->phy.type == e1000_phy_ife)
  4740. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
  4741. ew32(LEDCTL, hw->mac.ledctl_default);
  4742. return 0;
  4743. }
  4744. /**
  4745. * e1000_led_on_ich8lan - Turn LEDs on
  4746. * @hw: pointer to the HW structure
  4747. *
  4748. * Turn on the LEDs.
  4749. **/
  4750. static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
  4751. {
  4752. if (hw->phy.type == e1000_phy_ife)
  4753. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  4754. (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
  4755. ew32(LEDCTL, hw->mac.ledctl_mode2);
  4756. return 0;
  4757. }
  4758. /**
  4759. * e1000_led_off_ich8lan - Turn LEDs off
  4760. * @hw: pointer to the HW structure
  4761. *
  4762. * Turn off the LEDs.
  4763. **/
  4764. static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
  4765. {
  4766. if (hw->phy.type == e1000_phy_ife)
  4767. return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
  4768. (IFE_PSCL_PROBE_MODE |
  4769. IFE_PSCL_PROBE_LEDS_OFF));
  4770. ew32(LEDCTL, hw->mac.ledctl_mode1);
  4771. return 0;
  4772. }
  4773. /**
  4774. * e1000_setup_led_pchlan - Configures SW controllable LED
  4775. * @hw: pointer to the HW structure
  4776. *
  4777. * This prepares the SW controllable LED for use.
  4778. **/
  4779. static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
  4780. {
  4781. return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
  4782. }
  4783. /**
  4784. * e1000_cleanup_led_pchlan - Restore the default LED operation
  4785. * @hw: pointer to the HW structure
  4786. *
  4787. * Return the LED back to the default configuration.
  4788. **/
  4789. static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
  4790. {
  4791. return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
  4792. }
  4793. /**
  4794. * e1000_led_on_pchlan - Turn LEDs on
  4795. * @hw: pointer to the HW structure
  4796. *
  4797. * Turn on the LEDs.
  4798. **/
  4799. static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
  4800. {
  4801. u16 data = (u16)hw->mac.ledctl_mode2;
  4802. u32 i, led;
  4803. /* If no link, then turn LED on by setting the invert bit
  4804. * for each LED that's mode is "link_up" in ledctl_mode2.
  4805. */
  4806. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  4807. for (i = 0; i < 3; i++) {
  4808. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  4809. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  4810. E1000_LEDCTL_MODE_LINK_UP)
  4811. continue;
  4812. if (led & E1000_PHY_LED0_IVRT)
  4813. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  4814. else
  4815. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  4816. }
  4817. }
  4818. return e1e_wphy(hw, HV_LED_CONFIG, data);
  4819. }
  4820. /**
  4821. * e1000_led_off_pchlan - Turn LEDs off
  4822. * @hw: pointer to the HW structure
  4823. *
  4824. * Turn off the LEDs.
  4825. **/
  4826. static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
  4827. {
  4828. u16 data = (u16)hw->mac.ledctl_mode1;
  4829. u32 i, led;
  4830. /* If no link, then turn LED off by clearing the invert bit
  4831. * for each LED that's mode is "link_up" in ledctl_mode1.
  4832. */
  4833. if (!(er32(STATUS) & E1000_STATUS_LU)) {
  4834. for (i = 0; i < 3; i++) {
  4835. led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
  4836. if ((led & E1000_PHY_LED0_MODE_MASK) !=
  4837. E1000_LEDCTL_MODE_LINK_UP)
  4838. continue;
  4839. if (led & E1000_PHY_LED0_IVRT)
  4840. data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
  4841. else
  4842. data |= (E1000_PHY_LED0_IVRT << (i * 5));
  4843. }
  4844. }
  4845. return e1e_wphy(hw, HV_LED_CONFIG, data);
  4846. }
  4847. /**
  4848. * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
  4849. * @hw: pointer to the HW structure
  4850. *
  4851. * Read appropriate register for the config done bit for completion status
  4852. * and configure the PHY through s/w for EEPROM-less parts.
  4853. *
  4854. * NOTE: some silicon which is EEPROM-less will fail trying to read the
  4855. * config done bit, so only an error is logged and continues. If we were
  4856. * to return with error, EEPROM-less silicon would not be able to be reset
  4857. * or change link.
  4858. **/
  4859. static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
  4860. {
  4861. s32 ret_val = 0;
  4862. u32 bank = 0;
  4863. u32 status;
  4864. e1000e_get_cfg_done_generic(hw);
  4865. /* Wait for indication from h/w that it has completed basic config */
  4866. if (hw->mac.type >= e1000_ich10lan) {
  4867. e1000_lan_init_done_ich8lan(hw);
  4868. } else {
  4869. ret_val = e1000e_get_auto_rd_done(hw);
  4870. if (ret_val) {
  4871. /* When auto config read does not complete, do not
  4872. * return with an error. This can happen in situations
  4873. * where there is no eeprom and prevents getting link.
  4874. */
  4875. e_dbg("Auto Read Done did not complete\n");
  4876. ret_val = 0;
  4877. }
  4878. }
  4879. /* Clear PHY Reset Asserted bit */
  4880. status = er32(STATUS);
  4881. if (status & E1000_STATUS_PHYRA)
  4882. ew32(STATUS, status & ~E1000_STATUS_PHYRA);
  4883. else
  4884. e_dbg("PHY Reset Asserted not set - needs delay\n");
  4885. /* If EEPROM is not marked present, init the IGP 3 PHY manually */
  4886. if (hw->mac.type <= e1000_ich9lan) {
  4887. if (!(er32(EECD) & E1000_EECD_PRES) &&
  4888. (hw->phy.type == e1000_phy_igp_3)) {
  4889. e1000e_phy_init_script_igp3(hw);
  4890. }
  4891. } else {
  4892. if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
  4893. /* Maybe we should do a basic PHY config */
  4894. e_dbg("EEPROM not present\n");
  4895. ret_val = -E1000_ERR_CONFIG;
  4896. }
  4897. }
  4898. return ret_val;
  4899. }
  4900. /**
  4901. * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
  4902. * @hw: pointer to the HW structure
  4903. *
  4904. * In the case of a PHY power down to save power, or to turn off link during a
  4905. * driver unload, or wake on lan is not enabled, remove the link.
  4906. **/
  4907. static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
  4908. {
  4909. /* If the management interface is not enabled, then power down */
  4910. if (!(hw->mac.ops.check_mng_mode(hw) ||
  4911. hw->phy.ops.check_reset_block(hw)))
  4912. e1000_power_down_phy_copper(hw);
  4913. }
  4914. /**
  4915. * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
  4916. * @hw: pointer to the HW structure
  4917. *
  4918. * Clears hardware counters specific to the silicon family and calls
  4919. * clear_hw_cntrs_generic to clear all general purpose counters.
  4920. **/
  4921. static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
  4922. {
  4923. u16 phy_data;
  4924. s32 ret_val;
  4925. e1000e_clear_hw_cntrs_base(hw);
  4926. er32(ALGNERRC);
  4927. er32(RXERRC);
  4928. er32(TNCRS);
  4929. er32(CEXTERR);
  4930. er32(TSCTC);
  4931. er32(TSCTFC);
  4932. er32(MGTPRC);
  4933. er32(MGTPDC);
  4934. er32(MGTPTC);
  4935. er32(IAC);
  4936. er32(ICRXOC);
  4937. /* Clear PHY statistics registers */
  4938. if ((hw->phy.type == e1000_phy_82578) ||
  4939. (hw->phy.type == e1000_phy_82579) ||
  4940. (hw->phy.type == e1000_phy_i217) ||
  4941. (hw->phy.type == e1000_phy_82577)) {
  4942. ret_val = hw->phy.ops.acquire(hw);
  4943. if (ret_val)
  4944. return;
  4945. ret_val = hw->phy.ops.set_page(hw,
  4946. HV_STATS_PAGE << IGP_PAGE_SHIFT);
  4947. if (ret_val)
  4948. goto release;
  4949. hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
  4950. hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
  4951. hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
  4952. hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
  4953. hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
  4954. hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
  4955. hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
  4956. hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
  4957. hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
  4958. hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
  4959. hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
  4960. hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
  4961. hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
  4962. hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
  4963. release:
  4964. hw->phy.ops.release(hw);
  4965. }
  4966. }
  4967. static const struct e1000_mac_operations ich8_mac_ops = {
  4968. /* check_mng_mode dependent on mac type */
  4969. .check_for_link = e1000_check_for_copper_link_ich8lan,
  4970. /* cleanup_led dependent on mac type */
  4971. .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
  4972. .get_bus_info = e1000_get_bus_info_ich8lan,
  4973. .set_lan_id = e1000_set_lan_id_single_port,
  4974. .get_link_up_info = e1000_get_link_up_info_ich8lan,
  4975. /* led_on dependent on mac type */
  4976. /* led_off dependent on mac type */
  4977. .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
  4978. .reset_hw = e1000_reset_hw_ich8lan,
  4979. .init_hw = e1000_init_hw_ich8lan,
  4980. .setup_link = e1000_setup_link_ich8lan,
  4981. .setup_physical_interface = e1000_setup_copper_link_ich8lan,
  4982. /* id_led_init dependent on mac type */
  4983. .config_collision_dist = e1000e_config_collision_dist_generic,
  4984. .rar_set = e1000e_rar_set_generic,
  4985. .rar_get_count = e1000e_rar_get_count_generic,
  4986. };
  4987. static const struct e1000_phy_operations ich8_phy_ops = {
  4988. .acquire = e1000_acquire_swflag_ich8lan,
  4989. .check_reset_block = e1000_check_reset_block_ich8lan,
  4990. .commit = NULL,
  4991. .get_cfg_done = e1000_get_cfg_done_ich8lan,
  4992. .get_cable_length = e1000e_get_cable_length_igp_2,
  4993. .read_reg = e1000e_read_phy_reg_igp,
  4994. .release = e1000_release_swflag_ich8lan,
  4995. .reset = e1000_phy_hw_reset_ich8lan,
  4996. .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
  4997. .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
  4998. .write_reg = e1000e_write_phy_reg_igp,
  4999. };
  5000. static const struct e1000_nvm_operations ich8_nvm_ops = {
  5001. .acquire = e1000_acquire_nvm_ich8lan,
  5002. .read = e1000_read_nvm_ich8lan,
  5003. .release = e1000_release_nvm_ich8lan,
  5004. .reload = e1000e_reload_nvm_generic,
  5005. .update = e1000_update_nvm_checksum_ich8lan,
  5006. .valid_led_default = e1000_valid_led_default_ich8lan,
  5007. .validate = e1000_validate_nvm_checksum_ich8lan,
  5008. .write = e1000_write_nvm_ich8lan,
  5009. };
  5010. static const struct e1000_nvm_operations spt_nvm_ops = {
  5011. .acquire = e1000_acquire_nvm_ich8lan,
  5012. .release = e1000_release_nvm_ich8lan,
  5013. .read = e1000_read_nvm_spt,
  5014. .update = e1000_update_nvm_checksum_spt,
  5015. .reload = e1000e_reload_nvm_generic,
  5016. .valid_led_default = e1000_valid_led_default_ich8lan,
  5017. .validate = e1000_validate_nvm_checksum_ich8lan,
  5018. .write = e1000_write_nvm_ich8lan,
  5019. };
  5020. const struct e1000_info e1000_ich8_info = {
  5021. .mac = e1000_ich8lan,
  5022. .flags = FLAG_HAS_WOL
  5023. | FLAG_IS_ICH
  5024. | FLAG_HAS_CTRLEXT_ON_LOAD
  5025. | FLAG_HAS_AMT
  5026. | FLAG_HAS_FLASH
  5027. | FLAG_APME_IN_WUC,
  5028. .pba = 8,
  5029. .max_hw_frame_size = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN,
  5030. .get_variants = e1000_get_variants_ich8lan,
  5031. .mac_ops = &ich8_mac_ops,
  5032. .phy_ops = &ich8_phy_ops,
  5033. .nvm_ops = &ich8_nvm_ops,
  5034. };
  5035. const struct e1000_info e1000_ich9_info = {
  5036. .mac = e1000_ich9lan,
  5037. .flags = FLAG_HAS_JUMBO_FRAMES
  5038. | FLAG_IS_ICH
  5039. | FLAG_HAS_WOL
  5040. | FLAG_HAS_CTRLEXT_ON_LOAD
  5041. | FLAG_HAS_AMT
  5042. | FLAG_HAS_FLASH
  5043. | FLAG_APME_IN_WUC,
  5044. .pba = 18,
  5045. .max_hw_frame_size = DEFAULT_JUMBO,
  5046. .get_variants = e1000_get_variants_ich8lan,
  5047. .mac_ops = &ich8_mac_ops,
  5048. .phy_ops = &ich8_phy_ops,
  5049. .nvm_ops = &ich8_nvm_ops,
  5050. };
  5051. const struct e1000_info e1000_ich10_info = {
  5052. .mac = e1000_ich10lan,
  5053. .flags = FLAG_HAS_JUMBO_FRAMES
  5054. | FLAG_IS_ICH
  5055. | FLAG_HAS_WOL
  5056. | FLAG_HAS_CTRLEXT_ON_LOAD
  5057. | FLAG_HAS_AMT
  5058. | FLAG_HAS_FLASH
  5059. | FLAG_APME_IN_WUC,
  5060. .pba = 18,
  5061. .max_hw_frame_size = DEFAULT_JUMBO,
  5062. .get_variants = e1000_get_variants_ich8lan,
  5063. .mac_ops = &ich8_mac_ops,
  5064. .phy_ops = &ich8_phy_ops,
  5065. .nvm_ops = &ich8_nvm_ops,
  5066. };
  5067. const struct e1000_info e1000_pch_info = {
  5068. .mac = e1000_pchlan,
  5069. .flags = FLAG_IS_ICH
  5070. | FLAG_HAS_WOL
  5071. | FLAG_HAS_CTRLEXT_ON_LOAD
  5072. | FLAG_HAS_AMT
  5073. | FLAG_HAS_FLASH
  5074. | FLAG_HAS_JUMBO_FRAMES
  5075. | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
  5076. | FLAG_APME_IN_WUC,
  5077. .flags2 = FLAG2_HAS_PHY_STATS,
  5078. .pba = 26,
  5079. .max_hw_frame_size = 4096,
  5080. .get_variants = e1000_get_variants_ich8lan,
  5081. .mac_ops = &ich8_mac_ops,
  5082. .phy_ops = &ich8_phy_ops,
  5083. .nvm_ops = &ich8_nvm_ops,
  5084. };
  5085. const struct e1000_info e1000_pch2_info = {
  5086. .mac = e1000_pch2lan,
  5087. .flags = FLAG_IS_ICH
  5088. | FLAG_HAS_WOL
  5089. | FLAG_HAS_HW_TIMESTAMP
  5090. | FLAG_HAS_CTRLEXT_ON_LOAD
  5091. | FLAG_HAS_AMT
  5092. | FLAG_HAS_FLASH
  5093. | FLAG_HAS_JUMBO_FRAMES
  5094. | FLAG_APME_IN_WUC,
  5095. .flags2 = FLAG2_HAS_PHY_STATS
  5096. | FLAG2_HAS_EEE,
  5097. .pba = 26,
  5098. .max_hw_frame_size = 9022,
  5099. .get_variants = e1000_get_variants_ich8lan,
  5100. .mac_ops = &ich8_mac_ops,
  5101. .phy_ops = &ich8_phy_ops,
  5102. .nvm_ops = &ich8_nvm_ops,
  5103. };
  5104. const struct e1000_info e1000_pch_lpt_info = {
  5105. .mac = e1000_pch_lpt,
  5106. .flags = FLAG_IS_ICH
  5107. | FLAG_HAS_WOL
  5108. | FLAG_HAS_HW_TIMESTAMP
  5109. | FLAG_HAS_CTRLEXT_ON_LOAD
  5110. | FLAG_HAS_AMT
  5111. | FLAG_HAS_FLASH
  5112. | FLAG_HAS_JUMBO_FRAMES
  5113. | FLAG_APME_IN_WUC,
  5114. .flags2 = FLAG2_HAS_PHY_STATS
  5115. | FLAG2_HAS_EEE,
  5116. .pba = 26,
  5117. .max_hw_frame_size = 9022,
  5118. .get_variants = e1000_get_variants_ich8lan,
  5119. .mac_ops = &ich8_mac_ops,
  5120. .phy_ops = &ich8_phy_ops,
  5121. .nvm_ops = &ich8_nvm_ops,
  5122. };
  5123. const struct e1000_info e1000_pch_spt_info = {
  5124. .mac = e1000_pch_spt,
  5125. .flags = FLAG_IS_ICH
  5126. | FLAG_HAS_WOL
  5127. | FLAG_HAS_HW_TIMESTAMP
  5128. | FLAG_HAS_CTRLEXT_ON_LOAD
  5129. | FLAG_HAS_AMT
  5130. | FLAG_HAS_FLASH
  5131. | FLAG_HAS_JUMBO_FRAMES
  5132. | FLAG_APME_IN_WUC,
  5133. .flags2 = FLAG2_HAS_PHY_STATS
  5134. | FLAG2_HAS_EEE,
  5135. .pba = 26,
  5136. .max_hw_frame_size = 9022,
  5137. .get_variants = e1000_get_variants_ich8lan,
  5138. .mac_ops = &ich8_mac_ops,
  5139. .phy_ops = &ich8_phy_ops,
  5140. .nvm_ops = &spt_nvm_ops,
  5141. };