ich8lan.c 162 KB

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