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