ich8lan.c 162 KB

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