26 #define valid_port(idx) ((idx) == 1 || (idx) == 2)
31 static struct clk *usb_clk;
41 return hcd->self.controller->platform_data;
89 ohci_s3c2410_hub_status_data(
struct usb_hcd *hcd,
char *
buf)
96 orig = ohci_hub_status_data(hcd, buf);
101 port = &info->
port[0];
105 for (portno = 0; portno < 2; port++, portno++) {
109 "oc change on port %d\n", portno);
114 buf[0] |= 1<<(portno+1);
134 info->
port[port-1].power = to;
146 static int ohci_s3c2410_hub_control(
160 "s3c2410_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n",
161 hcd, typeReq, wValue, wIndex, buf, wLength);
167 ret = ohci_hub_control(hcd, typeReq, wValue,
168 wIndex, buf, wLength);
177 dev_dbg(hcd->self.controller,
"SetPortFeat: POWER\n");
178 s3c2410_usb_set_power(info, wIndex, 1);
183 case ClearPortFeature:
187 "ClearPortFeature: C_OVER_CURRENT\n");
190 info->
port[wIndex-1].oc_changed = 0;
191 info->
port[wIndex-1].oc_status = 0;
198 "ClearPortFeature: OVER_CURRENT\n");
201 info->
port[wIndex-1].oc_status = 0;
207 "ClearPortFeature: POWER\n");
210 s3c2410_usb_set_power(info, wIndex, 0);
217 ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
222 case GetHubDescriptor:
231 dev_dbg(hcd->self.controller,
"wHubCharacteristics 0x%04x\n",
249 dev_dbg(hcd->self.controller,
"wHubCharacteristics after 0x%04x\n",
257 dev_dbg(hcd->self.controller,
"GetPortStatus(%d)\n", wIndex);
260 if (info->
port[wIndex-1].oc_changed)
263 if (info->
port[wIndex-1].oc_status)
287 port = &info->
port[0];
292 for (portno = 0; portno < 2; port++, portno++) {
293 if (port_oc & (1<<portno) &&
300 s3c2410_usb_set_power(info, portno+1, 0);
322 usb_hcd_s3c2410_remove(
struct usb_hcd *hcd,
struct platform_device *dev)
325 s3c2410_stop_hc(dev);
340 static int usb_hcd_s3c2410_probe(
const struct hc_driver *
driver,
343 struct usb_hcd *hcd =
NULL;
346 s3c2410_usb_set_power(dev->
dev.platform_data, 1, 1);
347 s3c2410_usb_set_power(dev->
dev.platform_data, 2, 1);
353 hcd->rsrc_start = dev->
resource[0].start;
354 hcd->rsrc_len = resource_size(&dev->
resource[0]);
357 dev_err(&dev->
dev,
"request_mem_region failed\n");
364 dev_err(&dev->
dev,
"cannot get usb-host clock\n");
365 retval = PTR_ERR(clk);
370 if (IS_ERR(usb_clk)) {
371 dev_err(&dev->
dev,
"cannot get usb-bus-host clock\n");
372 retval = PTR_ERR(usb_clk);
376 s3c2410_start_hc(dev, hcd);
378 hcd->regs =
ioremap(hcd->rsrc_start, hcd->rsrc_len);
385 ohci_hcd_init(hcd_to_ohci(hcd));
394 s3c2410_stop_hc(dev);
412 ohci_s3c2410_start(
struct usb_hcd *hcd)
417 ret = ohci_init(ohci);
421 ret = ohci_run(ohci);
423 dev_err(hcd->self.controller,
"can't start %s\n",
433 static const struct hc_driver ohci_s3c2410_hc_driver = {
434 .description = hcd_name,
435 .product_desc =
"S3C24XX OHCI",
436 .hcd_priv_size =
sizeof(
struct ohci_hcd),
442 .flags = HCD_USB11 | HCD_MEMORY,
447 .start = ohci_s3c2410_start,
449 .shutdown = ohci_shutdown,
454 .urb_enqueue = ohci_urb_enqueue,
455 .urb_dequeue = ohci_urb_dequeue,
456 .endpoint_disable = ohci_endpoint_disable,
461 .get_frame_number = ohci_get_frame,
466 .hub_status_data = ohci_s3c2410_hub_status_data,
467 .hub_control = ohci_s3c2410_hub_control,
469 .bus_suspend = ohci_bus_suspend,
470 .bus_resume = ohci_bus_resume,
479 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev);
484 struct usb_hcd *hcd = platform_get_drvdata(pdev);
486 usb_hcd_s3c2410_remove(hcd, pdev);
494 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
511 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
513 s3c2410_stop_hc(pdev);
515 spin_unlock_irqrestore(&ohci->
lock, flags);
525 s3c2410_start_hc(pdev, hcd);
527 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
528 ohci_finish_controller_resume(hcd);
533 #define ohci_hcd_s3c2410_drv_suspend NULL
534 #define ohci_hcd_s3c2410_drv_resume NULL
537 static const struct dev_pm_ops ohci_hcd_s3c2410_pm_ops = {
543 .probe = ohci_hcd_s3c2410_drv_probe,
544 .remove =
__devexit_p(ohci_hcd_s3c2410_drv_remove),
548 .name =
"s3c2410-ohci",
549 .pm = &ohci_hcd_s3c2410_pm_ops,