common: spl_fit: Default to IH_OS_U_BOOT if FIT_IMAGE_TINY enabled
[oweals/u-boot.git] / drivers / usb / gadget / dwc2_udc_otg_priv.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Designware DWC2 on-chip full/high speed USB device controllers
4  * Copyright (C) 2005 for Samsung Electronics
5  */
6
7 #ifndef __DWC2_UDC_OTG_PRIV__
8 #define __DWC2_UDC_OTG_PRIV__
9
10 #include <linux/errno.h>
11 #include <linux/sizes.h>
12 #include <linux/usb/ch9.h>
13 #include <linux/usb/gadget.h>
14 #include <linux/list.h>
15 #include <usb/dwc2_udc.h>
16
17 /*-------------------------------------------------------------------------*/
18 /* DMA bounce buffer size, 16K is enough even for mass storage */
19 #define DMA_BUFFER_SIZE (16*SZ_1K)
20
21 #define EP0_FIFO_SIZE           64
22 #define EP_FIFO_SIZE            512
23 #define EP_FIFO_SIZE2           1024
24 /* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */
25 #define DWC2_MAX_ENDPOINTS      4
26 #define DWC2_MAX_HW_ENDPOINTS   16
27
28 #define WAIT_FOR_SETUP          0
29 #define DATA_STATE_XMIT         1
30 #define DATA_STATE_NEED_ZLP     2
31 #define WAIT_FOR_OUT_STATUS     3
32 #define DATA_STATE_RECV         4
33 #define WAIT_FOR_COMPLETE       5
34 #define WAIT_FOR_OUT_COMPLETE   6
35 #define WAIT_FOR_IN_COMPLETE    7
36 #define WAIT_FOR_NULL_COMPLETE  8
37
38 #define TEST_J_SEL              0x1
39 #define TEST_K_SEL              0x2
40 #define TEST_SE0_NAK_SEL        0x3
41 #define TEST_PACKET_SEL         0x4
42 #define TEST_FORCE_ENABLE_SEL   0x5
43
44 /* ************************************************************************* */
45 /* IO
46  */
47
48 enum ep_type {
49         ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
50 };
51
52 struct dwc2_ep {
53         struct usb_ep ep;
54         struct dwc2_udc *dev;
55
56         const struct usb_endpoint_descriptor *desc;
57         struct list_head queue;
58         unsigned long pio_irqs;
59         int len;
60         void *dma_buf;
61
62         u8 stopped;
63         u8 bEndpointAddress;
64         u8 bmAttributes;
65
66         enum ep_type ep_type;
67         int fifo_num;
68 };
69
70 struct dwc2_request {
71         struct usb_request req;
72         struct list_head queue;
73 };
74
75 struct dwc2_udc {
76         struct usb_gadget gadget;
77         struct usb_gadget_driver *driver;
78
79         struct dwc2_plat_otg_data *pdata;
80
81         int ep0state;
82         struct dwc2_ep ep[DWC2_MAX_ENDPOINTS];
83
84         unsigned char usb_address;
85
86         unsigned req_pending:1, req_std:1;
87 };
88
89 #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN)
90 #define ep_index(EP) ((EP)->bEndpointAddress&0xF)
91 #define ep_maxpacket(EP) ((EP)->ep.maxpacket)
92
93 void otg_phy_init(struct dwc2_udc *dev);
94 void otg_phy_off(struct dwc2_udc *dev);
95
96 #endif  /* __DWC2_UDC_OTG_PRIV__ */