ohci-at91.c 17.2 KB
Newer Older
1 2 3 4 5 6
/*
 * OHCI HCD (Host Controller Driver) for USB.
 *
 *  Copyright (C) 2004 SAN People (Pty) Ltd.
 *  Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
 *
7
 * AT91 Bus Glue
8 9 10 11 12 13 14 15
 *
 * Based on fragments of 2.4 driver by Rick Bronson.
 * Based on ohci-omap.c
 *
 * This file is licenced under the GPL.
 */

#include <linux/clk.h>
16
#include <linux/dma-mapping.h>
17 18
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
19
#include <linux/platform_device.h>
20
#include <linux/platform_data/atmel.h>
21 22 23 24 25
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
26

27
#include <mach/hardware.h>
28 29
#include <asm/gpio.h>

30
#include <mach/cpu.h>
31

32 33

#include "ohci.h"
34

35 36 37 38
#define valid_port(index)	((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
#define at91_for_each_port(index)	\
		for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)

39 40
/* interface, function and usb clocks; sometimes also an AHB clock */
static struct clk *iclk, *fclk, *uclk, *hclk;
41 42 43 44 45 46 47
/* interface and function clocks; sometimes also an AHB clock */

#define DRIVER_DESC "OHCI Atmel driver"

static const char hcd_name[] = "ohci-atmel";

static struct hc_driver __read_mostly ohci_at91_hc_driver;
48
static int clocked;
49 50 51
static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, u16 typeReq,
			u16 wValue, u16 wIndex, char *buf, u16 wLength);
static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
52 53 54 55 56

extern int usb_disabled(void);

/*-------------------------------------------------------------------------*/

57 58
static void at91_start_clock(void)
{
59 60 61 62
	if (IS_ENABLED(CONFIG_COMMON_CLK)) {
		clk_set_rate(uclk, 48000000);
		clk_prepare_enable(uclk);
	}
63 64 65
	clk_prepare_enable(hclk);
	clk_prepare_enable(iclk);
	clk_prepare_enable(fclk);
66 67 68 69 70
	clocked = 1;
}

static void at91_stop_clock(void)
{
71 72 73
	clk_disable_unprepare(fclk);
	clk_disable_unprepare(iclk);
	clk_disable_unprepare(hclk);
74 75
	if (IS_ENABLED(CONFIG_COMMON_CLK))
		clk_disable_unprepare(uclk);
76 77 78
	clocked = 0;
}

79 80 81 82 83
static void at91_start_hc(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct ohci_regs __iomem *regs = hcd->regs;

84
	dev_dbg(&pdev->dev, "start\n");
85 86 87 88

	/*
	 * Start the USB clocks.
	 */
89
	at91_start_clock();
90 91 92 93 94 95 96 97 98 99 100 101

	/*
	 * The USB host controller must remain in reset.
	 */
	writel(0, &regs->control);
}

static void at91_stop_hc(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct ohci_regs __iomem *regs = hcd->regs;

102
	dev_dbg(&pdev->dev, "stop\n");
103 104 105 106 107 108 109 110 111

	/*
	 * Put the USB host controller into reset.
	 */
	writel(0, &regs->control);

	/*
	 * Stop the USB clocks.
	 */
112
	at91_stop_clock();
113 114 115 116 117
}


/*-------------------------------------------------------------------------*/

B
Bill Pemberton 已提交
118
static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
119 120 121 122 123 124

/* configure so an HC device and id are always provided */
/* always called with process context; sleeping is OK */


/**
125
 * usb_hcd_at91_probe - initialize AT91-based HCDs
126 127 128 129 130 131
 * Context: !in_interrupt()
 *
 * Allocates basic resources for this USB host controller, and
 * then invokes the start() method for the HCD associated with it
 * through the hotplug entry's driver_data.
 */
B
Bill Pemberton 已提交
132
static int usb_hcd_at91_probe(const struct hc_driver *driver,
133
			struct platform_device *pdev)
134
{
135 136
	struct at91_usbh_data *board;
	struct ohci_hcd *ohci;
137 138 139 140 141 142 143 144
	int retval;
	struct usb_hcd *hcd = NULL;

	if (pdev->num_resources != 2) {
		pr_debug("hcd probe: invalid num_resources");
		return -ENODEV;
	}

145 146
	if ((pdev->resource[0].flags != IORESOURCE_MEM)
			|| (pdev->resource[1].flags != IORESOURCE_IRQ)) {
147 148 149 150
		pr_debug("hcd probe: invalid resource type\n");
		return -ENODEV;
	}

151
	hcd = usb_create_hcd(driver, &pdev->dev, "at91");
152 153 154
	if (!hcd)
		return -ENOMEM;
	hcd->rsrc_start = pdev->resource[0].start;
155
	hcd->rsrc_len = resource_size(&pdev->resource[0]);
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170

	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
		pr_debug("request_mem_region failed\n");
		retval = -EBUSY;
		goto err1;
	}

	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
	if (!hcd->regs) {
		pr_debug("ioremap failed\n");
		retval = -EIO;
		goto err2;
	}

	iclk = clk_get(&pdev->dev, "ohci_clk");
