| 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> | 
| Linus Torvalds | 4fd5f82 | 2005-10-31 07:32:56 -0800 | [diff] [blame] | 25 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/mach-types.h> | 
 | 27 | #include <asm/hardware.h> | 
 | 28 | #include <asm/arch/pxa-regs.h> | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 29 | #include <asm/arch/ohci.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 |  | 
 | 31 | #define PXA_UHC_MAX_PORTNUM    3 | 
 | 32 |  | 
 | 33 | #define UHCRHPS(x)              __REG2( 0x4C000050, (x)<<2 ) | 
 | 34 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | /* | 
 | 36 |   PMM_NPS_MODE -- PMM Non-power switching mode | 
 | 37 |       Ports are powered continuously. | 
 | 38 |  | 
 | 39 |   PMM_GLOBAL_MODE -- PMM global switching mode | 
 | 40 |       All ports are powered at the same time. | 
 | 41 |  | 
 | 42 |   PMM_PERPORT_MODE -- PMM per port switching mode | 
 | 43 |       Ports are powered individually. | 
 | 44 |  */ | 
 | 45 | static int pxa27x_ohci_select_pmm( int mode ) | 
 | 46 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | 	switch ( mode ) { | 
 | 48 | 	case PMM_NPS_MODE: | 
 | 49 | 		UHCRHDA |= RH_A_NPS; | 
 | 50 | 		break;  | 
 | 51 | 	case PMM_GLOBAL_MODE: | 
 | 52 | 		UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); | 
 | 53 | 		break; | 
 | 54 | 	case PMM_PERPORT_MODE: | 
 | 55 | 		UHCRHDA &= ~(RH_A_NPS); | 
 | 56 | 		UHCRHDA |= RH_A_PSM; | 
 | 57 |  | 
 | 58 | 		/* Set port power control mask bits, only 3 ports. */ | 
 | 59 | 		UHCRHDB |= (0x7<<17); | 
 | 60 | 		break; | 
 | 61 | 	default: | 
 | 62 | 		printk( KERN_ERR | 
 | 63 | 			"Invalid mode %d, set to non-power switch mode.\n",  | 
 | 64 | 			mode ); | 
 | 65 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | 		UHCRHDA |= RH_A_NPS; | 
 | 67 | 	} | 
 | 68 |  | 
 | 69 | 	return 0; | 
 | 70 | } | 
 | 71 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | extern int usb_disabled(void); | 
 | 73 |  | 
 | 74 | /*-------------------------------------------------------------------------*/ | 
 | 75 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 76 | static int pxa27x_start_hc(struct device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 78 | 	int retval = 0; | 
 | 79 | 	struct pxaohci_platform_data *inf; | 
 | 80 |  | 
 | 81 | 	inf = dev->platform_data; | 
 | 82 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | 	pxa_set_cken(CKEN10_USBHOST, 1); | 
 | 84 |  | 
 | 85 | 	UHCHR |= UHCHR_FHR; | 
 | 86 | 	udelay(11); | 
 | 87 | 	UHCHR &= ~UHCHR_FHR; | 
 | 88 |  | 
 | 89 | 	UHCHR |= UHCHR_FSBIR; | 
 | 90 | 	while (UHCHR & UHCHR_FSBIR) | 
 | 91 | 		cpu_relax(); | 
 | 92 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 93 | 	if (inf->init) | 
 | 94 | 		retval = inf->init(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 96 | 	if (retval < 0) | 
 | 97 | 		return retval; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 |  | 
 | 99 | 	UHCHR &= ~UHCHR_SSE; | 
 | 100 |  | 
 | 101 | 	UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE); | 
| David Brownell | 155faf5 | 2005-08-31 11:54:09 -0700 | [diff] [blame] | 102 |  | 
 | 103 | 	/* Clear any OTG Pin Hold */ | 
 | 104 | 	if (PSSR & PSSR_OTGPH) | 
 | 105 | 		PSSR |= PSSR_OTGPH; | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 106 |  | 
 | 107 | 	return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } | 
 | 109 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 110 | static void pxa27x_stop_hc(struct device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 112 | 	struct pxaohci_platform_data *inf; | 
 | 113 |  | 
 | 114 | 	inf = dev->platform_data; | 
 | 115 |  | 
 | 116 | 	if (inf->exit) | 
 | 117 | 		inf->exit(dev); | 
 | 118 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | 	UHCHR |= UHCHR_FHR; | 
 | 120 | 	udelay(11); | 
 | 121 | 	UHCHR &= ~UHCHR_FHR; | 
 | 122 |  | 
 | 123 | 	UHCCOMS |= 1; | 
 | 124 | 	udelay(10); | 
 | 125 |  | 
 | 126 | 	pxa_set_cken(CKEN10_USBHOST, 0); | 
 | 127 | } | 
 | 128 |  | 
 | 129 |  | 
 | 130 | /*-------------------------------------------------------------------------*/ | 
 | 131 |  | 
 | 132 | /* configure so an HC device and id are always provided */ | 
 | 133 | /* always called with process context; sleeping is OK */ | 
 | 134 |  | 
 | 135 |  | 
 | 136 | /** | 
 | 137 |  * usb_hcd_pxa27x_probe - initialize pxa27x-based HCDs | 
 | 138 |  * Context: !in_interrupt() | 
 | 139 |  * | 
 | 140 |  * Allocates basic resources for this USB host controller, and | 
 | 141 |  * then invokes the start() method for the HCD associated with it | 
 | 142 |  * through the hotplug entry's driver_data. | 
 | 143 |  * | 
 | 144 |  */ | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 145 | 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] | 146 | { | 
 | 147 | 	int retval; | 
 | 148 | 	struct usb_hcd *hcd; | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 149 | 	struct pxaohci_platform_data *inf; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 151 | 	inf = pdev->dev.platform_data; | 
 | 152 |  | 
 | 153 | 	if (!inf) | 
 | 154 | 		return -ENODEV; | 
 | 155 |  | 
 | 156 | 	if (pdev->resource[1].flags != IORESOURCE_IRQ) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | 		pr_debug ("resource[1] is not IORESOURCE_IRQ"); | 
 | 158 | 		return -ENOMEM; | 
 | 159 | 	} | 
 | 160 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 161 | 	hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | 	if (!hcd) | 
 | 163 | 		return -ENOMEM; | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 164 | 	hcd->rsrc_start = pdev->resource[0].start; | 
 | 165 | 	hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 |  | 
 | 167 | 	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 
 | 168 | 		pr_debug("request_mem_region failed"); | 
 | 169 | 		retval = -EBUSY; | 
 | 170 | 		goto err1; | 
 | 171 | 	} | 
 | 172 |  | 
 | 173 | 	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 
 | 174 | 	if (!hcd->regs) { | 
 | 175 | 		pr_debug("ioremap failed"); | 
 | 176 | 		retval = -ENOMEM; | 
 | 177 | 		goto err2; | 
 | 178 | 	} | 
 | 179 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 180 | 	if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { | 
 | 181 | 		pr_debug("pxa27x_start_hc failed"); | 
 | 182 | 		goto err3; | 
 | 183 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 |  | 
 | 185 | 	/* Select Power Management Mode */ | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 186 | 	pxa27x_ohci_select_pmm(inf->port_mode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 |  | 
| Richard Purdie | 0c27c5d | 2006-06-08 22:44:07 +0100 | [diff] [blame] | 188 | 	if (inf->power_budget) | 
 | 189 | 		hcd->power_budget = inf->power_budget; | 
 | 190 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | 	ohci_hcd_init(hcd_to_ohci(hcd)); | 
 | 192 |  | 
| Thomas Gleixner | d54b5ca | 2006-07-01 19:29:44 -0700 | [diff] [blame] | 193 | 	retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | 	if (retval == 0) | 
 | 195 | 		return retval; | 
 | 196 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 197 | 	pxa27x_stop_hc(&pdev->dev); | 
 | 198 |  err3: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | 	iounmap(hcd->regs); | 
 | 200 |  err2: | 
 | 201 | 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 
 | 202 |  err1: | 
 | 203 | 	usb_put_hcd(hcd); | 
 | 204 | 	return retval; | 
 | 205 | } | 
 | 206 |  | 
 | 207 |  | 
 | 208 | /* may be called without controller electrically present */ | 
 | 209 | /* may be called with controller, bus, and devices active */ | 
 | 210 |  | 
 | 211 | /** | 
 | 212 |  * usb_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs | 
 | 213 |  * @dev: USB Host Controller being removed | 
 | 214 |  * Context: !in_interrupt() | 
 | 215 |  * | 
 | 216 |  * Reverses the effect of usb_hcd_pxa27x_probe(), first invoking | 
 | 217 |  * the HCD's stop() method.  It is always called from a thread | 
 | 218 |  * context, normally "rmmod", "apmd", or something similar. | 
 | 219 |  * | 
 | 220 |  */ | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 221 | 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] | 222 | { | 
 | 223 | 	usb_remove_hcd(hcd); | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 224 | 	pxa27x_stop_hc(&pdev->dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | 	iounmap(hcd->regs); | 
 | 226 | 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 
 | 227 | 	usb_put_hcd(hcd); | 
 | 228 | } | 
 | 229 |  | 
 | 230 | /*-------------------------------------------------------------------------*/ | 
 | 231 |  | 
 | 232 | static int __devinit | 
 | 233 | ohci_pxa27x_start (struct usb_hcd *hcd) | 
 | 234 | { | 
 | 235 | 	struct ohci_hcd	*ohci = hcd_to_ohci (hcd); | 
 | 236 | 	int		ret; | 
 | 237 |  | 
 | 238 | 	ohci_dbg (ohci, "ohci_pxa27x_start, ohci:%p", ohci); | 
 | 239 |  | 
| David Brownell | fdd13b3 | 2005-08-31 11:52:57 -0700 | [diff] [blame] | 240 | 	/* The value of NDP in roothub_a is incorrect on this hardware */ | 
 | 241 | 	ohci->num_ports = 3; | 
 | 242 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | 	if ((ret = ohci_init(ohci)) < 0) | 
 | 244 | 		return ret; | 
 | 245 |  | 
 | 246 | 	if ((ret = ohci_run (ohci)) < 0) { | 
 | 247 | 		err ("can't start %s", hcd->self.bus_name); | 
 | 248 | 		ohci_stop (hcd); | 
 | 249 | 		return ret; | 
 | 250 | 	} | 
 | 251 |  | 
 | 252 | 	return 0; | 
 | 253 | } | 
 | 254 |  | 
 | 255 | /*-------------------------------------------------------------------------*/ | 
 | 256 |  | 
 | 257 | static const struct hc_driver ohci_pxa27x_hc_driver = { | 
 | 258 | 	.description =		hcd_name, | 
 | 259 | 	.product_desc =		"PXA27x OHCI", | 
 | 260 | 	.hcd_priv_size =	sizeof(struct ohci_hcd), | 
 | 261 |  | 
 | 262 | 	/* | 
 | 263 | 	 * generic hardware linkage | 
 | 264 | 	 */ | 
 | 265 | 	.irq =			ohci_irq, | 
 | 266 | 	.flags =		HCD_USB11 | HCD_MEMORY, | 
 | 267 |  | 
 | 268 | 	/* | 
 | 269 | 	 * basic lifecycle operations | 
 | 270 | 	 */ | 
 | 271 | 	.start =		ohci_pxa27x_start, | 
 | 272 | 	.stop =			ohci_stop, | 
 | 273 |  | 
 | 274 | 	/* | 
 | 275 | 	 * managing i/o requests and associated device resources | 
 | 276 | 	 */ | 
 | 277 | 	.urb_enqueue =		ohci_urb_enqueue, | 
 | 278 | 	.urb_dequeue =		ohci_urb_dequeue, | 
 | 279 | 	.endpoint_disable =	ohci_endpoint_disable, | 
 | 280 |  | 
 | 281 | 	/* | 
 | 282 | 	 * scheduling support | 
 | 283 | 	 */ | 
 | 284 | 	.get_frame_number =	ohci_get_frame, | 
 | 285 |  | 
 | 286 | 	/* | 
 | 287 | 	 * root hub support | 
 | 288 | 	 */ | 
 | 289 | 	.hub_status_data =	ohci_hub_status_data, | 
 | 290 | 	.hub_control =		ohci_hub_control, | 
| David Brownell | 8ad7fe1 | 2005-09-13 19:59:11 -0700 | [diff] [blame] | 291 | #ifdef  CONFIG_PM | 
| Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 292 | 	.bus_suspend =		ohci_bus_suspend, | 
 | 293 | 	.bus_resume =		ohci_bus_resume, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | #endif | 
| David Brownell | 9293677 | 2005-09-22 22:32:11 -0700 | [diff] [blame] | 295 | 	.start_port_reset =	ohci_start_port_reset, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | }; | 
 | 297 |  | 
 | 298 | /*-------------------------------------------------------------------------*/ | 
 | 299 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 300 | static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | 	pr_debug ("In ohci_hcd_pxa27x_drv_probe"); | 
 | 303 |  | 
 | 304 | 	if (usb_disabled()) | 
 | 305 | 		return -ENODEV; | 
 | 306 |  | 
| Richard Purdie | 81f280e | 2005-11-12 14:22:11 +0000 | [diff] [blame] | 307 | 	return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } | 
 | 309 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 310 | static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 312 | 	struct usb_hcd *hcd = platform_get_drvdata(pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 |  | 
 | 314 | 	usb_hcd_pxa27x_remove(hcd, pdev); | 
| Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 315 | 	platform_set_drvdata(pdev, NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | 	return 0; | 
 | 317 | } | 
 | 318 |  | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 319 | #ifdef	CONFIG_PM | 
 | 320 | static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | { | 
| Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 322 | 	struct usb_hcd *hcd = platform_get_drvdata(pdev); | 
 | 323 | 	struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 324 |  | 
 | 325 | 	if (time_before(jiffies, ohci->next_statechange)) | 
 | 326 | 		msleep(5); | 
 | 327 | 	ohci->next_statechange = jiffies; | 
 | 328 |  | 
 | 329 | 	pxa27x_stop_hc(&pdev->dev); | 
| Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 330 | 	hcd->state = HC_STATE_SUSPENDED; | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 331 | 	pdev->dev.power.power_state = PMSG_SUSPEND; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 |  | 
 | 333 | 	return 0; | 
 | 334 | } | 
 | 335 |  | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 336 | static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { | 
| Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 338 | 	struct usb_hcd *hcd = platform_get_drvdata(pdev); | 
 | 339 | 	struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 340 | 	int status; | 
 | 341 |  | 
 | 342 | 	if (time_before(jiffies, ohci->next_statechange)) | 
 | 343 | 		msleep(5); | 
 | 344 | 	ohci->next_statechange = jiffies; | 
 | 345 |  | 
 | 346 | 	if ((status = pxa27x_start_hc(&pdev->dev)) < 0) | 
 | 347 | 		return status; | 
 | 348 |  | 
 | 349 | 	pdev->dev.power.power_state = PMSG_ON; | 
| Richard Purdie | a5e36d2 | 2005-11-28 22:15:46 +0000 | [diff] [blame] | 350 | 	usb_hcd_resume_root_hub(hcd); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 |  | 
 | 352 | 	return 0; | 
 | 353 | } | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 354 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 |  | 
 | 356 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 357 | static struct platform_driver ohci_hcd_pxa27x_driver = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | 	.probe		= ohci_hcd_pxa27x_drv_probe, | 
 | 359 | 	.remove		= ohci_hcd_pxa27x_drv_remove, | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 360 | #ifdef CONFIG_PM | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | 	.suspend	= ohci_hcd_pxa27x_drv_suspend,  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 362 | 	.resume		= ohci_hcd_pxa27x_drv_resume, | 
| Richard Purdie | 2e1dcc1 | 2005-11-12 14:22:14 +0000 | [diff] [blame] | 363 | #endif | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 364 | 	.driver		= { | 
 | 365 | 		.name	= "pxa27x-ohci", | 
 | 366 | 	}, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | }; | 
 | 368 |  | 
 | 369 | static int __init ohci_hcd_pxa27x_init (void) | 
 | 370 | { | 
 | 371 | 	pr_debug (DRIVER_INFO " (pxa27x)"); | 
 | 372 | 	pr_debug ("block sizes: ed %d td %d\n", | 
 | 373 | 		sizeof (struct ed), sizeof (struct td)); | 
 | 374 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 375 | 	return platform_driver_register(&ohci_hcd_pxa27x_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } | 
 | 377 |  | 
 | 378 | static void __exit ohci_hcd_pxa27x_cleanup (void) | 
 | 379 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 380 | 	platform_driver_unregister(&ohci_hcd_pxa27x_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } | 
 | 382 |  | 
 | 383 | module_init (ohci_hcd_pxa27x_init); | 
 | 384 | module_exit (ohci_hcd_pxa27x_cleanup); |