si_dpm.c 231 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180
  1. /*
  2. * Copyright 2013 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #include "drmP.h"
  24. #include "radeon.h"
  25. #include "radeon_asic.h"
  26. #include "sid.h"
  27. #include "r600_dpm.h"
  28. #include "si_dpm.h"
  29. #include "atom.h"
  30. #include <linux/math64.h>
  31. #include <linux/seq_file.h>
  32. #define MC_CG_ARB_FREQ_F0 0x0a
  33. #define MC_CG_ARB_FREQ_F1 0x0b
  34. #define MC_CG_ARB_FREQ_F2 0x0c
  35. #define MC_CG_ARB_FREQ_F3 0x0d
  36. #define SMC_RAM_END 0x20000
  37. #define SCLK_MIN_DEEPSLEEP_FREQ 1350
  38. static const struct si_cac_config_reg cac_weights_tahiti[] =
  39. {
  40. { 0x0, 0x0000ffff, 0, 0xc, SISLANDS_CACCONFIG_CGIND },
  41. { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  42. { 0x1, 0x0000ffff, 0, 0x101, SISLANDS_CACCONFIG_CGIND },
  43. { 0x1, 0xffff0000, 16, 0xc, SISLANDS_CACCONFIG_CGIND },
  44. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  45. { 0x3, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  46. { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  47. { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  48. { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  49. { 0x5, 0x0000ffff, 0, 0x8fc, SISLANDS_CACCONFIG_CGIND },
  50. { 0x5, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  51. { 0x6, 0x0000ffff, 0, 0x95, SISLANDS_CACCONFIG_CGIND },
  52. { 0x6, 0xffff0000, 16, 0x34e, SISLANDS_CACCONFIG_CGIND },
  53. { 0x18f, 0x0000ffff, 0, 0x1a1, SISLANDS_CACCONFIG_CGIND },
  54. { 0x7, 0x0000ffff, 0, 0xda, SISLANDS_CACCONFIG_CGIND },
  55. { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  56. { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  57. { 0x8, 0xffff0000, 16, 0x46, SISLANDS_CACCONFIG_CGIND },
  58. { 0x9, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  59. { 0xa, 0x0000ffff, 0, 0x208, SISLANDS_CACCONFIG_CGIND },
  60. { 0xb, 0x0000ffff, 0, 0xe7, SISLANDS_CACCONFIG_CGIND },
  61. { 0xb, 0xffff0000, 16, 0x948, SISLANDS_CACCONFIG_CGIND },
  62. { 0xc, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  63. { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  64. { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  65. { 0xe, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  66. { 0xf, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  67. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  68. { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  69. { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  70. { 0x11, 0x0000ffff, 0, 0x167, SISLANDS_CACCONFIG_CGIND },
  71. { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  72. { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  73. { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  74. { 0x13, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  75. { 0x14, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  76. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  77. { 0x15, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
  78. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  79. { 0x16, 0x0000ffff, 0, 0x31, SISLANDS_CACCONFIG_CGIND },
  80. { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  81. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  82. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  83. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  84. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  85. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  86. { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  87. { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  88. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  89. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  90. { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  91. { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  92. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  93. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  94. { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  95. { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  96. { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  97. { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  98. { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  99. { 0x6d, 0x0000ffff, 0, 0x18e, SISLANDS_CACCONFIG_CGIND },
  100. { 0xFFFFFFFF }
  101. };
  102. static const struct si_cac_config_reg lcac_tahiti[] =
  103. {
  104. { 0x143, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
  105. { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  106. { 0x146, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
  107. { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  108. { 0x149, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
  109. { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  110. { 0x14c, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
  111. { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  112. { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  113. { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  114. { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  115. { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  116. { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  117. { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  118. { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  119. { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  120. { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  121. { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  122. { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  123. { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  124. { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  125. { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  126. { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  127. { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  128. { 0x8c, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  129. { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  130. { 0x8f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  131. { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  132. { 0x92, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  133. { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  134. { 0x95, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  135. { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  136. { 0x14f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  137. { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  138. { 0x152, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  139. { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  140. { 0x155, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  141. { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  142. { 0x158, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  143. { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  144. { 0x110, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  145. { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  146. { 0x113, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  147. { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  148. { 0x116, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  149. { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  150. { 0x119, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
  151. { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  152. { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  153. { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  154. { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  155. { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  156. { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  157. { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  158. { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  159. { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  160. { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  161. { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  162. { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  163. { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  164. { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  165. { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  166. { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  167. { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  168. { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  169. { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  170. { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  171. { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  172. { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  173. { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  174. { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  175. { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  176. { 0x16d, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  177. { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  178. { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  179. { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  180. { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  181. { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  182. { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  183. { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  184. { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  185. { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  186. { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  187. { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  188. { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  189. { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  190. { 0xFFFFFFFF }
  191. };
  192. static const struct si_cac_config_reg cac_override_tahiti[] =
  193. {
  194. { 0xFFFFFFFF }
  195. };
  196. static const struct si_powertune_data powertune_data_tahiti =
  197. {
  198. ((1 << 16) | 27027),
  199. 6,
  200. 0,
  201. 4,
  202. 95,
  203. {
  204. 0UL,
  205. 0UL,
  206. 4521550UL,
  207. 309631529UL,
  208. -1270850L,
  209. 4513710L,
  210. 40
  211. },
  212. 595000000UL,
  213. 12,
  214. {
  215. 0,
  216. 0,
  217. 0,
  218. 0,
  219. 0,
  220. 0,
  221. 0,
  222. 0
  223. },
  224. true
  225. };
  226. static const struct si_dte_data dte_data_tahiti =
  227. {
  228. { 1159409, 0, 0, 0, 0 },
  229. { 777, 0, 0, 0, 0 },
  230. 2,
  231. 54000,
  232. 127000,
  233. 25,
  234. 2,
  235. 10,
  236. 13,
  237. { 27, 31, 35, 39, 43, 47, 54, 61, 67, 74, 81, 88, 95, 0, 0, 0 },
  238. { 240888759, 221057860, 235370597, 162287531, 158510299, 131423027, 116673180, 103067515, 87941937, 76209048, 68209175, 64090048, 58301890, 0, 0, 0 },
  239. { 12024, 11189, 11451, 8411, 7939, 6666, 5681, 4905, 4241, 3720, 3354, 3122, 2890, 0, 0, 0 },
  240. 85,
  241. false
  242. };
  243. static const struct si_dte_data dte_data_tahiti_le =
  244. {
  245. { 0x1E8480, 0x7A1200, 0x2160EC0, 0x3938700, 0 },
  246. { 0x7D, 0x7D, 0x4E4, 0xB00, 0 },
  247. 0x5,
  248. 0xAFC8,
  249. 0x64,
  250. 0x32,
  251. 1,
  252. 0,
  253. 0x10,
  254. { 0x78, 0x7C, 0x82, 0x88, 0x8E, 0x94, 0x9A, 0xA0, 0xA6, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, 0xC0, 0xC4 },
  255. { 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700 },
  256. { 0x2AF8, 0x2AF8, 0x29BB, 0x27F9, 0x2637, 0x2475, 0x22B3, 0x20F1, 0x1F2F, 0x1D6D, 0x1734, 0x1414, 0x10F4, 0xDD4, 0xAB4, 0x794 },
  257. 85,
  258. true
  259. };
  260. static const struct si_dte_data dte_data_tahiti_pro =
  261. {
  262. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  263. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  264. 5,
  265. 45000,
  266. 100,
  267. 0xA,
  268. 1,
  269. 0,
  270. 0x10,
  271. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  272. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  273. { 0x7D0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  274. 90,
  275. true
  276. };
  277. static const struct si_dte_data dte_data_new_zealand =
  278. {
  279. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0 },
  280. { 0x29B, 0x3E9, 0x537, 0x7D2, 0 },
  281. 0x5,
  282. 0xAFC8,
  283. 0x69,
  284. 0x32,
  285. 1,
  286. 0,
  287. 0x10,
  288. { 0x82, 0xA0, 0xB4, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE },
  289. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  290. { 0xDAC, 0x1388, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685 },
  291. 85,
  292. true
  293. };
  294. static const struct si_dte_data dte_data_aruba_pro =
  295. {
  296. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  297. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  298. 5,
  299. 45000,
  300. 100,
  301. 0xA,
  302. 1,
  303. 0,
  304. 0x10,
  305. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  306. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  307. { 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  308. 90,
  309. true
  310. };
  311. static const struct si_dte_data dte_data_malta =
  312. {
  313. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  314. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  315. 5,
  316. 45000,
  317. 100,
  318. 0xA,
  319. 1,
  320. 0,
  321. 0x10,
  322. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  323. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  324. { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  325. 90,
  326. true
  327. };
  328. struct si_cac_config_reg cac_weights_pitcairn[] =
  329. {
  330. { 0x0, 0x0000ffff, 0, 0x8a, SISLANDS_CACCONFIG_CGIND },
  331. { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  332. { 0x1, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  333. { 0x1, 0xffff0000, 16, 0x24d, SISLANDS_CACCONFIG_CGIND },
  334. { 0x2, 0x0000ffff, 0, 0x19, SISLANDS_CACCONFIG_CGIND },
  335. { 0x3, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  336. { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  337. { 0x4, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
  338. { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  339. { 0x5, 0x0000ffff, 0, 0xc11, SISLANDS_CACCONFIG_CGIND },
  340. { 0x5, 0xffff0000, 16, 0x7f3, SISLANDS_CACCONFIG_CGIND },
  341. { 0x6, 0x0000ffff, 0, 0x403, SISLANDS_CACCONFIG_CGIND },
  342. { 0x6, 0xffff0000, 16, 0x367, SISLANDS_CACCONFIG_CGIND },
  343. { 0x18f, 0x0000ffff, 0, 0x4c9, SISLANDS_CACCONFIG_CGIND },
  344. { 0x7, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  345. { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  346. { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  347. { 0x8, 0xffff0000, 16, 0x45d, SISLANDS_CACCONFIG_CGIND },
  348. { 0x9, 0x0000ffff, 0, 0x36d, SISLANDS_CACCONFIG_CGIND },
  349. { 0xa, 0x0000ffff, 0, 0x534, SISLANDS_CACCONFIG_CGIND },
  350. { 0xb, 0x0000ffff, 0, 0x5da, SISLANDS_CACCONFIG_CGIND },
  351. { 0xb, 0xffff0000, 16, 0x880, SISLANDS_CACCONFIG_CGIND },
  352. { 0xc, 0x0000ffff, 0, 0x201, SISLANDS_CACCONFIG_CGIND },
  353. { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  354. { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  355. { 0xe, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
  356. { 0xf, 0x0000ffff, 0, 0x1f, SISLANDS_CACCONFIG_CGIND },
  357. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  358. { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  359. { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  360. { 0x11, 0x0000ffff, 0, 0x5de, SISLANDS_CACCONFIG_CGIND },
  361. { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  362. { 0x12, 0x0000ffff, 0, 0x7b, SISLANDS_CACCONFIG_CGIND },
  363. { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  364. { 0x13, 0xffff0000, 16, 0x13, SISLANDS_CACCONFIG_CGIND },
  365. { 0x14, 0x0000ffff, 0, 0xf9, SISLANDS_CACCONFIG_CGIND },
  366. { 0x15, 0x0000ffff, 0, 0x66, SISLANDS_CACCONFIG_CGIND },
  367. { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  368. { 0x4e, 0x0000ffff, 0, 0x13, SISLANDS_CACCONFIG_CGIND },
  369. { 0x16, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  370. { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  371. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  372. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  373. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  374. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  375. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  376. { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  377. { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  378. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  379. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  380. { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  381. { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  382. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  383. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  384. { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  385. { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  386. { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  387. { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  388. { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  389. { 0x6d, 0x0000ffff, 0, 0x186, SISLANDS_CACCONFIG_CGIND },
  390. { 0xFFFFFFFF }
  391. };
  392. static const struct si_cac_config_reg lcac_pitcairn[] =
  393. {
  394. { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  395. { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  396. { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  397. { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  398. { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  399. { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  400. { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  401. { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  402. { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  403. { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  404. { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  405. { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  406. { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  407. { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  408. { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  409. { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  410. { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  411. { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  412. { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  413. { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  414. { 0x8f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  415. { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  416. { 0x146, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  417. { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  418. { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  419. { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  420. { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  421. { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  422. { 0x116, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  423. { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  424. { 0x155, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  425. { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  426. { 0x92, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  427. { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  428. { 0x149, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  429. { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  430. { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  431. { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  432. { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  433. { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  434. { 0x119, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  435. { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  436. { 0x158, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  437. { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  438. { 0x95, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  439. { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  440. { 0x14c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  441. { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  442. { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  443. { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  444. { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  445. { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  446. { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  447. { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  448. { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  449. { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  450. { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  451. { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  452. { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  453. { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  454. { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  455. { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  456. { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  457. { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  458. { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  459. { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  460. { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  461. { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  462. { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  463. { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  464. { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  465. { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  466. { 0x16d, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  467. { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  468. { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  469. { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  470. { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  471. { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  472. { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  473. { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  474. { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  475. { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  476. { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  477. { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  478. { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  479. { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  480. { 0xFFFFFFFF }
  481. };
  482. static const struct si_cac_config_reg cac_override_pitcairn[] =
  483. {
  484. { 0xFFFFFFFF }
  485. };
  486. static const struct si_powertune_data powertune_data_pitcairn =
  487. {
  488. ((1 << 16) | 27027),
  489. 5,
  490. 0,
  491. 6,
  492. 100,
  493. {
  494. 51600000UL,
  495. 1800000UL,
  496. 7194395UL,
  497. 309631529UL,
  498. -1270850L,
  499. 4513710L,
  500. 100
  501. },
  502. 117830498UL,
  503. 12,
  504. {
  505. 0,
  506. 0,
  507. 0,
  508. 0,
  509. 0,
  510. 0,
  511. 0,
  512. 0
  513. },
  514. true
  515. };
  516. static const struct si_dte_data dte_data_pitcairn =
  517. {
  518. { 0, 0, 0, 0, 0 },
  519. { 0, 0, 0, 0, 0 },
  520. 0,
  521. 0,
  522. 0,
  523. 0,
  524. 0,
  525. 0,
  526. 0,
  527. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  528. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  529. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  530. 0,
  531. false
  532. };
  533. static const struct si_dte_data dte_data_curacao_xt =
  534. {
  535. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  536. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  537. 5,
  538. 45000,
  539. 100,
  540. 0xA,
  541. 1,
  542. 0,
  543. 0x10,
  544. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  545. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  546. { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  547. 90,
  548. true
  549. };
  550. static const struct si_dte_data dte_data_curacao_pro =
  551. {
  552. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  553. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  554. 5,
  555. 45000,
  556. 100,
  557. 0xA,
  558. 1,
  559. 0,
  560. 0x10,
  561. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  562. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  563. { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  564. 90,
  565. true
  566. };
  567. static const struct si_dte_data dte_data_neptune_xt =
  568. {
  569. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  570. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  571. 5,
  572. 45000,
  573. 100,
  574. 0xA,
  575. 1,
  576. 0,
  577. 0x10,
  578. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  579. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  580. { 0x3A2F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  581. 90,
  582. true
  583. };
  584. static const struct si_cac_config_reg cac_weights_chelsea_pro[] =
  585. {
  586. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  587. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  588. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  589. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  590. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  591. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  592. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  593. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  594. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  595. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  596. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  597. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  598. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  599. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  600. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  601. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  602. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  603. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  604. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  605. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  606. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  607. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  608. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  609. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  610. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  611. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  612. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  613. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  614. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  615. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  616. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  617. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  618. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  619. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  620. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  621. { 0x14, 0x0000ffff, 0, 0x2BD, SISLANDS_CACCONFIG_CGIND },
  622. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  623. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  624. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  625. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  626. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  627. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  628. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  629. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  630. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  631. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  632. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  633. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  634. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  635. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  636. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  637. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  638. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  639. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  640. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  641. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  642. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  643. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  644. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  645. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  646. { 0xFFFFFFFF }
  647. };
  648. static const struct si_cac_config_reg cac_weights_chelsea_xt[] =
  649. {
  650. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  651. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  652. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  653. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  654. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  655. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  656. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  657. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  658. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  659. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  660. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  661. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  662. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  663. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  664. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  665. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  666. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  667. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  668. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  669. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  670. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  671. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  672. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  673. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  674. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  675. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  676. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  677. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  678. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  679. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  680. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  681. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  682. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  683. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  684. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  685. { 0x14, 0x0000ffff, 0, 0x30A, SISLANDS_CACCONFIG_CGIND },
  686. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  687. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  688. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  689. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  690. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  691. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  692. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  693. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  694. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  695. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  696. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  697. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  698. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  699. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  700. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  701. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  702. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  703. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  704. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  705. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  706. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  707. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  708. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  709. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  710. { 0xFFFFFFFF }
  711. };
  712. static const struct si_cac_config_reg cac_weights_heathrow[] =
  713. {
  714. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  715. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  716. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  717. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  718. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  719. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  720. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  721. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  722. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  723. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  724. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  725. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  726. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  727. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  728. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  729. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  730. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  731. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  732. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  733. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  734. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  735. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  736. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  737. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  738. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  739. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  740. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  741. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  742. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  743. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  744. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  745. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  746. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  747. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  748. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  749. { 0x14, 0x0000ffff, 0, 0x362, SISLANDS_CACCONFIG_CGIND },
  750. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  751. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  752. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  753. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  754. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  755. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  756. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  757. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  758. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  759. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  760. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  761. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  762. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  763. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  764. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  765. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  766. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  767. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  768. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  769. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  770. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  771. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  772. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  773. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  774. { 0xFFFFFFFF }
  775. };
  776. static const struct si_cac_config_reg cac_weights_cape_verde_pro[] =
  777. {
  778. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  779. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  780. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  781. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  782. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  783. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  784. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  785. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  786. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  787. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  788. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  789. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  790. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  791. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  792. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  793. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  794. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  795. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  796. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  797. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  798. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  799. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  800. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  801. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  802. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  803. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  804. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  805. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  806. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  807. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  808. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  809. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  810. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  811. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  812. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  813. { 0x14, 0x0000ffff, 0, 0x315, SISLANDS_CACCONFIG_CGIND },
  814. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  815. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  816. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  817. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  818. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  819. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  820. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  821. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  822. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  823. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  824. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  825. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  826. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  827. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  828. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  829. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  830. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  831. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  832. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  833. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  834. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  835. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  836. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  837. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  838. { 0xFFFFFFFF }
  839. };
  840. static const struct si_cac_config_reg cac_weights_cape_verde[] =
  841. {
  842. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  843. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  844. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  845. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  846. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  847. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  848. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  849. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  850. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  851. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  852. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  853. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  854. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  855. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  856. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  857. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  858. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  859. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  860. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  861. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  862. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  863. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  864. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  865. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  866. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  867. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  868. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  869. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  870. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  871. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  872. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  873. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  874. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  875. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  876. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  877. { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
  878. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  879. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  880. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  881. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  882. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  883. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  884. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  885. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  886. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  887. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  888. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  889. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  890. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  891. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  892. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  893. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  894. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  895. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  896. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  897. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  898. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  899. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  900. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  901. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  902. { 0xFFFFFFFF }
  903. };
  904. static const struct si_cac_config_reg lcac_cape_verde[] =
  905. {
  906. { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  907. { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  908. { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  909. { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  910. { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  911. { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  912. { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  913. { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  914. { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  915. { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  916. { 0x143, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  917. { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  918. { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  919. { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  920. { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  921. { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  922. { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  923. { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  924. { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
  925. { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  926. { 0x8f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  927. { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  928. { 0x146, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  929. { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  930. { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  931. { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  932. { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  933. { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  934. { 0x164, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  935. { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  936. { 0x167, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  937. { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  938. { 0x16a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  939. { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  940. { 0x15e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  941. { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  942. { 0x161, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  943. { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  944. { 0x15b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  945. { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  946. { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  947. { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  948. { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  949. { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  950. { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  951. { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  952. { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  953. { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  954. { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  955. { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  956. { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  957. { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  958. { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  959. { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  960. { 0xFFFFFFFF }
  961. };
  962. static const struct si_cac_config_reg cac_override_cape_verde[] =
  963. {
  964. { 0xFFFFFFFF }
  965. };
  966. static const struct si_powertune_data powertune_data_cape_verde =
  967. {
  968. ((1 << 16) | 0x6993),
  969. 5,
  970. 0,
  971. 7,
  972. 105,
  973. {
  974. 0UL,
  975. 0UL,
  976. 7194395UL,
  977. 309631529UL,
  978. -1270850L,
  979. 4513710L,
  980. 100
  981. },
  982. 117830498UL,
  983. 12,
  984. {
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0
  993. },
  994. true
  995. };
  996. static const struct si_dte_data dte_data_cape_verde =
  997. {
  998. { 0, 0, 0, 0, 0 },
  999. { 0, 0, 0, 0, 0 },
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0,
  1007. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1008. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1009. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1010. 0,
  1011. false
  1012. };
  1013. static const struct si_dte_data dte_data_venus_xtx =
  1014. {
  1015. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  1016. { 0x71C, 0xAAB, 0xE39, 0x11C7, 0x0 },
  1017. 5,
  1018. 55000,
  1019. 0x69,
  1020. 0xA,
  1021. 1,
  1022. 0,
  1023. 0x3,
  1024. { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1025. { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1026. { 0xD6D8, 0x88B8, 0x1555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1027. 90,
  1028. true
  1029. };
  1030. static const struct si_dte_data dte_data_venus_xt =
  1031. {
  1032. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  1033. { 0xBDA, 0x11C7, 0x17B4, 0x1DA1, 0x0 },
  1034. 5,
  1035. 55000,
  1036. 0x69,
  1037. 0xA,
  1038. 1,
  1039. 0,
  1040. 0x3,
  1041. { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1042. { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1043. { 0xAFC8, 0x88B8, 0x238E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1044. 90,
  1045. true
  1046. };
  1047. static const struct si_dte_data dte_data_venus_pro =
  1048. {
  1049. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  1050. { 0x11C7, 0x1AAB, 0x238E, 0x2C72, 0x0 },
  1051. 5,
  1052. 55000,
  1053. 0x69,
  1054. 0xA,
  1055. 1,
  1056. 0,
  1057. 0x3,
  1058. { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1059. { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1060. { 0x88B8, 0x88B8, 0x3555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1061. 90,
  1062. true
  1063. };
  1064. struct si_cac_config_reg cac_weights_oland[] =
  1065. {
  1066. { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
  1067. { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  1068. { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
  1069. { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
  1070. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1071. { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  1072. { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
  1073. { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
  1074. { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
  1075. { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
  1076. { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
  1077. { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
  1078. { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
  1079. { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  1080. { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
  1081. { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
  1082. { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
  1083. { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
  1084. { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
  1085. { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
  1086. { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
  1087. { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
  1088. { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
  1089. { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
  1090. { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
  1091. { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1092. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  1093. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1094. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1095. { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
  1096. { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1097. { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
  1098. { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
  1099. { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
  1100. { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  1101. { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
  1102. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1103. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  1104. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1105. { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
  1106. { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
  1107. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1108. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1109. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1110. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1111. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1112. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1113. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1114. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1115. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1116. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1117. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1118. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1119. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1120. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1121. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1122. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1123. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1124. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1125. { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
  1126. { 0xFFFFFFFF }
  1127. };
  1128. static const struct si_cac_config_reg cac_weights_mars_pro[] =
  1129. {
  1130. { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
  1131. { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1132. { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
  1133. { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
  1134. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1135. { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1136. { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1137. { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1138. { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
  1139. { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
  1140. { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
  1141. { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
  1142. { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
  1143. { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
  1144. { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
  1145. { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
  1146. { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
  1147. { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
  1148. { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
  1149. { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
  1150. { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
  1151. { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
  1152. { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
  1153. { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1154. { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
  1155. { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
  1156. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  1157. { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
  1158. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1159. { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  1160. { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
  1161. { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1162. { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
  1163. { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
  1164. { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
  1165. { 0x14, 0x0000ffff, 0, 0x2, SISLANDS_CACCONFIG_CGIND },
  1166. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1167. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  1168. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1169. { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
  1170. { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
  1171. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1172. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1173. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1174. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1175. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1176. { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
  1177. { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1178. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1179. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1180. { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
  1181. { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
  1182. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1183. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1184. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1185. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1186. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1187. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1188. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1189. { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
  1190. { 0xFFFFFFFF }
  1191. };
  1192. static const struct si_cac_config_reg cac_weights_mars_xt[] =
  1193. {
  1194. { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
  1195. { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1196. { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
  1197. { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
  1198. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1199. { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1200. { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1201. { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1202. { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
  1203. { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
  1204. { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
  1205. { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
  1206. { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
  1207. { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
  1208. { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
  1209. { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
  1210. { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
  1211. { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
  1212. { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
  1213. { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
  1214. { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
  1215. { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
  1216. { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
  1217. { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1218. { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
  1219. { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
  1220. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  1221. { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
  1222. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1223. { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  1224. { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
  1225. { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1226. { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
  1227. { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
  1228. { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
  1229. { 0x14, 0x0000ffff, 0, 0x60, SISLANDS_CACCONFIG_CGIND },
  1230. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1231. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  1232. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1233. { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
  1234. { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
  1235. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1236. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1237. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1238. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1239. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1240. { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
  1241. { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1242. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1243. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1244. { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
  1245. { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
  1246. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1247. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1248. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1249. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1250. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1251. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1252. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1253. { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
  1254. { 0xFFFFFFFF }
  1255. };
  1256. static const struct si_cac_config_reg cac_weights_oland_pro[] =
  1257. {
  1258. { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
  1259. { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1260. { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
  1261. { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
  1262. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1263. { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1264. { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1265. { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1266. { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
  1267. { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
  1268. { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
  1269. { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
  1270. { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
  1271. { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
  1272. { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
  1273. { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
  1274. { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
  1275. { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
  1276. { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
  1277. { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
  1278. { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
  1279. { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
  1280. { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
  1281. { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1282. { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
  1283. { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
  1284. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  1285. { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
  1286. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1287. { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  1288. { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
  1289. { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1290. { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
  1291. { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
  1292. { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
  1293. { 0x14, 0x0000ffff, 0, 0x90, SISLANDS_CACCONFIG_CGIND },
  1294. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1295. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  1296. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1297. { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
  1298. { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
  1299. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1300. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1301. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1302. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1303. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1304. { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
  1305. { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1306. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1307. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1308. { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
  1309. { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
  1310. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1311. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1312. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1313. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1314. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1315. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1316. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1317. { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
  1318. { 0xFFFFFFFF }
  1319. };
  1320. static const struct si_cac_config_reg cac_weights_oland_xt[] =
  1321. {
  1322. { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
  1323. { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1324. { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
  1325. { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
  1326. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1327. { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1328. { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
  1329. { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
  1330. { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
  1331. { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
  1332. { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
  1333. { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
  1334. { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
  1335. { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
  1336. { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
  1337. { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
  1338. { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
  1339. { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
  1340. { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
  1341. { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
  1342. { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
  1343. { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
  1344. { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
  1345. { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
  1346. { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
  1347. { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
  1348. { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
  1349. { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
  1350. { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1351. { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
  1352. { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
  1353. { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1354. { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
  1355. { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
  1356. { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
  1357. { 0x14, 0x0000ffff, 0, 0x120, SISLANDS_CACCONFIG_CGIND },
  1358. { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1359. { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
  1360. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1361. { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
  1362. { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
  1363. { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1364. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1365. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1366. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1367. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1368. { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
  1369. { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
  1370. { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1371. { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1372. { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
  1373. { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
  1374. { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1375. { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1376. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1377. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1378. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1379. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1380. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1381. { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
  1382. { 0xFFFFFFFF }
  1383. };
  1384. static const struct si_cac_config_reg lcac_oland[] =
  1385. {
  1386. { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1387. { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1388. { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1389. { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1390. { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1391. { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1392. { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1393. { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1394. { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1395. { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1396. { 0x143, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
  1397. { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1398. { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1399. { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1400. { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1401. { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1402. { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1403. { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1404. { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1405. { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1406. { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1407. { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1408. { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1409. { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1410. { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1411. { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1412. { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1413. { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1414. { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1415. { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1416. { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1417. { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1418. { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1419. { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1420. { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1421. { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1422. { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1423. { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1424. { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1425. { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1426. { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1427. { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1428. { 0xFFFFFFFF }
  1429. };
  1430. static const struct si_cac_config_reg lcac_mars_pro[] =
  1431. {
  1432. { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1433. { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1434. { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1435. { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1436. { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1437. { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1438. { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1439. { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1440. { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
  1441. { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1442. { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1443. { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1444. { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1445. { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1446. { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1447. { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1448. { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1449. { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1450. { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1451. { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1452. { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1453. { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1454. { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1455. { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1456. { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1457. { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1458. { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1459. { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1460. { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
  1461. { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1462. { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1463. { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1464. { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1465. { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1466. { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1467. { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1468. { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1469. { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1470. { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1471. { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1472. { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
  1473. { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
  1474. { 0xFFFFFFFF }
  1475. };
  1476. static const struct si_cac_config_reg cac_override_oland[] =
  1477. {
  1478. { 0xFFFFFFFF }
  1479. };
  1480. static const struct si_powertune_data powertune_data_oland =
  1481. {
  1482. ((1 << 16) | 0x6993),
  1483. 5,
  1484. 0,
  1485. 7,
  1486. 105,
  1487. {
  1488. 0UL,
  1489. 0UL,
  1490. 7194395UL,
  1491. 309631529UL,
  1492. -1270850L,
  1493. 4513710L,
  1494. 100
  1495. },
  1496. 117830498UL,
  1497. 12,
  1498. {
  1499. 0,
  1500. 0,
  1501. 0,
  1502. 0,
  1503. 0,
  1504. 0,
  1505. 0,
  1506. 0
  1507. },
  1508. true
  1509. };
  1510. static const struct si_powertune_data powertune_data_mars_pro =
  1511. {
  1512. ((1 << 16) | 0x6993),
  1513. 5,
  1514. 0,
  1515. 7,
  1516. 105,
  1517. {
  1518. 0UL,
  1519. 0UL,
  1520. 7194395UL,
  1521. 309631529UL,
  1522. -1270850L,
  1523. 4513710L,
  1524. 100
  1525. },
  1526. 117830498UL,
  1527. 12,
  1528. {
  1529. 0,
  1530. 0,
  1531. 0,
  1532. 0,
  1533. 0,
  1534. 0,
  1535. 0,
  1536. 0
  1537. },
  1538. true
  1539. };
  1540. static const struct si_dte_data dte_data_oland =
  1541. {
  1542. { 0, 0, 0, 0, 0 },
  1543. { 0, 0, 0, 0, 0 },
  1544. 0,
  1545. 0,
  1546. 0,
  1547. 0,
  1548. 0,
  1549. 0,
  1550. 0,
  1551. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1552. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1553. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1554. 0,
  1555. false
  1556. };
  1557. static const struct si_dte_data dte_data_mars_pro =
  1558. {
  1559. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  1560. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  1561. 5,
  1562. 55000,
  1563. 105,
  1564. 0xA,
  1565. 1,
  1566. 0,
  1567. 0x10,
  1568. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  1569. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  1570. { 0xF627, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1571. 90,
  1572. true
  1573. };
  1574. static const struct si_dte_data dte_data_sun_xt =
  1575. {
  1576. { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
  1577. { 0x0, 0x0, 0x0, 0x0, 0x0 },
  1578. 5,
  1579. 55000,
  1580. 105,
  1581. 0xA,
  1582. 1,
  1583. 0,
  1584. 0x10,
  1585. { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
  1586. { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
  1587. { 0xD555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1588. 90,
  1589. true
  1590. };
  1591. static const struct si_cac_config_reg cac_weights_hainan[] =
  1592. {
  1593. { 0x0, 0x0000ffff, 0, 0x2d9, SISLANDS_CACCONFIG_CGIND },
  1594. { 0x0, 0xffff0000, 16, 0x22b, SISLANDS_CACCONFIG_CGIND },
  1595. { 0x1, 0x0000ffff, 0, 0x21c, SISLANDS_CACCONFIG_CGIND },
  1596. { 0x1, 0xffff0000, 16, 0x1dc, SISLANDS_CACCONFIG_CGIND },
  1597. { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1598. { 0x3, 0x0000ffff, 0, 0x24e, SISLANDS_CACCONFIG_CGIND },
  1599. { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1600. { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1601. { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1602. { 0x5, 0x0000ffff, 0, 0x35e, SISLANDS_CACCONFIG_CGIND },
  1603. { 0x5, 0xffff0000, 16, 0x1143, SISLANDS_CACCONFIG_CGIND },
  1604. { 0x6, 0x0000ffff, 0, 0xe17, SISLANDS_CACCONFIG_CGIND },
  1605. { 0x6, 0xffff0000, 16, 0x441, SISLANDS_CACCONFIG_CGIND },
  1606. { 0x18f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1607. { 0x7, 0x0000ffff, 0, 0x28b, SISLANDS_CACCONFIG_CGIND },
  1608. { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1609. { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1610. { 0x8, 0xffff0000, 16, 0xabe, SISLANDS_CACCONFIG_CGIND },
  1611. { 0x9, 0x0000ffff, 0, 0xf11, SISLANDS_CACCONFIG_CGIND },
  1612. { 0xa, 0x0000ffff, 0, 0x907, SISLANDS_CACCONFIG_CGIND },
  1613. { 0xb, 0x0000ffff, 0, 0xb45, SISLANDS_CACCONFIG_CGIND },
  1614. { 0xb, 0xffff0000, 16, 0xd1e, SISLANDS_CACCONFIG_CGIND },
  1615. { 0xc, 0x0000ffff, 0, 0xa2c, SISLANDS_CACCONFIG_CGIND },
  1616. { 0xd, 0x0000ffff, 0, 0x62, SISLANDS_CACCONFIG_CGIND },
  1617. { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1618. { 0xe, 0x0000ffff, 0, 0x1f3, SISLANDS_CACCONFIG_CGIND },
  1619. { 0xf, 0x0000ffff, 0, 0x42, SISLANDS_CACCONFIG_CGIND },
  1620. { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1621. { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1622. { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1623. { 0x11, 0x0000ffff, 0, 0x709, SISLANDS_CACCONFIG_CGIND },
  1624. { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1625. { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1626. { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1627. { 0x13, 0xffff0000, 16, 0x3a, SISLANDS_CACCONFIG_CGIND },
  1628. { 0x14, 0x0000ffff, 0, 0x357, SISLANDS_CACCONFIG_CGIND },
  1629. { 0x15, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
  1630. { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1631. { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1632. { 0x16, 0x0000ffff, 0, 0x314, SISLANDS_CACCONFIG_CGIND },
  1633. { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1634. { 0x17, 0x0000ffff, 0, 0x6d, SISLANDS_CACCONFIG_CGIND },
  1635. { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1636. { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1637. { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
  1638. { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
  1639. { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1640. { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1641. { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1642. { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1643. { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1644. { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1645. { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1646. { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1647. { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1648. { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1649. { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1650. { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
  1651. { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
  1652. { 0x6d, 0x0000ffff, 0, 0x1b9, SISLANDS_CACCONFIG_CGIND },
  1653. { 0xFFFFFFFF }
  1654. };
  1655. static const struct si_powertune_data powertune_data_hainan =
  1656. {
  1657. ((1 << 16) | 0x6993),
  1658. 5,
  1659. 0,
  1660. 9,
  1661. 105,
  1662. {
  1663. 0UL,
  1664. 0UL,
  1665. 7194395UL,
  1666. 309631529UL,
  1667. -1270850L,
  1668. 4513710L,
  1669. 100
  1670. },
  1671. 117830498UL,
  1672. 12,
  1673. {
  1674. 0,
  1675. 0,
  1676. 0,
  1677. 0,
  1678. 0,
  1679. 0,
  1680. 0,
  1681. 0
  1682. },
  1683. true
  1684. };
  1685. struct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
  1686. struct evergreen_power_info *evergreen_get_pi(struct radeon_device *rdev);
  1687. struct ni_power_info *ni_get_pi(struct radeon_device *rdev);
  1688. struct ni_ps *ni_get_ps(struct radeon_ps *rps);
  1689. extern int si_mc_load_microcode(struct radeon_device *rdev);
  1690. extern void vce_v1_0_enable_mgcg(struct radeon_device *rdev, bool enable);
  1691. static int si_populate_voltage_value(struct radeon_device *rdev,
  1692. const struct atom_voltage_table *table,
  1693. u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage);
  1694. static int si_get_std_voltage_value(struct radeon_device *rdev,
  1695. SISLANDS_SMC_VOLTAGE_VALUE *voltage,
  1696. u16 *std_voltage);
  1697. static int si_write_smc_soft_register(struct radeon_device *rdev,
  1698. u16 reg_offset, u32 value);
  1699. static int si_convert_power_level_to_smc(struct radeon_device *rdev,
  1700. struct rv7xx_pl *pl,
  1701. SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level);
  1702. static int si_calculate_sclk_params(struct radeon_device *rdev,
  1703. u32 engine_clock,
  1704. SISLANDS_SMC_SCLK_VALUE *sclk);
  1705. static void si_thermal_start_smc_fan_control(struct radeon_device *rdev);
  1706. static void si_fan_ctrl_set_default_mode(struct radeon_device *rdev);
  1707. static struct si_power_info *si_get_pi(struct radeon_device *rdev)
  1708. {
  1709. struct si_power_info *pi = rdev->pm.dpm.priv;
  1710. return pi;
  1711. }
  1712. static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients *coeff,
  1713. u16 v, s32 t, u32 ileakage, u32 *leakage)
  1714. {
  1715. s64 kt, kv, leakage_w, i_leakage, vddc;
  1716. s64 temperature, t_slope, t_intercept, av, bv, t_ref;
  1717. s64 tmp;
  1718. i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
  1719. vddc = div64_s64(drm_int2fixp(v), 1000);
  1720. temperature = div64_s64(drm_int2fixp(t), 1000);
  1721. t_slope = div64_s64(drm_int2fixp(coeff->t_slope), 100000000);
  1722. t_intercept = div64_s64(drm_int2fixp(coeff->t_intercept), 100000000);
  1723. av = div64_s64(drm_int2fixp(coeff->av), 100000000);
  1724. bv = div64_s64(drm_int2fixp(coeff->bv), 100000000);
  1725. t_ref = drm_int2fixp(coeff->t_ref);
  1726. tmp = drm_fixp_mul(t_slope, vddc) + t_intercept;
  1727. kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature));
  1728. kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref)));
  1729. kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc)));
  1730. leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
  1731. *leakage = drm_fixp2int(leakage_w * 1000);
  1732. }
  1733. static void si_calculate_leakage_for_v_and_t(struct radeon_device *rdev,
  1734. const struct ni_leakage_coeffients *coeff,
  1735. u16 v,
  1736. s32 t,
  1737. u32 i_leakage,
  1738. u32 *leakage)
  1739. {
  1740. si_calculate_leakage_for_v_and_t_formula(coeff, v, t, i_leakage, leakage);
  1741. }
  1742. static void si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients *coeff,
  1743. const u32 fixed_kt, u16 v,
  1744. u32 ileakage, u32 *leakage)
  1745. {
  1746. s64 kt, kv, leakage_w, i_leakage, vddc;
  1747. i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
  1748. vddc = div64_s64(drm_int2fixp(v), 1000);
  1749. kt = div64_s64(drm_int2fixp(fixed_kt), 100000000);
  1750. kv = drm_fixp_mul(div64_s64(drm_int2fixp(coeff->av), 100000000),
  1751. drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff->bv), 100000000), vddc)));
  1752. leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
  1753. *leakage = drm_fixp2int(leakage_w * 1000);
  1754. }
  1755. static void si_calculate_leakage_for_v(struct radeon_device *rdev,
  1756. const struct ni_leakage_coeffients *coeff,
  1757. const u32 fixed_kt,
  1758. u16 v,
  1759. u32 i_leakage,
  1760. u32 *leakage)
  1761. {
  1762. si_calculate_leakage_for_v_formula(coeff, fixed_kt, v, i_leakage, leakage);
  1763. }
  1764. static void si_update_dte_from_pl2(struct radeon_device *rdev,
  1765. struct si_dte_data *dte_data)
  1766. {
  1767. u32 p_limit1 = rdev->pm.dpm.tdp_limit;
  1768. u32 p_limit2 = rdev->pm.dpm.near_tdp_limit;
  1769. u32 k = dte_data->k;
  1770. u32 t_max = dte_data->max_t;
  1771. u32 t_split[5] = { 10, 15, 20, 25, 30 };
  1772. u32 t_0 = dte_data->t0;
  1773. u32 i;
  1774. if (p_limit2 != 0 && p_limit2 <= p_limit1) {
  1775. dte_data->tdep_count = 3;
  1776. for (i = 0; i < k; i++) {
  1777. dte_data->r[i] =
  1778. (t_split[i] * (t_max - t_0/(u32)1000) * (1 << 14)) /
  1779. (p_limit2 * (u32)100);
  1780. }
  1781. dte_data->tdep_r[1] = dte_data->r[4] * 2;
  1782. for (i = 2; i < SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; i++) {
  1783. dte_data->tdep_r[i] = dte_data->r[4];
  1784. }
  1785. } else {
  1786. DRM_ERROR("Invalid PL2! DTE will not be updated.\n");
  1787. }
  1788. }
  1789. static void si_initialize_powertune_defaults(struct radeon_device *rdev)
  1790. {
  1791. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  1792. struct si_power_info *si_pi = si_get_pi(rdev);
  1793. bool update_dte_from_pl2 = false;
  1794. if (rdev->family == CHIP_TAHITI) {
  1795. si_pi->cac_weights = cac_weights_tahiti;
  1796. si_pi->lcac_config = lcac_tahiti;
  1797. si_pi->cac_override = cac_override_tahiti;
  1798. si_pi->powertune_data = &powertune_data_tahiti;
  1799. si_pi->dte_data = dte_data_tahiti;
  1800. switch (rdev->pdev->device) {
  1801. case 0x6798:
  1802. si_pi->dte_data.enable_dte_by_default = true;
  1803. break;
  1804. case 0x6799:
  1805. si_pi->dte_data = dte_data_new_zealand;
  1806. break;
  1807. case 0x6790:
  1808. case 0x6791:
  1809. case 0x6792:
  1810. case 0x679E:
  1811. si_pi->dte_data = dte_data_aruba_pro;
  1812. update_dte_from_pl2 = true;
  1813. break;
  1814. case 0x679B:
  1815. si_pi->dte_data = dte_data_malta;
  1816. update_dte_from_pl2 = true;
  1817. break;
  1818. case 0x679A:
  1819. si_pi->dte_data = dte_data_tahiti_pro;
  1820. update_dte_from_pl2 = true;
  1821. break;
  1822. default:
  1823. if (si_pi->dte_data.enable_dte_by_default == true)
  1824. DRM_ERROR("DTE is not enabled!\n");
  1825. break;
  1826. }
  1827. } else if (rdev->family == CHIP_PITCAIRN) {
  1828. switch (rdev->pdev->device) {
  1829. case 0x6810:
  1830. case 0x6818:
  1831. si_pi->cac_weights = cac_weights_pitcairn;
  1832. si_pi->lcac_config = lcac_pitcairn;
  1833. si_pi->cac_override = cac_override_pitcairn;
  1834. si_pi->powertune_data = &powertune_data_pitcairn;
  1835. si_pi->dte_data = dte_data_curacao_xt;
  1836. update_dte_from_pl2 = true;
  1837. break;
  1838. case 0x6819:
  1839. case 0x6811:
  1840. si_pi->cac_weights = cac_weights_pitcairn;
  1841. si_pi->lcac_config = lcac_pitcairn;
  1842. si_pi->cac_override = cac_override_pitcairn;
  1843. si_pi->powertune_data = &powertune_data_pitcairn;
  1844. si_pi->dte_data = dte_data_curacao_pro;
  1845. update_dte_from_pl2 = true;
  1846. break;
  1847. case 0x6800:
  1848. case 0x6806:
  1849. si_pi->cac_weights = cac_weights_pitcairn;
  1850. si_pi->lcac_config = lcac_pitcairn;
  1851. si_pi->cac_override = cac_override_pitcairn;
  1852. si_pi->powertune_data = &powertune_data_pitcairn;
  1853. si_pi->dte_data = dte_data_neptune_xt;
  1854. update_dte_from_pl2 = true;
  1855. break;
  1856. default:
  1857. si_pi->cac_weights = cac_weights_pitcairn;
  1858. si_pi->lcac_config = lcac_pitcairn;
  1859. si_pi->cac_override = cac_override_pitcairn;
  1860. si_pi->powertune_data = &powertune_data_pitcairn;
  1861. si_pi->dte_data = dte_data_pitcairn;
  1862. break;
  1863. }
  1864. } else if (rdev->family == CHIP_VERDE) {
  1865. si_pi->lcac_config = lcac_cape_verde;
  1866. si_pi->cac_override = cac_override_cape_verde;
  1867. si_pi->powertune_data = &powertune_data_cape_verde;
  1868. switch (rdev->pdev->device) {
  1869. case 0x683B:
  1870. case 0x683F:
  1871. case 0x6829:
  1872. case 0x6835:
  1873. si_pi->cac_weights = cac_weights_cape_verde_pro;
  1874. si_pi->dte_data = dte_data_cape_verde;
  1875. break;
  1876. case 0x682C:
  1877. si_pi->cac_weights = cac_weights_cape_verde_pro;
  1878. si_pi->dte_data = dte_data_sun_xt;
  1879. break;
  1880. case 0x6825:
  1881. case 0x6827:
  1882. si_pi->cac_weights = cac_weights_heathrow;
  1883. si_pi->dte_data = dte_data_cape_verde;
  1884. break;
  1885. case 0x6824:
  1886. case 0x682D:
  1887. si_pi->cac_weights = cac_weights_chelsea_xt;
  1888. si_pi->dte_data = dte_data_cape_verde;
  1889. break;
  1890. case 0x682F:
  1891. si_pi->cac_weights = cac_weights_chelsea_pro;
  1892. si_pi->dte_data = dte_data_cape_verde;
  1893. break;
  1894. case 0x6820:
  1895. si_pi->cac_weights = cac_weights_heathrow;
  1896. si_pi->dte_data = dte_data_venus_xtx;
  1897. break;
  1898. case 0x6821:
  1899. si_pi->cac_weights = cac_weights_heathrow;
  1900. si_pi->dte_data = dte_data_venus_xt;
  1901. break;
  1902. case 0x6823:
  1903. case 0x682B:
  1904. case 0x6822:
  1905. case 0x682A:
  1906. si_pi->cac_weights = cac_weights_chelsea_pro;
  1907. si_pi->dte_data = dte_data_venus_pro;
  1908. break;
  1909. default:
  1910. si_pi->cac_weights = cac_weights_cape_verde;
  1911. si_pi->dte_data = dte_data_cape_verde;
  1912. break;
  1913. }
  1914. } else if (rdev->family == CHIP_OLAND) {
  1915. switch (rdev->pdev->device) {
  1916. case 0x6601:
  1917. case 0x6621:
  1918. case 0x6603:
  1919. case 0x6605:
  1920. si_pi->cac_weights = cac_weights_mars_pro;
  1921. si_pi->lcac_config = lcac_mars_pro;
  1922. si_pi->cac_override = cac_override_oland;
  1923. si_pi->powertune_data = &powertune_data_mars_pro;
  1924. si_pi->dte_data = dte_data_mars_pro;
  1925. update_dte_from_pl2 = true;
  1926. break;
  1927. case 0x6600:
  1928. case 0x6606:
  1929. case 0x6620:
  1930. case 0x6604:
  1931. si_pi->cac_weights = cac_weights_mars_xt;
  1932. si_pi->lcac_config = lcac_mars_pro;
  1933. si_pi->cac_override = cac_override_oland;
  1934. si_pi->powertune_data = &powertune_data_mars_pro;
  1935. si_pi->dte_data = dte_data_mars_pro;
  1936. update_dte_from_pl2 = true;
  1937. break;
  1938. case 0x6611:
  1939. case 0x6613:
  1940. case 0x6608:
  1941. si_pi->cac_weights = cac_weights_oland_pro;
  1942. si_pi->lcac_config = lcac_mars_pro;
  1943. si_pi->cac_override = cac_override_oland;
  1944. si_pi->powertune_data = &powertune_data_mars_pro;
  1945. si_pi->dte_data = dte_data_mars_pro;
  1946. update_dte_from_pl2 = true;
  1947. break;
  1948. case 0x6610:
  1949. si_pi->cac_weights = cac_weights_oland_xt;
  1950. si_pi->lcac_config = lcac_mars_pro;
  1951. si_pi->cac_override = cac_override_oland;
  1952. si_pi->powertune_data = &powertune_data_mars_pro;
  1953. si_pi->dte_data = dte_data_mars_pro;
  1954. update_dte_from_pl2 = true;
  1955. break;
  1956. default:
  1957. si_pi->cac_weights = cac_weights_oland;
  1958. si_pi->lcac_config = lcac_oland;
  1959. si_pi->cac_override = cac_override_oland;
  1960. si_pi->powertune_data = &powertune_data_oland;
  1961. si_pi->dte_data = dte_data_oland;
  1962. break;
  1963. }
  1964. } else if (rdev->family == CHIP_HAINAN) {
  1965. si_pi->cac_weights = cac_weights_hainan;
  1966. si_pi->lcac_config = lcac_oland;
  1967. si_pi->cac_override = cac_override_oland;
  1968. si_pi->powertune_data = &powertune_data_hainan;
  1969. si_pi->dte_data = dte_data_sun_xt;
  1970. update_dte_from_pl2 = true;
  1971. } else {
  1972. DRM_ERROR("Unknown SI asic revision, failed to initialize PowerTune!\n");
  1973. return;
  1974. }
  1975. ni_pi->enable_power_containment = false;
  1976. ni_pi->enable_cac = false;
  1977. ni_pi->enable_sq_ramping = false;
  1978. si_pi->enable_dte = false;
  1979. if (si_pi->powertune_data->enable_powertune_by_default) {
  1980. ni_pi->enable_power_containment= true;
  1981. ni_pi->enable_cac = true;
  1982. if (si_pi->dte_data.enable_dte_by_default) {
  1983. si_pi->enable_dte = true;
  1984. if (update_dte_from_pl2)
  1985. si_update_dte_from_pl2(rdev, &si_pi->dte_data);
  1986. }
  1987. ni_pi->enable_sq_ramping = true;
  1988. }
  1989. ni_pi->driver_calculate_cac_leakage = true;
  1990. ni_pi->cac_configuration_required = true;
  1991. if (ni_pi->cac_configuration_required) {
  1992. ni_pi->support_cac_long_term_average = true;
  1993. si_pi->dyn_powertune_data.l2_lta_window_size =
  1994. si_pi->powertune_data->l2_lta_window_size_default;
  1995. si_pi->dyn_powertune_data.lts_truncate =
  1996. si_pi->powertune_data->lts_truncate_default;
  1997. } else {
  1998. ni_pi->support_cac_long_term_average = false;
  1999. si_pi->dyn_powertune_data.l2_lta_window_size = 0;
  2000. si_pi->dyn_powertune_data.lts_truncate = 0;
  2001. }
  2002. si_pi->dyn_powertune_data.disable_uvd_powertune = false;
  2003. }
  2004. static u32 si_get_smc_power_scaling_factor(struct radeon_device *rdev)
  2005. {
  2006. return 1;
  2007. }
  2008. static u32 si_calculate_cac_wintime(struct radeon_device *rdev)
  2009. {
  2010. u32 xclk;
  2011. u32 wintime;
  2012. u32 cac_window;
  2013. u32 cac_window_size;
  2014. xclk = radeon_get_xclk(rdev);
  2015. if (xclk == 0)
  2016. return 0;
  2017. cac_window = RREG32(CG_CAC_CTRL) & CAC_WINDOW_MASK;
  2018. cac_window_size = ((cac_window & 0xFFFF0000) >> 16) * (cac_window & 0x0000FFFF);
  2019. wintime = (cac_window_size * 100) / xclk;
  2020. return wintime;
  2021. }
  2022. static u32 si_scale_power_for_smc(u32 power_in_watts, u32 scaling_factor)
  2023. {
  2024. return power_in_watts;
  2025. }
  2026. static int si_calculate_adjusted_tdp_limits(struct radeon_device *rdev,
  2027. bool adjust_polarity,
  2028. u32 tdp_adjustment,
  2029. u32 *tdp_limit,
  2030. u32 *near_tdp_limit)
  2031. {
  2032. u32 adjustment_delta, max_tdp_limit;
  2033. if (tdp_adjustment > (u32)rdev->pm.dpm.tdp_od_limit)
  2034. return -EINVAL;
  2035. max_tdp_limit = ((100 + 100) * rdev->pm.dpm.tdp_limit) / 100;
  2036. if (adjust_polarity) {
  2037. *tdp_limit = ((100 + tdp_adjustment) * rdev->pm.dpm.tdp_limit) / 100;
  2038. *near_tdp_limit = rdev->pm.dpm.near_tdp_limit_adjusted + (*tdp_limit - rdev->pm.dpm.tdp_limit);
  2039. } else {
  2040. *tdp_limit = ((100 - tdp_adjustment) * rdev->pm.dpm.tdp_limit) / 100;
  2041. adjustment_delta = rdev->pm.dpm.tdp_limit - *tdp_limit;
  2042. if (adjustment_delta < rdev->pm.dpm.near_tdp_limit_adjusted)
  2043. *near_tdp_limit = rdev->pm.dpm.near_tdp_limit_adjusted - adjustment_delta;
  2044. else
  2045. *near_tdp_limit = 0;
  2046. }
  2047. if ((*tdp_limit <= 0) || (*tdp_limit > max_tdp_limit))
  2048. return -EINVAL;
  2049. if ((*near_tdp_limit <= 0) || (*near_tdp_limit > *tdp_limit))
  2050. return -EINVAL;
  2051. return 0;
  2052. }
  2053. static int si_populate_smc_tdp_limits(struct radeon_device *rdev,
  2054. struct radeon_ps *radeon_state)
  2055. {
  2056. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2057. struct si_power_info *si_pi = si_get_pi(rdev);
  2058. if (ni_pi->enable_power_containment) {
  2059. SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
  2060. PP_SIslands_PAPMParameters *papm_parm;
  2061. struct radeon_ppm_table *ppm = rdev->pm.dpm.dyn_state.ppm_table;
  2062. u32 scaling_factor = si_get_smc_power_scaling_factor(rdev);
  2063. u32 tdp_limit;
  2064. u32 near_tdp_limit;
  2065. int ret;
  2066. if (scaling_factor == 0)
  2067. return -EINVAL;
  2068. memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
  2069. ret = si_calculate_adjusted_tdp_limits(rdev,
  2070. false, /* ??? */
  2071. rdev->pm.dpm.tdp_adjustment,
  2072. &tdp_limit,
  2073. &near_tdp_limit);
  2074. if (ret)
  2075. return ret;
  2076. smc_table->dpm2Params.TDPLimit =
  2077. cpu_to_be32(si_scale_power_for_smc(tdp_limit, scaling_factor) * 1000);
  2078. smc_table->dpm2Params.NearTDPLimit =
  2079. cpu_to_be32(si_scale_power_for_smc(near_tdp_limit, scaling_factor) * 1000);
  2080. smc_table->dpm2Params.SafePowerLimit =
  2081. cpu_to_be32(si_scale_power_for_smc((near_tdp_limit * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
  2082. ret = si_copy_bytes_to_smc(rdev,
  2083. (si_pi->state_table_start + offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
  2084. offsetof(PP_SIslands_DPM2Parameters, TDPLimit)),
  2085. (u8 *)(&(smc_table->dpm2Params.TDPLimit)),
  2086. sizeof(u32) * 3,
  2087. si_pi->sram_end);
  2088. if (ret)
  2089. return ret;
  2090. if (si_pi->enable_ppm) {
  2091. papm_parm = &si_pi->papm_parm;
  2092. memset(papm_parm, 0, sizeof(PP_SIslands_PAPMParameters));
  2093. papm_parm->NearTDPLimitTherm = cpu_to_be32(ppm->dgpu_tdp);
  2094. papm_parm->dGPU_T_Limit = cpu_to_be32(ppm->tj_max);
  2095. papm_parm->dGPU_T_Warning = cpu_to_be32(95);
  2096. papm_parm->dGPU_T_Hysteresis = cpu_to_be32(5);
  2097. papm_parm->PlatformPowerLimit = 0xffffffff;
  2098. papm_parm->NearTDPLimitPAPM = 0xffffffff;
  2099. ret = si_copy_bytes_to_smc(rdev, si_pi->papm_cfg_table_start,
  2100. (u8 *)papm_parm,
  2101. sizeof(PP_SIslands_PAPMParameters),
  2102. si_pi->sram_end);
  2103. if (ret)
  2104. return ret;
  2105. }
  2106. }
  2107. return 0;
  2108. }
  2109. static int si_populate_smc_tdp_limits_2(struct radeon_device *rdev,
  2110. struct radeon_ps *radeon_state)
  2111. {
  2112. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2113. struct si_power_info *si_pi = si_get_pi(rdev);
  2114. if (ni_pi->enable_power_containment) {
  2115. SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
  2116. u32 scaling_factor = si_get_smc_power_scaling_factor(rdev);
  2117. int ret;
  2118. memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
  2119. smc_table->dpm2Params.NearTDPLimit =
  2120. cpu_to_be32(si_scale_power_for_smc(rdev->pm.dpm.near_tdp_limit_adjusted, scaling_factor) * 1000);
  2121. smc_table->dpm2Params.SafePowerLimit =
  2122. cpu_to_be32(si_scale_power_for_smc((rdev->pm.dpm.near_tdp_limit_adjusted * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
  2123. ret = si_copy_bytes_to_smc(rdev,
  2124. (si_pi->state_table_start +
  2125. offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
  2126. offsetof(PP_SIslands_DPM2Parameters, NearTDPLimit)),
  2127. (u8 *)(&(smc_table->dpm2Params.NearTDPLimit)),
  2128. sizeof(u32) * 2,
  2129. si_pi->sram_end);
  2130. if (ret)
  2131. return ret;
  2132. }
  2133. return 0;
  2134. }
  2135. static u16 si_calculate_power_efficiency_ratio(struct radeon_device *rdev,
  2136. const u16 prev_std_vddc,
  2137. const u16 curr_std_vddc)
  2138. {
  2139. u64 margin = (u64)SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN;
  2140. u64 prev_vddc = (u64)prev_std_vddc;
  2141. u64 curr_vddc = (u64)curr_std_vddc;
  2142. u64 pwr_efficiency_ratio, n, d;
  2143. if ((prev_vddc == 0) || (curr_vddc == 0))
  2144. return 0;
  2145. n = div64_u64((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin), (u64)1000);
  2146. d = prev_vddc * prev_vddc;
  2147. pwr_efficiency_ratio = div64_u64(n, d);
  2148. if (pwr_efficiency_ratio > (u64)0xFFFF)
  2149. return 0;
  2150. return (u16)pwr_efficiency_ratio;
  2151. }
  2152. static bool si_should_disable_uvd_powertune(struct radeon_device *rdev,
  2153. struct radeon_ps *radeon_state)
  2154. {
  2155. struct si_power_info *si_pi = si_get_pi(rdev);
  2156. if (si_pi->dyn_powertune_data.disable_uvd_powertune &&
  2157. radeon_state->vclk && radeon_state->dclk)
  2158. return true;
  2159. return false;
  2160. }
  2161. static int si_populate_power_containment_values(struct radeon_device *rdev,
  2162. struct radeon_ps *radeon_state,
  2163. SISLANDS_SMC_SWSTATE *smc_state)
  2164. {
  2165. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2166. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2167. struct ni_ps *state = ni_get_ps(radeon_state);
  2168. SISLANDS_SMC_VOLTAGE_VALUE vddc;
  2169. u32 prev_sclk;
  2170. u32 max_sclk;
  2171. u32 min_sclk;
  2172. u16 prev_std_vddc;
  2173. u16 curr_std_vddc;
  2174. int i;
  2175. u16 pwr_efficiency_ratio;
  2176. u8 max_ps_percent;
  2177. bool disable_uvd_power_tune;
  2178. int ret;
  2179. if (ni_pi->enable_power_containment == false)
  2180. return 0;
  2181. if (state->performance_level_count == 0)
  2182. return -EINVAL;
  2183. if (smc_state->levelCount != state->performance_level_count)
  2184. return -EINVAL;
  2185. disable_uvd_power_tune = si_should_disable_uvd_powertune(rdev, radeon_state);
  2186. smc_state->levels[0].dpm2.MaxPS = 0;
  2187. smc_state->levels[0].dpm2.NearTDPDec = 0;
  2188. smc_state->levels[0].dpm2.AboveSafeInc = 0;
  2189. smc_state->levels[0].dpm2.BelowSafeInc = 0;
  2190. smc_state->levels[0].dpm2.PwrEfficiencyRatio = 0;
  2191. for (i = 1; i < state->performance_level_count; i++) {
  2192. prev_sclk = state->performance_levels[i-1].sclk;
  2193. max_sclk = state->performance_levels[i].sclk;
  2194. if (i == 1)
  2195. max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_M;
  2196. else
  2197. max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_H;
  2198. if (prev_sclk > max_sclk)
  2199. return -EINVAL;
  2200. if ((max_ps_percent == 0) ||
  2201. (prev_sclk == max_sclk) ||
  2202. disable_uvd_power_tune) {
  2203. min_sclk = max_sclk;
  2204. } else if (i == 1) {
  2205. min_sclk = prev_sclk;
  2206. } else {
  2207. min_sclk = (prev_sclk * (u32)max_ps_percent) / 100;
  2208. }
  2209. if (min_sclk < state->performance_levels[0].sclk)
  2210. min_sclk = state->performance_levels[0].sclk;
  2211. if (min_sclk == 0)
  2212. return -EINVAL;
  2213. ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
  2214. state->performance_levels[i-1].vddc, &vddc);
  2215. if (ret)
  2216. return ret;
  2217. ret = si_get_std_voltage_value(rdev, &vddc, &prev_std_vddc);
  2218. if (ret)
  2219. return ret;
  2220. ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
  2221. state->performance_levels[i].vddc, &vddc);
  2222. if (ret)
  2223. return ret;
  2224. ret = si_get_std_voltage_value(rdev, &vddc, &curr_std_vddc);
  2225. if (ret)
  2226. return ret;
  2227. pwr_efficiency_ratio = si_calculate_power_efficiency_ratio(rdev,
  2228. prev_std_vddc, curr_std_vddc);
  2229. smc_state->levels[i].dpm2.MaxPS = (u8)((SISLANDS_DPM2_MAX_PULSE_SKIP * (max_sclk - min_sclk)) / max_sclk);
  2230. smc_state->levels[i].dpm2.NearTDPDec = SISLANDS_DPM2_NEAR_TDP_DEC;
  2231. smc_state->levels[i].dpm2.AboveSafeInc = SISLANDS_DPM2_ABOVE_SAFE_INC;
  2232. smc_state->levels[i].dpm2.BelowSafeInc = SISLANDS_DPM2_BELOW_SAFE_INC;
  2233. smc_state->levels[i].dpm2.PwrEfficiencyRatio = cpu_to_be16(pwr_efficiency_ratio);
  2234. }
  2235. return 0;
  2236. }
  2237. static int si_populate_sq_ramping_values(struct radeon_device *rdev,
  2238. struct radeon_ps *radeon_state,
  2239. SISLANDS_SMC_SWSTATE *smc_state)
  2240. {
  2241. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2242. struct ni_ps *state = ni_get_ps(radeon_state);
  2243. u32 sq_power_throttle, sq_power_throttle2;
  2244. bool enable_sq_ramping = ni_pi->enable_sq_ramping;
  2245. int i;
  2246. if (state->performance_level_count == 0)
  2247. return -EINVAL;
  2248. if (smc_state->levelCount != state->performance_level_count)
  2249. return -EINVAL;
  2250. if (rdev->pm.dpm.sq_ramping_threshold == 0)
  2251. return -EINVAL;
  2252. if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER > (MAX_POWER_MASK >> MAX_POWER_SHIFT))
  2253. enable_sq_ramping = false;
  2254. if (SISLANDS_DPM2_SQ_RAMP_MIN_POWER > (MIN_POWER_MASK >> MIN_POWER_SHIFT))
  2255. enable_sq_ramping = false;
  2256. if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA > (MAX_POWER_DELTA_MASK >> MAX_POWER_DELTA_SHIFT))
  2257. enable_sq_ramping = false;
  2258. if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
  2259. enable_sq_ramping = false;
  2260. if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
  2261. enable_sq_ramping = false;
  2262. for (i = 0; i < state->performance_level_count; i++) {
  2263. sq_power_throttle = 0;
  2264. sq_power_throttle2 = 0;
  2265. if ((state->performance_levels[i].sclk >= rdev->pm.dpm.sq_ramping_threshold) &&
  2266. enable_sq_ramping) {
  2267. sq_power_throttle |= MAX_POWER(SISLANDS_DPM2_SQ_RAMP_MAX_POWER);
  2268. sq_power_throttle |= MIN_POWER(SISLANDS_DPM2_SQ_RAMP_MIN_POWER);
  2269. sq_power_throttle2 |= MAX_POWER_DELTA(SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA);
  2270. sq_power_throttle2 |= STI_SIZE(SISLANDS_DPM2_SQ_RAMP_STI_SIZE);
  2271. sq_power_throttle2 |= LTI_RATIO(SISLANDS_DPM2_SQ_RAMP_LTI_RATIO);
  2272. } else {
  2273. sq_power_throttle |= MAX_POWER_MASK | MIN_POWER_MASK;
  2274. sq_power_throttle2 |= MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
  2275. }
  2276. smc_state->levels[i].SQPowerThrottle = cpu_to_be32(sq_power_throttle);
  2277. smc_state->levels[i].SQPowerThrottle_2 = cpu_to_be32(sq_power_throttle2);
  2278. }
  2279. return 0;
  2280. }
  2281. static int si_enable_power_containment(struct radeon_device *rdev,
  2282. struct radeon_ps *radeon_new_state,
  2283. bool enable)
  2284. {
  2285. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2286. PPSMC_Result smc_result;
  2287. int ret = 0;
  2288. if (ni_pi->enable_power_containment) {
  2289. if (enable) {
  2290. if (!si_should_disable_uvd_powertune(rdev, radeon_new_state)) {
  2291. smc_result = si_send_msg_to_smc(rdev, PPSMC_TDPClampingActive);
  2292. if (smc_result != PPSMC_Result_OK) {
  2293. ret = -EINVAL;
  2294. ni_pi->pc_enabled = false;
  2295. } else {
  2296. ni_pi->pc_enabled = true;
  2297. }
  2298. }
  2299. } else {
  2300. smc_result = si_send_msg_to_smc(rdev, PPSMC_TDPClampingInactive);
  2301. if (smc_result != PPSMC_Result_OK)
  2302. ret = -EINVAL;
  2303. ni_pi->pc_enabled = false;
  2304. }
  2305. }
  2306. return ret;
  2307. }
  2308. static int si_initialize_smc_dte_tables(struct radeon_device *rdev)
  2309. {
  2310. struct si_power_info *si_pi = si_get_pi(rdev);
  2311. int ret = 0;
  2312. struct si_dte_data *dte_data = &si_pi->dte_data;
  2313. Smc_SIslands_DTE_Configuration *dte_tables = NULL;
  2314. u32 table_size;
  2315. u8 tdep_count;
  2316. u32 i;
  2317. if (dte_data == NULL)
  2318. si_pi->enable_dte = false;
  2319. if (si_pi->enable_dte == false)
  2320. return 0;
  2321. if (dte_data->k <= 0)
  2322. return -EINVAL;
  2323. dte_tables = kzalloc(sizeof(Smc_SIslands_DTE_Configuration), GFP_KERNEL);
  2324. if (dte_tables == NULL) {
  2325. si_pi->enable_dte = false;
  2326. return -ENOMEM;
  2327. }
  2328. table_size = dte_data->k;
  2329. if (table_size > SMC_SISLANDS_DTE_MAX_FILTER_STAGES)
  2330. table_size = SMC_SISLANDS_DTE_MAX_FILTER_STAGES;
  2331. tdep_count = dte_data->tdep_count;
  2332. if (tdep_count > SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE)
  2333. tdep_count = SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE;
  2334. dte_tables->K = cpu_to_be32(table_size);
  2335. dte_tables->T0 = cpu_to_be32(dte_data->t0);
  2336. dte_tables->MaxT = cpu_to_be32(dte_data->max_t);
  2337. dte_tables->WindowSize = dte_data->window_size;
  2338. dte_tables->temp_select = dte_data->temp_select;
  2339. dte_tables->DTE_mode = dte_data->dte_mode;
  2340. dte_tables->Tthreshold = cpu_to_be32(dte_data->t_threshold);
  2341. if (tdep_count > 0)
  2342. table_size--;
  2343. for (i = 0; i < table_size; i++) {
  2344. dte_tables->tau[i] = cpu_to_be32(dte_data->tau[i]);
  2345. dte_tables->R[i] = cpu_to_be32(dte_data->r[i]);
  2346. }
  2347. dte_tables->Tdep_count = tdep_count;
  2348. for (i = 0; i < (u32)tdep_count; i++) {
  2349. dte_tables->T_limits[i] = dte_data->t_limits[i];
  2350. dte_tables->Tdep_tau[i] = cpu_to_be32(dte_data->tdep_tau[i]);
  2351. dte_tables->Tdep_R[i] = cpu_to_be32(dte_data->tdep_r[i]);
  2352. }
  2353. ret = si_copy_bytes_to_smc(rdev, si_pi->dte_table_start, (u8 *)dte_tables,
  2354. sizeof(Smc_SIslands_DTE_Configuration), si_pi->sram_end);
  2355. kfree(dte_tables);
  2356. return ret;
  2357. }
  2358. static int si_get_cac_std_voltage_max_min(struct radeon_device *rdev,
  2359. u16 *max, u16 *min)
  2360. {
  2361. struct si_power_info *si_pi = si_get_pi(rdev);
  2362. struct radeon_cac_leakage_table *table =
  2363. &rdev->pm.dpm.dyn_state.cac_leakage_table;
  2364. u32 i;
  2365. u32 v0_loadline;
  2366. if (table == NULL)
  2367. return -EINVAL;
  2368. *max = 0;
  2369. *min = 0xFFFF;
  2370. for (i = 0; i < table->count; i++) {
  2371. if (table->entries[i].vddc > *max)
  2372. *max = table->entries[i].vddc;
  2373. if (table->entries[i].vddc < *min)
  2374. *min = table->entries[i].vddc;
  2375. }
  2376. if (si_pi->powertune_data->lkge_lut_v0_percent > 100)
  2377. return -EINVAL;
  2378. v0_loadline = (*min) * (100 - si_pi->powertune_data->lkge_lut_v0_percent) / 100;
  2379. if (v0_loadline > 0xFFFFUL)
  2380. return -EINVAL;
  2381. *min = (u16)v0_loadline;
  2382. if ((*min > *max) || (*max == 0) || (*min == 0))
  2383. return -EINVAL;
  2384. return 0;
  2385. }
  2386. static u16 si_get_cac_std_voltage_step(u16 max, u16 min)
  2387. {
  2388. return ((max - min) + (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)) /
  2389. SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES;
  2390. }
  2391. static int si_init_dte_leakage_table(struct radeon_device *rdev,
  2392. PP_SIslands_CacConfig *cac_tables,
  2393. u16 vddc_max, u16 vddc_min, u16 vddc_step,
  2394. u16 t0, u16 t_step)
  2395. {
  2396. struct si_power_info *si_pi = si_get_pi(rdev);
  2397. u32 leakage;
  2398. unsigned int i, j;
  2399. s32 t;
  2400. u32 smc_leakage;
  2401. u32 scaling_factor;
  2402. u16 voltage;
  2403. scaling_factor = si_get_smc_power_scaling_factor(rdev);
  2404. for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) {
  2405. t = (1000 * (i * t_step + t0));
  2406. for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
  2407. voltage = vddc_max - (vddc_step * j);
  2408. si_calculate_leakage_for_v_and_t(rdev,
  2409. &si_pi->powertune_data->leakage_coefficients,
  2410. voltage,
  2411. t,
  2412. si_pi->dyn_powertune_data.cac_leakage,
  2413. &leakage);
  2414. smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
  2415. if (smc_leakage > 0xFFFF)
  2416. smc_leakage = 0xFFFF;
  2417. cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
  2418. cpu_to_be16((u16)smc_leakage);
  2419. }
  2420. }
  2421. return 0;
  2422. }
  2423. static int si_init_simplified_leakage_table(struct radeon_device *rdev,
  2424. PP_SIslands_CacConfig *cac_tables,
  2425. u16 vddc_max, u16 vddc_min, u16 vddc_step)
  2426. {
  2427. struct si_power_info *si_pi = si_get_pi(rdev);
  2428. u32 leakage;
  2429. unsigned int i, j;
  2430. u32 smc_leakage;
  2431. u32 scaling_factor;
  2432. u16 voltage;
  2433. scaling_factor = si_get_smc_power_scaling_factor(rdev);
  2434. for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
  2435. voltage = vddc_max - (vddc_step * j);
  2436. si_calculate_leakage_for_v(rdev,
  2437. &si_pi->powertune_data->leakage_coefficients,
  2438. si_pi->powertune_data->fixed_kt,
  2439. voltage,
  2440. si_pi->dyn_powertune_data.cac_leakage,
  2441. &leakage);
  2442. smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
  2443. if (smc_leakage > 0xFFFF)
  2444. smc_leakage = 0xFFFF;
  2445. for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++)
  2446. cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
  2447. cpu_to_be16((u16)smc_leakage);
  2448. }
  2449. return 0;
  2450. }
  2451. static int si_initialize_smc_cac_tables(struct radeon_device *rdev)
  2452. {
  2453. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2454. struct si_power_info *si_pi = si_get_pi(rdev);
  2455. PP_SIslands_CacConfig *cac_tables = NULL;
  2456. u16 vddc_max, vddc_min, vddc_step;
  2457. u16 t0, t_step;
  2458. u32 load_line_slope, reg;
  2459. int ret = 0;
  2460. u32 ticks_per_us = radeon_get_xclk(rdev) / 100;
  2461. if (ni_pi->enable_cac == false)
  2462. return 0;
  2463. cac_tables = kzalloc(sizeof(PP_SIslands_CacConfig), GFP_KERNEL);
  2464. if (!cac_tables)
  2465. return -ENOMEM;
  2466. reg = RREG32(CG_CAC_CTRL) & ~CAC_WINDOW_MASK;
  2467. reg |= CAC_WINDOW(si_pi->powertune_data->cac_window);
  2468. WREG32(CG_CAC_CTRL, reg);
  2469. si_pi->dyn_powertune_data.cac_leakage = rdev->pm.dpm.cac_leakage;
  2470. si_pi->dyn_powertune_data.dc_pwr_value =
  2471. si_pi->powertune_data->dc_cac[NISLANDS_DCCAC_LEVEL_0];
  2472. si_pi->dyn_powertune_data.wintime = si_calculate_cac_wintime(rdev);
  2473. si_pi->dyn_powertune_data.shift_n = si_pi->powertune_data->shift_n_default;
  2474. si_pi->dyn_powertune_data.leakage_minimum_temperature = 80 * 1000;
  2475. ret = si_get_cac_std_voltage_max_min(rdev, &vddc_max, &vddc_min);
  2476. if (ret)
  2477. goto done_free;
  2478. vddc_step = si_get_cac_std_voltage_step(vddc_max, vddc_min);
  2479. vddc_min = vddc_max - (vddc_step * (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1));
  2480. t_step = 4;
  2481. t0 = 60;
  2482. if (si_pi->enable_dte || ni_pi->driver_calculate_cac_leakage)
  2483. ret = si_init_dte_leakage_table(rdev, cac_tables,
  2484. vddc_max, vddc_min, vddc_step,
  2485. t0, t_step);
  2486. else
  2487. ret = si_init_simplified_leakage_table(rdev, cac_tables,
  2488. vddc_max, vddc_min, vddc_step);
  2489. if (ret)
  2490. goto done_free;
  2491. load_line_slope = ((u32)rdev->pm.dpm.load_line_slope << SMC_SISLANDS_SCALE_R) / 100;
  2492. cac_tables->l2numWin_TDP = cpu_to_be32(si_pi->dyn_powertune_data.l2_lta_window_size);
  2493. cac_tables->lts_truncate_n = si_pi->dyn_powertune_data.lts_truncate;
  2494. cac_tables->SHIFT_N = si_pi->dyn_powertune_data.shift_n;
  2495. cac_tables->lkge_lut_V0 = cpu_to_be32((u32)vddc_min);
  2496. cac_tables->lkge_lut_Vstep = cpu_to_be32((u32)vddc_step);
  2497. cac_tables->R_LL = cpu_to_be32(load_line_slope);
  2498. cac_tables->WinTime = cpu_to_be32(si_pi->dyn_powertune_data.wintime);
  2499. cac_tables->calculation_repeats = cpu_to_be32(2);
  2500. cac_tables->dc_cac = cpu_to_be32(0);
  2501. cac_tables->log2_PG_LKG_SCALE = 12;
  2502. cac_tables->cac_temp = si_pi->powertune_data->operating_temp;
  2503. cac_tables->lkge_lut_T0 = cpu_to_be32((u32)t0);
  2504. cac_tables->lkge_lut_Tstep = cpu_to_be32((u32)t_step);
  2505. ret = si_copy_bytes_to_smc(rdev, si_pi->cac_table_start, (u8 *)cac_tables,
  2506. sizeof(PP_SIslands_CacConfig), si_pi->sram_end);
  2507. if (ret)
  2508. goto done_free;
  2509. ret = si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_ticks_per_us, ticks_per_us);
  2510. done_free:
  2511. if (ret) {
  2512. ni_pi->enable_cac = false;
  2513. ni_pi->enable_power_containment = false;
  2514. }
  2515. kfree(cac_tables);
  2516. return 0;
  2517. }
  2518. static int si_program_cac_config_registers(struct radeon_device *rdev,
  2519. const struct si_cac_config_reg *cac_config_regs)
  2520. {
  2521. const struct si_cac_config_reg *config_regs = cac_config_regs;
  2522. u32 data = 0, offset;
  2523. if (!config_regs)
  2524. return -EINVAL;
  2525. while (config_regs->offset != 0xFFFFFFFF) {
  2526. switch (config_regs->type) {
  2527. case SISLANDS_CACCONFIG_CGIND:
  2528. offset = SMC_CG_IND_START + config_regs->offset;
  2529. if (offset < SMC_CG_IND_END)
  2530. data = RREG32_SMC(offset);
  2531. break;
  2532. default:
  2533. data = RREG32(config_regs->offset << 2);
  2534. break;
  2535. }
  2536. data &= ~config_regs->mask;
  2537. data |= ((config_regs->value << config_regs->shift) & config_regs->mask);
  2538. switch (config_regs->type) {
  2539. case SISLANDS_CACCONFIG_CGIND:
  2540. offset = SMC_CG_IND_START + config_regs->offset;
  2541. if (offset < SMC_CG_IND_END)
  2542. WREG32_SMC(offset, data);
  2543. break;
  2544. default:
  2545. WREG32(config_regs->offset << 2, data);
  2546. break;
  2547. }
  2548. config_regs++;
  2549. }
  2550. return 0;
  2551. }
  2552. static int si_initialize_hardware_cac_manager(struct radeon_device *rdev)
  2553. {
  2554. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2555. struct si_power_info *si_pi = si_get_pi(rdev);
  2556. int ret;
  2557. if ((ni_pi->enable_cac == false) ||
  2558. (ni_pi->cac_configuration_required == false))
  2559. return 0;
  2560. ret = si_program_cac_config_registers(rdev, si_pi->lcac_config);
  2561. if (ret)
  2562. return ret;
  2563. ret = si_program_cac_config_registers(rdev, si_pi->cac_override);
  2564. if (ret)
  2565. return ret;
  2566. ret = si_program_cac_config_registers(rdev, si_pi->cac_weights);
  2567. if (ret)
  2568. return ret;
  2569. return 0;
  2570. }
  2571. static int si_enable_smc_cac(struct radeon_device *rdev,
  2572. struct radeon_ps *radeon_new_state,
  2573. bool enable)
  2574. {
  2575. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2576. struct si_power_info *si_pi = si_get_pi(rdev);
  2577. PPSMC_Result smc_result;
  2578. int ret = 0;
  2579. if (ni_pi->enable_cac) {
  2580. if (enable) {
  2581. if (!si_should_disable_uvd_powertune(rdev, radeon_new_state)) {
  2582. if (ni_pi->support_cac_long_term_average) {
  2583. smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgEnable);
  2584. if (smc_result != PPSMC_Result_OK)
  2585. ni_pi->support_cac_long_term_average = false;
  2586. }
  2587. smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableCac);
  2588. if (smc_result != PPSMC_Result_OK) {
  2589. ret = -EINVAL;
  2590. ni_pi->cac_enabled = false;
  2591. } else {
  2592. ni_pi->cac_enabled = true;
  2593. }
  2594. if (si_pi->enable_dte) {
  2595. smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableDTE);
  2596. if (smc_result != PPSMC_Result_OK)
  2597. ret = -EINVAL;
  2598. }
  2599. }
  2600. } else if (ni_pi->cac_enabled) {
  2601. if (si_pi->enable_dte)
  2602. smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableDTE);
  2603. smc_result = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableCac);
  2604. ni_pi->cac_enabled = false;
  2605. if (ni_pi->support_cac_long_term_average)
  2606. smc_result = si_send_msg_to_smc(rdev, PPSMC_CACLongTermAvgDisable);
  2607. }
  2608. }
  2609. return ret;
  2610. }
  2611. static int si_init_smc_spll_table(struct radeon_device *rdev)
  2612. {
  2613. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  2614. struct si_power_info *si_pi = si_get_pi(rdev);
  2615. SMC_SISLANDS_SPLL_DIV_TABLE *spll_table;
  2616. SISLANDS_SMC_SCLK_VALUE sclk_params;
  2617. u32 fb_div, p_div;
  2618. u32 clk_s, clk_v;
  2619. u32 sclk = 0;
  2620. int ret = 0;
  2621. u32 tmp;
  2622. int i;
  2623. if (si_pi->spll_table_start == 0)
  2624. return -EINVAL;
  2625. spll_table = kzalloc(sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), GFP_KERNEL);
  2626. if (spll_table == NULL)
  2627. return -ENOMEM;
  2628. for (i = 0; i < 256; i++) {
  2629. ret = si_calculate_sclk_params(rdev, sclk, &sclk_params);
  2630. if (ret)
  2631. break;
  2632. p_div = (sclk_params.vCG_SPLL_FUNC_CNTL & SPLL_PDIV_A_MASK) >> SPLL_PDIV_A_SHIFT;
  2633. fb_div = (sclk_params.vCG_SPLL_FUNC_CNTL_3 & SPLL_FB_DIV_MASK) >> SPLL_FB_DIV_SHIFT;
  2634. clk_s = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM & CLK_S_MASK) >> CLK_S_SHIFT;
  2635. clk_v = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM_2 & CLK_V_MASK) >> CLK_V_SHIFT;
  2636. fb_div &= ~0x00001FFF;
  2637. fb_div >>= 1;
  2638. clk_v >>= 6;
  2639. if (p_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT))
  2640. ret = -EINVAL;
  2641. if (fb_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT))
  2642. ret = -EINVAL;
  2643. if (clk_s & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
  2644. ret = -EINVAL;
  2645. if (clk_v & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT))
  2646. ret = -EINVAL;
  2647. if (ret)
  2648. break;
  2649. tmp = ((fb_div << SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK) |
  2650. ((p_div << SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK);
  2651. spll_table->freq[i] = cpu_to_be32(tmp);
  2652. tmp = ((clk_v << SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK) |
  2653. ((clk_s << SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK);
  2654. spll_table->ss[i] = cpu_to_be32(tmp);
  2655. sclk += 512;
  2656. }
  2657. if (!ret)
  2658. ret = si_copy_bytes_to_smc(rdev, si_pi->spll_table_start,
  2659. (u8 *)spll_table, sizeof(SMC_SISLANDS_SPLL_DIV_TABLE),
  2660. si_pi->sram_end);
  2661. if (ret)
  2662. ni_pi->enable_power_containment = false;
  2663. kfree(spll_table);
  2664. return ret;
  2665. }
  2666. struct si_dpm_quirk {
  2667. u32 chip_vendor;
  2668. u32 chip_device;
  2669. u32 subsys_vendor;
  2670. u32 subsys_device;
  2671. u32 max_sclk;
  2672. u32 max_mclk;
  2673. };
  2674. /* cards with dpm stability problems */
  2675. static struct si_dpm_quirk si_dpm_quirk_list[] = {
  2676. /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */
  2677. { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 },
  2678. { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 },
  2679. { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0x2015, 0, 120000 },
  2680. { PCI_VENDOR_ID_ATI, 0x6810, 0x174b, 0xe271, 85000, 90000 },
  2681. { PCI_VENDOR_ID_ATI, 0x6811, 0x1462, 0x2015, 0, 120000 },
  2682. { PCI_VENDOR_ID_ATI, 0x6811, 0x1043, 0x2015, 0, 120000 },
  2683. { PCI_VENDOR_ID_ATI, 0x6811, 0x148c, 0x2015, 0, 120000 },
  2684. { PCI_VENDOR_ID_ATI, 0x6810, 0x1682, 0x9275, 0, 120000 },
  2685. { 0, 0, 0, 0 },
  2686. };
  2687. static u16 si_get_lower_of_leakage_and_vce_voltage(struct radeon_device *rdev,
  2688. u16 vce_voltage)
  2689. {
  2690. u16 highest_leakage = 0;
  2691. struct si_power_info *si_pi = si_get_pi(rdev);
  2692. int i;
  2693. for (i = 0; i < si_pi->leakage_voltage.count; i++){
  2694. if (highest_leakage < si_pi->leakage_voltage.entries[i].voltage)
  2695. highest_leakage = si_pi->leakage_voltage.entries[i].voltage;
  2696. }
  2697. if (si_pi->leakage_voltage.count && (highest_leakage < vce_voltage))
  2698. return highest_leakage;
  2699. return vce_voltage;
  2700. }
  2701. static int si_get_vce_clock_voltage(struct radeon_device *rdev,
  2702. u32 evclk, u32 ecclk, u16 *voltage)
  2703. {
  2704. u32 i;
  2705. int ret = -EINVAL;
  2706. struct radeon_vce_clock_voltage_dependency_table *table =
  2707. &rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
  2708. if (((evclk == 0) && (ecclk == 0)) ||
  2709. (table && (table->count == 0))) {
  2710. *voltage = 0;
  2711. return 0;
  2712. }
  2713. for (i = 0; i < table->count; i++) {
  2714. if ((evclk <= table->entries[i].evclk) &&
  2715. (ecclk <= table->entries[i].ecclk)) {
  2716. *voltage = table->entries[i].v;
  2717. ret = 0;
  2718. break;
  2719. }
  2720. }
  2721. /* if no match return the highest voltage */
  2722. if (ret)
  2723. *voltage = table->entries[table->count - 1].v;
  2724. *voltage = si_get_lower_of_leakage_and_vce_voltage(rdev, *voltage);
  2725. return ret;
  2726. }
  2727. static void si_apply_state_adjust_rules(struct radeon_device *rdev,
  2728. struct radeon_ps *rps)
  2729. {
  2730. struct ni_ps *ps = ni_get_ps(rps);
  2731. struct radeon_clock_and_voltage_limits *max_limits;
  2732. bool disable_mclk_switching = false;
  2733. bool disable_sclk_switching = false;
  2734. u32 mclk, sclk;
  2735. u16 vddc, vddci, min_vce_voltage = 0;
  2736. u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
  2737. u32 max_sclk = 0, max_mclk = 0;
  2738. int i;
  2739. struct si_dpm_quirk *p = si_dpm_quirk_list;
  2740. /* limit all SI kickers */
  2741. if (rdev->family == CHIP_PITCAIRN) {
  2742. if ((rdev->pdev->revision == 0x81) ||
  2743. (rdev->pdev->device == 0x6810) ||
  2744. (rdev->pdev->device == 0x6811) ||
  2745. (rdev->pdev->device == 0x6816) ||
  2746. (rdev->pdev->device == 0x6817) ||
  2747. (rdev->pdev->device == 0x6806))
  2748. max_mclk = 120000;
  2749. } else if (rdev->family == CHIP_OLAND) {
  2750. if ((rdev->pdev->revision == 0xC7) ||
  2751. (rdev->pdev->revision == 0x80) ||
  2752. (rdev->pdev->revision == 0x81) ||
  2753. (rdev->pdev->revision == 0x83) ||
  2754. (rdev->pdev->revision == 0x87) ||
  2755. (rdev->pdev->device == 0x6604) ||
  2756. (rdev->pdev->device == 0x6605)) {
  2757. max_sclk = 75000;
  2758. max_mclk = 80000;
  2759. }
  2760. } else if (rdev->family == CHIP_HAINAN) {
  2761. if ((rdev->pdev->revision == 0x81) ||
  2762. (rdev->pdev->revision == 0x83) ||
  2763. (rdev->pdev->revision == 0xC3) ||
  2764. (rdev->pdev->device == 0x6664) ||
  2765. (rdev->pdev->device == 0x6665) ||
  2766. (rdev->pdev->device == 0x6667)) {
  2767. max_sclk = 75000;
  2768. max_mclk = 80000;
  2769. }
  2770. } else if (rdev->family == CHIP_OLAND) {
  2771. if ((rdev->pdev->revision == 0xC7) ||
  2772. (rdev->pdev->revision == 0x80) ||
  2773. (rdev->pdev->revision == 0x81) ||
  2774. (rdev->pdev->revision == 0x83) ||
  2775. (rdev->pdev->revision == 0x87) ||
  2776. (rdev->pdev->device == 0x6604) ||
  2777. (rdev->pdev->device == 0x6605)) {
  2778. max_sclk = 75000;
  2779. }
  2780. }
  2781. /* Apply dpm quirks */
  2782. while (p && p->chip_device != 0) {
  2783. if (rdev->pdev->vendor == p->chip_vendor &&
  2784. rdev->pdev->device == p->chip_device &&
  2785. rdev->pdev->subsystem_vendor == p->subsys_vendor &&
  2786. rdev->pdev->subsystem_device == p->subsys_device) {
  2787. max_sclk = p->max_sclk;
  2788. max_mclk = p->max_mclk;
  2789. break;
  2790. }
  2791. ++p;
  2792. }
  2793. if (rps->vce_active) {
  2794. rps->evclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].evclk;
  2795. rps->ecclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].ecclk;
  2796. si_get_vce_clock_voltage(rdev, rps->evclk, rps->ecclk,
  2797. &min_vce_voltage);
  2798. } else {
  2799. rps->evclk = 0;
  2800. rps->ecclk = 0;
  2801. }
  2802. if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
  2803. ni_dpm_vblank_too_short(rdev))
  2804. disable_mclk_switching = true;
  2805. if (rps->vclk || rps->dclk) {
  2806. disable_mclk_switching = true;
  2807. disable_sclk_switching = true;
  2808. }
  2809. if (rdev->pm.dpm.ac_power)
  2810. max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
  2811. else
  2812. max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
  2813. for (i = ps->performance_level_count - 2; i >= 0; i--) {
  2814. if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc)
  2815. ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc;
  2816. }
  2817. if (rdev->pm.dpm.ac_power == false) {
  2818. for (i = 0; i < ps->performance_level_count; i++) {
  2819. if (ps->performance_levels[i].mclk > max_limits->mclk)
  2820. ps->performance_levels[i].mclk = max_limits->mclk;
  2821. if (ps->performance_levels[i].sclk > max_limits->sclk)
  2822. ps->performance_levels[i].sclk = max_limits->sclk;
  2823. if (ps->performance_levels[i].vddc > max_limits->vddc)
  2824. ps->performance_levels[i].vddc = max_limits->vddc;
  2825. if (ps->performance_levels[i].vddci > max_limits->vddci)
  2826. ps->performance_levels[i].vddci = max_limits->vddci;
  2827. }
  2828. }
  2829. /* limit clocks to max supported clocks based on voltage dependency tables */
  2830. btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
  2831. &max_sclk_vddc);
  2832. btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  2833. &max_mclk_vddci);
  2834. btc_get_max_clock_from_voltage_dependency_table(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  2835. &max_mclk_vddc);
  2836. for (i = 0; i < ps->performance_level_count; i++) {
  2837. if (max_sclk_vddc) {
  2838. if (ps->performance_levels[i].sclk > max_sclk_vddc)
  2839. ps->performance_levels[i].sclk = max_sclk_vddc;
  2840. }
  2841. if (max_mclk_vddci) {
  2842. if (ps->performance_levels[i].mclk > max_mclk_vddci)
  2843. ps->performance_levels[i].mclk = max_mclk_vddci;
  2844. }
  2845. if (max_mclk_vddc) {
  2846. if (ps->performance_levels[i].mclk > max_mclk_vddc)
  2847. ps->performance_levels[i].mclk = max_mclk_vddc;
  2848. }
  2849. if (max_mclk) {
  2850. if (ps->performance_levels[i].mclk > max_mclk)
  2851. ps->performance_levels[i].mclk = max_mclk;
  2852. }
  2853. if (max_sclk) {
  2854. if (ps->performance_levels[i].sclk > max_sclk)
  2855. ps->performance_levels[i].sclk = max_sclk;
  2856. }
  2857. }
  2858. /* XXX validate the min clocks required for display */
  2859. if (disable_mclk_switching) {
  2860. mclk = ps->performance_levels[ps->performance_level_count - 1].mclk;
  2861. vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
  2862. } else {
  2863. mclk = ps->performance_levels[0].mclk;
  2864. vddci = ps->performance_levels[0].vddci;
  2865. }
  2866. if (disable_sclk_switching) {
  2867. sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
  2868. vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
  2869. } else {
  2870. sclk = ps->performance_levels[0].sclk;
  2871. vddc = ps->performance_levels[0].vddc;
  2872. }
  2873. if (rps->vce_active) {
  2874. if (sclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk)
  2875. sclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk;
  2876. if (mclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk)
  2877. mclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk;
  2878. }
  2879. /* adjusted low state */
  2880. ps->performance_levels[0].sclk = sclk;
  2881. ps->performance_levels[0].mclk = mclk;
  2882. ps->performance_levels[0].vddc = vddc;
  2883. ps->performance_levels[0].vddci = vddci;
  2884. if (disable_sclk_switching) {
  2885. sclk = ps->performance_levels[0].sclk;
  2886. for (i = 1; i < ps->performance_level_count; i++) {
  2887. if (sclk < ps->performance_levels[i].sclk)
  2888. sclk = ps->performance_levels[i].sclk;
  2889. }
  2890. for (i = 0; i < ps->performance_level_count; i++) {
  2891. ps->performance_levels[i].sclk = sclk;
  2892. ps->performance_levels[i].vddc = vddc;
  2893. }
  2894. } else {
  2895. for (i = 1; i < ps->performance_level_count; i++) {
  2896. if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
  2897. ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
  2898. if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
  2899. ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
  2900. }
  2901. }
  2902. if (disable_mclk_switching) {
  2903. mclk = ps->performance_levels[0].mclk;
  2904. for (i = 1; i < ps->performance_level_count; i++) {
  2905. if (mclk < ps->performance_levels[i].mclk)
  2906. mclk = ps->performance_levels[i].mclk;
  2907. }
  2908. for (i = 0; i < ps->performance_level_count; i++) {
  2909. ps->performance_levels[i].mclk = mclk;
  2910. ps->performance_levels[i].vddci = vddci;
  2911. }
  2912. } else {
  2913. for (i = 1; i < ps->performance_level_count; i++) {
  2914. if (ps->performance_levels[i].mclk < ps->performance_levels[i - 1].mclk)
  2915. ps->performance_levels[i].mclk = ps->performance_levels[i - 1].mclk;
  2916. if (ps->performance_levels[i].vddci < ps->performance_levels[i - 1].vddci)
  2917. ps->performance_levels[i].vddci = ps->performance_levels[i - 1].vddci;
  2918. }
  2919. }
  2920. for (i = 0; i < ps->performance_level_count; i++)
  2921. btc_adjust_clock_combinations(rdev, max_limits,
  2922. &ps->performance_levels[i]);
  2923. for (i = 0; i < ps->performance_level_count; i++) {
  2924. if (ps->performance_levels[i].vddc < min_vce_voltage)
  2925. ps->performance_levels[i].vddc = min_vce_voltage;
  2926. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
  2927. ps->performance_levels[i].sclk,
  2928. max_limits->vddc, &ps->performance_levels[i].vddc);
  2929. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  2930. ps->performance_levels[i].mclk,
  2931. max_limits->vddci, &ps->performance_levels[i].vddci);
  2932. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  2933. ps->performance_levels[i].mclk,
  2934. max_limits->vddc, &ps->performance_levels[i].vddc);
  2935. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
  2936. rdev->clock.current_dispclk,
  2937. max_limits->vddc, &ps->performance_levels[i].vddc);
  2938. }
  2939. for (i = 0; i < ps->performance_level_count; i++) {
  2940. btc_apply_voltage_delta_rules(rdev,
  2941. max_limits->vddc, max_limits->vddci,
  2942. &ps->performance_levels[i].vddc,
  2943. &ps->performance_levels[i].vddci);
  2944. }
  2945. ps->dc_compatible = true;
  2946. for (i = 0; i < ps->performance_level_count; i++) {
  2947. if (ps->performance_levels[i].vddc > rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc)
  2948. ps->dc_compatible = false;
  2949. }
  2950. }
  2951. #if 0
  2952. static int si_read_smc_soft_register(struct radeon_device *rdev,
  2953. u16 reg_offset, u32 *value)
  2954. {
  2955. struct si_power_info *si_pi = si_get_pi(rdev);
  2956. return si_read_smc_sram_dword(rdev,
  2957. si_pi->soft_regs_start + reg_offset, value,
  2958. si_pi->sram_end);
  2959. }
  2960. #endif
  2961. static int si_write_smc_soft_register(struct radeon_device *rdev,
  2962. u16 reg_offset, u32 value)
  2963. {
  2964. struct si_power_info *si_pi = si_get_pi(rdev);
  2965. return si_write_smc_sram_dword(rdev,
  2966. si_pi->soft_regs_start + reg_offset,
  2967. value, si_pi->sram_end);
  2968. }
  2969. static bool si_is_special_1gb_platform(struct radeon_device *rdev)
  2970. {
  2971. bool ret = false;
  2972. u32 tmp, width, row, column, bank, density;
  2973. bool is_memory_gddr5, is_special;
  2974. tmp = RREG32(MC_SEQ_MISC0);
  2975. is_memory_gddr5 = (MC_SEQ_MISC0_GDDR5_VALUE == ((tmp & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT));
  2976. is_special = (MC_SEQ_MISC0_REV_ID_VALUE == ((tmp & MC_SEQ_MISC0_REV_ID_MASK) >> MC_SEQ_MISC0_REV_ID_SHIFT))
  2977. & (MC_SEQ_MISC0_VEN_ID_VALUE == ((tmp & MC_SEQ_MISC0_VEN_ID_MASK) >> MC_SEQ_MISC0_VEN_ID_SHIFT));
  2978. WREG32(MC_SEQ_IO_DEBUG_INDEX, 0xb);
  2979. width = ((RREG32(MC_SEQ_IO_DEBUG_DATA) >> 1) & 1) ? 16 : 32;
  2980. tmp = RREG32(MC_ARB_RAMCFG);
  2981. row = ((tmp & NOOFROWS_MASK) >> NOOFROWS_SHIFT) + 10;
  2982. column = ((tmp & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) + 8;
  2983. bank = ((tmp & NOOFBANK_MASK) >> NOOFBANK_SHIFT) + 2;
  2984. density = (1 << (row + column - 20 + bank)) * width;
  2985. if ((rdev->pdev->device == 0x6819) &&
  2986. is_memory_gddr5 && is_special && (density == 0x400))
  2987. ret = true;
  2988. return ret;
  2989. }
  2990. static void si_get_leakage_vddc(struct radeon_device *rdev)
  2991. {
  2992. struct si_power_info *si_pi = si_get_pi(rdev);
  2993. u16 vddc, count = 0;
  2994. int i, ret;
  2995. for (i = 0; i < SISLANDS_MAX_LEAKAGE_COUNT; i++) {
  2996. ret = radeon_atom_get_leakage_vddc_based_on_leakage_idx(rdev, &vddc, SISLANDS_LEAKAGE_INDEX0 + i);
  2997. if (!ret && (vddc > 0) && (vddc != (SISLANDS_LEAKAGE_INDEX0 + i))) {
  2998. si_pi->leakage_voltage.entries[count].voltage = vddc;
  2999. si_pi->leakage_voltage.entries[count].leakage_index =
  3000. SISLANDS_LEAKAGE_INDEX0 + i;
  3001. count++;
  3002. }
  3003. }
  3004. si_pi->leakage_voltage.count = count;
  3005. }
  3006. static int si_get_leakage_voltage_from_leakage_index(struct radeon_device *rdev,
  3007. u32 index, u16 *leakage_voltage)
  3008. {
  3009. struct si_power_info *si_pi = si_get_pi(rdev);
  3010. int i;
  3011. if (leakage_voltage == NULL)
  3012. return -EINVAL;
  3013. if ((index & 0xff00) != 0xff00)
  3014. return -EINVAL;
  3015. if ((index & 0xff) > SISLANDS_MAX_LEAKAGE_COUNT + 1)
  3016. return -EINVAL;
  3017. if (index < SISLANDS_LEAKAGE_INDEX0)
  3018. return -EINVAL;
  3019. for (i = 0; i < si_pi->leakage_voltage.count; i++) {
  3020. if (si_pi->leakage_voltage.entries[i].leakage_index == index) {
  3021. *leakage_voltage = si_pi->leakage_voltage.entries[i].voltage;
  3022. return 0;
  3023. }
  3024. }
  3025. return -EAGAIN;
  3026. }
  3027. static void si_set_dpm_event_sources(struct radeon_device *rdev, u32 sources)
  3028. {
  3029. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3030. bool want_thermal_protection;
  3031. enum radeon_dpm_event_src dpm_event_src;
  3032. switch (sources) {
  3033. case 0:
  3034. default:
  3035. want_thermal_protection = false;
  3036. break;
  3037. case (1 << RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL):
  3038. want_thermal_protection = true;
  3039. dpm_event_src = RADEON_DPM_EVENT_SRC_DIGITAL;
  3040. break;
  3041. case (1 << RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL):
  3042. want_thermal_protection = true;
  3043. dpm_event_src = RADEON_DPM_EVENT_SRC_EXTERNAL;
  3044. break;
  3045. case ((1 << RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL) |
  3046. (1 << RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL)):
  3047. want_thermal_protection = true;
  3048. dpm_event_src = RADEON_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL;
  3049. break;
  3050. }
  3051. if (want_thermal_protection) {
  3052. WREG32_P(CG_THERMAL_CTRL, DPM_EVENT_SRC(dpm_event_src), ~DPM_EVENT_SRC_MASK);
  3053. if (pi->thermal_protection)
  3054. WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
  3055. } else {
  3056. WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
  3057. }
  3058. }
  3059. static void si_enable_auto_throttle_source(struct radeon_device *rdev,
  3060. enum radeon_dpm_auto_throttle_src source,
  3061. bool enable)
  3062. {
  3063. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3064. if (enable) {
  3065. if (!(pi->active_auto_throttle_sources & (1 << source))) {
  3066. pi->active_auto_throttle_sources |= 1 << source;
  3067. si_set_dpm_event_sources(rdev, pi->active_auto_throttle_sources);
  3068. }
  3069. } else {
  3070. if (pi->active_auto_throttle_sources & (1 << source)) {
  3071. pi->active_auto_throttle_sources &= ~(1 << source);
  3072. si_set_dpm_event_sources(rdev, pi->active_auto_throttle_sources);
  3073. }
  3074. }
  3075. }
  3076. static void si_start_dpm(struct radeon_device *rdev)
  3077. {
  3078. WREG32_P(GENERAL_PWRMGT, GLOBAL_PWRMGT_EN, ~GLOBAL_PWRMGT_EN);
  3079. }
  3080. static void si_stop_dpm(struct radeon_device *rdev)
  3081. {
  3082. WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
  3083. }
  3084. static void si_enable_sclk_control(struct radeon_device *rdev, bool enable)
  3085. {
  3086. if (enable)
  3087. WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
  3088. else
  3089. WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
  3090. }
  3091. #if 0
  3092. static int si_notify_hardware_of_thermal_state(struct radeon_device *rdev,
  3093. u32 thermal_level)
  3094. {
  3095. PPSMC_Result ret;
  3096. if (thermal_level == 0) {
  3097. ret = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableThermalInterrupt);
  3098. if (ret == PPSMC_Result_OK)
  3099. return 0;
  3100. else
  3101. return -EINVAL;
  3102. }
  3103. return 0;
  3104. }
  3105. static void si_notify_hardware_vpu_recovery_event(struct radeon_device *rdev)
  3106. {
  3107. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen, true);
  3108. }
  3109. #endif
  3110. #if 0
  3111. static int si_notify_hw_of_powersource(struct radeon_device *rdev, bool ac_power)
  3112. {
  3113. if (ac_power)
  3114. return (si_send_msg_to_smc(rdev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
  3115. 0 : -EINVAL;
  3116. return 0;
  3117. }
  3118. #endif
  3119. static PPSMC_Result si_send_msg_to_smc_with_parameter(struct radeon_device *rdev,
  3120. PPSMC_Msg msg, u32 parameter)
  3121. {
  3122. WREG32(SMC_SCRATCH0, parameter);
  3123. return si_send_msg_to_smc(rdev, msg);
  3124. }
  3125. static int si_restrict_performance_levels_before_switch(struct radeon_device *rdev)
  3126. {
  3127. if (si_send_msg_to_smc(rdev, PPSMC_MSG_NoForcedLevel) != PPSMC_Result_OK)
  3128. return -EINVAL;
  3129. return (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) == PPSMC_Result_OK) ?
  3130. 0 : -EINVAL;
  3131. }
  3132. int si_dpm_force_performance_level(struct radeon_device *rdev,
  3133. enum radeon_dpm_forced_level level)
  3134. {
  3135. struct radeon_ps *rps = rdev->pm.dpm.current_ps;
  3136. struct ni_ps *ps = ni_get_ps(rps);
  3137. u32 levels = ps->performance_level_count;
  3138. if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
  3139. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
  3140. return -EINVAL;
  3141. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK)
  3142. return -EINVAL;
  3143. } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
  3144. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
  3145. return -EINVAL;
  3146. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
  3147. return -EINVAL;
  3148. } else if (level == RADEON_DPM_FORCED_LEVEL_AUTO) {
  3149. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
  3150. return -EINVAL;
  3151. if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
  3152. return -EINVAL;
  3153. }
  3154. rdev->pm.dpm.forced_level = level;
  3155. return 0;
  3156. }
  3157. #if 0
  3158. static int si_set_boot_state(struct radeon_device *rdev)
  3159. {
  3160. return (si_send_msg_to_smc(rdev, PPSMC_MSG_SwitchToInitialState) == PPSMC_Result_OK) ?
  3161. 0 : -EINVAL;
  3162. }
  3163. #endif
  3164. static int si_set_sw_state(struct radeon_device *rdev)
  3165. {
  3166. return (si_send_msg_to_smc(rdev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ?
  3167. 0 : -EINVAL;
  3168. }
  3169. static int si_halt_smc(struct radeon_device *rdev)
  3170. {
  3171. if (si_send_msg_to_smc(rdev, PPSMC_MSG_Halt) != PPSMC_Result_OK)
  3172. return -EINVAL;
  3173. return (si_wait_for_smc_inactive(rdev) == PPSMC_Result_OK) ?
  3174. 0 : -EINVAL;
  3175. }
  3176. static int si_resume_smc(struct radeon_device *rdev)
  3177. {
  3178. if (si_send_msg_to_smc(rdev, PPSMC_FlushDataCache) != PPSMC_Result_OK)
  3179. return -EINVAL;
  3180. return (si_send_msg_to_smc(rdev, PPSMC_MSG_Resume) == PPSMC_Result_OK) ?
  3181. 0 : -EINVAL;
  3182. }
  3183. static void si_dpm_start_smc(struct radeon_device *rdev)
  3184. {
  3185. si_program_jump_on_start(rdev);
  3186. si_start_smc(rdev);
  3187. si_start_smc_clock(rdev);
  3188. }
  3189. static void si_dpm_stop_smc(struct radeon_device *rdev)
  3190. {
  3191. si_reset_smc(rdev);
  3192. si_stop_smc_clock(rdev);
  3193. }
  3194. static int si_process_firmware_header(struct radeon_device *rdev)
  3195. {
  3196. struct si_power_info *si_pi = si_get_pi(rdev);
  3197. u32 tmp;
  3198. int ret;
  3199. ret = si_read_smc_sram_dword(rdev,
  3200. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3201. SISLANDS_SMC_FIRMWARE_HEADER_stateTable,
  3202. &tmp, si_pi->sram_end);
  3203. if (ret)
  3204. return ret;
  3205. si_pi->state_table_start = tmp;
  3206. ret = si_read_smc_sram_dword(rdev,
  3207. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3208. SISLANDS_SMC_FIRMWARE_HEADER_softRegisters,
  3209. &tmp, si_pi->sram_end);
  3210. if (ret)
  3211. return ret;
  3212. si_pi->soft_regs_start = tmp;
  3213. ret = si_read_smc_sram_dword(rdev,
  3214. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3215. SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable,
  3216. &tmp, si_pi->sram_end);
  3217. if (ret)
  3218. return ret;
  3219. si_pi->mc_reg_table_start = tmp;
  3220. ret = si_read_smc_sram_dword(rdev,
  3221. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3222. SISLANDS_SMC_FIRMWARE_HEADER_fanTable,
  3223. &tmp, si_pi->sram_end);
  3224. if (ret)
  3225. return ret;
  3226. si_pi->fan_table_start = tmp;
  3227. ret = si_read_smc_sram_dword(rdev,
  3228. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3229. SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable,
  3230. &tmp, si_pi->sram_end);
  3231. if (ret)
  3232. return ret;
  3233. si_pi->arb_table_start = tmp;
  3234. ret = si_read_smc_sram_dword(rdev,
  3235. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3236. SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable,
  3237. &tmp, si_pi->sram_end);
  3238. if (ret)
  3239. return ret;
  3240. si_pi->cac_table_start = tmp;
  3241. ret = si_read_smc_sram_dword(rdev,
  3242. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3243. SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration,
  3244. &tmp, si_pi->sram_end);
  3245. if (ret)
  3246. return ret;
  3247. si_pi->dte_table_start = tmp;
  3248. ret = si_read_smc_sram_dword(rdev,
  3249. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3250. SISLANDS_SMC_FIRMWARE_HEADER_spllTable,
  3251. &tmp, si_pi->sram_end);
  3252. if (ret)
  3253. return ret;
  3254. si_pi->spll_table_start = tmp;
  3255. ret = si_read_smc_sram_dword(rdev,
  3256. SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
  3257. SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters,
  3258. &tmp, si_pi->sram_end);
  3259. if (ret)
  3260. return ret;
  3261. si_pi->papm_cfg_table_start = tmp;
  3262. return ret;
  3263. }
  3264. static void si_read_clock_registers(struct radeon_device *rdev)
  3265. {
  3266. struct si_power_info *si_pi = si_get_pi(rdev);
  3267. si_pi->clock_registers.cg_spll_func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
  3268. si_pi->clock_registers.cg_spll_func_cntl_2 = RREG32(CG_SPLL_FUNC_CNTL_2);
  3269. si_pi->clock_registers.cg_spll_func_cntl_3 = RREG32(CG_SPLL_FUNC_CNTL_3);
  3270. si_pi->clock_registers.cg_spll_func_cntl_4 = RREG32(CG_SPLL_FUNC_CNTL_4);
  3271. si_pi->clock_registers.cg_spll_spread_spectrum = RREG32(CG_SPLL_SPREAD_SPECTRUM);
  3272. si_pi->clock_registers.cg_spll_spread_spectrum_2 = RREG32(CG_SPLL_SPREAD_SPECTRUM_2);
  3273. si_pi->clock_registers.dll_cntl = RREG32(DLL_CNTL);
  3274. si_pi->clock_registers.mclk_pwrmgt_cntl = RREG32(MCLK_PWRMGT_CNTL);
  3275. si_pi->clock_registers.mpll_ad_func_cntl = RREG32(MPLL_AD_FUNC_CNTL);
  3276. si_pi->clock_registers.mpll_dq_func_cntl = RREG32(MPLL_DQ_FUNC_CNTL);
  3277. si_pi->clock_registers.mpll_func_cntl = RREG32(MPLL_FUNC_CNTL);
  3278. si_pi->clock_registers.mpll_func_cntl_1 = RREG32(MPLL_FUNC_CNTL_1);
  3279. si_pi->clock_registers.mpll_func_cntl_2 = RREG32(MPLL_FUNC_CNTL_2);
  3280. si_pi->clock_registers.mpll_ss1 = RREG32(MPLL_SS1);
  3281. si_pi->clock_registers.mpll_ss2 = RREG32(MPLL_SS2);
  3282. }
  3283. static void si_enable_thermal_protection(struct radeon_device *rdev,
  3284. bool enable)
  3285. {
  3286. if (enable)
  3287. WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
  3288. else
  3289. WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
  3290. }
  3291. static void si_enable_acpi_power_management(struct radeon_device *rdev)
  3292. {
  3293. WREG32_P(GENERAL_PWRMGT, STATIC_PM_EN, ~STATIC_PM_EN);
  3294. }
  3295. #if 0
  3296. static int si_enter_ulp_state(struct radeon_device *rdev)
  3297. {
  3298. WREG32(SMC_MESSAGE_0, PPSMC_MSG_SwitchToMinimumPower);
  3299. udelay(25000);
  3300. return 0;
  3301. }
  3302. static int si_exit_ulp_state(struct radeon_device *rdev)
  3303. {
  3304. int i;
  3305. WREG32(SMC_MESSAGE_0, PPSMC_MSG_ResumeFromMinimumPower);
  3306. udelay(7000);
  3307. for (i = 0; i < rdev->usec_timeout; i++) {
  3308. if (RREG32(SMC_RESP_0) == 1)
  3309. break;
  3310. udelay(1000);
  3311. }
  3312. return 0;
  3313. }
  3314. #endif
  3315. static int si_notify_smc_display_change(struct radeon_device *rdev,
  3316. bool has_display)
  3317. {
  3318. PPSMC_Msg msg = has_display ?
  3319. PPSMC_MSG_HasDisplay : PPSMC_MSG_NoDisplay;
  3320. return (si_send_msg_to_smc(rdev, msg) == PPSMC_Result_OK) ?
  3321. 0 : -EINVAL;
  3322. }
  3323. static void si_program_response_times(struct radeon_device *rdev)
  3324. {
  3325. u32 voltage_response_time, backbias_response_time, acpi_delay_time, vbi_time_out;
  3326. u32 vddc_dly, acpi_dly, vbi_dly;
  3327. u32 reference_clock;
  3328. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1);
  3329. voltage_response_time = (u32)rdev->pm.dpm.voltage_response_time;
  3330. backbias_response_time = (u32)rdev->pm.dpm.backbias_response_time;
  3331. if (voltage_response_time == 0)
  3332. voltage_response_time = 1000;
  3333. acpi_delay_time = 15000;
  3334. vbi_time_out = 100000;
  3335. reference_clock = radeon_get_xclk(rdev);
  3336. vddc_dly = (voltage_response_time * reference_clock) / 100;
  3337. acpi_dly = (acpi_delay_time * reference_clock) / 100;
  3338. vbi_dly = (vbi_time_out * reference_clock) / 100;
  3339. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_delay_vreg, vddc_dly);
  3340. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_delay_acpi, acpi_dly);
  3341. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mclk_chg_timeout, vbi_dly);
  3342. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_mc_block_delay, 0xAA);
  3343. }
  3344. static void si_program_ds_registers(struct radeon_device *rdev)
  3345. {
  3346. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  3347. u32 tmp = 1; /* XXX: 0x10 on tahiti A0 */
  3348. if (eg_pi->sclk_deep_sleep) {
  3349. WREG32_P(MISC_CLK_CNTL, DEEP_SLEEP_CLK_SEL(tmp), ~DEEP_SLEEP_CLK_SEL_MASK);
  3350. WREG32_P(CG_SPLL_AUTOSCALE_CNTL, AUTOSCALE_ON_SS_CLEAR,
  3351. ~AUTOSCALE_ON_SS_CLEAR);
  3352. }
  3353. }
  3354. static void si_program_display_gap(struct radeon_device *rdev)
  3355. {
  3356. u32 tmp, pipe;
  3357. int i;
  3358. tmp = RREG32(CG_DISPLAY_GAP_CNTL) & ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
  3359. if (rdev->pm.dpm.new_active_crtc_count > 0)
  3360. tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
  3361. else
  3362. tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE);
  3363. if (rdev->pm.dpm.new_active_crtc_count > 1)
  3364. tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
  3365. else
  3366. tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE);
  3367. WREG32(CG_DISPLAY_GAP_CNTL, tmp);
  3368. tmp = RREG32(DCCG_DISP_SLOW_SELECT_REG);
  3369. pipe = (tmp & DCCG_DISP1_SLOW_SELECT_MASK) >> DCCG_DISP1_SLOW_SELECT_SHIFT;
  3370. if ((rdev->pm.dpm.new_active_crtc_count > 0) &&
  3371. (!(rdev->pm.dpm.new_active_crtcs & (1 << pipe)))) {
  3372. /* find the first active crtc */
  3373. for (i = 0; i < rdev->num_crtc; i++) {
  3374. if (rdev->pm.dpm.new_active_crtcs & (1 << i))
  3375. break;
  3376. }
  3377. if (i == rdev->num_crtc)
  3378. pipe = 0;
  3379. else
  3380. pipe = i;
  3381. tmp &= ~DCCG_DISP1_SLOW_SELECT_MASK;
  3382. tmp |= DCCG_DISP1_SLOW_SELECT(pipe);
  3383. WREG32(DCCG_DISP_SLOW_SELECT_REG, tmp);
  3384. }
  3385. /* Setting this to false forces the performance state to low if the crtcs are disabled.
  3386. * This can be a problem on PowerXpress systems or if you want to use the card
  3387. * for offscreen rendering or compute if there are no crtcs enabled.
  3388. */
  3389. si_notify_smc_display_change(rdev, rdev->pm.dpm.new_active_crtc_count > 0);
  3390. }
  3391. static void si_enable_spread_spectrum(struct radeon_device *rdev, bool enable)
  3392. {
  3393. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3394. if (enable) {
  3395. if (pi->sclk_ss)
  3396. WREG32_P(GENERAL_PWRMGT, DYN_SPREAD_SPECTRUM_EN, ~DYN_SPREAD_SPECTRUM_EN);
  3397. } else {
  3398. WREG32_P(CG_SPLL_SPREAD_SPECTRUM, 0, ~SSEN);
  3399. WREG32_P(GENERAL_PWRMGT, 0, ~DYN_SPREAD_SPECTRUM_EN);
  3400. }
  3401. }
  3402. static void si_setup_bsp(struct radeon_device *rdev)
  3403. {
  3404. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3405. u32 xclk = radeon_get_xclk(rdev);
  3406. r600_calculate_u_and_p(pi->asi,
  3407. xclk,
  3408. 16,
  3409. &pi->bsp,
  3410. &pi->bsu);
  3411. r600_calculate_u_and_p(pi->pasi,
  3412. xclk,
  3413. 16,
  3414. &pi->pbsp,
  3415. &pi->pbsu);
  3416. pi->dsp = BSP(pi->bsp) | BSU(pi->bsu);
  3417. pi->psp = BSP(pi->pbsp) | BSU(pi->pbsu);
  3418. WREG32(CG_BSP, pi->dsp);
  3419. }
  3420. static void si_program_git(struct radeon_device *rdev)
  3421. {
  3422. WREG32_P(CG_GIT, CG_GICST(R600_GICST_DFLT), ~CG_GICST_MASK);
  3423. }
  3424. static void si_program_tp(struct radeon_device *rdev)
  3425. {
  3426. int i;
  3427. enum r600_td td = R600_TD_DFLT;
  3428. for (i = 0; i < R600_PM_NUMBER_OF_TC; i++)
  3429. WREG32(CG_FFCT_0 + (i * 4), (UTC_0(r600_utc[i]) | DTC_0(r600_dtc[i])));
  3430. if (td == R600_TD_AUTO)
  3431. WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_FORCE_TREND_SEL);
  3432. else
  3433. WREG32_P(SCLK_PWRMGT_CNTL, FIR_FORCE_TREND_SEL, ~FIR_FORCE_TREND_SEL);
  3434. if (td == R600_TD_UP)
  3435. WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_TREND_MODE);
  3436. if (td == R600_TD_DOWN)
  3437. WREG32_P(SCLK_PWRMGT_CNTL, FIR_TREND_MODE, ~FIR_TREND_MODE);
  3438. }
  3439. static void si_program_tpp(struct radeon_device *rdev)
  3440. {
  3441. WREG32(CG_TPC, R600_TPC_DFLT);
  3442. }
  3443. static void si_program_sstp(struct radeon_device *rdev)
  3444. {
  3445. WREG32(CG_SSP, (SSTU(R600_SSTU_DFLT) | SST(R600_SST_DFLT)));
  3446. }
  3447. static void si_enable_display_gap(struct radeon_device *rdev)
  3448. {
  3449. u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
  3450. tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
  3451. tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) |
  3452. DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE));
  3453. tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
  3454. tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) |
  3455. DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE));
  3456. WREG32(CG_DISPLAY_GAP_CNTL, tmp);
  3457. }
  3458. static void si_program_vc(struct radeon_device *rdev)
  3459. {
  3460. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3461. WREG32(CG_FTV, pi->vrc);
  3462. }
  3463. static void si_clear_vc(struct radeon_device *rdev)
  3464. {
  3465. WREG32(CG_FTV, 0);
  3466. }
  3467. u8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock)
  3468. {
  3469. u8 mc_para_index;
  3470. if (memory_clock < 10000)
  3471. mc_para_index = 0;
  3472. else if (memory_clock >= 80000)
  3473. mc_para_index = 0x0f;
  3474. else
  3475. mc_para_index = (u8)((memory_clock - 10000) / 5000 + 1);
  3476. return mc_para_index;
  3477. }
  3478. u8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode)
  3479. {
  3480. u8 mc_para_index;
  3481. if (strobe_mode) {
  3482. if (memory_clock < 12500)
  3483. mc_para_index = 0x00;
  3484. else if (memory_clock > 47500)
  3485. mc_para_index = 0x0f;
  3486. else
  3487. mc_para_index = (u8)((memory_clock - 10000) / 2500);
  3488. } else {
  3489. if (memory_clock < 65000)
  3490. mc_para_index = 0x00;
  3491. else if (memory_clock > 135000)
  3492. mc_para_index = 0x0f;
  3493. else
  3494. mc_para_index = (u8)((memory_clock - 60000) / 5000);
  3495. }
  3496. return mc_para_index;
  3497. }
  3498. static u8 si_get_strobe_mode_settings(struct radeon_device *rdev, u32 mclk)
  3499. {
  3500. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3501. bool strobe_mode = false;
  3502. u8 result = 0;
  3503. if (mclk <= pi->mclk_strobe_mode_threshold)
  3504. strobe_mode = true;
  3505. if (pi->mem_gddr5)
  3506. result = si_get_mclk_frequency_ratio(mclk, strobe_mode);
  3507. else
  3508. result = si_get_ddr3_mclk_frequency_ratio(mclk);
  3509. if (strobe_mode)
  3510. result |= SISLANDS_SMC_STROBE_ENABLE;
  3511. return result;
  3512. }
  3513. static int si_upload_firmware(struct radeon_device *rdev)
  3514. {
  3515. struct si_power_info *si_pi = si_get_pi(rdev);
  3516. int ret;
  3517. si_reset_smc(rdev);
  3518. si_stop_smc_clock(rdev);
  3519. ret = si_load_smc_ucode(rdev, si_pi->sram_end);
  3520. return ret;
  3521. }
  3522. static bool si_validate_phase_shedding_tables(struct radeon_device *rdev,
  3523. const struct atom_voltage_table *table,
  3524. const struct radeon_phase_shedding_limits_table *limits)
  3525. {
  3526. u32 data, num_bits, num_levels;
  3527. if ((table == NULL) || (limits == NULL))
  3528. return false;
  3529. data = table->mask_low;
  3530. num_bits = hweight32(data);
  3531. if (num_bits == 0)
  3532. return false;
  3533. num_levels = (1 << num_bits);
  3534. if (table->count != num_levels)
  3535. return false;
  3536. if (limits->count != (num_levels - 1))
  3537. return false;
  3538. return true;
  3539. }
  3540. void si_trim_voltage_table_to_fit_state_table(struct radeon_device *rdev,
  3541. u32 max_voltage_steps,
  3542. struct atom_voltage_table *voltage_table)
  3543. {
  3544. unsigned int i, diff;
  3545. if (voltage_table->count <= max_voltage_steps)
  3546. return;
  3547. diff = voltage_table->count - max_voltage_steps;
  3548. for (i= 0; i < max_voltage_steps; i++)
  3549. voltage_table->entries[i] = voltage_table->entries[i + diff];
  3550. voltage_table->count = max_voltage_steps;
  3551. }
  3552. static int si_get_svi2_voltage_table(struct radeon_device *rdev,
  3553. struct radeon_clock_voltage_dependency_table *voltage_dependency_table,
  3554. struct atom_voltage_table *voltage_table)
  3555. {
  3556. u32 i;
  3557. if (voltage_dependency_table == NULL)
  3558. return -EINVAL;
  3559. voltage_table->mask_low = 0;
  3560. voltage_table->phase_delay = 0;
  3561. voltage_table->count = voltage_dependency_table->count;
  3562. for (i = 0; i < voltage_table->count; i++) {
  3563. voltage_table->entries[i].value = voltage_dependency_table->entries[i].v;
  3564. voltage_table->entries[i].smio_low = 0;
  3565. }
  3566. return 0;
  3567. }
  3568. static int si_construct_voltage_tables(struct radeon_device *rdev)
  3569. {
  3570. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3571. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  3572. struct si_power_info *si_pi = si_get_pi(rdev);
  3573. int ret;
  3574. if (pi->voltage_control) {
  3575. ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDC,
  3576. VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddc_voltage_table);
  3577. if (ret)
  3578. return ret;
  3579. if (eg_pi->vddc_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
  3580. si_trim_voltage_table_to_fit_state_table(rdev,
  3581. SISLANDS_MAX_NO_VREG_STEPS,
  3582. &eg_pi->vddc_voltage_table);
  3583. } else if (si_pi->voltage_control_svi2) {
  3584. ret = si_get_svi2_voltage_table(rdev,
  3585. &rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  3586. &eg_pi->vddc_voltage_table);
  3587. if (ret)
  3588. return ret;
  3589. } else {
  3590. return -EINVAL;
  3591. }
  3592. if (eg_pi->vddci_control) {
  3593. ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDCI,
  3594. VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddci_voltage_table);
  3595. if (ret)
  3596. return ret;
  3597. if (eg_pi->vddci_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
  3598. si_trim_voltage_table_to_fit_state_table(rdev,
  3599. SISLANDS_MAX_NO_VREG_STEPS,
  3600. &eg_pi->vddci_voltage_table);
  3601. }
  3602. if (si_pi->vddci_control_svi2) {
  3603. ret = si_get_svi2_voltage_table(rdev,
  3604. &rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  3605. &eg_pi->vddci_voltage_table);
  3606. if (ret)
  3607. return ret;
  3608. }
  3609. if (pi->mvdd_control) {
  3610. ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_MVDDC,
  3611. VOLTAGE_OBJ_GPIO_LUT, &si_pi->mvdd_voltage_table);
  3612. if (ret) {
  3613. pi->mvdd_control = false;
  3614. return ret;
  3615. }
  3616. if (si_pi->mvdd_voltage_table.count == 0) {
  3617. pi->mvdd_control = false;
  3618. return -EINVAL;
  3619. }
  3620. if (si_pi->mvdd_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
  3621. si_trim_voltage_table_to_fit_state_table(rdev,
  3622. SISLANDS_MAX_NO_VREG_STEPS,
  3623. &si_pi->mvdd_voltage_table);
  3624. }
  3625. if (si_pi->vddc_phase_shed_control) {
  3626. ret = radeon_atom_get_voltage_table(rdev, VOLTAGE_TYPE_VDDC,
  3627. VOLTAGE_OBJ_PHASE_LUT, &si_pi->vddc_phase_shed_table);
  3628. if (ret)
  3629. si_pi->vddc_phase_shed_control = false;
  3630. if ((si_pi->vddc_phase_shed_table.count == 0) ||
  3631. (si_pi->vddc_phase_shed_table.count > SISLANDS_MAX_NO_VREG_STEPS))
  3632. si_pi->vddc_phase_shed_control = false;
  3633. }
  3634. return 0;
  3635. }
  3636. static void si_populate_smc_voltage_table(struct radeon_device *rdev,
  3637. const struct atom_voltage_table *voltage_table,
  3638. SISLANDS_SMC_STATETABLE *table)
  3639. {
  3640. unsigned int i;
  3641. for (i = 0; i < voltage_table->count; i++)
  3642. table->lowSMIO[i] |= cpu_to_be32(voltage_table->entries[i].smio_low);
  3643. }
  3644. static int si_populate_smc_voltage_tables(struct radeon_device *rdev,
  3645. SISLANDS_SMC_STATETABLE *table)
  3646. {
  3647. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3648. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  3649. struct si_power_info *si_pi = si_get_pi(rdev);
  3650. u8 i;
  3651. if (si_pi->voltage_control_svi2) {
  3652. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc,
  3653. si_pi->svc_gpio_id);
  3654. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd,
  3655. si_pi->svd_gpio_id);
  3656. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_svi_rework_plat_type,
  3657. 2);
  3658. } else {
  3659. if (eg_pi->vddc_voltage_table.count) {
  3660. si_populate_smc_voltage_table(rdev, &eg_pi->vddc_voltage_table, table);
  3661. table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] =
  3662. cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
  3663. for (i = 0; i < eg_pi->vddc_voltage_table.count; i++) {
  3664. if (pi->max_vddc_in_table <= eg_pi->vddc_voltage_table.entries[i].value) {
  3665. table->maxVDDCIndexInPPTable = i;
  3666. break;
  3667. }
  3668. }
  3669. }
  3670. if (eg_pi->vddci_voltage_table.count) {
  3671. si_populate_smc_voltage_table(rdev, &eg_pi->vddci_voltage_table, table);
  3672. table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDCI] =
  3673. cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
  3674. }
  3675. if (si_pi->mvdd_voltage_table.count) {
  3676. si_populate_smc_voltage_table(rdev, &si_pi->mvdd_voltage_table, table);
  3677. table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_MVDD] =
  3678. cpu_to_be32(si_pi->mvdd_voltage_table.mask_low);
  3679. }
  3680. if (si_pi->vddc_phase_shed_control) {
  3681. if (si_validate_phase_shedding_tables(rdev, &si_pi->vddc_phase_shed_table,
  3682. &rdev->pm.dpm.dyn_state.phase_shedding_limits_table)) {
  3683. si_populate_smc_voltage_table(rdev, &si_pi->vddc_phase_shed_table, table);
  3684. table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] =
  3685. cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low);
  3686. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_phase_shedding_delay,
  3687. (u32)si_pi->vddc_phase_shed_table.phase_delay);
  3688. } else {
  3689. si_pi->vddc_phase_shed_control = false;
  3690. }
  3691. }
  3692. }
  3693. return 0;
  3694. }
  3695. static int si_populate_voltage_value(struct radeon_device *rdev,
  3696. const struct atom_voltage_table *table,
  3697. u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage)
  3698. {
  3699. unsigned int i;
  3700. for (i = 0; i < table->count; i++) {
  3701. if (value <= table->entries[i].value) {
  3702. voltage->index = (u8)i;
  3703. voltage->value = cpu_to_be16(table->entries[i].value);
  3704. break;
  3705. }
  3706. }
  3707. if (i >= table->count)
  3708. return -EINVAL;
  3709. return 0;
  3710. }
  3711. static int si_populate_mvdd_value(struct radeon_device *rdev, u32 mclk,
  3712. SISLANDS_SMC_VOLTAGE_VALUE *voltage)
  3713. {
  3714. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3715. struct si_power_info *si_pi = si_get_pi(rdev);
  3716. if (pi->mvdd_control) {
  3717. if (mclk <= pi->mvdd_split_frequency)
  3718. voltage->index = 0;
  3719. else
  3720. voltage->index = (u8)(si_pi->mvdd_voltage_table.count) - 1;
  3721. voltage->value = cpu_to_be16(si_pi->mvdd_voltage_table.entries[voltage->index].value);
  3722. }
  3723. return 0;
  3724. }
  3725. static int si_get_std_voltage_value(struct radeon_device *rdev,
  3726. SISLANDS_SMC_VOLTAGE_VALUE *voltage,
  3727. u16 *std_voltage)
  3728. {
  3729. u16 v_index;
  3730. bool voltage_found = false;
  3731. *std_voltage = be16_to_cpu(voltage->value);
  3732. if (rdev->pm.dpm.dyn_state.cac_leakage_table.entries) {
  3733. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_NEW_CAC_VOLTAGE) {
  3734. if (rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries == NULL)
  3735. return -EINVAL;
  3736. for (v_index = 0; (u32)v_index < rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
  3737. if (be16_to_cpu(voltage->value) ==
  3738. (u16)rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
  3739. voltage_found = true;
  3740. if ((u32)v_index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
  3741. *std_voltage =
  3742. rdev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
  3743. else
  3744. *std_voltage =
  3745. rdev->pm.dpm.dyn_state.cac_leakage_table.entries[rdev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
  3746. break;
  3747. }
  3748. }
  3749. if (!voltage_found) {
  3750. for (v_index = 0; (u32)v_index < rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
  3751. if (be16_to_cpu(voltage->value) <=
  3752. (u16)rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
  3753. voltage_found = true;
  3754. if ((u32)v_index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
  3755. *std_voltage =
  3756. rdev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
  3757. else
  3758. *std_voltage =
  3759. rdev->pm.dpm.dyn_state.cac_leakage_table.entries[rdev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
  3760. break;
  3761. }
  3762. }
  3763. }
  3764. } else {
  3765. if ((u32)voltage->index < rdev->pm.dpm.dyn_state.cac_leakage_table.count)
  3766. *std_voltage = rdev->pm.dpm.dyn_state.cac_leakage_table.entries[voltage->index].vddc;
  3767. }
  3768. }
  3769. return 0;
  3770. }
  3771. static int si_populate_std_voltage_value(struct radeon_device *rdev,
  3772. u16 value, u8 index,
  3773. SISLANDS_SMC_VOLTAGE_VALUE *voltage)
  3774. {
  3775. voltage->index = index;
  3776. voltage->value = cpu_to_be16(value);
  3777. return 0;
  3778. }
  3779. static int si_populate_phase_shedding_value(struct radeon_device *rdev,
  3780. const struct radeon_phase_shedding_limits_table *limits,
  3781. u16 voltage, u32 sclk, u32 mclk,
  3782. SISLANDS_SMC_VOLTAGE_VALUE *smc_voltage)
  3783. {
  3784. unsigned int i;
  3785. for (i = 0; i < limits->count; i++) {
  3786. if ((voltage <= limits->entries[i].voltage) &&
  3787. (sclk <= limits->entries[i].sclk) &&
  3788. (mclk <= limits->entries[i].mclk))
  3789. break;
  3790. }
  3791. smc_voltage->phase_settings = (u8)i;
  3792. return 0;
  3793. }
  3794. static int si_init_arb_table_index(struct radeon_device *rdev)
  3795. {
  3796. struct si_power_info *si_pi = si_get_pi(rdev);
  3797. u32 tmp;
  3798. int ret;
  3799. ret = si_read_smc_sram_dword(rdev, si_pi->arb_table_start, &tmp, si_pi->sram_end);
  3800. if (ret)
  3801. return ret;
  3802. tmp &= 0x00FFFFFF;
  3803. tmp |= MC_CG_ARB_FREQ_F1 << 24;
  3804. return si_write_smc_sram_dword(rdev, si_pi->arb_table_start, tmp, si_pi->sram_end);
  3805. }
  3806. static int si_initial_switch_from_arb_f0_to_f1(struct radeon_device *rdev)
  3807. {
  3808. return ni_copy_and_switch_arb_sets(rdev, MC_CG_ARB_FREQ_F0, MC_CG_ARB_FREQ_F1);
  3809. }
  3810. static int si_reset_to_default(struct radeon_device *rdev)
  3811. {
  3812. return (si_send_msg_to_smc(rdev, PPSMC_MSG_ResetToDefaults) == PPSMC_Result_OK) ?
  3813. 0 : -EINVAL;
  3814. }
  3815. static int si_force_switch_to_arb_f0(struct radeon_device *rdev)
  3816. {
  3817. struct si_power_info *si_pi = si_get_pi(rdev);
  3818. u32 tmp;
  3819. int ret;
  3820. ret = si_read_smc_sram_dword(rdev, si_pi->arb_table_start,
  3821. &tmp, si_pi->sram_end);
  3822. if (ret)
  3823. return ret;
  3824. tmp = (tmp >> 24) & 0xff;
  3825. if (tmp == MC_CG_ARB_FREQ_F0)
  3826. return 0;
  3827. return ni_copy_and_switch_arb_sets(rdev, tmp, MC_CG_ARB_FREQ_F0);
  3828. }
  3829. static u32 si_calculate_memory_refresh_rate(struct radeon_device *rdev,
  3830. u32 engine_clock)
  3831. {
  3832. u32 dram_rows;
  3833. u32 dram_refresh_rate;
  3834. u32 mc_arb_rfsh_rate;
  3835. u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT;
  3836. if (tmp >= 4)
  3837. dram_rows = 16384;
  3838. else
  3839. dram_rows = 1 << (tmp + 10);
  3840. dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3);
  3841. mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64;
  3842. return mc_arb_rfsh_rate;
  3843. }
  3844. static int si_populate_memory_timing_parameters(struct radeon_device *rdev,
  3845. struct rv7xx_pl *pl,
  3846. SMC_SIslands_MCArbDramTimingRegisterSet *arb_regs)
  3847. {
  3848. u32 dram_timing;
  3849. u32 dram_timing2;
  3850. u32 burst_time;
  3851. arb_regs->mc_arb_rfsh_rate =
  3852. (u8)si_calculate_memory_refresh_rate(rdev, pl->sclk);
  3853. radeon_atom_set_engine_dram_timings(rdev,
  3854. pl->sclk,
  3855. pl->mclk);
  3856. dram_timing = RREG32(MC_ARB_DRAM_TIMING);
  3857. dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
  3858. burst_time = RREG32(MC_ARB_BURST_TIME) & STATE0_MASK;
  3859. arb_regs->mc_arb_dram_timing = cpu_to_be32(dram_timing);
  3860. arb_regs->mc_arb_dram_timing2 = cpu_to_be32(dram_timing2);
  3861. arb_regs->mc_arb_burst_time = (u8)burst_time;
  3862. return 0;
  3863. }
  3864. static int si_do_program_memory_timing_parameters(struct radeon_device *rdev,
  3865. struct radeon_ps *radeon_state,
  3866. unsigned int first_arb_set)
  3867. {
  3868. struct si_power_info *si_pi = si_get_pi(rdev);
  3869. struct ni_ps *state = ni_get_ps(radeon_state);
  3870. SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
  3871. int i, ret = 0;
  3872. for (i = 0; i < state->performance_level_count; i++) {
  3873. ret = si_populate_memory_timing_parameters(rdev, &state->performance_levels[i], &arb_regs);
  3874. if (ret)
  3875. break;
  3876. ret = si_copy_bytes_to_smc(rdev,
  3877. si_pi->arb_table_start +
  3878. offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
  3879. sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * (first_arb_set + i),
  3880. (u8 *)&arb_regs,
  3881. sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
  3882. si_pi->sram_end);
  3883. if (ret)
  3884. break;
  3885. }
  3886. return ret;
  3887. }
  3888. static int si_program_memory_timing_parameters(struct radeon_device *rdev,
  3889. struct radeon_ps *radeon_new_state)
  3890. {
  3891. return si_do_program_memory_timing_parameters(rdev, radeon_new_state,
  3892. SISLANDS_DRIVER_STATE_ARB_INDEX);
  3893. }
  3894. static int si_populate_initial_mvdd_value(struct radeon_device *rdev,
  3895. struct SISLANDS_SMC_VOLTAGE_VALUE *voltage)
  3896. {
  3897. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3898. struct si_power_info *si_pi = si_get_pi(rdev);
  3899. if (pi->mvdd_control)
  3900. return si_populate_voltage_value(rdev, &si_pi->mvdd_voltage_table,
  3901. si_pi->mvdd_bootup_value, voltage);
  3902. return 0;
  3903. }
  3904. static int si_populate_smc_initial_state(struct radeon_device *rdev,
  3905. struct radeon_ps *radeon_initial_state,
  3906. SISLANDS_SMC_STATETABLE *table)
  3907. {
  3908. struct ni_ps *initial_state = ni_get_ps(radeon_initial_state);
  3909. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  3910. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  3911. struct si_power_info *si_pi = si_get_pi(rdev);
  3912. u32 reg;
  3913. int ret;
  3914. table->initialState.levels[0].mclk.vDLL_CNTL =
  3915. cpu_to_be32(si_pi->clock_registers.dll_cntl);
  3916. table->initialState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
  3917. cpu_to_be32(si_pi->clock_registers.mclk_pwrmgt_cntl);
  3918. table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
  3919. cpu_to_be32(si_pi->clock_registers.mpll_ad_func_cntl);
  3920. table->initialState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
  3921. cpu_to_be32(si_pi->clock_registers.mpll_dq_func_cntl);
  3922. table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL =
  3923. cpu_to_be32(si_pi->clock_registers.mpll_func_cntl);
  3924. table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
  3925. cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_1);
  3926. table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
  3927. cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_2);
  3928. table->initialState.levels[0].mclk.vMPLL_SS =
  3929. cpu_to_be32(si_pi->clock_registers.mpll_ss1);
  3930. table->initialState.levels[0].mclk.vMPLL_SS2 =
  3931. cpu_to_be32(si_pi->clock_registers.mpll_ss2);
  3932. table->initialState.levels[0].mclk.mclk_value =
  3933. cpu_to_be32(initial_state->performance_levels[0].mclk);
  3934. table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
  3935. cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl);
  3936. table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
  3937. cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_2);
  3938. table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
  3939. cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_3);
  3940. table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
  3941. cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_4);
  3942. table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM =
  3943. cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum);
  3944. table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM_2 =
  3945. cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum_2);
  3946. table->initialState.levels[0].sclk.sclk_value =
  3947. cpu_to_be32(initial_state->performance_levels[0].sclk);
  3948. table->initialState.levels[0].arbRefreshState =
  3949. SISLANDS_INITIAL_STATE_ARB_INDEX;
  3950. table->initialState.levels[0].ACIndex = 0;
  3951. ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
  3952. initial_state->performance_levels[0].vddc,
  3953. &table->initialState.levels[0].vddc);
  3954. if (!ret) {
  3955. u16 std_vddc;
  3956. ret = si_get_std_voltage_value(rdev,
  3957. &table->initialState.levels[0].vddc,
  3958. &std_vddc);
  3959. if (!ret)
  3960. si_populate_std_voltage_value(rdev, std_vddc,
  3961. table->initialState.levels[0].vddc.index,
  3962. &table->initialState.levels[0].std_vddc);
  3963. }
  3964. if (eg_pi->vddci_control)
  3965. si_populate_voltage_value(rdev,
  3966. &eg_pi->vddci_voltage_table,
  3967. initial_state->performance_levels[0].vddci,
  3968. &table->initialState.levels[0].vddci);
  3969. if (si_pi->vddc_phase_shed_control)
  3970. si_populate_phase_shedding_value(rdev,
  3971. &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
  3972. initial_state->performance_levels[0].vddc,
  3973. initial_state->performance_levels[0].sclk,
  3974. initial_state->performance_levels[0].mclk,
  3975. &table->initialState.levels[0].vddc);
  3976. si_populate_initial_mvdd_value(rdev, &table->initialState.levels[0].mvdd);
  3977. reg = CG_R(0xffff) | CG_L(0);
  3978. table->initialState.levels[0].aT = cpu_to_be32(reg);
  3979. table->initialState.levels[0].bSP = cpu_to_be32(pi->dsp);
  3980. table->initialState.levels[0].gen2PCIE = (u8)si_pi->boot_pcie_gen;
  3981. if (pi->mem_gddr5) {
  3982. table->initialState.levels[0].strobeMode =
  3983. si_get_strobe_mode_settings(rdev,
  3984. initial_state->performance_levels[0].mclk);
  3985. if (initial_state->performance_levels[0].mclk > pi->mclk_edc_enable_threshold)
  3986. table->initialState.levels[0].mcFlags = SISLANDS_SMC_MC_EDC_RD_FLAG | SISLANDS_SMC_MC_EDC_WR_FLAG;
  3987. else
  3988. table->initialState.levels[0].mcFlags = 0;
  3989. }
  3990. table->initialState.levelCount = 1;
  3991. table->initialState.flags |= PPSMC_SWSTATE_FLAG_DC;
  3992. table->initialState.levels[0].dpm2.MaxPS = 0;
  3993. table->initialState.levels[0].dpm2.NearTDPDec = 0;
  3994. table->initialState.levels[0].dpm2.AboveSafeInc = 0;
  3995. table->initialState.levels[0].dpm2.BelowSafeInc = 0;
  3996. table->initialState.levels[0].dpm2.PwrEfficiencyRatio = 0;
  3997. reg = MIN_POWER_MASK | MAX_POWER_MASK;
  3998. table->initialState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
  3999. reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
  4000. table->initialState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
  4001. return 0;
  4002. }
  4003. static int si_populate_smc_acpi_state(struct radeon_device *rdev,
  4004. SISLANDS_SMC_STATETABLE *table)
  4005. {
  4006. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4007. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  4008. struct si_power_info *si_pi = si_get_pi(rdev);
  4009. u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
  4010. u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
  4011. u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
  4012. u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
  4013. u32 dll_cntl = si_pi->clock_registers.dll_cntl;
  4014. u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
  4015. u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
  4016. u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
  4017. u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
  4018. u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
  4019. u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
  4020. u32 reg;
  4021. int ret;
  4022. table->ACPIState = table->initialState;
  4023. table->ACPIState.flags &= ~PPSMC_SWSTATE_FLAG_DC;
  4024. if (pi->acpi_vddc) {
  4025. ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
  4026. pi->acpi_vddc, &table->ACPIState.levels[0].vddc);
  4027. if (!ret) {
  4028. u16 std_vddc;
  4029. ret = si_get_std_voltage_value(rdev,
  4030. &table->ACPIState.levels[0].vddc, &std_vddc);
  4031. if (!ret)
  4032. si_populate_std_voltage_value(rdev, std_vddc,
  4033. table->ACPIState.levels[0].vddc.index,
  4034. &table->ACPIState.levels[0].std_vddc);
  4035. }
  4036. table->ACPIState.levels[0].gen2PCIE = si_pi->acpi_pcie_gen;
  4037. if (si_pi->vddc_phase_shed_control) {
  4038. si_populate_phase_shedding_value(rdev,
  4039. &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
  4040. pi->acpi_vddc,
  4041. 0,
  4042. 0,
  4043. &table->ACPIState.levels[0].vddc);
  4044. }
  4045. } else {
  4046. ret = si_populate_voltage_value(rdev, &eg_pi->vddc_voltage_table,
  4047. pi->min_vddc_in_table, &table->ACPIState.levels[0].vddc);
  4048. if (!ret) {
  4049. u16 std_vddc;
  4050. ret = si_get_std_voltage_value(rdev,
  4051. &table->ACPIState.levels[0].vddc, &std_vddc);
  4052. if (!ret)
  4053. si_populate_std_voltage_value(rdev, std_vddc,
  4054. table->ACPIState.levels[0].vddc.index,
  4055. &table->ACPIState.levels[0].std_vddc);
  4056. }
  4057. table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(rdev,
  4058. si_pi->sys_pcie_mask,
  4059. si_pi->boot_pcie_gen,
  4060. RADEON_PCIE_GEN1);
  4061. if (si_pi->vddc_phase_shed_control)
  4062. si_populate_phase_shedding_value(rdev,
  4063. &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
  4064. pi->min_vddc_in_table,
  4065. 0,
  4066. 0,
  4067. &table->ACPIState.levels[0].vddc);
  4068. }
  4069. if (pi->acpi_vddc) {
  4070. if (eg_pi->acpi_vddci)
  4071. si_populate_voltage_value(rdev, &eg_pi->vddci_voltage_table,
  4072. eg_pi->acpi_vddci,
  4073. &table->ACPIState.levels[0].vddci);
  4074. }
  4075. mclk_pwrmgt_cntl |= MRDCK0_RESET | MRDCK1_RESET;
  4076. mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
  4077. dll_cntl &= ~(MRDCK0_BYPASS | MRDCK1_BYPASS);
  4078. spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
  4079. spll_func_cntl_2 |= SCLK_MUX_SEL(4);
  4080. table->ACPIState.levels[0].mclk.vDLL_CNTL =
  4081. cpu_to_be32(dll_cntl);
  4082. table->ACPIState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
  4083. cpu_to_be32(mclk_pwrmgt_cntl);
  4084. table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
  4085. cpu_to_be32(mpll_ad_func_cntl);
  4086. table->ACPIState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
  4087. cpu_to_be32(mpll_dq_func_cntl);
  4088. table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL =
  4089. cpu_to_be32(mpll_func_cntl);
  4090. table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
  4091. cpu_to_be32(mpll_func_cntl_1);
  4092. table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
  4093. cpu_to_be32(mpll_func_cntl_2);
  4094. table->ACPIState.levels[0].mclk.vMPLL_SS =
  4095. cpu_to_be32(si_pi->clock_registers.mpll_ss1);
  4096. table->ACPIState.levels[0].mclk.vMPLL_SS2 =
  4097. cpu_to_be32(si_pi->clock_registers.mpll_ss2);
  4098. table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
  4099. cpu_to_be32(spll_func_cntl);
  4100. table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
  4101. cpu_to_be32(spll_func_cntl_2);
  4102. table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
  4103. cpu_to_be32(spll_func_cntl_3);
  4104. table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
  4105. cpu_to_be32(spll_func_cntl_4);
  4106. table->ACPIState.levels[0].mclk.mclk_value = 0;
  4107. table->ACPIState.levels[0].sclk.sclk_value = 0;
  4108. si_populate_mvdd_value(rdev, 0, &table->ACPIState.levels[0].mvdd);
  4109. if (eg_pi->dynamic_ac_timing)
  4110. table->ACPIState.levels[0].ACIndex = 0;
  4111. table->ACPIState.levels[0].dpm2.MaxPS = 0;
  4112. table->ACPIState.levels[0].dpm2.NearTDPDec = 0;
  4113. table->ACPIState.levels[0].dpm2.AboveSafeInc = 0;
  4114. table->ACPIState.levels[0].dpm2.BelowSafeInc = 0;
  4115. table->ACPIState.levels[0].dpm2.PwrEfficiencyRatio = 0;
  4116. reg = MIN_POWER_MASK | MAX_POWER_MASK;
  4117. table->ACPIState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
  4118. reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
  4119. table->ACPIState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
  4120. return 0;
  4121. }
  4122. static int si_populate_ulv_state(struct radeon_device *rdev,
  4123. SISLANDS_SMC_SWSTATE *state)
  4124. {
  4125. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  4126. struct si_power_info *si_pi = si_get_pi(rdev);
  4127. struct si_ulv_param *ulv = &si_pi->ulv;
  4128. u32 sclk_in_sr = 1350; /* ??? */
  4129. int ret;
  4130. ret = si_convert_power_level_to_smc(rdev, &ulv->pl,
  4131. &state->levels[0]);
  4132. if (!ret) {
  4133. if (eg_pi->sclk_deep_sleep) {
  4134. if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
  4135. state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
  4136. else
  4137. state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
  4138. }
  4139. if (ulv->one_pcie_lane_in_ulv)
  4140. state->flags |= PPSMC_SWSTATE_FLAG_PCIE_X1;
  4141. state->levels[0].arbRefreshState = (u8)(SISLANDS_ULV_STATE_ARB_INDEX);
  4142. state->levels[0].ACIndex = 1;
  4143. state->levels[0].std_vddc = state->levels[0].vddc;
  4144. state->levelCount = 1;
  4145. state->flags |= PPSMC_SWSTATE_FLAG_DC;
  4146. }
  4147. return ret;
  4148. }
  4149. static int si_program_ulv_memory_timing_parameters(struct radeon_device *rdev)
  4150. {
  4151. struct si_power_info *si_pi = si_get_pi(rdev);
  4152. struct si_ulv_param *ulv = &si_pi->ulv;
  4153. SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
  4154. int ret;
  4155. ret = si_populate_memory_timing_parameters(rdev, &ulv->pl,
  4156. &arb_regs);
  4157. if (ret)
  4158. return ret;
  4159. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_ulv_volt_change_delay,
  4160. ulv->volt_change_delay);
  4161. ret = si_copy_bytes_to_smc(rdev,
  4162. si_pi->arb_table_start +
  4163. offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
  4164. sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * SISLANDS_ULV_STATE_ARB_INDEX,
  4165. (u8 *)&arb_regs,
  4166. sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
  4167. si_pi->sram_end);
  4168. return ret;
  4169. }
  4170. static void si_get_mvdd_configuration(struct radeon_device *rdev)
  4171. {
  4172. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4173. pi->mvdd_split_frequency = 30000;
  4174. }
  4175. static int si_init_smc_table(struct radeon_device *rdev)
  4176. {
  4177. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4178. struct si_power_info *si_pi = si_get_pi(rdev);
  4179. struct radeon_ps *radeon_boot_state = rdev->pm.dpm.boot_ps;
  4180. const struct si_ulv_param *ulv = &si_pi->ulv;
  4181. SISLANDS_SMC_STATETABLE *table = &si_pi->smc_statetable;
  4182. int ret;
  4183. u32 lane_width;
  4184. u32 vr_hot_gpio;
  4185. si_populate_smc_voltage_tables(rdev, table);
  4186. switch (rdev->pm.int_thermal_type) {
  4187. case THERMAL_TYPE_SI:
  4188. case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
  4189. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
  4190. break;
  4191. case THERMAL_TYPE_NONE:
  4192. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
  4193. break;
  4194. default:
  4195. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
  4196. break;
  4197. }
  4198. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
  4199. table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
  4200. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) {
  4201. if ((rdev->pdev->device != 0x6818) && (rdev->pdev->device != 0x6819))
  4202. table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
  4203. }
  4204. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
  4205. table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
  4206. if (pi->mem_gddr5)
  4207. table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
  4208. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REVERT_GPIO5_POLARITY)
  4209. table->extraFlags |= PPSMC_EXTRAFLAGS_AC2DC_GPIO5_POLARITY_HIGH;
  4210. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_VRHOT_GPIO_CONFIGURABLE) {
  4211. table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT_PROG_GPIO;
  4212. vr_hot_gpio = rdev->pm.dpm.backbias_response_time;
  4213. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_vr_hot_gpio,
  4214. vr_hot_gpio);
  4215. }
  4216. ret = si_populate_smc_initial_state(rdev, radeon_boot_state, table);
  4217. if (ret)
  4218. return ret;
  4219. ret = si_populate_smc_acpi_state(rdev, table);
  4220. if (ret)
  4221. return ret;
  4222. table->driverState = table->initialState;
  4223. ret = si_do_program_memory_timing_parameters(rdev, radeon_boot_state,
  4224. SISLANDS_INITIAL_STATE_ARB_INDEX);
  4225. if (ret)
  4226. return ret;
  4227. if (ulv->supported && ulv->pl.vddc) {
  4228. ret = si_populate_ulv_state(rdev, &table->ULVState);
  4229. if (ret)
  4230. return ret;
  4231. ret = si_program_ulv_memory_timing_parameters(rdev);
  4232. if (ret)
  4233. return ret;
  4234. WREG32(CG_ULV_CONTROL, ulv->cg_ulv_control);
  4235. WREG32(CG_ULV_PARAMETER, ulv->cg_ulv_parameter);
  4236. lane_width = radeon_get_pcie_lanes(rdev);
  4237. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
  4238. } else {
  4239. table->ULVState = table->initialState;
  4240. }
  4241. return si_copy_bytes_to_smc(rdev, si_pi->state_table_start,
  4242. (u8 *)table, sizeof(SISLANDS_SMC_STATETABLE),
  4243. si_pi->sram_end);
  4244. }
  4245. static int si_calculate_sclk_params(struct radeon_device *rdev,
  4246. u32 engine_clock,
  4247. SISLANDS_SMC_SCLK_VALUE *sclk)
  4248. {
  4249. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4250. struct si_power_info *si_pi = si_get_pi(rdev);
  4251. struct atom_clock_dividers dividers;
  4252. u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
  4253. u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
  4254. u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
  4255. u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
  4256. u32 cg_spll_spread_spectrum = si_pi->clock_registers.cg_spll_spread_spectrum;
  4257. u32 cg_spll_spread_spectrum_2 = si_pi->clock_registers.cg_spll_spread_spectrum_2;
  4258. u64 tmp;
  4259. u32 reference_clock = rdev->clock.spll.reference_freq;
  4260. u32 reference_divider;
  4261. u32 fbdiv;
  4262. int ret;
  4263. ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
  4264. engine_clock, false, &dividers);
  4265. if (ret)
  4266. return ret;
  4267. reference_divider = 1 + dividers.ref_div;
  4268. tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384;
  4269. do_div(tmp, reference_clock);
  4270. fbdiv = (u32) tmp;
  4271. spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
  4272. spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
  4273. spll_func_cntl |= SPLL_PDIV_A(dividers.post_div);
  4274. spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
  4275. spll_func_cntl_2 |= SCLK_MUX_SEL(2);
  4276. spll_func_cntl_3 &= ~SPLL_FB_DIV_MASK;
  4277. spll_func_cntl_3 |= SPLL_FB_DIV(fbdiv);
  4278. spll_func_cntl_3 |= SPLL_DITHEN;
  4279. if (pi->sclk_ss) {
  4280. struct radeon_atom_ss ss;
  4281. u32 vco_freq = engine_clock * dividers.post_div;
  4282. if (radeon_atombios_get_asic_ss_info(rdev, &ss,
  4283. ASIC_INTERNAL_ENGINE_SS, vco_freq)) {
  4284. u32 clk_s = reference_clock * 5 / (reference_divider * ss.rate);
  4285. u32 clk_v = 4 * ss.percentage * fbdiv / (clk_s * 10000);
  4286. cg_spll_spread_spectrum &= ~CLK_S_MASK;
  4287. cg_spll_spread_spectrum |= CLK_S(clk_s);
  4288. cg_spll_spread_spectrum |= SSEN;
  4289. cg_spll_spread_spectrum_2 &= ~CLK_V_MASK;
  4290. cg_spll_spread_spectrum_2 |= CLK_V(clk_v);
  4291. }
  4292. }
  4293. sclk->sclk_value = engine_clock;
  4294. sclk->vCG_SPLL_FUNC_CNTL = spll_func_cntl;
  4295. sclk->vCG_SPLL_FUNC_CNTL_2 = spll_func_cntl_2;
  4296. sclk->vCG_SPLL_FUNC_CNTL_3 = spll_func_cntl_3;
  4297. sclk->vCG_SPLL_FUNC_CNTL_4 = spll_func_cntl_4;
  4298. sclk->vCG_SPLL_SPREAD_SPECTRUM = cg_spll_spread_spectrum;
  4299. sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cg_spll_spread_spectrum_2;
  4300. return 0;
  4301. }
  4302. static int si_populate_sclk_value(struct radeon_device *rdev,
  4303. u32 engine_clock,
  4304. SISLANDS_SMC_SCLK_VALUE *sclk)
  4305. {
  4306. SISLANDS_SMC_SCLK_VALUE sclk_tmp;
  4307. int ret;
  4308. ret = si_calculate_sclk_params(rdev, engine_clock, &sclk_tmp);
  4309. if (!ret) {
  4310. sclk->sclk_value = cpu_to_be32(sclk_tmp.sclk_value);
  4311. sclk->vCG_SPLL_FUNC_CNTL = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL);
  4312. sclk->vCG_SPLL_FUNC_CNTL_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_2);
  4313. sclk->vCG_SPLL_FUNC_CNTL_3 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_3);
  4314. sclk->vCG_SPLL_FUNC_CNTL_4 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_4);
  4315. sclk->vCG_SPLL_SPREAD_SPECTRUM = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM);
  4316. sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM_2);
  4317. }
  4318. return ret;
  4319. }
  4320. static int si_populate_mclk_value(struct radeon_device *rdev,
  4321. u32 engine_clock,
  4322. u32 memory_clock,
  4323. SISLANDS_SMC_MCLK_VALUE *mclk,
  4324. bool strobe_mode,
  4325. bool dll_state_on)
  4326. {
  4327. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4328. struct si_power_info *si_pi = si_get_pi(rdev);
  4329. u32 dll_cntl = si_pi->clock_registers.dll_cntl;
  4330. u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
  4331. u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
  4332. u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
  4333. u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
  4334. u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
  4335. u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
  4336. u32 mpll_ss1 = si_pi->clock_registers.mpll_ss1;
  4337. u32 mpll_ss2 = si_pi->clock_registers.mpll_ss2;
  4338. struct atom_mpll_param mpll_param;
  4339. int ret;
  4340. ret = radeon_atom_get_memory_pll_dividers(rdev, memory_clock, strobe_mode, &mpll_param);
  4341. if (ret)
  4342. return ret;
  4343. mpll_func_cntl &= ~BWCTRL_MASK;
  4344. mpll_func_cntl |= BWCTRL(mpll_param.bwcntl);
  4345. mpll_func_cntl_1 &= ~(CLKF_MASK | CLKFRAC_MASK | VCO_MODE_MASK);
  4346. mpll_func_cntl_1 |= CLKF(mpll_param.clkf) |
  4347. CLKFRAC(mpll_param.clkfrac) | VCO_MODE(mpll_param.vco_mode);
  4348. mpll_ad_func_cntl &= ~YCLK_POST_DIV_MASK;
  4349. mpll_ad_func_cntl |= YCLK_POST_DIV(mpll_param.post_div);
  4350. if (pi->mem_gddr5) {
  4351. mpll_dq_func_cntl &= ~(YCLK_SEL_MASK | YCLK_POST_DIV_MASK);
  4352. mpll_dq_func_cntl |= YCLK_SEL(mpll_param.yclk_sel) |
  4353. YCLK_POST_DIV(mpll_param.post_div);
  4354. }
  4355. if (pi->mclk_ss) {
  4356. struct radeon_atom_ss ss;
  4357. u32 freq_nom;
  4358. u32 tmp;
  4359. u32 reference_clock = rdev->clock.mpll.reference_freq;
  4360. if (pi->mem_gddr5)
  4361. freq_nom = memory_clock * 4;
  4362. else
  4363. freq_nom = memory_clock * 2;
  4364. tmp = freq_nom / reference_clock;
  4365. tmp = tmp * tmp;
  4366. if (radeon_atombios_get_asic_ss_info(rdev, &ss,
  4367. ASIC_INTERNAL_MEMORY_SS, freq_nom)) {
  4368. u32 clks = reference_clock * 5 / ss.rate;
  4369. u32 clkv = (u32)((((131 * ss.percentage * ss.rate) / 100) * tmp) / freq_nom);
  4370. mpll_ss1 &= ~CLKV_MASK;
  4371. mpll_ss1 |= CLKV(clkv);
  4372. mpll_ss2 &= ~CLKS_MASK;
  4373. mpll_ss2 |= CLKS(clks);
  4374. }
  4375. }
  4376. mclk_pwrmgt_cntl &= ~DLL_SPEED_MASK;
  4377. mclk_pwrmgt_cntl |= DLL_SPEED(mpll_param.dll_speed);
  4378. if (dll_state_on)
  4379. mclk_pwrmgt_cntl |= MRDCK0_PDNB | MRDCK1_PDNB;
  4380. else
  4381. mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
  4382. mclk->mclk_value = cpu_to_be32(memory_clock);
  4383. mclk->vMPLL_FUNC_CNTL = cpu_to_be32(mpll_func_cntl);
  4384. mclk->vMPLL_FUNC_CNTL_1 = cpu_to_be32(mpll_func_cntl_1);
  4385. mclk->vMPLL_FUNC_CNTL_2 = cpu_to_be32(mpll_func_cntl_2);
  4386. mclk->vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl);
  4387. mclk->vMPLL_DQ_FUNC_CNTL = cpu_to_be32(mpll_dq_func_cntl);
  4388. mclk->vMCLK_PWRMGT_CNTL = cpu_to_be32(mclk_pwrmgt_cntl);
  4389. mclk->vDLL_CNTL = cpu_to_be32(dll_cntl);
  4390. mclk->vMPLL_SS = cpu_to_be32(mpll_ss1);
  4391. mclk->vMPLL_SS2 = cpu_to_be32(mpll_ss2);
  4392. return 0;
  4393. }
  4394. static void si_populate_smc_sp(struct radeon_device *rdev,
  4395. struct radeon_ps *radeon_state,
  4396. SISLANDS_SMC_SWSTATE *smc_state)
  4397. {
  4398. struct ni_ps *ps = ni_get_ps(radeon_state);
  4399. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4400. int i;
  4401. for (i = 0; i < ps->performance_level_count - 1; i++)
  4402. smc_state->levels[i].bSP = cpu_to_be32(pi->dsp);
  4403. smc_state->levels[ps->performance_level_count - 1].bSP =
  4404. cpu_to_be32(pi->psp);
  4405. }
  4406. static int si_convert_power_level_to_smc(struct radeon_device *rdev,
  4407. struct rv7xx_pl *pl,
  4408. SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level)
  4409. {
  4410. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4411. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  4412. struct si_power_info *si_pi = si_get_pi(rdev);
  4413. int ret;
  4414. bool dll_state_on;
  4415. u16 std_vddc;
  4416. bool gmc_pg = false;
  4417. if (eg_pi->pcie_performance_request &&
  4418. (si_pi->force_pcie_gen != RADEON_PCIE_GEN_INVALID))
  4419. level->gen2PCIE = (u8)si_pi->force_pcie_gen;
  4420. else
  4421. level->gen2PCIE = (u8)pl->pcie_gen;
  4422. ret = si_populate_sclk_value(rdev, pl->sclk, &level->sclk);
  4423. if (ret)
  4424. return ret;
  4425. level->mcFlags = 0;
  4426. if (pi->mclk_stutter_mode_threshold &&
  4427. (pl->mclk <= pi->mclk_stutter_mode_threshold) &&
  4428. !eg_pi->uvd_enabled &&
  4429. (RREG32(DPG_PIPE_STUTTER_CONTROL) & STUTTER_ENABLE) &&
  4430. (rdev->pm.dpm.new_active_crtc_count <= 2)) {
  4431. level->mcFlags |= SISLANDS_SMC_MC_STUTTER_EN;
  4432. if (gmc_pg)
  4433. level->mcFlags |= SISLANDS_SMC_MC_PG_EN;
  4434. }
  4435. if (pi->mem_gddr5) {
  4436. if (pl->mclk > pi->mclk_edc_enable_threshold)
  4437. level->mcFlags |= SISLANDS_SMC_MC_EDC_RD_FLAG;
  4438. if (pl->mclk > eg_pi->mclk_edc_wr_enable_threshold)
  4439. level->mcFlags |= SISLANDS_SMC_MC_EDC_WR_FLAG;
  4440. level->strobeMode = si_get_strobe_mode_settings(rdev, pl->mclk);
  4441. if (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) {
  4442. if (si_get_mclk_frequency_ratio(pl->mclk, true) >=
  4443. ((RREG32(MC_SEQ_MISC7) >> 16) & 0xf))
  4444. dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
  4445. else
  4446. dll_state_on = ((RREG32(MC_SEQ_MISC6) >> 1) & 0x1) ? true : false;
  4447. } else {
  4448. dll_state_on = false;
  4449. }
  4450. } else {
  4451. level->strobeMode = si_get_strobe_mode_settings(rdev,
  4452. pl->mclk);
  4453. dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
  4454. }
  4455. ret = si_populate_mclk_value(rdev,
  4456. pl->sclk,
  4457. pl->mclk,
  4458. &level->mclk,
  4459. (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) != 0, dll_state_on);
  4460. if (ret)
  4461. return ret;
  4462. ret = si_populate_voltage_value(rdev,
  4463. &eg_pi->vddc_voltage_table,
  4464. pl->vddc, &level->vddc);
  4465. if (ret)
  4466. return ret;
  4467. ret = si_get_std_voltage_value(rdev, &level->vddc, &std_vddc);
  4468. if (ret)
  4469. return ret;
  4470. ret = si_populate_std_voltage_value(rdev, std_vddc,
  4471. level->vddc.index, &level->std_vddc);
  4472. if (ret)
  4473. return ret;
  4474. if (eg_pi->vddci_control) {
  4475. ret = si_populate_voltage_value(rdev, &eg_pi->vddci_voltage_table,
  4476. pl->vddci, &level->vddci);
  4477. if (ret)
  4478. return ret;
  4479. }
  4480. if (si_pi->vddc_phase_shed_control) {
  4481. ret = si_populate_phase_shedding_value(rdev,
  4482. &rdev->pm.dpm.dyn_state.phase_shedding_limits_table,
  4483. pl->vddc,
  4484. pl->sclk,
  4485. pl->mclk,
  4486. &level->vddc);
  4487. if (ret)
  4488. return ret;
  4489. }
  4490. level->MaxPoweredUpCU = si_pi->max_cu;
  4491. ret = si_populate_mvdd_value(rdev, pl->mclk, &level->mvdd);
  4492. return ret;
  4493. }
  4494. static int si_populate_smc_t(struct radeon_device *rdev,
  4495. struct radeon_ps *radeon_state,
  4496. SISLANDS_SMC_SWSTATE *smc_state)
  4497. {
  4498. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4499. struct ni_ps *state = ni_get_ps(radeon_state);
  4500. u32 a_t;
  4501. u32 t_l, t_h;
  4502. u32 high_bsp;
  4503. int i, ret;
  4504. if (state->performance_level_count >= 9)
  4505. return -EINVAL;
  4506. if (state->performance_level_count < 2) {
  4507. a_t = CG_R(0xffff) | CG_L(0);
  4508. smc_state->levels[0].aT = cpu_to_be32(a_t);
  4509. return 0;
  4510. }
  4511. smc_state->levels[0].aT = cpu_to_be32(0);
  4512. for (i = 0; i <= state->performance_level_count - 2; i++) {
  4513. ret = r600_calculate_at(
  4514. (50 / SISLANDS_MAX_HARDWARE_POWERLEVELS) * 100 * (i + 1),
  4515. 100 * R600_AH_DFLT,
  4516. state->performance_levels[i + 1].sclk,
  4517. state->performance_levels[i].sclk,
  4518. &t_l,
  4519. &t_h);
  4520. if (ret) {
  4521. t_h = (i + 1) * 1000 - 50 * R600_AH_DFLT;
  4522. t_l = (i + 1) * 1000 + 50 * R600_AH_DFLT;
  4523. }
  4524. a_t = be32_to_cpu(smc_state->levels[i].aT) & ~CG_R_MASK;
  4525. a_t |= CG_R(t_l * pi->bsp / 20000);
  4526. smc_state->levels[i].aT = cpu_to_be32(a_t);
  4527. high_bsp = (i == state->performance_level_count - 2) ?
  4528. pi->pbsp : pi->bsp;
  4529. a_t = CG_R(0xffff) | CG_L(t_h * high_bsp / 20000);
  4530. smc_state->levels[i + 1].aT = cpu_to_be32(a_t);
  4531. }
  4532. return 0;
  4533. }
  4534. static int si_disable_ulv(struct radeon_device *rdev)
  4535. {
  4536. struct si_power_info *si_pi = si_get_pi(rdev);
  4537. struct si_ulv_param *ulv = &si_pi->ulv;
  4538. if (ulv->supported)
  4539. return (si_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ?
  4540. 0 : -EINVAL;
  4541. return 0;
  4542. }
  4543. static bool si_is_state_ulv_compatible(struct radeon_device *rdev,
  4544. struct radeon_ps *radeon_state)
  4545. {
  4546. const struct si_power_info *si_pi = si_get_pi(rdev);
  4547. const struct si_ulv_param *ulv = &si_pi->ulv;
  4548. const struct ni_ps *state = ni_get_ps(radeon_state);
  4549. int i;
  4550. if (state->performance_levels[0].mclk != ulv->pl.mclk)
  4551. return false;
  4552. /* XXX validate against display requirements! */
  4553. for (i = 0; i < rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count; i++) {
  4554. if (rdev->clock.current_dispclk <=
  4555. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].clk) {
  4556. if (ulv->pl.vddc <
  4557. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].v)
  4558. return false;
  4559. }
  4560. }
  4561. if ((radeon_state->vclk != 0) || (radeon_state->dclk != 0))
  4562. return false;
  4563. return true;
  4564. }
  4565. static int si_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev,
  4566. struct radeon_ps *radeon_new_state)
  4567. {
  4568. const struct si_power_info *si_pi = si_get_pi(rdev);
  4569. const struct si_ulv_param *ulv = &si_pi->ulv;
  4570. if (ulv->supported) {
  4571. if (si_is_state_ulv_compatible(rdev, radeon_new_state))
  4572. return (si_send_msg_to_smc(rdev, PPSMC_MSG_EnableULV) == PPSMC_Result_OK) ?
  4573. 0 : -EINVAL;
  4574. }
  4575. return 0;
  4576. }
  4577. static int si_convert_power_state_to_smc(struct radeon_device *rdev,
  4578. struct radeon_ps *radeon_state,
  4579. SISLANDS_SMC_SWSTATE *smc_state)
  4580. {
  4581. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  4582. struct ni_power_info *ni_pi = ni_get_pi(rdev);
  4583. struct si_power_info *si_pi = si_get_pi(rdev);
  4584. struct ni_ps *state = ni_get_ps(radeon_state);
  4585. int i, ret;
  4586. u32 threshold;
  4587. u32 sclk_in_sr = 1350; /* ??? */
  4588. if (state->performance_level_count > SISLANDS_MAX_HARDWARE_POWERLEVELS)
  4589. return -EINVAL;
  4590. threshold = state->performance_levels[state->performance_level_count-1].sclk * 100 / 100;
  4591. if (radeon_state->vclk && radeon_state->dclk) {
  4592. eg_pi->uvd_enabled = true;
  4593. if (eg_pi->smu_uvd_hs)
  4594. smc_state->flags |= PPSMC_SWSTATE_FLAG_UVD;
  4595. } else {
  4596. eg_pi->uvd_enabled = false;
  4597. }
  4598. if (state->dc_compatible)
  4599. smc_state->flags |= PPSMC_SWSTATE_FLAG_DC;
  4600. smc_state->levelCount = 0;
  4601. for (i = 0; i < state->performance_level_count; i++) {
  4602. if (eg_pi->sclk_deep_sleep) {
  4603. if ((i == 0) || si_pi->sclk_deep_sleep_above_low) {
  4604. if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
  4605. smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
  4606. else
  4607. smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
  4608. }
  4609. }
  4610. ret = si_convert_power_level_to_smc(rdev, &state->performance_levels[i],
  4611. &smc_state->levels[i]);
  4612. smc_state->levels[i].arbRefreshState =
  4613. (u8)(SISLANDS_DRIVER_STATE_ARB_INDEX + i);
  4614. if (ret)
  4615. return ret;
  4616. if (ni_pi->enable_power_containment)
  4617. smc_state->levels[i].displayWatermark =
  4618. (state->performance_levels[i].sclk < threshold) ?
  4619. PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
  4620. else
  4621. smc_state->levels[i].displayWatermark = (i < 2) ?
  4622. PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
  4623. if (eg_pi->dynamic_ac_timing)
  4624. smc_state->levels[i].ACIndex = SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i;
  4625. else
  4626. smc_state->levels[i].ACIndex = 0;
  4627. smc_state->levelCount++;
  4628. }
  4629. si_write_smc_soft_register(rdev,
  4630. SI_SMC_SOFT_REGISTER_watermark_threshold,
  4631. threshold / 512);
  4632. si_populate_smc_sp(rdev, radeon_state, smc_state);
  4633. ret = si_populate_power_containment_values(rdev, radeon_state, smc_state);
  4634. if (ret)
  4635. ni_pi->enable_power_containment = false;
  4636. ret = si_populate_sq_ramping_values(rdev, radeon_state, smc_state);
  4637. if (ret)
  4638. ni_pi->enable_sq_ramping = false;
  4639. return si_populate_smc_t(rdev, radeon_state, smc_state);
  4640. }
  4641. static int si_upload_sw_state(struct radeon_device *rdev,
  4642. struct radeon_ps *radeon_new_state)
  4643. {
  4644. struct si_power_info *si_pi = si_get_pi(rdev);
  4645. struct ni_ps *new_state = ni_get_ps(radeon_new_state);
  4646. int ret;
  4647. u32 address = si_pi->state_table_start +
  4648. offsetof(SISLANDS_SMC_STATETABLE, driverState);
  4649. u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
  4650. ((new_state->performance_level_count - 1) *
  4651. sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
  4652. SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
  4653. memset(smc_state, 0, state_size);
  4654. ret = si_convert_power_state_to_smc(rdev, radeon_new_state, smc_state);
  4655. if (ret)
  4656. return ret;
  4657. ret = si_copy_bytes_to_smc(rdev, address, (u8 *)smc_state,
  4658. state_size, si_pi->sram_end);
  4659. return ret;
  4660. }
  4661. static int si_upload_ulv_state(struct radeon_device *rdev)
  4662. {
  4663. struct si_power_info *si_pi = si_get_pi(rdev);
  4664. struct si_ulv_param *ulv = &si_pi->ulv;
  4665. int ret = 0;
  4666. if (ulv->supported && ulv->pl.vddc) {
  4667. u32 address = si_pi->state_table_start +
  4668. offsetof(SISLANDS_SMC_STATETABLE, ULVState);
  4669. SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.ULVState;
  4670. u32 state_size = sizeof(SISLANDS_SMC_SWSTATE);
  4671. memset(smc_state, 0, state_size);
  4672. ret = si_populate_ulv_state(rdev, smc_state);
  4673. if (!ret)
  4674. ret = si_copy_bytes_to_smc(rdev, address, (u8 *)smc_state,
  4675. state_size, si_pi->sram_end);
  4676. }
  4677. return ret;
  4678. }
  4679. static int si_upload_smc_data(struct radeon_device *rdev)
  4680. {
  4681. struct radeon_crtc *radeon_crtc = NULL;
  4682. int i;
  4683. if (rdev->pm.dpm.new_active_crtc_count == 0)
  4684. return 0;
  4685. for (i = 0; i < rdev->num_crtc; i++) {
  4686. if (rdev->pm.dpm.new_active_crtcs & (1 << i)) {
  4687. radeon_crtc = rdev->mode_info.crtcs[i];
  4688. break;
  4689. }
  4690. }
  4691. if (radeon_crtc == NULL)
  4692. return 0;
  4693. if (radeon_crtc->line_time <= 0)
  4694. return 0;
  4695. if (si_write_smc_soft_register(rdev,
  4696. SI_SMC_SOFT_REGISTER_crtc_index,
  4697. radeon_crtc->crtc_id) != PPSMC_Result_OK)
  4698. return 0;
  4699. if (si_write_smc_soft_register(rdev,
  4700. SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
  4701. radeon_crtc->wm_high / radeon_crtc->line_time) != PPSMC_Result_OK)
  4702. return 0;
  4703. if (si_write_smc_soft_register(rdev,
  4704. SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
  4705. radeon_crtc->wm_low / radeon_crtc->line_time) != PPSMC_Result_OK)
  4706. return 0;
  4707. return 0;
  4708. }
  4709. static int si_set_mc_special_registers(struct radeon_device *rdev,
  4710. struct si_mc_reg_table *table)
  4711. {
  4712. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  4713. u8 i, j, k;
  4714. u32 temp_reg;
  4715. for (i = 0, j = table->last; i < table->last; i++) {
  4716. if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4717. return -EINVAL;
  4718. switch (table->mc_reg_address[i].s1 << 2) {
  4719. case MC_SEQ_MISC1:
  4720. temp_reg = RREG32(MC_PMG_CMD_EMRS);
  4721. table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS >> 2;
  4722. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
  4723. for (k = 0; k < table->num_entries; k++)
  4724. table->mc_reg_table_entry[k].mc_data[j] =
  4725. ((temp_reg & 0xffff0000)) |
  4726. ((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
  4727. j++;
  4728. if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4729. return -EINVAL;
  4730. temp_reg = RREG32(MC_PMG_CMD_MRS);
  4731. table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS >> 2;
  4732. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP >> 2;
  4733. for (k = 0; k < table->num_entries; k++) {
  4734. table->mc_reg_table_entry[k].mc_data[j] =
  4735. (temp_reg & 0xffff0000) |
  4736. (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
  4737. if (!pi->mem_gddr5)
  4738. table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
  4739. }
  4740. j++;
  4741. if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4742. return -EINVAL;
  4743. if (!pi->mem_gddr5) {
  4744. table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD >> 2;
  4745. table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD >> 2;
  4746. for (k = 0; k < table->num_entries; k++)
  4747. table->mc_reg_table_entry[k].mc_data[j] =
  4748. (table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16;
  4749. j++;
  4750. if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4751. return -EINVAL;
  4752. }
  4753. break;
  4754. case MC_SEQ_RESERVE_M:
  4755. temp_reg = RREG32(MC_PMG_CMD_MRS1);
  4756. table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
  4757. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
  4758. for(k = 0; k < table->num_entries; k++)
  4759. table->mc_reg_table_entry[k].mc_data[j] =
  4760. (temp_reg & 0xffff0000) |
  4761. (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
  4762. j++;
  4763. if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4764. return -EINVAL;
  4765. break;
  4766. default:
  4767. break;
  4768. }
  4769. }
  4770. table->last = j;
  4771. return 0;
  4772. }
  4773. static bool si_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
  4774. {
  4775. bool result = true;
  4776. switch (in_reg) {
  4777. case MC_SEQ_RAS_TIMING >> 2:
  4778. *out_reg = MC_SEQ_RAS_TIMING_LP >> 2;
  4779. break;
  4780. case MC_SEQ_CAS_TIMING >> 2:
  4781. *out_reg = MC_SEQ_CAS_TIMING_LP >> 2;
  4782. break;
  4783. case MC_SEQ_MISC_TIMING >> 2:
  4784. *out_reg = MC_SEQ_MISC_TIMING_LP >> 2;
  4785. break;
  4786. case MC_SEQ_MISC_TIMING2 >> 2:
  4787. *out_reg = MC_SEQ_MISC_TIMING2_LP >> 2;
  4788. break;
  4789. case MC_SEQ_RD_CTL_D0 >> 2:
  4790. *out_reg = MC_SEQ_RD_CTL_D0_LP >> 2;
  4791. break;
  4792. case MC_SEQ_RD_CTL_D1 >> 2:
  4793. *out_reg = MC_SEQ_RD_CTL_D1_LP >> 2;
  4794. break;
  4795. case MC_SEQ_WR_CTL_D0 >> 2:
  4796. *out_reg = MC_SEQ_WR_CTL_D0_LP >> 2;
  4797. break;
  4798. case MC_SEQ_WR_CTL_D1 >> 2:
  4799. *out_reg = MC_SEQ_WR_CTL_D1_LP >> 2;
  4800. break;
  4801. case MC_PMG_CMD_EMRS >> 2:
  4802. *out_reg = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
  4803. break;
  4804. case MC_PMG_CMD_MRS >> 2:
  4805. *out_reg = MC_SEQ_PMG_CMD_MRS_LP >> 2;
  4806. break;
  4807. case MC_PMG_CMD_MRS1 >> 2:
  4808. *out_reg = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
  4809. break;
  4810. case MC_SEQ_PMG_TIMING >> 2:
  4811. *out_reg = MC_SEQ_PMG_TIMING_LP >> 2;
  4812. break;
  4813. case MC_PMG_CMD_MRS2 >> 2:
  4814. *out_reg = MC_SEQ_PMG_CMD_MRS2_LP >> 2;
  4815. break;
  4816. case MC_SEQ_WR_CTL_2 >> 2:
  4817. *out_reg = MC_SEQ_WR_CTL_2_LP >> 2;
  4818. break;
  4819. default:
  4820. result = false;
  4821. break;
  4822. }
  4823. return result;
  4824. }
  4825. static void si_set_valid_flag(struct si_mc_reg_table *table)
  4826. {
  4827. u8 i, j;
  4828. for (i = 0; i < table->last; i++) {
  4829. for (j = 1; j < table->num_entries; j++) {
  4830. if (table->mc_reg_table_entry[j-1].mc_data[i] != table->mc_reg_table_entry[j].mc_data[i]) {
  4831. table->valid_flag |= 1 << i;
  4832. break;
  4833. }
  4834. }
  4835. }
  4836. }
  4837. static void si_set_s0_mc_reg_index(struct si_mc_reg_table *table)
  4838. {
  4839. u32 i;
  4840. u16 address;
  4841. for (i = 0; i < table->last; i++)
  4842. table->mc_reg_address[i].s0 = si_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
  4843. address : table->mc_reg_address[i].s1;
  4844. }
  4845. static int si_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
  4846. struct si_mc_reg_table *si_table)
  4847. {
  4848. u8 i, j;
  4849. if (table->last > SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4850. return -EINVAL;
  4851. if (table->num_entries > MAX_AC_TIMING_ENTRIES)
  4852. return -EINVAL;
  4853. for (i = 0; i < table->last; i++)
  4854. si_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
  4855. si_table->last = table->last;
  4856. for (i = 0; i < table->num_entries; i++) {
  4857. si_table->mc_reg_table_entry[i].mclk_max =
  4858. table->mc_reg_table_entry[i].mclk_max;
  4859. for (j = 0; j < table->last; j++) {
  4860. si_table->mc_reg_table_entry[i].mc_data[j] =
  4861. table->mc_reg_table_entry[i].mc_data[j];
  4862. }
  4863. }
  4864. si_table->num_entries = table->num_entries;
  4865. return 0;
  4866. }
  4867. static int si_initialize_mc_reg_table(struct radeon_device *rdev)
  4868. {
  4869. struct si_power_info *si_pi = si_get_pi(rdev);
  4870. struct atom_mc_reg_table *table;
  4871. struct si_mc_reg_table *si_table = &si_pi->mc_reg_table;
  4872. u8 module_index = rv770_get_memory_module_index(rdev);
  4873. int ret;
  4874. table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
  4875. if (!table)
  4876. return -ENOMEM;
  4877. WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
  4878. WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
  4879. WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
  4880. WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
  4881. WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
  4882. WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
  4883. WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
  4884. WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
  4885. WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
  4886. WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
  4887. WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
  4888. WREG32(MC_SEQ_PMG_TIMING_LP, RREG32(MC_SEQ_PMG_TIMING));
  4889. WREG32(MC_SEQ_PMG_CMD_MRS2_LP, RREG32(MC_PMG_CMD_MRS2));
  4890. WREG32(MC_SEQ_WR_CTL_2_LP, RREG32(MC_SEQ_WR_CTL_2));
  4891. ret = radeon_atom_init_mc_reg_table(rdev, module_index, table);
  4892. if (ret)
  4893. goto init_mc_done;
  4894. ret = si_copy_vbios_mc_reg_table(table, si_table);
  4895. if (ret)
  4896. goto init_mc_done;
  4897. si_set_s0_mc_reg_index(si_table);
  4898. ret = si_set_mc_special_registers(rdev, si_table);
  4899. if (ret)
  4900. goto init_mc_done;
  4901. si_set_valid_flag(si_table);
  4902. init_mc_done:
  4903. kfree(table);
  4904. return ret;
  4905. }
  4906. static void si_populate_mc_reg_addresses(struct radeon_device *rdev,
  4907. SMC_SIslands_MCRegisters *mc_reg_table)
  4908. {
  4909. struct si_power_info *si_pi = si_get_pi(rdev);
  4910. u32 i, j;
  4911. for (i = 0, j = 0; j < si_pi->mc_reg_table.last; j++) {
  4912. if (si_pi->mc_reg_table.valid_flag & (1 << j)) {
  4913. if (i >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
  4914. break;
  4915. mc_reg_table->address[i].s0 =
  4916. cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s0);
  4917. mc_reg_table->address[i].s1 =
  4918. cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s1);
  4919. i++;
  4920. }
  4921. }
  4922. mc_reg_table->last = (u8)i;
  4923. }
  4924. static void si_convert_mc_registers(const struct si_mc_reg_entry *entry,
  4925. SMC_SIslands_MCRegisterSet *data,
  4926. u32 num_entries, u32 valid_flag)
  4927. {
  4928. u32 i, j;
  4929. for(i = 0, j = 0; j < num_entries; j++) {
  4930. if (valid_flag & (1 << j)) {
  4931. data->value[i] = cpu_to_be32(entry->mc_data[j]);
  4932. i++;
  4933. }
  4934. }
  4935. }
  4936. static void si_convert_mc_reg_table_entry_to_smc(struct radeon_device *rdev,
  4937. struct rv7xx_pl *pl,
  4938. SMC_SIslands_MCRegisterSet *mc_reg_table_data)
  4939. {
  4940. struct si_power_info *si_pi = si_get_pi(rdev);
  4941. u32 i = 0;
  4942. for (i = 0; i < si_pi->mc_reg_table.num_entries; i++) {
  4943. if (pl->mclk <= si_pi->mc_reg_table.mc_reg_table_entry[i].mclk_max)
  4944. break;
  4945. }
  4946. if ((i == si_pi->mc_reg_table.num_entries) && (i > 0))
  4947. --i;
  4948. si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[i],
  4949. mc_reg_table_data, si_pi->mc_reg_table.last,
  4950. si_pi->mc_reg_table.valid_flag);
  4951. }
  4952. static void si_convert_mc_reg_table_to_smc(struct radeon_device *rdev,
  4953. struct radeon_ps *radeon_state,
  4954. SMC_SIslands_MCRegisters *mc_reg_table)
  4955. {
  4956. struct ni_ps *state = ni_get_ps(radeon_state);
  4957. int i;
  4958. for (i = 0; i < state->performance_level_count; i++) {
  4959. si_convert_mc_reg_table_entry_to_smc(rdev,
  4960. &state->performance_levels[i],
  4961. &mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i]);
  4962. }
  4963. }
  4964. static int si_populate_mc_reg_table(struct radeon_device *rdev,
  4965. struct radeon_ps *radeon_boot_state)
  4966. {
  4967. struct ni_ps *boot_state = ni_get_ps(radeon_boot_state);
  4968. struct si_power_info *si_pi = si_get_pi(rdev);
  4969. struct si_ulv_param *ulv = &si_pi->ulv;
  4970. SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
  4971. memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
  4972. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_seq_index, 1);
  4973. si_populate_mc_reg_addresses(rdev, smc_mc_reg_table);
  4974. si_convert_mc_reg_table_entry_to_smc(rdev, &boot_state->performance_levels[0],
  4975. &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_INITIAL_SLOT]);
  4976. si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
  4977. &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ACPI_SLOT],
  4978. si_pi->mc_reg_table.last,
  4979. si_pi->mc_reg_table.valid_flag);
  4980. if (ulv->supported && ulv->pl.vddc != 0)
  4981. si_convert_mc_reg_table_entry_to_smc(rdev, &ulv->pl,
  4982. &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT]);
  4983. else
  4984. si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
  4985. &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT],
  4986. si_pi->mc_reg_table.last,
  4987. si_pi->mc_reg_table.valid_flag);
  4988. si_convert_mc_reg_table_to_smc(rdev, radeon_boot_state, smc_mc_reg_table);
  4989. return si_copy_bytes_to_smc(rdev, si_pi->mc_reg_table_start,
  4990. (u8 *)smc_mc_reg_table,
  4991. sizeof(SMC_SIslands_MCRegisters), si_pi->sram_end);
  4992. }
  4993. static int si_upload_mc_reg_table(struct radeon_device *rdev,
  4994. struct radeon_ps *radeon_new_state)
  4995. {
  4996. struct ni_ps *new_state = ni_get_ps(radeon_new_state);
  4997. struct si_power_info *si_pi = si_get_pi(rdev);
  4998. u32 address = si_pi->mc_reg_table_start +
  4999. offsetof(SMC_SIslands_MCRegisters,
  5000. data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT]);
  5001. SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
  5002. memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
  5003. si_convert_mc_reg_table_to_smc(rdev, radeon_new_state, smc_mc_reg_table);
  5004. return si_copy_bytes_to_smc(rdev, address,
  5005. (u8 *)&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT],
  5006. sizeof(SMC_SIslands_MCRegisterSet) * new_state->performance_level_count,
  5007. si_pi->sram_end);
  5008. }
  5009. static void si_enable_voltage_control(struct radeon_device *rdev, bool enable)
  5010. {
  5011. if (enable)
  5012. WREG32_P(GENERAL_PWRMGT, VOLT_PWRMGT_EN, ~VOLT_PWRMGT_EN);
  5013. else
  5014. WREG32_P(GENERAL_PWRMGT, 0, ~VOLT_PWRMGT_EN);
  5015. }
  5016. static enum radeon_pcie_gen si_get_maximum_link_speed(struct radeon_device *rdev,
  5017. struct radeon_ps *radeon_state)
  5018. {
  5019. struct ni_ps *state = ni_get_ps(radeon_state);
  5020. int i;
  5021. u16 pcie_speed, max_speed = 0;
  5022. for (i = 0; i < state->performance_level_count; i++) {
  5023. pcie_speed = state->performance_levels[i].pcie_gen;
  5024. if (max_speed < pcie_speed)
  5025. max_speed = pcie_speed;
  5026. }
  5027. return max_speed;
  5028. }
  5029. static u16 si_get_current_pcie_speed(struct radeon_device *rdev)
  5030. {
  5031. u32 speed_cntl;
  5032. speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL) & LC_CURRENT_DATA_RATE_MASK;
  5033. speed_cntl >>= LC_CURRENT_DATA_RATE_SHIFT;
  5034. return (u16)speed_cntl;
  5035. }
  5036. static void si_request_link_speed_change_before_state_change(struct radeon_device *rdev,
  5037. struct radeon_ps *radeon_new_state,
  5038. struct radeon_ps *radeon_current_state)
  5039. {
  5040. struct si_power_info *si_pi = si_get_pi(rdev);
  5041. enum radeon_pcie_gen target_link_speed = si_get_maximum_link_speed(rdev, radeon_new_state);
  5042. enum radeon_pcie_gen current_link_speed;
  5043. if (si_pi->force_pcie_gen == RADEON_PCIE_GEN_INVALID)
  5044. current_link_speed = si_get_maximum_link_speed(rdev, radeon_current_state);
  5045. else
  5046. current_link_speed = si_pi->force_pcie_gen;
  5047. si_pi->force_pcie_gen = RADEON_PCIE_GEN_INVALID;
  5048. si_pi->pspp_notify_required = false;
  5049. if (target_link_speed > current_link_speed) {
  5050. switch (target_link_speed) {
  5051. #if defined(CONFIG_ACPI)
  5052. case RADEON_PCIE_GEN3:
  5053. if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN3, false) == 0)
  5054. break;
  5055. si_pi->force_pcie_gen = RADEON_PCIE_GEN2;
  5056. if (current_link_speed == RADEON_PCIE_GEN2)
  5057. break;
  5058. case RADEON_PCIE_GEN2:
  5059. if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
  5060. break;
  5061. #endif
  5062. default:
  5063. si_pi->force_pcie_gen = si_get_current_pcie_speed(rdev);
  5064. break;
  5065. }
  5066. } else {
  5067. if (target_link_speed < current_link_speed)
  5068. si_pi->pspp_notify_required = true;
  5069. }
  5070. }
  5071. static void si_notify_link_speed_change_after_state_change(struct radeon_device *rdev,
  5072. struct radeon_ps *radeon_new_state,
  5073. struct radeon_ps *radeon_current_state)
  5074. {
  5075. struct si_power_info *si_pi = si_get_pi(rdev);
  5076. enum radeon_pcie_gen target_link_speed = si_get_maximum_link_speed(rdev, radeon_new_state);
  5077. u8 request;
  5078. if (si_pi->pspp_notify_required) {
  5079. if (target_link_speed == RADEON_PCIE_GEN3)
  5080. request = PCIE_PERF_REQ_PECI_GEN3;
  5081. else if (target_link_speed == RADEON_PCIE_GEN2)
  5082. request = PCIE_PERF_REQ_PECI_GEN2;
  5083. else
  5084. request = PCIE_PERF_REQ_PECI_GEN1;
  5085. if ((request == PCIE_PERF_REQ_PECI_GEN1) &&
  5086. (si_get_current_pcie_speed(rdev) > 0))
  5087. return;
  5088. #if defined(CONFIG_ACPI)
  5089. radeon_acpi_pcie_performance_request(rdev, request, false);
  5090. #endif
  5091. }
  5092. }
  5093. #if 0
  5094. static int si_ds_request(struct radeon_device *rdev,
  5095. bool ds_status_on, u32 count_write)
  5096. {
  5097. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5098. if (eg_pi->sclk_deep_sleep) {
  5099. if (ds_status_on)
  5100. return (si_send_msg_to_smc(rdev, PPSMC_MSG_CancelThrottleOVRDSCLKDS) ==
  5101. PPSMC_Result_OK) ?
  5102. 0 : -EINVAL;
  5103. else
  5104. return (si_send_msg_to_smc(rdev, PPSMC_MSG_ThrottleOVRDSCLKDS) ==
  5105. PPSMC_Result_OK) ? 0 : -EINVAL;
  5106. }
  5107. return 0;
  5108. }
  5109. #endif
  5110. static void si_set_max_cu_value(struct radeon_device *rdev)
  5111. {
  5112. struct si_power_info *si_pi = si_get_pi(rdev);
  5113. if (rdev->family == CHIP_VERDE) {
  5114. switch (rdev->pdev->device) {
  5115. case 0x6820:
  5116. case 0x6825:
  5117. case 0x6821:
  5118. case 0x6823:
  5119. case 0x6827:
  5120. si_pi->max_cu = 10;
  5121. break;
  5122. case 0x682D:
  5123. case 0x6824:
  5124. case 0x682F:
  5125. case 0x6826:
  5126. si_pi->max_cu = 8;
  5127. break;
  5128. case 0x6828:
  5129. case 0x6830:
  5130. case 0x6831:
  5131. case 0x6838:
  5132. case 0x6839:
  5133. case 0x683D:
  5134. si_pi->max_cu = 10;
  5135. break;
  5136. case 0x683B:
  5137. case 0x683F:
  5138. case 0x6829:
  5139. si_pi->max_cu = 8;
  5140. break;
  5141. default:
  5142. si_pi->max_cu = 0;
  5143. break;
  5144. }
  5145. } else {
  5146. si_pi->max_cu = 0;
  5147. }
  5148. }
  5149. static int si_patch_single_dependency_table_based_on_leakage(struct radeon_device *rdev,
  5150. struct radeon_clock_voltage_dependency_table *table)
  5151. {
  5152. u32 i;
  5153. int j;
  5154. u16 leakage_voltage;
  5155. if (table) {
  5156. for (i = 0; i < table->count; i++) {
  5157. switch (si_get_leakage_voltage_from_leakage_index(rdev,
  5158. table->entries[i].v,
  5159. &leakage_voltage)) {
  5160. case 0:
  5161. table->entries[i].v = leakage_voltage;
  5162. break;
  5163. case -EAGAIN:
  5164. return -EINVAL;
  5165. case -EINVAL:
  5166. default:
  5167. break;
  5168. }
  5169. }
  5170. for (j = (table->count - 2); j >= 0; j--) {
  5171. table->entries[j].v = (table->entries[j].v <= table->entries[j + 1].v) ?
  5172. table->entries[j].v : table->entries[j + 1].v;
  5173. }
  5174. }
  5175. return 0;
  5176. }
  5177. static int si_patch_dependency_tables_based_on_leakage(struct radeon_device *rdev)
  5178. {
  5179. int ret = 0;
  5180. ret = si_patch_single_dependency_table_based_on_leakage(rdev,
  5181. &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk);
  5182. ret = si_patch_single_dependency_table_based_on_leakage(rdev,
  5183. &rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk);
  5184. ret = si_patch_single_dependency_table_based_on_leakage(rdev,
  5185. &rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk);
  5186. return ret;
  5187. }
  5188. static void si_set_pcie_lane_width_in_smc(struct radeon_device *rdev,
  5189. struct radeon_ps *radeon_new_state,
  5190. struct radeon_ps *radeon_current_state)
  5191. {
  5192. u32 lane_width;
  5193. u32 new_lane_width =
  5194. ((radeon_new_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
  5195. u32 current_lane_width =
  5196. ((radeon_current_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
  5197. if (new_lane_width != current_lane_width) {
  5198. radeon_set_pcie_lanes(rdev, new_lane_width);
  5199. lane_width = radeon_get_pcie_lanes(rdev);
  5200. si_write_smc_soft_register(rdev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
  5201. }
  5202. }
  5203. static void si_set_vce_clock(struct radeon_device *rdev,
  5204. struct radeon_ps *new_rps,
  5205. struct radeon_ps *old_rps)
  5206. {
  5207. if ((old_rps->evclk != new_rps->evclk) ||
  5208. (old_rps->ecclk != new_rps->ecclk)) {
  5209. /* turn the clocks on when encoding, off otherwise */
  5210. if (new_rps->evclk || new_rps->ecclk)
  5211. vce_v1_0_enable_mgcg(rdev, false);
  5212. else
  5213. vce_v1_0_enable_mgcg(rdev, true);
  5214. radeon_set_vce_clocks(rdev, new_rps->evclk, new_rps->ecclk);
  5215. }
  5216. }
  5217. void si_dpm_setup_asic(struct radeon_device *rdev)
  5218. {
  5219. int r;
  5220. r = si_mc_load_microcode(rdev);
  5221. if (r)
  5222. DRM_ERROR("Failed to load MC firmware!\n");
  5223. rv770_get_memory_type(rdev);
  5224. si_read_clock_registers(rdev);
  5225. si_enable_acpi_power_management(rdev);
  5226. }
  5227. static int si_thermal_enable_alert(struct radeon_device *rdev,
  5228. bool enable)
  5229. {
  5230. u32 thermal_int = RREG32(CG_THERMAL_INT);
  5231. if (enable) {
  5232. PPSMC_Result result;
  5233. thermal_int &= ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW);
  5234. WREG32(CG_THERMAL_INT, thermal_int);
  5235. rdev->irq.dpm_thermal = false;
  5236. result = si_send_msg_to_smc(rdev, PPSMC_MSG_EnableThermalInterrupt);
  5237. if (result != PPSMC_Result_OK) {
  5238. DRM_DEBUG_KMS("Could not enable thermal interrupts.\n");
  5239. return -EINVAL;
  5240. }
  5241. } else {
  5242. thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW;
  5243. WREG32(CG_THERMAL_INT, thermal_int);
  5244. rdev->irq.dpm_thermal = true;
  5245. }
  5246. return 0;
  5247. }
  5248. static int si_thermal_set_temperature_range(struct radeon_device *rdev,
  5249. int min_temp, int max_temp)
  5250. {
  5251. int low_temp = 0 * 1000;
  5252. int high_temp = 255 * 1000;
  5253. if (low_temp < min_temp)
  5254. low_temp = min_temp;
  5255. if (high_temp > max_temp)
  5256. high_temp = max_temp;
  5257. if (high_temp < low_temp) {
  5258. DRM_ERROR("invalid thermal range: %d - %d\n", low_temp, high_temp);
  5259. return -EINVAL;
  5260. }
  5261. WREG32_P(CG_THERMAL_INT, DIG_THERM_INTH(high_temp / 1000), ~DIG_THERM_INTH_MASK);
  5262. WREG32_P(CG_THERMAL_INT, DIG_THERM_INTL(low_temp / 1000), ~DIG_THERM_INTL_MASK);
  5263. WREG32_P(CG_THERMAL_CTRL, DIG_THERM_DPM(high_temp / 1000), ~DIG_THERM_DPM_MASK);
  5264. rdev->pm.dpm.thermal.min_temp = low_temp;
  5265. rdev->pm.dpm.thermal.max_temp = high_temp;
  5266. return 0;
  5267. }
  5268. static void si_fan_ctrl_set_static_mode(struct radeon_device *rdev, u32 mode)
  5269. {
  5270. struct si_power_info *si_pi = si_get_pi(rdev);
  5271. u32 tmp;
  5272. if (si_pi->fan_ctrl_is_in_default_mode) {
  5273. tmp = (RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK) >> FDO_PWM_MODE_SHIFT;
  5274. si_pi->fan_ctrl_default_mode = tmp;
  5275. tmp = (RREG32(CG_FDO_CTRL2) & TMIN_MASK) >> TMIN_SHIFT;
  5276. si_pi->t_min = tmp;
  5277. si_pi->fan_ctrl_is_in_default_mode = false;
  5278. }
  5279. tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
  5280. tmp |= TMIN(0);
  5281. WREG32(CG_FDO_CTRL2, tmp);
  5282. tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
  5283. tmp |= FDO_PWM_MODE(mode);
  5284. WREG32(CG_FDO_CTRL2, tmp);
  5285. }
  5286. static int si_thermal_setup_fan_table(struct radeon_device *rdev)
  5287. {
  5288. struct si_power_info *si_pi = si_get_pi(rdev);
  5289. PP_SIslands_FanTable fan_table = { FDO_MODE_HARDWARE };
  5290. u32 duty100;
  5291. u32 t_diff1, t_diff2, pwm_diff1, pwm_diff2;
  5292. u16 fdo_min, slope1, slope2;
  5293. u32 reference_clock, tmp;
  5294. int ret;
  5295. u64 tmp64;
  5296. if (!si_pi->fan_table_start) {
  5297. rdev->pm.dpm.fan.ucode_fan_control = false;
  5298. return 0;
  5299. }
  5300. duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
  5301. if (duty100 == 0) {
  5302. rdev->pm.dpm.fan.ucode_fan_control = false;
  5303. return 0;
  5304. }
  5305. tmp64 = (u64)rdev->pm.dpm.fan.pwm_min * duty100;
  5306. do_div(tmp64, 10000);
  5307. fdo_min = (u16)tmp64;
  5308. t_diff1 = rdev->pm.dpm.fan.t_med - rdev->pm.dpm.fan.t_min;
  5309. t_diff2 = rdev->pm.dpm.fan.t_high - rdev->pm.dpm.fan.t_med;
  5310. pwm_diff1 = rdev->pm.dpm.fan.pwm_med - rdev->pm.dpm.fan.pwm_min;
  5311. pwm_diff2 = rdev->pm.dpm.fan.pwm_high - rdev->pm.dpm.fan.pwm_med;
  5312. slope1 = (u16)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
  5313. slope2 = (u16)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
  5314. fan_table.temp_min = cpu_to_be16((50 + rdev->pm.dpm.fan.t_min) / 100);
  5315. fan_table.temp_med = cpu_to_be16((50 + rdev->pm.dpm.fan.t_med) / 100);
  5316. fan_table.temp_max = cpu_to_be16((50 + rdev->pm.dpm.fan.t_max) / 100);
  5317. fan_table.slope1 = cpu_to_be16(slope1);
  5318. fan_table.slope2 = cpu_to_be16(slope2);
  5319. fan_table.fdo_min = cpu_to_be16(fdo_min);
  5320. fan_table.hys_down = cpu_to_be16(rdev->pm.dpm.fan.t_hyst);
  5321. fan_table.hys_up = cpu_to_be16(1);
  5322. fan_table.hys_slope = cpu_to_be16(1);
  5323. fan_table.temp_resp_lim = cpu_to_be16(5);
  5324. reference_clock = radeon_get_xclk(rdev);
  5325. fan_table.refresh_period = cpu_to_be32((rdev->pm.dpm.fan.cycle_delay *
  5326. reference_clock) / 1600);
  5327. fan_table.fdo_max = cpu_to_be16((u16)duty100);
  5328. tmp = (RREG32(CG_MULT_THERMAL_CTRL) & TEMP_SEL_MASK) >> TEMP_SEL_SHIFT;
  5329. fan_table.temp_src = (uint8_t)tmp;
  5330. ret = si_copy_bytes_to_smc(rdev,
  5331. si_pi->fan_table_start,
  5332. (u8 *)(&fan_table),
  5333. sizeof(fan_table),
  5334. si_pi->sram_end);
  5335. if (ret) {
  5336. DRM_ERROR("Failed to load fan table to the SMC.");
  5337. rdev->pm.dpm.fan.ucode_fan_control = false;
  5338. }
  5339. return 0;
  5340. }
  5341. static int si_fan_ctrl_start_smc_fan_control(struct radeon_device *rdev)
  5342. {
  5343. struct si_power_info *si_pi = si_get_pi(rdev);
  5344. PPSMC_Result ret;
  5345. ret = si_send_msg_to_smc(rdev, PPSMC_StartFanControl);
  5346. if (ret == PPSMC_Result_OK) {
  5347. si_pi->fan_is_controlled_by_smc = true;
  5348. return 0;
  5349. } else {
  5350. return -EINVAL;
  5351. }
  5352. }
  5353. static int si_fan_ctrl_stop_smc_fan_control(struct radeon_device *rdev)
  5354. {
  5355. struct si_power_info *si_pi = si_get_pi(rdev);
  5356. PPSMC_Result ret;
  5357. ret = si_send_msg_to_smc(rdev, PPSMC_StopFanControl);
  5358. if (ret == PPSMC_Result_OK) {
  5359. si_pi->fan_is_controlled_by_smc = false;
  5360. return 0;
  5361. } else {
  5362. return -EINVAL;
  5363. }
  5364. }
  5365. int si_fan_ctrl_get_fan_speed_percent(struct radeon_device *rdev,
  5366. u32 *speed)
  5367. {
  5368. u32 duty, duty100;
  5369. u64 tmp64;
  5370. if (rdev->pm.no_fan)
  5371. return -ENOENT;
  5372. duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
  5373. duty = (RREG32(CG_THERMAL_STATUS) & FDO_PWM_DUTY_MASK) >> FDO_PWM_DUTY_SHIFT;
  5374. if (duty100 == 0)
  5375. return -EINVAL;
  5376. tmp64 = (u64)duty * 100;
  5377. do_div(tmp64, duty100);
  5378. *speed = (u32)tmp64;
  5379. if (*speed > 100)
  5380. *speed = 100;
  5381. return 0;
  5382. }
  5383. int si_fan_ctrl_set_fan_speed_percent(struct radeon_device *rdev,
  5384. u32 speed)
  5385. {
  5386. struct si_power_info *si_pi = si_get_pi(rdev);
  5387. u32 tmp;
  5388. u32 duty, duty100;
  5389. u64 tmp64;
  5390. if (rdev->pm.no_fan)
  5391. return -ENOENT;
  5392. if (si_pi->fan_is_controlled_by_smc)
  5393. return -EINVAL;
  5394. if (speed > 100)
  5395. return -EINVAL;
  5396. duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
  5397. if (duty100 == 0)
  5398. return -EINVAL;
  5399. tmp64 = (u64)speed * duty100;
  5400. do_div(tmp64, 100);
  5401. duty = (u32)tmp64;
  5402. tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK;
  5403. tmp |= FDO_STATIC_DUTY(duty);
  5404. WREG32(CG_FDO_CTRL0, tmp);
  5405. return 0;
  5406. }
  5407. void si_fan_ctrl_set_mode(struct radeon_device *rdev, u32 mode)
  5408. {
  5409. if (mode) {
  5410. /* stop auto-manage */
  5411. if (rdev->pm.dpm.fan.ucode_fan_control)
  5412. si_fan_ctrl_stop_smc_fan_control(rdev);
  5413. si_fan_ctrl_set_static_mode(rdev, mode);
  5414. } else {
  5415. /* restart auto-manage */
  5416. if (rdev->pm.dpm.fan.ucode_fan_control)
  5417. si_thermal_start_smc_fan_control(rdev);
  5418. else
  5419. si_fan_ctrl_set_default_mode(rdev);
  5420. }
  5421. }
  5422. u32 si_fan_ctrl_get_mode(struct radeon_device *rdev)
  5423. {
  5424. struct si_power_info *si_pi = si_get_pi(rdev);
  5425. u32 tmp;
  5426. if (si_pi->fan_is_controlled_by_smc)
  5427. return 0;
  5428. tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;
  5429. return (tmp >> FDO_PWM_MODE_SHIFT);
  5430. }
  5431. #if 0
  5432. static int si_fan_ctrl_get_fan_speed_rpm(struct radeon_device *rdev,
  5433. u32 *speed)
  5434. {
  5435. u32 tach_period;
  5436. u32 xclk = radeon_get_xclk(rdev);
  5437. if (rdev->pm.no_fan)
  5438. return -ENOENT;
  5439. if (rdev->pm.fan_pulses_per_revolution == 0)
  5440. return -ENOENT;
  5441. tach_period = (RREG32(CG_TACH_STATUS) & TACH_PERIOD_MASK) >> TACH_PERIOD_SHIFT;
  5442. if (tach_period == 0)
  5443. return -ENOENT;
  5444. *speed = 60 * xclk * 10000 / tach_period;
  5445. return 0;
  5446. }
  5447. static int si_fan_ctrl_set_fan_speed_rpm(struct radeon_device *rdev,
  5448. u32 speed)
  5449. {
  5450. u32 tach_period, tmp;
  5451. u32 xclk = radeon_get_xclk(rdev);
  5452. if (rdev->pm.no_fan)
  5453. return -ENOENT;
  5454. if (rdev->pm.fan_pulses_per_revolution == 0)
  5455. return -ENOENT;
  5456. if ((speed < rdev->pm.fan_min_rpm) ||
  5457. (speed > rdev->pm.fan_max_rpm))
  5458. return -EINVAL;
  5459. if (rdev->pm.dpm.fan.ucode_fan_control)
  5460. si_fan_ctrl_stop_smc_fan_control(rdev);
  5461. tach_period = 60 * xclk * 10000 / (8 * speed);
  5462. tmp = RREG32(CG_TACH_CTRL) & ~TARGET_PERIOD_MASK;
  5463. tmp |= TARGET_PERIOD(tach_period);
  5464. WREG32(CG_TACH_CTRL, tmp);
  5465. si_fan_ctrl_set_static_mode(rdev, FDO_PWM_MODE_STATIC_RPM);
  5466. return 0;
  5467. }
  5468. #endif
  5469. static void si_fan_ctrl_set_default_mode(struct radeon_device *rdev)
  5470. {
  5471. struct si_power_info *si_pi = si_get_pi(rdev);
  5472. u32 tmp;
  5473. if (!si_pi->fan_ctrl_is_in_default_mode) {
  5474. tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
  5475. tmp |= FDO_PWM_MODE(si_pi->fan_ctrl_default_mode);
  5476. WREG32(CG_FDO_CTRL2, tmp);
  5477. tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
  5478. tmp |= TMIN(si_pi->t_min);
  5479. WREG32(CG_FDO_CTRL2, tmp);
  5480. si_pi->fan_ctrl_is_in_default_mode = true;
  5481. }
  5482. }
  5483. static void si_thermal_start_smc_fan_control(struct radeon_device *rdev)
  5484. {
  5485. if (rdev->pm.dpm.fan.ucode_fan_control) {
  5486. si_fan_ctrl_start_smc_fan_control(rdev);
  5487. si_fan_ctrl_set_static_mode(rdev, FDO_PWM_MODE_STATIC);
  5488. }
  5489. }
  5490. static void si_thermal_initialize(struct radeon_device *rdev)
  5491. {
  5492. u32 tmp;
  5493. if (rdev->pm.fan_pulses_per_revolution) {
  5494. tmp = RREG32(CG_TACH_CTRL) & ~EDGE_PER_REV_MASK;
  5495. tmp |= EDGE_PER_REV(rdev->pm.fan_pulses_per_revolution -1);
  5496. WREG32(CG_TACH_CTRL, tmp);
  5497. }
  5498. tmp = RREG32(CG_FDO_CTRL2) & ~TACH_PWM_RESP_RATE_MASK;
  5499. tmp |= TACH_PWM_RESP_RATE(0x28);
  5500. WREG32(CG_FDO_CTRL2, tmp);
  5501. }
  5502. static int si_thermal_start_thermal_controller(struct radeon_device *rdev)
  5503. {
  5504. int ret;
  5505. si_thermal_initialize(rdev);
  5506. ret = si_thermal_set_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
  5507. if (ret)
  5508. return ret;
  5509. ret = si_thermal_enable_alert(rdev, true);
  5510. if (ret)
  5511. return ret;
  5512. if (rdev->pm.dpm.fan.ucode_fan_control) {
  5513. ret = si_halt_smc(rdev);
  5514. if (ret)
  5515. return ret;
  5516. ret = si_thermal_setup_fan_table(rdev);
  5517. if (ret)
  5518. return ret;
  5519. ret = si_resume_smc(rdev);
  5520. if (ret)
  5521. return ret;
  5522. si_thermal_start_smc_fan_control(rdev);
  5523. }
  5524. return 0;
  5525. }
  5526. static void si_thermal_stop_thermal_controller(struct radeon_device *rdev)
  5527. {
  5528. if (!rdev->pm.no_fan) {
  5529. si_fan_ctrl_set_default_mode(rdev);
  5530. si_fan_ctrl_stop_smc_fan_control(rdev);
  5531. }
  5532. }
  5533. int si_dpm_enable(struct radeon_device *rdev)
  5534. {
  5535. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  5536. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5537. struct si_power_info *si_pi = si_get_pi(rdev);
  5538. struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
  5539. int ret;
  5540. if (si_is_smc_running(rdev))
  5541. return -EINVAL;
  5542. if (pi->voltage_control || si_pi->voltage_control_svi2)
  5543. si_enable_voltage_control(rdev, true);
  5544. if (pi->mvdd_control)
  5545. si_get_mvdd_configuration(rdev);
  5546. if (pi->voltage_control || si_pi->voltage_control_svi2) {
  5547. ret = si_construct_voltage_tables(rdev);
  5548. if (ret) {
  5549. DRM_ERROR("si_construct_voltage_tables failed\n");
  5550. return ret;
  5551. }
  5552. }
  5553. if (eg_pi->dynamic_ac_timing) {
  5554. ret = si_initialize_mc_reg_table(rdev);
  5555. if (ret)
  5556. eg_pi->dynamic_ac_timing = false;
  5557. }
  5558. if (pi->dynamic_ss)
  5559. si_enable_spread_spectrum(rdev, true);
  5560. if (pi->thermal_protection)
  5561. si_enable_thermal_protection(rdev, true);
  5562. si_setup_bsp(rdev);
  5563. si_program_git(rdev);
  5564. si_program_tp(rdev);
  5565. si_program_tpp(rdev);
  5566. si_program_sstp(rdev);
  5567. si_enable_display_gap(rdev);
  5568. si_program_vc(rdev);
  5569. ret = si_upload_firmware(rdev);
  5570. if (ret) {
  5571. DRM_ERROR("si_upload_firmware failed\n");
  5572. return ret;
  5573. }
  5574. ret = si_process_firmware_header(rdev);
  5575. if (ret) {
  5576. DRM_ERROR("si_process_firmware_header failed\n");
  5577. return ret;
  5578. }
  5579. ret = si_initial_switch_from_arb_f0_to_f1(rdev);
  5580. if (ret) {
  5581. DRM_ERROR("si_initial_switch_from_arb_f0_to_f1 failed\n");
  5582. return ret;
  5583. }
  5584. ret = si_init_smc_table(rdev);
  5585. if (ret) {
  5586. DRM_ERROR("si_init_smc_table failed\n");
  5587. return ret;
  5588. }
  5589. ret = si_init_smc_spll_table(rdev);
  5590. if (ret) {
  5591. DRM_ERROR("si_init_smc_spll_table failed\n");
  5592. return ret;
  5593. }
  5594. ret = si_init_arb_table_index(rdev);
  5595. if (ret) {
  5596. DRM_ERROR("si_init_arb_table_index failed\n");
  5597. return ret;
  5598. }
  5599. if (eg_pi->dynamic_ac_timing) {
  5600. ret = si_populate_mc_reg_table(rdev, boot_ps);
  5601. if (ret) {
  5602. DRM_ERROR("si_populate_mc_reg_table failed\n");
  5603. return ret;
  5604. }
  5605. }
  5606. ret = si_initialize_smc_cac_tables(rdev);
  5607. if (ret) {
  5608. DRM_ERROR("si_initialize_smc_cac_tables failed\n");
  5609. return ret;
  5610. }
  5611. ret = si_initialize_hardware_cac_manager(rdev);
  5612. if (ret) {
  5613. DRM_ERROR("si_initialize_hardware_cac_manager failed\n");
  5614. return ret;
  5615. }
  5616. ret = si_initialize_smc_dte_tables(rdev);
  5617. if (ret) {
  5618. DRM_ERROR("si_initialize_smc_dte_tables failed\n");
  5619. return ret;
  5620. }
  5621. ret = si_populate_smc_tdp_limits(rdev, boot_ps);
  5622. if (ret) {
  5623. DRM_ERROR("si_populate_smc_tdp_limits failed\n");
  5624. return ret;
  5625. }
  5626. ret = si_populate_smc_tdp_limits_2(rdev, boot_ps);
  5627. if (ret) {
  5628. DRM_ERROR("si_populate_smc_tdp_limits_2 failed\n");
  5629. return ret;
  5630. }
  5631. si_program_response_times(rdev);
  5632. si_program_ds_registers(rdev);
  5633. si_dpm_start_smc(rdev);
  5634. ret = si_notify_smc_display_change(rdev, false);
  5635. if (ret) {
  5636. DRM_ERROR("si_notify_smc_display_change failed\n");
  5637. return ret;
  5638. }
  5639. si_enable_sclk_control(rdev, true);
  5640. si_start_dpm(rdev);
  5641. si_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
  5642. si_thermal_start_thermal_controller(rdev);
  5643. ni_update_current_ps(rdev, boot_ps);
  5644. return 0;
  5645. }
  5646. static int si_set_temperature_range(struct radeon_device *rdev)
  5647. {
  5648. int ret;
  5649. ret = si_thermal_enable_alert(rdev, false);
  5650. if (ret)
  5651. return ret;
  5652. ret = si_thermal_set_temperature_range(rdev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
  5653. if (ret)
  5654. return ret;
  5655. ret = si_thermal_enable_alert(rdev, true);
  5656. if (ret)
  5657. return ret;
  5658. return ret;
  5659. }
  5660. int si_dpm_late_enable(struct radeon_device *rdev)
  5661. {
  5662. int ret;
  5663. ret = si_set_temperature_range(rdev);
  5664. if (ret)
  5665. return ret;
  5666. return ret;
  5667. }
  5668. void si_dpm_disable(struct radeon_device *rdev)
  5669. {
  5670. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  5671. struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
  5672. if (!si_is_smc_running(rdev))
  5673. return;
  5674. si_thermal_stop_thermal_controller(rdev);
  5675. si_disable_ulv(rdev);
  5676. si_clear_vc(rdev);
  5677. if (pi->thermal_protection)
  5678. si_enable_thermal_protection(rdev, false);
  5679. si_enable_power_containment(rdev, boot_ps, false);
  5680. si_enable_smc_cac(rdev, boot_ps, false);
  5681. si_enable_spread_spectrum(rdev, false);
  5682. si_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, false);
  5683. si_stop_dpm(rdev);
  5684. si_reset_to_default(rdev);
  5685. si_dpm_stop_smc(rdev);
  5686. si_force_switch_to_arb_f0(rdev);
  5687. ni_update_current_ps(rdev, boot_ps);
  5688. }
  5689. int si_dpm_pre_set_power_state(struct radeon_device *rdev)
  5690. {
  5691. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5692. struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
  5693. struct radeon_ps *new_ps = &requested_ps;
  5694. ni_update_requested_ps(rdev, new_ps);
  5695. si_apply_state_adjust_rules(rdev, &eg_pi->requested_rps);
  5696. return 0;
  5697. }
  5698. static int si_power_control_set_level(struct radeon_device *rdev)
  5699. {
  5700. struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
  5701. int ret;
  5702. ret = si_restrict_performance_levels_before_switch(rdev);
  5703. if (ret)
  5704. return ret;
  5705. ret = si_halt_smc(rdev);
  5706. if (ret)
  5707. return ret;
  5708. ret = si_populate_smc_tdp_limits(rdev, new_ps);
  5709. if (ret)
  5710. return ret;
  5711. ret = si_populate_smc_tdp_limits_2(rdev, new_ps);
  5712. if (ret)
  5713. return ret;
  5714. ret = si_resume_smc(rdev);
  5715. if (ret)
  5716. return ret;
  5717. ret = si_set_sw_state(rdev);
  5718. if (ret)
  5719. return ret;
  5720. return 0;
  5721. }
  5722. int si_dpm_set_power_state(struct radeon_device *rdev)
  5723. {
  5724. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5725. struct radeon_ps *new_ps = &eg_pi->requested_rps;
  5726. struct radeon_ps *old_ps = &eg_pi->current_rps;
  5727. int ret;
  5728. ret = si_disable_ulv(rdev);
  5729. if (ret) {
  5730. DRM_ERROR("si_disable_ulv failed\n");
  5731. return ret;
  5732. }
  5733. ret = si_restrict_performance_levels_before_switch(rdev);
  5734. if (ret) {
  5735. DRM_ERROR("si_restrict_performance_levels_before_switch failed\n");
  5736. return ret;
  5737. }
  5738. if (eg_pi->pcie_performance_request)
  5739. si_request_link_speed_change_before_state_change(rdev, new_ps, old_ps);
  5740. ni_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
  5741. ret = si_enable_power_containment(rdev, new_ps, false);
  5742. if (ret) {
  5743. DRM_ERROR("si_enable_power_containment failed\n");
  5744. return ret;
  5745. }
  5746. ret = si_enable_smc_cac(rdev, new_ps, false);
  5747. if (ret) {
  5748. DRM_ERROR("si_enable_smc_cac failed\n");
  5749. return ret;
  5750. }
  5751. ret = si_halt_smc(rdev);
  5752. if (ret) {
  5753. DRM_ERROR("si_halt_smc failed\n");
  5754. return ret;
  5755. }
  5756. ret = si_upload_sw_state(rdev, new_ps);
  5757. if (ret) {
  5758. DRM_ERROR("si_upload_sw_state failed\n");
  5759. return ret;
  5760. }
  5761. ret = si_upload_smc_data(rdev);
  5762. if (ret) {
  5763. DRM_ERROR("si_upload_smc_data failed\n");
  5764. return ret;
  5765. }
  5766. ret = si_upload_ulv_state(rdev);
  5767. if (ret) {
  5768. DRM_ERROR("si_upload_ulv_state failed\n");
  5769. return ret;
  5770. }
  5771. if (eg_pi->dynamic_ac_timing) {
  5772. ret = si_upload_mc_reg_table(rdev, new_ps);
  5773. if (ret) {
  5774. DRM_ERROR("si_upload_mc_reg_table failed\n");
  5775. return ret;
  5776. }
  5777. }
  5778. ret = si_program_memory_timing_parameters(rdev, new_ps);
  5779. if (ret) {
  5780. DRM_ERROR("si_program_memory_timing_parameters failed\n");
  5781. return ret;
  5782. }
  5783. si_set_pcie_lane_width_in_smc(rdev, new_ps, old_ps);
  5784. ret = si_resume_smc(rdev);
  5785. if (ret) {
  5786. DRM_ERROR("si_resume_smc failed\n");
  5787. return ret;
  5788. }
  5789. ret = si_set_sw_state(rdev);
  5790. if (ret) {
  5791. DRM_ERROR("si_set_sw_state failed\n");
  5792. return ret;
  5793. }
  5794. ni_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
  5795. si_set_vce_clock(rdev, new_ps, old_ps);
  5796. if (eg_pi->pcie_performance_request)
  5797. si_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
  5798. ret = si_set_power_state_conditionally_enable_ulv(rdev, new_ps);
  5799. if (ret) {
  5800. DRM_ERROR("si_set_power_state_conditionally_enable_ulv failed\n");
  5801. return ret;
  5802. }
  5803. ret = si_enable_smc_cac(rdev, new_ps, true);
  5804. if (ret) {
  5805. DRM_ERROR("si_enable_smc_cac failed\n");
  5806. return ret;
  5807. }
  5808. ret = si_enable_power_containment(rdev, new_ps, true);
  5809. if (ret) {
  5810. DRM_ERROR("si_enable_power_containment failed\n");
  5811. return ret;
  5812. }
  5813. ret = si_power_control_set_level(rdev);
  5814. if (ret) {
  5815. DRM_ERROR("si_power_control_set_level failed\n");
  5816. return ret;
  5817. }
  5818. return 0;
  5819. }
  5820. void si_dpm_post_set_power_state(struct radeon_device *rdev)
  5821. {
  5822. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5823. struct radeon_ps *new_ps = &eg_pi->requested_rps;
  5824. ni_update_current_ps(rdev, new_ps);
  5825. }
  5826. #if 0
  5827. void si_dpm_reset_asic(struct radeon_device *rdev)
  5828. {
  5829. si_restrict_performance_levels_before_switch(rdev);
  5830. si_disable_ulv(rdev);
  5831. si_set_boot_state(rdev);
  5832. }
  5833. #endif
  5834. void si_dpm_display_configuration_changed(struct radeon_device *rdev)
  5835. {
  5836. si_program_display_gap(rdev);
  5837. }
  5838. union power_info {
  5839. struct _ATOM_POWERPLAY_INFO info;
  5840. struct _ATOM_POWERPLAY_INFO_V2 info_2;
  5841. struct _ATOM_POWERPLAY_INFO_V3 info_3;
  5842. struct _ATOM_PPLIB_POWERPLAYTABLE pplib;
  5843. struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2;
  5844. struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3;
  5845. };
  5846. union pplib_clock_info {
  5847. struct _ATOM_PPLIB_R600_CLOCK_INFO r600;
  5848. struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780;
  5849. struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen;
  5850. struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo;
  5851. struct _ATOM_PPLIB_SI_CLOCK_INFO si;
  5852. };
  5853. union pplib_power_state {
  5854. struct _ATOM_PPLIB_STATE v1;
  5855. struct _ATOM_PPLIB_STATE_V2 v2;
  5856. };
  5857. static void si_parse_pplib_non_clock_info(struct radeon_device *rdev,
  5858. struct radeon_ps *rps,
  5859. struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info,
  5860. u8 table_rev)
  5861. {
  5862. rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings);
  5863. rps->class = le16_to_cpu(non_clock_info->usClassification);
  5864. rps->class2 = le16_to_cpu(non_clock_info->usClassification2);
  5865. if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
  5866. rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
  5867. rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
  5868. } else if (r600_is_uvd_state(rps->class, rps->class2)) {
  5869. rps->vclk = RV770_DEFAULT_VCLK_FREQ;
  5870. rps->dclk = RV770_DEFAULT_DCLK_FREQ;
  5871. } else {
  5872. rps->vclk = 0;
  5873. rps->dclk = 0;
  5874. }
  5875. if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
  5876. rdev->pm.dpm.boot_ps = rps;
  5877. if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
  5878. rdev->pm.dpm.uvd_ps = rps;
  5879. }
  5880. static void si_parse_pplib_clock_info(struct radeon_device *rdev,
  5881. struct radeon_ps *rps, int index,
  5882. union pplib_clock_info *clock_info)
  5883. {
  5884. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  5885. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  5886. struct si_power_info *si_pi = si_get_pi(rdev);
  5887. struct ni_ps *ps = ni_get_ps(rps);
  5888. u16 leakage_voltage;
  5889. struct rv7xx_pl *pl = &ps->performance_levels[index];
  5890. int ret;
  5891. ps->performance_level_count = index + 1;
  5892. pl->sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
  5893. pl->sclk |= clock_info->si.ucEngineClockHigh << 16;
  5894. pl->mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
  5895. pl->mclk |= clock_info->si.ucMemoryClockHigh << 16;
  5896. pl->vddc = le16_to_cpu(clock_info->si.usVDDC);
  5897. pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);
  5898. pl->flags = le32_to_cpu(clock_info->si.ulFlags);
  5899. pl->pcie_gen = r600_get_pcie_gen_support(rdev,
  5900. si_pi->sys_pcie_mask,
  5901. si_pi->boot_pcie_gen,
  5902. clock_info->si.ucPCIEGen);
  5903. /* patch up vddc if necessary */
  5904. ret = si_get_leakage_voltage_from_leakage_index(rdev, pl->vddc,
  5905. &leakage_voltage);
  5906. if (ret == 0)
  5907. pl->vddc = leakage_voltage;
  5908. if (rps->class & ATOM_PPLIB_CLASSIFICATION_ACPI) {
  5909. pi->acpi_vddc = pl->vddc;
  5910. eg_pi->acpi_vddci = pl->vddci;
  5911. si_pi->acpi_pcie_gen = pl->pcie_gen;
  5912. }
  5913. if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
  5914. index == 0) {
  5915. /* XXX disable for A0 tahiti */
  5916. si_pi->ulv.supported = false;
  5917. si_pi->ulv.pl = *pl;
  5918. si_pi->ulv.one_pcie_lane_in_ulv = false;
  5919. si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
  5920. si_pi->ulv.cg_ulv_parameter = SISLANDS_CGULVPARAMETER_DFLT;
  5921. si_pi->ulv.cg_ulv_control = SISLANDS_CGULVCONTROL_DFLT;
  5922. }
  5923. if (pi->min_vddc_in_table > pl->vddc)
  5924. pi->min_vddc_in_table = pl->vddc;
  5925. if (pi->max_vddc_in_table < pl->vddc)
  5926. pi->max_vddc_in_table = pl->vddc;
  5927. /* patch up boot state */
  5928. if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) {
  5929. u16 vddc, vddci, mvdd;
  5930. radeon_atombios_get_default_voltages(rdev, &vddc, &vddci, &mvdd);
  5931. pl->mclk = rdev->clock.default_mclk;
  5932. pl->sclk = rdev->clock.default_sclk;
  5933. pl->vddc = vddc;
  5934. pl->vddci = vddci;
  5935. si_pi->mvdd_bootup_value = mvdd;
  5936. }
  5937. if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) ==
  5938. ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) {
  5939. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk = pl->sclk;
  5940. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.mclk = pl->mclk;
  5941. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddc = pl->vddc;
  5942. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddci = pl->vddci;
  5943. }
  5944. }
  5945. static int si_parse_power_table(struct radeon_device *rdev)
  5946. {
  5947. struct radeon_mode_info *mode_info = &rdev->mode_info;
  5948. struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info;
  5949. union pplib_power_state *power_state;
  5950. int i, j, k, non_clock_array_index, clock_array_index;
  5951. union pplib_clock_info *clock_info;
  5952. struct _StateArray *state_array;
  5953. struct _ClockInfoArray *clock_info_array;
  5954. struct _NonClockInfoArray *non_clock_info_array;
  5955. union power_info *power_info;
  5956. int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
  5957. u16 data_offset;
  5958. u8 frev, crev;
  5959. u8 *power_state_offset;
  5960. struct ni_ps *ps;
  5961. if (!atom_parse_data_header(mode_info->atom_context, index, NULL,
  5962. &frev, &crev, &data_offset))
  5963. return -EINVAL;
  5964. power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
  5965. state_array = (struct _StateArray *)
  5966. (mode_info->atom_context->bios + data_offset +
  5967. le16_to_cpu(power_info->pplib.usStateArrayOffset));
  5968. clock_info_array = (struct _ClockInfoArray *)
  5969. (mode_info->atom_context->bios + data_offset +
  5970. le16_to_cpu(power_info->pplib.usClockInfoArrayOffset));
  5971. non_clock_info_array = (struct _NonClockInfoArray *)
  5972. (mode_info->atom_context->bios + data_offset +
  5973. le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
  5974. rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
  5975. state_array->ucNumEntries, GFP_KERNEL);
  5976. if (!rdev->pm.dpm.ps)
  5977. return -ENOMEM;
  5978. power_state_offset = (u8 *)state_array->states;
  5979. for (i = 0; i < state_array->ucNumEntries; i++) {
  5980. u8 *idx;
  5981. power_state = (union pplib_power_state *)power_state_offset;
  5982. non_clock_array_index = power_state->v2.nonClockInfoIndex;
  5983. non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
  5984. &non_clock_info_array->nonClockInfo[non_clock_array_index];
  5985. if (!rdev->pm.power_state[i].clock_info)
  5986. return -EINVAL;
  5987. ps = kzalloc(sizeof(struct ni_ps), GFP_KERNEL);
  5988. if (ps == NULL) {
  5989. kfree(rdev->pm.dpm.ps);
  5990. return -ENOMEM;
  5991. }
  5992. rdev->pm.dpm.ps[i].ps_priv = ps;
  5993. si_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i],
  5994. non_clock_info,
  5995. non_clock_info_array->ucEntrySize);
  5996. k = 0;
  5997. idx = (u8 *)&power_state->v2.clockInfoIndex[0];
  5998. for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
  5999. clock_array_index = idx[j];
  6000. if (clock_array_index >= clock_info_array->ucNumEntries)
  6001. continue;
  6002. if (k >= SISLANDS_MAX_HARDWARE_POWERLEVELS)
  6003. break;
  6004. clock_info = (union pplib_clock_info *)
  6005. ((u8 *)&clock_info_array->clockInfo[0] +
  6006. (clock_array_index * clock_info_array->ucEntrySize));
  6007. si_parse_pplib_clock_info(rdev,
  6008. &rdev->pm.dpm.ps[i], k,
  6009. clock_info);
  6010. k++;
  6011. }
  6012. power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
  6013. }
  6014. rdev->pm.dpm.num_ps = state_array->ucNumEntries;
  6015. /* fill in the vce power states */
  6016. for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) {
  6017. u32 sclk, mclk;
  6018. clock_array_index = rdev->pm.dpm.vce_states[i].clk_idx;
  6019. clock_info = (union pplib_clock_info *)
  6020. &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
  6021. sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
  6022. sclk |= clock_info->si.ucEngineClockHigh << 16;
  6023. mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
  6024. mclk |= clock_info->si.ucMemoryClockHigh << 16;
  6025. rdev->pm.dpm.vce_states[i].sclk = sclk;
  6026. rdev->pm.dpm.vce_states[i].mclk = mclk;
  6027. }
  6028. return 0;
  6029. }
  6030. int si_dpm_init(struct radeon_device *rdev)
  6031. {
  6032. struct rv7xx_power_info *pi;
  6033. struct evergreen_power_info *eg_pi;
  6034. struct ni_power_info *ni_pi;
  6035. struct si_power_info *si_pi;
  6036. struct atom_clock_dividers dividers;
  6037. int ret;
  6038. u32 mask;
  6039. si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);
  6040. if (si_pi == NULL)
  6041. return -ENOMEM;
  6042. rdev->pm.dpm.priv = si_pi;
  6043. ni_pi = &si_pi->ni;
  6044. eg_pi = &ni_pi->eg;
  6045. pi = &eg_pi->rv7xx;
  6046. ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask);
  6047. if (ret)
  6048. si_pi->sys_pcie_mask = 0;
  6049. else
  6050. si_pi->sys_pcie_mask = mask;
  6051. si_pi->force_pcie_gen = RADEON_PCIE_GEN_INVALID;
  6052. si_pi->boot_pcie_gen = si_get_current_pcie_speed(rdev);
  6053. si_set_max_cu_value(rdev);
  6054. rv770_get_max_vddc(rdev);
  6055. si_get_leakage_vddc(rdev);
  6056. si_patch_dependency_tables_based_on_leakage(rdev);
  6057. pi->acpi_vddc = 0;
  6058. eg_pi->acpi_vddci = 0;
  6059. pi->min_vddc_in_table = 0;
  6060. pi->max_vddc_in_table = 0;
  6061. ret = r600_get_platform_caps(rdev);
  6062. if (ret)
  6063. return ret;
  6064. ret = r600_parse_extended_power_table(rdev);
  6065. if (ret)
  6066. return ret;
  6067. ret = si_parse_power_table(rdev);
  6068. if (ret)
  6069. return ret;
  6070. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
  6071. kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
  6072. if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
  6073. r600_free_extended_power_table(rdev);
  6074. return -ENOMEM;
  6075. }
  6076. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
  6077. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
  6078. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
  6079. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
  6080. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 720;
  6081. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
  6082. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 810;
  6083. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
  6084. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900;
  6085. if (rdev->pm.dpm.voltage_response_time == 0)
  6086. rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
  6087. if (rdev->pm.dpm.backbias_response_time == 0)
  6088. rdev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
  6089. ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
  6090. 0, false, &dividers);
  6091. if (ret)
  6092. pi->ref_div = dividers.ref_div + 1;
  6093. else
  6094. pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
  6095. eg_pi->smu_uvd_hs = false;
  6096. pi->mclk_strobe_mode_threshold = 40000;
  6097. if (si_is_special_1gb_platform(rdev))
  6098. pi->mclk_stutter_mode_threshold = 0;
  6099. else
  6100. pi->mclk_stutter_mode_threshold = pi->mclk_strobe_mode_threshold;
  6101. pi->mclk_edc_enable_threshold = 40000;
  6102. eg_pi->mclk_edc_wr_enable_threshold = 40000;
  6103. ni_pi->mclk_rtt_mode_threshold = eg_pi->mclk_edc_wr_enable_threshold;
  6104. pi->voltage_control =
  6105. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
  6106. VOLTAGE_OBJ_GPIO_LUT);
  6107. if (!pi->voltage_control) {
  6108. si_pi->voltage_control_svi2 =
  6109. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
  6110. VOLTAGE_OBJ_SVID2);
  6111. if (si_pi->voltage_control_svi2)
  6112. radeon_atom_get_svi2_info(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
  6113. &si_pi->svd_gpio_id, &si_pi->svc_gpio_id);
  6114. }
  6115. pi->mvdd_control =
  6116. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC,
  6117. VOLTAGE_OBJ_GPIO_LUT);
  6118. eg_pi->vddci_control =
  6119. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
  6120. VOLTAGE_OBJ_GPIO_LUT);
  6121. if (!eg_pi->vddci_control)
  6122. si_pi->vddci_control_svi2 =
  6123. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
  6124. VOLTAGE_OBJ_SVID2);
  6125. si_pi->vddc_phase_shed_control =
  6126. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC,
  6127. VOLTAGE_OBJ_PHASE_LUT);
  6128. rv770_get_engine_memory_ss(rdev);
  6129. pi->asi = RV770_ASI_DFLT;
  6130. pi->pasi = CYPRESS_HASI_DFLT;
  6131. pi->vrc = SISLANDS_VRC_DFLT;
  6132. pi->gfx_clock_gating = true;
  6133. eg_pi->sclk_deep_sleep = true;
  6134. si_pi->sclk_deep_sleep_above_low = false;
  6135. if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
  6136. pi->thermal_protection = true;
  6137. else
  6138. pi->thermal_protection = false;
  6139. eg_pi->dynamic_ac_timing = true;
  6140. eg_pi->light_sleep = true;
  6141. #if defined(CONFIG_ACPI)
  6142. eg_pi->pcie_performance_request =
  6143. radeon_acpi_is_pcie_performance_request_supported(rdev);
  6144. #else
  6145. eg_pi->pcie_performance_request = false;
  6146. #endif
  6147. si_pi->sram_end = SMC_RAM_END;
  6148. rdev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
  6149. rdev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
  6150. rdev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
  6151. rdev->pm.dpm.dyn_state.valid_sclk_values.count = 0;
  6152. rdev->pm.dpm.dyn_state.valid_sclk_values.values = NULL;
  6153. rdev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
  6154. rdev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
  6155. si_initialize_powertune_defaults(rdev);
  6156. /* make sure dc limits are valid */
  6157. if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
  6158. (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
  6159. rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
  6160. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
  6161. si_pi->fan_ctrl_is_in_default_mode = true;
  6162. return 0;
  6163. }
  6164. void si_dpm_fini(struct radeon_device *rdev)
  6165. {
  6166. int i;
  6167. for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
  6168. kfree(rdev->pm.dpm.ps[i].ps_priv);
  6169. }
  6170. kfree(rdev->pm.dpm.ps);
  6171. kfree(rdev->pm.dpm.priv);
  6172. kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
  6173. r600_free_extended_power_table(rdev);
  6174. }
  6175. void si_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
  6176. struct seq_file *m)
  6177. {
  6178. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  6179. struct radeon_ps *rps = &eg_pi->current_rps;
  6180. struct ni_ps *ps = ni_get_ps(rps);
  6181. struct rv7xx_pl *pl;
  6182. u32 current_index =
  6183. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
  6184. CURRENT_STATE_INDEX_SHIFT;
  6185. if (current_index >= ps->performance_level_count) {
  6186. seq_printf(m, "invalid dpm profile %d\n", current_index);
  6187. } else {
  6188. pl = &ps->performance_levels[current_index];
  6189. seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
  6190. seq_printf(m, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
  6191. current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
  6192. }
  6193. }
  6194. u32 si_dpm_get_current_sclk(struct radeon_device *rdev)
  6195. {
  6196. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  6197. struct radeon_ps *rps = &eg_pi->current_rps;
  6198. struct ni_ps *ps = ni_get_ps(rps);
  6199. struct rv7xx_pl *pl;
  6200. u32 current_index =
  6201. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
  6202. CURRENT_STATE_INDEX_SHIFT;
  6203. if (current_index >= ps->performance_level_count) {
  6204. return 0;
  6205. } else {
  6206. pl = &ps->performance_levels[current_index];
  6207. return pl->sclk;
  6208. }
  6209. }
  6210. u32 si_dpm_get_current_mclk(struct radeon_device *rdev)
  6211. {
  6212. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  6213. struct radeon_ps *rps = &eg_pi->current_rps;
  6214. struct ni_ps *ps = ni_get_ps(rps);
  6215. struct rv7xx_pl *pl;
  6216. u32 current_index =
  6217. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
  6218. CURRENT_STATE_INDEX_SHIFT;
  6219. if (current_index >= ps->performance_level_count) {
  6220. return 0;
  6221. } else {
  6222. pl = &ps->performance_levels[current_index];
  6223. return pl->mclk;
  6224. }
  6225. }