171 172 173 174 175
	if (IS_ERR(iclk)) {
		dev_err(&pdev->dev, "failed to get ohci_clk\n");
		retval = PTR_ERR(iclk);
		goto err3;
	}
176
	fclk = clk_get(&pdev->dev, "uhpck");
177 178 179 180 181
	if (IS_ERR(fclk)) {
		dev_err(&pdev->dev, "failed to get uhpck\n");
		retval = PTR_ERR(fclk);
		goto err4;
	}
182
	hclk = clk_get(&pdev->dev, "hclk");
183 184 185 186 187
	if (IS_ERR(hclk)) {
		dev_err(&pdev->dev, "failed to get hclk\n");
		retval = PTR_ERR(hclk);
		goto err5;
	}
188 189 190 191 192 193 194 195
	if (IS_ENABLED(CONFIG_COMMON_CLK)) {
		uclk = clk_get(&pdev->dev, "usb_clk");
		if (IS_ERR(uclk)) {
			dev_err(&pdev->dev, "failed to get uclk\n");
			retval = PTR_ERR(uclk);
			goto err6;
		}
	}
196

197 198 199
	board = hcd->self.controller->platform_data;
	ohci = hcd_to_ohci(hcd);
	ohci->num_ports = board->ports;
200 201
	at91_start_hc(pdev);

202
	retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
203 204 205 206 207 208
	if (retval == 0)
		return retval;

	/* Error handling */
	at91_stop_hc(pdev);

209 210 211
	if (IS_ENABLED(CONFIG_COMMON_CLK))
		clk_put(uclk);
 err6:
212
	clk_put(hclk);
213
 err5:
214
	clk_put(fclk);
215
 err4:
216 217
	clk_put(iclk);

218
 err3:
219 220 221 222 223 224 225 226 227 228 229 230 231 232
	iounmap(hcd->regs);

 err2:
	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);

 err1:
	usb_put_hcd(hcd);
	return retval;
}


/* may be called with controller, bus, and devices active */

/**
233
 * usb_hcd_at91_remove - shutdown processing for AT91-based HCDs
234 235 236 237 238
 * @dev: USB Host Controller being removed
 * Context: !in_interrupt()
 *
 * Reverses the effect of usb_hcd_at91_probe(), first invoking
 * the HCD's stop() method.  It is always called from a thread
239
 * context, "rmmod" or something similar.
240 241
 *
 */
B
Bill Pemberton 已提交
242
static void usb_hcd_at91_remove(struct usb_hcd *hcd,
243
				struct platform_device *pdev)
244 245 246 247
{
	usb_remove_hcd(hcd);
	at91_stop_hc(pdev);
	iounmap(hcd->regs);
248
	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
249
	usb_put_hcd(hcd);
250

251 252
	if (IS_ENABLED(CONFIG_COMMON_CLK))
		clk_put(uclk);
253
	clk_put(hclk);
254 255
	clk_put(fclk);
	clk_put(iclk);
256
	fclk = iclk = hclk = NULL;
257 258 259
}

/*-------------------------------------------------------------------------*/
260 261
static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable)
{
262
	if (!valid_port(port))
263 264
		return;

265
	if (!gpio_is_valid(pdata->vbus_pin[port]))
266 267
		return;

268
	gpio_set_value(pdata->vbus_pin[port],
269
		       pdata->vbus_pin_active_low[port] ^ enable);
270 271 272 273
}

static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port)
{
274
	if (!valid_port(port))
275 276
		return -EINVAL;

277
	if (!gpio_is_valid(pdata->vbus_pin[port]))
278 279
		return -EINVAL;

280
	return gpio_get_value(pdata->vbus_pin[port]) ^
281
		pdata->vbus_pin_active_low[port];
282 283 284 285 286 287 288
}

/*
 * Update the status data from the hub with the over-current indicator change.
 */
static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf)
{
289 290
	struct at91_usbh_data *pdata = hcd->self.controller->platform_data;
	int length = orig_ohci_hub_status_data(hcd, buf);
291 292
	int port;

293
	at91_for_each_port(port) {
294
		if (pdata->overcurrent_changed[port]) {
295
			if (!length)
296 297 298 299 300 301 302 303 304 305 306 307 308 309
				length = 1;
			buf[0] |= 1 << (port + 1);
		}
	}

	return length;
}

