27 static inline struct jz4740_ohci_hcd *hcd_to_jz4740_hcd(
struct usb_hcd *hcd)
32 static inline struct usb_hcd *jz4740_hcd_to_hcd(
struct jz4740_ohci_hcd *jz4740_ohci)
34 return container_of((
void *)jz4740_ohci,
struct usb_hcd, hcd_priv);
37 static int ohci_jz4740_start(
struct usb_hcd *hcd)
42 ret = ohci_init(ohci);
50 dev_err(hcd->self.controller,
"Can not start %s",
58 static int ohci_jz4740_set_vbus_power(
struct jz4740_ohci_hcd *jz4740_ohci,
63 if (!jz4740_ohci->
vbus)
70 "Could not power vbus\n");
81 static int ohci_jz4740_hub_control(
struct usb_hcd *hcd,
u16 typeReq,
u16 wValue,
90 ret = ohci_jz4740_set_vbus_power(jz4740_ohci,
true);
94 ret = ohci_jz4740_set_vbus_power(jz4740_ohci,
false);
101 return ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
105 static const struct hc_driver ohci_jz4740_hc_driver = {
106 .description = hcd_name,
107 .product_desc =
"JZ4740 OHCI",
114 .flags = HCD_USB11 | HCD_MEMORY,
119 .start = ohci_jz4740_start,
121 .shutdown = ohci_shutdown,
126 .urb_enqueue = ohci_urb_enqueue,
127 .urb_dequeue = ohci_urb_dequeue,
128 .endpoint_disable = ohci_endpoint_disable,
133 .get_frame_number = ohci_get_frame,
138 .hub_status_data = ohci_hub_status_data,
139 .hub_control = ohci_jz4740_hub_control,
141 .bus_suspend = ohci_bus_suspend,
142 .bus_resume = ohci_bus_resume,
159 dev_err(&pdev->
dev,
"Failed to get platform resource\n");
165 dev_err(&pdev->
dev,
"Failed to get platform irq\n");
171 dev_err(&pdev->
dev,
"Failed to create hcd.\n");
175 jz4740_ohci = hcd_to_jz4740_hcd(hcd);
179 dev_err(&pdev->
dev,
"Failed to request mem region.\n");
184 hcd->rsrc_start = res->
start;
185 hcd->rsrc_len = resource_size(res);
189 dev_err(&pdev->
dev,
"Failed to ioremap registers.\n");
191 goto err_release_mem;
195 if (IS_ERR(jz4740_ohci->
clk)) {
196 ret = PTR_ERR(jz4740_ohci->
clk);
197 dev_err(&pdev->
dev,
"Failed to get clock: %d\n", ret);
202 if (IS_ERR(jz4740_ohci->
vbus))
208 if (jz4740_ohci->
vbus)
209 ohci_jz4740_set_vbus_power(jz4740_ohci,
true);
211 platform_set_drvdata(pdev, hcd);
213 ohci_hcd_init(hcd_to_ohci(hcd));
217 dev_err(&pdev->
dev,
"Failed to add hcd: %d\n", ret);
224 platform_set_drvdata(pdev,
NULL);
225 if (jz4740_ohci->
vbus) {
244 struct usb_hcd *hcd = platform_get_drvdata(pdev);
249 platform_set_drvdata(pdev,
NULL);
251 if (jz4740_ohci->
vbus) {
268 .probe = jz4740_ohci_probe,
271 .name =
"jz4740-ohci",