]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
omap3: cm-t35: move the USB hub reset code
authorIgor Grinberg <grinberg@compulab.co.il>
Mon, 3 Nov 2014 09:32:19 +0000 (11:32 +0200)
committerTom Rini <trini@ti.com>
Thu, 6 Nov 2014 16:04:40 +0000 (11:04 -0500)
Extract the USB hub reset code to a common location where it can be
reused by other compulab boards.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Reviewed-by: Tom Rini <trini@ti.com>
board/compulab/cm_t35/cm_t35.c
board/compulab/common/common.c
board/compulab/common/common.h

index 5453942202d5a3cb8b2d925a57a9cee26e4a9cf3..aca41c8f3d244f3701a1f78b6bbaec3c2549b08c 100644 (file)
@@ -568,21 +568,12 @@ struct omap_usbhs_board_data usbhs_bdata = {
 
 #define SB_T35_USB_HUB_RESET_GPIO      167
 int ehci_hcd_init(int index, enum usb_init_type init,
-               struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+                 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
        u8 val;
        int offset;
 
-       if (gpio_request(SB_T35_USB_HUB_RESET_GPIO, "SB-T35 usb hub reset")) {
-               printf("Error: can't obtain GPIO %d for SB-T35 usb hub reset",
-                               SB_T35_USB_HUB_RESET_GPIO);
-               return -1;
-       }
-
-       gpio_direction_output(SB_T35_USB_HUB_RESET_GPIO, 0);
-       udelay(10);
-       gpio_set_value(SB_T35_USB_HUB_RESET_GPIO, 1);
-       udelay(1000);
+       cl_usb_hub_init(SB_T35_USB_HUB_RESET_GPIO, "sb-t35 hub rst");
 
        offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_GPIODATADIR1;
        twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, offset, &val);
@@ -599,6 +590,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 
 int ehci_hcd_stop(void)
 {
+       cl_usb_hub_deinit(SB_T35_USB_HUB_RESET_GPIO);
        return omap_ehci_hcd_stop();
 }
 #endif /* CONFIG_USB_EHCI_OMAP */
index 6d2d7b0bd02b376deefef547bc08a327115efa96..f2ce522fa68535a9685f1da4420c3f3e75d81c41 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <asm/bootm.h>
+#include <asm/gpio.h>
 
 #include "common.h"
 #include "eeprom.h"
@@ -23,3 +24,24 @@ void cl_print_pcb_info(void)
 
        printf("PCB:   %u.%u\n", rev_major, rev_minor);
 }
+
+#ifdef CONFIG_CMD_USB
+int cl_usb_hub_init(int gpio, const char *label)
+{
+       if (gpio_request(gpio, label)) {
+               printf("Error: can't obtain GPIO%d for %s", gpio, label);
+               return -1;
+       }
+
+       gpio_direction_output(gpio, 0);
+       udelay(10);
+       gpio_set_value(gpio, 1);
+       udelay(1000);
+       return 0;
+}
+
+void cl_usb_hub_deinit(int gpio)
+{
+       gpio_free(gpio);
+}
+#endif
index 316ee4c6cd6896edb0e77b43b2c91a7187135d5e..ffe1ef8174f21eab57538c1e6244ad73cff63924 100644 (file)
@@ -9,6 +9,19 @@
 #ifndef _CL_COMMON_
 #define _CL_COMMON_
 
+#include <asm/errno.h>
+
 void cl_print_pcb_info(void);
 
+#ifdef CONFIG_CMD_USB
+int cl_usb_hub_init(int gpio, const char *label);
+void cl_usb_hub_deinit(int gpio);
+#else /* !CONFIG_CMD_USB */
+static inline int cl_usb_hub_init(int gpio, const char *label)
+{
+       return -ENOSYS;
+}
+static inline void cl_usb_hub_deinit(int gpio) {}
+#endif /* CONFIG_CMD_USB */
+
 #endif /* _CL_COMMON_ */