ar9003_eeprom.c 132 KB

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