rtw8852b.c 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626
  1. // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2. /* Copyright(c) 2019-2022 Realtek Corporation
  3. */
  4. #include "coex.h"
  5. #include "fw.h"
  6. #include "mac.h"
  7. #include "phy.h"
  8. #include "reg.h"
  9. #include "rtw8852b.h"
  10. #include "rtw8852b_rfk.h"
  11. #include "rtw8852b_table.h"
  12. #include "txrx.h"
  13. #define RTW8852B_FW_FORMAT_MAX 1
  14. #define RTW8852B_FW_BASENAME "rtw89/rtw8852b_fw"
  15. #define RTW8852B_MODULE_FIRMWARE \
  16. RTW8852B_FW_BASENAME "-" __stringify(RTW8852B_FW_FORMAT_MAX) ".bin"
  17. static const struct rtw89_hfc_ch_cfg rtw8852b_hfc_chcfg_pcie[] = {
  18. {5, 341, grp_0}, /* ACH 0 */
  19. {5, 341, grp_0}, /* ACH 1 */
  20. {4, 342, grp_0}, /* ACH 2 */
  21. {4, 342, grp_0}, /* ACH 3 */
  22. {0, 0, grp_0}, /* ACH 4 */
  23. {0, 0, grp_0}, /* ACH 5 */
  24. {0, 0, grp_0}, /* ACH 6 */
  25. {0, 0, grp_0}, /* ACH 7 */
  26. {4, 342, grp_0}, /* B0MGQ */
  27. {4, 342, grp_0}, /* B0HIQ */
  28. {0, 0, grp_0}, /* B1MGQ */
  29. {0, 0, grp_0}, /* B1HIQ */
  30. {40, 0, 0} /* FWCMDQ */
  31. };
  32. static const struct rtw89_hfc_pub_cfg rtw8852b_hfc_pubcfg_pcie = {
  33. 446, /* Group 0 */
  34. 0, /* Group 1 */
  35. 446, /* Public Max */
  36. 0 /* WP threshold */
  37. };
  38. static const struct rtw89_hfc_param_ini rtw8852b_hfc_param_ini_pcie[] = {
  39. [RTW89_QTA_SCC] = {rtw8852b_hfc_chcfg_pcie, &rtw8852b_hfc_pubcfg_pcie,
  40. &rtw89_mac_size.hfc_preccfg_pcie, RTW89_HCIFC_POH},
  41. [RTW89_QTA_DLFW] = {NULL, NULL, &rtw89_mac_size.hfc_preccfg_pcie,
  42. RTW89_HCIFC_POH},
  43. [RTW89_QTA_INVALID] = {NULL},
  44. };
  45. static const struct rtw89_dle_mem rtw8852b_dle_mem_pcie[] = {
  46. [RTW89_QTA_SCC] = {RTW89_QTA_SCC, &rtw89_mac_size.wde_size7,
  47. &rtw89_mac_size.ple_size6, &rtw89_mac_size.wde_qt7,
  48. &rtw89_mac_size.wde_qt7, &rtw89_mac_size.ple_qt18,
  49. &rtw89_mac_size.ple_qt58},
  50. [RTW89_QTA_WOW] = {RTW89_QTA_WOW, &rtw89_mac_size.wde_size7,
  51. &rtw89_mac_size.ple_size6, &rtw89_mac_size.wde_qt7,
  52. &rtw89_mac_size.wde_qt7, &rtw89_mac_size.ple_qt18,
  53. &rtw89_mac_size.ple_qt_52b_wow},
  54. [RTW89_QTA_DLFW] = {RTW89_QTA_DLFW, &rtw89_mac_size.wde_size9,
  55. &rtw89_mac_size.ple_size8, &rtw89_mac_size.wde_qt4,
  56. &rtw89_mac_size.wde_qt4, &rtw89_mac_size.ple_qt13,
  57. &rtw89_mac_size.ple_qt13},
  58. [RTW89_QTA_INVALID] = {RTW89_QTA_INVALID, NULL, NULL, NULL, NULL, NULL,
  59. NULL},
  60. };
  61. static const struct rtw89_reg3_def rtw8852b_pmac_ht20_mcs7_tbl[] = {
  62. {0x4580, 0x0000ffff, 0x0},
  63. {0x4580, 0xffff0000, 0x0},
  64. {0x4584, 0x0000ffff, 0x0},
  65. {0x4584, 0xffff0000, 0x0},
  66. {0x4580, 0x0000ffff, 0x1},
  67. {0x4578, 0x00ffffff, 0x2018b},
  68. {0x4570, 0x03ffffff, 0x7},
  69. {0x4574, 0x03ffffff, 0x32407},
  70. {0x45b8, 0x00000010, 0x0},
  71. {0x45b8, 0x00000100, 0x0},
  72. {0x45b8, 0x00000080, 0x0},
  73. {0x45b8, 0x00000008, 0x0},
  74. {0x45a0, 0x0000ff00, 0x0},
  75. {0x45a0, 0xff000000, 0x1},
  76. {0x45a4, 0x0000ff00, 0x2},
  77. {0x45a4, 0xff000000, 0x3},
  78. {0x45b8, 0x00000020, 0x0},
  79. {0x4568, 0xe0000000, 0x0},
  80. {0x45b8, 0x00000002, 0x1},
  81. {0x456c, 0xe0000000, 0x0},
  82. {0x45b4, 0x00006000, 0x0},
  83. {0x45b4, 0x00001800, 0x1},
  84. {0x45b8, 0x00000040, 0x0},
  85. {0x45b8, 0x00000004, 0x0},
  86. {0x45b8, 0x00000200, 0x0},
  87. {0x4598, 0xf8000000, 0x0},
  88. {0x45b8, 0x00100000, 0x0},
  89. {0x45a8, 0x00000fc0, 0x0},
  90. {0x45b8, 0x00200000, 0x0},
  91. {0x45b0, 0x00000038, 0x0},
  92. {0x45b0, 0x000001c0, 0x0},
  93. {0x45a0, 0x000000ff, 0x0},
  94. {0x45b8, 0x00400000, 0x0},
  95. {0x4590, 0x000007ff, 0x0},
  96. {0x45b0, 0x00000e00, 0x0},
  97. {0x45ac, 0x0000001f, 0x0},
  98. {0x45b8, 0x00800000, 0x0},
  99. {0x45a8, 0x0003f000, 0x0},
  100. {0x45b8, 0x01000000, 0x0},
  101. {0x45b0, 0x00007000, 0x0},
  102. {0x45b0, 0x00038000, 0x0},
  103. {0x45a0, 0x00ff0000, 0x0},
  104. {0x45b8, 0x02000000, 0x0},
  105. {0x4590, 0x003ff800, 0x0},
  106. {0x45b0, 0x001c0000, 0x0},
  107. {0x45ac, 0x000003e0, 0x0},
  108. {0x45b8, 0x04000000, 0x0},
  109. {0x45a8, 0x00fc0000, 0x0},
  110. {0x45b8, 0x08000000, 0x0},
  111. {0x45b0, 0x00e00000, 0x0},
  112. {0x45b0, 0x07000000, 0x0},
  113. {0x45a4, 0x000000ff, 0x0},
  114. {0x45b8, 0x10000000, 0x0},
  115. {0x4594, 0x000007ff, 0x0},
  116. {0x45b0, 0x38000000, 0x0},
  117. {0x45ac, 0x00007c00, 0x0},
  118. {0x45b8, 0x20000000, 0x0},
  119. {0x45a8, 0x3f000000, 0x0},
  120. {0x45b8, 0x40000000, 0x0},
  121. {0x45b4, 0x00000007, 0x0},
  122. {0x45b4, 0x00000038, 0x0},
  123. {0x45a4, 0x00ff0000, 0x0},
  124. {0x45b8, 0x80000000, 0x0},
  125. {0x4594, 0x003ff800, 0x0},
  126. {0x45b4, 0x000001c0, 0x0},
  127. {0x4598, 0xf8000000, 0x0},
  128. {0x45b8, 0x00100000, 0x0},
  129. {0x45a8, 0x00000fc0, 0x7},
  130. {0x45b8, 0x00200000, 0x0},
  131. {0x45b0, 0x00000038, 0x0},
  132. {0x45b0, 0x000001c0, 0x0},
  133. {0x45a0, 0x000000ff, 0x0},
  134. {0x45b4, 0x06000000, 0x0},
  135. {0x45b0, 0x00000007, 0x0},
  136. {0x45b8, 0x00080000, 0x0},
  137. {0x45a8, 0x0000003f, 0x0},
  138. {0x457c, 0xffe00000, 0x1},
  139. {0x4530, 0xffffffff, 0x0},
  140. {0x4588, 0x00003fff, 0x0},
  141. {0x4598, 0x000001ff, 0x0},
  142. {0x4534, 0xffffffff, 0x0},
  143. {0x4538, 0xffffffff, 0x0},
  144. {0x453c, 0xffffffff, 0x0},
  145. {0x4588, 0x0fffc000, 0x0},
  146. {0x4598, 0x0003fe00, 0x0},
  147. {0x4540, 0xffffffff, 0x0},
  148. {0x4544, 0xffffffff, 0x0},
  149. {0x4548, 0xffffffff, 0x0},
  150. {0x458c, 0x00003fff, 0x0},
  151. {0x4598, 0x07fc0000, 0x0},
  152. {0x454c, 0xffffffff, 0x0},
  153. {0x4550, 0xffffffff, 0x0},
  154. {0x4554, 0xffffffff, 0x0},
  155. {0x458c, 0x0fffc000, 0x0},
  156. {0x459c, 0x000001ff, 0x0},
  157. {0x4558, 0xffffffff, 0x0},
  158. {0x455c, 0xffffffff, 0x0},
  159. {0x4530, 0xffffffff, 0x4e790001},
  160. {0x4588, 0x00003fff, 0x0},
  161. {0x4598, 0x000001ff, 0x1},
  162. {0x4534, 0xffffffff, 0x0},
  163. {0x4538, 0xffffffff, 0x4b},
  164. {0x45ac, 0x38000000, 0x7},
  165. {0x4588, 0xf0000000, 0x0},
  166. {0x459c, 0x7e000000, 0x0},
  167. {0x45b8, 0x00040000, 0x0},
  168. {0x45b8, 0x00020000, 0x0},
  169. {0x4590, 0xffc00000, 0x0},
  170. {0x45b8, 0x00004000, 0x0},
  171. {0x4578, 0xff000000, 0x0},
  172. {0x45b8, 0x00000400, 0x0},
  173. {0x45b8, 0x00000800, 0x0},
  174. {0x45b8, 0x00001000, 0x0},
  175. {0x45b8, 0x00002000, 0x0},
  176. {0x45b4, 0x00018000, 0x0},
  177. {0x45ac, 0x07800000, 0x0},
  178. {0x45b4, 0x00000600, 0x2},
  179. {0x459c, 0x0001fe00, 0x80},
  180. {0x45ac, 0x00078000, 0x3},
  181. {0x459c, 0x01fe0000, 0x1},
  182. };
  183. static const struct rtw89_reg3_def rtw8852b_btc_preagc_en_defs[] = {
  184. {0x46D0, GENMASK(1, 0), 0x3},
  185. {0x4790, GENMASK(1, 0), 0x3},
  186. {0x4AD4, GENMASK(31, 0), 0xf},
  187. {0x4AE0, GENMASK(31, 0), 0xf},
  188. {0x4688, GENMASK(31, 24), 0x80},
  189. {0x476C, GENMASK(31, 24), 0x80},
  190. {0x4694, GENMASK(7, 0), 0x80},
  191. {0x4694, GENMASK(15, 8), 0x80},
  192. {0x4778, GENMASK(7, 0), 0x80},
  193. {0x4778, GENMASK(15, 8), 0x80},
  194. {0x4AE4, GENMASK(23, 0), 0x780D1E},
  195. {0x4AEC, GENMASK(23, 0), 0x780D1E},
  196. {0x469C, GENMASK(31, 26), 0x34},
  197. {0x49F0, GENMASK(31, 26), 0x34},
  198. };
  199. static DECLARE_PHY_REG3_TBL(rtw8852b_btc_preagc_en_defs);
  200. static const struct rtw89_reg3_def rtw8852b_btc_preagc_dis_defs[] = {
  201. {0x46D0, GENMASK(1, 0), 0x0},
  202. {0x4790, GENMASK(1, 0), 0x0},
  203. {0x4AD4, GENMASK(31, 0), 0x60},
  204. {0x4AE0, GENMASK(31, 0), 0x60},
  205. {0x4688, GENMASK(31, 24), 0x1a},
  206. {0x476C, GENMASK(31, 24), 0x1a},
  207. {0x4694, GENMASK(7, 0), 0x2a},
  208. {0x4694, GENMASK(15, 8), 0x2a},
  209. {0x4778, GENMASK(7, 0), 0x2a},
  210. {0x4778, GENMASK(15, 8), 0x2a},
  211. {0x4AE4, GENMASK(23, 0), 0x79E99E},
  212. {0x4AEC, GENMASK(23, 0), 0x79E99E},
  213. {0x469C, GENMASK(31, 26), 0x26},
  214. {0x49F0, GENMASK(31, 26), 0x26},
  215. };
  216. static DECLARE_PHY_REG3_TBL(rtw8852b_btc_preagc_dis_defs);
  217. static const u32 rtw8852b_h2c_regs[RTW89_H2CREG_MAX] = {
  218. R_AX_H2CREG_DATA0, R_AX_H2CREG_DATA1, R_AX_H2CREG_DATA2,
  219. R_AX_H2CREG_DATA3
  220. };
  221. static const u32 rtw8852b_c2h_regs[RTW89_C2HREG_MAX] = {
  222. R_AX_C2HREG_DATA0, R_AX_C2HREG_DATA1, R_AX_C2HREG_DATA2,
  223. R_AX_C2HREG_DATA3
  224. };
  225. static const struct rtw89_page_regs rtw8852b_page_regs = {
  226. .hci_fc_ctrl = R_AX_HCI_FC_CTRL,
  227. .ch_page_ctrl = R_AX_CH_PAGE_CTRL,
  228. .ach_page_ctrl = R_AX_ACH0_PAGE_CTRL,
  229. .ach_page_info = R_AX_ACH0_PAGE_INFO,
  230. .pub_page_info3 = R_AX_PUB_PAGE_INFO3,
  231. .pub_page_ctrl1 = R_AX_PUB_PAGE_CTRL1,
  232. .pub_page_ctrl2 = R_AX_PUB_PAGE_CTRL2,
  233. .pub_page_info1 = R_AX_PUB_PAGE_INFO1,
  234. .pub_page_info2 = R_AX_PUB_PAGE_INFO2,
  235. .wp_page_ctrl1 = R_AX_WP_PAGE_CTRL1,
  236. .wp_page_ctrl2 = R_AX_WP_PAGE_CTRL2,
  237. .wp_page_info1 = R_AX_WP_PAGE_INFO1,
  238. };
  239. static const struct rtw89_reg_def rtw8852b_dcfo_comp = {
  240. R_DCFO_COMP_S0, B_DCFO_COMP_S0_MSK
  241. };
  242. static const struct rtw89_imr_info rtw8852b_imr_info = {
  243. .wdrls_imr_set = B_AX_WDRLS_IMR_SET,
  244. .wsec_imr_reg = R_AX_SEC_DEBUG,
  245. .wsec_imr_set = B_AX_IMR_ERROR,
  246. .mpdu_tx_imr_set = 0,
  247. .mpdu_rx_imr_set = 0,
  248. .sta_sch_imr_set = B_AX_STA_SCHEDULER_IMR_SET,
  249. .txpktctl_imr_b0_reg = R_AX_TXPKTCTL_ERR_IMR_ISR,
  250. .txpktctl_imr_b0_clr = B_AX_TXPKTCTL_IMR_B0_CLR,
  251. .txpktctl_imr_b0_set = B_AX_TXPKTCTL_IMR_B0_SET,
  252. .txpktctl_imr_b1_reg = R_AX_TXPKTCTL_ERR_IMR_ISR_B1,
  253. .txpktctl_imr_b1_clr = B_AX_TXPKTCTL_IMR_B1_CLR,
  254. .txpktctl_imr_b1_set = B_AX_TXPKTCTL_IMR_B1_SET,
  255. .wde_imr_clr = B_AX_WDE_IMR_CLR,
  256. .wde_imr_set = B_AX_WDE_IMR_SET,
  257. .ple_imr_clr = B_AX_PLE_IMR_CLR,
  258. .ple_imr_set = B_AX_PLE_IMR_SET,
  259. .host_disp_imr_clr = B_AX_HOST_DISP_IMR_CLR,
  260. .host_disp_imr_set = B_AX_HOST_DISP_IMR_SET,
  261. .cpu_disp_imr_clr = B_AX_CPU_DISP_IMR_CLR,
  262. .cpu_disp_imr_set = B_AX_CPU_DISP_IMR_SET,
  263. .other_disp_imr_clr = B_AX_OTHER_DISP_IMR_CLR,
  264. .other_disp_imr_set = 0,
  265. .bbrpt_com_err_imr_reg = R_AX_BBRPT_COM_ERR_IMR_ISR,
  266. .bbrpt_chinfo_err_imr_reg = R_AX_BBRPT_CHINFO_ERR_IMR_ISR,
  267. .bbrpt_err_imr_set = 0,
  268. .bbrpt_dfs_err_imr_reg = R_AX_BBRPT_DFS_ERR_IMR_ISR,
  269. .ptcl_imr_clr = B_AX_PTCL_IMR_CLR_ALL,
  270. .ptcl_imr_set = B_AX_PTCL_IMR_SET,
  271. .cdma_imr_0_reg = R_AX_DLE_CTRL,
  272. .cdma_imr_0_clr = B_AX_DLE_IMR_CLR,
  273. .cdma_imr_0_set = B_AX_DLE_IMR_SET,
  274. .cdma_imr_1_reg = 0,
  275. .cdma_imr_1_clr = 0,
  276. .cdma_imr_1_set = 0,
  277. .phy_intf_imr_reg = R_AX_PHYINFO_ERR_IMR,
  278. .phy_intf_imr_clr = 0,
  279. .phy_intf_imr_set = 0,
  280. .rmac_imr_reg = R_AX_RMAC_ERR_ISR,
  281. .rmac_imr_clr = B_AX_RMAC_IMR_CLR,
  282. .rmac_imr_set = B_AX_RMAC_IMR_SET,
  283. .tmac_imr_reg = R_AX_TMAC_ERR_IMR_ISR,
  284. .tmac_imr_clr = B_AX_TMAC_IMR_CLR,
  285. .tmac_imr_set = B_AX_TMAC_IMR_SET,
  286. };
  287. static const struct rtw89_rrsr_cfgs rtw8852b_rrsr_cfgs = {
  288. .ref_rate = {R_AX_TRXPTCL_RRSR_CTL_0, B_AX_WMAC_RESP_REF_RATE_SEL, 0},
  289. .rsc = {R_AX_TRXPTCL_RRSR_CTL_0, B_AX_WMAC_RESP_RSC_MASK, 2},
  290. };
  291. static const struct rtw89_dig_regs rtw8852b_dig_regs = {
  292. .seg0_pd_reg = R_SEG0R_PD_V1,
  293. .pd_lower_bound_mask = B_SEG0R_PD_LOWER_BOUND_MSK,
  294. .pd_spatial_reuse_en = B_SEG0R_PD_SPATIAL_REUSE_EN_MSK_V1,
  295. .bmode_pd_reg = R_BMODE_PDTH_EN_V1,
  296. .bmode_cca_rssi_limit_en = B_BMODE_PDTH_LIMIT_EN_MSK_V1,
  297. .bmode_pd_lower_bound_reg = R_BMODE_PDTH_V1,
  298. .bmode_rssi_nocca_low_th_mask = B_BMODE_PDTH_LOWER_BOUND_MSK_V1,
  299. .p0_lna_init = {R_PATH0_LNA_INIT_V1, B_PATH0_LNA_INIT_IDX_MSK},
  300. .p1_lna_init = {R_PATH1_LNA_INIT_V1, B_PATH1_LNA_INIT_IDX_MSK},
  301. .p0_tia_init = {R_PATH0_TIA_INIT_V1, B_PATH0_TIA_INIT_IDX_MSK_V1},
  302. .p1_tia_init = {R_PATH1_TIA_INIT_V1, B_PATH1_TIA_INIT_IDX_MSK_V1},
  303. .p0_rxb_init = {R_PATH0_RXB_INIT_V1, B_PATH0_RXB_INIT_IDX_MSK_V1},
  304. .p1_rxb_init = {R_PATH1_RXB_INIT_V1, B_PATH1_RXB_INIT_IDX_MSK_V1},
  305. .p0_p20_pagcugc_en = {R_PATH0_P20_FOLLOW_BY_PAGCUGC_V2,
  306. B_PATH0_P20_FOLLOW_BY_PAGCUGC_EN_MSK},
  307. .p0_s20_pagcugc_en = {R_PATH0_S20_FOLLOW_BY_PAGCUGC_V2,
  308. B_PATH0_S20_FOLLOW_BY_PAGCUGC_EN_MSK},
  309. .p1_p20_pagcugc_en = {R_PATH1_P20_FOLLOW_BY_PAGCUGC_V2,
  310. B_PATH1_P20_FOLLOW_BY_PAGCUGC_EN_MSK},
  311. .p1_s20_pagcugc_en = {R_PATH1_S20_FOLLOW_BY_PAGCUGC_V2,
  312. B_PATH1_S20_FOLLOW_BY_PAGCUGC_EN_MSK},
  313. };
  314. static const struct rtw89_btc_rf_trx_para rtw89_btc_8852b_rf_ul[] = {
  315. {255, 0, 0, 7}, /* 0 -> original */
  316. {255, 2, 0, 7}, /* 1 -> for BT-connected ACI issue && BTG co-rx */
  317. {255, 0, 0, 7}, /* 2 ->reserved for shared-antenna */
  318. {255, 0, 0, 7}, /* 3- >reserved for shared-antenna */
  319. {255, 0, 0, 7}, /* 4 ->reserved for shared-antenna */
  320. {255, 1, 0, 7}, /* the below id is for non-shared-antenna free-run */
  321. {6, 1, 0, 7},
  322. {13, 1, 0, 7},
  323. {13, 1, 0, 7}
  324. };
  325. static const struct rtw89_btc_rf_trx_para rtw89_btc_8852b_rf_dl[] = {
  326. {255, 0, 0, 7}, /* 0 -> original */
  327. {255, 2, 0, 7}, /* 1 -> reserved for shared-antenna */
  328. {255, 0, 0, 7}, /* 2 ->reserved for shared-antenna */
  329. {255, 0, 0, 7}, /* 3- >reserved for shared-antenna */
  330. {255, 0, 0, 7}, /* 4 ->reserved for shared-antenna */
  331. {255, 1, 0, 7}, /* the below id is for non-shared-antenna free-run */
  332. {255, 1, 0, 7},
  333. {255, 1, 0, 7},
  334. {255, 1, 0, 7}
  335. };
  336. static const struct rtw89_btc_fbtc_mreg rtw89_btc_8852b_mon_reg[] = {
  337. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda24),
  338. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda28),
  339. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda2c),
  340. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda30),
  341. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda4c),
  342. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda10),
  343. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda20),
  344. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xda34),
  345. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xcef4),
  346. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0x8424),
  347. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xd200),
  348. RTW89_DEF_FBTC_MREG(REG_MAC, 4, 0xd220),
  349. RTW89_DEF_FBTC_MREG(REG_BB, 4, 0x980),
  350. RTW89_DEF_FBTC_MREG(REG_BB, 4, 0x4738),
  351. RTW89_DEF_FBTC_MREG(REG_BB, 4, 0x4688),
  352. RTW89_DEF_FBTC_MREG(REG_BB, 4, 0x4694),
  353. };
  354. static const u8 rtw89_btc_8852b_wl_rssi_thres[BTC_WL_RSSI_THMAX] = {70, 60, 50, 40};
  355. static const u8 rtw89_btc_8852b_bt_rssi_thres[BTC_BT_RSSI_THMAX] = {50, 40, 30, 20};
  356. static int rtw8852b_pwr_on_func(struct rtw89_dev *rtwdev)
  357. {
  358. u32 val32;
  359. u32 ret;
  360. rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_AFSM_WLSUS_EN |
  361. B_AX_AFSM_PCIE_SUS_EN);
  362. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_DIS_WLBT_PDNSUSEN_SOPC);
  363. rtw89_write32_set(rtwdev, R_AX_WLLPS_CTRL, B_AX_DIS_WLBT_LPSEN_LOPC);
  364. rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APDM_HPDN);
  365. rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFM_SWLPS);
  366. ret = read_poll_timeout(rtw89_read32, val32, val32 & B_AX_RDY_SYSPWR,
  367. 1000, 20000, false, rtwdev, R_AX_SYS_PW_CTRL);
  368. if (ret)
  369. return ret;
  370. rtw89_write32_set(rtwdev, R_AX_AFE_LDO_CTRL, B_AX_AON_OFF_PC_EN);
  371. ret = read_poll_timeout(rtw89_read32, val32, val32 & B_AX_AON_OFF_PC_EN,
  372. 1000, 20000, false, rtwdev, R_AX_AFE_LDO_CTRL);
  373. if (ret)
  374. return ret;
  375. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_OFF_CTRL0, B_AX_C1_L1_MASK, 0x1);
  376. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_OFF_CTRL0, B_AX_C3_L1_MASK, 0x3);
  377. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_EN_WLON);
  378. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFN_ONMAC);
  379. ret = read_poll_timeout(rtw89_read32, val32, !(val32 & B_AX_APFN_ONMAC),
  380. 1000, 20000, false, rtwdev, R_AX_SYS_PW_CTRL);
  381. if (ret)
  382. return ret;
  383. rtw89_write8_set(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_PLATFORM_EN);
  384. rtw89_write8_clr(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_PLATFORM_EN);
  385. rtw89_write8_set(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_PLATFORM_EN);
  386. rtw89_write8_clr(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_PLATFORM_EN);
  387. rtw89_write8_set(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_PLATFORM_EN);
  388. rtw89_write32_clr(rtwdev, R_AX_SYS_SDIO_CTRL, B_AX_PCIE_CALIB_EN_V1);
  389. rtw89_write32_set(rtwdev, R_AX_SYS_ADIE_PAD_PWR_CTRL, B_AX_SYM_PADPDN_WL_PTA_1P3);
  390. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL,
  391. XTAL_SI_GND_SHDN_WL, XTAL_SI_GND_SHDN_WL);
  392. if (ret)
  393. return ret;
  394. rtw89_write32_set(rtwdev, R_AX_SYS_ADIE_PAD_PWR_CTRL, B_AX_SYM_PADPDN_WL_RFC_1P3);
  395. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL,
  396. XTAL_SI_SHDN_WL, XTAL_SI_SHDN_WL);
  397. if (ret)
  398. return ret;
  399. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_OFF_WEI,
  400. XTAL_SI_OFF_WEI);
  401. if (ret)
  402. return ret;
  403. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_OFF_EI,
  404. XTAL_SI_OFF_EI);
  405. if (ret)
  406. return ret;
  407. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_RFC2RF);
  408. if (ret)
  409. return ret;
  410. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_PON_WEI,
  411. XTAL_SI_PON_WEI);
  412. if (ret)
  413. return ret;
  414. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_PON_EI,
  415. XTAL_SI_PON_EI);
  416. if (ret)
  417. return ret;
  418. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_SRAM2RFC);
  419. if (ret)
  420. return ret;
  421. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_SRAM_CTRL, 0, XTAL_SI_SRAM_DIS);
  422. if (ret)
  423. return ret;
  424. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_XMD_2, 0, XTAL_SI_LDO_LPS);
  425. if (ret)
  426. return ret;
  427. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_XMD_4, 0, XTAL_SI_LPS_CAP);
  428. if (ret)
  429. return ret;
  430. rtw89_write32_set(rtwdev, R_AX_PMC_DBG_CTRL2, B_AX_SYSON_DIS_PMCR_AX_WRMSK);
  431. rtw89_write32_set(rtwdev, R_AX_SYS_ISO_CTRL, B_AX_ISO_EB2CORE);
  432. rtw89_write32_clr(rtwdev, R_AX_SYS_ISO_CTRL, B_AX_PWC_EV2EF_B15);
  433. fsleep(1000);
  434. rtw89_write32_clr(rtwdev, R_AX_SYS_ISO_CTRL, B_AX_PWC_EV2EF_B14);
  435. rtw89_write32_clr(rtwdev, R_AX_PMC_DBG_CTRL2, B_AX_SYSON_DIS_PMCR_AX_WRMSK);
  436. if (!rtwdev->efuse.valid || rtwdev->efuse.power_k_valid)
  437. goto func_en;
  438. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, B_AX_VOL_L1_MASK, 0x9);
  439. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, B_AX_VREFPFM_L_MASK, 0xA);
  440. if (rtwdev->hal.cv == CHIP_CBV) {
  441. rtw89_write32_set(rtwdev, R_AX_PMC_DBG_CTRL2, B_AX_SYSON_DIS_PMCR_AX_WRMSK);
  442. rtw89_write16_mask(rtwdev, R_AX_HCI_LDO_CTRL, B_AX_R_AX_VADJ_MASK, 0xA);
  443. rtw89_write32_clr(rtwdev, R_AX_PMC_DBG_CTRL2, B_AX_SYSON_DIS_PMCR_AX_WRMSK);
  444. }
  445. func_en:
  446. rtw89_write32_set(rtwdev, R_AX_DMAC_FUNC_EN,
  447. B_AX_MAC_FUNC_EN | B_AX_DMAC_FUNC_EN | B_AX_MPDU_PROC_EN |
  448. B_AX_WD_RLS_EN | B_AX_DLE_WDE_EN | B_AX_TXPKT_CTRL_EN |
  449. B_AX_STA_SCH_EN | B_AX_DLE_PLE_EN | B_AX_PKT_BUF_EN |
  450. B_AX_DMAC_TBL_EN | B_AX_PKT_IN_EN | B_AX_DLE_CPUIO_EN |
  451. B_AX_DISPATCHER_EN | B_AX_BBRPT_EN | B_AX_MAC_SEC_EN |
  452. B_AX_DMACREG_GCKEN);
  453. rtw89_write32_set(rtwdev, R_AX_CMAC_FUNC_EN,
  454. B_AX_CMAC_EN | B_AX_CMAC_TXEN | B_AX_CMAC_RXEN |
  455. B_AX_FORCE_CMACREG_GCKEN | B_AX_PHYINTF_EN | B_AX_CMAC_DMA_EN |
  456. B_AX_PTCLTOP_EN | B_AX_SCHEDULER_EN | B_AX_TMAC_EN |
  457. B_AX_RMAC_EN);
  458. rtw89_write32_mask(rtwdev, R_AX_EECS_EESK_FUNC_SEL, B_AX_PINMUX_EESK_FUNC_SEL_MASK,
  459. PINMUX_EESK_FUNC_SEL_BT_LOG);
  460. return 0;
  461. }
  462. static int rtw8852b_pwr_off_func(struct rtw89_dev *rtwdev)
  463. {
  464. u32 val32;
  465. u32 ret;
  466. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_RFC2RF,
  467. XTAL_SI_RFC2RF);
  468. if (ret)
  469. return ret;
  470. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_OFF_EI);
  471. if (ret)
  472. return ret;
  473. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_OFF_WEI);
  474. if (ret)
  475. return ret;
  476. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S0, 0, XTAL_SI_RF00);
  477. if (ret)
  478. return ret;
  479. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S1, 0, XTAL_SI_RF10);
  480. if (ret)
  481. return ret;
  482. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, XTAL_SI_SRAM2RFC,
  483. XTAL_SI_SRAM2RFC);
  484. if (ret)
  485. return ret;
  486. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_PON_EI);
  487. if (ret)
  488. return ret;
  489. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_PON_WEI);
  490. if (ret)
  491. return ret;
  492. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_EN_WLON);
  493. rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BB_GLB_RSTN | B_AX_FEN_BBRSTB);
  494. rtw89_write32_clr(rtwdev, R_AX_SYS_ADIE_PAD_PWR_CTRL, B_AX_SYM_PADPDN_WL_RFC_1P3);
  495. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_SHDN_WL);
  496. if (ret)
  497. return ret;
  498. rtw89_write32_clr(rtwdev, R_AX_SYS_ADIE_PAD_PWR_CTRL, B_AX_SYM_PADPDN_WL_PTA_1P3);
  499. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_GND_SHDN_WL);
  500. if (ret)
  501. return ret;
  502. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFM_OFFMAC);
  503. ret = read_poll_timeout(rtw89_read32, val32, !(val32 & B_AX_APFM_OFFMAC),
  504. 1000, 20000, false, rtwdev, R_AX_SYS_PW_CTRL);
  505. if (ret)
  506. return ret;
  507. rtw89_write32(rtwdev, R_AX_WLLPS_CTRL, SW_LPS_OPTION);
  508. rtw89_write32_set(rtwdev, R_AX_SYS_SWR_CTRL1, B_AX_SYM_CTRL_SPS_PWMFREQ);
  509. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, B_AX_REG_ZCDC_H_MASK, 0x3);
  510. rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFM_SWLPS);
  511. return 0;
  512. }
  513. static void rtw8852be_efuse_parsing(struct rtw89_efuse *efuse,
  514. struct rtw8852b_efuse *map)
  515. {
  516. ether_addr_copy(efuse->addr, map->e.mac_addr);
  517. efuse->rfe_type = map->rfe_type;
  518. efuse->xtal_cap = map->xtal_k;
  519. }
  520. static void rtw8852b_efuse_parsing_tssi(struct rtw89_dev *rtwdev,
  521. struct rtw8852b_efuse *map)
  522. {
  523. struct rtw89_tssi_info *tssi = &rtwdev->tssi;
  524. struct rtw8852b_tssi_offset *ofst[] = {&map->path_a_tssi, &map->path_b_tssi};
  525. u8 i, j;
  526. tssi->thermal[RF_PATH_A] = map->path_a_therm;
  527. tssi->thermal[RF_PATH_B] = map->path_b_therm;
  528. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  529. memcpy(tssi->tssi_cck[i], ofst[i]->cck_tssi,
  530. sizeof(ofst[i]->cck_tssi));
  531. for (j = 0; j < TSSI_CCK_CH_GROUP_NUM; j++)
  532. rtw89_debug(rtwdev, RTW89_DBG_TSSI,
  533. "[TSSI][EFUSE] path=%d cck[%d]=0x%x\n",
  534. i, j, tssi->tssi_cck[i][j]);
  535. memcpy(tssi->tssi_mcs[i], ofst[i]->bw40_tssi,
  536. sizeof(ofst[i]->bw40_tssi));
  537. memcpy(tssi->tssi_mcs[i] + TSSI_MCS_2G_CH_GROUP_NUM,
  538. ofst[i]->bw40_1s_tssi_5g, sizeof(ofst[i]->bw40_1s_tssi_5g));
  539. for (j = 0; j < TSSI_MCS_CH_GROUP_NUM; j++)
  540. rtw89_debug(rtwdev, RTW89_DBG_TSSI,
  541. "[TSSI][EFUSE] path=%d mcs[%d]=0x%x\n",
  542. i, j, tssi->tssi_mcs[i][j]);
  543. }
  544. }
  545. static bool _decode_efuse_gain(u8 data, s8 *high, s8 *low)
  546. {
  547. if (high)
  548. *high = sign_extend32(FIELD_GET(GENMASK(7, 4), data), 3);
  549. if (low)
  550. *low = sign_extend32(FIELD_GET(GENMASK(3, 0), data), 3);
  551. return data != 0xff;
  552. }
  553. static void rtw8852b_efuse_parsing_gain_offset(struct rtw89_dev *rtwdev,
  554. struct rtw8852b_efuse *map)
  555. {
  556. struct rtw89_phy_efuse_gain *gain = &rtwdev->efuse_gain;
  557. bool valid = false;
  558. valid |= _decode_efuse_gain(map->rx_gain_2g_cck,
  559. &gain->offset[RF_PATH_A][RTW89_GAIN_OFFSET_2G_CCK],
  560. &gain->offset[RF_PATH_B][RTW89_GAIN_OFFSET_2G_CCK]);
  561. valid |= _decode_efuse_gain(map->rx_gain_2g_ofdm,
  562. &gain->offset[RF_PATH_A][RTW89_GAIN_OFFSET_2G_OFDM],
  563. &gain->offset[RF_PATH_B][RTW89_GAIN_OFFSET_2G_OFDM]);
  564. valid |= _decode_efuse_gain(map->rx_gain_5g_low,
  565. &gain->offset[RF_PATH_A][RTW89_GAIN_OFFSET_5G_LOW],
  566. &gain->offset[RF_PATH_B][RTW89_GAIN_OFFSET_5G_LOW]);
  567. valid |= _decode_efuse_gain(map->rx_gain_5g_mid,
  568. &gain->offset[RF_PATH_A][RTW89_GAIN_OFFSET_5G_MID],
  569. &gain->offset[RF_PATH_B][RTW89_GAIN_OFFSET_5G_MID]);
  570. valid |= _decode_efuse_gain(map->rx_gain_5g_high,
  571. &gain->offset[RF_PATH_A][RTW89_GAIN_OFFSET_5G_HIGH],
  572. &gain->offset[RF_PATH_B][RTW89_GAIN_OFFSET_5G_HIGH]);
  573. gain->offset_valid = valid;
  574. }
  575. static int rtw8852b_read_efuse(struct rtw89_dev *rtwdev, u8 *log_map)
  576. {
  577. struct rtw89_efuse *efuse = &rtwdev->efuse;
  578. struct rtw8852b_efuse *map;
  579. map = (struct rtw8852b_efuse *)log_map;
  580. efuse->country_code[0] = map->country_code[0];
  581. efuse->country_code[1] = map->country_code[1];
  582. rtw8852b_efuse_parsing_tssi(rtwdev, map);
  583. rtw8852b_efuse_parsing_gain_offset(rtwdev, map);
  584. switch (rtwdev->hci.type) {
  585. case RTW89_HCI_TYPE_PCIE:
  586. rtw8852be_efuse_parsing(efuse, map);
  587. break;
  588. default:
  589. return -EOPNOTSUPP;
  590. }
  591. rtw89_info(rtwdev, "chip rfe_type is %d\n", efuse->rfe_type);
  592. return 0;
  593. }
  594. static void rtw8852b_phycap_parsing_power_cal(struct rtw89_dev *rtwdev, u8 *phycap_map)
  595. {
  596. #define PWR_K_CHK_OFFSET 0x5E9
  597. #define PWR_K_CHK_VALUE 0xAA
  598. u32 offset = PWR_K_CHK_OFFSET - rtwdev->chip->phycap_addr;
  599. if (phycap_map[offset] == PWR_K_CHK_VALUE)
  600. rtwdev->efuse.power_k_valid = true;
  601. }
  602. static void rtw8852b_phycap_parsing_tssi(struct rtw89_dev *rtwdev, u8 *phycap_map)
  603. {
  604. struct rtw89_tssi_info *tssi = &rtwdev->tssi;
  605. static const u32 tssi_trim_addr[RF_PATH_NUM_8852B] = {0x5D6, 0x5AB};
  606. u32 addr = rtwdev->chip->phycap_addr;
  607. bool pg = false;
  608. u32 ofst;
  609. u8 i, j;
  610. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  611. for (j = 0; j < TSSI_TRIM_CH_GROUP_NUM; j++) {
  612. /* addrs are in decreasing order */
  613. ofst = tssi_trim_addr[i] - addr - j;
  614. tssi->tssi_trim[i][j] = phycap_map[ofst];
  615. if (phycap_map[ofst] != 0xff)
  616. pg = true;
  617. }
  618. }
  619. if (!pg) {
  620. memset(tssi->tssi_trim, 0, sizeof(tssi->tssi_trim));
  621. rtw89_debug(rtwdev, RTW89_DBG_TSSI,
  622. "[TSSI][TRIM] no PG, set all trim info to 0\n");
  623. }
  624. for (i = 0; i < RF_PATH_NUM_8852B; i++)
  625. for (j = 0; j < TSSI_TRIM_CH_GROUP_NUM; j++)
  626. rtw89_debug(rtwdev, RTW89_DBG_TSSI,
  627. "[TSSI] path=%d idx=%d trim=0x%x addr=0x%x\n",
  628. i, j, tssi->tssi_trim[i][j],
  629. tssi_trim_addr[i] - j);
  630. }
  631. static void rtw8852b_phycap_parsing_thermal_trim(struct rtw89_dev *rtwdev,
  632. u8 *phycap_map)
  633. {
  634. struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
  635. static const u32 thm_trim_addr[RF_PATH_NUM_8852B] = {0x5DF, 0x5DC};
  636. u32 addr = rtwdev->chip->phycap_addr;
  637. u8 i;
  638. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  639. info->thermal_trim[i] = phycap_map[thm_trim_addr[i] - addr];
  640. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  641. "[THERMAL][TRIM] path=%d thermal_trim=0x%x\n",
  642. i, info->thermal_trim[i]);
  643. if (info->thermal_trim[i] != 0xff)
  644. info->pg_thermal_trim = true;
  645. }
  646. }
  647. static void rtw8852b_thermal_trim(struct rtw89_dev *rtwdev)
  648. {
  649. #define __thm_setting(raw) \
  650. ({ \
  651. u8 __v = (raw); \
  652. ((__v & 0x1) << 3) | ((__v & 0x1f) >> 1); \
  653. })
  654. struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
  655. u8 i, val;
  656. if (!info->pg_thermal_trim) {
  657. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  658. "[THERMAL][TRIM] no PG, do nothing\n");
  659. return;
  660. }
  661. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  662. val = __thm_setting(info->thermal_trim[i]);
  663. rtw89_write_rf(rtwdev, i, RR_TM2, RR_TM2_OFF, val);
  664. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  665. "[THERMAL][TRIM] path=%d thermal_setting=0x%x\n",
  666. i, val);
  667. }
  668. #undef __thm_setting
  669. }
  670. static void rtw8852b_phycap_parsing_pa_bias_trim(struct rtw89_dev *rtwdev,
  671. u8 *phycap_map)
  672. {
  673. struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
  674. static const u32 pabias_trim_addr[RF_PATH_NUM_8852B] = {0x5DE, 0x5DB};
  675. u32 addr = rtwdev->chip->phycap_addr;
  676. u8 i;
  677. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  678. info->pa_bias_trim[i] = phycap_map[pabias_trim_addr[i] - addr];
  679. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  680. "[PA_BIAS][TRIM] path=%d pa_bias_trim=0x%x\n",
  681. i, info->pa_bias_trim[i]);
  682. if (info->pa_bias_trim[i] != 0xff)
  683. info->pg_pa_bias_trim = true;
  684. }
  685. }
  686. static void rtw8852b_pa_bias_trim(struct rtw89_dev *rtwdev)
  687. {
  688. struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
  689. u8 pabias_2g, pabias_5g;
  690. u8 i;
  691. if (!info->pg_pa_bias_trim) {
  692. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  693. "[PA_BIAS][TRIM] no PG, do nothing\n");
  694. return;
  695. }
  696. for (i = 0; i < RF_PATH_NUM_8852B; i++) {
  697. pabias_2g = FIELD_GET(GENMASK(3, 0), info->pa_bias_trim[i]);
  698. pabias_5g = FIELD_GET(GENMASK(7, 4), info->pa_bias_trim[i]);
  699. rtw89_debug(rtwdev, RTW89_DBG_RFK,
  700. "[PA_BIAS][TRIM] path=%d 2G=0x%x 5G=0x%x\n",
  701. i, pabias_2g, pabias_5g);
  702. rtw89_write_rf(rtwdev, i, RR_BIASA, RR_BIASA_TXG, pabias_2g);
  703. rtw89_write_rf(rtwdev, i, RR_BIASA, RR_BIASA_TXA, pabias_5g);
  704. }
  705. }
  706. static void rtw8852b_phycap_parsing_gain_comp(struct rtw89_dev *rtwdev, u8 *phycap_map)
  707. {
  708. static const u32 comp_addrs[][RTW89_SUBBAND_2GHZ_5GHZ_NR] = {
  709. {0x5BB, 0x5BA, 0, 0x5B9, 0x5B8},
  710. {0x590, 0x58F, 0, 0x58E, 0x58D},
  711. };
  712. struct rtw89_phy_efuse_gain *gain = &rtwdev->efuse_gain;
  713. u32 phycap_addr = rtwdev->chip->phycap_addr;
  714. bool valid = false;
  715. int path, i;
  716. u8 data;
  717. for (path = 0; path < 2; path++)
  718. for (i = 0; i < RTW89_SUBBAND_2GHZ_5GHZ_NR; i++) {
  719. if (comp_addrs[path][i] == 0)
  720. continue;
  721. data = phycap_map[comp_addrs[path][i] - phycap_addr];
  722. valid |= _decode_efuse_gain(data, NULL,
  723. &gain->comp[path][i]);
  724. }
  725. gain->comp_valid = valid;
  726. }
  727. static int rtw8852b_read_phycap(struct rtw89_dev *rtwdev, u8 *phycap_map)
  728. {
  729. rtw8852b_phycap_parsing_power_cal(rtwdev, phycap_map);
  730. rtw8852b_phycap_parsing_tssi(rtwdev, phycap_map);
  731. rtw8852b_phycap_parsing_thermal_trim(rtwdev, phycap_map);
  732. rtw8852b_phycap_parsing_pa_bias_trim(rtwdev, phycap_map);
  733. rtw8852b_phycap_parsing_gain_comp(rtwdev, phycap_map);
  734. return 0;
  735. }
  736. static void rtw8852b_power_trim(struct rtw89_dev *rtwdev)
  737. {
  738. rtw8852b_thermal_trim(rtwdev);
  739. rtw8852b_pa_bias_trim(rtwdev);
  740. }
  741. static void rtw8852b_set_channel_mac(struct rtw89_dev *rtwdev,
  742. const struct rtw89_chan *chan,
  743. u8 mac_idx)
  744. {
  745. u32 rf_mod = rtw89_mac_reg_by_idx(rtwdev, R_AX_WMAC_RFMOD, mac_idx);
  746. u32 sub_carr = rtw89_mac_reg_by_idx(rtwdev, R_AX_TX_SUB_CARRIER_VALUE, mac_idx);
  747. u32 chk_rate = rtw89_mac_reg_by_idx(rtwdev, R_AX_TXRATE_CHK, mac_idx);
  748. u8 txsc20 = 0, txsc40 = 0;
  749. switch (chan->band_width) {
  750. case RTW89_CHANNEL_WIDTH_80:
  751. txsc40 = rtw89_phy_get_txsc(rtwdev, chan, RTW89_CHANNEL_WIDTH_40);
  752. fallthrough;
  753. case RTW89_CHANNEL_WIDTH_40:
  754. txsc20 = rtw89_phy_get_txsc(rtwdev, chan, RTW89_CHANNEL_WIDTH_20);
  755. break;
  756. default:
  757. break;
  758. }
  759. switch (chan->band_width) {
  760. case RTW89_CHANNEL_WIDTH_80:
  761. rtw89_write8_mask(rtwdev, rf_mod, B_AX_WMAC_RFMOD_MASK, BIT(1));
  762. rtw89_write32(rtwdev, sub_carr, txsc20 | (txsc40 << 4));
  763. break;
  764. case RTW89_CHANNEL_WIDTH_40:
  765. rtw89_write8_mask(rtwdev, rf_mod, B_AX_WMAC_RFMOD_MASK, BIT(0));
  766. rtw89_write32(rtwdev, sub_carr, txsc20);
  767. break;
  768. case RTW89_CHANNEL_WIDTH_20:
  769. rtw89_write8_clr(rtwdev, rf_mod, B_AX_WMAC_RFMOD_MASK);
  770. rtw89_write32(rtwdev, sub_carr, 0);
  771. break;
  772. default:
  773. break;
  774. }
  775. if (chan->channel > 14) {
  776. rtw89_write8_clr(rtwdev, chk_rate, B_AX_BAND_MODE);
  777. rtw89_write8_set(rtwdev, chk_rate,
  778. B_AX_CHECK_CCK_EN | B_AX_RTS_LIMIT_IN_OFDM6);
  779. } else {
  780. rtw89_write8_set(rtwdev, chk_rate, B_AX_BAND_MODE);
  781. rtw89_write8_clr(rtwdev, chk_rate,
  782. B_AX_CHECK_CCK_EN | B_AX_RTS_LIMIT_IN_OFDM6);
  783. }
  784. }
  785. static const u32 rtw8852b_sco_barker_threshold[14] = {
  786. 0x1cfea, 0x1d0e1, 0x1d1d7, 0x1d2cd, 0x1d3c3, 0x1d4b9, 0x1d5b0, 0x1d6a6,
  787. 0x1d79c, 0x1d892, 0x1d988, 0x1da7f, 0x1db75, 0x1ddc4
  788. };
  789. static const u32 rtw8852b_sco_cck_threshold[14] = {
  790. 0x27de3, 0x27f35, 0x28088, 0x281da, 0x2832d, 0x2847f, 0x285d2, 0x28724,
  791. 0x28877, 0x289c9, 0x28b1c, 0x28c6e, 0x28dc1, 0x290ed
  792. };
  793. static void rtw8852b_ctrl_sco_cck(struct rtw89_dev *rtwdev, u8 primary_ch)
  794. {
  795. u8 ch_element = primary_ch - 1;
  796. rtw89_phy_write32_mask(rtwdev, R_RXSCOBC, B_RXSCOBC_TH,
  797. rtw8852b_sco_barker_threshold[ch_element]);
  798. rtw89_phy_write32_mask(rtwdev, R_RXSCOCCK, B_RXSCOCCK_TH,
  799. rtw8852b_sco_cck_threshold[ch_element]);
  800. }
  801. static u8 rtw8852b_sco_mapping(u8 central_ch)
  802. {
  803. if (central_ch == 1)
  804. return 109;
  805. else if (central_ch >= 2 && central_ch <= 6)
  806. return 108;
  807. else if (central_ch >= 7 && central_ch <= 10)
  808. return 107;
  809. else if (central_ch >= 11 && central_ch <= 14)
  810. return 106;
  811. else if (central_ch == 36 || central_ch == 38)
  812. return 51;
  813. else if (central_ch >= 40 && central_ch <= 58)
  814. return 50;
  815. else if (central_ch >= 60 && central_ch <= 64)
  816. return 49;
  817. else if (central_ch == 100 || central_ch == 102)
  818. return 48;
  819. else if (central_ch >= 104 && central_ch <= 126)
  820. return 47;
  821. else if (central_ch >= 128 && central_ch <= 151)
  822. return 46;
  823. else if (central_ch >= 153 && central_ch <= 177)
  824. return 45;
  825. else
  826. return 0;
  827. }
  828. struct rtw8852b_bb_gain {
  829. u32 gain_g[BB_PATH_NUM_8852B];
  830. u32 gain_a[BB_PATH_NUM_8852B];
  831. u32 gain_mask;
  832. };
  833. static const struct rtw8852b_bb_gain bb_gain_lna[LNA_GAIN_NUM] = {
  834. { .gain_g = {0x4678, 0x475C}, .gain_a = {0x45DC, 0x4740},
  835. .gain_mask = 0x00ff0000 },
  836. { .gain_g = {0x4678, 0x475C}, .gain_a = {0x45DC, 0x4740},
  837. .gain_mask = 0xff000000 },
  838. { .gain_g = {0x467C, 0x4760}, .gain_a = {0x4660, 0x4744},
  839. .gain_mask = 0x000000ff },
  840. { .gain_g = {0x467C, 0x4760}, .gain_a = {0x4660, 0x4744},
  841. .gain_mask = 0x0000ff00 },
  842. { .gain_g = {0x467C, 0x4760}, .gain_a = {0x4660, 0x4744},
  843. .gain_mask = 0x00ff0000 },
  844. { .gain_g = {0x467C, 0x4760}, .gain_a = {0x4660, 0x4744},
  845. .gain_mask = 0xff000000 },
  846. { .gain_g = {0x4680, 0x4764}, .gain_a = {0x4664, 0x4748},
  847. .gain_mask = 0x000000ff },
  848. };
  849. static const struct rtw8852b_bb_gain bb_gain_tia[TIA_GAIN_NUM] = {
  850. { .gain_g = {0x4680, 0x4764}, .gain_a = {0x4664, 0x4748},
  851. .gain_mask = 0x00ff0000 },
  852. { .gain_g = {0x4680, 0x4764}, .gain_a = {0x4664, 0x4748},
  853. .gain_mask = 0xff000000 },
  854. };
  855. static void rtw8852b_set_gain_error(struct rtw89_dev *rtwdev,
  856. enum rtw89_subband subband,
  857. enum rtw89_rf_path path)
  858. {
  859. const struct rtw89_phy_bb_gain_info *gain = &rtwdev->bb_gain;
  860. u8 gain_band = rtw89_subband_to_bb_gain_band(subband);
  861. s32 val;
  862. u32 reg;
  863. u32 mask;
  864. int i;
  865. for (i = 0; i < LNA_GAIN_NUM; i++) {
  866. if (subband == RTW89_CH_2G)
  867. reg = bb_gain_lna[i].gain_g[path];
  868. else
  869. reg = bb_gain_lna[i].gain_a[path];
  870. mask = bb_gain_lna[i].gain_mask;
  871. val = gain->lna_gain[gain_band][path][i];
  872. rtw89_phy_write32_mask(rtwdev, reg, mask, val);
  873. }
  874. for (i = 0; i < TIA_GAIN_NUM; i++) {
  875. if (subband == RTW89_CH_2G)
  876. reg = bb_gain_tia[i].gain_g[path];
  877. else
  878. reg = bb_gain_tia[i].gain_a[path];
  879. mask = bb_gain_tia[i].gain_mask;
  880. val = gain->tia_gain[gain_band][path][i];
  881. rtw89_phy_write32_mask(rtwdev, reg, mask, val);
  882. }
  883. }
  884. static void rtw8852b_set_gain_offset(struct rtw89_dev *rtwdev,
  885. enum rtw89_subband subband,
  886. enum rtw89_phy_idx phy_idx)
  887. {
  888. static const u32 gain_err_addr[2] = {R_P0_AGC_RSVD, R_P1_AGC_RSVD};
  889. static const u32 rssi_ofst_addr[2] = {R_PATH0_G_TIA1_LNA6_OP1DB_V1,
  890. R_PATH1_G_TIA1_LNA6_OP1DB_V1};
  891. struct rtw89_hal *hal = &rtwdev->hal;
  892. struct rtw89_phy_efuse_gain *efuse_gain = &rtwdev->efuse_gain;
  893. enum rtw89_gain_offset gain_ofdm_band;
  894. s32 offset_a, offset_b;
  895. s32 offset_ofdm, offset_cck;
  896. s32 tmp;
  897. u8 path;
  898. if (!efuse_gain->comp_valid)
  899. goto next;
  900. for (path = RF_PATH_A; path < BB_PATH_NUM_8852B; path++) {
  901. tmp = efuse_gain->comp[path][subband];
  902. tmp = clamp_t(s32, tmp << 2, S8_MIN, S8_MAX);
  903. rtw89_phy_write32_mask(rtwdev, gain_err_addr[path], MASKBYTE0, tmp);
  904. }
  905. next:
  906. if (!efuse_gain->offset_valid)
  907. return;
  908. gain_ofdm_band = rtw89_subband_to_gain_offset_band_of_ofdm(subband);
  909. offset_a = -efuse_gain->offset[RF_PATH_A][gain_ofdm_band];
  910. offset_b = -efuse_gain->offset[RF_PATH_B][gain_ofdm_band];
  911. tmp = -((offset_a << 2) + (efuse_gain->offset_base[RTW89_PHY_0] >> 2));
  912. tmp = clamp_t(s32, tmp, S8_MIN, S8_MAX);
  913. rtw89_phy_write32_mask(rtwdev, rssi_ofst_addr[RF_PATH_A], B_PATH0_R_G_OFST_MASK, tmp);
  914. tmp = -((offset_b << 2) + (efuse_gain->offset_base[RTW89_PHY_0] >> 2));
  915. tmp = clamp_t(s32, tmp, S8_MIN, S8_MAX);
  916. rtw89_phy_write32_mask(rtwdev, rssi_ofst_addr[RF_PATH_B], B_PATH0_R_G_OFST_MASK, tmp);
  917. if (hal->antenna_rx == RF_B) {
  918. offset_ofdm = -efuse_gain->offset[RF_PATH_B][gain_ofdm_band];
  919. offset_cck = -efuse_gain->offset[RF_PATH_B][0];
  920. } else {
  921. offset_ofdm = -efuse_gain->offset[RF_PATH_A][gain_ofdm_band];
  922. offset_cck = -efuse_gain->offset[RF_PATH_A][0];
  923. }
  924. tmp = (offset_ofdm << 4) + efuse_gain->offset_base[RTW89_PHY_0];
  925. tmp = clamp_t(s32, tmp, S8_MIN, S8_MAX);
  926. rtw89_phy_write32_idx(rtwdev, R_P0_RPL1, B_P0_RPL1_BIAS_MASK, tmp, phy_idx);
  927. tmp = (offset_ofdm << 4) + efuse_gain->rssi_base[RTW89_PHY_0];
  928. tmp = clamp_t(s32, tmp, S8_MIN, S8_MAX);
  929. rtw89_phy_write32_idx(rtwdev, R_P1_RPL1, B_P0_RPL1_BIAS_MASK, tmp, phy_idx);
  930. if (subband == RTW89_CH_2G) {
  931. tmp = (offset_cck << 3) + (efuse_gain->offset_base[RTW89_PHY_0] >> 1);
  932. tmp = clamp_t(s32, tmp, S8_MIN >> 1, S8_MAX >> 1);
  933. rtw89_phy_write32_mask(rtwdev, R_RX_RPL_OFST,
  934. B_RX_RPL_OFST_CCK_MASK, tmp);
  935. }
  936. }
  937. static
  938. void rtw8852b_set_rxsc_rpl_comp(struct rtw89_dev *rtwdev, enum rtw89_subband subband)
  939. {
  940. const struct rtw89_phy_bb_gain_info *gain = &rtwdev->bb_gain;
  941. u8 band = rtw89_subband_to_bb_gain_band(subband);
  942. u32 val;
  943. val = FIELD_PREP(B_P0_RPL1_20_MASK, (gain->rpl_ofst_20[band][RF_PATH_A] +
  944. gain->rpl_ofst_20[band][RF_PATH_B]) / 2) |
  945. FIELD_PREP(B_P0_RPL1_40_MASK, (gain->rpl_ofst_40[band][RF_PATH_A][0] +
  946. gain->rpl_ofst_40[band][RF_PATH_B][0]) / 2) |
  947. FIELD_PREP(B_P0_RPL1_41_MASK, (gain->rpl_ofst_40[band][RF_PATH_A][1] +
  948. gain->rpl_ofst_40[band][RF_PATH_B][1]) / 2);
  949. val >>= B_P0_RPL1_SHIFT;
  950. rtw89_phy_write32_mask(rtwdev, R_P0_RPL1, B_P0_RPL1_MASK, val);
  951. rtw89_phy_write32_mask(rtwdev, R_P1_RPL1, B_P0_RPL1_MASK, val);
  952. val = FIELD_PREP(B_P0_RTL2_42_MASK, (gain->rpl_ofst_40[band][RF_PATH_A][2] +
  953. gain->rpl_ofst_40[band][RF_PATH_B][2]) / 2) |
  954. FIELD_PREP(B_P0_RTL2_80_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][0] +
  955. gain->rpl_ofst_80[band][RF_PATH_B][0]) / 2) |
  956. FIELD_PREP(B_P0_RTL2_81_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][1] +
  957. gain->rpl_ofst_80[band][RF_PATH_B][1]) / 2) |
  958. FIELD_PREP(B_P0_RTL2_8A_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][10] +
  959. gain->rpl_ofst_80[band][RF_PATH_B][10]) / 2);
  960. rtw89_phy_write32(rtwdev, R_P0_RPL2, val);
  961. rtw89_phy_write32(rtwdev, R_P1_RPL2, val);
  962. val = FIELD_PREP(B_P0_RTL3_82_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][2] +
  963. gain->rpl_ofst_80[band][RF_PATH_B][2]) / 2) |
  964. FIELD_PREP(B_P0_RTL3_83_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][3] +
  965. gain->rpl_ofst_80[band][RF_PATH_B][3]) / 2) |
  966. FIELD_PREP(B_P0_RTL3_84_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][4] +
  967. gain->rpl_ofst_80[band][RF_PATH_B][4]) / 2) |
  968. FIELD_PREP(B_P0_RTL3_89_MASK, (gain->rpl_ofst_80[band][RF_PATH_A][9] +
  969. gain->rpl_ofst_80[band][RF_PATH_B][9]) / 2);
  970. rtw89_phy_write32(rtwdev, R_P0_RPL3, val);
  971. rtw89_phy_write32(rtwdev, R_P1_RPL3, val);
  972. }
  973. static void rtw8852b_ctrl_ch(struct rtw89_dev *rtwdev,
  974. const struct rtw89_chan *chan,
  975. enum rtw89_phy_idx phy_idx)
  976. {
  977. u8 central_ch = chan->channel;
  978. u8 subband = chan->subband_type;
  979. u8 sco_comp;
  980. bool is_2g = central_ch <= 14;
  981. /* Path A */
  982. if (is_2g)
  983. rtw89_phy_write32_idx(rtwdev, R_PATH0_BAND_SEL_V1,
  984. B_PATH0_BAND_SEL_MSK_V1, 1, phy_idx);
  985. else
  986. rtw89_phy_write32_idx(rtwdev, R_PATH0_BAND_SEL_V1,
  987. B_PATH0_BAND_SEL_MSK_V1, 0, phy_idx);
  988. /* Path B */
  989. if (is_2g)
  990. rtw89_phy_write32_idx(rtwdev, R_PATH1_BAND_SEL_V1,
  991. B_PATH1_BAND_SEL_MSK_V1, 1, phy_idx);
  992. else
  993. rtw89_phy_write32_idx(rtwdev, R_PATH1_BAND_SEL_V1,
  994. B_PATH1_BAND_SEL_MSK_V1, 0, phy_idx);
  995. /* SCO compensate FC setting */
  996. sco_comp = rtw8852b_sco_mapping(central_ch);
  997. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_INV, sco_comp, phy_idx);
  998. if (chan->band_type == RTW89_BAND_6G)
  999. return;
  1000. /* CCK parameters */
  1001. if (central_ch == 14) {
  1002. rtw89_phy_write32_mask(rtwdev, R_TXFIR0, B_TXFIR_C01, 0x3b13ff);
  1003. rtw89_phy_write32_mask(rtwdev, R_TXFIR2, B_TXFIR_C23, 0x1c42de);
  1004. rtw89_phy_write32_mask(rtwdev, R_TXFIR4, B_TXFIR_C45, 0xfdb0ad);
  1005. rtw89_phy_write32_mask(rtwdev, R_TXFIR6, B_TXFIR_C67, 0xf60f6e);
  1006. rtw89_phy_write32_mask(rtwdev, R_TXFIR8, B_TXFIR_C89, 0xfd8f92);
  1007. rtw89_phy_write32_mask(rtwdev, R_TXFIRA, B_TXFIR_CAB, 0x2d011);
  1008. rtw89_phy_write32_mask(rtwdev, R_TXFIRC, B_TXFIR_CCD, 0x1c02c);
  1009. rtw89_phy_write32_mask(rtwdev, R_TXFIRE, B_TXFIR_CEF, 0xfff00a);
  1010. } else {
  1011. rtw89_phy_write32_mask(rtwdev, R_TXFIR0, B_TXFIR_C01, 0x3d23ff);
  1012. rtw89_phy_write32_mask(rtwdev, R_TXFIR2, B_TXFIR_C23, 0x29b354);
  1013. rtw89_phy_write32_mask(rtwdev, R_TXFIR4, B_TXFIR_C45, 0xfc1c8);
  1014. rtw89_phy_write32_mask(rtwdev, R_TXFIR6, B_TXFIR_C67, 0xfdb053);
  1015. rtw89_phy_write32_mask(rtwdev, R_TXFIR8, B_TXFIR_C89, 0xf86f9a);
  1016. rtw89_phy_write32_mask(rtwdev, R_TXFIRA, B_TXFIR_CAB, 0xfaef92);
  1017. rtw89_phy_write32_mask(rtwdev, R_TXFIRC, B_TXFIR_CCD, 0xfe5fcc);
  1018. rtw89_phy_write32_mask(rtwdev, R_TXFIRE, B_TXFIR_CEF, 0xffdff5);
  1019. }
  1020. rtw8852b_set_gain_error(rtwdev, subband, RF_PATH_A);
  1021. rtw8852b_set_gain_error(rtwdev, subband, RF_PATH_B);
  1022. rtw8852b_set_gain_offset(rtwdev, subband, phy_idx);
  1023. rtw8852b_set_rxsc_rpl_comp(rtwdev, subband);
  1024. }
  1025. static void rtw8852b_bw_setting(struct rtw89_dev *rtwdev, u8 bw, u8 path)
  1026. {
  1027. static const u32 adc_sel[2] = {0xC0EC, 0xC1EC};
  1028. static const u32 wbadc_sel[2] = {0xC0E4, 0xC1E4};
  1029. switch (bw) {
  1030. case RTW89_CHANNEL_WIDTH_5:
  1031. rtw89_phy_write32_mask(rtwdev, adc_sel[path], 0x6000, 0x1);
  1032. rtw89_phy_write32_mask(rtwdev, wbadc_sel[path], 0x30, 0x0);
  1033. break;
  1034. case RTW89_CHANNEL_WIDTH_10:
  1035. rtw89_phy_write32_mask(rtwdev, adc_sel[path], 0x6000, 0x2);
  1036. rtw89_phy_write32_mask(rtwdev, wbadc_sel[path], 0x30, 0x1);
  1037. break;
  1038. case RTW89_CHANNEL_WIDTH_20:
  1039. rtw89_phy_write32_mask(rtwdev, adc_sel[path], 0x6000, 0x0);
  1040. rtw89_phy_write32_mask(rtwdev, wbadc_sel[path], 0x30, 0x2);
  1041. break;
  1042. case RTW89_CHANNEL_WIDTH_40:
  1043. rtw89_phy_write32_mask(rtwdev, adc_sel[path], 0x6000, 0x0);
  1044. rtw89_phy_write32_mask(rtwdev, wbadc_sel[path], 0x30, 0x2);
  1045. break;
  1046. case RTW89_CHANNEL_WIDTH_80:
  1047. rtw89_phy_write32_mask(rtwdev, adc_sel[path], 0x6000, 0x0);
  1048. rtw89_phy_write32_mask(rtwdev, wbadc_sel[path], 0x30, 0x2);
  1049. break;
  1050. default:
  1051. rtw89_warn(rtwdev, "Fail to set ADC\n");
  1052. }
  1053. }
  1054. static void rtw8852b_ctrl_bw(struct rtw89_dev *rtwdev, u8 pri_ch, u8 bw,
  1055. enum rtw89_phy_idx phy_idx)
  1056. {
  1057. u32 rx_path_0;
  1058. switch (bw) {
  1059. case RTW89_CHANNEL_WIDTH_5:
  1060. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_SET, 0x0, phy_idx);
  1061. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_SBW, 0x1, phy_idx);
  1062. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_PRICH, 0x0, phy_idx);
  1063. /*Set RF mode at 3 */
  1064. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1065. B_P0_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1066. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1067. B_P1_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1068. break;
  1069. case RTW89_CHANNEL_WIDTH_10:
  1070. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_SET, 0x0, phy_idx);
  1071. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_SBW, 0x2, phy_idx);
  1072. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_PRICH, 0x0, phy_idx);
  1073. /*Set RF mode at 3 */
  1074. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1075. B_P0_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1076. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1077. B_P1_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1078. break;
  1079. case RTW89_CHANNEL_WIDTH_20:
  1080. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_SET, 0x0, phy_idx);
  1081. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_SBW, 0x0, phy_idx);
  1082. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_PRICH, 0x0, phy_idx);
  1083. /*Set RF mode at 3 */
  1084. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1085. B_P0_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1086. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1087. B_P1_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1088. break;
  1089. case RTW89_CHANNEL_WIDTH_40:
  1090. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_SET, 0x1, phy_idx);
  1091. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_SBW, 0x0, phy_idx);
  1092. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_PRICH,
  1093. pri_ch, phy_idx);
  1094. /*Set RF mode at 3 */
  1095. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1096. B_P0_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1097. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1098. B_P1_RFMODE_ORI_RX_ALL, 0x333, phy_idx);
  1099. /*CCK primary channel */
  1100. if (pri_ch == RTW89_SC_20_UPPER)
  1101. rtw89_phy_write32_mask(rtwdev, R_RXSC, B_RXSC_EN, 1);
  1102. else
  1103. rtw89_phy_write32_mask(rtwdev, R_RXSC, B_RXSC_EN, 0);
  1104. break;
  1105. case RTW89_CHANNEL_WIDTH_80:
  1106. rtw89_phy_write32_idx(rtwdev, R_FC0_BW_V1, B_FC0_BW_SET, 0x2, phy_idx);
  1107. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_SBW, 0x0, phy_idx);
  1108. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_CHBW_MOD_PRICH,
  1109. pri_ch, phy_idx);
  1110. /*Set RF mode at A */
  1111. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1112. B_P0_RFMODE_ORI_RX_ALL, 0xaaa, phy_idx);
  1113. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1114. B_P1_RFMODE_ORI_RX_ALL, 0xaaa, phy_idx);
  1115. break;
  1116. default:
  1117. rtw89_warn(rtwdev, "Fail to switch bw (bw:%d, pri ch:%d)\n", bw,
  1118. pri_ch);
  1119. }
  1120. rtw8852b_bw_setting(rtwdev, bw, RF_PATH_A);
  1121. rtw8852b_bw_setting(rtwdev, bw, RF_PATH_B);
  1122. rx_path_0 = rtw89_phy_read32_idx(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0,
  1123. phy_idx);
  1124. if (rx_path_0 == 0x1)
  1125. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_ORI_RX,
  1126. B_P1_RFMODE_ORI_RX_ALL, 0x111, phy_idx);
  1127. else if (rx_path_0 == 0x2)
  1128. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_ORI_RX,
  1129. B_P0_RFMODE_ORI_RX_ALL, 0x111, phy_idx);
  1130. }
  1131. static void rtw8852b_ctrl_cck_en(struct rtw89_dev *rtwdev, bool cck_en)
  1132. {
  1133. if (cck_en) {
  1134. rtw89_phy_write32_mask(rtwdev, R_UPD_CLK_ADC, B_ENABLE_CCK, 1);
  1135. rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 0);
  1136. } else {
  1137. rtw89_phy_write32_mask(rtwdev, R_UPD_CLK_ADC, B_ENABLE_CCK, 0);
  1138. rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 1);
  1139. }
  1140. }
  1141. static void rtw8852b_5m_mask(struct rtw89_dev *rtwdev, const struct rtw89_chan *chan,
  1142. enum rtw89_phy_idx phy_idx)
  1143. {
  1144. u8 pri_ch = chan->pri_ch_idx;
  1145. bool mask_5m_low;
  1146. bool mask_5m_en;
  1147. switch (chan->band_width) {
  1148. case RTW89_CHANNEL_WIDTH_40:
  1149. /* Prich=1: Mask 5M High, Prich=2: Mask 5M Low */
  1150. mask_5m_en = true;
  1151. mask_5m_low = pri_ch == RTW89_SC_20_LOWER;
  1152. break;
  1153. case RTW89_CHANNEL_WIDTH_80:
  1154. /* Prich=3: Mask 5M High, Prich=4: Mask 5M Low, Else: Disable */
  1155. mask_5m_en = pri_ch == RTW89_SC_20_UPMOST ||
  1156. pri_ch == RTW89_SC_20_LOWEST;
  1157. mask_5m_low = pri_ch == RTW89_SC_20_LOWEST;
  1158. break;
  1159. default:
  1160. mask_5m_en = false;
  1161. break;
  1162. }
  1163. if (!mask_5m_en) {
  1164. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_EN, 0x0);
  1165. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_EN, 0x0);
  1166. rtw89_phy_write32_idx(rtwdev, R_ASSIGN_SBD_OPT_V1,
  1167. B_ASSIGN_SBD_OPT_EN_V1, 0x0, phy_idx);
  1168. return;
  1169. }
  1170. if (mask_5m_low) {
  1171. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_TH, 0x4);
  1172. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_EN, 0x1);
  1173. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_SB2, 0x0);
  1174. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_SB0, 0x1);
  1175. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_TH, 0x4);
  1176. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_EN, 0x1);
  1177. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_SB2, 0x0);
  1178. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_SB0, 0x1);
  1179. } else {
  1180. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_TH, 0x4);
  1181. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_EN, 0x1);
  1182. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_SB2, 0x1);
  1183. rtw89_phy_write32_mask(rtwdev, R_PATH0_5MDET_V1, B_PATH0_5MDET_SB0, 0x0);
  1184. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_TH, 0x4);
  1185. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_EN, 0x1);
  1186. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_SB2, 0x1);
  1187. rtw89_phy_write32_mask(rtwdev, R_PATH1_5MDET_V1, B_PATH1_5MDET_SB0, 0x0);
  1188. }
  1189. rtw89_phy_write32_idx(rtwdev, R_ASSIGN_SBD_OPT_V1,
  1190. B_ASSIGN_SBD_OPT_EN_V1, 0x1, phy_idx);
  1191. }
  1192. static void rtw8852b_bb_reset_all(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
  1193. {
  1194. rtw89_phy_write32_idx(rtwdev, R_S0_HW_SI_DIS, B_S0_HW_SI_DIS_W_R_TRIG, 0x7, phy_idx);
  1195. rtw89_phy_write32_idx(rtwdev, R_S1_HW_SI_DIS, B_S1_HW_SI_DIS_W_R_TRIG, 0x7, phy_idx);
  1196. fsleep(1);
  1197. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 1, phy_idx);
  1198. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 0, phy_idx);
  1199. rtw89_phy_write32_idx(rtwdev, R_S0_HW_SI_DIS, B_S0_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);
  1200. rtw89_phy_write32_idx(rtwdev, R_S1_HW_SI_DIS, B_S1_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);
  1201. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 1, phy_idx);
  1202. }
  1203. static void rtw8852b_bb_reset_en(struct rtw89_dev *rtwdev, enum rtw89_band band,
  1204. enum rtw89_phy_idx phy_idx, bool en)
  1205. {
  1206. if (en) {
  1207. rtw89_phy_write32_idx(rtwdev, R_S0_HW_SI_DIS,
  1208. B_S0_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);
  1209. rtw89_phy_write32_idx(rtwdev, R_S1_HW_SI_DIS,
  1210. B_S1_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);
  1211. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 1, phy_idx);
  1212. if (band == RTW89_BAND_2G)
  1213. rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 0x0);
  1214. rtw89_phy_write32_mask(rtwdev, R_PD_CTRL, B_PD_HIT_DIS, 0x0);
  1215. } else {
  1216. rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 0x1);
  1217. rtw89_phy_write32_mask(rtwdev, R_PD_CTRL, B_PD_HIT_DIS, 0x1);
  1218. rtw89_phy_write32_idx(rtwdev, R_S0_HW_SI_DIS,
  1219. B_S0_HW_SI_DIS_W_R_TRIG, 0x7, phy_idx);
  1220. rtw89_phy_write32_idx(rtwdev, R_S1_HW_SI_DIS,
  1221. B_S1_HW_SI_DIS_W_R_TRIG, 0x7, phy_idx);
  1222. fsleep(1);
  1223. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 0, phy_idx);
  1224. }
  1225. }
  1226. static void rtw8852b_bb_reset(struct rtw89_dev *rtwdev,
  1227. enum rtw89_phy_idx phy_idx)
  1228. {
  1229. rtw89_phy_write32_set(rtwdev, R_P0_TXPW_RSTB, B_P0_TXPW_RSTB_MANON);
  1230. rtw89_phy_write32_set(rtwdev, R_P0_TSSI_TRK, B_P0_TSSI_TRK_EN);
  1231. rtw89_phy_write32_set(rtwdev, R_P1_TXPW_RSTB, B_P1_TXPW_RSTB_MANON);
  1232. rtw89_phy_write32_set(rtwdev, R_P1_TSSI_TRK, B_P1_TSSI_TRK_EN);
  1233. rtw8852b_bb_reset_all(rtwdev, phy_idx);
  1234. rtw89_phy_write32_clr(rtwdev, R_P0_TXPW_RSTB, B_P0_TXPW_RSTB_MANON);
  1235. rtw89_phy_write32_clr(rtwdev, R_P0_TSSI_TRK, B_P0_TSSI_TRK_EN);
  1236. rtw89_phy_write32_clr(rtwdev, R_P1_TXPW_RSTB, B_P1_TXPW_RSTB_MANON);
  1237. rtw89_phy_write32_clr(rtwdev, R_P1_TSSI_TRK, B_P1_TSSI_TRK_EN);
  1238. }
  1239. static void rtw8852b_bb_macid_ctrl_init(struct rtw89_dev *rtwdev,
  1240. enum rtw89_phy_idx phy_idx)
  1241. {
  1242. u32 addr;
  1243. for (addr = R_AX_PWR_MACID_LMT_TABLE0;
  1244. addr <= R_AX_PWR_MACID_LMT_TABLE127; addr += 4)
  1245. rtw89_mac_txpwr_write32(rtwdev, phy_idx, addr, 0);
  1246. }
  1247. static void rtw8852b_bb_sethw(struct rtw89_dev *rtwdev)
  1248. {
  1249. struct rtw89_phy_efuse_gain *gain = &rtwdev->efuse_gain;
  1250. rtw89_phy_write32_clr(rtwdev, R_P0_EN_SOUND_WO_NDP, B_P0_EN_SOUND_WO_NDP);
  1251. rtw89_phy_write32_clr(rtwdev, R_P1_EN_SOUND_WO_NDP, B_P1_EN_SOUND_WO_NDP);
  1252. rtw8852b_bb_macid_ctrl_init(rtwdev, RTW89_PHY_0);
  1253. /* read these registers after loading BB parameters */
  1254. gain->offset_base[RTW89_PHY_0] =
  1255. rtw89_phy_read32_mask(rtwdev, R_P0_RPL1, B_P0_RPL1_BIAS_MASK);
  1256. gain->rssi_base[RTW89_PHY_0] =
  1257. rtw89_phy_read32_mask(rtwdev, R_P1_RPL1, B_P0_RPL1_BIAS_MASK);
  1258. }
  1259. static void rtw8852b_bb_set_pop(struct rtw89_dev *rtwdev)
  1260. {
  1261. if (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR)
  1262. rtw89_phy_write32_clr(rtwdev, R_PKT_CTRL, B_PKT_POP_EN);
  1263. }
  1264. static void rtw8852b_set_channel_bb(struct rtw89_dev *rtwdev, const struct rtw89_chan *chan,
  1265. enum rtw89_phy_idx phy_idx)
  1266. {
  1267. bool cck_en = chan->channel <= 14;
  1268. u8 pri_ch_idx = chan->pri_ch_idx;
  1269. u8 band = chan->band_type, chan_idx;
  1270. if (cck_en)
  1271. rtw8852b_ctrl_sco_cck(rtwdev, chan->primary_channel);
  1272. rtw8852b_ctrl_ch(rtwdev, chan, phy_idx);
  1273. rtw8852b_ctrl_bw(rtwdev, pri_ch_idx, chan->band_width, phy_idx);
  1274. rtw8852b_ctrl_cck_en(rtwdev, cck_en);
  1275. if (chan->band_type == RTW89_BAND_5G) {
  1276. rtw89_phy_write32_mask(rtwdev, R_PATH0_BT_SHARE_V1,
  1277. B_PATH0_BT_SHARE_V1, 0x0);
  1278. rtw89_phy_write32_mask(rtwdev, R_PATH0_BTG_PATH_V1,
  1279. B_PATH0_BTG_PATH_V1, 0x0);
  1280. rtw89_phy_write32_mask(rtwdev, R_PATH1_BT_SHARE_V1,
  1281. B_PATH1_BT_SHARE_V1, 0x0);
  1282. rtw89_phy_write32_mask(rtwdev, R_PATH1_BTG_PATH_V1,
  1283. B_PATH1_BTG_PATH_V1, 0x0);
  1284. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_BT_SHARE, 0x0);
  1285. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_BT_SEG0, 0x0);
  1286. rtw89_phy_write32_mask(rtwdev, R_BT_DYN_DC_EST_EN_V1,
  1287. B_BT_DYN_DC_EST_EN_MSK, 0x0);
  1288. rtw89_phy_write32_mask(rtwdev, R_GNT_BT_WGT_EN, B_GNT_BT_WGT_EN, 0x0);
  1289. }
  1290. chan_idx = rtw89_encode_chan_idx(rtwdev, chan->primary_channel, band);
  1291. rtw89_phy_write32_mask(rtwdev, R_MAC_PIN_SEL, B_CH_IDX_SEG0, chan_idx);
  1292. rtw8852b_5m_mask(rtwdev, chan, phy_idx);
  1293. rtw8852b_bb_set_pop(rtwdev);
  1294. rtw8852b_bb_reset_all(rtwdev, phy_idx);
  1295. }
  1296. static void rtw8852b_set_channel(struct rtw89_dev *rtwdev,
  1297. const struct rtw89_chan *chan,
  1298. enum rtw89_mac_idx mac_idx,
  1299. enum rtw89_phy_idx phy_idx)
  1300. {
  1301. rtw8852b_set_channel_mac(rtwdev, chan, mac_idx);
  1302. rtw8852b_set_channel_bb(rtwdev, chan, phy_idx);
  1303. rtw8852b_set_channel_rf(rtwdev, chan, phy_idx);
  1304. }
  1305. static void rtw8852b_tssi_cont_en(struct rtw89_dev *rtwdev, bool en,
  1306. enum rtw89_rf_path path)
  1307. {
  1308. static const u32 tssi_trk[2] = {R_P0_TSSI_TRK, R_P1_TSSI_TRK};
  1309. static const u32 ctrl_bbrst[2] = {R_P0_TXPW_RSTB, R_P1_TXPW_RSTB};
  1310. if (en) {
  1311. rtw89_phy_write32_mask(rtwdev, ctrl_bbrst[path], B_P0_TXPW_RSTB_MANON, 0x0);
  1312. rtw89_phy_write32_mask(rtwdev, tssi_trk[path], B_P0_TSSI_TRK_EN, 0x0);
  1313. } else {
  1314. rtw89_phy_write32_mask(rtwdev, ctrl_bbrst[path], B_P0_TXPW_RSTB_MANON, 0x1);
  1315. rtw89_phy_write32_mask(rtwdev, tssi_trk[path], B_P0_TSSI_TRK_EN, 0x1);
  1316. }
  1317. }
  1318. static void rtw8852b_tssi_cont_en_phyidx(struct rtw89_dev *rtwdev, bool en,
  1319. u8 phy_idx)
  1320. {
  1321. if (!rtwdev->dbcc_en) {
  1322. rtw8852b_tssi_cont_en(rtwdev, en, RF_PATH_A);
  1323. rtw8852b_tssi_cont_en(rtwdev, en, RF_PATH_B);
  1324. } else {
  1325. if (phy_idx == RTW89_PHY_0)
  1326. rtw8852b_tssi_cont_en(rtwdev, en, RF_PATH_A);
  1327. else
  1328. rtw8852b_tssi_cont_en(rtwdev, en, RF_PATH_B);
  1329. }
  1330. }
  1331. static void rtw8852b_adc_en(struct rtw89_dev *rtwdev, bool en)
  1332. {
  1333. if (en)
  1334. rtw89_phy_write32_mask(rtwdev, R_ADC_FIFO, B_ADC_FIFO_RST, 0x0);
  1335. else
  1336. rtw89_phy_write32_mask(rtwdev, R_ADC_FIFO, B_ADC_FIFO_RST, 0xf);
  1337. }
  1338. static void rtw8852b_set_channel_help(struct rtw89_dev *rtwdev, bool enter,
  1339. struct rtw89_channel_help_params *p,
  1340. const struct rtw89_chan *chan,
  1341. enum rtw89_mac_idx mac_idx,
  1342. enum rtw89_phy_idx phy_idx)
  1343. {
  1344. if (enter) {
  1345. rtw89_chip_stop_sch_tx(rtwdev, RTW89_MAC_0, &p->tx_en, RTW89_SCH_TX_SEL_ALL);
  1346. rtw89_mac_cfg_ppdu_status(rtwdev, RTW89_MAC_0, false);
  1347. rtw8852b_tssi_cont_en_phyidx(rtwdev, false, RTW89_PHY_0);
  1348. rtw8852b_adc_en(rtwdev, false);
  1349. fsleep(40);
  1350. rtw8852b_bb_reset_en(rtwdev, chan->band_type, phy_idx, false);
  1351. } else {
  1352. rtw89_mac_cfg_ppdu_status(rtwdev, RTW89_MAC_0, true);
  1353. rtw8852b_adc_en(rtwdev, true);
  1354. rtw8852b_tssi_cont_en_phyidx(rtwdev, true, RTW89_PHY_0);
  1355. rtw8852b_bb_reset_en(rtwdev, chan->band_type, phy_idx, true);
  1356. rtw89_chip_resume_sch_tx(rtwdev, RTW89_MAC_0, p->tx_en);
  1357. }
  1358. }
  1359. static void rtw8852b_rfk_init(struct rtw89_dev *rtwdev)
  1360. {
  1361. rtwdev->is_tssi_mode[RF_PATH_A] = false;
  1362. rtwdev->is_tssi_mode[RF_PATH_B] = false;
  1363. rtw8852b_dpk_init(rtwdev);
  1364. rtw8852b_rck(rtwdev);
  1365. rtw8852b_dack(rtwdev);
  1366. rtw8852b_rx_dck(rtwdev, RTW89_PHY_0);
  1367. }
  1368. static void rtw8852b_rfk_channel(struct rtw89_dev *rtwdev)
  1369. {
  1370. enum rtw89_phy_idx phy_idx = RTW89_PHY_0;
  1371. rtw8852b_rx_dck(rtwdev, phy_idx);
  1372. rtw8852b_iqk(rtwdev, phy_idx);
  1373. rtw8852b_tssi(rtwdev, phy_idx, true);
  1374. rtw8852b_dpk(rtwdev, phy_idx);
  1375. }
  1376. static void rtw8852b_rfk_band_changed(struct rtw89_dev *rtwdev,
  1377. enum rtw89_phy_idx phy_idx)
  1378. {
  1379. rtw8852b_tssi_scan(rtwdev, phy_idx);
  1380. }
  1381. static void rtw8852b_rfk_scan(struct rtw89_dev *rtwdev, bool start)
  1382. {
  1383. rtw8852b_wifi_scan_notify(rtwdev, start, RTW89_PHY_0);
  1384. }
  1385. static void rtw8852b_rfk_track(struct rtw89_dev *rtwdev)
  1386. {
  1387. rtw8852b_dpk_track(rtwdev);
  1388. }
  1389. static u32 rtw8852b_bb_cal_txpwr_ref(struct rtw89_dev *rtwdev,
  1390. enum rtw89_phy_idx phy_idx, s16 ref)
  1391. {
  1392. const u16 tssi_16dbm_cw = 0x12c;
  1393. const u8 base_cw_0db = 0x27;
  1394. const s8 ofst_int = 0;
  1395. s16 pwr_s10_3;
  1396. s16 rf_pwr_cw;
  1397. u16 bb_pwr_cw;
  1398. u32 pwr_cw;
  1399. u32 tssi_ofst_cw;
  1400. pwr_s10_3 = (ref << 1) + (s16)(ofst_int) + (s16)(base_cw_0db << 3);
  1401. bb_pwr_cw = FIELD_GET(GENMASK(2, 0), pwr_s10_3);
  1402. rf_pwr_cw = FIELD_GET(GENMASK(8, 3), pwr_s10_3);
  1403. rf_pwr_cw = clamp_t(s16, rf_pwr_cw, 15, 63);
  1404. pwr_cw = (rf_pwr_cw << 3) | bb_pwr_cw;
  1405. tssi_ofst_cw = (u32)((s16)tssi_16dbm_cw + (ref << 1) - (16 << 3));
  1406. rtw89_debug(rtwdev, RTW89_DBG_TXPWR,
  1407. "[TXPWR] tssi_ofst_cw=%d rf_cw=0x%x bb_cw=0x%x\n",
  1408. tssi_ofst_cw, rf_pwr_cw, bb_pwr_cw);
  1409. return FIELD_PREP(B_DPD_TSSI_CW, tssi_ofst_cw) |
  1410. FIELD_PREP(B_DPD_PWR_CW, pwr_cw) |
  1411. FIELD_PREP(B_DPD_REF, ref);
  1412. }
  1413. static void rtw8852b_set_txpwr_ref(struct rtw89_dev *rtwdev,
  1414. enum rtw89_phy_idx phy_idx)
  1415. {
  1416. static const u32 addr[RF_PATH_NUM_8852B] = {0x5800, 0x7800};
  1417. const u32 mask = B_DPD_TSSI_CW | B_DPD_PWR_CW | B_DPD_REF;
  1418. const u8 ofst_ofdm = 0x4;
  1419. const u8 ofst_cck = 0x8;
  1420. const s16 ref_ofdm = 0;
  1421. const s16 ref_cck = 0;
  1422. u32 val;
  1423. u8 i;
  1424. rtw89_debug(rtwdev, RTW89_DBG_TXPWR, "[TXPWR] set txpwr reference\n");
  1425. rtw89_mac_txpwr_write32_mask(rtwdev, phy_idx, R_AX_PWR_RATE_CTRL,
  1426. B_AX_PWR_REF, 0x0);
  1427. rtw89_debug(rtwdev, RTW89_DBG_TXPWR, "[TXPWR] set bb ofdm txpwr ref\n");
  1428. val = rtw8852b_bb_cal_txpwr_ref(rtwdev, phy_idx, ref_ofdm);
  1429. for (i = 0; i < RF_PATH_NUM_8852B; i++)
  1430. rtw89_phy_write32_idx(rtwdev, addr[i] + ofst_ofdm, mask, val,
  1431. phy_idx);
  1432. rtw89_debug(rtwdev, RTW89_DBG_TXPWR, "[TXPWR] set bb cck txpwr ref\n");
  1433. val = rtw8852b_bb_cal_txpwr_ref(rtwdev, phy_idx, ref_cck);
  1434. for (i = 0; i < RF_PATH_NUM_8852B; i++)
  1435. rtw89_phy_write32_idx(rtwdev, addr[i] + ofst_cck, mask, val,
  1436. phy_idx);
  1437. }
  1438. static void rtw8852b_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev,
  1439. const struct rtw89_chan *chan,
  1440. u8 tx_shape_idx,
  1441. enum rtw89_phy_idx phy_idx)
  1442. {
  1443. #define __DFIR_CFG_ADDR(i) (R_TXFIR0 + ((i) << 2))
  1444. #define __DFIR_CFG_MASK 0xffffffff
  1445. #define __DFIR_CFG_NR 8
  1446. #define __DECL_DFIR_PARAM(_name, _val...) \
  1447. static const u32 param_ ## _name[] = {_val}; \
  1448. static_assert(ARRAY_SIZE(param_ ## _name) == __DFIR_CFG_NR)
  1449. __DECL_DFIR_PARAM(flat,
  1450. 0x023D23FF, 0x0029B354, 0x000FC1C8, 0x00FDB053,
  1451. 0x00F86F9A, 0x06FAEF92, 0x00FE5FCC, 0x00FFDFF5);
  1452. __DECL_DFIR_PARAM(sharp,
  1453. 0x023D83FF, 0x002C636A, 0x0013F204, 0x00008090,
  1454. 0x00F87FB0, 0x06F99F83, 0x00FDBFBA, 0x00003FF5);
  1455. __DECL_DFIR_PARAM(sharp_14,
  1456. 0x023B13FF, 0x001C42DE, 0x00FDB0AD, 0x00F60F6E,
  1457. 0x00FD8F92, 0x0602D011, 0x0001C02C, 0x00FFF00A);
  1458. u8 ch = chan->channel;
  1459. const u32 *param;
  1460. u32 addr;
  1461. int i;
  1462. if (ch > 14) {
  1463. rtw89_warn(rtwdev,
  1464. "set tx shape dfir by unknown ch: %d on 2G\n", ch);
  1465. return;
  1466. }
  1467. if (ch == 14)
  1468. param = param_sharp_14;
  1469. else
  1470. param = tx_shape_idx == 0 ? param_flat : param_sharp;
  1471. for (i = 0; i < __DFIR_CFG_NR; i++) {
  1472. addr = __DFIR_CFG_ADDR(i);
  1473. rtw89_debug(rtwdev, RTW89_DBG_TXPWR,
  1474. "set tx shape dfir: 0x%x: 0x%x\n", addr, param[i]);
  1475. rtw89_phy_write32_idx(rtwdev, addr, __DFIR_CFG_MASK, param[i],
  1476. phy_idx);
  1477. }
  1478. #undef __DECL_DFIR_PARAM
  1479. #undef __DFIR_CFG_NR
  1480. #undef __DFIR_CFG_MASK
  1481. #undef __DECL_CFG_ADDR
  1482. }
  1483. static void rtw8852b_set_tx_shape(struct rtw89_dev *rtwdev,
  1484. const struct rtw89_chan *chan,
  1485. enum rtw89_phy_idx phy_idx)
  1486. {
  1487. const struct rtw89_rfe_parms *rfe_parms = rtwdev->rfe_parms;
  1488. u8 band = chan->band_type;
  1489. u8 regd = rtw89_regd_get(rtwdev, band);
  1490. u8 tx_shape_cck = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_CCK][regd];
  1491. u8 tx_shape_ofdm = (*rfe_parms->tx_shape.lmt)[band][RTW89_RS_OFDM][regd];
  1492. if (band == RTW89_BAND_2G)
  1493. rtw8852b_bb_set_tx_shape_dfir(rtwdev, chan, tx_shape_cck, phy_idx);
  1494. rtw89_phy_write32_mask(rtwdev, R_DCFO_OPT, B_TXSHAPE_TRIANGULAR_CFG,
  1495. tx_shape_ofdm);
  1496. }
  1497. static void rtw8852b_set_txpwr(struct rtw89_dev *rtwdev,
  1498. const struct rtw89_chan *chan,
  1499. enum rtw89_phy_idx phy_idx)
  1500. {
  1501. rtw89_phy_set_txpwr_byrate(rtwdev, chan, phy_idx);
  1502. rtw89_phy_set_txpwr_offset(rtwdev, chan, phy_idx);
  1503. rtw8852b_set_tx_shape(rtwdev, chan, phy_idx);
  1504. rtw89_phy_set_txpwr_limit(rtwdev, chan, phy_idx);
  1505. rtw89_phy_set_txpwr_limit_ru(rtwdev, chan, phy_idx);
  1506. }
  1507. static void rtw8852b_set_txpwr_ctrl(struct rtw89_dev *rtwdev,
  1508. enum rtw89_phy_idx phy_idx)
  1509. {
  1510. rtw8852b_set_txpwr_ref(rtwdev, phy_idx);
  1511. }
  1512. static
  1513. void rtw8852b_set_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
  1514. s8 pw_ofst, enum rtw89_mac_idx mac_idx)
  1515. {
  1516. u32 reg;
  1517. if (pw_ofst < -16 || pw_ofst > 15) {
  1518. rtw89_warn(rtwdev, "[ULTB] Err pwr_offset=%d\n", pw_ofst);
  1519. return;
  1520. }
  1521. reg = rtw89_mac_reg_by_idx(rtwdev, R_AX_PWR_UL_TB_CTRL, mac_idx);
  1522. rtw89_write32_set(rtwdev, reg, B_AX_PWR_UL_TB_CTRL_EN);
  1523. reg = rtw89_mac_reg_by_idx(rtwdev, R_AX_PWR_UL_TB_1T, mac_idx);
  1524. rtw89_write32_mask(rtwdev, reg, B_AX_PWR_UL_TB_1T_MASK, pw_ofst);
  1525. pw_ofst = max_t(s8, pw_ofst - 3, -16);
  1526. reg = rtw89_mac_reg_by_idx(rtwdev, R_AX_PWR_UL_TB_2T, mac_idx);
  1527. rtw89_write32_mask(rtwdev, reg, B_AX_PWR_UL_TB_2T_MASK, pw_ofst);
  1528. }
  1529. static int
  1530. rtw8852b_init_txpwr_unit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
  1531. {
  1532. int ret;
  1533. ret = rtw89_mac_txpwr_write32(rtwdev, phy_idx, R_AX_PWR_UL_CTRL2, 0x07763333);
  1534. if (ret)
  1535. return ret;
  1536. ret = rtw89_mac_txpwr_write32(rtwdev, phy_idx, R_AX_PWR_COEXT_CTRL, 0x01ebf000);
  1537. if (ret)
  1538. return ret;
  1539. ret = rtw89_mac_txpwr_write32(rtwdev, phy_idx, R_AX_PWR_UL_CTRL0, 0x0002f8ff);
  1540. if (ret)
  1541. return ret;
  1542. rtw8852b_set_txpwr_ul_tb_offset(rtwdev, 0, phy_idx == RTW89_PHY_1 ?
  1543. RTW89_MAC_1 : RTW89_MAC_0);
  1544. return 0;
  1545. }
  1546. void rtw8852b_bb_set_plcp_tx(struct rtw89_dev *rtwdev)
  1547. {
  1548. const struct rtw89_reg3_def *def = rtw8852b_pmac_ht20_mcs7_tbl;
  1549. u8 i;
  1550. for (i = 0; i < ARRAY_SIZE(rtw8852b_pmac_ht20_mcs7_tbl); i++, def++)
  1551. rtw89_phy_write32_mask(rtwdev, def->addr, def->mask, def->data);
  1552. }
  1553. static void rtw8852b_stop_pmac_tx(struct rtw89_dev *rtwdev,
  1554. struct rtw8852b_bb_pmac_info *tx_info,
  1555. enum rtw89_phy_idx idx)
  1556. {
  1557. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC Stop Tx");
  1558. if (tx_info->mode == CONT_TX)
  1559. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_PRD, B_PMAC_CTX_EN, 0, idx);
  1560. else if (tx_info->mode == PKTS_TX)
  1561. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_PRD, B_PMAC_PTX_EN, 0, idx);
  1562. }
  1563. static void rtw8852b_start_pmac_tx(struct rtw89_dev *rtwdev,
  1564. struct rtw8852b_bb_pmac_info *tx_info,
  1565. enum rtw89_phy_idx idx)
  1566. {
  1567. enum rtw8852b_pmac_mode mode = tx_info->mode;
  1568. u32 pkt_cnt = tx_info->tx_cnt;
  1569. u16 period = tx_info->period;
  1570. if (mode == CONT_TX && !tx_info->is_cck) {
  1571. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_PRD, B_PMAC_CTX_EN, 1, idx);
  1572. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC CTx Start");
  1573. } else if (mode == PKTS_TX) {
  1574. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_PRD, B_PMAC_PTX_EN, 1, idx);
  1575. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_PRD,
  1576. B_PMAC_TX_PRD_MSK, period, idx);
  1577. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_CNT, B_PMAC_TX_CNT_MSK,
  1578. pkt_cnt, idx);
  1579. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC PTx Start");
  1580. }
  1581. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_CTRL, B_PMAC_TXEN_DIS, 1, idx);
  1582. rtw89_phy_write32_idx(rtwdev, R_PMAC_TX_CTRL, B_PMAC_TXEN_DIS, 0, idx);
  1583. }
  1584. void rtw8852b_bb_set_pmac_tx(struct rtw89_dev *rtwdev,
  1585. struct rtw8852b_bb_pmac_info *tx_info,
  1586. enum rtw89_phy_idx idx)
  1587. {
  1588. const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);
  1589. if (!tx_info->en_pmac_tx) {
  1590. rtw8852b_stop_pmac_tx(rtwdev, tx_info, idx);
  1591. rtw89_phy_write32_idx(rtwdev, R_PD_CTRL, B_PD_HIT_DIS, 0, idx);
  1592. if (chan->band_type == RTW89_BAND_2G)
  1593. rtw89_phy_write32_clr(rtwdev, R_RXCCA, B_RXCCA_DIS);
  1594. return;
  1595. }
  1596. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC Tx Enable");
  1597. rtw89_phy_write32_idx(rtwdev, R_PMAC_GNT, B_PMAC_GNT_TXEN, 1, idx);
  1598. rtw89_phy_write32_idx(rtwdev, R_PMAC_GNT, B_PMAC_GNT_RXEN, 1, idx);
  1599. rtw89_phy_write32_idx(rtwdev, R_PMAC_RX_CFG1, B_PMAC_OPT1_MSK, 0x3f, idx);
  1600. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 0, idx);
  1601. rtw89_phy_write32_idx(rtwdev, R_PD_CTRL, B_PD_HIT_DIS, 1, idx);
  1602. rtw89_phy_write32_set(rtwdev, R_RXCCA, B_RXCCA_DIS);
  1603. rtw89_phy_write32_idx(rtwdev, R_RSTB_ASYNC, B_RSTB_ASYNC_ALL, 1, idx);
  1604. rtw8852b_start_pmac_tx(rtwdev, tx_info, idx);
  1605. }
  1606. void rtw8852b_bb_set_pmac_pkt_tx(struct rtw89_dev *rtwdev, u8 enable,
  1607. u16 tx_cnt, u16 period, u16 tx_time,
  1608. enum rtw89_phy_idx idx)
  1609. {
  1610. struct rtw8852b_bb_pmac_info tx_info = {0};
  1611. tx_info.en_pmac_tx = enable;
  1612. tx_info.is_cck = 0;
  1613. tx_info.mode = PKTS_TX;
  1614. tx_info.tx_cnt = tx_cnt;
  1615. tx_info.period = period;
  1616. tx_info.tx_time = tx_time;
  1617. rtw8852b_bb_set_pmac_tx(rtwdev, &tx_info, idx);
  1618. }
  1619. void rtw8852b_bb_set_power(struct rtw89_dev *rtwdev, s16 pwr_dbm,
  1620. enum rtw89_phy_idx idx)
  1621. {
  1622. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC CFG Tx PWR = %d", pwr_dbm);
  1623. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_PWR_EN, 1, idx);
  1624. rtw89_phy_write32_idx(rtwdev, R_TXPWR, B_TXPWR_MSK, pwr_dbm, idx);
  1625. }
  1626. void rtw8852b_bb_cfg_tx_path(struct rtw89_dev *rtwdev, u8 tx_path)
  1627. {
  1628. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_MOD, 7, RTW89_PHY_0);
  1629. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "PMAC CFG Tx Path = %d", tx_path);
  1630. if (tx_path == RF_PATH_A) {
  1631. rtw89_phy_write32_mask(rtwdev, R_TXPATH_SEL, B_TXPATH_SEL_MSK, 1);
  1632. rtw89_phy_write32_mask(rtwdev, R_TXNSS_MAP, B_TXNSS_MAP_MSK, 0);
  1633. } else if (tx_path == RF_PATH_B) {
  1634. rtw89_phy_write32_mask(rtwdev, R_TXPATH_SEL, B_TXPATH_SEL_MSK, 2);
  1635. rtw89_phy_write32_mask(rtwdev, R_TXNSS_MAP, B_TXNSS_MAP_MSK, 0);
  1636. } else if (tx_path == RF_PATH_AB) {
  1637. rtw89_phy_write32_mask(rtwdev, R_TXPATH_SEL, B_TXPATH_SEL_MSK, 3);
  1638. rtw89_phy_write32_mask(rtwdev, R_TXNSS_MAP, B_TXNSS_MAP_MSK, 4);
  1639. } else {
  1640. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "Error Tx Path");
  1641. }
  1642. }
  1643. void rtw8852b_bb_tx_mode_switch(struct rtw89_dev *rtwdev,
  1644. enum rtw89_phy_idx idx, u8 mode)
  1645. {
  1646. if (mode != 0)
  1647. return;
  1648. rtw89_debug(rtwdev, RTW89_DBG_TSSI, "Tx mode switch");
  1649. rtw89_phy_write32_idx(rtwdev, R_PMAC_GNT, B_PMAC_GNT_TXEN, 0, idx);
  1650. rtw89_phy_write32_idx(rtwdev, R_PMAC_GNT, B_PMAC_GNT_RXEN, 0, idx);
  1651. rtw89_phy_write32_idx(rtwdev, R_PMAC_RX_CFG1, B_PMAC_OPT1_MSK, 0, idx);
  1652. rtw89_phy_write32_idx(rtwdev, R_PMAC_RXMOD, B_PMAC_RXMOD_MSK, 0, idx);
  1653. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_DPD_EN, 0, idx);
  1654. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_MOD, 0, idx);
  1655. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_PWR_EN, 0, idx);
  1656. }
  1657. void rtw8852b_bb_backup_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx idx,
  1658. struct rtw8852b_bb_tssi_bak *bak)
  1659. {
  1660. s32 tmp;
  1661. bak->tx_path = rtw89_phy_read32_idx(rtwdev, R_TXPATH_SEL, B_TXPATH_SEL_MSK, idx);
  1662. bak->rx_path = rtw89_phy_read32_idx(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0, idx);
  1663. bak->p0_rfmode = rtw89_phy_read32_idx(rtwdev, R_P0_RFMODE, MASKDWORD, idx);
  1664. bak->p0_rfmode_ftm = rtw89_phy_read32_idx(rtwdev, R_P0_RFMODE_FTM_RX, MASKDWORD, idx);
  1665. bak->p1_rfmode = rtw89_phy_read32_idx(rtwdev, R_P1_RFMODE, MASKDWORD, idx);
  1666. bak->p1_rfmode_ftm = rtw89_phy_read32_idx(rtwdev, R_P1_RFMODE_FTM_RX, MASKDWORD, idx);
  1667. tmp = rtw89_phy_read32_idx(rtwdev, R_TXPWR, B_TXPWR_MSK, idx);
  1668. bak->tx_pwr = sign_extend32(tmp, 8);
  1669. }
  1670. void rtw8852b_bb_restore_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx idx,
  1671. const struct rtw8852b_bb_tssi_bak *bak)
  1672. {
  1673. rtw89_phy_write32_idx(rtwdev, R_TXPATH_SEL, B_TXPATH_SEL_MSK, bak->tx_path, idx);
  1674. if (bak->tx_path == RF_AB)
  1675. rtw89_phy_write32_mask(rtwdev, R_TXNSS_MAP, B_TXNSS_MAP_MSK, 0x4);
  1676. else
  1677. rtw89_phy_write32_mask(rtwdev, R_TXNSS_MAP, B_TXNSS_MAP_MSK, 0x0);
  1678. rtw89_phy_write32_idx(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0, bak->rx_path, idx);
  1679. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_PWR_EN, 1, idx);
  1680. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE, MASKDWORD, bak->p0_rfmode, idx);
  1681. rtw89_phy_write32_idx(rtwdev, R_P0_RFMODE_FTM_RX, MASKDWORD, bak->p0_rfmode_ftm, idx);
  1682. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE, MASKDWORD, bak->p1_rfmode, idx);
  1683. rtw89_phy_write32_idx(rtwdev, R_P1_RFMODE_FTM_RX, MASKDWORD, bak->p1_rfmode_ftm, idx);
  1684. rtw89_phy_write32_idx(rtwdev, R_TXPWR, B_TXPWR_MSK, bak->tx_pwr, idx);
  1685. }
  1686. static void rtw8852b_bb_ctrl_btc_preagc(struct rtw89_dev *rtwdev, bool bt_en)
  1687. {
  1688. rtw89_phy_write_reg3_tbl(rtwdev, bt_en ? &rtw8852b_btc_preagc_en_defs_tbl :
  1689. &rtw8852b_btc_preagc_dis_defs_tbl);
  1690. }
  1691. static void rtw8852b_ctrl_btg(struct rtw89_dev *rtwdev, bool btg)
  1692. {
  1693. if (btg) {
  1694. rtw89_phy_write32_mask(rtwdev, R_PATH0_BT_SHARE_V1,
  1695. B_PATH0_BT_SHARE_V1, 0x1);
  1696. rtw89_phy_write32_mask(rtwdev, R_PATH0_BTG_PATH_V1,
  1697. B_PATH0_BTG_PATH_V1, 0x0);
  1698. rtw89_phy_write32_mask(rtwdev, R_PATH1_G_LNA6_OP1DB_V1,
  1699. B_PATH1_G_LNA6_OP1DB_V1, 0x20);
  1700. rtw89_phy_write32_mask(rtwdev, R_PATH1_G_TIA0_LNA6_OP1DB_V1,
  1701. B_PATH1_G_TIA0_LNA6_OP1DB_V1, 0x30);
  1702. rtw89_phy_write32_mask(rtwdev, R_PATH1_BT_SHARE_V1,
  1703. B_PATH1_BT_SHARE_V1, 0x1);
  1704. rtw89_phy_write32_mask(rtwdev, R_PATH1_BTG_PATH_V1,
  1705. B_PATH1_BTG_PATH_V1, 0x1);
  1706. rtw89_phy_write32_mask(rtwdev, R_PMAC_GNT, B_PMAC_GNT_P1, 0x0);
  1707. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_BT_SHARE, 0x1);
  1708. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_BT_SEG0, 0x2);
  1709. rtw89_phy_write32_mask(rtwdev, R_BT_DYN_DC_EST_EN_V1,
  1710. B_BT_DYN_DC_EST_EN_MSK, 0x1);
  1711. rtw89_phy_write32_mask(rtwdev, R_GNT_BT_WGT_EN, B_GNT_BT_WGT_EN, 0x1);
  1712. } else {
  1713. rtw89_phy_write32_mask(rtwdev, R_PATH0_BT_SHARE_V1,
  1714. B_PATH0_BT_SHARE_V1, 0x0);
  1715. rtw89_phy_write32_mask(rtwdev, R_PATH0_BTG_PATH_V1,
  1716. B_PATH0_BTG_PATH_V1, 0x0);
  1717. rtw89_phy_write32_mask(rtwdev, R_PATH1_G_LNA6_OP1DB_V1,
  1718. B_PATH1_G_LNA6_OP1DB_V1, 0x1a);
  1719. rtw89_phy_write32_mask(rtwdev, R_PATH1_G_TIA0_LNA6_OP1DB_V1,
  1720. B_PATH1_G_TIA0_LNA6_OP1DB_V1, 0x2a);
  1721. rtw89_phy_write32_mask(rtwdev, R_PATH1_BT_SHARE_V1,
  1722. B_PATH1_BT_SHARE_V1, 0x0);
  1723. rtw89_phy_write32_mask(rtwdev, R_PATH1_BTG_PATH_V1,
  1724. B_PATH1_BTG_PATH_V1, 0x0);
  1725. rtw89_phy_write32_mask(rtwdev, R_PMAC_GNT, B_PMAC_GNT_P1, 0xc);
  1726. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_BT_SHARE, 0x0);
  1727. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_BT_SEG0, 0x0);
  1728. rtw89_phy_write32_mask(rtwdev, R_BT_DYN_DC_EST_EN_V1,
  1729. B_BT_DYN_DC_EST_EN_MSK, 0x1);
  1730. rtw89_phy_write32_mask(rtwdev, R_GNT_BT_WGT_EN, B_GNT_BT_WGT_EN, 0x0);
  1731. }
  1732. }
  1733. void rtw8852b_bb_ctrl_rx_path(struct rtw89_dev *rtwdev,
  1734. enum rtw89_rf_path_bit rx_path)
  1735. {
  1736. const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);
  1737. u32 rst_mask0;
  1738. u32 rst_mask1;
  1739. if (rx_path == RF_A) {
  1740. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0, 1);
  1741. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG0, 1);
  1742. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG1, 1);
  1743. rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 0);
  1744. rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 0);
  1745. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_USER_MAX, 4);
  1746. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 0);
  1747. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHETB_MAX_NSS, 0);
  1748. } else if (rx_path == RF_B) {
  1749. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0, 2);
  1750. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG0, 2);
  1751. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG1, 2);
  1752. rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 0);
  1753. rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 0);
  1754. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_USER_MAX, 4);
  1755. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 0);
  1756. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHETB_MAX_NSS, 0);
  1757. } else if (rx_path == RF_AB) {
  1758. rtw89_phy_write32_mask(rtwdev, R_CHBW_MOD_V1, B_ANT_RX_SEG0, 3);
  1759. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG0, 3);
  1760. rtw89_phy_write32_mask(rtwdev, R_FC0_BW_V1, B_ANT_RX_1RCCA_SEG1, 3);
  1761. rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 1);
  1762. rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 1);
  1763. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_USER_MAX, 4);
  1764. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 1);
  1765. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHETB_MAX_NSS, 1);
  1766. }
  1767. rtw8852b_set_gain_offset(rtwdev, chan->subband_type, RTW89_PHY_0);
  1768. if (chan->band_type == RTW89_BAND_2G &&
  1769. (rx_path == RF_B || rx_path == RF_AB))
  1770. rtw8852b_ctrl_btg(rtwdev, true);
  1771. else
  1772. rtw8852b_ctrl_btg(rtwdev, false);
  1773. rst_mask0 = B_P0_TXPW_RSTB_MANON | B_P0_TXPW_RSTB_TSSI;
  1774. rst_mask1 = B_P1_TXPW_RSTB_MANON | B_P1_TXPW_RSTB_TSSI;
  1775. if (rx_path == RF_A) {
  1776. rtw89_phy_write32_mask(rtwdev, R_P0_TXPW_RSTB, rst_mask0, 1);
  1777. rtw89_phy_write32_mask(rtwdev, R_P0_TXPW_RSTB, rst_mask0, 3);
  1778. } else {
  1779. rtw89_phy_write32_mask(rtwdev, R_P1_TXPW_RSTB, rst_mask1, 1);
  1780. rtw89_phy_write32_mask(rtwdev, R_P1_TXPW_RSTB, rst_mask1, 3);
  1781. }
  1782. }
  1783. static void rtw8852b_bb_ctrl_rf_mode_rx_path(struct rtw89_dev *rtwdev,
  1784. enum rtw89_rf_path_bit rx_path)
  1785. {
  1786. if (rx_path == RF_A) {
  1787. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE,
  1788. B_P0_RFMODE_ORI_TXRX_FTM_TX, 0x1233312);
  1789. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE_FTM_RX,
  1790. B_P0_RFMODE_FTM_RX, 0x333);
  1791. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE,
  1792. B_P1_RFMODE_ORI_TXRX_FTM_TX, 0x1111111);
  1793. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE_FTM_RX,
  1794. B_P1_RFMODE_FTM_RX, 0x111);
  1795. } else if (rx_path == RF_B) {
  1796. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE,
  1797. B_P0_RFMODE_ORI_TXRX_FTM_TX, 0x1111111);
  1798. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE_FTM_RX,
  1799. B_P0_RFMODE_FTM_RX, 0x111);
  1800. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE,
  1801. B_P1_RFMODE_ORI_TXRX_FTM_TX, 0x1233312);
  1802. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE_FTM_RX,
  1803. B_P1_RFMODE_FTM_RX, 0x333);
  1804. } else if (rx_path == RF_AB) {
  1805. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE,
  1806. B_P0_RFMODE_ORI_TXRX_FTM_TX, 0x1233312);
  1807. rtw89_phy_write32_mask(rtwdev, R_P0_RFMODE_FTM_RX,
  1808. B_P0_RFMODE_FTM_RX, 0x333);
  1809. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE,
  1810. B_P1_RFMODE_ORI_TXRX_FTM_TX, 0x1233312);
  1811. rtw89_phy_write32_mask(rtwdev, R_P1_RFMODE_FTM_RX,
  1812. B_P1_RFMODE_FTM_RX, 0x333);
  1813. }
  1814. }
  1815. static void rtw8852b_bb_cfg_txrx_path(struct rtw89_dev *rtwdev)
  1816. {
  1817. struct rtw89_hal *hal = &rtwdev->hal;
  1818. enum rtw89_rf_path_bit rx_path = hal->antenna_rx ? hal->antenna_rx : RF_AB;
  1819. rtw8852b_bb_ctrl_rx_path(rtwdev, rx_path);
  1820. rtw8852b_bb_ctrl_rf_mode_rx_path(rtwdev, rx_path);
  1821. if (rtwdev->hal.rx_nss == 1) {
  1822. rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 0);
  1823. rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 0);
  1824. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 0);
  1825. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHETB_MAX_NSS, 0);
  1826. } else {
  1827. rtw89_phy_write32_mask(rtwdev, R_RXHT_MCS_LIMIT, B_RXHT_MCS_LIMIT, 1);
  1828. rtw89_phy_write32_mask(rtwdev, R_RXVHT_MCS_LIMIT, B_RXVHT_MCS_LIMIT, 1);
  1829. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHE_MAX_NSS, 1);
  1830. rtw89_phy_write32_mask(rtwdev, R_RXHE, B_RXHETB_MAX_NSS, 1);
  1831. }
  1832. rtw89_phy_write32_idx(rtwdev, R_MAC_SEL, B_MAC_SEL_MOD, 0x0, RTW89_PHY_0);
  1833. }
  1834. static u8 rtw8852b_get_thermal(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path)
  1835. {
  1836. if (rtwdev->is_tssi_mode[rf_path]) {
  1837. u32 addr = 0x1c10 + (rf_path << 13);
  1838. return rtw89_phy_read32_mask(rtwdev, addr, 0x3F000000);
  1839. }
  1840. rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1);
  1841. rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x0);
  1842. rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1);
  1843. fsleep(200);
  1844. return rtw89_read_rf(rtwdev, rf_path, RR_TM, RR_TM_VAL);
  1845. }
  1846. static void rtw8852b_btc_set_rfe(struct rtw89_dev *rtwdev)
  1847. {
  1848. struct rtw89_btc *btc = &rtwdev->btc;
  1849. struct rtw89_btc_module *module = &btc->mdinfo;
  1850. module->rfe_type = rtwdev->efuse.rfe_type;
  1851. module->cv = rtwdev->hal.cv;
  1852. module->bt_solo = 0;
  1853. module->switch_type = BTC_SWITCH_INTERNAL;
  1854. if (module->rfe_type > 0)
  1855. module->ant.num = module->rfe_type % 2 ? 2 : 3;
  1856. else
  1857. module->ant.num = 2;
  1858. module->ant.diversity = 0;
  1859. module->ant.isolation = 10;
  1860. if (module->ant.num == 3) {
  1861. module->ant.type = BTC_ANT_DEDICATED;
  1862. module->bt_pos = BTC_BT_ALONE;
  1863. } else {
  1864. module->ant.type = BTC_ANT_SHARED;
  1865. module->bt_pos = BTC_BT_BTG;
  1866. }
  1867. }
  1868. static
  1869. void rtw8852b_set_trx_mask(struct rtw89_dev *rtwdev, u8 path, u8 group, u32 val)
  1870. {
  1871. rtw89_write_rf(rtwdev, path, RR_LUTWE, RFREG_MASK, 0x20000);
  1872. rtw89_write_rf(rtwdev, path, RR_LUTWA, RFREG_MASK, group);
  1873. rtw89_write_rf(rtwdev, path, RR_LUTWD0, RFREG_MASK, val);
  1874. rtw89_write_rf(rtwdev, path, RR_LUTWE, RFREG_MASK, 0x0);
  1875. }
  1876. static void rtw8852b_btc_init_cfg(struct rtw89_dev *rtwdev)
  1877. {
  1878. struct rtw89_btc *btc = &rtwdev->btc;
  1879. struct rtw89_btc_module *module = &btc->mdinfo;
  1880. const struct rtw89_chip_info *chip = rtwdev->chip;
  1881. const struct rtw89_mac_ax_coex coex_params = {
  1882. .pta_mode = RTW89_MAC_AX_COEX_RTK_MODE,
  1883. .direction = RTW89_MAC_AX_COEX_INNER,
  1884. };
  1885. /* PTA init */
  1886. rtw89_mac_coex_init(rtwdev, &coex_params);
  1887. /* set WL Tx response = Hi-Pri */
  1888. chip->ops->btc_set_wl_pri(rtwdev, BTC_PRI_MASK_TX_RESP, true);
  1889. chip->ops->btc_set_wl_pri(rtwdev, BTC_PRI_MASK_BEACON, true);
  1890. /* set rf gnt debug off */
  1891. rtw89_write_rf(rtwdev, RF_PATH_A, RR_WLSEL, RFREG_MASK, 0x0);
  1892. rtw89_write_rf(rtwdev, RF_PATH_B, RR_WLSEL, RFREG_MASK, 0x0);
  1893. /* set WL Tx thru in TRX mask table if GNT_WL = 0 && BT_S1 = ss group */
  1894. if (module->ant.type == BTC_ANT_SHARED) {
  1895. rtw8852b_set_trx_mask(rtwdev, RF_PATH_A, BTC_BT_SS_GROUP, 0x5ff);
  1896. rtw8852b_set_trx_mask(rtwdev, RF_PATH_B, BTC_BT_SS_GROUP, 0x5ff);
  1897. /* set path-A(S0) Tx/Rx no-mask if GNT_WL=0 && BT_S1=tx group */
  1898. rtw8852b_set_trx_mask(rtwdev, RF_PATH_A, BTC_BT_TX_GROUP, 0x5ff);
  1899. rtw8852b_set_trx_mask(rtwdev, RF_PATH_B, BTC_BT_TX_GROUP, 0x55f);
  1900. } else { /* set WL Tx stb if GNT_WL = 0 && BT_S1 = ss group for 3-ant */
  1901. rtw8852b_set_trx_mask(rtwdev, RF_PATH_A, BTC_BT_SS_GROUP, 0x5df);
  1902. rtw8852b_set_trx_mask(rtwdev, RF_PATH_B, BTC_BT_SS_GROUP, 0x5df);
  1903. rtw8852b_set_trx_mask(rtwdev, RF_PATH_A, BTC_BT_TX_GROUP, 0x5ff);
  1904. rtw8852b_set_trx_mask(rtwdev, RF_PATH_B, BTC_BT_TX_GROUP, 0x5ff);
  1905. }
  1906. /* set PTA break table */
  1907. rtw89_write32(rtwdev, R_BTC_BREAK_TABLE, BTC_BREAK_PARAM);
  1908. /* enable BT counter 0xda40[16,2] = 2b'11 */
  1909. rtw89_write32_set(rtwdev, R_AX_CSR_MODE, B_AX_BT_CNT_RST | B_AX_STATIS_BT_EN);
  1910. btc->cx.wl.status.map.init_ok = true;
  1911. }
  1912. static
  1913. void rtw8852b_btc_set_wl_pri(struct rtw89_dev *rtwdev, u8 map, bool state)
  1914. {
  1915. u32 bitmap;
  1916. u32 reg;
  1917. switch (map) {
  1918. case BTC_PRI_MASK_TX_RESP:
  1919. reg = R_BTC_BT_COEX_MSK_TABLE;
  1920. bitmap = B_BTC_PRI_MASK_TX_RESP_V1;
  1921. break;
  1922. case BTC_PRI_MASK_BEACON:
  1923. reg = R_AX_WL_PRI_MSK;
  1924. bitmap = B_AX_PTA_WL_PRI_MASK_BCNQ;
  1925. break;
  1926. case BTC_PRI_MASK_RX_CCK:
  1927. reg = R_BTC_BT_COEX_MSK_TABLE;
  1928. bitmap = B_BTC_PRI_MASK_RXCCK_V1;
  1929. break;
  1930. default:
  1931. return;
  1932. }
  1933. if (state)
  1934. rtw89_write32_set(rtwdev, reg, bitmap);
  1935. else
  1936. rtw89_write32_clr(rtwdev, reg, bitmap);
  1937. }
  1938. union rtw8852b_btc_wl_txpwr_ctrl {
  1939. u32 txpwr_val;
  1940. struct {
  1941. union {
  1942. u16 ctrl_all_time;
  1943. struct {
  1944. s16 data:9;
  1945. u16 rsvd:6;
  1946. u16 flag:1;
  1947. } all_time;
  1948. };
  1949. union {
  1950. u16 ctrl_gnt_bt;
  1951. struct {
  1952. s16 data:9;
  1953. u16 rsvd:7;
  1954. } gnt_bt;
  1955. };
  1956. };
  1957. } __packed;
  1958. static void
  1959. rtw8852b_btc_set_wl_txpwr_ctrl(struct rtw89_dev *rtwdev, u32 txpwr_val)
  1960. {
  1961. union rtw8852b_btc_wl_txpwr_ctrl arg = { .txpwr_val = txpwr_val };
  1962. s32 val;
  1963. #define __write_ctrl(_reg, _msk, _val, _en, _cond) \
  1964. do { \
  1965. u32 _wrt = FIELD_PREP(_msk, _val); \
  1966. BUILD_BUG_ON(!!(_msk & _en)); \
  1967. if (_cond) \
  1968. _wrt |= _en; \
  1969. else \
  1970. _wrt &= ~_en; \
  1971. rtw89_mac_txpwr_write32_mask(rtwdev, RTW89_PHY_0, _reg, \
  1972. _msk | _en, _wrt); \
  1973. } while (0)
  1974. switch (arg.ctrl_all_time) {
  1975. case 0xffff:
  1976. val = 0;
  1977. break;
  1978. default:
  1979. val = arg.all_time.data;
  1980. break;
  1981. }
  1982. __write_ctrl(R_AX_PWR_RATE_CTRL, B_AX_FORCE_PWR_BY_RATE_VALUE_MASK,
  1983. val, B_AX_FORCE_PWR_BY_RATE_EN,
  1984. arg.ctrl_all_time != 0xffff);
  1985. switch (arg.ctrl_gnt_bt) {
  1986. case 0xffff:
  1987. val = 0;
  1988. break;
  1989. default:
  1990. val = arg.gnt_bt.data;
  1991. break;
  1992. }
  1993. __write_ctrl(R_AX_PWR_COEXT_CTRL, B_AX_TXAGC_BT_MASK, val,
  1994. B_AX_TXAGC_BT_EN, arg.ctrl_gnt_bt != 0xffff);
  1995. #undef __write_ctrl
  1996. }
  1997. static
  1998. s8 rtw8852b_btc_get_bt_rssi(struct rtw89_dev *rtwdev, s8 val)
  1999. {
  2000. /* +6 for compensate offset */
  2001. return clamp_t(s8, val + 6, -100, 0) + 100;
  2002. }
  2003. static
  2004. void rtw8852b_btc_update_bt_cnt(struct rtw89_dev *rtwdev)
  2005. {
  2006. /* Feature move to firmware */
  2007. }
  2008. static void rtw8852b_btc_wl_s1_standby(struct rtw89_dev *rtwdev, bool state)
  2009. {
  2010. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x80000);
  2011. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x1);
  2012. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD1, RFREG_MASK, 0x31);
  2013. /* set WL standby = Rx for GNT_BT_Tx = 1->0 settle issue */
  2014. if (state)
  2015. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x179);
  2016. else
  2017. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x20);
  2018. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x0);
  2019. }
  2020. static void rtw8852b_btc_set_wl_lna2(struct rtw89_dev *rtwdev, u8 level)
  2021. {
  2022. switch (level) {
  2023. case 0: /* default */
  2024. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x1000);
  2025. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x0);
  2026. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x15);
  2027. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x1);
  2028. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x17);
  2029. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x2);
  2030. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x15);
  2031. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x3);
  2032. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x17);
  2033. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x0);
  2034. break;
  2035. case 1: /* Fix LNA2=5 */
  2036. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x1000);
  2037. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x0);
  2038. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x15);
  2039. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x1);
  2040. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x5);
  2041. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x2);
  2042. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x15);
  2043. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWA, RFREG_MASK, 0x3);
  2044. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWD0, RFREG_MASK, 0x5);
  2045. rtw89_write_rf(rtwdev, RF_PATH_B, RR_LUTWE, RFREG_MASK, 0x0);
  2046. break;
  2047. }
  2048. }
  2049. static void rtw8852b_btc_set_wl_rx_gain(struct rtw89_dev *rtwdev, u32 level)
  2050. {
  2051. struct rtw89_btc *btc = &rtwdev->btc;
  2052. switch (level) {
  2053. case 0: /* original */
  2054. default:
  2055. rtw8852b_bb_ctrl_btc_preagc(rtwdev, false);
  2056. btc->dm.wl_lna2 = 0;
  2057. break;
  2058. case 1: /* for FDD free-run */
  2059. rtw8852b_bb_ctrl_btc_preagc(rtwdev, true);
  2060. btc->dm.wl_lna2 = 0;
  2061. break;
  2062. case 2: /* for BTG Co-Rx*/
  2063. rtw8852b_bb_ctrl_btc_preagc(rtwdev, false);
  2064. btc->dm.wl_lna2 = 1;
  2065. break;
  2066. }
  2067. rtw8852b_btc_set_wl_lna2(rtwdev, btc->dm.wl_lna2);
  2068. }
  2069. static void rtw8852b_fill_freq_with_ppdu(struct rtw89_dev *rtwdev,
  2070. struct rtw89_rx_phy_ppdu *phy_ppdu,
  2071. struct ieee80211_rx_status *status)
  2072. {
  2073. u16 chan = phy_ppdu->chan_idx;
  2074. enum nl80211_band band;
  2075. u8 ch;
  2076. if (chan == 0)
  2077. return;
  2078. rtw89_decode_chan_idx(rtwdev, chan, &ch, &band);
  2079. status->freq = ieee80211_channel_to_frequency(ch, band);
  2080. status->band = band;
  2081. }
  2082. static void rtw8852b_query_ppdu(struct rtw89_dev *rtwdev,
  2083. struct rtw89_rx_phy_ppdu *phy_ppdu,
  2084. struct ieee80211_rx_status *status)
  2085. {
  2086. u8 path;
  2087. u8 *rx_power = phy_ppdu->rssi;
  2088. status->signal = RTW89_RSSI_RAW_TO_DBM(max(rx_power[RF_PATH_A], rx_power[RF_PATH_B]));
  2089. for (path = 0; path < rtwdev->chip->rf_path_num; path++) {
  2090. status->chains |= BIT(path);
  2091. status->chain_signal[path] = RTW89_RSSI_RAW_TO_DBM(rx_power[path]);
  2092. }
  2093. if (phy_ppdu->valid)
  2094. rtw8852b_fill_freq_with_ppdu(rtwdev, phy_ppdu, status);
  2095. }
  2096. static int rtw8852b_mac_enable_bb_rf(struct rtw89_dev *rtwdev)
  2097. {
  2098. int ret;
  2099. rtw89_write8_set(rtwdev, R_AX_SYS_FUNC_EN,
  2100. B_AX_FEN_BBRSTB | B_AX_FEN_BB_GLB_RSTN);
  2101. rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, B_AX_REG_ZCDC_H_MASK, 0x1);
  2102. rtw89_write32_set(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG);
  2103. rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG);
  2104. rtw89_write32_set(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG);
  2105. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S0, 0xC7,
  2106. FULL_BIT_MASK);
  2107. if (ret)
  2108. return ret;
  2109. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S1, 0xC7,
  2110. FULL_BIT_MASK);
  2111. if (ret)
  2112. return ret;
  2113. rtw89_write8(rtwdev, R_AX_PHYREG_SET, PHYREG_SET_XYN_CYCLE);
  2114. return 0;
  2115. }
  2116. static int rtw8852b_mac_disable_bb_rf(struct rtw89_dev *rtwdev)
  2117. {
  2118. u8 wl_rfc_s0;
  2119. u8 wl_rfc_s1;
  2120. int ret;
  2121. rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN,
  2122. B_AX_FEN_BBRSTB | B_AX_FEN_BB_GLB_RSTN);
  2123. ret = rtw89_mac_read_xtal_si(rtwdev, XTAL_SI_WL_RFC_S0, &wl_rfc_s0);
  2124. if (ret)
  2125. return ret;
  2126. wl_rfc_s0 &= ~XTAL_SI_RF00S_EN;
  2127. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S0, wl_rfc_s0,
  2128. FULL_BIT_MASK);
  2129. if (ret)
  2130. return ret;
  2131. ret = rtw89_mac_read_xtal_si(rtwdev, XTAL_SI_WL_RFC_S1, &wl_rfc_s1);
  2132. if (ret)
  2133. return ret;
  2134. wl_rfc_s1 &= ~XTAL_SI_RF10S_EN;
  2135. ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_WL_RFC_S1, wl_rfc_s1,
  2136. FULL_BIT_MASK);
  2137. return ret;
  2138. }
  2139. static const struct rtw89_chip_ops rtw8852b_chip_ops = {
  2140. .enable_bb_rf = rtw8852b_mac_enable_bb_rf,
  2141. .disable_bb_rf = rtw8852b_mac_disable_bb_rf,
  2142. .bb_preinit = NULL,
  2143. .bb_reset = rtw8852b_bb_reset,
  2144. .bb_sethw = rtw8852b_bb_sethw,
  2145. .read_rf = rtw89_phy_read_rf_v1,
  2146. .write_rf = rtw89_phy_write_rf_v1,
  2147. .set_channel = rtw8852b_set_channel,
  2148. .set_channel_help = rtw8852b_set_channel_help,
  2149. .read_efuse = rtw8852b_read_efuse,
  2150. .read_phycap = rtw8852b_read_phycap,
  2151. .fem_setup = NULL,
  2152. .rfe_gpio = NULL,
  2153. .rfk_init = rtw8852b_rfk_init,
  2154. .rfk_channel = rtw8852b_rfk_channel,
  2155. .rfk_band_changed = rtw8852b_rfk_band_changed,
  2156. .rfk_scan = rtw8852b_rfk_scan,
  2157. .rfk_track = rtw8852b_rfk_track,
  2158. .power_trim = rtw8852b_power_trim,
  2159. .set_txpwr = rtw8852b_set_txpwr,
  2160. .set_txpwr_ctrl = rtw8852b_set_txpwr_ctrl,
  2161. .init_txpwr_unit = rtw8852b_init_txpwr_unit,
  2162. .get_thermal = rtw8852b_get_thermal,
  2163. .ctrl_btg = rtw8852b_ctrl_btg,
  2164. .query_ppdu = rtw8852b_query_ppdu,
  2165. .bb_ctrl_btc_preagc = rtw8852b_bb_ctrl_btc_preagc,
  2166. .cfg_txrx_path = rtw8852b_bb_cfg_txrx_path,
  2167. .set_txpwr_ul_tb_offset = rtw8852b_set_txpwr_ul_tb_offset,
  2168. .pwr_on_func = rtw8852b_pwr_on_func,
  2169. .pwr_off_func = rtw8852b_pwr_off_func,
  2170. .query_rxdesc = rtw89_core_query_rxdesc,
  2171. .fill_txdesc = rtw89_core_fill_txdesc,
  2172. .fill_txdesc_fwcmd = rtw89_core_fill_txdesc,
  2173. .cfg_ctrl_path = rtw89_mac_cfg_ctrl_path,
  2174. .mac_cfg_gnt = rtw89_mac_cfg_gnt,
  2175. .stop_sch_tx = rtw89_mac_stop_sch_tx,
  2176. .resume_sch_tx = rtw89_mac_resume_sch_tx,
  2177. .h2c_dctl_sec_cam = NULL,
  2178. .btc_set_rfe = rtw8852b_btc_set_rfe,
  2179. .btc_init_cfg = rtw8852b_btc_init_cfg,
  2180. .btc_set_wl_pri = rtw8852b_btc_set_wl_pri,
  2181. .btc_set_wl_txpwr_ctrl = rtw8852b_btc_set_wl_txpwr_ctrl,
  2182. .btc_get_bt_rssi = rtw8852b_btc_get_bt_rssi,
  2183. .btc_update_bt_cnt = rtw8852b_btc_update_bt_cnt,
  2184. .btc_wl_s1_standby = rtw8852b_btc_wl_s1_standby,
  2185. .btc_set_wl_rx_gain = rtw8852b_btc_set_wl_rx_gain,
  2186. .btc_set_policy = rtw89_btc_set_policy_v1,
  2187. };
  2188. #ifdef CONFIG_PM
  2189. static const struct wiphy_wowlan_support rtw_wowlan_stub_8852b = {
  2190. .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
  2191. .n_patterns = RTW89_MAX_PATTERN_NUM,
  2192. .pattern_max_len = RTW89_MAX_PATTERN_SIZE,
  2193. .pattern_min_len = 1,
  2194. };
  2195. #endif
  2196. const struct rtw89_chip_info rtw8852b_chip_info = {
  2197. .chip_id = RTL8852B,
  2198. .chip_gen = RTW89_CHIP_AX,
  2199. .ops = &rtw8852b_chip_ops,
  2200. .mac_def = &rtw89_mac_gen_ax,
  2201. .phy_def = &rtw89_phy_gen_ax,
  2202. .fw_basename = RTW8852B_FW_BASENAME,
  2203. .fw_format_max = RTW8852B_FW_FORMAT_MAX,
  2204. .try_ce_fw = true,
  2205. .bbmcu_nr = 0,
  2206. .needed_fw_elms = 0,
  2207. .fifo_size = 196608,
  2208. .small_fifo_size = true,
  2209. .dle_scc_rsvd_size = 98304,
  2210. .max_amsdu_limit = 3500,
  2211. .dis_2g_40m_ul_ofdma = true,
  2212. .rsvd_ple_ofst = 0x2f800,
  2213. .hfc_param_ini = rtw8852b_hfc_param_ini_pcie,
  2214. .dle_mem = rtw8852b_dle_mem_pcie,
  2215. .wde_qempty_acq_num = 4,
  2216. .wde_qempty_mgq_sel = 4,
  2217. .rf_base_addr = {0xe000, 0xf000},
  2218. .pwr_on_seq = NULL,
  2219. .pwr_off_seq = NULL,
  2220. .bb_table = &rtw89_8852b_phy_bb_table,
  2221. .bb_gain_table = &rtw89_8852b_phy_bb_gain_table,
  2222. .rf_table = {&rtw89_8852b_phy_radioa_table,
  2223. &rtw89_8852b_phy_radiob_table,},
  2224. .nctl_table = &rtw89_8852b_phy_nctl_table,
  2225. .nctl_post_table = NULL,
  2226. .dflt_parms = &rtw89_8852b_dflt_parms,
  2227. .rfe_parms_conf = NULL,
  2228. .txpwr_factor_rf = 2,
  2229. .txpwr_factor_mac = 1,
  2230. .dig_table = NULL,
  2231. .dig_regs = &rtw8852b_dig_regs,
  2232. .tssi_dbw_table = NULL,
  2233. .support_chanctx_num = 0,
  2234. .support_bands = BIT(NL80211_BAND_2GHZ) |
  2235. BIT(NL80211_BAND_5GHZ),
  2236. .support_bw160 = false,
  2237. .support_unii4 = true,
  2238. .ul_tb_waveform_ctrl = true,
  2239. .ul_tb_pwr_diff = false,
  2240. .hw_sec_hdr = false,
  2241. .rf_path_num = 2,
  2242. .tx_nss = 2,
  2243. .rx_nss = 2,
  2244. .acam_num = 128,
  2245. .bcam_num = 10,
  2246. .scam_num = 128,
  2247. .bacam_num = 2,
  2248. .bacam_dynamic_num = 4,
  2249. .bacam_ver = RTW89_BACAM_V0,
  2250. .sec_ctrl_efuse_size = 4,
  2251. .physical_efuse_size = 1216,
  2252. .logical_efuse_size = 2048,
  2253. .limit_efuse_size = 1280,
  2254. .dav_phy_efuse_size = 96,
  2255. .dav_log_efuse_size = 16,
  2256. .phycap_addr = 0x580,
  2257. .phycap_size = 128,
  2258. .para_ver = 0,
  2259. .wlcx_desired = 0x05050000,
  2260. .btcx_desired = 0x5,
  2261. .scbd = 0x1,
  2262. .mailbox = 0x1,
  2263. .afh_guard_ch = 6,
  2264. .wl_rssi_thres = rtw89_btc_8852b_wl_rssi_thres,
  2265. .bt_rssi_thres = rtw89_btc_8852b_bt_rssi_thres,
  2266. .rssi_tol = 2,
  2267. .mon_reg_num = ARRAY_SIZE(rtw89_btc_8852b_mon_reg),
  2268. .mon_reg = rtw89_btc_8852b_mon_reg,
  2269. .rf_para_ulink_num = ARRAY_SIZE(rtw89_btc_8852b_rf_ul),
  2270. .rf_para_ulink = rtw89_btc_8852b_rf_ul,
  2271. .rf_para_dlink_num = ARRAY_SIZE(rtw89_btc_8852b_rf_dl),
  2272. .rf_para_dlink = rtw89_btc_8852b_rf_dl,
  2273. .ps_mode_supported = BIT(RTW89_PS_MODE_RFOFF) |
  2274. BIT(RTW89_PS_MODE_CLK_GATED) |
  2275. BIT(RTW89_PS_MODE_PWR_GATED),
  2276. .low_power_hci_modes = 0,
  2277. .h2c_cctl_func_id = H2C_FUNC_MAC_CCTLINFO_UD,
  2278. .hci_func_en_addr = R_AX_HCI_FUNC_EN,
  2279. .h2c_desc_size = sizeof(struct rtw89_txwd_body),
  2280. .txwd_body_size = sizeof(struct rtw89_txwd_body),
  2281. .txwd_info_size = sizeof(struct rtw89_txwd_info),
  2282. .h2c_ctrl_reg = R_AX_H2CREG_CTRL,
  2283. .h2c_counter_reg = {R_AX_UDM1 + 1, B_AX_UDM1_HALMAC_H2C_DEQ_CNT_MASK >> 8},
  2284. .h2c_regs = rtw8852b_h2c_regs,
  2285. .c2h_ctrl_reg = R_AX_C2HREG_CTRL,
  2286. .c2h_counter_reg = {R_AX_UDM1 + 1, B_AX_UDM1_HALMAC_C2H_ENQ_CNT_MASK >> 8},
  2287. .c2h_regs = rtw8852b_c2h_regs,
  2288. .page_regs = &rtw8852b_page_regs,
  2289. .cfo_src_fd = true,
  2290. .cfo_hw_comp = true,
  2291. .dcfo_comp = &rtw8852b_dcfo_comp,
  2292. .dcfo_comp_sft = 10,
  2293. .imr_info = &rtw8852b_imr_info,
  2294. .rrsr_cfgs = &rtw8852b_rrsr_cfgs,
  2295. .bss_clr_map_reg = R_BSS_CLR_MAP_V1,
  2296. .dma_ch_mask = BIT(RTW89_DMA_ACH4) | BIT(RTW89_DMA_ACH5) |
  2297. BIT(RTW89_DMA_ACH6) | BIT(RTW89_DMA_ACH7) |
  2298. BIT(RTW89_DMA_B1MG) | BIT(RTW89_DMA_B1HI),
  2299. .edcca_lvl_reg = R_SEG0R_EDCCA_LVL_V1,
  2300. #ifdef CONFIG_PM
  2301. .wowlan_stub = &rtw_wowlan_stub_8852b,
  2302. #endif
  2303. .xtal_info = NULL,
  2304. };
  2305. EXPORT_SYMBOL(rtw8852b_chip_info);
  2306. MODULE_FIRMWARE(RTW8852B_MODULE_FIRMWARE);
  2307. MODULE_AUTHOR("Realtek Corporation");
  2308. MODULE_DESCRIPTION("Realtek 802.11ax wireless 8852B driver");
  2309. MODULE_LICENSE("Dual BSD/GPL");