/*
 * Look at the control requests to the root hub and see if we need to override.
 */
static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
				 u16 wIndex, char *buf, u16 wLength)
{
J
Jingoo Han 已提交
310
	struct at91_usbh_data *pdata = dev_get_platdata(hcd->self.controller);
311 312 313 314 315 316 317 318
	struct usb_hub_descriptor *desc;
	int ret = -EINVAL;
	u32 *data = (u32 *)buf;

	dev_dbg(hcd->self.controller,
		"ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
		hcd, typeReq, wValue, wIndex, buf, wLength);

319 320
	wIndex--;

321 322 323 324
	switch (typeReq) {
	case SetPortFeature:
		if (wValue == USB_PORT_FEAT_POWER) {
			dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n");
325 326 327 328 329
			if (valid_port(wIndex)) {
				ohci_at91_usb_set_power(pdata, wIndex, 1);
				ret = 0;
			}

330 331 332 333 334 335 336 337 338 339
			goto out;
		}
		break;

	case ClearPortFeature:
		switch (wValue) {
		case USB_PORT_FEAT_C_OVER_CURRENT:
			dev_dbg(hcd->self.controller,
				"ClearPortFeature: C_OVER_CURRENT\n");

340 341 342
			if (valid_port(wIndex)) {
				pdata->overcurrent_changed[wIndex] = 0;
				pdata->overcurrent_status[wIndex] = 0;
343 344 345 346 347 348 349 350
			}

			goto out;

		case USB_PORT_FEAT_OVER_CURRENT:
			dev_dbg(hcd->self.controller,
				"ClearPortFeature: OVER_CURRENT\n");

351 352
			if (valid_port(wIndex))
				pdata->overcurrent_status[wIndex] = 0;
353 354 355 356 357 358 359

			goto out;

		case USB_PORT_FEAT_POWER:
			dev_dbg(hcd->self.controller,
				"ClearPortFeature: POWER\n");

360 361
			if (valid_port(wIndex)) {
				ohci_at91_usb_set_power(pdata, wIndex, 0);
362 363 364 365 366 367
				return 0;
			}
		}
		break;
	}

368 369
	ret = orig_ohci_hub_control(hcd, typeReq, wValue, wIndex + 1,
				buf, wLength);
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
	if (ret)
		goto out;

	switch (typeReq) {
	case GetHubDescriptor:

		/* update the hub's descriptor */

		desc = (struct usb_hub_descriptor *)buf;

		dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n",
			desc->wHubCharacteristics);

		/* remove the old configurations for power-switching, and
		 * over-current protection, and insert our new configuration
		 */

		desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
		desc->wHubCharacteristics |= cpu_to_le16(0x0001);

		if (pdata->overcurrent_supported) {
			desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
			desc->wHubCharacteristics |=  cpu_to_le16(0x0008|0x0001);
		}

		dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
			desc->wHubCharacteristics);

		return ret;

	case GetPortStatus:
		/* check port status */

		dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex);

405 406
		if (valid_port(wIndex)) {
			if (!ohci_at91_usb_get_power(pdata, wIndex))
407 408
				*data &= ~cpu_to_le32(RH_PS_PPS);

409
			if (pdata->overcurrent_changed[wIndex])
410 411
				*data |= cpu_to_le32(RH_PS_OCIC);

412
			if (pdata->overcurrent_status[wIndex])
413 414 415 416 417 418 419 420
				*data |= cpu_to_le32(RH_PS_POCI);
		}
	}

 out:
	return ret;
}

421 422
/*-------------------------------------------------------------------------*/

423 424 425
static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
{
	struct platform_device *pdev = data;
J
Jingoo Han 已提交
426
	struct at91_usbh_data *pdata = dev_get_platdata(&pdev->dev);
427 428 429 430
	int val, gpio, port;

	/* From the GPIO notifying the over-current situation, find
	 * out the corresponding port */
431
	at91_for_each_port(port) {
432 433
		if (gpio_is_valid(pdata->overcurrent_pin[port]) &&
				gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
434
			gpio = pdata->overcurrent_pin[port];
435
			break;
436
		}
437 438
	}

439
	if (port == AT91_MAX_USBH_PORTS) {
440 441 442 443 444 445 446 447 448
		dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n");
		return IRQ_HANDLED;
	}

	val = gpio_get_value(gpio);

	/* When notified of an over-current situation, disable power
	   on the corresponding port, and mark this port in
	   over-current. */
449
	if (!val) {
450 451 452 453 454 455 456 457 458 459 460
		ohci_at91_usb_set_power(pdata, port, 0);
		pdata->overcurrent_status[port]  = 1;
		pdata->overcurrent_changed[port] = 1;
	}

	dev_dbg(& pdev->dev, "overcurrent situation %s\n",
		val ? "exited" : "notified");

	return IRQ_HANDLED;
}

