ar9003_eeprom.c 141 KB

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