ar9003_eeprom.c 156 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511
  1. /*
  2. * Copyright (c) 2010-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <asm/unaligned.h>
  17. #include "hw.h"
  18. #include "ar9003_phy.h"
  19. #include "ar9003_eeprom.h"
  20. #include "ar9003_mci.h"
  21. #define COMP_HDR_LEN 4
  22. #define COMP_CKSUM_LEN 2
  23. #define LE16(x) cpu_to_le16(x)
  24. #define LE32(x) cpu_to_le32(x)
  25. /* Local defines to distinguish between extension and control CTL's */
  26. #define EXT_ADDITIVE (0x8000)
  27. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  28. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  29. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  30. #define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
  31. #define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
  32. #define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
  33. #define EEPROM_DATA_LEN_9485 1088
  34. static int ar9003_hw_power_interpolate(int32_t x,
  35. int32_t *px, int32_t *py, u_int16_t np);
  36. static const struct ar9300_eeprom ar9300_default = {
  37. .eepromVersion = 2,
  38. .templateVersion = 2,
  39. .macAddr = {0, 2, 3, 4, 5, 6},
  40. .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  41. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  42. .baseEepHeader = {
  43. .regDmn = { LE16(0), LE16(0x1f) },
  44. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  45. .opCapFlags = {
  46. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  47. .eepMisc = 0,
  48. },
  49. .rfSilent = 0,
  50. .blueToothOptions = 0,
  51. .deviceCap = 0,
  52. .deviceType = 5, /* takes lower byte in eeprom location */
  53. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  54. .params_for_tuning_caps = {0, 0},
  55. .featureEnable = 0x0c,
  56. /*
  57. * bit0 - enable tx temp comp - disabled
  58. * bit1 - enable tx volt comp - disabled
  59. * bit2 - enable fastClock - enabled
  60. * bit3 - enable doubling - enabled
  61. * bit4 - enable internal regulator - disabled
  62. * bit5 - enable pa predistortion - disabled
  63. */
  64. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  65. .eepromWriteEnableGpio = 3,
  66. .wlanDisableGpio = 0,
  67. .wlanLedGpio = 8,
  68. .rxBandSelectGpio = 0xff,
  69. .txrxgain = 0,
  70. .swreg = 0,
  71. },
  72. .modalHeader2G = {
  73. /* ar9300_modal_eep_header 2g */
  74. /* 4 idle,t1,t2,b(4 bits per setting) */
  75. .antCtrlCommon = LE32(0x110),
  76. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  77. .antCtrlCommon2 = LE32(0x22222),
  78. /*
  79. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  80. * rx1, rx12, b (2 bits each)
  81. */
  82. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  83. /*
  84. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  85. * for ar9280 (0xa20c/b20c 5:0)
  86. */
  87. .xatten1DB = {0, 0, 0},
  88. /*
  89. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  90. * for ar9280 (0xa20c/b20c 16:12
  91. */
  92. .xatten1Margin = {0, 0, 0},
  93. .tempSlope = 36,
  94. .voltSlope = 0,
  95. /*
  96. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  97. * channels in usual fbin coding format
  98. */
  99. .spurChans = {0, 0, 0, 0, 0},
  100. /*
  101. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  102. * if the register is per chain
  103. */
  104. .noiseFloorThreshCh = {-1, 0, 0},
  105. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  106. .quick_drop = 0,
  107. .xpaBiasLvl = 0,
  108. .txFrameToDataStart = 0x0e,
  109. .txFrameToPaOn = 0x0e,
  110. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  111. .antennaGain = 0,
  112. .switchSettling = 0x2c,
  113. .adcDesiredSize = -30,
  114. .txEndToXpaOff = 0,
  115. .txEndToRxOn = 0x2,
  116. .txFrameToXpaOn = 0xe,
  117. .thresh62 = 28,
  118. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  119. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  120. .switchcomspdt = 0,
  121. .xlna_bias_strength = 0,
  122. .futureModal = {
  123. 0, 0, 0, 0, 0, 0, 0,
  124. },
  125. },
  126. .base_ext1 = {
  127. .ant_div_control = 0,
  128. .future = {0, 0},
  129. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  130. },
  131. .calFreqPier2G = {
  132. FREQ2FBIN(2412, 1),
  133. FREQ2FBIN(2437, 1),
  134. FREQ2FBIN(2472, 1),
  135. },
  136. /* ar9300_cal_data_per_freq_op_loop 2g */
  137. .calPierData2G = {
  138. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  139. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  140. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  141. },
  142. .calTarget_freqbin_Cck = {
  143. FREQ2FBIN(2412, 1),
  144. FREQ2FBIN(2484, 1),
  145. },
  146. .calTarget_freqbin_2G = {
  147. FREQ2FBIN(2412, 1),
  148. FREQ2FBIN(2437, 1),
  149. FREQ2FBIN(2472, 1)
  150. },
  151. .calTarget_freqbin_2GHT20 = {
  152. FREQ2FBIN(2412, 1),
  153. FREQ2FBIN(2437, 1),
  154. FREQ2FBIN(2472, 1)
  155. },
  156. .calTarget_freqbin_2GHT40 = {
  157. FREQ2FBIN(2412, 1),
  158. FREQ2FBIN(2437, 1),
  159. FREQ2FBIN(2472, 1)
  160. },
  161. .calTargetPowerCck = {
  162. /* 1L-5L,5S,11L,11S */
  163. { {36, 36, 36, 36} },
  164. { {36, 36, 36, 36} },
  165. },
  166. .calTargetPower2G = {
  167. /* 6-24,36,48,54 */
  168. { {32, 32, 28, 24} },
  169. { {32, 32, 28, 24} },
  170. { {32, 32, 28, 24} },
  171. },
  172. .calTargetPower2GHT20 = {
  173. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  174. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  175. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  176. },
  177. .calTargetPower2GHT40 = {
  178. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  179. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  180. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  181. },
  182. .ctlIndex_2G = {
  183. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  184. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  185. },
  186. .ctl_freqbin_2G = {
  187. {
  188. FREQ2FBIN(2412, 1),
  189. FREQ2FBIN(2417, 1),
  190. FREQ2FBIN(2457, 1),
  191. FREQ2FBIN(2462, 1)
  192. },
  193. {
  194. FREQ2FBIN(2412, 1),
  195. FREQ2FBIN(2417, 1),
  196. FREQ2FBIN(2462, 1),
  197. 0xFF,
  198. },
  199. {
  200. FREQ2FBIN(2412, 1),
  201. FREQ2FBIN(2417, 1),
  202. FREQ2FBIN(2462, 1),
  203. 0xFF,
  204. },
  205. {
  206. FREQ2FBIN(2422, 1),
  207. FREQ2FBIN(2427, 1),
  208. FREQ2FBIN(2447, 1),
  209. FREQ2FBIN(2452, 1)
  210. },
  211. {
  212. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  213. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  214. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  215. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  216. },
  217. {
  218. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  219. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  220. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  221. 0,
  222. },
  223. {
  224. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  225. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  226. FREQ2FBIN(2472, 1),
  227. 0,
  228. },
  229. {
  230. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  231. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  232. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  233. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  234. },
  235. {
  236. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  237. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  238. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  239. },
  240. {
  241. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  242. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  243. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  244. 0
  245. },
  246. {
  247. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  248. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  249. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  250. 0
  251. },
  252. {
  253. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  254. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  255. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  256. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  257. }
  258. },
  259. .ctlPowerData_2G = {
  260. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  261. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  262. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  263. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  264. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  265. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  266. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  267. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  268. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  269. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  270. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  271. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  272. },
  273. .modalHeader5G = {
  274. /* 4 idle,t1,t2,b (4 bits per setting) */
  275. .antCtrlCommon = LE32(0x110),
  276. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  277. .antCtrlCommon2 = LE32(0x22222),
  278. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  279. .antCtrlChain = {
  280. LE16(0x000), LE16(0x000), LE16(0x000),
  281. },
  282. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  283. .xatten1DB = {0, 0, 0},
  284. /*
  285. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  286. * for merlin (0xa20c/b20c 16:12
  287. */
  288. .xatten1Margin = {0, 0, 0},
  289. .tempSlope = 68,
  290. .voltSlope = 0,
  291. /* spurChans spur channels in usual fbin coding format */
  292. .spurChans = {0, 0, 0, 0, 0},
  293. /* noiseFloorThreshCh Check if the register is per chain */
  294. .noiseFloorThreshCh = {-1, 0, 0},
  295. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  296. .quick_drop = 0,
  297. .xpaBiasLvl = 0,
  298. .txFrameToDataStart = 0x0e,
  299. .txFrameToPaOn = 0x0e,
  300. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  301. .antennaGain = 0,
  302. .switchSettling = 0x2d,
  303. .adcDesiredSize = -30,
  304. .txEndToXpaOff = 0,
  305. .txEndToRxOn = 0x2,
  306. .txFrameToXpaOn = 0xe,
  307. .thresh62 = 28,
  308. .papdRateMaskHt20 = LE32(0x0c80c080),
  309. .papdRateMaskHt40 = LE32(0x0080c080),
  310. .switchcomspdt = 0,
  311. .xlna_bias_strength = 0,
  312. .futureModal = {
  313. 0, 0, 0, 0, 0, 0, 0,
  314. },
  315. },
  316. .base_ext2 = {
  317. .tempSlopeLow = 0,
  318. .tempSlopeHigh = 0,
  319. .xatten1DBLow = {0, 0, 0},
  320. .xatten1MarginLow = {0, 0, 0},
  321. .xatten1DBHigh = {0, 0, 0},
  322. .xatten1MarginHigh = {0, 0, 0}
  323. },
  324. .calFreqPier5G = {
  325. FREQ2FBIN(5180, 0),
  326. FREQ2FBIN(5220, 0),
  327. FREQ2FBIN(5320, 0),
  328. FREQ2FBIN(5400, 0),
  329. FREQ2FBIN(5500, 0),
  330. FREQ2FBIN(5600, 0),
  331. FREQ2FBIN(5725, 0),
  332. FREQ2FBIN(5825, 0)
  333. },
  334. .calPierData5G = {
  335. {
  336. {0, 0, 0, 0, 0},
  337. {0, 0, 0, 0, 0},
  338. {0, 0, 0, 0, 0},
  339. {0, 0, 0, 0, 0},
  340. {0, 0, 0, 0, 0},
  341. {0, 0, 0, 0, 0},
  342. {0, 0, 0, 0, 0},
  343. {0, 0, 0, 0, 0},
  344. },
  345. {
  346. {0, 0, 0, 0, 0},
  347. {0, 0, 0, 0, 0},
  348. {0, 0, 0, 0, 0},
  349. {0, 0, 0, 0, 0},
  350. {0, 0, 0, 0, 0},
  351. {0, 0, 0, 0, 0},
  352. {0, 0, 0, 0, 0},
  353. {0, 0, 0, 0, 0},
  354. },
  355. {
  356. {0, 0, 0, 0, 0},
  357. {0, 0, 0, 0, 0},
  358. {0, 0, 0, 0, 0},
  359. {0, 0, 0, 0, 0},
  360. {0, 0, 0, 0, 0},
  361. {0, 0, 0, 0, 0},
  362. {0, 0, 0, 0, 0},
  363. {0, 0, 0, 0, 0},
  364. },
  365. },
  366. .calTarget_freqbin_5G = {
  367. FREQ2FBIN(5180, 0),
  368. FREQ2FBIN(5220, 0),
  369. FREQ2FBIN(5320, 0),
  370. FREQ2FBIN(5400, 0),
  371. FREQ2FBIN(5500, 0),
  372. FREQ2FBIN(5600, 0),
  373. FREQ2FBIN(5725, 0),
  374. FREQ2FBIN(5825, 0)
  375. },
  376. .calTarget_freqbin_5GHT20 = {
  377. FREQ2FBIN(5180, 0),
  378. FREQ2FBIN(5240, 0),
  379. FREQ2FBIN(5320, 0),
  380. FREQ2FBIN(5500, 0),
  381. FREQ2FBIN(5700, 0),
  382. FREQ2FBIN(5745, 0),
  383. FREQ2FBIN(5725, 0),
  384. FREQ2FBIN(5825, 0)
  385. },
  386. .calTarget_freqbin_5GHT40 = {
  387. FREQ2FBIN(5180, 0),
  388. FREQ2FBIN(5240, 0),
  389. FREQ2FBIN(5320, 0),
  390. FREQ2FBIN(5500, 0),
  391. FREQ2FBIN(5700, 0),
  392. FREQ2FBIN(5745, 0),
  393. FREQ2FBIN(5725, 0),
  394. FREQ2FBIN(5825, 0)
  395. },
  396. .calTargetPower5G = {
  397. /* 6-24,36,48,54 */
  398. { {20, 20, 20, 10} },
  399. { {20, 20, 20, 10} },
  400. { {20, 20, 20, 10} },
  401. { {20, 20, 20, 10} },
  402. { {20, 20, 20, 10} },
  403. { {20, 20, 20, 10} },
  404. { {20, 20, 20, 10} },
  405. { {20, 20, 20, 10} },
  406. },
  407. .calTargetPower5GHT20 = {
  408. /*
  409. * 0_8_16,1-3_9-11_17-19,
  410. * 4,5,6,7,12,13,14,15,20,21,22,23
  411. */
  412. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  413. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  414. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  415. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  416. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  417. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  418. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  419. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  420. },
  421. .calTargetPower5GHT40 = {
  422. /*
  423. * 0_8_16,1-3_9-11_17-19,
  424. * 4,5,6,7,12,13,14,15,20,21,22,23
  425. */
  426. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  427. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  428. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  429. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  430. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  431. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  432. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  433. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  434. },
  435. .ctlIndex_5G = {
  436. 0x10, 0x16, 0x18, 0x40, 0x46,
  437. 0x48, 0x30, 0x36, 0x38
  438. },
  439. .ctl_freqbin_5G = {
  440. {
  441. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  442. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  443. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  444. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  445. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  446. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  447. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  448. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  449. },
  450. {
  451. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  452. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  453. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  454. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  455. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  456. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  457. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  458. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  459. },
  460. {
  461. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  462. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  463. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  464. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  465. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  466. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  467. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  468. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  469. },
  470. {
  471. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  472. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  473. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  474. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  475. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  476. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  477. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  478. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  479. },
  480. {
  481. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  482. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  483. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  484. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  485. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  486. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  487. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  488. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  489. },
  490. {
  491. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  492. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  493. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  494. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  495. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  496. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  497. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  498. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  499. },
  500. {
  501. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  502. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  503. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  504. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  505. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  506. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  507. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  508. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  509. },
  510. {
  511. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  512. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  513. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  514. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  515. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  516. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  517. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  518. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  519. },
  520. {
  521. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  522. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  523. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  524. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  525. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  526. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  527. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  528. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  529. }
  530. },
  531. .ctlPowerData_5G = {
  532. {
  533. {
  534. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  535. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  536. }
  537. },
  538. {
  539. {
  540. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  541. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  542. }
  543. },
  544. {
  545. {
  546. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  547. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  548. }
  549. },
  550. {
  551. {
  552. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  553. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  554. }
  555. },
  556. {
  557. {
  558. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  559. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  560. }
  561. },
  562. {
  563. {
  564. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  565. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  566. }
  567. },
  568. {
  569. {
  570. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  571. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  572. }
  573. },
  574. {
  575. {
  576. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  577. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  578. }
  579. },
  580. {
  581. {
  582. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  583. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  584. }
  585. },
  586. }
  587. };
  588. static const struct ar9300_eeprom ar9300_x113 = {
  589. .eepromVersion = 2,
  590. .templateVersion = 6,
  591. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  592. .custData = {"x113-023-f0000"},
  593. .baseEepHeader = {
  594. .regDmn = { LE16(0), LE16(0x1f) },
  595. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  596. .opCapFlags = {
  597. .opFlags = AR5416_OPFLAGS_11A,
  598. .eepMisc = 0,
  599. },
  600. .rfSilent = 0,
  601. .blueToothOptions = 0,
  602. .deviceCap = 0,
  603. .deviceType = 5, /* takes lower byte in eeprom location */
  604. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  605. .params_for_tuning_caps = {0, 0},
  606. .featureEnable = 0x0d,
  607. /*
  608. * bit0 - enable tx temp comp - disabled
  609. * bit1 - enable tx volt comp - disabled
  610. * bit2 - enable fastClock - enabled
  611. * bit3 - enable doubling - enabled
  612. * bit4 - enable internal regulator - disabled
  613. * bit5 - enable pa predistortion - disabled
  614. */
  615. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  616. .eepromWriteEnableGpio = 6,
  617. .wlanDisableGpio = 0,
  618. .wlanLedGpio = 8,
  619. .rxBandSelectGpio = 0xff,
  620. .txrxgain = 0x21,
  621. .swreg = 0,
  622. },
  623. .modalHeader2G = {
  624. /* ar9300_modal_eep_header 2g */
  625. /* 4 idle,t1,t2,b(4 bits per setting) */
  626. .antCtrlCommon = LE32(0x110),
  627. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  628. .antCtrlCommon2 = LE32(0x44444),
  629. /*
  630. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  631. * rx1, rx12, b (2 bits each)
  632. */
  633. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  634. /*
  635. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  636. * for ar9280 (0xa20c/b20c 5:0)
  637. */
  638. .xatten1DB = {0, 0, 0},
  639. /*
  640. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  641. * for ar9280 (0xa20c/b20c 16:12
  642. */
  643. .xatten1Margin = {0, 0, 0},
  644. .tempSlope = 25,
  645. .voltSlope = 0,
  646. /*
  647. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  648. * channels in usual fbin coding format
  649. */
  650. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  651. /*
  652. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  653. * if the register is per chain
  654. */
  655. .noiseFloorThreshCh = {-1, 0, 0},
  656. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  657. .quick_drop = 0,
  658. .xpaBiasLvl = 0,
  659. .txFrameToDataStart = 0x0e,
  660. .txFrameToPaOn = 0x0e,
  661. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  662. .antennaGain = 0,
  663. .switchSettling = 0x2c,
  664. .adcDesiredSize = -30,
  665. .txEndToXpaOff = 0,
  666. .txEndToRxOn = 0x2,
  667. .txFrameToXpaOn = 0xe,
  668. .thresh62 = 28,
  669. .papdRateMaskHt20 = LE32(0x0c80c080),
  670. .papdRateMaskHt40 = LE32(0x0080c080),
  671. .switchcomspdt = 0,
  672. .xlna_bias_strength = 0,
  673. .futureModal = {
  674. 0, 0, 0, 0, 0, 0, 0,
  675. },
  676. },
  677. .base_ext1 = {
  678. .ant_div_control = 0,
  679. .future = {0, 0},
  680. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  681. },
  682. .calFreqPier2G = {
  683. FREQ2FBIN(2412, 1),
  684. FREQ2FBIN(2437, 1),
  685. FREQ2FBIN(2472, 1),
  686. },
  687. /* ar9300_cal_data_per_freq_op_loop 2g */
  688. .calPierData2G = {
  689. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  690. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  691. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  692. },
  693. .calTarget_freqbin_Cck = {
  694. FREQ2FBIN(2412, 1),
  695. FREQ2FBIN(2472, 1),
  696. },
  697. .calTarget_freqbin_2G = {
  698. FREQ2FBIN(2412, 1),
  699. FREQ2FBIN(2437, 1),
  700. FREQ2FBIN(2472, 1)
  701. },
  702. .calTarget_freqbin_2GHT20 = {
  703. FREQ2FBIN(2412, 1),
  704. FREQ2FBIN(2437, 1),
  705. FREQ2FBIN(2472, 1)
  706. },
  707. .calTarget_freqbin_2GHT40 = {
  708. FREQ2FBIN(2412, 1),
  709. FREQ2FBIN(2437, 1),
  710. FREQ2FBIN(2472, 1)
  711. },
  712. .calTargetPowerCck = {
  713. /* 1L-5L,5S,11L,11S */
  714. { {34, 34, 34, 34} },
  715. { {34, 34, 34, 34} },
  716. },
  717. .calTargetPower2G = {
  718. /* 6-24,36,48,54 */
  719. { {34, 34, 32, 32} },
  720. { {34, 34, 32, 32} },
  721. { {34, 34, 32, 32} },
  722. },
  723. .calTargetPower2GHT20 = {
  724. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  725. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  726. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  727. },
  728. .calTargetPower2GHT40 = {
  729. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  730. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  731. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  732. },
  733. .ctlIndex_2G = {
  734. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  735. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  736. },
  737. .ctl_freqbin_2G = {
  738. {
  739. FREQ2FBIN(2412, 1),
  740. FREQ2FBIN(2417, 1),
  741. FREQ2FBIN(2457, 1),
  742. FREQ2FBIN(2462, 1)
  743. },
  744. {
  745. FREQ2FBIN(2412, 1),
  746. FREQ2FBIN(2417, 1),
  747. FREQ2FBIN(2462, 1),
  748. 0xFF,
  749. },
  750. {
  751. FREQ2FBIN(2412, 1),
  752. FREQ2FBIN(2417, 1),
  753. FREQ2FBIN(2462, 1),
  754. 0xFF,
  755. },
  756. {
  757. FREQ2FBIN(2422, 1),
  758. FREQ2FBIN(2427, 1),
  759. FREQ2FBIN(2447, 1),
  760. FREQ2FBIN(2452, 1)
  761. },
  762. {
  763. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  764. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  765. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  766. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  767. },
  768. {
  769. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  770. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  771. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  772. 0,
  773. },
  774. {
  775. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  776. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  777. FREQ2FBIN(2472, 1),
  778. 0,
  779. },
  780. {
  781. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  782. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  783. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  784. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  785. },
  786. {
  787. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  788. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  789. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  790. },
  791. {
  792. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  793. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  794. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  795. 0
  796. },
  797. {
  798. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  799. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  800. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  801. 0
  802. },
  803. {
  804. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  805. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  806. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  807. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  808. }
  809. },
  810. .ctlPowerData_2G = {
  811. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  812. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  813. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  814. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  815. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  816. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  817. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  818. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  819. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  820. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  821. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  822. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  823. },
  824. .modalHeader5G = {
  825. /* 4 idle,t1,t2,b (4 bits per setting) */
  826. .antCtrlCommon = LE32(0x220),
  827. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  828. .antCtrlCommon2 = LE32(0x11111),
  829. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  830. .antCtrlChain = {
  831. LE16(0x150), LE16(0x150), LE16(0x150),
  832. },
  833. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  834. .xatten1DB = {0, 0, 0},
  835. /*
  836. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  837. * for merlin (0xa20c/b20c 16:12
  838. */
  839. .xatten1Margin = {0, 0, 0},
  840. .tempSlope = 68,
  841. .voltSlope = 0,
  842. /* spurChans spur channels in usual fbin coding format */
  843. .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0},
  844. /* noiseFloorThreshCh Check if the register is per chain */
  845. .noiseFloorThreshCh = {-1, 0, 0},
  846. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  847. .quick_drop = 0,
  848. .xpaBiasLvl = 0xf,
  849. .txFrameToDataStart = 0x0e,
  850. .txFrameToPaOn = 0x0e,
  851. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  852. .antennaGain = 0,
  853. .switchSettling = 0x2d,
  854. .adcDesiredSize = -30,
  855. .txEndToXpaOff = 0,
  856. .txEndToRxOn = 0x2,
  857. .txFrameToXpaOn = 0xe,
  858. .thresh62 = 28,
  859. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  860. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  861. .switchcomspdt = 0,
  862. .xlna_bias_strength = 0,
  863. .futureModal = {
  864. 0, 0, 0, 0, 0, 0, 0,
  865. },
  866. },
  867. .base_ext2 = {
  868. .tempSlopeLow = 72,
  869. .tempSlopeHigh = 105,
  870. .xatten1DBLow = {0, 0, 0},
  871. .xatten1MarginLow = {0, 0, 0},
  872. .xatten1DBHigh = {0, 0, 0},
  873. .xatten1MarginHigh = {0, 0, 0}
  874. },
  875. .calFreqPier5G = {
  876. FREQ2FBIN(5180, 0),
  877. FREQ2FBIN(5240, 0),
  878. FREQ2FBIN(5320, 0),
  879. FREQ2FBIN(5400, 0),
  880. FREQ2FBIN(5500, 0),
  881. FREQ2FBIN(5600, 0),
  882. FREQ2FBIN(5745, 0),
  883. FREQ2FBIN(5785, 0)
  884. },
  885. .calPierData5G = {
  886. {
  887. {0, 0, 0, 0, 0},
  888. {0, 0, 0, 0, 0},
  889. {0, 0, 0, 0, 0},
  890. {0, 0, 0, 0, 0},
  891. {0, 0, 0, 0, 0},
  892. {0, 0, 0, 0, 0},
  893. {0, 0, 0, 0, 0},
  894. {0, 0, 0, 0, 0},
  895. },
  896. {
  897. {0, 0, 0, 0, 0},
  898. {0, 0, 0, 0, 0},
  899. {0, 0, 0, 0, 0},
  900. {0, 0, 0, 0, 0},
  901. {0, 0, 0, 0, 0},
  902. {0, 0, 0, 0, 0},
  903. {0, 0, 0, 0, 0},
  904. {0, 0, 0, 0, 0},
  905. },
  906. {
  907. {0, 0, 0, 0, 0},
  908. {0, 0, 0, 0, 0},
  909. {0, 0, 0, 0, 0},
  910. {0, 0, 0, 0, 0},
  911. {0, 0, 0, 0, 0},
  912. {0, 0, 0, 0, 0},
  913. {0, 0, 0, 0, 0},
  914. {0, 0, 0, 0, 0},
  915. },
  916. },
  917. .calTarget_freqbin_5G = {
  918. FREQ2FBIN(5180, 0),
  919. FREQ2FBIN(5220, 0),
  920. FREQ2FBIN(5320, 0),
  921. FREQ2FBIN(5400, 0),
  922. FREQ2FBIN(5500, 0),
  923. FREQ2FBIN(5600, 0),
  924. FREQ2FBIN(5745, 0),
  925. FREQ2FBIN(5785, 0)
  926. },
  927. .calTarget_freqbin_5GHT20 = {
  928. FREQ2FBIN(5180, 0),
  929. FREQ2FBIN(5240, 0),
  930. FREQ2FBIN(5320, 0),
  931. FREQ2FBIN(5400, 0),
  932. FREQ2FBIN(5500, 0),
  933. FREQ2FBIN(5700, 0),
  934. FREQ2FBIN(5745, 0),
  935. FREQ2FBIN(5825, 0)
  936. },
  937. .calTarget_freqbin_5GHT40 = {
  938. FREQ2FBIN(5190, 0),
  939. FREQ2FBIN(5230, 0),
  940. FREQ2FBIN(5320, 0),
  941. FREQ2FBIN(5410, 0),
  942. FREQ2FBIN(5510, 0),
  943. FREQ2FBIN(5670, 0),
  944. FREQ2FBIN(5755, 0),
  945. FREQ2FBIN(5825, 0)
  946. },
  947. .calTargetPower5G = {
  948. /* 6-24,36,48,54 */
  949. { {42, 40, 40, 34} },
  950. { {42, 40, 40, 34} },
  951. { {42, 40, 40, 34} },
  952. { {42, 40, 40, 34} },
  953. { {42, 40, 40, 34} },
  954. { {42, 40, 40, 34} },
  955. { {42, 40, 40, 34} },
  956. { {42, 40, 40, 34} },
  957. },
  958. .calTargetPower5GHT20 = {
  959. /*
  960. * 0_8_16,1-3_9-11_17-19,
  961. * 4,5,6,7,12,13,14,15,20,21,22,23
  962. */
  963. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  964. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  965. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  966. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  967. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  968. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  969. { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} },
  970. { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} },
  971. },
  972. .calTargetPower5GHT40 = {
  973. /*
  974. * 0_8_16,1-3_9-11_17-19,
  975. * 4,5,6,7,12,13,14,15,20,21,22,23
  976. */
  977. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  978. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  979. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  980. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  981. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  982. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  983. { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} },
  984. { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} },
  985. },
  986. .ctlIndex_5G = {
  987. 0x10, 0x16, 0x18, 0x40, 0x46,
  988. 0x48, 0x30, 0x36, 0x38
  989. },
  990. .ctl_freqbin_5G = {
  991. {
  992. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  993. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  994. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  995. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  996. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  997. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  998. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  999. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1000. },
  1001. {
  1002. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1003. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1004. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1005. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1006. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1007. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1008. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1009. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1010. },
  1011. {
  1012. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1013. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1014. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1015. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1016. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1017. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1018. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1019. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1020. },
  1021. {
  1022. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1023. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1024. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1025. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1026. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1027. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1028. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1029. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1030. },
  1031. {
  1032. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1033. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1034. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1035. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1036. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1037. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1038. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1039. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1040. },
  1041. {
  1042. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1043. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1044. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1045. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1046. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1047. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1048. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1049. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1050. },
  1051. {
  1052. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1053. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1054. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1055. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1056. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1057. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1058. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1059. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1060. },
  1061. {
  1062. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1063. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1064. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1065. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1066. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1067. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1068. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1069. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1070. },
  1071. {
  1072. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1073. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1074. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1075. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1076. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1077. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1078. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1079. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1080. }
  1081. },
  1082. .ctlPowerData_5G = {
  1083. {
  1084. {
  1085. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1086. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1087. }
  1088. },
  1089. {
  1090. {
  1091. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1092. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1093. }
  1094. },
  1095. {
  1096. {
  1097. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1098. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1099. }
  1100. },
  1101. {
  1102. {
  1103. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1104. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1105. }
  1106. },
  1107. {
  1108. {
  1109. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1110. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1111. }
  1112. },
  1113. {
  1114. {
  1115. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1116. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1117. }
  1118. },
  1119. {
  1120. {
  1121. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1122. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1123. }
  1124. },
  1125. {
  1126. {
  1127. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1128. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1129. }
  1130. },
  1131. {
  1132. {
  1133. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1134. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1135. }
  1136. },
  1137. }
  1138. };
  1139. static const struct ar9300_eeprom ar9300_h112 = {
  1140. .eepromVersion = 2,
  1141. .templateVersion = 3,
  1142. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1143. .custData = {"h112-241-f0000"},
  1144. .baseEepHeader = {
  1145. .regDmn = { LE16(0), LE16(0x1f) },
  1146. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1147. .opCapFlags = {
  1148. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1149. .eepMisc = 0,
  1150. },
  1151. .rfSilent = 0,
  1152. .blueToothOptions = 0,
  1153. .deviceCap = 0,
  1154. .deviceType = 5, /* takes lower byte in eeprom location */
  1155. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1156. .params_for_tuning_caps = {0, 0},
  1157. .featureEnable = 0x0d,
  1158. /*
  1159. * bit0 - enable tx temp comp - disabled
  1160. * bit1 - enable tx volt comp - disabled
  1161. * bit2 - enable fastClock - enabled
  1162. * bit3 - enable doubling - enabled
  1163. * bit4 - enable internal regulator - disabled
  1164. * bit5 - enable pa predistortion - disabled
  1165. */
  1166. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1167. .eepromWriteEnableGpio = 6,
  1168. .wlanDisableGpio = 0,
  1169. .wlanLedGpio = 8,
  1170. .rxBandSelectGpio = 0xff,
  1171. .txrxgain = 0x10,
  1172. .swreg = 0,
  1173. },
  1174. .modalHeader2G = {
  1175. /* ar9300_modal_eep_header 2g */
  1176. /* 4 idle,t1,t2,b(4 bits per setting) */
  1177. .antCtrlCommon = LE32(0x110),
  1178. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1179. .antCtrlCommon2 = LE32(0x44444),
  1180. /*
  1181. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  1182. * rx1, rx12, b (2 bits each)
  1183. */
  1184. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  1185. /*
  1186. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  1187. * for ar9280 (0xa20c/b20c 5:0)
  1188. */
  1189. .xatten1DB = {0, 0, 0},
  1190. /*
  1191. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1192. * for ar9280 (0xa20c/b20c 16:12
  1193. */
  1194. .xatten1Margin = {0, 0, 0},
  1195. .tempSlope = 25,
  1196. .voltSlope = 0,
  1197. /*
  1198. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  1199. * channels in usual fbin coding format
  1200. */
  1201. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1202. /*
  1203. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  1204. * if the register is per chain
  1205. */
  1206. .noiseFloorThreshCh = {-1, 0, 0},
  1207. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1208. .quick_drop = 0,
  1209. .xpaBiasLvl = 0,
  1210. .txFrameToDataStart = 0x0e,
  1211. .txFrameToPaOn = 0x0e,
  1212. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1213. .antennaGain = 0,
  1214. .switchSettling = 0x2c,
  1215. .adcDesiredSize = -30,
  1216. .txEndToXpaOff = 0,
  1217. .txEndToRxOn = 0x2,
  1218. .txFrameToXpaOn = 0xe,
  1219. .thresh62 = 28,
  1220. .papdRateMaskHt20 = LE32(0x0c80c080),
  1221. .papdRateMaskHt40 = LE32(0x0080c080),
  1222. .switchcomspdt = 0,
  1223. .xlna_bias_strength = 0,
  1224. .futureModal = {
  1225. 0, 0, 0, 0, 0, 0, 0,
  1226. },
  1227. },
  1228. .base_ext1 = {
  1229. .ant_div_control = 0,
  1230. .future = {0, 0},
  1231. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  1232. },
  1233. .calFreqPier2G = {
  1234. FREQ2FBIN(2412, 1),
  1235. FREQ2FBIN(2437, 1),
  1236. FREQ2FBIN(2462, 1),
  1237. },
  1238. /* ar9300_cal_data_per_freq_op_loop 2g */
  1239. .calPierData2G = {
  1240. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1241. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1242. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1243. },
  1244. .calTarget_freqbin_Cck = {
  1245. FREQ2FBIN(2412, 1),
  1246. FREQ2FBIN(2472, 1),
  1247. },
  1248. .calTarget_freqbin_2G = {
  1249. FREQ2FBIN(2412, 1),
  1250. FREQ2FBIN(2437, 1),
  1251. FREQ2FBIN(2472, 1)
  1252. },
  1253. .calTarget_freqbin_2GHT20 = {
  1254. FREQ2FBIN(2412, 1),
  1255. FREQ2FBIN(2437, 1),
  1256. FREQ2FBIN(2472, 1)
  1257. },
  1258. .calTarget_freqbin_2GHT40 = {
  1259. FREQ2FBIN(2412, 1),
  1260. FREQ2FBIN(2437, 1),
  1261. FREQ2FBIN(2472, 1)
  1262. },
  1263. .calTargetPowerCck = {
  1264. /* 1L-5L,5S,11L,11S */
  1265. { {34, 34, 34, 34} },
  1266. { {34, 34, 34, 34} },
  1267. },
  1268. .calTargetPower2G = {
  1269. /* 6-24,36,48,54 */
  1270. { {34, 34, 32, 32} },
  1271. { {34, 34, 32, 32} },
  1272. { {34, 34, 32, 32} },
  1273. },
  1274. .calTargetPower2GHT20 = {
  1275. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1276. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1277. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1278. },
  1279. .calTargetPower2GHT40 = {
  1280. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1281. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1282. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1283. },
  1284. .ctlIndex_2G = {
  1285. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1286. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1287. },
  1288. .ctl_freqbin_2G = {
  1289. {
  1290. FREQ2FBIN(2412, 1),
  1291. FREQ2FBIN(2417, 1),
  1292. FREQ2FBIN(2457, 1),
  1293. FREQ2FBIN(2462, 1)
  1294. },
  1295. {
  1296. FREQ2FBIN(2412, 1),
  1297. FREQ2FBIN(2417, 1),
  1298. FREQ2FBIN(2462, 1),
  1299. 0xFF,
  1300. },
  1301. {
  1302. FREQ2FBIN(2412, 1),
  1303. FREQ2FBIN(2417, 1),
  1304. FREQ2FBIN(2462, 1),
  1305. 0xFF,
  1306. },
  1307. {
  1308. FREQ2FBIN(2422, 1),
  1309. FREQ2FBIN(2427, 1),
  1310. FREQ2FBIN(2447, 1),
  1311. FREQ2FBIN(2452, 1)
  1312. },
  1313. {
  1314. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1315. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1316. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1317. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  1318. },
  1319. {
  1320. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1321. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1322. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1323. 0,
  1324. },
  1325. {
  1326. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1327. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1328. FREQ2FBIN(2472, 1),
  1329. 0,
  1330. },
  1331. {
  1332. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1333. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1334. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1335. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1336. },
  1337. {
  1338. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1339. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1340. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1341. },
  1342. {
  1343. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1344. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1345. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1346. 0
  1347. },
  1348. {
  1349. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1350. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1351. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1352. 0
  1353. },
  1354. {
  1355. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1356. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1357. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1358. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1359. }
  1360. },
  1361. .ctlPowerData_2G = {
  1362. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1363. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1364. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1365. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  1366. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1367. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1368. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1369. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1370. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1371. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1372. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1373. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1374. },
  1375. .modalHeader5G = {
  1376. /* 4 idle,t1,t2,b (4 bits per setting) */
  1377. .antCtrlCommon = LE32(0x220),
  1378. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1379. .antCtrlCommon2 = LE32(0x44444),
  1380. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1381. .antCtrlChain = {
  1382. LE16(0x150), LE16(0x150), LE16(0x150),
  1383. },
  1384. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  1385. .xatten1DB = {0, 0, 0},
  1386. /*
  1387. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1388. * for merlin (0xa20c/b20c 16:12
  1389. */
  1390. .xatten1Margin = {0, 0, 0},
  1391. .tempSlope = 45,
  1392. .voltSlope = 0,
  1393. /* spurChans spur channels in usual fbin coding format */
  1394. .spurChans = {0, 0, 0, 0, 0},
  1395. /* noiseFloorThreshCh Check if the register is per chain */
  1396. .noiseFloorThreshCh = {-1, 0, 0},
  1397. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1398. .quick_drop = 0,
  1399. .xpaBiasLvl = 0,
  1400. .txFrameToDataStart = 0x0e,
  1401. .txFrameToPaOn = 0x0e,
  1402. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1403. .antennaGain = 0,
  1404. .switchSettling = 0x2d,
  1405. .adcDesiredSize = -30,
  1406. .txEndToXpaOff = 0,
  1407. .txEndToRxOn = 0x2,
  1408. .txFrameToXpaOn = 0xe,
  1409. .thresh62 = 28,
  1410. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1411. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1412. .switchcomspdt = 0,
  1413. .xlna_bias_strength = 0,
  1414. .futureModal = {
  1415. 0, 0, 0, 0, 0, 0, 0,
  1416. },
  1417. },
  1418. .base_ext2 = {
  1419. .tempSlopeLow = 40,
  1420. .tempSlopeHigh = 50,
  1421. .xatten1DBLow = {0, 0, 0},
  1422. .xatten1MarginLow = {0, 0, 0},
  1423. .xatten1DBHigh = {0, 0, 0},
  1424. .xatten1MarginHigh = {0, 0, 0}
  1425. },
  1426. .calFreqPier5G = {
  1427. FREQ2FBIN(5180, 0),
  1428. FREQ2FBIN(5220, 0),
  1429. FREQ2FBIN(5320, 0),
  1430. FREQ2FBIN(5400, 0),
  1431. FREQ2FBIN(5500, 0),
  1432. FREQ2FBIN(5600, 0),
  1433. FREQ2FBIN(5700, 0),
  1434. FREQ2FBIN(5785, 0)
  1435. },
  1436. .calPierData5G = {
  1437. {
  1438. {0, 0, 0, 0, 0},
  1439. {0, 0, 0, 0, 0},
  1440. {0, 0, 0, 0, 0},
  1441. {0, 0, 0, 0, 0},
  1442. {0, 0, 0, 0, 0},
  1443. {0, 0, 0, 0, 0},
  1444. {0, 0, 0, 0, 0},
  1445. {0, 0, 0, 0, 0},
  1446. },
  1447. {
  1448. {0, 0, 0, 0, 0},
  1449. {0, 0, 0, 0, 0},
  1450. {0, 0, 0, 0, 0},
  1451. {0, 0, 0, 0, 0},
  1452. {0, 0, 0, 0, 0},
  1453. {0, 0, 0, 0, 0},
  1454. {0, 0, 0, 0, 0},
  1455. {0, 0, 0, 0, 0},
  1456. },
  1457. {
  1458. {0, 0, 0, 0, 0},
  1459. {0, 0, 0, 0, 0},
  1460. {0, 0, 0, 0, 0},
  1461. {0, 0, 0, 0, 0},
  1462. {0, 0, 0, 0, 0},
  1463. {0, 0, 0, 0, 0},
  1464. {0, 0, 0, 0, 0},
  1465. {0, 0, 0, 0, 0},
  1466. },
  1467. },
  1468. .calTarget_freqbin_5G = {
  1469. FREQ2FBIN(5180, 0),
  1470. FREQ2FBIN(5240, 0),
  1471. FREQ2FBIN(5320, 0),
  1472. FREQ2FBIN(5400, 0),
  1473. FREQ2FBIN(5500, 0),
  1474. FREQ2FBIN(5600, 0),
  1475. FREQ2FBIN(5700, 0),
  1476. FREQ2FBIN(5825, 0)
  1477. },
  1478. .calTarget_freqbin_5GHT20 = {
  1479. FREQ2FBIN(5180, 0),
  1480. FREQ2FBIN(5240, 0),
  1481. FREQ2FBIN(5320, 0),
  1482. FREQ2FBIN(5400, 0),
  1483. FREQ2FBIN(5500, 0),
  1484. FREQ2FBIN(5700, 0),
  1485. FREQ2FBIN(5745, 0),
  1486. FREQ2FBIN(5825, 0)
  1487. },
  1488. .calTarget_freqbin_5GHT40 = {
  1489. FREQ2FBIN(5180, 0),
  1490. FREQ2FBIN(5240, 0),
  1491. FREQ2FBIN(5320, 0),
  1492. FREQ2FBIN(5400, 0),
  1493. FREQ2FBIN(5500, 0),
  1494. FREQ2FBIN(5700, 0),
  1495. FREQ2FBIN(5745, 0),
  1496. FREQ2FBIN(5825, 0)
  1497. },
  1498. .calTargetPower5G = {
  1499. /* 6-24,36,48,54 */
  1500. { {30, 30, 28, 24} },
  1501. { {30, 30, 28, 24} },
  1502. { {30, 30, 28, 24} },
  1503. { {30, 30, 28, 24} },
  1504. { {30, 30, 28, 24} },
  1505. { {30, 30, 28, 24} },
  1506. { {30, 30, 28, 24} },
  1507. { {30, 30, 28, 24} },
  1508. },
  1509. .calTargetPower5GHT20 = {
  1510. /*
  1511. * 0_8_16,1-3_9-11_17-19,
  1512. * 4,5,6,7,12,13,14,15,20,21,22,23
  1513. */
  1514. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1515. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1516. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1517. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1518. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1519. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1520. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1521. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1522. },
  1523. .calTargetPower5GHT40 = {
  1524. /*
  1525. * 0_8_16,1-3_9-11_17-19,
  1526. * 4,5,6,7,12,13,14,15,20,21,22,23
  1527. */
  1528. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1529. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1530. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1531. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1532. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1533. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1534. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1535. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1536. },
  1537. .ctlIndex_5G = {
  1538. 0x10, 0x16, 0x18, 0x40, 0x46,
  1539. 0x48, 0x30, 0x36, 0x38
  1540. },
  1541. .ctl_freqbin_5G = {
  1542. {
  1543. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1544. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1545. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1546. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1547. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  1548. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1549. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1550. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1551. },
  1552. {
  1553. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1554. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1555. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1556. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1557. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1558. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1559. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1560. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1561. },
  1562. {
  1563. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1564. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1565. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1566. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1567. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1568. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1569. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1570. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1571. },
  1572. {
  1573. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1574. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1575. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1576. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1577. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1578. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1579. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1580. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1581. },
  1582. {
  1583. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1584. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1585. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1586. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1587. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1588. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1589. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1590. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1591. },
  1592. {
  1593. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1594. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1595. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1596. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1597. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1598. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1599. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1600. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1601. },
  1602. {
  1603. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1604. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1605. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1606. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1607. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1608. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1609. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1610. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1611. },
  1612. {
  1613. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1614. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1615. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1616. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1617. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1618. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1619. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1620. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1621. },
  1622. {
  1623. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1624. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1625. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1626. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1627. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1628. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1629. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1630. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1631. }
  1632. },
  1633. .ctlPowerData_5G = {
  1634. {
  1635. {
  1636. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1637. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1638. }
  1639. },
  1640. {
  1641. {
  1642. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1643. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1644. }
  1645. },
  1646. {
  1647. {
  1648. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1649. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1650. }
  1651. },
  1652. {
  1653. {
  1654. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1655. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1656. }
  1657. },
  1658. {
  1659. {
  1660. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1661. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1662. }
  1663. },
  1664. {
  1665. {
  1666. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1667. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1668. }
  1669. },
  1670. {
  1671. {
  1672. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1673. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1674. }
  1675. },
  1676. {
  1677. {
  1678. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1679. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1680. }
  1681. },
  1682. {
  1683. {
  1684. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1685. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1686. }
  1687. },
  1688. }
  1689. };
  1690. static const struct ar9300_eeprom ar9300_x112 = {
  1691. .eepromVersion = 2,
  1692. .templateVersion = 5,
  1693. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1694. .custData = {"x112-041-f0000"},
  1695. .baseEepHeader = {
  1696. .regDmn = { LE16(0), LE16(0x1f) },
  1697. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1698. .opCapFlags = {
  1699. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1700. .eepMisc = 0,
  1701. },
  1702. .rfSilent = 0,
  1703. .blueToothOptions = 0,
  1704. .deviceCap = 0,
  1705. .deviceType = 5, /* takes lower byte in eeprom location */
  1706. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1707. .params_for_tuning_caps = {0, 0},
  1708. .featureEnable = 0x0d,
  1709. /*
  1710. * bit0 - enable tx temp comp - disabled
  1711. * bit1 - enable tx volt comp - disabled
  1712. * bit2 - enable fastclock - enabled
  1713. * bit3 - enable doubling - enabled
  1714. * bit4 - enable internal regulator - disabled
  1715. * bit5 - enable pa predistortion - disabled
  1716. */
  1717. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1718. .eepromWriteEnableGpio = 6,
  1719. .wlanDisableGpio = 0,
  1720. .wlanLedGpio = 8,
  1721. .rxBandSelectGpio = 0xff,
  1722. .txrxgain = 0x0,
  1723. .swreg = 0,
  1724. },
  1725. .modalHeader2G = {
  1726. /* ar9300_modal_eep_header 2g */
  1727. /* 4 idle,t1,t2,b(4 bits per setting) */
  1728. .antCtrlCommon = LE32(0x110),
  1729. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1730. .antCtrlCommon2 = LE32(0x22222),
  1731. /*
  1732. * antCtrlChain[ar9300_max_chains]; 6 idle, t, r,
  1733. * rx1, rx12, b (2 bits each)
  1734. */
  1735. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  1736. /*
  1737. * xatten1DB[AR9300_max_chains]; 3 xatten1_db
  1738. * for ar9280 (0xa20c/b20c 5:0)
  1739. */
  1740. .xatten1DB = {0x1b, 0x1b, 0x1b},
  1741. /*
  1742. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1743. * for ar9280 (0xa20c/b20c 16:12
  1744. */
  1745. .xatten1Margin = {0x15, 0x15, 0x15},
  1746. .tempSlope = 50,
  1747. .voltSlope = 0,
  1748. /*
  1749. * spurChans[OSPrey_eeprom_modal_sPURS]; spur
  1750. * channels in usual fbin coding format
  1751. */
  1752. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1753. /*
  1754. * noiseFloorThreshch[ar9300_max_cHAINS]; 3 Check
  1755. * if the register is per chain
  1756. */
  1757. .noiseFloorThreshCh = {-1, 0, 0},
  1758. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1759. .quick_drop = 0,
  1760. .xpaBiasLvl = 0,
  1761. .txFrameToDataStart = 0x0e,
  1762. .txFrameToPaOn = 0x0e,
  1763. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1764. .antennaGain = 0,
  1765. .switchSettling = 0x2c,
  1766. .adcDesiredSize = -30,
  1767. .txEndToXpaOff = 0,
  1768. .txEndToRxOn = 0x2,
  1769. .txFrameToXpaOn = 0xe,
  1770. .thresh62 = 28,
  1771. .papdRateMaskHt20 = LE32(0x0c80c080),
  1772. .papdRateMaskHt40 = LE32(0x0080c080),
  1773. .switchcomspdt = 0,
  1774. .xlna_bias_strength = 0,
  1775. .futureModal = {
  1776. 0, 0, 0, 0, 0, 0, 0,
  1777. },
  1778. },
  1779. .base_ext1 = {
  1780. .ant_div_control = 0,
  1781. .future = {0, 0},
  1782. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  1783. },
  1784. .calFreqPier2G = {
  1785. FREQ2FBIN(2412, 1),
  1786. FREQ2FBIN(2437, 1),
  1787. FREQ2FBIN(2472, 1),
  1788. },
  1789. /* ar9300_cal_data_per_freq_op_loop 2g */
  1790. .calPierData2G = {
  1791. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1792. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1793. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1794. },
  1795. .calTarget_freqbin_Cck = {
  1796. FREQ2FBIN(2412, 1),
  1797. FREQ2FBIN(2472, 1),
  1798. },
  1799. .calTarget_freqbin_2G = {
  1800. FREQ2FBIN(2412, 1),
  1801. FREQ2FBIN(2437, 1),
  1802. FREQ2FBIN(2472, 1)
  1803. },
  1804. .calTarget_freqbin_2GHT20 = {
  1805. FREQ2FBIN(2412, 1),
  1806. FREQ2FBIN(2437, 1),
  1807. FREQ2FBIN(2472, 1)
  1808. },
  1809. .calTarget_freqbin_2GHT40 = {
  1810. FREQ2FBIN(2412, 1),
  1811. FREQ2FBIN(2437, 1),
  1812. FREQ2FBIN(2472, 1)
  1813. },
  1814. .calTargetPowerCck = {
  1815. /* 1L-5L,5S,11L,11s */
  1816. { {38, 38, 38, 38} },
  1817. { {38, 38, 38, 38} },
  1818. },
  1819. .calTargetPower2G = {
  1820. /* 6-24,36,48,54 */
  1821. { {38, 38, 36, 34} },
  1822. { {38, 38, 36, 34} },
  1823. { {38, 38, 34, 32} },
  1824. },
  1825. .calTargetPower2GHT20 = {
  1826. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1827. { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} },
  1828. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1829. },
  1830. .calTargetPower2GHT40 = {
  1831. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1832. { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} },
  1833. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1834. },
  1835. .ctlIndex_2G = {
  1836. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1837. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1838. },
  1839. .ctl_freqbin_2G = {
  1840. {
  1841. FREQ2FBIN(2412, 1),
  1842. FREQ2FBIN(2417, 1),
  1843. FREQ2FBIN(2457, 1),
  1844. FREQ2FBIN(2462, 1)
  1845. },
  1846. {
  1847. FREQ2FBIN(2412, 1),
  1848. FREQ2FBIN(2417, 1),
  1849. FREQ2FBIN(2462, 1),
  1850. 0xFF,
  1851. },
  1852. {
  1853. FREQ2FBIN(2412, 1),
  1854. FREQ2FBIN(2417, 1),
  1855. FREQ2FBIN(2462, 1),
  1856. 0xFF,
  1857. },
  1858. {
  1859. FREQ2FBIN(2422, 1),
  1860. FREQ2FBIN(2427, 1),
  1861. FREQ2FBIN(2447, 1),
  1862. FREQ2FBIN(2452, 1)
  1863. },
  1864. {
  1865. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1866. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1867. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1868. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(2484, 1),
  1869. },
  1870. {
  1871. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1872. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1873. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1874. 0,
  1875. },
  1876. {
  1877. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1878. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1879. FREQ2FBIN(2472, 1),
  1880. 0,
  1881. },
  1882. {
  1883. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1884. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1885. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1886. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1887. },
  1888. {
  1889. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1890. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1891. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1892. },
  1893. {
  1894. /* Data[9].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1895. /* Data[9].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1896. /* Data[9].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1897. 0
  1898. },
  1899. {
  1900. /* Data[10].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1901. /* Data[10].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1902. /* Data[10].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1903. 0
  1904. },
  1905. {
  1906. /* Data[11].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1907. /* Data[11].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1908. /* Data[11].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1909. /* Data[11].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1910. }
  1911. },
  1912. .ctlPowerData_2G = {
  1913. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1914. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1915. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1916. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  1917. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1918. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1919. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1920. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1921. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1922. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1923. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1924. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1925. },
  1926. .modalHeader5G = {
  1927. /* 4 idle,t1,t2,b (4 bits per setting) */
  1928. .antCtrlCommon = LE32(0x110),
  1929. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1930. .antCtrlCommon2 = LE32(0x22222),
  1931. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1932. .antCtrlChain = {
  1933. LE16(0x0), LE16(0x0), LE16(0x0),
  1934. },
  1935. /* xatten1DB 3 xatten1_db for ar9280 (0xa20c/b20c 5:0) */
  1936. .xatten1DB = {0x13, 0x19, 0x17},
  1937. /*
  1938. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1939. * for merlin (0xa20c/b20c 16:12
  1940. */
  1941. .xatten1Margin = {0x19, 0x19, 0x19},
  1942. .tempSlope = 70,
  1943. .voltSlope = 15,
  1944. /* spurChans spur channels in usual fbin coding format */
  1945. .spurChans = {0, 0, 0, 0, 0},
  1946. /* noiseFloorThreshch check if the register is per chain */
  1947. .noiseFloorThreshCh = {-1, 0, 0},
  1948. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1949. .quick_drop = 0,
  1950. .xpaBiasLvl = 0,
  1951. .txFrameToDataStart = 0x0e,
  1952. .txFrameToPaOn = 0x0e,
  1953. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1954. .antennaGain = 0,
  1955. .switchSettling = 0x2d,
  1956. .adcDesiredSize = -30,
  1957. .txEndToXpaOff = 0,
  1958. .txEndToRxOn = 0x2,
  1959. .txFrameToXpaOn = 0xe,
  1960. .thresh62 = 28,
  1961. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1962. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1963. .switchcomspdt = 0,
  1964. .xlna_bias_strength = 0,
  1965. .futureModal = {
  1966. 0, 0, 0, 0, 0, 0, 0,
  1967. },
  1968. },
  1969. .base_ext2 = {
  1970. .tempSlopeLow = 72,
  1971. .tempSlopeHigh = 105,
  1972. .xatten1DBLow = {0x10, 0x14, 0x10},
  1973. .xatten1MarginLow = {0x19, 0x19 , 0x19},
  1974. .xatten1DBHigh = {0x1d, 0x20, 0x24},
  1975. .xatten1MarginHigh = {0x10, 0x10, 0x10}
  1976. },
  1977. .calFreqPier5G = {
  1978. FREQ2FBIN(5180, 0),
  1979. FREQ2FBIN(5220, 0),
  1980. FREQ2FBIN(5320, 0),
  1981. FREQ2FBIN(5400, 0),
  1982. FREQ2FBIN(5500, 0),
  1983. FREQ2FBIN(5600, 0),
  1984. FREQ2FBIN(5700, 0),
  1985. FREQ2FBIN(5785, 0)
  1986. },
  1987. .calPierData5G = {
  1988. {
  1989. {0, 0, 0, 0, 0},
  1990. {0, 0, 0, 0, 0},
  1991. {0, 0, 0, 0, 0},
  1992. {0, 0, 0, 0, 0},
  1993. {0, 0, 0, 0, 0},
  1994. {0, 0, 0, 0, 0},
  1995. {0, 0, 0, 0, 0},
  1996. {0, 0, 0, 0, 0},
  1997. },
  1998. {
  1999. {0, 0, 0, 0, 0},
  2000. {0, 0, 0, 0, 0},
  2001. {0, 0, 0, 0, 0},
  2002. {0, 0, 0, 0, 0},
  2003. {0, 0, 0, 0, 0},
  2004. {0, 0, 0, 0, 0},
  2005. {0, 0, 0, 0, 0},
  2006. {0, 0, 0, 0, 0},
  2007. },
  2008. {
  2009. {0, 0, 0, 0, 0},
  2010. {0, 0, 0, 0, 0},
  2011. {0, 0, 0, 0, 0},
  2012. {0, 0, 0, 0, 0},
  2013. {0, 0, 0, 0, 0},
  2014. {0, 0, 0, 0, 0},
  2015. {0, 0, 0, 0, 0},
  2016. {0, 0, 0, 0, 0},
  2017. },
  2018. },
  2019. .calTarget_freqbin_5G = {
  2020. FREQ2FBIN(5180, 0),
  2021. FREQ2FBIN(5220, 0),
  2022. FREQ2FBIN(5320, 0),
  2023. FREQ2FBIN(5400, 0),
  2024. FREQ2FBIN(5500, 0),
  2025. FREQ2FBIN(5600, 0),
  2026. FREQ2FBIN(5725, 0),
  2027. FREQ2FBIN(5825, 0)
  2028. },
  2029. .calTarget_freqbin_5GHT20 = {
  2030. FREQ2FBIN(5180, 0),
  2031. FREQ2FBIN(5220, 0),
  2032. FREQ2FBIN(5320, 0),
  2033. FREQ2FBIN(5400, 0),
  2034. FREQ2FBIN(5500, 0),
  2035. FREQ2FBIN(5600, 0),
  2036. FREQ2FBIN(5725, 0),
  2037. FREQ2FBIN(5825, 0)
  2038. },
  2039. .calTarget_freqbin_5GHT40 = {
  2040. FREQ2FBIN(5180, 0),
  2041. FREQ2FBIN(5220, 0),
  2042. FREQ2FBIN(5320, 0),
  2043. FREQ2FBIN(5400, 0),
  2044. FREQ2FBIN(5500, 0),
  2045. FREQ2FBIN(5600, 0),
  2046. FREQ2FBIN(5725, 0),
  2047. FREQ2FBIN(5825, 0)
  2048. },
  2049. .calTargetPower5G = {
  2050. /* 6-24,36,48,54 */
  2051. { {32, 32, 28, 26} },
  2052. { {32, 32, 28, 26} },
  2053. { {32, 32, 28, 26} },
  2054. { {32, 32, 26, 24} },
  2055. { {32, 32, 26, 24} },
  2056. { {32, 32, 24, 22} },
  2057. { {30, 30, 24, 22} },
  2058. { {30, 30, 24, 22} },
  2059. },
  2060. .calTargetPower5GHT20 = {
  2061. /*
  2062. * 0_8_16,1-3_9-11_17-19,
  2063. * 4,5,6,7,12,13,14,15,20,21,22,23
  2064. */
  2065. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2066. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2067. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2068. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} },
  2069. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} },
  2070. { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} },
  2071. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2072. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2073. },
  2074. .calTargetPower5GHT40 = {
  2075. /*
  2076. * 0_8_16,1-3_9-11_17-19,
  2077. * 4,5,6,7,12,13,14,15,20,21,22,23
  2078. */
  2079. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2080. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2081. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2082. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} },
  2083. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} },
  2084. { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2085. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2086. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2087. },
  2088. .ctlIndex_5G = {
  2089. 0x10, 0x16, 0x18, 0x40, 0x46,
  2090. 0x48, 0x30, 0x36, 0x38
  2091. },
  2092. .ctl_freqbin_5G = {
  2093. {
  2094. /* Data[0].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2095. /* Data[0].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2096. /* Data[0].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2097. /* Data[0].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2098. /* Data[0].ctledges[4].bchannel */ FREQ2FBIN(5600, 0),
  2099. /* Data[0].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2100. /* Data[0].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2101. /* Data[0].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2102. },
  2103. {
  2104. /* Data[1].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2105. /* Data[1].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2106. /* Data[1].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2107. /* Data[1].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2108. /* Data[1].ctledges[4].bchannel */ FREQ2FBIN(5520, 0),
  2109. /* Data[1].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2110. /* Data[1].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2111. /* Data[1].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2112. },
  2113. {
  2114. /* Data[2].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2115. /* Data[2].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2116. /* Data[2].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2117. /* Data[2].ctledges[3].bchannel */ FREQ2FBIN(5310, 0),
  2118. /* Data[2].ctledges[4].bchannel */ FREQ2FBIN(5510, 0),
  2119. /* Data[2].ctledges[5].bchannel */ FREQ2FBIN(5550, 0),
  2120. /* Data[2].ctledges[6].bchannel */ FREQ2FBIN(5670, 0),
  2121. /* Data[2].ctledges[7].bchannel */ FREQ2FBIN(5755, 0)
  2122. },
  2123. {
  2124. /* Data[3].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2125. /* Data[3].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2126. /* Data[3].ctledges[2].bchannel */ FREQ2FBIN(5260, 0),
  2127. /* Data[3].ctledges[3].bchannel */ FREQ2FBIN(5320, 0),
  2128. /* Data[3].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2129. /* Data[3].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2130. /* Data[3].ctledges[6].bchannel */ 0xFF,
  2131. /* Data[3].ctledges[7].bchannel */ 0xFF,
  2132. },
  2133. {
  2134. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2135. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2136. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(5500, 0),
  2137. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(5700, 0),
  2138. /* Data[4].ctledges[4].bchannel */ 0xFF,
  2139. /* Data[4].ctledges[5].bchannel */ 0xFF,
  2140. /* Data[4].ctledges[6].bchannel */ 0xFF,
  2141. /* Data[4].ctledges[7].bchannel */ 0xFF,
  2142. },
  2143. {
  2144. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2145. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(5270, 0),
  2146. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(5310, 0),
  2147. /* Data[5].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2148. /* Data[5].ctledges[4].bchannel */ FREQ2FBIN(5590, 0),
  2149. /* Data[5].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2150. /* Data[5].ctledges[6].bchannel */ 0xFF,
  2151. /* Data[5].ctledges[7].bchannel */ 0xFF
  2152. },
  2153. {
  2154. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2155. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2156. /* Data[6].ctledges[2].bchannel */ FREQ2FBIN(5220, 0),
  2157. /* Data[6].ctledges[3].bchannel */ FREQ2FBIN(5260, 0),
  2158. /* Data[6].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2159. /* Data[6].ctledges[5].bchannel */ FREQ2FBIN(5600, 0),
  2160. /* Data[6].ctledges[6].bchannel */ FREQ2FBIN(5700, 0),
  2161. /* Data[6].ctledges[7].bchannel */ FREQ2FBIN(5745, 0)
  2162. },
  2163. {
  2164. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2165. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2166. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(5320, 0),
  2167. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2168. /* Data[7].ctledges[4].bchannel */ FREQ2FBIN(5560, 0),
  2169. /* Data[7].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2170. /* Data[7].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2171. /* Data[7].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2172. },
  2173. {
  2174. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2175. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2176. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2177. /* Data[8].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2178. /* Data[8].ctledges[4].bchannel */ FREQ2FBIN(5550, 0),
  2179. /* Data[8].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2180. /* Data[8].ctledges[6].bchannel */ FREQ2FBIN(5755, 0),
  2181. /* Data[8].ctledges[7].bchannel */ FREQ2FBIN(5795, 0)
  2182. }
  2183. },
  2184. .ctlPowerData_5G = {
  2185. {
  2186. {
  2187. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2188. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2189. }
  2190. },
  2191. {
  2192. {
  2193. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2194. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2195. }
  2196. },
  2197. {
  2198. {
  2199. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2200. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2201. }
  2202. },
  2203. {
  2204. {
  2205. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2206. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2207. }
  2208. },
  2209. {
  2210. {
  2211. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2212. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2213. }
  2214. },
  2215. {
  2216. {
  2217. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2218. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2219. }
  2220. },
  2221. {
  2222. {
  2223. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2224. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2225. }
  2226. },
  2227. {
  2228. {
  2229. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2230. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2231. }
  2232. },
  2233. {
  2234. {
  2235. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2236. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2237. }
  2238. },
  2239. }
  2240. };
  2241. static const struct ar9300_eeprom ar9300_h116 = {
  2242. .eepromVersion = 2,
  2243. .templateVersion = 4,
  2244. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  2245. .custData = {"h116-041-f0000"},
  2246. .baseEepHeader = {
  2247. .regDmn = { LE16(0), LE16(0x1f) },
  2248. .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
  2249. .opCapFlags = {
  2250. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  2251. .eepMisc = 0,
  2252. },
  2253. .rfSilent = 0,
  2254. .blueToothOptions = 0,
  2255. .deviceCap = 0,
  2256. .deviceType = 5, /* takes lower byte in eeprom location */
  2257. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  2258. .params_for_tuning_caps = {0, 0},
  2259. .featureEnable = 0x0d,
  2260. /*
  2261. * bit0 - enable tx temp comp - disabled
  2262. * bit1 - enable tx volt comp - disabled
  2263. * bit2 - enable fastClock - enabled
  2264. * bit3 - enable doubling - enabled
  2265. * bit4 - enable internal regulator - disabled
  2266. * bit5 - enable pa predistortion - disabled
  2267. */
  2268. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  2269. .eepromWriteEnableGpio = 6,
  2270. .wlanDisableGpio = 0,
  2271. .wlanLedGpio = 8,
  2272. .rxBandSelectGpio = 0xff,
  2273. .txrxgain = 0x10,
  2274. .swreg = 0,
  2275. },
  2276. .modalHeader2G = {
  2277. /* ar9300_modal_eep_header 2g */
  2278. /* 4 idle,t1,t2,b(4 bits per setting) */
  2279. .antCtrlCommon = LE32(0x110),
  2280. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  2281. .antCtrlCommon2 = LE32(0x44444),
  2282. /*
  2283. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  2284. * rx1, rx12, b (2 bits each)
  2285. */
  2286. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  2287. /*
  2288. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  2289. * for ar9280 (0xa20c/b20c 5:0)
  2290. */
  2291. .xatten1DB = {0x1f, 0x1f, 0x1f},
  2292. /*
  2293. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2294. * for ar9280 (0xa20c/b20c 16:12
  2295. */
  2296. .xatten1Margin = {0x12, 0x12, 0x12},
  2297. .tempSlope = 25,
  2298. .voltSlope = 0,
  2299. /*
  2300. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  2301. * channels in usual fbin coding format
  2302. */
  2303. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  2304. /*
  2305. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  2306. * if the register is per chain
  2307. */
  2308. .noiseFloorThreshCh = {-1, 0, 0},
  2309. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2310. .quick_drop = 0,
  2311. .xpaBiasLvl = 0,
  2312. .txFrameToDataStart = 0x0e,
  2313. .txFrameToPaOn = 0x0e,
  2314. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2315. .antennaGain = 0,
  2316. .switchSettling = 0x2c,
  2317. .adcDesiredSize = -30,
  2318. .txEndToXpaOff = 0,
  2319. .txEndToRxOn = 0x2,
  2320. .txFrameToXpaOn = 0xe,
  2321. .thresh62 = 28,
  2322. .papdRateMaskHt20 = LE32(0x0c80C080),
  2323. .papdRateMaskHt40 = LE32(0x0080C080),
  2324. .switchcomspdt = 0,
  2325. .xlna_bias_strength = 0,
  2326. .futureModal = {
  2327. 0, 0, 0, 0, 0, 0, 0,
  2328. },
  2329. },
  2330. .base_ext1 = {
  2331. .ant_div_control = 0,
  2332. .future = {0, 0},
  2333. .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
  2334. },
  2335. .calFreqPier2G = {
  2336. FREQ2FBIN(2412, 1),
  2337. FREQ2FBIN(2437, 1),
  2338. FREQ2FBIN(2462, 1),
  2339. },
  2340. /* ar9300_cal_data_per_freq_op_loop 2g */
  2341. .calPierData2G = {
  2342. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2343. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2344. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2345. },
  2346. .calTarget_freqbin_Cck = {
  2347. FREQ2FBIN(2412, 1),
  2348. FREQ2FBIN(2472, 1),
  2349. },
  2350. .calTarget_freqbin_2G = {
  2351. FREQ2FBIN(2412, 1),
  2352. FREQ2FBIN(2437, 1),
  2353. FREQ2FBIN(2472, 1)
  2354. },
  2355. .calTarget_freqbin_2GHT20 = {
  2356. FREQ2FBIN(2412, 1),
  2357. FREQ2FBIN(2437, 1),
  2358. FREQ2FBIN(2472, 1)
  2359. },
  2360. .calTarget_freqbin_2GHT40 = {
  2361. FREQ2FBIN(2412, 1),
  2362. FREQ2FBIN(2437, 1),
  2363. FREQ2FBIN(2472, 1)
  2364. },
  2365. .calTargetPowerCck = {
  2366. /* 1L-5L,5S,11L,11S */
  2367. { {34, 34, 34, 34} },
  2368. { {34, 34, 34, 34} },
  2369. },
  2370. .calTargetPower2G = {
  2371. /* 6-24,36,48,54 */
  2372. { {34, 34, 32, 32} },
  2373. { {34, 34, 32, 32} },
  2374. { {34, 34, 32, 32} },
  2375. },
  2376. .calTargetPower2GHT20 = {
  2377. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2378. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2379. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2380. },
  2381. .calTargetPower2GHT40 = {
  2382. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2383. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2384. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2385. },
  2386. .ctlIndex_2G = {
  2387. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  2388. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  2389. },
  2390. .ctl_freqbin_2G = {
  2391. {
  2392. FREQ2FBIN(2412, 1),
  2393. FREQ2FBIN(2417, 1),
  2394. FREQ2FBIN(2457, 1),
  2395. FREQ2FBIN(2462, 1)
  2396. },
  2397. {
  2398. FREQ2FBIN(2412, 1),
  2399. FREQ2FBIN(2417, 1),
  2400. FREQ2FBIN(2462, 1),
  2401. 0xFF,
  2402. },
  2403. {
  2404. FREQ2FBIN(2412, 1),
  2405. FREQ2FBIN(2417, 1),
  2406. FREQ2FBIN(2462, 1),
  2407. 0xFF,
  2408. },
  2409. {
  2410. FREQ2FBIN(2422, 1),
  2411. FREQ2FBIN(2427, 1),
  2412. FREQ2FBIN(2447, 1),
  2413. FREQ2FBIN(2452, 1)
  2414. },
  2415. {
  2416. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2417. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2418. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2419. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  2420. },
  2421. {
  2422. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2423. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2424. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2425. 0,
  2426. },
  2427. {
  2428. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2429. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2430. FREQ2FBIN(2472, 1),
  2431. 0,
  2432. },
  2433. {
  2434. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2435. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2436. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2437. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2438. },
  2439. {
  2440. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2441. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2442. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2443. },
  2444. {
  2445. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2446. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2447. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2448. 0
  2449. },
  2450. {
  2451. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2452. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2453. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2454. 0
  2455. },
  2456. {
  2457. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2458. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2459. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2460. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2461. }
  2462. },
  2463. .ctlPowerData_2G = {
  2464. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2465. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2466. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  2467. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  2468. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2469. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2470. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  2471. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2472. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2473. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2474. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2475. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2476. },
  2477. .modalHeader5G = {
  2478. /* 4 idle,t1,t2,b (4 bits per setting) */
  2479. .antCtrlCommon = LE32(0x220),
  2480. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  2481. .antCtrlCommon2 = LE32(0x44444),
  2482. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  2483. .antCtrlChain = {
  2484. LE16(0x150), LE16(0x150), LE16(0x150),
  2485. },
  2486. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  2487. .xatten1DB = {0x19, 0x19, 0x19},
  2488. /*
  2489. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2490. * for merlin (0xa20c/b20c 16:12
  2491. */
  2492. .xatten1Margin = {0x14, 0x14, 0x14},
  2493. .tempSlope = 70,
  2494. .voltSlope = 0,
  2495. /* spurChans spur channels in usual fbin coding format */
  2496. .spurChans = {0, 0, 0, 0, 0},
  2497. /* noiseFloorThreshCh Check if the register is per chain */
  2498. .noiseFloorThreshCh = {-1, 0, 0},
  2499. .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2500. .quick_drop = 0,
  2501. .xpaBiasLvl = 0,
  2502. .txFrameToDataStart = 0x0e,
  2503. .txFrameToPaOn = 0x0e,
  2504. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2505. .antennaGain = 0,
  2506. .switchSettling = 0x2d,
  2507. .adcDesiredSize = -30,
  2508. .txEndToXpaOff = 0,
  2509. .txEndToRxOn = 0x2,
  2510. .txFrameToXpaOn = 0xe,
  2511. .thresh62 = 28,
  2512. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  2513. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  2514. .switchcomspdt = 0,
  2515. .xlna_bias_strength = 0,
  2516. .futureModal = {
  2517. 0, 0, 0, 0, 0, 0, 0,
  2518. },
  2519. },
  2520. .base_ext2 = {
  2521. .tempSlopeLow = 35,
  2522. .tempSlopeHigh = 50,
  2523. .xatten1DBLow = {0, 0, 0},
  2524. .xatten1MarginLow = {0, 0, 0},
  2525. .xatten1DBHigh = {0, 0, 0},
  2526. .xatten1MarginHigh = {0, 0, 0}
  2527. },
  2528. .calFreqPier5G = {
  2529. FREQ2FBIN(5160, 0),
  2530. FREQ2FBIN(5220, 0),
  2531. FREQ2FBIN(5320, 0),
  2532. FREQ2FBIN(5400, 0),
  2533. FREQ2FBIN(5500, 0),
  2534. FREQ2FBIN(5600, 0),
  2535. FREQ2FBIN(5700, 0),
  2536. FREQ2FBIN(5785, 0)
  2537. },
  2538. .calPierData5G = {
  2539. {
  2540. {0, 0, 0, 0, 0},
  2541. {0, 0, 0, 0, 0},
  2542. {0, 0, 0, 0, 0},
  2543. {0, 0, 0, 0, 0},
  2544. {0, 0, 0, 0, 0},
  2545. {0, 0, 0, 0, 0},
  2546. {0, 0, 0, 0, 0},
  2547. {0, 0, 0, 0, 0},
  2548. },
  2549. {
  2550. {0, 0, 0, 0, 0},
  2551. {0, 0, 0, 0, 0},
  2552. {0, 0, 0, 0, 0},
  2553. {0, 0, 0, 0, 0},
  2554. {0, 0, 0, 0, 0},
  2555. {0, 0, 0, 0, 0},
  2556. {0, 0, 0, 0, 0},
  2557. {0, 0, 0, 0, 0},
  2558. },
  2559. {
  2560. {0, 0, 0, 0, 0},
  2561. {0, 0, 0, 0, 0},
  2562. {0, 0, 0, 0, 0},
  2563. {0, 0, 0, 0, 0},
  2564. {0, 0, 0, 0, 0},
  2565. {0, 0, 0, 0, 0},
  2566. {0, 0, 0, 0, 0},
  2567. {0, 0, 0, 0, 0},
  2568. },
  2569. },
  2570. .calTarget_freqbin_5G = {
  2571. FREQ2FBIN(5180, 0),
  2572. FREQ2FBIN(5240, 0),
  2573. FREQ2FBIN(5320, 0),
  2574. FREQ2FBIN(5400, 0),
  2575. FREQ2FBIN(5500, 0),
  2576. FREQ2FBIN(5600, 0),
  2577. FREQ2FBIN(5700, 0),
  2578. FREQ2FBIN(5825, 0)
  2579. },
  2580. .calTarget_freqbin_5GHT20 = {
  2581. FREQ2FBIN(5180, 0),
  2582. FREQ2FBIN(5240, 0),
  2583. FREQ2FBIN(5320, 0),
  2584. FREQ2FBIN(5400, 0),
  2585. FREQ2FBIN(5500, 0),
  2586. FREQ2FBIN(5700, 0),
  2587. FREQ2FBIN(5745, 0),
  2588. FREQ2FBIN(5825, 0)
  2589. },
  2590. .calTarget_freqbin_5GHT40 = {
  2591. FREQ2FBIN(5180, 0),
  2592. FREQ2FBIN(5240, 0),
  2593. FREQ2FBIN(5320, 0),
  2594. FREQ2FBIN(5400, 0),
  2595. FREQ2FBIN(5500, 0),
  2596. FREQ2FBIN(5700, 0),
  2597. FREQ2FBIN(5745, 0),
  2598. FREQ2FBIN(5825, 0)
  2599. },
  2600. .calTargetPower5G = {
  2601. /* 6-24,36,48,54 */
  2602. { {30, 30, 28, 24} },
  2603. { {30, 30, 28, 24} },
  2604. { {30, 30, 28, 24} },
  2605. { {30, 30, 28, 24} },
  2606. { {30, 30, 28, 24} },
  2607. { {30, 30, 28, 24} },
  2608. { {30, 30, 28, 24} },
  2609. { {30, 30, 28, 24} },
  2610. },
  2611. .calTargetPower5GHT20 = {
  2612. /*
  2613. * 0_8_16,1-3_9-11_17-19,
  2614. * 4,5,6,7,12,13,14,15,20,21,22,23
  2615. */
  2616. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2617. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2618. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2619. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2620. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2621. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2622. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2623. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2624. },
  2625. .calTargetPower5GHT40 = {
  2626. /*
  2627. * 0_8_16,1-3_9-11_17-19,
  2628. * 4,5,6,7,12,13,14,15,20,21,22,23
  2629. */
  2630. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2631. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2632. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2633. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2634. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2635. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2636. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2637. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2638. },
  2639. .ctlIndex_5G = {
  2640. 0x10, 0x16, 0x18, 0x40, 0x46,
  2641. 0x48, 0x30, 0x36, 0x38
  2642. },
  2643. .ctl_freqbin_5G = {
  2644. {
  2645. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2646. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2647. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2648. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2649. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  2650. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2651. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2652. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2653. },
  2654. {
  2655. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2656. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2657. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2658. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2659. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  2660. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2661. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2662. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2663. },
  2664. {
  2665. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2666. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2667. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2668. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  2669. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  2670. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  2671. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  2672. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  2673. },
  2674. {
  2675. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2676. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2677. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  2678. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  2679. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2680. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2681. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  2682. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  2683. },
  2684. {
  2685. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2686. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2687. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  2688. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  2689. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  2690. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  2691. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  2692. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  2693. },
  2694. {
  2695. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2696. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  2697. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  2698. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2699. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  2700. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2701. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  2702. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  2703. },
  2704. {
  2705. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2706. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2707. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  2708. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  2709. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2710. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  2711. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  2712. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  2713. },
  2714. {
  2715. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2716. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2717. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  2718. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2719. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  2720. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2721. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2722. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2723. },
  2724. {
  2725. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2726. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2727. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2728. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2729. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  2730. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2731. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  2732. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  2733. }
  2734. },
  2735. .ctlPowerData_5G = {
  2736. {
  2737. {
  2738. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2739. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2740. }
  2741. },
  2742. {
  2743. {
  2744. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2745. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2746. }
  2747. },
  2748. {
  2749. {
  2750. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2751. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2752. }
  2753. },
  2754. {
  2755. {
  2756. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2757. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2758. }
  2759. },
  2760. {
  2761. {
  2762. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2763. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2764. }
  2765. },
  2766. {
  2767. {
  2768. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2769. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2770. }
  2771. },
  2772. {
  2773. {
  2774. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2775. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2776. }
  2777. },
  2778. {
  2779. {
  2780. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2781. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2782. }
  2783. },
  2784. {
  2785. {
  2786. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2787. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2788. }
  2789. },
  2790. }
  2791. };
  2792. static const struct ar9300_eeprom *ar9300_eep_templates[] = {
  2793. &ar9300_default,
  2794. &ar9300_x112,
  2795. &ar9300_h116,
  2796. &ar9300_h112,
  2797. &ar9300_x113,
  2798. };
  2799. static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
  2800. {
  2801. #define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0]))
  2802. int it;
  2803. for (it = 0; it < N_LOOP; it++)
  2804. if (ar9300_eep_templates[it]->templateVersion == id)
  2805. return ar9300_eep_templates[it];
  2806. return NULL;
  2807. #undef N_LOOP
  2808. }
  2809. static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
  2810. {
  2811. return 0;
  2812. }
  2813. static int interpolate(int x, int xa, int xb, int ya, int yb)
  2814. {
  2815. int bf, factor, plus;
  2816. bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
  2817. factor = bf / 2;
  2818. plus = bf % 2;
  2819. return ya + factor + plus;
  2820. }
  2821. static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
  2822. enum eeprom_param param)
  2823. {
  2824. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  2825. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  2826. switch (param) {
  2827. case EEP_MAC_LSW:
  2828. return get_unaligned_be16(eep->macAddr);
  2829. case EEP_MAC_MID:
  2830. return get_unaligned_be16(eep->macAddr + 2);
  2831. case EEP_MAC_MSW:
  2832. return get_unaligned_be16(eep->macAddr + 4);
  2833. case EEP_REG_0:
  2834. return le16_to_cpu(pBase->regDmn[0]);
  2835. case EEP_OP_CAP:
  2836. return pBase->deviceCap;
  2837. case EEP_OP_MODE:
  2838. return pBase->opCapFlags.opFlags;
  2839. case EEP_RF_SILENT:
  2840. return pBase->rfSilent;
  2841. case EEP_TX_MASK:
  2842. return (pBase->txrxMask >> 4) & 0xf;
  2843. case EEP_RX_MASK:
  2844. return pBase->txrxMask & 0xf;
  2845. case EEP_PAPRD:
  2846. return !!(pBase->featureEnable & BIT(5));
  2847. case EEP_CHAIN_MASK_REDUCE:
  2848. return (pBase->miscConfiguration >> 0x3) & 0x1;
  2849. case EEP_ANT_DIV_CTL1:
  2850. if (AR_SREV_9565(ah))
  2851. return AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE;
  2852. else
  2853. return eep->base_ext1.ant_div_control;
  2854. case EEP_ANTENNA_GAIN_5G:
  2855. return eep->modalHeader5G.antennaGain;
  2856. case EEP_ANTENNA_GAIN_2G:
  2857. return eep->modalHeader2G.antennaGain;
  2858. default:
  2859. return 0;
  2860. }
  2861. }
  2862. static bool ar9300_eeprom_read_byte(struct ath_hw *ah, int address,
  2863. u8 *buffer)
  2864. {
  2865. u16 val;
  2866. if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
  2867. return false;
  2868. *buffer = (val >> (8 * (address % 2))) & 0xff;
  2869. return true;
  2870. }
  2871. static bool ar9300_eeprom_read_word(struct ath_hw *ah, int address,
  2872. u8 *buffer)
  2873. {
  2874. u16 val;
  2875. if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
  2876. return false;
  2877. buffer[0] = val >> 8;
  2878. buffer[1] = val & 0xff;
  2879. return true;
  2880. }
  2881. static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
  2882. int count)
  2883. {
  2884. struct ath_common *common = ath9k_hw_common(ah);
  2885. int i;
  2886. if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
  2887. ath_dbg(common, EEPROM, "eeprom address not in range\n");
  2888. return false;
  2889. }
  2890. /*
  2891. * Since we're reading the bytes in reverse order from a little-endian
  2892. * word stream, an even address means we only use the lower half of
  2893. * the 16-bit word at that address
  2894. */
  2895. if (address % 2 == 0) {
  2896. if (!ar9300_eeprom_read_byte(ah, address--, buffer++))
  2897. goto error;
  2898. count--;
  2899. }
  2900. for (i = 0; i < count / 2; i++) {
  2901. if (!ar9300_eeprom_read_word(ah, address, buffer))
  2902. goto error;
  2903. address -= 2;
  2904. buffer += 2;
  2905. }
  2906. if (count % 2)
  2907. if (!ar9300_eeprom_read_byte(ah, address, buffer))
  2908. goto error;
  2909. return true;
  2910. error:
  2911. ath_dbg(common, EEPROM, "unable to read eeprom region at offset %d\n",
  2912. address);
  2913. return false;
  2914. }
  2915. static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data)
  2916. {
  2917. REG_READ(ah, AR9300_OTP_BASE + (4 * addr));
  2918. if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE,
  2919. AR9300_OTP_STATUS_VALID, 1000))
  2920. return false;
  2921. *data = REG_READ(ah, AR9300_OTP_READ_DATA);
  2922. return true;
  2923. }
  2924. static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer,
  2925. int count)
  2926. {
  2927. u32 data;
  2928. int i;
  2929. for (i = 0; i < count; i++) {
  2930. int offset = 8 * ((address - i) % 4);
  2931. if (!ar9300_otp_read_word(ah, (address - i) / 4, &data))
  2932. return false;
  2933. buffer[i] = (data >> offset) & 0xff;
  2934. }
  2935. return true;
  2936. }
  2937. static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
  2938. int *length, int *major, int *minor)
  2939. {
  2940. unsigned long value[4];
  2941. value[0] = best[0];
  2942. value[1] = best[1];
  2943. value[2] = best[2];
  2944. value[3] = best[3];
  2945. *code = ((value[0] >> 5) & 0x0007);
  2946. *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
  2947. *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
  2948. *major = (value[2] & 0x000f);
  2949. *minor = (value[3] & 0x00ff);
  2950. }
  2951. static u16 ar9300_comp_cksum(u8 *data, int dsize)
  2952. {
  2953. int it, checksum = 0;
  2954. for (it = 0; it < dsize; it++) {
  2955. checksum += data[it];
  2956. checksum &= 0xffff;
  2957. }
  2958. return checksum;
  2959. }
  2960. static bool ar9300_uncompress_block(struct ath_hw *ah,
  2961. u8 *mptr,
  2962. int mdataSize,
  2963. u8 *block,
  2964. int size)
  2965. {
  2966. int it;
  2967. int spot;
  2968. int offset;
  2969. int length;
  2970. struct ath_common *common = ath9k_hw_common(ah);
  2971. spot = 0;
  2972. for (it = 0; it < size; it += (length+2)) {
  2973. offset = block[it];
  2974. offset &= 0xff;
  2975. spot += offset;
  2976. length = block[it+1];
  2977. length &= 0xff;
  2978. if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
  2979. ath_dbg(common, EEPROM,
  2980. "Restore at %d: spot=%d offset=%d length=%d\n",
  2981. it, spot, offset, length);
  2982. memcpy(&mptr[spot], &block[it+2], length);
  2983. spot += length;
  2984. } else if (length > 0) {
  2985. ath_dbg(common, EEPROM,
  2986. "Bad restore at %d: spot=%d offset=%d length=%d\n",
  2987. it, spot, offset, length);
  2988. return false;
  2989. }
  2990. }
  2991. return true;
  2992. }
  2993. static int ar9300_compress_decision(struct ath_hw *ah,
  2994. int it,
  2995. int code,
  2996. int reference,
  2997. u8 *mptr,
  2998. u8 *word, int length, int mdata_size)
  2999. {
  3000. struct ath_common *common = ath9k_hw_common(ah);
  3001. const struct ar9300_eeprom *eep = NULL;
  3002. switch (code) {
  3003. case _CompressNone:
  3004. if (length != mdata_size) {
  3005. ath_dbg(common, EEPROM,
  3006. "EEPROM structure size mismatch memory=%d eeprom=%d\n",
  3007. mdata_size, length);
  3008. return -1;
  3009. }
  3010. memcpy(mptr, word + COMP_HDR_LEN, length);
  3011. ath_dbg(common, EEPROM,
  3012. "restored eeprom %d: uncompressed, length %d\n",
  3013. it, length);
  3014. break;
  3015. case _CompressBlock:
  3016. if (reference != 0) {
  3017. eep = ar9003_eeprom_struct_find_by_id(reference);
  3018. if (eep == NULL) {
  3019. ath_dbg(common, EEPROM,
  3020. "can't find reference eeprom struct %d\n",
  3021. reference);
  3022. return -1;
  3023. }
  3024. memcpy(mptr, eep, mdata_size);
  3025. }
  3026. ath_dbg(common, EEPROM,
  3027. "restore eeprom %d: block, reference %d, length %d\n",
  3028. it, reference, length);
  3029. ar9300_uncompress_block(ah, mptr, mdata_size,
  3030. (word + COMP_HDR_LEN), length);
  3031. break;
  3032. default:
  3033. ath_dbg(common, EEPROM, "unknown compression code %d\n", code);
  3034. return -1;
  3035. }
  3036. return 0;
  3037. }
  3038. typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer,
  3039. int count);
  3040. static bool ar9300_check_header(void *data)
  3041. {
  3042. u32 *word = data;
  3043. return !(*word == 0 || *word == ~0);
  3044. }
  3045. static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
  3046. int base_addr)
  3047. {
  3048. u8 header[4];
  3049. if (!read(ah, base_addr, header, 4))
  3050. return false;
  3051. return ar9300_check_header(header);
  3052. }
  3053. static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
  3054. int mdata_size)
  3055. {
  3056. u16 *data = (u16 *) mptr;
  3057. int i;
  3058. for (i = 0; i < mdata_size / 2; i++, data++)
  3059. if (!ath9k_hw_nvram_read(ah, i, data))
  3060. return -EIO;
  3061. return 0;
  3062. }
  3063. /*
  3064. * Read the configuration data from the eeprom.
  3065. * The data can be put in any specified memory buffer.
  3066. *
  3067. * Returns -1 on error.
  3068. * Returns address of next memory location on success.
  3069. */
  3070. static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
  3071. u8 *mptr, int mdata_size)
  3072. {
  3073. #define MDEFAULT 15
  3074. #define MSTATE 100
  3075. int cptr;
  3076. u8 *word;
  3077. int code;
  3078. int reference, length, major, minor;
  3079. int osize;
  3080. int it;
  3081. u16 checksum, mchecksum;
  3082. struct ath_common *common = ath9k_hw_common(ah);
  3083. struct ar9300_eeprom *eep;
  3084. eeprom_read_op read;
  3085. if (ath9k_hw_use_flash(ah)) {
  3086. u8 txrx;
  3087. if (ar9300_eeprom_restore_flash(ah, mptr, mdata_size))
  3088. return -EIO;
  3089. /* check if eeprom contains valid data */
  3090. eep = (struct ar9300_eeprom *) mptr;
  3091. txrx = eep->baseEepHeader.txrxMask;
  3092. if (txrx != 0 && txrx != 0xff)
  3093. return 0;
  3094. }
  3095. word = kzalloc(2048, GFP_KERNEL);
  3096. if (!word)
  3097. return -ENOMEM;
  3098. memcpy(mptr, &ar9300_default, mdata_size);
  3099. read = ar9300_read_eeprom;
  3100. if (AR_SREV_9485(ah))
  3101. cptr = AR9300_BASE_ADDR_4K;
  3102. else if (AR_SREV_9330(ah))
  3103. cptr = AR9300_BASE_ADDR_512;
  3104. else
  3105. cptr = AR9300_BASE_ADDR;
  3106. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3107. cptr);
  3108. if (ar9300_check_eeprom_header(ah, read, cptr))
  3109. goto found;
  3110. cptr = AR9300_BASE_ADDR_512;
  3111. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3112. cptr);
  3113. if (ar9300_check_eeprom_header(ah, read, cptr))
  3114. goto found;
  3115. read = ar9300_read_otp;
  3116. cptr = AR9300_BASE_ADDR;
  3117. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3118. if (ar9300_check_eeprom_header(ah, read, cptr))
  3119. goto found;
  3120. cptr = AR9300_BASE_ADDR_512;
  3121. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3122. if (ar9300_check_eeprom_header(ah, read, cptr))
  3123. goto found;
  3124. goto fail;
  3125. found:
  3126. ath_dbg(common, EEPROM, "Found valid EEPROM data\n");
  3127. for (it = 0; it < MSTATE; it++) {
  3128. if (!read(ah, cptr, word, COMP_HDR_LEN))
  3129. goto fail;
  3130. if (!ar9300_check_header(word))
  3131. break;
  3132. ar9300_comp_hdr_unpack(word, &code, &reference,
  3133. &length, &major, &minor);
  3134. ath_dbg(common, EEPROM,
  3135. "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
  3136. cptr, code, reference, length, major, minor);
  3137. if ((!AR_SREV_9485(ah) && length >= 1024) ||
  3138. (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
  3139. ath_dbg(common, EEPROM, "Skipping bad header\n");
  3140. cptr -= COMP_HDR_LEN;
  3141. continue;
  3142. }
  3143. osize = length;
  3144. read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3145. checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
  3146. mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]);
  3147. ath_dbg(common, EEPROM, "checksum %x %x\n",
  3148. checksum, mchecksum);
  3149. if (checksum == mchecksum) {
  3150. ar9300_compress_decision(ah, it, code, reference, mptr,
  3151. word, length, mdata_size);
  3152. } else {
  3153. ath_dbg(common, EEPROM,
  3154. "skipping block with bad checksum\n");
  3155. }
  3156. cptr -= (COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3157. }
  3158. kfree(word);
  3159. return cptr;
  3160. fail:
  3161. kfree(word);
  3162. return -1;
  3163. }
  3164. /*
  3165. * Restore the configuration structure by reading the eeprom.
  3166. * This function destroys any existing in-memory structure
  3167. * content.
  3168. */
  3169. static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
  3170. {
  3171. u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
  3172. if (ar9300_eeprom_restore_internal(ah, mptr,
  3173. sizeof(struct ar9300_eeprom)) < 0)
  3174. return false;
  3175. return true;
  3176. }
  3177. #if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
  3178. static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
  3179. struct ar9300_modal_eep_header *modal_hdr)
  3180. {
  3181. PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  3182. PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  3183. PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
  3184. PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  3185. PR_EEP("Ant. Common Control2", le32_to_cpu(modal_hdr->antCtrlCommon2));
  3186. PR_EEP("Ant. Gain", modal_hdr->antennaGain);
  3187. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  3188. PR_EEP("Chain0 xatten1DB", modal_hdr->xatten1DB[0]);
  3189. PR_EEP("Chain1 xatten1DB", modal_hdr->xatten1DB[1]);
  3190. PR_EEP("Chain2 xatten1DB", modal_hdr->xatten1DB[2]);
  3191. PR_EEP("Chain0 xatten1Margin", modal_hdr->xatten1Margin[0]);
  3192. PR_EEP("Chain1 xatten1Margin", modal_hdr->xatten1Margin[1]);
  3193. PR_EEP("Chain2 xatten1Margin", modal_hdr->xatten1Margin[2]);
  3194. PR_EEP("Temp Slope", modal_hdr->tempSlope);
  3195. PR_EEP("Volt Slope", modal_hdr->voltSlope);
  3196. PR_EEP("spur Channels0", modal_hdr->spurChans[0]);
  3197. PR_EEP("spur Channels1", modal_hdr->spurChans[1]);
  3198. PR_EEP("spur Channels2", modal_hdr->spurChans[2]);
  3199. PR_EEP("spur Channels3", modal_hdr->spurChans[3]);
  3200. PR_EEP("spur Channels4", modal_hdr->spurChans[4]);
  3201. PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
  3202. PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
  3203. PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
  3204. PR_EEP("Quick Drop", modal_hdr->quick_drop);
  3205. PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
  3206. PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
  3207. PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
  3208. PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
  3209. PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
  3210. PR_EEP("txClip", modal_hdr->txClip);
  3211. PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
  3212. return len;
  3213. }
  3214. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3215. u8 *buf, u32 len, u32 size)
  3216. {
  3217. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3218. struct ar9300_base_eep_hdr *pBase;
  3219. if (!dump_base_hdr) {
  3220. len += scnprintf(buf + len, size - len,
  3221. "%20s :\n", "2GHz modal Header");
  3222. len = ar9003_dump_modal_eeprom(buf, len, size,
  3223. &eep->modalHeader2G);
  3224. len += scnprintf(buf + len, size - len,
  3225. "%20s :\n", "5GHz modal Header");
  3226. len = ar9003_dump_modal_eeprom(buf, len, size,
  3227. &eep->modalHeader5G);
  3228. goto out;
  3229. }
  3230. pBase = &eep->baseEepHeader;
  3231. PR_EEP("EEPROM Version", ah->eeprom.ar9300_eep.eepromVersion);
  3232. PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  3233. PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  3234. PR_EEP("TX Mask", (pBase->txrxMask >> 4));
  3235. PR_EEP("RX Mask", (pBase->txrxMask & 0x0f));
  3236. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags.opFlags &
  3237. AR5416_OPFLAGS_11A));
  3238. PR_EEP("Allow 2GHz", !!(pBase->opCapFlags.opFlags &
  3239. AR5416_OPFLAGS_11G));
  3240. PR_EEP("Disable 2GHz HT20", !!(pBase->opCapFlags.opFlags &
  3241. AR5416_OPFLAGS_N_2G_HT20));
  3242. PR_EEP("Disable 2GHz HT40", !!(pBase->opCapFlags.opFlags &
  3243. AR5416_OPFLAGS_N_2G_HT40));
  3244. PR_EEP("Disable 5Ghz HT20", !!(pBase->opCapFlags.opFlags &
  3245. AR5416_OPFLAGS_N_5G_HT20));
  3246. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags &
  3247. AR5416_OPFLAGS_N_5G_HT40));
  3248. PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & 0x01));
  3249. PR_EEP("RF Silent", pBase->rfSilent);
  3250. PR_EEP("BT option", pBase->blueToothOptions);
  3251. PR_EEP("Device Cap", pBase->deviceCap);
  3252. PR_EEP("Device Type", pBase->deviceType);
  3253. PR_EEP("Power Table Offset", pBase->pwrTableOffset);
  3254. PR_EEP("Tuning Caps1", pBase->params_for_tuning_caps[0]);
  3255. PR_EEP("Tuning Caps2", pBase->params_for_tuning_caps[1]);
  3256. PR_EEP("Enable Tx Temp Comp", !!(pBase->featureEnable & BIT(0)));
  3257. PR_EEP("Enable Tx Volt Comp", !!(pBase->featureEnable & BIT(1)));
  3258. PR_EEP("Enable fast clock", !!(pBase->featureEnable & BIT(2)));
  3259. PR_EEP("Enable doubling", !!(pBase->featureEnable & BIT(3)));
  3260. PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4)));
  3261. PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5)));
  3262. PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0)));
  3263. PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1)));
  3264. PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1);
  3265. PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio);
  3266. PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio);
  3267. PR_EEP("WLAN LED Gpio", pBase->wlanLedGpio);
  3268. PR_EEP("Rx Band Select Gpio", pBase->rxBandSelectGpio);
  3269. PR_EEP("Tx Gain", pBase->txrxgain >> 4);
  3270. PR_EEP("Rx Gain", pBase->txrxgain & 0xf);
  3271. PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));
  3272. len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  3273. ah->eeprom.ar9300_eep.macAddr);
  3274. out:
  3275. if (len > size)
  3276. len = size;
  3277. return len;
  3278. }
  3279. #else
  3280. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3281. u8 *buf, u32 len, u32 size)
  3282. {
  3283. return 0;
  3284. }
  3285. #endif
  3286. /* XXX: review hardware docs */
  3287. static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
  3288. {
  3289. return ah->eeprom.ar9300_eep.eepromVersion;
  3290. }
  3291. /* XXX: could be read from the eepromVersion, not sure yet */
  3292. static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
  3293. {
  3294. return 0;
  3295. }
  3296. static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
  3297. bool is2ghz)
  3298. {
  3299. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3300. if (is2ghz)
  3301. return &eep->modalHeader2G;
  3302. else
  3303. return &eep->modalHeader5G;
  3304. }
  3305. static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
  3306. {
  3307. int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
  3308. if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
  3309. AR_SREV_9531(ah) || AR_SREV_9561(ah))
  3310. REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
  3311. else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
  3312. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3313. else {
  3314. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3315. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3316. AR_CH0_THERM_XPABIASLVL_MSB,
  3317. bias >> 2);
  3318. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3319. AR_CH0_THERM_XPASHORT2GND, 1);
  3320. }
  3321. }
  3322. static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
  3323. {
  3324. return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
  3325. }
  3326. u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
  3327. {
  3328. return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
  3329. }
  3330. u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
  3331. {
  3332. return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
  3333. }
  3334. static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
  3335. bool is2ghz)
  3336. {
  3337. __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain];
  3338. return le16_to_cpu(val);
  3339. }
  3340. static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
  3341. {
  3342. struct ath_common *common = ath9k_hw_common(ah);
  3343. struct ath9k_hw_capabilities *pCap = &ah->caps;
  3344. int chain;
  3345. u32 regval, value, gpio;
  3346. static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
  3347. AR_PHY_SWITCH_CHAIN_0,
  3348. AR_PHY_SWITCH_CHAIN_1,
  3349. AR_PHY_SWITCH_CHAIN_2,
  3350. };
  3351. if (AR_SREV_9485(ah) && (ar9003_hw_get_rx_gain_idx(ah) == 0)) {
  3352. if (ah->config.xlna_gpio)
  3353. gpio = ah->config.xlna_gpio;
  3354. else
  3355. gpio = AR9300_EXT_LNA_CTL_GPIO_AR9485;
  3356. ath9k_hw_gpio_request_out(ah, gpio, NULL,
  3357. AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED);
  3358. }
  3359. value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz);
  3360. if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
  3361. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3362. AR_SWITCH_TABLE_COM_AR9462_ALL, value);
  3363. } else if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
  3364. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3365. AR_SWITCH_TABLE_COM_AR9550_ALL, value);
  3366. } else
  3367. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3368. AR_SWITCH_TABLE_COM_ALL, value);
  3369. /*
  3370. * AR9462 defines new switch table for BT/WLAN,
  3371. * here's new field name in XXX.ref for both 2G and 5G.
  3372. * Register: [GLB_CONTROL] GLB_CONTROL (@0x20044)
  3373. * 15:12 R/W SWITCH_TABLE_COM_SPDT_WLAN_RX
  3374. * SWITCH_TABLE_COM_SPDT_WLAN_RX
  3375. *
  3376. * 11:8 R/W SWITCH_TABLE_COM_SPDT_WLAN_TX
  3377. * SWITCH_TABLE_COM_SPDT_WLAN_TX
  3378. *
  3379. * 7:4 R/W SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3380. * SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3381. */
  3382. if (AR_SREV_9462_20_OR_LATER(ah) || AR_SREV_9565(ah)) {
  3383. value = ar9003_switch_com_spdt_get(ah, is2ghz);
  3384. REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL,
  3385. AR_SWITCH_TABLE_COM_SPDT_ALL, value);
  3386. REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, AR_BTCOEX_CTRL_SPDT_ENABLE);
  3387. }
  3388. value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
  3389. if (AR_SREV_9485(ah) && common->bt_ant_diversity) {
  3390. value &= ~AR_SWITCH_TABLE_COM2_ALL;
  3391. value |= ah->config.ant_ctrl_comm2g_switch_enable;
  3392. }
  3393. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
  3394. if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
  3395. value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
  3396. REG_RMW_FIELD(ah, switch_chain_reg[0],
  3397. AR_SWITCH_TABLE_ALL, value);
  3398. }
  3399. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  3400. if ((ah->rxchainmask & BIT(chain)) ||
  3401. (ah->txchainmask & BIT(chain))) {
  3402. value = ar9003_hw_ant_ctrl_chain_get(ah, chain,
  3403. is2ghz);
  3404. REG_RMW_FIELD(ah, switch_chain_reg[chain],
  3405. AR_SWITCH_TABLE_ALL, value);
  3406. }
  3407. }
  3408. if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
  3409. value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
  3410. /*
  3411. * main_lnaconf, alt_lnaconf, main_tb, alt_tb
  3412. * are the fields present
  3413. */
  3414. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3415. regval &= (~AR_ANT_DIV_CTRL_ALL);
  3416. regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
  3417. /* enable_lnadiv */
  3418. regval &= (~AR_PHY_ANT_DIV_LNADIV);
  3419. regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
  3420. if (AR_SREV_9485(ah) && common->bt_ant_diversity)
  3421. regval |= AR_ANT_DIV_ENABLE;
  3422. if (AR_SREV_9565(ah)) {
  3423. if (common->bt_ant_diversity) {
  3424. regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
  3425. REG_SET_BIT(ah, AR_PHY_RESTART,
  3426. AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
  3427. /* Force WLAN LNA diversity ON */
  3428. REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
  3429. AR_BTCOEX_WL_LNADIV_FORCE_ON);
  3430. } else {
  3431. regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
  3432. regval &= ~(1 << AR_PHY_ANT_SW_RX_PROT_S);
  3433. REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
  3434. (1 << AR_PHY_ANT_SW_RX_PROT_S));
  3435. /* Force WLAN LNA diversity OFF */
  3436. REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
  3437. AR_BTCOEX_WL_LNADIV_FORCE_ON);
  3438. }
  3439. }
  3440. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3441. /* enable fast_div */
  3442. regval = REG_READ(ah, AR_PHY_CCK_DETECT);
  3443. regval &= (~AR_FAST_DIV_ENABLE);
  3444. regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
  3445. if ((AR_SREV_9485(ah) || AR_SREV_9565(ah))
  3446. && common->bt_ant_diversity)
  3447. regval |= AR_FAST_DIV_ENABLE;
  3448. REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
  3449. if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
  3450. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3451. /*
  3452. * clear bits 25-30 main_lnaconf, alt_lnaconf,
  3453. * main_tb, alt_tb
  3454. */
  3455. regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
  3456. AR_PHY_ANT_DIV_ALT_LNACONF |
  3457. AR_PHY_ANT_DIV_ALT_GAINTB |
  3458. AR_PHY_ANT_DIV_MAIN_GAINTB));
  3459. /* by default use LNA1 for the main antenna */
  3460. regval |= (ATH_ANT_DIV_COMB_LNA1 <<
  3461. AR_PHY_ANT_DIV_MAIN_LNACONF_S);
  3462. regval |= (ATH_ANT_DIV_COMB_LNA2 <<
  3463. AR_PHY_ANT_DIV_ALT_LNACONF_S);
  3464. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3465. }
  3466. }
  3467. }
  3468. static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
  3469. {
  3470. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3471. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3472. int drive_strength;
  3473. unsigned long reg;
  3474. drive_strength = pBase->miscConfiguration & BIT(0);
  3475. if (!drive_strength)
  3476. return;
  3477. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS1);
  3478. reg &= ~0x00ffffc0;
  3479. reg |= 0x5 << 21;
  3480. reg |= 0x5 << 18;
  3481. reg |= 0x5 << 15;
  3482. reg |= 0x5 << 12;
  3483. reg |= 0x5 << 9;
  3484. reg |= 0x5 << 6;
  3485. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS1, reg);
  3486. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS2);
  3487. reg &= ~0xffffffe0;
  3488. reg |= 0x5 << 29;
  3489. reg |= 0x5 << 26;
  3490. reg |= 0x5 << 23;
  3491. reg |= 0x5 << 20;
  3492. reg |= 0x5 << 17;
  3493. reg |= 0x5 << 14;
  3494. reg |= 0x5 << 11;
  3495. reg |= 0x5 << 8;
  3496. reg |= 0x5 << 5;
  3497. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS2, reg);
  3498. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS4);
  3499. reg &= ~0xff800000;
  3500. reg |= 0x5 << 29;
  3501. reg |= 0x5 << 26;
  3502. reg |= 0x5 << 23;
  3503. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS4, reg);
  3504. }
  3505. static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain,
  3506. struct ath9k_channel *chan)
  3507. {
  3508. int f[3], t[3];
  3509. u16 value;
  3510. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3511. if (chain >= 0 && chain < 3) {
  3512. if (IS_CHAN_2GHZ(chan))
  3513. return eep->modalHeader2G.xatten1DB[chain];
  3514. else if (eep->base_ext2.xatten1DBLow[chain] != 0) {
  3515. t[0] = eep->base_ext2.xatten1DBLow[chain];
  3516. f[0] = 5180;
  3517. t[1] = eep->modalHeader5G.xatten1DB[chain];
  3518. f[1] = 5500;
  3519. t[2] = eep->base_ext2.xatten1DBHigh[chain];
  3520. f[2] = 5785;
  3521. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3522. f, t, 3);
  3523. return value;
  3524. } else
  3525. return eep->modalHeader5G.xatten1DB[chain];
  3526. }
  3527. return 0;
  3528. }
  3529. static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain,
  3530. struct ath9k_channel *chan)
  3531. {
  3532. int f[3], t[3];
  3533. u16 value;
  3534. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3535. if (chain >= 0 && chain < 3) {
  3536. if (IS_CHAN_2GHZ(chan))
  3537. return eep->modalHeader2G.xatten1Margin[chain];
  3538. else if (eep->base_ext2.xatten1MarginLow[chain] != 0) {
  3539. t[0] = eep->base_ext2.xatten1MarginLow[chain];
  3540. f[0] = 5180;
  3541. t[1] = eep->modalHeader5G.xatten1Margin[chain];
  3542. f[1] = 5500;
  3543. t[2] = eep->base_ext2.xatten1MarginHigh[chain];
  3544. f[2] = 5785;
  3545. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3546. f, t, 3);
  3547. return value;
  3548. } else
  3549. return eep->modalHeader5G.xatten1Margin[chain];
  3550. }
  3551. return 0;
  3552. }
  3553. static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan)
  3554. {
  3555. int i;
  3556. u16 value;
  3557. unsigned long ext_atten_reg[3] = {AR_PHY_EXT_ATTEN_CTL_0,
  3558. AR_PHY_EXT_ATTEN_CTL_1,
  3559. AR_PHY_EXT_ATTEN_CTL_2,
  3560. };
  3561. if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
  3562. value = ar9003_hw_atten_chain_get(ah, 1, chan);
  3563. REG_RMW_FIELD(ah, ext_atten_reg[0],
  3564. AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
  3565. value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
  3566. REG_RMW_FIELD(ah, ext_atten_reg[0],
  3567. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3568. value);
  3569. }
  3570. /* Test value. if 0 then attenuation is unused. Don't load anything. */
  3571. for (i = 0; i < 3; i++) {
  3572. if (ah->txchainmask & BIT(i)) {
  3573. value = ar9003_hw_atten_chain_get(ah, i, chan);
  3574. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3575. AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
  3576. if (AR_SREV_9485(ah) &&
  3577. (ar9003_hw_get_rx_gain_idx(ah) == 0) &&
  3578. ah->config.xatten_margin_cfg)
  3579. value = 5;
  3580. else
  3581. value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
  3582. if (ah->config.alt_mingainidx)
  3583. REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0,
  3584. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3585. value);
  3586. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3587. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3588. value);
  3589. }
  3590. }
  3591. }
  3592. static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set)
  3593. {
  3594. int timeout = 100;
  3595. while (pmu_set != REG_READ(ah, pmu_reg)) {
  3596. if (timeout-- == 0)
  3597. return false;
  3598. REG_WRITE(ah, pmu_reg, pmu_set);
  3599. udelay(10);
  3600. }
  3601. return true;
  3602. }
  3603. void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
  3604. {
  3605. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3606. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3607. u32 reg_val;
  3608. if (pBase->featureEnable & BIT(4)) {
  3609. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3610. int reg_pmu_set;
  3611. reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM;
  3612. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3613. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3614. return;
  3615. if (AR_SREV_9330(ah)) {
  3616. if (ah->is_clk_25mhz) {
  3617. reg_pmu_set = (3 << 1) | (8 << 4) |
  3618. (3 << 8) | (1 << 14) |
  3619. (6 << 17) | (1 << 20) |
  3620. (3 << 24);
  3621. } else {
  3622. reg_pmu_set = (4 << 1) | (7 << 4) |
  3623. (3 << 8) | (1 << 14) |
  3624. (6 << 17) | (1 << 20) |
  3625. (3 << 24);
  3626. }
  3627. } else {
  3628. reg_pmu_set = (5 << 1) | (7 << 4) |
  3629. (2 << 8) | (2 << 14) |
  3630. (6 << 17) | (1 << 20) |
  3631. (3 << 24) | (1 << 28);
  3632. }
  3633. REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set);
  3634. if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set))
  3635. return;
  3636. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0xFFC00000)
  3637. | (4 << 26);
  3638. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3639. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3640. return;
  3641. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0x00200000)
  3642. | (1 << 21);
  3643. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3644. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3645. return;
  3646. } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah) ||
  3647. AR_SREV_9561(ah)) {
  3648. reg_val = le32_to_cpu(pBase->swreg);
  3649. REG_WRITE(ah, AR_PHY_PMU1, reg_val);
  3650. if (AR_SREV_9561(ah))
  3651. REG_WRITE(ah, AR_PHY_PMU2, 0x10200000);
  3652. } else {
  3653. /* Internal regulator is ON. Write swreg register. */
  3654. reg_val = le32_to_cpu(pBase->swreg);
  3655. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3656. REG_READ(ah, AR_RTC_REG_CONTROL1) &
  3657. (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM));
  3658. REG_WRITE(ah, AR_RTC_REG_CONTROL0, reg_val);
  3659. /* Set REG_CONTROL1.SWREG_PROGRAM */
  3660. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3661. REG_READ(ah,
  3662. AR_RTC_REG_CONTROL1) |
  3663. AR_RTC_REG_CONTROL1_SWREG_PROGRAM);
  3664. }
  3665. } else {
  3666. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3667. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0);
  3668. while (REG_READ_FIELD(ah, AR_PHY_PMU2,
  3669. AR_PHY_PMU2_PGM))
  3670. udelay(10);
  3671. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3672. while (!REG_READ_FIELD(ah, AR_PHY_PMU1,
  3673. AR_PHY_PMU1_PWD))
  3674. udelay(10);
  3675. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0x1);
  3676. while (!REG_READ_FIELD(ah, AR_PHY_PMU2,
  3677. AR_PHY_PMU2_PGM))
  3678. udelay(10);
  3679. } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
  3680. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3681. else {
  3682. reg_val = REG_READ(ah, AR_RTC_SLEEP_CLK) |
  3683. AR_RTC_FORCE_SWREG_PRD;
  3684. REG_WRITE(ah, AR_RTC_SLEEP_CLK, reg_val);
  3685. }
  3686. }
  3687. }
  3688. static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)
  3689. {
  3690. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3691. u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0];
  3692. if (AR_SREV_9340(ah) || AR_SREV_9531(ah))
  3693. return;
  3694. if (eep->baseEepHeader.featureEnable & 0x40) {
  3695. tuning_caps_param &= 0x7f;
  3696. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC,
  3697. tuning_caps_param);
  3698. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPOUTDAC,
  3699. tuning_caps_param);
  3700. }
  3701. }
  3702. static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
  3703. {
  3704. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3705. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3706. int quick_drop;
  3707. s32 t[3], f[3] = {5180, 5500, 5785};
  3708. if (!(pBase->miscConfiguration & BIT(4)))
  3709. return;
  3710. if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
  3711. if (freq < 4000) {
  3712. quick_drop = eep->modalHeader2G.quick_drop;
  3713. } else {
  3714. t[0] = eep->base_ext1.quick_drop_low;
  3715. t[1] = eep->modalHeader5G.quick_drop;
  3716. t[2] = eep->base_ext1.quick_drop_high;
  3717. quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
  3718. }
  3719. REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
  3720. }
  3721. }
  3722. static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
  3723. {
  3724. u32 value;
  3725. value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
  3726. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3727. AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value);
  3728. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3729. AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value);
  3730. }
  3731. static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
  3732. {
  3733. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3734. u8 xpa_ctl;
  3735. if (!(eep->baseEepHeader.featureEnable & 0x80))
  3736. return;
  3737. if (!AR_SREV_9300(ah) &&
  3738. !AR_SREV_9340(ah) &&
  3739. !AR_SREV_9580(ah) &&
  3740. !AR_SREV_9531(ah) &&
  3741. !AR_SREV_9561(ah))
  3742. return;
  3743. xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
  3744. if (is2ghz)
  3745. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3746. AR_PHY_XPA_TIMING_CTL_FRAME_XPAB_ON, xpa_ctl);
  3747. else
  3748. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3749. AR_PHY_XPA_TIMING_CTL_FRAME_XPAA_ON, xpa_ctl);
  3750. }
  3751. static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
  3752. {
  3753. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3754. u8 bias;
  3755. if (!(eep->baseEepHeader.miscConfiguration & 0x40))
  3756. return;
  3757. if (!AR_SREV_9300(ah))
  3758. return;
  3759. bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
  3760. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3761. bias & 0x3);
  3762. bias >>= 2;
  3763. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3764. bias & 0x3);
  3765. bias >>= 2;
  3766. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
  3767. bias & 0x3);
  3768. }
  3769. static int ar9003_hw_get_thermometer(struct ath_hw *ah)
  3770. {
  3771. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3772. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  3773. int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
  3774. return --thermometer;
  3775. }
  3776. static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
  3777. {
  3778. struct ath9k_hw_capabilities *pCap = &ah->caps;
  3779. int thermometer = ar9003_hw_get_thermometer(ah);
  3780. u8 therm_on = (thermometer < 0) ? 0 : 1;
  3781. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
  3782. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3783. if (pCap->chip_chainmask & BIT(1))
  3784. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
  3785. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3786. if (pCap->chip_chainmask & BIT(2))
  3787. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
  3788. AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
  3789. therm_on = thermometer == 0;
  3790. REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
  3791. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3792. if (pCap->chip_chainmask & BIT(1)) {
  3793. therm_on = thermometer == 1;
  3794. REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
  3795. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3796. }
  3797. if (pCap->chip_chainmask & BIT(2)) {
  3798. therm_on = thermometer == 2;
  3799. REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
  3800. AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
  3801. }
  3802. }
  3803. static void ar9003_hw_thermo_cal_apply(struct ath_hw *ah)
  3804. {
  3805. u32 data, ko, kg;
  3806. if (!AR_SREV_9462_20_OR_LATER(ah))
  3807. return;
  3808. ar9300_otp_read_word(ah, 1, &data);
  3809. ko = data & 0xff;
  3810. kg = (data >> 8) & 0xff;
  3811. if (ko || kg) {
  3812. REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
  3813. AR_PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET, ko);
  3814. REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
  3815. AR_PHY_BB_THERM_ADC_3_THERM_ADC_SCALE_GAIN,
  3816. kg + 256);
  3817. }
  3818. }
  3819. static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
  3820. bool is2ghz)
  3821. {
  3822. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3823. const u_int32_t cca_ctrl[AR9300_MAX_CHAINS] = {
  3824. AR_PHY_CCA_CTRL_0,
  3825. AR_PHY_CCA_CTRL_1,
  3826. AR_PHY_CCA_CTRL_2,
  3827. };
  3828. int chain;
  3829. u32 val;
  3830. if (is2ghz) {
  3831. if (!(eep->base_ext1.misc_enable & BIT(2)))
  3832. return;
  3833. } else {
  3834. if (!(eep->base_ext1.misc_enable & BIT(3)))
  3835. return;
  3836. }
  3837. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  3838. if (!(ah->caps.tx_chainmask & BIT(chain)))
  3839. continue;
  3840. val = ar9003_modal_header(ah, is2ghz)->noiseFloorThreshCh[chain];
  3841. REG_RMW_FIELD(ah, cca_ctrl[chain],
  3842. AR_PHY_EXT_CCA0_THRESH62_1, val);
  3843. }
  3844. }
  3845. static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah,
  3846. struct ath9k_channel *chan)
  3847. {
  3848. bool is2ghz = IS_CHAN_2GHZ(chan);
  3849. ar9003_hw_xpa_timing_control_apply(ah, is2ghz);
  3850. ar9003_hw_xpa_bias_level_apply(ah, is2ghz);
  3851. ar9003_hw_ant_ctrl_apply(ah, is2ghz);
  3852. ar9003_hw_drive_strength_apply(ah);
  3853. ar9003_hw_xlna_bias_strength_apply(ah, is2ghz);
  3854. ar9003_hw_atten_apply(ah, chan);
  3855. ar9003_hw_quick_drop_apply(ah, chan->channel);
  3856. if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && !AR_SREV_9531(ah))
  3857. ar9003_hw_internal_regulator_apply(ah);
  3858. ar9003_hw_apply_tuning_caps(ah);
  3859. ar9003_hw_apply_minccapwr_thresh(ah, is2ghz);
  3860. ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz);
  3861. ar9003_hw_thermometer_apply(ah);
  3862. ar9003_hw_thermo_cal_apply(ah);
  3863. }
  3864. static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah,
  3865. struct ath9k_channel *chan)
  3866. {
  3867. }
  3868. /*
  3869. * Returns the interpolated y value corresponding to the specified x value
  3870. * from the np ordered pairs of data (px,py).
  3871. * The pairs do not have to be in any order.
  3872. * If the specified x value is less than any of the px,
  3873. * the returned y value is equal to the py for the lowest px.
  3874. * If the specified x value is greater than any of the px,
  3875. * the returned y value is equal to the py for the highest px.
  3876. */
  3877. static int ar9003_hw_power_interpolate(int32_t x,
  3878. int32_t *px, int32_t *py, u_int16_t np)
  3879. {
  3880. int ip = 0;
  3881. int lx = 0, ly = 0, lhave = 0;
  3882. int hx = 0, hy = 0, hhave = 0;
  3883. int dx = 0;
  3884. int y = 0;
  3885. lhave = 0;
  3886. hhave = 0;
  3887. /* identify best lower and higher x calibration measurement */
  3888. for (ip = 0; ip < np; ip++) {
  3889. dx = x - px[ip];
  3890. /* this measurement is higher than our desired x */
  3891. if (dx <= 0) {
  3892. if (!hhave || dx > (x - hx)) {
  3893. /* new best higher x measurement */
  3894. hx = px[ip];
  3895. hy = py[ip];
  3896. hhave = 1;
  3897. }
  3898. }
  3899. /* this measurement is lower than our desired x */
  3900. if (dx >= 0) {
  3901. if (!lhave || dx < (x - lx)) {
  3902. /* new best lower x measurement */
  3903. lx = px[ip];
  3904. ly = py[ip];
  3905. lhave = 1;
  3906. }
  3907. }
  3908. }
  3909. /* the low x is good */
  3910. if (lhave) {
  3911. /* so is the high x */
  3912. if (hhave) {
  3913. /* they're the same, so just pick one */
  3914. if (hx == lx)
  3915. y = ly;
  3916. else /* interpolate */
  3917. y = interpolate(x, lx, hx, ly, hy);
  3918. } else /* only low is good, use it */
  3919. y = ly;
  3920. } else if (hhave) /* only high is good, use it */
  3921. y = hy;
  3922. else /* nothing is good,this should never happen unless np=0, ???? */
  3923. y = -(1 << 30);
  3924. return y;
  3925. }
  3926. static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
  3927. u16 rateIndex, u16 freq, bool is2GHz)
  3928. {
  3929. u16 numPiers, i;
  3930. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3931. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3932. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3933. struct cal_tgt_pow_legacy *pEepromTargetPwr;
  3934. u8 *pFreqBin;
  3935. if (is2GHz) {
  3936. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  3937. pEepromTargetPwr = eep->calTargetPower2G;
  3938. pFreqBin = eep->calTarget_freqbin_2G;
  3939. } else {
  3940. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  3941. pEepromTargetPwr = eep->calTargetPower5G;
  3942. pFreqBin = eep->calTarget_freqbin_5G;
  3943. }
  3944. /*
  3945. * create array of channels and targetpower from
  3946. * targetpower piers stored on eeprom
  3947. */
  3948. for (i = 0; i < numPiers; i++) {
  3949. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  3950. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3951. }
  3952. /* interpolate to get target power for given frequency */
  3953. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3954. freqArray,
  3955. targetPowerArray, numPiers);
  3956. }
  3957. static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
  3958. u16 rateIndex,
  3959. u16 freq, bool is2GHz)
  3960. {
  3961. u16 numPiers, i;
  3962. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3963. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3964. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3965. struct cal_tgt_pow_ht *pEepromTargetPwr;
  3966. u8 *pFreqBin;
  3967. if (is2GHz) {
  3968. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  3969. pEepromTargetPwr = eep->calTargetPower2GHT20;
  3970. pFreqBin = eep->calTarget_freqbin_2GHT20;
  3971. } else {
  3972. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  3973. pEepromTargetPwr = eep->calTargetPower5GHT20;
  3974. pFreqBin = eep->calTarget_freqbin_5GHT20;
  3975. }
  3976. /*
  3977. * create array of channels and targetpower
  3978. * from targetpower piers stored on eeprom
  3979. */
  3980. for (i = 0; i < numPiers; i++) {
  3981. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  3982. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3983. }
  3984. /* interpolate to get target power for given frequency */
  3985. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3986. freqArray,
  3987. targetPowerArray, numPiers);
  3988. }
  3989. static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
  3990. u16 rateIndex,
  3991. u16 freq, bool is2GHz)
  3992. {
  3993. u16 numPiers, i;
  3994. s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS];
  3995. s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS];
  3996. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3997. struct cal_tgt_pow_ht *pEepromTargetPwr;
  3998. u8 *pFreqBin;
  3999. if (is2GHz) {
  4000. numPiers = AR9300_NUM_2G_40_TARGET_POWERS;
  4001. pEepromTargetPwr = eep->calTargetPower2GHT40;
  4002. pFreqBin = eep->calTarget_freqbin_2GHT40;
  4003. } else {
  4004. numPiers = AR9300_NUM_5G_40_TARGET_POWERS;
  4005. pEepromTargetPwr = eep->calTargetPower5GHT40;
  4006. pFreqBin = eep->calTarget_freqbin_5GHT40;
  4007. }
  4008. /*
  4009. * create array of channels and targetpower from
  4010. * targetpower piers stored on eeprom
  4011. */
  4012. for (i = 0; i < numPiers; i++) {
  4013. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  4014. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4015. }
  4016. /* interpolate to get target power for given frequency */
  4017. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4018. freqArray,
  4019. targetPowerArray, numPiers);
  4020. }
  4021. static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah,
  4022. u16 rateIndex, u16 freq)
  4023. {
  4024. u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i;
  4025. s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  4026. s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  4027. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4028. struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck;
  4029. u8 *pFreqBin = eep->calTarget_freqbin_Cck;
  4030. /*
  4031. * create array of channels and targetpower from
  4032. * targetpower piers stored on eeprom
  4033. */
  4034. for (i = 0; i < numPiers; i++) {
  4035. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
  4036. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  4037. }
  4038. /* interpolate to get target power for given frequency */
  4039. return (u8) ar9003_hw_power_interpolate((s32) freq,
  4040. freqArray,
  4041. targetPowerArray, numPiers);
  4042. }
  4043. static void ar9003_hw_selfgen_tpc_txpower(struct ath_hw *ah,
  4044. struct ath9k_channel *chan,
  4045. u8 *pwr_array)
  4046. {
  4047. u32 val;
  4048. /* target power values for self generated frames (ACK,RTS/CTS) */
  4049. if (IS_CHAN_2GHZ(chan)) {
  4050. val = SM(pwr_array[ALL_TARGET_LEGACY_1L_5L], AR_TPC_ACK) |
  4051. SM(pwr_array[ALL_TARGET_LEGACY_1L_5L], AR_TPC_CTS) |
  4052. SM(0x3f, AR_TPC_CHIRP) | SM(0x3f, AR_TPC_RPT);
  4053. } else {
  4054. val = SM(pwr_array[ALL_TARGET_LEGACY_6_24], AR_TPC_ACK) |
  4055. SM(pwr_array[ALL_TARGET_LEGACY_6_24], AR_TPC_CTS) |
  4056. SM(0x3f, AR_TPC_CHIRP) | SM(0x3f, AR_TPC_RPT);
  4057. }
  4058. REG_WRITE(ah, AR_TPC, val);
  4059. }
  4060. /* Set tx power registers to array of values passed in */
  4061. int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray)
  4062. {
  4063. #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  4064. /* make sure forced gain is not set */
  4065. REG_WRITE(ah, AR_PHY_TX_FORCED_GAIN, 0);
  4066. /* Write the OFDM power per rate set */
  4067. /* 6 (LSB), 9, 12, 18 (MSB) */
  4068. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(0),
  4069. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  4070. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) |
  4071. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  4072. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  4073. /* 24 (LSB), 36, 48, 54 (MSB) */
  4074. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(1),
  4075. POW_SM(pPwrArray[ALL_TARGET_LEGACY_54], 24) |
  4076. POW_SM(pPwrArray[ALL_TARGET_LEGACY_48], 16) |
  4077. POW_SM(pPwrArray[ALL_TARGET_LEGACY_36], 8) |
  4078. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  4079. /* Write the CCK power per rate set */
  4080. /* 1L (LSB), reserved, 2L, 2S (MSB) */
  4081. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(2),
  4082. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 24) |
  4083. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  4084. /* POW_SM(txPowerTimes2, 8) | this is reserved for AR9003 */
  4085. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0));
  4086. /* 5.5L (LSB), 5.5S, 11L, 11S (MSB) */
  4087. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(3),
  4088. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11S], 24) |
  4089. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11L], 16) |
  4090. POW_SM(pPwrArray[ALL_TARGET_LEGACY_5S], 8) |
  4091. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  4092. );
  4093. /* Write the power for duplicated frames - HT40 */
  4094. /* dup40_cck (LSB), dup40_ofdm, ext20_cck, ext20_ofdm (MSB) */
  4095. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(8),
  4096. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  4097. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  4098. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  4099. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  4100. );
  4101. /* Write the HT20 power per rate set */
  4102. /* 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB) */
  4103. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(4),
  4104. POW_SM(pPwrArray[ALL_TARGET_HT20_5], 24) |
  4105. POW_SM(pPwrArray[ALL_TARGET_HT20_4], 16) |
  4106. POW_SM(pPwrArray[ALL_TARGET_HT20_1_3_9_11_17_19], 8) |
  4107. POW_SM(pPwrArray[ALL_TARGET_HT20_0_8_16], 0)
  4108. );
  4109. /* 6 (LSB), 7, 12, 13 (MSB) */
  4110. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(5),
  4111. POW_SM(pPwrArray[ALL_TARGET_HT20_13], 24) |
  4112. POW_SM(pPwrArray[ALL_TARGET_HT20_12], 16) |
  4113. POW_SM(pPwrArray[ALL_TARGET_HT20_7], 8) |
  4114. POW_SM(pPwrArray[ALL_TARGET_HT20_6], 0)
  4115. );
  4116. /* 14 (LSB), 15, 20, 21 */
  4117. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(9),
  4118. POW_SM(pPwrArray[ALL_TARGET_HT20_21], 24) |
  4119. POW_SM(pPwrArray[ALL_TARGET_HT20_20], 16) |
  4120. POW_SM(pPwrArray[ALL_TARGET_HT20_15], 8) |
  4121. POW_SM(pPwrArray[ALL_TARGET_HT20_14], 0)
  4122. );
  4123. /* Mixed HT20 and HT40 rates */
  4124. /* HT20 22 (LSB), HT20 23, HT40 22, HT40 23 (MSB) */
  4125. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(10),
  4126. POW_SM(pPwrArray[ALL_TARGET_HT40_23], 24) |
  4127. POW_SM(pPwrArray[ALL_TARGET_HT40_22], 16) |
  4128. POW_SM(pPwrArray[ALL_TARGET_HT20_23], 8) |
  4129. POW_SM(pPwrArray[ALL_TARGET_HT20_22], 0)
  4130. );
  4131. /*
  4132. * Write the HT40 power per rate set
  4133. * correct PAR difference between HT40 and HT20/LEGACY
  4134. * 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB)
  4135. */
  4136. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(6),
  4137. POW_SM(pPwrArray[ALL_TARGET_HT40_5], 24) |
  4138. POW_SM(pPwrArray[ALL_TARGET_HT40_4], 16) |
  4139. POW_SM(pPwrArray[ALL_TARGET_HT40_1_3_9_11_17_19], 8) |
  4140. POW_SM(pPwrArray[ALL_TARGET_HT40_0_8_16], 0)
  4141. );
  4142. /* 6 (LSB), 7, 12, 13 (MSB) */
  4143. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(7),
  4144. POW_SM(pPwrArray[ALL_TARGET_HT40_13], 24) |
  4145. POW_SM(pPwrArray[ALL_TARGET_HT40_12], 16) |
  4146. POW_SM(pPwrArray[ALL_TARGET_HT40_7], 8) |
  4147. POW_SM(pPwrArray[ALL_TARGET_HT40_6], 0)
  4148. );
  4149. /* 14 (LSB), 15, 20, 21 */
  4150. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(11),
  4151. POW_SM(pPwrArray[ALL_TARGET_HT40_21], 24) |
  4152. POW_SM(pPwrArray[ALL_TARGET_HT40_20], 16) |
  4153. POW_SM(pPwrArray[ALL_TARGET_HT40_15], 8) |
  4154. POW_SM(pPwrArray[ALL_TARGET_HT40_14], 0)
  4155. );
  4156. return 0;
  4157. #undef POW_SM
  4158. }
  4159. static void ar9003_hw_get_legacy_target_powers(struct ath_hw *ah, u16 freq,
  4160. u8 *targetPowerValT2,
  4161. bool is2GHz)
  4162. {
  4163. targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
  4164. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
  4165. is2GHz);
  4166. targetPowerValT2[ALL_TARGET_LEGACY_36] =
  4167. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_36, freq,
  4168. is2GHz);
  4169. targetPowerValT2[ALL_TARGET_LEGACY_48] =
  4170. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_48, freq,
  4171. is2GHz);
  4172. targetPowerValT2[ALL_TARGET_LEGACY_54] =
  4173. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq,
  4174. is2GHz);
  4175. }
  4176. static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
  4177. u8 *targetPowerValT2)
  4178. {
  4179. targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
  4180. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
  4181. freq);
  4182. targetPowerValT2[ALL_TARGET_LEGACY_5S] =
  4183. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_5S, freq);
  4184. targetPowerValT2[ALL_TARGET_LEGACY_11L] =
  4185. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq);
  4186. targetPowerValT2[ALL_TARGET_LEGACY_11S] =
  4187. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq);
  4188. }
  4189. static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
  4190. u8 *targetPowerValT2, bool is2GHz)
  4191. {
  4192. targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
  4193. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  4194. is2GHz);
  4195. targetPowerValT2[ALL_TARGET_HT20_1_3_9_11_17_19] =
  4196. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  4197. freq, is2GHz);
  4198. targetPowerValT2[ALL_TARGET_HT20_4] =
  4199. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  4200. is2GHz);
  4201. targetPowerValT2[ALL_TARGET_HT20_5] =
  4202. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  4203. is2GHz);
  4204. targetPowerValT2[ALL_TARGET_HT20_6] =
  4205. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4206. is2GHz);
  4207. targetPowerValT2[ALL_TARGET_HT20_7] =
  4208. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4209. is2GHz);
  4210. targetPowerValT2[ALL_TARGET_HT20_12] =
  4211. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4212. is2GHz);
  4213. targetPowerValT2[ALL_TARGET_HT20_13] =
  4214. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4215. is2GHz);
  4216. targetPowerValT2[ALL_TARGET_HT20_14] =
  4217. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4218. is2GHz);
  4219. targetPowerValT2[ALL_TARGET_HT20_15] =
  4220. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4221. is2GHz);
  4222. targetPowerValT2[ALL_TARGET_HT20_20] =
  4223. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4224. is2GHz);
  4225. targetPowerValT2[ALL_TARGET_HT20_21] =
  4226. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4227. is2GHz);
  4228. targetPowerValT2[ALL_TARGET_HT20_22] =
  4229. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4230. is2GHz);
  4231. targetPowerValT2[ALL_TARGET_HT20_23] =
  4232. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4233. is2GHz);
  4234. }
  4235. static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
  4236. u16 freq,
  4237. u8 *targetPowerValT2,
  4238. bool is2GHz)
  4239. {
  4240. /* XXX: hard code for now, need to get from eeprom struct */
  4241. u8 ht40PowerIncForPdadc = 0;
  4242. targetPowerValT2[ALL_TARGET_HT40_0_8_16] =
  4243. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  4244. is2GHz) + ht40PowerIncForPdadc;
  4245. targetPowerValT2[ALL_TARGET_HT40_1_3_9_11_17_19] =
  4246. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  4247. freq,
  4248. is2GHz) + ht40PowerIncForPdadc;
  4249. targetPowerValT2[ALL_TARGET_HT40_4] =
  4250. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  4251. is2GHz) + ht40PowerIncForPdadc;
  4252. targetPowerValT2[ALL_TARGET_HT40_5] =
  4253. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  4254. is2GHz) + ht40PowerIncForPdadc;
  4255. targetPowerValT2[ALL_TARGET_HT40_6] =
  4256. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4257. is2GHz) + ht40PowerIncForPdadc;
  4258. targetPowerValT2[ALL_TARGET_HT40_7] =
  4259. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4260. is2GHz) + ht40PowerIncForPdadc;
  4261. targetPowerValT2[ALL_TARGET_HT40_12] =
  4262. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4263. is2GHz) + ht40PowerIncForPdadc;
  4264. targetPowerValT2[ALL_TARGET_HT40_13] =
  4265. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4266. is2GHz) + ht40PowerIncForPdadc;
  4267. targetPowerValT2[ALL_TARGET_HT40_14] =
  4268. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4269. is2GHz) + ht40PowerIncForPdadc;
  4270. targetPowerValT2[ALL_TARGET_HT40_15] =
  4271. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4272. is2GHz) + ht40PowerIncForPdadc;
  4273. targetPowerValT2[ALL_TARGET_HT40_20] =
  4274. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4275. is2GHz) + ht40PowerIncForPdadc;
  4276. targetPowerValT2[ALL_TARGET_HT40_21] =
  4277. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4278. is2GHz) + ht40PowerIncForPdadc;
  4279. targetPowerValT2[ALL_TARGET_HT40_22] =
  4280. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4281. is2GHz) + ht40PowerIncForPdadc;
  4282. targetPowerValT2[ALL_TARGET_HT40_23] =
  4283. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4284. is2GHz) + ht40PowerIncForPdadc;
  4285. }
  4286. static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
  4287. struct ath9k_channel *chan,
  4288. u8 *targetPowerValT2)
  4289. {
  4290. bool is2GHz = IS_CHAN_2GHZ(chan);
  4291. unsigned int i = 0;
  4292. struct ath_common *common = ath9k_hw_common(ah);
  4293. u16 freq = chan->channel;
  4294. if (is2GHz)
  4295. ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
  4296. ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4297. ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4298. if (IS_CHAN_HT40(chan))
  4299. ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
  4300. is2GHz);
  4301. for (i = 0; i < ar9300RateSize; i++) {
  4302. ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
  4303. i, targetPowerValT2[i]);
  4304. }
  4305. }
  4306. static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
  4307. int mode,
  4308. int ipier,
  4309. int ichain,
  4310. int *pfrequency,
  4311. int *pcorrection,
  4312. int *ptemperature, int *pvoltage)
  4313. {
  4314. u8 *pCalPier;
  4315. struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
  4316. int is2GHz;
  4317. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4318. struct ath_common *common = ath9k_hw_common(ah);
  4319. if (ichain >= AR9300_MAX_CHAINS) {
  4320. ath_dbg(common, EEPROM,
  4321. "Invalid chain index, must be less than %d\n",
  4322. AR9300_MAX_CHAINS);
  4323. return -1;
  4324. }
  4325. if (mode) { /* 5GHz */
  4326. if (ipier >= AR9300_NUM_5G_CAL_PIERS) {
  4327. ath_dbg(common, EEPROM,
  4328. "Invalid 5GHz cal pier index, must be less than %d\n",
  4329. AR9300_NUM_5G_CAL_PIERS);
  4330. return -1;
  4331. }
  4332. pCalPier = &(eep->calFreqPier5G[ipier]);
  4333. pCalPierStruct = &(eep->calPierData5G[ichain][ipier]);
  4334. is2GHz = 0;
  4335. } else {
  4336. if (ipier >= AR9300_NUM_2G_CAL_PIERS) {
  4337. ath_dbg(common, EEPROM,
  4338. "Invalid 2GHz cal pier index, must be less than %d\n",
  4339. AR9300_NUM_2G_CAL_PIERS);
  4340. return -1;
  4341. }
  4342. pCalPier = &(eep->calFreqPier2G[ipier]);
  4343. pCalPierStruct = &(eep->calPierData2G[ichain][ipier]);
  4344. is2GHz = 1;
  4345. }
  4346. *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2GHz);
  4347. *pcorrection = pCalPierStruct->refPower;
  4348. *ptemperature = pCalPierStruct->tempMeas;
  4349. *pvoltage = pCalPierStruct->voltMeas;
  4350. return 0;
  4351. }
  4352. static void ar9003_hw_power_control_override(struct ath_hw *ah,
  4353. int frequency,
  4354. int *correction,
  4355. int *voltage, int *temperature)
  4356. {
  4357. int temp_slope = 0, temp_slope1 = 0, temp_slope2 = 0;
  4358. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4359. int f[8], t[8], t1[3], t2[3], i;
  4360. REG_RMW(ah, AR_PHY_TPC_11_B0,
  4361. (correction[0] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4362. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4363. if (ah->caps.tx_chainmask & BIT(1))
  4364. REG_RMW(ah, AR_PHY_TPC_11_B1,
  4365. (correction[1] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4366. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4367. if (ah->caps.tx_chainmask & BIT(2))
  4368. REG_RMW(ah, AR_PHY_TPC_11_B2,
  4369. (correction[2] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4370. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4371. /* enable open loop power control on chip */
  4372. REG_RMW(ah, AR_PHY_TPC_6_B0,
  4373. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4374. AR_PHY_TPC_6_ERROR_EST_MODE);
  4375. if (ah->caps.tx_chainmask & BIT(1))
  4376. REG_RMW(ah, AR_PHY_TPC_6_B1,
  4377. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4378. AR_PHY_TPC_6_ERROR_EST_MODE);
  4379. if (ah->caps.tx_chainmask & BIT(2))
  4380. REG_RMW(ah, AR_PHY_TPC_6_B2,
  4381. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4382. AR_PHY_TPC_6_ERROR_EST_MODE);
  4383. /*
  4384. * enable temperature compensation
  4385. * Need to use register names
  4386. */
  4387. if (frequency < 4000) {
  4388. temp_slope = eep->modalHeader2G.tempSlope;
  4389. } else {
  4390. if (AR_SREV_9550(ah)) {
  4391. t[0] = eep->base_ext1.tempslopextension[2];
  4392. t1[0] = eep->base_ext1.tempslopextension[3];
  4393. t2[0] = eep->base_ext1.tempslopextension[4];
  4394. f[0] = 5180;
  4395. t[1] = eep->modalHeader5G.tempSlope;
  4396. t1[1] = eep->base_ext1.tempslopextension[0];
  4397. t2[1] = eep->base_ext1.tempslopextension[1];
  4398. f[1] = 5500;
  4399. t[2] = eep->base_ext1.tempslopextension[5];
  4400. t1[2] = eep->base_ext1.tempslopextension[6];
  4401. t2[2] = eep->base_ext1.tempslopextension[7];
  4402. f[2] = 5785;
  4403. temp_slope = ar9003_hw_power_interpolate(frequency,
  4404. f, t, 3);
  4405. temp_slope1 = ar9003_hw_power_interpolate(frequency,
  4406. f, t1, 3);
  4407. temp_slope2 = ar9003_hw_power_interpolate(frequency,
  4408. f, t2, 3);
  4409. goto tempslope;
  4410. }
  4411. if ((eep->baseEepHeader.miscConfiguration & 0x20) != 0) {
  4412. for (i = 0; i < 8; i++) {
  4413. t[i] = eep->base_ext1.tempslopextension[i];
  4414. f[i] = FBIN2FREQ(eep->calFreqPier5G[i], 0);
  4415. }
  4416. temp_slope = ar9003_hw_power_interpolate((s32) frequency,
  4417. f, t, 8);
  4418. } else if (eep->base_ext2.tempSlopeLow != 0) {
  4419. t[0] = eep->base_ext2.tempSlopeLow;
  4420. f[0] = 5180;
  4421. t[1] = eep->modalHeader5G.tempSlope;
  4422. f[1] = 5500;
  4423. t[2] = eep->base_ext2.tempSlopeHigh;
  4424. f[2] = 5785;
  4425. temp_slope = ar9003_hw_power_interpolate((s32) frequency,
  4426. f, t, 3);
  4427. } else {
  4428. temp_slope = eep->modalHeader5G.tempSlope;
  4429. }
  4430. }
  4431. tempslope:
  4432. if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
  4433. u8 txmask = (eep->baseEepHeader.txrxMask & 0xf0) >> 4;
  4434. /*
  4435. * AR955x has tempSlope register for each chain.
  4436. * Check whether temp_compensation feature is enabled or not.
  4437. */
  4438. if (eep->baseEepHeader.featureEnable & 0x1) {
  4439. if (frequency < 4000) {
  4440. if (txmask & BIT(0))
  4441. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4442. AR_PHY_TPC_19_ALPHA_THERM,
  4443. eep->base_ext2.tempSlopeLow);
  4444. if (txmask & BIT(1))
  4445. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4446. AR_PHY_TPC_19_ALPHA_THERM,
  4447. temp_slope);
  4448. if (txmask & BIT(2))
  4449. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4450. AR_PHY_TPC_19_ALPHA_THERM,
  4451. eep->base_ext2.tempSlopeHigh);
  4452. } else {
  4453. if (txmask & BIT(0))
  4454. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4455. AR_PHY_TPC_19_ALPHA_THERM,
  4456. temp_slope);
  4457. if (txmask & BIT(1))
  4458. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4459. AR_PHY_TPC_19_ALPHA_THERM,
  4460. temp_slope1);
  4461. if (txmask & BIT(2))
  4462. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4463. AR_PHY_TPC_19_ALPHA_THERM,
  4464. temp_slope2);
  4465. }
  4466. } else {
  4467. /*
  4468. * If temp compensation is not enabled,
  4469. * set all registers to 0.
  4470. */
  4471. if (txmask & BIT(0))
  4472. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4473. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4474. if (txmask & BIT(1))
  4475. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4476. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4477. if (txmask & BIT(2))
  4478. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
  4479. AR_PHY_TPC_19_ALPHA_THERM, 0);
  4480. }
  4481. } else {
  4482. REG_RMW_FIELD(ah, AR_PHY_TPC_19,
  4483. AR_PHY_TPC_19_ALPHA_THERM, temp_slope);
  4484. }
  4485. if (AR_SREV_9462_20_OR_LATER(ah))
  4486. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4487. AR_PHY_TPC_19_B1_ALPHA_THERM, temp_slope);
  4488. REG_RMW_FIELD(ah, AR_PHY_TPC_18, AR_PHY_TPC_18_THERM_CAL_VALUE,
  4489. temperature[0]);
  4490. }
  4491. /* Apply the recorded correction values. */
  4492. static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
  4493. {
  4494. int ichain, ipier, npier;
  4495. int mode;
  4496. int lfrequency[AR9300_MAX_CHAINS],
  4497. lcorrection[AR9300_MAX_CHAINS],
  4498. ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS];
  4499. int hfrequency[AR9300_MAX_CHAINS],
  4500. hcorrection[AR9300_MAX_CHAINS],
  4501. htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS];
  4502. int fdiff;
  4503. int correction[AR9300_MAX_CHAINS],
  4504. voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS];
  4505. int pfrequency, pcorrection, ptemperature, pvoltage;
  4506. struct ath_common *common = ath9k_hw_common(ah);
  4507. mode = (frequency >= 4000);
  4508. if (mode)
  4509. npier = AR9300_NUM_5G_CAL_PIERS;
  4510. else
  4511. npier = AR9300_NUM_2G_CAL_PIERS;
  4512. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4513. lfrequency[ichain] = 0;
  4514. hfrequency[ichain] = 100000;
  4515. }
  4516. /* identify best lower and higher frequency calibration measurement */
  4517. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4518. for (ipier = 0; ipier < npier; ipier++) {
  4519. if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
  4520. &pfrequency, &pcorrection,
  4521. &ptemperature, &pvoltage)) {
  4522. fdiff = frequency - pfrequency;
  4523. /*
  4524. * this measurement is higher than
  4525. * our desired frequency
  4526. */
  4527. if (fdiff <= 0) {
  4528. if (hfrequency[ichain] <= 0 ||
  4529. hfrequency[ichain] >= 100000 ||
  4530. fdiff >
  4531. (frequency - hfrequency[ichain])) {
  4532. /*
  4533. * new best higher
  4534. * frequency measurement
  4535. */
  4536. hfrequency[ichain] = pfrequency;
  4537. hcorrection[ichain] =
  4538. pcorrection;
  4539. htemperature[ichain] =
  4540. ptemperature;
  4541. hvoltage[ichain] = pvoltage;
  4542. }
  4543. }
  4544. if (fdiff >= 0) {
  4545. if (lfrequency[ichain] <= 0
  4546. || fdiff <
  4547. (frequency - lfrequency[ichain])) {
  4548. /*
  4549. * new best lower
  4550. * frequency measurement
  4551. */
  4552. lfrequency[ichain] = pfrequency;
  4553. lcorrection[ichain] =
  4554. pcorrection;
  4555. ltemperature[ichain] =
  4556. ptemperature;
  4557. lvoltage[ichain] = pvoltage;
  4558. }
  4559. }
  4560. }
  4561. }
  4562. }
  4563. /* interpolate */
  4564. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4565. ath_dbg(common, EEPROM, "ch=%d f=%d low=%d %d h=%d %d\n",
  4566. ichain, frequency, lfrequency[ichain],
  4567. lcorrection[ichain], hfrequency[ichain],
  4568. hcorrection[ichain]);
  4569. /* they're the same, so just pick one */
  4570. if (hfrequency[ichain] == lfrequency[ichain]) {
  4571. correction[ichain] = lcorrection[ichain];
  4572. voltage[ichain] = lvoltage[ichain];
  4573. temperature[ichain] = ltemperature[ichain];
  4574. }
  4575. /* the low frequency is good */
  4576. else if (frequency - lfrequency[ichain] < 1000) {
  4577. /* so is the high frequency, interpolate */
  4578. if (hfrequency[ichain] - frequency < 1000) {
  4579. correction[ichain] = interpolate(frequency,
  4580. lfrequency[ichain],
  4581. hfrequency[ichain],
  4582. lcorrection[ichain],
  4583. hcorrection[ichain]);
  4584. temperature[ichain] = interpolate(frequency,
  4585. lfrequency[ichain],
  4586. hfrequency[ichain],
  4587. ltemperature[ichain],
  4588. htemperature[ichain]);
  4589. voltage[ichain] = interpolate(frequency,
  4590. lfrequency[ichain],
  4591. hfrequency[ichain],
  4592. lvoltage[ichain],
  4593. hvoltage[ichain]);
  4594. }
  4595. /* only low is good, use it */
  4596. else {
  4597. correction[ichain] = lcorrection[ichain];
  4598. temperature[ichain] = ltemperature[ichain];
  4599. voltage[ichain] = lvoltage[ichain];
  4600. }
  4601. }
  4602. /* only high is good, use it */
  4603. else if (hfrequency[ichain] - frequency < 1000) {
  4604. correction[ichain] = hcorrection[ichain];
  4605. temperature[ichain] = htemperature[ichain];
  4606. voltage[ichain] = hvoltage[ichain];
  4607. } else { /* nothing is good, presume 0???? */
  4608. correction[ichain] = 0;
  4609. temperature[ichain] = 0;
  4610. voltage[ichain] = 0;
  4611. }
  4612. }
  4613. ar9003_hw_power_control_override(ah, frequency, correction, voltage,
  4614. temperature);
  4615. ath_dbg(common, EEPROM,
  4616. "for frequency=%d, calibration correction = %d %d %d\n",
  4617. frequency, correction[0], correction[1], correction[2]);
  4618. return 0;
  4619. }
  4620. static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
  4621. int idx,
  4622. int edge,
  4623. bool is2GHz)
  4624. {
  4625. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4626. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4627. if (is2GHz)
  4628. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
  4629. else
  4630. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
  4631. }
  4632. static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
  4633. int idx,
  4634. unsigned int edge,
  4635. u16 freq,
  4636. bool is2GHz)
  4637. {
  4638. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4639. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4640. u8 *ctl_freqbin = is2GHz ?
  4641. &eep->ctl_freqbin_2G[idx][0] :
  4642. &eep->ctl_freqbin_5G[idx][0];
  4643. if (is2GHz) {
  4644. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
  4645. CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
  4646. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
  4647. } else {
  4648. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
  4649. CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
  4650. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
  4651. }
  4652. return MAX_RATE_POWER;
  4653. }
  4654. /*
  4655. * Find the maximum conformance test limit for the given channel and CTL info
  4656. */
  4657. static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
  4658. u16 freq, int idx, bool is2GHz)
  4659. {
  4660. u16 twiceMaxEdgePower = MAX_RATE_POWER;
  4661. u8 *ctl_freqbin = is2GHz ?
  4662. &eep->ctl_freqbin_2G[idx][0] :
  4663. &eep->ctl_freqbin_5G[idx][0];
  4664. u16 num_edges = is2GHz ?
  4665. AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
  4666. unsigned int edge;
  4667. /* Get the edge power */
  4668. for (edge = 0;
  4669. (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
  4670. edge++) {
  4671. /*
  4672. * If there's an exact channel match or an inband flag set
  4673. * on the lower channel use the given rdEdgePower
  4674. */
  4675. if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
  4676. twiceMaxEdgePower =
  4677. ar9003_hw_get_direct_edge_power(eep, idx,
  4678. edge, is2GHz);
  4679. break;
  4680. } else if ((edge > 0) &&
  4681. (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
  4682. is2GHz))) {
  4683. twiceMaxEdgePower =
  4684. ar9003_hw_get_indirect_edge_power(eep, idx,
  4685. edge, freq,
  4686. is2GHz);
  4687. /*
  4688. * Leave loop - no more affecting edges possible in
  4689. * this monotonic increasing list
  4690. */
  4691. break;
  4692. }
  4693. }
  4694. if (is2GHz && !twiceMaxEdgePower)
  4695. twiceMaxEdgePower = 60;
  4696. return twiceMaxEdgePower;
  4697. }
  4698. static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
  4699. struct ath9k_channel *chan,
  4700. u8 *pPwrArray, u16 cfgCtl,
  4701. u8 antenna_reduction,
  4702. u16 powerLimit)
  4703. {
  4704. struct ath_common *common = ath9k_hw_common(ah);
  4705. struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
  4706. u16 twiceMaxEdgePower;
  4707. int i;
  4708. u16 scaledPower = 0, minCtlPower;
  4709. static const u16 ctlModesFor11a[] = {
  4710. CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
  4711. };
  4712. static const u16 ctlModesFor11g[] = {
  4713. CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
  4714. CTL_11G_EXT, CTL_2GHT40
  4715. };
  4716. u16 numCtlModes;
  4717. const u16 *pCtlMode;
  4718. u16 ctlMode, freq;
  4719. struct chan_centers centers;
  4720. u8 *ctlIndex;
  4721. u8 ctlNum;
  4722. u16 twiceMinEdgePower;
  4723. bool is2ghz = IS_CHAN_2GHZ(chan);
  4724. ath9k_hw_get_channel_centers(ah, chan, &centers);
  4725. scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
  4726. antenna_reduction);
  4727. if (is2ghz) {
  4728. /* Setup for CTL modes */
  4729. /* CTL_11B, CTL_11G, CTL_2GHT20 */
  4730. numCtlModes =
  4731. ARRAY_SIZE(ctlModesFor11g) -
  4732. SUB_NUM_CTL_MODES_AT_2G_40;
  4733. pCtlMode = ctlModesFor11g;
  4734. if (IS_CHAN_HT40(chan))
  4735. /* All 2G CTL's */
  4736. numCtlModes = ARRAY_SIZE(ctlModesFor11g);
  4737. } else {
  4738. /* Setup for CTL modes */
  4739. /* CTL_11A, CTL_5GHT20 */
  4740. numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
  4741. SUB_NUM_CTL_MODES_AT_5G_40;
  4742. pCtlMode = ctlModesFor11a;
  4743. if (IS_CHAN_HT40(chan))
  4744. /* All 5G CTL's */
  4745. numCtlModes = ARRAY_SIZE(ctlModesFor11a);
  4746. }
  4747. /*
  4748. * For MIMO, need to apply regulatory caps individually across
  4749. * dynamically running modes: CCK, OFDM, HT20, HT40
  4750. *
  4751. * The outer loop walks through each possible applicable runtime mode.
  4752. * The inner loop walks through each ctlIndex entry in EEPROM.
  4753. * The ctl value is encoded as [7:4] == test group, [3:0] == test mode.
  4754. */
  4755. for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
  4756. bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
  4757. (pCtlMode[ctlMode] == CTL_2GHT40);
  4758. if (isHt40CtlMode)
  4759. freq = centers.synth_center;
  4760. else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
  4761. freq = centers.ext_center;
  4762. else
  4763. freq = centers.ctl_center;
  4764. ath_dbg(common, REGULATORY,
  4765. "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n",
  4766. ctlMode, numCtlModes, isHt40CtlMode,
  4767. (pCtlMode[ctlMode] & EXT_ADDITIVE));
  4768. /* walk through each CTL index stored in EEPROM */
  4769. if (is2ghz) {
  4770. ctlIndex = pEepData->ctlIndex_2G;
  4771. ctlNum = AR9300_NUM_CTLS_2G;
  4772. } else {
  4773. ctlIndex = pEepData->ctlIndex_5G;
  4774. ctlNum = AR9300_NUM_CTLS_5G;
  4775. }
  4776. twiceMaxEdgePower = MAX_RATE_POWER;
  4777. for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
  4778. ath_dbg(common, REGULATORY,
  4779. "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
  4780. i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
  4781. chan->channel);
  4782. /*
  4783. * compare test group from regulatory
  4784. * channel list with test mode from pCtlMode
  4785. * list
  4786. */
  4787. if ((((cfgCtl & ~CTL_MODE_M) |
  4788. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4789. ctlIndex[i]) ||
  4790. (((cfgCtl & ~CTL_MODE_M) |
  4791. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4792. ((ctlIndex[i] & CTL_MODE_M) |
  4793. SD_NO_CTL))) {
  4794. twiceMinEdgePower =
  4795. ar9003_hw_get_max_edge_power(pEepData,
  4796. freq, i,
  4797. is2ghz);
  4798. if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL)
  4799. /*
  4800. * Find the minimum of all CTL
  4801. * edge powers that apply to
  4802. * this channel
  4803. */
  4804. twiceMaxEdgePower =
  4805. min(twiceMaxEdgePower,
  4806. twiceMinEdgePower);
  4807. else {
  4808. /* specific */
  4809. twiceMaxEdgePower = twiceMinEdgePower;
  4810. break;
  4811. }
  4812. }
  4813. }
  4814. minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
  4815. ath_dbg(common, REGULATORY,
  4816. "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n",
  4817. ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
  4818. scaledPower, minCtlPower);
  4819. /* Apply ctl mode to correct target power set */
  4820. switch (pCtlMode[ctlMode]) {
  4821. case CTL_11B:
  4822. for (i = ALL_TARGET_LEGACY_1L_5L;
  4823. i <= ALL_TARGET_LEGACY_11S; i++)
  4824. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4825. minCtlPower);
  4826. break;
  4827. case CTL_11A:
  4828. case CTL_11G:
  4829. for (i = ALL_TARGET_LEGACY_6_24;
  4830. i <= ALL_TARGET_LEGACY_54; i++)
  4831. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4832. minCtlPower);
  4833. break;
  4834. case CTL_5GHT20:
  4835. case CTL_2GHT20:
  4836. for (i = ALL_TARGET_HT20_0_8_16;
  4837. i <= ALL_TARGET_HT20_23; i++) {
  4838. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4839. minCtlPower);
  4840. if (ath9k_hw_mci_is_enabled(ah))
  4841. pPwrArray[i] =
  4842. (u8)min((u16)pPwrArray[i],
  4843. ar9003_mci_get_max_txpower(ah,
  4844. pCtlMode[ctlMode]));
  4845. }
  4846. break;
  4847. case CTL_5GHT40:
  4848. case CTL_2GHT40:
  4849. for (i = ALL_TARGET_HT40_0_8_16;
  4850. i <= ALL_TARGET_HT40_23; i++) {
  4851. pPwrArray[i] = (u8)min((u16)pPwrArray[i],
  4852. minCtlPower);
  4853. if (ath9k_hw_mci_is_enabled(ah))
  4854. pPwrArray[i] =
  4855. (u8)min((u16)pPwrArray[i],
  4856. ar9003_mci_get_max_txpower(ah,
  4857. pCtlMode[ctlMode]));
  4858. }
  4859. break;
  4860. default:
  4861. break;
  4862. }
  4863. } /* end ctl mode checking */
  4864. }
  4865. static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx)
  4866. {
  4867. u8 mod_idx = mcs_idx % 8;
  4868. if (mod_idx <= 3)
  4869. return mod_idx ? (base_pwridx + 1) : base_pwridx;
  4870. else
  4871. return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2;
  4872. }
  4873. static void ar9003_paprd_set_txpower(struct ath_hw *ah,
  4874. struct ath9k_channel *chan,
  4875. u8 *targetPowerValT2)
  4876. {
  4877. int i;
  4878. if (!ar9003_is_paprd_enabled(ah))
  4879. return;
  4880. if (IS_CHAN_HT40(chan))
  4881. i = ALL_TARGET_HT40_7;
  4882. else
  4883. i = ALL_TARGET_HT20_7;
  4884. if (IS_CHAN_2GHZ(chan)) {
  4885. if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) &&
  4886. !AR_SREV_9462(ah) && !AR_SREV_9565(ah)) {
  4887. if (IS_CHAN_HT40(chan))
  4888. i = ALL_TARGET_HT40_0_8_16;
  4889. else
  4890. i = ALL_TARGET_HT20_0_8_16;
  4891. }
  4892. }
  4893. ah->paprd_target_power = targetPowerValT2[i];
  4894. }
  4895. static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
  4896. struct ath9k_channel *chan, u16 cfgCtl,
  4897. u8 twiceAntennaReduction,
  4898. u8 powerLimit, bool test)
  4899. {
  4900. struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
  4901. struct ath_common *common = ath9k_hw_common(ah);
  4902. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4903. struct ar9300_modal_eep_header *modal_hdr;
  4904. u8 targetPowerValT2[ar9300RateSize];
  4905. u8 target_power_val_t2_eep[ar9300RateSize];
  4906. u8 targetPowerValT2_tpc[ar9300RateSize];
  4907. unsigned int i = 0, paprd_scale_factor = 0;
  4908. u8 pwr_idx, min_pwridx = 0;
  4909. memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
  4910. /*
  4911. * Get target powers from EEPROM - our baseline for TX Power
  4912. */
  4913. ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
  4914. if (ar9003_is_paprd_enabled(ah)) {
  4915. if (IS_CHAN_2GHZ(chan))
  4916. modal_hdr = &eep->modalHeader2G;
  4917. else
  4918. modal_hdr = &eep->modalHeader5G;
  4919. ah->paprd_ratemask =
  4920. le32_to_cpu(modal_hdr->papdRateMaskHt20) &
  4921. AR9300_PAPRD_RATE_MASK;
  4922. ah->paprd_ratemask_ht40 =
  4923. le32_to_cpu(modal_hdr->papdRateMaskHt40) &
  4924. AR9300_PAPRD_RATE_MASK;
  4925. paprd_scale_factor = ar9003_get_paprd_scale_factor(ah, chan);
  4926. min_pwridx = IS_CHAN_HT40(chan) ? ALL_TARGET_HT40_0_8_16 :
  4927. ALL_TARGET_HT20_0_8_16;
  4928. if (!ah->paprd_table_write_done) {
  4929. memcpy(target_power_val_t2_eep, targetPowerValT2,
  4930. sizeof(targetPowerValT2));
  4931. for (i = 0; i < 24; i++) {
  4932. pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx);
  4933. if (ah->paprd_ratemask & (1 << i)) {
  4934. if (targetPowerValT2[pwr_idx] &&
  4935. targetPowerValT2[pwr_idx] ==
  4936. target_power_val_t2_eep[pwr_idx])
  4937. targetPowerValT2[pwr_idx] -=
  4938. paprd_scale_factor;
  4939. }
  4940. }
  4941. }
  4942. memcpy(target_power_val_t2_eep, targetPowerValT2,
  4943. sizeof(targetPowerValT2));
  4944. }
  4945. ar9003_hw_set_power_per_rate_table(ah, chan,
  4946. targetPowerValT2, cfgCtl,
  4947. twiceAntennaReduction,
  4948. powerLimit);
  4949. memcpy(targetPowerValT2_tpc, targetPowerValT2,
  4950. sizeof(targetPowerValT2));
  4951. if (ar9003_is_paprd_enabled(ah)) {
  4952. for (i = 0; i < ar9300RateSize; i++) {
  4953. if ((ah->paprd_ratemask & (1 << i)) &&
  4954. (abs(targetPowerValT2[i] -
  4955. target_power_val_t2_eep[i]) >
  4956. paprd_scale_factor)) {
  4957. ah->paprd_ratemask &= ~(1 << i);
  4958. ath_dbg(common, EEPROM,
  4959. "paprd disabled for mcs %d\n", i);
  4960. }
  4961. }
  4962. }
  4963. regulatory->max_power_level = 0;
  4964. for (i = 0; i < ar9300RateSize; i++) {
  4965. if (targetPowerValT2[i] > regulatory->max_power_level)
  4966. regulatory->max_power_level = targetPowerValT2[i];
  4967. }
  4968. ath9k_hw_update_regulatory_maxpower(ah);
  4969. if (test)
  4970. return;
  4971. for (i = 0; i < ar9300RateSize; i++) {
  4972. ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
  4973. i, targetPowerValT2[i]);
  4974. }
  4975. /* Write target power array to registers */
  4976. ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
  4977. ar9003_hw_calibration_apply(ah, chan->channel);
  4978. ar9003_paprd_set_txpower(ah, chan, targetPowerValT2);
  4979. ar9003_hw_selfgen_tpc_txpower(ah, chan, targetPowerValT2);
  4980. /* TPC initializations */
  4981. if (ah->tpc_enabled) {
  4982. u32 val;
  4983. ar9003_hw_init_rate_txpower(ah, targetPowerValT2_tpc, chan);
  4984. /* Enable TPC */
  4985. REG_WRITE(ah, AR_PHY_PWRTX_MAX,
  4986. AR_PHY_POWER_TX_RATE_MAX_TPC_ENABLE);
  4987. /* Disable per chain power reduction */
  4988. val = REG_READ(ah, AR_PHY_POWER_TX_SUB);
  4989. if (AR_SREV_9340(ah))
  4990. REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
  4991. val & 0xFFFFFFC0);
  4992. else
  4993. REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
  4994. val & 0xFFFFF000);
  4995. } else {
  4996. /* Disable TPC */
  4997. REG_WRITE(ah, AR_PHY_PWRTX_MAX, 0);
  4998. }
  4999. }
  5000. static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah,
  5001. u16 i, bool is2GHz)
  5002. {
  5003. return AR_NO_SPUR;
  5004. }
  5005. s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
  5006. {
  5007. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5008. return (eep->baseEepHeader.txrxgain >> 4) & 0xf; /* bits 7:4 */
  5009. }
  5010. s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
  5011. {
  5012. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5013. return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */
  5014. }
  5015. u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz)
  5016. {
  5017. return ar9003_modal_header(ah, is2ghz)->spurChans;
  5018. }
  5019. unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
  5020. struct ath9k_channel *chan)
  5021. {
  5022. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  5023. if (IS_CHAN_2GHZ(chan))
  5024. return MS(le32_to_cpu(eep->modalHeader2G.papdRateMaskHt20),
  5025. AR9300_PAPRD_SCALE_1);
  5026. else {
  5027. if (chan->channel >= 5700)
  5028. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20),
  5029. AR9300_PAPRD_SCALE_1);
  5030. else if (chan->channel >= 5400)
  5031. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  5032. AR9300_PAPRD_SCALE_2);
  5033. else
  5034. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  5035. AR9300_PAPRD_SCALE_1);
  5036. }
  5037. }
  5038. const struct eeprom_ops eep_ar9300_ops = {
  5039. .check_eeprom = ath9k_hw_ar9300_check_eeprom,
  5040. .get_eeprom = ath9k_hw_ar9300_get_eeprom,
  5041. .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
  5042. .dump_eeprom = ath9k_hw_ar9003_dump_eeprom,
  5043. .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
  5044. .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
  5045. .set_board_values = ath9k_hw_ar9300_set_board_values,
  5046. .set_addac = ath9k_hw_ar9300_set_addac,
  5047. .set_txpower = ath9k_hw_ar9300_set_txpower,
  5048. .get_spur_channel = ath9k_hw_ar9300_get_spur_channel
  5049. };