ar9003_eeprom.c 153 KB

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