ich8lan.c 162 KB

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