ar9003_eeprom.c 157 KB

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