ipa_data-v3.1.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2019-2024 Linaro Ltd.
  4. */
  5. #include <linux/array_size.h>
  6. #include <linux/log2.h>
  7. #include "../ipa_data.h"
  8. #include "../ipa_endpoint.h"
  9. #include "../ipa_mem.h"
  10. #include "../ipa_version.h"
  11. /** enum ipa_resource_type - IPA resource types for an SoC having IPA v3.1 */
  12. enum ipa_resource_type {
  13. /* Source resource types; first must have value 0 */
  14. IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS = 0,
  15. IPA_RESOURCE_TYPE_SRC_HDR_SECTORS,
  16. IPA_RESOURCE_TYPE_SRC_HDRI1_BUFFER,
  17. IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
  18. IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
  19. IPA_RESOURCE_TYPE_SRC_HDRI2_BUFFERS,
  20. IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
  21. IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
  22. /* Destination resource types; first must have value 0 */
  23. IPA_RESOURCE_TYPE_DST_DATA_SECTORS = 0,
  24. IPA_RESOURCE_TYPE_DST_DATA_SECTOR_LISTS,
  25. IPA_RESOURCE_TYPE_DST_DPS_DMARS,
  26. };
  27. /* Resource groups used for an SoC having IPA v3.1 */
  28. enum ipa_rsrc_group_id {
  29. /* Source resource group identifiers */
  30. IPA_RSRC_GROUP_SRC_UL = 0,
  31. IPA_RSRC_GROUP_SRC_DL,
  32. IPA_RSRC_GROUP_SRC_DIAG,
  33. IPA_RSRC_GROUP_SRC_DMA,
  34. IPA_RSRC_GROUP_SRC_UNUSED,
  35. IPA_RSRC_GROUP_SRC_UC_RX_Q,
  36. IPA_RSRC_GROUP_SRC_COUNT, /* Last in set; not a source group */
  37. /* Destination resource group identifiers */
  38. IPA_RSRC_GROUP_DST_UL = 0,
  39. IPA_RSRC_GROUP_DST_DL,
  40. IPA_RSRC_GROUP_DST_DIAG_DPL,
  41. IPA_RSRC_GROUP_DST_DMA,
  42. IPA_RSRC_GROUP_DST_Q6ZIP_GENERAL,
  43. IPA_RSRC_GROUP_DST_Q6ZIP_ENGINE,
  44. IPA_RSRC_GROUP_DST_COUNT, /* Last; not a destination group */
  45. };
  46. /* QSB configuration data for an SoC having IPA v3.1 */
  47. static const struct ipa_qsb_data ipa_qsb_data[] = {
  48. [IPA_QSB_MASTER_DDR] = {
  49. .max_writes = 8,
  50. .max_reads = 8,
  51. },
  52. [IPA_QSB_MASTER_PCIE] = {
  53. .max_writes = 2,
  54. .max_reads = 8,
  55. },
  56. };
  57. /* Endpoint data for an SoC having IPA v3.1 */
  58. static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
  59. [IPA_ENDPOINT_AP_COMMAND_TX] = {
  60. .ee_id = GSI_EE_AP,
  61. .channel_id = 6,
  62. .endpoint_id = 22,
  63. .toward_ipa = true,
  64. .channel = {
  65. .tre_count = 256,
  66. .event_count = 256,
  67. .tlv_count = 18,
  68. },
  69. .endpoint = {
  70. .config = {
  71. .resource_group = IPA_RSRC_GROUP_SRC_UL,
  72. .dma_mode = true,
  73. .dma_endpoint = IPA_ENDPOINT_AP_LAN_RX,
  74. .tx = {
  75. .seq_type = IPA_SEQ_DMA,
  76. },
  77. },
  78. },
  79. },
  80. [IPA_ENDPOINT_AP_LAN_RX] = {
  81. .ee_id = GSI_EE_AP,
  82. .channel_id = 7,
  83. .endpoint_id = 15,
  84. .toward_ipa = false,
  85. .channel = {
  86. .tre_count = 256,
  87. .event_count = 256,
  88. .tlv_count = 8,
  89. },
  90. .endpoint = {
  91. .config = {
  92. .resource_group = IPA_RSRC_GROUP_SRC_UL,
  93. .aggregation = true,
  94. .status_enable = true,
  95. .rx = {
  96. .buffer_size = 8192,
  97. .pad_align = ilog2(sizeof(u32)),
  98. .aggr_time_limit = 500,
  99. },
  100. },
  101. },
  102. },
  103. [IPA_ENDPOINT_AP_MODEM_TX] = {
  104. .ee_id = GSI_EE_AP,
  105. .channel_id = 5,
  106. .endpoint_id = 3,
  107. .toward_ipa = true,
  108. .channel = {
  109. .tre_count = 512,
  110. .event_count = 512,
  111. .tlv_count = 16,
  112. },
  113. .endpoint = {
  114. .filter_support = true,
  115. .config = {
  116. .resource_group = IPA_RSRC_GROUP_SRC_UL,
  117. .checksum = true,
  118. .qmap = true,
  119. .status_enable = true,
  120. .tx = {
  121. .seq_type = IPA_SEQ_2_PASS_SKIP_LAST_UC,
  122. .status_endpoint =
  123. IPA_ENDPOINT_MODEM_AP_RX,
  124. },
  125. },
  126. },
  127. },
  128. [IPA_ENDPOINT_AP_MODEM_RX] = {
  129. .ee_id = GSI_EE_AP,
  130. .channel_id = 8,
  131. .endpoint_id = 16,
  132. .toward_ipa = false,
  133. .channel = {
  134. .tre_count = 256,
  135. .event_count = 256,
  136. .tlv_count = 8,
  137. },
  138. .endpoint = {
  139. .config = {
  140. .resource_group = IPA_RSRC_GROUP_DST_DL,
  141. .checksum = true,
  142. .qmap = true,
  143. .aggregation = true,
  144. .rx = {
  145. .buffer_size = 8192,
  146. .aggr_time_limit = 500,
  147. .aggr_close_eof = true,
  148. },
  149. },
  150. },
  151. },
  152. [IPA_ENDPOINT_MODEM_LAN_TX] = {
  153. .ee_id = GSI_EE_MODEM,
  154. .channel_id = 4,
  155. .endpoint_id = 9,
  156. .toward_ipa = true,
  157. .endpoint = {
  158. .filter_support = true,
  159. },
  160. },
  161. [IPA_ENDPOINT_MODEM_AP_TX] = {
  162. .ee_id = GSI_EE_MODEM,
  163. .channel_id = 0,
  164. .endpoint_id = 5,
  165. .toward_ipa = true,
  166. .endpoint = {
  167. .filter_support = true,
  168. },
  169. },
  170. [IPA_ENDPOINT_MODEM_AP_RX] = {
  171. .ee_id = GSI_EE_MODEM,
  172. .channel_id = 5,
  173. .endpoint_id = 18,
  174. .toward_ipa = false,
  175. },
  176. };
  177. /* Source resource configuration data for an SoC having IPA v3.1 */
  178. static const struct ipa_resource ipa_resource_src[] = {
  179. [IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS] = {
  180. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  181. .min = 3, .max = 255,
  182. },
  183. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  184. .min = 3, .max = 255,
  185. },
  186. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  187. .min = 1, .max = 255,
  188. },
  189. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  190. .min = 1, .max = 255,
  191. },
  192. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  193. .min = 2, .max = 255,
  194. },
  195. },
  196. [IPA_RESOURCE_TYPE_SRC_HDR_SECTORS] = {
  197. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  198. .min = 0, .max = 255,
  199. },
  200. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  201. .min = 0, .max = 255,
  202. },
  203. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  204. .min = 0, .max = 255,
  205. },
  206. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  207. .min = 0, .max = 255,
  208. },
  209. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  210. .min = 0, .max = 255,
  211. },
  212. },
  213. [IPA_RESOURCE_TYPE_SRC_HDRI1_BUFFER] = {
  214. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  215. .min = 0, .max = 255,
  216. },
  217. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  218. .min = 0, .max = 255,
  219. },
  220. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  221. .min = 0, .max = 255,
  222. },
  223. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  224. .min = 0, .max = 255,
  225. },
  226. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  227. .min = 0, .max = 255,
  228. },
  229. },
  230. [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS] = {
  231. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  232. .min = 14, .max = 14,
  233. },
  234. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  235. .min = 16, .max = 16,
  236. },
  237. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  238. .min = 5, .max = 5,
  239. },
  240. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  241. .min = 5, .max = 5,
  242. },
  243. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  244. .min = 8, .max = 8,
  245. },
  246. },
  247. [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF] = {
  248. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  249. .min = 19, .max = 19,
  250. },
  251. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  252. .min = 26, .max = 26,
  253. },
  254. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  255. .min = 5, .max = 5, /* 3 downstream */
  256. },
  257. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  258. .min = 5, .max = 5, /* 7 downstream */
  259. },
  260. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  261. .min = 8, .max = 8,
  262. },
  263. },
  264. [IPA_RESOURCE_TYPE_SRC_HDRI2_BUFFERS] = {
  265. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  266. .min = 0, .max = 255,
  267. },
  268. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  269. .min = 0, .max = 255,
  270. },
  271. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  272. .min = 0, .max = 255,
  273. },
  274. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  275. .min = 0, .max = 255,
  276. },
  277. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  278. .min = 0, .max = 255,
  279. },
  280. },
  281. [IPA_RESOURCE_TYPE_SRC_HPS_DMARS] = {
  282. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  283. .min = 0, .max = 255,
  284. },
  285. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  286. .min = 0, .max = 255,
  287. },
  288. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  289. .min = 0, .max = 255,
  290. },
  291. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  292. .min = 0, .max = 255,
  293. },
  294. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  295. .min = 0, .max = 255,
  296. },
  297. },
  298. [IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES] = {
  299. .limits[IPA_RSRC_GROUP_SRC_UL] = {
  300. .min = 19, .max = 19,
  301. },
  302. .limits[IPA_RSRC_GROUP_SRC_DL] = {
  303. .min = 26, .max = 26,
  304. },
  305. .limits[IPA_RSRC_GROUP_SRC_DIAG] = {
  306. .min = 5, .max = 5,
  307. },
  308. .limits[IPA_RSRC_GROUP_SRC_DMA] = {
  309. .min = 5, .max = 5,
  310. },
  311. .limits[IPA_RSRC_GROUP_SRC_UC_RX_Q] = {
  312. .min = 8, .max = 8,
  313. },
  314. },
  315. };
  316. /* Destination resource configuration data for an SoC having IPA v3.1 */
  317. static const struct ipa_resource ipa_resource_dst[] = {
  318. [IPA_RESOURCE_TYPE_DST_DATA_SECTORS] = {
  319. .limits[IPA_RSRC_GROUP_DST_UL] = {
  320. .min = 3, .max = 3, /* 2 downstream */
  321. },
  322. .limits[IPA_RSRC_GROUP_DST_DL] = {
  323. .min = 3, .max = 3,
  324. },
  325. .limits[IPA_RSRC_GROUP_DST_DIAG_DPL] = {
  326. .min = 1, .max = 1, /* 0 downstream */
  327. },
  328. /* IPA_RSRC_GROUP_DST_DMA uses 2 downstream */
  329. .limits[IPA_RSRC_GROUP_DST_Q6ZIP_GENERAL] = {
  330. .min = 3, .max = 3,
  331. },
  332. .limits[IPA_RSRC_GROUP_DST_Q6ZIP_ENGINE] = {
  333. .min = 3, .max = 3,
  334. },
  335. },
  336. [IPA_RESOURCE_TYPE_DST_DATA_SECTOR_LISTS] = {
  337. .limits[IPA_RSRC_GROUP_DST_UL] = {
  338. .min = 0, .max = 255,
  339. },
  340. .limits[IPA_RSRC_GROUP_DST_DL] = {
  341. .min = 0, .max = 255,
  342. },
  343. .limits[IPA_RSRC_GROUP_DST_DIAG_DPL] = {
  344. .min = 0, .max = 255,
  345. },
  346. .limits[IPA_RSRC_GROUP_DST_DMA] = {
  347. .min = 0, .max = 255,
  348. },
  349. .limits[IPA_RSRC_GROUP_DST_Q6ZIP_GENERAL] = {
  350. .min = 0, .max = 255,
  351. },
  352. .limits[IPA_RSRC_GROUP_DST_Q6ZIP_ENGINE] = {
  353. .min = 0, .max = 255,
  354. },
  355. },
  356. [IPA_RESOURCE_TYPE_DST_DPS_DMARS] = {
  357. .limits[IPA_RSRC_GROUP_DST_UL] = {
  358. .min = 1, .max = 1,
  359. },
  360. .limits[IPA_RSRC_GROUP_DST_DL] = {
  361. .min = 1, .max = 1,
  362. },
  363. .limits[IPA_RSRC_GROUP_DST_DIAG_DPL] = {
  364. .min = 1, .max = 1,
  365. },
  366. .limits[IPA_RSRC_GROUP_DST_DMA] = {
  367. .min = 1, .max = 1,
  368. },
  369. .limits[IPA_RSRC_GROUP_DST_Q6ZIP_GENERAL] = {
  370. .min = 1, .max = 1,
  371. },
  372. },
  373. };
  374. /* Resource configuration data for an SoC having IPA v3.1 */
  375. static const struct ipa_resource_data ipa_resource_data = {
  376. .rsrc_group_src_count = IPA_RSRC_GROUP_SRC_COUNT,
  377. .rsrc_group_dst_count = IPA_RSRC_GROUP_DST_COUNT,
  378. .resource_src_count = ARRAY_SIZE(ipa_resource_src),
  379. .resource_src = ipa_resource_src,
  380. .resource_dst_count = ARRAY_SIZE(ipa_resource_dst),
  381. .resource_dst = ipa_resource_dst,
  382. };
  383. /* IPA-resident memory region data for an SoC having IPA v3.1 */
  384. static const struct ipa_mem ipa_mem_local_data[] = {
  385. {
  386. .id = IPA_MEM_UC_SHARED,
  387. .offset = 0x0000,
  388. .size = 0x0080,
  389. .canary_count = 0,
  390. },
  391. {
  392. .id = IPA_MEM_UC_INFO,
  393. .offset = 0x0080,
  394. .size = 0x0200,
  395. .canary_count = 0,
  396. },
  397. {
  398. .id = IPA_MEM_V4_FILTER_HASHED,
  399. .offset = 0x0288,
  400. .size = 0x0078,
  401. .canary_count = 2,
  402. },
  403. {
  404. .id = IPA_MEM_V4_FILTER,
  405. .offset = 0x0308,
  406. .size = 0x0078,
  407. .canary_count = 2,
  408. },
  409. {
  410. .id = IPA_MEM_V6_FILTER_HASHED,
  411. .offset = 0x0388,
  412. .size = 0x0078,
  413. .canary_count = 2,
  414. },
  415. {
  416. .id = IPA_MEM_V6_FILTER,
  417. .offset = 0x0408,
  418. .size = 0x0078,
  419. .canary_count = 2,
  420. },
  421. {
  422. .id = IPA_MEM_V4_ROUTE_HASHED,
  423. .offset = 0x0488,
  424. .size = 0x0078,
  425. .canary_count = 2,
  426. },
  427. {
  428. .id = IPA_MEM_V4_ROUTE,
  429. .offset = 0x0508,
  430. .size = 0x0078,
  431. .canary_count = 2,
  432. },
  433. {
  434. .id = IPA_MEM_V6_ROUTE_HASHED,
  435. .offset = 0x0588,
  436. .size = 0x0078,
  437. .canary_count = 2,
  438. },
  439. {
  440. .id = IPA_MEM_V6_ROUTE,
  441. .offset = 0x0608,
  442. .size = 0x0078,
  443. .canary_count = 2,
  444. },
  445. {
  446. .id = IPA_MEM_MODEM_HEADER,
  447. .offset = 0x0688,
  448. .size = 0x0140,
  449. .canary_count = 2,
  450. },
  451. {
  452. .id = IPA_MEM_MODEM_PROC_CTX,
  453. .offset = 0x07d0,
  454. .size = 0x0200,
  455. .canary_count = 2,
  456. },
  457. {
  458. .id = IPA_MEM_AP_PROC_CTX,
  459. .offset = 0x09d0,
  460. .size = 0x0200,
  461. .canary_count = 0,
  462. },
  463. {
  464. .id = IPA_MEM_MODEM,
  465. .offset = 0x0bd8,
  466. .size = 0x1424,
  467. .canary_count = 0,
  468. },
  469. {
  470. .id = IPA_MEM_END_MARKER,
  471. .offset = 0x2000,
  472. .size = 0,
  473. .canary_count = 1,
  474. },
  475. };
  476. /* Memory configuration data for an SoC having IPA v3.1 */
  477. static const struct ipa_mem_data ipa_mem_data = {
  478. .local_count = ARRAY_SIZE(ipa_mem_local_data),
  479. .local = ipa_mem_local_data,
  480. .imem_addr = 0x146bd000,
  481. .imem_size = 0x00002000,
  482. .smem_id = 497,
  483. .smem_size = 0x00002000,
  484. };
  485. /* Interconnect bandwidths are in 1000 byte/second units */
  486. static const struct ipa_interconnect_data ipa_interconnect_data[] = {
  487. {
  488. .name = "memory",
  489. .peak_bandwidth = 640000, /* 640 MBps */
  490. .average_bandwidth = 80000, /* 80 MBps */
  491. },
  492. {
  493. .name = "imem",
  494. .peak_bandwidth = 640000, /* 640 MBps */
  495. .average_bandwidth = 80000, /* 80 MBps */
  496. },
  497. /* Average bandwidth is unused for the next interconnect */
  498. {
  499. .name = "config",
  500. .peak_bandwidth = 80000, /* 80 MBps */
  501. .average_bandwidth = 0, /* unused */
  502. },
  503. };
  504. /* Clock and interconnect configuration data for an SoC having IPA v3.1 */
  505. static const struct ipa_power_data ipa_power_data = {
  506. .core_clock_rate = 16 * 1000 * 1000, /* Hz */
  507. .interconnect_count = ARRAY_SIZE(ipa_interconnect_data),
  508. .interconnect_data = ipa_interconnect_data,
  509. };
  510. /* Configuration data for an SoC having IPA v3.1 */
  511. const struct ipa_data ipa_data_v3_1 = {
  512. .version = IPA_VERSION_3_1,
  513. .backward_compat = BIT(BCR_CMDQ_L_LACK_ONE_ENTRY),
  514. .qsb_count = ARRAY_SIZE(ipa_qsb_data),
  515. .qsb_data = ipa_qsb_data,
  516. .modem_route_count = 8,
  517. .endpoint_count = ARRAY_SIZE(ipa_gsi_endpoint_data),
  518. .endpoint_data = ipa_gsi_endpoint_data,
  519. .resource_data = &ipa_resource_data,
  520. .mem_data = &ipa_mem_data,
  521. .power_data = &ipa_power_data,
  522. };