summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-06-19 10:13:41 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-06-19 10:13:41 +0000
commit9e32544f7a17edad4606f49a99461c7f7951ddd2 (patch)
treec9af6aaaaff1ae689683b269e7f7f89134361da5
parent60f2c64e65e73819a36b78f4665a68c7d7eef333 (diff)
ar71xx: add a common function to configure USB power GPIOs
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32454 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c4
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c4
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c4
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c5
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c4
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c3
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c6
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c5
-rw-r--r--target/linux/ar71xx/patches-3.3/511-MIPS-ath79-add-ath79_set_usb_power_gpio.patch47
9 files changed, 63 insertions, 19 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c
index 45dc0f618..f8870e711 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-hornet-ub.c
@@ -101,8 +101,8 @@ static void __init hornet_ub_gpio_setup(void)
t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
- gpio_request(HORNET_UB_GPIO_USB_POWER, "USB power");
- gpio_direction_output(HORNET_UB_GPIO_USB_POWER, 1);
+ ath79_set_usb_power_gpio(HORNET_UB_GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
+ "USB power");
}
static void __init hornet_ub_setup(void)
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c
index 4acb47942..87facff7f 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr11u.c
@@ -93,8 +93,8 @@ static void __init tl_mr11u_setup(void)
ARRAY_SIZE(tl_mr11u_gpio_keys),
tl_mr11u_gpio_keys);
- gpio_request(TL_MR11U_GPIO_USB_POWER, "USB power");
- gpio_direction_output(TL_MR11U_GPIO_USB_POWER, 1);
+ ath79_set_usb_power_gpio(TL_MR11U_GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
+ "USB power");
ath79_register_usb();
ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c
index 176ad9790..8f37d7a87 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3020.c
@@ -109,8 +109,8 @@ static void __init tl_mr3020_setup(void)
ARRAY_SIZE(tl_mr3020_gpio_keys),
tl_mr3020_gpio_keys);
- gpio_request(TL_MR3020_GPIO_USB_POWER, "USB power");
- gpio_direction_output(TL_MR3020_GPIO_USB_POWER, 1);
+ ath79_set_usb_power_gpio(TL_MR3020_GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
+ "USB power");
ath79_register_usb();
ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c
index 35515a9b4..b35f09f8a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-mr3x20.c
@@ -102,9 +102,8 @@ static void __init tl_ap99_setup(void)
static void __init tl_mr3x20_usb_setup(void)
{
/* enable power for the USB port */
- gpio_request(TL_MR3X20_GPIO_USB_POWER, "USB power");
- gpio_direction_output(TL_MR3X20_GPIO_USB_POWER, 1);
-
+ ath79_set_usb_power_gpio(TL_MR3X20_GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
+ "USB power");
ath79_register_usb();
}
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c
index c61a16c99..f60f96245 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr703n.c
@@ -69,8 +69,8 @@ static void __init tl_wr703n_setup(void)
ARRAY_SIZE(tl_wr703n_gpio_keys),
tl_wr703n_gpio_keys);
- gpio_request(TL_WR703N_GPIO_USB_POWER, "USB power");
- gpio_direction_output(TL_WR703N_GPIO_USB_POWER, 1);
+ ath79_set_usb_power_gpio(TL_WR703N_GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
+ "USB power");
ath79_register_usb();
ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c
index 1223e842d..5941d5ca9 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c
@@ -137,9 +137,8 @@ static void __init wzrhpag300h_setup(void)
ath79_register_eth(0);
ath79_register_eth(1);
+ ath79_set_usb_power_gpio(2, GPIOF_OUT_INIT_HIGH, "USB power");
ath79_register_usb();
- gpio_request(2, "usb");
- gpio_direction_output(2, 1);
ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
wzrhpag300h_leds_gpio);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c
index 6ccafcb49..6c850cee5 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g300nh2.c
@@ -156,10 +156,10 @@ static void __init wzrhpg300nh2_setup(void)
ath79_eth0_data.phy_mask = BIT(0);
ath79_register_eth(0);
- ath79_register_usb();
+
/* gpio13 is usb power. Turn it on. */
- gpio_request(13, "usb");
- gpio_direction_output(13, 1);
+ ath79_set_usb_power_gpio(13, GPIOF_OUT_INIT_HIGH, "USB power");
+ ath79_register_usb();
ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
wzrhpg300nh2_leds_gpio);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c
index f60614557..b5292db54 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-g450h.c
@@ -10,7 +10,7 @@
* by the Free Software Foundation.
*/
-#include <asm/mach-ath79/gpio.h>
+#include <linux/gpio.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
@@ -156,9 +156,8 @@ static void __init wzrhpg450h_init(void)
ath79_register_eth(0);
+ ath79_set_usb_power_gpio(16, GPIOF_OUT_INIT_HIGH, "USB power");
ath79_register_usb();
- gpio_request(16, "usb");
- gpio_direction_output(16, 1);
ap91_pci_init(ee, NULL);
ap9x_pci_setup_wmac_led_pin(0, 15);
diff --git a/target/linux/ar71xx/patches-3.3/511-MIPS-ath79-add-ath79_set_usb_power_gpio.patch b/target/linux/ar71xx/patches-3.3/511-MIPS-ath79-add-ath79_set_usb_power_gpio.patch
new file mode 100644
index 000000000..fa8178971
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.3/511-MIPS-ath79-add-ath79_set_usb_power_gpio.patch
@@ -0,0 +1,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>
+@@ -236,3 +237,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 */