ar9003_eeprom.c 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141
  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_DRIVE_STRENGTH:
  2820. #define AR9300_EEP_BASE_DRIV_STRENGTH 0x1
  2821. return pBase->miscConfiguration & AR9300_EEP_BASE_DRIV_STRENGTH;
  2822. case EEP_INTERNAL_REGULATOR:
  2823. /* Bit 4 is internal regulator flag */
  2824. return (pBase->featureEnable & 0x10) >> 4;
  2825. case EEP_SWREG:
  2826. return le32_to_cpu(pBase->swreg);
  2827. case EEP_PAPRD:
  2828. return !!(pBase->featureEnable & BIT(5));
  2829. case EEP_CHAIN_MASK_REDUCE:
  2830. return (pBase->miscConfiguration >> 0x3) & 0x1;
  2831. case EEP_ANT_DIV_CTL1:
  2832. return eep->base_ext1.ant_div_control;
  2833. case EEP_ANTENNA_GAIN_5G:
  2834. return eep->modalHeader5G.antennaGain;
  2835. case EEP_ANTENNA_GAIN_2G:
  2836. return eep->modalHeader2G.antennaGain;
  2837. case EEP_QUICK_DROP:
  2838. return pBase->miscConfiguration & BIT(1);
  2839. default:
  2840. return 0;
  2841. }
  2842. }
  2843. static bool ar9300_eeprom_read_byte(struct ath_common *common, int address,
  2844. u8 *buffer)
  2845. {
  2846. u16 val;
  2847. if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
  2848. return false;
  2849. *buffer = (val >> (8 * (address % 2))) & 0xff;
  2850. return true;
  2851. }
  2852. static bool ar9300_eeprom_read_word(struct ath_common *common, int address,
  2853. u8 *buffer)
  2854. {
  2855. u16 val;
  2856. if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
  2857. return false;
  2858. buffer[0] = val >> 8;
  2859. buffer[1] = val & 0xff;
  2860. return true;
  2861. }
  2862. static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
  2863. int count)
  2864. {
  2865. struct ath_common *common = ath9k_hw_common(ah);
  2866. int i;
  2867. if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
  2868. ath_dbg(common, EEPROM, "eeprom address not in range\n");
  2869. return false;
  2870. }
  2871. /*
  2872. * Since we're reading the bytes in reverse order from a little-endian
  2873. * word stream, an even address means we only use the lower half of
  2874. * the 16-bit word at that address
  2875. */
  2876. if (address % 2 == 0) {
  2877. if (!ar9300_eeprom_read_byte(common, address--, buffer++))
  2878. goto error;
  2879. count--;
  2880. }
  2881. for (i = 0; i < count / 2; i++) {
  2882. if (!ar9300_eeprom_read_word(common, address, buffer))
  2883. goto error;
  2884. address -= 2;
  2885. buffer += 2;
  2886. }
  2887. if (count % 2)
  2888. if (!ar9300_eeprom_read_byte(common, address, buffer))
  2889. goto error;
  2890. return true;
  2891. error:
  2892. ath_dbg(common, EEPROM, "unable to read eeprom region at offset %d\n",
  2893. address);
  2894. return false;
  2895. }
  2896. static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data)
  2897. {
  2898. REG_READ(ah, AR9300_OTP_BASE + (4 * addr));
  2899. if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE,
  2900. AR9300_OTP_STATUS_VALID, 1000))
  2901. return false;
  2902. *data = REG_READ(ah, AR9300_OTP_READ_DATA);
  2903. return true;
  2904. }
  2905. static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer,
  2906. int count)
  2907. {
  2908. u32 data;
  2909. int i;
  2910. for (i = 0; i < count; i++) {
  2911. int offset = 8 * ((address - i) % 4);
  2912. if (!ar9300_otp_read_word(ah, (address - i) / 4, &data))
  2913. return false;
  2914. buffer[i] = (data >> offset) & 0xff;
  2915. }
  2916. return true;
  2917. }
  2918. static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
  2919. int *length, int *major, int *minor)
  2920. {
  2921. unsigned long value[4];
  2922. value[0] = best[0];
  2923. value[1] = best[1];
  2924. value[2] = best[2];
  2925. value[3] = best[3];
  2926. *code = ((value[0] >> 5) & 0x0007);
  2927. *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
  2928. *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
  2929. *major = (value[2] & 0x000f);
  2930. *minor = (value[3] & 0x00ff);
  2931. }
  2932. static u16 ar9300_comp_cksum(u8 *data, int dsize)
  2933. {
  2934. int it, checksum = 0;
  2935. for (it = 0; it < dsize; it++) {
  2936. checksum += data[it];
  2937. checksum &= 0xffff;
  2938. }
  2939. return checksum;
  2940. }
  2941. static bool ar9300_uncompress_block(struct ath_hw *ah,
  2942. u8 *mptr,
  2943. int mdataSize,
  2944. u8 *block,
  2945. int size)
  2946. {
  2947. int it;
  2948. int spot;
  2949. int offset;
  2950. int length;
  2951. struct ath_common *common = ath9k_hw_common(ah);
  2952. spot = 0;
  2953. for (it = 0; it < size; it += (length+2)) {
  2954. offset = block[it];
  2955. offset &= 0xff;
  2956. spot += offset;
  2957. length = block[it+1];
  2958. length &= 0xff;
  2959. if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
  2960. ath_dbg(common, EEPROM,
  2961. "Restore at %d: spot=%d offset=%d length=%d\n",
  2962. it, spot, offset, length);
  2963. memcpy(&mptr[spot], &block[it+2], length);
  2964. spot += length;
  2965. } else if (length > 0) {
  2966. ath_dbg(common, EEPROM,
  2967. "Bad restore at %d: spot=%d offset=%d length=%d\n",
  2968. it, spot, offset, length);
  2969. return false;
  2970. }
  2971. }
  2972. return true;
  2973. }
  2974. static int ar9300_compress_decision(struct ath_hw *ah,
  2975. int it,
  2976. int code,
  2977. int reference,
  2978. u8 *mptr,
  2979. u8 *word, int length, int mdata_size)
  2980. {
  2981. struct ath_common *common = ath9k_hw_common(ah);
  2982. const struct ar9300_eeprom *eep = NULL;
  2983. switch (code) {
  2984. case _CompressNone:
  2985. if (length != mdata_size) {
  2986. ath_dbg(common, EEPROM,
  2987. "EEPROM structure size mismatch memory=%d eeprom=%d\n",
  2988. mdata_size, length);
  2989. return -1;
  2990. }
  2991. memcpy(mptr, (u8 *) (word + COMP_HDR_LEN), length);
  2992. ath_dbg(common, EEPROM,
  2993. "restored eeprom %d: uncompressed, length %d\n",
  2994. it, length);
  2995. break;
  2996. case _CompressBlock:
  2997. if (reference == 0) {
  2998. } else {
  2999. eep = ar9003_eeprom_struct_find_by_id(reference);
  3000. if (eep == NULL) {
  3001. ath_dbg(common, EEPROM,
  3002. "can't find reference eeprom struct %d\n",
  3003. reference);
  3004. return -1;
  3005. }
  3006. memcpy(mptr, eep, mdata_size);
  3007. }
  3008. ath_dbg(common, EEPROM,
  3009. "restore eeprom %d: block, reference %d, length %d\n",
  3010. it, reference, length);
  3011. ar9300_uncompress_block(ah, mptr, mdata_size,
  3012. (u8 *) (word + COMP_HDR_LEN), length);
  3013. break;
  3014. default:
  3015. ath_dbg(common, EEPROM, "unknown compression code %d\n", code);
  3016. return -1;
  3017. }
  3018. return 0;
  3019. }
  3020. typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer,
  3021. int count);
  3022. static bool ar9300_check_header(void *data)
  3023. {
  3024. u32 *word = data;
  3025. return !(*word == 0 || *word == ~0);
  3026. }
  3027. static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
  3028. int base_addr)
  3029. {
  3030. u8 header[4];
  3031. if (!read(ah, base_addr, header, 4))
  3032. return false;
  3033. return ar9300_check_header(header);
  3034. }
  3035. static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
  3036. int mdata_size)
  3037. {
  3038. struct ath_common *common = ath9k_hw_common(ah);
  3039. u16 *data = (u16 *) mptr;
  3040. int i;
  3041. for (i = 0; i < mdata_size / 2; i++, data++)
  3042. ath9k_hw_nvram_read(common, i, data);
  3043. return 0;
  3044. }
  3045. /*
  3046. * Read the configuration data from the eeprom.
  3047. * The data can be put in any specified memory buffer.
  3048. *
  3049. * Returns -1 on error.
  3050. * Returns address of next memory location on success.
  3051. */
  3052. static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
  3053. u8 *mptr, int mdata_size)
  3054. {
  3055. #define MDEFAULT 15
  3056. #define MSTATE 100
  3057. int cptr;
  3058. u8 *word;
  3059. int code;
  3060. int reference, length, major, minor;
  3061. int osize;
  3062. int it;
  3063. u16 checksum, mchecksum;
  3064. struct ath_common *common = ath9k_hw_common(ah);
  3065. eeprom_read_op read;
  3066. if (ath9k_hw_use_flash(ah))
  3067. return ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
  3068. word = kzalloc(2048, GFP_KERNEL);
  3069. if (!word)
  3070. return -ENOMEM;
  3071. memcpy(mptr, &ar9300_default, mdata_size);
  3072. read = ar9300_read_eeprom;
  3073. if (AR_SREV_9485(ah))
  3074. cptr = AR9300_BASE_ADDR_4K;
  3075. else if (AR_SREV_9330(ah))
  3076. cptr = AR9300_BASE_ADDR_512;
  3077. else
  3078. cptr = AR9300_BASE_ADDR;
  3079. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3080. cptr);
  3081. if (ar9300_check_eeprom_header(ah, read, cptr))
  3082. goto found;
  3083. cptr = AR9300_BASE_ADDR_512;
  3084. ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
  3085. cptr);
  3086. if (ar9300_check_eeprom_header(ah, read, cptr))
  3087. goto found;
  3088. read = ar9300_read_otp;
  3089. cptr = AR9300_BASE_ADDR;
  3090. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3091. if (ar9300_check_eeprom_header(ah, read, cptr))
  3092. goto found;
  3093. cptr = AR9300_BASE_ADDR_512;
  3094. ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
  3095. if (ar9300_check_eeprom_header(ah, read, cptr))
  3096. goto found;
  3097. goto fail;
  3098. found:
  3099. ath_dbg(common, EEPROM, "Found valid EEPROM data\n");
  3100. for (it = 0; it < MSTATE; it++) {
  3101. if (!read(ah, cptr, word, COMP_HDR_LEN))
  3102. goto fail;
  3103. if (!ar9300_check_header(word))
  3104. break;
  3105. ar9300_comp_hdr_unpack(word, &code, &reference,
  3106. &length, &major, &minor);
  3107. ath_dbg(common, EEPROM,
  3108. "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
  3109. cptr, code, reference, length, major, minor);
  3110. if ((!AR_SREV_9485(ah) && length >= 1024) ||
  3111. (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
  3112. ath_dbg(common, EEPROM, "Skipping bad header\n");
  3113. cptr -= COMP_HDR_LEN;
  3114. continue;
  3115. }
  3116. osize = length;
  3117. read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3118. checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
  3119. mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]);
  3120. ath_dbg(common, EEPROM, "checksum %x %x\n",
  3121. checksum, mchecksum);
  3122. if (checksum == mchecksum) {
  3123. ar9300_compress_decision(ah, it, code, reference, mptr,
  3124. word, length, mdata_size);
  3125. } else {
  3126. ath_dbg(common, EEPROM,
  3127. "skipping block with bad checksum\n");
  3128. }
  3129. cptr -= (COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3130. }
  3131. kfree(word);
  3132. return cptr;
  3133. fail:
  3134. kfree(word);
  3135. return -1;
  3136. }
  3137. /*
  3138. * Restore the configuration structure by reading the eeprom.
  3139. * This function destroys any existing in-memory structure
  3140. * content.
  3141. */
  3142. static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
  3143. {
  3144. u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
  3145. if (ar9300_eeprom_restore_internal(ah, mptr,
  3146. sizeof(struct ar9300_eeprom)) < 0)
  3147. return false;
  3148. return true;
  3149. }
  3150. #if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
  3151. static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
  3152. struct ar9300_modal_eep_header *modal_hdr)
  3153. {
  3154. PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
  3155. PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
  3156. PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
  3157. PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
  3158. PR_EEP("Ant. Common Control2", le32_to_cpu(modal_hdr->antCtrlCommon2));
  3159. PR_EEP("Ant. Gain", modal_hdr->antennaGain);
  3160. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  3161. PR_EEP("Chain0 xatten1DB", modal_hdr->xatten1DB[0]);
  3162. PR_EEP("Chain1 xatten1DB", modal_hdr->xatten1DB[1]);
  3163. PR_EEP("Chain2 xatten1DB", modal_hdr->xatten1DB[2]);
  3164. PR_EEP("Chain0 xatten1Margin", modal_hdr->xatten1Margin[0]);
  3165. PR_EEP("Chain1 xatten1Margin", modal_hdr->xatten1Margin[1]);
  3166. PR_EEP("Chain2 xatten1Margin", modal_hdr->xatten1Margin[2]);
  3167. PR_EEP("Temp Slope", modal_hdr->tempSlope);
  3168. PR_EEP("Volt Slope", modal_hdr->voltSlope);
  3169. PR_EEP("spur Channels0", modal_hdr->spurChans[0]);
  3170. PR_EEP("spur Channels1", modal_hdr->spurChans[1]);
  3171. PR_EEP("spur Channels2", modal_hdr->spurChans[2]);
  3172. PR_EEP("spur Channels3", modal_hdr->spurChans[3]);
  3173. PR_EEP("spur Channels4", modal_hdr->spurChans[4]);
  3174. PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
  3175. PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
  3176. PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
  3177. PR_EEP("Quick Drop", modal_hdr->quick_drop);
  3178. PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
  3179. PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
  3180. PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
  3181. PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
  3182. PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
  3183. PR_EEP("txClip", modal_hdr->txClip);
  3184. PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
  3185. return len;
  3186. }
  3187. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3188. u8 *buf, u32 len, u32 size)
  3189. {
  3190. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3191. struct ar9300_base_eep_hdr *pBase;
  3192. if (!dump_base_hdr) {
  3193. len += snprintf(buf + len, size - len,
  3194. "%20s :\n", "2GHz modal Header");
  3195. len += ar9003_dump_modal_eeprom(buf, len, size,
  3196. &eep->modalHeader2G);
  3197. len += snprintf(buf + len, size - len,
  3198. "%20s :\n", "5GHz modal Header");
  3199. len += ar9003_dump_modal_eeprom(buf, len, size,
  3200. &eep->modalHeader5G);
  3201. goto out;
  3202. }
  3203. pBase = &eep->baseEepHeader;
  3204. PR_EEP("EEPROM Version", ah->eeprom.ar9300_eep.eepromVersion);
  3205. PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
  3206. PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
  3207. PR_EEP("TX Mask", (pBase->txrxMask >> 4));
  3208. PR_EEP("RX Mask", (pBase->txrxMask & 0x0f));
  3209. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags.opFlags &
  3210. AR5416_OPFLAGS_11A));
  3211. PR_EEP("Allow 2GHz", !!(pBase->opCapFlags.opFlags &
  3212. AR5416_OPFLAGS_11G));
  3213. PR_EEP("Disable 2GHz HT20", !!(pBase->opCapFlags.opFlags &
  3214. AR5416_OPFLAGS_N_2G_HT20));
  3215. PR_EEP("Disable 2GHz HT40", !!(pBase->opCapFlags.opFlags &
  3216. AR5416_OPFLAGS_N_2G_HT40));
  3217. PR_EEP("Disable 5Ghz HT20", !!(pBase->opCapFlags.opFlags &
  3218. AR5416_OPFLAGS_N_5G_HT20));
  3219. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags &
  3220. AR5416_OPFLAGS_N_5G_HT40));
  3221. PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & 0x01));
  3222. PR_EEP("RF Silent", pBase->rfSilent);
  3223. PR_EEP("BT option", pBase->blueToothOptions);
  3224. PR_EEP("Device Cap", pBase->deviceCap);
  3225. PR_EEP("Device Type", pBase->deviceType);
  3226. PR_EEP("Power Table Offset", pBase->pwrTableOffset);
  3227. PR_EEP("Tuning Caps1", pBase->params_for_tuning_caps[0]);
  3228. PR_EEP("Tuning Caps2", pBase->params_for_tuning_caps[1]);
  3229. PR_EEP("Enable Tx Temp Comp", !!(pBase->featureEnable & BIT(0)));
  3230. PR_EEP("Enable Tx Volt Comp", !!(pBase->featureEnable & BIT(1)));
  3231. PR_EEP("Enable fast clock", !!(pBase->featureEnable & BIT(2)));
  3232. PR_EEP("Enable doubling", !!(pBase->featureEnable & BIT(3)));
  3233. PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4)));
  3234. PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5)));
  3235. PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0)));
  3236. PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1)));
  3237. PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1);
  3238. PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio);
  3239. PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio);
  3240. PR_EEP("WLAN LED Gpio", pBase->wlanLedGpio);
  3241. PR_EEP("Rx Band Select Gpio", pBase->rxBandSelectGpio);
  3242. PR_EEP("Tx Gain", pBase->txrxgain >> 4);
  3243. PR_EEP("Rx Gain", pBase->txrxgain & 0xf);
  3244. PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));
  3245. len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  3246. ah->eeprom.ar9300_eep.macAddr);
  3247. out:
  3248. if (len > size)
  3249. len = size;
  3250. return len;
  3251. }
  3252. #else
  3253. static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  3254. u8 *buf, u32 len, u32 size)
  3255. {
  3256. return 0;
  3257. }
  3258. #endif
  3259. /* XXX: review hardware docs */
  3260. static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
  3261. {
  3262. return ah->eeprom.ar9300_eep.eepromVersion;
  3263. }
  3264. /* XXX: could be read from the eepromVersion, not sure yet */
  3265. static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
  3266. {
  3267. return 0;
  3268. }
  3269. static s32 ar9003_hw_xpa_bias_level_get(struct ath_hw *ah, bool is2ghz)
  3270. {
  3271. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3272. if (is2ghz)
  3273. return eep->modalHeader2G.xpaBiasLvl;
  3274. else
  3275. return eep->modalHeader5G.xpaBiasLvl;
  3276. }
  3277. static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
  3278. {
  3279. int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz);
  3280. if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah))
  3281. REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
  3282. else if (AR_SREV_9462(ah))
  3283. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3284. else {
  3285. REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
  3286. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3287. AR_CH0_THERM_XPABIASLVL_MSB,
  3288. bias >> 2);
  3289. REG_RMW_FIELD(ah, AR_CH0_THERM,
  3290. AR_CH0_THERM_XPASHORT2GND, 1);
  3291. }
  3292. }
  3293. static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is_2ghz)
  3294. {
  3295. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3296. __le16 val;
  3297. if (is_2ghz)
  3298. val = eep->modalHeader2G.switchcomspdt;
  3299. else
  3300. val = eep->modalHeader5G.switchcomspdt;
  3301. return le16_to_cpu(val);
  3302. }
  3303. static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
  3304. {
  3305. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3306. __le32 val;
  3307. if (is2ghz)
  3308. val = eep->modalHeader2G.antCtrlCommon;
  3309. else
  3310. val = eep->modalHeader5G.antCtrlCommon;
  3311. return le32_to_cpu(val);
  3312. }
  3313. static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
  3314. {
  3315. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3316. __le32 val;
  3317. if (is2ghz)
  3318. val = eep->modalHeader2G.antCtrlCommon2;
  3319. else
  3320. val = eep->modalHeader5G.antCtrlCommon2;
  3321. return le32_to_cpu(val);
  3322. }
  3323. static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
  3324. int chain,
  3325. bool is2ghz)
  3326. {
  3327. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3328. __le16 val = 0;
  3329. if (chain >= 0 && chain < AR9300_MAX_CHAINS) {
  3330. if (is2ghz)
  3331. val = eep->modalHeader2G.antCtrlChain[chain];
  3332. else
  3333. val = eep->modalHeader5G.antCtrlChain[chain];
  3334. }
  3335. return le16_to_cpu(val);
  3336. }
  3337. static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
  3338. {
  3339. int chain;
  3340. u32 regval;
  3341. u32 ant_div_ctl1;
  3342. static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
  3343. AR_PHY_SWITCH_CHAIN_0,
  3344. AR_PHY_SWITCH_CHAIN_1,
  3345. AR_PHY_SWITCH_CHAIN_2,
  3346. };
  3347. u32 value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz);
  3348. if (AR_SREV_9462(ah)) {
  3349. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3350. AR_SWITCH_TABLE_COM_AR9462_ALL, value);
  3351. } else
  3352. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
  3353. AR_SWITCH_TABLE_COM_ALL, value);
  3354. /*
  3355. * AR9462 defines new switch table for BT/WLAN,
  3356. * here's new field name in XXX.ref for both 2G and 5G.
  3357. * Register: [GLB_CONTROL] GLB_CONTROL (@0x20044)
  3358. * 15:12 R/W SWITCH_TABLE_COM_SPDT_WLAN_RX
  3359. * SWITCH_TABLE_COM_SPDT_WLAN_RX
  3360. *
  3361. * 11:8 R/W SWITCH_TABLE_COM_SPDT_WLAN_TX
  3362. * SWITCH_TABLE_COM_SPDT_WLAN_TX
  3363. *
  3364. * 7:4 R/W SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3365. * SWITCH_TABLE_COM_SPDT_WLAN_IDLE
  3366. */
  3367. if (AR_SREV_9462_20_OR_LATER(ah)) {
  3368. value = ar9003_switch_com_spdt_get(ah, is2ghz);
  3369. REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL,
  3370. AR_SWITCH_TABLE_COM_SPDT_ALL, value);
  3371. }
  3372. value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
  3373. REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
  3374. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  3375. if ((ah->rxchainmask & BIT(chain)) ||
  3376. (ah->txchainmask & BIT(chain))) {
  3377. value = ar9003_hw_ant_ctrl_chain_get(ah, chain,
  3378. is2ghz);
  3379. REG_RMW_FIELD(ah, switch_chain_reg[chain],
  3380. AR_SWITCH_TABLE_ALL, value);
  3381. }
  3382. }
  3383. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3384. value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
  3385. /*
  3386. * main_lnaconf, alt_lnaconf, main_tb, alt_tb
  3387. * are the fields present
  3388. */
  3389. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3390. regval &= (~AR_ANT_DIV_CTRL_ALL);
  3391. regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
  3392. /* enable_lnadiv */
  3393. regval &= (~AR_PHY_9485_ANT_DIV_LNADIV);
  3394. regval |= ((value >> 6) & 0x1) <<
  3395. AR_PHY_9485_ANT_DIV_LNADIV_S;
  3396. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3397. /*enable fast_div */
  3398. regval = REG_READ(ah, AR_PHY_CCK_DETECT);
  3399. regval &= (~AR_FAST_DIV_ENABLE);
  3400. regval |= ((value >> 7) & 0x1) <<
  3401. AR_FAST_DIV_ENABLE_S;
  3402. REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
  3403. ant_div_ctl1 =
  3404. ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
  3405. /* check whether antenna diversity is enabled */
  3406. if ((ant_div_ctl1 >> 0x6) == 0x3) {
  3407. regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
  3408. /*
  3409. * clear bits 25-30 main_lnaconf, alt_lnaconf,
  3410. * main_tb, alt_tb
  3411. */
  3412. regval &= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
  3413. AR_PHY_9485_ANT_DIV_ALT_LNACONF |
  3414. AR_PHY_9485_ANT_DIV_ALT_GAINTB |
  3415. AR_PHY_9485_ANT_DIV_MAIN_GAINTB));
  3416. /* by default use LNA1 for the main antenna */
  3417. regval |= (AR_PHY_9485_ANT_DIV_LNA1 <<
  3418. AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S);
  3419. regval |= (AR_PHY_9485_ANT_DIV_LNA2 <<
  3420. AR_PHY_9485_ANT_DIV_ALT_LNACONF_S);
  3421. REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
  3422. }
  3423. }
  3424. }
  3425. static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
  3426. {
  3427. int drive_strength;
  3428. unsigned long reg;
  3429. drive_strength = ath9k_hw_ar9300_get_eeprom(ah, EEP_DRIVE_STRENGTH);
  3430. if (!drive_strength)
  3431. return;
  3432. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS1);
  3433. reg &= ~0x00ffffc0;
  3434. reg |= 0x5 << 21;
  3435. reg |= 0x5 << 18;
  3436. reg |= 0x5 << 15;
  3437. reg |= 0x5 << 12;
  3438. reg |= 0x5 << 9;
  3439. reg |= 0x5 << 6;
  3440. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS1, reg);
  3441. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS2);
  3442. reg &= ~0xffffffe0;
  3443. reg |= 0x5 << 29;
  3444. reg |= 0x5 << 26;
  3445. reg |= 0x5 << 23;
  3446. reg |= 0x5 << 20;
  3447. reg |= 0x5 << 17;
  3448. reg |= 0x5 << 14;
  3449. reg |= 0x5 << 11;
  3450. reg |= 0x5 << 8;
  3451. reg |= 0x5 << 5;
  3452. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS2, reg);
  3453. reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS4);
  3454. reg &= ~0xff800000;
  3455. reg |= 0x5 << 29;
  3456. reg |= 0x5 << 26;
  3457. reg |= 0x5 << 23;
  3458. REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS4, reg);
  3459. }
  3460. static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain,
  3461. struct ath9k_channel *chan)
  3462. {
  3463. int f[3], t[3];
  3464. u16 value;
  3465. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3466. if (chain >= 0 && chain < 3) {
  3467. if (IS_CHAN_2GHZ(chan))
  3468. return eep->modalHeader2G.xatten1DB[chain];
  3469. else if (eep->base_ext2.xatten1DBLow[chain] != 0) {
  3470. t[0] = eep->base_ext2.xatten1DBLow[chain];
  3471. f[0] = 5180;
  3472. t[1] = eep->modalHeader5G.xatten1DB[chain];
  3473. f[1] = 5500;
  3474. t[2] = eep->base_ext2.xatten1DBHigh[chain];
  3475. f[2] = 5785;
  3476. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3477. f, t, 3);
  3478. return value;
  3479. } else
  3480. return eep->modalHeader5G.xatten1DB[chain];
  3481. }
  3482. return 0;
  3483. }
  3484. static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain,
  3485. struct ath9k_channel *chan)
  3486. {
  3487. int f[3], t[3];
  3488. u16 value;
  3489. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3490. if (chain >= 0 && chain < 3) {
  3491. if (IS_CHAN_2GHZ(chan))
  3492. return eep->modalHeader2G.xatten1Margin[chain];
  3493. else if (eep->base_ext2.xatten1MarginLow[chain] != 0) {
  3494. t[0] = eep->base_ext2.xatten1MarginLow[chain];
  3495. f[0] = 5180;
  3496. t[1] = eep->modalHeader5G.xatten1Margin[chain];
  3497. f[1] = 5500;
  3498. t[2] = eep->base_ext2.xatten1MarginHigh[chain];
  3499. f[2] = 5785;
  3500. value = ar9003_hw_power_interpolate((s32) chan->channel,
  3501. f, t, 3);
  3502. return value;
  3503. } else
  3504. return eep->modalHeader5G.xatten1Margin[chain];
  3505. }
  3506. return 0;
  3507. }
  3508. static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan)
  3509. {
  3510. int i;
  3511. u16 value;
  3512. unsigned long ext_atten_reg[3] = {AR_PHY_EXT_ATTEN_CTL_0,
  3513. AR_PHY_EXT_ATTEN_CTL_1,
  3514. AR_PHY_EXT_ATTEN_CTL_2,
  3515. };
  3516. /* Test value. if 0 then attenuation is unused. Don't load anything. */
  3517. for (i = 0; i < 3; i++) {
  3518. if (ah->txchainmask & BIT(i)) {
  3519. value = ar9003_hw_atten_chain_get(ah, i, chan);
  3520. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3521. AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
  3522. value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
  3523. REG_RMW_FIELD(ah, ext_atten_reg[i],
  3524. AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
  3525. value);
  3526. }
  3527. }
  3528. }
  3529. static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set)
  3530. {
  3531. int timeout = 100;
  3532. while (pmu_set != REG_READ(ah, pmu_reg)) {
  3533. if (timeout-- == 0)
  3534. return false;
  3535. REG_WRITE(ah, pmu_reg, pmu_set);
  3536. udelay(10);
  3537. }
  3538. return true;
  3539. }
  3540. void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
  3541. {
  3542. int internal_regulator =
  3543. ath9k_hw_ar9300_get_eeprom(ah, EEP_INTERNAL_REGULATOR);
  3544. u32 reg_val;
  3545. if (internal_regulator) {
  3546. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3547. int reg_pmu_set;
  3548. reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM;
  3549. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3550. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3551. return;
  3552. if (AR_SREV_9330(ah)) {
  3553. if (ah->is_clk_25mhz) {
  3554. reg_pmu_set = (3 << 1) | (8 << 4) |
  3555. (3 << 8) | (1 << 14) |
  3556. (6 << 17) | (1 << 20) |
  3557. (3 << 24);
  3558. } else {
  3559. reg_pmu_set = (4 << 1) | (7 << 4) |
  3560. (3 << 8) | (1 << 14) |
  3561. (6 << 17) | (1 << 20) |
  3562. (3 << 24);
  3563. }
  3564. } else {
  3565. reg_pmu_set = (5 << 1) | (7 << 4) |
  3566. (2 << 8) | (2 << 14) |
  3567. (6 << 17) | (1 << 20) |
  3568. (3 << 24) | (1 << 28);
  3569. }
  3570. REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set);
  3571. if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set))
  3572. return;
  3573. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0xFFC00000)
  3574. | (4 << 26);
  3575. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3576. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3577. return;
  3578. reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0x00200000)
  3579. | (1 << 21);
  3580. REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
  3581. if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
  3582. return;
  3583. } else if (AR_SREV_9462(ah)) {
  3584. reg_val = ath9k_hw_ar9300_get_eeprom(ah, EEP_SWREG);
  3585. REG_WRITE(ah, AR_PHY_PMU1, reg_val);
  3586. } else {
  3587. /* Internal regulator is ON. Write swreg register. */
  3588. reg_val = ath9k_hw_ar9300_get_eeprom(ah, EEP_SWREG);
  3589. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3590. REG_READ(ah, AR_RTC_REG_CONTROL1) &
  3591. (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM));
  3592. REG_WRITE(ah, AR_RTC_REG_CONTROL0, reg_val);
  3593. /* Set REG_CONTROL1.SWREG_PROGRAM */
  3594. REG_WRITE(ah, AR_RTC_REG_CONTROL1,
  3595. REG_READ(ah,
  3596. AR_RTC_REG_CONTROL1) |
  3597. AR_RTC_REG_CONTROL1_SWREG_PROGRAM);
  3598. }
  3599. } else {
  3600. if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
  3601. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0);
  3602. while (REG_READ_FIELD(ah, AR_PHY_PMU2,
  3603. AR_PHY_PMU2_PGM))
  3604. udelay(10);
  3605. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3606. while (!REG_READ_FIELD(ah, AR_PHY_PMU1,
  3607. AR_PHY_PMU1_PWD))
  3608. udelay(10);
  3609. REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0x1);
  3610. while (!REG_READ_FIELD(ah, AR_PHY_PMU2,
  3611. AR_PHY_PMU2_PGM))
  3612. udelay(10);
  3613. } else if (AR_SREV_9462(ah))
  3614. REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
  3615. else {
  3616. reg_val = REG_READ(ah, AR_RTC_SLEEP_CLK) |
  3617. AR_RTC_FORCE_SWREG_PRD;
  3618. REG_WRITE(ah, AR_RTC_SLEEP_CLK, reg_val);
  3619. }
  3620. }
  3621. }
  3622. static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)
  3623. {
  3624. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3625. u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0];
  3626. if (eep->baseEepHeader.featureEnable & 0x40) {
  3627. tuning_caps_param &= 0x7f;
  3628. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC,
  3629. tuning_caps_param);
  3630. REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPOUTDAC,
  3631. tuning_caps_param);
  3632. }
  3633. }
  3634. static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
  3635. {
  3636. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3637. int quick_drop = ath9k_hw_ar9300_get_eeprom(ah, EEP_QUICK_DROP);
  3638. s32 t[3], f[3] = {5180, 5500, 5785};
  3639. if (!quick_drop)
  3640. return;
  3641. if (freq < 4000)
  3642. quick_drop = eep->modalHeader2G.quick_drop;
  3643. else {
  3644. t[0] = eep->base_ext1.quick_drop_low;
  3645. t[1] = eep->modalHeader5G.quick_drop;
  3646. t[2] = eep->base_ext1.quick_drop_high;
  3647. quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
  3648. }
  3649. REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
  3650. }
  3651. static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, u16 freq)
  3652. {
  3653. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3654. u32 value;
  3655. value = (freq < 4000) ? eep->modalHeader2G.txEndToXpaOff :
  3656. eep->modalHeader5G.txEndToXpaOff;
  3657. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3658. AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value);
  3659. REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
  3660. AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value);
  3661. }
  3662. static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah,
  3663. struct ath9k_channel *chan)
  3664. {
  3665. ar9003_hw_xpa_bias_level_apply(ah, IS_CHAN_2GHZ(chan));
  3666. ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan));
  3667. ar9003_hw_drive_strength_apply(ah);
  3668. ar9003_hw_atten_apply(ah, chan);
  3669. ar9003_hw_quick_drop_apply(ah, chan->channel);
  3670. if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah))
  3671. ar9003_hw_internal_regulator_apply(ah);
  3672. if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah))
  3673. ar9003_hw_apply_tuning_caps(ah);
  3674. ar9003_hw_txend_to_xpa_off_apply(ah, chan->channel);
  3675. }
  3676. static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah,
  3677. struct ath9k_channel *chan)
  3678. {
  3679. }
  3680. /*
  3681. * Returns the interpolated y value corresponding to the specified x value
  3682. * from the np ordered pairs of data (px,py).
  3683. * The pairs do not have to be in any order.
  3684. * If the specified x value is less than any of the px,
  3685. * the returned y value is equal to the py for the lowest px.
  3686. * If the specified x value is greater than any of the px,
  3687. * the returned y value is equal to the py for the highest px.
  3688. */
  3689. static int ar9003_hw_power_interpolate(int32_t x,
  3690. int32_t *px, int32_t *py, u_int16_t np)
  3691. {
  3692. int ip = 0;
  3693. int lx = 0, ly = 0, lhave = 0;
  3694. int hx = 0, hy = 0, hhave = 0;
  3695. int dx = 0;
  3696. int y = 0;
  3697. lhave = 0;
  3698. hhave = 0;
  3699. /* identify best lower and higher x calibration measurement */
  3700. for (ip = 0; ip < np; ip++) {
  3701. dx = x - px[ip];
  3702. /* this measurement is higher than our desired x */
  3703. if (dx <= 0) {
  3704. if (!hhave || dx > (x - hx)) {
  3705. /* new best higher x measurement */
  3706. hx = px[ip];
  3707. hy = py[ip];
  3708. hhave = 1;
  3709. }
  3710. }
  3711. /* this measurement is lower than our desired x */
  3712. if (dx >= 0) {
  3713. if (!lhave || dx < (x - lx)) {
  3714. /* new best lower x measurement */
  3715. lx = px[ip];
  3716. ly = py[ip];
  3717. lhave = 1;
  3718. }
  3719. }
  3720. }
  3721. /* the low x is good */
  3722. if (lhave) {
  3723. /* so is the high x */
  3724. if (hhave) {
  3725. /* they're the same, so just pick one */
  3726. if (hx == lx)
  3727. y = ly;
  3728. else /* interpolate */
  3729. y = interpolate(x, lx, hx, ly, hy);
  3730. } else /* only low is good, use it */
  3731. y = ly;
  3732. } else if (hhave) /* only high is good, use it */
  3733. y = hy;
  3734. else /* nothing is good,this should never happen unless np=0, ???? */
  3735. y = -(1 << 30);
  3736. return y;
  3737. }
  3738. static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
  3739. u16 rateIndex, u16 freq, bool is2GHz)
  3740. {
  3741. u16 numPiers, i;
  3742. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3743. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3744. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3745. struct cal_tgt_pow_legacy *pEepromTargetPwr;
  3746. u8 *pFreqBin;
  3747. if (is2GHz) {
  3748. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  3749. pEepromTargetPwr = eep->calTargetPower2G;
  3750. pFreqBin = eep->calTarget_freqbin_2G;
  3751. } else {
  3752. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  3753. pEepromTargetPwr = eep->calTargetPower5G;
  3754. pFreqBin = eep->calTarget_freqbin_5G;
  3755. }
  3756. /*
  3757. * create array of channels and targetpower from
  3758. * targetpower piers stored on eeprom
  3759. */
  3760. for (i = 0; i < numPiers; i++) {
  3761. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  3762. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3763. }
  3764. /* interpolate to get target power for given frequency */
  3765. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3766. freqArray,
  3767. targetPowerArray, numPiers);
  3768. }
  3769. static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
  3770. u16 rateIndex,
  3771. u16 freq, bool is2GHz)
  3772. {
  3773. u16 numPiers, i;
  3774. s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3775. s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
  3776. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3777. struct cal_tgt_pow_ht *pEepromTargetPwr;
  3778. u8 *pFreqBin;
  3779. if (is2GHz) {
  3780. numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
  3781. pEepromTargetPwr = eep->calTargetPower2GHT20;
  3782. pFreqBin = eep->calTarget_freqbin_2GHT20;
  3783. } else {
  3784. numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
  3785. pEepromTargetPwr = eep->calTargetPower5GHT20;
  3786. pFreqBin = eep->calTarget_freqbin_5GHT20;
  3787. }
  3788. /*
  3789. * create array of channels and targetpower
  3790. * from targetpower piers stored on eeprom
  3791. */
  3792. for (i = 0; i < numPiers; i++) {
  3793. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  3794. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3795. }
  3796. /* interpolate to get target power for given frequency */
  3797. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3798. freqArray,
  3799. targetPowerArray, numPiers);
  3800. }
  3801. static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
  3802. u16 rateIndex,
  3803. u16 freq, bool is2GHz)
  3804. {
  3805. u16 numPiers, i;
  3806. s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS];
  3807. s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS];
  3808. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3809. struct cal_tgt_pow_ht *pEepromTargetPwr;
  3810. u8 *pFreqBin;
  3811. if (is2GHz) {
  3812. numPiers = AR9300_NUM_2G_40_TARGET_POWERS;
  3813. pEepromTargetPwr = eep->calTargetPower2GHT40;
  3814. pFreqBin = eep->calTarget_freqbin_2GHT40;
  3815. } else {
  3816. numPiers = AR9300_NUM_5G_40_TARGET_POWERS;
  3817. pEepromTargetPwr = eep->calTargetPower5GHT40;
  3818. pFreqBin = eep->calTarget_freqbin_5GHT40;
  3819. }
  3820. /*
  3821. * create array of channels and targetpower from
  3822. * targetpower piers stored on eeprom
  3823. */
  3824. for (i = 0; i < numPiers; i++) {
  3825. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
  3826. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3827. }
  3828. /* interpolate to get target power for given frequency */
  3829. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3830. freqArray,
  3831. targetPowerArray, numPiers);
  3832. }
  3833. static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah,
  3834. u16 rateIndex, u16 freq)
  3835. {
  3836. u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i;
  3837. s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  3838. s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
  3839. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  3840. struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck;
  3841. u8 *pFreqBin = eep->calTarget_freqbin_Cck;
  3842. /*
  3843. * create array of channels and targetpower from
  3844. * targetpower piers stored on eeprom
  3845. */
  3846. for (i = 0; i < numPiers; i++) {
  3847. freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
  3848. targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
  3849. }
  3850. /* interpolate to get target power for given frequency */
  3851. return (u8) ar9003_hw_power_interpolate((s32) freq,
  3852. freqArray,
  3853. targetPowerArray, numPiers);
  3854. }
  3855. /* Set tx power registers to array of values passed in */
  3856. static int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray)
  3857. {
  3858. #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
  3859. /* make sure forced gain is not set */
  3860. REG_WRITE(ah, AR_PHY_TX_FORCED_GAIN, 0);
  3861. /* Write the OFDM power per rate set */
  3862. /* 6 (LSB), 9, 12, 18 (MSB) */
  3863. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(0),
  3864. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  3865. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) |
  3866. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  3867. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  3868. /* 24 (LSB), 36, 48, 54 (MSB) */
  3869. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(1),
  3870. POW_SM(pPwrArray[ALL_TARGET_LEGACY_54], 24) |
  3871. POW_SM(pPwrArray[ALL_TARGET_LEGACY_48], 16) |
  3872. POW_SM(pPwrArray[ALL_TARGET_LEGACY_36], 8) |
  3873. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
  3874. /* Write the CCK power per rate set */
  3875. /* 1L (LSB), reserved, 2L, 2S (MSB) */
  3876. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(2),
  3877. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 24) |
  3878. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  3879. /* POW_SM(txPowerTimes2, 8) | this is reserved for AR9003 */
  3880. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0));
  3881. /* 5.5L (LSB), 5.5S, 11L, 11S (MSB) */
  3882. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(3),
  3883. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11S], 24) |
  3884. POW_SM(pPwrArray[ALL_TARGET_LEGACY_11L], 16) |
  3885. POW_SM(pPwrArray[ALL_TARGET_LEGACY_5S], 8) |
  3886. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  3887. );
  3888. /* Write the power for duplicated frames - HT40 */
  3889. /* dup40_cck (LSB), dup40_ofdm, ext20_cck, ext20_ofdm (MSB) */
  3890. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(8),
  3891. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
  3892. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
  3893. POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
  3894. POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
  3895. );
  3896. /* Write the HT20 power per rate set */
  3897. /* 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB) */
  3898. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(4),
  3899. POW_SM(pPwrArray[ALL_TARGET_HT20_5], 24) |
  3900. POW_SM(pPwrArray[ALL_TARGET_HT20_4], 16) |
  3901. POW_SM(pPwrArray[ALL_TARGET_HT20_1_3_9_11_17_19], 8) |
  3902. POW_SM(pPwrArray[ALL_TARGET_HT20_0_8_16], 0)
  3903. );
  3904. /* 6 (LSB), 7, 12, 13 (MSB) */
  3905. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(5),
  3906. POW_SM(pPwrArray[ALL_TARGET_HT20_13], 24) |
  3907. POW_SM(pPwrArray[ALL_TARGET_HT20_12], 16) |
  3908. POW_SM(pPwrArray[ALL_TARGET_HT20_7], 8) |
  3909. POW_SM(pPwrArray[ALL_TARGET_HT20_6], 0)
  3910. );
  3911. /* 14 (LSB), 15, 20, 21 */
  3912. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(9),
  3913. POW_SM(pPwrArray[ALL_TARGET_HT20_21], 24) |
  3914. POW_SM(pPwrArray[ALL_TARGET_HT20_20], 16) |
  3915. POW_SM(pPwrArray[ALL_TARGET_HT20_15], 8) |
  3916. POW_SM(pPwrArray[ALL_TARGET_HT20_14], 0)
  3917. );
  3918. /* Mixed HT20 and HT40 rates */
  3919. /* HT20 22 (LSB), HT20 23, HT40 22, HT40 23 (MSB) */
  3920. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(10),
  3921. POW_SM(pPwrArray[ALL_TARGET_HT40_23], 24) |
  3922. POW_SM(pPwrArray[ALL_TARGET_HT40_22], 16) |
  3923. POW_SM(pPwrArray[ALL_TARGET_HT20_23], 8) |
  3924. POW_SM(pPwrArray[ALL_TARGET_HT20_22], 0)
  3925. );
  3926. /*
  3927. * Write the HT40 power per rate set
  3928. * correct PAR difference between HT40 and HT20/LEGACY
  3929. * 0/8/16 (LSB), 1-3/9-11/17-19, 4, 5 (MSB)
  3930. */
  3931. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(6),
  3932. POW_SM(pPwrArray[ALL_TARGET_HT40_5], 24) |
  3933. POW_SM(pPwrArray[ALL_TARGET_HT40_4], 16) |
  3934. POW_SM(pPwrArray[ALL_TARGET_HT40_1_3_9_11_17_19], 8) |
  3935. POW_SM(pPwrArray[ALL_TARGET_HT40_0_8_16], 0)
  3936. );
  3937. /* 6 (LSB), 7, 12, 13 (MSB) */
  3938. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(7),
  3939. POW_SM(pPwrArray[ALL_TARGET_HT40_13], 24) |
  3940. POW_SM(pPwrArray[ALL_TARGET_HT40_12], 16) |
  3941. POW_SM(pPwrArray[ALL_TARGET_HT40_7], 8) |
  3942. POW_SM(pPwrArray[ALL_TARGET_HT40_6], 0)
  3943. );
  3944. /* 14 (LSB), 15, 20, 21 */
  3945. REG_WRITE(ah, AR_PHY_POWER_TX_RATE(11),
  3946. POW_SM(pPwrArray[ALL_TARGET_HT40_21], 24) |
  3947. POW_SM(pPwrArray[ALL_TARGET_HT40_20], 16) |
  3948. POW_SM(pPwrArray[ALL_TARGET_HT40_15], 8) |
  3949. POW_SM(pPwrArray[ALL_TARGET_HT40_14], 0)
  3950. );
  3951. return 0;
  3952. #undef POW_SM
  3953. }
  3954. static void ar9003_hw_get_legacy_target_powers(struct ath_hw *ah, u16 freq,
  3955. u8 *targetPowerValT2,
  3956. bool is2GHz)
  3957. {
  3958. targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
  3959. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
  3960. is2GHz);
  3961. targetPowerValT2[ALL_TARGET_LEGACY_36] =
  3962. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_36, freq,
  3963. is2GHz);
  3964. targetPowerValT2[ALL_TARGET_LEGACY_48] =
  3965. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_48, freq,
  3966. is2GHz);
  3967. targetPowerValT2[ALL_TARGET_LEGACY_54] =
  3968. ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq,
  3969. is2GHz);
  3970. }
  3971. static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
  3972. u8 *targetPowerValT2)
  3973. {
  3974. targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
  3975. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
  3976. freq);
  3977. targetPowerValT2[ALL_TARGET_LEGACY_5S] =
  3978. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_5S, freq);
  3979. targetPowerValT2[ALL_TARGET_LEGACY_11L] =
  3980. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq);
  3981. targetPowerValT2[ALL_TARGET_LEGACY_11S] =
  3982. ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq);
  3983. }
  3984. static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
  3985. u8 *targetPowerValT2, bool is2GHz)
  3986. {
  3987. targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
  3988. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  3989. is2GHz);
  3990. targetPowerValT2[ALL_TARGET_HT20_1_3_9_11_17_19] =
  3991. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  3992. freq, is2GHz);
  3993. targetPowerValT2[ALL_TARGET_HT20_4] =
  3994. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  3995. is2GHz);
  3996. targetPowerValT2[ALL_TARGET_HT20_5] =
  3997. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  3998. is2GHz);
  3999. targetPowerValT2[ALL_TARGET_HT20_6] =
  4000. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4001. is2GHz);
  4002. targetPowerValT2[ALL_TARGET_HT20_7] =
  4003. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4004. is2GHz);
  4005. targetPowerValT2[ALL_TARGET_HT20_12] =
  4006. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4007. is2GHz);
  4008. targetPowerValT2[ALL_TARGET_HT20_13] =
  4009. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4010. is2GHz);
  4011. targetPowerValT2[ALL_TARGET_HT20_14] =
  4012. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4013. is2GHz);
  4014. targetPowerValT2[ALL_TARGET_HT20_15] =
  4015. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4016. is2GHz);
  4017. targetPowerValT2[ALL_TARGET_HT20_20] =
  4018. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4019. is2GHz);
  4020. targetPowerValT2[ALL_TARGET_HT20_21] =
  4021. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4022. is2GHz);
  4023. targetPowerValT2[ALL_TARGET_HT20_22] =
  4024. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4025. is2GHz);
  4026. targetPowerValT2[ALL_TARGET_HT20_23] =
  4027. ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4028. is2GHz);
  4029. }
  4030. static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
  4031. u16 freq,
  4032. u8 *targetPowerValT2,
  4033. bool is2GHz)
  4034. {
  4035. /* XXX: hard code for now, need to get from eeprom struct */
  4036. u8 ht40PowerIncForPdadc = 0;
  4037. targetPowerValT2[ALL_TARGET_HT40_0_8_16] =
  4038. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
  4039. is2GHz) + ht40PowerIncForPdadc;
  4040. targetPowerValT2[ALL_TARGET_HT40_1_3_9_11_17_19] =
  4041. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
  4042. freq,
  4043. is2GHz) + ht40PowerIncForPdadc;
  4044. targetPowerValT2[ALL_TARGET_HT40_4] =
  4045. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
  4046. is2GHz) + ht40PowerIncForPdadc;
  4047. targetPowerValT2[ALL_TARGET_HT40_5] =
  4048. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
  4049. is2GHz) + ht40PowerIncForPdadc;
  4050. targetPowerValT2[ALL_TARGET_HT40_6] =
  4051. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
  4052. is2GHz) + ht40PowerIncForPdadc;
  4053. targetPowerValT2[ALL_TARGET_HT40_7] =
  4054. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
  4055. is2GHz) + ht40PowerIncForPdadc;
  4056. targetPowerValT2[ALL_TARGET_HT40_12] =
  4057. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
  4058. is2GHz) + ht40PowerIncForPdadc;
  4059. targetPowerValT2[ALL_TARGET_HT40_13] =
  4060. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
  4061. is2GHz) + ht40PowerIncForPdadc;
  4062. targetPowerValT2[ALL_TARGET_HT40_14] =
  4063. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
  4064. is2GHz) + ht40PowerIncForPdadc;
  4065. targetPowerValT2[ALL_TARGET_HT40_15] =
  4066. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
  4067. is2GHz) + ht40PowerIncForPdadc;
  4068. targetPowerValT2[ALL_TARGET_HT40_20] =
  4069. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
  4070. is2GHz) + ht40PowerIncForPdadc;
  4071. targetPowerValT2[ALL_TARGET_HT40_21] =
  4072. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
  4073. is2GHz) + ht40PowerIncForPdadc;
  4074. targetPowerValT2[ALL_TARGET_HT40_22] =
  4075. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
  4076. is2GHz) + ht40PowerIncForPdadc;
  4077. targetPowerValT2[ALL_TARGET_HT40_23] =
  4078. ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
  4079. is2GHz) + ht40PowerIncForPdadc;
  4080. }
  4081. static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
  4082. struct ath9k_channel *chan,
  4083. u8 *targetPowerValT2)
  4084. {
  4085. bool is2GHz = IS_CHAN_2GHZ(chan);
  4086. unsigned int i = 0;
  4087. struct ath_common *common = ath9k_hw_common(ah);
  4088. u16 freq = chan->channel;
  4089. if (is2GHz)
  4090. ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
  4091. ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4092. ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
  4093. if (IS_CHAN_HT40(chan))
  4094. ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
  4095. is2GHz);
  4096. for (i = 0; i < ar9300RateSize; i++) {
  4097. ath_dbg(common, EEPROM, "TPC[%02d] 0x%08x\n",
  4098. i, targetPowerValT2[i]);
  4099. }
  4100. }
  4101. static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
  4102. int mode,
  4103. int ipier,
  4104. int ichain,
  4105. int *pfrequency,
  4106. int *pcorrection,
  4107. int *ptemperature, int *pvoltage)
  4108. {
  4109. u8 *pCalPier;
  4110. struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
  4111. int is2GHz;
  4112. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4113. struct ath_common *common = ath9k_hw_common(ah);
  4114. if (ichain >= AR9300_MAX_CHAINS) {
  4115. ath_dbg(common, EEPROM,
  4116. "Invalid chain index, must be less than %d\n",
  4117. AR9300_MAX_CHAINS);
  4118. return -1;
  4119. }
  4120. if (mode) { /* 5GHz */
  4121. if (ipier >= AR9300_NUM_5G_CAL_PIERS) {
  4122. ath_dbg(common, EEPROM,
  4123. "Invalid 5GHz cal pier index, must be less than %d\n",
  4124. AR9300_NUM_5G_CAL_PIERS);
  4125. return -1;
  4126. }
  4127. pCalPier = &(eep->calFreqPier5G[ipier]);
  4128. pCalPierStruct = &(eep->calPierData5G[ichain][ipier]);
  4129. is2GHz = 0;
  4130. } else {
  4131. if (ipier >= AR9300_NUM_2G_CAL_PIERS) {
  4132. ath_dbg(common, EEPROM,
  4133. "Invalid 2GHz cal pier index, must be less than %d\n",
  4134. AR9300_NUM_2G_CAL_PIERS);
  4135. return -1;
  4136. }
  4137. pCalPier = &(eep->calFreqPier2G[ipier]);
  4138. pCalPierStruct = &(eep->calPierData2G[ichain][ipier]);
  4139. is2GHz = 1;
  4140. }
  4141. *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2GHz);
  4142. *pcorrection = pCalPierStruct->refPower;
  4143. *ptemperature = pCalPierStruct->tempMeas;
  4144. *pvoltage = pCalPierStruct->voltMeas;
  4145. return 0;
  4146. }
  4147. static int ar9003_hw_power_control_override(struct ath_hw *ah,
  4148. int frequency,
  4149. int *correction,
  4150. int *voltage, int *temperature)
  4151. {
  4152. int tempSlope = 0;
  4153. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4154. int f[3], t[3];
  4155. REG_RMW(ah, AR_PHY_TPC_11_B0,
  4156. (correction[0] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4157. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4158. if (ah->caps.tx_chainmask & BIT(1))
  4159. REG_RMW(ah, AR_PHY_TPC_11_B1,
  4160. (correction[1] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4161. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4162. if (ah->caps.tx_chainmask & BIT(2))
  4163. REG_RMW(ah, AR_PHY_TPC_11_B2,
  4164. (correction[2] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
  4165. AR_PHY_TPC_OLPC_GAIN_DELTA);
  4166. /* enable open loop power control on chip */
  4167. REG_RMW(ah, AR_PHY_TPC_6_B0,
  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(1))
  4171. REG_RMW(ah, AR_PHY_TPC_6_B1,
  4172. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4173. AR_PHY_TPC_6_ERROR_EST_MODE);
  4174. if (ah->caps.tx_chainmask & BIT(2))
  4175. REG_RMW(ah, AR_PHY_TPC_6_B2,
  4176. (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
  4177. AR_PHY_TPC_6_ERROR_EST_MODE);
  4178. /*
  4179. * enable temperature compensation
  4180. * Need to use register names
  4181. */
  4182. if (frequency < 4000)
  4183. tempSlope = eep->modalHeader2G.tempSlope;
  4184. else if (eep->base_ext2.tempSlopeLow != 0) {
  4185. t[0] = eep->base_ext2.tempSlopeLow;
  4186. f[0] = 5180;
  4187. t[1] = eep->modalHeader5G.tempSlope;
  4188. f[1] = 5500;
  4189. t[2] = eep->base_ext2.tempSlopeHigh;
  4190. f[2] = 5785;
  4191. tempSlope = ar9003_hw_power_interpolate((s32) frequency,
  4192. f, t, 3);
  4193. } else
  4194. tempSlope = eep->modalHeader5G.tempSlope;
  4195. REG_RMW_FIELD(ah, AR_PHY_TPC_19, AR_PHY_TPC_19_ALPHA_THERM, tempSlope);
  4196. if (AR_SREV_9462_20(ah))
  4197. REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
  4198. AR_PHY_TPC_19_B1_ALPHA_THERM, tempSlope);
  4199. REG_RMW_FIELD(ah, AR_PHY_TPC_18, AR_PHY_TPC_18_THERM_CAL_VALUE,
  4200. temperature[0]);
  4201. return 0;
  4202. }
  4203. /* Apply the recorded correction values. */
  4204. static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
  4205. {
  4206. int ichain, ipier, npier;
  4207. int mode;
  4208. int lfrequency[AR9300_MAX_CHAINS],
  4209. lcorrection[AR9300_MAX_CHAINS],
  4210. ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS];
  4211. int hfrequency[AR9300_MAX_CHAINS],
  4212. hcorrection[AR9300_MAX_CHAINS],
  4213. htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS];
  4214. int fdiff;
  4215. int correction[AR9300_MAX_CHAINS],
  4216. voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS];
  4217. int pfrequency, pcorrection, ptemperature, pvoltage;
  4218. struct ath_common *common = ath9k_hw_common(ah);
  4219. mode = (frequency >= 4000);
  4220. if (mode)
  4221. npier = AR9300_NUM_5G_CAL_PIERS;
  4222. else
  4223. npier = AR9300_NUM_2G_CAL_PIERS;
  4224. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4225. lfrequency[ichain] = 0;
  4226. hfrequency[ichain] = 100000;
  4227. }
  4228. /* identify best lower and higher frequency calibration measurement */
  4229. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4230. for (ipier = 0; ipier < npier; ipier++) {
  4231. if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
  4232. &pfrequency, &pcorrection,
  4233. &ptemperature, &pvoltage)) {
  4234. fdiff = frequency - pfrequency;
  4235. /*
  4236. * this measurement is higher than
  4237. * our desired frequency
  4238. */
  4239. if (fdiff <= 0) {
  4240. if (hfrequency[ichain] <= 0 ||
  4241. hfrequency[ichain] >= 100000 ||
  4242. fdiff >
  4243. (frequency - hfrequency[ichain])) {
  4244. /*
  4245. * new best higher
  4246. * frequency measurement
  4247. */
  4248. hfrequency[ichain] = pfrequency;
  4249. hcorrection[ichain] =
  4250. pcorrection;
  4251. htemperature[ichain] =
  4252. ptemperature;
  4253. hvoltage[ichain] = pvoltage;
  4254. }
  4255. }
  4256. if (fdiff >= 0) {
  4257. if (lfrequency[ichain] <= 0
  4258. || fdiff <
  4259. (frequency - lfrequency[ichain])) {
  4260. /*
  4261. * new best lower
  4262. * frequency measurement
  4263. */
  4264. lfrequency[ichain] = pfrequency;
  4265. lcorrection[ichain] =
  4266. pcorrection;
  4267. ltemperature[ichain] =
  4268. ptemperature;
  4269. lvoltage[ichain] = pvoltage;
  4270. }
  4271. }
  4272. }
  4273. }
  4274. }
  4275. /* interpolate */
  4276. for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
  4277. ath_dbg(common, EEPROM, "ch=%d f=%d low=%d %d h=%d %d\n",
  4278. ichain, frequency, lfrequency[ichain],
  4279. lcorrection[ichain], hfrequency[ichain],
  4280. hcorrection[ichain]);
  4281. /* they're the same, so just pick one */
  4282. if (hfrequency[ichain] == lfrequency[ichain]) {
  4283. correction[ichain] = lcorrection[ichain];
  4284. voltage[ichain] = lvoltage[ichain];
  4285. temperature[ichain] = ltemperature[ichain];
  4286. }
  4287. /* the low frequency is good */
  4288. else if (frequency - lfrequency[ichain] < 1000) {
  4289. /* so is the high frequency, interpolate */
  4290. if (hfrequency[ichain] - frequency < 1000) {
  4291. correction[ichain] = interpolate(frequency,
  4292. lfrequency[ichain],
  4293. hfrequency[ichain],
  4294. lcorrection[ichain],
  4295. hcorrection[ichain]);
  4296. temperature[ichain] = interpolate(frequency,
  4297. lfrequency[ichain],
  4298. hfrequency[ichain],
  4299. ltemperature[ichain],
  4300. htemperature[ichain]);
  4301. voltage[ichain] = interpolate(frequency,
  4302. lfrequency[ichain],
  4303. hfrequency[ichain],
  4304. lvoltage[ichain],
  4305. hvoltage[ichain]);
  4306. }
  4307. /* only low is good, use it */
  4308. else {
  4309. correction[ichain] = lcorrection[ichain];
  4310. temperature[ichain] = ltemperature[ichain];
  4311. voltage[ichain] = lvoltage[ichain];
  4312. }
  4313. }
  4314. /* only high is good, use it */
  4315. else if (hfrequency[ichain] - frequency < 1000) {
  4316. correction[ichain] = hcorrection[ichain];
  4317. temperature[ichain] = htemperature[ichain];
  4318. voltage[ichain] = hvoltage[ichain];
  4319. } else { /* nothing is good, presume 0???? */
  4320. correction[ichain] = 0;
  4321. temperature[ichain] = 0;
  4322. voltage[ichain] = 0;
  4323. }
  4324. }
  4325. ar9003_hw_power_control_override(ah, frequency, correction, voltage,
  4326. temperature);
  4327. ath_dbg(common, EEPROM,
  4328. "for frequency=%d, calibration correction = %d %d %d\n",
  4329. frequency, correction[0], correction[1], correction[2]);
  4330. return 0;
  4331. }
  4332. static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
  4333. int idx,
  4334. int edge,
  4335. bool is2GHz)
  4336. {
  4337. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4338. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4339. if (is2GHz)
  4340. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
  4341. else
  4342. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
  4343. }
  4344. static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
  4345. int idx,
  4346. unsigned int edge,
  4347. u16 freq,
  4348. bool is2GHz)
  4349. {
  4350. struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
  4351. struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
  4352. u8 *ctl_freqbin = is2GHz ?
  4353. &eep->ctl_freqbin_2G[idx][0] :
  4354. &eep->ctl_freqbin_5G[idx][0];
  4355. if (is2GHz) {
  4356. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
  4357. CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
  4358. return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
  4359. } else {
  4360. if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
  4361. CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
  4362. return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
  4363. }
  4364. return MAX_RATE_POWER;
  4365. }
  4366. /*
  4367. * Find the maximum conformance test limit for the given channel and CTL info
  4368. */
  4369. static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
  4370. u16 freq, int idx, bool is2GHz)
  4371. {
  4372. u16 twiceMaxEdgePower = MAX_RATE_POWER;
  4373. u8 *ctl_freqbin = is2GHz ?
  4374. &eep->ctl_freqbin_2G[idx][0] :
  4375. &eep->ctl_freqbin_5G[idx][0];
  4376. u16 num_edges = is2GHz ?
  4377. AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
  4378. unsigned int edge;
  4379. /* Get the edge power */
  4380. for (edge = 0;
  4381. (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
  4382. edge++) {
  4383. /*
  4384. * If there's an exact channel match or an inband flag set
  4385. * on the lower channel use the given rdEdgePower
  4386. */
  4387. if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
  4388. twiceMaxEdgePower =
  4389. ar9003_hw_get_direct_edge_power(eep, idx,
  4390. edge, is2GHz);
  4391. break;
  4392. } else if ((edge > 0) &&
  4393. (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
  4394. is2GHz))) {
  4395. twiceMaxEdgePower =
  4396. ar9003_hw_get_indirect_edge_power(eep, idx,
  4397. edge, freq,
  4398. is2GHz);
  4399. /*
  4400. * Leave loop - no more affecting edges possible in
  4401. * this monotonic increasing list
  4402. */
  4403. break;
  4404. }
  4405. }
  4406. return twiceMaxEdgePower;
  4407. }
  4408. static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
  4409. struct ath9k_channel *chan,
  4410. u8 *pPwrArray, u16 cfgCtl,
  4411. u8 antenna_reduction,
  4412. u16 powerLimit)
  4413. {
  4414. struct ath_common *common = ath9k_hw_common(ah);
  4415. struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
  4416. u16 twiceMaxEdgePower;
  4417. int i;
  4418. u16 scaledPower = 0, minCtlPower;
  4419. static const u16 ctlModesFor11a[] = {
  4420. CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
  4421. };
  4422. static const u16 ctlModesFor11g[] = {
  4423. CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
  4424. CTL_11G_EXT, CTL_2GHT40
  4425. };
  4426. u16 numCtlModes;
  4427. const u16 *pCtlMode;
  4428. u16 ctlMode, freq;
  4429. struct chan_centers centers;
  4430. u8 *ctlIndex;
  4431. u8 ctlNum;
  4432. u16 twiceMinEdgePower;
  4433. bool is2ghz = IS_CHAN_2GHZ(chan);
  4434. ath9k_hw_get_channel_centers(ah, chan, &centers);
  4435. scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
  4436. antenna_reduction);
  4437. if (is2ghz) {
  4438. /* Setup for CTL modes */
  4439. /* CTL_11B, CTL_11G, CTL_2GHT20 */
  4440. numCtlModes =
  4441. ARRAY_SIZE(ctlModesFor11g) -
  4442. SUB_NUM_CTL_MODES_AT_2G_40;
  4443. pCtlMode = ctlModesFor11g;
  4444. if (IS_CHAN_HT40(chan))
  4445. /* All 2G CTL's */
  4446. numCtlModes = ARRAY_SIZE(ctlModesFor11g);
  4447. } else {
  4448. /* Setup for CTL modes */
  4449. /* CTL_11A, CTL_5GHT20 */
  4450. numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
  4451. SUB_NUM_CTL_MODES_AT_5G_40;
  4452. pCtlMode = ctlModesFor11a;
  4453. if (IS_CHAN_HT40(chan))
  4454. /* All 5G CTL's */
  4455. numCtlModes = ARRAY_SIZE(ctlModesFor11a);
  4456. }
  4457. /*
  4458. * For MIMO, need to apply regulatory caps individually across
  4459. * dynamically running modes: CCK, OFDM, HT20, HT40
  4460. *
  4461. * The outer loop walks through each possible applicable runtime mode.
  4462. * The inner loop walks through each ctlIndex entry in EEPROM.
  4463. * The ctl value is encoded as [7:4] == test group, [3:0] == test mode.
  4464. */
  4465. for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
  4466. bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
  4467. (pCtlMode[ctlMode] == CTL_2GHT40);
  4468. if (isHt40CtlMode)
  4469. freq = centers.synth_center;
  4470. else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
  4471. freq = centers.ext_center;
  4472. else
  4473. freq = centers.ctl_center;
  4474. ath_dbg(common, REGULATORY,
  4475. "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n",
  4476. ctlMode, numCtlModes, isHt40CtlMode,
  4477. (pCtlMode[ctlMode] & EXT_ADDITIVE));
  4478. /* walk through each CTL index stored in EEPROM */
  4479. if (is2ghz) {
  4480. ctlIndex = pEepData->ctlIndex_2G;
  4481. ctlNum = AR9300_NUM_CTLS_2G;
  4482. } else {
  4483. ctlIndex = pEepData->ctlIndex_5G;
  4484. ctlNum = AR9300_NUM_CTLS_5G;
  4485. }
  4486. twiceMaxEdgePower = MAX_RATE_POWER;
  4487. for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
  4488. ath_dbg(common, REGULATORY,
  4489. "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
  4490. i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
  4491. chan->channel);
  4492. /*
  4493. * compare test group from regulatory
  4494. * channel list with test mode from pCtlMode
  4495. * list
  4496. */
  4497. if ((((cfgCtl & ~CTL_MODE_M) |
  4498. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4499. ctlIndex[i]) ||
  4500. (((cfgCtl & ~CTL_MODE_M) |
  4501. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  4502. ((ctlIndex[i] & CTL_MODE_M) |
  4503. SD_NO_CTL))) {
  4504. twiceMinEdgePower =
  4505. ar9003_hw_get_max_edge_power(pEepData,
  4506. freq, i,
  4507. is2ghz);
  4508. if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL)
  4509. /*
  4510. * Find the minimum of all CTL
  4511. * edge powers that apply to
  4512. * this channel
  4513. */
  4514. twiceMaxEdgePower =
  4515. min(twiceMaxEdgePower,
  4516. twiceMinEdgePower);
  4517. else {
  4518. /* specific */
  4519. twiceMaxEdgePower =
  4520. twiceMinEdgePower;
  4521. break;
  4522. }
  4523. }
  4524. }
  4525. minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
  4526. ath_dbg(common, REGULATORY,
  4527. "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n",
  4528. ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
  4529. scaledPower, minCtlPower);
  4530. /* Apply ctl mode to correct target power set */
  4531. switch (pCtlMode[ctlMode]) {
  4532. case CTL_11B:
  4533. for (i = ALL_TARGET_LEGACY_1L_5L;
  4534. i <= ALL_TARGET_LEGACY_11S; i++)
  4535. pPwrArray[i] =
  4536. (u8)min((u16)pPwrArray[i],
  4537. minCtlPower);
  4538. break;
  4539. case CTL_11A:
  4540. case CTL_11G:
  4541. for (i = ALL_TARGET_LEGACY_6_24;
  4542. i <= ALL_TARGET_LEGACY_54; i++)
  4543. pPwrArray[i] =
  4544. (u8)min((u16)pPwrArray[i],
  4545. minCtlPower);
  4546. break;
  4547. case CTL_5GHT20:
  4548. case CTL_2GHT20:
  4549. for (i = ALL_TARGET_HT20_0_8_16;
  4550. i <= ALL_TARGET_HT20_21; i++)
  4551. pPwrArray[i] =
  4552. (u8)min((u16)pPwrArray[i],
  4553. minCtlPower);
  4554. pPwrArray[ALL_TARGET_HT20_22] =
  4555. (u8)min((u16)pPwrArray[ALL_TARGET_HT20_22],
  4556. minCtlPower);
  4557. pPwrArray[ALL_TARGET_HT20_23] =
  4558. (u8)min((u16)pPwrArray[ALL_TARGET_HT20_23],
  4559. minCtlPower);
  4560. break;
  4561. case CTL_5GHT40:
  4562. case CTL_2GHT40:
  4563. for (i = ALL_TARGET_HT40_0_8_16;
  4564. i <= ALL_TARGET_HT40_23; i++)
  4565. pPwrArray[i] =
  4566. (u8)min((u16)pPwrArray[i],
  4567. minCtlPower);
  4568. break;
  4569. default:
  4570. break;
  4571. }
  4572. } /* end ctl mode checking */
  4573. }
  4574. static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx)
  4575. {
  4576. u8 mod_idx = mcs_idx % 8;
  4577. if (mod_idx <= 3)
  4578. return mod_idx ? (base_pwridx + 1) : base_pwridx;
  4579. else
  4580. return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2;
  4581. }
  4582. static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
  4583. struct ath9k_channel *chan, u16 cfgCtl,
  4584. u8 twiceAntennaReduction,
  4585. u8 powerLimit, bool test)
  4586. {
  4587. struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
  4588. struct ath_common *common = ath9k_hw_common(ah);
  4589. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4590. struct ar9300_modal_eep_header *modal_hdr;
  4591. u8 targetPowerValT2[ar9300RateSize];
  4592. u8 target_power_val_t2_eep[ar9300RateSize];
  4593. unsigned int i = 0, paprd_scale_factor = 0;
  4594. u8 pwr_idx, min_pwridx = 0;
  4595. memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
  4596. /*
  4597. * Get target powers from EEPROM - our baseline for TX Power
  4598. */
  4599. ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
  4600. if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) {
  4601. if (IS_CHAN_2GHZ(chan))
  4602. modal_hdr = &eep->modalHeader2G;
  4603. else
  4604. modal_hdr = &eep->modalHeader5G;
  4605. ah->paprd_ratemask =
  4606. le32_to_cpu(modal_hdr->papdRateMaskHt20) &
  4607. AR9300_PAPRD_RATE_MASK;
  4608. ah->paprd_ratemask_ht40 =
  4609. le32_to_cpu(modal_hdr->papdRateMaskHt40) &
  4610. AR9300_PAPRD_RATE_MASK;
  4611. paprd_scale_factor = ar9003_get_paprd_scale_factor(ah, chan);
  4612. min_pwridx = IS_CHAN_HT40(chan) ? ALL_TARGET_HT40_0_8_16 :
  4613. ALL_TARGET_HT20_0_8_16;
  4614. if (!ah->paprd_table_write_done) {
  4615. memcpy(target_power_val_t2_eep, targetPowerValT2,
  4616. sizeof(targetPowerValT2));
  4617. for (i = 0; i < 24; i++) {
  4618. pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx);
  4619. if (ah->paprd_ratemask & (1 << i)) {
  4620. if (targetPowerValT2[pwr_idx] &&
  4621. targetPowerValT2[pwr_idx] ==
  4622. target_power_val_t2_eep[pwr_idx])
  4623. targetPowerValT2[pwr_idx] -=
  4624. paprd_scale_factor;
  4625. }
  4626. }
  4627. }
  4628. memcpy(target_power_val_t2_eep, targetPowerValT2,
  4629. sizeof(targetPowerValT2));
  4630. }
  4631. ar9003_hw_set_power_per_rate_table(ah, chan,
  4632. targetPowerValT2, cfgCtl,
  4633. twiceAntennaReduction,
  4634. powerLimit);
  4635. if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) {
  4636. for (i = 0; i < ar9300RateSize; i++) {
  4637. if ((ah->paprd_ratemask & (1 << i)) &&
  4638. (abs(targetPowerValT2[i] -
  4639. target_power_val_t2_eep[i]) >
  4640. paprd_scale_factor)) {
  4641. ah->paprd_ratemask &= ~(1 << i);
  4642. ath_dbg(common, EEPROM,
  4643. "paprd disabled for mcs %d\n", i);
  4644. }
  4645. }
  4646. }
  4647. regulatory->max_power_level = 0;
  4648. for (i = 0; i < ar9300RateSize; i++) {
  4649. if (targetPowerValT2[i] > regulatory->max_power_level)
  4650. regulatory->max_power_level = targetPowerValT2[i];
  4651. }
  4652. ath9k_hw_update_regulatory_maxpower(ah);
  4653. if (test)
  4654. return;
  4655. for (i = 0; i < ar9300RateSize; i++) {
  4656. ath_dbg(common, EEPROM, "TPC[%02d] 0x%08x\n",
  4657. i, targetPowerValT2[i]);
  4658. }
  4659. /* Write target power array to registers */
  4660. ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
  4661. ar9003_hw_calibration_apply(ah, chan->channel);
  4662. if (IS_CHAN_2GHZ(chan)) {
  4663. if (IS_CHAN_HT40(chan))
  4664. i = ALL_TARGET_HT40_0_8_16;
  4665. else
  4666. i = ALL_TARGET_HT20_0_8_16;
  4667. } else {
  4668. if (IS_CHAN_HT40(chan))
  4669. i = ALL_TARGET_HT40_7;
  4670. else
  4671. i = ALL_TARGET_HT20_7;
  4672. }
  4673. ah->paprd_target_power = targetPowerValT2[i];
  4674. }
  4675. static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah,
  4676. u16 i, bool is2GHz)
  4677. {
  4678. return AR_NO_SPUR;
  4679. }
  4680. s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
  4681. {
  4682. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4683. return (eep->baseEepHeader.txrxgain >> 4) & 0xf; /* bits 7:4 */
  4684. }
  4685. s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
  4686. {
  4687. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4688. return (eep->baseEepHeader.txrxgain) & 0xf; /* bits 3:0 */
  4689. }
  4690. u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz)
  4691. {
  4692. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4693. if (is_2ghz)
  4694. return eep->modalHeader2G.spurChans;
  4695. else
  4696. return eep->modalHeader5G.spurChans;
  4697. }
  4698. unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
  4699. struct ath9k_channel *chan)
  4700. {
  4701. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  4702. if (IS_CHAN_2GHZ(chan))
  4703. return MS(le32_to_cpu(eep->modalHeader2G.papdRateMaskHt20),
  4704. AR9300_PAPRD_SCALE_1);
  4705. else {
  4706. if (chan->channel >= 5700)
  4707. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20),
  4708. AR9300_PAPRD_SCALE_1);
  4709. else if (chan->channel >= 5400)
  4710. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  4711. AR9300_PAPRD_SCALE_2);
  4712. else
  4713. return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
  4714. AR9300_PAPRD_SCALE_1);
  4715. }
  4716. }
  4717. const struct eeprom_ops eep_ar9300_ops = {
  4718. .check_eeprom = ath9k_hw_ar9300_check_eeprom,
  4719. .get_eeprom = ath9k_hw_ar9300_get_eeprom,
  4720. .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
  4721. .dump_eeprom = ath9k_hw_ar9003_dump_eeprom,
  4722. .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
  4723. .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
  4724. .set_board_values = ath9k_hw_ar9300_set_board_values,
  4725. .set_addac = ath9k_hw_ar9300_set_addac,
  4726. .set_txpower = ath9k_hw_ar9300_set_txpower,
  4727. .get_spur_channel = ath9k_hw_ar9300_get_spur_channel
  4728. };