ich8lan.c 164 KB

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