ar9003_eeprom.c 132 KB

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