ar9003_eeprom.c 134 KB

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