Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * OHCI HCD (Host Controller Driver) for USB. |
| 3 | * |
| 4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> |
| 5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> |
| 6 | * (C) Copyright 2002 Hewlett-Packard Company |
| 7 | * |
| 8 | * Bus Glue for pxa27x |
| 9 | * |
| 10 | * Written by Christopher Hoover <ch@hpl.hp.com> |
| 11 | * Based on fragments of previous driver by Russell King et al. |
| 12 | * |
| 13 | * Modified for LH7A404 from ohci-sa1111.c |
| 14 | * by Durgesh Pattamatta <pattamattad@sharpsec.com> |
| 15 | * |
| 16 | * Modified for pxa27x from ohci-lh7a404.c |
| 17 | * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004 |
| 18 | * |
| 19 | * This file is licenced under the GPL. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/device.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 23 | #include <linux/signal.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 25 | #include <linux/clk.h> |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 26 | #include <linux/of_platform.h> |
| 27 | #include <linux/of_gpio.h> |
Rob Herring | 60b9bd8 | 2012-03-01 21:13:13 -0600 | [diff] [blame] | 28 | #include <mach/hardware.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 29 | #include <linux/platform_data/usb-ohci-pxa27x.h> |
| 30 | #include <linux/platform_data/usb-pxa3xx-ulpi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 32 | /* |
| 33 | * UHC: USB Host Controller (OHCI-like) register definitions |
| 34 | */ |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 35 | #define UHCREV (0x0000) /* UHC HCI Spec Revision */ |
| 36 | #define UHCHCON (0x0004) /* UHC Host Control Register */ |
| 37 | #define UHCCOMS (0x0008) /* UHC Command Status Register */ |
| 38 | #define UHCINTS (0x000C) /* UHC Interrupt Status Register */ |
| 39 | #define UHCINTE (0x0010) /* UHC Interrupt Enable */ |
| 40 | #define UHCINTD (0x0014) /* UHC Interrupt Disable */ |
| 41 | #define UHCHCCA (0x0018) /* UHC Host Controller Comm. Area */ |
| 42 | #define UHCPCED (0x001C) /* UHC Period Current Endpt Descr */ |
| 43 | #define UHCCHED (0x0020) /* UHC Control Head Endpt Descr */ |
| 44 | #define UHCCCED (0x0024) /* UHC Control Current Endpt Descr */ |
| 45 | #define UHCBHED (0x0028) /* UHC Bulk Head Endpt Descr */ |
| 46 | #define UHCBCED (0x002C) /* UHC Bulk Current Endpt Descr */ |
| 47 | #define UHCDHEAD (0x0030) /* UHC Done Head */ |
| 48 | #define UHCFMI (0x0034) /* UHC Frame Interval */ |
| 49 | #define UHCFMR (0x0038) /* UHC Frame Remaining */ |
| 50 | #define UHCFMN (0x003C) /* UHC Frame Number */ |
| 51 | #define UHCPERS (0x0040) /* UHC Periodic Start */ |
| 52 | #define UHCLS (0x0044) /* UHC Low Speed Threshold */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 53 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 54 | #define UHCRHDA (0x0048) /* UHC Root Hub Descriptor A */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 55 | #define UHCRHDA_NOCP (1 << 12) /* No over current protection */ |
| 56 | #define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */ |
| 57 | #define UHCRHDA_POTPGT(x) \ |
| 58 | (((x) & 0xff) << 24) /* Power On To Power Good Time */ |
| 59 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 60 | #define UHCRHDB (0x004C) /* UHC Root Hub Descriptor B */ |
| 61 | #define UHCRHS (0x0050) /* UHC Root Hub Status */ |
| 62 | #define UHCRHPS1 (0x0054) /* UHC Root Hub Port 1 Status */ |
| 63 | #define UHCRHPS2 (0x0058) /* UHC Root Hub Port 2 Status */ |
| 64 | #define UHCRHPS3 (0x005C) /* UHC Root Hub Port 3 Status */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 65 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 66 | #define UHCSTAT (0x0060) /* UHC Status Register */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 67 | #define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */ |
| 68 | #define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/ |
| 69 | #define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/ |
| 70 | #define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */ |
| 71 | #define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */ |
| 72 | #define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */ |
| 73 | #define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */ |
| 74 | #define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */ |
| 75 | #define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */ |
| 76 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 77 | #define UHCHR (0x0064) /* UHC Reset Register */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 78 | #define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */ |
| 79 | #define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */ |
| 80 | #define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */ |
| 81 | #define UHCHR_PCPL (1 << 7) /* Power control polarity low */ |
| 82 | #define UHCHR_PSPL (1 << 6) /* Power sense polarity low */ |
| 83 | #define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */ |
| 84 | #define UHCHR_UIT (1 << 4) /* USB Interrupt Test */ |
| 85 | #define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */ |
| 86 | #define UHCHR_CGR (1 << 2) /* Clock Generation Reset */ |
| 87 | #define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */ |
| 88 | #define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */ |
| 89 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 90 | #define UHCHIE (0x0068) /* UHC Interrupt Enable Register*/ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 91 | #define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */ |
| 92 | #define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */ |
| 93 | #define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */ |
| 94 | #define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */ |
| 95 | #define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort |
| 96 | Interrupt Enable*/ |
| 97 | #define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */ |
| 98 | #define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */ |
| 99 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 100 | #define UHCHIT (0x006C) /* UHC Interrupt Test register */ |
Eric Miao | 596050b | 2008-09-27 16:12:32 +0800 | [diff] [blame] | 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #define PXA_UHC_MAX_PORTNUM 3 |
| 103 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 104 | struct pxa27x_ohci { |
| 105 | /* must be 1st member here for hcd_to_ohci() to work */ |
| 106 | struct ohci_hcd ohci; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 108 | struct device *dev; |
| 109 | struct clk *clk; |
| 110 | void __iomem *mmio_base; |
| 111 | }; |
| 112 | |
| 113 | #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)hcd_to_ohci(hcd) |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | /* |
| 116 | PMM_NPS_MODE -- PMM Non-power switching mode |
| 117 | Ports are powered continuously. |
| 118 | |
| 119 | PMM_GLOBAL_MODE -- PMM global switching mode |
| 120 | All ports are powered at the same time. |
| 121 | |
| 122 | PMM_PERPORT_MODE -- PMM per port switching mode |
| 123 | Ports are powered individually. |
| 124 | */ |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 125 | static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 127 | uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA); |
| 128 | uint32_t uhcrhdb = __raw_readl(ohci->mmio_base + UHCRHDB); |
| 129 | |
| 130 | switch (mode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | case PMM_NPS_MODE: |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 132 | uhcrhda |= RH_A_NPS; |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 133 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | case PMM_GLOBAL_MODE: |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 135 | uhcrhda &= ~(RH_A_NPS & RH_A_PSM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | break; |
| 137 | case PMM_PERPORT_MODE: |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 138 | uhcrhda &= ~(RH_A_NPS); |
| 139 | uhcrhda |= RH_A_PSM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | /* Set port power control mask bits, only 3 ports. */ |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 142 | uhcrhdb |= (0x7<<17); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | break; |
| 144 | default: |
| 145 | printk( KERN_ERR |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 146 | "Invalid mode %d, set to non-power switch mode.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | mode ); |
| 148 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 149 | uhcrhda |= RH_A_NPS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 152 | __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA); |
| 153 | __raw_writel(uhcrhdb, ohci->mmio_base + UHCRHDB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | return 0; |
| 155 | } |
| 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | extern int usb_disabled(void); |
| 158 | |
| 159 | /*-------------------------------------------------------------------------*/ |
| 160 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 161 | static inline void pxa27x_setup_hc(struct pxa27x_ohci *ohci, |
| 162 | struct pxaohci_platform_data *inf) |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 163 | { |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 164 | uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR); |
| 165 | uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA); |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 166 | |
| 167 | if (inf->flags & ENABLE_PORT1) |
| 168 | uhchr &= ~UHCHR_SSEP1; |
| 169 | |
| 170 | if (inf->flags & ENABLE_PORT2) |
| 171 | uhchr &= ~UHCHR_SSEP2; |
| 172 | |
| 173 | if (inf->flags & ENABLE_PORT3) |
| 174 | uhchr &= ~UHCHR_SSEP3; |
| 175 | |
| 176 | if (inf->flags & POWER_CONTROL_LOW) |
| 177 | uhchr |= UHCHR_PCPL; |
| 178 | |
| 179 | if (inf->flags & POWER_SENSE_LOW) |
| 180 | uhchr |= UHCHR_PSPL; |
| 181 | |
| 182 | if (inf->flags & NO_OC_PROTECTION) |
| 183 | uhcrhda |= UHCRHDA_NOCP; |
Aric Blumer | 7b4361f | 2009-07-30 13:26:58 -0400 | [diff] [blame] | 184 | else |
| 185 | uhcrhda &= ~UHCRHDA_NOCP; |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 186 | |
| 187 | if (inf->flags & OC_MODE_PERPORT) |
| 188 | uhcrhda |= UHCRHDA_OCPM; |
Aric Blumer | 7b4361f | 2009-07-30 13:26:58 -0400 | [diff] [blame] | 189 | else |
| 190 | uhcrhda &= ~UHCRHDA_OCPM; |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 191 | |
| 192 | if (inf->power_on_delay) { |
| 193 | uhcrhda &= ~UHCRHDA_POTPGT(0xff); |
| 194 | uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2); |
| 195 | } |
| 196 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 197 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); |
| 198 | __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA); |
| 199 | } |
| 200 | |
| 201 | static inline void pxa27x_reset_hc(struct pxa27x_ohci *ohci) |
| 202 | { |
| 203 | uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR); |
| 204 | |
| 205 | __raw_writel(uhchr | UHCHR_FHR, ohci->mmio_base + UHCHR); |
| 206 | udelay(11); |
| 207 | __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR); |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 208 | } |
| 209 | |
Eric Miao | 59376cc | 2010-07-14 21:17:25 +0800 | [diff] [blame] | 210 | #ifdef CONFIG_PXA27x |
Eric Miao | 0cb0b0d | 2008-10-04 12:45:39 +0800 | [diff] [blame] | 211 | extern void pxa27x_clear_otgph(void); |
| 212 | #else |
| 213 | #define pxa27x_clear_otgph() do {} while (0) |
| 214 | #endif |
| 215 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 216 | static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | { |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 218 | int retval = 0; |
| 219 | struct pxaohci_platform_data *inf; |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 220 | uint32_t uhchr; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 221 | |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 222 | inf = dev_get_platdata(dev); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 223 | |
Philipp Zabel | 4bf34b8 | 2012-03-15 19:20:24 +0100 | [diff] [blame] | 224 | clk_prepare_enable(ohci->clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 226 | pxa27x_reset_hc(ohci); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 228 | uhchr = __raw_readl(ohci->mmio_base + UHCHR) | UHCHR_FSBIR; |
| 229 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); |
| 230 | |
| 231 | while (__raw_readl(ohci->mmio_base + UHCHR) & UHCHR_FSBIR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | cpu_relax(); |
| 233 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 234 | pxa27x_setup_hc(ohci, inf); |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 235 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 236 | if (inf->init) |
| 237 | retval = inf->init(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 239 | if (retval < 0) |
| 240 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
Igor Grinberg | 6dc3ae8 | 2010-07-27 15:06:59 +0300 | [diff] [blame] | 242 | if (cpu_is_pxa3xx()) |
| 243 | pxa3xx_u2d_start_hc(&ohci_to_hcd(&ohci->ohci)->self); |
| 244 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 245 | uhchr = __raw_readl(ohci->mmio_base + UHCHR) & ~UHCHR_SSE; |
| 246 | __raw_writel(uhchr, ohci->mmio_base + UHCHR); |
| 247 | __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, ohci->mmio_base + UHCHIE); |
David Brownell | 155faf5 | 2005-08-31 11:54:09 -0700 | [diff] [blame] | 248 | |
| 249 | /* Clear any OTG Pin Hold */ |
Eric Miao | 0cb0b0d | 2008-10-04 12:45:39 +0800 | [diff] [blame] | 250 | pxa27x_clear_otgph(); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 251 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 254 | static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 256 | struct pxaohci_platform_data *inf; |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 257 | uint32_t uhccoms; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 258 | |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 259 | inf = dev_get_platdata(dev); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 260 | |
Igor Grinberg | 6dc3ae8 | 2010-07-27 15:06:59 +0300 | [diff] [blame] | 261 | if (cpu_is_pxa3xx()) |
| 262 | pxa3xx_u2d_stop_hc(&ohci_to_hcd(&ohci->ohci)->self); |
| 263 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 264 | if (inf->exit) |
| 265 | inf->exit(dev); |
| 266 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 267 | pxa27x_reset_hc(ohci); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 269 | /* Host Controller Reset */ |
| 270 | uhccoms = __raw_readl(ohci->mmio_base + UHCCOMS) | 0x01; |
| 271 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | udelay(10); |
| 273 | |
Philipp Zabel | 4bf34b8 | 2012-03-15 19:20:24 +0100 | [diff] [blame] | 274 | clk_disable_unprepare(ohci->clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 277 | #ifdef CONFIG_OF |
| 278 | static const struct of_device_id pxa_ohci_dt_ids[] = { |
| 279 | { .compatible = "marvell,pxa-ohci" }, |
| 280 | { } |
| 281 | }; |
| 282 | |
| 283 | MODULE_DEVICE_TABLE(of, pxa_ohci_dt_ids); |
| 284 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 285 | static int ohci_pxa_of_init(struct platform_device *pdev) |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 286 | { |
| 287 | struct device_node *np = pdev->dev.of_node; |
| 288 | struct pxaohci_platform_data *pdata; |
| 289 | u32 tmp; |
| 290 | |
| 291 | if (!np) |
| 292 | return 0; |
| 293 | |
| 294 | /* Right now device-tree probed devices don't get dma_mask set. |
| 295 | * Since shared usb code relies on it, set it here for now. |
| 296 | * Once we have dma capability bindings this can go away. |
| 297 | */ |
| 298 | if (!pdev->dev.dma_mask) |
Stephen Warren | 3b9561e | 2013-05-07 16:53:52 -0600 | [diff] [blame] | 299 | pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; |
| 300 | if (!pdev->dev.coherent_dma_mask) |
| 301 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 302 | |
| 303 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
| 304 | if (!pdata) |
| 305 | return -ENOMEM; |
| 306 | |
| 307 | if (of_get_property(np, "marvell,enable-port1", NULL)) |
| 308 | pdata->flags |= ENABLE_PORT1; |
| 309 | if (of_get_property(np, "marvell,enable-port2", NULL)) |
| 310 | pdata->flags |= ENABLE_PORT2; |
| 311 | if (of_get_property(np, "marvell,enable-port3", NULL)) |
| 312 | pdata->flags |= ENABLE_PORT3; |
| 313 | if (of_get_property(np, "marvell,port-sense-low", NULL)) |
| 314 | pdata->flags |= POWER_SENSE_LOW; |
| 315 | if (of_get_property(np, "marvell,power-control-low", NULL)) |
| 316 | pdata->flags |= POWER_CONTROL_LOW; |
| 317 | if (of_get_property(np, "marvell,no-oc-protection", NULL)) |
| 318 | pdata->flags |= NO_OC_PROTECTION; |
| 319 | if (of_get_property(np, "marvell,oc-mode-perport", NULL)) |
| 320 | pdata->flags |= OC_MODE_PERPORT; |
| 321 | if (!of_property_read_u32(np, "marvell,power-on-delay", &tmp)) |
| 322 | pdata->power_on_delay = tmp; |
| 323 | if (!of_property_read_u32(np, "marvell,port-mode", &tmp)) |
| 324 | pdata->port_mode = tmp; |
| 325 | if (!of_property_read_u32(np, "marvell,power-budget", &tmp)) |
| 326 | pdata->power_budget = tmp; |
| 327 | |
| 328 | pdev->dev.platform_data = pdata; |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | #else |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 333 | static int ohci_pxa_of_init(struct platform_device *pdev) |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 334 | { |
| 335 | return 0; |
| 336 | } |
| 337 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | /*-------------------------------------------------------------------------*/ |
| 340 | |
| 341 | /* configure so an HC device and id are always provided */ |
| 342 | /* always called with process context; sleeping is OK */ |
| 343 | |
| 344 | |
| 345 | /** |
| 346 | * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs |
| 347 | * Context: !in_interrupt() |
| 348 | * |
| 349 | * Allocates basic resources for this USB host controller, and |
| 350 | * then invokes the start() method for the HCD associated with it |
| 351 | * through the hotplug entry's driver_data. |
| 352 | * |
| 353 | */ |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 354 | int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
Eric Miao | 84bab73 | 2008-10-03 22:37:21 +0800 | [diff] [blame] | 356 | int retval, irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | struct usb_hcd *hcd; |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 358 | struct pxaohci_platform_data *inf; |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 359 | struct pxa27x_ohci *ohci; |
Eric Miao | 84bab73 | 2008-10-03 22:37:21 +0800 | [diff] [blame] | 360 | struct resource *r; |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 361 | struct clk *usb_clk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 363 | retval = ohci_pxa_of_init(pdev); |
| 364 | if (retval) |
| 365 | return retval; |
| 366 | |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 367 | inf = dev_get_platdata(&pdev->dev); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 368 | |
| 369 | if (!inf) |
| 370 | return -ENODEV; |
| 371 | |
Eric Miao | 84bab73 | 2008-10-03 22:37:21 +0800 | [diff] [blame] | 372 | irq = platform_get_irq(pdev, 0); |
| 373 | if (irq < 0) { |
| 374 | pr_err("no resource of IORESOURCE_IRQ"); |
| 375 | return -ENXIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Russell King | e0d8b13 | 2008-11-11 17:52:32 +0000 | [diff] [blame] | 378 | usb_clk = clk_get(&pdev->dev, NULL); |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 379 | if (IS_ERR(usb_clk)) |
| 380 | return PTR_ERR(usb_clk); |
| 381 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 382 | hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); |
Julia Lawall | 7febe2b | 2011-06-01 19:10:06 +0200 | [diff] [blame] | 383 | if (!hcd) { |
| 384 | retval = -ENOMEM; |
| 385 | goto err0; |
| 386 | } |
Eric Miao | 84bab73 | 2008-10-03 22:37:21 +0800 | [diff] [blame] | 387 | |
| 388 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 389 | if (!r) { |
| 390 | pr_err("no resource of IORESOURCE_MEM"); |
| 391 | retval = -ENXIO; |
| 392 | goto err1; |
| 393 | } |
| 394 | |
| 395 | hcd->rsrc_start = r->start; |
| 396 | hcd->rsrc_len = resource_size(r); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
| 398 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
| 399 | pr_debug("request_mem_region failed"); |
| 400 | retval = -EBUSY; |
| 401 | goto err1; |
| 402 | } |
| 403 | |
| 404 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); |
| 405 | if (!hcd->regs) { |
| 406 | pr_debug("ioremap failed"); |
| 407 | retval = -ENOMEM; |
| 408 | goto err2; |
| 409 | } |
| 410 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 411 | /* initialize "struct pxa27x_ohci" */ |
| 412 | ohci = (struct pxa27x_ohci *)hcd_to_ohci(hcd); |
| 413 | ohci->dev = &pdev->dev; |
| 414 | ohci->clk = usb_clk; |
| 415 | ohci->mmio_base = (void __iomem *)hcd->regs; |
| 416 | |
| 417 | if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) { |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 418 | pr_debug("pxa27x_start_hc failed"); |
| 419 | goto err3; |
| 420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
| 422 | /* Select Power Management Mode */ |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 423 | pxa27x_ohci_select_pmm(ohci, inf->port_mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Richard Purdie | 0c27c5d | 2006-06-08 22:44:07 +0100 | [diff] [blame] | 425 | if (inf->power_budget) |
| 426 | hcd->power_budget = inf->power_budget; |
| 427 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | ohci_hcd_init(hcd_to_ohci(hcd)); |
| 429 | |
Yong Zhang | b5dd18d | 2011-09-07 16:10:52 +0800 | [diff] [blame] | 430 | retval = usb_add_hcd(hcd, irq, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | if (retval == 0) |
| 432 | return retval; |
| 433 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 434 | pxa27x_stop_hc(ohci, &pdev->dev); |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 435 | err3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | iounmap(hcd->regs); |
| 437 | err2: |
| 438 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 439 | err1: |
| 440 | usb_put_hcd(hcd); |
Julia Lawall | 7febe2b | 2011-06-01 19:10:06 +0200 | [diff] [blame] | 441 | err0: |
eric miao | a8bcf41 | 2007-12-12 08:53:25 +0800 | [diff] [blame] | 442 | clk_put(usb_clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | return retval; |
| 444 | } |
| 445 | |
| 446 | |
| 447 | /* may be called without controller electrically present */ |
| 448 | /* may be called with controller, bus, and devices active */ |
| 449 | |
| 450 | /** |
| 451 | * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs |
| 452 | * @dev: USB Host Controller being removed |
| 453 | * Context: !in_interrupt() |
| 454 | * |
| 455 | * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking |
| 456 | * the HCD's stop() method. It is always called from a thread |
| 457 | * context, normally "rmmod", "apmd", or something similar. |
| 458 | * |
| 459 | */ |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 460 | void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | { |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 462 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); |
| 463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | usb_remove_hcd(hcd); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 465 | pxa27x_stop_hc(ohci, &pdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | iounmap(hcd->regs); |
| 467 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 468 | usb_put_hcd(hcd); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 469 | clk_put(ohci->clk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | /*-------------------------------------------------------------------------*/ |
| 473 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 474 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | ohci_pxa27x_start (struct usb_hcd *hcd) |
| 476 | { |
| 477 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 478 | int ret; |
| 479 | |
| 480 | ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci); |
| 481 | |
David Brownell | fdd13b3 | 2005-08-31 11:52:57 -0700 | [diff] [blame] | 482 | /* The value of NDP in roothub_a is incorrect on this hardware */ |
| 483 | ohci->num_ports = 3; |
| 484 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | if ((ret = ohci_init(ohci)) < 0) |
| 486 | return ret; |
| 487 | |
| 488 | if ((ret = ohci_run (ohci)) < 0) { |
Paul Gortmaker | ade749a | 2012-05-01 17:36:54 -0400 | [diff] [blame] | 489 | dev_err(hcd->self.controller, "can't start %s", |
| 490 | hcd->self.bus_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | ohci_stop (hcd); |
| 492 | return ret; |
| 493 | } |
| 494 | |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | /*-------------------------------------------------------------------------*/ |
| 499 | |
| 500 | static const struct hc_driver ohci_pxa27x_hc_driver = { |
| 501 | .description = hcd_name, |
| 502 | .product_desc = "PXA27x OHCI", |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 503 | .hcd_priv_size = sizeof(struct pxa27x_ohci), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | /* |
| 506 | * generic hardware linkage |
| 507 | */ |
| 508 | .irq = ohci_irq, |
| 509 | .flags = HCD_USB11 | HCD_MEMORY, |
| 510 | |
| 511 | /* |
| 512 | * basic lifecycle operations |
| 513 | */ |
| 514 | .start = ohci_pxa27x_start, |
| 515 | .stop = ohci_stop, |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 516 | .shutdown = ohci_shutdown, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
| 518 | /* |
| 519 | * managing i/o requests and associated device resources |
| 520 | */ |
| 521 | .urb_enqueue = ohci_urb_enqueue, |
| 522 | .urb_dequeue = ohci_urb_dequeue, |
| 523 | .endpoint_disable = ohci_endpoint_disable, |
| 524 | |
| 525 | /* |
| 526 | * scheduling support |
| 527 | */ |
| 528 | .get_frame_number = ohci_get_frame, |
| 529 | |
| 530 | /* |
| 531 | * root hub support |
| 532 | */ |
| 533 | .hub_status_data = ohci_hub_status_data, |
| 534 | .hub_control = ohci_hub_control, |
David Brownell | 8ad7fe1 | 2005-09-13 19:59:11 -0700 | [diff] [blame] | 535 | #ifdef CONFIG_PM |
Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 536 | .bus_suspend = ohci_bus_suspend, |
| 537 | .bus_resume = ohci_bus_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | #endif |
David Brownell | 9293677 | 2005-09-22 22:32:11 -0700 | [diff] [blame] | 539 | .start_port_reset = ohci_start_port_reset, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | /*-------------------------------------------------------------------------*/ |
| 543 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 544 | static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | pr_debug ("In ohci_hcd_pxa27x_drv_probe"); |
| 547 | |
| 548 | if (usb_disabled()) |
| 549 | return -ENODEV; |
| 550 | |
Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 551 | return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 554 | static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | { |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 556 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | |
| 558 | usb_hcd_pxa27x_remove(hcd, pdev); |
| 559 | return 0; |
| 560 | } |
| 561 | |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 562 | #ifdef CONFIG_PM |
| 563 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | { |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 565 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 566 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 567 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 568 | if (time_before(jiffies, ohci->ohci.next_statechange)) |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 569 | msleep(5); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 570 | ohci->ohci.next_statechange = jiffies; |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 571 | |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 572 | pxa27x_stop_hc(ohci, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | return 0; |
| 574 | } |
| 575 | |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 576 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | { |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 578 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 579 | struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd); |
Jingoo Han | d4f09e2 | 2013-07-30 19:59:40 +0900 | [diff] [blame] | 580 | struct pxaohci_platform_data *inf = dev_get_platdata(dev); |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 581 | int status; |
| 582 | |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 583 | if (time_before(jiffies, ohci->ohci.next_statechange)) |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 584 | msleep(5); |
Eric Miao | 0c392ed | 2008-10-04 12:57:21 +0800 | [diff] [blame] | 585 | ohci->ohci.next_statechange = jiffies; |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 586 | |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 587 | if ((status = pxa27x_start_hc(ohci, dev)) < 0) |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 588 | return status; |
| 589 | |
Aric D. Blumer | a75d048 | 2009-07-30 13:42:30 -0400 | [diff] [blame] | 590 | /* Select Power Management Mode */ |
| 591 | pxa27x_ohci_select_pmm(ohci, inf->port_mode); |
| 592 | |
Florian Fainelli | cfa49b4 | 2012-10-08 15:11:29 +0200 | [diff] [blame] | 593 | ohci_resume(hcd, false); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | return 0; |
| 595 | } |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 596 | |
Alexey Dobriyan | 4714521 | 2009-12-14 18:00:08 -0800 | [diff] [blame] | 597 | static const struct dev_pm_ops ohci_hcd_pxa27x_pm_ops = { |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 598 | .suspend = ohci_hcd_pxa27x_drv_suspend, |
| 599 | .resume = ohci_hcd_pxa27x_drv_resume, |
| 600 | }; |
Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 601 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
Kay Sievers | f4fce61 | 2008-04-10 21:29:22 -0700 | [diff] [blame] | 603 | /* work with hotplug and coldplug */ |
| 604 | MODULE_ALIAS("platform:pxa27x-ohci"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 606 | static struct platform_driver ohci_hcd_pxa27x_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | .probe = ohci_hcd_pxa27x_drv_probe, |
| 608 | .remove = ohci_hcd_pxa27x_drv_remove, |
David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 609 | .shutdown = usb_hcd_platform_shutdown, |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 610 | .driver = { |
| 611 | .name = "pxa27x-ohci", |
Kay Sievers | f4fce61 | 2008-04-10 21:29:22 -0700 | [diff] [blame] | 612 | .owner = THIS_MODULE, |
Daniel Mack | 1139b45 | 2012-07-30 09:29:12 +0200 | [diff] [blame] | 613 | .of_match_table = of_match_ptr(pxa_ohci_dt_ids), |
Mike Rapoport | b7f3f59 | 2009-07-21 17:49:39 +0300 | [diff] [blame] | 614 | #ifdef CONFIG_PM |
| 615 | .pm = &ohci_hcd_pxa27x_pm_ops, |
| 616 | #endif |
Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 617 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | }; |
| 619 | |