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 "hw.h"
  17. #include "ar9003_phy.h"
  18. #include "ar9003_eeprom.h"
  19. #define COMP_HDR_LEN 4
  20. #define COMP_CKSUM_LEN 2
  21. #define AR_CH0_TOP (0x00016288)
  22. #define AR_CH0_TOP_XPABIASLVL (0x300)
  23. #define AR_CH0_TOP_XPABIASLVL_S (8)
  24. #define AR_CH0_THERM (0x00016290)
  25. #define AR_CH0_THERM_XPABIASLVL_MSB 0x3
  26. #define AR_CH0_THERM_XPABIASLVL_MSB_S 0
  27. #define AR_CH0_THERM_XPASHORT2GND 0x4
  28. #define AR_CH0_THERM_XPASHORT2GND_S 2
  29. #define AR_SWITCH_TABLE_COM_ALL (0xffff)
  30. #define AR_SWITCH_TABLE_COM_ALL_S (0)
  31. #define AR_SWITCH_TABLE_COM2_ALL (0xffffff)
  32. #define AR_SWITCH_TABLE_COM2_ALL_S (0)
  33. #define AR_SWITCH_TABLE_ALL (0xfff)
  34. #define AR_SWITCH_TABLE_ALL_S (0)
  35. #define LE16(x) __constant_cpu_to_le16(x)
  36. #define LE32(x) __constant_cpu_to_le32(x)
  37. /* Local defines to distinguish between extension and control CTL's */
  38. #define EXT_ADDITIVE (0x8000)
  39. #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
  40. #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
  41. #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
  42. #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
  43. #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */
  44. #define PWRINCR_3_TO_1_CHAIN 9 /* 10*log(3)*2 */
  45. #define PWRINCR_3_TO_2_CHAIN 3 /* floor(10*log(3/2)*2) */
  46. #define PWRINCR_2_TO_1_CHAIN 6 /* 10*log(2)*2 */
  47. #define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
  48. #define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
  49. #define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
  50. #define EEPROM_DATA_LEN_9485 1088
  51. static int ar9003_hw_power_interpolate(int32_t x,
  52. int32_t *px, int32_t *py, u_int16_t np);
  53. static const struct ar9300_eeprom ar9300_default = {
  54. .eepromVersion = 2,
  55. .templateVersion = 2,
  56. .macAddr = {1, 2, 3, 4, 5, 6},
  57. .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  59. .baseEepHeader = {
  60. .regDmn = { LE16(0), LE16(0x1f) },
  61. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  62. .opCapFlags = {
  63. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  64. .eepMisc = 0,
  65. },
  66. .rfSilent = 0,
  67. .blueToothOptions = 0,
  68. .deviceCap = 0,
  69. .deviceType = 5, /* takes lower byte in eeprom location */
  70. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  71. .params_for_tuning_caps = {0, 0},
  72. .featureEnable = 0x0c,
  73. /*
  74. * bit0 - enable tx temp comp - disabled
  75. * bit1 - enable tx volt comp - disabled
  76. * bit2 - enable fastClock - enabled
  77. * bit3 - enable doubling - enabled
  78. * bit4 - enable internal regulator - disabled
  79. * bit5 - enable pa predistortion - disabled
  80. */
  81. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  82. .eepromWriteEnableGpio = 3,
  83. .wlanDisableGpio = 0,
  84. .wlanLedGpio = 8,
  85. .rxBandSelectGpio = 0xff,
  86. .txrxgain = 0,
  87. .swreg = 0,
  88. },
  89. .modalHeader2G = {
  90. /* ar9300_modal_eep_header 2g */
  91. /* 4 idle,t1,t2,b(4 bits per setting) */
  92. .antCtrlCommon = LE32(0x110),
  93. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  94. .antCtrlCommon2 = LE32(0x22222),
  95. /*
  96. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  97. * rx1, rx12, b (2 bits each)
  98. */
  99. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  100. /*
  101. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  102. * for ar9280 (0xa20c/b20c 5:0)
  103. */
  104. .xatten1DB = {0, 0, 0},
  105. /*
  106. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  107. * for ar9280 (0xa20c/b20c 16:12
  108. */
  109. .xatten1Margin = {0, 0, 0},
  110. .tempSlope = 36,
  111. .voltSlope = 0,
  112. /*
  113. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  114. * channels in usual fbin coding format
  115. */
  116. .spurChans = {0, 0, 0, 0, 0},
  117. /*
  118. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  119. * if the register is per chain
  120. */
  121. .noiseFloorThreshCh = {-1, 0, 0},
  122. .ob = {1, 1, 1},/* 3 chain */
  123. .db_stage2 = {1, 1, 1}, /* 3 chain */
  124. .db_stage3 = {0, 0, 0},
  125. .db_stage4 = {0, 0, 0},
  126. .xpaBiasLvl = 0,
  127. .txFrameToDataStart = 0x0e,
  128. .txFrameToPaOn = 0x0e,
  129. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  130. .antennaGain = 0,
  131. .switchSettling = 0x2c,
  132. .adcDesiredSize = -30,
  133. .txEndToXpaOff = 0,
  134. .txEndToRxOn = 0x2,
  135. .txFrameToXpaOn = 0xe,
  136. .thresh62 = 28,
  137. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  138. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  139. .futureModal = {
  140. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  141. },
  142. },
  143. .base_ext1 = {
  144. .ant_div_control = 0,
  145. .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  146. },
  147. .calFreqPier2G = {
  148. FREQ2FBIN(2412, 1),
  149. FREQ2FBIN(2437, 1),
  150. FREQ2FBIN(2472, 1),
  151. },
  152. /* ar9300_cal_data_per_freq_op_loop 2g */
  153. .calPierData2G = {
  154. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  155. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  156. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  157. },
  158. .calTarget_freqbin_Cck = {
  159. FREQ2FBIN(2412, 1),
  160. FREQ2FBIN(2484, 1),
  161. },
  162. .calTarget_freqbin_2G = {
  163. FREQ2FBIN(2412, 1),
  164. FREQ2FBIN(2437, 1),
  165. FREQ2FBIN(2472, 1)
  166. },
  167. .calTarget_freqbin_2GHT20 = {
  168. FREQ2FBIN(2412, 1),
  169. FREQ2FBIN(2437, 1),
  170. FREQ2FBIN(2472, 1)
  171. },
  172. .calTarget_freqbin_2GHT40 = {
  173. FREQ2FBIN(2412, 1),
  174. FREQ2FBIN(2437, 1),
  175. FREQ2FBIN(2472, 1)
  176. },
  177. .calTargetPowerCck = {
  178. /* 1L-5L,5S,11L,11S */
  179. { {36, 36, 36, 36} },
  180. { {36, 36, 36, 36} },
  181. },
  182. .calTargetPower2G = {
  183. /* 6-24,36,48,54 */
  184. { {32, 32, 28, 24} },
  185. { {32, 32, 28, 24} },
  186. { {32, 32, 28, 24} },
  187. },
  188. .calTargetPower2GHT20 = {
  189. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  190. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  191. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  192. },
  193. .calTargetPower2GHT40 = {
  194. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  195. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  196. { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
  197. },
  198. .ctlIndex_2G = {
  199. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  200. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  201. },
  202. .ctl_freqbin_2G = {
  203. {
  204. FREQ2FBIN(2412, 1),
  205. FREQ2FBIN(2417, 1),
  206. FREQ2FBIN(2457, 1),
  207. FREQ2FBIN(2462, 1)
  208. },
  209. {
  210. FREQ2FBIN(2412, 1),
  211. FREQ2FBIN(2417, 1),
  212. FREQ2FBIN(2462, 1),
  213. 0xFF,
  214. },
  215. {
  216. FREQ2FBIN(2412, 1),
  217. FREQ2FBIN(2417, 1),
  218. FREQ2FBIN(2462, 1),
  219. 0xFF,
  220. },
  221. {
  222. FREQ2FBIN(2422, 1),
  223. FREQ2FBIN(2427, 1),
  224. FREQ2FBIN(2447, 1),
  225. FREQ2FBIN(2452, 1)
  226. },
  227. {
  228. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  229. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  230. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  231. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  232. },
  233. {
  234. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  235. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  236. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  237. 0,
  238. },
  239. {
  240. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  241. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  242. FREQ2FBIN(2472, 1),
  243. 0,
  244. },
  245. {
  246. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  247. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  248. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  249. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  250. },
  251. {
  252. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  253. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  254. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  255. },
  256. {
  257. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  258. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  259. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  260. 0
  261. },
  262. {
  263. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  264. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  265. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  266. 0
  267. },
  268. {
  269. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  270. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  271. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  272. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  273. }
  274. },
  275. .ctlPowerData_2G = {
  276. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  277. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  278. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  279. { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
  280. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  281. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  282. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  283. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  284. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  285. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  286. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  287. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  288. },
  289. .modalHeader5G = {
  290. /* 4 idle,t1,t2,b (4 bits per setting) */
  291. .antCtrlCommon = LE32(0x110),
  292. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  293. .antCtrlCommon2 = LE32(0x22222),
  294. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  295. .antCtrlChain = {
  296. LE16(0x000), LE16(0x000), LE16(0x000),
  297. },
  298. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  299. .xatten1DB = {0, 0, 0},
  300. /*
  301. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  302. * for merlin (0xa20c/b20c 16:12
  303. */
  304. .xatten1Margin = {0, 0, 0},
  305. .tempSlope = 68,
  306. .voltSlope = 0,
  307. /* spurChans spur channels in usual fbin coding format */
  308. .spurChans = {0, 0, 0, 0, 0},
  309. /* noiseFloorThreshCh Check if the register is per chain */
  310. .noiseFloorThreshCh = {-1, 0, 0},
  311. .ob = {3, 3, 3}, /* 3 chain */
  312. .db_stage2 = {3, 3, 3}, /* 3 chain */
  313. .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */
  314. .db_stage4 = {3, 3, 3}, /* don't exist for 2G */
  315. .xpaBiasLvl = 0,
  316. .txFrameToDataStart = 0x0e,
  317. .txFrameToPaOn = 0x0e,
  318. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  319. .antennaGain = 0,
  320. .switchSettling = 0x2d,
  321. .adcDesiredSize = -30,
  322. .txEndToXpaOff = 0,
  323. .txEndToRxOn = 0x2,
  324. .txFrameToXpaOn = 0xe,
  325. .thresh62 = 28,
  326. .papdRateMaskHt20 = LE32(0x0c80c080),
  327. .papdRateMaskHt40 = LE32(0x0080c080),
  328. .futureModal = {
  329. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  330. },
  331. },
  332. .base_ext2 = {
  333. .tempSlopeLow = 0,
  334. .tempSlopeHigh = 0,
  335. .xatten1DBLow = {0, 0, 0},
  336. .xatten1MarginLow = {0, 0, 0},
  337. .xatten1DBHigh = {0, 0, 0},
  338. .xatten1MarginHigh = {0, 0, 0}
  339. },
  340. .calFreqPier5G = {
  341. FREQ2FBIN(5180, 0),
  342. FREQ2FBIN(5220, 0),
  343. FREQ2FBIN(5320, 0),
  344. FREQ2FBIN(5400, 0),
  345. FREQ2FBIN(5500, 0),
  346. FREQ2FBIN(5600, 0),
  347. FREQ2FBIN(5725, 0),
  348. FREQ2FBIN(5825, 0)
  349. },
  350. .calPierData5G = {
  351. {
  352. {0, 0, 0, 0, 0},
  353. {0, 0, 0, 0, 0},
  354. {0, 0, 0, 0, 0},
  355. {0, 0, 0, 0, 0},
  356. {0, 0, 0, 0, 0},
  357. {0, 0, 0, 0, 0},
  358. {0, 0, 0, 0, 0},
  359. {0, 0, 0, 0, 0},
  360. },
  361. {
  362. {0, 0, 0, 0, 0},
  363. {0, 0, 0, 0, 0},
  364. {0, 0, 0, 0, 0},
  365. {0, 0, 0, 0, 0},
  366. {0, 0, 0, 0, 0},
  367. {0, 0, 0, 0, 0},
  368. {0, 0, 0, 0, 0},
  369. {0, 0, 0, 0, 0},
  370. },
  371. {
  372. {0, 0, 0, 0, 0},
  373. {0, 0, 0, 0, 0},
  374. {0, 0, 0, 0, 0},
  375. {0, 0, 0, 0, 0},
  376. {0, 0, 0, 0, 0},
  377. {0, 0, 0, 0, 0},
  378. {0, 0, 0, 0, 0},
  379. {0, 0, 0, 0, 0},
  380. },
  381. },
  382. .calTarget_freqbin_5G = {
  383. FREQ2FBIN(5180, 0),
  384. FREQ2FBIN(5220, 0),
  385. FREQ2FBIN(5320, 0),
  386. FREQ2FBIN(5400, 0),
  387. FREQ2FBIN(5500, 0),
  388. FREQ2FBIN(5600, 0),
  389. FREQ2FBIN(5725, 0),
  390. FREQ2FBIN(5825, 0)
  391. },
  392. .calTarget_freqbin_5GHT20 = {
  393. FREQ2FBIN(5180, 0),
  394. FREQ2FBIN(5240, 0),
  395. FREQ2FBIN(5320, 0),
  396. FREQ2FBIN(5500, 0),
  397. FREQ2FBIN(5700, 0),
  398. FREQ2FBIN(5745, 0),
  399. FREQ2FBIN(5725, 0),
  400. FREQ2FBIN(5825, 0)
  401. },
  402. .calTarget_freqbin_5GHT40 = {
  403. FREQ2FBIN(5180, 0),
  404. FREQ2FBIN(5240, 0),
  405. FREQ2FBIN(5320, 0),
  406. FREQ2FBIN(5500, 0),
  407. FREQ2FBIN(5700, 0),
  408. FREQ2FBIN(5745, 0),
  409. FREQ2FBIN(5725, 0),
  410. FREQ2FBIN(5825, 0)
  411. },
  412. .calTargetPower5G = {
  413. /* 6-24,36,48,54 */
  414. { {20, 20, 20, 10} },
  415. { {20, 20, 20, 10} },
  416. { {20, 20, 20, 10} },
  417. { {20, 20, 20, 10} },
  418. { {20, 20, 20, 10} },
  419. { {20, 20, 20, 10} },
  420. { {20, 20, 20, 10} },
  421. { {20, 20, 20, 10} },
  422. },
  423. .calTargetPower5GHT20 = {
  424. /*
  425. * 0_8_16,1-3_9-11_17-19,
  426. * 4,5,6,7,12,13,14,15,20,21,22,23
  427. */
  428. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  429. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  430. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  431. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  432. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  433. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  434. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  435. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  436. },
  437. .calTargetPower5GHT40 = {
  438. /*
  439. * 0_8_16,1-3_9-11_17-19,
  440. * 4,5,6,7,12,13,14,15,20,21,22,23
  441. */
  442. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  443. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  444. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  445. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  446. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  447. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  448. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  449. { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
  450. },
  451. .ctlIndex_5G = {
  452. 0x10, 0x16, 0x18, 0x40, 0x46,
  453. 0x48, 0x30, 0x36, 0x38
  454. },
  455. .ctl_freqbin_5G = {
  456. {
  457. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  458. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  459. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  460. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  461. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  462. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  463. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  464. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  465. },
  466. {
  467. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  468. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  469. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  470. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  471. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  472. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  473. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  474. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  475. },
  476. {
  477. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  478. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  479. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  480. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  481. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  482. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  483. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  484. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  485. },
  486. {
  487. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  488. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  489. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  490. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  491. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  492. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  493. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  494. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  495. },
  496. {
  497. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  498. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  499. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  500. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  501. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  502. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  503. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  504. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  505. },
  506. {
  507. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  508. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  509. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  510. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  511. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  512. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  513. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  514. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  515. },
  516. {
  517. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  518. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  519. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  520. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  521. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  522. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  523. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  524. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  525. },
  526. {
  527. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  528. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  529. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  530. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  531. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  532. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  533. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  534. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  535. },
  536. {
  537. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  538. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  539. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  540. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  541. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  542. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  543. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  544. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  545. }
  546. },
  547. .ctlPowerData_5G = {
  548. {
  549. {
  550. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  551. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  552. }
  553. },
  554. {
  555. {
  556. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  557. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  558. }
  559. },
  560. {
  561. {
  562. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  563. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  564. }
  565. },
  566. {
  567. {
  568. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  569. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  570. }
  571. },
  572. {
  573. {
  574. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  575. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  576. }
  577. },
  578. {
  579. {
  580. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  581. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  582. }
  583. },
  584. {
  585. {
  586. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  587. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  588. }
  589. },
  590. {
  591. {
  592. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  593. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  594. }
  595. },
  596. {
  597. {
  598. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  599. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  600. }
  601. },
  602. }
  603. };
  604. static const struct ar9300_eeprom ar9300_x113 = {
  605. .eepromVersion = 2,
  606. .templateVersion = 6,
  607. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  608. .custData = {"x113-023-f0000"},
  609. .baseEepHeader = {
  610. .regDmn = { LE16(0), LE16(0x1f) },
  611. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  612. .opCapFlags = {
  613. .opFlags = AR5416_OPFLAGS_11A,
  614. .eepMisc = 0,
  615. },
  616. .rfSilent = 0,
  617. .blueToothOptions = 0,
  618. .deviceCap = 0,
  619. .deviceType = 5, /* takes lower byte in eeprom location */
  620. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  621. .params_for_tuning_caps = {0, 0},
  622. .featureEnable = 0x0d,
  623. /*
  624. * bit0 - enable tx temp comp - disabled
  625. * bit1 - enable tx volt comp - disabled
  626. * bit2 - enable fastClock - enabled
  627. * bit3 - enable doubling - enabled
  628. * bit4 - enable internal regulator - disabled
  629. * bit5 - enable pa predistortion - disabled
  630. */
  631. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  632. .eepromWriteEnableGpio = 6,
  633. .wlanDisableGpio = 0,
  634. .wlanLedGpio = 8,
  635. .rxBandSelectGpio = 0xff,
  636. .txrxgain = 0x21,
  637. .swreg = 0,
  638. },
  639. .modalHeader2G = {
  640. /* ar9300_modal_eep_header 2g */
  641. /* 4 idle,t1,t2,b(4 bits per setting) */
  642. .antCtrlCommon = LE32(0x110),
  643. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  644. .antCtrlCommon2 = LE32(0x44444),
  645. /*
  646. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  647. * rx1, rx12, b (2 bits each)
  648. */
  649. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  650. /*
  651. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  652. * for ar9280 (0xa20c/b20c 5:0)
  653. */
  654. .xatten1DB = {0, 0, 0},
  655. /*
  656. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  657. * for ar9280 (0xa20c/b20c 16:12
  658. */
  659. .xatten1Margin = {0, 0, 0},
  660. .tempSlope = 25,
  661. .voltSlope = 0,
  662. /*
  663. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  664. * channels in usual fbin coding format
  665. */
  666. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  667. /*
  668. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  669. * if the register is per chain
  670. */
  671. .noiseFloorThreshCh = {-1, 0, 0},
  672. .ob = {1, 1, 1},/* 3 chain */
  673. .db_stage2 = {1, 1, 1}, /* 3 chain */
  674. .db_stage3 = {0, 0, 0},
  675. .db_stage4 = {0, 0, 0},
  676. .xpaBiasLvl = 0,
  677. .txFrameToDataStart = 0x0e,
  678. .txFrameToPaOn = 0x0e,
  679. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  680. .antennaGain = 0,
  681. .switchSettling = 0x2c,
  682. .adcDesiredSize = -30,
  683. .txEndToXpaOff = 0,
  684. .txEndToRxOn = 0x2,
  685. .txFrameToXpaOn = 0xe,
  686. .thresh62 = 28,
  687. .papdRateMaskHt20 = LE32(0x0c80c080),
  688. .papdRateMaskHt40 = LE32(0x0080c080),
  689. .futureModal = {
  690. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  691. },
  692. },
  693. .base_ext1 = {
  694. .ant_div_control = 0,
  695. .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  696. },
  697. .calFreqPier2G = {
  698. FREQ2FBIN(2412, 1),
  699. FREQ2FBIN(2437, 1),
  700. FREQ2FBIN(2472, 1),
  701. },
  702. /* ar9300_cal_data_per_freq_op_loop 2g */
  703. .calPierData2G = {
  704. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  705. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  706. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  707. },
  708. .calTarget_freqbin_Cck = {
  709. FREQ2FBIN(2412, 1),
  710. FREQ2FBIN(2472, 1),
  711. },
  712. .calTarget_freqbin_2G = {
  713. FREQ2FBIN(2412, 1),
  714. FREQ2FBIN(2437, 1),
  715. FREQ2FBIN(2472, 1)
  716. },
  717. .calTarget_freqbin_2GHT20 = {
  718. FREQ2FBIN(2412, 1),
  719. FREQ2FBIN(2437, 1),
  720. FREQ2FBIN(2472, 1)
  721. },
  722. .calTarget_freqbin_2GHT40 = {
  723. FREQ2FBIN(2412, 1),
  724. FREQ2FBIN(2437, 1),
  725. FREQ2FBIN(2472, 1)
  726. },
  727. .calTargetPowerCck = {
  728. /* 1L-5L,5S,11L,11S */
  729. { {34, 34, 34, 34} },
  730. { {34, 34, 34, 34} },
  731. },
  732. .calTargetPower2G = {
  733. /* 6-24,36,48,54 */
  734. { {34, 34, 32, 32} },
  735. { {34, 34, 32, 32} },
  736. { {34, 34, 32, 32} },
  737. },
  738. .calTargetPower2GHT20 = {
  739. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  740. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  741. { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
  742. },
  743. .calTargetPower2GHT40 = {
  744. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  745. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  746. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  747. },
  748. .ctlIndex_2G = {
  749. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  750. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  751. },
  752. .ctl_freqbin_2G = {
  753. {
  754. FREQ2FBIN(2412, 1),
  755. FREQ2FBIN(2417, 1),
  756. FREQ2FBIN(2457, 1),
  757. FREQ2FBIN(2462, 1)
  758. },
  759. {
  760. FREQ2FBIN(2412, 1),
  761. FREQ2FBIN(2417, 1),
  762. FREQ2FBIN(2462, 1),
  763. 0xFF,
  764. },
  765. {
  766. FREQ2FBIN(2412, 1),
  767. FREQ2FBIN(2417, 1),
  768. FREQ2FBIN(2462, 1),
  769. 0xFF,
  770. },
  771. {
  772. FREQ2FBIN(2422, 1),
  773. FREQ2FBIN(2427, 1),
  774. FREQ2FBIN(2447, 1),
  775. FREQ2FBIN(2452, 1)
  776. },
  777. {
  778. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  779. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  780. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  781. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  782. },
  783. {
  784. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  785. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  786. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  787. 0,
  788. },
  789. {
  790. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  791. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  792. FREQ2FBIN(2472, 1),
  793. 0,
  794. },
  795. {
  796. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  797. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  798. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  799. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  800. },
  801. {
  802. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  803. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  804. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  805. },
  806. {
  807. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  808. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  809. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  810. 0
  811. },
  812. {
  813. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  814. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  815. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  816. 0
  817. },
  818. {
  819. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  820. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  821. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  822. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  823. }
  824. },
  825. .ctlPowerData_2G = {
  826. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  827. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  828. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  829. { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
  830. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  831. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  832. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  833. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  834. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  835. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  836. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  837. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  838. },
  839. .modalHeader5G = {
  840. /* 4 idle,t1,t2,b (4 bits per setting) */
  841. .antCtrlCommon = LE32(0x220),
  842. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  843. .antCtrlCommon2 = LE32(0x11111),
  844. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  845. .antCtrlChain = {
  846. LE16(0x150), LE16(0x150), LE16(0x150),
  847. },
  848. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  849. .xatten1DB = {0, 0, 0},
  850. /*
  851. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  852. * for merlin (0xa20c/b20c 16:12
  853. */
  854. .xatten1Margin = {0, 0, 0},
  855. .tempSlope = 68,
  856. .voltSlope = 0,
  857. /* spurChans spur channels in usual fbin coding format */
  858. .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0},
  859. /* noiseFloorThreshCh Check if the register is per chain */
  860. .noiseFloorThreshCh = {-1, 0, 0},
  861. .ob = {3, 3, 3}, /* 3 chain */
  862. .db_stage2 = {3, 3, 3}, /* 3 chain */
  863. .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */
  864. .db_stage4 = {3, 3, 3}, /* don't exist for 2G */
  865. .xpaBiasLvl = 0xf,
  866. .txFrameToDataStart = 0x0e,
  867. .txFrameToPaOn = 0x0e,
  868. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  869. .antennaGain = 0,
  870. .switchSettling = 0x2d,
  871. .adcDesiredSize = -30,
  872. .txEndToXpaOff = 0,
  873. .txEndToRxOn = 0x2,
  874. .txFrameToXpaOn = 0xe,
  875. .thresh62 = 28,
  876. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  877. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  878. .futureModal = {
  879. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  880. },
  881. },
  882. .base_ext2 = {
  883. .tempSlopeLow = 72,
  884. .tempSlopeHigh = 105,
  885. .xatten1DBLow = {0, 0, 0},
  886. .xatten1MarginLow = {0, 0, 0},
  887. .xatten1DBHigh = {0, 0, 0},
  888. .xatten1MarginHigh = {0, 0, 0}
  889. },
  890. .calFreqPier5G = {
  891. FREQ2FBIN(5180, 0),
  892. FREQ2FBIN(5240, 0),
  893. FREQ2FBIN(5320, 0),
  894. FREQ2FBIN(5400, 0),
  895. FREQ2FBIN(5500, 0),
  896. FREQ2FBIN(5600, 0),
  897. FREQ2FBIN(5745, 0),
  898. FREQ2FBIN(5785, 0)
  899. },
  900. .calPierData5G = {
  901. {
  902. {0, 0, 0, 0, 0},
  903. {0, 0, 0, 0, 0},
  904. {0, 0, 0, 0, 0},
  905. {0, 0, 0, 0, 0},
  906. {0, 0, 0, 0, 0},
  907. {0, 0, 0, 0, 0},
  908. {0, 0, 0, 0, 0},
  909. {0, 0, 0, 0, 0},
  910. },
  911. {
  912. {0, 0, 0, 0, 0},
  913. {0, 0, 0, 0, 0},
  914. {0, 0, 0, 0, 0},
  915. {0, 0, 0, 0, 0},
  916. {0, 0, 0, 0, 0},
  917. {0, 0, 0, 0, 0},
  918. {0, 0, 0, 0, 0},
  919. {0, 0, 0, 0, 0},
  920. },
  921. {
  922. {0, 0, 0, 0, 0},
  923. {0, 0, 0, 0, 0},
  924. {0, 0, 0, 0, 0},
  925. {0, 0, 0, 0, 0},
  926. {0, 0, 0, 0, 0},
  927. {0, 0, 0, 0, 0},
  928. {0, 0, 0, 0, 0},
  929. {0, 0, 0, 0, 0},
  930. },
  931. },
  932. .calTarget_freqbin_5G = {
  933. FREQ2FBIN(5180, 0),
  934. FREQ2FBIN(5220, 0),
  935. FREQ2FBIN(5320, 0),
  936. FREQ2FBIN(5400, 0),
  937. FREQ2FBIN(5500, 0),
  938. FREQ2FBIN(5600, 0),
  939. FREQ2FBIN(5745, 0),
  940. FREQ2FBIN(5785, 0)
  941. },
  942. .calTarget_freqbin_5GHT20 = {
  943. FREQ2FBIN(5180, 0),
  944. FREQ2FBIN(5240, 0),
  945. FREQ2FBIN(5320, 0),
  946. FREQ2FBIN(5400, 0),
  947. FREQ2FBIN(5500, 0),
  948. FREQ2FBIN(5700, 0),
  949. FREQ2FBIN(5745, 0),
  950. FREQ2FBIN(5825, 0)
  951. },
  952. .calTarget_freqbin_5GHT40 = {
  953. FREQ2FBIN(5190, 0),
  954. FREQ2FBIN(5230, 0),
  955. FREQ2FBIN(5320, 0),
  956. FREQ2FBIN(5410, 0),
  957. FREQ2FBIN(5510, 0),
  958. FREQ2FBIN(5670, 0),
  959. FREQ2FBIN(5755, 0),
  960. FREQ2FBIN(5825, 0)
  961. },
  962. .calTargetPower5G = {
  963. /* 6-24,36,48,54 */
  964. { {42, 40, 40, 34} },
  965. { {42, 40, 40, 34} },
  966. { {42, 40, 40, 34} },
  967. { {42, 40, 40, 34} },
  968. { {42, 40, 40, 34} },
  969. { {42, 40, 40, 34} },
  970. { {42, 40, 40, 34} },
  971. { {42, 40, 40, 34} },
  972. },
  973. .calTargetPower5GHT20 = {
  974. /*
  975. * 0_8_16,1-3_9-11_17-19,
  976. * 4,5,6,7,12,13,14,15,20,21,22,23
  977. */
  978. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  979. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  980. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  981. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  982. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  983. { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
  984. { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} },
  985. { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} },
  986. },
  987. .calTargetPower5GHT40 = {
  988. /*
  989. * 0_8_16,1-3_9-11_17-19,
  990. * 4,5,6,7,12,13,14,15,20,21,22,23
  991. */
  992. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  993. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  994. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  995. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  996. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  997. { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
  998. { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} },
  999. { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} },
  1000. },
  1001. .ctlIndex_5G = {
  1002. 0x10, 0x16, 0x18, 0x40, 0x46,
  1003. 0x48, 0x30, 0x36, 0x38
  1004. },
  1005. .ctl_freqbin_5G = {
  1006. {
  1007. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1008. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1009. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1010. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1011. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  1012. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1013. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1014. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1015. },
  1016. {
  1017. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1018. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1019. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1020. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1021. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1022. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1023. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1024. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1025. },
  1026. {
  1027. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1028. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1029. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1030. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1031. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1032. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1033. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1034. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1035. },
  1036. {
  1037. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1038. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1039. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1040. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1041. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1042. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1043. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1044. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1045. },
  1046. {
  1047. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1048. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1049. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1050. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1051. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1052. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1053. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1054. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1055. },
  1056. {
  1057. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1058. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1059. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1060. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1061. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1062. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1063. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1064. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1065. },
  1066. {
  1067. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1068. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1069. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1070. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1071. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1072. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1073. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1074. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1075. },
  1076. {
  1077. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1078. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1079. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1080. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1081. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1082. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1083. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1084. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1085. },
  1086. {
  1087. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1088. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1089. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1090. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1091. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1092. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1093. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1094. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1095. }
  1096. },
  1097. .ctlPowerData_5G = {
  1098. {
  1099. {
  1100. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1101. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1102. }
  1103. },
  1104. {
  1105. {
  1106. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1107. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1108. }
  1109. },
  1110. {
  1111. {
  1112. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1113. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1114. }
  1115. },
  1116. {
  1117. {
  1118. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1119. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1120. }
  1121. },
  1122. {
  1123. {
  1124. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1125. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1126. }
  1127. },
  1128. {
  1129. {
  1130. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1131. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1132. }
  1133. },
  1134. {
  1135. {
  1136. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1137. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1138. }
  1139. },
  1140. {
  1141. {
  1142. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1143. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1144. }
  1145. },
  1146. {
  1147. {
  1148. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1149. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1150. }
  1151. },
  1152. }
  1153. };
  1154. static const struct ar9300_eeprom ar9300_h112 = {
  1155. .eepromVersion = 2,
  1156. .templateVersion = 3,
  1157. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1158. .custData = {"h112-241-f0000"},
  1159. .baseEepHeader = {
  1160. .regDmn = { LE16(0), LE16(0x1f) },
  1161. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1162. .opCapFlags = {
  1163. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1164. .eepMisc = 0,
  1165. },
  1166. .rfSilent = 0,
  1167. .blueToothOptions = 0,
  1168. .deviceCap = 0,
  1169. .deviceType = 5, /* takes lower byte in eeprom location */
  1170. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1171. .params_for_tuning_caps = {0, 0},
  1172. .featureEnable = 0x0d,
  1173. /*
  1174. * bit0 - enable tx temp comp - disabled
  1175. * bit1 - enable tx volt comp - disabled
  1176. * bit2 - enable fastClock - enabled
  1177. * bit3 - enable doubling - enabled
  1178. * bit4 - enable internal regulator - disabled
  1179. * bit5 - enable pa predistortion - disabled
  1180. */
  1181. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1182. .eepromWriteEnableGpio = 6,
  1183. .wlanDisableGpio = 0,
  1184. .wlanLedGpio = 8,
  1185. .rxBandSelectGpio = 0xff,
  1186. .txrxgain = 0x10,
  1187. .swreg = 0,
  1188. },
  1189. .modalHeader2G = {
  1190. /* ar9300_modal_eep_header 2g */
  1191. /* 4 idle,t1,t2,b(4 bits per setting) */
  1192. .antCtrlCommon = LE32(0x110),
  1193. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1194. .antCtrlCommon2 = LE32(0x44444),
  1195. /*
  1196. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  1197. * rx1, rx12, b (2 bits each)
  1198. */
  1199. .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
  1200. /*
  1201. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  1202. * for ar9280 (0xa20c/b20c 5:0)
  1203. */
  1204. .xatten1DB = {0, 0, 0},
  1205. /*
  1206. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1207. * for ar9280 (0xa20c/b20c 16:12
  1208. */
  1209. .xatten1Margin = {0, 0, 0},
  1210. .tempSlope = 25,
  1211. .voltSlope = 0,
  1212. /*
  1213. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  1214. * channels in usual fbin coding format
  1215. */
  1216. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1217. /*
  1218. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  1219. * if the register is per chain
  1220. */
  1221. .noiseFloorThreshCh = {-1, 0, 0},
  1222. .ob = {1, 1, 1},/* 3 chain */
  1223. .db_stage2 = {1, 1, 1}, /* 3 chain */
  1224. .db_stage3 = {0, 0, 0},
  1225. .db_stage4 = {0, 0, 0},
  1226. .xpaBiasLvl = 0,
  1227. .txFrameToDataStart = 0x0e,
  1228. .txFrameToPaOn = 0x0e,
  1229. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1230. .antennaGain = 0,
  1231. .switchSettling = 0x2c,
  1232. .adcDesiredSize = -30,
  1233. .txEndToXpaOff = 0,
  1234. .txEndToRxOn = 0x2,
  1235. .txFrameToXpaOn = 0xe,
  1236. .thresh62 = 28,
  1237. .papdRateMaskHt20 = LE32(0x80c080),
  1238. .papdRateMaskHt40 = LE32(0x80c080),
  1239. .futureModal = {
  1240. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1241. },
  1242. },
  1243. .base_ext1 = {
  1244. .ant_div_control = 0,
  1245. .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  1246. },
  1247. .calFreqPier2G = {
  1248. FREQ2FBIN(2412, 1),
  1249. FREQ2FBIN(2437, 1),
  1250. FREQ2FBIN(2472, 1),
  1251. },
  1252. /* ar9300_cal_data_per_freq_op_loop 2g */
  1253. .calPierData2G = {
  1254. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1255. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1256. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1257. },
  1258. .calTarget_freqbin_Cck = {
  1259. FREQ2FBIN(2412, 1),
  1260. FREQ2FBIN(2484, 1),
  1261. },
  1262. .calTarget_freqbin_2G = {
  1263. FREQ2FBIN(2412, 1),
  1264. FREQ2FBIN(2437, 1),
  1265. FREQ2FBIN(2472, 1)
  1266. },
  1267. .calTarget_freqbin_2GHT20 = {
  1268. FREQ2FBIN(2412, 1),
  1269. FREQ2FBIN(2437, 1),
  1270. FREQ2FBIN(2472, 1)
  1271. },
  1272. .calTarget_freqbin_2GHT40 = {
  1273. FREQ2FBIN(2412, 1),
  1274. FREQ2FBIN(2437, 1),
  1275. FREQ2FBIN(2472, 1)
  1276. },
  1277. .calTargetPowerCck = {
  1278. /* 1L-5L,5S,11L,11S */
  1279. { {34, 34, 34, 34} },
  1280. { {34, 34, 34, 34} },
  1281. },
  1282. .calTargetPower2G = {
  1283. /* 6-24,36,48,54 */
  1284. { {34, 34, 32, 32} },
  1285. { {34, 34, 32, 32} },
  1286. { {34, 34, 32, 32} },
  1287. },
  1288. .calTargetPower2GHT20 = {
  1289. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1290. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1291. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
  1292. },
  1293. .calTargetPower2GHT40 = {
  1294. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1295. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1296. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
  1297. },
  1298. .ctlIndex_2G = {
  1299. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1300. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1301. },
  1302. .ctl_freqbin_2G = {
  1303. {
  1304. FREQ2FBIN(2412, 1),
  1305. FREQ2FBIN(2417, 1),
  1306. FREQ2FBIN(2457, 1),
  1307. FREQ2FBIN(2462, 1)
  1308. },
  1309. {
  1310. FREQ2FBIN(2412, 1),
  1311. FREQ2FBIN(2417, 1),
  1312. FREQ2FBIN(2462, 1),
  1313. 0xFF,
  1314. },
  1315. {
  1316. FREQ2FBIN(2412, 1),
  1317. FREQ2FBIN(2417, 1),
  1318. FREQ2FBIN(2462, 1),
  1319. 0xFF,
  1320. },
  1321. {
  1322. FREQ2FBIN(2422, 1),
  1323. FREQ2FBIN(2427, 1),
  1324. FREQ2FBIN(2447, 1),
  1325. FREQ2FBIN(2452, 1)
  1326. },
  1327. {
  1328. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1329. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1330. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1331. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  1332. },
  1333. {
  1334. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1335. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1336. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1337. 0,
  1338. },
  1339. {
  1340. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1341. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1342. FREQ2FBIN(2472, 1),
  1343. 0,
  1344. },
  1345. {
  1346. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1347. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1348. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1349. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1350. },
  1351. {
  1352. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1353. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1354. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1355. },
  1356. {
  1357. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1358. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1359. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1360. 0
  1361. },
  1362. {
  1363. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  1364. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  1365. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  1366. 0
  1367. },
  1368. {
  1369. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  1370. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  1371. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  1372. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  1373. }
  1374. },
  1375. .ctlPowerData_2G = {
  1376. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1377. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1378. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1379. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  1380. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1381. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1382. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1383. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1384. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1385. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1386. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1387. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1388. },
  1389. .modalHeader5G = {
  1390. /* 4 idle,t1,t2,b (4 bits per setting) */
  1391. .antCtrlCommon = LE32(0x220),
  1392. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1393. .antCtrlCommon2 = LE32(0x44444),
  1394. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1395. .antCtrlChain = {
  1396. LE16(0x150), LE16(0x150), LE16(0x150),
  1397. },
  1398. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  1399. .xatten1DB = {0, 0, 0},
  1400. /*
  1401. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  1402. * for merlin (0xa20c/b20c 16:12
  1403. */
  1404. .xatten1Margin = {0, 0, 0},
  1405. .tempSlope = 45,
  1406. .voltSlope = 0,
  1407. /* spurChans spur channels in usual fbin coding format */
  1408. .spurChans = {0, 0, 0, 0, 0},
  1409. /* noiseFloorThreshCh Check if the register is per chain */
  1410. .noiseFloorThreshCh = {-1, 0, 0},
  1411. .ob = {3, 3, 3}, /* 3 chain */
  1412. .db_stage2 = {3, 3, 3}, /* 3 chain */
  1413. .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */
  1414. .db_stage4 = {3, 3, 3}, /* don't exist for 2G */
  1415. .xpaBiasLvl = 0,
  1416. .txFrameToDataStart = 0x0e,
  1417. .txFrameToPaOn = 0x0e,
  1418. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1419. .antennaGain = 0,
  1420. .switchSettling = 0x2d,
  1421. .adcDesiredSize = -30,
  1422. .txEndToXpaOff = 0,
  1423. .txEndToRxOn = 0x2,
  1424. .txFrameToXpaOn = 0xe,
  1425. .thresh62 = 28,
  1426. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1427. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1428. .futureModal = {
  1429. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1430. },
  1431. },
  1432. .base_ext2 = {
  1433. .tempSlopeLow = 40,
  1434. .tempSlopeHigh = 50,
  1435. .xatten1DBLow = {0, 0, 0},
  1436. .xatten1MarginLow = {0, 0, 0},
  1437. .xatten1DBHigh = {0, 0, 0},
  1438. .xatten1MarginHigh = {0, 0, 0}
  1439. },
  1440. .calFreqPier5G = {
  1441. FREQ2FBIN(5180, 0),
  1442. FREQ2FBIN(5220, 0),
  1443. FREQ2FBIN(5320, 0),
  1444. FREQ2FBIN(5400, 0),
  1445. FREQ2FBIN(5500, 0),
  1446. FREQ2FBIN(5600, 0),
  1447. FREQ2FBIN(5700, 0),
  1448. FREQ2FBIN(5825, 0)
  1449. },
  1450. .calPierData5G = {
  1451. {
  1452. {0, 0, 0, 0, 0},
  1453. {0, 0, 0, 0, 0},
  1454. {0, 0, 0, 0, 0},
  1455. {0, 0, 0, 0, 0},
  1456. {0, 0, 0, 0, 0},
  1457. {0, 0, 0, 0, 0},
  1458. {0, 0, 0, 0, 0},
  1459. {0, 0, 0, 0, 0},
  1460. },
  1461. {
  1462. {0, 0, 0, 0, 0},
  1463. {0, 0, 0, 0, 0},
  1464. {0, 0, 0, 0, 0},
  1465. {0, 0, 0, 0, 0},
  1466. {0, 0, 0, 0, 0},
  1467. {0, 0, 0, 0, 0},
  1468. {0, 0, 0, 0, 0},
  1469. {0, 0, 0, 0, 0},
  1470. },
  1471. {
  1472. {0, 0, 0, 0, 0},
  1473. {0, 0, 0, 0, 0},
  1474. {0, 0, 0, 0, 0},
  1475. {0, 0, 0, 0, 0},
  1476. {0, 0, 0, 0, 0},
  1477. {0, 0, 0, 0, 0},
  1478. {0, 0, 0, 0, 0},
  1479. {0, 0, 0, 0, 0},
  1480. },
  1481. },
  1482. .calTarget_freqbin_5G = {
  1483. FREQ2FBIN(5180, 0),
  1484. FREQ2FBIN(5240, 0),
  1485. FREQ2FBIN(5320, 0),
  1486. FREQ2FBIN(5400, 0),
  1487. FREQ2FBIN(5500, 0),
  1488. FREQ2FBIN(5600, 0),
  1489. FREQ2FBIN(5700, 0),
  1490. FREQ2FBIN(5825, 0)
  1491. },
  1492. .calTarget_freqbin_5GHT20 = {
  1493. FREQ2FBIN(5180, 0),
  1494. FREQ2FBIN(5240, 0),
  1495. FREQ2FBIN(5320, 0),
  1496. FREQ2FBIN(5400, 0),
  1497. FREQ2FBIN(5500, 0),
  1498. FREQ2FBIN(5700, 0),
  1499. FREQ2FBIN(5745, 0),
  1500. FREQ2FBIN(5825, 0)
  1501. },
  1502. .calTarget_freqbin_5GHT40 = {
  1503. FREQ2FBIN(5180, 0),
  1504. FREQ2FBIN(5240, 0),
  1505. FREQ2FBIN(5320, 0),
  1506. FREQ2FBIN(5400, 0),
  1507. FREQ2FBIN(5500, 0),
  1508. FREQ2FBIN(5700, 0),
  1509. FREQ2FBIN(5745, 0),
  1510. FREQ2FBIN(5825, 0)
  1511. },
  1512. .calTargetPower5G = {
  1513. /* 6-24,36,48,54 */
  1514. { {30, 30, 28, 24} },
  1515. { {30, 30, 28, 24} },
  1516. { {30, 30, 28, 24} },
  1517. { {30, 30, 28, 24} },
  1518. { {30, 30, 28, 24} },
  1519. { {30, 30, 28, 24} },
  1520. { {30, 30, 28, 24} },
  1521. { {30, 30, 28, 24} },
  1522. },
  1523. .calTargetPower5GHT20 = {
  1524. /*
  1525. * 0_8_16,1-3_9-11_17-19,
  1526. * 4,5,6,7,12,13,14,15,20,21,22,23
  1527. */
  1528. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1529. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
  1530. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1531. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
  1532. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1533. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
  1534. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1535. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
  1536. },
  1537. .calTargetPower5GHT40 = {
  1538. /*
  1539. * 0_8_16,1-3_9-11_17-19,
  1540. * 4,5,6,7,12,13,14,15,20,21,22,23
  1541. */
  1542. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1543. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
  1544. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1545. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
  1546. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1547. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
  1548. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1549. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
  1550. },
  1551. .ctlIndex_5G = {
  1552. 0x10, 0x16, 0x18, 0x40, 0x46,
  1553. 0x48, 0x30, 0x36, 0x38
  1554. },
  1555. .ctl_freqbin_5G = {
  1556. {
  1557. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1558. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1559. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1560. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1561. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  1562. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1563. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1564. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1565. },
  1566. {
  1567. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1568. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1569. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  1570. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1571. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  1572. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1573. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1574. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1575. },
  1576. {
  1577. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1578. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1579. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1580. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  1581. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  1582. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  1583. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  1584. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  1585. },
  1586. {
  1587. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1588. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1589. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  1590. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  1591. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1592. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1593. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  1594. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  1595. },
  1596. {
  1597. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1598. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1599. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  1600. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  1601. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  1602. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  1603. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  1604. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  1605. },
  1606. {
  1607. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1608. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  1609. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  1610. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1611. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  1612. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1613. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  1614. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  1615. },
  1616. {
  1617. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1618. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  1619. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  1620. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  1621. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  1622. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  1623. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  1624. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  1625. },
  1626. {
  1627. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  1628. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  1629. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  1630. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  1631. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  1632. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  1633. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  1634. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  1635. },
  1636. {
  1637. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  1638. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  1639. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  1640. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  1641. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  1642. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  1643. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  1644. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  1645. }
  1646. },
  1647. .ctlPowerData_5G = {
  1648. {
  1649. {
  1650. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1651. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1652. }
  1653. },
  1654. {
  1655. {
  1656. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1657. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1658. }
  1659. },
  1660. {
  1661. {
  1662. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1663. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1664. }
  1665. },
  1666. {
  1667. {
  1668. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1669. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1670. }
  1671. },
  1672. {
  1673. {
  1674. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1675. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1676. }
  1677. },
  1678. {
  1679. {
  1680. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1681. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  1682. }
  1683. },
  1684. {
  1685. {
  1686. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1687. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  1688. }
  1689. },
  1690. {
  1691. {
  1692. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1693. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  1694. }
  1695. },
  1696. {
  1697. {
  1698. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  1699. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  1700. }
  1701. },
  1702. }
  1703. };
  1704. static const struct ar9300_eeprom ar9300_x112 = {
  1705. .eepromVersion = 2,
  1706. .templateVersion = 5,
  1707. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  1708. .custData = {"x112-041-f0000"},
  1709. .baseEepHeader = {
  1710. .regDmn = { LE16(0), LE16(0x1f) },
  1711. .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
  1712. .opCapFlags = {
  1713. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  1714. .eepMisc = 0,
  1715. },
  1716. .rfSilent = 0,
  1717. .blueToothOptions = 0,
  1718. .deviceCap = 0,
  1719. .deviceType = 5, /* takes lower byte in eeprom location */
  1720. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  1721. .params_for_tuning_caps = {0, 0},
  1722. .featureEnable = 0x0d,
  1723. /*
  1724. * bit0 - enable tx temp comp - disabled
  1725. * bit1 - enable tx volt comp - disabled
  1726. * bit2 - enable fastclock - enabled
  1727. * bit3 - enable doubling - enabled
  1728. * bit4 - enable internal regulator - disabled
  1729. * bit5 - enable pa predistortion - disabled
  1730. */
  1731. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  1732. .eepromWriteEnableGpio = 6,
  1733. .wlanDisableGpio = 0,
  1734. .wlanLedGpio = 8,
  1735. .rxBandSelectGpio = 0xff,
  1736. .txrxgain = 0x0,
  1737. .swreg = 0,
  1738. },
  1739. .modalHeader2G = {
  1740. /* ar9300_modal_eep_header 2g */
  1741. /* 4 idle,t1,t2,b(4 bits per setting) */
  1742. .antCtrlCommon = LE32(0x110),
  1743. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  1744. .antCtrlCommon2 = LE32(0x22222),
  1745. /*
  1746. * antCtrlChain[ar9300_max_chains]; 6 idle, t, r,
  1747. * rx1, rx12, b (2 bits each)
  1748. */
  1749. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  1750. /*
  1751. * xatten1DB[AR9300_max_chains]; 3 xatten1_db
  1752. * for ar9280 (0xa20c/b20c 5:0)
  1753. */
  1754. .xatten1DB = {0x1b, 0x1b, 0x1b},
  1755. /*
  1756. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1757. * for ar9280 (0xa20c/b20c 16:12
  1758. */
  1759. .xatten1Margin = {0x15, 0x15, 0x15},
  1760. .tempSlope = 50,
  1761. .voltSlope = 0,
  1762. /*
  1763. * spurChans[OSPrey_eeprom_modal_sPURS]; spur
  1764. * channels in usual fbin coding format
  1765. */
  1766. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  1767. /*
  1768. * noiseFloorThreshch[ar9300_max_cHAINS]; 3 Check
  1769. * if the register is per chain
  1770. */
  1771. .noiseFloorThreshCh = {-1, 0, 0},
  1772. .ob = {1, 1, 1},/* 3 chain */
  1773. .db_stage2 = {1, 1, 1}, /* 3 chain */
  1774. .db_stage3 = {0, 0, 0},
  1775. .db_stage4 = {0, 0, 0},
  1776. .xpaBiasLvl = 0,
  1777. .txFrameToDataStart = 0x0e,
  1778. .txFrameToPaOn = 0x0e,
  1779. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1780. .antennaGain = 0,
  1781. .switchSettling = 0x2c,
  1782. .adcDesiredSize = -30,
  1783. .txEndToXpaOff = 0,
  1784. .txEndToRxOn = 0x2,
  1785. .txFrameToXpaOn = 0xe,
  1786. .thresh62 = 28,
  1787. .papdRateMaskHt20 = LE32(0x0c80c080),
  1788. .papdRateMaskHt40 = LE32(0x0080c080),
  1789. .futureModal = {
  1790. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1791. },
  1792. },
  1793. .base_ext1 = {
  1794. .ant_div_control = 0,
  1795. .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  1796. },
  1797. .calFreqPier2G = {
  1798. FREQ2FBIN(2412, 1),
  1799. FREQ2FBIN(2437, 1),
  1800. FREQ2FBIN(2472, 1),
  1801. },
  1802. /* ar9300_cal_data_per_freq_op_loop 2g */
  1803. .calPierData2G = {
  1804. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1805. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1806. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  1807. },
  1808. .calTarget_freqbin_Cck = {
  1809. FREQ2FBIN(2412, 1),
  1810. FREQ2FBIN(2472, 1),
  1811. },
  1812. .calTarget_freqbin_2G = {
  1813. FREQ2FBIN(2412, 1),
  1814. FREQ2FBIN(2437, 1),
  1815. FREQ2FBIN(2472, 1)
  1816. },
  1817. .calTarget_freqbin_2GHT20 = {
  1818. FREQ2FBIN(2412, 1),
  1819. FREQ2FBIN(2437, 1),
  1820. FREQ2FBIN(2472, 1)
  1821. },
  1822. .calTarget_freqbin_2GHT40 = {
  1823. FREQ2FBIN(2412, 1),
  1824. FREQ2FBIN(2437, 1),
  1825. FREQ2FBIN(2472, 1)
  1826. },
  1827. .calTargetPowerCck = {
  1828. /* 1L-5L,5S,11L,11s */
  1829. { {38, 38, 38, 38} },
  1830. { {38, 38, 38, 38} },
  1831. },
  1832. .calTargetPower2G = {
  1833. /* 6-24,36,48,54 */
  1834. { {38, 38, 36, 34} },
  1835. { {38, 38, 36, 34} },
  1836. { {38, 38, 34, 32} },
  1837. },
  1838. .calTargetPower2GHT20 = {
  1839. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1840. { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} },
  1841. { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
  1842. },
  1843. .calTargetPower2GHT40 = {
  1844. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1845. { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} },
  1846. { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
  1847. },
  1848. .ctlIndex_2G = {
  1849. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  1850. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  1851. },
  1852. .ctl_freqbin_2G = {
  1853. {
  1854. FREQ2FBIN(2412, 1),
  1855. FREQ2FBIN(2417, 1),
  1856. FREQ2FBIN(2457, 1),
  1857. FREQ2FBIN(2462, 1)
  1858. },
  1859. {
  1860. FREQ2FBIN(2412, 1),
  1861. FREQ2FBIN(2417, 1),
  1862. FREQ2FBIN(2462, 1),
  1863. 0xFF,
  1864. },
  1865. {
  1866. FREQ2FBIN(2412, 1),
  1867. FREQ2FBIN(2417, 1),
  1868. FREQ2FBIN(2462, 1),
  1869. 0xFF,
  1870. },
  1871. {
  1872. FREQ2FBIN(2422, 1),
  1873. FREQ2FBIN(2427, 1),
  1874. FREQ2FBIN(2447, 1),
  1875. FREQ2FBIN(2452, 1)
  1876. },
  1877. {
  1878. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1879. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1880. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1881. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(2484, 1),
  1882. },
  1883. {
  1884. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1885. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1886. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1887. 0,
  1888. },
  1889. {
  1890. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1891. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1892. FREQ2FBIN(2472, 1),
  1893. 0,
  1894. },
  1895. {
  1896. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1897. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1898. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1899. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1900. },
  1901. {
  1902. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1903. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1904. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1905. },
  1906. {
  1907. /* Data[9].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1908. /* Data[9].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1909. /* Data[9].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1910. 0
  1911. },
  1912. {
  1913. /* Data[10].ctledges[0].bchannel */ FREQ2FBIN(2412, 1),
  1914. /* Data[10].ctledges[1].bchannel */ FREQ2FBIN(2417, 1),
  1915. /* Data[10].ctledges[2].bchannel */ FREQ2FBIN(2472, 1),
  1916. 0
  1917. },
  1918. {
  1919. /* Data[11].ctledges[0].bchannel */ FREQ2FBIN(2422, 1),
  1920. /* Data[11].ctledges[1].bchannel */ FREQ2FBIN(2427, 1),
  1921. /* Data[11].ctledges[2].bchannel */ FREQ2FBIN(2447, 1),
  1922. /* Data[11].ctledges[3].bchannel */ FREQ2FBIN(2462, 1),
  1923. }
  1924. },
  1925. .ctlPowerData_2G = {
  1926. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1927. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1928. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  1929. { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
  1930. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1931. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1932. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  1933. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1934. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1935. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  1936. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1937. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  1938. },
  1939. .modalHeader5G = {
  1940. /* 4 idle,t1,t2,b (4 bits per setting) */
  1941. .antCtrlCommon = LE32(0x110),
  1942. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  1943. .antCtrlCommon2 = LE32(0x22222),
  1944. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  1945. .antCtrlChain = {
  1946. LE16(0x0), LE16(0x0), LE16(0x0),
  1947. },
  1948. /* xatten1DB 3 xatten1_db for ar9280 (0xa20c/b20c 5:0) */
  1949. .xatten1DB = {0x13, 0x19, 0x17},
  1950. /*
  1951. * xatten1Margin[ar9300_max_chains]; 3 xatten1_margin
  1952. * for merlin (0xa20c/b20c 16:12
  1953. */
  1954. .xatten1Margin = {0x19, 0x19, 0x19},
  1955. .tempSlope = 70,
  1956. .voltSlope = 15,
  1957. /* spurChans spur channels in usual fbin coding format */
  1958. .spurChans = {0, 0, 0, 0, 0},
  1959. /* noiseFloorThreshch check if the register is per chain */
  1960. .noiseFloorThreshCh = {-1, 0, 0},
  1961. .ob = {3, 3, 3}, /* 3 chain */
  1962. .db_stage2 = {3, 3, 3}, /* 3 chain */
  1963. .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */
  1964. .db_stage4 = {3, 3, 3}, /* don't exist for 2G */
  1965. .xpaBiasLvl = 0,
  1966. .txFrameToDataStart = 0x0e,
  1967. .txFrameToPaOn = 0x0e,
  1968. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  1969. .antennaGain = 0,
  1970. .switchSettling = 0x2d,
  1971. .adcDesiredSize = -30,
  1972. .txEndToXpaOff = 0,
  1973. .txEndToRxOn = 0x2,
  1974. .txFrameToXpaOn = 0xe,
  1975. .thresh62 = 28,
  1976. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  1977. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  1978. .futureModal = {
  1979. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1980. },
  1981. },
  1982. .base_ext2 = {
  1983. .tempSlopeLow = 72,
  1984. .tempSlopeHigh = 105,
  1985. .xatten1DBLow = {0x10, 0x14, 0x10},
  1986. .xatten1MarginLow = {0x19, 0x19 , 0x19},
  1987. .xatten1DBHigh = {0x1d, 0x20, 0x24},
  1988. .xatten1MarginHigh = {0x10, 0x10, 0x10}
  1989. },
  1990. .calFreqPier5G = {
  1991. FREQ2FBIN(5180, 0),
  1992. FREQ2FBIN(5220, 0),
  1993. FREQ2FBIN(5320, 0),
  1994. FREQ2FBIN(5400, 0),
  1995. FREQ2FBIN(5500, 0),
  1996. FREQ2FBIN(5600, 0),
  1997. FREQ2FBIN(5700, 0),
  1998. FREQ2FBIN(5785, 0)
  1999. },
  2000. .calPierData5G = {
  2001. {
  2002. {0, 0, 0, 0, 0},
  2003. {0, 0, 0, 0, 0},
  2004. {0, 0, 0, 0, 0},
  2005. {0, 0, 0, 0, 0},
  2006. {0, 0, 0, 0, 0},
  2007. {0, 0, 0, 0, 0},
  2008. {0, 0, 0, 0, 0},
  2009. {0, 0, 0, 0, 0},
  2010. },
  2011. {
  2012. {0, 0, 0, 0, 0},
  2013. {0, 0, 0, 0, 0},
  2014. {0, 0, 0, 0, 0},
  2015. {0, 0, 0, 0, 0},
  2016. {0, 0, 0, 0, 0},
  2017. {0, 0, 0, 0, 0},
  2018. {0, 0, 0, 0, 0},
  2019. {0, 0, 0, 0, 0},
  2020. },
  2021. {
  2022. {0, 0, 0, 0, 0},
  2023. {0, 0, 0, 0, 0},
  2024. {0, 0, 0, 0, 0},
  2025. {0, 0, 0, 0, 0},
  2026. {0, 0, 0, 0, 0},
  2027. {0, 0, 0, 0, 0},
  2028. {0, 0, 0, 0, 0},
  2029. {0, 0, 0, 0, 0},
  2030. },
  2031. },
  2032. .calTarget_freqbin_5G = {
  2033. FREQ2FBIN(5180, 0),
  2034. FREQ2FBIN(5220, 0),
  2035. FREQ2FBIN(5320, 0),
  2036. FREQ2FBIN(5400, 0),
  2037. FREQ2FBIN(5500, 0),
  2038. FREQ2FBIN(5600, 0),
  2039. FREQ2FBIN(5725, 0),
  2040. FREQ2FBIN(5825, 0)
  2041. },
  2042. .calTarget_freqbin_5GHT20 = {
  2043. FREQ2FBIN(5180, 0),
  2044. FREQ2FBIN(5220, 0),
  2045. FREQ2FBIN(5320, 0),
  2046. FREQ2FBIN(5400, 0),
  2047. FREQ2FBIN(5500, 0),
  2048. FREQ2FBIN(5600, 0),
  2049. FREQ2FBIN(5725, 0),
  2050. FREQ2FBIN(5825, 0)
  2051. },
  2052. .calTarget_freqbin_5GHT40 = {
  2053. FREQ2FBIN(5180, 0),
  2054. FREQ2FBIN(5220, 0),
  2055. FREQ2FBIN(5320, 0),
  2056. FREQ2FBIN(5400, 0),
  2057. FREQ2FBIN(5500, 0),
  2058. FREQ2FBIN(5600, 0),
  2059. FREQ2FBIN(5725, 0),
  2060. FREQ2FBIN(5825, 0)
  2061. },
  2062. .calTargetPower5G = {
  2063. /* 6-24,36,48,54 */
  2064. { {32, 32, 28, 26} },
  2065. { {32, 32, 28, 26} },
  2066. { {32, 32, 28, 26} },
  2067. { {32, 32, 26, 24} },
  2068. { {32, 32, 26, 24} },
  2069. { {32, 32, 24, 22} },
  2070. { {30, 30, 24, 22} },
  2071. { {30, 30, 24, 22} },
  2072. },
  2073. .calTargetPower5GHT20 = {
  2074. /*
  2075. * 0_8_16,1-3_9-11_17-19,
  2076. * 4,5,6,7,12,13,14,15,20,21,22,23
  2077. */
  2078. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2079. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2080. { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
  2081. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} },
  2082. { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} },
  2083. { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} },
  2084. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2085. { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
  2086. },
  2087. .calTargetPower5GHT40 = {
  2088. /*
  2089. * 0_8_16,1-3_9-11_17-19,
  2090. * 4,5,6,7,12,13,14,15,20,21,22,23
  2091. */
  2092. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2093. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2094. { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
  2095. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} },
  2096. { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} },
  2097. { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2098. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2099. { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
  2100. },
  2101. .ctlIndex_5G = {
  2102. 0x10, 0x16, 0x18, 0x40, 0x46,
  2103. 0x48, 0x30, 0x36, 0x38
  2104. },
  2105. .ctl_freqbin_5G = {
  2106. {
  2107. /* Data[0].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2108. /* Data[0].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2109. /* Data[0].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2110. /* Data[0].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2111. /* Data[0].ctledges[4].bchannel */ FREQ2FBIN(5600, 0),
  2112. /* Data[0].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2113. /* Data[0].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2114. /* Data[0].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2115. },
  2116. {
  2117. /* Data[1].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2118. /* Data[1].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2119. /* Data[1].ctledges[2].bchannel */ FREQ2FBIN(5280, 0),
  2120. /* Data[1].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2121. /* Data[1].ctledges[4].bchannel */ FREQ2FBIN(5520, 0),
  2122. /* Data[1].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2123. /* Data[1].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2124. /* Data[1].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2125. },
  2126. {
  2127. /* Data[2].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2128. /* Data[2].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2129. /* Data[2].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2130. /* Data[2].ctledges[3].bchannel */ FREQ2FBIN(5310, 0),
  2131. /* Data[2].ctledges[4].bchannel */ FREQ2FBIN(5510, 0),
  2132. /* Data[2].ctledges[5].bchannel */ FREQ2FBIN(5550, 0),
  2133. /* Data[2].ctledges[6].bchannel */ FREQ2FBIN(5670, 0),
  2134. /* Data[2].ctledges[7].bchannel */ FREQ2FBIN(5755, 0)
  2135. },
  2136. {
  2137. /* Data[3].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2138. /* Data[3].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2139. /* Data[3].ctledges[2].bchannel */ FREQ2FBIN(5260, 0),
  2140. /* Data[3].ctledges[3].bchannel */ FREQ2FBIN(5320, 0),
  2141. /* Data[3].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2142. /* Data[3].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2143. /* Data[3].ctledges[6].bchannel */ 0xFF,
  2144. /* Data[3].ctledges[7].bchannel */ 0xFF,
  2145. },
  2146. {
  2147. /* Data[4].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2148. /* Data[4].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2149. /* Data[4].ctledges[2].bchannel */ FREQ2FBIN(5500, 0),
  2150. /* Data[4].ctledges[3].bchannel */ FREQ2FBIN(5700, 0),
  2151. /* Data[4].ctledges[4].bchannel */ 0xFF,
  2152. /* Data[4].ctledges[5].bchannel */ 0xFF,
  2153. /* Data[4].ctledges[6].bchannel */ 0xFF,
  2154. /* Data[4].ctledges[7].bchannel */ 0xFF,
  2155. },
  2156. {
  2157. /* Data[5].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2158. /* Data[5].ctledges[1].bchannel */ FREQ2FBIN(5270, 0),
  2159. /* Data[5].ctledges[2].bchannel */ FREQ2FBIN(5310, 0),
  2160. /* Data[5].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2161. /* Data[5].ctledges[4].bchannel */ FREQ2FBIN(5590, 0),
  2162. /* Data[5].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2163. /* Data[5].ctledges[6].bchannel */ 0xFF,
  2164. /* Data[5].ctledges[7].bchannel */ 0xFF
  2165. },
  2166. {
  2167. /* Data[6].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2168. /* Data[6].ctledges[1].bchannel */ FREQ2FBIN(5200, 0),
  2169. /* Data[6].ctledges[2].bchannel */ FREQ2FBIN(5220, 0),
  2170. /* Data[6].ctledges[3].bchannel */ FREQ2FBIN(5260, 0),
  2171. /* Data[6].ctledges[4].bchannel */ FREQ2FBIN(5500, 0),
  2172. /* Data[6].ctledges[5].bchannel */ FREQ2FBIN(5600, 0),
  2173. /* Data[6].ctledges[6].bchannel */ FREQ2FBIN(5700, 0),
  2174. /* Data[6].ctledges[7].bchannel */ FREQ2FBIN(5745, 0)
  2175. },
  2176. {
  2177. /* Data[7].ctledges[0].bchannel */ FREQ2FBIN(5180, 0),
  2178. /* Data[7].ctledges[1].bchannel */ FREQ2FBIN(5260, 0),
  2179. /* Data[7].ctledges[2].bchannel */ FREQ2FBIN(5320, 0),
  2180. /* Data[7].ctledges[3].bchannel */ FREQ2FBIN(5500, 0),
  2181. /* Data[7].ctledges[4].bchannel */ FREQ2FBIN(5560, 0),
  2182. /* Data[7].ctledges[5].bchannel */ FREQ2FBIN(5700, 0),
  2183. /* Data[7].ctledges[6].bchannel */ FREQ2FBIN(5745, 0),
  2184. /* Data[7].ctledges[7].bchannel */ FREQ2FBIN(5825, 0)
  2185. },
  2186. {
  2187. /* Data[8].ctledges[0].bchannel */ FREQ2FBIN(5190, 0),
  2188. /* Data[8].ctledges[1].bchannel */ FREQ2FBIN(5230, 0),
  2189. /* Data[8].ctledges[2].bchannel */ FREQ2FBIN(5270, 0),
  2190. /* Data[8].ctledges[3].bchannel */ FREQ2FBIN(5510, 0),
  2191. /* Data[8].ctledges[4].bchannel */ FREQ2FBIN(5550, 0),
  2192. /* Data[8].ctledges[5].bchannel */ FREQ2FBIN(5670, 0),
  2193. /* Data[8].ctledges[6].bchannel */ FREQ2FBIN(5755, 0),
  2194. /* Data[8].ctledges[7].bchannel */ FREQ2FBIN(5795, 0)
  2195. }
  2196. },
  2197. .ctlPowerData_5G = {
  2198. {
  2199. {
  2200. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2201. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2202. }
  2203. },
  2204. {
  2205. {
  2206. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2207. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2208. }
  2209. },
  2210. {
  2211. {
  2212. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2213. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2214. }
  2215. },
  2216. {
  2217. {
  2218. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2219. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2220. }
  2221. },
  2222. {
  2223. {
  2224. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2225. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2226. }
  2227. },
  2228. {
  2229. {
  2230. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2231. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2232. }
  2233. },
  2234. {
  2235. {
  2236. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2237. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2238. }
  2239. },
  2240. {
  2241. {
  2242. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2243. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2244. }
  2245. },
  2246. {
  2247. {
  2248. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2249. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2250. }
  2251. },
  2252. }
  2253. };
  2254. static const struct ar9300_eeprom ar9300_h116 = {
  2255. .eepromVersion = 2,
  2256. .templateVersion = 4,
  2257. .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
  2258. .custData = {"h116-041-f0000"},
  2259. .baseEepHeader = {
  2260. .regDmn = { LE16(0), LE16(0x1f) },
  2261. .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
  2262. .opCapFlags = {
  2263. .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
  2264. .eepMisc = 0,
  2265. },
  2266. .rfSilent = 0,
  2267. .blueToothOptions = 0,
  2268. .deviceCap = 0,
  2269. .deviceType = 5, /* takes lower byte in eeprom location */
  2270. .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
  2271. .params_for_tuning_caps = {0, 0},
  2272. .featureEnable = 0x0d,
  2273. /*
  2274. * bit0 - enable tx temp comp - disabled
  2275. * bit1 - enable tx volt comp - disabled
  2276. * bit2 - enable fastClock - enabled
  2277. * bit3 - enable doubling - enabled
  2278. * bit4 - enable internal regulator - disabled
  2279. * bit5 - enable pa predistortion - disabled
  2280. */
  2281. .miscConfiguration = 0, /* bit0 - turn down drivestrength */
  2282. .eepromWriteEnableGpio = 6,
  2283. .wlanDisableGpio = 0,
  2284. .wlanLedGpio = 8,
  2285. .rxBandSelectGpio = 0xff,
  2286. .txrxgain = 0x10,
  2287. .swreg = 0,
  2288. },
  2289. .modalHeader2G = {
  2290. /* ar9300_modal_eep_header 2g */
  2291. /* 4 idle,t1,t2,b(4 bits per setting) */
  2292. .antCtrlCommon = LE32(0x110),
  2293. /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
  2294. .antCtrlCommon2 = LE32(0x44444),
  2295. /*
  2296. * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
  2297. * rx1, rx12, b (2 bits each)
  2298. */
  2299. .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
  2300. /*
  2301. * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
  2302. * for ar9280 (0xa20c/b20c 5:0)
  2303. */
  2304. .xatten1DB = {0x1f, 0x1f, 0x1f},
  2305. /*
  2306. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2307. * for ar9280 (0xa20c/b20c 16:12
  2308. */
  2309. .xatten1Margin = {0x12, 0x12, 0x12},
  2310. .tempSlope = 25,
  2311. .voltSlope = 0,
  2312. /*
  2313. * spurChans[OSPREY_EEPROM_MODAL_SPURS]; spur
  2314. * channels in usual fbin coding format
  2315. */
  2316. .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
  2317. /*
  2318. * noiseFloorThreshCh[AR9300_MAX_CHAINS]; 3 Check
  2319. * if the register is per chain
  2320. */
  2321. .noiseFloorThreshCh = {-1, 0, 0},
  2322. .ob = {1, 1, 1},/* 3 chain */
  2323. .db_stage2 = {1, 1, 1}, /* 3 chain */
  2324. .db_stage3 = {0, 0, 0},
  2325. .db_stage4 = {0, 0, 0},
  2326. .xpaBiasLvl = 0,
  2327. .txFrameToDataStart = 0x0e,
  2328. .txFrameToPaOn = 0x0e,
  2329. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2330. .antennaGain = 0,
  2331. .switchSettling = 0x2c,
  2332. .adcDesiredSize = -30,
  2333. .txEndToXpaOff = 0,
  2334. .txEndToRxOn = 0x2,
  2335. .txFrameToXpaOn = 0xe,
  2336. .thresh62 = 28,
  2337. .papdRateMaskHt20 = LE32(0x0c80C080),
  2338. .papdRateMaskHt40 = LE32(0x0080C080),
  2339. .futureModal = {
  2340. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  2341. },
  2342. },
  2343. .base_ext1 = {
  2344. .ant_div_control = 0,
  2345. .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  2346. },
  2347. .calFreqPier2G = {
  2348. FREQ2FBIN(2412, 1),
  2349. FREQ2FBIN(2437, 1),
  2350. FREQ2FBIN(2472, 1),
  2351. },
  2352. /* ar9300_cal_data_per_freq_op_loop 2g */
  2353. .calPierData2G = {
  2354. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2355. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2356. { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
  2357. },
  2358. .calTarget_freqbin_Cck = {
  2359. FREQ2FBIN(2412, 1),
  2360. FREQ2FBIN(2472, 1),
  2361. },
  2362. .calTarget_freqbin_2G = {
  2363. FREQ2FBIN(2412, 1),
  2364. FREQ2FBIN(2437, 1),
  2365. FREQ2FBIN(2472, 1)
  2366. },
  2367. .calTarget_freqbin_2GHT20 = {
  2368. FREQ2FBIN(2412, 1),
  2369. FREQ2FBIN(2437, 1),
  2370. FREQ2FBIN(2472, 1)
  2371. },
  2372. .calTarget_freqbin_2GHT40 = {
  2373. FREQ2FBIN(2412, 1),
  2374. FREQ2FBIN(2437, 1),
  2375. FREQ2FBIN(2472, 1)
  2376. },
  2377. .calTargetPowerCck = {
  2378. /* 1L-5L,5S,11L,11S */
  2379. { {34, 34, 34, 34} },
  2380. { {34, 34, 34, 34} },
  2381. },
  2382. .calTargetPower2G = {
  2383. /* 6-24,36,48,54 */
  2384. { {34, 34, 32, 32} },
  2385. { {34, 34, 32, 32} },
  2386. { {34, 34, 32, 32} },
  2387. },
  2388. .calTargetPower2GHT20 = {
  2389. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2390. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2391. { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
  2392. },
  2393. .calTargetPower2GHT40 = {
  2394. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2395. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2396. { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
  2397. },
  2398. .ctlIndex_2G = {
  2399. 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
  2400. 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
  2401. },
  2402. .ctl_freqbin_2G = {
  2403. {
  2404. FREQ2FBIN(2412, 1),
  2405. FREQ2FBIN(2417, 1),
  2406. FREQ2FBIN(2457, 1),
  2407. FREQ2FBIN(2462, 1)
  2408. },
  2409. {
  2410. FREQ2FBIN(2412, 1),
  2411. FREQ2FBIN(2417, 1),
  2412. FREQ2FBIN(2462, 1),
  2413. 0xFF,
  2414. },
  2415. {
  2416. FREQ2FBIN(2412, 1),
  2417. FREQ2FBIN(2417, 1),
  2418. FREQ2FBIN(2462, 1),
  2419. 0xFF,
  2420. },
  2421. {
  2422. FREQ2FBIN(2422, 1),
  2423. FREQ2FBIN(2427, 1),
  2424. FREQ2FBIN(2447, 1),
  2425. FREQ2FBIN(2452, 1)
  2426. },
  2427. {
  2428. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2429. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2430. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2431. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(2484, 1),
  2432. },
  2433. {
  2434. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2435. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2436. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2437. 0,
  2438. },
  2439. {
  2440. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2441. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2442. FREQ2FBIN(2472, 1),
  2443. 0,
  2444. },
  2445. {
  2446. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2447. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2448. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2449. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2450. },
  2451. {
  2452. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2453. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2454. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2455. },
  2456. {
  2457. /* Data[9].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2458. /* Data[9].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2459. /* Data[9].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2460. 0
  2461. },
  2462. {
  2463. /* Data[10].ctlEdges[0].bChannel */ FREQ2FBIN(2412, 1),
  2464. /* Data[10].ctlEdges[1].bChannel */ FREQ2FBIN(2417, 1),
  2465. /* Data[10].ctlEdges[2].bChannel */ FREQ2FBIN(2472, 1),
  2466. 0
  2467. },
  2468. {
  2469. /* Data[11].ctlEdges[0].bChannel */ FREQ2FBIN(2422, 1),
  2470. /* Data[11].ctlEdges[1].bChannel */ FREQ2FBIN(2427, 1),
  2471. /* Data[11].ctlEdges[2].bChannel */ FREQ2FBIN(2447, 1),
  2472. /* Data[11].ctlEdges[3].bChannel */ FREQ2FBIN(2462, 1),
  2473. }
  2474. },
  2475. .ctlPowerData_2G = {
  2476. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2477. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2478. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
  2479. { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
  2480. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2481. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2482. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
  2483. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2484. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2485. { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
  2486. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2487. { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
  2488. },
  2489. .modalHeader5G = {
  2490. /* 4 idle,t1,t2,b (4 bits per setting) */
  2491. .antCtrlCommon = LE32(0x220),
  2492. /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
  2493. .antCtrlCommon2 = LE32(0x44444),
  2494. /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
  2495. .antCtrlChain = {
  2496. LE16(0x150), LE16(0x150), LE16(0x150),
  2497. },
  2498. /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
  2499. .xatten1DB = {0x19, 0x19, 0x19},
  2500. /*
  2501. * xatten1Margin[AR9300_MAX_CHAINS]; 3 xatten1_margin
  2502. * for merlin (0xa20c/b20c 16:12
  2503. */
  2504. .xatten1Margin = {0x14, 0x14, 0x14},
  2505. .tempSlope = 70,
  2506. .voltSlope = 0,
  2507. /* spurChans spur channels in usual fbin coding format */
  2508. .spurChans = {0, 0, 0, 0, 0},
  2509. /* noiseFloorThreshCh Check if the register is per chain */
  2510. .noiseFloorThreshCh = {-1, 0, 0},
  2511. .ob = {3, 3, 3}, /* 3 chain */
  2512. .db_stage2 = {3, 3, 3}, /* 3 chain */
  2513. .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */
  2514. .db_stage4 = {3, 3, 3}, /* don't exist for 2G */
  2515. .xpaBiasLvl = 0,
  2516. .txFrameToDataStart = 0x0e,
  2517. .txFrameToPaOn = 0x0e,
  2518. .txClip = 3, /* 4 bits tx_clip, 4 bits dac_scale_cck */
  2519. .antennaGain = 0,
  2520. .switchSettling = 0x2d,
  2521. .adcDesiredSize = -30,
  2522. .txEndToXpaOff = 0,
  2523. .txEndToRxOn = 0x2,
  2524. .txFrameToXpaOn = 0xe,
  2525. .thresh62 = 28,
  2526. .papdRateMaskHt20 = LE32(0x0cf0e0e0),
  2527. .papdRateMaskHt40 = LE32(0x6cf0e0e0),
  2528. .futureModal = {
  2529. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  2530. },
  2531. },
  2532. .base_ext2 = {
  2533. .tempSlopeLow = 35,
  2534. .tempSlopeHigh = 50,
  2535. .xatten1DBLow = {0, 0, 0},
  2536. .xatten1MarginLow = {0, 0, 0},
  2537. .xatten1DBHigh = {0, 0, 0},
  2538. .xatten1MarginHigh = {0, 0, 0}
  2539. },
  2540. .calFreqPier5G = {
  2541. FREQ2FBIN(5180, 0),
  2542. FREQ2FBIN(5220, 0),
  2543. FREQ2FBIN(5320, 0),
  2544. FREQ2FBIN(5400, 0),
  2545. FREQ2FBIN(5500, 0),
  2546. FREQ2FBIN(5600, 0),
  2547. FREQ2FBIN(5700, 0),
  2548. FREQ2FBIN(5785, 0)
  2549. },
  2550. .calPierData5G = {
  2551. {
  2552. {0, 0, 0, 0, 0},
  2553. {0, 0, 0, 0, 0},
  2554. {0, 0, 0, 0, 0},
  2555. {0, 0, 0, 0, 0},
  2556. {0, 0, 0, 0, 0},
  2557. {0, 0, 0, 0, 0},
  2558. {0, 0, 0, 0, 0},
  2559. {0, 0, 0, 0, 0},
  2560. },
  2561. {
  2562. {0, 0, 0, 0, 0},
  2563. {0, 0, 0, 0, 0},
  2564. {0, 0, 0, 0, 0},
  2565. {0, 0, 0, 0, 0},
  2566. {0, 0, 0, 0, 0},
  2567. {0, 0, 0, 0, 0},
  2568. {0, 0, 0, 0, 0},
  2569. {0, 0, 0, 0, 0},
  2570. },
  2571. {
  2572. {0, 0, 0, 0, 0},
  2573. {0, 0, 0, 0, 0},
  2574. {0, 0, 0, 0, 0},
  2575. {0, 0, 0, 0, 0},
  2576. {0, 0, 0, 0, 0},
  2577. {0, 0, 0, 0, 0},
  2578. {0, 0, 0, 0, 0},
  2579. {0, 0, 0, 0, 0},
  2580. },
  2581. },
  2582. .calTarget_freqbin_5G = {
  2583. FREQ2FBIN(5180, 0),
  2584. FREQ2FBIN(5240, 0),
  2585. FREQ2FBIN(5320, 0),
  2586. FREQ2FBIN(5400, 0),
  2587. FREQ2FBIN(5500, 0),
  2588. FREQ2FBIN(5600, 0),
  2589. FREQ2FBIN(5700, 0),
  2590. FREQ2FBIN(5825, 0)
  2591. },
  2592. .calTarget_freqbin_5GHT20 = {
  2593. FREQ2FBIN(5180, 0),
  2594. FREQ2FBIN(5240, 0),
  2595. FREQ2FBIN(5320, 0),
  2596. FREQ2FBIN(5400, 0),
  2597. FREQ2FBIN(5500, 0),
  2598. FREQ2FBIN(5700, 0),
  2599. FREQ2FBIN(5745, 0),
  2600. FREQ2FBIN(5825, 0)
  2601. },
  2602. .calTarget_freqbin_5GHT40 = {
  2603. FREQ2FBIN(5180, 0),
  2604. FREQ2FBIN(5240, 0),
  2605. FREQ2FBIN(5320, 0),
  2606. FREQ2FBIN(5400, 0),
  2607. FREQ2FBIN(5500, 0),
  2608. FREQ2FBIN(5700, 0),
  2609. FREQ2FBIN(5745, 0),
  2610. FREQ2FBIN(5825, 0)
  2611. },
  2612. .calTargetPower5G = {
  2613. /* 6-24,36,48,54 */
  2614. { {30, 30, 28, 24} },
  2615. { {30, 30, 28, 24} },
  2616. { {30, 30, 28, 24} },
  2617. { {30, 30, 28, 24} },
  2618. { {30, 30, 28, 24} },
  2619. { {30, 30, 28, 24} },
  2620. { {30, 30, 28, 24} },
  2621. { {30, 30, 28, 24} },
  2622. },
  2623. .calTargetPower5GHT20 = {
  2624. /*
  2625. * 0_8_16,1-3_9-11_17-19,
  2626. * 4,5,6,7,12,13,14,15,20,21,22,23
  2627. */
  2628. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2629. { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
  2630. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2631. { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
  2632. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2633. { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
  2634. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2635. { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
  2636. },
  2637. .calTargetPower5GHT40 = {
  2638. /*
  2639. * 0_8_16,1-3_9-11_17-19,
  2640. * 4,5,6,7,12,13,14,15,20,21,22,23
  2641. */
  2642. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2643. { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
  2644. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2645. { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
  2646. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2647. { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
  2648. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2649. { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
  2650. },
  2651. .ctlIndex_5G = {
  2652. 0x10, 0x16, 0x18, 0x40, 0x46,
  2653. 0x48, 0x30, 0x36, 0x38
  2654. },
  2655. .ctl_freqbin_5G = {
  2656. {
  2657. /* Data[0].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2658. /* Data[0].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2659. /* Data[0].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2660. /* Data[0].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2661. /* Data[0].ctlEdges[4].bChannel */ FREQ2FBIN(5600, 0),
  2662. /* Data[0].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2663. /* Data[0].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2664. /* Data[0].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2665. },
  2666. {
  2667. /* Data[1].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2668. /* Data[1].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2669. /* Data[1].ctlEdges[2].bChannel */ FREQ2FBIN(5280, 0),
  2670. /* Data[1].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2671. /* Data[1].ctlEdges[4].bChannel */ FREQ2FBIN(5520, 0),
  2672. /* Data[1].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2673. /* Data[1].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2674. /* Data[1].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2675. },
  2676. {
  2677. /* Data[2].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2678. /* Data[2].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2679. /* Data[2].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2680. /* Data[2].ctlEdges[3].bChannel */ FREQ2FBIN(5310, 0),
  2681. /* Data[2].ctlEdges[4].bChannel */ FREQ2FBIN(5510, 0),
  2682. /* Data[2].ctlEdges[5].bChannel */ FREQ2FBIN(5550, 0),
  2683. /* Data[2].ctlEdges[6].bChannel */ FREQ2FBIN(5670, 0),
  2684. /* Data[2].ctlEdges[7].bChannel */ FREQ2FBIN(5755, 0)
  2685. },
  2686. {
  2687. /* Data[3].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2688. /* Data[3].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2689. /* Data[3].ctlEdges[2].bChannel */ FREQ2FBIN(5260, 0),
  2690. /* Data[3].ctlEdges[3].bChannel */ FREQ2FBIN(5320, 0),
  2691. /* Data[3].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2692. /* Data[3].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2693. /* Data[3].ctlEdges[6].bChannel */ 0xFF,
  2694. /* Data[3].ctlEdges[7].bChannel */ 0xFF,
  2695. },
  2696. {
  2697. /* Data[4].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2698. /* Data[4].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2699. /* Data[4].ctlEdges[2].bChannel */ FREQ2FBIN(5500, 0),
  2700. /* Data[4].ctlEdges[3].bChannel */ FREQ2FBIN(5700, 0),
  2701. /* Data[4].ctlEdges[4].bChannel */ 0xFF,
  2702. /* Data[4].ctlEdges[5].bChannel */ 0xFF,
  2703. /* Data[4].ctlEdges[6].bChannel */ 0xFF,
  2704. /* Data[4].ctlEdges[7].bChannel */ 0xFF,
  2705. },
  2706. {
  2707. /* Data[5].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2708. /* Data[5].ctlEdges[1].bChannel */ FREQ2FBIN(5270, 0),
  2709. /* Data[5].ctlEdges[2].bChannel */ FREQ2FBIN(5310, 0),
  2710. /* Data[5].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2711. /* Data[5].ctlEdges[4].bChannel */ FREQ2FBIN(5590, 0),
  2712. /* Data[5].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2713. /* Data[5].ctlEdges[6].bChannel */ 0xFF,
  2714. /* Data[5].ctlEdges[7].bChannel */ 0xFF
  2715. },
  2716. {
  2717. /* Data[6].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2718. /* Data[6].ctlEdges[1].bChannel */ FREQ2FBIN(5200, 0),
  2719. /* Data[6].ctlEdges[2].bChannel */ FREQ2FBIN(5220, 0),
  2720. /* Data[6].ctlEdges[3].bChannel */ FREQ2FBIN(5260, 0),
  2721. /* Data[6].ctlEdges[4].bChannel */ FREQ2FBIN(5500, 0),
  2722. /* Data[6].ctlEdges[5].bChannel */ FREQ2FBIN(5600, 0),
  2723. /* Data[6].ctlEdges[6].bChannel */ FREQ2FBIN(5700, 0),
  2724. /* Data[6].ctlEdges[7].bChannel */ FREQ2FBIN(5745, 0)
  2725. },
  2726. {
  2727. /* Data[7].ctlEdges[0].bChannel */ FREQ2FBIN(5180, 0),
  2728. /* Data[7].ctlEdges[1].bChannel */ FREQ2FBIN(5260, 0),
  2729. /* Data[7].ctlEdges[2].bChannel */ FREQ2FBIN(5320, 0),
  2730. /* Data[7].ctlEdges[3].bChannel */ FREQ2FBIN(5500, 0),
  2731. /* Data[7].ctlEdges[4].bChannel */ FREQ2FBIN(5560, 0),
  2732. /* Data[7].ctlEdges[5].bChannel */ FREQ2FBIN(5700, 0),
  2733. /* Data[7].ctlEdges[6].bChannel */ FREQ2FBIN(5745, 0),
  2734. /* Data[7].ctlEdges[7].bChannel */ FREQ2FBIN(5825, 0)
  2735. },
  2736. {
  2737. /* Data[8].ctlEdges[0].bChannel */ FREQ2FBIN(5190, 0),
  2738. /* Data[8].ctlEdges[1].bChannel */ FREQ2FBIN(5230, 0),
  2739. /* Data[8].ctlEdges[2].bChannel */ FREQ2FBIN(5270, 0),
  2740. /* Data[8].ctlEdges[3].bChannel */ FREQ2FBIN(5510, 0),
  2741. /* Data[8].ctlEdges[4].bChannel */ FREQ2FBIN(5550, 0),
  2742. /* Data[8].ctlEdges[5].bChannel */ FREQ2FBIN(5670, 0),
  2743. /* Data[8].ctlEdges[6].bChannel */ FREQ2FBIN(5755, 0),
  2744. /* Data[8].ctlEdges[7].bChannel */ FREQ2FBIN(5795, 0)
  2745. }
  2746. },
  2747. .ctlPowerData_5G = {
  2748. {
  2749. {
  2750. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2751. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2752. }
  2753. },
  2754. {
  2755. {
  2756. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2757. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2758. }
  2759. },
  2760. {
  2761. {
  2762. CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2763. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2764. }
  2765. },
  2766. {
  2767. {
  2768. CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2769. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2770. }
  2771. },
  2772. {
  2773. {
  2774. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2775. CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2776. }
  2777. },
  2778. {
  2779. {
  2780. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2781. CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
  2782. }
  2783. },
  2784. {
  2785. {
  2786. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2787. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
  2788. }
  2789. },
  2790. {
  2791. {
  2792. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2793. CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
  2794. }
  2795. },
  2796. {
  2797. {
  2798. CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
  2799. CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
  2800. }
  2801. },
  2802. }
  2803. };
  2804. static const struct ar9300_eeprom *ar9300_eep_templates[] = {
  2805. &ar9300_default,
  2806. &ar9300_x112,
  2807. &ar9300_h116,
  2808. &ar9300_h112,
  2809. &ar9300_x113,
  2810. };
  2811. static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
  2812. {
  2813. #define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0]))
  2814. int it;
  2815. for (it = 0; it < N_LOOP; it++)
  2816. if (ar9300_eep_templates[it]->templateVersion == id)
  2817. return ar9300_eep_templates[it];
  2818. return NULL;
  2819. #undef N_LOOP
  2820. }
  2821. static u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
  2822. {
  2823. if (fbin == AR5416_BCHAN_UNUSED)
  2824. return fbin;
  2825. return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
  2826. }
  2827. static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
  2828. {
  2829. return 0;
  2830. }
  2831. static int interpolate(int x, int xa, int xb, int ya, int yb)
  2832. {
  2833. int bf, factor, plus;
  2834. bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
  2835. factor = bf / 2;
  2836. plus = bf % 2;
  2837. return ya + factor + plus;
  2838. }
  2839. static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
  2840. enum eeprom_param param)
  2841. {
  2842. struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
  2843. struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
  2844. switch (param) {
  2845. case EEP_MAC_LSW:
  2846. return eep->macAddr[0] << 8 | eep->macAddr[1];
  2847. case EEP_MAC_MID:
  2848. return eep->macAddr[2] << 8 | eep->macAddr[3];
  2849. case EEP_MAC_MSW:
  2850. return eep->macAddr[4] << 8 | eep->macAddr[5];
  2851. case EEP_REG_0:
  2852. return le16_to_cpu(pBase->regDmn[0]);
  2853. case EEP_REG_1:
  2854. return le16_to_cpu(pBase->regDmn[1]);
  2855. case EEP_OP_CAP:
  2856. return pBase->deviceCap;
  2857. case EEP_OP_MODE:
  2858. return pBase->opCapFlags.opFlags;
  2859. case EEP_RF_SILENT:
  2860. return pBase->rfSilent;
  2861. case EEP_TX_MASK:
  2862. return (pBase->txrxMask >> 4) & 0xf;
  2863. case EEP_RX_MASK:
  2864. return pBase->txrxMask & 0xf;
  2865. case EEP_DRIVE_STRENGTH:
  2866. #define AR9300_EEP_BASE_DRIV_STRENGTH 0x1
  2867. return pBase->miscConfiguration & AR9300_EEP_BASE_DRIV_STRENGTH;
  2868. case EEP_INTERNAL_REGULATOR:
  2869. /* Bit 4 is internal regulator flag */
  2870. return (pBase->featureEnable & 0x10) >> 4;
  2871. case EEP_SWREG:
  2872. return le32_to_cpu(pBase->swreg);
  2873. case EEP_PAPRD:
  2874. return !!(pBase->featureEnable & BIT(5));
  2875. case EEP_CHAIN_MASK_REDUCE:
  2876. return (pBase->miscConfiguration >> 0x3) & 0x1;
  2877. case EEP_ANT_DIV_CTL1:
  2878. return le32_to_cpu(eep->base_ext1.ant_div_control);
  2879. default:
  2880. return 0;
  2881. }
  2882. }
  2883. static bool ar9300_eeprom_read_byte(struct ath_common *common, int address,
  2884. u8 *buffer)
  2885. {
  2886. u16 val;
  2887. if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
  2888. return false;
  2889. *buffer = (val >> (8 * (address % 2))) & 0xff;
  2890. return true;
  2891. }
  2892. static bool ar9300_eeprom_read_word(struct ath_common *common, int address,
  2893. u8 *buffer)
  2894. {
  2895. u16 val;
  2896. if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
  2897. return false;
  2898. buffer[0] = val >> 8;
  2899. buffer[1] = val & 0xff;
  2900. return true;
  2901. }
  2902. static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
  2903. int count)
  2904. {
  2905. struct ath_common *common = ath9k_hw_common(ah);
  2906. int i;
  2907. if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
  2908. ath_dbg(common, ATH_DBG_EEPROM,
  2909. "eeprom address not in range\n");
  2910. return false;
  2911. }
  2912. /*
  2913. * Since we're reading the bytes in reverse order from a little-endian
  2914. * word stream, an even address means we only use the lower half of
  2915. * the 16-bit word at that address
  2916. */
  2917. if (address % 2 == 0) {
  2918. if (!ar9300_eeprom_read_byte(common, address--, buffer++))
  2919. goto error;
  2920. count--;
  2921. }
  2922. for (i = 0; i < count / 2; i++) {
  2923. if (!ar9300_eeprom_read_word(common, address, buffer))
  2924. goto error;
  2925. address -= 2;
  2926. buffer += 2;
  2927. }
  2928. if (count % 2)
  2929. if (!ar9300_eeprom_read_byte(common, address, buffer))
  2930. goto error;
  2931. return true;
  2932. error:
  2933. ath_dbg(common, ATH_DBG_EEPROM,
  2934. "unable to read eeprom region at offset %d\n", address);
  2935. return false;
  2936. }
  2937. static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data)
  2938. {
  2939. REG_READ(ah, AR9300_OTP_BASE + (4 * addr));
  2940. if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE,
  2941. AR9300_OTP_STATUS_VALID, 1000))
  2942. return false;
  2943. *data = REG_READ(ah, AR9300_OTP_READ_DATA);
  2944. return true;
  2945. }
  2946. static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer,
  2947. int count)
  2948. {
  2949. u32 data;
  2950. int i;
  2951. for (i = 0; i < count; i++) {
  2952. int offset = 8 * ((address - i) % 4);
  2953. if (!ar9300_otp_read_word(ah, (address - i) / 4, &data))
  2954. return false;
  2955. buffer[i] = (data >> offset) & 0xff;
  2956. }
  2957. return true;
  2958. }
  2959. static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
  2960. int *length, int *major, int *minor)
  2961. {
  2962. unsigned long value[4];
  2963. value[0] = best[0];
  2964. value[1] = best[1];
  2965. value[2] = best[2];
  2966. value[3] = best[3];
  2967. *code = ((value[0] >> 5) & 0x0007);
  2968. *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
  2969. *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
  2970. *major = (value[2] & 0x000f);
  2971. *minor = (value[3] & 0x00ff);
  2972. }
  2973. static u16 ar9300_comp_cksum(u8 *data, int dsize)
  2974. {
  2975. int it, checksum = 0;
  2976. for (it = 0; it < dsize; it++) {
  2977. checksum += data[it];
  2978. checksum &= 0xffff;
  2979. }
  2980. return checksum;
  2981. }
  2982. static bool ar9300_uncompress_block(struct ath_hw *ah,
  2983. u8 *mptr,
  2984. int mdataSize,
  2985. u8 *block,
  2986. int size)
  2987. {
  2988. int it;
  2989. int spot;
  2990. int offset;
  2991. int length;
  2992. struct ath_common *common = ath9k_hw_common(ah);
  2993. spot = 0;
  2994. for (it = 0; it < size; it += (length+2)) {
  2995. offset = block[it];
  2996. offset &= 0xff;
  2997. spot += offset;
  2998. length = block[it+1];
  2999. length &= 0xff;
  3000. if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
  3001. ath_dbg(common, ATH_DBG_EEPROM,
  3002. "Restore at %d: spot=%d offset=%d length=%d\n",
  3003. it, spot, offset, length);
  3004. memcpy(&mptr[spot], &block[it+2], length);
  3005. spot += length;
  3006. } else if (length > 0) {
  3007. ath_dbg(common, ATH_DBG_EEPROM,
  3008. "Bad restore at %d: spot=%d offset=%d length=%d\n",
  3009. it, spot, offset, length);
  3010. return false;
  3011. }
  3012. }
  3013. return true;
  3014. }
  3015. static int ar9300_compress_decision(struct ath_hw *ah,
  3016. int it,
  3017. int code,
  3018. int reference,
  3019. u8 *mptr,
  3020. u8 *word, int length, int mdata_size)
  3021. {
  3022. struct ath_common *common = ath9k_hw_common(ah);
  3023. const struct ar9300_eeprom *eep = NULL;
  3024. switch (code) {
  3025. case _CompressNone:
  3026. if (length != mdata_size) {
  3027. ath_dbg(common, ATH_DBG_EEPROM,
  3028. "EEPROM structure size mismatch memory=%d eeprom=%d\n",
  3029. mdata_size, length);
  3030. return -1;
  3031. }
  3032. memcpy(mptr, (u8 *) (word + COMP_HDR_LEN), length);
  3033. ath_dbg(common, ATH_DBG_EEPROM,
  3034. "restored eeprom %d: uncompressed, length %d\n",
  3035. it, length);
  3036. break;
  3037. case _CompressBlock:
  3038. if (reference == 0) {
  3039. } else {
  3040. eep = ar9003_eeprom_struct_find_by_id(reference);
  3041. if (eep == NULL) {
  3042. ath_dbg(common, ATH_DBG_EEPROM,
  3043. "can't find reference eeprom struct %d\n",
  3044. reference);
  3045. return -1;
  3046. }
  3047. memcpy(mptr, eep, mdata_size);
  3048. }
  3049. ath_dbg(common, ATH_DBG_EEPROM,
  3050. "restore eeprom %d: block, reference %d, length %d\n",
  3051. it, reference, length);
  3052. ar9300_uncompress_block(ah, mptr, mdata_size,
  3053. (u8 *) (word + COMP_HDR_LEN), length);
  3054. break;
  3055. default:
  3056. ath_dbg(common, ATH_DBG_EEPROM,
  3057. "unknown compression code %d\n", code);
  3058. return -1;
  3059. }
  3060. return 0;
  3061. }
  3062. typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer,
  3063. int count);
  3064. static bool ar9300_check_header(void *data)
  3065. {
  3066. u32 *word = data;
  3067. return !(*word == 0 || *word == ~0);
  3068. }
  3069. static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
  3070. int base_addr)
  3071. {
  3072. u8 header[4];
  3073. if (!read(ah, base_addr, header, 4))
  3074. return false;
  3075. return ar9300_check_header(header);
  3076. }
  3077. static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
  3078. int mdata_size)
  3079. {
  3080. struct ath_common *common = ath9k_hw_common(ah);
  3081. u16 *data = (u16 *) mptr;
  3082. int i;
  3083. for (i = 0; i < mdata_size / 2; i++, data++)
  3084. ath9k_hw_nvram_read(common, i, data);
  3085. return 0;
  3086. }
  3087. /*
  3088. * Read the configuration data from the eeprom.
  3089. * The data can be put in any specified memory buffer.
  3090. *
  3091. * Returns -1 on error.
  3092. * Returns address of next memory location on success.
  3093. */
  3094. static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
  3095. u8 *mptr, int mdata_size)
  3096. {
  3097. #define MDEFAULT 15
  3098. #define MSTATE 100
  3099. int cptr;
  3100. u8 *word;
  3101. int code;
  3102. int reference, length, major, minor;
  3103. int osize;
  3104. int it;
  3105. u16 checksum, mchecksum;
  3106. struct ath_common *common = ath9k_hw_common(ah);
  3107. eeprom_read_op read;
  3108. if (ath9k_hw_use_flash(ah))
  3109. return ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
  3110. word = kzalloc(2048, GFP_KERNEL);
  3111. if (!word)
  3112. return -1;
  3113. memcpy(mptr, &ar9300_default, mdata_size);
  3114. read = ar9300_read_eeprom;
  3115. if (AR_SREV_9485(ah))
  3116. cptr = AR9300_BASE_ADDR_4K;
  3117. else if (AR_SREV_9330(ah))
  3118. cptr = AR9300_BASE_ADDR_512;
  3119. else
  3120. cptr = AR9300_BASE_ADDR;
  3121. ath_dbg(common, ATH_DBG_EEPROM,
  3122. "Trying EEPROM access at Address 0x%04x\n", cptr);
  3123. if (ar9300_check_eeprom_header(ah, read, cptr))
  3124. goto found;
  3125. cptr = AR9300_BASE_ADDR_512;
  3126. ath_dbg(common, ATH_DBG_EEPROM,
  3127. "Trying EEPROM access at Address 0x%04x\n", cptr);
  3128. if (ar9300_check_eeprom_header(ah, read, cptr))
  3129. goto found;
  3130. read = ar9300_read_otp;
  3131. cptr = AR9300_BASE_ADDR;
  3132. ath_dbg(common, ATH_DBG_EEPROM,
  3133. "Trying OTP access at Address 0x%04x\n", cptr);
  3134. if (ar9300_check_eeprom_header(ah, read, cptr))
  3135. goto found;
  3136. cptr = AR9300_BASE_ADDR_512;
  3137. ath_dbg(common, ATH_DBG_EEPROM,
  3138. "Trying OTP access at Address 0x%04x\n", cptr);
  3139. if (ar9300_check_eeprom_header(ah, read, cptr))
  3140. goto found;
  3141. goto fail;
  3142. found:
  3143. ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data\n");
  3144. for (it = 0; it < MSTATE; it++) {
  3145. if (!read(ah, cptr, word, COMP_HDR_LEN))
  3146. goto fail;
  3147. if (!ar9300_check_header(word))
  3148. break;
  3149. ar9300_comp_hdr_unpack(word, &code, &reference,
  3150. &length, &major, &minor);
  3151. ath_dbg(common, ATH_DBG_EEPROM,
  3152. "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
  3153. cptr, code, reference, length, major, minor);
  3154. if ((!AR_SREV_9485(ah) && length >= 1024) ||
  3155. (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
  3156. ath_dbg(common, ATH_DBG_EEPROM,
  3157. "Skipping bad header\n");
  3158. cptr -= COMP_HDR_LEN;
  3159. continue;
  3160. }
  3161. osize = length;
  3162. read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
  3163. checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
  3164. mchecksum = word[COMP_HDR_LEN + osize] |
  3165. (word[COMP_HDR_LEN + osize + 1] << 8);
  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. };