ar9003_eeprom.c 146 KB

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