2 * EHCI HCD (Host Controller Driver) for USB.
4 * (C) Copyright 2006-2007 Stefan Roese <sr@denx.de>, DENX Software Engineering
6 * Bus Glue for PPC On-Chip EHCI driver
7 * Tested on AMCC 440EPx
9 * Based on "ehci-au12xx.c" by David Brownell <dbrownell@users.sourceforge.net>
11 * This file is licenced under the GPL.
14 #include <linux/platform_device.h>
16 extern int usb_disabled(void);
19 * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs
20 * Context: !in_interrupt()
22 * Allocates basic resources for this USB host controller, and
23 * then invokes the start() method for the HCD associated with it
24 * through the hotplug entry's driver_data.
27 int usb_ehci_ppc_soc_probe(const struct hc_driver
*driver
,
28 struct usb_hcd
**hcd_out
,
29 struct platform_device
*dev
)
33 struct ehci_hcd
*ehci
;
35 if (dev
->resource
[1].flags
!= IORESOURCE_IRQ
) {
36 pr_debug("resource[1] is not IORESOURCE_IRQ");
39 hcd
= usb_create_hcd(driver
, &dev
->dev
, "PPC-SOC EHCI");
42 hcd
->rsrc_start
= dev
->resource
[0].start
;
43 hcd
->rsrc_len
= dev
->resource
[0].end
- dev
->resource
[0].start
+ 1;
45 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
46 pr_debug("request_mem_region failed");
51 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
53 pr_debug("ioremap failed");
58 ehci
= hcd_to_ehci(hcd
);
59 ehci
->big_endian_mmio
= 1;
60 ehci
->big_endian_desc
= 1;
61 ehci
->caps
= hcd
->regs
;
62 ehci
->regs
= hcd
->regs
+ HC_LENGTH(ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
64 /* cache this readonly data; minimize chip reads */
65 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
67 #if defined(CONFIG_440EPX)
69 * 440EPx Errata USBH_3
70 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3
72 out_be32((void *)((ulong
)(&ehci
->regs
->command
) + 0x8c), (1 << 0));
73 ehci_dbg(ehci
, "Break Memory Transfer (BMT) has beed enabled!\n");
76 retval
= usb_add_hcd(hcd
, dev
->resource
[1].start
, IRQF_DISABLED
);
82 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
88 /* may be called without controller electrically present */
89 /* may be called with controller, bus, and devices active */
92 * usb_ehci_hcd_ppc_soc_remove - shutdown processing for PPC-SoC-based HCDs
93 * @dev: USB Host Controller being removed
94 * Context: !in_interrupt()
96 * Reverses the effect of usb_ehci_hcd_ppc_soc_probe(), first invoking
97 * the HCD's stop() method. It is always called from a thread
98 * context, normally "rmmod", "apmd", or something similar.
101 void usb_ehci_ppc_soc_remove(struct usb_hcd
*hcd
, struct platform_device
*dev
)
105 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
109 static const struct hc_driver ehci_ppc_soc_hc_driver
= {
110 .description
= hcd_name
,
111 .product_desc
= "PPC-SOC EHCI",
112 .hcd_priv_size
= sizeof(struct ehci_hcd
),
115 * generic hardware linkage
118 .flags
= HCD_MEMORY
| HCD_USB2
,
121 * basic lifecycle operations
126 .shutdown
= ehci_shutdown
,
129 * managing i/o requests and associated device resources
131 .urb_enqueue
= ehci_urb_enqueue
,
132 .urb_dequeue
= ehci_urb_dequeue
,
133 .endpoint_disable
= ehci_endpoint_disable
,
138 .get_frame_number
= ehci_get_frame
,
143 .hub_status_data
= ehci_hub_status_data
,
144 .hub_control
= ehci_hub_control
,
146 .hub_suspend
= ehci_hub_suspend
,
147 .hub_resume
= ehci_hub_resume
,
151 static int ehci_hcd_ppc_soc_drv_probe(struct platform_device
*pdev
)
153 struct usb_hcd
*hcd
= NULL
;
156 pr_debug("In ehci_hcd_ppc_soc_drv_probe\n");
161 ret
= usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver
, &hcd
, pdev
);
165 static int ehci_hcd_ppc_soc_drv_remove(struct platform_device
*pdev
)
167 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
169 usb_ehci_ppc_soc_remove(hcd
, pdev
);
173 MODULE_ALIAS("ppc-soc-ehci");
174 static struct platform_driver ehci_ppc_soc_driver
= {
175 .probe
= ehci_hcd_ppc_soc_drv_probe
,
176 .remove
= ehci_hcd_ppc_soc_drv_remove
,
177 .shutdown
= usb_hcd_platform_shutdown
,
179 .name
= "ppc-soc-ehci",
180 .bus
= &platform_bus_type