ar9003_eeprom.c 149 KB

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