ar9003_eeprom.c 146 KB

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