Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2 | /* |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 3 | * URB OHCI HCD (Host Controller Driver) for USB on the AT91RM9200 and PCI bus. |
| 4 | * |
| 5 | * Interrupt support is added. Now, it has been tested |
| 6 | * on ULI1575 chip and works well with USB keyboard. |
| 7 | * |
| 8 | * (C) Copyright 2007 |
| 9 | * Zhang Wei, Freescale Semiconductor, Inc. <wei.zhang@freescale.com> |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 10 | * |
| 11 | * (C) Copyright 2003 |
Detlev Zundel | f1b3f2b | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 12 | * Gary Jennejohn, DENX Software Engineering <garyj@denx.de> |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 13 | * |
| 14 | * Note: Much of this code has been derived from Linux 2.4 |
| 15 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> |
| 16 | * (C) Copyright 2000-2002 David Brownell |
| 17 | * |
| 18 | * Modified for the MP2USB by (C) Copyright 2005 Eric Benard |
| 19 | * ebenard@eukrea.com - based on s3c24x0's driver |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 20 | */ |
| 21 | /* |
| 22 | * IMPORTANT NOTES |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 23 | * 1 - Read doc/README.generic_usb_ohci |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 24 | * 2 - this driver is intended for use with USB Mass Storage Devices |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 25 | * (BBB) and USB keyboard. There is NO support for Isochronous pipes! |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 26 | * 2 - when running on a PQFP208 AT91RM9200, define CONFIG_AT91C_PQFP_UHPBUG |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 27 | * to activate workaround for bug #41 or this driver will NOT work! |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 31 | #include <cpu_func.h> |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 32 | #include <asm/byteorder.h> |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 33 | #include <dm.h> |
| 34 | #include <errno.h> |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 35 | |
| 36 | #if defined(CONFIG_PCI_OHCI) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 37 | # include <pci.h> |
Sergei Poselenov | 0b4570f | 2008-05-22 01:15:53 +0200 | [diff] [blame] | 38 | #if !defined(CONFIG_PCI_OHCI_DEVNO) |
| 39 | #define CONFIG_PCI_OHCI_DEVNO 0 |
| 40 | #endif |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 41 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 42 | |
| 43 | #include <malloc.h> |
Simon Glass | 2dd337a | 2015-09-02 17:24:58 -0600 | [diff] [blame] | 44 | #include <memalign.h> |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 45 | #include <usb.h> |
Jean-Christophe PLAGNIOL-VILLARD | 8f6bcf4 | 2009-04-03 12:46:58 +0200 | [diff] [blame] | 46 | |
| 47 | #include "ohci.h" |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 48 | |
Wolfgang Denk | dcac38b | 2007-11-19 12:59:14 +0100 | [diff] [blame] | 49 | #ifdef CONFIG_AT91RM9200 |
| 50 | #include <asm/arch/hardware.h> /* needed for AT91_USB_HOST_BASE */ |
| 51 | #endif |
| 52 | |
Masahiro Yamada | 7a5b292 | 2014-11-06 14:59:35 +0900 | [diff] [blame] | 53 | #if defined(CONFIG_CPU_ARM920T) || \ |
Heiko Schocher | 2e1134f | 2019-07-16 10:49:05 +0200 | [diff] [blame] | 54 | defined(CONFIG_PCI_OHCI) || \ |
| 55 | defined(CONFIG_DM_PCI) || \ |
| 56 | defined(CONFIG_SYS_OHCI_USE_NPS) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 57 | # define OHCI_USE_NPS /* force NoPowerSwitching mode */ |
| 58 | #endif |
| 59 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 60 | #undef OHCI_VERBOSE_DEBUG /* not always helpful */ |
Markus Klotzbuecher | d209de6 | 2006-11-27 11:46:46 +0100 | [diff] [blame] | 61 | #undef DEBUG |
| 62 | #undef SHOW_INFO |
| 63 | #undef OHCI_FILL_TRACE |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 64 | |
| 65 | /* For initializing controller (mask in an HCFS mode too) */ |
| 66 | #define OHCI_CONTROL_INIT \ |
| 67 | (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE |
| 68 | |
Heiko Schocher | fe410a4 | 2019-07-16 10:49:03 +0200 | [diff] [blame] | 69 | #if !CONFIG_IS_ENABLED(DM_USB) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 70 | #ifdef CONFIG_PCI_OHCI |
| 71 | static struct pci_device_id ohci_pci_ids[] = { |
| 72 | {0x10b9, 0x5237}, /* ULI1575 PCI OHCI module ids */ |
David Saada | e3b2842 | 2007-09-17 17:04:47 +0200 | [diff] [blame] | 73 | {0x1033, 0x0035}, /* NEC PCI OHCI module ids */ |
TsiChung Liew | 923f43a | 2008-01-11 20:42:58 -0600 | [diff] [blame] | 74 | {0x1131, 0x1561}, /* Philips 1561 PCI OHCI module ids */ |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 75 | /* Please add supported PCI OHCI controller ids here */ |
| 76 | {0, 0} |
| 77 | }; |
| 78 | #endif |
Heiko Schocher | fe410a4 | 2019-07-16 10:49:03 +0200 | [diff] [blame] | 79 | #endif |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 80 | |
Yuri Tikhonov | 11af42c | 2008-09-04 11:19:05 +0200 | [diff] [blame] | 81 | #ifdef CONFIG_PCI_EHCI_DEVNO |
| 82 | static struct pci_device_id ehci_pci_ids[] = { |
| 83 | {0x1131, 0x1562}, /* Philips 1562 PCI EHCI module ids */ |
| 84 | /* Please add supported PCI EHCI controller ids here */ |
| 85 | {0, 0} |
| 86 | }; |
| 87 | #endif |
| 88 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 89 | #ifdef DEBUG |
| 90 | #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg) |
| 91 | #else |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 92 | #define dbg(format, arg...) do {} while (0) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 93 | #endif /* DEBUG */ |
| 94 | #define err(format, arg...) printf("ERROR: " format "\n", ## arg) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 95 | #ifdef SHOW_INFO |
| 96 | #define info(format, arg...) printf("INFO: " format "\n", ## arg) |
| 97 | #else |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 98 | #define info(format, arg...) do {} while (0) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 99 | #endif |
| 100 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | #ifdef CONFIG_SYS_OHCI_BE_CONTROLLER |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 102 | # define m16_swap(x) cpu_to_be16(x) |
| 103 | # define m32_swap(x) cpu_to_be32(x) |
Markus Klotzbuecher | d209de6 | 2006-11-27 11:46:46 +0100 | [diff] [blame] | 104 | #else |
Markus Klotzbuecher | 18f5ccb | 2007-06-06 11:49:35 +0200 | [diff] [blame] | 105 | # define m16_swap(x) cpu_to_le16(x) |
| 106 | # define m32_swap(x) cpu_to_le32(x) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 107 | #endif /* CONFIG_SYS_OHCI_BE_CONTROLLER */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 108 | |
Wu, Josh | c385714 | 2015-07-27 11:40:18 +0800 | [diff] [blame] | 109 | /* We really should do proper cache flushing everywhere */ |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 110 | #define flush_dcache_buffer(addr, size) \ |
| 111 | flush_dcache_range((unsigned long)(addr), \ |
| 112 | ALIGN((unsigned long)(addr) + size, ARCH_DMA_MINALIGN)) |
| 113 | #define invalidate_dcache_buffer(addr, size) \ |
| 114 | invalidate_dcache_range((unsigned long)(addr), \ |
| 115 | ALIGN((unsigned long)(addr) + size, ARCH_DMA_MINALIGN)) |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 116 | |
| 117 | /* Do not use sizeof(ed / td) as our ed / td structs contain extra members */ |
| 118 | #define flush_dcache_ed(addr) flush_dcache_buffer(addr, 16) |
| 119 | #define flush_dcache_td(addr) flush_dcache_buffer(addr, 16) |
| 120 | #define flush_dcache_iso_td(addr) flush_dcache_buffer(addr, 32) |
| 121 | #define flush_dcache_hcca(addr) flush_dcache_buffer(addr, 256) |
| 122 | #define invalidate_dcache_ed(addr) invalidate_dcache_buffer(addr, 16) |
| 123 | #define invalidate_dcache_td(addr) invalidate_dcache_buffer(addr, 16) |
| 124 | #define invalidate_dcache_iso_td(addr) invalidate_dcache_buffer(addr, 32) |
| 125 | #define invalidate_dcache_hcca(addr) invalidate_dcache_buffer(addr, 256) |
| 126 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 127 | #if CONFIG_IS_ENABLED(DM_USB) |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 128 | /* |
| 129 | * The various ohci_mdelay(1) calls in the code seem unnecessary. We keep |
| 130 | * them around when building for older boards not yet converted to the dm |
| 131 | * just in case (to avoid regressions), for dm this turns them into nops. |
| 132 | */ |
| 133 | #define ohci_mdelay(x) |
| 134 | #else |
| 135 | #define ohci_mdelay(x) mdelay(x) |
| 136 | #endif |
| 137 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 138 | #if !CONFIG_IS_ENABLED(DM_USB) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 139 | /* global ohci_t */ |
| 140 | static ohci_t gohci; |
| 141 | /* this must be aligned to a 256 byte boundary */ |
| 142 | struct ohci_hcca ghcca[1]; |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 143 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 144 | |
Hans de Goede | 516c987 | 2015-05-05 23:56:11 +0200 | [diff] [blame] | 145 | /* mapping of the OHCI CC status to error codes */ |
| 146 | static int cc_to_error[16] = { |
| 147 | /* No Error */ 0, |
| 148 | /* CRC Error */ USB_ST_CRC_ERR, |
| 149 | /* Bit Stuff */ USB_ST_BIT_ERR, |
| 150 | /* Data Togg */ USB_ST_CRC_ERR, |
| 151 | /* Stall */ USB_ST_STALLED, |
| 152 | /* DevNotResp */ -1, |
| 153 | /* PIDCheck */ USB_ST_BIT_ERR, |
| 154 | /* UnExpPID */ USB_ST_BIT_ERR, |
| 155 | /* DataOver */ USB_ST_BUF_ERR, |
| 156 | /* DataUnder */ USB_ST_BUF_ERR, |
| 157 | /* reservd */ -1, |
| 158 | /* reservd */ -1, |
| 159 | /* BufferOver */ USB_ST_BUF_ERR, |
| 160 | /* BuffUnder */ USB_ST_BUF_ERR, |
| 161 | /* Not Access */ -1, |
| 162 | /* Not Access */ -1 |
| 163 | }; |
| 164 | |
| 165 | static const char *cc_to_string[16] = { |
| 166 | "No Error", |
| 167 | "CRC: Last data packet from endpoint contained a CRC error.", |
| 168 | "BITSTUFFING: Last data packet from endpoint contained a bit " \ |
| 169 | "stuffing violation", |
| 170 | "DATATOGGLEMISMATCH: Last packet from endpoint had data toggle PID\n" \ |
| 171 | "that did not match the expected value.", |
| 172 | "STALL: TD was moved to the Done Queue because the endpoint returned" \ |
| 173 | " a STALL PID", |
| 174 | "DEVICENOTRESPONDING: Device did not respond to token (IN) or did\n" \ |
| 175 | "not provide a handshake (OUT)", |
| 176 | "PIDCHECKFAILURE: Check bits on PID from endpoint failed on data PID\n"\ |
| 177 | "(IN) or handshake (OUT)", |
| 178 | "UNEXPECTEDPID: Receive PID was not valid when encountered or PID\n" \ |
| 179 | "value is not defined.", |
| 180 | "DATAOVERRUN: The amount of data returned by the endpoint exceeded\n" \ |
| 181 | "either the size of the maximum data packet allowed\n" \ |
| 182 | "from the endpoint (found in MaximumPacketSize field\n" \ |
| 183 | "of ED) or the remaining buffer size.", |
| 184 | "DATAUNDERRUN: The endpoint returned less than MaximumPacketSize\n" \ |
| 185 | "and that amount was not sufficient to fill the\n" \ |
| 186 | "specified buffer", |
| 187 | "reserved1", |
| 188 | "reserved2", |
| 189 | "BUFFEROVERRUN: During an IN, HC received data from endpoint faster\n" \ |
| 190 | "than it could be written to system memory", |
| 191 | "BUFFERUNDERRUN: During an OUT, HC could not retrieve data from\n" \ |
| 192 | "system memory fast enough to keep up with data USB " \ |
| 193 | "data rate.", |
| 194 | "NOT ACCESSED: This code is set by software before the TD is placed" \ |
| 195 | "on a list to be processed by the HC.(1)", |
| 196 | "NOT ACCESSED: This code is set by software before the TD is placed" \ |
| 197 | "on a list to be processed by the HC.(2)", |
| 198 | }; |
| 199 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 200 | static inline u32 roothub_a(struct ohci *hc) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 201 | { return ohci_readl(&hc->regs->roothub.a); } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 202 | static inline u32 roothub_b(struct ohci *hc) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 203 | { return ohci_readl(&hc->regs->roothub.b); } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 204 | static inline u32 roothub_status(struct ohci *hc) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 205 | { return ohci_readl(&hc->regs->roothub.status); } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 206 | static inline u32 roothub_portstatus(struct ohci *hc, int i) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 207 | { return ohci_readl(&hc->regs->roothub.portstatus[i]); } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 208 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 209 | /* forward declaration */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 210 | static int hc_interrupt(ohci_t *ohci); |
| 211 | static void td_submit_job(ohci_t *ohci, struct usb_device *dev, |
| 212 | unsigned long pipe, void *buffer, int transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 213 | struct devrequest *setup, urb_priv_t *urb, |
| 214 | int interval); |
Hans de Goede | 516c987 | 2015-05-05 23:56:11 +0200 | [diff] [blame] | 215 | static int ep_link(ohci_t * ohci, ed_t * ed); |
| 216 | static int ep_unlink(ohci_t * ohci, ed_t * ed); |
| 217 | static ed_t *ep_add_ed(ohci_dev_t *ohci_dev, struct usb_device *usb_dev, |
| 218 | unsigned long pipe, int interval, int load); |
| 219 | |
| 220 | /*-------------------------------------------------------------------------*/ |
| 221 | |
| 222 | /* TDs ... */ |
| 223 | static struct td *td_alloc(ohci_dev_t *ohci_dev, struct usb_device *usb_dev) |
| 224 | { |
| 225 | int i; |
| 226 | struct td *td; |
| 227 | |
| 228 | td = NULL; |
| 229 | for (i = 0; i < NUM_TD; i++) |
| 230 | { |
| 231 | if (ohci_dev->tds[i].usb_dev == NULL) |
| 232 | { |
| 233 | td = &ohci_dev->tds[i]; |
| 234 | td->usb_dev = usb_dev; |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | return td; |
| 240 | } |
| 241 | |
| 242 | static inline void ed_free(struct ed *ed) |
| 243 | { |
| 244 | ed->usb_dev = NULL; |
| 245 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 246 | |
| 247 | /*-------------------------------------------------------------------------* |
| 248 | * URB support functions |
| 249 | *-------------------------------------------------------------------------*/ |
| 250 | |
| 251 | /* free HCD-private data associated with this URB */ |
| 252 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 253 | static void urb_free_priv(urb_priv_t *urb) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 254 | { |
| 255 | int i; |
| 256 | int last; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 257 | struct td *td; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 258 | |
| 259 | last = urb->length - 1; |
| 260 | if (last >= 0) { |
| 261 | for (i = 0; i <= last; i++) { |
| 262 | td = urb->td[i]; |
| 263 | if (td) { |
| 264 | td->usb_dev = NULL; |
| 265 | urb->td[i] = NULL; |
| 266 | } |
| 267 | } |
| 268 | } |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 269 | free(urb); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | /*-------------------------------------------------------------------------*/ |
| 273 | |
| 274 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 275 | static int sohci_get_current_frame_number(ohci_t *ohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 276 | |
| 277 | /* debug| print the main components of an URB |
| 278 | * small: 0) header + data packets 1) just header */ |
| 279 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 280 | static void pkt_print(ohci_t *ohci, urb_priv_t *purb, struct usb_device *dev, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 281 | unsigned long pipe, void *buffer, int transfer_len, |
| 282 | struct devrequest *setup, char *str, int small) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 283 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 284 | dbg("%s URB:[%4x] dev:%2lu,ep:%2lu-%c,type:%s,len:%d/%d stat:%#lx", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 285 | str, |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 286 | sohci_get_current_frame_number(ohci), |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 287 | usb_pipedevice(pipe), |
| 288 | usb_pipeendpoint(pipe), |
| 289 | usb_pipeout(pipe)? 'O': 'I', |
| 290 | usb_pipetype(pipe) < 2 ? \ |
| 291 | (usb_pipeint(pipe)? "INTR": "ISOC"): \ |
| 292 | (usb_pipecontrol(pipe)? "CTRL": "BULK"), |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 293 | (purb ? purb->actual_length : 0), |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 294 | transfer_len, dev->status); |
| 295 | #ifdef OHCI_VERBOSE_DEBUG |
| 296 | if (!small) { |
| 297 | int i, len; |
| 298 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 299 | if (usb_pipecontrol(pipe)) { |
| 300 | printf(__FILE__ ": cmd(8):"); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 301 | for (i = 0; i < 8 ; i++) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 302 | printf(" %02x", ((__u8 *) setup) [i]); |
| 303 | printf("\n"); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 304 | } |
| 305 | if (transfer_len > 0 && buffer) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 306 | printf(__FILE__ ": data(%d/%d):", |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 307 | (purb ? purb->actual_length : 0), |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 308 | transfer_len); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 309 | len = usb_pipeout(pipe)? transfer_len: |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 310 | (purb ? purb->actual_length : 0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 311 | for (i = 0; i < 16 && i < len; i++) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 312 | printf(" %02x", ((__u8 *) buffer) [i]); |
| 313 | printf("%s\n", i < len? "...": ""); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | #endif |
| 317 | } |
| 318 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 319 | /* just for debugging; prints non-empty branches of the int ed tree |
| 320 | * inclusive iso eds */ |
| 321 | void ep_print_int_eds(ohci_t *ohci, char *str) |
| 322 | { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 323 | int i, j; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 324 | __u32 *ed_p; |
| 325 | for (i = 0; i < 32; i++) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 326 | j = 5; |
| 327 | ed_p = &(ohci->hcca->int_table [i]); |
| 328 | if (*ed_p == 0) |
| 329 | continue; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 330 | invalidate_dcache_ed(ed_p); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 331 | printf(__FILE__ ": %s branch int %2d(%2x):", str, i, i); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 332 | while (*ed_p != 0 && j--) { |
| 333 | ed_t *ed = (ed_t *)m32_swap(ed_p); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 334 | invalidate_dcache_ed(ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 335 | printf(" ed: %4x;", ed->hwINFO); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 336 | ed_p = &ed->hwNextED; |
| 337 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 338 | printf("\n"); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 342 | static void ohci_dump_intr_mask(char *label, __u32 mask) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 343 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 344 | dbg("%s: 0x%08x%s%s%s%s%s%s%s%s%s", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 345 | label, |
| 346 | mask, |
| 347 | (mask & OHCI_INTR_MIE) ? " MIE" : "", |
| 348 | (mask & OHCI_INTR_OC) ? " OC" : "", |
| 349 | (mask & OHCI_INTR_RHSC) ? " RHSC" : "", |
| 350 | (mask & OHCI_INTR_FNO) ? " FNO" : "", |
| 351 | (mask & OHCI_INTR_UE) ? " UE" : "", |
| 352 | (mask & OHCI_INTR_RD) ? " RD" : "", |
| 353 | (mask & OHCI_INTR_SF) ? " SF" : "", |
| 354 | (mask & OHCI_INTR_WDH) ? " WDH" : "", |
| 355 | (mask & OHCI_INTR_SO) ? " SO" : "" |
| 356 | ); |
| 357 | } |
| 358 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 359 | static void maybe_print_eds(char *label, __u32 value) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 360 | { |
| 361 | ed_t *edp = (ed_t *)value; |
| 362 | |
| 363 | if (value) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 364 | dbg("%s %08x", label, value); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 365 | invalidate_dcache_ed(edp); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 366 | dbg("%08x", edp->hwINFO); |
| 367 | dbg("%08x", edp->hwTailP); |
| 368 | dbg("%08x", edp->hwHeadP); |
| 369 | dbg("%08x", edp->hwNextED); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 373 | static char *hcfs2string(int state) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 374 | { |
| 375 | switch (state) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 376 | case OHCI_USB_RESET: return "reset"; |
| 377 | case OHCI_USB_RESUME: return "resume"; |
| 378 | case OHCI_USB_OPER: return "operational"; |
| 379 | case OHCI_USB_SUSPEND: return "suspend"; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 380 | } |
| 381 | return "?"; |
| 382 | } |
| 383 | |
| 384 | /* dump control and status registers */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 385 | static void ohci_dump_status(ohci_t *controller) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 386 | { |
| 387 | struct ohci_regs *regs = controller->regs; |
| 388 | __u32 temp; |
| 389 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 390 | temp = ohci_readl(®s->revision) & 0xff; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 391 | if (temp != 0x10) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 392 | dbg("spec %d.%d", (temp >> 4), (temp & 0x0f)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 393 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 394 | temp = ohci_readl(®s->control); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 395 | dbg("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp, |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 396 | (temp & OHCI_CTRL_RWE) ? " RWE" : "", |
| 397 | (temp & OHCI_CTRL_RWC) ? " RWC" : "", |
| 398 | (temp & OHCI_CTRL_IR) ? " IR" : "", |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 399 | hcfs2string(temp & OHCI_CTRL_HCFS), |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 400 | (temp & OHCI_CTRL_BLE) ? " BLE" : "", |
| 401 | (temp & OHCI_CTRL_CLE) ? " CLE" : "", |
| 402 | (temp & OHCI_CTRL_IE) ? " IE" : "", |
| 403 | (temp & OHCI_CTRL_PLE) ? " PLE" : "", |
| 404 | temp & OHCI_CTRL_CBSR |
| 405 | ); |
| 406 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 407 | temp = ohci_readl(®s->cmdstatus); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 408 | dbg("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp, |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 409 | (temp & OHCI_SOC) >> 16, |
| 410 | (temp & OHCI_OCR) ? " OCR" : "", |
| 411 | (temp & OHCI_BLF) ? " BLF" : "", |
| 412 | (temp & OHCI_CLF) ? " CLF" : "", |
| 413 | (temp & OHCI_HCR) ? " HCR" : "" |
| 414 | ); |
| 415 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 416 | ohci_dump_intr_mask("intrstatus", ohci_readl(®s->intrstatus)); |
| 417 | ohci_dump_intr_mask("intrenable", ohci_readl(®s->intrenable)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 418 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 419 | maybe_print_eds("ed_periodcurrent", |
| 420 | ohci_readl(®s->ed_periodcurrent)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 421 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 422 | maybe_print_eds("ed_controlhead", ohci_readl(®s->ed_controlhead)); |
| 423 | maybe_print_eds("ed_controlcurrent", |
| 424 | ohci_readl(®s->ed_controlcurrent)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 425 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 426 | maybe_print_eds("ed_bulkhead", ohci_readl(®s->ed_bulkhead)); |
| 427 | maybe_print_eds("ed_bulkcurrent", ohci_readl(®s->ed_bulkcurrent)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 428 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 429 | maybe_print_eds("donehead", ohci_readl(®s->donehead)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 430 | } |
| 431 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 432 | static void ohci_dump_roothub(ohci_t *controller, int verbose) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 433 | { |
| 434 | __u32 temp, ndp, i; |
| 435 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 436 | temp = roothub_a(controller); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 437 | ndp = (temp & RH_A_NDP); |
| 438 | #ifdef CONFIG_AT91C_PQFP_UHPBUG |
| 439 | ndp = (ndp == 2) ? 1:0; |
| 440 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 441 | if (verbose) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 442 | dbg("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp, |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 443 | ((temp & RH_A_POTPGT) >> 24) & 0xff, |
| 444 | (temp & RH_A_NOCP) ? " NOCP" : "", |
| 445 | (temp & RH_A_OCPM) ? " OCPM" : "", |
| 446 | (temp & RH_A_DT) ? " DT" : "", |
| 447 | (temp & RH_A_NPS) ? " NPS" : "", |
| 448 | (temp & RH_A_PSM) ? " PSM" : "", |
| 449 | ndp |
| 450 | ); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 451 | temp = roothub_b(controller); |
| 452 | dbg("roothub.b: %08x PPCM=%04x DR=%04x", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 453 | temp, |
| 454 | (temp & RH_B_PPCM) >> 16, |
| 455 | (temp & RH_B_DR) |
| 456 | ); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 457 | temp = roothub_status(controller); |
| 458 | dbg("roothub.status: %08x%s%s%s%s%s%s", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 459 | temp, |
| 460 | (temp & RH_HS_CRWE) ? " CRWE" : "", |
| 461 | (temp & RH_HS_OCIC) ? " OCIC" : "", |
| 462 | (temp & RH_HS_LPSC) ? " LPSC" : "", |
| 463 | (temp & RH_HS_DRWE) ? " DRWE" : "", |
| 464 | (temp & RH_HS_OCI) ? " OCI" : "", |
| 465 | (temp & RH_HS_LPS) ? " LPS" : "" |
| 466 | ); |
| 467 | } |
| 468 | |
| 469 | for (i = 0; i < ndp; i++) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 470 | temp = roothub_portstatus(controller, i); |
| 471 | dbg("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 472 | i, |
| 473 | temp, |
| 474 | (temp & RH_PS_PRSC) ? " PRSC" : "", |
| 475 | (temp & RH_PS_OCIC) ? " OCIC" : "", |
| 476 | (temp & RH_PS_PSSC) ? " PSSC" : "", |
| 477 | (temp & RH_PS_PESC) ? " PESC" : "", |
| 478 | (temp & RH_PS_CSC) ? " CSC" : "", |
| 479 | |
| 480 | (temp & RH_PS_LSDA) ? " LSDA" : "", |
| 481 | (temp & RH_PS_PPS) ? " PPS" : "", |
| 482 | (temp & RH_PS_PRS) ? " PRS" : "", |
| 483 | (temp & RH_PS_POCI) ? " POCI" : "", |
| 484 | (temp & RH_PS_PSS) ? " PSS" : "", |
| 485 | |
| 486 | (temp & RH_PS_PES) ? " PES" : "", |
| 487 | (temp & RH_PS_CCS) ? " CCS" : "" |
| 488 | ); |
| 489 | } |
| 490 | } |
| 491 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 492 | static void ohci_dump(ohci_t *controller, int verbose) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 493 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 494 | dbg("OHCI controller usb-%s state", controller->slot_name); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 495 | |
| 496 | /* dumps some of the state we know about */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 497 | ohci_dump_status(controller); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 498 | if (verbose) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 499 | ep_print_int_eds(controller, "hcca"); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 500 | invalidate_dcache_hcca(controller->hcca); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 501 | dbg("hcca frame #%04x", controller->hcca->frame_no); |
| 502 | ohci_dump_roothub(controller, 1); |
Stefan Roese | 41e74eb | 2008-03-05 12:29:32 +0100 | [diff] [blame] | 503 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 504 | #endif /* DEBUG */ |
| 505 | |
| 506 | /*-------------------------------------------------------------------------* |
| 507 | * Interface functions (URB) |
| 508 | *-------------------------------------------------------------------------*/ |
| 509 | |
| 510 | /* get a transfer request */ |
| 511 | |
Hans de Goede | 0c0e960 | 2015-05-05 23:56:08 +0200 | [diff] [blame] | 512 | int sohci_submit_job(ohci_t *ohci, ohci_dev_t *ohci_dev, urb_priv_t *urb, |
| 513 | struct devrequest *setup) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 514 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 515 | ed_t *ed; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 516 | urb_priv_t *purb_priv = urb; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 517 | int i, size = 0; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 518 | struct usb_device *dev = urb->dev; |
| 519 | unsigned long pipe = urb->pipe; |
| 520 | void *buffer = urb->transfer_buffer; |
| 521 | int transfer_len = urb->transfer_buffer_length; |
| 522 | int interval = urb->interval; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 523 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 524 | /* when controller's hung, permit only roothub cleanup attempts |
| 525 | * such as powering down ports */ |
| 526 | if (ohci->disabled) { |
| 527 | err("sohci_submit_job: EPIPE"); |
| 528 | return -1; |
| 529 | } |
Markus Klotzbuecher | e3af6d5 | 2007-03-26 11:21:05 +0200 | [diff] [blame] | 530 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 531 | /* we're about to begin a new transaction here so mark the |
| 532 | * URB unfinished */ |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 533 | urb->finished = 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 534 | |
| 535 | /* every endpoint has a ed, locate and fill it */ |
Hans de Goede | 0c0e960 | 2015-05-05 23:56:08 +0200 | [diff] [blame] | 536 | ed = ep_add_ed(ohci_dev, dev, pipe, interval, 1); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 537 | if (!ed) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 538 | err("sohci_submit_job: ENOMEM"); |
| 539 | return -1; |
| 540 | } |
| 541 | |
| 542 | /* for the private part of the URB we need the number of TDs (size) */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 543 | switch (usb_pipetype(pipe)) { |
| 544 | case PIPE_BULK: /* one TD for every 4096 Byte */ |
| 545 | size = (transfer_len - 1) / 4096 + 1; |
| 546 | break; |
| 547 | case PIPE_CONTROL:/* 1 TD for setup, 1 for ACK and 1 for every 4096 B */ |
| 548 | size = (transfer_len == 0)? 2: |
| 549 | (transfer_len - 1) / 4096 + 3; |
| 550 | break; |
| 551 | case PIPE_INTERRUPT: /* 1 TD */ |
| 552 | size = 1; |
| 553 | break; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 554 | } |
| 555 | |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 556 | ed->purb = urb; |
| 557 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 558 | if (size >= (N_URB_TD - 1)) { |
| 559 | err("need %d TDs, only have %d", size, N_URB_TD); |
| 560 | return -1; |
| 561 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 562 | purb_priv->pipe = pipe; |
| 563 | |
| 564 | /* fill the private part of the URB */ |
| 565 | purb_priv->length = size; |
| 566 | purb_priv->ed = ed; |
| 567 | purb_priv->actual_length = 0; |
| 568 | |
| 569 | /* allocate the TDs */ |
| 570 | /* note that td[0] was allocated in ep_add_ed */ |
| 571 | for (i = 0; i < size; i++) { |
Hans de Goede | e5ef421 | 2015-05-05 23:56:09 +0200 | [diff] [blame] | 572 | purb_priv->td[i] = td_alloc(ohci_dev, dev); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 573 | if (!purb_priv->td[i]) { |
| 574 | purb_priv->length = i; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 575 | urb_free_priv(purb_priv); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 576 | err("sohci_submit_job: ENOMEM"); |
| 577 | return -1; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | if (ed->state == ED_NEW || (ed->state & ED_DEL)) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 582 | urb_free_priv(purb_priv); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 583 | err("sohci_submit_job: EINVAL"); |
| 584 | return -1; |
| 585 | } |
| 586 | |
| 587 | /* link the ed into a chain if is not already */ |
| 588 | if (ed->state != ED_OPER) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 589 | ep_link(ohci, ed); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 590 | |
| 591 | /* fill the TDs and link it to the ed */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 592 | td_submit_job(ohci, dev, pipe, buffer, transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 593 | setup, purb_priv, interval); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 594 | |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | /*-------------------------------------------------------------------------*/ |
| 599 | |
| 600 | #ifdef DEBUG |
| 601 | /* tell us the current USB frame number */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 602 | static int sohci_get_current_frame_number(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 603 | { |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 604 | invalidate_dcache_hcca(ohci->hcca); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 605 | return m16_swap(ohci->hcca->frame_no); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 606 | } |
| 607 | #endif |
| 608 | |
| 609 | /*-------------------------------------------------------------------------* |
| 610 | * ED handling functions |
| 611 | *-------------------------------------------------------------------------*/ |
| 612 | |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 613 | /* search for the right branch to insert an interrupt ed into the int tree |
| 614 | * do some load ballancing; |
| 615 | * returns the branch and |
| 616 | * sets the interval to interval = 2^integer (ld (interval)) */ |
| 617 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 618 | static int ep_int_ballance(ohci_t *ohci, int interval, int load) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 619 | { |
| 620 | int i, branch = 0; |
| 621 | |
| 622 | /* search for the least loaded interrupt endpoint |
| 623 | * branch of all 32 branches |
| 624 | */ |
| 625 | for (i = 0; i < 32; i++) |
| 626 | if (ohci->ohci_int_load [branch] > ohci->ohci_int_load [i]) |
| 627 | branch = i; |
| 628 | |
| 629 | branch = branch % interval; |
| 630 | for (i = branch; i < 32; i += interval) |
| 631 | ohci->ohci_int_load [i] += load; |
| 632 | |
| 633 | return branch; |
| 634 | } |
| 635 | |
| 636 | /*-------------------------------------------------------------------------*/ |
| 637 | |
| 638 | /* 2^int( ld (inter)) */ |
| 639 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 640 | static int ep_2_n_interval(int inter) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 641 | { |
| 642 | int i; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 643 | for (i = 0; ((inter >> i) > 1) && (i < 5); i++); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 644 | return 1 << i; |
| 645 | } |
| 646 | |
| 647 | /*-------------------------------------------------------------------------*/ |
| 648 | |
| 649 | /* the int tree is a binary tree |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 650 | * in order to process it sequentially the indexes of the branches have to |
| 651 | * be mapped the mapping reverses the bits of a word of num_bits length */ |
| 652 | static int ep_rev(int num_bits, int word) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 653 | { |
| 654 | int i, wout = 0; |
| 655 | |
| 656 | for (i = 0; i < num_bits; i++) |
| 657 | wout |= (((word >> i) & 1) << (num_bits - i - 1)); |
| 658 | return wout; |
| 659 | } |
| 660 | |
| 661 | /*-------------------------------------------------------------------------* |
| 662 | * ED handling functions |
| 663 | *-------------------------------------------------------------------------*/ |
| 664 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 665 | /* link an ed into one of the HC chains */ |
| 666 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 667 | static int ep_link(ohci_t *ohci, ed_t *edi) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 668 | { |
| 669 | volatile ed_t *ed = edi; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 670 | int int_branch; |
| 671 | int i; |
| 672 | int inter; |
| 673 | int interval; |
| 674 | int load; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 675 | __u32 *ed_p; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 676 | |
| 677 | ed->state = ED_OPER; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 678 | ed->int_interval = 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 679 | |
| 680 | switch (ed->type) { |
| 681 | case PIPE_CONTROL: |
| 682 | ed->hwNextED = 0; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 683 | flush_dcache_ed(ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 684 | if (ohci->ed_controltail == NULL) |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 685 | ohci_writel((uintptr_t)ed, &ohci->regs->ed_controlhead); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 686 | else |
| 687 | ohci->ed_controltail->hwNextED = |
| 688 | m32_swap((unsigned long)ed); |
| 689 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 690 | ed->ed_prev = ohci->ed_controltail; |
| 691 | if (!ohci->ed_controltail && !ohci->ed_rm_list[0] && |
| 692 | !ohci->ed_rm_list[1] && !ohci->sleeping) { |
| 693 | ohci->hc_control |= OHCI_CTRL_CLE; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 694 | ohci_writel(ohci->hc_control, &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 695 | } |
| 696 | ohci->ed_controltail = edi; |
| 697 | break; |
| 698 | |
| 699 | case PIPE_BULK: |
| 700 | ed->hwNextED = 0; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 701 | flush_dcache_ed(ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 702 | if (ohci->ed_bulktail == NULL) |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 703 | ohci_writel((uintptr_t)ed, &ohci->regs->ed_bulkhead); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 704 | else |
| 705 | ohci->ed_bulktail->hwNextED = |
| 706 | m32_swap((unsigned long)ed); |
| 707 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 708 | ed->ed_prev = ohci->ed_bulktail; |
| 709 | if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] && |
| 710 | !ohci->ed_rm_list[1] && !ohci->sleeping) { |
| 711 | ohci->hc_control |= OHCI_CTRL_BLE; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 712 | ohci_writel(ohci->hc_control, &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 713 | } |
| 714 | ohci->ed_bulktail = edi; |
| 715 | break; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 716 | |
| 717 | case PIPE_INTERRUPT: |
| 718 | load = ed->int_load; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 719 | interval = ep_2_n_interval(ed->int_period); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 720 | ed->int_interval = interval; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 721 | int_branch = ep_int_ballance(ohci, interval, load); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 722 | ed->int_branch = int_branch; |
| 723 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 724 | for (i = 0; i < ep_rev(6, interval); i += inter) { |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 725 | inter = 1; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 726 | for (ed_p = &(ohci->hcca->int_table[\ |
| 727 | ep_rev(5, i) + int_branch]); |
| 728 | (*ed_p != 0) && |
| 729 | (((ed_t *)ed_p)->int_interval >= interval); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 730 | ed_p = &(((ed_t *)ed_p)->hwNextED)) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 731 | inter = ep_rev(6, |
| 732 | ((ed_t *)ed_p)->int_interval); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 733 | ed->hwNextED = *ed_p; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 734 | flush_dcache_ed(ed); |
Martin Krause | 8a58819 | 2007-08-21 12:40:34 +0200 | [diff] [blame] | 735 | *ed_p = m32_swap((unsigned long)ed); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 736 | flush_dcache_hcca(ohci->hcca); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 737 | } |
| 738 | break; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 739 | } |
| 740 | return 0; |
| 741 | } |
| 742 | |
| 743 | /*-------------------------------------------------------------------------*/ |
| 744 | |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 745 | /* scan the periodic table to find and unlink this ED */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 746 | static void periodic_unlink(struct ohci *ohci, volatile struct ed *ed, |
| 747 | unsigned index, unsigned period) |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 748 | { |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 749 | __maybe_unused unsigned long aligned_ed_p; |
| 750 | |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 751 | for (; index < NUM_INTS; index += period) { |
| 752 | __u32 *ed_p = &ohci->hcca->int_table [index]; |
| 753 | |
| 754 | /* ED might have been unlinked through another path */ |
| 755 | while (*ed_p != 0) { |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 756 | if (((struct ed *)(uintptr_t) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 757 | m32_swap((unsigned long)ed_p)) == ed) { |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 758 | *ed_p = ed->hwNextED; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 759 | aligned_ed_p = (unsigned long)ed_p; |
| 760 | aligned_ed_p &= ~(ARCH_DMA_MINALIGN - 1); |
| 761 | flush_dcache_range(aligned_ed_p, |
| 762 | aligned_ed_p + ARCH_DMA_MINALIGN); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 763 | break; |
| 764 | } |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 765 | ed_p = &(((struct ed *)(uintptr_t) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 766 | m32_swap((unsigned long)ed_p))->hwNextED); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 771 | /* unlink an ed from one of the HC chains. |
| 772 | * just the link to the ed is unlinked. |
| 773 | * the link from the ed still points to another operational ed or 0 |
| 774 | * so the HC can eventually finish the processing of the unlinked ed */ |
| 775 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 776 | static int ep_unlink(ohci_t *ohci, ed_t *edi) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 777 | { |
Markus Klotzbuecher | 661ffe5 | 2006-11-27 11:43:09 +0100 | [diff] [blame] | 778 | volatile ed_t *ed = edi; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 779 | int i; |
Markus Klotzbuecher | 661ffe5 | 2006-11-27 11:43:09 +0100 | [diff] [blame] | 780 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 781 | ed->hwINFO |= m32_swap(OHCI_ED_SKIP); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 782 | flush_dcache_ed(ed); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 783 | |
| 784 | switch (ed->type) { |
| 785 | case PIPE_CONTROL: |
| 786 | if (ed->ed_prev == NULL) { |
| 787 | if (!ed->hwNextED) { |
| 788 | ohci->hc_control &= ~OHCI_CTRL_CLE; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 789 | ohci_writel(ohci->hc_control, |
| 790 | &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 791 | } |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 792 | ohci_writel(m32_swap(*((__u32 *)&ed->hwNextED)), |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 793 | &ohci->regs->ed_controlhead); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 794 | } else { |
| 795 | ed->ed_prev->hwNextED = ed->hwNextED; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 796 | flush_dcache_ed(ed->ed_prev); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 797 | } |
| 798 | if (ohci->ed_controltail == ed) { |
| 799 | ohci->ed_controltail = ed->ed_prev; |
| 800 | } else { |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 801 | ((ed_t *)(uintptr_t)m32_swap( |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 802 | *((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 803 | } |
| 804 | break; |
| 805 | |
| 806 | case PIPE_BULK: |
| 807 | if (ed->ed_prev == NULL) { |
| 808 | if (!ed->hwNextED) { |
| 809 | ohci->hc_control &= ~OHCI_CTRL_BLE; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 810 | ohci_writel(ohci->hc_control, |
| 811 | &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 812 | } |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 813 | ohci_writel(m32_swap(*((__u32 *)&ed->hwNextED)), |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 814 | &ohci->regs->ed_bulkhead); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 815 | } else { |
| 816 | ed->ed_prev->hwNextED = ed->hwNextED; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 817 | flush_dcache_ed(ed->ed_prev); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 818 | } |
| 819 | if (ohci->ed_bulktail == ed) { |
| 820 | ohci->ed_bulktail = ed->ed_prev; |
| 821 | } else { |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 822 | ((ed_t *)(uintptr_t)m32_swap( |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 823 | *((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 824 | } |
| 825 | break; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 826 | |
| 827 | case PIPE_INTERRUPT: |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 828 | periodic_unlink(ohci, ed, 0, 1); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 829 | for (i = ed->int_branch; i < 32; i += ed->int_interval) |
| 830 | ohci->ohci_int_load[i] -= ed->int_load; |
| 831 | break; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 832 | } |
| 833 | ed->state = ED_UNLINK; |
| 834 | return 0; |
| 835 | } |
| 836 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 837 | /*-------------------------------------------------------------------------*/ |
| 838 | |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 839 | /* add/reinit an endpoint; this should be done once at the |
| 840 | * usb_set_configuration command, but the USB stack is a little bit |
| 841 | * stateless so we do it at every transaction if the state of the ed |
| 842 | * is ED_NEW then a dummy td is added and the state is changed to |
| 843 | * ED_UNLINK in all other cases the state is left unchanged the ed |
| 844 | * info fields are setted anyway even though most of them should not |
| 845 | * change |
| 846 | */ |
Hans de Goede | 0c0e960 | 2015-05-05 23:56:08 +0200 | [diff] [blame] | 847 | static ed_t *ep_add_ed(ohci_dev_t *ohci_dev, struct usb_device *usb_dev, |
| 848 | unsigned long pipe, int interval, int load) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 849 | { |
| 850 | td_t *td; |
| 851 | ed_t *ed_ret; |
| 852 | volatile ed_t *ed; |
| 853 | |
Hans de Goede | 0c0e960 | 2015-05-05 23:56:08 +0200 | [diff] [blame] | 854 | ed = ed_ret = &ohci_dev->ed[(usb_pipeendpoint(pipe) << 1) | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 855 | (usb_pipecontrol(pipe)? 0: usb_pipeout(pipe))]; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 856 | |
| 857 | if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) { |
| 858 | err("ep_add_ed: pending delete"); |
| 859 | /* pending delete request */ |
| 860 | return NULL; |
| 861 | } |
| 862 | |
| 863 | if (ed->state == ED_NEW) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 864 | /* dummy td; end of td list for ed */ |
Hans de Goede | e5ef421 | 2015-05-05 23:56:09 +0200 | [diff] [blame] | 865 | td = td_alloc(ohci_dev, usb_dev); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 866 | ed->hwTailP = m32_swap((unsigned long)td); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 867 | ed->hwHeadP = ed->hwTailP; |
| 868 | ed->state = ED_UNLINK; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 869 | ed->type = usb_pipetype(pipe); |
Hans de Goede | 0c0e960 | 2015-05-05 23:56:08 +0200 | [diff] [blame] | 870 | ohci_dev->ed_cnt++; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 871 | } |
| 872 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 873 | ed->hwINFO = m32_swap(usb_pipedevice(pipe) |
| 874 | | usb_pipeendpoint(pipe) << 7 |
| 875 | | (usb_pipeisoc(pipe)? 0x8000: 0) |
| 876 | | (usb_pipecontrol(pipe)? 0: \ |
| 877 | (usb_pipeout(pipe)? 0x800: 0x1000)) |
Ilya Yanok | a1cf10f | 2012-11-06 13:48:20 +0000 | [diff] [blame] | 878 | | (usb_dev->speed == USB_SPEED_LOW) << 13 |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 879 | | usb_maxpacket(usb_dev, pipe) << 16); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 880 | |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 881 | if (ed->type == PIPE_INTERRUPT && ed->state == ED_UNLINK) { |
| 882 | ed->int_period = interval; |
| 883 | ed->int_load = load; |
| 884 | } |
| 885 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 886 | flush_dcache_ed(ed); |
| 887 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 888 | return ed_ret; |
| 889 | } |
| 890 | |
| 891 | /*-------------------------------------------------------------------------* |
| 892 | * TD handling functions |
| 893 | *-------------------------------------------------------------------------*/ |
| 894 | |
| 895 | /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */ |
| 896 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 897 | static void td_fill(ohci_t *ohci, unsigned int info, |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 898 | void *data, int len, |
| 899 | struct usb_device *dev, int index, urb_priv_t *urb_priv) |
| 900 | { |
| 901 | volatile td_t *td, *td_pt; |
| 902 | #ifdef OHCI_FILL_TRACE |
| 903 | int i; |
| 904 | #endif |
| 905 | |
| 906 | if (index > urb_priv->length) { |
| 907 | err("index > length"); |
| 908 | return; |
| 909 | } |
| 910 | /* use this td as the next dummy */ |
| 911 | td_pt = urb_priv->td [index]; |
| 912 | td_pt->hwNextTD = 0; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 913 | flush_dcache_td(td_pt); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 914 | |
| 915 | /* fill the old dummy TD */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 916 | td = urb_priv->td [index] = |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 917 | (td_t *)(uintptr_t) |
| 918 | (m32_swap(urb_priv->ed->hwTailP) & ~0xf); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 919 | |
| 920 | td->ed = urb_priv->ed; |
| 921 | td->next_dl_td = NULL; |
| 922 | td->index = index; |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 923 | td->data = (uintptr_t)data; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 924 | #ifdef OHCI_FILL_TRACE |
Remy Bohmer | 47e7208 | 2008-10-10 10:23:21 +0200 | [diff] [blame] | 925 | if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 926 | for (i = 0; i < len; i++) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 927 | printf("td->data[%d] %#2x ", i, ((unsigned char *)td->data)[i]); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 928 | printf("\n"); |
| 929 | } |
| 930 | #endif |
| 931 | if (!len) |
| 932 | data = 0; |
| 933 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 934 | td->hwINFO = m32_swap(info); |
| 935 | td->hwCBP = m32_swap((unsigned long)data); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 936 | if (data) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 937 | td->hwBE = m32_swap((unsigned long)(data + len - 1)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 938 | else |
| 939 | td->hwBE = 0; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 940 | |
| 941 | td->hwNextTD = m32_swap((unsigned long)td_pt); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 942 | flush_dcache_td(td); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 943 | |
| 944 | /* append to queue */ |
| 945 | td->ed->hwTailP = td->hwNextTD; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 946 | flush_dcache_ed(td->ed); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | /*-------------------------------------------------------------------------*/ |
| 950 | |
| 951 | /* prepare all TDs of a transfer */ |
| 952 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 953 | static void td_submit_job(ohci_t *ohci, struct usb_device *dev, |
| 954 | unsigned long pipe, void *buffer, int transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 955 | struct devrequest *setup, urb_priv_t *urb, |
| 956 | int interval) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 957 | { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 958 | int data_len = transfer_len; |
| 959 | void *data; |
| 960 | int cnt = 0; |
| 961 | __u32 info = 0; |
| 962 | unsigned int toggle = 0; |
| 963 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 964 | flush_dcache_buffer(buffer, data_len); |
| 965 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 966 | /* OHCI handles the DATA-toggles itself, we just use the USB-toggle |
Vagrant Cascadian | 259b1fb | 2016-10-23 20:45:19 -0700 | [diff] [blame] | 967 | * bits for resetting */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 968 | if (usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 969 | toggle = TD_T_TOGGLE; |
| 970 | } else { |
| 971 | toggle = TD_T_DATA0; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 972 | usb_settoggle(dev, usb_pipeendpoint(pipe), |
| 973 | usb_pipeout(pipe), 1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 974 | } |
| 975 | urb->td_cnt = 0; |
| 976 | if (data_len) |
| 977 | data = buffer; |
| 978 | else |
| 979 | data = 0; |
| 980 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 981 | switch (usb_pipetype(pipe)) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 982 | case PIPE_BULK: |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 983 | info = usb_pipeout(pipe)? |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 984 | TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 985 | while (data_len > 4096) { |
| 986 | td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), |
| 987 | data, 4096, dev, cnt, urb); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 988 | data += 4096; data_len -= 4096; cnt++; |
| 989 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 990 | info = usb_pipeout(pipe)? |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 991 | TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 992 | td_fill(ohci, info | (cnt? TD_T_TOGGLE:toggle), data, |
| 993 | data_len, dev, cnt, urb); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 994 | cnt++; |
| 995 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 996 | if (!ohci->sleeping) { |
| 997 | /* start bulk list */ |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 998 | ohci_writel(OHCI_BLF, &ohci->regs->cmdstatus); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 999 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1000 | break; |
| 1001 | |
| 1002 | case PIPE_CONTROL: |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1003 | /* Setup phase */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1004 | info = TD_CC | TD_DP_SETUP | TD_T_DATA0; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1005 | flush_dcache_buffer(setup, 8); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1006 | td_fill(ohci, info, setup, 8, dev, cnt++, urb); |
| 1007 | |
| 1008 | /* Optional Data phase */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1009 | if (data_len > 0) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1010 | info = usb_pipeout(pipe)? |
| 1011 | TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : |
| 1012 | TD_CC | TD_R | TD_DP_IN | TD_T_DATA1; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1013 | /* NOTE: mishandles transfers >8K, some >4K */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1014 | td_fill(ohci, info, data, data_len, dev, cnt++, urb); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1015 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1016 | |
| 1017 | /* Status phase */ |
Hans de Goede | 60f4bd0 | 2015-05-05 23:56:12 +0200 | [diff] [blame] | 1018 | info = (usb_pipeout(pipe) || data_len == 0) ? |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1019 | TD_CC | TD_DP_IN | TD_T_DATA1: |
| 1020 | TD_CC | TD_DP_OUT | TD_T_DATA1; |
| 1021 | td_fill(ohci, info, data, 0, dev, cnt++, urb); |
| 1022 | |
| 1023 | if (!ohci->sleeping) { |
| 1024 | /* start Control list */ |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1025 | ohci_writel(OHCI_CLF, &ohci->regs->cmdstatus); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1026 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1027 | break; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1028 | |
| 1029 | case PIPE_INTERRUPT: |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1030 | info = usb_pipeout(urb->pipe)? |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1031 | TD_CC | TD_DP_OUT | toggle: |
| 1032 | TD_CC | TD_R | TD_DP_IN | toggle; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1033 | td_fill(ohci, info, data, data_len, dev, cnt++, urb); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1034 | break; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1035 | } |
| 1036 | if (urb->length != cnt) |
| 1037 | dbg("TD LENGTH %d != CNT %d", urb->length, cnt); |
| 1038 | } |
| 1039 | |
| 1040 | /*-------------------------------------------------------------------------* |
| 1041 | * Done List handling functions |
| 1042 | *-------------------------------------------------------------------------*/ |
| 1043 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1044 | /* calculate the transfer length and update the urb */ |
| 1045 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1046 | static void dl_transfer_length(td_t *td) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1047 | { |
Wolfgang Denk | 0ef5f62 | 2011-10-05 23:03:43 +0200 | [diff] [blame] | 1048 | __u32 tdBE, tdCBP; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1049 | urb_priv_t *lurb_priv = td->ed->purb; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1050 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1051 | tdBE = m32_swap(td->hwBE); |
| 1052 | tdCBP = m32_swap(td->hwCBP); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1053 | |
Remy Bohmer | 47e7208 | 2008-10-10 10:23:21 +0200 | [diff] [blame] | 1054 | if (!(usb_pipecontrol(lurb_priv->pipe) && |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1055 | ((td->index == 0) || (td->index == lurb_priv->length - 1)))) { |
| 1056 | if (tdBE != 0) { |
| 1057 | if (td->hwCBP == 0) |
| 1058 | lurb_priv->actual_length += tdBE - td->data + 1; |
| 1059 | else |
| 1060 | lurb_priv->actual_length += tdCBP - td->data; |
| 1061 | } |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | /*-------------------------------------------------------------------------*/ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1066 | static void check_status(td_t *td_list) |
| 1067 | { |
| 1068 | urb_priv_t *lurb_priv = td_list->ed->purb; |
| 1069 | int urb_len = lurb_priv->length; |
| 1070 | __u32 *phwHeadP = &td_list->ed->hwHeadP; |
| 1071 | int cc; |
| 1072 | |
| 1073 | cc = TD_CC_GET(m32_swap(td_list->hwINFO)); |
| 1074 | if (cc) { |
| 1075 | err(" USB-error: %s (%x)", cc_to_string[cc], cc); |
| 1076 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1077 | invalidate_dcache_ed(td_list->ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1078 | if (*phwHeadP & m32_swap(0x1)) { |
| 1079 | if (lurb_priv && |
| 1080 | ((td_list->index + 1) < urb_len)) { |
| 1081 | *phwHeadP = |
| 1082 | (lurb_priv->td[urb_len - 1]->hwNextTD &\ |
| 1083 | m32_swap(0xfffffff0)) | |
| 1084 | (*phwHeadP & m32_swap(0x2)); |
| 1085 | |
| 1086 | lurb_priv->td_cnt += urb_len - |
| 1087 | td_list->index - 1; |
| 1088 | } else |
| 1089 | *phwHeadP &= m32_swap(0xfffffff2); |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1090 | flush_dcache_ed(td_list->ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1091 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1092 | } |
| 1093 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1094 | |
| 1095 | /* replies to the request have to be on a FIFO basis so |
| 1096 | * we reverse the reversed done-list */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1097 | static td_t *dl_reverse_done_list(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1098 | { |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 1099 | uintptr_t td_list_hc; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1100 | td_t *td_rev = NULL; |
| 1101 | td_t *td_list = NULL; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1102 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1103 | invalidate_dcache_hcca(ohci->hcca); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1104 | td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1105 | ohci->hcca->done_head = 0; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1106 | flush_dcache_hcca(ohci->hcca); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1107 | |
| 1108 | while (td_list_hc) { |
| 1109 | td_list = (td_t *)td_list_hc; |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1110 | invalidate_dcache_td(td_list); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1111 | check_status(td_list); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1112 | td_list->next_dl_td = td_rev; |
| 1113 | td_rev = td_list; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1114 | td_list_hc = m32_swap(td_list->hwNextTD) & 0xfffffff0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1115 | } |
| 1116 | return td_list; |
| 1117 | } |
| 1118 | |
| 1119 | /*-------------------------------------------------------------------------*/ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1120 | /*-------------------------------------------------------------------------*/ |
| 1121 | |
| 1122 | static void finish_urb(ohci_t *ohci, urb_priv_t *urb, int status) |
| 1123 | { |
| 1124 | if ((status & (ED_OPER | ED_UNLINK)) && (urb->state != URB_DEL)) |
Hans de Goede | 2787337 | 2015-05-10 14:10:22 +0200 | [diff] [blame] | 1125 | urb->finished = 1; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1126 | else |
| 1127 | dbg("finish_urb: strange.., ED state %x, \n", status); |
| 1128 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1129 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1130 | /* |
| 1131 | * Used to take back a TD from the host controller. This would normally be |
| 1132 | * called from within dl_done_list, however it may be called directly if the |
| 1133 | * HC no longer sees the TD and it has not appeared on the donelist (after |
| 1134 | * two frames). This bug has been observed on ZF Micro systems. |
| 1135 | */ |
| 1136 | static int takeback_td(ohci_t *ohci, td_t *td_list) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1137 | { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1138 | ed_t *ed; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1139 | int cc; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1140 | int stat = 0; |
| 1141 | /* urb_t *urb; */ |
| 1142 | urb_priv_t *lurb_priv; |
| 1143 | __u32 tdINFO, edHeadP, edTailP; |
| 1144 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1145 | invalidate_dcache_td(td_list); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1146 | tdINFO = m32_swap(td_list->hwINFO); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1147 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1148 | ed = td_list->ed; |
| 1149 | lurb_priv = ed->purb; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1150 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1151 | dl_transfer_length(td_list); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1152 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1153 | lurb_priv->td_cnt++; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1154 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1155 | /* error code of transfer */ |
| 1156 | cc = TD_CC_GET(tdINFO); |
| 1157 | if (cc) { |
| 1158 | err("USB-error: %s (%x)", cc_to_string[cc], cc); |
| 1159 | stat = cc_to_error[cc]; |
| 1160 | } |
Markus Klotzbuecher | e3af6d5 | 2007-03-26 11:21:05 +0200 | [diff] [blame] | 1161 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1162 | /* see if this done list makes for all TD's of current URB, |
| 1163 | * and mark the URB finished if so */ |
| 1164 | if (lurb_priv->td_cnt == lurb_priv->length) |
| 1165 | finish_urb(ohci, lurb_priv, ed->state); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1166 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1167 | dbg("dl_done_list: processing TD %x, len %x\n", |
| 1168 | lurb_priv->td_cnt, lurb_priv->length); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1169 | |
Remy Bohmer | 47e7208 | 2008-10-10 10:23:21 +0200 | [diff] [blame] | 1170 | if (ed->state != ED_NEW && (!usb_pipeint(lurb_priv->pipe))) { |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1171 | invalidate_dcache_ed(ed); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1172 | edHeadP = m32_swap(ed->hwHeadP) & 0xfffffff0; |
| 1173 | edTailP = m32_swap(ed->hwTailP); |
| 1174 | |
| 1175 | /* unlink eds if they are not busy */ |
| 1176 | if ((edHeadP == edTailP) && (ed->state == ED_OPER)) |
| 1177 | ep_unlink(ohci, ed); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1178 | } |
| 1179 | return stat; |
| 1180 | } |
| 1181 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1182 | static int dl_done_list(ohci_t *ohci) |
| 1183 | { |
| 1184 | int stat = 0; |
| 1185 | td_t *td_list = dl_reverse_done_list(ohci); |
| 1186 | |
| 1187 | while (td_list) { |
| 1188 | td_t *td_next = td_list->next_dl_td; |
| 1189 | stat = takeback_td(ohci, td_list); |
| 1190 | td_list = td_next; |
| 1191 | } |
| 1192 | return stat; |
| 1193 | } |
| 1194 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1195 | /*-------------------------------------------------------------------------* |
| 1196 | * Virtual Root Hub |
| 1197 | *-------------------------------------------------------------------------*/ |
| 1198 | |
Stephen Warren | 39c8968 | 2014-02-13 21:15:18 -0700 | [diff] [blame] | 1199 | #include <usbroothubdes.h> |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1200 | |
| 1201 | /* Hub class-specific descriptor is constructed dynamically */ |
| 1202 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1203 | /*-------------------------------------------------------------------------*/ |
| 1204 | |
| 1205 | #define OK(x) len = (x); break |
| 1206 | #ifdef DEBUG |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1207 | #define WR_RH_STAT(x) {info("WR:status %#8x", (x)); ohci_writel((x), \ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1208 | &ohci->regs->roothub.status); } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1209 | #define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, \ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1210 | (x)); ohci_writel((x), &ohci->regs->roothub.portstatus[wIndex-1]); } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1211 | #else |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1212 | #define WR_RH_STAT(x) ohci_writel((x), &ohci->regs->roothub.status) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1213 | #define WR_RH_PORTSTAT(x) ohci_writel((x), \ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1214 | &ohci->regs->roothub.portstatus[wIndex-1]) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1215 | #endif |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1216 | #define RD_RH_STAT roothub_status(ohci) |
| 1217 | #define RD_RH_PORTSTAT roothub_portstatus(ohci, wIndex-1) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1218 | |
| 1219 | /* request to virtual root hub */ |
| 1220 | |
| 1221 | int rh_check_port_status(ohci_t *controller) |
| 1222 | { |
| 1223 | __u32 temp, ndp, i; |
| 1224 | int res; |
| 1225 | |
| 1226 | res = -1; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1227 | temp = roothub_a(controller); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1228 | ndp = (temp & RH_A_NDP); |
| 1229 | #ifdef CONFIG_AT91C_PQFP_UHPBUG |
| 1230 | ndp = (ndp == 2) ? 1:0; |
| 1231 | #endif |
| 1232 | for (i = 0; i < ndp; i++) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1233 | temp = roothub_portstatus(controller, i); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1234 | /* check for a device disconnect */ |
| 1235 | if (((temp & (RH_PS_PESC | RH_PS_CSC)) == |
| 1236 | (RH_PS_PESC | RH_PS_CSC)) && |
| 1237 | ((temp & RH_PS_CCS) == 0)) { |
| 1238 | res = i; |
| 1239 | break; |
| 1240 | } |
| 1241 | } |
| 1242 | return res; |
| 1243 | } |
| 1244 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1245 | static int ohci_submit_rh_msg(ohci_t *ohci, struct usb_device *dev, |
| 1246 | unsigned long pipe, void *buffer, int transfer_len, |
| 1247 | struct devrequest *cmd) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1248 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1249 | void *data = buffer; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1250 | int leni = transfer_len; |
| 1251 | int len = 0; |
| 1252 | int stat = 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1253 | __u16 bmRType_bReq; |
| 1254 | __u16 wValue; |
| 1255 | __u16 wIndex; |
| 1256 | __u16 wLength; |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1257 | ALLOC_ALIGN_BUFFER(__u8, databuf, 16, sizeof(u32)); |
Marek Vasut | fc5cf88 | 2011-10-07 02:00:13 +0200 | [diff] [blame] | 1258 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1259 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1260 | pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1261 | cmd, "SUB(rh)", usb_pipein(pipe)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1262 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1263 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1264 | #endif |
Remy Bohmer | 47e7208 | 2008-10-10 10:23:21 +0200 | [diff] [blame] | 1265 | if (usb_pipeint(pipe)) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1266 | info("Root-Hub submit IRQ: NOT implemented"); |
| 1267 | return 0; |
| 1268 | } |
| 1269 | |
| 1270 | bmRType_bReq = cmd->requesttype | (cmd->request << 8); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1271 | wValue = le16_to_cpu(cmd->value); |
| 1272 | wIndex = le16_to_cpu(cmd->index); |
| 1273 | wLength = le16_to_cpu(cmd->length); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1274 | |
| 1275 | info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x", |
| 1276 | dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength); |
| 1277 | |
| 1278 | switch (bmRType_bReq) { |
| 1279 | /* Request Destination: |
| 1280 | without flags: Device, |
| 1281 | RH_INTERFACE: interface, |
| 1282 | RH_ENDPOINT: endpoint, |
| 1283 | RH_CLASS means HUB here, |
| 1284 | RH_OTHER | RH_CLASS almost ever means HUB_PORT here |
| 1285 | */ |
| 1286 | |
| 1287 | case RH_GET_STATUS: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1288 | *(u16 *)databuf = cpu_to_le16(1); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1289 | OK(2); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1290 | case RH_GET_STATUS | RH_INTERFACE: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1291 | *(u16 *)databuf = cpu_to_le16(0); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1292 | OK(2); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1293 | case RH_GET_STATUS | RH_ENDPOINT: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1294 | *(u16 *)databuf = cpu_to_le16(0); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1295 | OK(2); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1296 | case RH_GET_STATUS | RH_CLASS: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1297 | *(u32 *)databuf = cpu_to_le32( |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1298 | RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE)); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1299 | OK(4); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1300 | case RH_GET_STATUS | RH_OTHER | RH_CLASS: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1301 | *(u32 *)databuf = cpu_to_le32(RD_RH_PORTSTAT); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1302 | OK(4); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1303 | |
| 1304 | case RH_CLEAR_FEATURE | RH_ENDPOINT: |
| 1305 | switch (wValue) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1306 | case (RH_ENDPOINT_STALL): |
| 1307 | OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1308 | } |
| 1309 | break; |
| 1310 | |
| 1311 | case RH_CLEAR_FEATURE | RH_CLASS: |
| 1312 | switch (wValue) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1313 | case RH_C_HUB_LOCAL_POWER: |
| 1314 | OK(0); |
| 1315 | case (RH_C_HUB_OVER_CURRENT): |
| 1316 | WR_RH_STAT(RH_HS_OCIC); |
| 1317 | OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1318 | } |
| 1319 | break; |
| 1320 | |
| 1321 | case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS: |
| 1322 | switch (wValue) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1323 | case (RH_PORT_ENABLE): WR_RH_PORTSTAT(RH_PS_CCS); OK(0); |
| 1324 | case (RH_PORT_SUSPEND): WR_RH_PORTSTAT(RH_PS_POCI); OK(0); |
| 1325 | case (RH_PORT_POWER): WR_RH_PORTSTAT(RH_PS_LSDA); OK(0); |
| 1326 | case (RH_C_PORT_CONNECTION): WR_RH_PORTSTAT(RH_PS_CSC); OK(0); |
| 1327 | case (RH_C_PORT_ENABLE): WR_RH_PORTSTAT(RH_PS_PESC); OK(0); |
| 1328 | case (RH_C_PORT_SUSPEND): WR_RH_PORTSTAT(RH_PS_PSSC); OK(0); |
| 1329 | case (RH_C_PORT_OVER_CURRENT):WR_RH_PORTSTAT(RH_PS_OCIC); OK(0); |
| 1330 | case (RH_C_PORT_RESET): WR_RH_PORTSTAT(RH_PS_PRSC); OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1331 | } |
| 1332 | break; |
| 1333 | |
| 1334 | case RH_SET_FEATURE | RH_OTHER | RH_CLASS: |
| 1335 | switch (wValue) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1336 | case (RH_PORT_SUSPEND): |
| 1337 | WR_RH_PORTSTAT(RH_PS_PSS); OK(0); |
| 1338 | case (RH_PORT_RESET): /* BUG IN HUP CODE *********/ |
| 1339 | if (RD_RH_PORTSTAT & RH_PS_CCS) |
| 1340 | WR_RH_PORTSTAT(RH_PS_PRS); |
| 1341 | OK(0); |
| 1342 | case (RH_PORT_POWER): |
| 1343 | WR_RH_PORTSTAT(RH_PS_PPS); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1344 | OK(0); |
| 1345 | case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/ |
| 1346 | if (RD_RH_PORTSTAT & RH_PS_CCS) |
| 1347 | WR_RH_PORTSTAT(RH_PS_PES); |
| 1348 | OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1349 | } |
| 1350 | break; |
| 1351 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1352 | case RH_SET_ADDRESS: |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1353 | ohci->rh.devnum = wValue; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1354 | OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1355 | |
| 1356 | case RH_GET_DESCRIPTOR: |
| 1357 | switch ((wValue & 0xff00) >> 8) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1358 | case (0x01): /* device descriptor */ |
| 1359 | len = min_t(unsigned int, |
| 1360 | leni, |
| 1361 | min_t(unsigned int, |
| 1362 | sizeof(root_hub_dev_des), |
| 1363 | wLength)); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1364 | databuf = root_hub_dev_des; OK(len); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1365 | case (0x02): /* configuration descriptor */ |
| 1366 | len = min_t(unsigned int, |
| 1367 | leni, |
| 1368 | min_t(unsigned int, |
| 1369 | sizeof(root_hub_config_des), |
| 1370 | wLength)); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1371 | databuf = root_hub_config_des; OK(len); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1372 | case (0x03): /* string descriptors */ |
| 1373 | if (wValue == 0x0300) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1374 | len = min_t(unsigned int, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1375 | leni, |
| 1376 | min_t(unsigned int, |
| 1377 | sizeof(root_hub_str_index0), |
| 1378 | wLength)); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1379 | databuf = root_hub_str_index0; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1380 | OK(len); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1381 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1382 | if (wValue == 0x0301) { |
| 1383 | len = min_t(unsigned int, |
| 1384 | leni, |
| 1385 | min_t(unsigned int, |
| 1386 | sizeof(root_hub_str_index1), |
| 1387 | wLength)); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1388 | databuf = root_hub_str_index1; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1389 | OK(len); |
| 1390 | } |
| 1391 | default: |
| 1392 | stat = USB_ST_STALLED; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1393 | } |
| 1394 | break; |
| 1395 | |
| 1396 | case RH_GET_DESCRIPTOR | RH_CLASS: |
| 1397 | { |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1398 | __u32 temp = roothub_a(ohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1399 | |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1400 | databuf[0] = 9; /* min length; */ |
| 1401 | databuf[1] = 0x29; |
| 1402 | databuf[2] = temp & RH_A_NDP; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1403 | #ifdef CONFIG_AT91C_PQFP_UHPBUG |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1404 | databuf[2] = (databuf[2] == 2) ? 1 : 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1405 | #endif |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1406 | databuf[3] = 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1407 | if (temp & RH_A_PSM) /* per-port power switching? */ |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1408 | databuf[3] |= 0x1; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1409 | if (temp & RH_A_NOCP) /* no overcurrent reporting? */ |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1410 | databuf[3] |= 0x10; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1411 | else if (temp & RH_A_OCPM)/* per-port overcurrent reporting? */ |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1412 | databuf[3] |= 0x8; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1413 | |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1414 | databuf[4] = 0; |
| 1415 | databuf[5] = (temp & RH_A_POTPGT) >> 24; |
| 1416 | databuf[6] = 0; |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1417 | temp = roothub_b(ohci); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1418 | databuf[7] = temp & RH_B_DR; |
| 1419 | if (databuf[2] < 7) { |
| 1420 | databuf[8] = 0xff; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1421 | } else { |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1422 | databuf[0] += 2; |
| 1423 | databuf[8] = (temp & RH_B_DR) >> 8; |
| 1424 | databuf[10] = databuf[9] = 0xff; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | len = min_t(unsigned int, leni, |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1428 | min_t(unsigned int, databuf[0], wLength)); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1429 | OK(len); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1430 | } |
| 1431 | |
Marek Vasut | fc5cf88 | 2011-10-07 02:00:13 +0200 | [diff] [blame] | 1432 | case RH_GET_CONFIGURATION: |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1433 | databuf[0] = 0x01; |
Marek Vasut | fc5cf88 | 2011-10-07 02:00:13 +0200 | [diff] [blame] | 1434 | OK(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1435 | |
Marek Vasut | fc5cf88 | 2011-10-07 02:00:13 +0200 | [diff] [blame] | 1436 | case RH_SET_CONFIGURATION: |
| 1437 | WR_RH_STAT(0x10000); |
| 1438 | OK(0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1439 | |
| 1440 | default: |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1441 | dbg("unsupported root hub command"); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1442 | stat = USB_ST_STALLED; |
| 1443 | } |
| 1444 | |
| 1445 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1446 | ohci_dump_roothub(ohci, 1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1447 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1448 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1449 | #endif |
| 1450 | |
| 1451 | len = min_t(int, len, leni); |
Troy Kisky | 62c1c7c | 2012-08-11 14:49:09 -0700 | [diff] [blame] | 1452 | if (data != databuf) |
| 1453 | memcpy(data, databuf, len); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1454 | dev->act_len = len; |
| 1455 | dev->status = stat; |
| 1456 | |
| 1457 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1458 | pkt_print(ohci, NULL, dev, pipe, buffer, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1459 | transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1460 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1461 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1462 | #endif |
| 1463 | |
| 1464 | return stat; |
| 1465 | } |
| 1466 | |
| 1467 | /*-------------------------------------------------------------------------*/ |
| 1468 | |
Hans de Goede | d7a3942 | 2015-05-13 14:42:15 +0200 | [diff] [blame] | 1469 | static ohci_dev_t *ohci_get_ohci_dev(ohci_t *ohci, int devnum, int intr) |
| 1470 | { |
| 1471 | int i; |
| 1472 | |
| 1473 | if (!intr) |
| 1474 | return &ohci->ohci_dev; |
| 1475 | |
| 1476 | /* First see if we already have an ohci_dev for this dev. */ |
| 1477 | for (i = 0; i < NUM_INT_DEVS; i++) { |
| 1478 | if (ohci->int_dev[i].devnum == devnum) |
| 1479 | return &ohci->int_dev[i]; |
| 1480 | } |
| 1481 | |
| 1482 | /* If not then find a free one. */ |
| 1483 | for (i = 0; i < NUM_INT_DEVS; i++) { |
| 1484 | if (ohci->int_dev[i].devnum == -1) { |
| 1485 | ohci->int_dev[i].devnum = devnum; |
| 1486 | return &ohci->int_dev[i]; |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | printf("ohci: Error out of ohci_devs for interrupt endpoints\n"); |
| 1491 | return NULL; |
| 1492 | } |
| 1493 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1494 | /* common code for handling submit messages - used for all but root hub */ |
| 1495 | /* accesses. */ |
Hans de Goede | 66b1d6d | 2015-05-13 14:42:16 +0200 | [diff] [blame] | 1496 | static urb_priv_t *ohci_alloc_urb(struct usb_device *dev, unsigned long pipe, |
| 1497 | void *buffer, int transfer_len, int interval) |
| 1498 | { |
| 1499 | urb_priv_t *urb; |
| 1500 | |
| 1501 | urb = calloc(1, sizeof(urb_priv_t)); |
| 1502 | if (!urb) { |
| 1503 | printf("ohci: Error out of memory allocating urb\n"); |
| 1504 | return NULL; |
| 1505 | } |
| 1506 | |
| 1507 | urb->dev = dev; |
| 1508 | urb->pipe = pipe; |
| 1509 | urb->transfer_buffer = buffer; |
| 1510 | urb->transfer_buffer_length = transfer_len; |
| 1511 | urb->interval = interval; |
| 1512 | |
| 1513 | return urb; |
| 1514 | } |
| 1515 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1516 | static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, |
| 1517 | unsigned long pipe, void *buffer, int transfer_len, |
| 1518 | struct devrequest *setup, int interval) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1519 | { |
| 1520 | int stat = 0; |
| 1521 | int maxsize = usb_maxpacket(dev, pipe); |
| 1522 | int timeout; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1523 | urb_priv_t *urb; |
Hans de Goede | d7a3942 | 2015-05-13 14:42:15 +0200 | [diff] [blame] | 1524 | ohci_dev_t *ohci_dev; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1525 | |
Hans de Goede | 66b1d6d | 2015-05-13 14:42:16 +0200 | [diff] [blame] | 1526 | urb = ohci_alloc_urb(dev, pipe, buffer, transfer_len, interval); |
| 1527 | if (!urb) |
| 1528 | return -ENOMEM; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1529 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1530 | #ifdef DEBUG |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1531 | urb->actual_length = 0; |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1532 | pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1533 | setup, "SUB", usb_pipein(pipe)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1534 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1535 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1536 | #endif |
| 1537 | if (!maxsize) { |
| 1538 | err("submit_common_message: pipesize for pipe %lx is zero", |
| 1539 | pipe); |
| 1540 | return -1; |
| 1541 | } |
| 1542 | |
Hans de Goede | d7a3942 | 2015-05-13 14:42:15 +0200 | [diff] [blame] | 1543 | ohci_dev = ohci_get_ohci_dev(ohci, dev->devnum, usb_pipeint(pipe)); |
| 1544 | if (!ohci_dev) |
| 1545 | return -ENOMEM; |
| 1546 | |
| 1547 | if (sohci_submit_job(ohci, ohci_dev, urb, setup) < 0) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1548 | err("sohci_submit_job failed"); |
| 1549 | return -1; |
| 1550 | } |
| 1551 | |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1552 | mdelay(10); |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1553 | /* ohci_dump_status(ohci); */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1554 | |
Simon Glass | fd7f513 | 2011-02-07 14:42:16 -0800 | [diff] [blame] | 1555 | timeout = USB_TIMEOUT_MS(pipe); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1556 | |
| 1557 | /* wait for it to complete */ |
| 1558 | for (;;) { |
| 1559 | /* check whether the controller is done */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1560 | stat = hc_interrupt(ohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1561 | if (stat < 0) { |
| 1562 | stat = USB_ST_CRC_ERR; |
| 1563 | break; |
| 1564 | } |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1565 | |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1566 | /* NOTE: since we are not interrupt driven in U-Boot and always |
| 1567 | * handle only one URB at a time, we cannot assume the |
| 1568 | * transaction finished on the first successful return from |
| 1569 | * hc_interrupt().. unless the flag for current URB is set, |
| 1570 | * meaning that all TD's to/from device got actually |
| 1571 | * transferred and processed. If the current URB is not |
| 1572 | * finished we need to re-iterate this loop so as |
| 1573 | * hc_interrupt() gets called again as there needs to be some |
| 1574 | * more TD's to process still */ |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1575 | if ((stat >= 0) && (stat != 0xff) && (urb->finished)) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1576 | /* 0xff is returned for an SF-interrupt */ |
| 1577 | break; |
| 1578 | } |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1579 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1580 | if (--timeout) { |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1581 | mdelay(1); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1582 | if (!urb->finished) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1583 | dbg("*"); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1584 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1585 | } else { |
Hans de Goede | d98dc99 | 2015-05-05 23:56:14 +0200 | [diff] [blame] | 1586 | if (!usb_pipeint(pipe)) |
| 1587 | err("CTL:TIMEOUT "); |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1588 | dbg("submit_common_msg: TO status %x\n", stat); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 1589 | urb->finished = 1; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1590 | stat = USB_ST_CRC_ERR; |
| 1591 | break; |
| 1592 | } |
| 1593 | } |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1594 | |
| 1595 | dev->status = stat; |
Mateusz Kulikowski | 10b479d | 2013-10-23 20:26:27 +0200 | [diff] [blame] | 1596 | dev->act_len = urb->actual_length; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1597 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1598 | if (usb_pipein(pipe) && dev->status == 0 && dev->act_len) |
| 1599 | invalidate_dcache_buffer(buffer, dev->act_len); |
| 1600 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1601 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1602 | pkt_print(ohci, urb, dev, pipe, buffer, transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1603 | setup, "RET(ctlr)", usb_pipein(pipe)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1604 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1605 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1606 | #endif |
Hans de Goede | 2787337 | 2015-05-10 14:10:22 +0200 | [diff] [blame] | 1607 | urb_free_priv(urb); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1608 | return 0; |
| 1609 | } |
| 1610 | |
Hans de Goede | 5477e6f | 2015-05-13 14:42:17 +0200 | [diff] [blame] | 1611 | #define MAX_INT_QUEUESIZE 8 |
| 1612 | |
| 1613 | struct int_queue { |
| 1614 | int queuesize; |
| 1615 | int curr_urb; |
| 1616 | urb_priv_t *urb[MAX_INT_QUEUESIZE]; |
| 1617 | }; |
| 1618 | |
| 1619 | static struct int_queue *_ohci_create_int_queue(ohci_t *ohci, |
| 1620 | struct usb_device *udev, unsigned long pipe, int queuesize, |
| 1621 | int elementsize, void *buffer, int interval) |
| 1622 | { |
| 1623 | struct int_queue *queue; |
| 1624 | ohci_dev_t *ohci_dev; |
| 1625 | int i; |
| 1626 | |
| 1627 | if (queuesize > MAX_INT_QUEUESIZE) |
| 1628 | return NULL; |
| 1629 | |
| 1630 | ohci_dev = ohci_get_ohci_dev(ohci, udev->devnum, 1); |
| 1631 | if (!ohci_dev) |
| 1632 | return NULL; |
| 1633 | |
| 1634 | queue = malloc(sizeof(*queue)); |
| 1635 | if (!queue) { |
| 1636 | printf("ohci: Error out of memory allocating int queue\n"); |
| 1637 | return NULL; |
| 1638 | } |
| 1639 | |
| 1640 | for (i = 0; i < queuesize; i++) { |
| 1641 | queue->urb[i] = ohci_alloc_urb(udev, pipe, |
| 1642 | buffer + i * elementsize, |
| 1643 | elementsize, interval); |
| 1644 | if (!queue->urb[i]) |
| 1645 | break; |
| 1646 | |
| 1647 | if (sohci_submit_job(ohci, ohci_dev, queue->urb[i], NULL)) { |
| 1648 | printf("ohci: Error submitting int queue job\n"); |
| 1649 | urb_free_priv(queue->urb[i]); |
| 1650 | break; |
| 1651 | } |
| 1652 | } |
| 1653 | if (i == 0) { |
| 1654 | /* We did not succeed in submitting even 1 urb */ |
| 1655 | free(queue); |
| 1656 | return NULL; |
| 1657 | } |
| 1658 | |
| 1659 | queue->queuesize = i; |
| 1660 | queue->curr_urb = 0; |
| 1661 | |
| 1662 | return queue; |
| 1663 | } |
| 1664 | |
| 1665 | static void *_ohci_poll_int_queue(ohci_t *ohci, struct usb_device *udev, |
| 1666 | struct int_queue *queue) |
| 1667 | { |
| 1668 | if (queue->curr_urb == queue->queuesize) |
| 1669 | return NULL; /* Queue depleted */ |
| 1670 | |
| 1671 | if (hc_interrupt(ohci) < 0) |
| 1672 | return NULL; |
| 1673 | |
| 1674 | if (queue->urb[queue->curr_urb]->finished) { |
| 1675 | void *ret = queue->urb[queue->curr_urb]->transfer_buffer; |
| 1676 | queue->curr_urb++; |
| 1677 | return ret; |
| 1678 | } |
| 1679 | |
| 1680 | return NULL; |
| 1681 | } |
| 1682 | |
| 1683 | static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, |
| 1684 | struct int_queue *queue) |
| 1685 | { |
| 1686 | int i; |
| 1687 | |
| 1688 | for (i = 0; i < queue->queuesize; i++) |
| 1689 | urb_free_priv(queue->urb[i]); |
| 1690 | |
| 1691 | free(queue); |
| 1692 | |
| 1693 | return 0; |
| 1694 | } |
| 1695 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 1696 | #if !CONFIG_IS_ENABLED(DM_USB) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1697 | /* submit routines called from usb.c */ |
| 1698 | int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
| 1699 | int transfer_len) |
| 1700 | { |
| 1701 | info("submit_bulk_msg"); |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1702 | return submit_common_msg(&gohci, dev, pipe, buffer, transfer_len, |
| 1703 | NULL, 0); |
| 1704 | } |
| 1705 | |
| 1706 | int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, |
Michal Suchanek | 1c95b9f | 2019-08-18 10:55:27 +0200 | [diff] [blame] | 1707 | int transfer_len, int interval, bool nonblock) |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1708 | { |
| 1709 | info("submit_int_msg"); |
| 1710 | return submit_common_msg(&gohci, dev, pipe, buffer, transfer_len, NULL, |
| 1711 | interval); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1712 | } |
Hans de Goede | 5477e6f | 2015-05-13 14:42:17 +0200 | [diff] [blame] | 1713 | |
| 1714 | struct int_queue *create_int_queue(struct usb_device *dev, |
| 1715 | unsigned long pipe, int queuesize, int elementsize, |
| 1716 | void *buffer, int interval) |
| 1717 | { |
| 1718 | return _ohci_create_int_queue(&gohci, dev, pipe, queuesize, |
| 1719 | elementsize, buffer, interval); |
| 1720 | } |
| 1721 | |
| 1722 | void *poll_int_queue(struct usb_device *dev, struct int_queue *queue) |
| 1723 | { |
| 1724 | return _ohci_poll_int_queue(&gohci, dev, queue); |
| 1725 | } |
| 1726 | |
| 1727 | int destroy_int_queue(struct usb_device *dev, struct int_queue *queue) |
| 1728 | { |
| 1729 | return _ohci_destroy_int_queue(&gohci, dev, queue); |
| 1730 | } |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 1731 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1732 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1733 | static int _ohci_submit_control_msg(ohci_t *ohci, struct usb_device *dev, |
| 1734 | unsigned long pipe, void *buffer, int transfer_len, |
| 1735 | struct devrequest *setup) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1736 | { |
| 1737 | int maxsize = usb_maxpacket(dev, pipe); |
| 1738 | |
| 1739 | info("submit_control_msg"); |
| 1740 | #ifdef DEBUG |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1741 | pkt_print(ohci, NULL, dev, pipe, buffer, transfer_len, |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1742 | setup, "SUB", usb_pipein(pipe)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1743 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1744 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1745 | #endif |
| 1746 | if (!maxsize) { |
| 1747 | err("submit_control_message: pipesize for pipe %lx is zero", |
| 1748 | pipe); |
| 1749 | return -1; |
| 1750 | } |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1751 | if (((pipe >> 8) & 0x7f) == ohci->rh.devnum) { |
| 1752 | ohci->rh.dev = dev; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1753 | /* root hub - redirect */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1754 | return ohci_submit_rh_msg(ohci, dev, pipe, buffer, |
| 1755 | transfer_len, setup); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1756 | } |
| 1757 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1758 | return submit_common_msg(ohci, dev, pipe, buffer, transfer_len, |
| 1759 | setup, 0); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1760 | } |
| 1761 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1762 | /*-------------------------------------------------------------------------* |
| 1763 | * HC functions |
| 1764 | *-------------------------------------------------------------------------*/ |
| 1765 | |
| 1766 | /* reset the HC and BUS */ |
| 1767 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1768 | static int hc_reset(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1769 | { |
Yuri Tikhonov | 11af42c | 2008-09-04 11:19:05 +0200 | [diff] [blame] | 1770 | #ifdef CONFIG_PCI_EHCI_DEVNO |
| 1771 | pci_dev_t pdev; |
| 1772 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1773 | int timeout = 30; |
| 1774 | int smm_timeout = 50; /* 0,5 sec */ |
| 1775 | |
| 1776 | dbg("%s\n", __FUNCTION__); |
| 1777 | |
Yuri Tikhonov | 11af42c | 2008-09-04 11:19:05 +0200 | [diff] [blame] | 1778 | #ifdef CONFIG_PCI_EHCI_DEVNO |
| 1779 | /* |
| 1780 | * Some multi-function controllers (e.g. ISP1562) allow root hub |
| 1781 | * resetting via EHCI registers only. |
| 1782 | */ |
| 1783 | pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVNO); |
| 1784 | if (pdev != -1) { |
| 1785 | u32 base; |
| 1786 | int timeout = 1000; |
| 1787 | |
| 1788 | pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1789 | base += EHCI_USBCMD_OFF; |
| 1790 | ohci_writel(ohci_readl(base) | EHCI_USBCMD_HCRESET, base); |
Yuri Tikhonov | 11af42c | 2008-09-04 11:19:05 +0200 | [diff] [blame] | 1791 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1792 | while (ohci_readl(base) & EHCI_USBCMD_HCRESET) { |
Yuri Tikhonov | 11af42c | 2008-09-04 11:19:05 +0200 | [diff] [blame] | 1793 | if (timeout-- <= 0) { |
| 1794 | printf("USB RootHub reset timed out!"); |
| 1795 | break; |
| 1796 | } |
| 1797 | udelay(1); |
| 1798 | } |
| 1799 | } else |
| 1800 | printf("No EHCI func at %d index!\n", CONFIG_PCI_EHCI_DEVNO); |
| 1801 | #endif |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1802 | if (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { |
| 1803 | /* SMM owns the HC, request ownership */ |
| 1804 | ohci_writel(OHCI_OCR, &ohci->regs->cmdstatus); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1805 | info("USB HC TakeOver from SMM"); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1806 | while (ohci_readl(&ohci->regs->control) & OHCI_CTRL_IR) { |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1807 | mdelay(10); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1808 | if (--smm_timeout == 0) { |
| 1809 | err("USB HC TakeOver failed!"); |
| 1810 | return -1; |
| 1811 | } |
| 1812 | } |
| 1813 | } |
| 1814 | |
| 1815 | /* Disable HC interrupts */ |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1816 | ohci_writel(OHCI_INTR_MIE, &ohci->regs->intrdisable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1817 | |
| 1818 | dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;\n", |
| 1819 | ohci->slot_name, |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1820 | ohci_readl(&ohci->regs->control)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1821 | |
| 1822 | /* Reset USB (needed by some controllers) */ |
Markus Klotzbuecher | 661ffe5 | 2006-11-27 11:43:09 +0100 | [diff] [blame] | 1823 | ohci->hc_control = 0; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1824 | ohci_writel(ohci->hc_control, &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1825 | |
| 1826 | /* HC Reset requires max 10 us delay */ |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1827 | ohci_writel(OHCI_HCR, &ohci->regs->cmdstatus); |
| 1828 | while ((ohci_readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1829 | if (--timeout == 0) { |
| 1830 | err("USB HC reset timed out!"); |
| 1831 | return -1; |
| 1832 | } |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1833 | udelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1834 | } |
| 1835 | return 0; |
| 1836 | } |
| 1837 | |
| 1838 | /*-------------------------------------------------------------------------*/ |
| 1839 | |
| 1840 | /* Start an OHCI controller, set the BUS operational |
| 1841 | * enable interrupts |
| 1842 | * connect the virtual root hub */ |
| 1843 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1844 | static int hc_start(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1845 | { |
| 1846 | __u32 mask; |
| 1847 | unsigned int fminterval; |
Hans de Goede | d7a3942 | 2015-05-13 14:42:15 +0200 | [diff] [blame] | 1848 | int i; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1849 | |
| 1850 | ohci->disabled = 1; |
Hans de Goede | d7a3942 | 2015-05-13 14:42:15 +0200 | [diff] [blame] | 1851 | for (i = 0; i < NUM_INT_DEVS; i++) |
| 1852 | ohci->int_dev[i].devnum = -1; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1853 | |
| 1854 | /* Tell the controller where the control and bulk lists are |
| 1855 | * The lists are empty now. */ |
| 1856 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1857 | ohci_writel(0, &ohci->regs->ed_controlhead); |
| 1858 | ohci_writel(0, &ohci->regs->ed_bulkhead); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1859 | |
Andre Przywara | c114a98 | 2016-10-21 02:24:29 +0100 | [diff] [blame] | 1860 | ohci_writel((uintptr_t)ohci->hcca, |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1861 | &ohci->regs->hcca); /* reset clears this */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1862 | |
| 1863 | fminterval = 0x2edf; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1864 | ohci_writel((fminterval * 9) / 10, &ohci->regs->periodicstart); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1865 | fminterval |= ((((fminterval - 210) * 6) / 7) << 16); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1866 | ohci_writel(fminterval, &ohci->regs->fminterval); |
| 1867 | ohci_writel(0x628, &ohci->regs->lsthresh); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1868 | |
| 1869 | /* start controller operations */ |
| 1870 | ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; |
| 1871 | ohci->disabled = 0; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1872 | ohci_writel(ohci->hc_control, &ohci->regs->control); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1873 | |
| 1874 | /* disable all interrupts */ |
| 1875 | mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD | |
| 1876 | OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC | |
| 1877 | OHCI_INTR_OC | OHCI_INTR_MIE); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1878 | ohci_writel(mask, &ohci->regs->intrdisable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1879 | /* clear all interrupts */ |
| 1880 | mask &= ~OHCI_INTR_MIE; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1881 | ohci_writel(mask, &ohci->regs->intrstatus); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1882 | /* Choose the interrupts we care about now - but w/o MIE */ |
| 1883 | mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO; |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1884 | ohci_writel(mask, &ohci->regs->intrenable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1885 | |
| 1886 | #ifdef OHCI_USE_NPS |
| 1887 | /* required for AMD-756 and some Mac platforms */ |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1888 | ohci_writel((roothub_a(ohci) | RH_A_NPS) & ~RH_A_PSM, |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1889 | &ohci->regs->roothub.a); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1890 | ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1891 | #endif /* OHCI_USE_NPS */ |
| 1892 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1893 | /* connect the virtual root hub */ |
| 1894 | ohci->rh.devnum = 0; |
| 1895 | |
| 1896 | return 0; |
| 1897 | } |
| 1898 | |
| 1899 | /*-------------------------------------------------------------------------*/ |
| 1900 | |
| 1901 | /* an interrupt happens */ |
| 1902 | |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1903 | static int hc_interrupt(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1904 | { |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1905 | struct ohci_regs *regs = ohci->regs; |
| 1906 | int ints; |
| 1907 | int stat = -1; |
| 1908 | |
Hans de Goede | 8e41f66 | 2015-05-05 23:56:13 +0200 | [diff] [blame] | 1909 | invalidate_dcache_hcca(ohci->hcca); |
| 1910 | |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1911 | if ((ohci->hcca->done_head != 0) && |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1912 | !(m32_swap(ohci->hcca->done_head) & 0x01)) { |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1913 | ints = OHCI_INTR_WDH; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1914 | } else { |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1915 | ints = ohci_readl(®s->intrstatus); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1916 | if (ints == ~(u32)0) { |
| 1917 | ohci->disabled++; |
| 1918 | err("%s device removed!", ohci->slot_name); |
| 1919 | return -1; |
| 1920 | } else { |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1921 | ints &= ohci_readl(®s->intrenable); |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1922 | if (ints == 0) { |
| 1923 | dbg("hc_interrupt: returning..\n"); |
| 1924 | return 0xff; |
| 1925 | } |
| 1926 | } |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1927 | } |
Markus Klotzbuecher | e3af6d5 | 2007-03-26 11:21:05 +0200 | [diff] [blame] | 1928 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1929 | /* dbg("Interrupt: %x frame: %x", ints, |
| 1930 | le16_to_cpu(ohci->hcca->frame_no)); */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1931 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1932 | if (ints & OHCI_INTR_RHSC) |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 1933 | stat = 0xff; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1934 | |
| 1935 | if (ints & OHCI_INTR_UE) { |
| 1936 | ohci->disabled++; |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1937 | err("OHCI Unrecoverable Error, controller usb-%s disabled", |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1938 | ohci->slot_name); |
| 1939 | /* e.g. due to PCI Master/Target Abort */ |
| 1940 | |
| 1941 | #ifdef DEBUG |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1942 | ohci_dump(ohci, 1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1943 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1944 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1945 | #endif |
| 1946 | /* FIXME: be optimistic, hope that bug won't repeat often. */ |
| 1947 | /* Make some non-interrupt context restart the controller. */ |
| 1948 | /* Count and limit the retries though; either hardware or */ |
| 1949 | /* software errors can go forever... */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1950 | hc_reset(ohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1951 | return -1; |
| 1952 | } |
| 1953 | |
| 1954 | if (ints & OHCI_INTR_WDH) { |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 1955 | ohci_mdelay(1); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1956 | ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); |
| 1957 | (void)ohci_readl(®s->intrdisable); /* flush */ |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 1958 | stat = dl_done_list(ohci); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1959 | ohci_writel(OHCI_INTR_WDH, ®s->intrenable); |
| 1960 | (void)ohci_readl(®s->intrdisable); /* flush */ |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1961 | } |
| 1962 | |
| 1963 | if (ints & OHCI_INTR_SO) { |
| 1964 | dbg("USB Schedule overrun\n"); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1965 | ohci_writel(OHCI_INTR_SO, ®s->intrenable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1966 | stat = -1; |
| 1967 | } |
| 1968 | |
| 1969 | /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */ |
| 1970 | if (ints & OHCI_INTR_SF) { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1971 | unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1; |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 1972 | mdelay(1); |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1973 | ohci_writel(OHCI_INTR_SF, ®s->intrdisable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1974 | if (ohci->ed_rm_list[frame] != NULL) |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1975 | ohci_writel(OHCI_INTR_SF, ®s->intrenable); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1976 | stat = 0xff; |
| 1977 | } |
| 1978 | |
Becky Bruce | 4abaacb | 2010-06-30 13:05:44 -0500 | [diff] [blame] | 1979 | ohci_writel(ints, ®s->intrstatus); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1980 | return stat; |
| 1981 | } |
| 1982 | |
| 1983 | /*-------------------------------------------------------------------------*/ |
| 1984 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 1985 | #if !CONFIG_IS_ENABLED(DM_USB) |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 1986 | |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1987 | /*-------------------------------------------------------------------------*/ |
| 1988 | |
| 1989 | /* De-allocate all resources.. */ |
| 1990 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1991 | static void hc_release_ohci(ohci_t *ohci) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1992 | { |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1993 | dbg("USB HC release ohci usb-%s", ohci->slot_name); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1994 | |
| 1995 | if (!ohci->disabled) |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 1996 | hc_reset(ohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 1997 | } |
| 1998 | |
| 1999 | /*-------------------------------------------------------------------------*/ |
| 2000 | |
| 2001 | /* |
| 2002 | * low level initalisation routine, called from usb.c |
| 2003 | */ |
| 2004 | static char ohci_inited = 0; |
| 2005 | |
Troy Kisky | 8f9c49d | 2013-10-10 15:27:56 -0700 | [diff] [blame] | 2006 | int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2007 | { |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2008 | #ifdef CONFIG_PCI_OHCI |
| 2009 | pci_dev_t pdev; |
| 2010 | #endif |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2011 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2012 | #ifdef CONFIG_SYS_USB_OHCI_CPU_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2013 | /* cpu dependant init */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2014 | if (usb_cpu_init()) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2015 | return -1; |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2016 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2017 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2018 | #ifdef CONFIG_SYS_USB_OHCI_BOARD_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2019 | /* board dependant init */ |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 2020 | if (board_usb_init(index, USB_INIT_HOST)) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2021 | return -1; |
| 2022 | #endif |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2023 | memset(&gohci, 0, sizeof(ohci_t)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2024 | |
| 2025 | /* align the storage */ |
| 2026 | if ((__u32)&ghcca[0] & 0xff) { |
| 2027 | err("HCCA not aligned!!"); |
| 2028 | return -1; |
| 2029 | } |
Hans de Goede | eb509d3 | 2015-05-05 23:56:10 +0200 | [diff] [blame] | 2030 | gohci.hcca = &ghcca[0]; |
| 2031 | info("aligned ghcca %p", gohci.hcca); |
| 2032 | memset(gohci.hcca, 0, sizeof(struct ohci_hcca)); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2033 | |
| 2034 | gohci.disabled = 1; |
| 2035 | gohci.sleeping = 0; |
| 2036 | gohci.irq = -1; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2037 | #ifdef CONFIG_PCI_OHCI |
Sergei Poselenov | 0b4570f | 2008-05-22 01:15:53 +0200 | [diff] [blame] | 2038 | pdev = pci_find_devices(ohci_pci_ids, CONFIG_PCI_OHCI_DEVNO); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2039 | |
| 2040 | if (pdev != -1) { |
| 2041 | u16 vid, did; |
| 2042 | u32 base; |
| 2043 | pci_read_config_word(pdev, PCI_VENDOR_ID, &vid); |
| 2044 | pci_read_config_word(pdev, PCI_DEVICE_ID, &did); |
| 2045 | printf("OHCI pci controller (%04x, %04x) found @(%d:%d:%d)\n", |
| 2046 | vid, did, (pdev >> 16) & 0xff, |
| 2047 | (pdev >> 11) & 0x1f, (pdev >> 8) & 0x7); |
| 2048 | pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base); |
| 2049 | printf("OHCI regs address 0x%08x\n", base); |
| 2050 | gohci.regs = (struct ohci_regs *)base; |
Heiko Schocher | 882830a | 2019-07-16 10:49:06 +0200 | [diff] [blame] | 2051 | } else { |
| 2052 | printf("%s: OHCI devnr: %d not found\n", __func__, |
| 2053 | CONFIG_PCI_OHCI_DEVNO); |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2054 | return -1; |
Heiko Schocher | 882830a | 2019-07-16 10:49:06 +0200 | [diff] [blame] | 2055 | } |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2056 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2057 | gohci.regs = (struct ohci_regs *)CONFIG_SYS_USB_OHCI_REGS_BASE; |
Zhang Wei | 8d15efa | 2007-06-06 10:08:14 +0200 | [diff] [blame] | 2058 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2059 | |
| 2060 | gohci.flags = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2061 | gohci.slot_name = CONFIG_SYS_USB_OHCI_SLOT_NAME; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2062 | |
| 2063 | if (hc_reset (&gohci) < 0) { |
| 2064 | hc_release_ohci (&gohci); |
| 2065 | err ("can't reset usb-%s", gohci.slot_name); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2066 | #ifdef CONFIG_SYS_USB_OHCI_BOARD_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2067 | /* board dependant cleanup */ |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 2068 | board_usb_cleanup(index, USB_INIT_HOST); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2069 | #endif |
| 2070 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2071 | #ifdef CONFIG_SYS_USB_OHCI_CPU_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2072 | /* cpu dependant cleanup */ |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 2073 | usb_cpu_init_fail(); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2074 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2075 | return -1; |
| 2076 | } |
| 2077 | |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2078 | if (hc_start(&gohci) < 0) { |
| 2079 | err("can't start usb-%s", gohci.slot_name); |
| 2080 | hc_release_ohci(&gohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2081 | /* Initialization failed */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2082 | #ifdef CONFIG_SYS_USB_OHCI_BOARD_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2083 | /* board dependant cleanup */ |
| 2084 | usb_board_stop(); |
| 2085 | #endif |
| 2086 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2087 | #ifdef CONFIG_SYS_USB_OHCI_CPU_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2088 | /* cpu dependant cleanup */ |
| 2089 | usb_cpu_stop(); |
| 2090 | #endif |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2091 | return -1; |
| 2092 | } |
| 2093 | |
| 2094 | #ifdef DEBUG |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2095 | ohci_dump(&gohci, 1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2096 | #else |
Hans de Goede | d6cc1d1 | 2015-05-10 14:10:24 +0200 | [diff] [blame] | 2097 | ohci_mdelay(1); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2098 | #endif |
| 2099 | ohci_inited = 1; |
| 2100 | return 0; |
| 2101 | } |
| 2102 | |
Lucas Stach | a323128 | 2012-09-26 00:14:34 +0200 | [diff] [blame] | 2103 | int usb_lowlevel_stop(int index) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2104 | { |
| 2105 | /* this gets called really early - before the controller has */ |
| 2106 | /* even been initialized! */ |
| 2107 | if (!ohci_inited) |
| 2108 | return 0; |
| 2109 | /* TODO release any interrupts, etc. */ |
| 2110 | /* call hc_release_ohci() here ? */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2111 | hc_reset(&gohci); |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2112 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2113 | #ifdef CONFIG_SYS_USB_OHCI_BOARD_INIT |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2114 | /* board dependant cleanup */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2115 | if (usb_board_stop()) |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2116 | return -1; |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2117 | #endif |
| 2118 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 2119 | #ifdef CONFIG_SYS_USB_OHCI_CPU_INIT |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2120 | /* cpu dependant cleanup */ |
Remy Bohmer | 172a113 | 2008-09-16 14:55:43 +0200 | [diff] [blame] | 2121 | if (usb_cpu_stop()) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2122 | return -1; |
| 2123 | #endif |
Remy Bohmer | 743dd49 | 2008-08-20 11:22:02 +0200 | [diff] [blame] | 2124 | /* This driver is no longer initialised. It needs a new low-level |
| 2125 | * init (board/cpu) before it can be used again. */ |
| 2126 | ohci_inited = 0; |
Markus Klotzbuecher | d8d023f | 2006-05-22 16:33:54 +0200 | [diff] [blame] | 2127 | return 0; |
| 2128 | } |
Hans de Goede | 2a240e7 | 2015-05-05 23:56:07 +0200 | [diff] [blame] | 2129 | |
| 2130 | int submit_control_msg(struct usb_device *dev, unsigned long pipe, |
| 2131 | void *buffer, int transfer_len, struct devrequest *setup) |
| 2132 | { |
| 2133 | return _ohci_submit_control_msg(&gohci, dev, pipe, buffer, |
| 2134 | transfer_len, setup); |
| 2135 | } |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2136 | #endif |
| 2137 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 2138 | #if CONFIG_IS_ENABLED(DM_USB) |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2139 | static int ohci_submit_control_msg(struct udevice *dev, struct usb_device *udev, |
| 2140 | unsigned long pipe, void *buffer, int length, |
| 2141 | struct devrequest *setup) |
| 2142 | { |
| 2143 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2144 | |
| 2145 | return _ohci_submit_control_msg(ohci, udev, pipe, buffer, |
| 2146 | length, setup); |
| 2147 | } |
| 2148 | |
| 2149 | static int ohci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, |
| 2150 | unsigned long pipe, void *buffer, int length) |
| 2151 | { |
| 2152 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2153 | |
| 2154 | return submit_common_msg(ohci, udev, pipe, buffer, length, NULL, 0); |
| 2155 | } |
| 2156 | |
| 2157 | static int ohci_submit_int_msg(struct udevice *dev, struct usb_device *udev, |
| 2158 | unsigned long pipe, void *buffer, int length, |
Michal Suchanek | 1c95b9f | 2019-08-18 10:55:27 +0200 | [diff] [blame] | 2159 | int interval, bool nonblock) |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2160 | { |
| 2161 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2162 | |
| 2163 | return submit_common_msg(ohci, udev, pipe, buffer, length, |
| 2164 | NULL, interval); |
| 2165 | } |
| 2166 | |
Hans de Goede | 5477e6f | 2015-05-13 14:42:17 +0200 | [diff] [blame] | 2167 | static struct int_queue *ohci_create_int_queue(struct udevice *dev, |
| 2168 | struct usb_device *udev, unsigned long pipe, int queuesize, |
| 2169 | int elementsize, void *buffer, int interval) |
| 2170 | { |
| 2171 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2172 | |
| 2173 | return _ohci_create_int_queue(ohci, udev, pipe, queuesize, elementsize, |
| 2174 | buffer, interval); |
| 2175 | } |
| 2176 | |
| 2177 | static void *ohci_poll_int_queue(struct udevice *dev, struct usb_device *udev, |
| 2178 | struct int_queue *queue) |
| 2179 | { |
| 2180 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2181 | |
| 2182 | return _ohci_poll_int_queue(ohci, udev, queue); |
| 2183 | } |
| 2184 | |
| 2185 | static int ohci_destroy_int_queue(struct udevice *dev, struct usb_device *udev, |
| 2186 | struct int_queue *queue) |
| 2187 | { |
| 2188 | ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); |
| 2189 | |
| 2190 | return _ohci_destroy_int_queue(ohci, udev, queue); |
| 2191 | } |
| 2192 | |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2193 | int ohci_register(struct udevice *dev, struct ohci_regs *regs) |
| 2194 | { |
| 2195 | struct usb_bus_priv *priv = dev_get_uclass_priv(dev); |
| 2196 | ohci_t *ohci = dev_get_priv(dev); |
| 2197 | u32 reg; |
| 2198 | |
| 2199 | priv->desc_before_addr = true; |
| 2200 | |
| 2201 | ohci->regs = regs; |
| 2202 | ohci->hcca = memalign(256, sizeof(struct ohci_hcca)); |
| 2203 | if (!ohci->hcca) |
| 2204 | return -ENOMEM; |
| 2205 | memset(ohci->hcca, 0, sizeof(struct ohci_hcca)); |
Hans de Goede | 66cb3e4 | 2015-10-20 18:39:29 +0200 | [diff] [blame] | 2206 | flush_dcache_hcca(ohci->hcca); |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2207 | |
| 2208 | if (hc_reset(ohci) < 0) |
| 2209 | return -EIO; |
| 2210 | |
| 2211 | if (hc_start(ohci) < 0) |
| 2212 | return -EIO; |
| 2213 | |
| 2214 | reg = ohci_readl(®s->revision); |
| 2215 | printf("USB OHCI %x.%x\n", (reg >> 4) & 0xf, reg & 0xf); |
| 2216 | |
| 2217 | return 0; |
| 2218 | } |
| 2219 | |
| 2220 | int ohci_deregister(struct udevice *dev) |
| 2221 | { |
| 2222 | ohci_t *ohci = dev_get_priv(dev); |
| 2223 | |
| 2224 | if (hc_reset(ohci) < 0) |
| 2225 | return -EIO; |
| 2226 | |
| 2227 | free(ohci->hcca); |
| 2228 | |
| 2229 | return 0; |
| 2230 | } |
| 2231 | |
| 2232 | struct dm_usb_ops ohci_usb_ops = { |
| 2233 | .control = ohci_submit_control_msg, |
| 2234 | .bulk = ohci_submit_bulk_msg, |
| 2235 | .interrupt = ohci_submit_int_msg, |
Hans de Goede | 5477e6f | 2015-05-13 14:42:17 +0200 | [diff] [blame] | 2236 | .create_int_queue = ohci_create_int_queue, |
| 2237 | .poll_int_queue = ohci_poll_int_queue, |
| 2238 | .destroy_int_queue = ohci_destroy_int_queue, |
Hans de Goede | 8a62c50 | 2015-05-10 14:10:25 +0200 | [diff] [blame] | 2239 | }; |
| 2240 | |
| 2241 | #endif |