d590f8ffb99c00b597c71af1991d360011339144
[openembedded.git] /
1 From f8f10f496bce396416d7156da876222c6ce8c341 Mon Sep 17 00:00:00 2001
2 From: Steven Kipisz <skipisz@beagleboard.org>
3 Date: Wed, 9 Jan 2009 12:01:11 -0600
4 Subject: [PATCH-USB] Omap3 beagleboard: add support for EHCI in revision C1 boards
5
6 Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
7 ---
8  arch/arm/mach-omap2/board-omap3beagle.c |   10 +---------
9  arch/arm/mach-omap2/usb-ehci.c          |    4 +---
10  drivers/usb/host/ehci-omap.c            |   26 ++++++++++++++++++++++++++
11  3 files changed, 28 insertions(+), 12 deletions(-)
12
13 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
14 index fe97bab..de81153 100644
15 --- a/arch/arm/mach-omap2/board-omap3beagle.c
16 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
17 @@ -140,15 +140,7 @@ static int beagle_twl_gpio_setup(struct device *dev,
18          * power switch and overcurrent detect
19          */
20  
21 -       gpio_request(gpio + 1, "EHCI_nOC");
22 -       gpio_direction_input(gpio + 1);
23 -
24 -       /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
25 -       gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
26 -       gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
27 -
28 -       /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
29 -       gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
30 +        /* TODO: This needs to be modified to not rely on u-boot */
31  
32         return 0;
33  }
34 diff --git a/arch/arm/mach-omap2/usb-ehci.c b/arch/arm/mach-omap2/usb-ehci.c
35 index 489439d..2c6305b 100644
36 --- a/arch/arm/mach-omap2/usb-ehci.c
37 +++ b/arch/arm/mach-omap2/usb-ehci.c
38 @@ -152,9 +152,7 @@ static void setup_ehci_io_mux(void)
39  void __init usb_ehci_init(void)
40  {
41  #if     defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
42 -       /* Setup Pin IO MUX for EHCI */
43 -       if (cpu_is_omap34xx())
44 -               setup_ehci_io_mux();
45 +       /* TODO: Setup Pin IO MUX for EHCI - moved this temporarily to U-boot */
46  
47         if (platform_device_register(&ehci_device) < 0) {
48                 printk(KERN_ERR "Unable to register HS-USB (EHCI) device\n");
49
50 diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
51 index 1b3266c..8472996 100644
52 --- a/drivers/usb/host/ehci-omap.c
53 +++ b/drivers/usb/host/ehci-omap.c
54 @@ -48,16 +48,26 @@
55   *             to get the PHY state machine in working state
56   */
57  #define EXTERNAL_PHY_RESET
58 +#ifdef CONFIG_MACH_OMAP3_BEAGLE
59 +#define        EXT_PHY_RESET_GPIO_PORT2        (147)
60 +#else
61  #define        EXT_PHY_RESET_GPIO_PORT1        (57)
62  #define        EXT_PHY_RESET_GPIO_PORT2        (61)
63 +#endif
64  #define        EXT_PHY_RESET_DELAY             (10)
65  
66 +#define PHY_STP_PULLUP_ENABLE           (0x10)
67 +#define PHY_STP_PULLUP_DISABLE          (0x90)
68 +
69 +
70  /* ISSUE2:
71   * USBHOST supports External charge pump PHYs only
72   * Use the VBUS from Port1 to power VBUS of Port2 externally
73   * So use Port2 as the working ULPI port
74   */
75 +#ifndef CONFIG_MACH_OMAP3_BEAGLE
76  #define VBUS_INTERNAL_CHARGEPUMP_HACK
77 +#endif
78  
79  #endif /* CONFIG_OMAP_EHCI_PHY_MODE */
80  
81 @@ -225,14 +235,43 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
82  
83  #ifdef EXTERNAL_PHY_RESET
84         /* Refer: ISSUE1 */
85 +#ifndef CONFIG_MACH_OMAP3_BEAGLE
86         gpio_request(EXT_PHY_RESET_GPIO_PORT1, "USB1 PHY reset");
87         gpio_direction_output(EXT_PHY_RESET_GPIO_PORT1, 0);
88 +#endif
89         gpio_request(EXT_PHY_RESET_GPIO_PORT2, "USB2 PHY reset");
90         gpio_direction_output(EXT_PHY_RESET_GPIO_PORT2, 0);
91 +       gpio_set_value(EXT_PHY_RESET_GPIO_PORT2, 0);
92         /* Hold the PHY in RESET for enough time till DIR is high */
93         udelay(EXT_PHY_RESET_DELAY);
94  #endif
95  
96 +        /*
97 +         * The PHY register 0x7 - Interface Control register is
98 +         * configured to disable the integrated STP pull-up resistor
99 +         * used for interface protection.
100 +        *
101 +        * May not need to be here.
102 +         */
103 +        omap_writel((0x7 << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* interface reg */
104 +                (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/*   Write */
105 +                (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
106 +                (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
107 +                (PHY_STP_PULLUP_DISABLE),
108 +                EHCI_INSNREG05_ULPI);
109 +
110 +        while (!(omap_readl(EHCI_INSNREG05_ULPI) & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT)));
111 +
112 +        /* Force PHY to HS */
113 +        omap_writel((0x4 << EHCI_INSNREG05_ULPI_REGADD_SHIFT) |/* function ctrl */
114 +                (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT) |/*   Write */
115 +                (1 << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT) |/* Port1 */
116 +                (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT) |/* Start */
117 +                (0x40),
118 +                EHCI_INSNREG05_ULPI);
119 +
120 +        while (!(omap_readl(EHCI_INSNREG05_ULPI) & (1<<EHCI_INSNREG05_ULPI_CONTROL_SHIFT)));
121 +
122         /* Configure TLL for 60Mhz clk for ULPI */
123         ehci_clocks->usbtll_fck_clk = clk_get(&dev->dev, USBHOST_TLL_FCLK);
124         if (IS_ERR(ehci_clocks->usbtll_fck_clk))
125 @@ -307,7 +346,9 @@ static int omap_start_ehc(struct platform_device *dev, struct usb_hcd *hcd)
126          * Hold the PHY in RESET for enough time till PHY is settled and ready
127          */
128         udelay(EXT_PHY_RESET_DELAY);
129 +#ifndef CONFIG_MACH_OMAP3_BEAGLE
130         gpio_set_value(EXT_PHY_RESET_GPIO_PORT1, 1);
131 +#endif
132         gpio_set_value(EXT_PHY_RESET_GPIO_PORT2, 1);
133  #endif
134  
135 @@ -393,7 +434,9 @@ static void omap_stop_ehc(struct platform_device *dev, struct usb_hcd *hcd)
136  
137  
138  #ifdef EXTERNAL_PHY_RESET
139 +#ifndef CONFIG_MACH_OMAP3_BEAGLE
140         gpio_free(EXT_PHY_RESET_GPIO_PORT1);
141 +#endif
142         gpio_free(EXT_PHY_RESET_GPIO_PORT2);
143  #endif
144
145 --
146 1.6.0.4.790.gaa14a