Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1 | /* |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 2 | * URB OHCI HCD (Host Controller Driver) for USB on the PPC440EP. |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 3 | * |
| 4 | * (C) Copyright 2003-2004 |
Detlev Zundel | f1b3f2b | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 5 | * Gary Jennejohn, DENX Software Engineering <garyj@denx.de> |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 6 | * |
| 7 | * (C) Copyright 2004 |
| 8 | * Pierre Aubert, Staubli Faverges <p.aubert@staubli.com> |
| 9 | * |
| 10 | * Note: Much of this code has been derived from Linux 2.4 |
| 11 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> |
| 12 | * (C) Copyright 2000-2002 David Brownell |
| 13 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 14 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 15 | */ |
| 16 | /* |
| 17 | * IMPORTANT NOTES |
| 18 | * 1 - this driver is intended for use with USB Mass Storage Devices |
| 19 | * (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes! |
| 20 | */ |
| 21 | |
| 22 | #include <common.h> |
| 23 | |
| 24 | #ifdef CONFIG_USB_OHCI |
| 25 | |
| 26 | #include <malloc.h> |
| 27 | #include <usb.h> |
| 28 | #include "usb_ohci.h" |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 29 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 30 | #define OHCI_USE_NPS /* force NoPowerSwitching mode */ |
| 31 | #undef OHCI_VERBOSE_DEBUG /* not always helpful */ |
| 32 | #undef DEBUG |
| 33 | #undef SHOW_INFO |
| 34 | #undef OHCI_FILL_TRACE |
| 35 | |
| 36 | /* For initializing controller (mask in an HCFS mode too) */ |
| 37 | #define OHCI_CONTROL_INIT \ |
| 38 | (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE |
| 39 | |
Wolfgang Denk | 9af5805 | 2008-04-25 12:44:08 +0200 | [diff] [blame] | 40 | #define readl(a) (*((volatile u32 *)(a))) |
| 41 | #define writel(a, b) (*((volatile u32 *)(b)) = ((volatile u32)a)) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 42 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 43 | #ifdef DEBUG |
| 44 | #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg) |
| 45 | #else |
| 46 | #define dbg(format, arg...) do {} while(0) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 47 | #endif /* DEBUG */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 48 | #define err(format, arg...) printf("ERROR: " format "\n", ## arg) |
| 49 | #ifdef SHOW_INFO |
| 50 | #define info(format, arg...) printf("INFO: " format "\n", ## arg) |
| 51 | #else |
| 52 | #define info(format, arg...) do {} while(0) |
| 53 | #endif |
| 54 | |
| 55 | #define m16_swap(x) swap_16(x) |
| 56 | #define m32_swap(x) swap_32(x) |
| 57 | |
Stefan Roese | 17ffbc8 | 2007-03-21 13:38:59 +0100 | [diff] [blame] | 58 | #if defined(CONFIG_405EZ) || defined(CONFIG_440EP) || defined(CONFIG_440EPX) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 59 | #define ohci_cpu_to_le16(x) (x) |
| 60 | #define ohci_cpu_to_le32(x) (x) |
| 61 | #else |
| 62 | #define ohci_cpu_to_le16(x) swap_16(x) |
| 63 | #define ohci_cpu_to_le32(x) swap_32(x) |
| 64 | #endif |
| 65 | |
| 66 | /* global ohci_t */ |
| 67 | static ohci_t gohci; |
| 68 | /* this must be aligned to a 256 byte boundary */ |
| 69 | struct ohci_hcca ghcca[1]; |
| 70 | /* a pointer to the aligned storage */ |
| 71 | struct ohci_hcca *phcca; |
| 72 | /* this allocates EDs for all possible endpoints */ |
| 73 | struct ohci_device ohci_dev; |
| 74 | /* urb_priv */ |
| 75 | urb_priv_t urb_priv; |
| 76 | /* RHSC flag */ |
| 77 | int got_rhsc; |
| 78 | /* device which was disconnected */ |
| 79 | struct usb_device *devgone; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 80 | /* flag guarding URB transation */ |
| 81 | int urb_finished = 0; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 82 | |
| 83 | /*-------------------------------------------------------------------------*/ |
| 84 | |
| 85 | /* AMD-756 (D2 rev) reports corrupt register contents in some cases. |
| 86 | * The erratum (#4) description is incorrect. AMD's workaround waits |
| 87 | * till some bits (mostly reserved) are clear; ok for all revs. |
| 88 | */ |
| 89 | #define OHCI_QUIRK_AMD756 0xabcd |
| 90 | #define read_roothub(hc, register, mask) ({ \ |
| 91 | u32 temp = readl (&hc->regs->roothub.register); \ |
| 92 | if (hc->flags & OHCI_QUIRK_AMD756) \ |
| 93 | while (temp & mask) \ |
| 94 | temp = readl (&hc->regs->roothub.register); \ |
| 95 | temp; }) |
| 96 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 97 | static u32 roothub_a (struct ohci *hc) |
| 98 | { return read_roothub (hc, a, 0xfc0fe000); } |
| 99 | static inline u32 roothub_b (struct ohci *hc) |
| 100 | { return readl (&hc->regs->roothub.b); } |
| 101 | static inline u32 roothub_status (struct ohci *hc) |
| 102 | { return readl (&hc->regs->roothub.status); } |
| 103 | static u32 roothub_portstatus (struct ohci *hc, int i) |
| 104 | { return read_roothub (hc, portstatus [i], 0xffe0fce0); } |
| 105 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 106 | |
| 107 | /* forward declaration */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 108 | static int hc_interrupt (void); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 109 | static void |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 110 | td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer, |
| 111 | int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 112 | |
| 113 | /*-------------------------------------------------------------------------* |
| 114 | * URB support functions |
| 115 | *-------------------------------------------------------------------------*/ |
| 116 | |
| 117 | /* free HCD-private data associated with this URB */ |
| 118 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 119 | static void urb_free_priv (urb_priv_t * urb) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 120 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 121 | int i; |
| 122 | int last; |
| 123 | struct td * td; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 124 | |
| 125 | last = urb->length - 1; |
| 126 | if (last >= 0) { |
| 127 | for (i = 0; i <= last; i++) { |
| 128 | td = urb->td[i]; |
| 129 | if (td) { |
| 130 | td->usb_dev = NULL; |
| 131 | urb->td[i] = NULL; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /*-------------------------------------------------------------------------*/ |
| 138 | |
| 139 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 140 | static int sohci_get_current_frame_number (struct usb_device * dev); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 141 | |
| 142 | /* debug| print the main components of an URB |
| 143 | * small: 0) header + data packets 1) just header */ |
| 144 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 145 | static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer, |
| 146 | int transfer_len, struct devrequest * setup, char * str, int small) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 147 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 148 | urb_priv_t * purb = &urb_priv; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 149 | |
| 150 | dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 151 | str, |
| 152 | sohci_get_current_frame_number (dev), |
| 153 | usb_pipedevice (pipe), |
| 154 | usb_pipeendpoint (pipe), |
| 155 | usb_pipeout (pipe)? 'O': 'I', |
| 156 | usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"): |
| 157 | (usb_pipecontrol (pipe)? "CTRL": "BULK"), |
| 158 | purb->actual_length, |
| 159 | transfer_len, dev->status); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 160 | #ifdef OHCI_VERBOSE_DEBUG |
| 161 | if (!small) { |
| 162 | int i, len; |
| 163 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 164 | if (usb_pipecontrol (pipe)) { |
| 165 | printf (__FILE__ ": cmd(8):"); |
| 166 | for (i = 0; i < 8 ; i++) |
| 167 | printf (" %02x", ((__u8 *) setup) [i]); |
| 168 | printf ("\n"); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 169 | } |
| 170 | if (transfer_len > 0 && buffer) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 171 | printf (__FILE__ ": data(%d/%d):", |
| 172 | purb->actual_length, |
| 173 | transfer_len); |
| 174 | len = usb_pipeout (pipe)? |
| 175 | transfer_len: purb->actual_length; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 176 | for (i = 0; i < 16 && i < len; i++) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 177 | printf (" %02x", ((__u8 *) buffer) [i]); |
| 178 | printf ("%s\n", i < len? "...": ""); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | #endif |
| 182 | } |
| 183 | |
| 184 | /* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 185 | void ep_print_int_eds (ohci_t *ohci, char * str) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 186 | int i, j; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 187 | __u32 * ed_p; |
| 188 | for (i= 0; i < 32; i++) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 189 | j = 5; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 190 | ed_p = &(ohci->hcca->int_table [i]); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 191 | if (*ed_p == 0) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 192 | continue; |
| 193 | printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 194 | while (*ed_p != 0 && j--) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 195 | ed_t *ed = (ed_t *)ohci_cpu_to_le32(ed_p); |
| 196 | printf (" ed: %4x;", ed->hwINFO); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 197 | ed_p = &ed->hwNextED; |
| 198 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 199 | printf ("\n"); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 203 | static void ohci_dump_intr_mask (char *label, __u32 mask) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 204 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 205 | dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s", |
| 206 | label, |
| 207 | mask, |
| 208 | (mask & OHCI_INTR_MIE) ? " MIE" : "", |
| 209 | (mask & OHCI_INTR_OC) ? " OC" : "", |
| 210 | (mask & OHCI_INTR_RHSC) ? " RHSC" : "", |
| 211 | (mask & OHCI_INTR_FNO) ? " FNO" : "", |
| 212 | (mask & OHCI_INTR_UE) ? " UE" : "", |
| 213 | (mask & OHCI_INTR_RD) ? " RD" : "", |
| 214 | (mask & OHCI_INTR_SF) ? " SF" : "", |
| 215 | (mask & OHCI_INTR_WDH) ? " WDH" : "", |
| 216 | (mask & OHCI_INTR_SO) ? " SO" : "" |
| 217 | ); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 218 | } |
| 219 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 220 | static void maybe_print_eds (char *label, __u32 value) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 221 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 222 | ed_t *edp = (ed_t *)value; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 223 | |
| 224 | if (value) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 225 | dbg ("%s %08x", label, value); |
| 226 | dbg ("%08x", edp->hwINFO); |
| 227 | dbg ("%08x", edp->hwTailP); |
| 228 | dbg ("%08x", edp->hwHeadP); |
| 229 | dbg ("%08x", edp->hwNextED); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 233 | static char * hcfs2string (int state) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 234 | { |
| 235 | switch (state) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 236 | case OHCI_USB_RESET: return "reset"; |
| 237 | case OHCI_USB_RESUME: return "resume"; |
| 238 | case OHCI_USB_OPER: return "operational"; |
| 239 | case OHCI_USB_SUSPEND: return "suspend"; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 240 | } |
| 241 | return "?"; |
| 242 | } |
| 243 | |
| 244 | /* dump control and status registers */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 245 | static void ohci_dump_status (ohci_t *controller) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 246 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 247 | struct ohci_regs *regs = controller->regs; |
| 248 | __u32 temp; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 249 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 250 | temp = readl (®s->revision) & 0xff; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 251 | if (temp != 0x10) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 252 | dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 253 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 254 | temp = readl (®s->control); |
| 255 | dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp, |
| 256 | (temp & OHCI_CTRL_RWE) ? " RWE" : "", |
| 257 | (temp & OHCI_CTRL_RWC) ? " RWC" : "", |
| 258 | (temp & OHCI_CTRL_IR) ? " IR" : "", |
| 259 | hcfs2string (temp & OHCI_CTRL_HCFS), |
| 260 | (temp & OHCI_CTRL_BLE) ? " BLE" : "", |
| 261 | (temp & OHCI_CTRL_CLE) ? " CLE" : "", |
| 262 | (temp & OHCI_CTRL_IE) ? " IE" : "", |
| 263 | (temp & OHCI_CTRL_PLE) ? " PLE" : "", |
| 264 | temp & OHCI_CTRL_CBSR |
| 265 | ); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 266 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 267 | temp = readl (®s->cmdstatus); |
| 268 | dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp, |
| 269 | (temp & OHCI_SOC) >> 16, |
| 270 | (temp & OHCI_OCR) ? " OCR" : "", |
| 271 | (temp & OHCI_BLF) ? " BLF" : "", |
| 272 | (temp & OHCI_CLF) ? " CLF" : "", |
| 273 | (temp & OHCI_HCR) ? " HCR" : "" |
| 274 | ); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 275 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 276 | ohci_dump_intr_mask ("intrstatus", readl (®s->intrstatus)); |
| 277 | ohci_dump_intr_mask ("intrenable", readl (®s->intrenable)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 278 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 279 | maybe_print_eds ("ed_periodcurrent", readl (®s->ed_periodcurrent)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 280 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 281 | maybe_print_eds ("ed_controlhead", readl (®s->ed_controlhead)); |
| 282 | maybe_print_eds ("ed_controlcurrent", readl (®s->ed_controlcurrent)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 283 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 284 | maybe_print_eds ("ed_bulkhead", readl (®s->ed_bulkhead)); |
| 285 | maybe_print_eds ("ed_bulkcurrent", readl (®s->ed_bulkcurrent)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 286 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 287 | maybe_print_eds ("donehead", readl (®s->donehead)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 288 | } |
| 289 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 290 | static void ohci_dump_roothub (ohci_t *controller, int verbose) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 291 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 292 | __u32 temp, ndp, i; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 293 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 294 | temp = roothub_a (controller); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 295 | ndp = (temp & RH_A_NDP); |
| 296 | |
| 297 | if (verbose) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 298 | dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp, |
| 299 | ((temp & RH_A_POTPGT) >> 24) & 0xff, |
| 300 | (temp & RH_A_NOCP) ? " NOCP" : "", |
| 301 | (temp & RH_A_OCPM) ? " OCPM" : "", |
| 302 | (temp & RH_A_DT) ? " DT" : "", |
| 303 | (temp & RH_A_NPS) ? " NPS" : "", |
| 304 | (temp & RH_A_PSM) ? " PSM" : "", |
| 305 | ndp |
| 306 | ); |
| 307 | temp = roothub_b (controller); |
| 308 | dbg ("roothub.b: %08x PPCM=%04x DR=%04x", |
| 309 | temp, |
| 310 | (temp & RH_B_PPCM) >> 16, |
| 311 | (temp & RH_B_DR) |
| 312 | ); |
| 313 | temp = roothub_status (controller); |
| 314 | dbg ("roothub.status: %08x%s%s%s%s%s%s", |
| 315 | temp, |
| 316 | (temp & RH_HS_CRWE) ? " CRWE" : "", |
| 317 | (temp & RH_HS_OCIC) ? " OCIC" : "", |
| 318 | (temp & RH_HS_LPSC) ? " LPSC" : "", |
| 319 | (temp & RH_HS_DRWE) ? " DRWE" : "", |
| 320 | (temp & RH_HS_OCI) ? " OCI" : "", |
| 321 | (temp & RH_HS_LPS) ? " LPS" : "" |
| 322 | ); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | for (i = 0; i < ndp; i++) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 326 | temp = roothub_portstatus (controller, i); |
| 327 | dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s", |
| 328 | i, |
| 329 | temp, |
| 330 | (temp & RH_PS_PRSC) ? " PRSC" : "", |
| 331 | (temp & RH_PS_OCIC) ? " OCIC" : "", |
| 332 | (temp & RH_PS_PSSC) ? " PSSC" : "", |
| 333 | (temp & RH_PS_PESC) ? " PESC" : "", |
| 334 | (temp & RH_PS_CSC) ? " CSC" : "", |
| 335 | |
| 336 | (temp & RH_PS_LSDA) ? " LSDA" : "", |
| 337 | (temp & RH_PS_PPS) ? " PPS" : "", |
| 338 | (temp & RH_PS_PRS) ? " PRS" : "", |
| 339 | (temp & RH_PS_POCI) ? " POCI" : "", |
| 340 | (temp & RH_PS_PSS) ? " PSS" : "", |
| 341 | |
| 342 | (temp & RH_PS_PES) ? " PES" : "", |
| 343 | (temp & RH_PS_CCS) ? " CCS" : "" |
| 344 | ); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 348 | static void ohci_dump (ohci_t *controller, int verbose) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 349 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 350 | dbg ("OHCI controller usb-%s state", controller->slot_name); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 351 | |
| 352 | /* dumps some of the state we know about */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 353 | ohci_dump_status (controller); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 354 | if (verbose) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 355 | ep_print_int_eds (controller, "hcca"); |
| 356 | dbg ("hcca frame #%04x", controller->hcca->frame_no); |
| 357 | ohci_dump_roothub (controller, 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 358 | } |
| 359 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 360 | |
| 361 | #endif /* DEBUG */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 362 | |
| 363 | /*-------------------------------------------------------------------------* |
| 364 | * Interface functions (URB) |
| 365 | *-------------------------------------------------------------------------*/ |
| 366 | |
| 367 | /* get a transfer request */ |
| 368 | |
| 369 | int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 370 | int transfer_len, struct devrequest *setup, int interval) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 371 | { |
| 372 | ohci_t *ohci; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 373 | ed_t * ed; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 374 | urb_priv_t *purb_priv; |
| 375 | int i, size = 0; |
| 376 | |
| 377 | ohci = &gohci; |
| 378 | |
| 379 | /* when controller's hung, permit only roothub cleanup attempts |
| 380 | * such as powering down ports */ |
| 381 | if (ohci->disabled) { |
| 382 | err("sohci_submit_job: EPIPE"); |
| 383 | return -1; |
| 384 | } |
| 385 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 386 | /* if we have an unfinished URB from previous transaction let's |
| 387 | * fail and scream as quickly as possible so as not to corrupt |
| 388 | * further communication */ |
| 389 | if (!urb_finished) { |
| 390 | err("sohci_submit_job: URB NOT FINISHED"); |
| 391 | return -1; |
| 392 | } |
| 393 | /* we're about to begin a new transaction here so mark the URB unfinished */ |
| 394 | urb_finished = 0; |
| 395 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 396 | /* every endpoint has a ed, locate and fill it */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 397 | if (!(ed = ep_add_ed (dev, pipe))) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 398 | err("sohci_submit_job: ENOMEM"); |
| 399 | return -1; |
| 400 | } |
| 401 | |
| 402 | /* for the private part of the URB we need the number of TDs (size) */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 403 | switch (usb_pipetype (pipe)) { |
| 404 | case PIPE_BULK: /* one TD for every 4096 Byte */ |
| 405 | size = (transfer_len - 1) / 4096 + 1; |
| 406 | break; |
| 407 | case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */ |
| 408 | size = (transfer_len == 0)? 2: |
| 409 | (transfer_len - 1) / 4096 + 3; |
| 410 | break; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | if (size >= (N_URB_TD - 1)) { |
| 414 | err("need %d TDs, only have %d", size, N_URB_TD); |
| 415 | return -1; |
| 416 | } |
| 417 | purb_priv = &urb_priv; |
| 418 | purb_priv->pipe = pipe; |
| 419 | |
| 420 | /* fill the private part of the URB */ |
| 421 | purb_priv->length = size; |
| 422 | purb_priv->ed = ed; |
| 423 | purb_priv->actual_length = 0; |
| 424 | |
| 425 | /* allocate the TDs */ |
| 426 | /* note that td[0] was allocated in ep_add_ed */ |
| 427 | for (i = 0; i < size; i++) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 428 | purb_priv->td[i] = td_alloc (dev); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 429 | if (!purb_priv->td[i]) { |
| 430 | purb_priv->length = i; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 431 | urb_free_priv (purb_priv); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 432 | err("sohci_submit_job: ENOMEM"); |
| 433 | return -1; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | if (ed->state == ED_NEW || (ed->state & ED_DEL)) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 438 | urb_free_priv (purb_priv); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 439 | err("sohci_submit_job: EINVAL"); |
| 440 | return -1; |
| 441 | } |
| 442 | |
| 443 | /* link the ed into a chain if is not already */ |
| 444 | if (ed->state != ED_OPER) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 445 | ep_link (ohci, ed); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 446 | |
| 447 | /* fill the TDs and link it to the ed */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 448 | td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | /*-------------------------------------------------------------------------*/ |
| 454 | |
| 455 | #ifdef DEBUG |
| 456 | /* tell us the current USB frame number */ |
| 457 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 458 | static int sohci_get_current_frame_number (struct usb_device *usb_dev) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 459 | { |
| 460 | ohci_t *ohci = &gohci; |
| 461 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 462 | return ohci_cpu_to_le16 (ohci->hcca->frame_no); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 463 | } |
| 464 | #endif |
| 465 | |
| 466 | /*-------------------------------------------------------------------------* |
| 467 | * ED handling functions |
| 468 | *-------------------------------------------------------------------------*/ |
| 469 | |
| 470 | /* link an ed into one of the HC chains */ |
| 471 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 472 | static int ep_link (ohci_t *ohci, ed_t *edi) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 473 | { |
| 474 | volatile ed_t *ed = edi; |
| 475 | |
| 476 | ed->state = ED_OPER; |
| 477 | |
| 478 | switch (ed->type) { |
| 479 | case PIPE_CONTROL: |
| 480 | ed->hwNextED = 0; |
| 481 | if (ohci->ed_controltail == NULL) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 482 | writel (ed, &ohci->regs->ed_controlhead); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 483 | } else { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 484 | ohci->ed_controltail->hwNextED = ohci_cpu_to_le32 ((unsigned long)ed); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 485 | } |
| 486 | ed->ed_prev = ohci->ed_controltail; |
| 487 | if (!ohci->ed_controltail && !ohci->ed_rm_list[0] && |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 488 | !ohci->ed_rm_list[1] && !ohci->sleeping) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 489 | ohci->hc_control |= OHCI_CTRL_CLE; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 490 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 491 | } |
| 492 | ohci->ed_controltail = edi; |
| 493 | break; |
| 494 | |
| 495 | case PIPE_BULK: |
| 496 | ed->hwNextED = 0; |
| 497 | if (ohci->ed_bulktail == NULL) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 498 | writel (ed, &ohci->regs->ed_bulkhead); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 499 | } else { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 500 | ohci->ed_bulktail->hwNextED = ohci_cpu_to_le32 ((unsigned long)ed); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 501 | } |
| 502 | ed->ed_prev = ohci->ed_bulktail; |
| 503 | if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] && |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 504 | !ohci->ed_rm_list[1] && !ohci->sleeping) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 505 | ohci->hc_control |= OHCI_CTRL_BLE; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 506 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 507 | } |
| 508 | ohci->ed_bulktail = edi; |
| 509 | break; |
| 510 | } |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | /*-------------------------------------------------------------------------*/ |
| 515 | |
| 516 | /* unlink an ed from one of the HC chains. |
| 517 | * just the link to the ed is unlinked. |
| 518 | * the link from the ed still points to another operational ed or 0 |
| 519 | * so the HC can eventually finish the processing of the unlinked ed */ |
| 520 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 521 | static int ep_unlink (ohci_t *ohci, ed_t *edi) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 522 | { |
| 523 | volatile ed_t *ed = edi; |
| 524 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 525 | ed->hwINFO |= ohci_cpu_to_le32 (OHCI_ED_SKIP); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 526 | |
| 527 | switch (ed->type) { |
| 528 | case PIPE_CONTROL: |
| 529 | if (ed->ed_prev == NULL) { |
| 530 | if (!ed->hwNextED) { |
| 531 | ohci->hc_control &= ~OHCI_CTRL_CLE; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 532 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 533 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 534 | writel (ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 535 | } else { |
| 536 | ed->ed_prev->hwNextED = ed->hwNextED; |
| 537 | } |
| 538 | if (ohci->ed_controltail == ed) { |
| 539 | ohci->ed_controltail = ed->ed_prev; |
| 540 | } else { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 541 | ((ed_t *)ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 542 | } |
| 543 | break; |
| 544 | |
| 545 | case PIPE_BULK: |
| 546 | if (ed->ed_prev == NULL) { |
| 547 | if (!ed->hwNextED) { |
| 548 | ohci->hc_control &= ~OHCI_CTRL_BLE; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 549 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 550 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 551 | writel (ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 552 | } else { |
| 553 | ed->ed_prev->hwNextED = ed->hwNextED; |
| 554 | } |
| 555 | if (ohci->ed_bulktail == ed) { |
| 556 | ohci->ed_bulktail = ed->ed_prev; |
| 557 | } else { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 558 | ((ed_t *)ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 559 | } |
| 560 | break; |
| 561 | } |
| 562 | ed->state = ED_UNLINK; |
| 563 | return 0; |
| 564 | } |
| 565 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 566 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 567 | /*-------------------------------------------------------------------------*/ |
| 568 | |
| 569 | /* add/reinit an endpoint; this should be done once at the usb_set_configuration command, |
| 570 | * but the USB stack is a little bit stateless so we do it at every transaction |
| 571 | * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK |
| 572 | * in all other cases the state is left unchanged |
| 573 | * the ed info fields are setted anyway even though most of them should not change */ |
| 574 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 575 | static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 576 | { |
| 577 | td_t *td; |
| 578 | ed_t *ed_ret; |
| 579 | volatile ed_t *ed; |
| 580 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 581 | ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) | |
| 582 | (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))]; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 583 | |
| 584 | if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) { |
| 585 | err("ep_add_ed: pending delete"); |
| 586 | /* pending delete request */ |
| 587 | return NULL; |
| 588 | } |
| 589 | |
| 590 | if (ed->state == ED_NEW) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 591 | ed->hwINFO = ohci_cpu_to_le32 (OHCI_ED_SKIP); /* skip ed */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 592 | /* dummy td; end of td list for ed */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 593 | td = td_alloc (usb_dev); |
| 594 | ed->hwTailP = ohci_cpu_to_le32 ((unsigned long)td); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 595 | ed->hwHeadP = ed->hwTailP; |
| 596 | ed->state = ED_UNLINK; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 597 | ed->type = usb_pipetype (pipe); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 598 | ohci_dev.ed_cnt++; |
| 599 | } |
| 600 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 601 | ed->hwINFO = ohci_cpu_to_le32 (usb_pipedevice (pipe) |
| 602 | | usb_pipeendpoint (pipe) << 7 |
| 603 | | (usb_pipeisoc (pipe)? 0x8000: 0) |
| 604 | | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000)) |
Ilya Yanok | a1cf10f | 2012-11-06 13:48:20 +0000 | [diff] [blame] | 605 | | (usb_dev->speed == USB_SPEED_LOW) << 13 |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 606 | | usb_maxpacket (usb_dev, pipe) << 16); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 607 | |
| 608 | return ed_ret; |
| 609 | } |
| 610 | |
| 611 | /*-------------------------------------------------------------------------* |
| 612 | * TD handling functions |
| 613 | *-------------------------------------------------------------------------*/ |
| 614 | |
| 615 | /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */ |
| 616 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 617 | static void td_fill (ohci_t *ohci, unsigned int info, |
| 618 | void *data, int len, |
| 619 | struct usb_device *dev, int index, urb_priv_t *urb_priv) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 620 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 621 | volatile td_t *td, *td_pt; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 622 | #ifdef OHCI_FILL_TRACE |
| 623 | int i; |
| 624 | #endif |
| 625 | |
| 626 | if (index > urb_priv->length) { |
| 627 | err("index > length"); |
| 628 | return; |
| 629 | } |
| 630 | /* use this td as the next dummy */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 631 | td_pt = urb_priv->td [index]; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 632 | td_pt->hwNextTD = 0; |
| 633 | |
| 634 | /* fill the old dummy TD */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 635 | td = urb_priv->td [index] = (td_t *)(ohci_cpu_to_le32 (urb_priv->ed->hwTailP) & ~0xf); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 636 | |
| 637 | td->ed = urb_priv->ed; |
| 638 | td->next_dl_td = NULL; |
| 639 | td->index = index; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 640 | td->data = (__u32)data; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 641 | #ifdef OHCI_FILL_TRACE |
Remy Bohmer | d8c55ab | 2008-10-10 10:23:22 +0200 | [diff] [blame] | 642 | if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 643 | for (i = 0; i < len; i++) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 644 | printf("td->data[%d] %#2x ",i, ((unsigned char *)td->data)[i]); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 645 | printf("\n"); |
| 646 | } |
| 647 | #endif |
| 648 | if (!len) |
| 649 | data = 0; |
| 650 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 651 | td->hwINFO = ohci_cpu_to_le32 (info); |
| 652 | td->hwCBP = ohci_cpu_to_le32 ((unsigned long)data); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 653 | if (data) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 654 | td->hwBE = ohci_cpu_to_le32 ((unsigned long)(data + len - 1)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 655 | else |
| 656 | td->hwBE = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 657 | td->hwNextTD = ohci_cpu_to_le32 ((unsigned long)td_pt); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 658 | |
| 659 | /* append to queue */ |
| 660 | td->ed->hwTailP = td->hwNextTD; |
| 661 | } |
| 662 | |
| 663 | /*-------------------------------------------------------------------------*/ |
| 664 | |
| 665 | /* prepare all TDs of a transfer */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 666 | static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer, |
| 667 | int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 668 | { |
| 669 | ohci_t *ohci = &gohci; |
| 670 | int data_len = transfer_len; |
| 671 | void *data; |
| 672 | int cnt = 0; |
| 673 | __u32 info = 0; |
| 674 | unsigned int toggle = 0; |
| 675 | |
| 676 | /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 677 | if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 678 | toggle = TD_T_TOGGLE; |
| 679 | } else { |
| 680 | toggle = TD_T_DATA0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 681 | usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 682 | } |
| 683 | urb->td_cnt = 0; |
| 684 | if (data_len) |
| 685 | data = buffer; |
| 686 | else |
| 687 | data = 0; |
| 688 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 689 | switch (usb_pipetype (pipe)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 690 | case PIPE_BULK: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 691 | info = usb_pipeout (pipe)? |
| 692 | TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ; |
| 693 | while(data_len > 4096) { |
| 694 | td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb); |
| 695 | data += 4096; data_len -= 4096; cnt++; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 696 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 697 | info = usb_pipeout (pipe)? |
| 698 | TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ; |
| 699 | td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 700 | cnt++; |
| 701 | |
| 702 | if (!ohci->sleeping) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 703 | writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 704 | break; |
| 705 | |
| 706 | case PIPE_CONTROL: |
| 707 | info = TD_CC | TD_DP_SETUP | TD_T_DATA0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 708 | td_fill (ohci, info, setup, 8, dev, cnt++, urb); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 709 | if (data_len > 0) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 710 | info = usb_pipeout (pipe)? |
| 711 | TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 712 | /* NOTE: mishandles transfers >8K, some >4K */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 713 | td_fill (ohci, info, data, data_len, dev, cnt++, urb); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 714 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 715 | info = usb_pipeout (pipe)? |
| 716 | TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1; |
| 717 | td_fill (ohci, info, data, 0, dev, cnt++, urb); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 718 | if (!ohci->sleeping) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 719 | writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 720 | break; |
| 721 | } |
| 722 | if (urb->length != cnt) |
| 723 | dbg("TD LENGTH %d != CNT %d", urb->length, cnt); |
| 724 | } |
| 725 | |
| 726 | /*-------------------------------------------------------------------------* |
| 727 | * Done List handling functions |
| 728 | *-------------------------------------------------------------------------*/ |
| 729 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 730 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 731 | /* calculate the transfer length and update the urb */ |
| 732 | |
| 733 | static void dl_transfer_length(td_t * td) |
| 734 | { |
Stefan Roese | bc114cc | 2011-11-15 08:01:45 +0000 | [diff] [blame] | 735 | __u32 tdBE, tdCBP; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 736 | urb_priv_t *lurb_priv = &urb_priv; |
| 737 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 738 | tdBE = ohci_cpu_to_le32 (td->hwBE); |
| 739 | tdCBP = ohci_cpu_to_le32 (td->hwCBP); |
| 740 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 741 | |
Remy Bohmer | d8c55ab | 2008-10-10 10:23:22 +0200 | [diff] [blame] | 742 | if (!(usb_pipecontrol(lurb_priv->pipe) && |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 743 | ((td->index == 0) || (td->index == lurb_priv->length - 1)))) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 744 | if (tdBE != 0) { |
| 745 | if (td->hwCBP == 0) |
| 746 | lurb_priv->actual_length += tdBE - td->data + 1; |
| 747 | else |
| 748 | lurb_priv->actual_length += tdCBP - td->data; |
| 749 | } |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | /*-------------------------------------------------------------------------*/ |
| 754 | |
| 755 | /* replies to the request have to be on a FIFO basis so |
| 756 | * we reverse the reversed done-list */ |
| 757 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 758 | static td_t * dl_reverse_done_list (ohci_t *ohci) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 759 | { |
| 760 | __u32 td_list_hc; |
| 761 | td_t *td_rev = NULL; |
| 762 | td_t *td_list = NULL; |
| 763 | urb_priv_t *lurb_priv = NULL; |
| 764 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 765 | td_list_hc = ohci_cpu_to_le32 (ohci->hcca->done_head) & 0xfffffff0; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 766 | ohci->hcca->done_head = 0; |
| 767 | |
| 768 | while (td_list_hc) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 769 | td_list = (td_t *)td_list_hc; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 770 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 771 | if (TD_CC_GET (ohci_cpu_to_le32 (td_list->hwINFO))) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 772 | lurb_priv = &urb_priv; |
| 773 | dbg(" USB-error/status: %x : %p", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 774 | TD_CC_GET (ohci_cpu_to_le32 (td_list->hwINFO)), td_list); |
| 775 | if (td_list->ed->hwHeadP & ohci_cpu_to_le32 (0x1)) { |
| 776 | if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 777 | td_list->ed->hwHeadP = |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 778 | (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & ohci_cpu_to_le32 (0xfffffff0)) | |
| 779 | (td_list->ed->hwHeadP & ohci_cpu_to_le32 (0x2)); |
| 780 | lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 781 | } else |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 782 | td_list->ed->hwHeadP &= ohci_cpu_to_le32 (0xfffffff2); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 783 | } |
| 784 | #ifdef CONFIG_MPC5200 |
| 785 | td_list->hwNextTD = 0; |
| 786 | #endif |
| 787 | } |
| 788 | |
| 789 | td_list->next_dl_td = td_rev; |
| 790 | td_rev = td_list; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 791 | td_list_hc = ohci_cpu_to_le32 (td_list->hwNextTD) & 0xfffffff0; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 792 | } |
| 793 | return td_list; |
| 794 | } |
| 795 | |
| 796 | /*-------------------------------------------------------------------------*/ |
| 797 | |
| 798 | /* td done list */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 799 | static int dl_done_list (ohci_t *ohci, td_t *td_list) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 800 | { |
| 801 | td_t *td_list_next = NULL; |
| 802 | ed_t *ed; |
| 803 | int cc = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 804 | int stat = 0; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 805 | /* urb_t *urb; */ |
| 806 | urb_priv_t *lurb_priv; |
| 807 | __u32 tdINFO, edHeadP, edTailP; |
| 808 | |
| 809 | while (td_list) { |
| 810 | td_list_next = td_list->next_dl_td; |
| 811 | |
| 812 | lurb_priv = &urb_priv; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 813 | tdINFO = ohci_cpu_to_le32 (td_list->hwINFO); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 814 | |
| 815 | ed = td_list->ed; |
| 816 | |
| 817 | dl_transfer_length(td_list); |
| 818 | |
| 819 | /* error code of transfer */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 820 | cc = TD_CC_GET (tdINFO); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 821 | if (++(lurb_priv->td_cnt) == lurb_priv->length) { |
| 822 | if ((ed->state & (ED_OPER | ED_UNLINK)) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 823 | && (lurb_priv->state != URB_DEL)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 824 | dbg("ConditionCode %#x", cc); |
| 825 | stat = cc_to_error[cc]; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 826 | urb_finished = 1; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 827 | } |
| 828 | } |
| 829 | |
| 830 | if (ed->state != ED_NEW) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 831 | edHeadP = ohci_cpu_to_le32 (ed->hwHeadP) & 0xfffffff0; |
| 832 | edTailP = ohci_cpu_to_le32 (ed->hwTailP); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 833 | |
| 834 | /* unlink eds if they are not busy */ |
| 835 | if ((edHeadP == edTailP) && (ed->state == ED_OPER)) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 836 | ep_unlink (ohci, ed); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | td_list = td_list_next; |
| 840 | } |
| 841 | return stat; |
| 842 | } |
| 843 | |
| 844 | /*-------------------------------------------------------------------------* |
| 845 | * Virtual Root Hub |
| 846 | *-------------------------------------------------------------------------*/ |
| 847 | |
Stephen Warren | 39c8968 | 2014-02-13 21:15:18 -0700 | [diff] [blame] | 848 | #include <usbroothubdes.h> |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 849 | |
| 850 | /* Hub class-specific descriptor is constructed dynamically */ |
| 851 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 852 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 853 | /*-------------------------------------------------------------------------*/ |
| 854 | |
| 855 | #define OK(x) len = (x); break |
| 856 | #ifdef DEBUG |
| 857 | #define WR_RH_STAT(x) {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);} |
| 858 | #define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);} |
| 859 | #else |
| 860 | #define WR_RH_STAT(x) writel((x), &gohci.regs->roothub.status) |
| 861 | #define WR_RH_PORTSTAT(x) writel((x), &gohci.regs->roothub.portstatus[wIndex-1]) |
| 862 | #endif |
| 863 | #define RD_RH_STAT roothub_status(&gohci) |
| 864 | #define RD_RH_PORTSTAT roothub_portstatus(&gohci,wIndex-1) |
| 865 | |
| 866 | /* request to virtual root hub */ |
| 867 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 868 | int rh_check_port_status(ohci_t *controller) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 869 | { |
| 870 | __u32 temp, ndp, i; |
| 871 | int res; |
| 872 | |
| 873 | res = -1; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 874 | temp = roothub_a (controller); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 875 | ndp = (temp & RH_A_NDP); |
| 876 | for (i = 0; i < ndp; i++) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 877 | temp = roothub_portstatus (controller, i); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 878 | /* check for a device disconnect */ |
| 879 | if (((temp & (RH_PS_PESC | RH_PS_CSC)) == |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 880 | (RH_PS_PESC | RH_PS_CSC)) && |
| 881 | ((temp & RH_PS_CCS) == 0)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 882 | res = i; |
| 883 | break; |
| 884 | } |
| 885 | } |
| 886 | return res; |
| 887 | } |
| 888 | |
| 889 | static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 890 | void *buffer, int transfer_len, struct devrequest *cmd) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 891 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 892 | void * data = buffer; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 893 | int leni = transfer_len; |
| 894 | int len = 0; |
| 895 | int stat = 0; |
| 896 | __u32 datab[4]; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 897 | __u8 *data_buf = (__u8 *)datab; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 898 | __u16 bmRType_bReq; |
| 899 | __u16 wValue; |
| 900 | __u16 wIndex; |
| 901 | __u16 wLength; |
| 902 | |
| 903 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 904 | urb_priv.actual_length = 0; |
| 905 | pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 906 | #endif |
Remy Bohmer | d8c55ab | 2008-10-10 10:23:22 +0200 | [diff] [blame] | 907 | if (usb_pipeint(pipe)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 908 | info("Root-Hub submit IRQ: NOT implemented"); |
| 909 | return 0; |
| 910 | } |
| 911 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 912 | bmRType_bReq = cmd->requesttype | (cmd->request << 8); |
| 913 | wValue = m16_swap (cmd->value); |
| 914 | wIndex = m16_swap (cmd->index); |
| 915 | wLength = m16_swap (cmd->length); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 916 | |
| 917 | info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 918 | dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 919 | |
| 920 | switch (bmRType_bReq) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 921 | /* Request Destination: |
| 922 | without flags: Device, |
| 923 | RH_INTERFACE: interface, |
| 924 | RH_ENDPOINT: endpoint, |
| 925 | RH_CLASS means HUB here, |
| 926 | RH_OTHER | RH_CLASS almost ever means HUB_PORT here |
| 927 | */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 928 | |
| 929 | case RH_GET_STATUS: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 930 | *(__u16 *) data_buf = m16_swap (1); OK (2); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 931 | case RH_GET_STATUS | RH_INTERFACE: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 932 | *(__u16 *) data_buf = m16_swap (0); OK (2); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 933 | case RH_GET_STATUS | RH_ENDPOINT: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 934 | *(__u16 *) data_buf = m16_swap (0); OK (2); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 935 | case RH_GET_STATUS | RH_CLASS: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 936 | *(__u32 *) data_buf = m32_swap ( |
| 937 | RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE)); |
| 938 | OK (4); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 939 | case RH_GET_STATUS | RH_OTHER | RH_CLASS: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 940 | *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 941 | |
| 942 | case RH_CLEAR_FEATURE | RH_ENDPOINT: |
| 943 | switch (wValue) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 944 | case (RH_ENDPOINT_STALL): OK (0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 945 | } |
| 946 | break; |
| 947 | |
| 948 | case RH_CLEAR_FEATURE | RH_CLASS: |
| 949 | switch (wValue) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 950 | case RH_C_HUB_LOCAL_POWER: |
| 951 | OK(0); |
| 952 | case (RH_C_HUB_OVER_CURRENT): |
| 953 | WR_RH_STAT(RH_HS_OCIC); OK (0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 954 | } |
| 955 | break; |
| 956 | |
| 957 | case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS: |
| 958 | switch (wValue) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 959 | case (RH_PORT_ENABLE): |
| 960 | WR_RH_PORTSTAT (RH_PS_CCS ); OK (0); |
| 961 | case (RH_PORT_SUSPEND): |
| 962 | WR_RH_PORTSTAT (RH_PS_POCI); OK (0); |
| 963 | case (RH_PORT_POWER): |
| 964 | WR_RH_PORTSTAT (RH_PS_LSDA); OK (0); |
| 965 | case (RH_C_PORT_CONNECTION): |
| 966 | WR_RH_PORTSTAT (RH_PS_CSC ); OK (0); |
| 967 | case (RH_C_PORT_ENABLE): |
| 968 | WR_RH_PORTSTAT (RH_PS_PESC); OK (0); |
| 969 | case (RH_C_PORT_SUSPEND): |
| 970 | WR_RH_PORTSTAT (RH_PS_PSSC); OK (0); |
| 971 | case (RH_C_PORT_OVER_CURRENT): |
| 972 | WR_RH_PORTSTAT (RH_PS_OCIC); OK (0); |
| 973 | case (RH_C_PORT_RESET): |
| 974 | WR_RH_PORTSTAT (RH_PS_PRSC); OK (0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 975 | } |
| 976 | break; |
| 977 | |
| 978 | case RH_SET_FEATURE | RH_OTHER | RH_CLASS: |
| 979 | switch (wValue) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 980 | case (RH_PORT_SUSPEND): |
| 981 | WR_RH_PORTSTAT (RH_PS_PSS ); OK (0); |
| 982 | case (RH_PORT_RESET): /* BUG IN HUP CODE *********/ |
| 983 | if (RD_RH_PORTSTAT & RH_PS_CCS) |
| 984 | WR_RH_PORTSTAT (RH_PS_PRS); |
| 985 | OK (0); |
| 986 | case (RH_PORT_POWER): |
| 987 | WR_RH_PORTSTAT (RH_PS_PPS ); OK (0); |
| 988 | case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/ |
| 989 | if (RD_RH_PORTSTAT & RH_PS_CCS) |
| 990 | WR_RH_PORTSTAT (RH_PS_PES ); |
| 991 | OK (0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 992 | } |
| 993 | break; |
| 994 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 995 | case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 996 | |
| 997 | case RH_GET_DESCRIPTOR: |
| 998 | switch ((wValue & 0xff00) >> 8) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 999 | case (0x01): /* device descriptor */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1000 | len = min_t(unsigned int, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1001 | leni, |
| 1002 | min_t(unsigned int, |
| 1003 | sizeof (root_hub_dev_des), |
| 1004 | wLength)); |
| 1005 | data_buf = root_hub_dev_des; OK(len); |
| 1006 | case (0x02): /* configuration descriptor */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1007 | len = min_t(unsigned int, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1008 | leni, |
| 1009 | min_t(unsigned int, |
| 1010 | sizeof (root_hub_config_des), |
| 1011 | wLength)); |
| 1012 | data_buf = root_hub_config_des; OK(len); |
| 1013 | case (0x03): /* string descriptors */ |
| 1014 | if(wValue==0x0300) { |
| 1015 | len = min_t(unsigned int, |
| 1016 | leni, |
| 1017 | min_t(unsigned int, |
| 1018 | sizeof (root_hub_str_index0), |
| 1019 | wLength)); |
| 1020 | data_buf = root_hub_str_index0; |
| 1021 | OK(len); |
| 1022 | } |
| 1023 | if(wValue==0x0301) { |
| 1024 | len = min_t(unsigned int, |
| 1025 | leni, |
| 1026 | min_t(unsigned int, |
| 1027 | sizeof (root_hub_str_index1), |
| 1028 | wLength)); |
| 1029 | data_buf = root_hub_str_index1; |
| 1030 | OK(len); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1031 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1032 | default: |
| 1033 | stat = USB_ST_STALLED; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1034 | } |
| 1035 | break; |
| 1036 | |
| 1037 | case RH_GET_DESCRIPTOR | RH_CLASS: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1038 | { |
| 1039 | __u32 temp = roothub_a (&gohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1040 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1041 | data_buf [0] = 9; /* min length; */ |
| 1042 | data_buf [1] = 0x29; |
| 1043 | data_buf [2] = temp & RH_A_NDP; |
| 1044 | data_buf [3] = 0; |
| 1045 | if (temp & RH_A_PSM) /* per-port power switching? */ |
| 1046 | data_buf [3] |= 0x1; |
| 1047 | if (temp & RH_A_NOCP) /* no overcurrent reporting? */ |
| 1048 | data_buf [3] |= 0x10; |
| 1049 | else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */ |
| 1050 | data_buf [3] |= 0x8; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1051 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1052 | /* corresponds to data_buf[4-7] */ |
| 1053 | datab [1] = 0; |
| 1054 | data_buf [5] = (temp & RH_A_POTPGT) >> 24; |
| 1055 | temp = roothub_b (&gohci); |
| 1056 | data_buf [7] = temp & RH_B_DR; |
| 1057 | if (data_buf [2] < 7) { |
| 1058 | data_buf [8] = 0xff; |
| 1059 | } else { |
| 1060 | data_buf [0] += 2; |
| 1061 | data_buf [8] = (temp & RH_B_DR) >> 8; |
| 1062 | data_buf [10] = data_buf [9] = 0xff; |
| 1063 | } |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1064 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1065 | len = min_t(unsigned int, leni, |
| 1066 | min_t(unsigned int, data_buf [0], wLength)); |
| 1067 | OK (len); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1068 | } |
| 1069 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1070 | case RH_GET_CONFIGURATION: *(__u8 *) data_buf = 0x01; OK (1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1071 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1072 | case RH_SET_CONFIGURATION: WR_RH_STAT (0x10000); OK (0); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1073 | |
| 1074 | default: |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1075 | dbg ("unsupported root hub command"); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1076 | stat = USB_ST_STALLED; |
| 1077 | } |
| 1078 | |
| 1079 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1080 | ohci_dump_roothub (&gohci, 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1081 | #endif |
| 1082 | |
| 1083 | len = min_t(int, len, leni); |
| 1084 | if (data != data_buf) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1085 | memcpy (data, data_buf, len); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1086 | dev->act_len = len; |
| 1087 | dev->status = stat; |
| 1088 | |
| 1089 | #ifdef DEBUG |
| 1090 | if (transfer_len) |
| 1091 | urb_priv.actual_length = transfer_len; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1092 | pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1093 | #endif |
| 1094 | |
| 1095 | return stat; |
| 1096 | } |
| 1097 | |
| 1098 | /*-------------------------------------------------------------------------*/ |
| 1099 | |
| 1100 | /* common code for handling submit messages - used for all but root hub */ |
| 1101 | /* accesses. */ |
| 1102 | int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1103 | int transfer_len, struct devrequest *setup, int interval) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1104 | { |
| 1105 | int stat = 0; |
| 1106 | int maxsize = usb_maxpacket(dev, pipe); |
| 1107 | int timeout; |
| 1108 | |
| 1109 | /* device pulled? Shortcut the action. */ |
| 1110 | if (devgone == dev) { |
| 1111 | dev->status = USB_ST_CRC_ERR; |
| 1112 | return 0; |
| 1113 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1114 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1115 | #ifdef DEBUG |
| 1116 | urb_priv.actual_length = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1117 | pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1118 | #endif |
| 1119 | if (!maxsize) { |
| 1120 | err("submit_common_message: pipesize for pipe %lx is zero", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1121 | pipe); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1122 | return -1; |
| 1123 | } |
| 1124 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1125 | if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1126 | err("sohci_submit_job failed"); |
| 1127 | return -1; |
| 1128 | } |
| 1129 | |
| 1130 | /* allow more time for a BULK device to react - some are slow */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1131 | #define BULK_TO 5000 /* timeout in milliseconds */ |
Remy Bohmer | d8c55ab | 2008-10-10 10:23:22 +0200 | [diff] [blame] | 1132 | if (usb_pipebulk(pipe)) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1133 | timeout = BULK_TO; |
| 1134 | else |
| 1135 | timeout = 100; |
| 1136 | |
| 1137 | /* wait for it to complete */ |
| 1138 | for (;;) { |
| 1139 | /* check whether the controller is done */ |
| 1140 | stat = hc_interrupt(); |
| 1141 | if (stat < 0) { |
| 1142 | stat = USB_ST_CRC_ERR; |
| 1143 | break; |
| 1144 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1145 | |
| 1146 | /* NOTE: since we are not interrupt driven in U-Boot and always |
| 1147 | * handle only one URB at a time, we cannot assume the |
| 1148 | * transaction finished on the first successful return from |
| 1149 | * hc_interrupt().. unless the flag for current URB is set, |
| 1150 | * meaning that all TD's to/from device got actually |
| 1151 | * transferred and processed. If the current URB is not |
| 1152 | * finished we need to re-iterate this loop so as |
| 1153 | * hc_interrupt() gets called again as there needs to be some |
| 1154 | * more TD's to process still */ |
| 1155 | if ((stat >= 0) && (stat != 0xff) && (urb_finished)) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1156 | /* 0xff is returned for an SF-interrupt */ |
| 1157 | break; |
| 1158 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1159 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1160 | if (--timeout) { |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1161 | mdelay(1); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1162 | if (!urb_finished) |
| 1163 | dbg("\%"); |
| 1164 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1165 | } else { |
| 1166 | err("CTL:TIMEOUT "); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1167 | dbg("submit_common_msg: TO status %x\n", stat); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1168 | stat = USB_ST_CRC_ERR; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1169 | urb_finished = 1; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1170 | break; |
| 1171 | } |
| 1172 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1173 | #if 0 |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1174 | /* we got an Root Hub Status Change interrupt */ |
| 1175 | if (got_rhsc) { |
| 1176 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1177 | ohci_dump_roothub (&gohci, 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1178 | #endif |
| 1179 | got_rhsc = 0; |
| 1180 | /* abuse timeout */ |
| 1181 | timeout = rh_check_port_status(&gohci); |
| 1182 | if (timeout >= 0) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1183 | #if 0 /* this does nothing useful, but leave it here in case that changes */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1184 | /* the called routine adds 1 to the passed value */ |
| 1185 | usb_hub_port_connect_change(gohci.rh.dev, timeout - 1); |
| 1186 | #endif |
| 1187 | /* |
| 1188 | * XXX |
| 1189 | * This is potentially dangerous because it assumes |
| 1190 | * that only one device is ever plugged in! |
| 1191 | */ |
| 1192 | devgone = dev; |
| 1193 | } |
| 1194 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1195 | #endif |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1196 | |
| 1197 | dev->status = stat; |
| 1198 | dev->act_len = transfer_len; |
| 1199 | |
| 1200 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1201 | pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1202 | #endif |
| 1203 | |
| 1204 | /* free TDs in urb_priv */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1205 | urb_free_priv (&urb_priv); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1206 | return 0; |
| 1207 | } |
| 1208 | |
| 1209 | /* submit routines called from usb.c */ |
| 1210 | int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1211 | int transfer_len) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1212 | { |
| 1213 | info("submit_bulk_msg"); |
| 1214 | return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0); |
| 1215 | } |
| 1216 | |
| 1217 | int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1218 | int transfer_len, struct devrequest *setup) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1219 | { |
| 1220 | int maxsize = usb_maxpacket(dev, pipe); |
| 1221 | |
| 1222 | info("submit_control_msg"); |
| 1223 | #ifdef DEBUG |
| 1224 | urb_priv.actual_length = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1225 | pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1226 | #endif |
| 1227 | if (!maxsize) { |
| 1228 | err("submit_control_message: pipesize for pipe %lx is zero", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1229 | pipe); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1230 | return -1; |
| 1231 | } |
| 1232 | if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) { |
| 1233 | gohci.rh.dev = dev; |
| 1234 | /* root hub - redirect */ |
| 1235 | return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1236 | setup); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0); |
| 1240 | } |
| 1241 | |
| 1242 | int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1243 | int transfer_len, int interval) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1244 | { |
| 1245 | info("submit_int_msg"); |
| 1246 | return -1; |
| 1247 | } |
| 1248 | |
| 1249 | /*-------------------------------------------------------------------------* |
| 1250 | * HC functions |
| 1251 | *-------------------------------------------------------------------------*/ |
| 1252 | |
| 1253 | /* reset the HC and BUS */ |
| 1254 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1255 | static int hc_reset (ohci_t *ohci) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1256 | { |
| 1257 | int timeout = 30; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1258 | int smm_timeout = 50; /* 0,5 sec */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1259 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1260 | if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */ |
| 1261 | writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1262 | info("USB HC TakeOver from SMM"); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1263 | while (readl (&ohci->regs->control) & OHCI_CTRL_IR) { |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1264 | mdelay (10); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1265 | if (--smm_timeout == 0) { |
| 1266 | err("USB HC TakeOver failed!"); |
| 1267 | return -1; |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | /* Disable HC interrupts */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1273 | writel (OHCI_INTR_MIE, &ohci->regs->intrdisable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1274 | |
| 1275 | dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;", |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1276 | ohci->slot_name, |
| 1277 | readl (&ohci->regs->control)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1278 | |
| 1279 | /* Reset USB (needed by some controllers) */ |
| 1280 | ohci->hc_control = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1281 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1282 | |
| 1283 | /* HC Reset requires max 10 us delay */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1284 | writel (OHCI_HCR, &ohci->regs->cmdstatus); |
| 1285 | while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1286 | if (--timeout == 0) { |
| 1287 | err("USB HC reset timed out!"); |
| 1288 | return -1; |
| 1289 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1290 | udelay (1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1291 | } |
| 1292 | return 0; |
| 1293 | } |
| 1294 | |
| 1295 | /*-------------------------------------------------------------------------*/ |
| 1296 | |
| 1297 | /* Start an OHCI controller, set the BUS operational |
| 1298 | * enable interrupts |
| 1299 | * connect the virtual root hub */ |
| 1300 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1301 | static int hc_start (ohci_t * ohci) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1302 | { |
| 1303 | __u32 mask; |
| 1304 | unsigned int fminterval; |
| 1305 | |
| 1306 | ohci->disabled = 1; |
| 1307 | |
| 1308 | /* Tell the controller where the control and bulk lists are |
| 1309 | * The lists are empty now. */ |
| 1310 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1311 | writel (0, &ohci->regs->ed_controlhead); |
| 1312 | writel (0, &ohci->regs->ed_bulkhead); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1313 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1314 | writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1315 | |
| 1316 | fminterval = 0x2edf; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1317 | writel ((fminterval * 9) / 10, &ohci->regs->periodicstart); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1318 | fminterval |= ((((fminterval - 210) * 6) / 7) << 16); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1319 | writel (fminterval, &ohci->regs->fminterval); |
| 1320 | writel (0x628, &ohci->regs->lsthresh); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1321 | |
| 1322 | /* start controller operations */ |
| 1323 | ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; |
| 1324 | ohci->disabled = 0; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1325 | writel (ohci->hc_control, &ohci->regs->control); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1326 | |
| 1327 | /* disable all interrupts */ |
| 1328 | mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1329 | OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC | |
| 1330 | OHCI_INTR_OC | OHCI_INTR_MIE); |
| 1331 | writel (mask, &ohci->regs->intrdisable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1332 | /* clear all interrupts */ |
| 1333 | mask &= ~OHCI_INTR_MIE; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1334 | writel (mask, &ohci->regs->intrstatus); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1335 | /* Choose the interrupts we care about now - but w/o MIE */ |
| 1336 | mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1337 | writel (mask, &ohci->regs->intrenable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1338 | |
| 1339 | #ifdef OHCI_USE_NPS |
| 1340 | /* required for AMD-756 and some Mac platforms */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1341 | writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM, |
| 1342 | &ohci->regs->roothub.a); |
| 1343 | writel (RH_HS_LPSC, &ohci->regs->roothub.status); |
| 1344 | #endif /* OHCI_USE_NPS */ |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1345 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1346 | /* POTPGT delay is bits 24-31, in 2 ms units. */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1347 | mdelay ((roothub_a (ohci) >> 23) & 0x1fe); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1348 | |
| 1349 | /* connect the virtual root hub */ |
| 1350 | ohci->rh.devnum = 0; |
| 1351 | |
| 1352 | return 0; |
| 1353 | } |
| 1354 | |
| 1355 | /*-------------------------------------------------------------------------*/ |
| 1356 | |
| 1357 | /* an interrupt happens */ |
| 1358 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1359 | static int |
| 1360 | hc_interrupt (void) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1361 | { |
| 1362 | ohci_t *ohci = &gohci; |
| 1363 | struct ohci_regs *regs = ohci->regs; |
| 1364 | int ints; |
| 1365 | int stat = -1; |
| 1366 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1367 | if ((ohci->hcca->done_head != 0) && |
| 1368 | !(ohci_cpu_to_le32(ohci->hcca->done_head) & 0x01)) { |
| 1369 | |
| 1370 | ints = OHCI_INTR_WDH; |
| 1371 | |
| 1372 | } else if ((ints = readl (®s->intrstatus)) == ~(u32)0) { |
| 1373 | ohci->disabled++; |
| 1374 | err ("%s device removed!", ohci->slot_name); |
| 1375 | return -1; |
| 1376 | |
| 1377 | } else if ((ints &= readl (®s->intrenable)) == 0) { |
| 1378 | dbg("hc_interrupt: returning..\n"); |
| 1379 | return 0xff; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */ |
| 1383 | |
| 1384 | if (ints & OHCI_INTR_RHSC) { |
| 1385 | got_rhsc = 1; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1386 | stat = 0xff; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1387 | } |
| 1388 | |
| 1389 | if (ints & OHCI_INTR_UE) { |
| 1390 | ohci->disabled++; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1391 | err ("OHCI Unrecoverable Error, controller usb-%s disabled", |
| 1392 | ohci->slot_name); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1393 | /* e.g. due to PCI Master/Target Abort */ |
| 1394 | |
| 1395 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1396 | ohci_dump (ohci, 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1397 | #endif |
| 1398 | /* FIXME: be optimistic, hope that bug won't repeat often. */ |
| 1399 | /* Make some non-interrupt context restart the controller. */ |
| 1400 | /* Count and limit the retries though; either hardware or */ |
| 1401 | /* software errors can go forever... */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1402 | hc_reset (ohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1403 | return -1; |
| 1404 | } |
| 1405 | |
| 1406 | if (ints & OHCI_INTR_WDH) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1407 | writel (OHCI_INTR_WDH, ®s->intrdisable); |
| 1408 | stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci)); |
| 1409 | writel (OHCI_INTR_WDH, ®s->intrenable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | if (ints & OHCI_INTR_SO) { |
| 1413 | dbg("USB Schedule overrun\n"); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1414 | writel (OHCI_INTR_SO, ®s->intrenable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1415 | stat = -1; |
| 1416 | } |
| 1417 | |
| 1418 | /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */ |
| 1419 | if (ints & OHCI_INTR_SF) { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1420 | unsigned int frame = ohci_cpu_to_le16 (ohci->hcca->frame_no) & 1; |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1421 | mdelay(1); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1422 | writel (OHCI_INTR_SF, ®s->intrdisable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1423 | if (ohci->ed_rm_list[frame] != NULL) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1424 | writel (OHCI_INTR_SF, ®s->intrenable); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1425 | stat = 0xff; |
| 1426 | } |
| 1427 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1428 | writel (ints, ®s->intrstatus); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1429 | return stat; |
| 1430 | } |
| 1431 | |
| 1432 | /*-------------------------------------------------------------------------*/ |
| 1433 | |
| 1434 | /*-------------------------------------------------------------------------*/ |
| 1435 | |
| 1436 | /* De-allocate all resources.. */ |
| 1437 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1438 | static void hc_release_ohci (ohci_t *ohci) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1439 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1440 | dbg ("USB HC release ohci usb-%s", ohci->slot_name); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1441 | |
| 1442 | if (!ohci->disabled) |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1443 | hc_reset (ohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1444 | } |
| 1445 | |
| 1446 | /*-------------------------------------------------------------------------*/ |
| 1447 | |
| 1448 | /* |
| 1449 | * low level initalisation routine, called from usb.c |
| 1450 | */ |
| 1451 | static char ohci_inited = 0; |
| 1452 | |
Troy Kisky | 8f9c49d | 2013-10-10 15:27:56 -0700 | [diff] [blame] | 1453 | int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1454 | { |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1455 | memset (&gohci, 0, sizeof (ohci_t)); |
| 1456 | memset (&urb_priv, 0, sizeof (urb_priv_t)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1457 | |
| 1458 | /* align the storage */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1459 | if ((__u32)&ghcca[0] & 0xff) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1460 | err("HCCA not aligned!!"); |
| 1461 | return -1; |
| 1462 | } |
| 1463 | phcca = &ghcca[0]; |
| 1464 | info("aligned ghcca %p", phcca); |
| 1465 | memset(&ohci_dev, 0, sizeof(struct ohci_device)); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1466 | if ((__u32)&ohci_dev.ed[0] & 0x7) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1467 | err("EDs not aligned!!"); |
| 1468 | return -1; |
| 1469 | } |
| 1470 | memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1)); |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1471 | if ((__u32)gtd & 0x7) { |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1472 | err("TDs not aligned!!"); |
| 1473 | return -1; |
| 1474 | } |
| 1475 | ptd = gtd; |
| 1476 | gohci.hcca = phcca; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1477 | memset (phcca, 0, sizeof (struct ohci_hcca)); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1478 | |
| 1479 | gohci.disabled = 1; |
| 1480 | gohci.sleeping = 0; |
| 1481 | gohci.irq = -1; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1482 | #if defined(CONFIG_440EP) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1483 | gohci.regs = (struct ohci_regs *)(CONFIG_SYS_PERIPHERAL_BASE | 0x1000); |
| 1484 | #elif defined(CONFIG_440EPX) || defined(CONFIG_SYS_USB_HOST) |
| 1485 | gohci.regs = (struct ohci_regs *)(CONFIG_SYS_USB_HOST); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1486 | #endif |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1487 | |
| 1488 | gohci.flags = 0; |
| 1489 | gohci.slot_name = "ppc440"; |
| 1490 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1491 | if (hc_reset (&gohci) < 0) { |
| 1492 | hc_release_ohci (&gohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1493 | return -1; |
| 1494 | } |
| 1495 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1496 | if (hc_start (&gohci) < 0) { |
| 1497 | err ("can't start usb-%s", gohci.slot_name); |
| 1498 | hc_release_ohci (&gohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1499 | return -1; |
| 1500 | } |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1501 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1502 | #ifdef DEBUG |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1503 | ohci_dump (&gohci, 1); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1504 | #endif |
| 1505 | ohci_inited = 1; |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1506 | urb_finished = 1; |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1507 | |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1508 | return 0; |
| 1509 | } |
| 1510 | |
Lucas Stach | a323128 | 2012-09-26 00:14:34 +0200 | [diff] [blame] | 1511 | int usb_lowlevel_stop(int index) |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1512 | { |
| 1513 | /* this gets called really early - before the controller has */ |
| 1514 | /* even been initialized! */ |
| 1515 | if (!ohci_inited) |
| 1516 | return 0; |
| 1517 | /* TODO release any interrupts, etc. */ |
| 1518 | /* call hc_release_ohci() here ? */ |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1519 | hc_reset (&gohci); |
Stefan Roese | 326c971 | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 1520 | return 0; |
| 1521 | } |
| 1522 | |
Stefan Roese | 40ee63b | 2005-08-02 10:05:21 +0200 | [diff] [blame] | 1523 | #endif /* CONFIG_USB_OHCI */ |