AM261x MCU+ SDK  11.00.00
pcd.h
Go to the documentation of this file.
1 /* ==========================================================================
2  * $File: //dwh/usb_iip/dev/software/DWC_usb3/driver/pcd.h $
3  * $Revision: #66 $
4  * $Date: 2013/12/17 $
5  * $Change: 2392669 $
6  *
7  * Synopsys SS USB3 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.
10  *
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.
20  *
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
31  * DAMAGE.
32  * ========================================================================== */
33 #ifndef _DWC_PCD_H_
34 #define _DWC_PCD_H_
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
60 #include "dwc_queue.h"
61 
66 #define DWC_MAX_TX_FIFOS 16
67 
72 #define DWC_MAX_PHYS_EP 32
73 
77 #define DWC_MAX_DATA_BUFS 13
78 
82 /*16 TODO reducing the memory foot print */
83 #define DWC_MAX_EPS 5U
84 
88 #define DWC_MAX_EP0_SIZE 512
89 
93 #define DWC_MAX_PACKET_SIZE 1024
94 
98 typedef enum ep0_state {
109 } ep0state_e;
110 
114 typedef enum pcd_state {
119 } pcdstate_e;
120 
121 struct dwc_usb3_device;
122 struct dwc_usb3_pcd;
123 
131 typedef struct dwc_reqt {
139 #define DWC_PCD_REQ_ZERO 0x001U
140 #define DWC_PCD_REQ_STARTED 0x002U
141 #define DWC_PCD_REQ_MAP_DMA 0x100
142 #define DWC_PCD_REQ_IN 0x200
144  int numbuf;
145  char *buf[DWC_MAX_DATA_BUFS];
146  dwc_dma_t bufdma[DWC_MAX_DATA_BUFS];
147  u32 buflen[DWC_MAX_DATA_BUFS];
148 } dwc_req_t;
149 
157 typedef struct dwc_usb3_pcd_req {
160 
161  /* ==== The rest is OS-specific ==== */
162 
164 #if defined(__linux__) || defined(SELA_PLATFORM)
165  struct list_head entry;
166 #else
167  DWC_CIRCLEQ_ENTRY(dwc_usb3_pcd_req) entry;
168 #endif
169 
171  struct usb_request usb_req;
173 
175 typedef struct dwc_usb3_event_req{
176  u32 event;
177  DWC_SIMPLEQ_ENTRY(dwc_usb3_event_req) entry;
178 } dwc_usb3_event_req_t ;
186 typedef struct dwc_ept {
188  struct dwc_usb3_pcd *pcd;
189 
192 
195 
198 
201 
204 
207 
210 
213 
216 
219 
222 
231  unsigned int stopped : 1;
232  unsigned int disabling : 1;
233  unsigned int queue_sof : 1;
238  unsigned int send_zlp : 1;
239 
241  unsigned int stall_clear_flag : 1;
242 
244  unsigned int three_stage : 1;
245 
247  unsigned int xfer_started : 1;
251  unsigned int is_in : 1;
252 
254  unsigned int active : 1;
255 
257  unsigned int desc_link : 1;
258 
260  unsigned int data_pid_start : 1;
261 
263  unsigned int ena_once : 1;
264 
266  unsigned int stalled_save : 1;
267 
280 
283 
288  int desc_size;
289  int num_desc;
294 
296  int desc_idx;
297 
300 
301  /* ==== The rest is OS-specific ==== */
302 
305 
307 #if defined(__linux__) || defined(SELA_PLATFORM)
308  struct list_head queue;
309 #else
310  DWC_CIRCLEQ_HEAD(circleq, dwc_usb3_pcd_req) queue;
311 #endif
312 } dwc_ep_t;
313 
315 typedef union dwc_setup_pkt {
316  usb_device_request_t req;
317  u32 d32[2];
318  char d8[8];
320 
324 typedef struct dwc_usb3_pcd_ep {
326  dwc_ep_t dwc_ep;
327 
328  /* ==== The rest is OS-specific ==== */
329 
331  struct usb_ept usb_ep;
333 
335 /* PCD EP accessor functions */
341 #define dwc_usb3_pcd_ep_to_pcd(pcd_ep) ((pcd_ep)->dwc_ep.pcd)
342 
348 #define dwc_usb3_pcd_ep_num(pcd_ep) ((pcd_ep)->dwc_ep.num)
349 
355 #define dwc_usb3_pcd_ep_type(pcd_ep) ((pcd_ep)->dwc_ep.type)
356 
362 #define dwc_usb3_pcd_ep_is_in(pcd_ep) ((pcd_ep)->dwc_ep.is_in)
363 
369  u64 dma_addr[15];
370 };
371 
375 typedef struct dwc_usb3_pcd {
377  struct dwc_usb3_device *usb3_dev;
378 
381 
384 
387 
389  unsigned int ep0_status_pending : 1;
390 
392  unsigned int request_config : 1;
393 
395  unsigned int remote_wakeup_enable : 1;
396 
398  unsigned int ltm_enable : 1;
399 
401  unsigned int send_lpm : 1;
402 
404  unsigned int wkup_rdy : 1;
405 
407  unsigned int eps_enabled : 1;
408 
410  unsigned int ute_change : 1;
411 
412 #ifdef DWC_STAR_9000463548_WORKAROUND
413  unsigned int configuring : 1;
414 #endif
415 
416 #ifdef CONFIG_USB_OTG_DWC
417 
418  unsigned int wants_host : 1;
419 
421  unsigned int b_hnp_enable : 1;
422 #endif
423 
425 
427  volatile dwc_usb3_pcd_ep_t *out_ep[DWC_MAX_EPS - 1U];
428 
430  volatile dwc_usb3_pcd_ep_t *in_ep[DWC_MAX_EPS - 1U];
431 
436 
439 
442 
445  void *hiber_scratchpad[15];
458 
459 #ifdef DWC_UTE
460 
461  unsigned rxf_size;
462 
464  unsigned txf_size[DWC_MAX_TX_FIFOS];
465 
467  unsigned txf_map[DWC_MAX_PHYS_EP];
468 
470  unsigned def_rxf_size;
471 
473  unsigned def_txf_size[DWC_MAX_TX_FIFOS];
474 #endif
475 
492 
494  unsigned request_pending;
495 
496  /* ==== The rest is OS-specific ==== */
497 #ifdef SELA_PLATFORM
498 
499  int max_in_eps, max_out_eps;
500 
502  int *dev_event, *ep_event;
503 #endif
504 #if defined(__linux__) || defined(LINUXTEST)
505 
506  spinlock_t lock;
507 #endif
508 #ifdef __linux__
509 
510  struct usb_gadget *gadget;
511 #endif
512 
515  struct tasklet_struct test_mode_tasklet;
516 
550 #define DWC_STATUS_BUF_SIZE 512U
551 
563 
565 /* PCD accessor functions */
571 #define dwc_usb3_ep0_setup_desc(pcd) (pcd)->ep0_setup_desc
572 
578 #define dwc_usb3_ep0_setup_desc_dma(pcd) (pcd)->ep0_setup_desc_dma
579 
585 #define dwc_usb3_ep0_out_desc(pcd) (pcd)->ep0_out_desc
586 
592 #define dwc_usb3_ep0_out_desc_dma(pcd) (pcd)->ep0_out_desc_dma
593 
599 #define dwc_usb3_ep0_in_desc(pcd) (pcd)->ep0_in_desc
600 
606 #define dwc_usb3_ep0_in_desc_dma(pcd) (pcd)->ep0_in_desc_dma
607 
613 #define dwc_usb3_ep0_setup_pkt(pcd) (pcd)->ep0_setup_pkt
614 
620 #define dwc_usb3_ep0_setup_pkt_dma(pcd) (pcd)->ep0_setup_pkt_dma
621 
623 extern void dwc_usb3_stop_all_xfers(volatile dwc_usb3_pcd_t *pcd);
624 extern void dwc_usb3_complete_request(volatile dwc_usb3_pcd_t *pcd,
625  volatile dwc_usb3_pcd_ep_t *ep, u32 event);
626 extern volatile dwc_usb3_pcd_ep_t *dwc_usb3_get_out_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num);
627 extern volatile dwc_usb3_pcd_ep_t *dwc_usb3_get_in_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num);
628 #ifdef DEBUG_EP0
629 extern void dwc_usb3_print_ep0_state(volatile dwc_usb3_pcd_t *pcd);
630 #endif
631 extern void dwc_usb3_handle_ep_intr(volatile dwc_usb3_pcd_t *pcd, u32 physep, u32 event);
632 extern int dwc_usb3_handle_dev_intr(volatile dwc_usb3_pcd_t *pcd, u32 event);
633 extern void dwc_usb3_handle_connect_done_intr(volatile dwc_usb3_pcd_t *pcd);
634 extern void dwc_enter_hibernation(volatile dwc_usb3_pcd_t *pcd, int save_state);
635 extern void dwc_exit_hibernation_after_connect(volatile dwc_usb3_pcd_t *pcd,
636  int connected);
637 extern int dwc_exit_hibernation(volatile dwc_usb3_pcd_t *pcd, int restore_state);
638 extern int dwc_usb3_handle_pme_intr(volatile struct dwc_usb3_device *dev);
639 extern void dwc_usb3_power_ctl(volatile struct dwc_usb3_device *dev, int on);
640 
643 extern int dwc_usb3_pcd_init(volatile struct dwc_usb3_device *dev);
644 extern void dwc_usb3_pcd_remove(volatile struct dwc_usb3_device *dev);
652  int num_trbs, uByte trb_type, int iso_intvl, int link,
653  dwc_dma_t *trbs_dma_ret);
654 extern void dwc_usb3_pcd_trb_free(volatile dwc_usb3_pcd_ep_t *ep /*, int num_trbs, int link,
655  void *trbs, dwc_dma_t trbs_dma*/);
656 extern void dwc_usb3_pcd_fill_trbs(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep,
657  dwc_usb3_pcd_req_t *req);
669 extern void dwc_usb3_ep_activate(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep,
670  int restore);
671 extern int dwc_usb3_pcd_ep_enable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep,
672  const usb_endpoint_descriptor_t *ep_desc,
673  const ss_endpoint_companion_descriptor_t *ep_comp);
674 extern int dwc_usb3_pcd_ep_disable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep);
675 extern int dwc_usb3_pcd_ep_submit_req(volatile dwc_usb3_pcd_t *pcd,
676  dwc_usb3_pcd_ep_t *ep,
677  dwc_usb3_pcd_req_t *req, u32 req_flags);
678 extern void dwc_usb3_pcd_ep_cancel_req(volatile dwc_usb3_pcd_t *pcd,
679  dwc_usb3_pcd_ep_t *ep,
680  dwc_usb3_pcd_req_t *req, u32 stream);
681 extern void dwc_usb3_pcd_request_done(volatile dwc_usb3_pcd_t *pcd,
682  volatile dwc_usb3_pcd_ep_t *ep,
683  volatile dwc_usb3_pcd_req_t *req, int status);
684 extern void dwc_usb3_pcd_ep_start_transfer(volatile dwc_usb3_pcd_t *pcd,
685  volatile dwc_usb3_pcd_ep_t *ep,
686  volatile dwc_usb3_pcd_req_t *req, u32 event);
687 extern void dwc_usb3_pcd_ep_set_stall(volatile dwc_usb3_pcd_t *pcd,
688  volatile dwc_usb3_pcd_ep_t *ep);
689 extern void dwc_usb3_pcd_ep_clear_stall(volatile dwc_usb3_pcd_t *pcd,
690  volatile dwc_usb3_pcd_ep_t *ep);
691 extern void dwc_usb3_pcd_ep_set_halt(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep,
692  int value);
699 extern void dwc_usb3_ep0_activate(volatile dwc_usb3_pcd_t *pcd, int restore);
700 extern void dwc_usb3_pcd_ep0_out_start(volatile dwc_usb3_pcd_t *pcd);
701 extern void dwc_usb3_pcd_ep0_start_transfer(volatile dwc_usb3_pcd_t *pcd,
702  volatile dwc_usb3_pcd_req_t *req);
703 extern void dwc_usb3_pcd_ep0_data_stage(volatile dwc_usb3_pcd_t *pcd, int length);
704 extern void dwc_usb3_handle_ep0_xfer(volatile dwc_usb3_pcd_t *pcd, u32 event);
705 
713 extern volatile dwc_usb3_pcd_ep_t *dwc_usb3_pcd_get_ep_by_addr(volatile dwc_usb3_pcd_t *pcd,
714  u16 idx);
715 extern int dwc_usb3_pcd_get_frame_number(volatile dwc_usb3_pcd_t *pcd);
716 extern int dwc_usb3_pcd_isoc_ep_hiber_restart(volatile dwc_usb3_pcd_t *pcd,
717  volatile dwc_usb3_pcd_ep_t *ep);
718 extern void dwc_usb3_pcd_stop(volatile dwc_usb3_pcd_t *pcd);
726 extern int dwc_usb3_gadget_connect(volatile dwc_usb3_pcd_t *pcd, int speed);
727 extern int dwc_usb3_gadget_disconnect(volatile dwc_usb3_pcd_t *pcd);
728 extern int dwc_usb3_gadget_suspend(volatile dwc_usb3_pcd_t *pcd);
729 extern int dwc_usb3_gadget_resume(volatile dwc_usb3_pcd_t *pcd);
730 extern int dwc_usb3_gadget_setup(volatile dwc_usb3_pcd_t *pcd,
731  usb_device_request_t *ctrl);
732 extern int dwc_usb3_gadget_complete(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep,
733  volatile dwc_usb3_pcd_req_t *pcd_req, int status);
741 extern void *dwc_usb3_gadget_alloc_dma(volatile dwc_usb3_pcd_ep_t *ep, int size,
742  dwc_dma_t *mem_dma_ret);
743 extern void dwc_usb3_gadget_free_dma(volatile dwc_usb3_pcd_ep_t *ep, int size, void *mem,
744  dwc_dma_t mem_dma);
746  volatile dwc_usb3_pcd_ep_t *ep);
747 extern void dwc_usb3_gadget_start_next_request(volatile dwc_usb3_pcd_t *pcd,
748  volatile dwc_usb3_pcd_ep_t *ep);
749 extern void dwc_usb3_gadget_isoc_ep_start(volatile dwc_usb3_pcd_t *pcd,
750  volatile dwc_usb3_pcd_ep_t *ep, u32 event);
751 extern void dwc_usb3_gadget_request_nuke(volatile dwc_usb3_pcd_t *pcd,
752  volatile dwc_usb3_pcd_ep_t *ep);
753 extern void dwc_usb3_gadget_set_ep_not_started(volatile dwc_usb3_pcd_t *pcd,
754  volatile dwc_usb3_pcd_ep_t *ep);
762 extern void dwc_usb3_task_schedule(volatile struct tasklet_struct *tasklet);
763 
764 #ifdef CONFIG_USB_OTG_DWC
765 extern void dwc_usb3_start_hnp(volatile dwc_usb3_pcd_t *pcd);
766 extern void dwc_usb3_host_release(volatile dwc_usb3_pcd_t *pcd);
767 #endif
768 
769 #ifdef __cplusplus
770 }
771 #endif
772 
773 #endif /* _DWC_PCD_H_ */
dwc_usb3_pcd_ep_submit_req
int dwc_usb3_pcd_ep_submit_req(volatile dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 req_flags)
This routine submits an I/O Request to an EP.
Definition: pcd.c:1719
dwc_usb3_pcd_req_t
DWC_usb3 request structure.
Definition: pcd.h:157
dwc_ep_t::desc_size
int desc_size
Definition: pcd.h:288
dwc_usb3_stop_all_xfers
void dwc_usb3_stop_all_xfers(volatile dwc_usb3_pcd_t *pcd)
Stop any active xfers on the non-EP0 endpoints.
Definition: pcd.c:1087
dwc_req_t::length
u32 length
Definition: pcd.h:134
dwc_usb3_pcd_t::usb3_dev
struct dwc_usb3_device * usb3_dev
Definition: pcd.h:377
dwc_usb3_pcd_t::ep0_setup_desc
dwc_usb3_dma_desc_t * ep0_setup_desc
Definition: pcd.h:524
dwc_ep_t::condition
u32 condition
Definition: pcd.h:304
dwc_usb3_pcd_t::rx_thr_en
u16 rx_thr_en
Definition: pcd.h:478
dwc_usb3_pcd_t::ep0_in_desc
dwc_usb3_dma_desc_t * ep0_in_desc
Definition: pcd.h:538
dwc_ep_t::three_stage
unsigned int three_stage
Definition: pcd.h:244
u32
unsigned int u32
Definition: os_defs.h:41
dwc_usb3_ep_activate
void dwc_usb3_ep_activate(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, int restore)
This routine activates an EP. The Device EP control registers for the EP are configured as defined in...
Definition: pcd.c:396
dwc_ep_t::xfer_started
unsigned int xfer_started
Definition: pcd.h:247
dwc_ep_t::pcd
struct dwc_usb3_pcd * pcd
Definition: pcd.h:188
dwc_usb3_pcd_t::remote_wakeup_enable
unsigned int remote_wakeup_enable
Definition: pcd.h:395
dwc_usb3_pcd_t::test_mode
u8 test_mode
Definition: pcd.h:491
dwc_usb3_pcd_t::in_ep_regs
dwc_usb3_dev_ep_regs_t __iomem * in_ep_regs
Definition: pcd.h:441
dwc_ep_t::param0in
u32 param0in
Definition: pcd.h:274
u16
unsigned short u16
Definition: os_defs.h:43
dwc_usb3_pcd_t::iso_tx_thr_en
u16 iso_tx_thr_en
Definition: pcd.h:479
dwc_usb3_pcd_t::ep0_out_desc_dma
dwc_dma_t ep0_out_desc_dma
Definition: pcd.h:533
dwc_usb3_pcd_t::ep0_status_buf_dma
dwc_dma_t ep0_status_buf_dma
Definition: pcd.h:549
dwc_usb3_handle_dev_intr
int dwc_usb3_handle_dev_intr(volatile dwc_usb3_pcd_t *pcd, u32 event)
PCD interrupt handler.
Definition: pcd_intr.c:652
dwc_usb3_pcd_request_done
void dwc_usb3_pcd_request_done(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *req, int status)
This routine completes a request. It calls the request callback.
Definition: pcd.c:1898
DWC_STATE_ADDRESSED
@ DWC_STATE_ADDRESSED
Definition: pcd.h:117
dwc_usb3_pcd_ep_cancel_req
void dwc_usb3_pcd_ep_cancel_req(volatile dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 stream)
This routine cancels an I/O request from an EP.
Definition: pcd.c:1821
dwc_usb3_pcd_t::ep0_req
volatile dwc_usb3_pcd_req_t * ep0_req
Definition: pcd.h:457
dwc_ep_t::num
u8 num
Definition: pcd.h:200
dwc_usb3_pcd_t::ep0_out_desc
dwc_usb3_dma_desc_t * ep0_out_desc
Definition: pcd.h:531
dwc_usb3_gadget_suspend
int dwc_usb3_gadget_suspend(volatile dwc_usb3_pcd_t *pcd)
This routine receives Suspend notifications from the PCD.
Definition: no_os_gadget.c:128
EP0_OUT_WAIT_NRDY
@ EP0_OUT_WAIT_NRDY
Definition: pcd.h:105
dwc_usb3_pcd_t::ep0_setup_pkt_dma
dwc_dma_t ep0_setup_pkt_dma
Definition: pcd.h:557
dwc_usb3_pcd_remove
void dwc_usb3_pcd_remove(volatile struct dwc_usb3_device *dev)
dwc_usb3_gadget_alloc_dma
void * dwc_usb3_gadget_alloc_dma(volatile dwc_usb3_pcd_ep_t *ep, int size, dwc_dma_t *mem_dma_ret)
This routine allocates coherent DMA memory. It is used by the PCD to allocate memory for TRBs....
Definition: no_os_gadget.c:259
__iomem
#define __iomem
Definition: os_defs.h:74
dwc_usb3_gadget_disconnect
int dwc_usb3_gadget_disconnect(volatile dwc_usb3_pcd_t *pcd)
This routine receives Disconnect notifications from the PCD.
Definition: no_os_gadget.c:107
dwc_usb3_pcd_t::ep0_status_buf
u8 * ep0_status_buf
Definition: pcd.h:547
dwc_ep_t::dma_desc
dwc_usb3_dma_desc_t * dma_desc
Definition: pcd.h:286
EP0_OUT_DATA_PHASE
@ EP0_OUT_DATA_PHASE
Definition: pcd.h:101
dwc_usb3_pcd_ep_set_stall
void dwc_usb3_pcd_ep_set_stall(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
Set the EP to STALL.
Definition: pcd.c:1420
dwc_ep_t::tri_in
u8 tri_in
Definition: pcd.h:226
dwc_usb3_gadget_free_dma
void dwc_usb3_gadget_free_dma(volatile dwc_usb3_pcd_ep_t *ep, int size, void *mem, dwc_dma_t mem_dma)
This routine frees DMA memory allocated by dwc_usb3_gadget_alloc_dma().
Definition: no_os_gadget.c:298
dwc_usb3_handle_pme_intr
int dwc_usb3_handle_pme_intr(volatile struct dwc_usb3_device *dev)
dwc_usb3_pcd_t::hiber_scratchpad_array
struct dwc_hiber_scratchpad_array * hiber_scratchpad_array
Definition: pcd.h:446
dwc_usb3_gadget_isoc_ep_start
void dwc_usb3_gadget_isoc_ep_start(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, u32 event)
This routine starts an Isoc EP running at the proper interval, after receiving the initial XferNrdy e...
Definition: no_os_gadget.c:376
dwc_req_t::flags
u32 flags
Definition: pcd.h:138
dwc_usb3_pcd_t::wkup_rdy
unsigned int wkup_rdy
Definition: pcd.h:404
ss_endpoint_companion_descriptor_t
Definition: usb.h:344
dwc_dma_t
unsigned long dwc_dma_t
Definition: os_defs.h:62
EP0_OUT_WAIT_GADGET
@ EP0_OUT_WAIT_GADGET
Definition: pcd.h:103
dwc_usb3_pcd_t
DWC_usb3 PCD Structure. This structure encapsulates the data for the dwc_usb3 PCD.
Definition: pcd.h:375
ep0state_e
ep0state_e
Enumeration representing the various states of Endpoint 0 (EP0).
Definition: pcd.h:98
DWC_STATE_UNCONNECTED
@ DWC_STATE_UNCONNECTED
Definition: pcd.h:115
dwc_usb3_pcd_fill_trbs
void dwc_usb3_pcd_fill_trbs(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req)
This routine assigns and fills in the TRBs for a request.
Definition: pcd.c:208
dwc_ep_t::phys
u8 phys
Definition: pcd.h:197
dwc_usb3_pcd_t::event_q
dwc_queue_t event_q
Definition: pcd.h:561
dwc_ep_t::mult
u8 mult
Definition: pcd.h:212
dwc_usb3_gadget_set_ep_not_started
void dwc_usb3_gadget_set_ep_not_started(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine marks all pending requests for an EP as not started.
Definition: no_os_gadget.c:470
dwc_setup_pkt_t::req
usb_device_request_t req
Definition: pcd.h:316
dwc_usb3_power_ctl
void dwc_usb3_power_ctl(volatile struct dwc_usb3_device *dev, int on)
dwc_usb3_pcd_ep_start_transfer
void dwc_usb3_pcd_ep_start_transfer(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *req, u32 event)
This routine does the setup for a data transfer for an EP and starts the transfer.
Definition: pcd.c:809
dwc_ep_t::usb_ep_desc
const usb_endpoint_descriptor_t * usb_ep_desc
Definition: pcd.h:282
dwc_ep_t::type
u8 type
Definition: pcd.h:203
dwc_ep_t::hiber_desc_idx
int hiber_desc_idx
Definition: pcd.h:299
dwc_usb3_pcd_get_frame_number
int dwc_usb3_pcd_get_frame_number(volatile dwc_usb3_pcd_t *pcd)
Gets the current USB frame number.
Definition: pcd.c:1975
dwc_usb3_pcd_t::dev_global_regs
dwc_usb3_dev_global_regs_t __iomem * dev_global_regs
Definition: pcd.h:435
dwc_usb3_pcd_t::ep0_setup_pkt
dwc_setup_pkt_t * ep0_setup_pkt
Definition: pcd.h:555
EP0_IN_DATA_PHASE
@ EP0_IN_DATA_PHASE
Definition: pcd.h:100
dwc_usb3_pcd_t::speed
u8 speed
Definition: pcd.h:486
dwc_ep_t::intvl
u8 intvl
Definition: pcd.h:206
dwc_usb3_handle_connect_done_intr
void dwc_usb3_handle_connect_done_intr(volatile dwc_usb3_pcd_t *pcd)
This interrupt occurs when a Connect Done is detected. Read the device status register and set the de...
Definition: pcd_intr.c:215
dwc_req_t::actual
u32 actual
Definition: pcd.h:135
dwc_ep_t::maxburst
u8 maxburst
Definition: pcd.h:215
dwc_ep_t::DWC_CIRCLEQ_HEAD
DWC_CIRCLEQ_HEAD(circleq, dwc_usb3_pcd_req) queue
dwc_exit_hibernation_after_connect
void dwc_exit_hibernation_after_connect(volatile dwc_usb3_pcd_t *pcd, int connected)
This routine finishes exiting from hibernation once the device is connected.
Definition: pcd_hiber.c:399
dwc_usb3_pcd_t::request_config
unsigned int request_config
Definition: pcd.h:392
dwc_usb3_handle_ep0_xfer
void dwc_usb3_handle_ep0_xfer(volatile dwc_usb3_pcd_t *pcd, u32 event)
This routine handles EP0 transfers.
Definition: ep0.c:1421
dwc_usb3_pcd_ep_disable
int dwc_usb3_pcd_ep_disable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine is called when an EP (except EP0) is disabled due to disconnect or change in configurati...
Definition: pcd.c:1684
EP0_IN_WAIT_NRDY
@ EP0_IN_WAIT_NRDY
Definition: pcd.h:104
u64
unsigned long long u64
Definition: os_defs.h:39
dwc_usb3_pcd_ep0_out_start
void dwc_usb3_pcd_ep0_out_start(volatile dwc_usb3_pcd_t *pcd)
This routine sets up a SETUP stage transfer for EP0 and starts the transfer.
Definition: pcd.c:645
dwc_ep_t::desc_idx
int desc_idx
Definition: pcd.h:296
dwc_usb3_gadget_request_nuke
void dwc_usb3_gadget_request_nuke(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine terminates all requests which are pending on an endpoint.
Definition: no_os_gadget.c:447
dwc_usb3_pcd_t::hiber_scratchpad_array_dma
dwc_dma_t hiber_scratchpad_array_dma
Definition: pcd.h:447
dwc_ep_t::num_desc
int num_desc
Definition: pcd.h:289
EP0_IN_WAIT_GADGET
@ EP0_IN_WAIT_GADGET
Definition: pcd.h:102
DWC_MAX_EPS
#define DWC_MAX_EPS
Maximum number of EPs, defined by USB spec.
Definition: pcd.h:83
dwc_usb3_pcd_ep_enable
int dwc_usb3_pcd_ep_enable(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, const usb_endpoint_descriptor_t *ep_desc, const ss_endpoint_companion_descriptor_t *ep_comp)
This routine is called by the Function Driver for each EP (except EP0) to be configured for the curre...
Definition: pcd.c:1558
tasklet_struct
Definition: os_defs.h:120
DWC_MAX_PHYS_EP
#define DWC_MAX_PHYS_EP
Maximum number of physical EPs. Depends on the RTL configuration. No way to probe the value at runtim...
Definition: pcd.h:72
EP0_STALL
@ EP0_STALL
Definition: pcd.h:108
dwc_usb3_complete_request
void dwc_usb3_complete_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, u32 event)
This routine handles non-EP0 transfers.
Definition: pcd.c:1369
dwc_ep_t::stall_clear_flag
unsigned int stall_clear_flag
Definition: pcd.h:241
dwc_usb3_pcd_t::ep0_in_desc_dma
dwc_dma_t ep0_in_desc_dma
Definition: pcd.h:540
dwc_hiber_scratchpad_array
Structure representing an array of hibernation scratchpad DMA addresses.
Definition: pcd.h:368
dwc_ep_t::ena_once
unsigned int ena_once
Definition: pcd.h:263
dwc_usb3_get_in_ep
volatile dwc_usb3_pcd_ep_t * dwc_usb3_get_in_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num)
This routine returns a pointer to In EP struct with number ep_num.
Definition: pcd.c:1494
dwc_usb3_pcd_t::ep0_in_save_state
u32 ep0_in_save_state
Definition: pcd.h:453
dwc_usb3_gadget_setup
int dwc_usb3_gadget_setup(volatile dwc_usb3_pcd_t *pcd, usb_device_request_t *ctrl)
This routine receives Setup request notifications from the PCD.
Definition: no_os_gadget.c:169
dwc_ep_t::desc_link
unsigned int desc_link
Definition: pcd.h:257
dwc_ep_t::queue_sof
unsigned int queue_sof
Definition: pcd.h:233
dwc_ep_t::param1out
u32 param1out
Definition: pcd.h:273
dwc_usb3_pcd_t::state
pcdstate_e state
Definition: pcd.h:383
dwc_usb3_dev_ep_regs_t
Definition: hw.h:1727
dwc_usb3_pcd_t::non_iso_tx_thr_en
u16 non_iso_tx_thr_en
Definition: pcd.h:480
dwc_ep_t::dma_desc_dma
dwc_dma_t dma_desc_dma
Definition: pcd.h:287
dwc_usb3_dma_desc_t
DMA Descriptor structure.
Definition: hw.h:1840
dwc_usb3_pcd_t::ltm_enable
unsigned int ltm_enable
Definition: pcd.h:398
dwc_usb3_handle_ep_intr
void dwc_usb3_handle_ep_intr(volatile dwc_usb3_pcd_t *pcd, u32 physep, u32 event)
This interrupt indicates that an EP has a pending interrupt.
Definition: pcd_intr.c:477
dwc_usb3_gadget_resume
int dwc_usb3_gadget_resume(volatile dwc_usb3_pcd_t *pcd)
This routine receives Resume notifications from the PCD.
Definition: no_os_gadget.c:148
DWC_MAX_TX_FIFOS
#define DWC_MAX_TX_FIFOS
Maximum number of Tx FIFOs. Depends on the RTL configuration. No way to probe the value at runtime.
Definition: pcd.h:66
dwc_ep_t::tx_fifo_num
u8 tx_fifo_num
Definition: pcd.h:221
dwc_ep_t::maxpacket
u16 maxpacket
Definition: pcd.h:209
dwc_usb3_pcd_stop
void dwc_usb3_pcd_stop(volatile dwc_usb3_pcd_t *pcd)
This routine is called when the Device is disconnected. It stops any active requests and informs the ...
Definition: pcd.c:1930
dwc_usb3_pcd_req_t::dwc_req
dwc_req_t dwc_req
DWC_usb3 request data.
Definition: pcd.h:159
dwc_usb3_pcd_trb_alloc
dwc_usb3_dma_desc_t * dwc_usb3_pcd_trb_alloc(volatile dwc_usb3_pcd_ep_t *ep, int num_trbs, uByte trb_type, int iso_intvl, int link, dwc_dma_t *trbs_dma_ret)
This routine allocates the TRBs for an EP.
Definition: pcd.c:91
dwc_usb3_dev_global_regs_t
Definition: hw.h:1538
dwc_usb3_pcd_ep0_start_transfer
void dwc_usb3_pcd_ep0_start_transfer(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_req_t *req)
This routine sets up a data/status stage transfer for EP0 and starts the transfer....
Definition: pcd.c:689
dwc_ep_t::stopped
unsigned int stopped
Definition: pcd.h:231
dwc_usb3_pcd_t::ep0state
ep0state_e ep0state
Definition: pcd.h:386
dwc_usb3_task_schedule
void dwc_usb3_task_schedule(volatile struct tasklet_struct *tasklet)
OS-specific routines called from core code.
dwc_usb3_pcd_t::ep0_status_pending
unsigned int ep0_status_pending
Definition: pcd.h:389
dwc_usb3_pcd_t::num_in_eps
u8 num_in_eps
Definition: pcd.h:488
dwc_usb3_gadget_connect
int dwc_usb3_gadget_connect(volatile dwc_usb3_pcd_t *pcd, int speed)
This routine receives Connect notifications from the PCD.
Definition: no_os_gadget.c:65
dwc_usb3_pcd_isoc_ep_hiber_restart
int dwc_usb3_pcd_isoc_ep_hiber_restart(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
After hibernation, this function restarts the transfer using the TRB address that was active before h...
Definition: pcd.c:1005
dwc_ep_t::active
unsigned int active
Definition: pcd.h:254
dwc_usb3_gadget_complete
int dwc_usb3_gadget_complete(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, volatile dwc_usb3_pcd_req_t *pcd_req, int status)
This routine receives Transfer Complete notifications from the PCD.
Definition: no_os_gadget.c:204
usb_endpoint_descriptor_t
This structure describes a USB endpoint.
Definition: usb.h:317
dwc_ep_t::out_ep_reg
dwc_usb3_dev_ep_regs_t __iomem * out_ep_reg
Definition: pcd.h:191
dwc_usb3_pcd_ep0_data_stage
void dwc_usb3_pcd_ep0_data_stage(volatile dwc_usb3_pcd_t *pcd, int length)
This routine starts the data stage of a 3-stage control command. pcd->ep0state must be set to EP0_OUT...
Definition: ep0.c:114
dwc_ep_t::in_ep_reg
dwc_usb3_dev_ep_regs_t __iomem * in_ep_reg
Definition: pcd.h:194
dwc_ep_t::disabling
unsigned int disabling
Definition: pcd.h:232
dwc_req_t::stream
u32 stream
Definition: pcd.h:136
dwc_usb3_pcd_t::ep0_setup_desc_dma
dwc_dma_t ep0_setup_desc_dma
Definition: pcd.h:526
dwc_ep_t::param0out
u32 param0out
Definition: pcd.h:272
dwc_ep_t::is_in
unsigned int is_in
Definition: pcd.h:251
uByte
u8 uByte
Definition: usb.h:58
EP0_IN_STATUS_PHASE
@ EP0_IN_STATUS_PHASE
Definition: pcd.h:106
dwc_req_t::trbdma
dwc_dma_t trbdma
Definition: pcd.h:133
dwc_usb3_pcd_t::tx_thr_length
u16 tx_thr_length
Definition: pcd.h:482
dwc_usb3_get_out_ep
volatile dwc_usb3_pcd_ep_t * dwc_usb3_get_out_ep(volatile dwc_usb3_pcd_t *pcd, u32 ep_num)
This routine returns a pointer to Out EP struct with number ep_num.
Definition: pcd.c:1474
dwc_req_t
Structure representing a USB transfer request.
Definition: pcd.h:131
dwc_ep_t::desc_avail
int desc_avail
Definition: pcd.h:293
DWC_STATE_CONFIGURED
@ DWC_STATE_CONFIGURED
Definition: pcd.h:118
dwc_ep_t::data_pid_start
unsigned int data_pid_start
Definition: pcd.h:260
dwc_usb3_gadget_get_request
dwc_usb3_pcd_req_t * dwc_usb3_gadget_get_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine returns the PCD request corresponding to the current transfer request for an endpoint....
Definition: no_os_gadget.c:316
dwc_usb3_pcd_ep_clear_stall
void dwc_usb3_pcd_ep_clear_stall(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
Clear the EP STALL.
Definition: pcd.c:1446
dwc_req_t::trb
dwc_usb3_dma_desc_t * trb
Definition: pcd.h:132
dwc_usb3_gadget_start_next_request
void dwc_usb3_gadget_start_next_request(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep)
This routine checks to see if there is another transfer request waiting on an endpoint that has not b...
Definition: no_os_gadget.c:340
dwc_enter_hibernation
void dwc_enter_hibernation(volatile dwc_usb3_pcd_t *pcd, int save_state)
This routine sends the core into hibernation, saving the core's runtime state if requested.
Definition: pcd_hiber.c:58
dwc_usb3_pcd_get_ep_by_addr
volatile dwc_usb3_pcd_ep_t * dwc_usb3_pcd_get_ep_by_addr(volatile dwc_usb3_pcd_t *pcd, u16 idx)
This routine gets a pointer to an EP from the wIndex address value of the control request.
Definition: pcd.c:1515
dwc_setup_pkt_t
Buffer used to store the SETUP packet for EP0.
Definition: pcd.h:315
dwc_ep_t::tri_out
u8 tri_out
Definition: pcd.h:225
dwc_usb3_pcd_t::rx_thr_length
u16 rx_thr_length
Definition: pcd.h:481
u8
unsigned char u8
Definition: os_defs.h:45
dwc_queue_t
A structure representing a queue for managing data.
Definition: dwc_queue.h:57
dwc_usb3_pcd_t::ute_change
unsigned int ute_change
Definition: pcd.h:410
dwc_ep_t::stalled_save
unsigned int stalled_save
Definition: pcd.h:266
DWC_STATE_DEFAULT
@ DWC_STATE_DEFAULT
Definition: pcd.h:116
pcdstate_e
pcdstate_e
Enumeration representing the various states of the PCD.
Definition: pcd.h:114
dwc_usb3_pcd_t::out_ep_regs
dwc_usb3_dev_ep_regs_t __iomem * out_ep_regs
Definition: pcd.h:438
dwc_usb3_pcd_trb_free
void dwc_usb3_pcd_trb_free(volatile dwc_usb3_pcd_ep_t *ep)
This routine frees the TRBs allocated by dwc_usb3_pcd_trb_alloc().
Definition: pcd.c:184
dwc_usb3_pcd_ep_set_halt
void dwc_usb3_pcd_ep_set_halt(volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *ep, int value)
This function sets or clears a stall condition on an endpoint.
Definition: pcd.c:1849
dwc_ep_t::num_streams
u8 num_streams
Definition: pcd.h:218
dwc_ep_t::send_zlp
unsigned int send_zlp
Definition: pcd.h:238
dwc_queue.h
DWC queue implementation.
dwc_usb3_pcd_ep_t
PCD Endpoint structure. This structure represents an endpoint (EP) in the Peripheral Controller Drive...
Definition: pcd.h:324
dwc_usb3_pcd_t::send_lpm
unsigned int send_lpm
Definition: pcd.h:401
dwc_ep_t::param1in
u32 param1in
Definition: pcd.h:275
EP0_OUT_STATUS_PHASE
@ EP0_OUT_STATUS_PHASE
Definition: pcd.h:107
dwc_usb3_ep0_activate
void dwc_usb3_ep0_activate(volatile dwc_usb3_pcd_t *pcd, int restore)
This routine configures EP0 OUT to receive SETUP packets and configures EP0 IN for transmitting packe...
Definition: pcd.c:312
dwc_usb3_pcd_init
int dwc_usb3_pcd_init(volatile struct dwc_usb3_device *dev)
dwc_usb3_pcd_t::ep0_out_save_state
u32 ep0_out_save_state
Definition: pcd.h:452
dwc_usb3_pcd_t::num_out_eps
u8 num_out_eps
Definition: pcd.h:487
dwc_ep_t::save_state
u32 save_state
Definition: pcd.h:279
dwc_usb3_pcd_t::eps_enabled
unsigned int eps_enabled
Definition: pcd.h:407
EP0_IDLE
@ EP0_IDLE
Definition: pcd.h:99
dwc_usb3_pcd_t::link_state
int link_state
Definition: pcd.h:380
dwc_exit_hibernation
int dwc_exit_hibernation(volatile dwc_usb3_pcd_t *pcd, int restore_state)
This routine wakes the core from hibernation.
Definition: pcd_hiber.c:525
dwc_usb3_pcd_t::ep0
volatile dwc_usb3_pcd_ep_t * ep0
Definition: pcd.h:424
dwc_ep_t
The dwc_ep structure represents the state of a single EP when acting in device mode....
Definition: pcd.h:186