Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * EHCI HCD (Host Controller Driver) PCI Bus Glue. |
| 3 | * |
| 4 | * Copyright (c) 2000-2004 by David Brownell |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software Foundation, |
| 18 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef CONFIG_PCI |
| 22 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." |
| 23 | #endif |
| 24 | |
| 25 | /*-------------------------------------------------------------------------*/ |
| 26 | |
| 27 | /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... |
| 28 | * off the controller (maybe it can boot from highspeed USB disks). |
| 29 | */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 30 | static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 31 | { |
| 32 | struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); |
| 33 | |
| 34 | /* always say Linux will own the hardware */ |
| 35 | pci_write_config_byte(pdev, where + 3, 1); |
| 36 | |
| 37 | /* maybe wait a while for BIOS to respond */ |
| 38 | if (cap & (1 << 16)) { |
| 39 | int msec = 5000; |
| 40 | |
| 41 | do { |
| 42 | msleep(10); |
| 43 | msec -= 10; |
| 44 | pci_read_config_dword(pdev, where, &cap); |
| 45 | } while ((cap & (1 << 16)) && msec); |
| 46 | if (cap & (1 << 16)) { |
| 47 | ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n", |
| 48 | where, cap); |
| 49 | // some BIOS versions seem buggy... |
| 50 | // return 1; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 51 | ehci_warn(ehci, "continuing after BIOS bug...\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 52 | /* disable all SMIs, and clear "BIOS owns" flag */ |
| 53 | pci_write_config_dword(pdev, where + 4, 0); |
| 54 | pci_write_config_byte(pdev, where + 2, 0); |
| 55 | } else |
| 56 | ehci_dbg(ehci, "BIOS handoff succeeded\n"); |
| 57 | } |
| 58 | return 0; |
| 59 | } |
| 60 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 61 | /* called after powerup, by probe or system-pm "wakeup" */ |
| 62 | static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) |
| 63 | { |
| 64 | u32 temp; |
| 65 | int retval; |
| 66 | unsigned count = 256/4; |
| 67 | |
| 68 | /* optional debug port, normally in the first BAR */ |
| 69 | temp = pci_find_capability(pdev, 0x0a); |
| 70 | if (temp) { |
| 71 | pci_read_config_dword(pdev, temp, &temp); |
| 72 | temp >>= 16; |
| 73 | if ((temp & (3 << 13)) == (1 << 13)) { |
| 74 | temp &= 0x1fff; |
| 75 | ehci->debug = ehci_to_hcd(ehci)->regs + temp; |
| 76 | temp = readl(&ehci->debug->control); |
| 77 | ehci_info(ehci, "debug port %d%s\n", |
| 78 | HCS_DEBUG_PORT(ehci->hcs_params), |
| 79 | (temp & DBGP_ENABLED) |
| 80 | ? " IN USE" |
| 81 | : ""); |
| 82 | if (!(temp & DBGP_ENABLED)) |
| 83 | ehci->debug = NULL; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params)); |
| 88 | |
| 89 | /* EHCI 0.96 and later may have "extended capabilities" */ |
| 90 | while (temp && count--) { |
| 91 | u32 cap; |
| 92 | |
| 93 | pci_read_config_dword(pdev, temp, &cap); |
| 94 | ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp); |
| 95 | switch (cap & 0xff) { |
| 96 | case 1: /* BIOS/SMM/... handoff */ |
| 97 | if (bios_handoff(ehci, temp, cap) != 0) |
| 98 | return -EOPNOTSUPP; |
| 99 | break; |
| 100 | case 0: /* illegal reserved capability */ |
| 101 | ehci_dbg(ehci, "illegal capability!\n"); |
| 102 | cap = 0; |
| 103 | /* FALLTHROUGH */ |
| 104 | default: /* unknown */ |
| 105 | break; |
| 106 | } |
| 107 | temp = (cap >> 8) & 0xff; |
| 108 | } |
| 109 | if (!count) { |
| 110 | ehci_err(ehci, "bogus capabilities ... PCI problems!\n"); |
| 111 | return -EIO; |
| 112 | } |
| 113 | |
| 114 | /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ |
| 115 | retval = pci_set_mwi(pdev); |
| 116 | if (!retval) |
| 117 | ehci_dbg(ehci, "MWI active\n"); |
| 118 | |
| 119 | ehci_port_power(ehci, 0); |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 124 | /* called during probe() after chip reset completes */ |
| 125 | static int ehci_pci_setup(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 126 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 127 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 128 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 129 | u32 temp; |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 130 | int retval; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 131 | |
| 132 | ehci->caps = hcd->regs; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 133 | ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); |
| 134 | dbg_hcs_params(ehci, "reset"); |
| 135 | dbg_hcc_params(ehci, "reset"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 136 | |
| 137 | /* cache this readonly data; minimize chip reads */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 138 | ehci->hcs_params = readl(&ehci->caps->hcs_params); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 139 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 140 | retval = ehci_halt(ehci); |
| 141 | if (retval) |
| 142 | return retval; |
| 143 | |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 144 | /* data structure init */ |
| 145 | retval = ehci_init(hcd); |
| 146 | if (retval) |
| 147 | return retval; |
| 148 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 149 | /* NOTE: only the parts below this line are PCI-specific */ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 150 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 151 | switch (pdev->vendor) { |
| 152 | case PCI_VENDOR_ID_TDI: |
| 153 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { |
| 154 | ehci->is_tdi_rh_tt = 1; |
| 155 | tdi_reset(ehci); |
| 156 | } |
| 157 | break; |
| 158 | case PCI_VENDOR_ID_AMD: |
| 159 | /* AMD8111 EHCI doesn't work, according to AMD errata */ |
| 160 | if (pdev->device == 0x7463) { |
| 161 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 162 | retval = -EIO; |
| 163 | goto done; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 164 | } |
| 165 | break; |
| 166 | case PCI_VENDOR_ID_NVIDIA: |
| 167 | /* NVidia reports that certain chips don't handle |
| 168 | * QH, ITD, or SITD addresses above 2GB. (But TD, |
| 169 | * data buffer, and periodic schedule are normal.) |
| 170 | */ |
| 171 | switch (pdev->device) { |
| 172 | case 0x003c: /* MCP04 */ |
| 173 | case 0x005b: /* CK804 */ |
| 174 | case 0x00d8: /* CK8 */ |
| 175 | case 0x00e8: /* CK8S */ |
| 176 | if (pci_set_consistent_dma_mask(pdev, |
| 177 | DMA_31BIT_MASK) < 0) |
| 178 | ehci_warn(ehci, "can't enable NVidia " |
| 179 | "workaround for >2GB RAM\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 180 | break; |
| 181 | } |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 182 | break; |
| 183 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 184 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 185 | if (ehci_is_TDI(ehci)) |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 186 | ehci_reset(ehci); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 187 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 188 | /* at least the Genesys GL880S needs fixup here */ |
| 189 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); |
| 190 | temp &= 0x0f; |
| 191 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 192 | ehci_dbg(ehci, "bogus port configuration: " |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 193 | "cc=%d x pcc=%d < ports=%d\n", |
| 194 | HCS_N_CC(ehci->hcs_params), |
| 195 | HCS_N_PCC(ehci->hcs_params), |
| 196 | HCS_N_PORTS(ehci->hcs_params)); |
| 197 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 198 | switch (pdev->vendor) { |
| 199 | case 0x17a0: /* GENESYS */ |
| 200 | /* GL880S: should be PORTS=2 */ |
| 201 | temp |= (ehci->hcs_params & ~0xf); |
| 202 | ehci->hcs_params = temp; |
| 203 | break; |
| 204 | case PCI_VENDOR_ID_NVIDIA: |
| 205 | /* NF4: should be PCC=10 */ |
| 206 | break; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 210 | /* Serial Bus Release Number is at PCI 0x60 offset */ |
| 211 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 212 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 213 | /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 214 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 215 | retval = ehci_pci_reinit(ehci, pdev); |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 216 | done: |
| 217 | return retval; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /*-------------------------------------------------------------------------*/ |
| 221 | |
| 222 | #ifdef CONFIG_PM |
| 223 | |
| 224 | /* suspend/resume, section 4.3 */ |
| 225 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 226 | /* These routines rely on the PCI bus glue |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 227 | * to handle powerdown and wakeup, and currently also on |
| 228 | * transceivers that don't need any software attention to set up |
| 229 | * the right sort of wakeup. |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 230 | * Also they depend on separate root hub suspend/resume. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 231 | */ |
| 232 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 233 | static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 234 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 235 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Benjamin Herrenschmidt | 8de9840 | 2005-11-25 09:59:46 +1100 | [diff] [blame] | 236 | unsigned long flags; |
| 237 | int rc = 0; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 238 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 239 | if (time_before(jiffies, ehci->next_statechange)) |
| 240 | msleep(10); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 241 | |
Benjamin Herrenschmidt | 8de9840 | 2005-11-25 09:59:46 +1100 | [diff] [blame] | 242 | /* Root hub was already suspended. Disable irq emission and |
| 243 | * mark HW unaccessible, bail out if RH has been resumed. Use |
| 244 | * the spinlock to properly synchronize with possible pending |
| 245 | * RH suspend or resume activity. |
| 246 | * |
| 247 | * This is still racy as hcd->state is manipulated outside of |
| 248 | * any locks =P But that will be a different fix. |
| 249 | */ |
| 250 | spin_lock_irqsave (&ehci->lock, flags); |
| 251 | if (hcd->state != HC_STATE_SUSPENDED) { |
| 252 | rc = -EINVAL; |
| 253 | goto bail; |
| 254 | } |
| 255 | writel (0, &ehci->regs->intr_enable); |
| 256 | (void)readl(&ehci->regs->intr_enable); |
| 257 | |
| 258 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 259 | bail: |
| 260 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 261 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 262 | // could save FLADJ in case of Vaux power loss |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 263 | // ... we'd only use it to handle clock skew |
| 264 | |
Benjamin Herrenschmidt | 8de9840 | 2005-11-25 09:59:46 +1100 | [diff] [blame] | 265 | return rc; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 266 | } |
| 267 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 268 | static int ehci_pci_resume(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 269 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 270 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 271 | unsigned port; |
| 272 | struct usb_device *root = hcd->self.root_hub; |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 273 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 274 | int retval = -EINVAL; |
| 275 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 276 | // maybe restore FLADJ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 277 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 278 | if (time_before(jiffies, ehci->next_statechange)) |
| 279 | msleep(100); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 280 | |
Benjamin Herrenschmidt | 8de9840 | 2005-11-25 09:59:46 +1100 | [diff] [blame] | 281 | /* Mark hardware accessible again as we are out of D3 state by now */ |
| 282 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 283 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 284 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 285 | if (readl(&ehci->regs->configured_flag) != FLAG_CF) |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 286 | goto restart; |
| 287 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 288 | /* If any port is suspended (or owned by the companion), |
| 289 | * we know we can/must resume the HC (and mustn't reset it). |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 290 | * We just defer that to the root hub code. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 291 | */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 292 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 293 | u32 status; |
| 294 | port--; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 295 | status = readl(&ehci->regs->port_status [port]); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 296 | if (!(status & PORT_POWER)) |
| 297 | continue; |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 298 | if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { |
| 299 | usb_hcd_resume_root_hub(hcd); |
| 300 | return 0; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 301 | } |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | restart: |
| 305 | ehci_dbg(ehci, "lost power, restarting\n"); |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 306 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 307 | port--; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 308 | if (!root->children [port]) |
| 309 | continue; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 310 | usb_set_device_state(root->children[port], |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 311 | USB_STATE_NOTATTACHED); |
| 312 | } |
| 313 | |
| 314 | /* Else reset, to cope with power loss or flush-to-storage |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 315 | * style "resume" having let BIOS kick in during reboot. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 316 | */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 317 | (void) ehci_halt(ehci); |
| 318 | (void) ehci_reset(ehci); |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 319 | (void) ehci_pci_reinit(ehci, pdev); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 320 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 321 | /* emptying the schedule aborts any urbs */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 322 | spin_lock_irq(&ehci->lock); |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 323 | if (ehci->reclaim) |
| 324 | ehci->reclaim_ready = 1; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 325 | ehci_work(ehci, NULL); |
| 326 | spin_unlock_irq(&ehci->lock); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 327 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 328 | /* restart; khubd will disconnect devices */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 329 | retval = ehci_run(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 330 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 331 | /* here we "know" root ports should always stay powered */ |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 332 | ehci_port_power(ehci, 1); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 333 | |
| 334 | return retval; |
| 335 | } |
| 336 | #endif |
| 337 | |
| 338 | static const struct hc_driver ehci_pci_hc_driver = { |
| 339 | .description = hcd_name, |
| 340 | .product_desc = "EHCI Host Controller", |
| 341 | .hcd_priv_size = sizeof(struct ehci_hcd), |
| 342 | |
| 343 | /* |
| 344 | * generic hardware linkage |
| 345 | */ |
| 346 | .irq = ehci_irq, |
| 347 | .flags = HCD_MEMORY | HCD_USB2, |
| 348 | |
| 349 | /* |
| 350 | * basic lifecycle operations |
| 351 | */ |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 352 | .reset = ehci_pci_setup, |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 353 | .start = ehci_run, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 354 | #ifdef CONFIG_PM |
| 355 | .suspend = ehci_pci_suspend, |
| 356 | .resume = ehci_pci_resume, |
| 357 | #endif |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 358 | .stop = ehci_stop, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 359 | |
| 360 | /* |
| 361 | * managing i/o requests and associated device resources |
| 362 | */ |
| 363 | .urb_enqueue = ehci_urb_enqueue, |
| 364 | .urb_dequeue = ehci_urb_dequeue, |
| 365 | .endpoint_disable = ehci_endpoint_disable, |
| 366 | |
| 367 | /* |
| 368 | * scheduling support |
| 369 | */ |
| 370 | .get_frame_number = ehci_get_frame, |
| 371 | |
| 372 | /* |
| 373 | * root hub support |
| 374 | */ |
| 375 | .hub_status_data = ehci_hub_status_data, |
| 376 | .hub_control = ehci_hub_control, |
Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 377 | .bus_suspend = ehci_bus_suspend, |
| 378 | .bus_resume = ehci_bus_resume, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 379 | }; |
| 380 | |
| 381 | /*-------------------------------------------------------------------------*/ |
| 382 | |
| 383 | /* PCI driver selection metadata; PCI hotplugging uses this */ |
| 384 | static const struct pci_device_id pci_ids [] = { { |
| 385 | /* handle any USB 2.0 EHCI controller */ |
| 386 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), |
| 387 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
| 388 | }, |
| 389 | { /* end: all zeroes */ } |
| 390 | }; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 391 | MODULE_DEVICE_TABLE(pci, pci_ids); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 392 | |
| 393 | /* pci driver glue; this is a "new style" PCI driver module */ |
| 394 | static struct pci_driver ehci_pci_driver = { |
| 395 | .name = (char *) hcd_name, |
| 396 | .id_table = pci_ids, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 397 | |
| 398 | .probe = usb_hcd_pci_probe, |
| 399 | .remove = usb_hcd_pci_remove, |
| 400 | |
| 401 | #ifdef CONFIG_PM |
| 402 | .suspend = usb_hcd_pci_suspend, |
| 403 | .resume = usb_hcd_pci_resume, |
| 404 | #endif |
| 405 | }; |
| 406 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 407 | static int __init ehci_hcd_pci_init(void) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 408 | { |
| 409 | if (usb_disabled()) |
| 410 | return -ENODEV; |
| 411 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 412 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 413 | hcd_name, |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 414 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), |
| 415 | sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 416 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 417 | return pci_register_driver(&ehci_pci_driver); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 418 | } |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 419 | module_init(ehci_hcd_pci_init); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 420 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 421 | static void __exit ehci_hcd_pci_cleanup(void) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 422 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 423 | pci_unregister_driver(&ehci_pci_driver); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 424 | } |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 425 | module_exit(ehci_hcd_pci_cleanup); |