2 * drivers/usb/host/ehci-vt8500.c
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
6 * Based on ehci-au1xxx.c
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #include <linux/err.h>
21 #include <linux/platform_device.h>
23 static const struct hc_driver vt8500_ehci_hc_driver
= {
24 .description
= hcd_name
,
25 .product_desc
= "VT8500 EHCI",
26 .hcd_priv_size
= sizeof(struct ehci_hcd
),
29 * generic hardware linkage
32 .flags
= HCD_MEMORY
| HCD_USB2
,
35 * basic lifecycle operations
40 .shutdown
= ehci_shutdown
,
43 * managing i/o requests and associated device resources
45 .urb_enqueue
= ehci_urb_enqueue
,
46 .urb_dequeue
= ehci_urb_dequeue
,
47 .endpoint_disable
= ehci_endpoint_disable
,
48 .endpoint_reset
= ehci_endpoint_reset
,
53 .get_frame_number
= ehci_get_frame
,
58 .hub_status_data
= ehci_hub_status_data
,
59 .hub_control
= ehci_hub_control
,
60 .bus_suspend
= ehci_bus_suspend
,
61 .bus_resume
= ehci_bus_resume
,
62 .relinquish_port
= ehci_relinquish_port
,
63 .port_handed_over
= ehci_port_handed_over
,
65 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
68 static u64 vt8500_ehci_dma_mask
= DMA_BIT_MASK(32);
70 static int vt8500_ehci_drv_probe(struct platform_device
*pdev
)
73 struct ehci_hcd
*ehci
;
81 * Right now device-tree probed devices don't get dma_mask set.
82 * Since shared usb code relies on it, set it here for now.
83 * Once we have dma capability bindings this can go away.
85 if (!pdev
->dev
.dma_mask
)
86 pdev
->dev
.dma_mask
= &vt8500_ehci_dma_mask
;
88 if (pdev
->resource
[1].flags
!= IORESOURCE_IRQ
) {
89 pr_debug("resource[1] is not IORESOURCE_IRQ");
92 hcd
= usb_create_hcd(&vt8500_ehci_hc_driver
, &pdev
->dev
, "VT8500");
96 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
97 hcd
->rsrc_start
= res
->start
;
98 hcd
->rsrc_len
= resource_size(res
);
100 hcd
->regs
= devm_ioremap_resource(&pdev
->dev
, res
);
101 if (IS_ERR(hcd
->regs
)) {
102 ret
= PTR_ERR(hcd
->regs
);
106 ehci
= hcd_to_ehci(hcd
);
107 ehci
->caps
= hcd
->regs
;
109 ret
= usb_add_hcd(hcd
, pdev
->resource
[1].start
,
112 platform_set_drvdata(pdev
, hcd
);
121 static int vt8500_ehci_drv_remove(struct platform_device
*pdev
)
123 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
127 platform_set_drvdata(pdev
, NULL
);
132 static const struct of_device_id vt8500_ehci_ids
[] = {
133 { .compatible
= "via,vt8500-ehci", },
134 { .compatible
= "wm,prizm-ehci", },
138 static struct platform_driver vt8500_ehci_driver
= {
139 .probe
= vt8500_ehci_drv_probe
,
140 .remove
= vt8500_ehci_drv_remove
,
141 .shutdown
= usb_hcd_platform_shutdown
,
143 .name
= "vt8500-ehci",
144 .owner
= THIS_MODULE
,
145 .of_match_table
= of_match_ptr(vt8500_ehci_ids
),
149 MODULE_ALIAS("platform:vt8500-ehci");
150 MODULE_DEVICE_TABLE(of
, vt8500_ehci_ids
);