xref: /linux/drivers/net/ipa/ipa_data.h (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
11ed7d0c0SAlex Elder /* SPDX-License-Identifier: GPL-2.0 */
21ed7d0c0SAlex Elder 
31ed7d0c0SAlex Elder /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4*88412277SAlex Elder  * Copyright (C) 2019-2024 Linaro Ltd.
51ed7d0c0SAlex Elder  */
61ed7d0c0SAlex Elder #ifndef _IPA_DATA_H_
71ed7d0c0SAlex Elder #define _IPA_DATA_H_
81ed7d0c0SAlex Elder 
91ed7d0c0SAlex Elder #include <linux/types.h>
101ed7d0c0SAlex Elder 
111ed7d0c0SAlex Elder #include "ipa_endpoint.h"
121ed7d0c0SAlex Elder #include "ipa_mem.h"
13*88412277SAlex Elder #include "ipa_version.h"
141ed7d0c0SAlex Elder 
151ed7d0c0SAlex Elder /**
161ed7d0c0SAlex Elder  * DOC: IPA/GSI Configuration Data
171ed7d0c0SAlex Elder  *
181ed7d0c0SAlex Elder  * Boot-time configuration data is used to define the configuration of the
191ed7d0c0SAlex Elder  * IPA and GSI resources to use for a given platform.  This data is supplied
201ed7d0c0SAlex Elder  * via the Device Tree match table, associated with a particular compatible
21b259cc2aSAlex Elder  * string.  The data defines information about how resources, endpoints and
227aa0e8b8SAlex Elder  * channels, memory, power and so on are allocated and used for the
23b259cc2aSAlex Elder  * platform.
241ed7d0c0SAlex Elder  *
251ed7d0c0SAlex Elder  * Resources are data structures used internally by the IPA hardware.  The
261ed7d0c0SAlex Elder  * configuration data defines the number (or limits of the number) of various
271ed7d0c0SAlex Elder  * types of these resources.
281ed7d0c0SAlex Elder  *
291ed7d0c0SAlex Elder  * Endpoint configuration data defines properties of both IPA endpoints and
301ed7d0c0SAlex Elder  * GSI channels.  A channel is a GSI construct, and represents a single
311ed7d0c0SAlex Elder  * communication path between the IPA and a particular execution environment
321ed7d0c0SAlex Elder  * (EE), such as the AP or Modem.  Each EE has a set of channels associated
331ed7d0c0SAlex Elder  * with it, and each channel has an ID unique for that EE.  For the most part
34ace5dc61SAlex Elder  * the only GSI channels of concern to this driver belong to the AP.
351ed7d0c0SAlex Elder  *
361ed7d0c0SAlex Elder  * An endpoint is an IPA construct representing a single channel anywhere
371ed7d0c0SAlex Elder  * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
381ed7d0c0SAlex Elder  * pair.  Generally, this driver is concerned with only endpoints associated
391ed7d0c0SAlex Elder  * with the AP, however this will change when support for routing (etc.) is
401ed7d0c0SAlex Elder  * added.  IPA endpoint and GSI channel configuration data are defined
411ed7d0c0SAlex Elder  * together, establishing the endpoint_id->(EE, channel_id) mapping.
421ed7d0c0SAlex Elder  *
431ed7d0c0SAlex Elder  * Endpoint configuration data consists of three parts:  properties that
441ed7d0c0SAlex Elder  * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
451ed7d0c0SAlex Elder  * properties associated with the GSI channel; and properties associated with
461ed7d0c0SAlex Elder  * the IPA endpoint.
471ed7d0c0SAlex Elder  */
481ed7d0c0SAlex Elder 
493219953bSAlex Elder /* The maximum possible number of source or destination resource groups */
503219953bSAlex Elder #define IPA_RESOURCE_GROUP_MAX	8
511ed7d0c0SAlex Elder 
5237537fa8SAlex Elder /** enum ipa_qsb_master_id - array index for IPA QSB configuration data */
5337537fa8SAlex Elder enum ipa_qsb_master_id {
5437537fa8SAlex Elder 	IPA_QSB_MASTER_DDR,
5537537fa8SAlex Elder 	IPA_QSB_MASTER_PCIE,
5637537fa8SAlex Elder };
5737537fa8SAlex Elder 
5837537fa8SAlex Elder /**
5937537fa8SAlex Elder  * struct ipa_qsb_data - Qualcomm System Bus configuration data
6037537fa8SAlex Elder  * @max_writes:	Maximum outstanding write requests for this master
6137537fa8SAlex Elder  * @max_reads:	Maximum outstanding read requests for this master
62b9aa0805SAlex Elder  * @max_reads_beats: Max outstanding read bytes in 8-byte "beats" (if non-zero)
6337537fa8SAlex Elder  */
6437537fa8SAlex Elder struct ipa_qsb_data {
6537537fa8SAlex Elder 	u8 max_writes;
6637537fa8SAlex Elder 	u8 max_reads;
67b9aa0805SAlex Elder 	u8 max_reads_beats;		/* Not present for IPA v3.5.1 */
6837537fa8SAlex Elder };
6937537fa8SAlex Elder 
701ed7d0c0SAlex Elder /**
711ed7d0c0SAlex Elder  * struct gsi_channel_data - GSI channel configuration data
721ed7d0c0SAlex Elder  * @tre_count:		number of TREs in the channel ring
731ed7d0c0SAlex Elder  * @event_count:	number of slots in the associated event ring
741ed7d0c0SAlex Elder  * @tlv_count:		number of entries in channel's TLV FIFO
751ed7d0c0SAlex Elder  *
761ed7d0c0SAlex Elder  * A GSI channel is a unidirectional means of transferring data to or
771ed7d0c0SAlex Elder  * from (and through) the IPA.  A GSI channel has a ring buffer made
78b259cc2aSAlex Elder  * up of "transfer ring elements" (TREs) that specify individual data
79b259cc2aSAlex Elder  * transfers or IPA immediate commands.  TREs are filled by the AP,
80b259cc2aSAlex Elder  * and control is passed to IPA hardware by writing the last written
81b259cc2aSAlex Elder  * element into a doorbell register.
821ed7d0c0SAlex Elder  *
831ed7d0c0SAlex Elder  * When data transfer commands have completed the GSI generates an
841ed7d0c0SAlex Elder  * event (a structure of data) and optionally signals the AP with
851ed7d0c0SAlex Elder  * an interrupt.  Event structures are implemented by another ring
861ed7d0c0SAlex Elder  * buffer, directed toward the AP from the IPA.
871ed7d0c0SAlex Elder  *
881ed7d0c0SAlex Elder  * The input to a GSI channel is a FIFO of type/length/value (TLV)
891ed7d0c0SAlex Elder  * elements, and the size of this FIFO limits the number of TREs
901ed7d0c0SAlex Elder  * that can be included in a single transaction.
911ed7d0c0SAlex Elder  */
921ed7d0c0SAlex Elder struct gsi_channel_data {
9319aaf72cSAlex Elder 	u16 tre_count;			/* must be a power of 2 */
9419aaf72cSAlex Elder 	u16 event_count;		/* must be a power of 2 */
951ed7d0c0SAlex Elder 	u8 tlv_count;
961ed7d0c0SAlex Elder };
971ed7d0c0SAlex Elder 
981ed7d0c0SAlex Elder /**
991ed7d0c0SAlex Elder  * struct ipa_endpoint_data - IPA endpoint configuration data
1001ed7d0c0SAlex Elder  * @filter_support:	whether endpoint supports filtering
101cf4e73a1SAlex Elder  * @config:		hardware configuration
1021ed7d0c0SAlex Elder  *
1031ed7d0c0SAlex Elder  * Not all endpoints support the IPA filtering capability.  A filter table
1041ed7d0c0SAlex Elder  * defines the filters to apply for those endpoints that support it.  The
1051ed7d0c0SAlex Elder  * AP is responsible for initializing this table, and it must include entries
1061ed7d0c0SAlex Elder  * for non-AP endpoints.  For this reason we define *all* endpoints used
1071ed7d0c0SAlex Elder  * in the system, and indicate whether they support filtering.
1081ed7d0c0SAlex Elder  *
109cf4e73a1SAlex Elder  * The remaining endpoint configuration data specifies default hardware
110cf4e73a1SAlex Elder  * configuration values that apply only to AP endpoints.
1111ed7d0c0SAlex Elder  */
1121ed7d0c0SAlex Elder struct ipa_endpoint_data {
1131ed7d0c0SAlex Elder 	bool filter_support;
114cf4e73a1SAlex Elder 	struct ipa_endpoint_config config;
1151ed7d0c0SAlex Elder };
1161ed7d0c0SAlex Elder 
1171ed7d0c0SAlex Elder /**
1181ed7d0c0SAlex Elder  * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
119fd2b7bc3SAlex Elder  * @ee_id:	GSI execution environment ID
120fd2b7bc3SAlex Elder  * @channel_id:	GSI channel ID
121fd2b7bc3SAlex Elder  * @endpoint_id: IPA endpoint ID
122fd2b7bc3SAlex Elder  * @toward_ipa:	direction of data transfer
123fd2b7bc3SAlex Elder  * @channel:	GSI channel configuration data (see above)
124fd2b7bc3SAlex Elder  * @endpoint:	IPA endpoint configuration data (see above)
1251ed7d0c0SAlex Elder  */
1261ed7d0c0SAlex Elder struct ipa_gsi_endpoint_data {
1271ed7d0c0SAlex Elder 	u8 ee_id;		/* enum gsi_ee_id */
1281ed7d0c0SAlex Elder 	u8 channel_id;
1291ed7d0c0SAlex Elder 	u8 endpoint_id;
1301ed7d0c0SAlex Elder 	bool toward_ipa;
1311ed7d0c0SAlex Elder 
1321ed7d0c0SAlex Elder 	struct gsi_channel_data channel;
1331ed7d0c0SAlex Elder 	struct ipa_endpoint_data endpoint;
1341ed7d0c0SAlex Elder };
1351ed7d0c0SAlex Elder 
1361ed7d0c0SAlex Elder /**
1371ed7d0c0SAlex Elder  * struct ipa_resource_limits - minimum and maximum resource counts
1381ed7d0c0SAlex Elder  * @min:	minimum number of resources of a given type
1391ed7d0c0SAlex Elder  * @max:	maximum number of resources of a given type
1401ed7d0c0SAlex Elder  */
1411ed7d0c0SAlex Elder struct ipa_resource_limits {
1421ed7d0c0SAlex Elder 	u32 min;
1431ed7d0c0SAlex Elder 	u32 max;
1441ed7d0c0SAlex Elder };
1451ed7d0c0SAlex Elder 
1461ed7d0c0SAlex Elder /**
1477336ce1aSAlex Elder  * struct ipa_resource - resource group source or destination resource usage
1487336ce1aSAlex Elder  * @limits:	array of resource limits, indexed by group
1491ed7d0c0SAlex Elder  */
1507336ce1aSAlex Elder struct ipa_resource {
151d9d1cddfSAlex Elder 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_MAX];
1521ed7d0c0SAlex Elder };
1531ed7d0c0SAlex Elder 
1541ed7d0c0SAlex Elder /**
1551ed7d0c0SAlex Elder  * struct ipa_resource_data - IPA resource configuration data
1564fd704b3SAlex Elder  * @rsrc_group_src_count: number of source resource groups supported
1574fd704b3SAlex Elder  * @rsrc_group_dst_count: number of destination resource groups supported
1581ed7d0c0SAlex Elder  * @resource_src_count:	number of entries in the resource_src array
1591ed7d0c0SAlex Elder  * @resource_src:	source endpoint group resources
1601ed7d0c0SAlex Elder  * @resource_dst_count:	number of entries in the resource_dst array
1611ed7d0c0SAlex Elder  * @resource_dst:	destination endpoint group resources
1621ed7d0c0SAlex Elder  *
1631ed7d0c0SAlex Elder  * In order to manage quality of service between endpoints, certain resources
1641ed7d0c0SAlex Elder  * required for operation are allocated to groups of endpoints.  Generally
1651ed7d0c0SAlex Elder  * this information is invisible to the AP, but the AP is responsible for
1661ed7d0c0SAlex Elder  * programming it at initialization time, so we specify it here.
1671ed7d0c0SAlex Elder  */
1681ed7d0c0SAlex Elder struct ipa_resource_data {
1694fd704b3SAlex Elder 	u32 rsrc_group_src_count;
1704fd704b3SAlex Elder 	u32 rsrc_group_dst_count;
1711ed7d0c0SAlex Elder 	u32 resource_src_count;
1727336ce1aSAlex Elder 	const struct ipa_resource *resource_src;
1731ed7d0c0SAlex Elder 	u32 resource_dst_count;
1747336ce1aSAlex Elder 	const struct ipa_resource *resource_dst;
1751ed7d0c0SAlex Elder };
1761ed7d0c0SAlex Elder 
1771ed7d0c0SAlex Elder /**
178dfccb8b1SAlex Elder  * struct ipa_mem_data - description of IPA memory regions
1793128aae8SAlex Elder  * @local_count:	number of regions defined in the local[] array
1803128aae8SAlex Elder  * @local:		array of IPA-local memory region descriptors
1813e313c3fSAlex Elder  * @imem_addr:		physical address of IPA region within IMEM
1823e313c3fSAlex Elder  * @imem_size:		size in bytes of IPA IMEM region
183a0036bb4SAlex Elder  * @smem_id:		item identifier for IPA region within SMEM memory
184b259cc2aSAlex Elder  * @smem_size:		size in bytes of the IPA SMEM region
1851ed7d0c0SAlex Elder  */
1861ed7d0c0SAlex Elder struct ipa_mem_data {
1873128aae8SAlex Elder 	u32 local_count;
1883128aae8SAlex Elder 	const struct ipa_mem *local;
1893e313c3fSAlex Elder 	u32 imem_addr;
1903e313c3fSAlex Elder 	u32 imem_size;
191a0036bb4SAlex Elder 	u32 smem_id;
192a0036bb4SAlex Elder 	u32 smem_size;
1931ed7d0c0SAlex Elder };
1941ed7d0c0SAlex Elder 
195dfccb8b1SAlex Elder /**
196bf52e27bSAlex Elder  * struct ipa_interconnect_data - description of IPA interconnect bandwidths
197e938d7efSAlex Elder  * @name:		Interconnect name (matches interconnect-name in DT)
198bf52e27bSAlex Elder  * @peak_bandwidth:	Peak interconnect bandwidth (in 1000 byte/sec units)
199bf52e27bSAlex Elder  * @average_bandwidth:	Average interconnect bandwidth (in 1000 byte/sec units)
200dfccb8b1SAlex Elder  */
201dfccb8b1SAlex Elder struct ipa_interconnect_data {
202e938d7efSAlex Elder 	const char *name;
203bf52e27bSAlex Elder 	u32 peak_bandwidth;
204bf52e27bSAlex Elder 	u32 average_bandwidth;
205dfccb8b1SAlex Elder };
206dfccb8b1SAlex Elder 
207dfccb8b1SAlex Elder /**
2087aa0e8b8SAlex Elder  * struct ipa_power_data - description of IPA power configuration data
209dfccb8b1SAlex Elder  * @core_clock_rate:	Core clock rate (Hz)
210ea151e19SAlex Elder  * @interconnect_count:	Number of entries in the interconnect_data array
211ea151e19SAlex Elder  * @interconnect_data:	IPA interconnect configuration data
212dfccb8b1SAlex Elder  */
2137aa0e8b8SAlex Elder struct ipa_power_data {
214dfccb8b1SAlex Elder 	u32 core_clock_rate;
215ea151e19SAlex Elder 	u32 interconnect_count;		/* # entries in interconnect_data[] */
216ea151e19SAlex Elder 	const struct ipa_interconnect_data *interconnect_data;
217dfccb8b1SAlex Elder };
218dfccb8b1SAlex Elder 
2191ed7d0c0SAlex Elder /**
2201ed7d0c0SAlex Elder  * struct ipa_data - combined IPA/GSI configuration data
2211ed7d0c0SAlex Elder  * @version:		IPA hardware version
222e695bed2SAlex Elder  * @backward_compat:	BCR register value (prior to IPA v4.5 only)
22337537fa8SAlex Elder  * @qsb_count:		number of entries in the qsb_data array
22437537fa8SAlex Elder  * @qsb_data:		Qualcomm System Bus configuration data
2258defab8bSAlex Elder  * @modem_route_count:	number of modem entries in a routing table
22637537fa8SAlex Elder  * @endpoint_count:	number of entries in the endpoint_data array
2271ed7d0c0SAlex Elder  * @endpoint_data:	IPA endpoint/GSI channel data
2281ed7d0c0SAlex Elder  * @resource_data:	IPA resource configuration data
229b259cc2aSAlex Elder  * @mem_data:		IPA memory region data
2307aa0e8b8SAlex Elder  * @power_data:		IPA power data
2311ed7d0c0SAlex Elder  */
2321ed7d0c0SAlex Elder struct ipa_data {
2331ed7d0c0SAlex Elder 	enum ipa_version version;
234e695bed2SAlex Elder 	u32 backward_compat;
235b259cc2aSAlex Elder 	u32 qsb_count;		/* number of entries in qsb_data[] */
23637537fa8SAlex Elder 	const struct ipa_qsb_data *qsb_data;
2378defab8bSAlex Elder 	u32 modem_route_count;
238b259cc2aSAlex Elder 	u32 endpoint_count;	/* number of entries in endpoint_data[] */
2391ed7d0c0SAlex Elder 	const struct ipa_gsi_endpoint_data *endpoint_data;
2401ed7d0c0SAlex Elder 	const struct ipa_resource_data *resource_data;
2413128aae8SAlex Elder 	const struct ipa_mem_data *mem_data;
2427aa0e8b8SAlex Elder 	const struct ipa_power_data *power_data;
2431ed7d0c0SAlex Elder };
2441ed7d0c0SAlex Elder 
2451bb1a117SAlex Elder extern const struct ipa_data ipa_data_v3_1;
246fc566dabSAlex Elder extern const struct ipa_data ipa_data_v3_5_1;
247782d767aSAlex Elder extern const struct ipa_data ipa_data_v4_2;
248fbb763e7SAlex Elder extern const struct ipa_data ipa_data_v4_5;
249b310de78SAlex Elder extern const struct ipa_data ipa_data_v4_7;
250e557dc82SAlex Elder extern const struct ipa_data ipa_data_v4_9;
251927c5043SAlex Elder extern const struct ipa_data ipa_data_v4_11;
252cb7550b4SAlex Elder extern const struct ipa_data ipa_data_v5_0;
2537c592940SAlex Elder extern const struct ipa_data ipa_data_v5_5;
2541ed7d0c0SAlex Elder 
2551ed7d0c0SAlex Elder #endif /* _IPA_DATA_H_ */
256