ar9003_eeprom.c 146 KB

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