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 | |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 21 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/pci.h> |
| 24 | #include <linux/usb.h> |
| 25 | #include <linux/usb/hcd.h> |
| 26 | |
| 27 | #include "ehci.h" |
| 28 | #include "pci-quirks.h" |
| 29 | |
| 30 | #define DRIVER_DESC "EHCI PCI platform driver" |
| 31 | |
| 32 | static const char hcd_name[] = "ehci-pci"; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 33 | |
Dirk Brandewie | 4f68384 | 2010-11-17 07:43:09 -0800 | [diff] [blame] | 34 | /* defined here to avoid adding to pci_ids.h for single instance use */ |
| 35 | #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 |
| 36 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 37 | /*-------------------------------------------------------------------------*/ |
| 38 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 39 | /* called after powerup, by probe or system-pm "wakeup" */ |
| 40 | static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) |
| 41 | { |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 42 | int retval; |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 43 | |
David Brownell | 401feaf | 2006-01-24 07:15:30 -0800 | [diff] [blame] | 44 | /* we expect static quirk code to handle the "extended capabilities" |
| 45 | * (currently just BIOS handoff) allowed starting with EHCI 0.96 |
| 46 | */ |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 47 | |
| 48 | /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ |
| 49 | retval = pci_set_mwi(pdev); |
| 50 | if (!retval) |
| 51 | ehci_dbg(ehci, "MWI active\n"); |
| 52 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 56 | /* called during probe() after chip reset completes */ |
| 57 | static int ehci_pci_setup(struct usb_hcd *hcd) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 58 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 59 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 60 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 61 | struct pci_dev *p_smbus; |
| 62 | u8 rev; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 63 | u32 temp; |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 64 | int retval; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 65 | |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 66 | ehci->caps = hcd->regs; |
| 67 | |
| 68 | /* |
| 69 | * ehci_init() causes memory for DMA transfers to be |
| 70 | * allocated. Thus, any vendor-specific workarounds based on |
| 71 | * limiting the type of memory used for DMA transfers must |
| 72 | * happen before ehci_setup() is called. |
| 73 | * |
| 74 | * Most other workarounds can be done either before or after |
| 75 | * init and reset; they are located here too. |
| 76 | */ |
Benjamin Herrenschmidt | 083522d | 2006-12-15 06:54:08 +1100 | [diff] [blame] | 77 | switch (pdev->vendor) { |
| 78 | case PCI_VENDOR_ID_TOSHIBA_2: |
| 79 | /* celleb's companion chip */ |
| 80 | if (pdev->device == 0x01b5) { |
| 81 | #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO |
| 82 | ehci->big_endian_mmio = 1; |
| 83 | #else |
| 84 | ehci_warn(ehci, |
| 85 | "unsupported big endian Toshiba quirk\n"); |
| 86 | #endif |
| 87 | } |
| 88 | break; |
Paul Serice | c32ba30 | 2006-06-07 10:23:38 -0700 | [diff] [blame] | 89 | case PCI_VENDOR_ID_NVIDIA: |
| 90 | /* NVidia reports that certain chips don't handle |
| 91 | * QH, ITD, or SITD addresses above 2GB. (But TD, |
| 92 | * data buffer, and periodic schedule are normal.) |
| 93 | */ |
| 94 | switch (pdev->device) { |
| 95 | case 0x003c: /* MCP04 */ |
| 96 | case 0x005b: /* CK804 */ |
| 97 | case 0x00d8: /* CK8 */ |
| 98 | case 0x00e8: /* CK8S */ |
| 99 | if (pci_set_consistent_dma_mask(pdev, |
Yang Hongyang | 929a22a | 2009-04-06 19:01:16 -0700 | [diff] [blame] | 100 | DMA_BIT_MASK(31)) < 0) |
Paul Serice | c32ba30 | 2006-06-07 10:23:38 -0700 | [diff] [blame] | 101 | ehci_warn(ehci, "can't enable NVidia " |
| 102 | "workaround for >2GB RAM\n"); |
| 103 | break; |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 104 | |
| 105 | /* Some NForce2 chips have problems with selective suspend; |
| 106 | * fixed in newer silicon. |
| 107 | */ |
| 108 | case 0x0068: |
| 109 | if (pdev->revision < 0xa4) |
| 110 | ehci->no_selective_suspend = 1; |
| 111 | break; |
Paul Serice | c32ba30 | 2006-06-07 10:23:38 -0700 | [diff] [blame] | 112 | } |
| 113 | break; |
Alek Du | 403dbd3 | 2009-07-13 17:30:41 +0800 | [diff] [blame] | 114 | case PCI_VENDOR_ID_INTEL: |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 115 | if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) |
Dirk Brandewie | 4f68384 | 2010-11-17 07:43:09 -0800 | [diff] [blame] | 116 | hcd->has_tt = 1; |
Alek Du | 403dbd3 | 2009-07-13 17:30:41 +0800 | [diff] [blame] | 117 | break; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 118 | case PCI_VENDOR_ID_TDI: |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 119 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) |
Alan Stern | 7329e21 | 2008-04-03 18:02:56 -0400 | [diff] [blame] | 120 | hcd->has_tt = 1; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 121 | break; |
| 122 | case PCI_VENDOR_ID_AMD: |
Andiry Xu | ad93562 | 2011-03-01 14:57:05 +0800 | [diff] [blame] | 123 | /* AMD PLL quirk */ |
| 124 | if (usb_amd_find_chipset_info()) |
| 125 | ehci->amd_pll_fix = 1; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 126 | /* AMD8111 EHCI doesn't work, according to AMD errata */ |
| 127 | if (pdev->device == 0x7463) { |
| 128 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 129 | retval = -EIO; |
| 130 | goto done; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 131 | } |
Brian J. Tarricone | a85b4e7 | 2010-11-21 21:15:52 -0800 | [diff] [blame] | 132 | |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 133 | /* |
| 134 | * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may |
| 135 | * read/write memory space which does not belong to it when |
| 136 | * there is NULL pointer with T-bit set to 1 in the frame list |
| 137 | * table. To avoid the issue, the frame list link pointer |
| 138 | * should always contain a valid pointer to a inactive qh. |
Brian J. Tarricone | a85b4e7 | 2010-11-21 21:15:52 -0800 | [diff] [blame] | 139 | */ |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 140 | if (pdev->device == 0x7808) { |
| 141 | ehci->use_dummy_qh = 1; |
| 142 | ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 143 | } |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 144 | break; |
Rene Herman | 055b93c | 2008-03-20 00:58:16 -0700 | [diff] [blame] | 145 | case PCI_VENDOR_ID_VIA: |
| 146 | if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) { |
| 147 | u8 tmp; |
| 148 | |
| 149 | /* The VT6212 defaults to a 1 usec EHCI sleep time which |
| 150 | * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes |
| 151 | * that sleep time use the conventional 10 usec. |
| 152 | */ |
| 153 | pci_read_config_byte(pdev, 0x4b, &tmp); |
| 154 | if (tmp & 0x20) |
| 155 | break; |
| 156 | pci_write_config_byte(pdev, 0x4b, tmp | 0x20); |
| 157 | } |
| 158 | break; |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 159 | case PCI_VENDOR_ID_ATI: |
Andiry Xu | ad93562 | 2011-03-01 14:57:05 +0800 | [diff] [blame] | 160 | /* AMD PLL quirk */ |
| 161 | if (usb_amd_find_chipset_info()) |
| 162 | ehci->amd_pll_fix = 1; |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may |
| 166 | * read/write memory space which does not belong to it when |
| 167 | * there is NULL pointer with T-bit set to 1 in the frame list |
| 168 | * table. To avoid the issue, the frame list link pointer |
| 169 | * should always contain a valid pointer to a inactive qh. |
| 170 | */ |
| 171 | if (pdev->device == 0x4396) { |
| 172 | ehci->use_dummy_qh = 1; |
| 173 | ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI dummy qh workaround\n"); |
| 174 | } |
Shane Huang | 0a99e8a | 2008-11-25 15:12:33 +0800 | [diff] [blame] | 175 | /* SB600 and old version of SB700 have a bug in EHCI controller, |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 176 | * which causes usb devices lose response in some cases. |
| 177 | */ |
Shane Huang | 0a99e8a | 2008-11-25 15:12:33 +0800 | [diff] [blame] | 178 | if ((pdev->device == 0x4386) || (pdev->device == 0x4396)) { |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 179 | p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, |
| 180 | PCI_DEVICE_ID_ATI_SBX00_SMBUS, |
| 181 | NULL); |
| 182 | if (!p_smbus) |
| 183 | break; |
| 184 | rev = p_smbus->revision; |
Shane Huang | 0a99e8a | 2008-11-25 15:12:33 +0800 | [diff] [blame] | 185 | if ((pdev->device == 0x4386) || (rev == 0x3a) |
| 186 | || (rev == 0x3b)) { |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 187 | u8 tmp; |
Shane Huang | 0a99e8a | 2008-11-25 15:12:33 +0800 | [diff] [blame] | 188 | ehci_info(ehci, "applying AMD SB600/SB700 USB " |
| 189 | "freeze workaround\n"); |
Andiry Xu | b09bc6c | 2008-11-14 11:42:29 +0800 | [diff] [blame] | 190 | pci_read_config_byte(pdev, 0x53, &tmp); |
| 191 | pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); |
| 192 | } |
| 193 | pci_dev_put(p_smbus); |
| 194 | } |
| 195 | break; |
Alan Stern | 68aa95d | 2011-10-12 10:39:14 -0400 | [diff] [blame] | 196 | case PCI_VENDOR_ID_NETMOS: |
| 197 | /* MosChip frame-index-register bug */ |
| 198 | ehci_info(ehci, "applying MosChip frame-index workaround\n"); |
| 199 | ehci->frame_index_bug = 1; |
| 200 | break; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 201 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 202 | |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 203 | retval = ehci_setup(hcd); |
| 204 | if (retval) |
| 205 | return retval; |
| 206 | |
| 207 | /* These workarounds need to be applied after ehci_setup() */ |
| 208 | switch (pdev->vendor) { |
| 209 | case PCI_VENDOR_ID_NEC: |
| 210 | ehci->need_io_watchdog = 0; |
| 211 | break; |
| 212 | case PCI_VENDOR_ID_INTEL: |
| 213 | ehci->need_io_watchdog = 0; |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 214 | break; |
| 215 | case PCI_VENDOR_ID_NVIDIA: |
| 216 | switch (pdev->device) { |
| 217 | /* MCP89 chips on the MacBookAir3,1 give EPROTO when |
| 218 | * fetching device descriptors unless LPM is disabled. |
| 219 | * There are also intermittent problems enumerating |
| 220 | * devices with PPCD enabled. |
| 221 | */ |
| 222 | case 0x0d9d: |
Alan Stern | 4968f95 | 2012-10-31 13:12:11 -0400 | [diff] [blame] | 223 | ehci_info(ehci, "disable ppcd for nvidia mcp89\n"); |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 224 | ehci->has_ppcd = 0; |
| 225 | ehci->command &= ~CMD_PPCEE; |
| 226 | break; |
| 227 | } |
| 228 | break; |
| 229 | } |
| 230 | |
Jason Wessel | 8d053c7 | 2009-08-20 15:39:54 -0500 | [diff] [blame] | 231 | /* optional debug port, normally in the first BAR */ |
| 232 | temp = pci_find_capability(pdev, 0x0a); |
| 233 | if (temp) { |
| 234 | pci_read_config_dword(pdev, temp, &temp); |
| 235 | temp >>= 16; |
| 236 | if ((temp & (3 << 13)) == (1 << 13)) { |
| 237 | temp &= 0x1fff; |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 238 | ehci->debug = hcd->regs + temp; |
Jason Wessel | 8d053c7 | 2009-08-20 15:39:54 -0500 | [diff] [blame] | 239 | temp = ehci_readl(ehci, &ehci->debug->control); |
| 240 | ehci_info(ehci, "debug port %d%s\n", |
| 241 | HCS_DEBUG_PORT(ehci->hcs_params), |
| 242 | (temp & DBGP_ENABLED) |
| 243 | ? " IN USE" |
| 244 | : ""); |
| 245 | if (!(temp & DBGP_ENABLED)) |
| 246 | ehci->debug = NULL; |
| 247 | } |
| 248 | } |
| 249 | |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 250 | /* at least the Genesys GL880S needs fixup here */ |
| 251 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); |
| 252 | temp &= 0x0f; |
| 253 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 254 | ehci_dbg(ehci, "bogus port configuration: " |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 255 | "cc=%d x pcc=%d < ports=%d\n", |
| 256 | HCS_N_CC(ehci->hcs_params), |
| 257 | HCS_N_PCC(ehci->hcs_params), |
| 258 | HCS_N_PORTS(ehci->hcs_params)); |
| 259 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 260 | switch (pdev->vendor) { |
| 261 | case 0x17a0: /* GENESYS */ |
| 262 | /* GL880S: should be PORTS=2 */ |
| 263 | temp |= (ehci->hcs_params & ~0xf); |
| 264 | ehci->hcs_params = temp; |
| 265 | break; |
| 266 | case PCI_VENDOR_ID_NVIDIA: |
| 267 | /* NF4: should be PCC=10 */ |
| 268 | break; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 272 | /* Serial Bus Release Number is at PCI 0x60 offset */ |
Alessandro Rubini | 3a0bac0 | 2012-01-06 13:33:28 +0100 | [diff] [blame] | 273 | if (pdev->vendor == PCI_VENDOR_ID_STMICRO |
| 274 | && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) |
Alan Stern | 1a49e2a | 2012-07-09 15:55:14 -0400 | [diff] [blame] | 275 | ; /* ConneXT has no sbrn register */ |
| 276 | else |
| 277 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 278 | |
Alan Stern | 6fd9086 | 2008-12-17 17:20:38 -0500 | [diff] [blame] | 279 | /* Keep this around for a while just in case some EHCI |
| 280 | * implementation uses legacy PCI PM support. This test |
| 281 | * can be removed on 17 Dec 2009 if the dev_warn() hasn't |
| 282 | * been triggered by then. |
David Brownell | 2c1c3c4 | 2005-11-07 15:24:46 -0800 | [diff] [blame] | 283 | */ |
| 284 | if (!device_can_wakeup(&pdev->dev)) { |
| 285 | u16 port_wake; |
| 286 | |
| 287 | pci_read_config_word(pdev, 0x62, &port_wake); |
Alan Stern | 6fd9086 | 2008-12-17 17:20:38 -0500 | [diff] [blame] | 288 | if (port_wake & 0x0001) { |
| 289 | dev_warn(&pdev->dev, "Enabling legacy PCI PM\n"); |
Alan Stern | bcca06e | 2009-01-13 11:35:54 -0500 | [diff] [blame] | 290 | device_set_wakeup_capable(&pdev->dev, 1); |
Alan Stern | 6fd9086 | 2008-12-17 17:20:38 -0500 | [diff] [blame] | 291 | } |
David Brownell | 2c1c3c4 | 2005-11-07 15:24:46 -0800 | [diff] [blame] | 292 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 293 | |
David Brownell | f8aeb3b | 2006-01-20 13:55:14 -0800 | [diff] [blame] | 294 | #ifdef CONFIG_USB_SUSPEND |
| 295 | /* REVISIT: the controller works fine for wakeup iff the root hub |
| 296 | * itself is "globally" suspended, but usbcore currently doesn't |
| 297 | * understand such things. |
| 298 | * |
| 299 | * System suspend currently expects to be able to suspend the entire |
| 300 | * device tree, device-at-a-time. If we failed selective suspend |
| 301 | * reports, system suspend would fail; so the root hub code must claim |
Anand Gadiyar | 411c940 | 2009-07-07 15:24:23 +0530 | [diff] [blame] | 302 | * success. That's lying to usbcore, and it matters for runtime |
David Brownell | f8aeb3b | 2006-01-20 13:55:14 -0800 | [diff] [blame] | 303 | * PM scenarios with selective suspend and remote wakeup... |
| 304 | */ |
| 305 | if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) |
| 306 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); |
| 307 | #endif |
| 308 | |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 309 | retval = ehci_pci_reinit(ehci, pdev); |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 310 | done: |
| 311 | return retval; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /*-------------------------------------------------------------------------*/ |
| 315 | |
| 316 | #ifdef CONFIG_PM |
| 317 | |
| 318 | /* suspend/resume, section 4.3 */ |
| 319 | |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 320 | /* These routines rely on the PCI bus glue |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 321 | * to handle powerdown and wakeup, and currently also on |
| 322 | * transceivers that don't need any software attention to set up |
| 323 | * the right sort of wakeup. |
David Brownell | f03c17f | 2005-11-23 15:45:28 -0800 | [diff] [blame] | 324 | * Also they depend on separate root hub suspend/resume. |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 325 | */ |
| 326 | |
Sarah Sharp | 69e848c | 2011-02-22 09:57:15 -0800 | [diff] [blame] | 327 | static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) |
| 328 | { |
| 329 | return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && |
| 330 | pdev->vendor == PCI_VENDOR_ID_INTEL && |
Sarah Sharp | 1c12443 | 2012-02-09 15:55:13 -0800 | [diff] [blame] | 331 | (pdev->device == 0x1E26 || |
| 332 | pdev->device == 0x8C2D || |
Russell Webb | bb1e5dd | 2012-11-09 13:58:49 -0800 | [diff] [blame^] | 333 | pdev->device == 0x8C26 || |
| 334 | pdev->device == 0x9C26); |
Sarah Sharp | 69e848c | 2011-02-22 09:57:15 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | static void ehci_enable_xhci_companion(void) |
| 338 | { |
| 339 | struct pci_dev *companion = NULL; |
| 340 | |
| 341 | /* The xHCI and EHCI controllers are not on the same PCI slot */ |
| 342 | for_each_pci_dev(companion) { |
| 343 | if (!usb_is_intel_switchable_xhci(companion)) |
| 344 | continue; |
| 345 | usb_enable_xhci_ports(companion); |
| 346 | return; |
| 347 | } |
| 348 | } |
| 349 | |
Alan Stern | 6ec4beb | 2009-04-27 13:33:41 -0400 | [diff] [blame] | 350 | static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 351 | { |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 352 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
David Brownell | 1880752 | 2005-11-23 15:45:37 -0800 | [diff] [blame] | 353 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 354 | |
Sarah Sharp | 69e848c | 2011-02-22 09:57:15 -0800 | [diff] [blame] | 355 | /* The BIOS on systems with the Intel Panther Point chipset may or may |
| 356 | * not support xHCI natively. That means that during system resume, it |
| 357 | * may switch the ports back to EHCI so that users can use their |
| 358 | * keyboard to select a kernel from GRUB after resume from hibernate. |
| 359 | * |
| 360 | * The BIOS is supposed to remember whether the OS had xHCI ports |
| 361 | * enabled before resume, and switch the ports back to xHCI when the |
| 362 | * BIOS/OS semaphore is written, but we all know we can't trust BIOS |
| 363 | * writers. |
| 364 | * |
| 365 | * Unconditionally switch the ports back to xHCI after a system resume. |
| 366 | * We can't tell whether the EHCI or xHCI controller will be resumed |
| 367 | * first, so we have to do the port switchover in both drivers. Writing |
| 368 | * a '1' to the port switchover registers should have no effect if the |
| 369 | * port was already switched over. |
| 370 | */ |
| 371 | if (usb_is_intel_switchable_ehci(pdev)) |
| 372 | ehci_enable_xhci_companion(); |
| 373 | |
Alan Stern | c5cf921 | 2012-06-28 11:19:02 -0400 | [diff] [blame] | 374 | if (ehci_resume(hcd, hibernated) != 0) |
| 375 | (void) ehci_pci_reinit(ehci, pdev); |
Alan Stern | 8c03356 | 2006-11-09 14:42:16 -0500 | [diff] [blame] | 376 | return 0; |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 377 | } |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 378 | |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 379 | #else |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 380 | |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 381 | #define ehci_suspend NULL |
| 382 | #define ehci_pci_resume NULL |
| 383 | #endif /* CONFIG_PM */ |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 384 | |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 385 | static struct hc_driver __read_mostly ehci_pci_hc_driver; |
| 386 | |
Alan Stern | 1b36810 | 2012-11-07 16:12:47 -0500 | [diff] [blame] | 387 | static const struct ehci_driver_overrides pci_overrides __initdata = { |
David Brownell | 8926bfa | 2005-11-28 08:40:38 -0800 | [diff] [blame] | 388 | .reset = ehci_pci_setup, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 389 | }; |
| 390 | |
| 391 | /*-------------------------------------------------------------------------*/ |
| 392 | |
| 393 | /* PCI driver selection metadata; PCI hotplugging uses this */ |
| 394 | static const struct pci_device_id pci_ids [] = { { |
| 395 | /* handle any USB 2.0 EHCI controller */ |
Jean Delvare | c67808e | 2006-04-09 20:07:35 +0200 | [diff] [blame] | 396 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 397 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
Alessandro Rubini | 3a0bac0 | 2012-01-06 13:33:28 +0100 | [diff] [blame] | 398 | }, { |
| 399 | PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST), |
| 400 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 401 | }, |
| 402 | { /* end: all zeroes */ } |
| 403 | }; |
David Brownell | abcc94480 | 2005-11-23 15:45:32 -0800 | [diff] [blame] | 404 | MODULE_DEVICE_TABLE(pci, pci_ids); |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 405 | |
| 406 | /* pci driver glue; this is a "new style" PCI driver module */ |
| 407 | static struct pci_driver ehci_pci_driver = { |
| 408 | .name = (char *) hcd_name, |
| 409 | .id_table = pci_ids, |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 410 | |
| 411 | .probe = usb_hcd_pci_probe, |
| 412 | .remove = usb_hcd_pci_remove, |
Aleksey Gorelov | 64a21d0 | 2006-08-08 17:24:08 -0700 | [diff] [blame] | 413 | .shutdown = usb_hcd_pci_shutdown, |
Alan Stern | abb3064 | 2009-04-27 13:33:24 -0400 | [diff] [blame] | 414 | |
| 415 | #ifdef CONFIG_PM_SLEEP |
| 416 | .driver = { |
| 417 | .pm = &usb_hcd_pci_pm_ops |
| 418 | }, |
| 419 | #endif |
Matt Porter | 7ff71d6 | 2005-09-22 22:31:15 -0700 | [diff] [blame] | 420 | }; |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 421 | |
| 422 | static int __init ehci_pci_init(void) |
| 423 | { |
| 424 | if (usb_disabled()) |
| 425 | return -ENODEV; |
| 426 | |
| 427 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); |
| 428 | |
Alan Stern | 1b36810 | 2012-11-07 16:12:47 -0500 | [diff] [blame] | 429 | ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides); |
Alan Stern | adfa79d | 2012-11-01 11:13:04 -0400 | [diff] [blame] | 430 | |
| 431 | /* Entries for the PCI suspend/resume callbacks are special */ |
| 432 | ehci_pci_hc_driver.pci_suspend = ehci_suspend; |
| 433 | ehci_pci_hc_driver.pci_resume = ehci_pci_resume; |
| 434 | |
| 435 | return pci_register_driver(&ehci_pci_driver); |
| 436 | } |
| 437 | module_init(ehci_pci_init); |
| 438 | |
| 439 | static void __exit ehci_pci_cleanup(void) |
| 440 | { |
| 441 | pci_unregister_driver(&ehci_pci_driver); |
| 442 | } |
| 443 | module_exit(ehci_pci_cleanup); |
| 444 | |
| 445 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 446 | MODULE_AUTHOR("David Brownell"); |
| 447 | MODULE_AUTHOR("Alan Stern"); |
| 448 | MODULE_LICENSE("GPL"); |