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");
34 ehci_port_power(ehci
, 0);
39 static const struct hc_driver mcs814x_ehci_hc_driver
= {
40 .description
= hcd_name
,
41 .product_desc
= "MCS814X EHCI Host Controller",
42 .hcd_priv_size
= sizeof(struct ehci_hcd
),
44 .flags
= HCD_MEMORY
| HCD_USB2
,
45 .reset
= mcs814x_ehci_init
,
48 .shutdown
= ehci_shutdown
,
49 .urb_enqueue
= ehci_urb_enqueue
,
50 .urb_dequeue
= ehci_urb_dequeue
,
51 .endpoint_disable
= ehci_endpoint_disable
,
52 .get_frame_number
= ehci_get_frame
,
53 .hub_status_data
= ehci_hub_status_data
,
54 .hub_control
= ehci_hub_control
,
55 #if defined(CONFIG_PM)
56 .bus_suspend
= ehci_bus_suspend
,
57 .bus_resume
= ehci_bus_resume
,
59 .relinquish_port
= ehci_relinquish_port
,
60 .port_handed_over
= ehci_port_handed_over
,
62 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
65 static int mcs814x_ehci_probe(struct platform_device
*pdev
)
68 const struct hc_driver
*driver
= &mcs814x_ehci_hc_driver
;
76 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
79 "Found HC with no IRQ. Check %s setup!\n",
80 dev_name(&pdev
->dev
));
85 pdev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
86 pdev
->dev
.dma_mask
= &pdev
->dev
.coherent_dma_mask
;
88 hcd
= usb_create_hcd(driver
, &pdev
->dev
, dev_name(&pdev
->dev
));
94 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
97 "Found HC with no register addr. Check %s setup!\n",
98 dev_name(&pdev
->dev
));
100 goto fail_request_resource
;
102 hcd
->rsrc_start
= res
->start
;
103 hcd
->rsrc_len
= resource_size(res
);
105 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
,
106 driver
->description
)) {
107 dev_dbg(&pdev
->dev
, "controller already in use\n");
109 goto fail_request_resource
;
112 hcd
->regs
= ioremap_nocache(hcd
->rsrc_start
, hcd
->rsrc_len
);
113 if (hcd
->regs
== NULL
) {
114 dev_dbg(&pdev
->dev
, "error mapping memory\n");
119 retval
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
123 dev_info(&pdev
->dev
, "added MCS814X EHCI driver\n");
130 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
131 fail_request_resource
:
134 dev_err(&pdev
->dev
, "init %s fail, %d\n", dev_name(&pdev
->dev
), retval
);
138 static int mcs814x_ehci_remove(struct platform_device
*pdev
)
140 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
144 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
150 MODULE_ALIAS("platform:mcs814x-ehci");
152 static const struct of_device_id mcs814x_ehci_id
[] = {
153 { .compatible
= "moschip,mcs814x-ehci" },
154 { .compatible
= "usb-ehci" },
158 static struct platform_driver mcs814x_ehci_driver
= {
159 .probe
= mcs814x_ehci_probe
,
160 .remove
= mcs814x_ehci_remove
,
162 .name
= "mcs814x-ehci",
163 .of_match_table
= mcs814x_ehci_id
,