ar9003_eeprom.c 146 KB

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