1 /* Copyright 2013-2015 Freescale Semiconductor Inc.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of the above-listed copyright holders nor the
11 * names of any contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
15 * ALTERNATIVELY, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL") as published by the Free Software
17 * Foundation, either version 2 of that License or (at your option) any
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
35 /* Data Path Buffer Pool API
36 * Contains initialization APIs and runtime control APIs for DPBP
42 * dpbp_open() - Open a control session for the specified object.
43 * @mc_io: Pointer to MC portal's I/O object
44 * @dpbp_id: DPBP unique ID
45 * @token: Returned token; use in subsequent API calls
47 * This function can be used to open a control session for an
48 * already created object; an object may have been declared in
49 * the DPL or by calling the dpbp_create function.
50 * This function returns a unique authentication token,
51 * associated with the specific object ID and the specific MC
52 * portal; this token must be used in all subsequent commands for
53 * this specific object
55 * Return: '0' on Success; Error code otherwise.
57 int dpbp_open(struct fsl_mc_io *mc_io, int dpbp_id, uint16_t *token);
60 * dpbp_close() - Close the control session of the object
61 * @mc_io: Pointer to MC portal's I/O object
62 * @token: Token of DPBP object
64 * After this function is called, no further operations are
65 * allowed on the object without opening a new control session.
67 * Return: '0' on Success; Error code otherwise.
69 int dpbp_close(struct fsl_mc_io *mc_io, uint16_t token);
72 * struct dpbp_cfg() - Structure representing DPBP configuration
73 * @options: place holder
80 * dpbp_create() - Create the DPBP object.
81 * @mc_io: Pointer to MC portal's I/O object
82 * @cfg: Configuration structure
83 * @token: Returned token; use in subsequent API calls
85 * Create the DPBP object, allocate required resources and
86 * perform required initialization.
88 * The object can be created either by declaring it in the
89 * DPL file, or by calling this function.
90 * This function returns a unique authentication token,
91 * associated with the specific object ID and the specific MC
92 * portal; this token must be used in all subsequent calls to
93 * this specific object. For objects that are created using the
94 * DPL file, call dpbp_open function to get an authentication
97 * Return: '0' on Success; Error code otherwise.
99 int dpbp_create(struct fsl_mc_io *mc_io,
100 const struct dpbp_cfg *cfg,
104 * dpbp_destroy() - Destroy the DPBP object and release all its resources.
105 * @mc_io: Pointer to MC portal's I/O object
106 * @token: Token of DPBP object
108 * Return: '0' on Success; error code otherwise.
110 int dpbp_destroy(struct fsl_mc_io *mc_io, uint16_t token);
113 * dpbp_enable() - Enable the DPBP.
114 * @mc_io: Pointer to MC portal's I/O object
115 * @token: Token of DPBP object
117 * Return: '0' on Success; Error code otherwise.
119 int dpbp_enable(struct fsl_mc_io *mc_io, uint16_t token);
122 * dpbp_disable() - Disable the DPBP.
123 * @mc_io: Pointer to MC portal's I/O object
124 * @token: Token of DPBP object
126 * Return: '0' on Success; Error code otherwise.
128 int dpbp_disable(struct fsl_mc_io *mc_io, uint16_t token);
131 * dpbp_is_enabled() - Check if the DPBP is enabled.
132 * @mc_io: Pointer to MC portal's I/O object
133 * @token: Token of DPBP object
134 * @en: Returns '1' if object is enabled; '0' otherwise
136 * Return: '0' on Success; Error code otherwise.
138 int dpbp_is_enabled(struct fsl_mc_io *mc_io, uint16_t token, int *en);
141 * dpbp_reset() - Reset the DPBP, returns the object to initial state.
142 * @mc_io: Pointer to MC portal's I/O object
143 * @token: Token of DPBP object
145 * Return: '0' on Success; Error code otherwise.
147 int dpbp_reset(struct fsl_mc_io *mc_io, uint16_t token);
150 * dpbp_set_irq() - Set IRQ information for the DPBP to trigger an interrupt.
151 * @mc_io: Pointer to MC portal's I/O object
152 * @token: Token of DPBP object
153 * @irq_index: Identifies the interrupt index to configure
154 * @irq_addr: Address that must be written to
155 * signal a message-based interrupt
156 * @irq_val: Value to write into irq_addr address
157 * @user_irq_id: A user defined number associated with this IRQ
159 * Return: '0' on Success; Error code otherwise.
161 int dpbp_set_irq(struct fsl_mc_io *mc_io,
169 * dpbp_get_irq() - Get IRQ information from the DPBP.
170 * @mc_io: Pointer to MC portal's I/O object
171 * @token: Token of DPBP object
172 * @irq_index: The interrupt index to configure
173 * @type: Interrupt type: 0 represents message interrupt
174 * type (both irq_addr and irq_val are valid)
175 * @irq_addr: Returned address that must be written to
176 * signal the message-based interrupt
177 * @irq_val: Value to write into irq_addr address
178 * @user_irq_id: A user defined number associated with this IRQ
180 * Return: '0' on Success; Error code otherwise.
182 int dpbp_get_irq(struct fsl_mc_io *mc_io,
191 * dpbp_set_irq_enable() - Set overall interrupt state.
192 * @mc_io: Pointer to MC portal's I/O object
193 * @token: Token of DPBP object
194 * @irq_index: The interrupt index to configure
195 * @en: Interrupt state - enable = 1, disable = 0
197 * Allows GPP software to control when interrupts are generated.
198 * Each interrupt can have up to 32 causes. The enable/disable control's the
199 * overall interrupt state. if the interrupt is disabled no causes will cause
202 * Return: '0' on Success; Error code otherwise.
204 int dpbp_set_irq_enable(struct fsl_mc_io *mc_io,
210 * dpbp_get_irq_enable() - Get overall interrupt state
211 * @mc_io: Pointer to MC portal's I/O object
212 * @token: Token of DPBP object
213 * @irq_index: The interrupt index to configure
214 * @en: Returned interrupt state - enable = 1, disable = 0
216 * Return: '0' on Success; Error code otherwise.
218 int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
224 * dpbp_set_irq_mask() - Set interrupt mask.
225 * @mc_io: Pointer to MC portal's I/O object
226 * @token: Token of DPBP object
227 * @irq_index: The interrupt index to configure
228 * @mask: Event mask to trigger interrupt;
231 * 1 = consider event for asserting IRQ
233 * Every interrupt can have up to 32 causes and the interrupt model supports
234 * masking/unmasking each cause independently
236 * Return: '0' on Success; Error code otherwise.
238 int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
244 * dpbp_get_irq_mask() - Get interrupt mask.
245 * @mc_io: Pointer to MC portal's I/O object
246 * @token: Token of DPBP object
247 * @irq_index: The interrupt index to configure
248 * @mask: Returned event mask to trigger interrupt
250 * Every interrupt can have up to 32 causes and the interrupt model supports
251 * masking/unmasking each cause independently
253 * Return: '0' on Success; Error code otherwise.
255 int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
261 * dpbp_get_irq_status() - Get the current status of any pending interrupts.
263 * @mc_io: Pointer to MC portal's I/O object
264 * @token: Token of DPBP object
265 * @irq_index: The interrupt index to configure
266 * @status: Returned interrupts status - one bit per cause:
267 * 0 = no interrupt pending
268 * 1 = interrupt pending
270 * Return: '0' on Success; Error code otherwise.
272 int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
278 * dpbp_clear_irq_status() - Clear a pending interrupt's status
280 * @mc_io: Pointer to MC portal's I/O object
281 * @token: Token of DPBP object
282 * @irq_index: The interrupt index to configure
283 * @status: Bits to clear (W1C) - one bit per cause:
285 * 1 = clear status bit
287 * Return: '0' on Success; Error code otherwise.
289 int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
295 * struct dpbp_attr - Structure representing DPBP attributes
296 * @id: DPBP object ID
297 * @version: DPBP version
298 * @bpid: Hardware buffer pool ID; should be used as an argument in
299 * acquire/release operations on buffers
304 * struct version - Structure representing DPBP version
305 * @major: DPBP major version
306 * @minor: DPBP minor version
316 * dpbp_get_attributes - Retrieve DPBP attributes.
318 * @mc_io: Pointer to MC portal's I/O object
319 * @token: Token of DPBP object
320 * @attr: Returned object's attributes
322 * Return: '0' on Success; Error code otherwise.
324 int dpbp_get_attributes(struct fsl_mc_io *mc_io,
326 struct dpbp_attr *attr);
330 #endif /* __FSL_DPBP_H */