ar9003_eeprom.c 156 KB

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