ar9003_eeprom.c 146 KB

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