ar9003_eeprom.c 140 KB

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