![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * K3 Ring Accelerator (RA) subsystem interface 0004 * 0005 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com 0006 */ 0007 0008 #ifndef __SOC_TI_K3_RINGACC_API_H_ 0009 #define __SOC_TI_K3_RINGACC_API_H_ 0010 0011 #include <linux/types.h> 0012 0013 struct device_node; 0014 0015 /** 0016 * enum k3_ring_mode - &struct k3_ring_cfg mode 0017 * 0018 * RA ring operational modes 0019 * 0020 * @K3_RINGACC_RING_MODE_RING: Exposed Ring mode for SW direct access 0021 * @K3_RINGACC_RING_MODE_MESSAGE: Messaging mode. Messaging mode requires 0022 * that all accesses to the queue must go through this IP so that all 0023 * accesses to the memory are controlled and ordered. This IP then 0024 * controls the entire state of the queue, and SW has no directly control, 0025 * such as through doorbells and cannot access the storage memory directly. 0026 * This is particularly useful when more than one SW or HW entity can be 0027 * the producer and/or consumer at the same time 0028 * @K3_RINGACC_RING_MODE_CREDENTIALS: Credentials mode is message mode plus 0029 * stores credentials with each message, requiring the element size to be 0030 * doubled to fit the credentials. Any exposed memory should be protected 0031 * by a firewall from unwanted access 0032 */ 0033 enum k3_ring_mode { 0034 K3_RINGACC_RING_MODE_RING = 0, 0035 K3_RINGACC_RING_MODE_MESSAGE, 0036 K3_RINGACC_RING_MODE_CREDENTIALS, 0037 K3_RINGACC_RING_MODE_INVALID 0038 }; 0039 0040 /** 0041 * enum k3_ring_size - &struct k3_ring_cfg elm_size 0042 * 0043 * RA ring element's sizes in bytes. 0044 */ 0045 enum k3_ring_size { 0046 K3_RINGACC_RING_ELSIZE_4 = 0, 0047 K3_RINGACC_RING_ELSIZE_8, 0048 K3_RINGACC_RING_ELSIZE_16, 0049 K3_RINGACC_RING_ELSIZE_32, 0050 K3_RINGACC_RING_ELSIZE_64, 0051 K3_RINGACC_RING_ELSIZE_128, 0052 K3_RINGACC_RING_ELSIZE_256, 0053 K3_RINGACC_RING_ELSIZE_INVALID 0054 }; 0055 0056 struct k3_ringacc; 0057 struct k3_ring; 0058 0059 /** 0060 * enum k3_ring_cfg - RA ring configuration structure 0061 * 0062 * @size: Ring size, number of elements 0063 * @elm_size: Ring element size 0064 * @mode: Ring operational mode 0065 * @flags: Ring configuration flags. Possible values: 0066 * @K3_RINGACC_RING_SHARED: when set allows to request the same ring 0067 * few times. It's usable when the same ring is used as Free Host PD ring 0068 * for different flows, for example. 0069 * Note: Locking should be done by consumer if required 0070 * @dma_dev: Master device which is using and accessing to the ring 0071 * memory when the mode is K3_RINGACC_RING_MODE_RING. Memory allocations 0072 * should be done using this device. 0073 * @asel: Address Space Select value for physical addresses 0074 */ 0075 struct k3_ring_cfg { 0076 u32 size; 0077 enum k3_ring_size elm_size; 0078 enum k3_ring_mode mode; 0079 #define K3_RINGACC_RING_SHARED BIT(1) 0080 u32 flags; 0081 0082 struct device *dma_dev; 0083 u32 asel; 0084 }; 0085 0086 #define K3_RINGACC_RING_ID_ANY (-1) 0087 0088 /** 0089 * of_k3_ringacc_get_by_phandle - find a RA by phandle property 0090 * @np: device node 0091 * @propname: property name containing phandle on RA node 0092 * 0093 * Returns pointer on the RA - struct k3_ringacc 0094 * or -ENODEV if not found, 0095 * or -EPROBE_DEFER if not yet registered 0096 */ 0097 struct k3_ringacc *of_k3_ringacc_get_by_phandle(struct device_node *np, 0098 const char *property); 0099 0100 #define K3_RINGACC_RING_USE_PROXY BIT(1) 0101 0102 /** 0103 * k3_ringacc_request_ring - request ring from ringacc 0104 * @ringacc: pointer on ringacc 0105 * @id: ring id or K3_RINGACC_RING_ID_ANY for any general purpose ring 0106 * @flags: 0107 * @K3_RINGACC_RING_USE_PROXY: if set - proxy will be allocated and 0108 * used to access ring memory. Sopported only for rings in 0109 * Message/Credentials/Queue mode. 0110 * 0111 * Returns pointer on the Ring - struct k3_ring 0112 * or NULL in case of failure. 0113 */ 0114 struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, 0115 int id, u32 flags); 0116 0117 int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc, 0118 int fwd_id, int compl_id, 0119 struct k3_ring **fwd_ring, 0120 struct k3_ring **compl_ring); 0121 /** 0122 * k3_ringacc_ring_reset - ring reset 0123 * @ring: pointer on Ring 0124 * 0125 * Resets ring internal state ((hw)occ, (hw)idx). 0126 */ 0127 void k3_ringacc_ring_reset(struct k3_ring *ring); 0128 /** 0129 * k3_ringacc_ring_reset - ring reset for DMA rings 0130 * @ring: pointer on Ring 0131 * 0132 * Resets ring internal state ((hw)occ, (hw)idx). Should be used for rings 0133 * which are read by K3 UDMA, like TX or Free Host PD rings. 0134 */ 0135 void k3_ringacc_ring_reset_dma(struct k3_ring *ring, u32 occ); 0136 0137 /** 0138 * k3_ringacc_ring_free - ring free 0139 * @ring: pointer on Ring 0140 * 0141 * Resets ring and free all alocated resources. 0142 */ 0143 int k3_ringacc_ring_free(struct k3_ring *ring); 0144 0145 /** 0146 * k3_ringacc_get_ring_id - Get the Ring ID 0147 * @ring: pointer on ring 0148 * 0149 * Returns the Ring ID 0150 */ 0151 u32 k3_ringacc_get_ring_id(struct k3_ring *ring); 0152 0153 /** 0154 * k3_ringacc_get_ring_irq_num - Get the irq number for the ring 0155 * @ring: pointer on ring 0156 * 0157 * Returns the interrupt number which can be used to request the interrupt 0158 */ 0159 int k3_ringacc_get_ring_irq_num(struct k3_ring *ring); 0160 0161 /** 0162 * k3_ringacc_ring_cfg - ring configure 0163 * @ring: pointer on ring 0164 * @cfg: Ring configuration parameters (see &struct k3_ring_cfg) 0165 * 0166 * Configures ring, including ring memory allocation. 0167 * Returns 0 on success, errno otherwise. 0168 */ 0169 int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg); 0170 0171 /** 0172 * k3_ringacc_ring_get_size - get ring size 0173 * @ring: pointer on ring 0174 * 0175 * Returns ring size in number of elements. 0176 */ 0177 u32 k3_ringacc_ring_get_size(struct k3_ring *ring); 0178 0179 /** 0180 * k3_ringacc_ring_get_free - get free elements 0181 * @ring: pointer on ring 0182 * 0183 * Returns number of free elements in the ring. 0184 */ 0185 u32 k3_ringacc_ring_get_free(struct k3_ring *ring); 0186 0187 /** 0188 * k3_ringacc_ring_get_occ - get ring occupancy 0189 * @ring: pointer on ring 0190 * 0191 * Returns total number of valid entries on the ring 0192 */ 0193 u32 k3_ringacc_ring_get_occ(struct k3_ring *ring); 0194 0195 /** 0196 * k3_ringacc_ring_is_full - checks if ring is full 0197 * @ring: pointer on ring 0198 * 0199 * Returns true if the ring is full 0200 */ 0201 u32 k3_ringacc_ring_is_full(struct k3_ring *ring); 0202 0203 /** 0204 * k3_ringacc_ring_push - push element to the ring tail 0205 * @ring: pointer on ring 0206 * @elem: pointer on ring element buffer 0207 * 0208 * Push one ring element to the ring tail. Size of the ring element is 0209 * determined by ring configuration &struct k3_ring_cfg elm_size. 0210 * 0211 * Returns 0 on success, errno otherwise. 0212 */ 0213 int k3_ringacc_ring_push(struct k3_ring *ring, void *elem); 0214 0215 /** 0216 * k3_ringacc_ring_pop - pop element from the ring head 0217 * @ring: pointer on ring 0218 * @elem: pointer on ring element buffer 0219 * 0220 * Push one ring element from the ring head. Size of the ring element is 0221 * determined by ring configuration &struct k3_ring_cfg elm_size.. 0222 * 0223 * Returns 0 on success, errno otherwise. 0224 */ 0225 int k3_ringacc_ring_pop(struct k3_ring *ring, void *elem); 0226 0227 /** 0228 * k3_ringacc_ring_push_head - push element to the ring head 0229 * @ring: pointer on ring 0230 * @elem: pointer on ring element buffer 0231 * 0232 * Push one ring element to the ring head. Size of the ring element is 0233 * determined by ring configuration &struct k3_ring_cfg elm_size. 0234 * 0235 * Returns 0 on success, errno otherwise. 0236 * Not Supported by ring modes: K3_RINGACC_RING_MODE_RING 0237 */ 0238 int k3_ringacc_ring_push_head(struct k3_ring *ring, void *elem); 0239 0240 /** 0241 * k3_ringacc_ring_pop_tail - pop element from the ring tail 0242 * @ring: pointer on ring 0243 * @elem: pointer on ring element buffer 0244 * 0245 * Push one ring element from the ring tail. Size of the ring element is 0246 * determined by ring configuration &struct k3_ring_cfg elm_size. 0247 * 0248 * Returns 0 on success, errno otherwise. 0249 * Not Supported by ring modes: K3_RINGACC_RING_MODE_RING 0250 */ 0251 int k3_ringacc_ring_pop_tail(struct k3_ring *ring, void *elem); 0252 0253 u32 k3_ringacc_get_tisci_dev_id(struct k3_ring *ring); 0254 0255 /* DMA ring support */ 0256 struct ti_sci_handle; 0257 0258 /** 0259 * struct struct k3_ringacc_init_data - Initialization data for DMA rings 0260 */ 0261 struct k3_ringacc_init_data { 0262 const struct ti_sci_handle *tisci; 0263 u32 tisci_dev_id; 0264 u32 num_rings; 0265 }; 0266 0267 struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev, 0268 struct k3_ringacc_init_data *data); 0269 0270 #endif /* __SOC_TI_K3_RINGACC_API_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |