2 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the above-listed copyright holders nor the
12 * names of any contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 * Data Path Resource Container API
38 * Contains DPRC API for managing and querying DPAA resources
42 struct fsl_mc_obj_desc;
44 int dprc_open(struct fsl_mc_io *mc_io,
49 int dprc_close(struct fsl_mc_io *mc_io,
56 #define DPRC_IRQ_INDEX 0
58 /* Number of dprc's IRQs */
59 #define DPRC_NUM_OF_IRQS 1
63 /* IRQ event - Indicates that a new object added to the container */
64 #define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
65 /* IRQ event - Indicates that an object was removed from the container */
66 #define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
67 /* IRQ event - Indicates that resources added to the container */
68 #define DPRC_IRQ_EVENT_RES_ADDED 0x00000004
69 /* IRQ event - Indicates that resources removed from the container */
70 #define DPRC_IRQ_EVENT_RES_REMOVED 0x00000008
72 * IRQ event - Indicates that one of the descendant containers that opened by
73 * this container is destroyed
75 #define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
78 * IRQ event - Indicates that on one of the container's opened object is
81 #define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
83 /* Irq event - Indicates that object is created at the container */
84 #define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
87 * struct dprc_irq_cfg - IRQ configuration
88 * @paddr: Address that must be written to signal a message-based interrupt
89 * @val: Value to write into irq_addr address
90 * @irq_num: A user defined number associated with this IRQ
98 int dprc_set_irq(struct fsl_mc_io *mc_io,
102 struct dprc_irq_cfg *irq_cfg);
104 int dprc_get_irq(struct fsl_mc_io *mc_io,
109 struct dprc_irq_cfg *irq_cfg);
111 int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
117 int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
123 int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
129 int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
135 int dprc_get_irq_status(struct fsl_mc_io *mc_io,
141 int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
148 * struct dprc_attributes - Container attributes
149 * @container_id: Container's ID
150 * @icid: Container's ICID
151 * @portal_id: Container's portal ID
152 * @options: Container's options as set at container's creation
154 struct dprc_attributes {
161 int dprc_get_attributes(struct fsl_mc_io *mc_io,
164 struct dprc_attributes *attributes);
166 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
171 int dprc_get_obj(struct fsl_mc_io *mc_io,
175 struct fsl_mc_obj_desc *obj_desc);
177 int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
182 struct fsl_mc_obj_desc *obj_desc);
184 int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
190 struct dprc_irq_cfg *irq_cfg);
192 int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
199 struct dprc_irq_cfg *irq_cfg);
201 int dprc_get_res_count(struct fsl_mc_io *mc_io,
208 * enum dprc_iter_status - Iteration status
209 * @DPRC_ITER_STATUS_FIRST: Perform first iteration
210 * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
211 * @DPRC_ITER_STATUS_LAST: Indicates last iteration
213 enum dprc_iter_status {
214 DPRC_ITER_STATUS_FIRST = 0,
215 DPRC_ITER_STATUS_MORE = 1,
216 DPRC_ITER_STATUS_LAST = 2
220 /* Cacheable - Indicates that region should be mapped as cacheable */
221 #define DPRC_REGION_CACHEABLE 0x00000001
224 * enum dprc_region_type - Region type
225 * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
226 * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
228 enum dprc_region_type {
229 DPRC_REGION_TYPE_MC_PORTAL,
230 DPRC_REGION_TYPE_QBMAN_PORTAL
234 * struct dprc_region_desc - Mappable region descriptor
235 * @base_offset: Region offset from region's base address.
236 * For DPMCP and DPRC objects, region base is offset from SoC MC portals
237 * base address; For DPIO, region base is offset from SoC QMan portals
239 * @size: Region size (in bytes)
240 * @flags: Region attributes
241 * @type: Portal region type
243 struct dprc_region_desc {
247 enum dprc_region_type type;
250 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
256 struct dprc_region_desc *region_desc);
258 int dprc_get_api_version(struct fsl_mc_io *mc_io,
263 int dprc_get_container_id(struct fsl_mc_io *mc_io,
267 #endif /* _FSL_DPRC_H */