diff options
author | Tony Prisk <linux@prisktech.co.nz> | 2012-07-21 06:58:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 17:00:37 -0400 |
commit | 100d45970327f78584ff4846deeca14bba511e28 (patch) | |
tree | 3698827ac9c75aa66d461fd9862b7fcef4768e94 /drivers/usb/host/uhci-platform.c | |
parent | 8ad551d150e3bb0902696496a9d2aa094335705a (diff) |
ARM: vt8500: Add support for UHCI companion controller
Add support for a generic non-pci UHCI companion controller.
Existing board files for arch-vt8500 updated to include UHCI
support.
Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/uhci-platform.c')
-rw-r--r-- | drivers/usb/host/uhci-platform.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c new file mode 100644 index 000000000000..e4780491df4a --- /dev/null +++ b/drivers/usb/host/uhci-platform.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Generic UHCI HCD (Host Controller Driver) for Platform Devices | ||
3 | * | ||
4 | * Copyright (c) 2011 Tony Prisk <linux@prisktech.co.nz> | ||
5 | * | ||
6 | * This file is based on uhci-grlib.c | ||
7 | * (C) Copyright 2004-2007 Alan Stern, stern@rowland.harvard.edu | ||
8 | */ | ||
9 | |||
10 | #include <linux/of.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | |||
13 | static int uhci_platform_init(struct usb_hcd *hcd) | ||
14 | { | ||
15 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | ||
16 | |||
17 | uhci->rh_numports = uhci_count_ports(hcd); | ||
18 | |||
19 | /* Set up pointers to to generic functions */ | ||
20 | uhci->reset_hc = uhci_generic_reset_hc; | ||
21 | uhci->check_and_reset_hc = uhci_generic_check_and_reset_hc; | ||
22 | |||
23 | /* No special actions need to be taken for the functions below */ | ||
24 | uhci->configure_hc = NULL; | ||
25 | uhci->resume_detect_interrupts_are_broken = NULL; | ||
26 | uhci->global_suspend_mode_is_broken = NULL; | ||
27 | |||
28 | /* Reset if the controller isn't already safely quiescent. */ | ||
29 | check_and_reset_hc(uhci); | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static const struct hc_driver uhci_platform_hc_driver = { | ||
34 | .description = hcd_name, | ||
35 | .product_desc = "Generic UHCI Host Controller", | ||
36 | .hcd_priv_size = sizeof(struct uhci_hcd), | ||
37 | |||
38 | /* Generic hardware linkage */ | ||
39 | .irq = uhci_irq, | ||
40 | .flags = HCD_MEMORY | HCD_USB11, | ||
41 | |||
42 | /* Basic lifecycle operations */ | ||
43 | .reset = uhci_platform_init, | ||
44 | .start = uhci_start, | ||
45 | #ifdef CONFIG_PM | ||
46 | .pci_suspend = NULL, | ||
47 | .pci_resume = NULL, | ||
48 | .bus_suspend = uhci_rh_suspend, | ||
49 | .bus_resume = uhci_rh_resume, | ||
50 | #endif | ||
51 | .stop = uhci_stop, | ||
52 | |||
53 | .urb_enqueue = uhci_urb_enqueue, | ||
54 | .urb_dequeue = uhci_urb_dequeue, | ||
55 | |||
56 | .endpoint_disable = uhci_hcd_endpoint_disable, | ||
57 | .get_frame_number = uhci_hcd_get_frame_number, | ||
58 | |||
59 | .hub_status_data = uhci_hub_status_data, | ||
60 | .hub_control = uhci_hub_control, | ||
61 | }; | ||
62 | |||
63 | |||
64 | static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) | ||
65 | { | ||
66 | struct usb_hcd *hcd; | ||
67 | struct uhci_hcd *uhci; | ||
68 | struct resource *res; | ||
69 | int ret; | ||
70 | |||
71 | if (usb_disabled()) | ||
72 | return -ENODEV; | ||
73 | |||
74 | hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, | ||
75 | pdev->name); | ||
76 | if (!hcd) | ||
77 | return -ENOMEM; | ||
78 | |||
79 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
80 | hcd->rsrc_start = res->start; | ||
81 | hcd->rsrc_len = resource_size(res); | ||
82 | |||
83 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
84 | pr_err("%s: request_mem_region failed\n", __func__); | ||
85 | ret = -EBUSY; | ||
86 | goto err_rmr; | ||
87 | } | ||
88 | |||
89 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
90 | if (!hcd->regs) { | ||
91 | pr_err("%s: ioremap failed\n", __func__); | ||
92 | ret = -ENOMEM; | ||
93 | goto err_irq; | ||
94 | } | ||
95 | uhci = hcd_to_uhci(hcd); | ||
96 | |||
97 | uhci->regs = hcd->regs; | ||
98 | |||
99 | ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | | ||
100 | IRQF_SHARED); | ||
101 | if (ret) | ||
102 | goto err_uhci; | ||
103 | |||
104 | return 0; | ||
105 | |||
106 | err_uhci: | ||
107 | iounmap(hcd->regs); | ||
108 | err_irq: | ||
109 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
110 | err_rmr: | ||
111 | usb_put_hcd(hcd); | ||
112 | |||
113 | return ret; | ||
114 | } | ||
115 | |||
116 | static int uhci_hcd_platform_remove(struct platform_device *pdev) | ||
117 | { | ||
118 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
119 | |||
120 | usb_remove_hcd(hcd); | ||
121 | iounmap(hcd->regs); | ||
122 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
123 | usb_put_hcd(hcd); | ||
124 | platform_set_drvdata(pdev, NULL); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | /* Make sure the controller is quiescent and that we're not using it | ||
130 | * any more. This is mainly for the benefit of programs which, like kexec, | ||
131 | * expect the hardware to be idle: not doing DMA or generating IRQs. | ||
132 | * | ||
133 | * This routine may be called in a damaged or failing kernel. Hence we | ||
134 | * do not acquire the spinlock before shutting down the controller. | ||
135 | */ | ||
136 | static void uhci_hcd_platform_shutdown(struct platform_device *op) | ||
137 | { | ||
138 | struct usb_hcd *hcd = dev_get_drvdata(&op->dev); | ||
139 | |||
140 | uhci_hc_died(hcd_to_uhci(hcd)); | ||
141 | } | ||
142 | |||
143 | static const struct of_device_id platform_uhci_ids[] = { | ||
144 | { .compatible = "platform-uhci", }, | ||
145 | {} | ||
146 | }; | ||
147 | |||
148 | static struct platform_driver uhci_platform_driver = { | ||
149 | .probe = uhci_hcd_platform_probe, | ||
150 | .remove = uhci_hcd_platform_remove, | ||
151 | .shutdown = uhci_hcd_platform_shutdown, | ||
152 | .driver = { | ||
153 | .name = "platform-uhci", | ||
154 | .owner = THIS_MODULE, | ||
155 | .of_match_table = of_match_ptr(platform_uhci_ids), | ||
156 | }, | ||
157 | }; | ||