coredump.c 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /*
  2. * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
  3. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "coredump.h"
  18. #include <linux/devcoredump.h>
  19. #include <linux/kernel.h>
  20. #include <linux/types.h>
  21. #include <linux/utsname.h>
  22. #include "debug.h"
  23. #include "hw.h"
  24. static const struct ath10k_mem_section qca6174_hw21_register_sections[] = {
  25. {0x800, 0x810},
  26. {0x820, 0x82C},
  27. {0x830, 0x8F4},
  28. {0x90C, 0x91C},
  29. {0xA14, 0xA18},
  30. {0xA84, 0xA94},
  31. {0xAA8, 0xAD4},
  32. {0xADC, 0xB40},
  33. {0x1000, 0x10A4},
  34. {0x10BC, 0x111C},
  35. {0x1134, 0x1138},
  36. {0x1144, 0x114C},
  37. {0x1150, 0x115C},
  38. {0x1160, 0x1178},
  39. {0x1240, 0x1260},
  40. {0x2000, 0x207C},
  41. {0x3000, 0x3014},
  42. {0x4000, 0x4014},
  43. {0x5000, 0x5124},
  44. {0x6000, 0x6040},
  45. {0x6080, 0x60CC},
  46. {0x6100, 0x611C},
  47. {0x6140, 0x61D8},
  48. {0x6200, 0x6238},
  49. {0x6240, 0x628C},
  50. {0x62C0, 0x62EC},
  51. {0x6380, 0x63E8},
  52. {0x6400, 0x6440},
  53. {0x6480, 0x64CC},
  54. {0x6500, 0x651C},
  55. {0x6540, 0x6580},
  56. {0x6600, 0x6638},
  57. {0x6640, 0x668C},
  58. {0x66C0, 0x66EC},
  59. {0x6780, 0x67E8},
  60. {0x7080, 0x708C},
  61. {0x70C0, 0x70C8},
  62. {0x7400, 0x741C},
  63. {0x7440, 0x7454},
  64. {0x7800, 0x7818},
  65. {0x8000, 0x8004},
  66. {0x8010, 0x8064},
  67. {0x8080, 0x8084},
  68. {0x80A0, 0x80A4},
  69. {0x80C0, 0x80C4},
  70. {0x80E0, 0x80F4},
  71. {0x8100, 0x8104},
  72. {0x8110, 0x812C},
  73. {0x9000, 0x9004},
  74. {0x9800, 0x982C},
  75. {0x9830, 0x9838},
  76. {0x9840, 0x986C},
  77. {0x9870, 0x9898},
  78. {0x9A00, 0x9C00},
  79. {0xD580, 0xD59C},
  80. {0xF000, 0xF0E0},
  81. {0xF140, 0xF190},
  82. {0xF250, 0xF25C},
  83. {0xF260, 0xF268},
  84. {0xF26C, 0xF2A8},
  85. {0x10008, 0x1000C},
  86. {0x10014, 0x10018},
  87. {0x1001C, 0x10020},
  88. {0x10024, 0x10028},
  89. {0x10030, 0x10034},
  90. {0x10040, 0x10054},
  91. {0x10058, 0x1007C},
  92. {0x10080, 0x100C4},
  93. {0x100C8, 0x10114},
  94. {0x1012C, 0x10130},
  95. {0x10138, 0x10144},
  96. {0x10200, 0x10220},
  97. {0x10230, 0x10250},
  98. {0x10260, 0x10280},
  99. {0x10290, 0x102B0},
  100. {0x102C0, 0x102DC},
  101. {0x102E0, 0x102F4},
  102. {0x102FC, 0x1037C},
  103. {0x10380, 0x10390},
  104. {0x10800, 0x10828},
  105. {0x10840, 0x10844},
  106. {0x10880, 0x10884},
  107. {0x108C0, 0x108E8},
  108. {0x10900, 0x10928},
  109. {0x10940, 0x10944},
  110. {0x10980, 0x10984},
  111. {0x109C0, 0x109E8},
  112. {0x10A00, 0x10A28},
  113. {0x10A40, 0x10A50},
  114. {0x11000, 0x11028},
  115. {0x11030, 0x11034},
  116. {0x11038, 0x11068},
  117. {0x11070, 0x11074},
  118. {0x11078, 0x110A8},
  119. {0x110B0, 0x110B4},
  120. {0x110B8, 0x110E8},
  121. {0x110F0, 0x110F4},
  122. {0x110F8, 0x11128},
  123. {0x11138, 0x11144},
  124. {0x11178, 0x11180},
  125. {0x111B8, 0x111C0},
  126. {0x111F8, 0x11200},
  127. {0x11238, 0x1123C},
  128. {0x11270, 0x11274},
  129. {0x11278, 0x1127C},
  130. {0x112B0, 0x112B4},
  131. {0x112B8, 0x112BC},
  132. {0x112F0, 0x112F4},
  133. {0x112F8, 0x112FC},
  134. {0x11338, 0x1133C},
  135. {0x11378, 0x1137C},
  136. {0x113B8, 0x113BC},
  137. {0x113F8, 0x113FC},
  138. {0x11438, 0x11440},
  139. {0x11478, 0x11480},
  140. {0x114B8, 0x114BC},
  141. {0x114F8, 0x114FC},
  142. {0x11538, 0x1153C},
  143. {0x11578, 0x1157C},
  144. {0x115B8, 0x115BC},
  145. {0x115F8, 0x115FC},
  146. {0x11638, 0x1163C},
  147. {0x11678, 0x1167C},
  148. {0x116B8, 0x116BC},
  149. {0x116F8, 0x116FC},
  150. {0x11738, 0x1173C},
  151. {0x11778, 0x1177C},
  152. {0x117B8, 0x117BC},
  153. {0x117F8, 0x117FC},
  154. {0x17000, 0x1701C},
  155. {0x17020, 0x170AC},
  156. {0x18000, 0x18050},
  157. {0x18054, 0x18074},
  158. {0x18080, 0x180D4},
  159. {0x180DC, 0x18104},
  160. {0x18108, 0x1813C},
  161. {0x18144, 0x18148},
  162. {0x18168, 0x18174},
  163. {0x18178, 0x18180},
  164. {0x181C8, 0x181E0},
  165. {0x181E4, 0x181E8},
  166. {0x181EC, 0x1820C},
  167. {0x1825C, 0x18280},
  168. {0x18284, 0x18290},
  169. {0x18294, 0x182A0},
  170. {0x18300, 0x18304},
  171. {0x18314, 0x18320},
  172. {0x18328, 0x18350},
  173. {0x1835C, 0x1836C},
  174. {0x18370, 0x18390},
  175. {0x18398, 0x183AC},
  176. {0x183BC, 0x183D8},
  177. {0x183DC, 0x183F4},
  178. {0x18400, 0x186F4},
  179. {0x186F8, 0x1871C},
  180. {0x18720, 0x18790},
  181. {0x19800, 0x19830},
  182. {0x19834, 0x19840},
  183. {0x19880, 0x1989C},
  184. {0x198A4, 0x198B0},
  185. {0x198BC, 0x19900},
  186. {0x19C00, 0x19C88},
  187. {0x19D00, 0x19D20},
  188. {0x19E00, 0x19E7C},
  189. {0x19E80, 0x19E94},
  190. {0x19E98, 0x19EAC},
  191. {0x19EB0, 0x19EBC},
  192. {0x19F70, 0x19F74},
  193. {0x19F80, 0x19F8C},
  194. {0x19FA0, 0x19FB4},
  195. {0x19FC0, 0x19FD8},
  196. {0x1A000, 0x1A200},
  197. {0x1A204, 0x1A210},
  198. {0x1A228, 0x1A22C},
  199. {0x1A230, 0x1A248},
  200. {0x1A250, 0x1A270},
  201. {0x1A280, 0x1A290},
  202. {0x1A2A0, 0x1A2A4},
  203. {0x1A2C0, 0x1A2EC},
  204. {0x1A300, 0x1A3BC},
  205. {0x1A3F0, 0x1A3F4},
  206. {0x1A3F8, 0x1A434},
  207. {0x1A438, 0x1A444},
  208. {0x1A448, 0x1A468},
  209. {0x1A580, 0x1A58C},
  210. {0x1A644, 0x1A654},
  211. {0x1A670, 0x1A698},
  212. {0x1A6AC, 0x1A6B0},
  213. {0x1A6D0, 0x1A6D4},
  214. {0x1A6EC, 0x1A70C},
  215. {0x1A710, 0x1A738},
  216. {0x1A7C0, 0x1A7D0},
  217. {0x1A7D4, 0x1A7D8},
  218. {0x1A7DC, 0x1A7E4},
  219. {0x1A7F0, 0x1A7F8},
  220. {0x1A888, 0x1A89C},
  221. {0x1A8A8, 0x1A8AC},
  222. {0x1A8C0, 0x1A8DC},
  223. {0x1A8F0, 0x1A8FC},
  224. {0x1AE04, 0x1AE08},
  225. {0x1AE18, 0x1AE24},
  226. {0x1AF80, 0x1AF8C},
  227. {0x1AFA0, 0x1AFB4},
  228. {0x1B000, 0x1B200},
  229. {0x1B284, 0x1B288},
  230. {0x1B2D0, 0x1B2D8},
  231. {0x1B2DC, 0x1B2EC},
  232. {0x1B300, 0x1B340},
  233. {0x1B374, 0x1B378},
  234. {0x1B380, 0x1B384},
  235. {0x1B388, 0x1B38C},
  236. {0x1B404, 0x1B408},
  237. {0x1B420, 0x1B428},
  238. {0x1B440, 0x1B444},
  239. {0x1B448, 0x1B44C},
  240. {0x1B450, 0x1B458},
  241. {0x1B45C, 0x1B468},
  242. {0x1B584, 0x1B58C},
  243. {0x1B68C, 0x1B690},
  244. {0x1B6AC, 0x1B6B0},
  245. {0x1B7F0, 0x1B7F8},
  246. {0x1C800, 0x1CC00},
  247. {0x1CE00, 0x1CE04},
  248. {0x1CF80, 0x1CF84},
  249. {0x1D200, 0x1D800},
  250. {0x1E000, 0x20014},
  251. {0x20100, 0x20124},
  252. {0x21400, 0x217A8},
  253. {0x21800, 0x21BA8},
  254. {0x21C00, 0x21FA8},
  255. {0x22000, 0x223A8},
  256. {0x22400, 0x227A8},
  257. {0x22800, 0x22BA8},
  258. {0x22C00, 0x22FA8},
  259. {0x23000, 0x233A8},
  260. {0x24000, 0x24034},
  261. {0x26000, 0x26064},
  262. {0x27000, 0x27024},
  263. {0x34000, 0x3400C},
  264. {0x34400, 0x3445C},
  265. {0x34800, 0x3485C},
  266. {0x34C00, 0x34C5C},
  267. {0x35000, 0x3505C},
  268. {0x35400, 0x3545C},
  269. {0x35800, 0x3585C},
  270. {0x35C00, 0x35C5C},
  271. {0x36000, 0x3605C},
  272. {0x38000, 0x38064},
  273. {0x38070, 0x380E0},
  274. {0x3A000, 0x3A064},
  275. {0x40000, 0x400A4},
  276. {0x80000, 0x8000C},
  277. {0x80010, 0x80020},
  278. };
  279. static const struct ath10k_mem_section qca6174_hw30_register_sections[] = {
  280. {0x800, 0x810},
  281. {0x820, 0x82C},
  282. {0x830, 0x8F4},
  283. {0x90C, 0x91C},
  284. {0xA14, 0xA18},
  285. {0xA84, 0xA94},
  286. {0xAA8, 0xAD4},
  287. {0xADC, 0xB40},
  288. {0x1000, 0x10A4},
  289. {0x10BC, 0x111C},
  290. {0x1134, 0x1138},
  291. {0x1144, 0x114C},
  292. {0x1150, 0x115C},
  293. {0x1160, 0x1178},
  294. {0x1240, 0x1260},
  295. {0x2000, 0x207C},
  296. {0x3000, 0x3014},
  297. {0x4000, 0x4014},
  298. {0x5000, 0x5124},
  299. {0x6000, 0x6040},
  300. {0x6080, 0x60CC},
  301. {0x6100, 0x611C},
  302. {0x6140, 0x61D8},
  303. {0x6200, 0x6238},
  304. {0x6240, 0x628C},
  305. {0x62C0, 0x62EC},
  306. {0x6380, 0x63E8},
  307. {0x6400, 0x6440},
  308. {0x6480, 0x64CC},
  309. {0x6500, 0x651C},
  310. {0x6540, 0x6580},
  311. {0x6600, 0x6638},
  312. {0x6640, 0x668C},
  313. {0x66C0, 0x66EC},
  314. {0x6780, 0x67E8},
  315. {0x7080, 0x708C},
  316. {0x70C0, 0x70C8},
  317. {0x7400, 0x741C},
  318. {0x7440, 0x7454},
  319. {0x7800, 0x7818},
  320. {0x8000, 0x8004},
  321. {0x8010, 0x8064},
  322. {0x8080, 0x8084},
  323. {0x80A0, 0x80A4},
  324. {0x80C0, 0x80C4},
  325. {0x80E0, 0x80F4},
  326. {0x8100, 0x8104},
  327. {0x8110, 0x812C},
  328. {0x9000, 0x9004},
  329. {0x9800, 0x982C},
  330. {0x9830, 0x9838},
  331. {0x9840, 0x986C},
  332. {0x9870, 0x9898},
  333. {0x9A00, 0x9C00},
  334. {0xD580, 0xD59C},
  335. {0xF000, 0xF0E0},
  336. {0xF140, 0xF190},
  337. {0xF250, 0xF25C},
  338. {0xF260, 0xF268},
  339. {0xF26C, 0xF2A8},
  340. {0x10008, 0x1000C},
  341. {0x10014, 0x10018},
  342. {0x1001C, 0x10020},
  343. {0x10024, 0x10028},
  344. {0x10030, 0x10034},
  345. {0x10040, 0x10054},
  346. {0x10058, 0x1007C},
  347. {0x10080, 0x100C4},
  348. {0x100C8, 0x10114},
  349. {0x1012C, 0x10130},
  350. {0x10138, 0x10144},
  351. {0x10200, 0x10220},
  352. {0x10230, 0x10250},
  353. {0x10260, 0x10280},
  354. {0x10290, 0x102B0},
  355. {0x102C0, 0x102DC},
  356. {0x102E0, 0x102F4},
  357. {0x102FC, 0x1037C},
  358. {0x10380, 0x10390},
  359. {0x10800, 0x10828},
  360. {0x10840, 0x10844},
  361. {0x10880, 0x10884},
  362. {0x108C0, 0x108E8},
  363. {0x10900, 0x10928},
  364. {0x10940, 0x10944},
  365. {0x10980, 0x10984},
  366. {0x109C0, 0x109E8},
  367. {0x10A00, 0x10A28},
  368. {0x10A40, 0x10A50},
  369. {0x11000, 0x11028},
  370. {0x11030, 0x11034},
  371. {0x11038, 0x11068},
  372. {0x11070, 0x11074},
  373. {0x11078, 0x110A8},
  374. {0x110B0, 0x110B4},
  375. {0x110B8, 0x110E8},
  376. {0x110F0, 0x110F4},
  377. {0x110F8, 0x11128},
  378. {0x11138, 0x11144},
  379. {0x11178, 0x11180},
  380. {0x111B8, 0x111C0},
  381. {0x111F8, 0x11200},
  382. {0x11238, 0x1123C},
  383. {0x11270, 0x11274},
  384. {0x11278, 0x1127C},
  385. {0x112B0, 0x112B4},
  386. {0x112B8, 0x112BC},
  387. {0x112F0, 0x112F4},
  388. {0x112F8, 0x112FC},
  389. {0x11338, 0x1133C},
  390. {0x11378, 0x1137C},
  391. {0x113B8, 0x113BC},
  392. {0x113F8, 0x113FC},
  393. {0x11438, 0x11440},
  394. {0x11478, 0x11480},
  395. {0x114B8, 0x114BC},
  396. {0x114F8, 0x114FC},
  397. {0x11538, 0x1153C},
  398. {0x11578, 0x1157C},
  399. {0x115B8, 0x115BC},
  400. {0x115F8, 0x115FC},
  401. {0x11638, 0x1163C},
  402. {0x11678, 0x1167C},
  403. {0x116B8, 0x116BC},
  404. {0x116F8, 0x116FC},
  405. {0x11738, 0x1173C},
  406. {0x11778, 0x1177C},
  407. {0x117B8, 0x117BC},
  408. {0x117F8, 0x117FC},
  409. {0x17000, 0x1701C},
  410. {0x17020, 0x170AC},
  411. {0x18000, 0x18050},
  412. {0x18054, 0x18074},
  413. {0x18080, 0x180D4},
  414. {0x180DC, 0x18104},
  415. {0x18108, 0x1813C},
  416. {0x18144, 0x18148},
  417. {0x18168, 0x18174},
  418. {0x18178, 0x18180},
  419. {0x181C8, 0x181E0},
  420. {0x181E4, 0x181E8},
  421. {0x181EC, 0x1820C},
  422. {0x1825C, 0x18280},
  423. {0x18284, 0x18290},
  424. {0x18294, 0x182A0},
  425. {0x18300, 0x18304},
  426. {0x18314, 0x18320},
  427. {0x18328, 0x18350},
  428. {0x1835C, 0x1836C},
  429. {0x18370, 0x18390},
  430. {0x18398, 0x183AC},
  431. {0x183BC, 0x183D8},
  432. {0x183DC, 0x183F4},
  433. {0x18400, 0x186F4},
  434. {0x186F8, 0x1871C},
  435. {0x18720, 0x18790},
  436. {0x19800, 0x19830},
  437. {0x19834, 0x19840},
  438. {0x19880, 0x1989C},
  439. {0x198A4, 0x198B0},
  440. {0x198BC, 0x19900},
  441. {0x19C00, 0x19C88},
  442. {0x19D00, 0x19D20},
  443. {0x19E00, 0x19E7C},
  444. {0x19E80, 0x19E94},
  445. {0x19E98, 0x19EAC},
  446. {0x19EB0, 0x19EBC},
  447. {0x19F70, 0x19F74},
  448. {0x19F80, 0x19F8C},
  449. {0x19FA0, 0x19FB4},
  450. {0x19FC0, 0x19FD8},
  451. {0x1A000, 0x1A200},
  452. {0x1A204, 0x1A210},
  453. {0x1A228, 0x1A22C},
  454. {0x1A230, 0x1A248},
  455. {0x1A250, 0x1A270},
  456. {0x1A280, 0x1A290},
  457. {0x1A2A0, 0x1A2A4},
  458. {0x1A2C0, 0x1A2EC},
  459. {0x1A300, 0x1A3BC},
  460. {0x1A3F0, 0x1A3F4},
  461. {0x1A3F8, 0x1A434},
  462. {0x1A438, 0x1A444},
  463. {0x1A448, 0x1A468},
  464. {0x1A580, 0x1A58C},
  465. {0x1A644, 0x1A654},
  466. {0x1A670, 0x1A698},
  467. {0x1A6AC, 0x1A6B0},
  468. {0x1A6D0, 0x1A6D4},
  469. {0x1A6EC, 0x1A70C},
  470. {0x1A710, 0x1A738},
  471. {0x1A7C0, 0x1A7D0},
  472. {0x1A7D4, 0x1A7D8},
  473. {0x1A7DC, 0x1A7E4},
  474. {0x1A7F0, 0x1A7F8},
  475. {0x1A888, 0x1A89C},
  476. {0x1A8A8, 0x1A8AC},
  477. {0x1A8C0, 0x1A8DC},
  478. {0x1A8F0, 0x1A8FC},
  479. {0x1AE04, 0x1AE08},
  480. {0x1AE18, 0x1AE24},
  481. {0x1AF80, 0x1AF8C},
  482. {0x1AFA0, 0x1AFB4},
  483. {0x1B000, 0x1B200},
  484. {0x1B284, 0x1B288},
  485. {0x1B2D0, 0x1B2D8},
  486. {0x1B2DC, 0x1B2EC},
  487. {0x1B300, 0x1B340},
  488. {0x1B374, 0x1B378},
  489. {0x1B380, 0x1B384},
  490. {0x1B388, 0x1B38C},
  491. {0x1B404, 0x1B408},
  492. {0x1B420, 0x1B428},
  493. {0x1B440, 0x1B444},
  494. {0x1B448, 0x1B44C},
  495. {0x1B450, 0x1B458},
  496. {0x1B45C, 0x1B468},
  497. {0x1B584, 0x1B58C},
  498. {0x1B68C, 0x1B690},
  499. {0x1B6AC, 0x1B6B0},
  500. {0x1B7F0, 0x1B7F8},
  501. {0x1C800, 0x1CC00},
  502. {0x1CE00, 0x1CE04},
  503. {0x1CF80, 0x1CF84},
  504. {0x1D200, 0x1D800},
  505. {0x1E000, 0x20014},
  506. {0x20100, 0x20124},
  507. {0x21400, 0x217A8},
  508. {0x21800, 0x21BA8},
  509. {0x21C00, 0x21FA8},
  510. {0x22000, 0x223A8},
  511. {0x22400, 0x227A8},
  512. {0x22800, 0x22BA8},
  513. {0x22C00, 0x22FA8},
  514. {0x23000, 0x233A8},
  515. {0x24000, 0x24034},
  516. {0x26000, 0x26064},
  517. {0x27000, 0x27024},
  518. {0x34000, 0x3400C},
  519. {0x34400, 0x3445C},
  520. {0x34800, 0x3485C},
  521. {0x34C00, 0x34C5C},
  522. {0x35000, 0x3505C},
  523. {0x35400, 0x3545C},
  524. {0x35800, 0x3585C},
  525. {0x35C00, 0x35C5C},
  526. {0x36000, 0x3605C},
  527. {0x38000, 0x38064},
  528. {0x38070, 0x380E0},
  529. {0x3A000, 0x3A074},
  530. {0x40000, 0x400A4},
  531. {0x80000, 0x8000C},
  532. {0x80010, 0x80020},
  533. };
  534. static const struct ath10k_mem_region qca6174_hw10_mem_regions[] = {
  535. {
  536. .type = ATH10K_MEM_REGION_TYPE_DRAM,
  537. .start = 0x400000,
  538. .len = 0x70000,
  539. .name = "DRAM",
  540. .section_table = {
  541. .sections = NULL,
  542. .size = 0,
  543. },
  544. },
  545. {
  546. .type = ATH10K_MEM_REGION_TYPE_REG,
  547. /* RTC_SOC_BASE_ADDRESS */
  548. .start = 0x0,
  549. /* WLAN_MBOX_BASE_ADDRESS - RTC_SOC_BASE_ADDRESS */
  550. .len = 0x800 - 0x0,
  551. .name = "REG_PART1",
  552. .section_table = {
  553. .sections = NULL,
  554. .size = 0,
  555. },
  556. },
  557. {
  558. .type = ATH10K_MEM_REGION_TYPE_REG,
  559. /* STEREO_BASE_ADDRESS */
  560. .start = 0x27000,
  561. /* USB_BASE_ADDRESS - STEREO_BASE_ADDRESS */
  562. .len = 0x60000 - 0x27000,
  563. .name = "REG_PART2",
  564. .section_table = {
  565. .sections = NULL,
  566. .size = 0,
  567. },
  568. },
  569. };
  570. static const struct ath10k_mem_region qca6174_hw21_mem_regions[] = {
  571. {
  572. .type = ATH10K_MEM_REGION_TYPE_DRAM,
  573. .start = 0x400000,
  574. .len = 0x70000,
  575. .name = "DRAM",
  576. .section_table = {
  577. .sections = NULL,
  578. .size = 0,
  579. },
  580. },
  581. {
  582. .type = ATH10K_MEM_REGION_TYPE_AXI,
  583. .start = 0xa0000,
  584. .len = 0x18000,
  585. .name = "AXI",
  586. .section_table = {
  587. .sections = NULL,
  588. .size = 0,
  589. },
  590. },
  591. {
  592. .type = ATH10K_MEM_REGION_TYPE_REG,
  593. .start = 0x800,
  594. .len = 0x80020 - 0x800,
  595. .name = "REG_TOTAL",
  596. .section_table = {
  597. .sections = qca6174_hw21_register_sections,
  598. .size = ARRAY_SIZE(qca6174_hw21_register_sections),
  599. },
  600. },
  601. };
  602. static const struct ath10k_mem_region qca6174_hw30_mem_regions[] = {
  603. {
  604. .type = ATH10K_MEM_REGION_TYPE_DRAM,
  605. .start = 0x400000,
  606. .len = 0xa8000,
  607. .name = "DRAM",
  608. .section_table = {
  609. .sections = NULL,
  610. .size = 0,
  611. },
  612. },
  613. {
  614. .type = ATH10K_MEM_REGION_TYPE_AXI,
  615. .start = 0xa0000,
  616. .len = 0x18000,
  617. .name = "AXI",
  618. .section_table = {
  619. .sections = NULL,
  620. .size = 0,
  621. },
  622. },
  623. {
  624. .type = ATH10K_MEM_REGION_TYPE_REG,
  625. .start = 0x800,
  626. .len = 0x80020 - 0x800,
  627. .name = "REG_TOTAL",
  628. .section_table = {
  629. .sections = qca6174_hw30_register_sections,
  630. .size = ARRAY_SIZE(qca6174_hw30_register_sections),
  631. },
  632. },
  633. /* IRAM dump must be put last */
  634. {
  635. .type = ATH10K_MEM_REGION_TYPE_IRAM1,
  636. .start = 0x00980000,
  637. .len = 0x00080000,
  638. .name = "IRAM1",
  639. .section_table = {
  640. .sections = NULL,
  641. .size = 0,
  642. },
  643. },
  644. {
  645. .type = ATH10K_MEM_REGION_TYPE_IRAM2,
  646. .start = 0x00a00000,
  647. .len = 0x00040000,
  648. .name = "IRAM2",
  649. .section_table = {
  650. .sections = NULL,
  651. .size = 0,
  652. },
  653. },
  654. };
  655. static const struct ath10k_mem_region qca988x_hw20_mem_regions[] = {
  656. {
  657. .type = ATH10K_MEM_REGION_TYPE_DRAM,
  658. .start = 0x400000,
  659. .len = 0x50000,
  660. .name = "DRAM",
  661. .section_table = {
  662. .sections = NULL,
  663. .size = 0,
  664. },
  665. },
  666. {
  667. .type = ATH10K_MEM_REGION_TYPE_REG,
  668. .start = 0x4000,
  669. .len = 0x2000,
  670. .name = "REG_PART1",
  671. .section_table = {
  672. .sections = NULL,
  673. .size = 0,
  674. },
  675. },
  676. {
  677. .type = ATH10K_MEM_REGION_TYPE_REG,
  678. .start = 0x8000,
  679. .len = 0x58000,
  680. .name = "REG_PART2",
  681. .section_table = {
  682. .sections = NULL,
  683. .size = 0,
  684. },
  685. },
  686. };
  687. static const struct ath10k_mem_region qca9984_hw10_mem_regions[] = {
  688. {
  689. .type = ATH10K_MEM_REGION_TYPE_DRAM,
  690. .start = 0x400000,
  691. .len = 0x80000,
  692. .name = "DRAM",
  693. .section_table = {
  694. .sections = NULL,
  695. .size = 0,
  696. },
  697. },
  698. {
  699. .type = ATH10K_MEM_REGION_TYPE_REG,
  700. .start = 0x98000,
  701. .len = 0x50000,
  702. .name = "IRAM",
  703. .section_table = {
  704. .sections = NULL,
  705. .size = 0,
  706. },
  707. },
  708. {
  709. .type = ATH10K_MEM_REGION_TYPE_IOSRAM,
  710. .start = 0xC0000,
  711. .len = 0x40000,
  712. .name = "SRAM",
  713. .section_table = {
  714. .sections = NULL,
  715. .size = 0,
  716. },
  717. },
  718. {
  719. .type = ATH10K_MEM_REGION_TYPE_IOREG,
  720. .start = 0x30000,
  721. .len = 0x7000,
  722. .name = "APB REG 1",
  723. .section_table = {
  724. .sections = NULL,
  725. .size = 0,
  726. },
  727. },
  728. {
  729. .type = ATH10K_MEM_REGION_TYPE_IOREG,
  730. .start = 0x3f000,
  731. .len = 0x3000,
  732. .name = "APB REG 2",
  733. .section_table = {
  734. .sections = NULL,
  735. .size = 0,
  736. },
  737. },
  738. {
  739. .type = ATH10K_MEM_REGION_TYPE_IOREG,
  740. .start = 0x43000,
  741. .len = 0x3000,
  742. .name = "WIFI REG",
  743. .section_table = {
  744. .sections = NULL,
  745. .size = 0,
  746. },
  747. },
  748. {
  749. .type = ATH10K_MEM_REGION_TYPE_IOREG,
  750. .start = 0x4A000,
  751. .len = 0x5000,
  752. .name = "CE REG",
  753. .section_table = {
  754. .sections = NULL,
  755. .size = 0,
  756. },
  757. },
  758. {
  759. .type = ATH10K_MEM_REGION_TYPE_IOREG,
  760. .start = 0x80000,
  761. .len = 0x6000,
  762. .name = "SOC REG",
  763. .section_table = {
  764. .sections = NULL,
  765. .size = 0,
  766. },
  767. },
  768. };
  769. static const struct ath10k_hw_mem_layout hw_mem_layouts[] = {
  770. {
  771. .hw_id = QCA6174_HW_1_0_VERSION,
  772. .region_table = {
  773. .regions = qca6174_hw10_mem_regions,
  774. .size = ARRAY_SIZE(qca6174_hw10_mem_regions),
  775. },
  776. },
  777. {
  778. .hw_id = QCA6174_HW_1_1_VERSION,
  779. .region_table = {
  780. .regions = qca6174_hw10_mem_regions,
  781. .size = ARRAY_SIZE(qca6174_hw10_mem_regions),
  782. },
  783. },
  784. {
  785. .hw_id = QCA6174_HW_1_3_VERSION,
  786. .region_table = {
  787. .regions = qca6174_hw10_mem_regions,
  788. .size = ARRAY_SIZE(qca6174_hw10_mem_regions),
  789. },
  790. },
  791. {
  792. .hw_id = QCA6174_HW_2_1_VERSION,
  793. .region_table = {
  794. .regions = qca6174_hw21_mem_regions,
  795. .size = ARRAY_SIZE(qca6174_hw21_mem_regions),
  796. },
  797. },
  798. {
  799. .hw_id = QCA6174_HW_3_0_VERSION,
  800. .region_table = {
  801. .regions = qca6174_hw30_mem_regions,
  802. .size = ARRAY_SIZE(qca6174_hw30_mem_regions),
  803. },
  804. },
  805. {
  806. .hw_id = QCA6174_HW_3_2_VERSION,
  807. .region_table = {
  808. .regions = qca6174_hw30_mem_regions,
  809. .size = ARRAY_SIZE(qca6174_hw30_mem_regions),
  810. },
  811. },
  812. {
  813. .hw_id = QCA9377_HW_1_1_DEV_VERSION,
  814. .region_table = {
  815. .regions = qca6174_hw30_mem_regions,
  816. .size = ARRAY_SIZE(qca6174_hw30_mem_regions),
  817. },
  818. },
  819. {
  820. .hw_id = QCA988X_HW_2_0_VERSION,
  821. .region_table = {
  822. .regions = qca988x_hw20_mem_regions,
  823. .size = ARRAY_SIZE(qca988x_hw20_mem_regions),
  824. },
  825. },
  826. {
  827. .hw_id = QCA9984_HW_1_0_DEV_VERSION,
  828. .region_table = {
  829. .regions = qca9984_hw10_mem_regions,
  830. .size = ARRAY_SIZE(qca9984_hw10_mem_regions),
  831. },
  832. },
  833. };
  834. static u32 ath10k_coredump_get_ramdump_size(struct ath10k *ar)
  835. {
  836. const struct ath10k_hw_mem_layout *hw;
  837. const struct ath10k_mem_region *mem_region;
  838. size_t size = 0;
  839. int i;
  840. hw = ath10k_coredump_get_mem_layout(ar);
  841. if (!hw)
  842. return 0;
  843. mem_region = &hw->region_table.regions[0];
  844. for (i = 0; i < hw->region_table.size; i++) {
  845. size += mem_region->len;
  846. mem_region++;
  847. }
  848. /* reserve space for the headers */
  849. size += hw->region_table.size * sizeof(struct ath10k_dump_ram_data_hdr);
  850. /* make sure it is aligned 16 bytes for debug message print out */
  851. size = ALIGN(size, 16);
  852. return size;
  853. }
  854. const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar)
  855. {
  856. int i;
  857. if (!test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask))
  858. return NULL;
  859. if (WARN_ON(ar->target_version == 0))
  860. return NULL;
  861. for (i = 0; i < ARRAY_SIZE(hw_mem_layouts); i++) {
  862. if (ar->target_version == hw_mem_layouts[i].hw_id)
  863. return &hw_mem_layouts[i];
  864. }
  865. return NULL;
  866. }
  867. EXPORT_SYMBOL(ath10k_coredump_get_mem_layout);
  868. struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar)
  869. {
  870. struct ath10k_fw_crash_data *crash_data = ar->coredump.fw_crash_data;
  871. lockdep_assert_held(&ar->data_lock);
  872. if (ath10k_coredump_mask == 0)
  873. /* coredump disabled */
  874. return NULL;
  875. guid_gen(&crash_data->guid);
  876. ktime_get_real_ts64(&crash_data->timestamp);
  877. return crash_data;
  878. }
  879. EXPORT_SYMBOL(ath10k_coredump_new);
  880. static struct ath10k_dump_file_data *ath10k_coredump_build(struct ath10k *ar)
  881. {
  882. struct ath10k_fw_crash_data *crash_data = ar->coredump.fw_crash_data;
  883. struct ath10k_ce_crash_hdr *ce_hdr;
  884. struct ath10k_dump_file_data *dump_data;
  885. struct ath10k_tlv_dump_data *dump_tlv;
  886. size_t hdr_len = sizeof(*dump_data);
  887. size_t len, sofar = 0;
  888. unsigned char *buf;
  889. len = hdr_len;
  890. if (test_bit(ATH10K_FW_CRASH_DUMP_REGISTERS, &ath10k_coredump_mask))
  891. len += sizeof(*dump_tlv) + sizeof(crash_data->registers);
  892. if (test_bit(ATH10K_FW_CRASH_DUMP_CE_DATA, &ath10k_coredump_mask))
  893. len += sizeof(*dump_tlv) + sizeof(*ce_hdr) +
  894. CE_COUNT * sizeof(ce_hdr->entries[0]);
  895. if (test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask))
  896. len += sizeof(*dump_tlv) + crash_data->ramdump_buf_len;
  897. sofar += hdr_len;
  898. /* This is going to get big when we start dumping FW RAM and such,
  899. * so go ahead and use vmalloc.
  900. */
  901. buf = vzalloc(len);
  902. if (!buf)
  903. return NULL;
  904. spin_lock_bh(&ar->data_lock);
  905. dump_data = (struct ath10k_dump_file_data *)(buf);
  906. strlcpy(dump_data->df_magic, "ATH10K-FW-DUMP",
  907. sizeof(dump_data->df_magic));
  908. dump_data->len = cpu_to_le32(len);
  909. dump_data->version = cpu_to_le32(ATH10K_FW_CRASH_DUMP_VERSION);
  910. guid_copy(&dump_data->guid, &crash_data->guid);
  911. dump_data->chip_id = cpu_to_le32(ar->chip_id);
  912. dump_data->bus_type = cpu_to_le32(0);
  913. dump_data->target_version = cpu_to_le32(ar->target_version);
  914. dump_data->fw_version_major = cpu_to_le32(ar->fw_version_major);
  915. dump_data->fw_version_minor = cpu_to_le32(ar->fw_version_minor);
  916. dump_data->fw_version_release = cpu_to_le32(ar->fw_version_release);
  917. dump_data->fw_version_build = cpu_to_le32(ar->fw_version_build);
  918. dump_data->phy_capability = cpu_to_le32(ar->phy_capability);
  919. dump_data->hw_min_tx_power = cpu_to_le32(ar->hw_min_tx_power);
  920. dump_data->hw_max_tx_power = cpu_to_le32(ar->hw_max_tx_power);
  921. dump_data->ht_cap_info = cpu_to_le32(ar->ht_cap_info);
  922. dump_data->vht_cap_info = cpu_to_le32(ar->vht_cap_info);
  923. dump_data->num_rf_chains = cpu_to_le32(ar->num_rf_chains);
  924. strlcpy(dump_data->fw_ver, ar->hw->wiphy->fw_version,
  925. sizeof(dump_data->fw_ver));
  926. dump_data->kernel_ver_code = 0;
  927. strlcpy(dump_data->kernel_ver, init_utsname()->release,
  928. sizeof(dump_data->kernel_ver));
  929. dump_data->tv_sec = cpu_to_le64(crash_data->timestamp.tv_sec);
  930. dump_data->tv_nsec = cpu_to_le64(crash_data->timestamp.tv_nsec);
  931. if (test_bit(ATH10K_FW_CRASH_DUMP_REGISTERS, &ath10k_coredump_mask)) {
  932. dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
  933. dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_REGISTERS);
  934. dump_tlv->tlv_len = cpu_to_le32(sizeof(crash_data->registers));
  935. memcpy(dump_tlv->tlv_data, &crash_data->registers,
  936. sizeof(crash_data->registers));
  937. sofar += sizeof(*dump_tlv) + sizeof(crash_data->registers);
  938. }
  939. if (test_bit(ATH10K_FW_CRASH_DUMP_CE_DATA, &ath10k_coredump_mask)) {
  940. dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
  941. dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_CE_DATA);
  942. dump_tlv->tlv_len = cpu_to_le32(sizeof(*ce_hdr) +
  943. CE_COUNT * sizeof(ce_hdr->entries[0]));
  944. ce_hdr = (struct ath10k_ce_crash_hdr *)(dump_tlv->tlv_data);
  945. ce_hdr->ce_count = cpu_to_le32(CE_COUNT);
  946. memset(ce_hdr->reserved, 0, sizeof(ce_hdr->reserved));
  947. memcpy(ce_hdr->entries, crash_data->ce_crash_data,
  948. CE_COUNT * sizeof(ce_hdr->entries[0]));
  949. sofar += sizeof(*dump_tlv) + sizeof(*ce_hdr) +
  950. CE_COUNT * sizeof(ce_hdr->entries[0]);
  951. }
  952. /* Gather ram dump */
  953. if (test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask)) {
  954. dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
  955. dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_RAM_DATA);
  956. dump_tlv->tlv_len = cpu_to_le32(crash_data->ramdump_buf_len);
  957. memcpy(dump_tlv->tlv_data, crash_data->ramdump_buf,
  958. crash_data->ramdump_buf_len);
  959. sofar += sizeof(*dump_tlv) + crash_data->ramdump_buf_len;
  960. }
  961. spin_unlock_bh(&ar->data_lock);
  962. return dump_data;
  963. }
  964. int ath10k_coredump_submit(struct ath10k *ar)
  965. {
  966. struct ath10k_dump_file_data *dump;
  967. if (ath10k_coredump_mask == 0)
  968. /* coredump disabled */
  969. return 0;
  970. dump = ath10k_coredump_build(ar);
  971. if (!dump) {
  972. ath10k_warn(ar, "no crash dump data found for devcoredump");
  973. return -ENODATA;
  974. }
  975. dev_coredumpv(ar->dev, dump, le32_to_cpu(dump->len), GFP_KERNEL);
  976. return 0;
  977. }
  978. int ath10k_coredump_create(struct ath10k *ar)
  979. {
  980. if (ath10k_coredump_mask == 0)
  981. /* coredump disabled */
  982. return 0;
  983. ar->coredump.fw_crash_data = vzalloc(sizeof(*ar->coredump.fw_crash_data));
  984. if (!ar->coredump.fw_crash_data)
  985. return -ENOMEM;
  986. return 0;
  987. }
  988. int ath10k_coredump_register(struct ath10k *ar)
  989. {
  990. struct ath10k_fw_crash_data *crash_data = ar->coredump.fw_crash_data;
  991. if (test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask)) {
  992. crash_data->ramdump_buf_len = ath10k_coredump_get_ramdump_size(ar);
  993. crash_data->ramdump_buf = vzalloc(crash_data->ramdump_buf_len);
  994. if (!crash_data->ramdump_buf)
  995. return -ENOMEM;
  996. }
  997. return 0;
  998. }
  999. void ath10k_coredump_unregister(struct ath10k *ar)
  1000. {
  1001. struct ath10k_fw_crash_data *crash_data = ar->coredump.fw_crash_data;
  1002. vfree(crash_data->ramdump_buf);
  1003. }
  1004. void ath10k_coredump_destroy(struct ath10k *ar)
  1005. {
  1006. if (ar->coredump.fw_crash_data->ramdump_buf) {
  1007. vfree(ar->coredump.fw_crash_data->ramdump_buf);
  1008. ar->coredump.fw_crash_data->ramdump_buf = NULL;
  1009. ar->coredump.fw_crash_data->ramdump_buf_len = 0;
  1010. }
  1011. vfree(ar->coredump.fw_crash_data);
  1012. ar->coredump.fw_crash_data = NULL;
  1013. }