summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/patches-3.3/511-MIPS-ath79-add-ath79_set_usb_power_gpio.patch
blob: 91a793d5e1b8f7d5bd009544a3db15944cc501f7 (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
--- a/arch/mips/ath79/dev-usb.c
+++ b/arch/mips/ath79/dev-usb.c
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
+#include <linux/gpio.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/usb/ehci_pdriver.h>
@@ -282,3 +283,26 @@ void __init ath79_register_usb(void)
 	else
 		BUG();
 }
+
+void __init ath79_set_usb_power_gpio(unsigned int gpio, unsigned long flags,
+				     const char *label)
+{
+	int err;
+
+	err = gpio_request_one(gpio, flags, label);
+	if (err) {
+		pr_err("ath79: can't setup GPIO%u (%s), err=%d\n",
+			gpio, label, err);
+		return;
+	}
+
+	err = gpio_export(gpio, false);
+	if (err) {
+		pr_err("ath79: can't export GPIO%u (%s), err=%d\n",
+			gpio, label, err);
+	}
+
+	return;
+}
+
+
--- a/arch/mips/ath79/dev-usb.h
+++ b/arch/mips/ath79/dev-usb.h
@@ -13,5 +13,7 @@
 #define _ATH79_DEV_USB_H
 
 void ath79_register_usb(void);
+void ath79_set_usb_power_gpio(unsigned int gpio, unsigned long flags,
+			      const char *label);
 
 #endif /* _ATH79_DEV_USB_H */