This client driver allows you to use a GPIO pin as a source for PPS
[linux-2.6/next.git] / drivers / usb / host / ehci-xls.c
blobfe74bd6760187c221e79dae448005c07a25863be
1 /*
2 * EHCI HCD for Netlogic XLS processors.
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
6 * Based on various ehci-*.c drivers
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
13 #include <linux/platform_device.h>
15 static int ehci_xls_setup(struct usb_hcd *hcd)
17 int retval;
18 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
20 ehci->caps = hcd->regs;
21 ehci->regs = hcd->regs +
22 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
23 dbg_hcs_params(ehci, "reset");
24 dbg_hcc_params(ehci, "reset");
26 /* cache this readonly data; minimize chip reads */
27 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
29 retval = ehci_halt(ehci);
30 if (retval)
31 return retval;
33 /* data structure init */
34 retval = ehci_init(hcd);
35 if (retval)
36 return retval;
38 ehci_reset(ehci);
40 return retval;
43 int ehci_xls_probe_internal(const struct hc_driver *driver,
44 struct platform_device *pdev)
46 struct usb_hcd *hcd;
47 struct resource *res;
48 int retval, irq;
50 /* Get our IRQ from an earlier registered Platform Resource */
51 irq = platform_get_irq(pdev, 0);
52 if (irq < 0) {
53 dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n",
54 dev_name(&pdev->dev));
55 return -ENODEV;
58 /* Get our Memory Handle */
59 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
60 if (!res) {
61 dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n",
62 dev_name(&pdev->dev));
63 return -ENODEV;
65 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
66 if (!hcd) {
67 retval = -ENOMEM;
68 goto err1;
71 hcd->rsrc_start = res->start;
72 hcd->rsrc_len = res->end - res->start + 1;
74 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
75 driver->description)) {
76 dev_dbg(&pdev->dev, "controller already in use\n");
77 retval = -EBUSY;
78 goto err2;
80 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
82 if (hcd->regs == NULL) {
83 dev_dbg(&pdev->dev, "error mapping memory\n");
84 retval = -EFAULT;
85 goto err3;
88 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
89 if (retval != 0)
90 goto err4;
91 return retval;
93 err4:
94 iounmap(hcd->regs);
95 err3:
96 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
97 err2:
98 usb_put_hcd(hcd);
99 err1:
100 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev),
101 retval);
102 return retval;
105 static struct hc_driver ehci_xls_hc_driver = {
106 .description = hcd_name,
107 .product_desc = "XLS EHCI Host Controller",
108 .hcd_priv_size = sizeof(struct ehci_hcd),
109 .irq = ehci_irq,
110 .flags = HCD_USB2 | HCD_MEMORY,
111 .reset = ehci_xls_setup,
112 .start = ehci_run,
113 .stop = ehci_stop,
114 .shutdown = ehci_shutdown,
116 .urb_enqueue = ehci_urb_enqueue,
117 .urb_dequeue = ehci_urb_dequeue,
118 .endpoint_disable = ehci_endpoint_disable,
119 .endpoint_reset = ehci_endpoint_reset,
121 .get_frame_number = ehci_get_frame,
123 .hub_status_data = ehci_hub_status_data,
124 .hub_control = ehci_hub_control,
125 .bus_suspend = ehci_bus_suspend,
126 .bus_resume = ehci_bus_resume,
127 .relinquish_port = ehci_relinquish_port,
128 .port_handed_over = ehci_port_handed_over,
130 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
133 static int ehci_xls_probe(struct platform_device *pdev)
135 if (usb_disabled())
136 return -ENODEV;
138 return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev);
141 static int ehci_xls_remove(struct platform_device *pdev)
143 struct usb_hcd *hcd = platform_get_drvdata(pdev);
145 usb_remove_hcd(hcd);
146 iounmap(hcd->regs);
147 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
148 usb_put_hcd(hcd);
149 return 0;
152 MODULE_ALIAS("ehci-xls");
154 static struct platform_driver ehci_xls_driver = {
155 .probe = ehci_xls_probe,
156 .remove = ehci_xls_remove,
157 .shutdown = usb_hcd_platform_shutdown,
158 .driver = {
159 .name = "ehci-xls",