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
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __S3C_USB_GADGET
23 #define __S3C_USB_GADGET
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/ioport.h>
28 #include <linux/types.h>
29 #include <linux/version.h>
30 #include <linux/errno.h>
31 #include <linux/delay.h>
32 #include <linux/sched.h>
33 #include <linux/slab.h>
34 #include <linux/init.h>
35 #include <linux/timer.h>
36 #include <linux/list.h>
37 #include <linux/interrupt.h>
38 #include <linux/proc_fs.h>
40 #include <linux/device.h>
41 #include <linux/dma-mapping.h>
44 #include <asm/byteorder.h>
47 #include <asm/system.h>
48 #include <asm/unaligned.h>
50 #include <asm/hardware.h>
53 #include <linux/usb/ch9.h>
54 #include <linux/usb/gadget.h>
55 #include <linux/host_notify.h>
58 #if defined(CONFIG_USB_GADGET_S3C_FS)
59 #define EP0_FIFO_SIZE 8
60 #define EP_FIFO_SIZE 64
61 #define S3C_MAX_ENDPOINTS 5
62 #elif defined(CONFIG_USB_GADGET_S3C_HS) || defined(CONFIG_PLAT_S5P64XX)\
63 || defined(CONFIG_PLAT_S5PC11X) || defined(CONFIG_CPU_S5P6442)\
64 || defined(CONFIG_CPU_S5P6450) || defined(CONFIG_CPU_S5PV310)
65 #define EP0_FIFO_SIZE 64
66 #define EP_FIFO_SIZE 512
67 #define EP_FIFO_SIZE2 1024
68 #define S3C_MAX_ENDPOINTS 16
69 #define DED_TX_FIFO 1 /* Dedicated NPTx fifo for s5p6440 */
71 #define EP0_FIFO_SIZE 64
72 #define EP_FIFO_SIZE 512
73 #define EP_FIFO_SIZE2 1024
74 #define S3C_MAX_ENDPOINTS 16
77 #define WAIT_FOR_SETUP 0
78 #define DATA_STATE_XMIT 1
79 #define DATA_STATE_NEED_ZLP 2
80 #define WAIT_FOR_OUT_STATUS 3
81 #define DATA_STATE_RECV 4
83 #define FAIL_TO_SETUP 6
85 #define TEST_J_SEL 0x1
86 #define TEST_K_SEL 0x2
87 #define TEST_SE0_NAK_SEL 0x3
88 #define TEST_PACKET_SEL 0x4
89 #define TEST_FORCE_ENABLE_SEL 0x5
92 #define USE_USB_LDO_CONTROL /* This definition is for LDO control. */
93 #include <linux/regulator/consumer.h>
95 * ------------------------------------------------------------------------------------------
96 * Debugging macro and defines
98 /*#define CSY_DEBUG */
99 /* #define CSY_DEBUG2 */
100 #define CSY_DEBUG_ESS
101 /* #define CSY_MORE_DEBUG */
104 # ifdef CSY_MORE_DEBUG
105 # define CSY_DBG(fmt, args...) printk(KERN_INFO "usb %s:%d "fmt, __func__, __LINE__, ##args)
107 # define CSY_DBG(fmt, args...) printk(KERN_DEBUG "usb "fmt, ##args)
109 #else /* DO NOT PRINT LOG */
110 # define CSY_DBG(fmt, args...) do { } while (0)
111 #endif /* CSY_DEBUG */
114 # ifdef CSY_MORE_DEBUG
115 # define CSY_DBG2(fmt, args...) printk(KERN_INFO "usb %s:%d "fmt, __func__, __LINE__, ##args)
117 # define CSY_DBG2(fmt, args...) printk(KERN_DEBUG "usb "fmt, ##args)
119 #else /* DO NOT PRINT LOG */
120 # define CSY_DBG2(fmt, args...) do { } while (0)
121 #endif /* CSY_DEBUG2 */
124 # ifdef CSY_MORE_DEBUG
125 # define CSY_DBG_ESS(fmt, args...) printk(KERN_INFO "usb %s:%d "fmt, __func__, __LINE__, ##args)
127 # define CSY_DBG_ESS(fmt, args...) printk(KERN_DEBUG "usb "fmt, ##args)
129 #else /* DO NOT PRINT LOG */
130 # define CSY_DBG_ESS(fmt, args...) do { } while (0)
131 #endif /* CSY_DEBUG_ESS */
135 # define DBG(devvalue, fmt, args...) \
136 printk(KERN_INFO "usb %s:%d "fmt, __func__, __LINE__, ##args)
139 /* ************************************************************************* */
143 typedef enum ep_type {
144 ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
151 const struct usb_endpoint_descriptor *desc;
152 struct list_head queue;
153 unsigned long pio_irqs;
161 #ifdef CONFIG_USB_GADGET_S3C_FS
168 struct usb_request req;
169 struct list_head queue;
170 unsigned char mapped;
174 struct usb_gadget gadget;
175 struct usb_gadget_driver *driver;
179 struct platform_device *dev;
181 #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE
183 struct regulator *udc_vcc_d, *udc_vcc_a;
186 int (*get_usb_mode)(void);
187 int (*change_usb_mode)(int mode);
189 struct host_notify_dev * ndev;
192 struct s3c_ep ep[S3C_MAX_ENDPOINTS];
194 unsigned char usb_address;
196 unsigned req_pending:1, req_std:1, req_config:1;
199 extern struct s3c_udc *the_controller;
201 #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN)
203 #define ep_index(EP) ((EP)->bEndpointAddress&0xF)
204 #define ep_maxpacket(EP) ((EP)->ep.maxpacket)