]>
Commit | Line | Data |
---|---|---|
38517a78 ŁM |
1 | /* |
2 | * drivers/usb/gadget/s3c_udc.h | |
3 | * Samsung S3C on-chip full/high speed USB device controllers | |
4 | * Copyright (C) 2005 for Samsung Electronics | |
5 | * | |
1a459660 | 6 | * SPDX-License-Identifier: GPL-2.0+ |
38517a78 ŁM |
7 | */ |
8 | ||
9 | #ifndef __S3C_USB_GADGET | |
10 | #define __S3C_USB_GADGET | |
11 | ||
12 | #include <asm/errno.h> | |
1ace4022 | 13 | #include <linux/sizes.h> |
38517a78 ŁM |
14 | #include <linux/usb/ch9.h> |
15 | #include <linux/usb/gadget.h> | |
16 | #include <linux/list.h> | |
17 | #include <usb/lin_gadget_compat.h> | |
18 | ||
19 | #define PHY0_SLEEP (1 << 5) | |
20 | ||
21 | /*-------------------------------------------------------------------------*/ | |
22 | /* DMA bounce buffer size, 16K is enough even for mass storage */ | |
e0059eae | 23 | #define DMA_BUFFER_SIZE (16*SZ_1K) |
38517a78 ŁM |
24 | |
25 | #define EP0_FIFO_SIZE 64 | |
26 | #define EP_FIFO_SIZE 512 | |
27 | #define EP_FIFO_SIZE2 1024 | |
28 | /* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */ | |
29 | #define S3C_MAX_ENDPOINTS 4 | |
30 | #define S3C_MAX_HW_ENDPOINTS 16 | |
31 | ||
32 | #define WAIT_FOR_SETUP 0 | |
33 | #define DATA_STATE_XMIT 1 | |
34 | #define DATA_STATE_NEED_ZLP 2 | |
35 | #define WAIT_FOR_OUT_STATUS 3 | |
36 | #define DATA_STATE_RECV 4 | |
37 | #define WAIT_FOR_COMPLETE 5 | |
38 | #define WAIT_FOR_OUT_COMPLETE 6 | |
39 | #define WAIT_FOR_IN_COMPLETE 7 | |
40 | #define WAIT_FOR_NULL_COMPLETE 8 | |
41 | ||
42 | #define TEST_J_SEL 0x1 | |
43 | #define TEST_K_SEL 0x2 | |
44 | #define TEST_SE0_NAK_SEL 0x3 | |
45 | #define TEST_PACKET_SEL 0x4 | |
46 | #define TEST_FORCE_ENABLE_SEL 0x5 | |
47 | ||
48 | /* ************************************************************************* */ | |
49 | /* IO | |
50 | */ | |
51 | ||
52 | enum ep_type { | |
53 | ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt | |
54 | }; | |
55 | ||
56 | struct s3c_ep { | |
57 | struct usb_ep ep; | |
58 | struct s3c_udc *dev; | |
59 | ||
60 | const struct usb_endpoint_descriptor *desc; | |
61 | struct list_head queue; | |
62 | unsigned long pio_irqs; | |
63 | int len; | |
64 | void *dma_buf; | |
65 | ||
66 | u8 stopped; | |
67 | u8 bEndpointAddress; | |
68 | u8 bmAttributes; | |
69 | ||
70 | enum ep_type ep_type; | |
71 | int fifo_num; | |
72 | }; | |
73 | ||
74 | struct s3c_request { | |
75 | struct usb_request req; | |
76 | struct list_head queue; | |
77 | }; | |
78 | ||
79 | struct s3c_udc { | |
80 | struct usb_gadget gadget; | |
81 | struct usb_gadget_driver *driver; | |
82 | ||
83 | struct s3c_plat_otg_data *pdata; | |
84 | ||
38517a78 ŁM |
85 | int ep0state; |
86 | struct s3c_ep ep[S3C_MAX_ENDPOINTS]; | |
87 | ||
88 | unsigned char usb_address; | |
89 | ||
7cf7beff | 90 | unsigned req_pending:1, req_std:1; |
38517a78 ŁM |
91 | }; |
92 | ||
93 | extern struct s3c_udc *the_controller; | |
94 | ||
95 | #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN) | |
96 | #define ep_index(EP) ((EP)->bEndpointAddress&0xF) | |
97 | #define ep_maxpacket(EP) ((EP)->ep.maxpacket) | |
98 | ||
38517a78 ŁM |
99 | extern void otg_phy_init(struct s3c_udc *dev); |
100 | extern void otg_phy_off(struct s3c_udc *dev); | |
101 | ||
102 | extern void s3c_udc_ep_set_stall(struct s3c_ep *ep); | |
103 | extern int s3c_udc_probe(struct s3c_plat_otg_data *pdata); | |
104 | ||
105 | struct s3c_plat_otg_data { | |
106 | int (*phy_control)(int on); | |
107 | unsigned int regs_phy; | |
108 | unsigned int regs_otg; | |
109 | unsigned int usb_phy_ctrl; | |
110 | unsigned int usb_flags; | |
481a11c5 | 111 | unsigned int usb_gusbcfg; |
38517a78 ŁM |
112 | }; |
113 | #endif |