summaryrefslogtreecommitdiff
path: root/recipes/linux/gumstix-kernel-2.6.21/gumstix-pxa270-usb-host.patch
blob: f5da12fdeffdcb53a23ffe66675b4878eeadd153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
Index: linux-2.6.21gum/arch/arm/mach-pxa/gumstix.c
===================================================================
--- linux-2.6.21gum.orig/arch/arm/mach-pxa/gumstix.c
+++ linux-2.6.21gum/arch/arm/mach-pxa/gumstix.c
@@ -22,6 +22,7 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
+#include <asm/arch/ohci.h>
 #include <asm/arch/udc.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/pxa-regs.h>
@@ -178,9 +179,34 @@ static struct platform_device *devices[]
 	&gum_audio_device,
 };
 
+#ifdef CONFIG_ARCH_GUMSTIX_VERDEX
+static int gumstix_ohci_init(struct device *dev)
+{
+	/* setup Port1 GPIO pin. */
+	//pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN);	/* USBHPWR1 */
+	//pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT);	/* USBHPEN1 */
+
+	// Turn on port 2 in host mode
+	UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
+
+	UHCHR = (UHCHR) &
+		~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+
+	return 0;
+}
+
+static struct pxaohci_platform_data gumstix_ohci_platform_data = {
+	.port_mode	= PMM_PERPORT_MODE,
+	.init		= gumstix_ohci_init,
+};
+#endif
+
 static void __init gumstix_init(void)
 {
 	pxa_set_mci_info(&gumstix_mci_platform_data);
+#ifdef CONFIG_ARCH_GUMSTIX_VERDEX
+	pxa_set_ohci_info(&gumstix_ohci_platform_data);
+#endif
 	pxa_set_udc_info(&gumstix_udc_info);
 #if defined(CONFIG_FB_PXA_ALPS_CDOLLAR) | defined(CONFIG_FB_PXA_SHARP_LQ043_PSP) | defined(CONFIG_FB_PXA_SAMSUNG_LTE430WQ_F0C)
 	set_pxa_fb_info(&gumstix_fb_info);
Index: linux-2.6.21gum/drivers/usb/gadget/ether.c
===================================================================
--- linux-2.6.21gum.orig/drivers/usb/gadget/ether.c
+++ linux-2.6.21gum/drivers/usb/gadget/ether.c
@@ -260,6 +260,8 @@ MODULE_PARM_DESC(host_addr, "Host Ethern
 
 #ifdef CONFIG_USB_GADGET_PXA27X
 #define DEV_CONFIG_CDC
+extern struct usb_ep* pxa27x_ep_config(struct usb_gadget *gadget,
+	struct usb_endpoint_descriptor *desc,int config,int interface,int alt);
 #endif
 
 #ifdef CONFIG_USB_GADGET_S3C2410
@@ -482,15 +484,15 @@ eth_config = {
 #ifdef	CONFIG_USB_ETH_RNDIS
 static struct usb_config_descriptor
 rndis_config = {
-	.bLength =              sizeof rndis_config,
+	.bLength =	      sizeof rndis_config,
 	.bDescriptorType =      USB_DT_CONFIG,
 
 	/* compute wTotalLength on the fly */
-	.bNumInterfaces =       2,
+	.bNumInterfaces =	2,
 	.bConfigurationValue =  DEV_RNDIS_CONFIG_VALUE,
-	.iConfiguration =       STRING_RNDIS,
+	.iConfiguration =	STRING_RNDIS,
 	.bmAttributes =		USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-	.bMaxPower =            50,
+	.bMaxPower =	    50,
 };
 #endif
 
@@ -532,15 +534,15 @@ control_intf = {
 #ifdef	CONFIG_USB_ETH_RNDIS
 static const struct usb_interface_descriptor
 rndis_control_intf = {
-	.bLength =              sizeof rndis_control_intf,
+	.bLength =	      sizeof rndis_control_intf,
 	.bDescriptorType =      USB_DT_INTERFACE,
 
 	.bInterfaceNumber =     0,
-	.bNumEndpoints =        1,
+	.bNumEndpoints =	1,
 	.bInterfaceClass =      USB_CLASS_COMM,
 	.bInterfaceSubClass =   USB_CDC_SUBCLASS_ACM,
 	.bInterfaceProtocol =   USB_CDC_ACM_PROTO_VENDOR,
-	.iInterface =           STRING_RNDIS_CONTROL,
+	.iInterface =	   STRING_RNDIS_CONTROL,
 };
 #endif
 
@@ -1342,7 +1344,7 @@ static void rndis_response_complete (str
 
 static void rndis_command_complete (struct usb_ep *ep, struct usb_request *req)
 {
-	struct eth_dev          *dev = ep->driver_data;
+	struct eth_dev	  *dev = ep->driver_data;
 	int			status;
 
 	/* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */
@@ -1578,7 +1580,7 @@ done_set_intf:
 
 			/* return the result */
 			buf = rndis_get_next_response (dev->rndis_config,
-						       &value);
+							&value);
 			if (buf) {
 				memcpy (req->buf, buf, value);
 				req->complete = rndis_response_complete;
@@ -2064,7 +2066,7 @@ static void eth_req_free (struct usb_ep 
 static void
 rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
 {
-	struct eth_dev          *dev = ep->driver_data;
+	struct eth_dev	  *dev = ep->driver_data;
 
 	if (req->status || req->actual != req->length)
 		DEBUG (dev,
@@ -2415,7 +2417,27 @@ eth_bind (struct usb_gadget *gadget)
 
 	/* all we really need is bulk IN/OUT */
 	usb_ep_autoconfig_reset (gadget);
+#ifdef CONFIG_USB_GADGET_PXA27X 
+#ifdef  CONFIG_USB_ETH_RNDIS
+	in_ep = pxa27x_ep_config (gadget, &fs_source_desc,
+			DEV_RNDIS_CONFIG_VALUE,
+			(int)rndis_data_intf.bInterfaceNumber,
+			(int)rndis_data_intf.bAlternateSetting);
+#elif   defined(DEV_CONFIG_CDC) 
+	in_ep = pxa27x_ep_config (gadget, &fs_source_desc,
+			DEV_CONFIG_VALUE,
+			(int)data_intf.bInterfaceNumber,
+			(int)data_intf.bAlternateSetting);
+#elif   defined(DEV_CONFIG_SUBSET)		      
+	in_ep = pxa27x_ep_config (gadget, &fs_source_desc,
+			DEV_CONFIG_VALUE,
+			(int)subset_data_intf.bInterfaceNumber,
+			(int)subset_data_intf.bAlternateSetting);
+
+#endif //CONFIG_USB_ETH_RNDIS
+#else
 	in_ep = usb_ep_autoconfig (gadget, &fs_source_desc);
+#endif //CONFIG_USB_GADGET_PXA27X
 	if (!in_ep) {
 autoconf_fail:
 		dev_err (&gadget->dev,
@@ -2425,7 +2447,26 @@ autoconf_fail:
 	}
 	in_ep->driver_data = in_ep;	/* claim */
 
+#ifdef  CONFIG_USB_GADGET_PXA27X	
+#ifdef  CONFIG_USB_ETH_RNDIS
+	out_ep = pxa27x_ep_config (gadget, &fs_sink_desc,
+			DEV_RNDIS_CONFIG_VALUE,
+			(int)rndis_data_intf.bInterfaceNumber,
+			(int)rndis_data_intf.bAlternateSetting);
+#elif   defined(DEV_CONFIG_CDC)
+	out_ep = pxa27x_ep_config (gadget, &fs_sink_desc,
+			DEV_CONFIG_VALUE,
+			(int)data_intf.bInterfaceNumber,
+			(int)data_intf.bAlternateSetting);
+#elif   defined(DEV_CONFIG_SUBSET)		      
+	out_ep = pxa27x_ep_config (gadget, &fs_sink_desc,
+			DEV_CONFIG_VALUE,
+			(int)subset_data_intf.bInterfaceNumber,
+			(int)subset_data_intf.bAlternateSetting);
+#endif //CONFIG_USB_ETH_RNDIS
+#else
 	out_ep = usb_ep_autoconfig (gadget, &fs_sink_desc);
+#endif //CONFIG_USB_GADGET_PXA27X
 	if (!out_ep)
 		goto autoconf_fail;
 	out_ep->driver_data = out_ep;	/* claim */
@@ -2435,7 +2476,22 @@ autoconf_fail:
 	 * Since some hosts expect one, try to allocate one anyway.
 	 */
 	if (cdc || rndis) {
+#ifdef  CONFIG_USB_GADGET_PXA27X	
+#ifdef  CONFIG_USB_ETH_RNDIS
+		status_ep = pxa27x_ep_config (gadget, &fs_status_desc,
+				DEV_RNDIS_CONFIG_VALUE,
+				(int)rndis_control_intf.bInterfaceNumber,
+				(int)rndis_control_intf.bAlternateSetting);
+#elif   defined(DEV_CONFIG_CDC)
+		status_ep = pxa27x_ep_config (gadget, &fs_status_desc,
+				DEV_CONFIG_VALUE,
+				(int)control_intf.bInterfaceNumber,
+				(int)control_intf.bAlternateSetting);
+
+#endif //CONFIG_USB_ETH_RNDIS
+#else
 		status_ep = usb_ep_autoconfig (gadget, &fs_status_desc);
+#endif //CONFIG_USB_GADGET_PXA27X
 		if (status_ep) {
 			status_ep->driver_data = status_ep;	/* claim */
 		} else if (rndis) {
@@ -2444,11 +2500,13 @@ autoconf_fail:
 				gadget->name);
 			return -ENODEV;
 #ifdef DEV_CONFIG_CDC
+#ifndef CONFIG_USB_GADGET_PXA27X
 		/* pxa25x only does CDC subset; often used with RNDIS */
 		} else if (cdc) {
 			control_intf.bNumEndpoints = 0;
 			/* FIXME remove endpoint from descriptor list */
 #endif
+#endif
 		}
 	}
 #endif
Index: linux-2.6.21gum/drivers/usb/gadget/file_storage.c
===================================================================
--- linux-2.6.21gum.orig/drivers/usb/gadget/file_storage.c
+++ linux-2.6.21gum/drivers/usb/gadget/file_storage.c
@@ -280,6 +280,12 @@ MODULE_LICENSE("Dual BSD/GPL");
 #define DRIVER_PRODUCT_ID	0xa4a5	// Linux-USB File-backed Storage Gadget
 
 
+
+#ifdef CONFIG_USB_GADGET_PXA27X
+extern struct usb_ep* pxa27x_ep_config(struct usb_gadget *gadget,
+	struct usb_endpoint_descriptor *desc,int config,int interface,int alt);
+#endif
+
 /*
  * This driver assumes self-powered hardware and has no way for users to
  * trigger remote wakeup.  It uses autoconfiguration to select endpoints
@@ -3920,20 +3926,32 @@ static int __init fsg_bind(struct usb_ga
 
 	/* Find all the endpoints we will use */
 	usb_ep_autoconfig_reset(gadget);
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &fs_bulk_in_desc, CONFIG_VALUE, 0, 0);
+#else
 	ep = usb_ep_autoconfig(gadget, &fs_bulk_in_desc);
+#endif
 	if (!ep)
 		goto autoconf_fail;
 	ep->driver_data = fsg;		// claim the endpoint
 	fsg->bulk_in = ep;
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &fs_bulk_out_desc, CONFIG_VALUE, 0, 0);
+#else
 	ep = usb_ep_autoconfig(gadget, &fs_bulk_out_desc);
+#endif
 	if (!ep)
 		goto autoconf_fail;
 	ep->driver_data = fsg;		// claim the endpoint
 	fsg->bulk_out = ep;
 
 	if (transport_is_cbi()) {
+#ifdef CONFIG_USB_GADGET_PXA27X
+		ep = pxa27x_ep_config(gadget, &fs_intr_in_desc, CONFIG_VALUE, 0, 0);
+#else
 		ep = usb_ep_autoconfig(gadget, &fs_intr_in_desc);
+#endif
 		if (!ep)
 			goto autoconf_fail;
 		ep->driver_data = fsg;		// claim the endpoint
@@ -4063,6 +4081,7 @@ autoconf_fail:
 	rc = -ENOTSUPP;
 
 out:
+	ERROR(fsg, "cleaning up on the way out\n");
 	fsg->state = FSG_STATE_TERMINATED;	// The thread is dead
 	fsg_unbind(gadget);
 	close_all_backing_files(fsg);
Index: linux-2.6.21gum/drivers/usb/gadget/serial.c
===================================================================
--- linux-2.6.21gum.orig/drivers/usb/gadget/serial.c
+++ linux-2.6.21gum/drivers/usb/gadget/serial.c
@@ -126,6 +126,10 @@ static int debug = 1;
 #define GS_LOG2_NOTIFY_INTERVAL		5	/* 1 << 5 == 32 msec */
 #define GS_NOTIFY_MAXPACKET		8
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+extern struct usb_ep* pxa27x_ep_config(struct usb_gadget *gadget,
+	struct usb_endpoint_descriptor *desc,int config,int interface,int alt);
+#endif
 
 /* Structures */
 
@@ -1378,20 +1382,32 @@ static int __init gs_bind(struct usb_gad
 
 	usb_ep_autoconfig_reset(gadget);
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &gs_fullspeed_in_desc, use_acm ? GS_ACM_CONFIG_ID : GS_BULK_CONFIG_ID, gs_bulk_interface_desc.bInterfaceNumber, gs_bulk_interface_desc.bAlternateSetting);
+#else
 	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
+#endif
 	if (!ep)
 		goto autoconf_fail;
 	EP_IN_NAME = ep->name;
 	ep->driver_data = ep;	/* claim the endpoint */
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &gs_fullspeed_out_desc, use_acm ? GS_ACM_CONFIG_ID : GS_BULK_CONFIG_ID, gs_bulk_interface_desc.bInterfaceNumber, gs_bulk_interface_desc.bAlternateSetting);
+#else
 	ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
+#endif
 	if (!ep)
 		goto autoconf_fail;
 	EP_OUT_NAME = ep->name;
 	ep->driver_data = ep;	/* claim the endpoint */
 
 	if (use_acm) {
+#ifdef CONFIG_USB_GADGET_PXA27X
+		ep = pxa27x_ep_config(gadget, &gs_fullspeed_notify_desc, GS_BULK_CONFIG_ID, gs_control_interface_desc.bInterfaceNumber, gs_control_interface_desc.bAlternateSetting);
+#else
 		ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc);
+#endif
 		if (!ep) {
 			printk(KERN_ERR "gs_bind: cannot run ACM on %s\n", gadget->name);
 			goto autoconf_fail;
Index: linux-2.6.21gum/drivers/usb/gadget/zero.c
===================================================================
--- linux-2.6.21gum.orig/drivers/usb/gadget/zero.c
+++ linux-2.6.21gum/drivers/usb/gadget/zero.c
@@ -212,6 +212,11 @@ module_param (loopdefault, bool, S_IRUGO
 #define STRING_SOURCE_SINK		250
 #define STRING_LOOPBACK			251
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+extern struct usb_ep* pxa27x_ep_config(struct usb_gadget *gadget,
+	struct usb_endpoint_descriptor *desc,int config,int interface,int alt);
+#endif
+
 /*
  * This device advertises two configurations; these numbers work
  * on a pxa250 as well as more flexible hardware.
@@ -1155,7 +1160,11 @@ zero_bind (struct usb_gadget *gadget)
 	 * but there may also be important quirks to address.
 	 */
 	usb_ep_autoconfig_reset (gadget);
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &fs_source_desc, CONFIG_SOURCE_SINK, source_sink_intf.bInterfaceNumber, source_sink_intf.bAlternateSetting);
+#else
 	ep = usb_ep_autoconfig (gadget, &fs_source_desc);
+#endif
 	if (!ep) {
 autoconf_fail:
 		printk (KERN_ERR "%s: can't autoconfigure on %s\n",
@@ -1164,8 +1173,12 @@ autoconf_fail:
 	}
 	EP_IN_NAME = ep->name;
 	ep->driver_data = ep;	/* claim */
-	
+
+#ifdef CONFIG_USB_GADGET_PXA27X
+	ep = pxa27x_ep_config(gadget, &fs_sink_desc, CONFIG_SOURCE_SINK, source_sink_intf.bInterfaceNumber, source_sink_intf.bAlternateSetting);
+#else
 	ep = usb_ep_autoconfig (gadget, &fs_sink_desc);
+#endif
 	if (!ep)
 		goto autoconf_fail;
 	EP_OUT_NAME = ep->name;