1 /*
2  * linux/drivers/usb/gadget/s3c2410_udc.h
3  * Samsung on-chip full speed USB device controllers
4  *
5  * Copyright (C) 2004-2007 Herbert Pötzl - Arnaud Patard
6  *	Additional cleanups by Ben Dooks <ben-linux@fluff.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  */
13 
14 #ifndef _S3C2410_UDC_H
15 #define _S3C2410_UDC_H
16 
17 struct s3c2410_ep {
18 	struct list_head		queue;
19 	unsigned long			last_io;	/* jiffies timestamp */
20 	struct usb_gadget		*gadget;
21 	struct s3c2410_udc		*dev;
22 	const struct usb_endpoint_descriptor *desc;
23 	struct usb_ep			ep;
24 	u8				num;
25 
26 	unsigned short			fifo_size;
27 	u8				bEndpointAddress;
28 	u8				bmAttributes;
29 
30 	unsigned			halted : 1;
31 	unsigned			already_seen : 1;
32 	unsigned			setup_stage : 1;
33 };
34 
35 
36 /* Warning : ep0 has a fifo of 16 bytes */
37 /* Don't try to set 32 or 64            */
38 /* also testusb 14 fails  wit 16 but is */
39 /* fine with 8                          */
40 #define EP0_FIFO_SIZE		 8
41 #define EP_FIFO_SIZE		64
42 #define DEFAULT_POWER_STATE	0x00
43 
44 #define S3C2440_EP_FIFO_SIZE	128
45 
46 static const char ep0name [] = "ep0";
47 
48 static const char *const ep_name[] = {
49 	ep0name,                                /* everyone has ep0 */
50 	/* s3c2410 four bidirectional bulk endpoints */
51 	"ep1-bulk", "ep2-bulk", "ep3-bulk", "ep4-bulk",
52 };
53 
54 #define S3C2410_ENDPOINTS       ARRAY_SIZE(ep_name)
55 
56 struct s3c2410_request {
57 	struct list_head		queue;		/* ep's requests */
58 	struct usb_request		req;
59 };
60 
61 enum ep0_state {
62         EP0_IDLE,
63         EP0_IN_DATA_PHASE,
64         EP0_OUT_DATA_PHASE,
65         EP0_END_XFER,
66         EP0_STALL,
67 };
68 
69 static const char *ep0states[]= {
70         "EP0_IDLE",
71         "EP0_IN_DATA_PHASE",
72         "EP0_OUT_DATA_PHASE",
73         "EP0_END_XFER",
74         "EP0_STALL",
75 };
76 
77 struct s3c2410_udc {
78 	spinlock_t			lock;
79 
80 	struct s3c2410_ep		ep[S3C2410_ENDPOINTS];
81 	int				address;
82 	struct usb_gadget		gadget;
83 	struct usb_gadget_driver	*driver;
84 	struct s3c2410_request		fifo_req;
85 	u8				fifo_buf[EP_FIFO_SIZE];
86 	u16				devstatus;
87 
88 	u32				port_status;
89 	int				ep0state;
90 
91 	unsigned			got_irq : 1;
92 
93 	unsigned			req_std : 1;
94 	unsigned			req_config : 1;
95 	unsigned			req_pending : 1;
96 	u8				vbus;
97 	struct dentry			*regs_info;
98 };
99 
100 #endif
101