summaryrefslogtreecommitdiff
path: root/target/linux/at91/patches/600-usb_vbus_active_high.patch
blob: 08dfcb30328aa971246ed3069129c40ba2a7eb36 (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
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -77,7 +77,7 @@ void __init at91_add_device_usbh(struct
 	/* Enable VBus control for UHP ports */
 	for (i = 0; i < data->ports; i++) {
 		if (data->vbus_pin[i])
-			at91_set_gpio_output(data->vbus_pin[i], 0);
+			at91_set_gpio_output(data->vbus_pin[i], data->vbus_active_high);
 	}
 
 	usbh_data = *data;
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -71,7 +71,7 @@ void __init at91_add_device_usbh(struct
 	/* Enable VBus control for UHP ports */
 	for (i = 0; i < data->ports; i++) {
 		if (data->vbus_pin[i])
-			at91_set_gpio_output(data->vbus_pin[i], 0);
+			at91_set_gpio_output(data->vbus_pin[i], data->vbus_active_high);
 	}
 
 	usbh_data = *data;
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -121,7 +121,7 @@ void __init at91_add_device_usbh_ohci(st
 	/* Enable VBus control for UHP ports */
 	for (i = 0; i < data->ports; i++) {
 		if (data->vbus_pin[i])
-			at91_set_gpio_output(data->vbus_pin[i], 0);
+			at91_set_gpio_output(data->vbus_pin[i], data->vbus_active_high);
 	}
 
 	usbh_ohci_data = *data;
@@ -176,7 +176,7 @@ void __init at91_add_device_usbh_ehci(st
 	/* Enable VBus control for UHP ports */
 	for (i = 0; i < data->ports; i++) {
 		if (data->vbus_pin[i])
-			at91_set_gpio_output(data->vbus_pin[i], 0);
+			at91_set_gpio_output(data->vbus_pin[i], data->vbus_active_high);
 	}
 
 	usbh_ehci_data = *data;
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -96,8 +96,9 @@ extern void __init at91_add_device_eth(s
 
  /* USB Host */
 struct at91_usbh_data {
-	u8		ports;		/* number of ports on root hub */
-	u8		vbus_pin[2];	/* port power-control pin */
+	u8		ports;			/* number of ports on root hub */
+	u8		vbus_pin[2];		/* port power-control pin */
+	u8		vbus_active_high;	/* true == vbus_pins are active high */
 };
 extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
 extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -277,14 +277,13 @@ static int ohci_hcd_at91_drv_probe(struc
 	if (pdata) {
 		/* REVISIT make the driver support per-port power switching,
 		 * and also overcurrent detection.  Here we assume the ports
-		 * are always powered while this driver is active, and use
-		 * active-low power switches.
+		 * are always powered while this driver is active.
 		 */
 		for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
 			if (pdata->vbus_pin[i] <= 0)
 				continue;
 			gpio_request(pdata->vbus_pin[i], "ohci_vbus");
-			gpio_direction_output(pdata->vbus_pin[i], 0);
+			gpio_direction_output(pdata->vbus_pin[i], pdata->vbus_active_high);
 		}
 	}
 
@@ -301,7 +300,7 @@ static int ohci_hcd_at91_drv_remove(stru
 		for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
 			if (pdata->vbus_pin[i] <= 0)
 				continue;
-			gpio_direction_output(pdata->vbus_pin[i], 1);
+			gpio_direction_output(pdata->vbus_pin[i], !pdata->vbus_active_high);
 			gpio_free(pdata->vbus_pin[i]);
 		}
 	}