1 /* ==========================================================================
2 * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_pcd_if.h $
7 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
8 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
9 * otherwise expressly agreed to in writing between Synopsys and you.
11 * The Software IS NOT an item of Licensed Software or Licensed Product under
12 * any End User Software License Agreement or Agreement for Licensed Product
13 * with Synopsys or any supplement thereto. You are permitted to use and
14 * redistribute this Software in source and binary forms, with or without
15 * modification, provided that redistributions of source code must retain this
16 * notice. You may not view, use, disclose, copy or distribute this file or
17 * any information contained herein except pursuant to this license grant from
18 * Synopsys. If you do not agree with this notice, including the disclaimer
19 * below, then you are not authorized to use the Software.
21 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
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 HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32 * ========================================================================== */
35 #if !defined(__DWC_PCD_IF_H__)
36 #define __DWC_PCD_IF_H__
41 * This file defines DWC_OTG PCD Core API.
45 typedef struct dwc_otg_pcd dwc_otg_pcd_t;
47 /** Maxpacket size for EP0 */
48 #define MAX_EP0_SIZE 64
49 /** Maxpacket size for any EP */
50 #define MAX_PACKET_SIZE 1024
52 /** @name Function Driver Callbacks */
55 /** This function will be called whenever a previously queued request has
56 * completed. The status value will be set to -DWC_E_SHUTDOWN to indicated a
57 * failed or aborted transfer, or -DWC_E_RESTART to indicate the device was reset,
58 * or -DWC_E_TIMEOUT to indicate it timed out, or -DWC_E_INVALID to indicate invalid
60 typedef int (*dwc_completion_cb_t) (dwc_otg_pcd_t * pcd, void *ep_handle,
61 void *req_handle, int32_t status,
64 * This function will be called whenever a previousle queued ISOC request has
65 * completed. Count of ISOC packets could be read using dwc_otg_pcd_get_iso_packet_count
67 * The status of each ISOC packet could be read using dwc_otg_pcd_get_iso_packet_*
70 typedef int (*dwc_isoc_completion_cb_t) (dwc_otg_pcd_t * pcd, void *ep_handle,
71 void *req_handle, int proc_buf_num);
72 /** This function should handle any SETUP request that cannot be handled by the
73 * PCD Core. This includes most GET_DESCRIPTORs, SET_CONFIGS, Any
74 * class-specific requests, etc. The function must non-blocking.
76 * Returns 0 on success.
77 * Returns -DWC_E_NOT_SUPPORTED if the request is not supported.
78 * Returns -DWC_E_INVALID if the setup request had invalid parameters or bytes.
79 * Returns -DWC_E_SHUTDOWN on any other error. */
80 typedef int (*dwc_setup_cb_t) (dwc_otg_pcd_t * pcd, uint8_t * bytes);
81 /** This is called whenever the device has been disconnected. The function
82 * driver should take appropriate action to clean up all pending requests in the
83 * PCD Core, remove all endpoints (except ep0), and initialize back to reset
85 typedef int (*dwc_disconnect_cb_t) (dwc_otg_pcd_t * pcd);
86 /** This function is called when device has been connected. */
87 typedef int (*dwc_connect_cb_t) (dwc_otg_pcd_t * pcd, int speed);
88 /** This function is called when device has been suspended */
89 typedef int (*dwc_suspend_cb_t) (dwc_otg_pcd_t * pcd);
90 /** This function is called when device has received LPM tokens, i.e.
91 * device has been sent to sleep state. */
92 typedef int (*dwc_sleep_cb_t) (dwc_otg_pcd_t * pcd);
93 /** This function is called when device has been resumed
94 * from suspend(L2) or L1 sleep state. */
95 typedef int (*dwc_resume_cb_t) (dwc_otg_pcd_t * pcd);
96 /** This function is called whenever hnp params has been changed.
97 * User can call get_b_hnp_enable, get_a_hnp_support, get_a_alt_hnp_support functions
98 * to get hnp parameters. */
99 typedef int (*dwc_hnp_params_changed_cb_t) (dwc_otg_pcd_t * pcd);
100 /** This function is called whenever USB RESET is detected. */
101 typedef int (*dwc_reset_cb_t) (dwc_otg_pcd_t * pcd);
103 typedef int (*cfi_setup_cb_t) (dwc_otg_pcd_t * pcd, void *ctrl_req_bytes);
105 /** Function Driver Ops Data Structure */
106 struct dwc_otg_pcd_function_ops {
107 dwc_connect_cb_t connect;
108 dwc_disconnect_cb_t disconnect;
109 dwc_setup_cb_t setup;
110 dwc_completion_cb_t complete;
111 dwc_isoc_completion_cb_t isoc_complete;
112 dwc_suspend_cb_t suspend;
113 dwc_sleep_cb_t sleep;
114 dwc_resume_cb_t resume;
115 dwc_reset_cb_t reset;
116 dwc_hnp_params_changed_cb_t hnp_changed;
117 cfi_setup_cb_t cfi_setup;
121 /** @name Function Driver Functions */
124 /** Call this function to get pointer on dwc_otg_pcd_t,
125 * this pointer will be used for all PCD API functions.
127 * @param core_if The DWC_OTG Core
129 extern dwc_otg_pcd_t *dwc_otg_pcd_init(dwc_otg_core_if_t * core_if);
131 /** Frees PCD allocated by dwc_otg_pcd_init
135 extern void dwc_otg_pcd_remove(dwc_otg_pcd_t * pcd);
137 /** Call this to bind the function driver to the PCD Core.
139 * @param pcd Pointer on dwc_otg_pcd_t returned by dwc_otg_pcd_init function.
140 * @param fops The Function Driver Ops data structure containing pointers to all callbacks.
142 extern void dwc_otg_pcd_start(dwc_otg_pcd_t * pcd,
143 const struct dwc_otg_pcd_function_ops *fops);
145 /** Enables an endpoint for use. This function enables an endpoint in
146 * the PCD. The endpoint is described by the ep_desc which has the
147 * same format as a USB ep descriptor. The ep_handle parameter is used to refer
148 * to the endpoint from other API functions and in callbacks. Normally this
149 * should be called after a SET_CONFIGURATION/SET_INTERFACE to configure the
150 * core for that interface.
152 * Returns -DWC_E_INVALID if invalid parameters were passed.
153 * Returns -DWC_E_SHUTDOWN if any other error ocurred.
154 * Returns 0 on success.
157 * @param ep_desc Endpoint descriptor
158 * @param ep_handle Handle on endpoint, that will be used to identify endpoint.
160 extern int dwc_otg_pcd_ep_enable(dwc_otg_pcd_t * pcd,
161 const uint8_t * ep_desc, void *ep_handle);
163 /** Disable the endpoint referenced by ep_handle.
165 * Returns -DWC_E_INVALID if invalid parameters were passed.
166 * Returns -DWC_E_SHUTDOWN if any other error ocurred.
167 * Returns 0 on success. */
168 extern int dwc_otg_pcd_ep_disable(dwc_otg_pcd_t * pcd, void *ep_handle);
170 /** Queue a data transfer request on the endpoint referenced by ep_handle.
171 * After the transfer is completes, the complete callback will be called with
172 * the request status.
175 * @param ep_handle The handle of the endpoint
176 * @param buf The buffer for the data
177 * @param dma_buf The DMA buffer for the data
178 * @param buflen The length of the data transfer
179 * @param zero Specifies whether to send zero length last packet.
180 * @param req_handle Set this handle to any value to use to reference this
181 * request in the ep_dequeue function or from the complete callback
182 * @param atomic_alloc If driver need to perform atomic allocations
183 * for internal data structures.
185 * Returns -DWC_E_INVALID if invalid parameters were passed.
186 * Returns -DWC_E_SHUTDOWN if any other error ocurred.
187 * Returns 0 on success. */
188 extern int dwc_otg_pcd_ep_queue(dwc_otg_pcd_t * pcd, void *ep_handle,
189 uint8_t * buf, dwc_dma_t dma_buf,
190 uint32_t buflen, int zero, void *req_handle,
193 /** De-queue the specified data transfer that has not yet completed.
195 * Returns -DWC_E_INVALID if invalid parameters were passed.
196 * Returns -DWC_E_SHUTDOWN if any other error ocurred.
197 * Returns 0 on success. */
198 extern int dwc_otg_pcd_ep_dequeue(dwc_otg_pcd_t * pcd, void *ep_handle,
201 /** Halt (STALL) an endpoint or clear it.
203 * Returns -DWC_E_INVALID if invalid parameters were passed.
204 * Returns -DWC_E_SHUTDOWN if any other error ocurred.
205 * Returns -DWC_E_AGAIN if the STALL cannot be sent and must be tried again later
206 * Returns 0 on success. */
207 extern int dwc_otg_pcd_ep_halt(dwc_otg_pcd_t * pcd, void *ep_handle, int value);
209 /** This function should be called on every hardware interrupt */
210 extern int32_t dwc_otg_pcd_handle_intr(dwc_otg_pcd_t * pcd);
212 /** This function returns current frame number */
213 extern int dwc_otg_pcd_get_frame_number(dwc_otg_pcd_t * pcd);
216 * Start isochronous transfers on the endpoint referenced by ep_handle.
217 * For isochronous transfers duble buffering is used.
218 * After processing each of buffers comlete callback will be called with
219 * status for each transaction.
222 * @param ep_handle The handle of the endpoint
223 * @param buf0 The virtual address of first data buffer
224 * @param buf1 The virtual address of second data buffer
225 * @param dma0 The DMA address of first data buffer
226 * @param dma1 The DMA address of second data buffer
227 * @param sync_frame Data pattern frame number
228 * @param dp_frame Data size for pattern frame
229 * @param data_per_frame Data size for regular frame
230 * @param start_frame Frame number to start transfers, if -1 then start transfers ASAP.
231 * @param buf_proc_intrvl Interval of ISOC Buffer processing
232 * @param req_handle Handle of ISOC request
233 * @param atomic_alloc Specefies whether to perform atomic allocation for
234 * internal data structures.
236 * Returns -DWC_E_NO_MEMORY if there is no enough memory.
237 * Returns -DWC_E_INVALID if incorrect arguments are passed to the function.
238 * Returns -DW_E_SHUTDOWN for any other error.
239 * Returns 0 on success
241 extern int dwc_otg_pcd_iso_ep_start(dwc_otg_pcd_t * pcd, void *ep_handle,
242 uint8_t * buf0, uint8_t * buf1,
243 dwc_dma_t dma0, dwc_dma_t dma1,
244 int sync_frame, int dp_frame,
245 int data_per_frame, int start_frame,
246 int buf_proc_intrvl, void *req_handle,
249 /** Stop ISOC transfers on endpoint referenced by ep_handle.
252 * @param ep_handle The handle of the endpoint
253 * @param req_handle Handle of ISOC request
255 * Returns -DWC_E_INVALID if incorrect arguments are passed to the function
256 * Returns 0 on success
258 int dwc_otg_pcd_iso_ep_stop(dwc_otg_pcd_t * pcd, void *ep_handle,
261 /** Get ISOC packet status.
264 * @param ep_handle The handle of the endpoint
265 * @param iso_req_handle Isochronoush request handle
266 * @param packet Number of packet
267 * @param status Out parameter for returning status
268 * @param actual Out parameter for returning actual length
269 * @param offset Out parameter for returning offset
272 extern void dwc_otg_pcd_get_iso_packet_params(dwc_otg_pcd_t * pcd,
274 void *iso_req_handle, int packet,
275 int *status, int *actual,
278 /** Get ISOC packet count.
281 * @param ep_handle The handle of the endpoint
282 * @param iso_req_handle
284 extern int dwc_otg_pcd_get_iso_packet_count(dwc_otg_pcd_t * pcd,
286 void *iso_req_handle);
288 /** This function starts the SRP Protocol if no session is in progress. If
289 * a session is already in progress, but the device is suspended,
290 * remote wakeup signaling is started.
292 extern int dwc_otg_pcd_wakeup(dwc_otg_pcd_t * pcd);
294 /** This function returns 1 if LPM support is enabled, and 0 otherwise. */
295 extern int dwc_otg_pcd_is_lpm_enabled(dwc_otg_pcd_t * pcd);
297 /** This function returns 1 if remote wakeup is allowed and 0, otherwise. */
298 extern int dwc_otg_pcd_get_rmwkup_enable(dwc_otg_pcd_t * pcd);
301 extern void dwc_otg_pcd_initiate_srp(dwc_otg_pcd_t * pcd);
303 /** Starts remote wakeup signaling. */
304 extern void dwc_otg_pcd_remote_wakeup(dwc_otg_pcd_t * pcd, int set);
306 /** This function returns whether device is dualspeed.*/
307 extern uint32_t dwc_otg_pcd_is_dualspeed(dwc_otg_pcd_t * pcd);
309 /** This function returns whether device is otg. */
310 extern uint32_t dwc_otg_pcd_is_otg(dwc_otg_pcd_t * pcd);
312 /** These functions allow to get hnp parameters */
313 extern uint32_t get_b_hnp_enable(dwc_otg_pcd_t * pcd);
314 extern uint32_t get_a_hnp_support(dwc_otg_pcd_t * pcd);
315 extern uint32_t get_a_alt_hnp_support(dwc_otg_pcd_t * pcd);
317 /** CFI specific Interface functions */
318 /** Allocate a cfi buffer */
319 extern uint8_t *cfiw_ep_alloc_buffer(dwc_otg_pcd_t * pcd, void *pep,
320 dwc_dma_t * addr, size_t buflen,
323 /******************************************************************************/
327 #endif /* __DWC_PCD_IF_H__ */
329 #endif /* DWC_HOST_ONLY */