2 * MCS814X EHCI Host Controller Driver
4 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
12 #include <linux/platform_device.h>
15 #define MCS814X_EHCI_CAPS_OFFSET 0x68
17 static int mcs814x_ehci_init(struct usb_hcd
*hcd
)
19 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
22 ehci
->caps
= hcd
->regs
+ MCS814X_EHCI_CAPS_OFFSET
;
23 ehci
->regs
= hcd
->regs
24 + HC_LENGTH(ehci
, ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
25 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
28 retval
= ehci_init(hcd
);
30 pr_err("ehci_init failed\n");
37 static const struct hc_driver mcs814x_ehci_hc_driver
= {
38 .description
= hcd_name
,
39 .product_desc
= "MCS814X EHCI Host Controller",
40 .hcd_priv_size
= sizeof(struct ehci_hcd
),
42 .flags
= HCD_MEMORY
| HCD_USB2
,
43 .reset
= mcs814x_ehci_init
,
46 .shutdown
= ehci_shutdown
,
47 .urb_enqueue
= ehci_urb_enqueue
,
48 .urb_dequeue
= ehci_urb_dequeue
,
49 .endpoint_disable
= ehci_endpoint_disable
,
50 .get_frame_number
= ehci_get_frame
,
51 .hub_status_data
= ehci_hub_status_data
,
52 .hub_control
= ehci_hub_control
,
53 #if defined(CONFIG_PM)
54 .bus_suspend
= ehci_bus_suspend
,
55 .bus_resume
= ehci_bus_resume
,
57 .relinquish_port
= ehci_relinquish_port
,
58 .port_handed_over
= ehci_port_handed_over
,
60 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
63 static int mcs814x_ehci_probe(struct platform_device
*pdev
)
66 const struct hc_driver
*driver
= &mcs814x_ehci_hc_driver
;
74 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
77 "Found HC with no IRQ. Check %s setup!\n",
78 dev_name(&pdev
->dev
));
83 pdev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
84 pdev
->dev
.dma_mask
= &pdev
->dev
.coherent_dma_mask
;
86 hcd
= usb_create_hcd(driver
, &pdev
->dev
, dev_name(&pdev
->dev
));
92 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
95 "Found HC with no register addr. Check %s setup!\n",
96 dev_name(&pdev
->dev
));
98 goto fail_request_resource
;
100 hcd
->rsrc_start
= res
->start
;
101 hcd
->rsrc_len
= resource_size(res
);
103 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
,
104 driver
->description
)) {
105 dev_dbg(&pdev
->dev
, "controller already in use\n");
107 goto fail_request_resource
;
110 hcd
->regs
= ioremap_nocache(hcd
->rsrc_start
, hcd
->rsrc_len
);
111 if (hcd
->regs
== NULL
) {
112 dev_dbg(&pdev
->dev
, "error mapping memory\n");
117 retval
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
121 dev_info(&pdev
->dev
, "added MCS814X EHCI driver\n");
128 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
129 fail_request_resource
:
132 dev_err(&pdev
->dev
, "init %s fail, %d\n", dev_name(&pdev
->dev
), retval
);
136 static int mcs814x_ehci_remove(struct platform_device
*pdev
)
138 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
142 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
148 MODULE_ALIAS("platform:mcs814x-ehci");
150 static const struct of_device_id mcs814x_ehci_id
[] = {
151 { .compatible
= "moschip,mcs814x-ehci" },
152 { .compatible
= "usb-ehci" },
156 static struct platform_driver mcs814x_ehci_driver
= {
157 .probe
= mcs814x_ehci_probe
,
158 .remove
= mcs814x_ehci_remove
,
160 .name
= "mcs814x-ehci",
161 .of_match_table
= mcs814x_ehci_id
,