aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux/acern30/n30-usbstart.patch
blob: b7479b50e44374bcd726e380b5bd2214f11d0496 (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
This patch tries to start the USB gadget in a nice way by
disconnecting and then reconnecting the pull up.  

I ought to use the same callback and configuration as RTP does in
mach-h1940.

Index: linux-2.6.14/arch/arm/mach-s3c2410/mach-n30.c
===================================================================
--- linux-2.6.14.orig/arch/arm/mach-s3c2410/mach-n30.c
+++ linux-2.6.14/arch/arm/mach-s3c2410/mach-n30.c
@@ -356,7 +356,33 @@ static void __init n30_init_irq(void)
 	s3c24xx_init_irq();
 }
 
-/* GPB3 is the line that controls the pull-up for the USB D+ line */
+static int n30_usbstart_thread(void *unused)
+{
+	/* Disable both USB ports */
+	s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND0 |
+			      S3C2410_MISCCR_USBSUSPND1, 
+			      S3C2410_MISCCR_USBSUSPND0 |
+			      S3C2410_MISCCR_USBSUSPND1);
+
+	/* Turn off the D+ pull up for a few second so that the USB
+	 * host at the other end will do a rescan of the USB bus.  */
+	s3c2410_gpio_setpin(S3C2410_GPB3, 0);
+
+	msleep_interruptible(1 * 1000);
+
+	/* Enable the USB host port if this is a n30 */
+	if (machine_is_n30())
+		s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND0, 0);
+
+	/* Turn off suspend on USB device port and switch it to device
+	 * mode. */
+	s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
+			      S3C2410_MISCCR_USBSUSPND1, 0x0);
+
+	s3c2410_gpio_setpin(S3C2410_GPB3, 1);
+
+	return 0;
+}
 
 static void __init n30_init(void)
 {
@@ -380,12 +406,7 @@ static void __init n30_init(void)
 	msleep(1);
 	s3c2410_gpio_setpin(S3C2410_GPC5, 1);
 
-	/* Turn off suspend on both USB ports, and switch the
-	 * selectable USB port to USB device mode. */
-
-	s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
-			      S3C2410_MISCCR_USBSUSPND0 |
-			      S3C2410_MISCCR_USBSUSPND1, 0x0);
+	kthread_run(n30_usbstart_thread, NULL, "n30_usbstart");
 }
 
 MACHINE_START(N30, "Acer-N30")