ipa_data.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. #ifndef _IPA_DATA_H_
  6. #define _IPA_DATA_H_
  7. #include <linux/types.h>
  8. #include "ipa_endpoint.h"
  9. #include "ipa_mem.h"
  10. #include "ipa_version.h"
  11. /**
  12. * DOC: IPA/GSI Configuration Data
  13. *
  14. * Boot-time configuration data is used to define the configuration of the
  15. * IPA and GSI resources to use for a given platform. This data is supplied
  16. * via the Device Tree match table, associated with a particular compatible
  17. * string. The data defines information about how resources, endpoints and
  18. * channels, memory, power and so on are allocated and used for the
  19. * platform.
  20. *
  21. * Resources are data structures used internally by the IPA hardware. The
  22. * configuration data defines the number (or limits of the number) of various
  23. * types of these resources.
  24. *
  25. * Endpoint configuration data defines properties of both IPA endpoints and
  26. * GSI channels. A channel is a GSI construct, and represents a single
  27. * communication path between the IPA and a particular execution environment
  28. * (EE), such as the AP or Modem. Each EE has a set of channels associated
  29. * with it, and each channel has an ID unique for that EE. For the most part
  30. * the only GSI channels of concern to this driver belong to the AP.
  31. *
  32. * An endpoint is an IPA construct representing a single channel anywhere
  33. * in the system. An IPA endpoint ID maps directly to an (EE, channel_id)
  34. * pair. Generally, this driver is concerned with only endpoints associated
  35. * with the AP, however this will change when support for routing (etc.) is
  36. * added. IPA endpoint and GSI channel configuration data are defined
  37. * together, establishing the endpoint_id->(EE, channel_id) mapping.
  38. *
  39. * Endpoint configuration data consists of three parts: properties that
  40. * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
  41. * properties associated with the GSI channel; and properties associated with
  42. * the IPA endpoint.
  43. */
  44. /* The maximum possible number of source or destination resource groups */
  45. #define IPA_RESOURCE_GROUP_MAX 8
  46. /** enum ipa_qsb_master_id - array index for IPA QSB configuration data */
  47. enum ipa_qsb_master_id {
  48. IPA_QSB_MASTER_DDR,
  49. IPA_QSB_MASTER_PCIE,
  50. };
  51. /**
  52. * struct ipa_qsb_data - Qualcomm System Bus configuration data
  53. * @max_writes: Maximum outstanding write requests for this master
  54. * @max_reads: Maximum outstanding read requests for this master
  55. * @max_reads_beats: Max outstanding read bytes in 8-byte "beats" (if non-zero)
  56. */
  57. struct ipa_qsb_data {
  58. u8 max_writes;
  59. u8 max_reads;
  60. u8 max_reads_beats; /* Not present for IPA v3.5.1 */
  61. };
  62. /**
  63. * struct gsi_channel_data - GSI channel configuration data
  64. * @tre_count: number of TREs in the channel ring
  65. * @event_count: number of slots in the associated event ring
  66. * @tlv_count: number of entries in channel's TLV FIFO
  67. *
  68. * A GSI channel is a unidirectional means of transferring data to or
  69. * from (and through) the IPA. A GSI channel has a ring buffer made
  70. * up of "transfer ring elements" (TREs) that specify individual data
  71. * transfers or IPA immediate commands. TREs are filled by the AP,
  72. * and control is passed to IPA hardware by writing the last written
  73. * element into a doorbell register.
  74. *
  75. * When data transfer commands have completed the GSI generates an
  76. * event (a structure of data) and optionally signals the AP with
  77. * an interrupt. Event structures are implemented by another ring
  78. * buffer, directed toward the AP from the IPA.
  79. *
  80. * The input to a GSI channel is a FIFO of type/length/value (TLV)
  81. * elements, and the size of this FIFO limits the number of TREs
  82. * that can be included in a single transaction.
  83. */
  84. struct gsi_channel_data {
  85. u16 tre_count; /* must be a power of 2 */
  86. u16 event_count; /* must be a power of 2 */
  87. u8 tlv_count;
  88. };
  89. /**
  90. * struct ipa_endpoint_data - IPA endpoint configuration data
  91. * @filter_support: whether endpoint supports filtering
  92. * @config: hardware configuration
  93. *
  94. * Not all endpoints support the IPA filtering capability. A filter table
  95. * defines the filters to apply for those endpoints that support it. The
  96. * AP is responsible for initializing this table, and it must include entries
  97. * for non-AP endpoints. For this reason we define *all* endpoints used
  98. * in the system, and indicate whether they support filtering.
  99. *
  100. * The remaining endpoint configuration data specifies default hardware
  101. * configuration values that apply only to AP endpoints.
  102. */
  103. struct ipa_endpoint_data {
  104. bool filter_support;
  105. struct ipa_endpoint_config config;
  106. };
  107. /**
  108. * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
  109. * @ee_id: GSI execution environment ID
  110. * @channel_id: GSI channel ID
  111. * @endpoint_id: IPA endpoint ID
  112. * @toward_ipa: direction of data transfer
  113. * @channel: GSI channel configuration data (see above)
  114. * @endpoint: IPA endpoint configuration data (see above)
  115. */
  116. struct ipa_gsi_endpoint_data {
  117. u8 ee_id; /* enum gsi_ee_id */
  118. u8 channel_id;
  119. u8 endpoint_id;
  120. bool toward_ipa;
  121. struct gsi_channel_data channel;
  122. struct ipa_endpoint_data endpoint;
  123. };
  124. /**
  125. * struct ipa_resource_limits - minimum and maximum resource counts
  126. * @min: minimum number of resources of a given type
  127. * @max: maximum number of resources of a given type
  128. */
  129. struct ipa_resource_limits {
  130. u32 min;
  131. u32 max;
  132. };
  133. /**
  134. * struct ipa_resource - resource group source or destination resource usage
  135. * @limits: array of resource limits, indexed by group
  136. */
  137. struct ipa_resource {
  138. struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_MAX];
  139. };
  140. /**
  141. * struct ipa_resource_data - IPA resource configuration data
  142. * @rsrc_group_src_count: number of source resource groups supported
  143. * @rsrc_group_dst_count: number of destination resource groups supported
  144. * @resource_src_count: number of entries in the resource_src array
  145. * @resource_src: source endpoint group resources
  146. * @resource_dst_count: number of entries in the resource_dst array
  147. * @resource_dst: destination endpoint group resources
  148. *
  149. * In order to manage quality of service between endpoints, certain resources
  150. * required for operation are allocated to groups of endpoints. Generally
  151. * this information is invisible to the AP, but the AP is responsible for
  152. * programming it at initialization time, so we specify it here.
  153. */
  154. struct ipa_resource_data {
  155. u32 rsrc_group_src_count;
  156. u32 rsrc_group_dst_count;
  157. u32 resource_src_count;
  158. const struct ipa_resource *resource_src;
  159. u32 resource_dst_count;
  160. const struct ipa_resource *resource_dst;
  161. };
  162. /**
  163. * struct ipa_mem_data - description of IPA memory regions
  164. * @local_count: number of regions defined in the local[] array
  165. * @local: array of IPA-local memory region descriptors
  166. * @imem_addr: physical address of IPA region within IMEM
  167. * @imem_size: size in bytes of IPA IMEM region
  168. * @smem_id: item identifier for IPA region within SMEM memory
  169. * @smem_size: size in bytes of the IPA SMEM region
  170. */
  171. struct ipa_mem_data {
  172. u32 local_count;
  173. const struct ipa_mem *local;
  174. u32 imem_addr;
  175. u32 imem_size;
  176. u32 smem_id;
  177. u32 smem_size;
  178. };
  179. /**
  180. * struct ipa_interconnect_data - description of IPA interconnect bandwidths
  181. * @name: Interconnect name (matches interconnect-name in DT)
  182. * @peak_bandwidth: Peak interconnect bandwidth (in 1000 byte/sec units)
  183. * @average_bandwidth: Average interconnect bandwidth (in 1000 byte/sec units)
  184. */
  185. struct ipa_interconnect_data {
  186. const char *name;
  187. u32 peak_bandwidth;
  188. u32 average_bandwidth;
  189. };
  190. /**
  191. * struct ipa_power_data - description of IPA power configuration data
  192. * @core_clock_rate: Core clock rate (Hz)
  193. * @interconnect_count: Number of entries in the interconnect_data array
  194. * @interconnect_data: IPA interconnect configuration data
  195. */
  196. struct ipa_power_data {
  197. u32 core_clock_rate;
  198. u32 interconnect_count; /* # entries in interconnect_data[] */
  199. const struct ipa_interconnect_data *interconnect_data;
  200. };
  201. /**
  202. * struct ipa_data - combined IPA/GSI configuration data
  203. * @version: IPA hardware version
  204. * @backward_compat: BCR register value (prior to IPA v4.5 only)
  205. * @qsb_count: number of entries in the qsb_data array
  206. * @qsb_data: Qualcomm System Bus configuration data
  207. * @modem_route_count: number of modem entries in a routing table
  208. * @endpoint_count: number of entries in the endpoint_data array
  209. * @endpoint_data: IPA endpoint/GSI channel data
  210. * @resource_data: IPA resource configuration data
  211. * @mem_data: IPA memory region data
  212. * @power_data: IPA power data
  213. */
  214. struct ipa_data {
  215. enum ipa_version version;
  216. u32 backward_compat;
  217. u32 qsb_count; /* number of entries in qsb_data[] */
  218. const struct ipa_qsb_data *qsb_data;
  219. u32 modem_route_count;
  220. u32 endpoint_count; /* number of entries in endpoint_data[] */
  221. const struct ipa_gsi_endpoint_data *endpoint_data;
  222. const struct ipa_resource_data *resource_data;
  223. const struct ipa_mem_data *mem_data;
  224. const struct ipa_power_data *power_data;
  225. };
  226. extern const struct ipa_data ipa_data_v3_1;
  227. extern const struct ipa_data ipa_data_v3_5_1;
  228. extern const struct ipa_data ipa_data_v4_2;
  229. extern const struct ipa_data ipa_data_v4_5;
  230. extern const struct ipa_data ipa_data_v4_7;
  231. extern const struct ipa_data ipa_data_v4_9;
  232. extern const struct ipa_data ipa_data_v4_11;
  233. extern const struct ipa_data ipa_data_v5_0;
  234. extern const struct ipa_data ipa_data_v5_5;
  235. #endif /* _IPA_DATA_H_ */