11da177e4SLinus Torvalds /* 2578333abSAlan Stern * Enhanced Host Controller Interface (EHCI) driver for USB. 3578333abSAlan Stern * 4578333abSAlan Stern * Maintainer: Alan Stern <stern@rowland.harvard.edu> 5578333abSAlan Stern * 61da177e4SLinus Torvalds * Copyright (c) 2000-2004 by David Brownell 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 91da177e4SLinus Torvalds * under the terms of the GNU General Public License as published by the 101da177e4SLinus Torvalds * Free Software Foundation; either version 2 of the License, or (at your 111da177e4SLinus Torvalds * option) any later version. 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, but 141da177e4SLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 151da177e4SLinus Torvalds * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 161da177e4SLinus Torvalds * for more details. 171da177e4SLinus Torvalds * 181da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 191da177e4SLinus Torvalds * along with this program; if not, write to the Free Software Foundation, 201da177e4SLinus Torvalds * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 211da177e4SLinus Torvalds */ 221da177e4SLinus Torvalds 231da177e4SLinus Torvalds #include <linux/module.h> 241da177e4SLinus Torvalds #include <linux/pci.h> 251da177e4SLinus Torvalds #include <linux/dmapool.h> 261da177e4SLinus Torvalds #include <linux/kernel.h> 271da177e4SLinus Torvalds #include <linux/delay.h> 281da177e4SLinus Torvalds #include <linux/ioport.h> 291da177e4SLinus Torvalds #include <linux/sched.h> 303c04e20eSMing Lei #include <linux/vmalloc.h> 311da177e4SLinus Torvalds #include <linux/errno.h> 321da177e4SLinus Torvalds #include <linux/init.h> 33d58b4bccSAlan Stern #include <linux/hrtimer.h> 341da177e4SLinus Torvalds #include <linux/list.h> 351da177e4SLinus Torvalds #include <linux/interrupt.h> 361da177e4SLinus Torvalds #include <linux/usb.h> 3727729aadSEric Lescouet #include <linux/usb/hcd.h> 381da177e4SLinus Torvalds #include <linux/moduleparam.h> 391da177e4SLinus Torvalds #include <linux/dma-mapping.h> 40694cc208STony Jones #include <linux/debugfs.h> 415a0e3ad6STejun Heo #include <linux/slab.h> 42aa4d8342SAlek Du #include <linux/uaccess.h> 431da177e4SLinus Torvalds 441da177e4SLinus Torvalds #include <asm/byteorder.h> 451da177e4SLinus Torvalds #include <asm/io.h> 461da177e4SLinus Torvalds #include <asm/irq.h> 471da177e4SLinus Torvalds #include <asm/unaligned.h> 481da177e4SLinus Torvalds 49df7c1ca2SGeoff Levand #if defined(CONFIG_PPC_PS3) 50df7c1ca2SGeoff Levand #include <asm/firmware.h> 51df7c1ca2SGeoff Levand #endif 52df7c1ca2SGeoff Levand 531da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds /* 561da177e4SLinus Torvalds * EHCI hc_driver implementation ... experimental, incomplete. 571da177e4SLinus Torvalds * Based on the final 1.0 register interface specification. 581da177e4SLinus Torvalds * 591da177e4SLinus Torvalds * USB 2.0 shows up in upcoming www.pcmcia.org technology. 601da177e4SLinus Torvalds * First was PCMCIA, like ISA; then CardBus, which is PCI. 611da177e4SLinus Torvalds * Next comes "CardBay", using USB 2.0 signals. 621da177e4SLinus Torvalds * 631da177e4SLinus Torvalds * Contains additional contributions by Brad Hards, Rory Bolt, and others. 641da177e4SLinus Torvalds * Special thanks to Intel and VIA for providing host controllers to 651da177e4SLinus Torvalds * test this driver on, and Cypress (including In-System Design) for 661da177e4SLinus Torvalds * providing early devices for those host controllers to talk to! 671da177e4SLinus Torvalds */ 681da177e4SLinus Torvalds 691da177e4SLinus Torvalds #define DRIVER_AUTHOR "David Brownell" 701da177e4SLinus Torvalds #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds static const char hcd_name [] = "ehci_hcd"; 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds 759776afc8SDavid Brownell #undef VERBOSE_DEBUG 761da177e4SLinus Torvalds #undef EHCI_URB_TRACE 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds #ifdef DEBUG 791da177e4SLinus Torvalds #define EHCI_STATS 801da177e4SLinus Torvalds #endif 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds /* magic numbers that can affect system performance */ 831da177e4SLinus Torvalds #define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ 841da177e4SLinus Torvalds #define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */ 851da177e4SLinus Torvalds #define EHCI_TUNE_RL_TT 0 861da177e4SLinus Torvalds #define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ 871da177e4SLinus Torvalds #define EHCI_TUNE_MULT_TT 1 88ffda0803SAlan Stern /* 89ffda0803SAlan Stern * Some drivers think it's safe to schedule isochronous transfers more than 90ffda0803SAlan Stern * 256 ms into the future (partly as a result of an old bug in the scheduling 91ffda0803SAlan Stern * code). In an attempt to avoid trouble, we will use a minimum scheduling 92ffda0803SAlan Stern * length of 512 frames instead of 256. 93ffda0803SAlan Stern */ 94ffda0803SAlan Stern #define EHCI_TUNE_FLS 1 /* (medium) 512-frame schedule */ 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds /* Initial IRQ latency: faster than hw default */ 971da177e4SLinus Torvalds static int log2_irq_thresh = 0; // 0 to 6 981da177e4SLinus Torvalds module_param (log2_irq_thresh, int, S_IRUGO); 991da177e4SLinus Torvalds MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes"); 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds /* initial park setting: slower than hw default */ 1021da177e4SLinus Torvalds static unsigned park = 0; 1031da177e4SLinus Torvalds module_param (park, uint, S_IRUGO); 1041da177e4SLinus Torvalds MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); 1051da177e4SLinus Torvalds 10693f1a47cSDavid Brownell /* for flakey hardware, ignore overcurrent indicators */ 10790ab5ee9SRusty Russell static bool ignore_oc = 0; 10893f1a47cSDavid Brownell module_param (ignore_oc, bool, S_IRUGO); 10993f1a47cSDavid Brownell MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); 11093f1a47cSDavid Brownell 11148f24970SAlek Du /* for link power management(LPM) feature */ 11248f24970SAlek Du static unsigned int hird; 11348f24970SAlek Du module_param(hird, int, S_IRUGO); 114cc556871SNiels de Vos MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); 11548f24970SAlek Du 1161da177e4SLinus Torvalds #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 1191da177e4SLinus Torvalds 1201da177e4SLinus Torvalds #include "ehci.h" 1211da177e4SLinus Torvalds #include "ehci-dbg.c" 122ad93562bSAndiry Xu #include "pci-quirks.h" 1231da177e4SLinus Torvalds 1241da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds /* 1271da177e4SLinus Torvalds * handshake - spin reading hc until handshake completes or fails 1281da177e4SLinus Torvalds * @ptr: address of hc register to be read 1291da177e4SLinus Torvalds * @mask: bits to look at in result of read 1301da177e4SLinus Torvalds * @done: value of those bits when handshake succeeds 1311da177e4SLinus Torvalds * @usec: timeout in microseconds 1321da177e4SLinus Torvalds * 1331da177e4SLinus Torvalds * Returns negative errno, or zero on success 1341da177e4SLinus Torvalds * 1351da177e4SLinus Torvalds * Success happens when the "mask" bits have the specified value (hardware 1361da177e4SLinus Torvalds * handshake done). There are two failure modes: "usec" have passed (major 1371da177e4SLinus Torvalds * hardware flakeout), or the register reads as all-ones (hardware removed). 1381da177e4SLinus Torvalds * 1391da177e4SLinus Torvalds * That last failure should_only happen in cases like physical cardbus eject 1401da177e4SLinus Torvalds * before driver shutdown. But it also seems to be caused by bugs in cardbus 1411da177e4SLinus Torvalds * bridge shutdown: shutting down the bridge before the devices using it. 1421da177e4SLinus Torvalds */ 143083522d7SBenjamin Herrenschmidt static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, 144083522d7SBenjamin Herrenschmidt u32 mask, u32 done, int usec) 1451da177e4SLinus Torvalds { 1461da177e4SLinus Torvalds u32 result; 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds do { 149083522d7SBenjamin Herrenschmidt result = ehci_readl(ehci, ptr); 1501da177e4SLinus Torvalds if (result == ~(u32)0) /* card removed */ 1511da177e4SLinus Torvalds return -ENODEV; 1521da177e4SLinus Torvalds result &= mask; 1531da177e4SLinus Torvalds if (result == done) 1541da177e4SLinus Torvalds return 0; 1551da177e4SLinus Torvalds udelay (1); 1561da177e4SLinus Torvalds usec--; 1571da177e4SLinus Torvalds } while (usec > 0); 1581da177e4SLinus Torvalds return -ETIMEDOUT; 1591da177e4SLinus Torvalds } 1601da177e4SLinus Torvalds 16165fd4272SMatthieu CASTET /* check TDI/ARC silicon is in host mode */ 16265fd4272SMatthieu CASTET static int tdi_in_host_mode (struct ehci_hcd *ehci) 16365fd4272SMatthieu CASTET { 16465fd4272SMatthieu CASTET u32 tmp; 16565fd4272SMatthieu CASTET 166a46af4ebSAlan Stern tmp = ehci_readl(ehci, &ehci->regs->usbmode); 16765fd4272SMatthieu CASTET return (tmp & 3) == USBMODE_CM_HC; 16865fd4272SMatthieu CASTET } 16965fd4272SMatthieu CASTET 170*c4f34764SAlan Stern /* 171*c4f34764SAlan Stern * Force HC to halt state from unknown (EHCI spec section 2.3). 172*c4f34764SAlan Stern * Must be called with interrupts enabled and the lock not held. 173*c4f34764SAlan Stern */ 1741da177e4SLinus Torvalds static int ehci_halt (struct ehci_hcd *ehci) 1751da177e4SLinus Torvalds { 176*c4f34764SAlan Stern u32 temp; 177*c4f34764SAlan Stern 178*c4f34764SAlan Stern spin_lock_irq(&ehci->lock); 1791da177e4SLinus Torvalds 18072f30b6fSDavid Brownell /* disable any irqs left enabled by previous code */ 181083522d7SBenjamin Herrenschmidt ehci_writel(ehci, 0, &ehci->regs->intr_enable); 18272f30b6fSDavid Brownell 183*c4f34764SAlan Stern if (ehci_is_TDI(ehci) && !tdi_in_host_mode(ehci)) { 184*c4f34764SAlan Stern spin_unlock_irq(&ehci->lock); 18565fd4272SMatthieu CASTET return 0; 18665fd4272SMatthieu CASTET } 18765fd4272SMatthieu CASTET 1883d9545ccSAlan Stern /* 1893d9545ccSAlan Stern * This routine gets called during probe before ehci->command 1903d9545ccSAlan Stern * has been initialized, so we can't rely on its value. 1913d9545ccSAlan Stern */ 1923d9545ccSAlan Stern ehci->command &= ~CMD_RUN; 193083522d7SBenjamin Herrenschmidt temp = ehci_readl(ehci, &ehci->regs->command); 1943d9545ccSAlan Stern temp &= ~(CMD_RUN | CMD_IAAD); 195083522d7SBenjamin Herrenschmidt ehci_writel(ehci, temp, &ehci->regs->command); 196*c4f34764SAlan Stern 197*c4f34764SAlan Stern spin_unlock_irq(&ehci->lock); 198*c4f34764SAlan Stern synchronize_irq(ehci_to_hcd(ehci)->irq); 199*c4f34764SAlan Stern 200083522d7SBenjamin Herrenschmidt return handshake(ehci, &ehci->regs->status, 201083522d7SBenjamin Herrenschmidt STS_HALT, STS_HALT, 16 * 125); 2021da177e4SLinus Torvalds } 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds /* put TDI/ARC silicon into EHCI mode */ 2051da177e4SLinus Torvalds static void tdi_reset (struct ehci_hcd *ehci) 2061da177e4SLinus Torvalds { 2071da177e4SLinus Torvalds u32 tmp; 2081da177e4SLinus Torvalds 209a46af4ebSAlan Stern tmp = ehci_readl(ehci, &ehci->regs->usbmode); 210d23a1377SVladimir Barinov tmp |= USBMODE_CM_HC; 211d23a1377SVladimir Barinov /* The default byte access to MMR space is LE after 212d23a1377SVladimir Barinov * controller reset. Set the required endian mode 213d23a1377SVladimir Barinov * for transfer buffers to match the host microprocessor 214d23a1377SVladimir Barinov */ 215d23a1377SVladimir Barinov if (ehci_big_endian_mmio(ehci)) 216d23a1377SVladimir Barinov tmp |= USBMODE_BE; 217a46af4ebSAlan Stern ehci_writel(ehci, tmp, &ehci->regs->usbmode); 2181da177e4SLinus Torvalds } 2191da177e4SLinus Torvalds 220*c4f34764SAlan Stern /* 221*c4f34764SAlan Stern * Reset a non-running (STS_HALT == 1) controller. 222*c4f34764SAlan Stern * Must be called with interrupts enabled and the lock not held. 223*c4f34764SAlan Stern */ 2241da177e4SLinus Torvalds static int ehci_reset (struct ehci_hcd *ehci) 2251da177e4SLinus Torvalds { 2261da177e4SLinus Torvalds int retval; 227083522d7SBenjamin Herrenschmidt u32 command = ehci_readl(ehci, &ehci->regs->command); 2281da177e4SLinus Torvalds 2298d053c79SJason Wessel /* If the EHCI debug controller is active, special care must be 2308d053c79SJason Wessel * taken before and after a host controller reset */ 2318d053c79SJason Wessel if (ehci->debug && !dbgp_reset_prep()) 2328d053c79SJason Wessel ehci->debug = NULL; 2338d053c79SJason Wessel 2341da177e4SLinus Torvalds command |= CMD_RESET; 2351da177e4SLinus Torvalds dbg_cmd (ehci, "reset", command); 236083522d7SBenjamin Herrenschmidt ehci_writel(ehci, command, &ehci->regs->command); 237e8799906SAlan Stern ehci->rh_state = EHCI_RH_HALTED; 2381da177e4SLinus Torvalds ehci->next_statechange = jiffies; 239083522d7SBenjamin Herrenschmidt retval = handshake (ehci, &ehci->regs->command, 240083522d7SBenjamin Herrenschmidt CMD_RESET, 0, 250 * 1000); 2411da177e4SLinus Torvalds 242331ac6b2SAlek Du if (ehci->has_hostpc) { 243331ac6b2SAlek Du ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, 244a46af4ebSAlan Stern &ehci->regs->usbmode_ex); 245a46af4ebSAlan Stern ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning); 246331ac6b2SAlek Du } 2471da177e4SLinus Torvalds if (retval) 2481da177e4SLinus Torvalds return retval; 2491da177e4SLinus Torvalds 2501da177e4SLinus Torvalds if (ehci_is_TDI(ehci)) 2511da177e4SLinus Torvalds tdi_reset (ehci); 2521da177e4SLinus Torvalds 2538d053c79SJason Wessel if (ehci->debug) 2548d053c79SJason Wessel dbgp_external_startup(); 2558d053c79SJason Wessel 256a448e4dcSAlan Stern ehci->port_c_suspend = ehci->suspended_ports = 257a448e4dcSAlan Stern ehci->resuming_ports = 0; 2581da177e4SLinus Torvalds return retval; 2591da177e4SLinus Torvalds } 2601da177e4SLinus Torvalds 261*c4f34764SAlan Stern /* 262*c4f34764SAlan Stern * Idle the controller (turn off the schedules). 263*c4f34764SAlan Stern * Must be called with interrupts enabled and the lock not held. 264*c4f34764SAlan Stern */ 2651da177e4SLinus Torvalds static void ehci_quiesce (struct ehci_hcd *ehci) 2661da177e4SLinus Torvalds { 2671da177e4SLinus Torvalds u32 temp; 2681da177e4SLinus Torvalds 269e8799906SAlan Stern if (ehci->rh_state != EHCI_RH_RUNNING) 270c0c53dbcSAlan Stern return; 2711da177e4SLinus Torvalds 2721da177e4SLinus Torvalds /* wait for any schedule enables/disables to take effect */ 2733d9545ccSAlan Stern temp = (ehci->command << 10) & (STS_ASS | STS_PSS); 2749671cd7aSAlan Stern handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp, 16 * 125); 2751da177e4SLinus Torvalds 2761da177e4SLinus Torvalds /* then disable anything that's still active */ 277*c4f34764SAlan Stern spin_lock_irq(&ehci->lock); 2783d9545ccSAlan Stern ehci->command &= ~(CMD_ASE | CMD_PSE); 2793d9545ccSAlan Stern ehci_writel(ehci, ehci->command, &ehci->regs->command); 280*c4f34764SAlan Stern spin_unlock_irq(&ehci->lock); 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds /* hardware can take 16 microframes to turn off ... */ 2839671cd7aSAlan Stern handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0, 16 * 125); 2841da177e4SLinus Torvalds } 2851da177e4SLinus Torvalds 2861da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 2871da177e4SLinus Torvalds 28807d29b63SAlan Stern static void end_unlink_async(struct ehci_hcd *ehci); 28932830f20SAlan Stern static void unlink_empty_async(struct ehci_hcd *ehci); 2907d12e780SDavid Howells static void ehci_work(struct ehci_hcd *ehci); 291df202255SAlan Stern static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); 292df202255SAlan Stern static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); 2931da177e4SLinus Torvalds 294d58b4bccSAlan Stern #include "ehci-timer.c" 2951da177e4SLinus Torvalds #include "ehci-hub.c" 29648f24970SAlek Du #include "ehci-lpm.c" 2971da177e4SLinus Torvalds #include "ehci-mem.c" 2981da177e4SLinus Torvalds #include "ehci-q.c" 2991da177e4SLinus Torvalds #include "ehci-sched.c" 3004c67045bSKirill Smelkov #include "ehci-sysfs.c" 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 3031da177e4SLinus Torvalds 3048903795aSAlan Stern /* On some systems, leaving remote wakeup enabled prevents system shutdown. 3058903795aSAlan Stern * The firmware seems to think that powering off is a wakeup event! 3068903795aSAlan Stern * This routine turns off remote wakeup and everything else, on all ports. 3078903795aSAlan Stern */ 3088903795aSAlan Stern static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) 3098903795aSAlan Stern { 3108903795aSAlan Stern int port = HCS_N_PORTS(ehci->hcs_params); 3118903795aSAlan Stern 3128903795aSAlan Stern while (port--) 3138903795aSAlan Stern ehci_writel(ehci, PORT_RWC_BITS, 3148903795aSAlan Stern &ehci->regs->port_status[port]); 3158903795aSAlan Stern } 3168903795aSAlan Stern 31721da84a8SSarah Sharp /* 31821da84a8SSarah Sharp * Halt HC, turn off all ports, and let the BIOS use the companion controllers. 319*c4f34764SAlan Stern * Must be called with interrupts enabled and the lock not held. 32072f30b6fSDavid Brownell */ 32121da84a8SSarah Sharp static void ehci_silence_controller(struct ehci_hcd *ehci) 3221da177e4SLinus Torvalds { 32321da84a8SSarah Sharp ehci_halt(ehci); 324*c4f34764SAlan Stern 325*c4f34764SAlan Stern spin_lock_irq(&ehci->lock); 326*c4f34764SAlan Stern ehci->rh_state = EHCI_RH_HALTED; 3278903795aSAlan Stern ehci_turn_off_all_ports(ehci); 3281da177e4SLinus Torvalds 3291da177e4SLinus Torvalds /* make BIOS/etc use companion controller during reboot */ 330083522d7SBenjamin Herrenschmidt ehci_writel(ehci, 0, &ehci->regs->configured_flag); 3318903795aSAlan Stern 3328903795aSAlan Stern /* unblock posted writes */ 3338903795aSAlan Stern ehci_readl(ehci, &ehci->regs->configured_flag); 334*c4f34764SAlan Stern spin_unlock_irq(&ehci->lock); 3351da177e4SLinus Torvalds } 3361da177e4SLinus Torvalds 33721da84a8SSarah Sharp /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). 33821da84a8SSarah Sharp * This forcibly disables dma and IRQs, helping kexec and other cases 33921da84a8SSarah Sharp * where the next system software may expect clean state. 34021da84a8SSarah Sharp */ 34121da84a8SSarah Sharp static void ehci_shutdown(struct usb_hcd *hcd) 34221da84a8SSarah Sharp { 34321da84a8SSarah Sharp struct ehci_hcd *ehci = hcd_to_ehci(hcd); 34421da84a8SSarah Sharp 34521da84a8SSarah Sharp spin_lock_irq(&ehci->lock); 346c0c53dbcSAlan Stern ehci->rh_state = EHCI_RH_STOPPING; 347d58b4bccSAlan Stern ehci->enabled_hrtimer_events = 0; 34821da84a8SSarah Sharp spin_unlock_irq(&ehci->lock); 349d58b4bccSAlan Stern 350*c4f34764SAlan Stern ehci_silence_controller(ehci); 351*c4f34764SAlan Stern 352d58b4bccSAlan Stern hrtimer_cancel(&ehci->hrtimer); 35321da84a8SSarah Sharp } 35421da84a8SSarah Sharp 35556c1e26dSDavid Brownell static void ehci_port_power (struct ehci_hcd *ehci, int is_on) 35656c1e26dSDavid Brownell { 35756c1e26dSDavid Brownell unsigned port; 35856c1e26dSDavid Brownell 35956c1e26dSDavid Brownell if (!HCS_PPC (ehci->hcs_params)) 36056c1e26dSDavid Brownell return; 36156c1e26dSDavid Brownell 36256c1e26dSDavid Brownell ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down"); 36356c1e26dSDavid Brownell for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) 36456c1e26dSDavid Brownell (void) ehci_hub_control(ehci_to_hcd(ehci), 36556c1e26dSDavid Brownell is_on ? SetPortFeature : ClearPortFeature, 36656c1e26dSDavid Brownell USB_PORT_FEAT_POWER, 36756c1e26dSDavid Brownell port--, NULL, 0); 368383975d7SAlan Stern /* Flush those writes */ 369383975d7SAlan Stern ehci_readl(ehci, &ehci->regs->command); 37056c1e26dSDavid Brownell msleep(20); 37156c1e26dSDavid Brownell } 37256c1e26dSDavid Brownell 3737ff71d6aSMatt Porter /*-------------------------------------------------------------------------*/ 3741da177e4SLinus Torvalds 3757ff71d6aSMatt Porter /* 3767ff71d6aSMatt Porter * ehci_work is called from some interrupts, timers, and so on. 3777ff71d6aSMatt Porter * it calls driver completion functions, after dropping ehci->lock. 3787ff71d6aSMatt Porter */ 3797d12e780SDavid Howells static void ehci_work (struct ehci_hcd *ehci) 3807ff71d6aSMatt Porter { 3817ff71d6aSMatt Porter /* another CPU may drop ehci->lock during a schedule scan while 3827ff71d6aSMatt Porter * it reports urb completions. this flag guards against bogus 3837ff71d6aSMatt Porter * attempts at re-entrant schedule scanning. 3847ff71d6aSMatt Porter */ 385361aabf3SAlan Stern if (ehci->scanning) { 386361aabf3SAlan Stern ehci->need_rescan = true; 3877ff71d6aSMatt Porter return; 388361aabf3SAlan Stern } 389361aabf3SAlan Stern ehci->scanning = true; 390361aabf3SAlan Stern 391361aabf3SAlan Stern rescan: 392361aabf3SAlan Stern ehci->need_rescan = false; 39331446610SAlan Stern if (ehci->async_count) 3947d12e780SDavid Howells scan_async(ehci); 395569b394fSAlan Stern if (ehci->intr_count > 0) 396569b394fSAlan Stern scan_intr(ehci); 397569b394fSAlan Stern if (ehci->isoc_count > 0) 398569b394fSAlan Stern scan_isoc(ehci); 399361aabf3SAlan Stern if (ehci->need_rescan) 400361aabf3SAlan Stern goto rescan; 401361aabf3SAlan Stern ehci->scanning = false; 4027ff71d6aSMatt Porter 4037ff71d6aSMatt Porter /* the IO watchdog guards against hardware or driver bugs that 4047ff71d6aSMatt Porter * misplace IRQs, and should let us run completely without IRQs. 4057ff71d6aSMatt Porter * such lossage has been observed on both VT6202 and VT8235. 4067ff71d6aSMatt Porter */ 40718aafe64SAlan Stern turn_on_io_watchdog(ehci); 4087ff71d6aSMatt Porter } 4097ff71d6aSMatt Porter 41021da84a8SSarah Sharp /* 41121da84a8SSarah Sharp * Called when the ehci_hcd module is removed. 41221da84a8SSarah Sharp */ 4137ff71d6aSMatt Porter static void ehci_stop (struct usb_hcd *hcd) 4141da177e4SLinus Torvalds { 4151da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci (hcd); 4161da177e4SLinus Torvalds 4177ff71d6aSMatt Porter ehci_dbg (ehci, "stop\n"); 4181da177e4SLinus Torvalds 4197ff71d6aSMatt Porter /* no more interrupts ... */ 4201da177e4SLinus Torvalds 4217ff71d6aSMatt Porter spin_lock_irq(&ehci->lock); 422d58b4bccSAlan Stern ehci->enabled_hrtimer_events = 0; 423*c4f34764SAlan Stern spin_unlock_irq(&ehci->lock); 4241da177e4SLinus Torvalds 425*c4f34764SAlan Stern ehci_quiesce(ehci); 42621da84a8SSarah Sharp ehci_silence_controller(ehci); 4277ff71d6aSMatt Porter ehci_reset (ehci); 4287ff71d6aSMatt Porter 429d58b4bccSAlan Stern hrtimer_cancel(&ehci->hrtimer); 4304c67045bSKirill Smelkov remove_sysfs_files(ehci); 4317ff71d6aSMatt Porter remove_debug_files (ehci); 4327ff71d6aSMatt Porter 4337ff71d6aSMatt Porter /* root hub is shut down separately (first, when possible) */ 4347ff71d6aSMatt Porter spin_lock_irq (&ehci->lock); 43555934eb3SAlan Stern end_free_itds(ehci); 4367ff71d6aSMatt Porter spin_unlock_irq (&ehci->lock); 4377ff71d6aSMatt Porter ehci_mem_cleanup (ehci); 4387ff71d6aSMatt Porter 439ad93562bSAndiry Xu if (ehci->amd_pll_fix == 1) 440ad93562bSAndiry Xu usb_amd_dev_put(); 44105570297SAlex He 4427ff71d6aSMatt Porter #ifdef EHCI_STATS 44399ac5b1eSAlan Stern ehci_dbg(ehci, "irq normal %ld err %ld iaa %ld (lost %ld)\n", 44499ac5b1eSAlan Stern ehci->stats.normal, ehci->stats.error, ehci->stats.iaa, 4457ff71d6aSMatt Porter ehci->stats.lost_iaa); 4467ff71d6aSMatt Porter ehci_dbg (ehci, "complete %ld unlink %ld\n", 4477ff71d6aSMatt Porter ehci->stats.complete, ehci->stats.unlink); 4481da177e4SLinus Torvalds #endif 4497ff71d6aSMatt Porter 450083522d7SBenjamin Herrenschmidt dbg_status (ehci, "ehci_stop completed", 451083522d7SBenjamin Herrenschmidt ehci_readl(ehci, &ehci->regs->status)); 4521da177e4SLinus Torvalds } 4531da177e4SLinus Torvalds 45418807521SDavid Brownell /* one-time init, only for memory state */ 45518807521SDavid Brownell static int ehci_init(struct usb_hcd *hcd) 4561da177e4SLinus Torvalds { 4571da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci(hcd); 4581da177e4SLinus Torvalds u32 temp; 4591da177e4SLinus Torvalds int retval; 4601da177e4SLinus Torvalds u32 hcc_params; 4613807e26dSAlek Du struct ehci_qh_hw *hw; 4621da177e4SLinus Torvalds 46318807521SDavid Brownell spin_lock_init(&ehci->lock); 46418807521SDavid Brownell 465403dbd36SAlek Du /* 466403dbd36SAlek Du * keep io watchdog by default, those good HCDs could turn off it later 467403dbd36SAlek Du */ 468403dbd36SAlek Du ehci->need_io_watchdog = 1; 4691da177e4SLinus Torvalds 470d58b4bccSAlan Stern hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 471d58b4bccSAlan Stern ehci->hrtimer.function = ehci_hrtimer_func; 472d58b4bccSAlan Stern ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; 473d58b4bccSAlan Stern 474f75593ceSAlan Stern hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); 475f75593ceSAlan Stern 4761da177e4SLinus Torvalds /* 477cc62a7ebSKirill Smelkov * by default set standard 80% (== 100 usec/uframe) max periodic 478cc62a7ebSKirill Smelkov * bandwidth as required by USB 2.0 479cc62a7ebSKirill Smelkov */ 480cc62a7ebSKirill Smelkov ehci->uframe_periodic_max = 100; 481cc62a7ebSKirill Smelkov 482cc62a7ebSKirill Smelkov /* 4831da177e4SLinus Torvalds * hw default: 1K periodic list heads, one per frame. 4841da177e4SLinus Torvalds * periodic_size can shrink by USBCMD update if hcc_params allows. 4851da177e4SLinus Torvalds */ 4861da177e4SLinus Torvalds ehci->periodic_size = DEFAULT_I_TDPS; 487569b394fSAlan Stern INIT_LIST_HEAD(&ehci->intr_qh_list); 4889aa09d2fSKarsten Wiese INIT_LIST_HEAD(&ehci->cached_itd_list); 4890e5f231bSAlan Stern INIT_LIST_HEAD(&ehci->cached_sitd_list); 490f75593ceSAlan Stern 4918e192910SGreg Kroah-Hartman if (HCC_PGM_FRAMELISTLEN(hcc_params)) { 492f75593ceSAlan Stern /* periodic schedule size can be smaller than default */ 493f75593ceSAlan Stern switch (EHCI_TUNE_FLS) { 494f75593ceSAlan Stern case 0: ehci->periodic_size = 1024; break; 495f75593ceSAlan Stern case 1: ehci->periodic_size = 512; break; 496f75593ceSAlan Stern case 2: ehci->periodic_size = 256; break; 497f75593ceSAlan Stern default: BUG(); 498f75593ceSAlan Stern } 499f75593ceSAlan Stern } 50018807521SDavid Brownell if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) 5011da177e4SLinus Torvalds return retval; 5021da177e4SLinus Torvalds 5031da177e4SLinus Torvalds /* controllers may cache some of the periodic schedule ... */ 5041da177e4SLinus Torvalds if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 505dccd574cSSarah Sharp ehci->i_thresh = 2 + 8; 5061da177e4SLinus Torvalds else // N microframes cached 5071da177e4SLinus Torvalds ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 5081da177e4SLinus Torvalds 5091da177e4SLinus Torvalds /* 5101da177e4SLinus Torvalds * dedicate a qh for the async ring head, since we couldn't unlink 5111da177e4SLinus Torvalds * a 'real' qh without stopping the async schedule [4.8]. use it 5121da177e4SLinus Torvalds * as the 'reclamation list head' too. 5131da177e4SLinus Torvalds * its dummy is used in hw_alt_next of many tds, to prevent the qh 5141da177e4SLinus Torvalds * from automatically advancing to the next td after short reads. 5151da177e4SLinus Torvalds */ 5161da177e4SLinus Torvalds ehci->async->qh_next.qh = NULL; 5173807e26dSAlek Du hw = ehci->async->hw; 5183807e26dSAlek Du hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); 5193807e26dSAlek Du hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); 5204f7a67e2SRicardo Martins #if defined(CONFIG_PPC_PS3) 5214c53de72SAlan Stern hw->hw_info1 |= cpu_to_hc32(ehci, QH_INACTIVATE); 5224f7a67e2SRicardo Martins #endif 5233807e26dSAlek Du hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); 5243807e26dSAlek Du hw->hw_qtd_next = EHCI_LIST_END(ehci); 5251da177e4SLinus Torvalds ehci->async->qh_state = QH_STATE_LINKED; 5263807e26dSAlek Du hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma); 5271da177e4SLinus Torvalds 5281da177e4SLinus Torvalds /* clear interrupt enables, set irq latency */ 5291da177e4SLinus Torvalds if (log2_irq_thresh < 0 || log2_irq_thresh > 6) 5301da177e4SLinus Torvalds log2_irq_thresh = 0; 5311da177e4SLinus Torvalds temp = 1 << (16 + log2_irq_thresh); 5325a9cdf33SAlek Du if (HCC_PER_PORT_CHANGE_EVENT(hcc_params)) { 5335a9cdf33SAlek Du ehci->has_ppcd = 1; 5345a9cdf33SAlek Du ehci_dbg(ehci, "enable per-port change event\n"); 5355a9cdf33SAlek Du temp |= CMD_PPCEE; 5365a9cdf33SAlek Du } 5371da177e4SLinus Torvalds if (HCC_CANPARK(hcc_params)) { 5381da177e4SLinus Torvalds /* HW default park == 3, on hardware that supports it (like 5391da177e4SLinus Torvalds * NVidia and ALI silicon), maximizes throughput on the async 5401da177e4SLinus Torvalds * schedule by avoiding QH fetches between transfers. 5411da177e4SLinus Torvalds * 5421da177e4SLinus Torvalds * With fast usb storage devices and NForce2, "park" seems to 5431da177e4SLinus Torvalds * make problems: throughput reduction (!), data errors... 5441da177e4SLinus Torvalds */ 5451da177e4SLinus Torvalds if (park) { 5461da177e4SLinus Torvalds park = min(park, (unsigned) 3); 5471da177e4SLinus Torvalds temp |= CMD_PARK; 5481da177e4SLinus Torvalds temp |= park << 8; 5491da177e4SLinus Torvalds } 55018807521SDavid Brownell ehci_dbg(ehci, "park %d\n", park); 5511da177e4SLinus Torvalds } 5521da177e4SLinus Torvalds if (HCC_PGM_FRAMELISTLEN(hcc_params)) { 5531da177e4SLinus Torvalds /* periodic schedule size can be smaller than default */ 5541da177e4SLinus Torvalds temp &= ~(3 << 2); 5551da177e4SLinus Torvalds temp |= (EHCI_TUNE_FLS << 2); 5561da177e4SLinus Torvalds } 55748f24970SAlek Du if (HCC_LPM(hcc_params)) { 55848f24970SAlek Du /* support link power management EHCI 1.1 addendum */ 55948f24970SAlek Du ehci_dbg(ehci, "support lpm\n"); 56048f24970SAlek Du ehci->has_lpm = 1; 56148f24970SAlek Du if (hird > 0xf) { 56248f24970SAlek Du ehci_dbg(ehci, "hird %d invalid, use default 0", 56348f24970SAlek Du hird); 56448f24970SAlek Du hird = 0; 56548f24970SAlek Du } 56648f24970SAlek Du temp |= hird << 24; 56748f24970SAlek Du } 56818807521SDavid Brownell ehci->command = temp; 56918807521SDavid Brownell 57040f8db8fSAlan Stern /* Accept arbitrarily long scatter-gather lists */ 5714307a28eSAndrea Righi if (!(hcd->driver->flags & HCD_LOCAL_MEM)) 57240f8db8fSAlan Stern hcd->self.sg_tablesize = ~0; 57318807521SDavid Brownell return 0; 57418807521SDavid Brownell } 57518807521SDavid Brownell 57618807521SDavid Brownell /* start HC running; it's halted, ehci_init() has been run (once) */ 57718807521SDavid Brownell static int ehci_run (struct usb_hcd *hcd) 57818807521SDavid Brownell { 57918807521SDavid Brownell struct ehci_hcd *ehci = hcd_to_ehci (hcd); 58018807521SDavid Brownell u32 temp; 58118807521SDavid Brownell u32 hcc_params; 58218807521SDavid Brownell 5831d619f12SMarcelo Tosatti hcd->uses_new_polling = 1; 5841d619f12SMarcelo Tosatti 58518807521SDavid Brownell /* EHCI spec section 4.1 */ 586876e0df9SGeoff Levand 587083522d7SBenjamin Herrenschmidt ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); 588083522d7SBenjamin Herrenschmidt ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next); 58918807521SDavid Brownell 59018807521SDavid Brownell /* 59118807521SDavid Brownell * hcc_params controls whether ehci->regs->segment must (!!!) 59218807521SDavid Brownell * be used; it constrains QH/ITD/SITD and QTD locations. 59318807521SDavid Brownell * pci_pool consistent memory always uses segment zero. 59418807521SDavid Brownell * streaming mappings for I/O buffers, like pci_map_single(), 59518807521SDavid Brownell * can return segments above 4GB, if the device allows. 59618807521SDavid Brownell * 59718807521SDavid Brownell * NOTE: the dma mask is visible through dma_supported(), so 59818807521SDavid Brownell * drivers can pass this info along ... like NETIF_F_HIGHDMA, 59918807521SDavid Brownell * Scsi_Host.highmem_io, and so forth. It's readonly to all 60018807521SDavid Brownell * host side drivers though. 60118807521SDavid Brownell */ 602083522d7SBenjamin Herrenschmidt hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); 60318807521SDavid Brownell if (HCC_64BIT_ADDR(hcc_params)) { 604083522d7SBenjamin Herrenschmidt ehci_writel(ehci, 0, &ehci->regs->segment); 60518807521SDavid Brownell #if 0 60618807521SDavid Brownell // this is deeply broken on almost all architectures 6076a35528aSYang Hongyang if (!dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64))) 60818807521SDavid Brownell ehci_info(ehci, "enabled 64bit DMA\n"); 60918807521SDavid Brownell #endif 61018807521SDavid Brownell } 61118807521SDavid Brownell 61218807521SDavid Brownell 6131da177e4SLinus Torvalds // Philips, Intel, and maybe others need CMD_RUN before the 6141da177e4SLinus Torvalds // root hub will detect new devices (why?); NEC doesn't 61518807521SDavid Brownell ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET); 61618807521SDavid Brownell ehci->command |= CMD_RUN; 617083522d7SBenjamin Herrenschmidt ehci_writel(ehci, ehci->command, &ehci->regs->command); 61818807521SDavid Brownell dbg_cmd (ehci, "init", ehci->command); 6191da177e4SLinus Torvalds 6201da177e4SLinus Torvalds /* 6211da177e4SLinus Torvalds * Start, enabling full USB 2.0 functionality ... usb 1.1 devices 6221da177e4SLinus Torvalds * are explicitly handed to companion controller(s), so no TT is 6231da177e4SLinus Torvalds * involved with the root hub. (Except where one is integrated, 6241da177e4SLinus Torvalds * and there's no companion controller unless maybe for USB OTG.) 62532fe0198SAlan Stern * 62632fe0198SAlan Stern * Turning on the CF flag will transfer ownership of all ports 62732fe0198SAlan Stern * from the companions to the EHCI controller. If any of the 62832fe0198SAlan Stern * companions are in the middle of a port reset at the time, it 62932fe0198SAlan Stern * could cause trouble. Write-locking ehci_cf_port_reset_rwsem 6301cb52658SDavid Brownell * guarantees that no resets are in progress. After we set CF, 6311cb52658SDavid Brownell * a short delay lets the hardware catch up; new resets shouldn't 6321cb52658SDavid Brownell * be started before the port switching actions could complete. 6331da177e4SLinus Torvalds */ 63432fe0198SAlan Stern down_write(&ehci_cf_port_reset_rwsem); 635e8799906SAlan Stern ehci->rh_state = EHCI_RH_RUNNING; 636083522d7SBenjamin Herrenschmidt ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); 637083522d7SBenjamin Herrenschmidt ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ 6381cb52658SDavid Brownell msleep(5); 63932fe0198SAlan Stern up_write(&ehci_cf_port_reset_rwsem); 640ee4ecb8aSOliver Neukum ehci->last_periodic_enable = ktime_get_real(); 6411da177e4SLinus Torvalds 642c430131aSJan Andersson temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); 6431da177e4SLinus Torvalds ehci_info (ehci, 6442b70f073SAlan Stern "USB %x.%x started, EHCI %x.%02x%s\n", 6457ff71d6aSMatt Porter ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 6462b70f073SAlan Stern temp >> 8, temp & 0xff, 64793f1a47cSDavid Brownell ignore_oc ? ", overcurrent ignored" : ""); 6481da177e4SLinus Torvalds 649083522d7SBenjamin Herrenschmidt ehci_writel(ehci, INTR_MASK, 650083522d7SBenjamin Herrenschmidt &ehci->regs->intr_enable); /* Turn On Interrupts */ 6511da177e4SLinus Torvalds 65218807521SDavid Brownell /* GRR this is run-once init(), being done every time the HC starts. 65318807521SDavid Brownell * So long as they're part of class devices, we can't do it init() 65418807521SDavid Brownell * since the class device isn't created that early. 65518807521SDavid Brownell */ 6561da177e4SLinus Torvalds create_debug_files(ehci); 6574c67045bSKirill Smelkov create_sysfs_files(ehci); 6581da177e4SLinus Torvalds 6591da177e4SLinus Torvalds return 0; 6601da177e4SLinus Torvalds } 6611da177e4SLinus Torvalds 6621a49e2acSAlan Stern static int ehci_setup(struct usb_hcd *hcd) 6632093c6b4SMatthieu CASTET { 6642093c6b4SMatthieu CASTET struct ehci_hcd *ehci = hcd_to_ehci(hcd); 6652093c6b4SMatthieu CASTET int retval; 6662093c6b4SMatthieu CASTET 6672093c6b4SMatthieu CASTET ehci->regs = (void __iomem *)ehci->caps + 6682093c6b4SMatthieu CASTET HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); 6692093c6b4SMatthieu CASTET dbg_hcs_params(ehci, "reset"); 6702093c6b4SMatthieu CASTET dbg_hcc_params(ehci, "reset"); 6712093c6b4SMatthieu CASTET 6722093c6b4SMatthieu CASTET /* cache this readonly data; minimize chip reads */ 6732093c6b4SMatthieu CASTET ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 6742093c6b4SMatthieu CASTET 6752093c6b4SMatthieu CASTET ehci->sbrn = HCD_USB2; 6762093c6b4SMatthieu CASTET 677631fe9d9SAlan Stern /* data structure init */ 678631fe9d9SAlan Stern retval = ehci_init(hcd); 6792093c6b4SMatthieu CASTET if (retval) 6802093c6b4SMatthieu CASTET return retval; 6812093c6b4SMatthieu CASTET 682631fe9d9SAlan Stern retval = ehci_halt(ehci); 6832093c6b4SMatthieu CASTET if (retval) 6842093c6b4SMatthieu CASTET return retval; 6852093c6b4SMatthieu CASTET 6861a49e2acSAlan Stern if (ehci_is_TDI(ehci)) 6871a49e2acSAlan Stern tdi_reset(ehci); 6881a49e2acSAlan Stern 6892093c6b4SMatthieu CASTET ehci_reset(ehci); 6902093c6b4SMatthieu CASTET 6912093c6b4SMatthieu CASTET return 0; 6922093c6b4SMatthieu CASTET } 6932093c6b4SMatthieu CASTET 6941da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 6951da177e4SLinus Torvalds 6967d12e780SDavid Howells static irqreturn_t ehci_irq (struct usb_hcd *hcd) 6971da177e4SLinus Torvalds { 6981da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci (hcd); 69967b2e029SAlan Stern u32 status, masked_status, pcd_status = 0, cmd; 7001da177e4SLinus Torvalds int bh; 7011da177e4SLinus Torvalds 7021da177e4SLinus Torvalds spin_lock (&ehci->lock); 7031da177e4SLinus Torvalds 704083522d7SBenjamin Herrenschmidt status = ehci_readl(ehci, &ehci->regs->status); 7051da177e4SLinus Torvalds 7061da177e4SLinus Torvalds /* e.g. cardbus physical eject */ 7071da177e4SLinus Torvalds if (status == ~(u32) 0) { 7081da177e4SLinus Torvalds ehci_dbg (ehci, "device removed\n"); 7091da177e4SLinus Torvalds goto dead; 7101da177e4SLinus Torvalds } 7111da177e4SLinus Torvalds 7122fbe2bf1SAlan Stern /* 7132fbe2bf1SAlan Stern * We don't use STS_FLR, but some controllers don't like it to 7142fbe2bf1SAlan Stern * remain on, so mask it out along with the other status bits. 7152fbe2bf1SAlan Stern */ 7162fbe2bf1SAlan Stern masked_status = status & (INTR_MASK | STS_FLR); 7172fbe2bf1SAlan Stern 71869fff59dSAlan Stern /* Shared IRQ? */ 719e8799906SAlan Stern if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) { 7201da177e4SLinus Torvalds spin_unlock(&ehci->lock); 7211da177e4SLinus Torvalds return IRQ_NONE; 7221da177e4SLinus Torvalds } 7231da177e4SLinus Torvalds 7241da177e4SLinus Torvalds /* clear (just) interrupts */ 72567b2e029SAlan Stern ehci_writel(ehci, masked_status, &ehci->regs->status); 726e82cc128SDavid Brownell cmd = ehci_readl(ehci, &ehci->regs->command); 7271da177e4SLinus Torvalds bh = 0; 7281da177e4SLinus Torvalds 7299776afc8SDavid Brownell #ifdef VERBOSE_DEBUG 7301da177e4SLinus Torvalds /* unrequested/ignored: Frame List Rollover */ 7311da177e4SLinus Torvalds dbg_status (ehci, "irq", status); 7321da177e4SLinus Torvalds #endif 7331da177e4SLinus Torvalds 7341da177e4SLinus Torvalds /* INT, ERR, and IAA interrupt rates can be throttled */ 7351da177e4SLinus Torvalds 7361da177e4SLinus Torvalds /* normal [4.15.1.2] or error [4.15.1.1] completion */ 7371da177e4SLinus Torvalds if (likely ((status & (STS_INT|STS_ERR)) != 0)) { 7381da177e4SLinus Torvalds if (likely ((status & STS_ERR) == 0)) 7391da177e4SLinus Torvalds COUNT (ehci->stats.normal); 7401da177e4SLinus Torvalds else 7411da177e4SLinus Torvalds COUNT (ehci->stats.error); 7421da177e4SLinus Torvalds bh = 1; 7431da177e4SLinus Torvalds } 7441da177e4SLinus Torvalds 7451da177e4SLinus Torvalds /* complete the unlinking of some qh [4.15.2.3] */ 7461da177e4SLinus Torvalds if (status & STS_IAA) { 7479d938747SAlan Stern 7489d938747SAlan Stern /* Turn off the IAA watchdog */ 7499d938747SAlan Stern ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_IAA_WATCHDOG); 7509d938747SAlan Stern 7519d938747SAlan Stern /* 7529d938747SAlan Stern * Mild optimization: Allow another IAAD to reset the 7539d938747SAlan Stern * hrtimer, if one occurs before the next expiration. 7549d938747SAlan Stern * In theory we could always cancel the hrtimer, but 7559d938747SAlan Stern * tests show that about half the time it will be reset 7569d938747SAlan Stern * for some other event anyway. 7579d938747SAlan Stern */ 7589d938747SAlan Stern if (ehci->next_hrtimer_event == EHCI_HRTIMER_IAA_WATCHDOG) 7599d938747SAlan Stern ++ehci->next_hrtimer_event; 7609d938747SAlan Stern 761e82cc128SDavid Brownell /* guard against (alleged) silicon errata */ 7626feff1b9SAlan Stern if (cmd & CMD_IAAD) 763e82cc128SDavid Brownell ehci_dbg(ehci, "IAA with IAAD still set?\n"); 7643c273a05SAlan Stern if (ehci->async_iaa) { 76599ac5b1eSAlan Stern COUNT(ehci->stats.iaa); 76607d29b63SAlan Stern end_unlink_async(ehci); 767e82cc128SDavid Brownell } else 76899ac5b1eSAlan Stern ehci_dbg(ehci, "IAA with nothing unlinked?\n"); 7691da177e4SLinus Torvalds } 7701da177e4SLinus Torvalds 7711da177e4SLinus Torvalds /* remote wakeup [4.3.1] */ 772d97cc2f2SDavid Brownell if (status & STS_PCD) { 7731da177e4SLinus Torvalds unsigned i = HCS_N_PORTS (ehci->hcs_params); 7745a9cdf33SAlek Du u32 ppcd = 0; 775d1b1842cSDavid Brownell 776d1b1842cSDavid Brownell /* kick root hub later */ 7771d619f12SMarcelo Tosatti pcd_status = status; 7781da177e4SLinus Torvalds 7791da177e4SLinus Torvalds /* resume root hub? */ 780dc75ce9dSAlan Stern if (ehci->rh_state == EHCI_RH_SUSPENDED) 7818c03356aSAlan Stern usb_hcd_resume_root_hub(hcd); 7821da177e4SLinus Torvalds 7835a9cdf33SAlek Du /* get per-port change detect bits */ 7845a9cdf33SAlek Du if (ehci->has_ppcd) 7855a9cdf33SAlek Du ppcd = status >> 16; 7865a9cdf33SAlek Du 7871da177e4SLinus Torvalds while (i--) { 7885a9cdf33SAlek Du int pstatus; 7895a9cdf33SAlek Du 7905a9cdf33SAlek Du /* leverage per-port change bits feature */ 7915a9cdf33SAlek Du if (ehci->has_ppcd && !(ppcd & (1 << i))) 7925a9cdf33SAlek Du continue; 7935a9cdf33SAlek Du pstatus = ehci_readl(ehci, 794083522d7SBenjamin Herrenschmidt &ehci->regs->port_status[i]); 795b972b68cSDavid Brownell 796b972b68cSDavid Brownell if (pstatus & PORT_OWNER) 7971da177e4SLinus Torvalds continue; 798eafe5b99SAlan Stern if (!(test_bit(i, &ehci->suspended_ports) && 799eafe5b99SAlan Stern ((pstatus & PORT_RESUME) || 800eafe5b99SAlan Stern !(pstatus & PORT_SUSPEND)) && 801eafe5b99SAlan Stern (pstatus & PORT_PE) && 802eafe5b99SAlan Stern ehci->reset_done[i] == 0)) 8031da177e4SLinus Torvalds continue; 8041da177e4SLinus Torvalds 8051da177e4SLinus Torvalds /* start 20 msec resume signaling from this port, 8061da177e4SLinus Torvalds * and make khubd collect PORT_STAT_C_SUSPEND to 80749d0f078SAlan Stern * stop that signaling. Use 5 ms extra for safety, 80849d0f078SAlan Stern * like usb_port_resume() does. 8091da177e4SLinus Torvalds */ 81049d0f078SAlan Stern ehci->reset_done[i] = jiffies + msecs_to_jiffies(25); 811a448e4dcSAlan Stern set_bit(i, &ehci->resuming_ports); 8121da177e4SLinus Torvalds ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 81361e8b858SAlan Stern mod_timer(&hcd->rh_timer, ehci->reset_done[i]); 8141da177e4SLinus Torvalds } 8151da177e4SLinus Torvalds } 8161da177e4SLinus Torvalds 8171da177e4SLinus Torvalds /* PCI errors [4.15.2.4] */ 8181da177e4SLinus Torvalds if (unlikely ((status & STS_FATAL) != 0)) { 81967b2e029SAlan Stern ehci_err(ehci, "fatal error\n"); 820eafe5b99SAlan Stern dbg_cmd(ehci, "fatal", cmd); 8211da177e4SLinus Torvalds dbg_status(ehci, "fatal", status); 8221da177e4SLinus Torvalds dead: 82369fff59dSAlan Stern usb_hc_died(hcd); 824bf6387bcSAlan Stern 825bf6387bcSAlan Stern /* Don't let the controller do anything more */ 826bf6387bcSAlan Stern ehci->rh_state = EHCI_RH_STOPPING; 827bf6387bcSAlan Stern ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE); 828bf6387bcSAlan Stern ehci_writel(ehci, ehci->command, &ehci->regs->command); 829bf6387bcSAlan Stern ehci_writel(ehci, 0, &ehci->regs->intr_enable); 830bf6387bcSAlan Stern ehci_handle_controller_death(ehci); 831bf6387bcSAlan Stern 832bf6387bcSAlan Stern /* Handle completions when the controller stops */ 833bf6387bcSAlan Stern bh = 0; 8341da177e4SLinus Torvalds } 8351da177e4SLinus Torvalds 8361da177e4SLinus Torvalds if (bh) 8377d12e780SDavid Howells ehci_work (ehci); 8381da177e4SLinus Torvalds spin_unlock (&ehci->lock); 839d1b1842cSDavid Brownell if (pcd_status) 8401d619f12SMarcelo Tosatti usb_hcd_poll_rh_status(hcd); 8411da177e4SLinus Torvalds return IRQ_HANDLED; 8421da177e4SLinus Torvalds } 8431da177e4SLinus Torvalds 8441da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 8451da177e4SLinus Torvalds 8461da177e4SLinus Torvalds /* 8471da177e4SLinus Torvalds * non-error returns are a promise to giveback() the urb later 8481da177e4SLinus Torvalds * we drop ownership so next owner (or urb unlink) can get it 8491da177e4SLinus Torvalds * 8501da177e4SLinus Torvalds * urb + dev is in hcd.self.controller.urb_list 8511da177e4SLinus Torvalds * we're queueing TDs onto software and hardware lists 8521da177e4SLinus Torvalds * 8531da177e4SLinus Torvalds * hcd-specific init for hcpriv hasn't been done yet 8541da177e4SLinus Torvalds * 8551da177e4SLinus Torvalds * NOTE: control, bulk, and interrupt share the same code to append TDs 8561da177e4SLinus Torvalds * to a (possibly active) QH, and the same QH scanning code. 8571da177e4SLinus Torvalds */ 8581da177e4SLinus Torvalds static int ehci_urb_enqueue ( 8591da177e4SLinus Torvalds struct usb_hcd *hcd, 8601da177e4SLinus Torvalds struct urb *urb, 86155016f10SAl Viro gfp_t mem_flags 8621da177e4SLinus Torvalds ) { 8631da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci (hcd); 8641da177e4SLinus Torvalds struct list_head qtd_list; 8651da177e4SLinus Torvalds 8661da177e4SLinus Torvalds INIT_LIST_HEAD (&qtd_list); 8671da177e4SLinus Torvalds 8681da177e4SLinus Torvalds switch (usb_pipetype (urb->pipe)) { 86925b70a86SDavid Brownell case PIPE_CONTROL: 87025b70a86SDavid Brownell /* qh_completions() code doesn't handle all the fault cases 87125b70a86SDavid Brownell * in multi-TD control transfers. Even 1KB is rare anyway. 87225b70a86SDavid Brownell */ 87325b70a86SDavid Brownell if (urb->transfer_buffer_length > (16 * 1024)) 87425b70a86SDavid Brownell return -EMSGSIZE; 87525b70a86SDavid Brownell /* FALLTHROUGH */ 87625b70a86SDavid Brownell /* case PIPE_BULK: */ 8771da177e4SLinus Torvalds default: 8781da177e4SLinus Torvalds if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) 8791da177e4SLinus Torvalds return -ENOMEM; 880e9df41c5SAlan Stern return submit_async(ehci, urb, &qtd_list, mem_flags); 8811da177e4SLinus Torvalds 8821da177e4SLinus Torvalds case PIPE_INTERRUPT: 8831da177e4SLinus Torvalds if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) 8841da177e4SLinus Torvalds return -ENOMEM; 885e9df41c5SAlan Stern return intr_submit(ehci, urb, &qtd_list, mem_flags); 8861da177e4SLinus Torvalds 8871da177e4SLinus Torvalds case PIPE_ISOCHRONOUS: 8881da177e4SLinus Torvalds if (urb->dev->speed == USB_SPEED_HIGH) 8891da177e4SLinus Torvalds return itd_submit (ehci, urb, mem_flags); 8901da177e4SLinus Torvalds else 8911da177e4SLinus Torvalds return sitd_submit (ehci, urb, mem_flags); 8921da177e4SLinus Torvalds } 8931da177e4SLinus Torvalds } 8941da177e4SLinus Torvalds 8951da177e4SLinus Torvalds /* remove from hardware lists 8961da177e4SLinus Torvalds * completions normally happen asynchronously 8971da177e4SLinus Torvalds */ 8981da177e4SLinus Torvalds 899e9df41c5SAlan Stern static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) 9001da177e4SLinus Torvalds { 9011da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci (hcd); 9021da177e4SLinus Torvalds struct ehci_qh *qh; 9031da177e4SLinus Torvalds unsigned long flags; 904e9df41c5SAlan Stern int rc; 9051da177e4SLinus Torvalds 9061da177e4SLinus Torvalds spin_lock_irqsave (&ehci->lock, flags); 907e9df41c5SAlan Stern rc = usb_hcd_check_unlink_urb(hcd, urb, status); 908e9df41c5SAlan Stern if (rc) 909e9df41c5SAlan Stern goto done; 910e9df41c5SAlan Stern 9111da177e4SLinus Torvalds switch (usb_pipetype (urb->pipe)) { 9121da177e4SLinus Torvalds // case PIPE_CONTROL: 9131da177e4SLinus Torvalds // case PIPE_BULK: 9141da177e4SLinus Torvalds default: 9151da177e4SLinus Torvalds qh = (struct ehci_qh *) urb->hcpriv; 9161da177e4SLinus Torvalds if (!qh) 9171da177e4SLinus Torvalds break; 91807d29b63SAlan Stern switch (qh->qh_state) { 91907d29b63SAlan Stern case QH_STATE_LINKED: 92007d29b63SAlan Stern case QH_STATE_COMPLETING: 9213c273a05SAlan Stern start_unlink_async(ehci, qh); 9221da177e4SLinus Torvalds break; 92307d29b63SAlan Stern case QH_STATE_UNLINK: 92407d29b63SAlan Stern case QH_STATE_UNLINK_WAIT: 92507d29b63SAlan Stern /* already started */ 92607d29b63SAlan Stern break; 92707d29b63SAlan Stern case QH_STATE_IDLE: 9287a0f0d95SAlan Stern /* QH might be waiting for a Clear-TT-Buffer */ 9297a0f0d95SAlan Stern qh_completions(ehci, qh); 93007d29b63SAlan Stern break; 93107d29b63SAlan Stern } 93207d29b63SAlan Stern break; 9331da177e4SLinus Torvalds 9341da177e4SLinus Torvalds case PIPE_INTERRUPT: 9351da177e4SLinus Torvalds qh = (struct ehci_qh *) urb->hcpriv; 9361da177e4SLinus Torvalds if (!qh) 9371da177e4SLinus Torvalds break; 9381da177e4SLinus Torvalds switch (qh->qh_state) { 9391da177e4SLinus Torvalds case QH_STATE_LINKED: 940a448c9d8SAlan Stern case QH_STATE_COMPLETING: 941df202255SAlan Stern start_unlink_intr(ehci, qh); 942a448c9d8SAlan Stern break; 9431da177e4SLinus Torvalds case QH_STATE_IDLE: 9447d12e780SDavid Howells qh_completions (ehci, qh); 9451da177e4SLinus Torvalds break; 9461da177e4SLinus Torvalds default: 9471da177e4SLinus Torvalds ehci_dbg (ehci, "bogus qh %p state %d\n", 9481da177e4SLinus Torvalds qh, qh->qh_state); 9491da177e4SLinus Torvalds goto done; 9501da177e4SLinus Torvalds } 9511da177e4SLinus Torvalds break; 9521da177e4SLinus Torvalds 9531da177e4SLinus Torvalds case PIPE_ISOCHRONOUS: 9541da177e4SLinus Torvalds // itd or sitd ... 9551da177e4SLinus Torvalds 9561da177e4SLinus Torvalds // wait till next completion, do it then. 9571da177e4SLinus Torvalds // completion irqs can wait up to 1024 msec, 9581da177e4SLinus Torvalds break; 9591da177e4SLinus Torvalds } 9601da177e4SLinus Torvalds done: 9611da177e4SLinus Torvalds spin_unlock_irqrestore (&ehci->lock, flags); 962e9df41c5SAlan Stern return rc; 9631da177e4SLinus Torvalds } 9641da177e4SLinus Torvalds 9651da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 9661da177e4SLinus Torvalds 9671da177e4SLinus Torvalds // bulk qh holds the data toggle 9681da177e4SLinus Torvalds 9691da177e4SLinus Torvalds static void 9701da177e4SLinus Torvalds ehci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep) 9711da177e4SLinus Torvalds { 9721da177e4SLinus Torvalds struct ehci_hcd *ehci = hcd_to_ehci (hcd); 9731da177e4SLinus Torvalds unsigned long flags; 9741da177e4SLinus Torvalds struct ehci_qh *qh, *tmp; 9751da177e4SLinus Torvalds 9761da177e4SLinus Torvalds /* ASSERT: any requests/urbs are being unlinked */ 9771da177e4SLinus Torvalds /* ASSERT: nobody can be submitting urbs for this any more */ 9781da177e4SLinus Torvalds 9791da177e4SLinus Torvalds rescan: 9801da177e4SLinus Torvalds spin_lock_irqsave (&ehci->lock, flags); 9811da177e4SLinus Torvalds qh = ep->hcpriv; 9821da177e4SLinus Torvalds if (!qh) 9831da177e4SLinus Torvalds goto done; 9841da177e4SLinus Torvalds 9851da177e4SLinus Torvalds /* endpoints can be iso streams. for now, we don't 9861da177e4SLinus Torvalds * accelerate iso completions ... so spin a while. 9871da177e4SLinus Torvalds */ 9881082f57aSClemens Ladisch if (qh->hw == NULL) { 9898c5bf7beSAlan Stern struct ehci_iso_stream *stream = ep->hcpriv; 9908c5bf7beSAlan Stern 9918c5bf7beSAlan Stern if (!list_empty(&stream->td_list)) 9921da177e4SLinus Torvalds goto idle_timeout; 9938c5bf7beSAlan Stern 9948c5bf7beSAlan Stern /* BUG_ON(!list_empty(&stream->free_list)); */ 9958c5bf7beSAlan Stern kfree(stream); 9968c5bf7beSAlan Stern goto done; 9971da177e4SLinus Torvalds } 9981da177e4SLinus Torvalds 999c0c53dbcSAlan Stern if (ehci->rh_state < EHCI_RH_RUNNING) 10001da177e4SLinus Torvalds qh->qh_state = QH_STATE_IDLE; 10011da177e4SLinus Torvalds switch (qh->qh_state) { 10021da177e4SLinus Torvalds case QH_STATE_LINKED: 10033a44494eSAlan Stern case QH_STATE_COMPLETING: 10041da177e4SLinus Torvalds for (tmp = ehci->async->qh_next.qh; 10051da177e4SLinus Torvalds tmp && tmp != qh; 10061da177e4SLinus Torvalds tmp = tmp->qh_next.qh) 10071da177e4SLinus Torvalds continue; 100802e2c51bSAlan Stern /* periodic qh self-unlinks on empty, and a COMPLETING qh 100902e2c51bSAlan Stern * may already be unlinked. 101002e2c51bSAlan Stern */ 101102e2c51bSAlan Stern if (tmp) 10123c273a05SAlan Stern start_unlink_async(ehci, qh); 10131da177e4SLinus Torvalds /* FALL THROUGH */ 10141da177e4SLinus Torvalds case QH_STATE_UNLINK: /* wait for hw to finish? */ 101507d29b63SAlan Stern case QH_STATE_UNLINK_WAIT: 10161da177e4SLinus Torvalds idle_timeout: 10171da177e4SLinus Torvalds spin_unlock_irqrestore (&ehci->lock, flags); 101822c43863SNishanth Aravamudan schedule_timeout_uninterruptible(1); 10191da177e4SLinus Torvalds goto rescan; 10201da177e4SLinus Torvalds case QH_STATE_IDLE: /* fully unlinked */ 1021914b7012SAlan Stern if (qh->clearing_tt) 1022914b7012SAlan Stern goto idle_timeout; 10231da177e4SLinus Torvalds if (list_empty (&qh->qtd_list)) { 1024c83e1a9fSAlan Stern qh_destroy(ehci, qh); 10251da177e4SLinus Torvalds break; 10261da177e4SLinus Torvalds } 10271da177e4SLinus Torvalds /* else FALL THROUGH */ 10281da177e4SLinus Torvalds default: 10291da177e4SLinus Torvalds /* caller was supposed to have unlinked any requests; 10301da177e4SLinus Torvalds * that's not our job. just leak this memory. 10311da177e4SLinus Torvalds */ 10321da177e4SLinus Torvalds ehci_err (ehci, "qh %p (#%02x) state %d%s\n", 10331da177e4SLinus Torvalds qh, ep->desc.bEndpointAddress, qh->qh_state, 10341da177e4SLinus Torvalds list_empty (&qh->qtd_list) ? "" : "(has tds)"); 10351da177e4SLinus Torvalds break; 10361da177e4SLinus Torvalds } 10371da177e4SLinus Torvalds done: 10388c5bf7beSAlan Stern ep->hcpriv = NULL; 10391da177e4SLinus Torvalds spin_unlock_irqrestore (&ehci->lock, flags); 10401da177e4SLinus Torvalds } 10411da177e4SLinus Torvalds 1042b18ffd49SAlan Stern static void 1043b18ffd49SAlan Stern ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) 1044b18ffd49SAlan Stern { 1045b18ffd49SAlan Stern struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1046b18ffd49SAlan Stern struct ehci_qh *qh; 1047b18ffd49SAlan Stern int eptype = usb_endpoint_type(&ep->desc); 1048a455212dSAlan Stern int epnum = usb_endpoint_num(&ep->desc); 1049a455212dSAlan Stern int is_out = usb_endpoint_dir_out(&ep->desc); 1050a455212dSAlan Stern unsigned long flags; 1051b18ffd49SAlan Stern 1052b18ffd49SAlan Stern if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT) 1053b18ffd49SAlan Stern return; 1054b18ffd49SAlan Stern 1055a455212dSAlan Stern spin_lock_irqsave(&ehci->lock, flags); 1056b18ffd49SAlan Stern qh = ep->hcpriv; 1057b18ffd49SAlan Stern 1058b18ffd49SAlan Stern /* For Bulk and Interrupt endpoints we maintain the toggle state 1059b18ffd49SAlan Stern * in the hardware; the toggle bits in udev aren't used at all. 1060b18ffd49SAlan Stern * When an endpoint is reset by usb_clear_halt() we must reset 1061b18ffd49SAlan Stern * the toggle bit in the QH. 1062b18ffd49SAlan Stern */ 1063b18ffd49SAlan Stern if (qh) { 1064a455212dSAlan Stern usb_settoggle(qh->dev, epnum, is_out, 0); 1065b18ffd49SAlan Stern if (!list_empty(&qh->qtd_list)) { 1066b18ffd49SAlan Stern WARN_ONCE(1, "clear_halt for a busy endpoint\n"); 10673a44494eSAlan Stern } else if (qh->qh_state == QH_STATE_LINKED || 10683a44494eSAlan Stern qh->qh_state == QH_STATE_COMPLETING) { 1069a455212dSAlan Stern 1070a455212dSAlan Stern /* The toggle value in the QH can't be updated 1071a455212dSAlan Stern * while the QH is active. Unlink it now; 1072a455212dSAlan Stern * re-linking will call qh_refresh(). 1073b18ffd49SAlan Stern */ 1074a448c9d8SAlan Stern if (eptype == USB_ENDPOINT_XFER_BULK) 10753c273a05SAlan Stern start_unlink_async(ehci, qh); 1076a448c9d8SAlan Stern else 1077df202255SAlan Stern start_unlink_intr(ehci, qh); 1078b18ffd49SAlan Stern } 1079b18ffd49SAlan Stern } 1080a455212dSAlan Stern spin_unlock_irqrestore(&ehci->lock, flags); 1081b18ffd49SAlan Stern } 1082b18ffd49SAlan Stern 10837ff71d6aSMatt Porter static int ehci_get_frame (struct usb_hcd *hcd) 10847ff71d6aSMatt Porter { 10857ff71d6aSMatt Porter struct ehci_hcd *ehci = hcd_to_ehci (hcd); 108668aa95d5SAlan Stern return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size; 10877ff71d6aSMatt Porter } 10881da177e4SLinus Torvalds 10891da177e4SLinus Torvalds /*-------------------------------------------------------------------------*/ 1090c5cf9212SAlan Stern 1091c5cf9212SAlan Stern #ifdef CONFIG_PM 1092c5cf9212SAlan Stern 1093c5cf9212SAlan Stern /* suspend/resume, section 4.3 */ 1094c5cf9212SAlan Stern 1095c5cf9212SAlan Stern /* These routines handle the generic parts of controller suspend/resume */ 1096c5cf9212SAlan Stern 1097c5cf9212SAlan Stern static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) 1098c5cf9212SAlan Stern { 1099c5cf9212SAlan Stern struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1100c5cf9212SAlan Stern 1101c5cf9212SAlan Stern if (time_before(jiffies, ehci->next_statechange)) 1102c5cf9212SAlan Stern msleep(10); 1103c5cf9212SAlan Stern 1104c5cf9212SAlan Stern /* 1105c5cf9212SAlan Stern * Root hub was already suspended. Disable IRQ emission and 1106c5cf9212SAlan Stern * mark HW unaccessible. The PM and USB cores make sure that 1107c5cf9212SAlan Stern * the root hub is either suspended or stopped. 1108c5cf9212SAlan Stern */ 1109c5cf9212SAlan Stern ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup); 1110c5cf9212SAlan Stern 1111c5cf9212SAlan Stern spin_lock_irq(&ehci->lock); 1112c5cf9212SAlan Stern ehci_writel(ehci, 0, &ehci->regs->intr_enable); 1113c5cf9212SAlan Stern (void) ehci_readl(ehci, &ehci->regs->intr_enable); 1114c5cf9212SAlan Stern 1115c5cf9212SAlan Stern clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1116c5cf9212SAlan Stern spin_unlock_irq(&ehci->lock); 1117c5cf9212SAlan Stern 1118c5cf9212SAlan Stern return 0; 1119c5cf9212SAlan Stern } 1120c5cf9212SAlan Stern 1121c5cf9212SAlan Stern /* Returns 0 if power was preserved, 1 if power was lost */ 1122c5cf9212SAlan Stern static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) 1123c5cf9212SAlan Stern { 1124c5cf9212SAlan Stern struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1125c5cf9212SAlan Stern 1126c5cf9212SAlan Stern if (time_before(jiffies, ehci->next_statechange)) 1127c5cf9212SAlan Stern msleep(100); 1128c5cf9212SAlan Stern 1129c5cf9212SAlan Stern /* Mark hardware accessible again as we are back to full power by now */ 1130c5cf9212SAlan Stern set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1131c5cf9212SAlan Stern 1132c5cf9212SAlan Stern /* 1133c5cf9212SAlan Stern * If CF is still set and we aren't resuming from hibernation 1134c5cf9212SAlan Stern * then we maintained suspend power. 1135c5cf9212SAlan Stern * Just undo the effect of ehci_suspend(). 1136c5cf9212SAlan Stern */ 1137c5cf9212SAlan Stern if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF && 1138c5cf9212SAlan Stern !hibernated) { 1139c5cf9212SAlan Stern int mask = INTR_MASK; 1140c5cf9212SAlan Stern 1141c5cf9212SAlan Stern ehci_prepare_ports_for_controller_resume(ehci); 1142c5cf9212SAlan Stern if (!hcd->self.root_hub->do_remote_wakeup) 1143c5cf9212SAlan Stern mask &= ~STS_PCD; 1144c5cf9212SAlan Stern ehci_writel(ehci, mask, &ehci->regs->intr_enable); 1145c5cf9212SAlan Stern ehci_readl(ehci, &ehci->regs->intr_enable); 1146c5cf9212SAlan Stern return 0; 1147c5cf9212SAlan Stern } 1148c5cf9212SAlan Stern 1149c5cf9212SAlan Stern /* 1150c5cf9212SAlan Stern * Else reset, to cope with power loss or resume from hibernation 1151c5cf9212SAlan Stern * having let the firmware kick in during reboot. 1152c5cf9212SAlan Stern */ 1153c5cf9212SAlan Stern usb_root_hub_lost_power(hcd->self.root_hub); 1154c5cf9212SAlan Stern (void) ehci_halt(ehci); 1155c5cf9212SAlan Stern (void) ehci_reset(ehci); 1156c5cf9212SAlan Stern 1157c5cf9212SAlan Stern ehci_writel(ehci, ehci->command, &ehci->regs->command); 1158c5cf9212SAlan Stern ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); 1159c5cf9212SAlan Stern ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ 1160c5cf9212SAlan Stern 1161c5cf9212SAlan Stern /* here we "know" root ports should always stay powered */ 1162c5cf9212SAlan Stern ehci_port_power(ehci, 1); 1163c5cf9212SAlan Stern 1164c5cf9212SAlan Stern ehci->rh_state = EHCI_RH_SUSPENDED; 1165c5cf9212SAlan Stern return 1; 1166c5cf9212SAlan Stern } 1167c5cf9212SAlan Stern 1168c5cf9212SAlan Stern #endif 1169c5cf9212SAlan Stern 1170c5cf9212SAlan Stern /*-------------------------------------------------------------------------*/ 1171c5cf9212SAlan Stern 1172eb70e5abSAlexander Shishkin /* 1173eb70e5abSAlexander Shishkin * The EHCI in ChipIdea HDRC cannot be a separate module or device, 1174eb70e5abSAlexander Shishkin * because its registers (and irq) are shared between host/gadget/otg 1175eb70e5abSAlexander Shishkin * functions and in order to facilitate role switching we cannot 1176eb70e5abSAlexander Shishkin * give the ehci driver exclusive access to those. 1177eb70e5abSAlexander Shishkin */ 1178eb70e5abSAlexander Shishkin #ifndef CHIPIDEA_EHCI 11791da177e4SLinus Torvalds 11802b70f073SAlan Stern MODULE_DESCRIPTION(DRIVER_DESC); 11811da177e4SLinus Torvalds MODULE_AUTHOR (DRIVER_AUTHOR); 11821da177e4SLinus Torvalds MODULE_LICENSE ("GPL"); 11831da177e4SLinus Torvalds 11847ff71d6aSMatt Porter #ifdef CONFIG_PCI 11857ff71d6aSMatt Porter #include "ehci-pci.c" 118601cced25SKumar Gala #define PCI_DRIVER ehci_pci_driver 11877ff71d6aSMatt Porter #endif 11881da177e4SLinus Torvalds 1189ba02978aSLi Yang #ifdef CONFIG_USB_EHCI_FSL 119080cb9aeeSRandy Vinson #include "ehci-fsl.c" 119101cced25SKumar Gala #define PLATFORM_DRIVER ehci_fsl_driver 119280cb9aeeSRandy Vinson #endif 119380cb9aeeSRandy Vinson 11947e8d5cd9SDaniel Mack #ifdef CONFIG_USB_EHCI_MXC 11957e8d5cd9SDaniel Mack #include "ehci-mxc.c" 11967e8d5cd9SDaniel Mack #define PLATFORM_DRIVER ehci_mxc_driver 11977e8d5cd9SDaniel Mack #endif 11987e8d5cd9SDaniel Mack 119960b0bf0fSYoshihiro Shimoda #ifdef CONFIG_USB_EHCI_SH 120063c84552SPaul Mundt #include "ehci-sh.c" 120163c84552SPaul Mundt #define PLATFORM_DRIVER ehci_hcd_sh_driver 120263c84552SPaul Mundt #endif 120363c84552SPaul Mundt 120437663860SManuel Lauss #ifdef CONFIG_MIPS_ALCHEMY 120576fa9a24SJordan Crouse #include "ehci-au1xxx.c" 120601cced25SKumar Gala #define PLATFORM_DRIVER ehci_hcd_au1xxx_driver 120776fa9a24SJordan Crouse #endif 120876fa9a24SJordan Crouse 12097f124f4bSKeshava Munegowda #ifdef CONFIG_USB_EHCI_HCD_OMAP 121054ab2b02SFelipe Balbi #include "ehci-omap.c" 121154ab2b02SFelipe Balbi #define PLATFORM_DRIVER ehci_hcd_omap_driver 121254ab2b02SFelipe Balbi #endif 121354ab2b02SFelipe Balbi 1214ad75a410SGeoff Levand #ifdef CONFIG_PPC_PS3 1215ad75a410SGeoff Levand #include "ehci-ps3.c" 12167a4eb7fdSGeoff Levand #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver 1217ad75a410SGeoff Levand #endif 1218ad75a410SGeoff Levand 1219da0e8fb0SValentine Barshak #ifdef CONFIG_USB_EHCI_HCD_PPC_OF 1220da0e8fb0SValentine Barshak #include "ehci-ppc-of.c" 1221da0e8fb0SValentine Barshak #define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver 1222da0e8fb0SValentine Barshak #endif 1223da0e8fb0SValentine Barshak 122408d3c18eSJulie Zhu #ifdef CONFIG_XPS_USB_HCD_XILINX 122508d3c18eSJulie Zhu #include "ehci-xilinx-of.c" 12261f23b2d9SGrant Likely #define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver 122708d3c18eSJulie Zhu #endif 122808d3c18eSJulie Zhu 1229705a7521SLennert Buytenhek #ifdef CONFIG_PLAT_ORION 1230e96ffe2fSTzachi Perelstein #include "ehci-orion.c" 1231e96ffe2fSTzachi Perelstein #define PLATFORM_DRIVER ehci_orion_driver 1232e96ffe2fSTzachi Perelstein #endif 1233e96ffe2fSTzachi Perelstein 123491bc4d31SVladimir Barinov #ifdef CONFIG_ARCH_IXP4XX 123591bc4d31SVladimir Barinov #include "ehci-ixp4xx.c" 123691bc4d31SVladimir Barinov #define PLATFORM_DRIVER ixp4xx_ehci_driver 123791bc4d31SVladimir Barinov #endif 123891bc4d31SVladimir Barinov 1239586dfc8cSWan ZongShun #ifdef CONFIG_USB_W90X900_EHCI 1240586dfc8cSWan ZongShun #include "ehci-w90x900.c" 1241586dfc8cSWan ZongShun #define PLATFORM_DRIVER ehci_hcd_w90x900_driver 1242586dfc8cSWan ZongShun #endif 1243586dfc8cSWan ZongShun 1244501c9c08SNicolas Ferre #ifdef CONFIG_ARCH_AT91 1245501c9c08SNicolas Ferre #include "ehci-atmel.c" 1246501c9c08SNicolas Ferre #define PLATFORM_DRIVER ehci_atmel_driver 1247501c9c08SNicolas Ferre #endif 1248501c9c08SNicolas Ferre 12491643accdSDavid Daney #ifdef CONFIG_USB_OCTEON_EHCI 12501643accdSDavid Daney #include "ehci-octeon.c" 12511643accdSDavid Daney #define PLATFORM_DRIVER ehci_octeon_driver 12521643accdSDavid Daney #endif 12531643accdSDavid Daney 1254760efe69SMac Lin #ifdef CONFIG_USB_CNS3XXX_EHCI 1255760efe69SMac Lin #include "ehci-cns3xxx.c" 1256760efe69SMac Lin #define PLATFORM_DRIVER cns3xxx_ehci_driver 1257760efe69SMac Lin #endif 1258760efe69SMac Lin 1259ad78acafSAlexey Charkov #ifdef CONFIG_ARCH_VT8500 1260ad78acafSAlexey Charkov #include "ehci-vt8500.c" 1261ad78acafSAlexey Charkov #define PLATFORM_DRIVER vt8500_ehci_driver 1262ad78acafSAlexey Charkov #endif 1263ad78acafSAlexey Charkov 1264c8c38de9SDeepak Sikri #ifdef CONFIG_PLAT_SPEAR 1265c8c38de9SDeepak Sikri #include "ehci-spear.c" 1266c8c38de9SDeepak Sikri #define PLATFORM_DRIVER spear_ehci_hcd_driver 1267c8c38de9SDeepak Sikri #endif 1268c8c38de9SDeepak Sikri 1269b0848aeaSPavankumar Kondeti #ifdef CONFIG_USB_EHCI_MSM 1270b0848aeaSPavankumar Kondeti #include "ehci-msm.c" 1271b0848aeaSPavankumar Kondeti #define PLATFORM_DRIVER ehci_msm_driver 1272b0848aeaSPavankumar Kondeti #endif 1273b0848aeaSPavankumar Kondeti 127422ced687SAnoop #ifdef CONFIG_USB_EHCI_HCD_PMC_MSP 127522ced687SAnoop #include "ehci-pmcmsp.c" 127622ced687SAnoop #define PLATFORM_DRIVER ehci_hcd_msp_driver 127722ced687SAnoop #endif 127822ced687SAnoop 127979ad3b5aSBenoit Goby #ifdef CONFIG_USB_EHCI_TEGRA 128079ad3b5aSBenoit Goby #include "ehci-tegra.c" 128179ad3b5aSBenoit Goby #define PLATFORM_DRIVER tegra_ehci_driver 128279ad3b5aSBenoit Goby #endif 128379ad3b5aSBenoit Goby 12841bcc5aa8SJoonyoung Shim #ifdef CONFIG_USB_EHCI_S5P 12851bcc5aa8SJoonyoung Shim #include "ehci-s5p.c" 12861bcc5aa8SJoonyoung Shim #define PLATFORM_DRIVER s5p_ehci_driver 12871bcc5aa8SJoonyoung Shim #endif 12881bcc5aa8SJoonyoung Shim 12899be03929SJan Andersson #ifdef CONFIG_SPARC_LEON 12909be03929SJan Andersson #include "ehci-grlib.c" 12919be03929SJan Andersson #define PLATFORM_DRIVER ehci_grlib_driver 12929be03929SJan Andersson #endif 12939be03929SJan Andersson 12943af5154aSJayachandran C #ifdef CONFIG_CPU_XLR 129523106343SJayachandran C #include "ehci-xls.c" 129623106343SJayachandran C #define PLATFORM_DRIVER ehci_xls_driver 129723106343SJayachandran C #endif 129823106343SJayachandran C 12993a082ec9SNeil Zhang #ifdef CONFIG_USB_EHCI_MV 13003a082ec9SNeil Zhang #include "ehci-mv.c" 13013a082ec9SNeil Zhang #define PLATFORM_DRIVER ehci_mv_driver 13023a082ec9SNeil Zhang #endif 13033a082ec9SNeil Zhang 1304f30cdbcbSKelvin Cheung #ifdef CONFIG_MACH_LOONGSON1 1305f30cdbcbSKelvin Cheung #include "ehci-ls1x.c" 1306f30cdbcbSKelvin Cheung #define PLATFORM_DRIVER ehci_ls1x_driver 1307f30cdbcbSKelvin Cheung #endif 1308f30cdbcbSKelvin Cheung 1309c256667fSSteven J. Hill #ifdef CONFIG_MIPS_SEAD3 1310c256667fSSteven J. Hill #include "ehci-sead3.c" 1311c256667fSSteven J. Hill #define PLATFORM_DRIVER ehci_hcd_sead3_driver 1312c256667fSSteven J. Hill #endif 1313c256667fSSteven J. Hill 13147a7a4a59SHauke Mehrtens #ifdef CONFIG_USB_EHCI_HCD_PLATFORM 13157a7a4a59SHauke Mehrtens #include "ehci-platform.c" 13167a7a4a59SHauke Mehrtens #define PLATFORM_DRIVER ehci_platform_driver 13177a7a4a59SHauke Mehrtens #endif 13187a7a4a59SHauke Mehrtens 1319ad75a410SGeoff Levand #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 13201f23b2d9SGrant Likely !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 13211f23b2d9SGrant Likely !defined(XILINX_OF_PLATFORM_DRIVER) 13227ff71d6aSMatt Porter #error "missing bus glue for ehci-hcd" 13237ff71d6aSMatt Porter #endif 132401cced25SKumar Gala 132501cced25SKumar Gala static int __init ehci_hcd_init(void) 132601cced25SKumar Gala { 132701cced25SKumar Gala int retval = 0; 132801cced25SKumar Gala 13292b70f073SAlan Stern if (usb_disabled()) 13302b70f073SAlan Stern return -ENODEV; 13312b70f073SAlan Stern 13322b70f073SAlan Stern printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name); 13339beeee65SAlan Stern set_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 13349beeee65SAlan Stern if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) || 13359beeee65SAlan Stern test_bit(USB_OHCI_LOADED, &usb_hcds_loaded)) 13369beeee65SAlan Stern printk(KERN_WARNING "Warning! ehci_hcd should always be loaded" 13379beeee65SAlan Stern " before uhci_hcd and ohci_hcd, not after\n"); 13389beeee65SAlan Stern 133901cced25SKumar Gala pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 134001cced25SKumar Gala hcd_name, 134101cced25SKumar Gala sizeof(struct ehci_qh), sizeof(struct ehci_qtd), 134201cced25SKumar Gala sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); 134301cced25SKumar Gala 1344694cc208STony Jones #ifdef DEBUG 134508f4e586SGreg Kroah-Hartman ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root); 13469beeee65SAlan Stern if (!ehci_debug_root) { 13479beeee65SAlan Stern retval = -ENOENT; 13489beeee65SAlan Stern goto err_debug; 13499beeee65SAlan Stern } 1350694cc208STony Jones #endif 1351694cc208STony Jones 135201cced25SKumar Gala #ifdef PLATFORM_DRIVER 135301cced25SKumar Gala retval = platform_driver_register(&PLATFORM_DRIVER); 1354da0e8fb0SValentine Barshak if (retval < 0) 1355da0e8fb0SValentine Barshak goto clean0; 135601cced25SKumar Gala #endif 135701cced25SKumar Gala 135801cced25SKumar Gala #ifdef PCI_DRIVER 135901cced25SKumar Gala retval = pci_register_driver(&PCI_DRIVER); 1360da0e8fb0SValentine Barshak if (retval < 0) 1361da0e8fb0SValentine Barshak goto clean1; 1362ad75a410SGeoff Levand #endif 1363ad75a410SGeoff Levand 1364ad75a410SGeoff Levand #ifdef PS3_SYSTEM_BUS_DRIVER 13657a4eb7fdSGeoff Levand retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1366da0e8fb0SValentine Barshak if (retval < 0) 1367da0e8fb0SValentine Barshak goto clean2; 1368da0e8fb0SValentine Barshak #endif 1369da0e8fb0SValentine Barshak 1370da0e8fb0SValentine Barshak #ifdef OF_PLATFORM_DRIVER 1371d35fb641SGrant Likely retval = platform_driver_register(&OF_PLATFORM_DRIVER); 1372da0e8fb0SValentine Barshak if (retval < 0) 1373da0e8fb0SValentine Barshak goto clean3; 1374da0e8fb0SValentine Barshak #endif 13751f23b2d9SGrant Likely 13761f23b2d9SGrant Likely #ifdef XILINX_OF_PLATFORM_DRIVER 1377d35fb641SGrant Likely retval = platform_driver_register(&XILINX_OF_PLATFORM_DRIVER); 13781f23b2d9SGrant Likely if (retval < 0) 13791f23b2d9SGrant Likely goto clean4; 13801f23b2d9SGrant Likely #endif 1381da0e8fb0SValentine Barshak return retval; 1382da0e8fb0SValentine Barshak 13831f23b2d9SGrant Likely #ifdef XILINX_OF_PLATFORM_DRIVER 1384d35fb641SGrant Likely /* platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER); */ 13851f23b2d9SGrant Likely clean4: 13861f23b2d9SGrant Likely #endif 1387da0e8fb0SValentine Barshak #ifdef OF_PLATFORM_DRIVER 1388d35fb641SGrant Likely platform_driver_unregister(&OF_PLATFORM_DRIVER); 1389da0e8fb0SValentine Barshak clean3: 1390da0e8fb0SValentine Barshak #endif 1391da0e8fb0SValentine Barshak #ifdef PS3_SYSTEM_BUS_DRIVER 1392da0e8fb0SValentine Barshak ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1393da0e8fb0SValentine Barshak clean2: 1394da0e8fb0SValentine Barshak #endif 1395da0e8fb0SValentine Barshak #ifdef PCI_DRIVER 1396da0e8fb0SValentine Barshak pci_unregister_driver(&PCI_DRIVER); 1397da0e8fb0SValentine Barshak clean1: 1398da0e8fb0SValentine Barshak #endif 1399da0e8fb0SValentine Barshak #ifdef PLATFORM_DRIVER 1400da0e8fb0SValentine Barshak platform_driver_unregister(&PLATFORM_DRIVER); 1401da0e8fb0SValentine Barshak clean0: 1402da0e8fb0SValentine Barshak #endif 1403694cc208STony Jones #ifdef DEBUG 1404694cc208STony Jones debugfs_remove(ehci_debug_root); 1405694cc208STony Jones ehci_debug_root = NULL; 14069beeee65SAlan Stern err_debug: 1407a9b6148dSLinus Torvalds #endif 14089beeee65SAlan Stern clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 140901cced25SKumar Gala return retval; 141001cced25SKumar Gala } 141101cced25SKumar Gala module_init(ehci_hcd_init); 141201cced25SKumar Gala 141301cced25SKumar Gala static void __exit ehci_hcd_cleanup(void) 141401cced25SKumar Gala { 14151f23b2d9SGrant Likely #ifdef XILINX_OF_PLATFORM_DRIVER 1416d35fb641SGrant Likely platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER); 14171f23b2d9SGrant Likely #endif 1418da0e8fb0SValentine Barshak #ifdef OF_PLATFORM_DRIVER 1419d35fb641SGrant Likely platform_driver_unregister(&OF_PLATFORM_DRIVER); 1420da0e8fb0SValentine Barshak #endif 142101cced25SKumar Gala #ifdef PLATFORM_DRIVER 142201cced25SKumar Gala platform_driver_unregister(&PLATFORM_DRIVER); 142301cced25SKumar Gala #endif 142401cced25SKumar Gala #ifdef PCI_DRIVER 142501cced25SKumar Gala pci_unregister_driver(&PCI_DRIVER); 142601cced25SKumar Gala #endif 1427ad75a410SGeoff Levand #ifdef PS3_SYSTEM_BUS_DRIVER 14287a4eb7fdSGeoff Levand ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1429ad75a410SGeoff Levand #endif 1430694cc208STony Jones #ifdef DEBUG 1431694cc208STony Jones debugfs_remove(ehci_debug_root); 1432694cc208STony Jones #endif 14339beeee65SAlan Stern clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 143401cced25SKumar Gala } 143501cced25SKumar Gala module_exit(ehci_hcd_cleanup); 143601cced25SKumar Gala 1437eb70e5abSAlexander Shishkin #endif /* CHIPIDEA_EHCI */ 1438