Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ehci-xls.c
Go to the documentation of this file.
1 /*
2  * EHCI HCD for Netlogic XLS processors.
3  *
4  * (C) Copyright 2011 Netlogic Microsystems Inc.
5  *
6  * Based on various ehci-*.c drivers
7  *
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.
11  */
12 
13 #include <linux/platform_device.h>
14 
15 static int ehci_xls_setup(struct usb_hcd *hcd)
16 {
17  struct ehci_hcd *ehci = hcd_to_ehci(hcd);
18 
19  ehci->caps = hcd->regs;
20 
21  return ehci_setup(hcd);
22 }
23 
24 int ehci_xls_probe_internal(const struct hc_driver *driver,
25  struct platform_device *pdev)
26 {
27  struct usb_hcd *hcd;
28  struct resource *res;
29  int retval, irq;
30 
31  /* Get our IRQ from an earlier registered Platform Resource */
32  irq = platform_get_irq(pdev, 0);
33  if (irq < 0) {
34  dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n",
35  dev_name(&pdev->dev));
36  return -ENODEV;
37  }
38 
39  /* Get our Memory Handle */
40  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
41  if (!res) {
42  dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n",
43  dev_name(&pdev->dev));
44  return -ENODEV;
45  }
46  hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
47  if (!hcd) {
48  retval = -ENOMEM;
49  goto err1;
50  }
51 
52  hcd->rsrc_start = res->start;
53  hcd->rsrc_len = resource_size(res);
54 
55  if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
56  driver->description)) {
57  dev_dbg(&pdev->dev, "controller already in use\n");
58  retval = -EBUSY;
59  goto err2;
60  }
61  hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
62 
63  if (hcd->regs == NULL) {
64  dev_dbg(&pdev->dev, "error mapping memory\n");
65  retval = -EFAULT;
66  goto err3;
67  }
68 
69  retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
70  if (retval != 0)
71  goto err4;
72  return retval;
73 
74 err4:
75  iounmap(hcd->regs);
76 err3:
77  release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
78 err2:
79  usb_put_hcd(hcd);
80 err1:
81  dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev),
82  retval);
83  return retval;
84 }
85 
86 static struct hc_driver ehci_xls_hc_driver = {
87  .description = hcd_name,
88  .product_desc = "XLS EHCI Host Controller",
89  .hcd_priv_size = sizeof(struct ehci_hcd),
90  .irq = ehci_irq,
91  .flags = HCD_USB2 | HCD_MEMORY,
92  .reset = ehci_xls_setup,
93  .start = ehci_run,
94  .stop = ehci_stop,
95  .shutdown = ehci_shutdown,
96 
97  .urb_enqueue = ehci_urb_enqueue,
98  .urb_dequeue = ehci_urb_dequeue,
99  .endpoint_disable = ehci_endpoint_disable,
100  .endpoint_reset = ehci_endpoint_reset,
101 
102  .get_frame_number = ehci_get_frame,
103 
104  .hub_status_data = ehci_hub_status_data,
105  .hub_control = ehci_hub_control,
106  .bus_suspend = ehci_bus_suspend,
107  .bus_resume = ehci_bus_resume,
108  .relinquish_port = ehci_relinquish_port,
109  .port_handed_over = ehci_port_handed_over,
110 
111  .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
112 };
113 
114 static int ehci_xls_probe(struct platform_device *pdev)
115 {
116  if (usb_disabled())
117  return -ENODEV;
118 
119  return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev);
120 }
121 
122 static int ehci_xls_remove(struct platform_device *pdev)
123 {
124  struct usb_hcd *hcd = platform_get_drvdata(pdev);
125 
126  usb_remove_hcd(hcd);
127  iounmap(hcd->regs);
128  release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
129  usb_put_hcd(hcd);
130  return 0;
131 }
132 
133 MODULE_ALIAS("ehci-xls");
134 
135 static struct platform_driver ehci_xls_driver = {
136  .probe = ehci_xls_probe,
137  .remove = ehci_xls_remove,
138  .shutdown = usb_hcd_platform_shutdown,
139  .driver = {
140  .name = "ehci-xls",
141  },
142 };