ar9003_eeprom.c 146 KB

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