ar9003_eeprom.c 130 KB

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