ar9003_eeprom.c 153 KB

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