461 462 463 464 465 466 467 468
#ifdef CONFIG_OF
static const struct of_device_id at91_ohci_dt_ids[] = {
	{ .compatible = "atmel,at91rm9200-ohci" },
	{ /* sentinel */ }
};

MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);

B
Bill Pemberton 已提交
469
static int ohci_at91_of_init(struct platform_device *pdev)
470 471
{
	struct device_node *np = pdev->dev.of_node;
472
	int i, gpio;
473 474 475 476 477 478 479 480 481 482 483 484
	enum of_gpio_flags flags;
	struct at91_usbh_data	*pdata;
	u32 ports;

	if (!np)
		return 0;

	/* Right now device-tree probed devices don't get dma_mask set.
	 * Since shared usb code relies on it, set it here for now.
	 * Once we have dma capability bindings this can go away.
	 */
	if (!pdev->dev.dma_mask)
485 486 487
		pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
	if (!pdev->dev.coherent_dma_mask)
		pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
488 489 490 491 492 493 494 495

	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
	if (!pdata)
		return -ENOMEM;

	if (!of_property_read_u32(np, "num-ports", &ports))
		pdata->ports = ports;

496
	at91_for_each_port(i) {
497 498 499 500 501 502 503
		gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
		pdata->vbus_pin[i] = gpio;
		if (!gpio_is_valid(gpio))
			continue;
		pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
	}

504
	at91_for_each_port(i)
505 506
		pdata->overcurrent_pin[i] =
			of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
507 508 509 510 511 512

	pdev->dev.platform_data = pdata;

	return 0;
}
#else
B
Bill Pemberton 已提交
513
static int ohci_at91_of_init(struct platform_device *pdev)
514 515 516 517 518
{
	return 0;
}
#endif

519 520
/*-------------------------------------------------------------------------*/

B
Bill Pemberton 已提交
521
static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
522
{
523
	struct at91_usbh_data	*pdata;
524
	int			i;
525 526
	int			gpio;
	int			ret;
527

528 529 530
	ret = ohci_at91_of_init(pdev);
	if (ret)
		return ret;
531

J
Jingoo Han 已提交
532
	pdata = dev_get_platdata(&pdev->dev);
533

534
	if (pdata) {
535
		at91_for_each_port(i) {
536 537 538 539 540 541 542 543 544 545
			/*
			 * do not configure PIO if not in relation with
			 * real USB port on board
			 */
			if (i >= pdata->ports) {
				pdata->vbus_pin[i] = -EINVAL;
				pdata->overcurrent_pin[i] = -EINVAL;
				break;
			}

546
			if (!gpio_is_valid(pdata->vbus_pin[i]))
547
				continue;
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
			gpio = pdata->vbus_pin[i];

			ret = gpio_request(gpio, "ohci_vbus");
			if (ret) {
				dev_err(&pdev->dev,
					"can't request vbus gpio %d\n", gpio);
				continue;
			}
			ret = gpio_direction_output(gpio,
						!pdata->vbus_pin_active_low[i]);
			if (ret) {
				dev_err(&pdev->dev,
					"can't put vbus gpio %d as output %d\n",
					gpio, !pdata->vbus_pin_active_low[i]);
				gpio_free(gpio);
				continue;
			}

566 567 568
			ohci_at91_usb_set_power(pdata, i, 1);
		}

569
		at91_for_each_port(i) {
570
			if (!gpio_is_valid(pdata->overcurrent_pin[i]))
571
				continue;
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
			gpio = pdata->overcurrent_pin[i];

			ret = gpio_request(gpio, "ohci_overcurrent");
			if (ret) {
				dev_err(&pdev->dev,
					"can't request overcurrent gpio %d\n",
					gpio);
				continue;
			}

			ret = gpio_direction_input(gpio);
			if (ret) {
				dev_err(&pdev->dev,
					"can't configure overcurrent gpio %d as input\n",
					gpio);
				gpio_free(gpio);
				continue;
			}
590

591
			ret = request_irq(gpio_to_irq(gpio),
592 593 594
					  ohci_hcd_at91_overcurrent_irq,
					  IRQF_SHARED, "ohci_overcurrent", pdev);
			if (ret) {
595 596 597
				gpio_free(gpio);
				dev_err(&pdev->dev,
					"can't get gpio IRQ for overcurrent\n");
598
			}
599 600 601
		}
	}

602 603
	device_init_wakeup(&pdev->dev, 1);
	return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
604 605
}

