Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
0004  * Copyright (C) 2019-2021 Linaro Ltd.
0005  */
0006 #ifndef _IPA_DATA_H_
0007 #define _IPA_DATA_H_
0008 
0009 #include <linux/types.h>
0010 
0011 #include "ipa_version.h"
0012 #include "ipa_endpoint.h"
0013 #include "ipa_mem.h"
0014 
0015 /**
0016  * DOC: IPA/GSI Configuration Data
0017  *
0018  * Boot-time configuration data is used to define the configuration of the
0019  * IPA and GSI resources to use for a given platform.  This data is supplied
0020  * via the Device Tree match table, associated with a particular compatible
0021  * string.  The data defines information about how resources, endpoints and
0022  * channels, memory, power and so on are allocated and used for the
0023  * platform.
0024  *
0025  * Resources are data structures used internally by the IPA hardware.  The
0026  * configuration data defines the number (or limits of the number) of various
0027  * types of these resources.
0028  *
0029  * Endpoint configuration data defines properties of both IPA endpoints and
0030  * GSI channels.  A channel is a GSI construct, and represents a single
0031  * communication path between the IPA and a particular execution environment
0032  * (EE), such as the AP or Modem.  Each EE has a set of channels associated
0033  * with it, and each channel has an ID unique for that EE.  For the most part
0034  * the only GSI channels of concern to this driver belong to the AP
0035  *
0036  * An endpoint is an IPA construct representing a single channel anywhere
0037  * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
0038  * pair.  Generally, this driver is concerned with only endpoints associated
0039  * with the AP, however this will change when support for routing (etc.) is
0040  * added.  IPA endpoint and GSI channel configuration data are defined
0041  * together, establishing the endpoint_id->(EE, channel_id) mapping.
0042  *
0043  * Endpoint configuration data consists of three parts:  properties that
0044  * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
0045  * properties associated with the GSI channel; and properties associated with
0046  * the IPA endpoint.
0047  */
0048 
0049 /* The maximum possible number of source or destination resource groups */
0050 #define IPA_RESOURCE_GROUP_MAX  8
0051 
0052 /** enum ipa_qsb_master_id - array index for IPA QSB configuration data */
0053 enum ipa_qsb_master_id {
0054     IPA_QSB_MASTER_DDR,
0055     IPA_QSB_MASTER_PCIE,
0056 };
0057 
0058 /**
0059  * struct ipa_qsb_data - Qualcomm System Bus configuration data
0060  * @max_writes: Maximum outstanding write requests for this master
0061  * @max_reads:  Maximum outstanding read requests for this master
0062  * @max_reads_beats: Max outstanding read bytes in 8-byte "beats" (if non-zero)
0063  */
0064 struct ipa_qsb_data {
0065     u8 max_writes;
0066     u8 max_reads;
0067     u8 max_reads_beats;     /* Not present for IPA v3.5.1 */
0068 };
0069 
0070 /**
0071  * struct gsi_channel_data - GSI channel configuration data
0072  * @tre_count:      number of TREs in the channel ring
0073  * @event_count:    number of slots in the associated event ring
0074  * @tlv_count:      number of entries in channel's TLV FIFO
0075  *
0076  * A GSI channel is a unidirectional means of transferring data to or
0077  * from (and through) the IPA.  A GSI channel has a ring buffer made
0078  * up of "transfer ring elements" (TREs) that specify individual data
0079  * transfers or IPA immediate commands.  TREs are filled by the AP,
0080  * and control is passed to IPA hardware by writing the last written
0081  * element into a doorbell register.
0082  *
0083  * When data transfer commands have completed the GSI generates an
0084  * event (a structure of data) and optionally signals the AP with
0085  * an interrupt.  Event structures are implemented by another ring
0086  * buffer, directed toward the AP from the IPA.
0087  *
0088  * The input to a GSI channel is a FIFO of type/length/value (TLV)
0089  * elements, and the size of this FIFO limits the number of TREs
0090  * that can be included in a single transaction.
0091  */
0092 struct gsi_channel_data {
0093     u16 tre_count;          /* must be a power of 2 */
0094     u16 event_count;        /* must be a power of 2 */
0095     u8 tlv_count;
0096 };
0097 
0098 /**
0099  * struct ipa_endpoint_data - IPA endpoint configuration data
0100  * @filter_support: whether endpoint supports filtering
0101  * @config:     hardware configuration
0102  *
0103  * Not all endpoints support the IPA filtering capability.  A filter table
0104  * defines the filters to apply for those endpoints that support it.  The
0105  * AP is responsible for initializing this table, and it must include entries
0106  * for non-AP endpoints.  For this reason we define *all* endpoints used
0107  * in the system, and indicate whether they support filtering.
0108  *
0109  * The remaining endpoint configuration data specifies default hardware
0110  * configuration values that apply only to AP endpoints.
0111  */
0112 struct ipa_endpoint_data {
0113     bool filter_support;
0114     struct ipa_endpoint_config config;
0115 };
0116 
0117 /**
0118  * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
0119  * @ee_id:  GSI execution environment ID
0120  * @channel_id: GSI channel ID
0121  * @endpoint_id: IPA endpoint ID
0122  * @toward_ipa: direction of data transfer
0123  * @channel:    GSI channel configuration data (see above)
0124  * @endpoint:   IPA endpoint configuration data (see above)
0125  */
0126 struct ipa_gsi_endpoint_data {
0127     u8 ee_id;       /* enum gsi_ee_id */
0128     u8 channel_id;
0129     u8 endpoint_id;
0130     bool toward_ipa;
0131 
0132     struct gsi_channel_data channel;
0133     struct ipa_endpoint_data endpoint;
0134 };
0135 
0136 /**
0137  * struct ipa_resource_limits - minimum and maximum resource counts
0138  * @min:    minimum number of resources of a given type
0139  * @max:    maximum number of resources of a given type
0140  */
0141 struct ipa_resource_limits {
0142     u32 min;
0143     u32 max;
0144 };
0145 
0146 /**
0147  * struct ipa_resource - resource group source or destination resource usage
0148  * @limits: array of resource limits, indexed by group
0149  */
0150 struct ipa_resource {
0151     struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_MAX];
0152 };
0153 
0154 /**
0155  * struct ipa_resource_data - IPA resource configuration data
0156  * @rsrc_group_src_count: number of source resource groups supported
0157  * @rsrc_group_dst_count: number of destination resource groups supported
0158  * @resource_src_count: number of entries in the resource_src array
0159  * @resource_src:   source endpoint group resources
0160  * @resource_dst_count: number of entries in the resource_dst array
0161  * @resource_dst:   destination endpoint group resources
0162  *
0163  * In order to manage quality of service between endpoints, certain resources
0164  * required for operation are allocated to groups of endpoints.  Generally
0165  * this information is invisible to the AP, but the AP is responsible for
0166  * programming it at initialization time, so we specify it here.
0167  */
0168 struct ipa_resource_data {
0169     u32 rsrc_group_src_count;
0170     u32 rsrc_group_dst_count;
0171     u32 resource_src_count;
0172     const struct ipa_resource *resource_src;
0173     u32 resource_dst_count;
0174     const struct ipa_resource *resource_dst;
0175 };
0176 
0177 /**
0178  * struct ipa_mem_data - description of IPA memory regions
0179  * @local_count:    number of regions defined in the local[] array
0180  * @local:      array of IPA-local memory region descriptors
0181  * @imem_addr:      physical address of IPA region within IMEM
0182  * @imem_size:      size in bytes of IPA IMEM region
0183  * @smem_id:        item identifier for IPA region within SMEM memory
0184  * @smem_size:      size in bytes of the IPA SMEM region
0185  */
0186 struct ipa_mem_data {
0187     u32 local_count;
0188     const struct ipa_mem *local;
0189     u32 imem_addr;
0190     u32 imem_size;
0191     u32 smem_id;
0192     u32 smem_size;
0193 };
0194 
0195 /**
0196  * struct ipa_interconnect_data - description of IPA interconnect bandwidths
0197  * @name:       Interconnect name (matches interconnect-name in DT)
0198  * @peak_bandwidth: Peak interconnect bandwidth (in 1000 byte/sec units)
0199  * @average_bandwidth:  Average interconnect bandwidth (in 1000 byte/sec units)
0200  */
0201 struct ipa_interconnect_data {
0202     const char *name;
0203     u32 peak_bandwidth;
0204     u32 average_bandwidth;
0205 };
0206 
0207 /**
0208  * struct ipa_power_data - description of IPA power configuration data
0209  * @core_clock_rate:    Core clock rate (Hz)
0210  * @interconnect_count: Number of entries in the interconnect_data array
0211  * @interconnect_data:  IPA interconnect configuration data
0212  */
0213 struct ipa_power_data {
0214     u32 core_clock_rate;
0215     u32 interconnect_count;     /* # entries in interconnect_data[] */
0216     const struct ipa_interconnect_data *interconnect_data;
0217 };
0218 
0219 /**
0220  * struct ipa_data - combined IPA/GSI configuration data
0221  * @version:        IPA hardware version
0222  * @backward_compat:    BCR register value (prior to IPA v4.5 only)
0223  * @qsb_count:      number of entries in the qsb_data array
0224  * @qsb_data:       Qualcomm System Bus configuration data
0225  * @endpoint_count: number of entries in the endpoint_data array
0226  * @endpoint_data:  IPA endpoint/GSI channel data
0227  * @resource_data:  IPA resource configuration data
0228  * @mem_data:       IPA memory region data
0229  * @power_data:     IPA power data
0230  */
0231 struct ipa_data {
0232     enum ipa_version version;
0233     u32 backward_compat;
0234     u32 qsb_count;      /* number of entries in qsb_data[] */
0235     const struct ipa_qsb_data *qsb_data;
0236     u32 endpoint_count; /* number of entries in endpoint_data[] */
0237     const struct ipa_gsi_endpoint_data *endpoint_data;
0238     const struct ipa_resource_data *resource_data;
0239     const struct ipa_mem_data *mem_data;
0240     const struct ipa_power_data *power_data;
0241 };
0242 
0243 extern const struct ipa_data ipa_data_v3_1;
0244 extern const struct ipa_data ipa_data_v3_5_1;
0245 extern const struct ipa_data ipa_data_v4_2;
0246 extern const struct ipa_data ipa_data_v4_5;
0247 extern const struct ipa_data ipa_data_v4_9;
0248 extern const struct ipa_data ipa_data_v4_11;
0249 
0250 #endif /* _IPA_DATA_H_ */