ar9003_eeprom.c 147 KB

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