ar9003_eeprom.c 132 KB

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