ich8lan.c 162 KB

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