xref: /linux/drivers/net/ipa/ipa_data.h (revision ec8a42e7343234802b9054874fe01810880289ce)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2019-2020 Linaro Ltd.
5  */
6 #ifndef _IPA_DATA_H_
7 #define _IPA_DATA_H_
8 
9 #include <linux/types.h>
10 
11 #include "ipa_version.h"
12 #include "ipa_endpoint.h"
13 #include "ipa_mem.h"
14 
15 /**
16  * DOC: IPA/GSI Configuration Data
17  *
18  * Boot-time configuration data is used to define the configuration of the
19  * IPA and GSI resources to use for a given platform.  This data is supplied
20  * via the Device Tree match table, associated with a particular compatible
21  * string.  The data defines information about resources, endpoints, and
22  * channels.
23  *
24  * Resources are data structures used internally by the IPA hardware.  The
25  * configuration data defines the number (or limits of the number) of various
26  * types of these resources.
27  *
28  * Endpoint configuration data defines properties of both IPA endpoints and
29  * GSI channels.  A channel is a GSI construct, and represents a single
30  * communication path between the IPA and a particular execution environment
31  * (EE), such as the AP or Modem.  Each EE has a set of channels associated
32  * with it, and each channel has an ID unique for that EE.  For the most part
33  * the only GSI channels of concern to this driver belong to the AP
34  *
35  * An endpoint is an IPA construct representing a single channel anywhere
36  * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
37  * pair.  Generally, this driver is concerned with only endpoints associated
38  * with the AP, however this will change when support for routing (etc.) is
39  * added.  IPA endpoint and GSI channel configuration data are defined
40  * together, establishing the endpoint_id->(EE, channel_id) mapping.
41  *
42  * Endpoint configuration data consists of three parts:  properties that
43  * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
44  * properties associated with the GSI channel; and properties associated with
45  * the IPA endpoint.
46  */
47 
48 /* The maximum value returned by ipa_resource_group_{src,dst}_count() */
49 #define IPA_RESOURCE_GROUP_SRC_MAX	5
50 #define IPA_RESOURCE_GROUP_DST_MAX	5
51 
52 /**
53  * struct gsi_channel_data - GSI channel configuration data
54  * @tre_count:		number of TREs in the channel ring
55  * @event_count:	number of slots in the associated event ring
56  * @tlv_count:		number of entries in channel's TLV FIFO
57  *
58  * A GSI channel is a unidirectional means of transferring data to or
59  * from (and through) the IPA.  A GSI channel has a ring buffer made
60  * up of "transfer elements" (TREs) that specify individual data transfers
61  * or IPA immediate commands.  TREs are filled by the AP, and control
62  * is passed to IPA hardware by writing the last written element
63  * into a doorbell register.
64  *
65  * When data transfer commands have completed the GSI generates an
66  * event (a structure of data) and optionally signals the AP with
67  * an interrupt.  Event structures are implemented by another ring
68  * buffer, directed toward the AP from the IPA.
69  *
70  * The input to a GSI channel is a FIFO of type/length/value (TLV)
71  * elements, and the size of this FIFO limits the number of TREs
72  * that can be included in a single transaction.
73  */
74 struct gsi_channel_data {
75 	u16 tre_count;
76 	u16 event_count;
77 	u8 tlv_count;
78 };
79 
80 /**
81  * struct ipa_endpoint_tx_data - configuration data for TX endpoints
82  * @status_endpoint:	endpoint to which status elements are sent
83  *
84  * The @status_endpoint is only valid if the endpoint's @status_enable
85  * flag is set.
86  */
87 struct ipa_endpoint_tx_data {
88 	enum ipa_endpoint_name status_endpoint;
89 };
90 
91 /**
92  * struct ipa_endpoint_rx_data - configuration data for RX endpoints
93  * @pad_align:	power-of-2 boundary to which packet payload is aligned
94  * @aggr_close_eof: whether aggregation closes on end-of-frame
95  *
96  * With each packet it transfers, the IPA hardware can perform certain
97  * transformations of its packet data.  One of these is adding pad bytes
98  * to the end of the packet data so the result ends on a power-of-2 boundary.
99  *
100  * It is also able to aggregate multiple packets into a single receive buffer.
101  * Aggregation is "open" while a buffer is being filled, and "closes" when
102  * certain criteria are met.  One of those criteria is the sender indicating
103  * a "frame" consisting of several transfers has ended.
104  */
105 struct ipa_endpoint_rx_data {
106 	u32 pad_align;
107 	bool aggr_close_eof;
108 };
109 
110 /**
111  * struct ipa_endpoint_config_data - IPA endpoint hardware configuration
112  * @resource_group:	resource group to assign endpoint to
113  * @checksum:		whether checksum offload is enabled
114  * @qmap:		whether endpoint uses QMAP protocol
115  * @aggregation:	whether endpoint supports aggregation
116  * @status_enable:	whether endpoint uses status elements
117  * @dma_mode:		whether endpoint operates in DMA mode
118  * @dma_endpoint:	peer endpoint, if operating in DMA mode
119  * @tx:			TX-specific endpoint information (see above)
120  * @rx:			RX-specific endpoint information (see above)
121  */
122 struct ipa_endpoint_config_data {
123 	u32 resource_group;
124 	bool checksum;
125 	bool qmap;
126 	bool aggregation;
127 	bool status_enable;
128 	bool dma_mode;
129 	enum ipa_endpoint_name dma_endpoint;
130 	union {
131 		struct ipa_endpoint_tx_data tx;
132 		struct ipa_endpoint_rx_data rx;
133 	};
134 };
135 
136 /**
137  * struct ipa_endpoint_data - IPA endpoint configuration data
138  * @filter_support:	whether endpoint supports filtering
139  * @seq_type:		hardware sequencer type used for endpoint
140  * @config:		hardware configuration (see above)
141  *
142  * Not all endpoints support the IPA filtering capability.  A filter table
143  * defines the filters to apply for those endpoints that support it.  The
144  * AP is responsible for initializing this table, and it must include entries
145  * for non-AP endpoints.  For this reason we define *all* endpoints used
146  * in the system, and indicate whether they support filtering.
147  *
148  * The remaining endpoint configuration data applies only to AP endpoints.
149  * The IPA hardware is implemented by sequencers, and the AP must program
150  * the type(s) of these sequencers at initialization time.  The remaining
151  * endpoint configuration data is defined above.
152  */
153 struct ipa_endpoint_data {
154 	bool filter_support;
155 	/* The next two are specified only for AP endpoints */
156 	enum ipa_seq_type seq_type;
157 	struct ipa_endpoint_config_data config;
158 };
159 
160 /**
161  * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
162  * ee:		GSI execution environment ID
163  * channel_id:	GSI channel ID
164  * endpoint_id:	IPA endpoint ID
165  * toward_ipa:	direction of data transfer
166  * gsi:		GSI channel configuration data (see above)
167  * ipa:		IPA endpoint configuration data (see above)
168  */
169 struct ipa_gsi_endpoint_data {
170 	u8 ee_id;		/* enum gsi_ee_id */
171 	u8 channel_id;
172 	u8 endpoint_id;
173 	bool toward_ipa;
174 
175 	struct gsi_channel_data channel;
176 	struct ipa_endpoint_data endpoint;
177 };
178 
179 /** enum ipa_resource_type_src - source resource types */
180 enum ipa_resource_type_src {
181 	IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
182 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
183 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
184 	IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
185 	IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
186 };
187 
188 /** enum ipa_resource_type_dst - destination resource types */
189 enum ipa_resource_type_dst {
190 	IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
191 	IPA_RESOURCE_TYPE_DST_DPS_DMARS,
192 };
193 
194 /**
195  * struct ipa_resource_limits - minimum and maximum resource counts
196  * @min:	minimum number of resources of a given type
197  * @max:	maximum number of resources of a given type
198  */
199 struct ipa_resource_limits {
200 	u32 min;
201 	u32 max;
202 };
203 
204 /**
205  * struct ipa_resource_src - source endpoint group resource usage
206  * @type:	source group resource type
207  * @limits:	array of limits to use for each resource group
208  */
209 struct ipa_resource_src {
210 	enum ipa_resource_type_src type;
211 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX];
212 };
213 
214 /**
215  * struct ipa_resource_dst - destination endpoint group resource usage
216  * @type:	destination group resource type
217  * @limits:	array of limits to use for each resource group
218  */
219 struct ipa_resource_dst {
220 	enum ipa_resource_type_dst type;
221 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX];
222 };
223 
224 /**
225  * struct ipa_resource_data - IPA resource configuration data
226  * @resource_src_count:	number of entries in the resource_src array
227  * @resource_src:	source endpoint group resources
228  * @resource_dst_count:	number of entries in the resource_dst array
229  * @resource_dst:	destination endpoint group resources
230  *
231  * In order to manage quality of service between endpoints, certain resources
232  * required for operation are allocated to groups of endpoints.  Generally
233  * this information is invisible to the AP, but the AP is responsible for
234  * programming it at initialization time, so we specify it here.
235  */
236 struct ipa_resource_data {
237 	u32 resource_src_count;
238 	const struct ipa_resource_src *resource_src;
239 	u32 resource_dst_count;
240 	const struct ipa_resource_dst *resource_dst;
241 };
242 
243 /**
244  * struct ipa_mem_data - description of IPA memory regions
245  * @local_count:	number of regions defined in the local[] array
246  * @local:		array of IPA-local memory region descriptors
247  * @imem_addr:		physical address of IPA region within IMEM
248  * @imem_size:		size in bytes of IPA IMEM region
249  * @smem_id:		item identifier for IPA region within SMEM memory
250  * @imem_size:		size in bytes of the IPA SMEM region
251  */
252 struct ipa_mem_data {
253 	u32 local_count;
254 	const struct ipa_mem *local;
255 	u32 imem_addr;
256 	u32 imem_size;
257 	u32 smem_id;
258 	u32 smem_size;
259 };
260 
261 /**
262  * struct ipa_interconnect_data - description of IPA interconnect bandwidths
263  * @name:		Interconnect name (matches interconnect-name in DT)
264  * @peak_bandwidth:	Peak interconnect bandwidth (in 1000 byte/sec units)
265  * @average_bandwidth:	Average interconnect bandwidth (in 1000 byte/sec units)
266  */
267 struct ipa_interconnect_data {
268 	const char *name;
269 	u32 peak_bandwidth;
270 	u32 average_bandwidth;
271 };
272 
273 /**
274  * struct ipa_clock_data - description of IPA clock and interconnect rates
275  * @core_clock_rate:	Core clock rate (Hz)
276  * @interconnect_count:	Number of entries in the interconnect_data array
277  * @interconnect_data:	IPA interconnect configuration data
278  */
279 struct ipa_clock_data {
280 	u32 core_clock_rate;
281 	u32 interconnect_count;		/* # entries in interconnect_data[] */
282 	const struct ipa_interconnect_data *interconnect_data;
283 };
284 
285 /**
286  * struct ipa_data - combined IPA/GSI configuration data
287  * @version:		IPA hardware version
288  * @endpoint_count:	number of entries in endpoint_data array
289  * @endpoint_data:	IPA endpoint/GSI channel data
290  * @resource_data:	IPA resource configuration data
291  * @mem_count:		number of entries in mem_data array
292  * @mem_data:		IPA-local shared memory region data
293  */
294 struct ipa_data {
295 	enum ipa_version version;
296 	u32 endpoint_count;	/* # entries in endpoint_data[] */
297 	const struct ipa_gsi_endpoint_data *endpoint_data;
298 	const struct ipa_resource_data *resource_data;
299 	const struct ipa_mem_data *mem_data;
300 	const struct ipa_clock_data *clock_data;
301 };
302 
303 extern const struct ipa_data ipa_data_sdm845;
304 extern const struct ipa_data ipa_data_sc7180;
305 
306 #endif /* _IPA_DATA_H_ */
307