1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (C) ASPEED Technology Inc. 4 * 5 */ 6 7 #define gadget_to_aspeed_udc(g) (container_of(g, struct aspeed_udc_priv, gadget)) 8 #define req_to_aspeed_udc_req(r) (container_of(r, struct aspeed_udc_request, req)) 9 #define ep_to_aspeed_udc_ep(e) (container_of(e, struct aspeed_udc_ep, ep)) 10 11 #define AST_NUM_ENDPOINTS (21 + 1) 12 13 struct aspeed_ep_desc { 14 u32 des_0; 15 u32 des_1; 16 }; 17 18 struct aspeed_udc_ep { 19 u32 ep_base; 20 char name[5]; 21 struct usb_ep ep; 22 unsigned stopped:1; 23 u8 ep_dir; 24 void *ep_buf; 25 dma_addr_t ep_dma; 26 27 /* Request queue */ 28 struct list_head queue; 29 struct aspeed_udc_priv *udc; 30 struct aspeed_ep_desc *dma_desc_list; 31 dma_addr_t dma_desc_dma_handle; 32 u32 dma_desc_list_wptr; 33 u32 data_toggle; 34 u32 chunk_max; 35 }; 36 37 struct aspeed_udc_priv { 38 u32 udc_base; 39 u32 maximum_speed; 40 struct udevice *dev; 41 struct usb_gadget gadget; 42 struct usb_gadget_driver *gadget_driver; 43 struct aspeed_udc_ep ep[AST_NUM_ENDPOINTS]; 44 int init; 45 struct usb_ctrlrequest *root_setup; 46 47 /* EP0 DMA buffers allocated in one chunk */ 48 void *ep0_ctrl_buf; 49 u32 ep0_ctrl_dma; 50 unsigned is_udc_control_tx:1; 51 int desc_mode; 52 spinlock_t lock; /* lock for udc device */ 53 }; 54 55 struct aspeed_udc_request { 56 struct usb_request req; 57 struct list_head queue; 58 u32 actual_dma_length; 59 u32 saved_dma_wptr; 60 }; 61