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.
20 #include <linux/platform_device.h>
22 static int ehci_update_device(struct usb_hcd
*hcd
, struct usb_device
*udev
)
24 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
27 if (!udev
->parent
) /* udev is root hub itself, impossible */
29 /* we only support lpm device connected to root hub yet */
30 if (ehci
->has_lpm
&& !udev
->parent
->parent
) {
31 rc
= ehci_lpm_set_da(ehci
, udev
->devnum
, udev
->portnum
);
33 rc
= ehci_lpm_check(ehci
, udev
->portnum
);
38 static const struct hc_driver vt8500_ehci_hc_driver
= {
39 .description
= hcd_name
,
40 .product_desc
= "VT8500 EHCI",
41 .hcd_priv_size
= sizeof(struct ehci_hcd
),
44 * generic hardware linkage
47 .flags
= HCD_MEMORY
| HCD_USB2
,
50 * basic lifecycle operations
55 .shutdown
= ehci_shutdown
,
58 * managing i/o requests and associated device resources
60 .urb_enqueue
= ehci_urb_enqueue
,
61 .urb_dequeue
= ehci_urb_dequeue
,
62 .endpoint_disable
= ehci_endpoint_disable
,
63 .endpoint_reset
= ehci_endpoint_reset
,
68 .get_frame_number
= ehci_get_frame
,
73 .hub_status_data
= ehci_hub_status_data
,
74 .hub_control
= ehci_hub_control
,
75 .bus_suspend
= ehci_bus_suspend
,
76 .bus_resume
= ehci_bus_resume
,
77 .relinquish_port
= ehci_relinquish_port
,
78 .port_handed_over
= ehci_port_handed_over
,
81 * call back when device connected and addressed
83 .update_device
= ehci_update_device
,
85 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
88 static u64 vt8500_ehci_dma_mask
= DMA_BIT_MASK(32);
90 static int vt8500_ehci_drv_probe(struct platform_device
*pdev
)
93 struct ehci_hcd
*ehci
;
101 * Right now device-tree probed devices don't get dma_mask set.
102 * Since shared usb code relies on it, set it here for now.
103 * Once we have dma capability bindings this can go away.
105 if (!pdev
->dev
.dma_mask
)
106 pdev
->dev
.dma_mask
= &vt8500_ehci_dma_mask
;
108 if (pdev
->resource
[1].flags
!= IORESOURCE_IRQ
) {
109 pr_debug("resource[1] is not IORESOURCE_IRQ");
112 hcd
= usb_create_hcd(&vt8500_ehci_hc_driver
, &pdev
->dev
, "VT8500");
116 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
117 hcd
->rsrc_start
= res
->start
;
118 hcd
->rsrc_len
= resource_size(res
);
120 hcd
->regs
= devm_request_and_ioremap(&pdev
->dev
, res
);
122 pr_debug("ioremap failed");
127 ehci
= hcd_to_ehci(hcd
);
128 ehci
->caps
= hcd
->regs
;
130 ret
= usb_add_hcd(hcd
, pdev
->resource
[1].start
,
133 platform_set_drvdata(pdev
, hcd
);
142 static int vt8500_ehci_drv_remove(struct platform_device
*pdev
)
144 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
148 platform_set_drvdata(pdev
, NULL
);
153 static const struct of_device_id vt8500_ehci_ids
[] = {
154 { .compatible
= "via,vt8500-ehci", },
155 { .compatible
= "wm,prizm-ehci", },
159 static struct platform_driver vt8500_ehci_driver
= {
160 .probe
= vt8500_ehci_drv_probe
,
161 .remove
= vt8500_ehci_drv_remove
,
162 .shutdown
= usb_hcd_platform_shutdown
,
164 .name
= "vt8500-ehci",
165 .owner
= THIS_MODULE
,
166 .of_match_table
= of_match_ptr(vt8500_ehci_ids
),
170 MODULE_ALIAS("platform:vt8500-ehci");
171 MODULE_DEVICE_TABLE(of
, vt8500_ehci_ids
);