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 Management Command Portal API
36 * Contains initialization APIs and runtime control APIs for DPMCP
42 * dpmcp_open() - Open a control session for the specified object.
43 * @mc_io: Pointer to MC portal's I/O object
44 * @dpmcp_id: DPMCP 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 dpmcp_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 dpmcp_open(struct fsl_mc_io *mc_io, int dpmcp_id, uint16_t *token);
59 /* Get portal ID from pool */
60 #define DPMCP_GET_PORTAL_ID_FROM_POOL (-1)
63 * dpmcp_close() - Close the control session of the object
64 * @mc_io: Pointer to MC portal's I/O object
65 * @token: Token of DPMCP object
67 * After this function is called, no further operations are
68 * allowed on the object without opening a new control session.
70 * Return: '0' on Success; Error code otherwise.
72 int dpmcp_close(struct fsl_mc_io *mc_io, uint16_t token);
75 * struct dpmcp_cfg() - Structure representing DPMCP configuration
76 * @portal_id: Portal ID; 'DPMCP_GET_PORTAL_ID_FROM_POOL' to get the portal ID
84 * dpmcp_create() - Create the DPMCP object.
85 * @mc_io: Pointer to MC portal's I/O object
86 * @cfg: Configuration structure
87 * @token: Returned token; use in subsequent API calls
89 * Create the DPMCP object, allocate required resources and
90 * perform required initialization.
92 * The object can be created either by declaring it in the
93 * DPL file, or by calling this function.
94 * This function returns a unique authentication token,
95 * associated with the specific object ID and the specific MC
96 * portal; this token must be used in all subsequent calls to
97 * this specific object. For objects that are created using the
98 * DPL file, call dpmcp_open function to get an authentication
101 * Return: '0' on Success; Error code otherwise.
103 int dpmcp_create(struct fsl_mc_io *mc_io,
104 const struct dpmcp_cfg *cfg,
108 * dpmcp_destroy() - Destroy the DPMCP object and release all its resources.
109 * @mc_io: Pointer to MC portal's I/O object
110 * @token: Token of DPMCP object
112 * Return: '0' on Success; error code otherwise.
114 int dpmcp_destroy(struct fsl_mc_io *mc_io, uint16_t token);
117 * dpmcp_reset() - Reset the DPMCP, returns the object to initial state.
118 * @mc_io: Pointer to MC portal's I/O object
119 * @token: Token of DPMCP object
121 * Return: '0' on Success; Error code otherwise.
123 int dpmcp_reset(struct fsl_mc_io *mc_io, uint16_t token);
127 * @name dpmcp IRQ Index and Events
129 #define DPMCP_IRQ_INDEX 0
131 #define DPMCP_IRQ_EVENT_CMD_DONE 0x00000001
132 /*!< irq event - Indicates that the link state changed */
136 * dpmcp_set_irq() - Set IRQ information for the DPMCP to trigger an interrupt.
137 * @mc_io: Pointer to MC portal's I/O object
138 * @token: Token of DPMCP object
139 * @irq_index: Identifies the interrupt index to configure
140 * @irq_addr: Address that must be written to
141 * signal a message-based interrupt
142 * @irq_val: Value to write into irq_addr address
143 * @user_irq_id: A user defined number associated with this IRQ
145 * Return: '0' on Success; Error code otherwise.
147 int dpmcp_set_irq(struct fsl_mc_io *mc_io,
155 * dpmcp_get_irq() - Get IRQ information from the DPMCP.
156 * @mc_io: Pointer to MC portal's I/O object
157 * @token: Token of DPMCP object
158 * @irq_index: The interrupt index to configure
159 * @type: Interrupt type: 0 represents message interrupt
160 * type (both irq_addr and irq_val are valid)
161 * @irq_addr: Returned address that must be written to
162 * signal the message-based interrupt
163 * @irq_val: Value to write into irq_addr address
164 * @user_irq_id: A user defined number associated with this IRQ
166 * Return: '0' on Success; Error code otherwise.
168 int dpmcp_get_irq(struct fsl_mc_io *mc_io,
177 * dpmcp_set_irq_enable() - Set overall interrupt state.
178 * @mc_io: Pointer to MC portal's I/O object
179 * @token: Token of DPMCP object
180 * @irq_index: The interrupt index to configure
181 * @en: Interrupt state - enable = 1, disable = 0
183 * Allows GPP software to control when interrupts are generated.
184 * Each interrupt can have up to 32 causes. The enable/disable control's the
185 * overall interrupt state. if the interrupt is disabled no causes will cause
188 * Return: '0' on Success; Error code otherwise.
190 int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io,
196 * dpmcp_get_irq_enable() - Get overall interrupt state
197 * @mc_io: Pointer to MC portal's I/O object
198 * @token: Token of DPMCP object
199 * @irq_index: The interrupt index to configure
200 * @en: Returned interrupt state - enable = 1, disable = 0
202 * Return: '0' on Success; Error code otherwise.
204 int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
210 * dpmcp_set_irq_mask() - Set interrupt mask.
211 * @mc_io: Pointer to MC portal's I/O object
212 * @token: Token of DPMCP object
213 * @irq_index: The interrupt index to configure
214 * @mask: Event mask to trigger interrupt;
217 * 1 = consider event for asserting IRQ
219 * Every interrupt can have up to 32 causes and the interrupt model supports
220 * masking/unmasking each cause independently
222 * Return: '0' on Success; Error code otherwise.
224 int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io,
230 * dpmcp_get_irq_mask() - Get interrupt mask.
231 * @mc_io: Pointer to MC portal's I/O object
232 * @token: Token of DPMCP object
233 * @irq_index: The interrupt index to configure
234 * @mask: Returned event mask to trigger interrupt
236 * Every interrupt can have up to 32 causes and the interrupt model supports
237 * masking/unmasking each cause independently
239 * Return: '0' on Success; Error code otherwise.
241 int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
247 * dpmcp_get_irq_status() - Get the current status of any pending interrupts.
249 * @mc_io: Pointer to MC portal's I/O object
250 * @token: Token of DPMCP object
251 * @irq_index: The interrupt index to configure
252 * @status: Returned interrupts status - one bit per cause:
253 * 0 = no interrupt pending
254 * 1 = interrupt pending
256 * Return: '0' on Success; Error code otherwise.
258 int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
264 * dpmcp_clear_irq_status() - Clear a pending interrupt's status
266 * @mc_io: Pointer to MC portal's I/O object
267 * @token: Token of DPMCP object
268 * @irq_index: The interrupt index to configure
269 * @status: Bits to clear (W1C) - one bit per cause:
271 * 1 = clear status bit
273 * Return: '0' on Success; Error code otherwise.
275 int dpmcp_clear_irq_status(struct fsl_mc_io *mc_io,
281 * struct dpmcp_attr - Structure representing DPMCP attributes
282 * @id: DPMCP object ID
283 * @version: DPMCP version
288 * struct version - Structure representing DPMCP version
289 * @major: DPMCP major version
290 * @minor: DPMCP minor version
299 * dpmcp_get_attributes - Retrieve DPMCP attributes.
301 * @mc_io: Pointer to MC portal's I/O object
302 * @token: Token of DPMCP object
303 * @attr: Returned object's attributes
305 * Return: '0' on Success; Error code otherwise.
307 int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
309 struct dpmcp_attr *attr);
311 #endif /* __FSL_DPMCP_H */