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 | abcc944 | 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 | abcc944 | 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 | |
| 61 | /* called by khubd or root hub init threads */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 62 | static int ehci_pci_reset(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 63 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 64 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 65 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 66 | u32 temp; |
| 67 | unsigned count = 256/4; |
| 68 | |
| 69 | spin_lock_init (&ehci->lock); |
| 70 | |
| 71 | ehci->caps = hcd->regs; |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 72 | ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); |
| 73 | dbg_hcs_params(ehci, "reset"); |
| 74 | dbg_hcc_params(ehci, "reset"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 75 | |
| 76 | /* cache this readonly data; minimize chip reads */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 77 | ehci->hcs_params = readl(&ehci->caps->hcs_params); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 78 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 79 | /* NOTE: only the parts below this line are PCI-specific */ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 80 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 81 | switch (pdev->vendor) { |
| 82 | case PCI_VENDOR_ID_TDI: |
| 83 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { |
| 84 | ehci->is_tdi_rh_tt = 1; |
| 85 | tdi_reset(ehci); |
| 86 | } |
| 87 | break; |
| 88 | case PCI_VENDOR_ID_AMD: |
| 89 | /* AMD8111 EHCI doesn't work, according to AMD errata */ |
| 90 | if (pdev->device == 0x7463) { |
| 91 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); |
| 92 | return -EIO; |
| 93 | } |
| 94 | break; |
| 95 | case PCI_VENDOR_ID_NVIDIA: |
| 96 | /* NVidia reports that certain chips don't handle |
| 97 | * QH, ITD, or SITD addresses above 2GB. (But TD, |
| 98 | * data buffer, and periodic schedule are normal.) |
| 99 | */ |
| 100 | switch (pdev->device) { |
| 101 | case 0x003c: /* MCP04 */ |
| 102 | case 0x005b: /* CK804 */ |
| 103 | case 0x00d8: /* CK8 */ |
| 104 | case 0x00e8: /* CK8S */ |
| 105 | if (pci_set_consistent_dma_mask(pdev, |
| 106 | DMA_31BIT_MASK) < 0) |
| 107 | ehci_warn(ehci, "can't enable NVidia " |
| 108 | "workaround for >2GB RAM\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 109 | break; |
| 110 | } |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 111 | break; |
| 112 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 113 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 114 | /* optional debug port, normally in the first BAR */ |
| 115 | temp = pci_find_capability(pdev, 0x0a); |
| 116 | if (temp) { |
| 117 | pci_read_config_dword(pdev, temp, &temp); |
| 118 | temp >>= 16; |
| 119 | if ((temp & (3 << 13)) == (1 << 13)) { |
| 120 | temp &= 0x1fff; |
| 121 | ehci->debug = hcd->regs + temp; |
| 122 | temp = readl(&ehci->debug->control); |
| 123 | ehci_info(ehci, "debug port %d%s\n", |
| 124 | HCS_DEBUG_PORT(ehci->hcs_params), |
| 125 | (temp & DBGP_ENABLED) |
| 126 | ? " IN USE" |
| 127 | : ""); |
| 128 | if (!(temp & DBGP_ENABLED)) |
| 129 | ehci->debug = NULL; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 130 | } |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 131 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 132 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 133 | temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params)); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 134 | |
| 135 | /* EHCI 0.96 and later may have "extended capabilities" */ |
| 136 | while (temp && count--) { |
| 137 | u32 cap; |
| 138 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 139 | pci_read_config_dword(to_pci_dev(hcd->self.controller), |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 140 | temp, &cap); |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 141 | ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 142 | switch (cap & 0xff) { |
| 143 | case 1: /* BIOS/SMM/... handoff */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 144 | if (bios_handoff(ehci, temp, cap) != 0) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 145 | return -EOPNOTSUPP; |
| 146 | break; |
| 147 | case 0: /* illegal reserved capability */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 148 | ehci_warn(ehci, "illegal capability!\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 149 | cap = 0; |
| 150 | /* FALLTHROUGH */ |
| 151 | default: /* unknown */ |
| 152 | break; |
| 153 | } |
| 154 | temp = (cap >> 8) & 0xff; |
| 155 | } |
| 156 | if (!count) { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 157 | ehci_err(ehci, "bogus capabilities ... PCI problems!\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 158 | return -EIO; |
| 159 | } |
| 160 | if (ehci_is_TDI(ehci)) |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 161 | ehci_reset(ehci); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 162 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 163 | ehci_port_power(ehci, 0); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 164 | |
| 165 | /* at least the Genesys GL880S needs fixup here */ |
| 166 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); |
| 167 | temp &= 0x0f; |
| 168 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 169 | ehci_dbg(ehci, "bogus port configuration: " |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 170 | "cc=%d x pcc=%d < ports=%d\n", |
| 171 | HCS_N_CC(ehci->hcs_params), |
| 172 | HCS_N_PCC(ehci->hcs_params), |
| 173 | HCS_N_PORTS(ehci->hcs_params)); |
| 174 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 175 | switch (pdev->vendor) { |
| 176 | case 0x17a0: /* GENESYS */ |
| 177 | /* GL880S: should be PORTS=2 */ |
| 178 | temp |= (ehci->hcs_params & ~0xf); |
| 179 | ehci->hcs_params = temp; |
| 180 | break; |
| 181 | case PCI_VENDOR_ID_NVIDIA: |
| 182 | /* NF4: should be PCC=10 */ |
| 183 | break; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
| 187 | /* force HC to halt state */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 188 | return ehci_halt(ehci); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 189 | } |
| 190 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 191 | static int ehci_pci_start(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 192 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 193 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 194 | int result = 0; |
| 195 | struct pci_dev *pdev; |
| 196 | u16 port_wake; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 197 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 198 | pdev = to_pci_dev(hcd->self.controller); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 199 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 200 | /* Serial Bus Release Number is at PCI 0x60 offset */ |
| 201 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 202 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 203 | /* port wake capability, reported by boot firmware */ |
| 204 | pci_read_config_word(pdev, 0x62, &port_wake); |
| 205 | hcd->can_wakeup = (port_wake & 1) != 0; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 206 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 207 | /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ |
| 208 | result = pci_set_mwi(pdev); |
| 209 | if (!result) |
| 210 | ehci_dbg(ehci, "MWI active\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 211 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 212 | return ehci_run(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /* always called by thread; normally rmmod */ |
| 216 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 217 | static void ehci_pci_stop(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 218 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 219 | ehci_stop(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /*-------------------------------------------------------------------------*/ |
| 223 | |
| 224 | #ifdef CONFIG_PM |
| 225 | |
| 226 | /* suspend/resume, section 4.3 */ |
| 227 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 228 | /* These routines rely on the PCI bus glue |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 229 | * to handle powerdown and wakeup, and currently also on |
| 230 | * transceivers that don't need any software attention to set up |
| 231 | * the right sort of wakeup. |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 232 | * Also they depend on separate root hub suspend/resume. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 233 | */ |
| 234 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 235 | 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] | 236 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 237 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 238 | |
David Brownell | abcc944 | 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 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 242 | // could save FLADJ in case of Vaux power loss |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 243 | // ... we'd only use it to handle clock skew |
| 244 | |
| 245 | return 0; |
| 246 | } |
| 247 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 248 | static int ehci_pci_resume(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 249 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 250 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 251 | unsigned port; |
| 252 | struct usb_device *root = hcd->self.root_hub; |
| 253 | int retval = -EINVAL; |
| 254 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 255 | // maybe restore FLADJ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 256 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 257 | if (time_before(jiffies, ehci->next_statechange)) |
| 258 | msleep(100); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 259 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 260 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 261 | if (readl(&ehci->regs->configured_flag) != cpu_to_le32(FLAG_CF)) |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 262 | goto restart; |
| 263 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 264 | /* If any port is suspended (or owned by the companion), |
| 265 | * 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] | 266 | * We just defer that to the root hub code. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 267 | */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 268 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 269 | u32 status; |
| 270 | port--; |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 271 | status = readl(&ehci->regs->port_status [port]); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 272 | if (!(status & PORT_POWER)) |
| 273 | continue; |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 274 | if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { |
| 275 | usb_hcd_resume_root_hub(hcd); |
| 276 | return 0; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 277 | } |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | restart: |
| 281 | ehci_dbg(ehci, "lost power, restarting\n"); |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 282 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 283 | port--; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 284 | if (!root->children [port]) |
| 285 | continue; |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 286 | usb_set_device_state(root->children[port], |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 287 | USB_STATE_NOTATTACHED); |
| 288 | } |
| 289 | |
| 290 | /* Else reset, to cope with power loss or flush-to-storage |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 291 | * style "resume" having let BIOS kick in during reboot. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 292 | */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 293 | (void) ehci_halt(ehci); |
| 294 | (void) ehci_reset(ehci); |
| 295 | (void) ehci_pci_reset(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 296 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 297 | /* emptying the schedule aborts any urbs */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 298 | spin_lock_irq(&ehci->lock); |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 299 | if (ehci->reclaim) |
| 300 | ehci->reclaim_ready = 1; |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 301 | ehci_work(ehci, NULL); |
| 302 | spin_unlock_irq(&ehci->lock); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 303 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 304 | /* restart; khubd will disconnect devices */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 305 | retval = ehci_run(hcd); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 306 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 307 | /* here we "know" root ports should always stay powered; |
| 308 | * but some controllers may lose all power. |
| 309 | */ |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 310 | ehci_port_power(ehci, 1); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 311 | |
| 312 | return retval; |
| 313 | } |
| 314 | #endif |
| 315 | |
| 316 | static const struct hc_driver ehci_pci_hc_driver = { |
| 317 | .description = hcd_name, |
| 318 | .product_desc = "EHCI Host Controller", |
| 319 | .hcd_priv_size = sizeof(struct ehci_hcd), |
| 320 | |
| 321 | /* |
| 322 | * generic hardware linkage |
| 323 | */ |
| 324 | .irq = ehci_irq, |
| 325 | .flags = HCD_MEMORY | HCD_USB2, |
| 326 | |
| 327 | /* |
| 328 | * basic lifecycle operations |
| 329 | */ |
| 330 | .reset = ehci_pci_reset, |
| 331 | .start = ehci_pci_start, |
| 332 | #ifdef CONFIG_PM |
| 333 | .suspend = ehci_pci_suspend, |
| 334 | .resume = ehci_pci_resume, |
| 335 | #endif |
| 336 | .stop = ehci_pci_stop, |
| 337 | |
| 338 | /* |
| 339 | * managing i/o requests and associated device resources |
| 340 | */ |
| 341 | .urb_enqueue = ehci_urb_enqueue, |
| 342 | .urb_dequeue = ehci_urb_dequeue, |
| 343 | .endpoint_disable = ehci_endpoint_disable, |
| 344 | |
| 345 | /* |
| 346 | * scheduling support |
| 347 | */ |
| 348 | .get_frame_number = ehci_get_frame, |
| 349 | |
| 350 | /* |
| 351 | * root hub support |
| 352 | */ |
| 353 | .hub_status_data = ehci_hub_status_data, |
| 354 | .hub_control = ehci_hub_control, |
Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 355 | .bus_suspend = ehci_bus_suspend, |
| 356 | .bus_resume = ehci_bus_resume, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 357 | }; |
| 358 | |
| 359 | /*-------------------------------------------------------------------------*/ |
| 360 | |
| 361 | /* PCI driver selection metadata; PCI hotplugging uses this */ |
| 362 | static const struct pci_device_id pci_ids [] = { { |
| 363 | /* handle any USB 2.0 EHCI controller */ |
| 364 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), |
| 365 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
| 366 | }, |
| 367 | { /* end: all zeroes */ } |
| 368 | }; |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 369 | MODULE_DEVICE_TABLE(pci, pci_ids); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 370 | |
| 371 | /* pci driver glue; this is a "new style" PCI driver module */ |
| 372 | static struct pci_driver ehci_pci_driver = { |
| 373 | .name = (char *) hcd_name, |
| 374 | .id_table = pci_ids, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 375 | |
| 376 | .probe = usb_hcd_pci_probe, |
| 377 | .remove = usb_hcd_pci_remove, |
| 378 | |
| 379 | #ifdef CONFIG_PM |
| 380 | .suspend = usb_hcd_pci_suspend, |
| 381 | .resume = usb_hcd_pci_resume, |
| 382 | #endif |
| 383 | }; |
| 384 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 385 | static int __init ehci_hcd_pci_init(void) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 386 | { |
| 387 | if (usb_disabled()) |
| 388 | return -ENODEV; |
| 389 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 390 | 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] | 391 | hcd_name, |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 392 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), |
| 393 | sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 394 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 395 | return pci_register_driver(&ehci_pci_driver); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 396 | } |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 397 | module_init(ehci_hcd_pci_init); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 398 | |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 399 | static void __exit ehci_hcd_pci_cleanup(void) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 400 | { |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 401 | pci_unregister_driver(&ehci_pci_driver); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 402 | } |
David Brownell | abcc944 | 2005-11-23 15:45:32 -0800 | [diff] [blame^] | 403 | module_exit(ehci_hcd_pci_cleanup); |