B
Bill Pemberton 已提交
606
static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
607
{
J
Jingoo Han 已提交
608
	struct at91_usbh_data	*pdata = dev_get_platdata(&pdev->dev);
609 610 611
	int			i;

	if (pdata) {
612
		at91_for_each_port(i) {
613
			if (!gpio_is_valid(pdata->vbus_pin[i]))
614
				continue;
615
			ohci_at91_usb_set_power(pdata, i, 0);
616 617
			gpio_free(pdata->vbus_pin[i]);
		}
618

619
		at91_for_each_port(i) {
620
			if (!gpio_is_valid(pdata->overcurrent_pin[i]))
621 622 623 624
				continue;
			free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev);
			gpio_free(pdata->overcurrent_pin[i]);
		}
625 626
	}

627
	device_init_wakeup(&pdev->dev, 0);
628 629
	usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
	return 0;
630 631 632 633
}

#ifdef CONFIG_PM

634
static int
635
ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
636
{
637 638 639 640 641 642 643 644 645 646 647 648 649 650
	struct usb_hcd	*hcd = platform_get_drvdata(pdev);
	struct ohci_hcd	*ohci = hcd_to_ohci(hcd);

	if (device_may_wakeup(&pdev->dev))
		enable_irq_wake(hcd->irq);

	/*
	 * The integrated transceivers seem unable to notice disconnect,
	 * reconnect, or wakeup without the 48 MHz clock active.  so for
	 * correctness, always discard connection state (using reset).
	 *
	 * REVISIT: some boards will be able to turn VBUS off...
	 */
	if (at91_suspend_entering_slow_clock()) {
651 652 653 654 655
		ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
		ohci->hc_control &= OHCI_CTRL_RWC;
		ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
		ohci->rh_state = OHCI_RH_HALTED;

656 657
		/* flush the writes */
		(void) ohci_readl (ohci, &ohci->regs->control);
658
		at91_stop_clock();
659
	}
660 661 662 663

	return 0;
}

664
static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
665
{
666 667 668 669 670
	struct usb_hcd	*hcd = platform_get_drvdata(pdev);

	if (device_may_wakeup(&pdev->dev))
		disable_irq_wake(hcd->irq);

671 672
	if (!clocked)
		at91_start_clock();
673

674
	ohci_resume(hcd, false);
675 676 677 678 679 680 681 682 683
	return 0;
}
#else
#define ohci_hcd_at91_drv_suspend NULL
#define ohci_hcd_at91_drv_resume  NULL
#endif

static struct platform_driver ohci_hcd_at91_driver = {
	.probe		= ohci_hcd_at91_drv_probe,
B
Bill Pemberton 已提交
684
	.remove		= ohci_hcd_at91_drv_remove,
685
	.shutdown	= usb_hcd_platform_shutdown,
686 687 688
	.suspend	= ohci_hcd_at91_drv_suspend,
	.resume		= ohci_hcd_at91_drv_resume,
	.driver		= {
689
		.name	= "at91_ohci",
690
		.owner	= THIS_MODULE,
691
		.of_match_table	= of_match_ptr(at91_ohci_dt_ids),
692 693
	},
};
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730

static int __init ohci_at91_init(void)
{
	if (usb_disabled())
		return -ENODEV;

	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
	ohci_init_driver(&ohci_at91_hc_driver, NULL);

	/*
	 * The Atmel HW has some unusual quirks, which require Atmel-specific
	 * workarounds. We override certain hc_driver functions here to
	 * achieve that. We explicitly do not enhance ohci_driver_overrides to
	 * allow this more easily, since this is an unusual case, and we don't
	 * want to encourage others to override these functions by making it
	 * too easy.
	 */

	orig_ohci_hub_control = ohci_at91_hc_driver.hub_control;
	orig_ohci_hub_status_data = ohci_at91_hc_driver.hub_status_data;

	ohci_at91_hc_driver.hub_status_data	= ohci_at91_hub_status_data;
	ohci_at91_hc_driver.hub_control		= ohci_at91_hub_control;

	return platform_driver_register(&ohci_hcd_at91_driver);
}
module_init(ohci_at91_init);

static void __exit ohci_at91_cleanup(void)
{
	platform_driver_unregister(&ohci_hcd_at91_driver);
}
module_exit(ohci_at91_cleanup);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:at91_ohci");