diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-20 14:26:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-20 14:26:30 -0400 |
commit | ed378a52dabf77b406b447fd3238f83ea24b71fa (patch) | |
tree | 07e1a7ec2d1c08767ee81b9910f5912b80502632 /drivers/usb/host | |
parent | 843ec558f91b8e8fdb6efc908f2c0506407cc750 (diff) | |
parent | 11207b6fe05438b2e87a26435cd98db3d55e6fa7 (diff) |
Merge tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB merge for 3.4-rc1 from Greg KH:
"Here's the big USB merge for the 3.4-rc1 merge window.
Lots of gadget driver reworks here, driver updates, xhci changes, some
new drivers added, usb-serial core reworking to fix some bugs, and
other various minor things.
There are some patches touching arch code, but they have all been
acked by the various arch maintainers."
* tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (302 commits)
net: qmi_wwan: add support for ZTE MF820D
USB: option: add ZTE MF820D
usb: gadget: f_fs: Remove lock is held before freeing checks
USB: option: make interface blacklist work again
usb/ub: deprecate & schedule for removal the "Low Performance USB Block" driver
USB: ohci-pxa27x: add clk_prepare/clk_unprepare calls
USB: use generic platform driver on ath79
USB: EHCI: Add a generic platform device driver
USB: OHCI: Add a generic platform device driver
USB: ftdi_sio: new PID: LUMEL PD12
USB: ftdi_sio: add support for FT-X series devices
USB: serial: mos7840: Fixed MCS7820 device attach problem
usb: Don't make USB_ARCH_HAS_{XHCI,OHCI,EHCI} depend on USB_SUPPORT.
usb gadget: fix a section mismatch when compiling g_ffs with CONFIG_USB_FUNCTIONFS_ETH
USB: ohci-nxp: Remove i2c_write(), use smbus
USB: ohci-nxp: Support for LPC32xx
USB: ohci-nxp: Rename symbols from pnx4008 to nxp
USB: OHCI-HCD: Rename ohci-pnx4008 to ohci-nxp
usb: gadget: Kconfig: fix typo for 'different'
usb: dwc3: pci: fix another failure path in dwc3_pci_probe()
...
Diffstat (limited to 'drivers/usb/host')
39 files changed, 1675 insertions, 1191 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 353cdd488b93..f788eb86707c 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -27,6 +27,10 @@ config USB_XHCI_HCD | |||
27 | To compile this driver as a module, choose M here: the | 27 | To compile this driver as a module, choose M here: the |
28 | module will be called xhci-hcd. | 28 | module will be called xhci-hcd. |
29 | 29 | ||
30 | config USB_XHCI_PLATFORM | ||
31 | tristate | ||
32 | depends on USB_XHCI_HCD | ||
33 | |||
30 | config USB_XHCI_HCD_DEBUGGING | 34 | config USB_XHCI_HCD_DEBUGGING |
31 | bool "Debugging for the xHCI host controller" | 35 | bool "Debugging for the xHCI host controller" |
32 | depends on USB_XHCI_HCD | 36 | depends on USB_XHCI_HCD |
@@ -196,7 +200,7 @@ config USB_EHCI_S5P | |||
196 | 200 | ||
197 | config USB_EHCI_MV | 201 | config USB_EHCI_MV |
198 | bool "EHCI support for Marvell on-chip controller" | 202 | bool "EHCI support for Marvell on-chip controller" |
199 | depends on USB_EHCI_HCD | 203 | depends on USB_EHCI_HCD && (ARCH_PXA || ARCH_MMP) |
200 | select USB_EHCI_ROOT_HUB_TT | 204 | select USB_EHCI_ROOT_HUB_TT |
201 | ---help--- | 205 | ---help--- |
202 | Enables support for Marvell (including PXA and MMP series) on-chip | 206 | Enables support for Marvell (including PXA and MMP series) on-chip |
@@ -218,11 +222,15 @@ config USB_CNS3XXX_EHCI | |||
218 | support. | 222 | support. |
219 | 223 | ||
220 | config USB_EHCI_ATH79 | 224 | config USB_EHCI_ATH79 |
221 | bool "EHCI support for AR7XXX/AR9XXX SoCs" | 225 | bool "EHCI support for AR7XXX/AR9XXX SoCs (DEPRECATED)" |
222 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) | 226 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) |
223 | select USB_EHCI_ROOT_HUB_TT | 227 | select USB_EHCI_ROOT_HUB_TT |
228 | select USB_EHCI_HCD_PLATFORM | ||
224 | default y | 229 | default y |
225 | ---help--- | 230 | ---help--- |
231 | This option is deprecated now and the driver was removed, use | ||
232 | USB_EHCI_HCD_PLATFORM instead. | ||
233 | |||
226 | Enables support for the built-in EHCI controller present | 234 | Enables support for the built-in EHCI controller present |
227 | on the Atheros AR7XXX/AR9XXX SoCs. | 235 | on the Atheros AR7XXX/AR9XXX SoCs. |
228 | 236 | ||
@@ -312,10 +320,14 @@ config USB_OHCI_HCD_OMAP3 | |||
312 | OMAP3 and later chips. | 320 | OMAP3 and later chips. |
313 | 321 | ||
314 | config USB_OHCI_ATH79 | 322 | config USB_OHCI_ATH79 |
315 | bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs" | 323 | bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs (DEPRECATED)" |
316 | depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X) | 324 | depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X) |
325 | select USB_OHCI_HCD_PLATFORM | ||
317 | default y | 326 | default y |
318 | help | 327 | help |
328 | This option is deprecated now and the driver was removed, use | ||
329 | USB_OHCI_HCD_PLATFORM instead. | ||
330 | |||
319 | Enables support for the built-in OHCI controller present on the | 331 | Enables support for the built-in OHCI controller present on the |
320 | Atheros AR71XX/AR7240 SoCs. | 332 | Atheros AR71XX/AR7240 SoCs. |
321 | 333 | ||
@@ -393,6 +405,26 @@ config USB_CNS3XXX_OHCI | |||
393 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. | 405 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. |
394 | It is needed for low-speed USB 1.0 device support. | 406 | It is needed for low-speed USB 1.0 device support. |
395 | 407 | ||
408 | config USB_OHCI_HCD_PLATFORM | ||
409 | bool "Generic OHCI driver for a platform device" | ||
410 | depends on USB_OHCI_HCD && EXPERIMENTAL | ||
411 | default n | ||
412 | ---help--- | ||
413 | Adds an OHCI host driver for a generic platform device, which | ||
414 | provieds a memory space and an irq. | ||
415 | |||
416 | If unsure, say N. | ||
417 | |||
418 | config USB_EHCI_HCD_PLATFORM | ||
419 | bool "Generic EHCI driver for a platform device" | ||
420 | depends on USB_EHCI_HCD && EXPERIMENTAL | ||
421 | default n | ||
422 | ---help--- | ||
423 | Adds an EHCI host driver for a generic platform device, which | ||
424 | provieds a memory space and an irq. | ||
425 | |||
426 | If unsure, say N. | ||
427 | |||
396 | config USB_OHCI_BIG_ENDIAN_DESC | 428 | config USB_OHCI_BIG_ENDIAN_DESC |
397 | bool | 429 | bool |
398 | depends on USB_OHCI_HCD | 430 | depends on USB_OHCI_HCD |
@@ -606,10 +638,3 @@ config USB_OCTEON_OHCI | |||
606 | config USB_OCTEON2_COMMON | 638 | config USB_OCTEON2_COMMON |
607 | bool | 639 | bool |
608 | default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI | 640 | default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI |
609 | |||
610 | config USB_PXA168_EHCI | ||
611 | bool "Marvell PXA168 on-chip EHCI HCD support" | ||
612 | depends on USB_EHCI_HCD && ARCH_MMP | ||
613 | help | ||
614 | Enable support for Marvell PXA168 SoC's on-chip EHCI | ||
615 | host controller | ||
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 7ca290fcb070..0982bcc140bd 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -15,6 +15,10 @@ xhci-hcd-y := xhci.o xhci-mem.o | |||
15 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o | 15 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o |
16 | xhci-hcd-$(CONFIG_PCI) += xhci-pci.o | 16 | xhci-hcd-$(CONFIG_PCI) += xhci-pci.o |
17 | 17 | ||
18 | ifneq ($(CONFIG_USB_XHCI_PLATFORM), ) | ||
19 | xhci-hcd-y += xhci-plat.o | ||
20 | endif | ||
21 | |||
18 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ | 22 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ |
19 | 23 | ||
20 | obj-$(CONFIG_PCI) += pci-quirks.o | 24 | obj-$(CONFIG_PCI) += pci-quirks.o |
diff --git a/drivers/usb/host/ehci-ath79.c b/drivers/usb/host/ehci-ath79.c deleted file mode 100644 index f1424f9bc363..000000000000 --- a/drivers/usb/host/ehci-ath79.c +++ /dev/null | |||
@@ -1,208 +0,0 @@ | |||
1 | /* | ||
2 | * Bus Glue for Atheros AR7XXX/AR9XXX built-in EHCI controller. | ||
3 | * | ||
4 | * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> | ||
5 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> | ||
6 | * | ||
7 | * Parts of this file are based on Atheros' 2.6.15 BSP | ||
8 | * Copyright (C) 2007 Atheros Communications, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published | ||
12 | * by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/platform_device.h> | ||
16 | |||
17 | enum { | ||
18 | EHCI_ATH79_IP_V1 = 0, | ||
19 | EHCI_ATH79_IP_V2, | ||
20 | }; | ||
21 | |||
22 | static const struct platform_device_id ehci_ath79_id_table[] = { | ||
23 | { | ||
24 | .name = "ar71xx-ehci", | ||
25 | .driver_data = EHCI_ATH79_IP_V1, | ||
26 | }, | ||
27 | { | ||
28 | .name = "ar724x-ehci", | ||
29 | .driver_data = EHCI_ATH79_IP_V2, | ||
30 | }, | ||
31 | { | ||
32 | .name = "ar913x-ehci", | ||
33 | .driver_data = EHCI_ATH79_IP_V2, | ||
34 | }, | ||
35 | { | ||
36 | .name = "ar933x-ehci", | ||
37 | .driver_data = EHCI_ATH79_IP_V2, | ||
38 | }, | ||
39 | { | ||
40 | /* terminating entry */ | ||
41 | }, | ||
42 | }; | ||
43 | |||
44 | MODULE_DEVICE_TABLE(platform, ehci_ath79_id_table); | ||
45 | |||
46 | static int ehci_ath79_init(struct usb_hcd *hcd) | ||
47 | { | ||
48 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
49 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
50 | const struct platform_device_id *id; | ||
51 | int ret; | ||
52 | |||
53 | id = platform_get_device_id(pdev); | ||
54 | if (!id) { | ||
55 | dev_err(hcd->self.controller, "missing device id\n"); | ||
56 | return -EINVAL; | ||
57 | } | ||
58 | |||
59 | switch (id->driver_data) { | ||
60 | case EHCI_ATH79_IP_V1: | ||
61 | ehci->has_synopsys_hc_bug = 1; | ||
62 | |||
63 | ehci->caps = hcd->regs; | ||
64 | ehci->regs = hcd->regs + | ||
65 | HC_LENGTH(ehci, | ||
66 | ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
67 | break; | ||
68 | |||
69 | case EHCI_ATH79_IP_V2: | ||
70 | hcd->has_tt = 1; | ||
71 | |||
72 | ehci->caps = hcd->regs + 0x100; | ||
73 | ehci->regs = hcd->regs + 0x100 + | ||
74 | HC_LENGTH(ehci, | ||
75 | ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
76 | break; | ||
77 | |||
78 | default: | ||
79 | BUG(); | ||
80 | } | ||
81 | |||
82 | dbg_hcs_params(ehci, "reset"); | ||
83 | dbg_hcc_params(ehci, "reset"); | ||
84 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
85 | ehci->sbrn = 0x20; | ||
86 | |||
87 | ehci_reset(ehci); | ||
88 | |||
89 | ret = ehci_init(hcd); | ||
90 | if (ret) | ||
91 | return ret; | ||
92 | |||
93 | ehci_port_power(ehci, 0); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static const struct hc_driver ehci_ath79_hc_driver = { | ||
99 | .description = hcd_name, | ||
100 | .product_desc = "Atheros built-in EHCI controller", | ||
101 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
102 | .irq = ehci_irq, | ||
103 | .flags = HCD_MEMORY | HCD_USB2, | ||
104 | |||
105 | .reset = ehci_ath79_init, | ||
106 | .start = ehci_run, | ||
107 | .stop = ehci_stop, | ||
108 | .shutdown = ehci_shutdown, | ||
109 | |||
110 | .urb_enqueue = ehci_urb_enqueue, | ||
111 | .urb_dequeue = ehci_urb_dequeue, | ||
112 | .endpoint_disable = ehci_endpoint_disable, | ||
113 | .endpoint_reset = ehci_endpoint_reset, | ||
114 | |||
115 | .get_frame_number = ehci_get_frame, | ||
116 | |||
117 | .hub_status_data = ehci_hub_status_data, | ||
118 | .hub_control = ehci_hub_control, | ||
119 | |||
120 | .relinquish_port = ehci_relinquish_port, | ||
121 | .port_handed_over = ehci_port_handed_over, | ||
122 | |||
123 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
124 | }; | ||
125 | |||
126 | static int ehci_ath79_probe(struct platform_device *pdev) | ||
127 | { | ||
128 | struct usb_hcd *hcd; | ||
129 | struct resource *res; | ||
130 | int irq; | ||
131 | int ret; | ||
132 | |||
133 | if (usb_disabled()) | ||
134 | return -ENODEV; | ||
135 | |||
136 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
137 | if (!res) { | ||
138 | dev_dbg(&pdev->dev, "no IRQ specified\n"); | ||
139 | return -ENODEV; | ||
140 | } | ||
141 | irq = res->start; | ||
142 | |||
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
144 | if (!res) { | ||
145 | dev_dbg(&pdev->dev, "no base address specified\n"); | ||
146 | return -ENODEV; | ||
147 | } | ||
148 | |||
149 | hcd = usb_create_hcd(&ehci_ath79_hc_driver, &pdev->dev, | ||
150 | dev_name(&pdev->dev)); | ||
151 | if (!hcd) | ||
152 | return -ENOMEM; | ||
153 | |||
154 | hcd->rsrc_start = res->start; | ||
155 | hcd->rsrc_len = resource_size(res); | ||
156 | |||
157 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
158 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
159 | ret = -EBUSY; | ||
160 | goto err_put_hcd; | ||
161 | } | ||
162 | |||
163 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
164 | if (!hcd->regs) { | ||
165 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
166 | ret = -EFAULT; | ||
167 | goto err_release_region; | ||
168 | } | ||
169 | |||
170 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
171 | if (ret) | ||
172 | goto err_iounmap; | ||
173 | |||
174 | return 0; | ||
175 | |||
176 | err_iounmap: | ||
177 | iounmap(hcd->regs); | ||
178 | |||
179 | err_release_region: | ||
180 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
181 | err_put_hcd: | ||
182 | usb_put_hcd(hcd); | ||
183 | return ret; | ||
184 | } | ||
185 | |||
186 | static int ehci_ath79_remove(struct platform_device *pdev) | ||
187 | { | ||
188 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
189 | |||
190 | usb_remove_hcd(hcd); | ||
191 | iounmap(hcd->regs); | ||
192 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
193 | usb_put_hcd(hcd); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static struct platform_driver ehci_ath79_driver = { | ||
199 | .probe = ehci_ath79_probe, | ||
200 | .remove = ehci_ath79_remove, | ||
201 | .id_table = ehci_ath79_id_table, | ||
202 | .driver = { | ||
203 | .owner = THIS_MODULE, | ||
204 | .name = "ath79-ehci", | ||
205 | } | ||
206 | }; | ||
207 | |||
208 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ehci"); | ||
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index d6d74d2e09f4..fd9109d7eb0e 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -107,7 +107,7 @@ static void dbg_hcc_params (struct ehci_hcd *ehci, char *label) | |||
107 | HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "", | 107 | HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "", |
108 | HCC_HW_PREFETCH(params) ? " hw prefetch" : "", | 108 | HCC_HW_PREFETCH(params) ? " hw prefetch" : "", |
109 | HCC_32FRAME_PERIODIC_LIST(params) ? | 109 | HCC_32FRAME_PERIODIC_LIST(params) ? |
110 | " 32 peridic list" : ""); | 110 | " 32 periodic list" : ""); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | #else | 113 | #else |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index b556a72264d1..3e7345172e03 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -142,12 +142,12 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, | |||
142 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { | 142 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { |
143 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 143 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
144 | 144 | ||
145 | ehci->transceiver = otg_get_transceiver(); | 145 | ehci->transceiver = usb_get_transceiver(); |
146 | dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", | 146 | dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", |
147 | hcd, ehci, ehci->transceiver); | 147 | hcd, ehci, ehci->transceiver); |
148 | 148 | ||
149 | if (ehci->transceiver) { | 149 | if (ehci->transceiver) { |
150 | retval = otg_set_host(ehci->transceiver, | 150 | retval = otg_set_host(ehci->transceiver->otg, |
151 | &ehci_to_hcd(ehci)->self); | 151 | &ehci_to_hcd(ehci)->self); |
152 | if (retval) { | 152 | if (retval) { |
153 | if (ehci->transceiver) | 153 | if (ehci->transceiver) |
@@ -194,7 +194,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd, | |||
194 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 194 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
195 | 195 | ||
196 | if (ehci->transceiver) { | 196 | if (ehci->transceiver) { |
197 | otg_set_host(ehci->transceiver, NULL); | 197 | otg_set_host(ehci->transceiver->otg, NULL); |
198 | put_device(ehci->transceiver->dev); | 198 | put_device(ehci->transceiver->dev); |
199 | } | 199 | } |
200 | 200 | ||
@@ -216,6 +216,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci, | |||
216 | unsigned int port_offset) | 216 | unsigned int port_offset) |
217 | { | 217 | { |
218 | u32 portsc; | 218 | u32 portsc; |
219 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
220 | void __iomem *non_ehci = hcd->regs; | ||
219 | 221 | ||
220 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); | 222 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); |
221 | portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW); | 223 | portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW); |
@@ -231,6 +233,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci, | |||
231 | portsc |= PORT_PTS_PTW; | 233 | portsc |= PORT_PTS_PTW; |
232 | /* fall through */ | 234 | /* fall through */ |
233 | case FSL_USB2_PHY_UTMI: | 235 | case FSL_USB2_PHY_UTMI: |
236 | /* enable UTMI PHY */ | ||
237 | setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN); | ||
234 | portsc |= PORT_PTS_UTMI; | 238 | portsc |= PORT_PTS_UTMI; |
235 | break; | 239 | break; |
236 | case FSL_USB2_PHY_NONE: | 240 | case FSL_USB2_PHY_NONE: |
@@ -252,21 +256,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | |||
252 | if (pdata->have_sysif_regs) { | 256 | if (pdata->have_sysif_regs) { |
253 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); | 257 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); |
254 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); | 258 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); |
255 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b); | ||
256 | } | ||
257 | 259 | ||
258 | #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) | 260 | /* |
259 | /* | 261 | * Turn on cache snooping hardware, since some PowerPC platforms |
260 | * Turn on cache snooping hardware, since some PowerPC platforms | 262 | * wholly rely on hardware to deal with cache coherent |
261 | * wholly rely on hardware to deal with cache coherent | 263 | */ |
262 | */ | ||
263 | 264 | ||
264 | /* Setup Snooping for all the 4GB space */ | 265 | /* Setup Snooping for all the 4GB space */ |
265 | /* SNOOP1 starts from 0x0, size 2G */ | 266 | /* SNOOP1 starts from 0x0, size 2G */ |
266 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB); | 267 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB); |
267 | /* SNOOP2 starts from 0x80000000, size 2G */ | 268 | /* SNOOP2 starts from 0x80000000, size 2G */ |
268 | out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB); | 269 | out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB); |
269 | #endif | 270 | } |
270 | 271 | ||
271 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || | 272 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || |
272 | (pdata->operating_mode == FSL_USB2_DR_OTG)) | 273 | (pdata->operating_mode == FSL_USB2_DR_OTG)) |
@@ -316,7 +317,9 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
316 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 317 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
317 | int retval; | 318 | int retval; |
318 | struct fsl_usb2_platform_data *pdata; | 319 | struct fsl_usb2_platform_data *pdata; |
320 | struct device *dev; | ||
319 | 321 | ||
322 | dev = hcd->self.controller; | ||
320 | pdata = hcd->self.controller->platform_data; | 323 | pdata = hcd->self.controller->platform_data; |
321 | ehci->big_endian_desc = pdata->big_endian_desc; | 324 | ehci->big_endian_desc = pdata->big_endian_desc; |
322 | ehci->big_endian_mmio = pdata->big_endian_mmio; | 325 | ehci->big_endian_mmio = pdata->big_endian_mmio; |
@@ -346,6 +349,16 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
346 | 349 | ||
347 | ehci_reset(ehci); | 350 | ehci_reset(ehci); |
348 | 351 | ||
352 | if (of_device_is_compatible(dev->parent->of_node, | ||
353 | "fsl,mpc5121-usb2-dr")) { | ||
354 | /* | ||
355 | * set SBUSCFG:AHBBRST so that control msgs don't | ||
356 | * fail when doing heavy PATA writes. | ||
357 | */ | ||
358 | ehci_writel(ehci, SBUSCFG_INCR8, | ||
359 | hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
360 | } | ||
361 | |||
349 | retval = ehci_fsl_reinit(ehci); | 362 | retval = ehci_fsl_reinit(ehci); |
350 | return retval; | 363 | return retval; |
351 | } | 364 | } |
@@ -469,6 +482,8 @@ static int ehci_fsl_mpc512x_drv_resume(struct device *dev) | |||
469 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, | 482 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, |
470 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); | 483 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); |
471 | 484 | ||
485 | ehci_writel(ehci, SBUSCFG_INCR8, hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
486 | |||
472 | /* restore EHCI registers */ | 487 | /* restore EHCI registers */ |
473 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); | 488 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); |
474 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); | 489 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); |
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h index 491806221165..863fb0c080d7 100644 --- a/drivers/usb/host/ehci-fsl.h +++ b/drivers/usb/host/ehci-fsl.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #define _EHCI_FSL_H | 19 | #define _EHCI_FSL_H |
20 | 20 | ||
21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ | 21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ |
22 | #define FSL_SOC_USB_SBUSCFG 0x90 | ||
23 | #define SBUSCFG_INCR8 0x02 /* INCR8, specified */ | ||
22 | #define FSL_SOC_USB_ULPIVP 0x170 | 24 | #define FSL_SOC_USB_ULPIVP 0x170 |
23 | #define FSL_SOC_USB_PORTSC1 0x184 | 25 | #define FSL_SOC_USB_PORTSC1 0x184 |
24 | #define PORT_PTS_MSK (3<<30) | 26 | #define PORT_PTS_MSK (3<<30) |
@@ -45,5 +47,7 @@ | |||
45 | #define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */ | 47 | #define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */ |
46 | #define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */ | 48 | #define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */ |
47 | #define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */ | 49 | #define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */ |
50 | #define CTRL_UTMI_PHY_EN (1<<9) | ||
51 | #define CTRL_PHY_CLK_VALID (1 << 17) | ||
48 | #define SNOOP_SIZE_2GB 0x1e | 52 | #define SNOOP_SIZE_2GB 0x1e |
49 | #endif /* _EHCI_FSL_H */ | 53 | #endif /* _EHCI_FSL_H */ |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a007a9fe0f87..aede6374e4b6 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1351,21 +1351,11 @@ MODULE_LICENSE ("GPL"); | |||
1351 | #define PLATFORM_DRIVER s5p_ehci_driver | 1351 | #define PLATFORM_DRIVER s5p_ehci_driver |
1352 | #endif | 1352 | #endif |
1353 | 1353 | ||
1354 | #ifdef CONFIG_USB_EHCI_ATH79 | ||
1355 | #include "ehci-ath79.c" | ||
1356 | #define PLATFORM_DRIVER ehci_ath79_driver | ||
1357 | #endif | ||
1358 | |||
1359 | #ifdef CONFIG_SPARC_LEON | 1354 | #ifdef CONFIG_SPARC_LEON |
1360 | #include "ehci-grlib.c" | 1355 | #include "ehci-grlib.c" |
1361 | #define PLATFORM_DRIVER ehci_grlib_driver | 1356 | #define PLATFORM_DRIVER ehci_grlib_driver |
1362 | #endif | 1357 | #endif |
1363 | 1358 | ||
1364 | #ifdef CONFIG_USB_PXA168_EHCI | ||
1365 | #include "ehci-pxa168.c" | ||
1366 | #define PLATFORM_DRIVER ehci_pxa168_driver | ||
1367 | #endif | ||
1368 | |||
1369 | #ifdef CONFIG_CPU_XLR | 1359 | #ifdef CONFIG_CPU_XLR |
1370 | #include "ehci-xls.c" | 1360 | #include "ehci-xls.c" |
1371 | #define PLATFORM_DRIVER ehci_xls_driver | 1361 | #define PLATFORM_DRIVER ehci_xls_driver |
@@ -1376,6 +1366,16 @@ MODULE_LICENSE ("GPL"); | |||
1376 | #define PLATFORM_DRIVER ehci_mv_driver | 1366 | #define PLATFORM_DRIVER ehci_mv_driver |
1377 | #endif | 1367 | #endif |
1378 | 1368 | ||
1369 | #ifdef CONFIG_MACH_LOONGSON1 | ||
1370 | #include "ehci-ls1x.c" | ||
1371 | #define PLATFORM_DRIVER ehci_ls1x_driver | ||
1372 | #endif | ||
1373 | |||
1374 | #ifdef CONFIG_USB_EHCI_HCD_PLATFORM | ||
1375 | #include "ehci-platform.c" | ||
1376 | #define PLATFORM_DRIVER ehci_platform_driver | ||
1377 | #endif | ||
1378 | |||
1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1381 | !defined(XILINX_OF_PLATFORM_DRIVER) | 1381 | !defined(XILINX_OF_PLATFORM_DRIVER) |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 77bbb2357e47..256fbd42e48c 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -107,7 +107,7 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
107 | ehci->owned_ports = 0; | 107 | ehci->owned_ports = 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static int ehci_port_change(struct ehci_hcd *ehci) | 110 | static int __maybe_unused ehci_port_change(struct ehci_hcd *ehci) |
111 | { | 111 | { |
112 | int i = HCS_N_PORTS(ehci->hcs_params); | 112 | int i = HCS_N_PORTS(ehci->hcs_params); |
113 | 113 | ||
@@ -727,7 +727,7 @@ static int ehci_hub_control ( | |||
727 | #ifdef CONFIG_USB_OTG | 727 | #ifdef CONFIG_USB_OTG |
728 | if ((hcd->self.otg_port == (wIndex + 1)) | 728 | if ((hcd->self.otg_port == (wIndex + 1)) |
729 | && hcd->self.b_hnp_enable) { | 729 | && hcd->self.b_hnp_enable) { |
730 | otg_start_hnp(ehci->transceiver); | 730 | otg_start_hnp(ehci->transceiver->otg); |
731 | break; | 731 | break; |
732 | } | 732 | } |
733 | #endif | 733 | #endif |
@@ -1076,7 +1076,8 @@ error_exit: | |||
1076 | return retval; | 1076 | return retval; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | 1079 | static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, |
1080 | int portnum) | ||
1080 | { | 1081 | { |
1081 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1082 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1082 | 1083 | ||
@@ -1085,7 +1086,8 @@ static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | |||
1085 | set_owner(ehci, --portnum, PORT_OWNER); | 1086 | set_owner(ehci, --portnum, PORT_OWNER); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum) | 1089 | static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, |
1090 | int portnum) | ||
1089 | { | 1091 | { |
1090 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1092 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1091 | u32 __iomem *reg; | 1093 | u32 __iomem *reg; |
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c new file mode 100644 index 000000000000..a283e59709d6 --- /dev/null +++ b/drivers/usb/host/ehci-ls1x.c | |||
@@ -0,0 +1,159 @@ | |||
1 | /* | ||
2 | * Bus Glue for Loongson LS1X built-in EHCI controller. | ||
3 | * | ||
4 | * Copyright (c) 2012 Zhang, Keguang <keguang.zhang@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | |||
12 | #include <linux/platform_device.h> | ||
13 | |||
14 | static int ehci_ls1x_reset(struct usb_hcd *hcd) | ||
15 | { | ||
16 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
17 | int ret; | ||
18 | |||
19 | ehci->caps = hcd->regs; | ||
20 | |||
21 | ret = ehci_setup(hcd); | ||
22 | if (ret) | ||
23 | return ret; | ||
24 | |||
25 | ehci_port_power(ehci, 0); | ||
26 | |||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | static const struct hc_driver ehci_ls1x_hc_driver = { | ||
31 | .description = hcd_name, | ||
32 | .product_desc = "LOONGSON1 EHCI", | ||
33 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
34 | |||
35 | /* | ||
36 | * generic hardware linkage | ||
37 | */ | ||
38 | .irq = ehci_irq, | ||
39 | .flags = HCD_MEMORY | HCD_USB2, | ||
40 | |||
41 | /* | ||
42 | * basic lifecycle operations | ||
43 | */ | ||
44 | .reset = ehci_ls1x_reset, | ||
45 | .start = ehci_run, | ||
46 | .stop = ehci_stop, | ||
47 | .shutdown = ehci_shutdown, | ||
48 | |||
49 | /* | ||
50 | * managing i/o requests and associated device resources | ||
51 | */ | ||
52 | .urb_enqueue = ehci_urb_enqueue, | ||
53 | .urb_dequeue = ehci_urb_dequeue, | ||
54 | .endpoint_disable = ehci_endpoint_disable, | ||
55 | .endpoint_reset = ehci_endpoint_reset, | ||
56 | |||
57 | /* | ||
58 | * scheduling support | ||
59 | */ | ||
60 | .get_frame_number = ehci_get_frame, | ||
61 | |||
62 | /* | ||
63 | * root hub support | ||
64 | */ | ||
65 | .hub_status_data = ehci_hub_status_data, | ||
66 | .hub_control = ehci_hub_control, | ||
67 | .relinquish_port = ehci_relinquish_port, | ||
68 | .port_handed_over = ehci_port_handed_over, | ||
69 | |||
70 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
71 | }; | ||
72 | |||
73 | static int ehci_hcd_ls1x_probe(struct platform_device *pdev) | ||
74 | { | ||
75 | struct usb_hcd *hcd; | ||
76 | struct resource *res; | ||
77 | int irq; | ||
78 | int ret; | ||
79 | |||
80 | pr_debug("initializing loongson1 ehci USB Controller\n"); | ||
81 | |||
82 | if (usb_disabled()) | ||
83 | return -ENODEV; | ||
84 | |||
85 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
86 | if (!res) { | ||
87 | dev_err(&pdev->dev, | ||
88 | "Found HC with no IRQ. Check %s setup!\n", | ||
89 | dev_name(&pdev->dev)); | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | irq = res->start; | ||
93 | |||
94 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
95 | if (!res) { | ||
96 | dev_err(&pdev->dev, | ||
97 | "Found HC with no register addr. Check %s setup!\n", | ||
98 | dev_name(&pdev->dev)); | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | |||
102 | hcd = usb_create_hcd(&ehci_ls1x_hc_driver, &pdev->dev, | ||
103 | dev_name(&pdev->dev)); | ||
104 | if (!hcd) | ||
105 | return -ENOMEM; | ||
106 | hcd->rsrc_start = res->start; | ||
107 | hcd->rsrc_len = resource_size(res); | ||
108 | |||
109 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
110 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
111 | ret = -EBUSY; | ||
112 | goto err_put_hcd; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | ||
117 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
118 | ret = -EFAULT; | ||
119 | goto err_release_region; | ||
120 | } | ||
121 | |||
122 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
123 | if (ret) | ||
124 | goto err_iounmap; | ||
125 | |||
126 | return ret; | ||
127 | |||
128 | err_iounmap: | ||
129 | iounmap(hcd->regs); | ||
130 | err_release_region: | ||
131 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
132 | err_put_hcd: | ||
133 | usb_put_hcd(hcd); | ||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | static int ehci_hcd_ls1x_remove(struct platform_device *pdev) | ||
138 | { | ||
139 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
140 | |||
141 | usb_remove_hcd(hcd); | ||
142 | iounmap(hcd->regs); | ||
143 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
144 | usb_put_hcd(hcd); | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static struct platform_driver ehci_ls1x_driver = { | ||
150 | .probe = ehci_hcd_ls1x_probe, | ||
151 | .remove = ehci_hcd_ls1x_remove, | ||
152 | .shutdown = usb_hcd_platform_shutdown, | ||
153 | .driver = { | ||
154 | .name = "ls1x-ehci", | ||
155 | .owner = THIS_MODULE, | ||
156 | }, | ||
157 | }; | ||
158 | |||
159 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci"); | ||
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 592d5f76803e..9803a55fd5f4 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | #define MSM_USB_BASE (hcd->regs) | 33 | #define MSM_USB_BASE (hcd->regs) |
34 | 34 | ||
35 | static struct otg_transceiver *otg; | 35 | static struct usb_phy *phy; |
36 | 36 | ||
37 | static int ehci_msm_reset(struct usb_hcd *hcd) | 37 | static int ehci_msm_reset(struct usb_hcd *hcd) |
38 | { | 38 | { |
@@ -145,14 +145,14 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
145 | * powering up VBUS, mapping of registers address space and power | 145 | * powering up VBUS, mapping of registers address space and power |
146 | * management. | 146 | * management. |
147 | */ | 147 | */ |
148 | otg = otg_get_transceiver(); | 148 | phy = usb_get_transceiver(); |
149 | if (!otg) { | 149 | if (!phy) { |
150 | dev_err(&pdev->dev, "unable to find transceiver\n"); | 150 | dev_err(&pdev->dev, "unable to find transceiver\n"); |
151 | ret = -ENODEV; | 151 | ret = -ENODEV; |
152 | goto unmap; | 152 | goto unmap; |
153 | } | 153 | } |
154 | 154 | ||
155 | ret = otg_set_host(otg, &hcd->self); | 155 | ret = otg_set_host(phy->otg, &hcd->self); |
156 | if (ret < 0) { | 156 | if (ret < 0) { |
157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); | 157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); |
158 | goto put_transceiver; | 158 | goto put_transceiver; |
@@ -169,7 +169,7 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
169 | return 0; | 169 | return 0; |
170 | 170 | ||
171 | put_transceiver: | 171 | put_transceiver: |
172 | otg_put_transceiver(otg); | 172 | usb_put_transceiver(phy); |
173 | unmap: | 173 | unmap: |
174 | iounmap(hcd->regs); | 174 | iounmap(hcd->regs); |
175 | put_hcd: | 175 | put_hcd: |
@@ -186,8 +186,8 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev) | |||
186 | pm_runtime_disable(&pdev->dev); | 186 | pm_runtime_disable(&pdev->dev); |
187 | pm_runtime_set_suspended(&pdev->dev); | 187 | pm_runtime_set_suspended(&pdev->dev); |
188 | 188 | ||
189 | otg_set_host(otg, NULL); | 189 | otg_set_host(phy->otg, NULL); |
190 | otg_put_transceiver(otg); | 190 | usb_put_transceiver(phy); |
191 | 191 | ||
192 | usb_put_hcd(hcd); | 192 | usb_put_hcd(hcd); |
193 | 193 | ||
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index 52a604fb9321..a936bbcff8f4 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c | |||
@@ -28,7 +28,7 @@ struct ehci_hcd_mv { | |||
28 | void __iomem *cap_regs; | 28 | void __iomem *cap_regs; |
29 | void __iomem *op_regs; | 29 | void __iomem *op_regs; |
30 | 30 | ||
31 | struct otg_transceiver *otg; | 31 | struct usb_phy *otg; |
32 | 32 | ||
33 | struct mv_usb_platform_data *pdata; | 33 | struct mv_usb_platform_data *pdata; |
34 | 34 | ||
@@ -253,7 +253,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
253 | ehci_mv->mode = pdata->mode; | 253 | ehci_mv->mode = pdata->mode; |
254 | if (ehci_mv->mode == MV_USB_MODE_OTG) { | 254 | if (ehci_mv->mode == MV_USB_MODE_OTG) { |
255 | #ifdef CONFIG_USB_OTG_UTILS | 255 | #ifdef CONFIG_USB_OTG_UTILS |
256 | ehci_mv->otg = otg_get_transceiver(); | 256 | ehci_mv->otg = usb_get_transceiver(); |
257 | if (!ehci_mv->otg) { | 257 | if (!ehci_mv->otg) { |
258 | dev_err(&pdev->dev, | 258 | dev_err(&pdev->dev, |
259 | "unable to find transceiver\n"); | 259 | "unable to find transceiver\n"); |
@@ -261,7 +261,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
261 | goto err_disable_clk; | 261 | goto err_disable_clk; |
262 | } | 262 | } |
263 | 263 | ||
264 | retval = otg_set_host(ehci_mv->otg, &hcd->self); | 264 | retval = otg_set_host(ehci_mv->otg->otg, &hcd->self); |
265 | if (retval < 0) { | 265 | if (retval < 0) { |
266 | dev_err(&pdev->dev, | 266 | dev_err(&pdev->dev, |
267 | "unable to register with transceiver\n"); | 267 | "unable to register with transceiver\n"); |
@@ -303,7 +303,7 @@ err_set_vbus: | |||
303 | #ifdef CONFIG_USB_OTG_UTILS | 303 | #ifdef CONFIG_USB_OTG_UTILS |
304 | err_put_transceiver: | 304 | err_put_transceiver: |
305 | if (ehci_mv->otg) | 305 | if (ehci_mv->otg) |
306 | otg_put_transceiver(ehci_mv->otg); | 306 | usb_put_transceiver(ehci_mv->otg); |
307 | #endif | 307 | #endif |
308 | err_disable_clk: | 308 | err_disable_clk: |
309 | mv_ehci_disable(ehci_mv); | 309 | mv_ehci_disable(ehci_mv); |
@@ -332,8 +332,8 @@ static int mv_ehci_remove(struct platform_device *pdev) | |||
332 | usb_remove_hcd(hcd); | 332 | usb_remove_hcd(hcd); |
333 | 333 | ||
334 | if (ehci_mv->otg) { | 334 | if (ehci_mv->otg) { |
335 | otg_set_host(ehci_mv->otg, NULL); | 335 | otg_set_host(ehci_mv->otg->otg, NULL); |
336 | otg_put_transceiver(ehci_mv->otg); | 336 | usb_put_transceiver(ehci_mv->otg); |
337 | } | 337 | } |
338 | 338 | ||
339 | if (ehci_mv->mode == MV_USB_MODE_HOST) { | 339 | if (ehci_mv->mode == MV_USB_MODE_HOST) { |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 55978fcfa4b2..a797d51ecbe8 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -220,13 +220,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
220 | /* Initialize the transceiver */ | 220 | /* Initialize the transceiver */ |
221 | if (pdata->otg) { | 221 | if (pdata->otg) { |
222 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; | 222 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; |
223 | ret = otg_init(pdata->otg); | 223 | ret = usb_phy_init(pdata->otg); |
224 | if (ret) { | 224 | if (ret) { |
225 | dev_err(dev, "unable to init transceiver, probably missing\n"); | 225 | dev_err(dev, "unable to init transceiver, probably missing\n"); |
226 | ret = -ENODEV; | 226 | ret = -ENODEV; |
227 | goto err_add; | 227 | goto err_add; |
228 | } | 228 | } |
229 | ret = otg_set_vbus(pdata->otg, 1); | 229 | ret = otg_set_vbus(pdata->otg->otg, 1); |
230 | if (ret) { | 230 | if (ret) { |
231 | dev_err(dev, "unable to enable vbus on transceiver\n"); | 231 | dev_err(dev, "unable to enable vbus on transceiver\n"); |
232 | goto err_add; | 232 | goto err_add; |
@@ -247,9 +247,11 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
247 | * It's in violation of USB specs | 247 | * It's in violation of USB specs |
248 | */ | 248 | */ |
249 | if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) { | 249 | if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) { |
250 | flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL); | 250 | flags = usb_phy_io_read(pdata->otg, |
251 | ULPI_OTG_CTRL); | ||
251 | flags |= ULPI_OTG_CTRL_CHRGVBUS; | 252 | flags |= ULPI_OTG_CTRL_CHRGVBUS; |
252 | ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL); | 253 | ret = usb_phy_io_write(pdata->otg, flags, |
254 | ULPI_OTG_CTRL); | ||
253 | if (ret) { | 255 | if (ret) { |
254 | dev_err(dev, "unable to set CHRVBUS\n"); | 256 | dev_err(dev, "unable to set CHRVBUS\n"); |
255 | goto err_add; | 257 | goto err_add; |
@@ -297,7 +299,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) | |||
297 | pdata->exit(pdev); | 299 | pdata->exit(pdev); |
298 | 300 | ||
299 | if (pdata->otg) | 301 | if (pdata->otg) |
300 | otg_shutdown(pdata->otg); | 302 | usb_phy_shutdown(pdata->otg); |
301 | 303 | ||
302 | usb_remove_hcd(hcd); | 304 | usb_remove_hcd(hcd); |
303 | iounmap(hcd->regs); | 305 | iounmap(hcd->regs); |
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c new file mode 100644 index 000000000000..d238b4e24bb6 --- /dev/null +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Generic platform ehci driver | ||
3 | * | ||
4 | * Copyright 2007 Steven Brown <sbrown@cortland.com> | ||
5 | * Copyright 2010-2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
6 | * | ||
7 | * Derived from the ohci-ssb driver | ||
8 | * Copyright 2007 Michael Buesch <m@bues.ch> | ||
9 | * | ||
10 | * Derived from the EHCI-PCI driver | ||
11 | * Copyright (c) 2000-2004 by David Brownell | ||
12 | * | ||
13 | * Derived from the ohci-pci driver | ||
14 | * Copyright 1999 Roman Weissgaerber | ||
15 | * Copyright 2000-2002 David Brownell | ||
16 | * Copyright 1999 Linus Torvalds | ||
17 | * Copyright 1999 Gregory P. Smith | ||
18 | * | ||
19 | * Licensed under the GNU/GPL. See COPYING for details. | ||
20 | */ | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/usb/ehci_pdriver.h> | ||
23 | |||
24 | static int ehci_platform_reset(struct usb_hcd *hcd) | ||
25 | { | ||
26 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
27 | struct usb_ehci_pdata *pdata = pdev->dev.platform_data; | ||
28 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
29 | int retval; | ||
30 | |||
31 | hcd->has_tt = pdata->has_tt; | ||
32 | ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug; | ||
33 | ehci->big_endian_desc = pdata->big_endian_desc; | ||
34 | ehci->big_endian_mmio = pdata->big_endian_mmio; | ||
35 | |||
36 | ehci->caps = hcd->regs + pdata->caps_offset; | ||
37 | retval = ehci_setup(hcd); | ||
38 | if (retval) | ||
39 | return retval; | ||
40 | |||
41 | if (pdata->port_power_on) | ||
42 | ehci_port_power(ehci, 1); | ||
43 | if (pdata->port_power_off) | ||
44 | ehci_port_power(ehci, 0); | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static const struct hc_driver ehci_platform_hc_driver = { | ||
50 | .description = hcd_name, | ||
51 | .product_desc = "Generic Platform EHCI Controller", | ||
52 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
53 | |||
54 | .irq = ehci_irq, | ||
55 | .flags = HCD_MEMORY | HCD_USB2, | ||
56 | |||
57 | .reset = ehci_platform_reset, | ||
58 | .start = ehci_run, | ||
59 | .stop = ehci_stop, | ||
60 | .shutdown = ehci_shutdown, | ||
61 | |||
62 | .urb_enqueue = ehci_urb_enqueue, | ||
63 | .urb_dequeue = ehci_urb_dequeue, | ||
64 | .endpoint_disable = ehci_endpoint_disable, | ||
65 | .endpoint_reset = ehci_endpoint_reset, | ||
66 | |||
67 | .get_frame_number = ehci_get_frame, | ||
68 | |||
69 | .hub_status_data = ehci_hub_status_data, | ||
70 | .hub_control = ehci_hub_control, | ||
71 | #if defined(CONFIG_PM) | ||
72 | .bus_suspend = ehci_bus_suspend, | ||
73 | .bus_resume = ehci_bus_resume, | ||
74 | #endif | ||
75 | .relinquish_port = ehci_relinquish_port, | ||
76 | .port_handed_over = ehci_port_handed_over, | ||
77 | |||
78 | .update_device = ehci_update_device, | ||
79 | |||
80 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
81 | }; | ||
82 | |||
83 | static int __devinit ehci_platform_probe(struct platform_device *dev) | ||
84 | { | ||
85 | struct usb_hcd *hcd; | ||
86 | struct resource *res_mem; | ||
87 | int irq; | ||
88 | int err = -ENOMEM; | ||
89 | |||
90 | BUG_ON(!dev->dev.platform_data); | ||
91 | |||
92 | if (usb_disabled()) | ||
93 | return -ENODEV; | ||
94 | |||
95 | irq = platform_get_irq(dev, 0); | ||
96 | if (irq < 0) { | ||
97 | pr_err("no irq provieded"); | ||
98 | return irq; | ||
99 | } | ||
100 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
101 | if (!res_mem) { | ||
102 | pr_err("no memory recourse provieded"); | ||
103 | return -ENXIO; | ||
104 | } | ||
105 | |||
106 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, | ||
107 | dev_name(&dev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res_mem->start; | ||
112 | hcd->rsrc_len = resource_size(res_mem); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
115 | pr_err("controller already in use"); | ||
116 | err = -EBUSY; | ||
117 | goto err_put_hcd; | ||
118 | } | ||
119 | |||
120 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
121 | if (!hcd->regs) | ||
122 | goto err_release_region; | ||
123 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
124 | if (err) | ||
125 | goto err_iounmap; | ||
126 | |||
127 | platform_set_drvdata(dev, hcd); | ||
128 | |||
129 | return err; | ||
130 | |||
131 | err_iounmap: | ||
132 | iounmap(hcd->regs); | ||
133 | err_release_region: | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | err_put_hcd: | ||
136 | usb_put_hcd(hcd); | ||
137 | return err; | ||
138 | } | ||
139 | |||
140 | static int __devexit ehci_platform_remove(struct platform_device *dev) | ||
141 | { | ||
142 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
143 | |||
144 | usb_remove_hcd(hcd); | ||
145 | iounmap(hcd->regs); | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | usb_put_hcd(hcd); | ||
148 | platform_set_drvdata(dev, NULL); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | #ifdef CONFIG_PM | ||
154 | |||
155 | static int ehci_platform_suspend(struct device *dev) | ||
156 | { | ||
157 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
158 | bool wakeup = device_may_wakeup(dev); | ||
159 | |||
160 | ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd), wakeup); | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static int ehci_platform_resume(struct device *dev) | ||
165 | { | ||
166 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
167 | |||
168 | ehci_prepare_ports_for_controller_resume(hcd_to_ehci(hcd)); | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | #else /* !CONFIG_PM */ | ||
173 | #define ehci_platform_suspend NULL | ||
174 | #define ehci_platform_resume NULL | ||
175 | #endif /* CONFIG_PM */ | ||
176 | |||
177 | static const struct platform_device_id ehci_platform_table[] = { | ||
178 | { "ehci-platform", 0 }, | ||
179 | { } | ||
180 | }; | ||
181 | MODULE_DEVICE_TABLE(platform, ehci_platform_table); | ||
182 | |||
183 | static const struct dev_pm_ops ehci_platform_pm_ops = { | ||
184 | .suspend = ehci_platform_suspend, | ||
185 | .resume = ehci_platform_resume, | ||
186 | }; | ||
187 | |||
188 | static struct platform_driver ehci_platform_driver = { | ||
189 | .id_table = ehci_platform_table, | ||
190 | .probe = ehci_platform_probe, | ||
191 | .remove = __devexit_p(ehci_platform_remove), | ||
192 | .shutdown = usb_hcd_platform_shutdown, | ||
193 | .driver = { | ||
194 | .owner = THIS_MODULE, | ||
195 | .name = "ehci-platform", | ||
196 | .pm = &ehci_platform_pm_ops, | ||
197 | } | ||
198 | }; | ||
diff --git a/drivers/usb/host/ehci-pxa168.c b/drivers/usb/host/ehci-pxa168.c deleted file mode 100644 index 8d0e7a22e711..000000000000 --- a/drivers/usb/host/ehci-pxa168.c +++ /dev/null | |||
@@ -1,363 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/usb/host/ehci-pxa168.c | ||
3 | * | ||
4 | * Tanmay Upadhyay <tanmay.upadhyay@einfochips.com> | ||
5 | * | ||
6 | * Based on drivers/usb/host/ehci-orion.c | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public | ||
9 | * License version 2. This program is licensed "as is" without any | ||
10 | * warranty of any kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <mach/pxa168.h> | ||
18 | |||
19 | #define USB_PHY_CTRL_REG 0x4 | ||
20 | #define USB_PHY_PLL_REG 0x8 | ||
21 | #define USB_PHY_TX_REG 0xc | ||
22 | |||
23 | #define FBDIV_SHIFT 4 | ||
24 | |||
25 | #define ICP_SHIFT 12 | ||
26 | #define ICP_15 2 | ||
27 | #define ICP_20 3 | ||
28 | #define ICP_25 4 | ||
29 | |||
30 | #define KVCO_SHIFT 15 | ||
31 | |||
32 | #define PLLCALI12_SHIFT 25 | ||
33 | #define CALI12_VDD 0 | ||
34 | #define CALI12_09 1 | ||
35 | #define CALI12_10 2 | ||
36 | #define CALI12_11 3 | ||
37 | |||
38 | #define PLLVDD12_SHIFT 27 | ||
39 | #define VDD12_VDD 0 | ||
40 | #define VDD12_10 1 | ||
41 | #define VDD12_11 2 | ||
42 | #define VDD12_12 3 | ||
43 | |||
44 | #define PLLVDD18_SHIFT 29 | ||
45 | #define VDD18_19 0 | ||
46 | #define VDD18_20 1 | ||
47 | #define VDD18_21 2 | ||
48 | #define VDD18_22 3 | ||
49 | |||
50 | |||
51 | #define PLL_READY (1 << 23) | ||
52 | #define VCOCAL_START (1 << 21) | ||
53 | #define REG_RCAL_START (1 << 12) | ||
54 | |||
55 | struct pxa168_usb_drv_data { | ||
56 | struct ehci_hcd ehci; | ||
57 | struct clk *pxa168_usb_clk; | ||
58 | struct resource *usb_phy_res; | ||
59 | void __iomem *usb_phy_reg_base; | ||
60 | }; | ||
61 | |||
62 | static int ehci_pxa168_setup(struct usb_hcd *hcd) | ||
63 | { | ||
64 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
65 | int retval; | ||
66 | |||
67 | ehci_reset(ehci); | ||
68 | retval = ehci_halt(ehci); | ||
69 | if (retval) | ||
70 | return retval; | ||
71 | |||
72 | /* | ||
73 | * data structure init | ||
74 | */ | ||
75 | retval = ehci_init(hcd); | ||
76 | if (retval) | ||
77 | return retval; | ||
78 | |||
79 | hcd->has_tt = 1; | ||
80 | |||
81 | ehci_port_power(ehci, 0); | ||
82 | |||
83 | return retval; | ||
84 | } | ||
85 | |||
86 | static const struct hc_driver ehci_pxa168_hc_driver = { | ||
87 | .description = hcd_name, | ||
88 | .product_desc = "Marvell PXA168 EHCI", | ||
89 | .hcd_priv_size = sizeof(struct pxa168_usb_drv_data), | ||
90 | |||
91 | /* | ||
92 | * generic hardware linkage | ||
93 | */ | ||
94 | .irq = ehci_irq, | ||
95 | .flags = HCD_MEMORY | HCD_USB2, | ||
96 | |||
97 | /* | ||
98 | * basic lifecycle operations | ||
99 | */ | ||
100 | .reset = ehci_pxa168_setup, | ||
101 | .start = ehci_run, | ||
102 | .stop = ehci_stop, | ||
103 | .shutdown = ehci_shutdown, | ||
104 | |||
105 | /* | ||
106 | * managing i/o requests and associated device resources | ||
107 | */ | ||
108 | .urb_enqueue = ehci_urb_enqueue, | ||
109 | .urb_dequeue = ehci_urb_dequeue, | ||
110 | .endpoint_disable = ehci_endpoint_disable, | ||
111 | .endpoint_reset = ehci_endpoint_reset, | ||
112 | |||
113 | /* | ||
114 | * scheduling support | ||
115 | */ | ||
116 | .get_frame_number = ehci_get_frame, | ||
117 | |||
118 | /* | ||
119 | * root hub support | ||
120 | */ | ||
121 | .hub_status_data = ehci_hub_status_data, | ||
122 | .hub_control = ehci_hub_control, | ||
123 | .bus_suspend = ehci_bus_suspend, | ||
124 | .bus_resume = ehci_bus_resume, | ||
125 | .relinquish_port = ehci_relinquish_port, | ||
126 | .port_handed_over = ehci_port_handed_over, | ||
127 | |||
128 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
129 | }; | ||
130 | |||
131 | static int pxa168_usb_phy_init(struct platform_device *pdev) | ||
132 | { | ||
133 | struct resource *res; | ||
134 | void __iomem *usb_phy_reg_base; | ||
135 | struct pxa168_usb_pdata *pdata; | ||
136 | struct pxa168_usb_drv_data *drv_data; | ||
137 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
138 | unsigned long reg_val; | ||
139 | int pll_retry_cont = 10000, err = 0; | ||
140 | |||
141 | drv_data = (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
142 | pdata = (struct pxa168_usb_pdata *)pdev->dev.platform_data; | ||
143 | |||
144 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
145 | if (!res) { | ||
146 | dev_err(&pdev->dev, | ||
147 | "Found HC with no PHY register addr. Check %s setup!\n", | ||
148 | dev_name(&pdev->dev)); | ||
149 | return -ENODEV; | ||
150 | } | ||
151 | |||
152 | if (!request_mem_region(res->start, resource_size(res), | ||
153 | ehci_pxa168_hc_driver.description)) { | ||
154 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
155 | return -EBUSY; | ||
156 | } | ||
157 | |||
158 | usb_phy_reg_base = ioremap(res->start, resource_size(res)); | ||
159 | if (usb_phy_reg_base == NULL) { | ||
160 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
161 | err = -EFAULT; | ||
162 | goto err1; | ||
163 | } | ||
164 | drv_data->usb_phy_reg_base = usb_phy_reg_base; | ||
165 | drv_data->usb_phy_res = res; | ||
166 | |||
167 | /* If someone wants to init USB phy in board specific way */ | ||
168 | if (pdata && pdata->phy_init) | ||
169 | return pdata->phy_init(usb_phy_reg_base); | ||
170 | |||
171 | /* Power up the PHY and PLL */ | ||
172 | writel(readl(usb_phy_reg_base + USB_PHY_CTRL_REG) | 0x3, | ||
173 | usb_phy_reg_base + USB_PHY_CTRL_REG); | ||
174 | |||
175 | /* Configure PHY PLL */ | ||
176 | reg_val = readl(usb_phy_reg_base + USB_PHY_PLL_REG) & ~(0x7e03ffff); | ||
177 | reg_val |= (VDD18_22 << PLLVDD18_SHIFT | VDD12_12 << PLLVDD12_SHIFT | | ||
178 | CALI12_11 << PLLCALI12_SHIFT | 3 << KVCO_SHIFT | | ||
179 | ICP_15 << ICP_SHIFT | 0xee << FBDIV_SHIFT | 0xb); | ||
180 | writel(reg_val, usb_phy_reg_base + USB_PHY_PLL_REG); | ||
181 | |||
182 | /* Make sure PHY PLL is ready */ | ||
183 | while (!(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & PLL_READY)) { | ||
184 | if (!(pll_retry_cont--)) { | ||
185 | dev_dbg(&pdev->dev, "USB PHY PLL not ready\n"); | ||
186 | err = -EIO; | ||
187 | goto err2; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | /* Toggle VCOCAL_START bit of U2PLL for PLL calibration */ | ||
192 | udelay(200); | ||
193 | writel(readl(usb_phy_reg_base + USB_PHY_PLL_REG) | VCOCAL_START, | ||
194 | usb_phy_reg_base + USB_PHY_PLL_REG); | ||
195 | udelay(40); | ||
196 | writel(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & ~VCOCAL_START, | ||
197 | usb_phy_reg_base + USB_PHY_PLL_REG); | ||
198 | |||
199 | /* Toggle REG_RCAL_START bit of U2PTX for impedance calibration */ | ||
200 | udelay(400); | ||
201 | writel(readl(usb_phy_reg_base + USB_PHY_TX_REG) | REG_RCAL_START, | ||
202 | usb_phy_reg_base + USB_PHY_TX_REG); | ||
203 | udelay(40); | ||
204 | writel(readl(usb_phy_reg_base + USB_PHY_TX_REG) & ~REG_RCAL_START, | ||
205 | usb_phy_reg_base + USB_PHY_TX_REG); | ||
206 | |||
207 | /* Make sure PHY PLL is ready again */ | ||
208 | pll_retry_cont = 0; | ||
209 | while (!(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & PLL_READY)) { | ||
210 | if (!(pll_retry_cont--)) { | ||
211 | dev_dbg(&pdev->dev, "USB PHY PLL not ready\n"); | ||
212 | err = -EIO; | ||
213 | goto err2; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | return 0; | ||
218 | err2: | ||
219 | iounmap(usb_phy_reg_base); | ||
220 | err1: | ||
221 | release_mem_region(res->start, resource_size(res)); | ||
222 | return err; | ||
223 | } | ||
224 | |||
225 | static int __devinit ehci_pxa168_drv_probe(struct platform_device *pdev) | ||
226 | { | ||
227 | struct resource *res; | ||
228 | struct usb_hcd *hcd; | ||
229 | struct ehci_hcd *ehci; | ||
230 | struct pxa168_usb_drv_data *drv_data; | ||
231 | void __iomem *regs; | ||
232 | int irq, err = 0; | ||
233 | |||
234 | if (usb_disabled()) | ||
235 | return -ENODEV; | ||
236 | |||
237 | pr_debug("Initializing pxa168-SoC USB Host Controller\n"); | ||
238 | |||
239 | irq = platform_get_irq(pdev, 0); | ||
240 | if (irq <= 0) { | ||
241 | dev_err(&pdev->dev, | ||
242 | "Found HC with no IRQ. Check %s setup!\n", | ||
243 | dev_name(&pdev->dev)); | ||
244 | err = -ENODEV; | ||
245 | goto err1; | ||
246 | } | ||
247 | |||
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
249 | if (!res) { | ||
250 | dev_err(&pdev->dev, | ||
251 | "Found HC with no register addr. Check %s setup!\n", | ||
252 | dev_name(&pdev->dev)); | ||
253 | err = -ENODEV; | ||
254 | goto err1; | ||
255 | } | ||
256 | |||
257 | if (!request_mem_region(res->start, resource_size(res), | ||
258 | ehci_pxa168_hc_driver.description)) { | ||
259 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
260 | err = -EBUSY; | ||
261 | goto err1; | ||
262 | } | ||
263 | |||
264 | regs = ioremap(res->start, resource_size(res)); | ||
265 | if (regs == NULL) { | ||
266 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
267 | err = -EFAULT; | ||
268 | goto err2; | ||
269 | } | ||
270 | |||
271 | hcd = usb_create_hcd(&ehci_pxa168_hc_driver, | ||
272 | &pdev->dev, dev_name(&pdev->dev)); | ||
273 | if (!hcd) { | ||
274 | err = -ENOMEM; | ||
275 | goto err3; | ||
276 | } | ||
277 | |||
278 | drv_data = (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
279 | |||
280 | /* Enable USB clock */ | ||
281 | drv_data->pxa168_usb_clk = clk_get(&pdev->dev, "PXA168-USBCLK"); | ||
282 | if (IS_ERR(drv_data->pxa168_usb_clk)) { | ||
283 | dev_err(&pdev->dev, "Couldn't get USB clock\n"); | ||
284 | err = PTR_ERR(drv_data->pxa168_usb_clk); | ||
285 | goto err4; | ||
286 | } | ||
287 | clk_enable(drv_data->pxa168_usb_clk); | ||
288 | |||
289 | err = pxa168_usb_phy_init(pdev); | ||
290 | if (err) { | ||
291 | dev_err(&pdev->dev, "USB PHY initialization failed\n"); | ||
292 | goto err5; | ||
293 | } | ||
294 | |||
295 | hcd->rsrc_start = res->start; | ||
296 | hcd->rsrc_len = resource_size(res); | ||
297 | hcd->regs = regs; | ||
298 | |||
299 | ehci = hcd_to_ehci(hcd); | ||
300 | ehci->caps = hcd->regs + 0x100; | ||
301 | ehci->regs = hcd->regs + 0x100 + | ||
302 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
303 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
304 | hcd->has_tt = 1; | ||
305 | ehci->sbrn = 0x20; | ||
306 | |||
307 | err = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED); | ||
308 | if (err) | ||
309 | goto err5; | ||
310 | |||
311 | return 0; | ||
312 | |||
313 | err5: | ||
314 | clk_disable(drv_data->pxa168_usb_clk); | ||
315 | clk_put(drv_data->pxa168_usb_clk); | ||
316 | err4: | ||
317 | usb_put_hcd(hcd); | ||
318 | err3: | ||
319 | iounmap(regs); | ||
320 | err2: | ||
321 | release_mem_region(res->start, resource_size(res)); | ||
322 | err1: | ||
323 | dev_err(&pdev->dev, "init %s fail, %d\n", | ||
324 | dev_name(&pdev->dev), err); | ||
325 | |||
326 | return err; | ||
327 | } | ||
328 | |||
329 | static int __exit ehci_pxa168_drv_remove(struct platform_device *pdev) | ||
330 | { | ||
331 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
332 | struct pxa168_usb_drv_data *drv_data = | ||
333 | (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
334 | |||
335 | usb_remove_hcd(hcd); | ||
336 | |||
337 | /* Power down PHY & PLL */ | ||
338 | writel(readl(drv_data->usb_phy_reg_base + USB_PHY_CTRL_REG) & (~0x3), | ||
339 | drv_data->usb_phy_reg_base + USB_PHY_CTRL_REG); | ||
340 | |||
341 | clk_disable(drv_data->pxa168_usb_clk); | ||
342 | clk_put(drv_data->pxa168_usb_clk); | ||
343 | |||
344 | iounmap(hcd->regs); | ||
345 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
346 | |||
347 | iounmap(drv_data->usb_phy_reg_base); | ||
348 | release_mem_region(drv_data->usb_phy_res->start, | ||
349 | resource_size(drv_data->usb_phy_res)); | ||
350 | |||
351 | usb_put_hcd(hcd); | ||
352 | |||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | MODULE_ALIAS("platform:pxa168-ehci"); | ||
357 | |||
358 | static struct platform_driver ehci_pxa168_driver = { | ||
359 | .probe = ehci_pxa168_drv_probe, | ||
360 | .remove = __exit_p(ehci_pxa168_drv_remove), | ||
361 | .shutdown = usb_hcd_platform_shutdown, | ||
362 | .driver.name = "pxa168-ehci", | ||
363 | }; | ||
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 293f7412992e..f098e2a291a0 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -17,6 +17,15 @@ | |||
17 | #include <plat/ehci.h> | 17 | #include <plat/ehci.h> |
18 | #include <plat/usb-phy.h> | 18 | #include <plat/usb-phy.h> |
19 | 19 | ||
20 | #define EHCI_INSNREG00(base) (base + 0x90) | ||
21 | #define EHCI_INSNREG00_ENA_INCR16 (0x1 << 25) | ||
22 | #define EHCI_INSNREG00_ENA_INCR8 (0x1 << 24) | ||
23 | #define EHCI_INSNREG00_ENA_INCR4 (0x1 << 23) | ||
24 | #define EHCI_INSNREG00_ENA_INCRX_ALIGN (0x1 << 22) | ||
25 | #define EHCI_INSNREG00_ENABLE_DMA_BURST \ | ||
26 | (EHCI_INSNREG00_ENA_INCR16 | EHCI_INSNREG00_ENA_INCR8 | \ | ||
27 | EHCI_INSNREG00_ENA_INCR4 | EHCI_INSNREG00_ENA_INCRX_ALIGN) | ||
28 | |||
20 | struct s5p_ehci_hcd { | 29 | struct s5p_ehci_hcd { |
21 | struct device *dev; | 30 | struct device *dev; |
22 | struct usb_hcd *hcd; | 31 | struct usb_hcd *hcd; |
@@ -128,6 +137,9 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
128 | ehci->regs = hcd->regs + | 137 | ehci->regs = hcd->regs + |
129 | HC_LENGTH(ehci, readl(&ehci->caps->hc_capbase)); | 138 | HC_LENGTH(ehci, readl(&ehci->caps->hc_capbase)); |
130 | 139 | ||
140 | /* DMA burst Enable */ | ||
141 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); | ||
142 | |||
131 | dbg_hcs_params(ehci, "reset"); | 143 | dbg_hcs_params(ehci, "reset"); |
132 | dbg_hcc_params(ehci, "reset"); | 144 | dbg_hcc_params(ehci, "reset"); |
133 | 145 | ||
@@ -234,6 +246,9 @@ static int s5p_ehci_resume(struct device *dev) | |||
234 | if (pdata && pdata->phy_init) | 246 | if (pdata && pdata->phy_init) |
235 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | 247 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); |
236 | 248 | ||
249 | /* DMA burst Enable */ | ||
250 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); | ||
251 | |||
237 | if (time_before(jiffies, ehci->next_statechange)) | 252 | if (time_before(jiffies, ehci->next_statechange)) |
238 | msleep(100); | 253 | msleep(100); |
239 | 254 | ||
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index b115b0b76e33..6e928559169c 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -11,8 +11,10 @@ | |||
11 | * more details. | 11 | * more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/jiffies.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/pm.h> | ||
16 | 18 | ||
17 | struct spear_ehci { | 19 | struct spear_ehci { |
18 | struct ehci_hcd ehci; | 20 | struct ehci_hcd ehci; |
@@ -90,6 +92,82 @@ static const struct hc_driver ehci_spear_hc_driver = { | |||
90 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 92 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
91 | }; | 93 | }; |
92 | 94 | ||
95 | #ifdef CONFIG_PM | ||
96 | static int ehci_spear_drv_suspend(struct device *dev) | ||
97 | { | ||
98 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
99 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
100 | unsigned long flags; | ||
101 | int rc = 0; | ||
102 | |||
103 | if (time_before(jiffies, ehci->next_statechange)) | ||
104 | msleep(10); | ||
105 | |||
106 | /* | ||
107 | * Root hub was already suspended. Disable irq emission and mark HW | ||
108 | * unaccessible. The PM and USB cores make sure that the root hub is | ||
109 | * either suspended or stopped. | ||
110 | */ | ||
111 | spin_lock_irqsave(&ehci->lock, flags); | ||
112 | ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev)); | ||
113 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
114 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
115 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
116 | |||
117 | return rc; | ||
118 | } | ||
119 | |||
120 | static int ehci_spear_drv_resume(struct device *dev) | ||
121 | { | ||
122 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
123 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
124 | |||
125 | if (time_before(jiffies, ehci->next_statechange)) | ||
126 | msleep(100); | ||
127 | |||
128 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { | ||
129 | int mask = INTR_MASK; | ||
130 | |||
131 | ehci_prepare_ports_for_controller_resume(ehci); | ||
132 | |||
133 | if (!hcd->self.root_hub->do_remote_wakeup) | ||
134 | mask &= ~STS_PCD; | ||
135 | |||
136 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | ||
137 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | usb_root_hub_lost_power(hcd->self.root_hub); | ||
142 | |||
143 | /* | ||
144 | * Else reset, to cope with power loss or flush-to-storage style | ||
145 | * "resume" having let BIOS kick in during reboot. | ||
146 | */ | ||
147 | ehci_halt(ehci); | ||
148 | ehci_reset(ehci); | ||
149 | |||
150 | /* emptying the schedule aborts any urbs */ | ||
151 | spin_lock_irq(&ehci->lock); | ||
152 | if (ehci->reclaim) | ||
153 | end_unlink_async(ehci); | ||
154 | |||
155 | ehci_work(ehci); | ||
156 | spin_unlock_irq(&ehci->lock); | ||
157 | |||
158 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
159 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | ||
160 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | ||
161 | |||
162 | /* here we "know" root ports should always stay powered */ | ||
163 | ehci_port_power(ehci, 1); | ||
164 | return 0; | ||
165 | } | ||
166 | #endif /* CONFIG_PM */ | ||
167 | |||
168 | static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, | ||
169 | ehci_spear_drv_resume); | ||
170 | |||
93 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | 171 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) |
94 | { | 172 | { |
95 | struct usb_hcd *hcd ; | 173 | struct usb_hcd *hcd ; |
@@ -205,7 +283,8 @@ static struct platform_driver spear_ehci_hcd_driver = { | |||
205 | .shutdown = usb_hcd_platform_shutdown, | 283 | .shutdown = usb_hcd_platform_shutdown, |
206 | .driver = { | 284 | .driver = { |
207 | .name = "spear-ehci", | 285 | .name = "spear-ehci", |
208 | .bus = &platform_bus_type | 286 | .bus = &platform_bus_type, |
287 | .pm = &ehci_spear_pm_ops, | ||
209 | } | 288 | } |
210 | }; | 289 | }; |
211 | 290 | ||
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index dbc7fe8ca9e7..3de48a2d7955 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -35,7 +35,7 @@ struct tegra_ehci_hcd { | |||
35 | struct tegra_usb_phy *phy; | 35 | struct tegra_usb_phy *phy; |
36 | struct clk *clk; | 36 | struct clk *clk; |
37 | struct clk *emc_clk; | 37 | struct clk *emc_clk; |
38 | struct otg_transceiver *transceiver; | 38 | struct usb_phy *transceiver; |
39 | int host_resumed; | 39 | int host_resumed; |
40 | int bus_suspended; | 40 | int bus_suspended; |
41 | int port_resuming; | 41 | int port_resuming; |
@@ -733,9 +733,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
733 | 733 | ||
734 | #ifdef CONFIG_USB_OTG_UTILS | 734 | #ifdef CONFIG_USB_OTG_UTILS |
735 | if (pdata->operating_mode == TEGRA_USB_OTG) { | 735 | if (pdata->operating_mode == TEGRA_USB_OTG) { |
736 | tegra->transceiver = otg_get_transceiver(); | 736 | tegra->transceiver = usb_get_transceiver(); |
737 | if (tegra->transceiver) | 737 | if (tegra->transceiver) |
738 | otg_set_host(tegra->transceiver, &hcd->self); | 738 | otg_set_host(tegra->transceiver->otg, &hcd->self); |
739 | } | 739 | } |
740 | #endif | 740 | #endif |
741 | 741 | ||
@@ -750,8 +750,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
750 | fail: | 750 | fail: |
751 | #ifdef CONFIG_USB_OTG_UTILS | 751 | #ifdef CONFIG_USB_OTG_UTILS |
752 | if (tegra->transceiver) { | 752 | if (tegra->transceiver) { |
753 | otg_set_host(tegra->transceiver, NULL); | 753 | otg_set_host(tegra->transceiver->otg, NULL); |
754 | otg_put_transceiver(tegra->transceiver); | 754 | usb_put_transceiver(tegra->transceiver); |
755 | } | 755 | } |
756 | #endif | 756 | #endif |
757 | tegra_usb_phy_close(tegra->phy); | 757 | tegra_usb_phy_close(tegra->phy); |
@@ -808,8 +808,8 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
808 | 808 | ||
809 | #ifdef CONFIG_USB_OTG_UTILS | 809 | #ifdef CONFIG_USB_OTG_UTILS |
810 | if (tegra->transceiver) { | 810 | if (tegra->transceiver) { |
811 | otg_set_host(tegra->transceiver, NULL); | 811 | otg_set_host(tegra->transceiver->otg, NULL); |
812 | otg_put_transceiver(tegra->transceiver); | 812 | usb_put_transceiver(tegra->transceiver); |
813 | } | 813 | } |
814 | #endif | 814 | #endif |
815 | 815 | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 0a5fda73b3f2..8f9acbc96fde 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -176,7 +176,7 @@ struct ehci_hcd { /* one per controller */ | |||
176 | /* | 176 | /* |
177 | * OTG controllers and transceivers need software interaction | 177 | * OTG controllers and transceivers need software interaction |
178 | */ | 178 | */ |
179 | struct otg_transceiver *transceiver; | 179 | struct usb_phy *transceiver; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ | 182 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ |
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 7916e56a725e..ab333ac6071d 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c | |||
@@ -94,7 +94,6 @@ struct platform_device * __devinit fsl_usb2_device_register( | |||
94 | pdev->dev.parent = &ofdev->dev; | 94 | pdev->dev.parent = &ofdev->dev; |
95 | 95 | ||
96 | pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; | 96 | pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; |
97 | pdev->dev.dma_mask = &pdev->archdata.dma_mask; | ||
98 | *pdev->dev.dma_mask = *ofdev->dev.dma_mask; | 97 | *pdev->dev.dma_mask = *ofdev->dev.dma_mask; |
99 | 98 | ||
100 | retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); | 99 | retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); |
diff --git a/drivers/usb/host/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c index 6d7533427163..ec98ecee3517 100644 --- a/drivers/usb/host/imx21-dbg.c +++ b/drivers/usb/host/imx21-dbg.c | |||
@@ -239,7 +239,7 @@ static int debug_status_show(struct seq_file *s, void *v) | |||
239 | "ETDs allocated: %d/%d (max=%d)\n" | 239 | "ETDs allocated: %d/%d (max=%d)\n" |
240 | "ETDs in use sw: %d\n" | 240 | "ETDs in use sw: %d\n" |
241 | "ETDs in use hw: %d\n" | 241 | "ETDs in use hw: %d\n" |
242 | "DMEM alocated: %d/%d (max=%d)\n" | 242 | "DMEM allocated: %d/%d (max=%d)\n" |
243 | "DMEM blocks: %d\n" | 243 | "DMEM blocks: %d\n" |
244 | "Queued waiting for ETD: %d\n" | 244 | "Queued waiting for ETD: %d\n" |
245 | "Queued waiting for DMEM: %d\n", | 245 | "Queued waiting for DMEM: %d\n", |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index d91e5f211a76..924880087a74 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -1569,6 +1569,9 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1569 | int ret = 0; | 1569 | int ret = 0; |
1570 | unsigned long irqflags; | 1570 | unsigned long irqflags; |
1571 | 1571 | ||
1572 | if (usb_disabled()) | ||
1573 | return -ENODEV; | ||
1574 | |||
1572 | if (pdev->num_resources < 3) { | 1575 | if (pdev->num_resources < 3) { |
1573 | ret = -ENODEV; | 1576 | ret = -ENODEV; |
1574 | goto err1; | 1577 | goto err1; |
@@ -1708,22 +1711,4 @@ static struct platform_driver isp116x_driver = { | |||
1708 | }, | 1711 | }, |
1709 | }; | 1712 | }; |
1710 | 1713 | ||
1711 | /*-----------------------------------------------------------------*/ | 1714 | module_platform_driver(isp116x_driver); |
1712 | |||
1713 | static int __init isp116x_init(void) | ||
1714 | { | ||
1715 | if (usb_disabled()) | ||
1716 | return -ENODEV; | ||
1717 | |||
1718 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
1719 | return platform_driver_register(&isp116x_driver); | ||
1720 | } | ||
1721 | |||
1722 | module_init(isp116x_init); | ||
1723 | |||
1724 | static void __exit isp116x_cleanup(void) | ||
1725 | { | ||
1726 | platform_driver_unregister(&isp116x_driver); | ||
1727 | } | ||
1728 | |||
1729 | module_exit(isp116x_cleanup); | ||
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index e5fd8aa57af1..9e63cdf1ab75 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c | |||
@@ -2693,6 +2693,9 @@ static int __devinit isp1362_probe(struct platform_device *pdev) | |||
2693 | struct resource *irq_res; | 2693 | struct resource *irq_res; |
2694 | unsigned int irq_flags = 0; | 2694 | unsigned int irq_flags = 0; |
2695 | 2695 | ||
2696 | if (usb_disabled()) | ||
2697 | return -ENODEV; | ||
2698 | |||
2696 | /* basic sanity checks first. board-specific init logic should | 2699 | /* basic sanity checks first. board-specific init logic should |
2697 | * have initialized this the three resources and probably board | 2700 | * have initialized this the three resources and probably board |
2698 | * specific platform_data. we don't probe for IRQs, and do only | 2701 | * specific platform_data. we don't probe for IRQs, and do only |
@@ -2864,19 +2867,4 @@ static struct platform_driver isp1362_driver = { | |||
2864 | }, | 2867 | }, |
2865 | }; | 2868 | }; |
2866 | 2869 | ||
2867 | /*-------------------------------------------------------------------------*/ | 2870 | module_platform_driver(isp1362_driver); |
2868 | |||
2869 | static int __init isp1362_init(void) | ||
2870 | { | ||
2871 | if (usb_disabled()) | ||
2872 | return -ENODEV; | ||
2873 | pr_info("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
2874 | return platform_driver_register(&isp1362_driver); | ||
2875 | } | ||
2876 | module_init(isp1362_init); | ||
2877 | |||
2878 | static void __exit isp1362_cleanup(void) | ||
2879 | { | ||
2880 | platform_driver_unregister(&isp1362_driver); | ||
2881 | } | ||
2882 | module_exit(isp1362_cleanup); | ||
diff --git a/drivers/usb/host/ohci-ath79.c b/drivers/usb/host/ohci-ath79.c deleted file mode 100644 index 18d574d6958b..000000000000 --- a/drivers/usb/host/ohci-ath79.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Bus Glue for Atheros AR71XX/AR724X built-in OHCI controller. | ||
5 | * | ||
6 | * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> | ||
7 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> | ||
8 | * | ||
9 | * Parts of this file are based on Atheros' 2.6.15 BSP | ||
10 | * Copyright (C) 2007 Atheros Communications, Inc. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published | ||
14 | * by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/platform_device.h> | ||
18 | |||
19 | static int __devinit ohci_ath79_start(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
22 | int ret; | ||
23 | |||
24 | ret = ohci_init(ohci); | ||
25 | if (ret < 0) | ||
26 | return ret; | ||
27 | |||
28 | ret = ohci_run(ohci); | ||
29 | if (ret < 0) | ||
30 | goto err; | ||
31 | |||
32 | return 0; | ||
33 | |||
34 | err: | ||
35 | ohci_stop(hcd); | ||
36 | return ret; | ||
37 | } | ||
38 | |||
39 | static const struct hc_driver ohci_ath79_hc_driver = { | ||
40 | .description = hcd_name, | ||
41 | .product_desc = "Atheros built-in OHCI controller", | ||
42 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
43 | |||
44 | .irq = ohci_irq, | ||
45 | .flags = HCD_USB11 | HCD_MEMORY, | ||
46 | |||
47 | .start = ohci_ath79_start, | ||
48 | .stop = ohci_stop, | ||
49 | .shutdown = ohci_shutdown, | ||
50 | |||
51 | .urb_enqueue = ohci_urb_enqueue, | ||
52 | .urb_dequeue = ohci_urb_dequeue, | ||
53 | .endpoint_disable = ohci_endpoint_disable, | ||
54 | |||
55 | /* | ||
56 | * scheduling support | ||
57 | */ | ||
58 | .get_frame_number = ohci_get_frame, | ||
59 | |||
60 | /* | ||
61 | * root hub support | ||
62 | */ | ||
63 | .hub_status_data = ohci_hub_status_data, | ||
64 | .hub_control = ohci_hub_control, | ||
65 | .start_port_reset = ohci_start_port_reset, | ||
66 | }; | ||
67 | |||
68 | static int ohci_ath79_probe(struct platform_device *pdev) | ||
69 | { | ||
70 | struct usb_hcd *hcd; | ||
71 | struct resource *res; | ||
72 | int irq; | ||
73 | int ret; | ||
74 | |||
75 | if (usb_disabled()) | ||
76 | return -ENODEV; | ||
77 | |||
78 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
79 | if (!res) { | ||
80 | dev_dbg(&pdev->dev, "no IRQ specified\n"); | ||
81 | return -ENODEV; | ||
82 | } | ||
83 | irq = res->start; | ||
84 | |||
85 | hcd = usb_create_hcd(&ohci_ath79_hc_driver, &pdev->dev, | ||
86 | dev_name(&pdev->dev)); | ||
87 | if (!hcd) | ||
88 | return -ENOMEM; | ||
89 | |||
90 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
91 | if (!res) { | ||
92 | dev_dbg(&pdev->dev, "no base address specified\n"); | ||
93 | ret = -ENODEV; | ||
94 | goto err_put_hcd; | ||
95 | } | ||
96 | hcd->rsrc_start = res->start; | ||
97 | hcd->rsrc_len = resource_size(res); | ||
98 | |||
99 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
100 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
101 | ret = -EBUSY; | ||
102 | goto err_put_hcd; | ||
103 | } | ||
104 | |||
105 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
106 | if (!hcd->regs) { | ||
107 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
108 | ret = -EFAULT; | ||
109 | goto err_release_region; | ||
110 | } | ||
111 | |||
112 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
113 | |||
114 | ret = usb_add_hcd(hcd, irq, 0); | ||
115 | if (ret) | ||
116 | goto err_stop_hcd; | ||
117 | |||
118 | return 0; | ||
119 | |||
120 | err_stop_hcd: | ||
121 | iounmap(hcd->regs); | ||
122 | err_release_region: | ||
123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
124 | err_put_hcd: | ||
125 | usb_put_hcd(hcd); | ||
126 | return ret; | ||
127 | } | ||
128 | |||
129 | static int ohci_ath79_remove(struct platform_device *pdev) | ||
130 | { | ||
131 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
132 | |||
133 | usb_remove_hcd(hcd); | ||
134 | iounmap(hcd->regs); | ||
135 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
136 | usb_put_hcd(hcd); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static struct platform_driver ohci_hcd_ath79_driver = { | ||
142 | .probe = ohci_ath79_probe, | ||
143 | .remove = ohci_ath79_remove, | ||
144 | .shutdown = usb_hcd_platform_shutdown, | ||
145 | .driver = { | ||
146 | .name = "ath79-ohci", | ||
147 | .owner = THIS_MODULE, | ||
148 | }, | ||
149 | }; | ||
150 | |||
151 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ohci"); | ||
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 55aa35aa3d7b..37bb20ebb6fc 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c | |||
@@ -212,12 +212,10 @@ static int exynos_ohci_suspend(struct device *dev) | |||
212 | * mark HW unaccessible, bail out if RH has been resumed. Use | 212 | * mark HW unaccessible, bail out if RH has been resumed. Use |
213 | * the spinlock to properly synchronize with possible pending | 213 | * the spinlock to properly synchronize with possible pending |
214 | * RH suspend or resume activity. | 214 | * RH suspend or resume activity. |
215 | * | ||
216 | * This is still racy as hcd->state is manipulated outside of | ||
217 | * any locks =P But that will be a different fix. | ||
218 | */ | 215 | */ |
219 | spin_lock_irqsave(&ohci->lock, flags); | 216 | spin_lock_irqsave(&ohci->lock, flags); |
220 | if (hcd->state != HC_STATE_SUSPENDED && hcd->state != HC_STATE_HALT) { | 217 | if (ohci->rh_state != OHCI_RH_SUSPENDED && |
218 | ohci->rh_state != OHCI_RH_HALTED) { | ||
221 | rc = -EINVAL; | 219 | rc = -EINVAL; |
222 | goto fail; | 220 | goto fail; |
223 | } | 221 | } |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 34b9edd86651..cd5e382db89c 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -899,7 +899,7 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
899 | ohci_usb_reset (ohci); | 899 | ohci_usb_reset (ohci); |
900 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 900 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
901 | free_irq(hcd->irq, hcd); | 901 | free_irq(hcd->irq, hcd); |
902 | hcd->irq = -1; | 902 | hcd->irq = 0; |
903 | 903 | ||
904 | if (quirk_zfmicro(ohci)) | 904 | if (quirk_zfmicro(ohci)) |
905 | del_timer(&ohci->unlink_watchdog); | 905 | del_timer(&ohci->unlink_watchdog); |
@@ -1050,9 +1050,9 @@ MODULE_LICENSE ("GPL"); | |||
1050 | #define PLATFORM_DRIVER ohci_hcd_at91_driver | 1050 | #define PLATFORM_DRIVER ohci_hcd_at91_driver |
1051 | #endif | 1051 | #endif |
1052 | 1052 | ||
1053 | #ifdef CONFIG_ARCH_PNX4008 | 1053 | #if defined(CONFIG_ARCH_PNX4008) || defined(CONFIG_ARCH_LPC32XX) |
1054 | #include "ohci-pnx4008.c" | 1054 | #include "ohci-nxp.c" |
1055 | #define PLATFORM_DRIVER usb_hcd_pnx4008_driver | 1055 | #define PLATFORM_DRIVER usb_hcd_nxp_driver |
1056 | #endif | 1056 | #endif |
1057 | 1057 | ||
1058 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX | 1058 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
@@ -1111,16 +1111,16 @@ MODULE_LICENSE ("GPL"); | |||
1111 | #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver | 1111 | #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver |
1112 | #endif | 1112 | #endif |
1113 | 1113 | ||
1114 | #ifdef CONFIG_USB_OHCI_ATH79 | ||
1115 | #include "ohci-ath79.c" | ||
1116 | #define PLATFORM_DRIVER ohci_hcd_ath79_driver | ||
1117 | #endif | ||
1118 | |||
1119 | #ifdef CONFIG_CPU_XLR | 1114 | #ifdef CONFIG_CPU_XLR |
1120 | #include "ohci-xls.c" | 1115 | #include "ohci-xls.c" |
1121 | #define PLATFORM_DRIVER ohci_xls_driver | 1116 | #define PLATFORM_DRIVER ohci_xls_driver |
1122 | #endif | 1117 | #endif |
1123 | 1118 | ||
1119 | #ifdef CONFIG_USB_OHCI_HCD_PLATFORM | ||
1120 | #include "ohci-platform.c" | ||
1121 | #define PLATFORM_DRIVER ohci_platform_driver | ||
1122 | #endif | ||
1123 | |||
1124 | #if !defined(PCI_DRIVER) && \ | 1124 | #if !defined(PCI_DRIVER) && \ |
1125 | !defined(PLATFORM_DRIVER) && \ | 1125 | !defined(PLATFORM_DRIVER) && \ |
1126 | !defined(OMAP1_PLATFORM_DRIVER) && \ | 1126 | !defined(OMAP1_PLATFORM_DRIVER) && \ |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-nxp.c index 0013db7bdf92..6618de1d881d 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-nxp.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/usb/host/ohci-pnx4008.c | 2 | * driver for NXP USB Host devices |
3 | * | 3 | * |
4 | * driver for Philips PNX4008 USB Host | 4 | * Currently supported OHCI host devices: |
5 | * - Philips PNX4008 | ||
6 | * - NXP LPC32xx | ||
5 | * | 7 | * |
6 | * Authors: Dmitry Chigirev <source@mvista.com> | 8 | * Authors: Dmitry Chigirev <source@mvista.com> |
7 | * Vitaly Wool <vitalywool@gmail.com> | 9 | * Vitaly Wool <vitalywool@gmail.com> |
@@ -22,20 +24,24 @@ | |||
22 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
23 | 25 | ||
24 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
27 | #include <asm/mach-types.h> | ||
25 | #include <asm/io.h> | 28 | #include <asm/io.h> |
26 | 29 | ||
27 | #include <mach/platform.h> | 30 | #include <mach/platform.h> |
28 | #include <mach/irqs.h> | 31 | #include <mach/irqs.h> |
29 | #include <asm/gpio.h> | 32 | #include <asm/gpio.h> |
30 | 33 | ||
31 | #define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64) | 34 | #define USB_CONFIG_BASE 0x31020000 |
35 | #define PWRMAN_BASE 0x40004000 | ||
36 | |||
37 | #define USB_CTRL IO_ADDRESS(PWRMAN_BASE + 0x64) | ||
32 | 38 | ||
33 | /* USB_CTRL bit defines */ | 39 | /* USB_CTRL bit defines */ |
34 | #define USB_SLAVE_HCLK_EN (1 << 24) | 40 | #define USB_SLAVE_HCLK_EN (1 << 24) |
35 | #define USB_HOST_NEED_CLK_EN (1 << 21) | 41 | #define USB_HOST_NEED_CLK_EN (1 << 21) |
36 | 42 | ||
37 | #define USB_OTG_CLK_CTRL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF4) | 43 | #define USB_OTG_CLK_CTRL IO_ADDRESS(USB_CONFIG_BASE + 0xFF4) |
38 | #define USB_OTG_CLK_STAT IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF8) | 44 | #define USB_OTG_CLK_STAT IO_ADDRESS(USB_CONFIG_BASE + 0xFF8) |
39 | 45 | ||
40 | /* USB_OTG_CLK_CTRL bit defines */ | 46 | /* USB_OTG_CLK_CTRL bit defines */ |
41 | #define AHB_M_CLOCK_ON (1 << 4) | 47 | #define AHB_M_CLOCK_ON (1 << 4) |
@@ -44,7 +50,7 @@ | |||
44 | #define DEV_CLOCK_ON (1 << 1) | 50 | #define DEV_CLOCK_ON (1 << 1) |
45 | #define HOST_CLOCK_ON (1 << 0) | 51 | #define HOST_CLOCK_ON (1 << 0) |
46 | 52 | ||
47 | #define USB_OTG_STAT_CONTROL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x110) | 53 | #define USB_OTG_STAT_CONTROL IO_ADDRESS(USB_CONFIG_BASE + 0x110) |
48 | 54 | ||
49 | /* USB_OTG_STAT_CONTROL bit defines */ | 55 | /* USB_OTG_STAT_CONTROL bit defines */ |
50 | #define TRANSPARENT_I2C_EN (1 << 7) | 56 | #define TRANSPARENT_I2C_EN (1 << 7) |
@@ -98,6 +104,15 @@ | |||
98 | #define ISP1301_I2C_INTERRUPT_RISING 0xE | 104 | #define ISP1301_I2C_INTERRUPT_RISING 0xE |
99 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 | 105 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 |
100 | 106 | ||
107 | /* On LPC32xx, those are undefined */ | ||
108 | #ifndef start_int_set_falling_edge | ||
109 | #define start_int_set_falling_edge(irq) | ||
110 | #define start_int_set_rising_edge(irq) | ||
111 | #define start_int_ack(irq) | ||
112 | #define start_int_mask(irq) | ||
113 | #define start_int_umask(irq) | ||
114 | #endif | ||
115 | |||
101 | static struct i2c_driver isp1301_driver; | 116 | static struct i2c_driver isp1301_driver; |
102 | static struct i2c_client *isp1301_i2c_client; | 117 | static struct i2c_client *isp1301_i2c_client; |
103 | 118 | ||
@@ -121,73 +136,129 @@ static int isp1301_remove(struct i2c_client *client) | |||
121 | } | 136 | } |
122 | 137 | ||
123 | static const struct i2c_device_id isp1301_id[] = { | 138 | static const struct i2c_device_id isp1301_id[] = { |
124 | { "isp1301_pnx", 0 }, | 139 | { "isp1301_nxp", 0 }, |
125 | { } | 140 | { } |
126 | }; | 141 | }; |
127 | 142 | ||
128 | static struct i2c_driver isp1301_driver = { | 143 | static struct i2c_driver isp1301_driver = { |
129 | .driver = { | 144 | .driver = { |
130 | .name = "isp1301_pnx", | 145 | .name = "isp1301_nxp", |
131 | }, | 146 | }, |
132 | .probe = isp1301_probe, | 147 | .probe = isp1301_probe, |
133 | .remove = isp1301_remove, | 148 | .remove = isp1301_remove, |
134 | .id_table = isp1301_id, | 149 | .id_table = isp1301_id, |
135 | }; | 150 | }; |
136 | 151 | ||
137 | static void i2c_write(u8 buf, u8 subaddr) | 152 | static void isp1301_configure_pnx4008(void) |
138 | { | ||
139 | char tmpbuf[2]; | ||
140 | |||
141 | tmpbuf[0] = subaddr; /*register number */ | ||
142 | tmpbuf[1] = buf; /*register data */ | ||
143 | i2c_master_send(isp1301_i2c_client, &tmpbuf[0], 2); | ||
144 | } | ||
145 | |||
146 | static void isp1301_configure(void) | ||
147 | { | 153 | { |
148 | /* PNX4008 only supports DAT_SE0 USB mode */ | 154 | /* PNX4008 only supports DAT_SE0 USB mode */ |
149 | /* PNX4008 R2A requires setting the MAX603 to output 3.6V */ | 155 | /* PNX4008 R2A requires setting the MAX603 to output 3.6V */ |
150 | /* Power up externel charge-pump */ | 156 | /* Power up externel charge-pump */ |
151 | 157 | ||
152 | i2c_write(MC1_DAT_SE0 | MC1_SPEED_REG, ISP1301_I2C_MODE_CONTROL_1); | 158 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
153 | i2c_write(~(MC1_DAT_SE0 | MC1_SPEED_REG), | 159 | ISP1301_I2C_MODE_CONTROL_1, MC1_DAT_SE0 | MC1_SPEED_REG); |
154 | ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 160 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
155 | i2c_write(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL, | 161 | ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
156 | ISP1301_I2C_MODE_CONTROL_2); | 162 | ~(MC1_DAT_SE0 | MC1_SPEED_REG)); |
157 | i2c_write(~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL), | 163 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
158 | ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR); | 164 | ISP1301_I2C_MODE_CONTROL_2, |
159 | i2c_write(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN, | 165 | MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL); |
160 | ISP1301_I2C_OTG_CONTROL_1); | 166 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
161 | i2c_write(~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN), | 167 | ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR, |
162 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 168 | ~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL)); |
163 | i2c_write(0xFF, | 169 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
164 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR); | 170 | ISP1301_I2C_OTG_CONTROL_1, OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN); |
165 | i2c_write(0xFF, | 171 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
166 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR); | 172 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
167 | i2c_write(0xFF, | 173 | ~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN)); |
168 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR); | 174 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
175 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR, 0xFF); | ||
176 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
177 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
178 | 0xFF); | ||
179 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
180 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
181 | 0xFF); | ||
182 | } | ||
169 | 183 | ||
184 | static void isp1301_configure_lpc32xx(void) | ||
185 | { | ||
186 | /* LPC32XX only supports DAT_SE0 USB mode */ | ||
187 | /* This sequence is important */ | ||
188 | |||
189 | /* Disable transparent UART mode first */ | ||
190 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
191 | (ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
192 | MC1_UART_EN); | ||
193 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
194 | (ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
195 | ~MC1_SPEED_REG); | ||
196 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
197 | ISP1301_I2C_MODE_CONTROL_1, MC1_SPEED_REG); | ||
198 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
199 | (ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
200 | ~0); | ||
201 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
202 | ISP1301_I2C_MODE_CONTROL_2, | ||
203 | (MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL)); | ||
204 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
205 | (ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), ~0); | ||
206 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
207 | ISP1301_I2C_MODE_CONTROL_1, MC1_DAT_SE0); | ||
208 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
209 | ISP1301_I2C_OTG_CONTROL_1, | ||
210 | (OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN)); | ||
211 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
212 | (ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
213 | (OTG1_DM_PULLUP | OTG1_DP_PULLUP)); | ||
214 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
215 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR, ~0); | ||
216 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
217 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
218 | ~0); | ||
219 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
220 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, ~0); | ||
221 | |||
222 | /* Enable usb_need_clk clock after transceiver is initialized */ | ||
223 | __raw_writel((__raw_readl(USB_CTRL) | (1 << 22)), USB_CTRL); | ||
224 | |||
225 | printk(KERN_INFO "ISP1301 Vendor ID : 0x%04x\n", | ||
226 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x00)); | ||
227 | printk(KERN_INFO "ISP1301 Product ID : 0x%04x\n", | ||
228 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x02)); | ||
229 | printk(KERN_INFO "ISP1301 Version ID : 0x%04x\n", | ||
230 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x14)); | ||
231 | } | ||
232 | |||
233 | static void isp1301_configure(void) | ||
234 | { | ||
235 | if (machine_is_pnx4008()) | ||
236 | isp1301_configure_pnx4008(); | ||
237 | else | ||
238 | isp1301_configure_lpc32xx(); | ||
170 | } | 239 | } |
171 | 240 | ||
172 | static inline void isp1301_vbus_on(void) | 241 | static inline void isp1301_vbus_on(void) |
173 | { | 242 | { |
174 | i2c_write(OTG1_VBUS_DRV, ISP1301_I2C_OTG_CONTROL_1); | 243 | i2c_smbus_write_byte_data(isp1301_i2c_client, ISP1301_I2C_OTG_CONTROL_1, |
244 | OTG1_VBUS_DRV); | ||
175 | } | 245 | } |
176 | 246 | ||
177 | static inline void isp1301_vbus_off(void) | 247 | static inline void isp1301_vbus_off(void) |
178 | { | 248 | { |
179 | i2c_write(OTG1_VBUS_DRV, | 249 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
180 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 250 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
251 | OTG1_VBUS_DRV); | ||
181 | } | 252 | } |
182 | 253 | ||
183 | static void pnx4008_start_hc(void) | 254 | static void nxp_start_hc(void) |
184 | { | 255 | { |
185 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; | 256 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; |
186 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 257 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
187 | isp1301_vbus_on(); | 258 | isp1301_vbus_on(); |
188 | } | 259 | } |
189 | 260 | ||
190 | static void pnx4008_stop_hc(void) | 261 | static void nxp_stop_hc(void) |
191 | { | 262 | { |
192 | unsigned long tmp; | 263 | unsigned long tmp; |
193 | isp1301_vbus_off(); | 264 | isp1301_vbus_off(); |
@@ -195,7 +266,7 @@ static void pnx4008_stop_hc(void) | |||
195 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 266 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
196 | } | 267 | } |
197 | 268 | ||
198 | static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd) | 269 | static int __devinit ohci_nxp_start(struct usb_hcd *hcd) |
199 | { | 270 | { |
200 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 271 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
201 | int ret; | 272 | int ret; |
@@ -211,9 +282,9 @@ static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd) | |||
211 | return 0; | 282 | return 0; |
212 | } | 283 | } |
213 | 284 | ||
214 | static const struct hc_driver ohci_pnx4008_hc_driver = { | 285 | static const struct hc_driver ohci_nxp_hc_driver = { |
215 | .description = hcd_name, | 286 | .description = hcd_name, |
216 | .product_desc = "pnx4008 OHCI", | 287 | .product_desc = "nxp OHCI", |
217 | 288 | ||
218 | /* | 289 | /* |
219 | * generic hardware linkage | 290 | * generic hardware linkage |
@@ -225,7 +296,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
225 | /* | 296 | /* |
226 | * basic lifecycle operations | 297 | * basic lifecycle operations |
227 | */ | 298 | */ |
228 | .start = ohci_pnx4008_start, | 299 | .start = ohci_nxp_start, |
229 | .stop = ohci_stop, | 300 | .stop = ohci_stop, |
230 | .shutdown = ohci_shutdown, | 301 | .shutdown = ohci_shutdown, |
231 | 302 | ||
@@ -255,54 +326,58 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
255 | 326 | ||
256 | #define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON) | 327 | #define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON) |
257 | 328 | ||
258 | static void pnx4008_set_usb_bits(void) | 329 | static void nxp_set_usb_bits(void) |
259 | { | 330 | { |
260 | start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N); | 331 | if (machine_is_pnx4008()) { |
261 | start_int_ack(SE_USB_OTG_ATX_INT_N); | 332 | start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N); |
262 | start_int_umask(SE_USB_OTG_ATX_INT_N); | 333 | start_int_ack(SE_USB_OTG_ATX_INT_N); |
263 | 334 | start_int_umask(SE_USB_OTG_ATX_INT_N); | |
264 | start_int_set_rising_edge(SE_USB_OTG_TIMER_INT); | 335 | |
265 | start_int_ack(SE_USB_OTG_TIMER_INT); | 336 | start_int_set_rising_edge(SE_USB_OTG_TIMER_INT); |
266 | start_int_umask(SE_USB_OTG_TIMER_INT); | 337 | start_int_ack(SE_USB_OTG_TIMER_INT); |
267 | 338 | start_int_umask(SE_USB_OTG_TIMER_INT); | |
268 | start_int_set_rising_edge(SE_USB_I2C_INT); | 339 | |
269 | start_int_ack(SE_USB_I2C_INT); | 340 | start_int_set_rising_edge(SE_USB_I2C_INT); |
270 | start_int_umask(SE_USB_I2C_INT); | 341 | start_int_ack(SE_USB_I2C_INT); |
271 | 342 | start_int_umask(SE_USB_I2C_INT); | |
272 | start_int_set_rising_edge(SE_USB_INT); | 343 | |
273 | start_int_ack(SE_USB_INT); | 344 | start_int_set_rising_edge(SE_USB_INT); |
274 | start_int_umask(SE_USB_INT); | 345 | start_int_ack(SE_USB_INT); |
275 | 346 | start_int_umask(SE_USB_INT); | |
276 | start_int_set_rising_edge(SE_USB_NEED_CLK_INT); | 347 | |
277 | start_int_ack(SE_USB_NEED_CLK_INT); | 348 | start_int_set_rising_edge(SE_USB_NEED_CLK_INT); |
278 | start_int_umask(SE_USB_NEED_CLK_INT); | 349 | start_int_ack(SE_USB_NEED_CLK_INT); |
279 | 350 | start_int_umask(SE_USB_NEED_CLK_INT); | |
280 | start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT); | 351 | |
281 | start_int_ack(SE_USB_AHB_NEED_CLK_INT); | 352 | start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT); |
282 | start_int_umask(SE_USB_AHB_NEED_CLK_INT); | 353 | start_int_ack(SE_USB_AHB_NEED_CLK_INT); |
354 | start_int_umask(SE_USB_AHB_NEED_CLK_INT); | ||
355 | } | ||
283 | } | 356 | } |
284 | 357 | ||
285 | static void pnx4008_unset_usb_bits(void) | 358 | static void nxp_unset_usb_bits(void) |
286 | { | 359 | { |
287 | start_int_mask(SE_USB_OTG_ATX_INT_N); | 360 | if (machine_is_pnx4008()) { |
288 | start_int_mask(SE_USB_OTG_TIMER_INT); | 361 | start_int_mask(SE_USB_OTG_ATX_INT_N); |
289 | start_int_mask(SE_USB_I2C_INT); | 362 | start_int_mask(SE_USB_OTG_TIMER_INT); |
290 | start_int_mask(SE_USB_INT); | 363 | start_int_mask(SE_USB_I2C_INT); |
291 | start_int_mask(SE_USB_NEED_CLK_INT); | 364 | start_int_mask(SE_USB_INT); |
292 | start_int_mask(SE_USB_AHB_NEED_CLK_INT); | 365 | start_int_mask(SE_USB_NEED_CLK_INT); |
366 | start_int_mask(SE_USB_AHB_NEED_CLK_INT); | ||
367 | } | ||
293 | } | 368 | } |
294 | 369 | ||
295 | static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | 370 | static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) |
296 | { | 371 | { |
297 | struct usb_hcd *hcd = 0; | 372 | struct usb_hcd *hcd = 0; |
298 | struct ohci_hcd *ohci; | 373 | struct ohci_hcd *ohci; |
299 | const struct hc_driver *driver = &ohci_pnx4008_hc_driver; | 374 | const struct hc_driver *driver = &ohci_nxp_hc_driver; |
300 | struct i2c_adapter *i2c_adap; | 375 | struct i2c_adapter *i2c_adap; |
301 | struct i2c_board_info i2c_info; | 376 | struct i2c_board_info i2c_info; |
302 | 377 | ||
303 | int ret = 0, irq; | 378 | int ret = 0, irq; |
304 | 379 | ||
305 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name); | 380 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name); |
306 | if (usb_disabled()) { | 381 | if (usb_disabled()) { |
307 | err("USB is disabled"); | 382 | err("USB is disabled"); |
308 | ret = -ENODEV; | 383 | ret = -ENODEV; |
@@ -327,7 +402,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
327 | } | 402 | } |
328 | i2c_adap = i2c_get_adapter(2); | 403 | i2c_adap = i2c_get_adapter(2); |
329 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); | 404 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); |
330 | strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); | 405 | strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE); |
331 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, | 406 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, |
332 | normal_i2c, NULL); | 407 | normal_i2c, NULL); |
333 | i2c_put_adapter(i2c_adap); | 408 | i2c_put_adapter(i2c_adap); |
@@ -375,7 +450,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
375 | } | 450 | } |
376 | 451 | ||
377 | /* Set all USB bits in the Start Enable register */ | 452 | /* Set all USB bits in the Start Enable register */ |
378 | pnx4008_set_usb_bits(); | 453 | nxp_set_usb_bits(); |
379 | 454 | ||
380 | hcd->rsrc_start = pdev->resource[0].start; | 455 | hcd->rsrc_start = pdev->resource[0].start; |
381 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | 456 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; |
@@ -392,7 +467,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
392 | goto out4; | 467 | goto out4; |
393 | } | 468 | } |
394 | 469 | ||
395 | pnx4008_start_hc(); | 470 | nxp_start_hc(); |
396 | platform_set_drvdata(pdev, hcd); | 471 | platform_set_drvdata(pdev, hcd); |
397 | ohci = hcd_to_ohci(hcd); | 472 | ohci = hcd_to_ohci(hcd); |
398 | ohci_hcd_init(ohci); | 473 | ohci_hcd_init(ohci); |
@@ -402,9 +477,9 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
402 | if (ret == 0) | 477 | if (ret == 0) |
403 | return ret; | 478 | return ret; |
404 | 479 | ||
405 | pnx4008_stop_hc(); | 480 | nxp_stop_hc(); |
406 | out4: | 481 | out4: |
407 | pnx4008_unset_usb_bits(); | 482 | nxp_unset_usb_bits(); |
408 | usb_put_hcd(hcd); | 483 | usb_put_hcd(hcd); |
409 | out3: | 484 | out3: |
410 | clk_disable(usb_clk); | 485 | clk_disable(usb_clk); |
@@ -419,15 +494,15 @@ out: | |||
419 | return ret; | 494 | return ret; |
420 | } | 495 | } |
421 | 496 | ||
422 | static int usb_hcd_pnx4008_remove(struct platform_device *pdev) | 497 | static int usb_hcd_nxp_remove(struct platform_device *pdev) |
423 | { | 498 | { |
424 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 499 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
425 | 500 | ||
426 | usb_remove_hcd(hcd); | 501 | usb_remove_hcd(hcd); |
427 | pnx4008_stop_hc(); | 502 | nxp_stop_hc(); |
428 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 503 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
429 | usb_put_hcd(hcd); | 504 | usb_put_hcd(hcd); |
430 | pnx4008_unset_usb_bits(); | 505 | nxp_unset_usb_bits(); |
431 | clk_disable(usb_clk); | 506 | clk_disable(usb_clk); |
432 | clk_put(usb_clk); | 507 | clk_put(usb_clk); |
433 | i2c_unregister_device(isp1301_i2c_client); | 508 | i2c_unregister_device(isp1301_i2c_client); |
@@ -442,12 +517,12 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev) | |||
442 | /* work with hotplug and coldplug */ | 517 | /* work with hotplug and coldplug */ |
443 | MODULE_ALIAS("platform:usb-ohci"); | 518 | MODULE_ALIAS("platform:usb-ohci"); |
444 | 519 | ||
445 | static struct platform_driver usb_hcd_pnx4008_driver = { | 520 | static struct platform_driver usb_hcd_nxp_driver = { |
446 | .driver = { | 521 | .driver = { |
447 | .name = "usb-ohci", | 522 | .name = "usb-ohci", |
448 | .owner = THIS_MODULE, | 523 | .owner = THIS_MODULE, |
449 | }, | 524 | }, |
450 | .probe = usb_hcd_pnx4008_probe, | 525 | .probe = usb_hcd_nxp_probe, |
451 | .remove = usb_hcd_pnx4008_remove, | 526 | .remove = usb_hcd_nxp_remove, |
452 | }; | 527 | }; |
453 | 528 | ||
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index db3968656d21..96451e41ee8a 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -171,7 +171,7 @@ static void start_hnp(struct ohci_hcd *ohci) | |||
171 | unsigned long flags; | 171 | unsigned long flags; |
172 | u32 l; | 172 | u32 l; |
173 | 173 | ||
174 | otg_start_hnp(ohci->transceiver); | 174 | otg_start_hnp(ohci->transceiver->otg); |
175 | 175 | ||
176 | local_irq_save(flags); | 176 | local_irq_save(flags); |
177 | ohci->transceiver->state = OTG_STATE_A_SUSPEND; | 177 | ohci->transceiver->state = OTG_STATE_A_SUSPEND; |
@@ -210,9 +210,9 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
210 | 210 | ||
211 | #ifdef CONFIG_USB_OTG | 211 | #ifdef CONFIG_USB_OTG |
212 | if (need_transceiver) { | 212 | if (need_transceiver) { |
213 | ohci->transceiver = otg_get_transceiver(); | 213 | ohci->transceiver = usb_get_transceiver(); |
214 | if (ohci->transceiver) { | 214 | if (ohci->transceiver) { |
215 | int status = otg_set_host(ohci->transceiver, | 215 | int status = otg_set_host(ohci->transceiver->otg, |
216 | &ohci_to_hcd(ohci)->self); | 216 | &ohci_to_hcd(ohci)->self); |
217 | dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", | 217 | dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", |
218 | ohci->transceiver->label, status); | 218 | ohci->transceiver->label, status); |
@@ -404,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | |||
404 | 404 | ||
405 | usb_remove_hcd(hcd); | 405 | usb_remove_hcd(hcd); |
406 | if (ohci->transceiver) { | 406 | if (ohci->transceiver) { |
407 | (void) otg_set_host(ohci->transceiver, 0); | 407 | (void) otg_set_host(ohci->transceiver->otg, 0); |
408 | put_device(ohci->transceiver->dev); | 408 | put_device(ohci->transceiver->dev); |
409 | } | 409 | } |
410 | if (machine_is_omap_osk()) | 410 | if (machine_is_omap_osk()) |
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c new file mode 100644 index 000000000000..ec5c6791c8b4 --- /dev/null +++ b/drivers/usb/host/ohci-platform.c | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | * Generic platform ohci driver | ||
3 | * | ||
4 | * Copyright 2007 Michael Buesch <m@bues.ch> | ||
5 | * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
6 | * | ||
7 | * Derived from the OCHI-SSB driver | ||
8 | * Derived from the OHCI-PCI driver | ||
9 | * Copyright 1999 Roman Weissgaerber | ||
10 | * Copyright 2000-2002 David Brownell | ||
11 | * Copyright 1999 Linus Torvalds | ||
12 | * Copyright 1999 Gregory P. Smith | ||
13 | * | ||
14 | * Licensed under the GNU/GPL. See COPYING for details. | ||
15 | */ | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/usb/ohci_pdriver.h> | ||
18 | |||
19 | static int ohci_platform_reset(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
22 | struct usb_ohci_pdata *pdata = pdev->dev.platform_data; | ||
23 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
24 | int err; | ||
25 | |||
26 | if (pdata->big_endian_desc) | ||
27 | ohci->flags |= OHCI_QUIRK_BE_DESC; | ||
28 | if (pdata->big_endian_mmio) | ||
29 | ohci->flags |= OHCI_QUIRK_BE_MMIO; | ||
30 | if (pdata->no_big_frame_no) | ||
31 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | ||
32 | |||
33 | ohci_hcd_init(ohci); | ||
34 | err = ohci_init(ohci); | ||
35 | |||
36 | return err; | ||
37 | } | ||
38 | |||
39 | static int ohci_platform_start(struct usb_hcd *hcd) | ||
40 | { | ||
41 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
42 | int err; | ||
43 | |||
44 | err = ohci_run(ohci); | ||
45 | if (err < 0) { | ||
46 | ohci_err(ohci, "can't start\n"); | ||
47 | ohci_stop(hcd); | ||
48 | } | ||
49 | |||
50 | return err; | ||
51 | } | ||
52 | |||
53 | static const struct hc_driver ohci_platform_hc_driver = { | ||
54 | .description = hcd_name, | ||
55 | .product_desc = "Generic Platform OHCI Controller", | ||
56 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
57 | |||
58 | .irq = ohci_irq, | ||
59 | .flags = HCD_MEMORY | HCD_USB11, | ||
60 | |||
61 | .reset = ohci_platform_reset, | ||
62 | .start = ohci_platform_start, | ||
63 | .stop = ohci_stop, | ||
64 | .shutdown = ohci_shutdown, | ||
65 | |||
66 | .urb_enqueue = ohci_urb_enqueue, | ||
67 | .urb_dequeue = ohci_urb_dequeue, | ||
68 | .endpoint_disable = ohci_endpoint_disable, | ||
69 | |||
70 | .get_frame_number = ohci_get_frame, | ||
71 | |||
72 | .hub_status_data = ohci_hub_status_data, | ||
73 | .hub_control = ohci_hub_control, | ||
74 | #ifdef CONFIG_PM | ||
75 | .bus_suspend = ohci_bus_suspend, | ||
76 | .bus_resume = ohci_bus_resume, | ||
77 | #endif | ||
78 | |||
79 | .start_port_reset = ohci_start_port_reset, | ||
80 | }; | ||
81 | |||
82 | static int __devinit ohci_platform_probe(struct platform_device *dev) | ||
83 | { | ||
84 | struct usb_hcd *hcd; | ||
85 | struct resource *res_mem; | ||
86 | int irq; | ||
87 | int err = -ENOMEM; | ||
88 | |||
89 | BUG_ON(!dev->dev.platform_data); | ||
90 | |||
91 | if (usb_disabled()) | ||
92 | return -ENODEV; | ||
93 | |||
94 | irq = platform_get_irq(dev, 0); | ||
95 | if (irq < 0) { | ||
96 | pr_err("no irq provieded"); | ||
97 | return irq; | ||
98 | } | ||
99 | |||
100 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
101 | if (!res_mem) { | ||
102 | pr_err("no memory recourse provieded"); | ||
103 | return -ENXIO; | ||
104 | } | ||
105 | |||
106 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, | ||
107 | dev_name(&dev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res_mem->start; | ||
112 | hcd->rsrc_len = resource_size(res_mem); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
115 | pr_err("controller already in use"); | ||
116 | err = -EBUSY; | ||
117 | goto err_put_hcd; | ||
118 | } | ||
119 | |||
120 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
121 | if (!hcd->regs) | ||
122 | goto err_release_region; | ||
123 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
124 | if (err) | ||
125 | goto err_iounmap; | ||
126 | |||
127 | platform_set_drvdata(dev, hcd); | ||
128 | |||
129 | return err; | ||
130 | |||
131 | err_iounmap: | ||
132 | iounmap(hcd->regs); | ||
133 | err_release_region: | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | err_put_hcd: | ||
136 | usb_put_hcd(hcd); | ||
137 | return err; | ||
138 | } | ||
139 | |||
140 | static int __devexit ohci_platform_remove(struct platform_device *dev) | ||
141 | { | ||
142 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
143 | |||
144 | usb_remove_hcd(hcd); | ||
145 | iounmap(hcd->regs); | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | usb_put_hcd(hcd); | ||
148 | platform_set_drvdata(dev, NULL); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | #ifdef CONFIG_PM | ||
154 | |||
155 | static int ohci_platform_suspend(struct device *dev) | ||
156 | { | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static int ohci_platform_resume(struct device *dev) | ||
161 | { | ||
162 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
163 | |||
164 | ohci_finish_controller_resume(hcd); | ||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | #else /* !CONFIG_PM */ | ||
169 | #define ohci_platform_suspend NULL | ||
170 | #define ohci_platform_resume NULL | ||
171 | #endif /* CONFIG_PM */ | ||
172 | |||
173 | static const struct platform_device_id ohci_platform_table[] = { | ||
174 | { "ohci-platform", 0 }, | ||
175 | { } | ||
176 | }; | ||
177 | MODULE_DEVICE_TABLE(platform, ohci_platform_table); | ||
178 | |||
179 | static const struct dev_pm_ops ohci_platform_pm_ops = { | ||
180 | .suspend = ohci_platform_suspend, | ||
181 | .resume = ohci_platform_resume, | ||
182 | }; | ||
183 | |||
184 | static struct platform_driver ohci_platform_driver = { | ||
185 | .id_table = ohci_platform_table, | ||
186 | .probe = ohci_platform_probe, | ||
187 | .remove = __devexit_p(ohci_platform_remove), | ||
188 | .shutdown = usb_hcd_platform_shutdown, | ||
189 | .driver = { | ||
190 | .owner = THIS_MODULE, | ||
191 | .name = "ohci-platform", | ||
192 | .pm = &ohci_platform_pm_ops, | ||
193 | } | ||
194 | }; | ||
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 6313e4439f37..c31b2815be1c 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <mach/hardware.h> | ||
26 | #include <mach/ohci.h> | 27 | #include <mach/ohci.h> |
27 | #include <mach/pxa3xx-u2d.h> | 28 | #include <mach/pxa3xx-u2d.h> |
28 | 29 | ||
@@ -218,7 +219,7 @@ static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev) | |||
218 | 219 | ||
219 | inf = dev->platform_data; | 220 | inf = dev->platform_data; |
220 | 221 | ||
221 | clk_enable(ohci->clk); | 222 | clk_prepare_enable(ohci->clk); |
222 | 223 | ||
223 | pxa27x_reset_hc(ohci); | 224 | pxa27x_reset_hc(ohci); |
224 | 225 | ||
@@ -268,7 +269,7 @@ static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev) | |||
268 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); | 269 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); |
269 | udelay(10); | 270 | udelay(10); |
270 | 271 | ||
271 | clk_disable(ohci->clk); | 272 | clk_disable_unprepare(ohci->clk); |
272 | } | 273 | } |
273 | 274 | ||
274 | 275 | ||
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 8ff6f7ea96fd..1b19aea25a2b 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -376,7 +376,7 @@ struct ohci_hcd { | |||
376 | * OTG controllers and transceivers need software interaction; | 376 | * OTG controllers and transceivers need software interaction; |
377 | * other external transceivers should be software-transparent | 377 | * other external transceivers should be software-transparent |
378 | */ | 378 | */ |
379 | struct otg_transceiver *transceiver; | 379 | struct usb_phy *transceiver; |
380 | void (*start_hnp)(struct ohci_hcd *ohci); | 380 | void (*start_hnp)(struct ohci_hcd *ohci); |
381 | 381 | ||
382 | /* | 382 | /* |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index e84ca1928dbf..2bf1320dc9c3 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -2428,6 +2428,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2428 | int i; | 2428 | int i; |
2429 | unsigned long irq_trigger; | 2429 | unsigned long irq_trigger; |
2430 | 2430 | ||
2431 | if (usb_disabled()) | ||
2432 | return -ENODEV; | ||
2433 | |||
2431 | if (pdev->dev.dma_mask) { | 2434 | if (pdev->dev.dma_mask) { |
2432 | ret = -EINVAL; | 2435 | ret = -EINVAL; |
2433 | dev_err(&pdev->dev, "dma not supported\n"); | 2436 | dev_err(&pdev->dev, "dma not supported\n"); |
@@ -2552,20 +2555,4 @@ static struct platform_driver r8a66597_driver = { | |||
2552 | }, | 2555 | }, |
2553 | }; | 2556 | }; |
2554 | 2557 | ||
2555 | static int __init r8a66597_init(void) | 2558 | module_platform_driver(r8a66597_driver); |
2556 | { | ||
2557 | if (usb_disabled()) | ||
2558 | return -ENODEV; | ||
2559 | |||
2560 | printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name, | ||
2561 | DRIVER_VERSION); | ||
2562 | return platform_driver_register(&r8a66597_driver); | ||
2563 | } | ||
2564 | module_init(r8a66597_init); | ||
2565 | |||
2566 | static void __exit r8a66597_cleanup(void) | ||
2567 | { | ||
2568 | platform_driver_unregister(&r8a66597_driver); | ||
2569 | } | ||
2570 | module_exit(r8a66597_cleanup); | ||
2571 | |||
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 961d6638d8f9..2a2cce2d2fa7 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1632,6 +1632,9 @@ sl811h_probe(struct platform_device *dev) | |||
1632 | u8 tmp, ioaddr = 0; | 1632 | u8 tmp, ioaddr = 0; |
1633 | unsigned long irqflags; | 1633 | unsigned long irqflags; |
1634 | 1634 | ||
1635 | if (usb_disabled()) | ||
1636 | return -ENODEV; | ||
1637 | |||
1635 | /* basic sanity checks first. board-specific init logic should | 1638 | /* basic sanity checks first. board-specific init logic should |
1636 | * have initialized these three resources and probably board | 1639 | * have initialized these three resources and probably board |
1637 | * specific platform_data. we don't probe for IRQs, and do only | 1640 | * specific platform_data. we don't probe for IRQs, and do only |
@@ -1817,20 +1820,4 @@ struct platform_driver sl811h_driver = { | |||
1817 | }; | 1820 | }; |
1818 | EXPORT_SYMBOL(sl811h_driver); | 1821 | EXPORT_SYMBOL(sl811h_driver); |
1819 | 1822 | ||
1820 | /*-------------------------------------------------------------------------*/ | 1823 | module_platform_driver(sl811h_driver); |
1821 | |||
1822 | static int __init sl811h_init(void) | ||
1823 | { | ||
1824 | if (usb_disabled()) | ||
1825 | return -ENODEV; | ||
1826 | |||
1827 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
1828 | return platform_driver_register(&sl811h_driver); | ||
1829 | } | ||
1830 | module_init(sl811h_init); | ||
1831 | |||
1832 | static void __exit sl811h_cleanup(void) | ||
1833 | { | ||
1834 | platform_driver_unregister(&sl811h_driver); | ||
1835 | } | ||
1836 | module_exit(sl811h_cleanup); | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 6b5eb1017e2c..e37dea87bb56 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -565,6 +565,9 @@ static int uhci_start(struct usb_hcd *hcd) | |||
565 | struct dentry __maybe_unused *dentry; | 565 | struct dentry __maybe_unused *dentry; |
566 | 566 | ||
567 | hcd->uses_new_polling = 1; | 567 | hcd->uses_new_polling = 1; |
568 | /* Accept arbitrarily long scatter-gather lists */ | ||
569 | if (!(hcd->driver->flags & HCD_LOCAL_MEM)) | ||
570 | hcd->self.sg_tablesize = ~0; | ||
568 | 571 | ||
569 | spin_lock_init(&uhci->lock); | 572 | spin_lock_init(&uhci->lock); |
570 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, | 573 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 557b6f32db86..673ad120c43e 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -422,6 +422,32 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, | |||
422 | xhci_writel(xhci, temp, port_array[port_id]); | 422 | xhci_writel(xhci, temp, port_array[port_id]); |
423 | } | 423 | } |
424 | 424 | ||
425 | void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, | ||
426 | __le32 __iomem **port_array, int port_id, u16 wake_mask) | ||
427 | { | ||
428 | u32 temp; | ||
429 | |||
430 | temp = xhci_readl(xhci, port_array[port_id]); | ||
431 | temp = xhci_port_state_to_neutral(temp); | ||
432 | |||
433 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT) | ||
434 | temp |= PORT_WKCONN_E; | ||
435 | else | ||
436 | temp &= ~PORT_WKCONN_E; | ||
437 | |||
438 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT) | ||
439 | temp |= PORT_WKDISC_E; | ||
440 | else | ||
441 | temp &= ~PORT_WKDISC_E; | ||
442 | |||
443 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT) | ||
444 | temp |= PORT_WKOC_E; | ||
445 | else | ||
446 | temp &= ~PORT_WKOC_E; | ||
447 | |||
448 | xhci_writel(xhci, temp, port_array[port_id]); | ||
449 | } | ||
450 | |||
425 | /* Test and clear port RWC bit */ | 451 | /* Test and clear port RWC bit */ |
426 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, | 452 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, |
427 | int port_id, u32 port_bit) | 453 | int port_id, u32 port_bit) |
@@ -448,6 +474,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
448 | int slot_id; | 474 | int slot_id; |
449 | struct xhci_bus_state *bus_state; | 475 | struct xhci_bus_state *bus_state; |
450 | u16 link_state = 0; | 476 | u16 link_state = 0; |
477 | u16 wake_mask = 0; | ||
451 | 478 | ||
452 | max_ports = xhci_get_ports(hcd, &port_array); | 479 | max_ports = xhci_get_ports(hcd, &port_array); |
453 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 480 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
@@ -593,6 +620,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
593 | case SetPortFeature: | 620 | case SetPortFeature: |
594 | if (wValue == USB_PORT_FEAT_LINK_STATE) | 621 | if (wValue == USB_PORT_FEAT_LINK_STATE) |
595 | link_state = (wIndex & 0xff00) >> 3; | 622 | link_state = (wIndex & 0xff00) >> 3; |
623 | if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK) | ||
624 | wake_mask = wIndex & 0xff00; | ||
596 | wIndex &= 0xff; | 625 | wIndex &= 0xff; |
597 | if (!wIndex || wIndex > max_ports) | 626 | if (!wIndex || wIndex > max_ports) |
598 | goto error; | 627 | goto error; |
@@ -703,6 +732,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
703 | temp = xhci_readl(xhci, port_array[wIndex]); | 732 | temp = xhci_readl(xhci, port_array[wIndex]); |
704 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); | 733 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); |
705 | break; | 734 | break; |
735 | case USB_PORT_FEAT_REMOTE_WAKE_MASK: | ||
736 | xhci_set_remote_wake_mask(xhci, port_array, | ||
737 | wIndex, wake_mask); | ||
738 | temp = xhci_readl(xhci, port_array[wIndex]); | ||
739 | xhci_dbg(xhci, "set port remote wake mask, " | ||
740 | "actual port %d status = 0x%x\n", | ||
741 | wIndex, temp); | ||
742 | break; | ||
706 | case USB_PORT_FEAT_BH_PORT_RESET: | 743 | case USB_PORT_FEAT_BH_PORT_RESET: |
707 | temp |= PORT_WR; | 744 | temp |= PORT_WR; |
708 | xhci_writel(xhci, temp, port_array[wIndex]); | 745 | xhci_writel(xhci, temp, port_array[wIndex]); |
@@ -883,6 +920,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
883 | t2 |= PORT_LINK_STROBE | XDEV_U3; | 920 | t2 |= PORT_LINK_STROBE | XDEV_U3; |
884 | set_bit(port_index, &bus_state->bus_suspended); | 921 | set_bit(port_index, &bus_state->bus_suspended); |
885 | } | 922 | } |
923 | /* USB core sets remote wake mask for USB 3.0 hubs, | ||
924 | * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND | ||
925 | * is enabled, so also enable remote wake here. | ||
926 | */ | ||
886 | if (hcd->self.root_hub->do_remote_wakeup) { | 927 | if (hcd->self.root_hub->do_remote_wakeup) { |
887 | if (t1 & PORT_CONNECT) { | 928 | if (t1 & PORT_CONNECT) { |
888 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; | 929 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 383fc857491c..cae4c6f2845a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -34,10 +34,12 @@ | |||
34 | * Section 4.11.1.1: | 34 | * Section 4.11.1.1: |
35 | * "All components of all Command and Transfer TRBs shall be initialized to '0'" | 35 | * "All components of all Command and Transfer TRBs shall be initialized to '0'" |
36 | */ | 36 | */ |
37 | static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flags) | 37 | static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, |
38 | unsigned int cycle_state, gfp_t flags) | ||
38 | { | 39 | { |
39 | struct xhci_segment *seg; | 40 | struct xhci_segment *seg; |
40 | dma_addr_t dma; | 41 | dma_addr_t dma; |
42 | int i; | ||
41 | 43 | ||
42 | seg = kzalloc(sizeof *seg, flags); | 44 | seg = kzalloc(sizeof *seg, flags); |
43 | if (!seg) | 45 | if (!seg) |
@@ -50,6 +52,11 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flag | |||
50 | } | 52 | } |
51 | 53 | ||
52 | memset(seg->trbs, 0, SEGMENT_SIZE); | 54 | memset(seg->trbs, 0, SEGMENT_SIZE); |
55 | /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */ | ||
56 | if (cycle_state == 0) { | ||
57 | for (i = 0; i < TRBS_PER_SEGMENT; i++) | ||
58 | seg->trbs[i].link.control |= TRB_CYCLE; | ||
59 | } | ||
53 | seg->dma = dma; | 60 | seg->dma = dma; |
54 | seg->next = NULL; | 61 | seg->next = NULL; |
55 | 62 | ||
@@ -65,6 +72,20 @@ static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) | |||
65 | kfree(seg); | 72 | kfree(seg); |
66 | } | 73 | } |
67 | 74 | ||
75 | static void xhci_free_segments_for_ring(struct xhci_hcd *xhci, | ||
76 | struct xhci_segment *first) | ||
77 | { | ||
78 | struct xhci_segment *seg; | ||
79 | |||
80 | seg = first->next; | ||
81 | while (seg != first) { | ||
82 | struct xhci_segment *next = seg->next; | ||
83 | xhci_segment_free(xhci, seg); | ||
84 | seg = next; | ||
85 | } | ||
86 | xhci_segment_free(xhci, first); | ||
87 | } | ||
88 | |||
68 | /* | 89 | /* |
69 | * Make the prev segment point to the next segment. | 90 | * Make the prev segment point to the next segment. |
70 | * | 91 | * |
@@ -73,14 +94,14 @@ static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) | |||
73 | * related flags, such as End TRB, Toggle Cycle, and no snoop. | 94 | * related flags, such as End TRB, Toggle Cycle, and no snoop. |
74 | */ | 95 | */ |
75 | static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | 96 | static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, |
76 | struct xhci_segment *next, bool link_trbs, bool isoc) | 97 | struct xhci_segment *next, enum xhci_ring_type type) |
77 | { | 98 | { |
78 | u32 val; | 99 | u32 val; |
79 | 100 | ||
80 | if (!prev || !next) | 101 | if (!prev || !next) |
81 | return; | 102 | return; |
82 | prev->next = next; | 103 | prev->next = next; |
83 | if (link_trbs) { | 104 | if (type != TYPE_EVENT) { |
84 | prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = | 105 | prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = |
85 | cpu_to_le64(next->dma); | 106 | cpu_to_le64(next->dma); |
86 | 107 | ||
@@ -91,35 +112,55 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | |||
91 | /* Always set the chain bit with 0.95 hardware */ | 112 | /* Always set the chain bit with 0.95 hardware */ |
92 | /* Set chain bit for isoc rings on AMD 0.96 host */ | 113 | /* Set chain bit for isoc rings on AMD 0.96 host */ |
93 | if (xhci_link_trb_quirk(xhci) || | 114 | if (xhci_link_trb_quirk(xhci) || |
94 | (isoc && (xhci->quirks & XHCI_AMD_0x96_HOST))) | 115 | (type == TYPE_ISOC && |
116 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | ||
95 | val |= TRB_CHAIN; | 117 | val |= TRB_CHAIN; |
96 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); | 118 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); |
97 | } | 119 | } |
98 | } | 120 | } |
99 | 121 | ||
122 | /* | ||
123 | * Link the ring to the new segments. | ||
124 | * Set Toggle Cycle for the new ring if needed. | ||
125 | */ | ||
126 | static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
127 | struct xhci_segment *first, struct xhci_segment *last, | ||
128 | unsigned int num_segs) | ||
129 | { | ||
130 | struct xhci_segment *next; | ||
131 | |||
132 | if (!ring || !first || !last) | ||
133 | return; | ||
134 | |||
135 | next = ring->enq_seg->next; | ||
136 | xhci_link_segments(xhci, ring->enq_seg, first, ring->type); | ||
137 | xhci_link_segments(xhci, last, next, ring->type); | ||
138 | ring->num_segs += num_segs; | ||
139 | ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs; | ||
140 | |||
141 | if (ring->type != TYPE_EVENT && ring->enq_seg == ring->last_seg) { | ||
142 | ring->last_seg->trbs[TRBS_PER_SEGMENT-1].link.control | ||
143 | &= ~cpu_to_le32(LINK_TOGGLE); | ||
144 | last->trbs[TRBS_PER_SEGMENT-1].link.control | ||
145 | |= cpu_to_le32(LINK_TOGGLE); | ||
146 | ring->last_seg = last; | ||
147 | } | ||
148 | } | ||
149 | |||
100 | /* XXX: Do we need the hcd structure in all these functions? */ | 150 | /* XXX: Do we need the hcd structure in all these functions? */ |
101 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) | 151 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) |
102 | { | 152 | { |
103 | struct xhci_segment *seg; | ||
104 | struct xhci_segment *first_seg; | ||
105 | |||
106 | if (!ring) | 153 | if (!ring) |
107 | return; | 154 | return; |
108 | if (ring->first_seg) { | 155 | |
109 | first_seg = ring->first_seg; | 156 | if (ring->first_seg) |
110 | seg = first_seg->next; | 157 | xhci_free_segments_for_ring(xhci, ring->first_seg); |
111 | while (seg != first_seg) { | 158 | |
112 | struct xhci_segment *next = seg->next; | ||
113 | xhci_segment_free(xhci, seg); | ||
114 | seg = next; | ||
115 | } | ||
116 | xhci_segment_free(xhci, first_seg); | ||
117 | ring->first_seg = NULL; | ||
118 | } | ||
119 | kfree(ring); | 159 | kfree(ring); |
120 | } | 160 | } |
121 | 161 | ||
122 | static void xhci_initialize_ring_info(struct xhci_ring *ring) | 162 | static void xhci_initialize_ring_info(struct xhci_ring *ring, |
163 | unsigned int cycle_state) | ||
123 | { | 164 | { |
124 | /* The ring is empty, so the enqueue pointer == dequeue pointer */ | 165 | /* The ring is empty, so the enqueue pointer == dequeue pointer */ |
125 | ring->enqueue = ring->first_seg->trbs; | 166 | ring->enqueue = ring->first_seg->trbs; |
@@ -129,11 +170,53 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring) | |||
129 | /* The ring is initialized to 0. The producer must write 1 to the cycle | 170 | /* The ring is initialized to 0. The producer must write 1 to the cycle |
130 | * bit to handover ownership of the TRB, so PCS = 1. The consumer must | 171 | * bit to handover ownership of the TRB, so PCS = 1. The consumer must |
131 | * compare CCS to the cycle bit to check ownership, so CCS = 1. | 172 | * compare CCS to the cycle bit to check ownership, so CCS = 1. |
173 | * | ||
174 | * New rings are initialized with cycle state equal to 1; if we are | ||
175 | * handling ring expansion, set the cycle state equal to the old ring. | ||
132 | */ | 176 | */ |
133 | ring->cycle_state = 1; | 177 | ring->cycle_state = cycle_state; |
134 | /* Not necessary for new rings, but needed for re-initialized rings */ | 178 | /* Not necessary for new rings, but needed for re-initialized rings */ |
135 | ring->enq_updates = 0; | 179 | ring->enq_updates = 0; |
136 | ring->deq_updates = 0; | 180 | ring->deq_updates = 0; |
181 | |||
182 | /* | ||
183 | * Each segment has a link TRB, and leave an extra TRB for SW | ||
184 | * accounting purpose | ||
185 | */ | ||
186 | ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; | ||
187 | } | ||
188 | |||
189 | /* Allocate segments and link them for a ring */ | ||
190 | static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, | ||
191 | struct xhci_segment **first, struct xhci_segment **last, | ||
192 | unsigned int num_segs, unsigned int cycle_state, | ||
193 | enum xhci_ring_type type, gfp_t flags) | ||
194 | { | ||
195 | struct xhci_segment *prev; | ||
196 | |||
197 | prev = xhci_segment_alloc(xhci, cycle_state, flags); | ||
198 | if (!prev) | ||
199 | return -ENOMEM; | ||
200 | num_segs--; | ||
201 | |||
202 | *first = prev; | ||
203 | while (num_segs > 0) { | ||
204 | struct xhci_segment *next; | ||
205 | |||
206 | next = xhci_segment_alloc(xhci, cycle_state, flags); | ||
207 | if (!next) { | ||
208 | xhci_free_segments_for_ring(xhci, *first); | ||
209 | return -ENOMEM; | ||
210 | } | ||
211 | xhci_link_segments(xhci, prev, next, type); | ||
212 | |||
213 | prev = next; | ||
214 | num_segs--; | ||
215 | } | ||
216 | xhci_link_segments(xhci, prev, *first, type); | ||
217 | *last = prev; | ||
218 | |||
219 | return 0; | ||
137 | } | 220 | } |
138 | 221 | ||
139 | /** | 222 | /** |
@@ -144,44 +227,34 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring) | |||
144 | * See section 4.9.1 and figures 15 and 16. | 227 | * See section 4.9.1 and figures 15 and 16. |
145 | */ | 228 | */ |
146 | static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | 229 | static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, |
147 | unsigned int num_segs, bool link_trbs, bool isoc, gfp_t flags) | 230 | unsigned int num_segs, unsigned int cycle_state, |
231 | enum xhci_ring_type type, gfp_t flags) | ||
148 | { | 232 | { |
149 | struct xhci_ring *ring; | 233 | struct xhci_ring *ring; |
150 | struct xhci_segment *prev; | 234 | int ret; |
151 | 235 | ||
152 | ring = kzalloc(sizeof *(ring), flags); | 236 | ring = kzalloc(sizeof *(ring), flags); |
153 | if (!ring) | 237 | if (!ring) |
154 | return NULL; | 238 | return NULL; |
155 | 239 | ||
240 | ring->num_segs = num_segs; | ||
156 | INIT_LIST_HEAD(&ring->td_list); | 241 | INIT_LIST_HEAD(&ring->td_list); |
242 | ring->type = type; | ||
157 | if (num_segs == 0) | 243 | if (num_segs == 0) |
158 | return ring; | 244 | return ring; |
159 | 245 | ||
160 | ring->first_seg = xhci_segment_alloc(xhci, flags); | 246 | ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, |
161 | if (!ring->first_seg) | 247 | &ring->last_seg, num_segs, cycle_state, type, flags); |
248 | if (ret) | ||
162 | goto fail; | 249 | goto fail; |
163 | num_segs--; | ||
164 | 250 | ||
165 | prev = ring->first_seg; | 251 | /* Only event ring does not use link TRB */ |
166 | while (num_segs > 0) { | 252 | if (type != TYPE_EVENT) { |
167 | struct xhci_segment *next; | ||
168 | |||
169 | next = xhci_segment_alloc(xhci, flags); | ||
170 | if (!next) | ||
171 | goto fail; | ||
172 | xhci_link_segments(xhci, prev, next, link_trbs, isoc); | ||
173 | |||
174 | prev = next; | ||
175 | num_segs--; | ||
176 | } | ||
177 | xhci_link_segments(xhci, prev, ring->first_seg, link_trbs, isoc); | ||
178 | |||
179 | if (link_trbs) { | ||
180 | /* See section 4.9.2.1 and 6.4.4.1 */ | 253 | /* See section 4.9.2.1 and 6.4.4.1 */ |
181 | prev->trbs[TRBS_PER_SEGMENT-1].link.control |= | 254 | ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= |
182 | cpu_to_le32(LINK_TOGGLE); | 255 | cpu_to_le32(LINK_TOGGLE); |
183 | } | 256 | } |
184 | xhci_initialize_ring_info(ring); | 257 | xhci_initialize_ring_info(ring, cycle_state); |
185 | return ring; | 258 | return ring; |
186 | 259 | ||
187 | fail: | 260 | fail: |
@@ -217,23 +290,64 @@ void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | |||
217 | * pointers to the beginning of the ring. | 290 | * pointers to the beginning of the ring. |
218 | */ | 291 | */ |
219 | static void xhci_reinit_cached_ring(struct xhci_hcd *xhci, | 292 | static void xhci_reinit_cached_ring(struct xhci_hcd *xhci, |
220 | struct xhci_ring *ring, bool isoc) | 293 | struct xhci_ring *ring, unsigned int cycle_state, |
294 | enum xhci_ring_type type) | ||
221 | { | 295 | { |
222 | struct xhci_segment *seg = ring->first_seg; | 296 | struct xhci_segment *seg = ring->first_seg; |
297 | int i; | ||
298 | |||
223 | do { | 299 | do { |
224 | memset(seg->trbs, 0, | 300 | memset(seg->trbs, 0, |
225 | sizeof(union xhci_trb)*TRBS_PER_SEGMENT); | 301 | sizeof(union xhci_trb)*TRBS_PER_SEGMENT); |
302 | if (cycle_state == 0) { | ||
303 | for (i = 0; i < TRBS_PER_SEGMENT; i++) | ||
304 | seg->trbs[i].link.control |= TRB_CYCLE; | ||
305 | } | ||
226 | /* All endpoint rings have link TRBs */ | 306 | /* All endpoint rings have link TRBs */ |
227 | xhci_link_segments(xhci, seg, seg->next, 1, isoc); | 307 | xhci_link_segments(xhci, seg, seg->next, type); |
228 | seg = seg->next; | 308 | seg = seg->next; |
229 | } while (seg != ring->first_seg); | 309 | } while (seg != ring->first_seg); |
230 | xhci_initialize_ring_info(ring); | 310 | ring->type = type; |
311 | xhci_initialize_ring_info(ring, cycle_state); | ||
231 | /* td list should be empty since all URBs have been cancelled, | 312 | /* td list should be empty since all URBs have been cancelled, |
232 | * but just in case... | 313 | * but just in case... |
233 | */ | 314 | */ |
234 | INIT_LIST_HEAD(&ring->td_list); | 315 | INIT_LIST_HEAD(&ring->td_list); |
235 | } | 316 | } |
236 | 317 | ||
318 | /* | ||
319 | * Expand an existing ring. | ||
320 | * Look for a cached ring or allocate a new ring which has same segment numbers | ||
321 | * and link the two rings. | ||
322 | */ | ||
323 | int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
324 | unsigned int num_trbs, gfp_t flags) | ||
325 | { | ||
326 | struct xhci_segment *first; | ||
327 | struct xhci_segment *last; | ||
328 | unsigned int num_segs; | ||
329 | unsigned int num_segs_needed; | ||
330 | int ret; | ||
331 | |||
332 | num_segs_needed = (num_trbs + (TRBS_PER_SEGMENT - 1) - 1) / | ||
333 | (TRBS_PER_SEGMENT - 1); | ||
334 | |||
335 | /* Allocate number of segments we needed, or double the ring size */ | ||
336 | num_segs = ring->num_segs > num_segs_needed ? | ||
337 | ring->num_segs : num_segs_needed; | ||
338 | |||
339 | ret = xhci_alloc_segments_for_ring(xhci, &first, &last, | ||
340 | num_segs, ring->cycle_state, ring->type, flags); | ||
341 | if (ret) | ||
342 | return -ENOMEM; | ||
343 | |||
344 | xhci_link_rings(xhci, ring, first, last, num_segs); | ||
345 | xhci_dbg(xhci, "ring expansion succeed, now has %d segments\n", | ||
346 | ring->num_segs); | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
237 | #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) | 351 | #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) |
238 | 352 | ||
239 | static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, | 353 | static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, |
@@ -528,7 +642,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
528 | */ | 642 | */ |
529 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { | 643 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { |
530 | stream_info->stream_rings[cur_stream] = | 644 | stream_info->stream_rings[cur_stream] = |
531 | xhci_ring_alloc(xhci, 1, true, false, mem_flags); | 645 | xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, mem_flags); |
532 | cur_ring = stream_info->stream_rings[cur_stream]; | 646 | cur_ring = stream_info->stream_rings[cur_stream]; |
533 | if (!cur_ring) | 647 | if (!cur_ring) |
534 | goto cleanup_rings; | 648 | goto cleanup_rings; |
@@ -862,7 +976,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, | |||
862 | } | 976 | } |
863 | 977 | ||
864 | /* Allocate endpoint 0 ring */ | 978 | /* Allocate endpoint 0 ring */ |
865 | dev->eps[0].ring = xhci_ring_alloc(xhci, 1, true, false, flags); | 979 | dev->eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, flags); |
866 | if (!dev->eps[0].ring) | 980 | if (!dev->eps[0].ring) |
867 | goto fail; | 981 | goto fail; |
868 | 982 | ||
@@ -1300,24 +1414,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1300 | struct xhci_ring *ep_ring; | 1414 | struct xhci_ring *ep_ring; |
1301 | unsigned int max_packet; | 1415 | unsigned int max_packet; |
1302 | unsigned int max_burst; | 1416 | unsigned int max_burst; |
1417 | enum xhci_ring_type type; | ||
1303 | u32 max_esit_payload; | 1418 | u32 max_esit_payload; |
1304 | 1419 | ||
1305 | ep_index = xhci_get_endpoint_index(&ep->desc); | 1420 | ep_index = xhci_get_endpoint_index(&ep->desc); |
1306 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); | 1421 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); |
1307 | 1422 | ||
1423 | type = usb_endpoint_type(&ep->desc); | ||
1308 | /* Set up the endpoint ring */ | 1424 | /* Set up the endpoint ring */ |
1309 | /* | 1425 | virt_dev->eps[ep_index].new_ring = |
1310 | * Isochronous endpoint ring needs bigger size because one isoc URB | 1426 | xhci_ring_alloc(xhci, 2, 1, type, mem_flags); |
1311 | * carries multiple packets and it will insert multiple tds to the | ||
1312 | * ring. | ||
1313 | * This should be replaced with dynamic ring resizing in the future. | ||
1314 | */ | ||
1315 | if (usb_endpoint_xfer_isoc(&ep->desc)) | ||
1316 | virt_dev->eps[ep_index].new_ring = | ||
1317 | xhci_ring_alloc(xhci, 8, true, true, mem_flags); | ||
1318 | else | ||
1319 | virt_dev->eps[ep_index].new_ring = | ||
1320 | xhci_ring_alloc(xhci, 1, true, false, mem_flags); | ||
1321 | if (!virt_dev->eps[ep_index].new_ring) { | 1427 | if (!virt_dev->eps[ep_index].new_ring) { |
1322 | /* Attempt to use the ring cache */ | 1428 | /* Attempt to use the ring cache */ |
1323 | if (virt_dev->num_rings_cached == 0) | 1429 | if (virt_dev->num_rings_cached == 0) |
@@ -1327,7 +1433,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1327 | virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL; | 1433 | virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL; |
1328 | virt_dev->num_rings_cached--; | 1434 | virt_dev->num_rings_cached--; |
1329 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring, | 1435 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring, |
1330 | usb_endpoint_xfer_isoc(&ep->desc) ? true : false); | 1436 | 1, type); |
1331 | } | 1437 | } |
1332 | virt_dev->eps[ep_index].skip = false; | 1438 | virt_dev->eps[ep_index].skip = false; |
1333 | ep_ring = virt_dev->eps[ep_index].new_ring; | 1439 | ep_ring = virt_dev->eps[ep_index].new_ring; |
@@ -2157,7 +2263,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2157 | unsigned int val, val2; | 2263 | unsigned int val, val2; |
2158 | u64 val_64; | 2264 | u64 val_64; |
2159 | struct xhci_segment *seg; | 2265 | struct xhci_segment *seg; |
2160 | u32 page_size; | 2266 | u32 page_size, temp; |
2161 | int i; | 2267 | int i; |
2162 | 2268 | ||
2163 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); | 2269 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); |
@@ -2235,7 +2341,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2235 | goto fail; | 2341 | goto fail; |
2236 | 2342 | ||
2237 | /* Set up the command ring to have one segments for now. */ | 2343 | /* Set up the command ring to have one segments for now. */ |
2238 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, true, false, flags); | 2344 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); |
2239 | if (!xhci->cmd_ring) | 2345 | if (!xhci->cmd_ring) |
2240 | goto fail; | 2346 | goto fail; |
2241 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); | 2347 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); |
@@ -2266,7 +2372,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2266 | * the event ring segment table (ERST). Section 4.9.3. | 2372 | * the event ring segment table (ERST). Section 4.9.3. |
2267 | */ | 2373 | */ |
2268 | xhci_dbg(xhci, "// Allocating event ring\n"); | 2374 | xhci_dbg(xhci, "// Allocating event ring\n"); |
2269 | xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, false, | 2375 | xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT, |
2270 | flags); | 2376 | flags); |
2271 | if (!xhci->event_ring) | 2377 | if (!xhci->event_ring) |
2272 | goto fail; | 2378 | goto fail; |
@@ -2340,6 +2446,15 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2340 | 2446 | ||
2341 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); | 2447 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); |
2342 | 2448 | ||
2449 | /* Enable USB 3.0 device notifications for function remote wake, which | ||
2450 | * is necessary for allowing USB 3.0 devices to do remote wakeup from | ||
2451 | * U3 (device suspend). | ||
2452 | */ | ||
2453 | temp = xhci_readl(xhci, &xhci->op_regs->dev_notification); | ||
2454 | temp &= ~DEV_NOTE_MASK; | ||
2455 | temp |= DEV_NOTE_FWAKE; | ||
2456 | xhci_writel(xhci, temp, &xhci->op_regs->dev_notification); | ||
2457 | |||
2343 | return 0; | 2458 | return 0; |
2344 | 2459 | ||
2345 | fail: | 2460 | fail: |
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c new file mode 100644 index 000000000000..689bc18b051d --- /dev/null +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | * xhci-plat.c - xHCI host controller driver platform Bus Glue. | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> | ||
6 | * | ||
7 | * A lot of code borrowed from the Linux xHCI driver. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * version 2 as published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/slab.h> | ||
17 | |||
18 | #include "xhci.h" | ||
19 | |||
20 | static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) | ||
21 | { | ||
22 | /* | ||
23 | * As of now platform drivers don't provide MSI support so we ensure | ||
24 | * here that the generic code does not try to make a pci_dev from our | ||
25 | * dev struct in order to setup MSI | ||
26 | */ | ||
27 | xhci->quirks |= XHCI_BROKEN_MSI; | ||
28 | } | ||
29 | |||
30 | /* called during probe() after chip reset completes */ | ||
31 | static int xhci_plat_setup(struct usb_hcd *hcd) | ||
32 | { | ||
33 | return xhci_gen_setup(hcd, xhci_plat_quirks); | ||
34 | } | ||
35 | |||
36 | static const struct hc_driver xhci_plat_xhci_driver = { | ||
37 | .description = "xhci-hcd", | ||
38 | .product_desc = "xHCI Host Controller", | ||
39 | .hcd_priv_size = sizeof(struct xhci_hcd *), | ||
40 | |||
41 | /* | ||
42 | * generic hardware linkage | ||
43 | */ | ||
44 | .irq = xhci_irq, | ||
45 | .flags = HCD_MEMORY | HCD_USB3 | HCD_SHARED, | ||
46 | |||
47 | /* | ||
48 | * basic lifecycle operations | ||
49 | */ | ||
50 | .reset = xhci_plat_setup, | ||
51 | .start = xhci_run, | ||
52 | .stop = xhci_stop, | ||
53 | .shutdown = xhci_shutdown, | ||
54 | |||
55 | /* | ||
56 | * managing i/o requests and associated device resources | ||
57 | */ | ||
58 | .urb_enqueue = xhci_urb_enqueue, | ||
59 | .urb_dequeue = xhci_urb_dequeue, | ||
60 | .alloc_dev = xhci_alloc_dev, | ||
61 | .free_dev = xhci_free_dev, | ||
62 | .alloc_streams = xhci_alloc_streams, | ||
63 | .free_streams = xhci_free_streams, | ||
64 | .add_endpoint = xhci_add_endpoint, | ||
65 | .drop_endpoint = xhci_drop_endpoint, | ||
66 | .endpoint_reset = xhci_endpoint_reset, | ||
67 | .check_bandwidth = xhci_check_bandwidth, | ||
68 | .reset_bandwidth = xhci_reset_bandwidth, | ||
69 | .address_device = xhci_address_device, | ||
70 | .update_hub_device = xhci_update_hub_device, | ||
71 | .reset_device = xhci_discover_or_reset_device, | ||
72 | |||
73 | /* | ||
74 | * scheduling support | ||
75 | */ | ||
76 | .get_frame_number = xhci_get_frame, | ||
77 | |||
78 | /* Root hub support */ | ||
79 | .hub_control = xhci_hub_control, | ||
80 | .hub_status_data = xhci_hub_status_data, | ||
81 | .bus_suspend = xhci_bus_suspend, | ||
82 | .bus_resume = xhci_bus_resume, | ||
83 | }; | ||
84 | |||
85 | static int xhci_plat_probe(struct platform_device *pdev) | ||
86 | { | ||
87 | const struct hc_driver *driver; | ||
88 | struct xhci_hcd *xhci; | ||
89 | struct resource *res; | ||
90 | struct usb_hcd *hcd; | ||
91 | int ret; | ||
92 | int irq; | ||
93 | |||
94 | if (usb_disabled()) | ||
95 | return -ENODEV; | ||
96 | |||
97 | driver = &xhci_plat_xhci_driver; | ||
98 | |||
99 | irq = platform_get_irq(pdev, 0); | ||
100 | if (irq < 0) | ||
101 | return -ENODEV; | ||
102 | |||
103 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
104 | if (!res) | ||
105 | return -ENODEV; | ||
106 | |||
107 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res->start; | ||
112 | hcd->rsrc_len = resource_size(res); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
115 | driver->description)) { | ||
116 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
117 | ret = -EBUSY; | ||
118 | goto put_hcd; | ||
119 | } | ||
120 | |||
121 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
122 | if (!hcd->regs) { | ||
123 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
124 | ret = -EFAULT; | ||
125 | goto release_mem_region; | ||
126 | } | ||
127 | |||
128 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
129 | if (ret) | ||
130 | goto unmap_registers; | ||
131 | |||
132 | /* USB 2.0 roothub is stored in the platform_device now. */ | ||
133 | hcd = dev_get_drvdata(&pdev->dev); | ||
134 | xhci = hcd_to_xhci(hcd); | ||
135 | xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, | ||
136 | dev_name(&pdev->dev), hcd); | ||
137 | if (!xhci->shared_hcd) { | ||
138 | ret = -ENOMEM; | ||
139 | goto dealloc_usb2_hcd; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) | ||
144 | * is called by usb_add_hcd(). | ||
145 | */ | ||
146 | *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci; | ||
147 | |||
148 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); | ||
149 | if (ret) | ||
150 | goto put_usb3_hcd; | ||
151 | |||
152 | return 0; | ||
153 | |||
154 | put_usb3_hcd: | ||
155 | usb_put_hcd(xhci->shared_hcd); | ||
156 | |||
157 | dealloc_usb2_hcd: | ||
158 | usb_remove_hcd(hcd); | ||
159 | |||
160 | unmap_registers: | ||
161 | iounmap(hcd->regs); | ||
162 | |||
163 | release_mem_region: | ||
164 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
165 | |||
166 | put_hcd: | ||
167 | usb_put_hcd(hcd); | ||
168 | |||
169 | return ret; | ||
170 | } | ||
171 | |||
172 | static int xhci_plat_remove(struct platform_device *dev) | ||
173 | { | ||
174 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
175 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
176 | |||
177 | usb_remove_hcd(xhci->shared_hcd); | ||
178 | usb_put_hcd(xhci->shared_hcd); | ||
179 | |||
180 | usb_remove_hcd(hcd); | ||
181 | iounmap(hcd->regs); | ||
182 | usb_put_hcd(hcd); | ||
183 | kfree(xhci); | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static struct platform_driver usb_xhci_driver = { | ||
189 | .probe = xhci_plat_probe, | ||
190 | .remove = xhci_plat_remove, | ||
191 | .driver = { | ||
192 | .name = "xhci-hcd", | ||
193 | }, | ||
194 | }; | ||
195 | MODULE_ALIAS("platform:xhci-hcd"); | ||
196 | |||
197 | int xhci_register_plat(void) | ||
198 | { | ||
199 | return platform_driver_register(&usb_xhci_driver); | ||
200 | } | ||
201 | |||
202 | void xhci_unregister_plat(void) | ||
203 | { | ||
204 | platform_driver_unregister(&usb_xhci_driver); | ||
205 | } | ||
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b62037bff688..6bd9d53062eb 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -143,17 +143,25 @@ static void next_trb(struct xhci_hcd *xhci, | |||
143 | * See Cycle bit rules. SW is the consumer for the event ring only. | 143 | * See Cycle bit rules. SW is the consumer for the event ring only. |
144 | * Don't make a ring full of link TRBs. That would be dumb and this would loop. | 144 | * Don't make a ring full of link TRBs. That would be dumb and this would loop. |
145 | */ | 145 | */ |
146 | static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) | 146 | static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) |
147 | { | 147 | { |
148 | union xhci_trb *next = ++(ring->dequeue); | 148 | union xhci_trb *next; |
149 | unsigned long long addr; | 149 | unsigned long long addr; |
150 | 150 | ||
151 | ring->deq_updates++; | 151 | ring->deq_updates++; |
152 | |||
153 | /* If this is not event ring, there is one more usable TRB */ | ||
154 | if (ring->type != TYPE_EVENT && | ||
155 | !last_trb(xhci, ring, ring->deq_seg, ring->dequeue)) | ||
156 | ring->num_trbs_free++; | ||
157 | next = ++(ring->dequeue); | ||
158 | |||
152 | /* Update the dequeue pointer further if that was a link TRB or we're at | 159 | /* Update the dequeue pointer further if that was a link TRB or we're at |
153 | * the end of an event ring segment (which doesn't have link TRBS) | 160 | * the end of an event ring segment (which doesn't have link TRBS) |
154 | */ | 161 | */ |
155 | while (last_trb(xhci, ring, ring->deq_seg, next)) { | 162 | while (last_trb(xhci, ring, ring->deq_seg, next)) { |
156 | if (consumer && last_trb_on_last_seg(xhci, ring, ring->deq_seg, next)) { | 163 | if (ring->type == TYPE_EVENT && last_trb_on_last_seg(xhci, |
164 | ring, ring->deq_seg, next)) { | ||
157 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 165 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
158 | } | 166 | } |
159 | ring->deq_seg = ring->deq_seg->next; | 167 | ring->deq_seg = ring->deq_seg->next; |
@@ -181,13 +189,17 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer | |||
181 | * prepare_transfer()? | 189 | * prepare_transfer()? |
182 | */ | 190 | */ |
183 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | 191 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, |
184 | bool consumer, bool more_trbs_coming, bool isoc) | 192 | bool more_trbs_coming) |
185 | { | 193 | { |
186 | u32 chain; | 194 | u32 chain; |
187 | union xhci_trb *next; | 195 | union xhci_trb *next; |
188 | unsigned long long addr; | 196 | unsigned long long addr; |
189 | 197 | ||
190 | chain = le32_to_cpu(ring->enqueue->generic.field[3]) & TRB_CHAIN; | 198 | chain = le32_to_cpu(ring->enqueue->generic.field[3]) & TRB_CHAIN; |
199 | /* If this is not event ring, there is one less usable TRB */ | ||
200 | if (ring->type != TYPE_EVENT && | ||
201 | !last_trb(xhci, ring, ring->enq_seg, ring->enqueue)) | ||
202 | ring->num_trbs_free--; | ||
191 | next = ++(ring->enqueue); | 203 | next = ++(ring->enqueue); |
192 | 204 | ||
193 | ring->enq_updates++; | 205 | ring->enq_updates++; |
@@ -195,35 +207,35 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
195 | * the end of an event ring segment (which doesn't have link TRBS) | 207 | * the end of an event ring segment (which doesn't have link TRBS) |
196 | */ | 208 | */ |
197 | while (last_trb(xhci, ring, ring->enq_seg, next)) { | 209 | while (last_trb(xhci, ring, ring->enq_seg, next)) { |
198 | if (!consumer) { | 210 | if (ring->type != TYPE_EVENT) { |
199 | if (ring != xhci->event_ring) { | 211 | /* |
200 | /* | 212 | * If the caller doesn't plan on enqueueing more |
201 | * If the caller doesn't plan on enqueueing more | 213 | * TDs before ringing the doorbell, then we |
202 | * TDs before ringing the doorbell, then we | 214 | * don't want to give the link TRB to the |
203 | * don't want to give the link TRB to the | 215 | * hardware just yet. We'll give the link TRB |
204 | * hardware just yet. We'll give the link TRB | 216 | * back in prepare_ring() just before we enqueue |
205 | * back in prepare_ring() just before we enqueue | 217 | * the TD at the top of the ring. |
206 | * the TD at the top of the ring. | 218 | */ |
207 | */ | 219 | if (!chain && !more_trbs_coming) |
208 | if (!chain && !more_trbs_coming) | 220 | break; |
209 | break; | ||
210 | 221 | ||
211 | /* If we're not dealing with 0.95 hardware or | 222 | /* If we're not dealing with 0.95 hardware or |
212 | * isoc rings on AMD 0.96 host, | 223 | * isoc rings on AMD 0.96 host, |
213 | * carry over the chain bit of the previous TRB | 224 | * carry over the chain bit of the previous TRB |
214 | * (which may mean the chain bit is cleared). | 225 | * (which may mean the chain bit is cleared). |
215 | */ | 226 | */ |
216 | if (!(isoc && (xhci->quirks & XHCI_AMD_0x96_HOST)) | 227 | if (!(ring->type == TYPE_ISOC && |
228 | (xhci->quirks & XHCI_AMD_0x96_HOST)) | ||
217 | && !xhci_link_trb_quirk(xhci)) { | 229 | && !xhci_link_trb_quirk(xhci)) { |
218 | next->link.control &= | 230 | next->link.control &= |
219 | cpu_to_le32(~TRB_CHAIN); | 231 | cpu_to_le32(~TRB_CHAIN); |
220 | next->link.control |= | 232 | next->link.control |= |
221 | cpu_to_le32(chain); | 233 | cpu_to_le32(chain); |
222 | } | ||
223 | /* Give this link TRB to the hardware */ | ||
224 | wmb(); | ||
225 | next->link.control ^= cpu_to_le32(TRB_CYCLE); | ||
226 | } | 234 | } |
235 | /* Give this link TRB to the hardware */ | ||
236 | wmb(); | ||
237 | next->link.control ^= cpu_to_le32(TRB_CYCLE); | ||
238 | |||
227 | /* Toggle the cycle bit after the last ring segment. */ | 239 | /* Toggle the cycle bit after the last ring segment. */ |
228 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 240 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
229 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 241 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
@@ -237,55 +249,23 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
237 | } | 249 | } |
238 | 250 | ||
239 | /* | 251 | /* |
240 | * Check to see if there's room to enqueue num_trbs on the ring. See rules | 252 | * Check to see if there's room to enqueue num_trbs on the ring and make sure |
241 | * above. | 253 | * enqueue pointer will not advance into dequeue segment. See rules above. |
242 | * FIXME: this would be simpler and faster if we just kept track of the number | ||
243 | * of free TRBs in a ring. | ||
244 | */ | 254 | */ |
245 | static int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, | 255 | static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, |
246 | unsigned int num_trbs) | 256 | unsigned int num_trbs) |
247 | { | 257 | { |
248 | int i; | 258 | int num_trbs_in_deq_seg; |
249 | union xhci_trb *enq = ring->enqueue; | 259 | |
250 | struct xhci_segment *enq_seg = ring->enq_seg; | 260 | if (ring->num_trbs_free < num_trbs) |
251 | struct xhci_segment *cur_seg; | 261 | return 0; |
252 | unsigned int left_on_ring; | 262 | |
253 | 263 | if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) { | |
254 | /* If we are currently pointing to a link TRB, advance the | 264 | num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs; |
255 | * enqueue pointer before checking for space */ | 265 | if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg) |
256 | while (last_trb(xhci, ring, enq_seg, enq)) { | ||
257 | enq_seg = enq_seg->next; | ||
258 | enq = enq_seg->trbs; | ||
259 | } | ||
260 | |||
261 | /* Check if ring is empty */ | ||
262 | if (enq == ring->dequeue) { | ||
263 | /* Can't use link trbs */ | ||
264 | left_on_ring = TRBS_PER_SEGMENT - 1; | ||
265 | for (cur_seg = enq_seg->next; cur_seg != enq_seg; | ||
266 | cur_seg = cur_seg->next) | ||
267 | left_on_ring += TRBS_PER_SEGMENT - 1; | ||
268 | |||
269 | /* Always need one TRB free in the ring. */ | ||
270 | left_on_ring -= 1; | ||
271 | if (num_trbs > left_on_ring) { | ||
272 | xhci_warn(xhci, "Not enough room on ring; " | ||
273 | "need %u TRBs, %u TRBs left\n", | ||
274 | num_trbs, left_on_ring); | ||
275 | return 0; | ||
276 | } | ||
277 | return 1; | ||
278 | } | ||
279 | /* Make sure there's an extra empty TRB available */ | ||
280 | for (i = 0; i <= num_trbs; ++i) { | ||
281 | if (enq == ring->dequeue) | ||
282 | return 0; | 266 | return 0; |
283 | enq++; | ||
284 | while (last_trb(xhci, ring, enq_seg, enq)) { | ||
285 | enq_seg = enq_seg->next; | ||
286 | enq = enq_seg->trbs; | ||
287 | } | ||
288 | } | 267 | } |
268 | |||
289 | return 1; | 269 | return 1; |
290 | } | 270 | } |
291 | 271 | ||
@@ -892,6 +872,43 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
892 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); | 872 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); |
893 | } | 873 | } |
894 | 874 | ||
875 | |||
876 | static void update_ring_for_set_deq_completion(struct xhci_hcd *xhci, | ||
877 | struct xhci_virt_device *dev, | ||
878 | struct xhci_ring *ep_ring, | ||
879 | unsigned int ep_index) | ||
880 | { | ||
881 | union xhci_trb *dequeue_temp; | ||
882 | int num_trbs_free_temp; | ||
883 | bool revert = false; | ||
884 | |||
885 | num_trbs_free_temp = ep_ring->num_trbs_free; | ||
886 | dequeue_temp = ep_ring->dequeue; | ||
887 | |||
888 | while (ep_ring->dequeue != dev->eps[ep_index].queued_deq_ptr) { | ||
889 | /* We have more usable TRBs */ | ||
890 | ep_ring->num_trbs_free++; | ||
891 | ep_ring->dequeue++; | ||
892 | if (last_trb(xhci, ep_ring, ep_ring->deq_seg, | ||
893 | ep_ring->dequeue)) { | ||
894 | if (ep_ring->dequeue == | ||
895 | dev->eps[ep_index].queued_deq_ptr) | ||
896 | break; | ||
897 | ep_ring->deq_seg = ep_ring->deq_seg->next; | ||
898 | ep_ring->dequeue = ep_ring->deq_seg->trbs; | ||
899 | } | ||
900 | if (ep_ring->dequeue == dequeue_temp) { | ||
901 | revert = true; | ||
902 | break; | ||
903 | } | ||
904 | } | ||
905 | |||
906 | if (revert) { | ||
907 | xhci_dbg(xhci, "Unable to find new dequeue pointer\n"); | ||
908 | ep_ring->num_trbs_free = num_trbs_free_temp; | ||
909 | } | ||
910 | } | ||
911 | |||
895 | /* | 912 | /* |
896 | * When we get a completion for a Set Transfer Ring Dequeue Pointer command, | 913 | * When we get a completion for a Set Transfer Ring Dequeue Pointer command, |
897 | * we need to clear the set deq pending flag in the endpoint ring state, so that | 914 | * we need to clear the set deq pending flag in the endpoint ring state, so that |
@@ -973,8 +990,8 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, | |||
973 | /* Update the ring's dequeue segment and dequeue pointer | 990 | /* Update the ring's dequeue segment and dequeue pointer |
974 | * to reflect the new position. | 991 | * to reflect the new position. |
975 | */ | 992 | */ |
976 | ep_ring->deq_seg = dev->eps[ep_index].queued_deq_seg; | 993 | update_ring_for_set_deq_completion(xhci, dev, |
977 | ep_ring->dequeue = dev->eps[ep_index].queued_deq_ptr; | 994 | ep_ring, ep_index); |
978 | } else { | 995 | } else { |
979 | xhci_warn(xhci, "Mismatch between completed Set TR Deq " | 996 | xhci_warn(xhci, "Mismatch between completed Set TR Deq " |
980 | "Ptr command & xHCI internal state.\n"); | 997 | "Ptr command & xHCI internal state.\n"); |
@@ -1185,7 +1202,7 @@ bandwidth_change: | |||
1185 | xhci->error_bitmask |= 1 << 6; | 1202 | xhci->error_bitmask |= 1 << 6; |
1186 | break; | 1203 | break; |
1187 | } | 1204 | } |
1188 | inc_deq(xhci, xhci->cmd_ring, false); | 1205 | inc_deq(xhci, xhci->cmd_ring); |
1189 | } | 1206 | } |
1190 | 1207 | ||
1191 | static void handle_vendor_event(struct xhci_hcd *xhci, | 1208 | static void handle_vendor_event(struct xhci_hcd *xhci, |
@@ -1237,6 +1254,26 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, | |||
1237 | return num_similar_speed_ports; | 1254 | return num_similar_speed_ports; |
1238 | } | 1255 | } |
1239 | 1256 | ||
1257 | static void handle_device_notification(struct xhci_hcd *xhci, | ||
1258 | union xhci_trb *event) | ||
1259 | { | ||
1260 | u32 slot_id; | ||
1261 | struct usb_device *udev; | ||
1262 | |||
1263 | slot_id = TRB_TO_SLOT_ID(event->generic.field[3]); | ||
1264 | if (!xhci->devs[slot_id]) { | ||
1265 | xhci_warn(xhci, "Device Notification event for " | ||
1266 | "unused slot %u\n", slot_id); | ||
1267 | return; | ||
1268 | } | ||
1269 | |||
1270 | xhci_dbg(xhci, "Device Wake Notification event for slot ID %u\n", | ||
1271 | slot_id); | ||
1272 | udev = xhci->devs[slot_id]->udev; | ||
1273 | if (udev && udev->parent) | ||
1274 | usb_wakeup_notification(udev->parent, udev->portnum); | ||
1275 | } | ||
1276 | |||
1240 | static void handle_port_status(struct xhci_hcd *xhci, | 1277 | static void handle_port_status(struct xhci_hcd *xhci, |
1241 | union xhci_trb *event) | 1278 | union xhci_trb *event) |
1242 | { | 1279 | { |
@@ -1321,20 +1358,21 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1321 | } | 1358 | } |
1322 | 1359 | ||
1323 | if (DEV_SUPERSPEED(temp)) { | 1360 | if (DEV_SUPERSPEED(temp)) { |
1324 | xhci_dbg(xhci, "resume SS port %d\n", port_id); | 1361 | xhci_dbg(xhci, "remote wake SS port %d\n", port_id); |
1362 | /* Set a flag to say the port signaled remote wakeup, | ||
1363 | * so we can tell the difference between the end of | ||
1364 | * device and host initiated resume. | ||
1365 | */ | ||
1366 | bus_state->port_remote_wakeup |= 1 << faked_port_index; | ||
1367 | xhci_test_and_clear_bit(xhci, port_array, | ||
1368 | faked_port_index, PORT_PLC); | ||
1325 | xhci_set_link_state(xhci, port_array, faked_port_index, | 1369 | xhci_set_link_state(xhci, port_array, faked_port_index, |
1326 | XDEV_U0); | 1370 | XDEV_U0); |
1327 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | 1371 | /* Need to wait until the next link state change |
1328 | faked_port_index + 1); | 1372 | * indicates the device is actually in U0. |
1329 | if (!slot_id) { | 1373 | */ |
1330 | xhci_dbg(xhci, "slot_id is zero\n"); | 1374 | bogus_port_status = true; |
1331 | goto cleanup; | 1375 | goto cleanup; |
1332 | } | ||
1333 | xhci_ring_device(xhci, slot_id); | ||
1334 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1335 | /* Clear PORT_PLC */ | ||
1336 | xhci_test_and_clear_bit(xhci, port_array, | ||
1337 | faked_port_index, PORT_PLC); | ||
1338 | } else { | 1376 | } else { |
1339 | xhci_dbg(xhci, "resume HS port %d\n", port_id); | 1377 | xhci_dbg(xhci, "resume HS port %d\n", port_id); |
1340 | bus_state->resume_done[faked_port_index] = jiffies + | 1378 | bus_state->resume_done[faked_port_index] = jiffies + |
@@ -1345,13 +1383,39 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1345 | } | 1383 | } |
1346 | } | 1384 | } |
1347 | 1385 | ||
1386 | if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_U0 && | ||
1387 | DEV_SUPERSPEED(temp)) { | ||
1388 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1389 | /* We've just brought the device into U0 through either the | ||
1390 | * Resume state after a device remote wakeup, or through the | ||
1391 | * U3Exit state after a host-initiated resume. If it's a device | ||
1392 | * initiated remote wake, don't pass up the link state change, | ||
1393 | * so the roothub behavior is consistent with external | ||
1394 | * USB 3.0 hub behavior. | ||
1395 | */ | ||
1396 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | ||
1397 | faked_port_index + 1); | ||
1398 | if (slot_id && xhci->devs[slot_id]) | ||
1399 | xhci_ring_device(xhci, slot_id); | ||
1400 | if (bus_state->port_remote_wakeup && (1 << faked_port_index)) { | ||
1401 | bus_state->port_remote_wakeup &= | ||
1402 | ~(1 << faked_port_index); | ||
1403 | xhci_test_and_clear_bit(xhci, port_array, | ||
1404 | faked_port_index, PORT_PLC); | ||
1405 | usb_wakeup_notification(hcd->self.root_hub, | ||
1406 | faked_port_index + 1); | ||
1407 | bogus_port_status = true; | ||
1408 | goto cleanup; | ||
1409 | } | ||
1410 | } | ||
1411 | |||
1348 | if (hcd->speed != HCD_USB3) | 1412 | if (hcd->speed != HCD_USB3) |
1349 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, | 1413 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, |
1350 | PORT_PLC); | 1414 | PORT_PLC); |
1351 | 1415 | ||
1352 | cleanup: | 1416 | cleanup: |
1353 | /* Update event ring dequeue pointer before dropping the lock */ | 1417 | /* Update event ring dequeue pointer before dropping the lock */ |
1354 | inc_deq(xhci, xhci->event_ring, true); | 1418 | inc_deq(xhci, xhci->event_ring); |
1355 | 1419 | ||
1356 | /* Don't make the USB core poll the roothub if we got a bad port status | 1420 | /* Don't make the USB core poll the roothub if we got a bad port status |
1357 | * change event. Besides, at that point we can't tell which roothub | 1421 | * change event. Besides, at that point we can't tell which roothub |
@@ -1546,8 +1610,8 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1546 | } else { | 1610 | } else { |
1547 | /* Update ring dequeue pointer */ | 1611 | /* Update ring dequeue pointer */ |
1548 | while (ep_ring->dequeue != td->last_trb) | 1612 | while (ep_ring->dequeue != td->last_trb) |
1549 | inc_deq(xhci, ep_ring, false); | 1613 | inc_deq(xhci, ep_ring); |
1550 | inc_deq(xhci, ep_ring, false); | 1614 | inc_deq(xhci, ep_ring); |
1551 | } | 1615 | } |
1552 | 1616 | ||
1553 | td_cleanup: | 1617 | td_cleanup: |
@@ -1795,8 +1859,8 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1795 | 1859 | ||
1796 | /* Update ring dequeue pointer */ | 1860 | /* Update ring dequeue pointer */ |
1797 | while (ep_ring->dequeue != td->last_trb) | 1861 | while (ep_ring->dequeue != td->last_trb) |
1798 | inc_deq(xhci, ep_ring, false); | 1862 | inc_deq(xhci, ep_ring); |
1799 | inc_deq(xhci, ep_ring, false); | 1863 | inc_deq(xhci, ep_ring); |
1800 | 1864 | ||
1801 | return finish_td(xhci, td, NULL, event, ep, status, true); | 1865 | return finish_td(xhci, td, NULL, event, ep, status, true); |
1802 | } | 1866 | } |
@@ -2183,7 +2247,7 @@ cleanup: | |||
2183 | * Will roll back to continue process missed tds. | 2247 | * Will roll back to continue process missed tds. |
2184 | */ | 2248 | */ |
2185 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { | 2249 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { |
2186 | inc_deq(xhci, xhci->event_ring, true); | 2250 | inc_deq(xhci, xhci->event_ring); |
2187 | } | 2251 | } |
2188 | 2252 | ||
2189 | if (ret) { | 2253 | if (ret) { |
@@ -2277,6 +2341,9 @@ static int xhci_handle_event(struct xhci_hcd *xhci) | |||
2277 | else | 2341 | else |
2278 | update_ptrs = 0; | 2342 | update_ptrs = 0; |
2279 | break; | 2343 | break; |
2344 | case TRB_TYPE(TRB_DEV_NOTE): | ||
2345 | handle_device_notification(xhci, event); | ||
2346 | break; | ||
2280 | default: | 2347 | default: |
2281 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= | 2348 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= |
2282 | TRB_TYPE(48)) | 2349 | TRB_TYPE(48)) |
@@ -2295,7 +2362,7 @@ static int xhci_handle_event(struct xhci_hcd *xhci) | |||
2295 | 2362 | ||
2296 | if (update_ptrs) | 2363 | if (update_ptrs) |
2297 | /* Update SW event ring dequeue pointer */ | 2364 | /* Update SW event ring dequeue pointer */ |
2298 | inc_deq(xhci, xhci->event_ring, true); | 2365 | inc_deq(xhci, xhci->event_ring); |
2299 | 2366 | ||
2300 | /* Are there more items on the event ring? Caller will call us again to | 2367 | /* Are there more items on the event ring? Caller will call us again to |
2301 | * check. | 2368 | * check. |
@@ -2346,7 +2413,7 @@ hw_died: | |||
2346 | /* FIXME when MSI-X is supported and there are multiple vectors */ | 2413 | /* FIXME when MSI-X is supported and there are multiple vectors */ |
2347 | /* Clear the MSI-X event interrupt status */ | 2414 | /* Clear the MSI-X event interrupt status */ |
2348 | 2415 | ||
2349 | if (hcd->irq != -1) { | 2416 | if (hcd->irq) { |
2350 | u32 irq_pending; | 2417 | u32 irq_pending; |
2351 | /* Acknowledge the PCI interrupt */ | 2418 | /* Acknowledge the PCI interrupt */ |
2352 | irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); | 2419 | irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); |
@@ -2411,7 +2478,7 @@ irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd) | |||
2411 | * prepare_transfer()? | 2478 | * prepare_transfer()? |
2412 | */ | 2479 | */ |
2413 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | 2480 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, |
2414 | bool consumer, bool more_trbs_coming, bool isoc, | 2481 | bool more_trbs_coming, |
2415 | u32 field1, u32 field2, u32 field3, u32 field4) | 2482 | u32 field1, u32 field2, u32 field3, u32 field4) |
2416 | { | 2483 | { |
2417 | struct xhci_generic_trb *trb; | 2484 | struct xhci_generic_trb *trb; |
@@ -2421,7 +2488,7 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
2421 | trb->field[1] = cpu_to_le32(field2); | 2488 | trb->field[1] = cpu_to_le32(field2); |
2422 | trb->field[2] = cpu_to_le32(field3); | 2489 | trb->field[2] = cpu_to_le32(field3); |
2423 | trb->field[3] = cpu_to_le32(field4); | 2490 | trb->field[3] = cpu_to_le32(field4); |
2424 | inc_enq(xhci, ring, consumer, more_trbs_coming, isoc); | 2491 | inc_enq(xhci, ring, more_trbs_coming); |
2425 | } | 2492 | } |
2426 | 2493 | ||
2427 | /* | 2494 | /* |
@@ -2429,8 +2496,10 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
2429 | * FIXME allocate segments if the ring is full. | 2496 | * FIXME allocate segments if the ring is full. |
2430 | */ | 2497 | */ |
2431 | static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | 2498 | static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, |
2432 | u32 ep_state, unsigned int num_trbs, bool isoc, gfp_t mem_flags) | 2499 | u32 ep_state, unsigned int num_trbs, gfp_t mem_flags) |
2433 | { | 2500 | { |
2501 | unsigned int num_trbs_needed; | ||
2502 | |||
2434 | /* Make sure the endpoint has been added to xHC schedule */ | 2503 | /* Make sure the endpoint has been added to xHC schedule */ |
2435 | switch (ep_state) { | 2504 | switch (ep_state) { |
2436 | case EP_STATE_DISABLED: | 2505 | case EP_STATE_DISABLED: |
@@ -2458,11 +2527,25 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2458 | */ | 2527 | */ |
2459 | return -EINVAL; | 2528 | return -EINVAL; |
2460 | } | 2529 | } |
2461 | if (!room_on_ring(xhci, ep_ring, num_trbs)) { | 2530 | |
2462 | /* FIXME allocate more room */ | 2531 | while (1) { |
2463 | xhci_err(xhci, "ERROR no room on ep ring\n"); | 2532 | if (room_on_ring(xhci, ep_ring, num_trbs)) |
2464 | return -ENOMEM; | 2533 | break; |
2465 | } | 2534 | |
2535 | if (ep_ring == xhci->cmd_ring) { | ||
2536 | xhci_err(xhci, "Do not support expand command ring\n"); | ||
2537 | return -ENOMEM; | ||
2538 | } | ||
2539 | |||
2540 | xhci_dbg(xhci, "ERROR no room on ep ring, " | ||
2541 | "try ring expansion\n"); | ||
2542 | num_trbs_needed = num_trbs - ep_ring->num_trbs_free; | ||
2543 | if (xhci_ring_expansion(xhci, ep_ring, num_trbs_needed, | ||
2544 | mem_flags)) { | ||
2545 | xhci_err(xhci, "Ring expansion failed\n"); | ||
2546 | return -ENOMEM; | ||
2547 | } | ||
2548 | }; | ||
2466 | 2549 | ||
2467 | if (enqueue_is_link_trb(ep_ring)) { | 2550 | if (enqueue_is_link_trb(ep_ring)) { |
2468 | struct xhci_ring *ring = ep_ring; | 2551 | struct xhci_ring *ring = ep_ring; |
@@ -2474,8 +2557,9 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2474 | /* If we're not dealing with 0.95 hardware or isoc rings | 2557 | /* If we're not dealing with 0.95 hardware or isoc rings |
2475 | * on AMD 0.96 host, clear the chain bit. | 2558 | * on AMD 0.96 host, clear the chain bit. |
2476 | */ | 2559 | */ |
2477 | if (!xhci_link_trb_quirk(xhci) && !(isoc && | 2560 | if (!xhci_link_trb_quirk(xhci) && |
2478 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | 2561 | !(ring->type == TYPE_ISOC && |
2562 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | ||
2479 | next->link.control &= cpu_to_le32(~TRB_CHAIN); | 2563 | next->link.control &= cpu_to_le32(~TRB_CHAIN); |
2480 | else | 2564 | else |
2481 | next->link.control |= cpu_to_le32(TRB_CHAIN); | 2565 | next->link.control |= cpu_to_le32(TRB_CHAIN); |
@@ -2503,7 +2587,6 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
2503 | unsigned int num_trbs, | 2587 | unsigned int num_trbs, |
2504 | struct urb *urb, | 2588 | struct urb *urb, |
2505 | unsigned int td_index, | 2589 | unsigned int td_index, |
2506 | bool isoc, | ||
2507 | gfp_t mem_flags) | 2590 | gfp_t mem_flags) |
2508 | { | 2591 | { |
2509 | int ret; | 2592 | int ret; |
@@ -2521,7 +2604,7 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
2521 | 2604 | ||
2522 | ret = prepare_ring(xhci, ep_ring, | 2605 | ret = prepare_ring(xhci, ep_ring, |
2523 | le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, | 2606 | le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, |
2524 | num_trbs, isoc, mem_flags); | 2607 | num_trbs, mem_flags); |
2525 | if (ret) | 2608 | if (ret) |
2526 | return ret; | 2609 | return ret; |
2527 | 2610 | ||
@@ -2731,7 +2814,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2731 | 2814 | ||
2732 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], | 2815 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], |
2733 | ep_index, urb->stream_id, | 2816 | ep_index, urb->stream_id, |
2734 | num_trbs, urb, 0, false, mem_flags); | 2817 | num_trbs, urb, 0, mem_flags); |
2735 | if (trb_buff_len < 0) | 2818 | if (trb_buff_len < 0) |
2736 | return trb_buff_len; | 2819 | return trb_buff_len; |
2737 | 2820 | ||
@@ -2819,7 +2902,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2819 | more_trbs_coming = true; | 2902 | more_trbs_coming = true; |
2820 | else | 2903 | else |
2821 | more_trbs_coming = false; | 2904 | more_trbs_coming = false; |
2822 | queue_trb(xhci, ep_ring, false, more_trbs_coming, false, | 2905 | queue_trb(xhci, ep_ring, more_trbs_coming, |
2823 | lower_32_bits(addr), | 2906 | lower_32_bits(addr), |
2824 | upper_32_bits(addr), | 2907 | upper_32_bits(addr), |
2825 | length_field, | 2908 | length_field, |
@@ -2901,7 +2984,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2901 | 2984 | ||
2902 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 2985 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
2903 | ep_index, urb->stream_id, | 2986 | ep_index, urb->stream_id, |
2904 | num_trbs, urb, 0, false, mem_flags); | 2987 | num_trbs, urb, 0, mem_flags); |
2905 | if (ret < 0) | 2988 | if (ret < 0) |
2906 | return ret; | 2989 | return ret; |
2907 | 2990 | ||
@@ -2973,7 +3056,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2973 | more_trbs_coming = true; | 3056 | more_trbs_coming = true; |
2974 | else | 3057 | else |
2975 | more_trbs_coming = false; | 3058 | more_trbs_coming = false; |
2976 | queue_trb(xhci, ep_ring, false, more_trbs_coming, false, | 3059 | queue_trb(xhci, ep_ring, more_trbs_coming, |
2977 | lower_32_bits(addr), | 3060 | lower_32_bits(addr), |
2978 | upper_32_bits(addr), | 3061 | upper_32_bits(addr), |
2979 | length_field, | 3062 | length_field, |
@@ -3030,7 +3113,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3030 | num_trbs++; | 3113 | num_trbs++; |
3031 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 3114 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
3032 | ep_index, urb->stream_id, | 3115 | ep_index, urb->stream_id, |
3033 | num_trbs, urb, 0, false, mem_flags); | 3116 | num_trbs, urb, 0, mem_flags); |
3034 | if (ret < 0) | 3117 | if (ret < 0) |
3035 | return ret; | 3118 | return ret; |
3036 | 3119 | ||
@@ -3063,7 +3146,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3063 | } | 3146 | } |
3064 | } | 3147 | } |
3065 | 3148 | ||
3066 | queue_trb(xhci, ep_ring, false, true, false, | 3149 | queue_trb(xhci, ep_ring, true, |
3067 | setup->bRequestType | setup->bRequest << 8 | le16_to_cpu(setup->wValue) << 16, | 3150 | setup->bRequestType | setup->bRequest << 8 | le16_to_cpu(setup->wValue) << 16, |
3068 | le16_to_cpu(setup->wIndex) | le16_to_cpu(setup->wLength) << 16, | 3151 | le16_to_cpu(setup->wIndex) | le16_to_cpu(setup->wLength) << 16, |
3069 | TRB_LEN(8) | TRB_INTR_TARGET(0), | 3152 | TRB_LEN(8) | TRB_INTR_TARGET(0), |
@@ -3083,7 +3166,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3083 | if (urb->transfer_buffer_length > 0) { | 3166 | if (urb->transfer_buffer_length > 0) { |
3084 | if (setup->bRequestType & USB_DIR_IN) | 3167 | if (setup->bRequestType & USB_DIR_IN) |
3085 | field |= TRB_DIR_IN; | 3168 | field |= TRB_DIR_IN; |
3086 | queue_trb(xhci, ep_ring, false, true, false, | 3169 | queue_trb(xhci, ep_ring, true, |
3087 | lower_32_bits(urb->transfer_dma), | 3170 | lower_32_bits(urb->transfer_dma), |
3088 | upper_32_bits(urb->transfer_dma), | 3171 | upper_32_bits(urb->transfer_dma), |
3089 | length_field, | 3172 | length_field, |
@@ -3099,7 +3182,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3099 | field = 0; | 3182 | field = 0; |
3100 | else | 3183 | else |
3101 | field = TRB_DIR_IN; | 3184 | field = TRB_DIR_IN; |
3102 | queue_trb(xhci, ep_ring, false, false, false, | 3185 | queue_trb(xhci, ep_ring, false, |
3103 | 0, | 3186 | 0, |
3104 | 0, | 3187 | 0, |
3105 | TRB_INTR_TARGET(0), | 3188 | TRB_INTR_TARGET(0), |
@@ -3239,8 +3322,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3239 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); | 3322 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); |
3240 | 3323 | ||
3241 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, | 3324 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, |
3242 | urb->stream_id, trbs_per_td, urb, i, true, | 3325 | urb->stream_id, trbs_per_td, urb, i, mem_flags); |
3243 | mem_flags); | ||
3244 | if (ret < 0) { | 3326 | if (ret < 0) { |
3245 | if (i == 0) | 3327 | if (i == 0) |
3246 | return ret; | 3328 | return ret; |
@@ -3310,7 +3392,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3310 | remainder | | 3392 | remainder | |
3311 | TRB_INTR_TARGET(0); | 3393 | TRB_INTR_TARGET(0); |
3312 | 3394 | ||
3313 | queue_trb(xhci, ep_ring, false, more_trbs_coming, true, | 3395 | queue_trb(xhci, ep_ring, more_trbs_coming, |
3314 | lower_32_bits(addr), | 3396 | lower_32_bits(addr), |
3315 | upper_32_bits(addr), | 3397 | upper_32_bits(addr), |
3316 | length_field, | 3398 | length_field, |
@@ -3357,6 +3439,7 @@ cleanup: | |||
3357 | ep_ring->enqueue = urb_priv->td[0]->first_trb; | 3439 | ep_ring->enqueue = urb_priv->td[0]->first_trb; |
3358 | ep_ring->enq_seg = urb_priv->td[0]->start_seg; | 3440 | ep_ring->enq_seg = urb_priv->td[0]->start_seg; |
3359 | ep_ring->cycle_state = start_cycle; | 3441 | ep_ring->cycle_state = start_cycle; |
3442 | ep_ring->num_trbs_free = ep_ring->num_trbs_free_temp; | ||
3360 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); | 3443 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); |
3361 | return ret; | 3444 | return ret; |
3362 | } | 3445 | } |
@@ -3393,7 +3476,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3393 | * Do not insert any td of the urb to the ring if the check failed. | 3476 | * Do not insert any td of the urb to the ring if the check failed. |
3394 | */ | 3477 | */ |
3395 | ret = prepare_ring(xhci, ep_ring, le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, | 3478 | ret = prepare_ring(xhci, ep_ring, le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, |
3396 | num_trbs, true, mem_flags); | 3479 | num_trbs, mem_flags); |
3397 | if (ret) | 3480 | if (ret) |
3398 | return ret; | 3481 | return ret; |
3399 | 3482 | ||
@@ -3429,6 +3512,8 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3429 | urb->dev->speed == USB_SPEED_FULL) | 3512 | urb->dev->speed == USB_SPEED_FULL) |
3430 | urb->interval /= 8; | 3513 | urb->interval /= 8; |
3431 | } | 3514 | } |
3515 | ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free; | ||
3516 | |||
3432 | return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); | 3517 | return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); |
3433 | } | 3518 | } |
3434 | 3519 | ||
@@ -3452,7 +3537,7 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
3452 | reserved_trbs++; | 3537 | reserved_trbs++; |
3453 | 3538 | ||
3454 | ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING, | 3539 | ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING, |
3455 | reserved_trbs, false, GFP_ATOMIC); | 3540 | reserved_trbs, GFP_ATOMIC); |
3456 | if (ret < 0) { | 3541 | if (ret < 0) { |
3457 | xhci_err(xhci, "ERR: No room for command on command ring\n"); | 3542 | xhci_err(xhci, "ERR: No room for command on command ring\n"); |
3458 | if (command_must_succeed) | 3543 | if (command_must_succeed) |
@@ -3460,8 +3545,8 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
3460 | "unfailable commands failed.\n"); | 3545 | "unfailable commands failed.\n"); |
3461 | return ret; | 3546 | return ret; |
3462 | } | 3547 | } |
3463 | queue_trb(xhci, xhci->cmd_ring, false, false, false, field1, field2, | 3548 | queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, |
3464 | field3, field4 | xhci->cmd_ring->cycle_state); | 3549 | field4 | xhci->cmd_ring->cycle_state); |
3465 | return 0; | 3550 | return 0; |
3466 | } | 3551 | } |
3467 | 3552 | ||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c939f5fdef9e..e1963d4a430f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -224,13 +224,13 @@ static void xhci_free_irq(struct xhci_hcd *xhci) | |||
224 | int ret; | 224 | int ret; |
225 | 225 | ||
226 | /* return if using legacy interrupt */ | 226 | /* return if using legacy interrupt */ |
227 | if (xhci_to_hcd(xhci)->irq >= 0) | 227 | if (xhci_to_hcd(xhci)->irq > 0) |
228 | return; | 228 | return; |
229 | 229 | ||
230 | ret = xhci_free_msi(xhci); | 230 | ret = xhci_free_msi(xhci); |
231 | if (!ret) | 231 | if (!ret) |
232 | return; | 232 | return; |
233 | if (pdev->irq >= 0) | 233 | if (pdev->irq > 0) |
234 | free_irq(pdev->irq, xhci_to_hcd(xhci)); | 234 | free_irq(pdev->irq, xhci_to_hcd(xhci)); |
235 | 235 | ||
236 | return; | 236 | return; |
@@ -341,7 +341,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) | |||
341 | /* unregister the legacy interrupt */ | 341 | /* unregister the legacy interrupt */ |
342 | if (hcd->irq) | 342 | if (hcd->irq) |
343 | free_irq(hcd->irq, hcd); | 343 | free_irq(hcd->irq, hcd); |
344 | hcd->irq = -1; | 344 | hcd->irq = 0; |
345 | 345 | ||
346 | ret = xhci_setup_msix(xhci); | 346 | ret = xhci_setup_msix(xhci); |
347 | if (ret) | 347 | if (ret) |
@@ -349,7 +349,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) | |||
349 | ret = xhci_setup_msi(xhci); | 349 | ret = xhci_setup_msi(xhci); |
350 | 350 | ||
351 | if (!ret) | 351 | if (!ret) |
352 | /* hcd->irq is -1, we have MSI */ | 352 | /* hcd->irq is 0, we have MSI */ |
353 | return 0; | 353 | return 0; |
354 | 354 | ||
355 | if (!pdev->irq) { | 355 | if (!pdev->irq) { |
@@ -729,6 +729,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) | |||
729 | ring->enq_seg = ring->deq_seg; | 729 | ring->enq_seg = ring->deq_seg; |
730 | ring->enqueue = ring->dequeue; | 730 | ring->enqueue = ring->dequeue; |
731 | 731 | ||
732 | ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; | ||
732 | /* | 733 | /* |
733 | * Ring is now zeroed, so the HW should look for change of ownership | 734 | * Ring is now zeroed, so the HW should look for change of ownership |
734 | * when the cycle bit is set to 1. | 735 | * when the cycle bit is set to 1. |
@@ -3614,26 +3615,38 @@ static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000, | |||
3614 | 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000}; | 3615 | 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000}; |
3615 | 3616 | ||
3616 | /* Calculate HIRD/BESL for USB2 PORTPMSC*/ | 3617 | /* Calculate HIRD/BESL for USB2 PORTPMSC*/ |
3617 | static int xhci_calculate_hird_besl(int u2del, bool use_besl) | 3618 | static int xhci_calculate_hird_besl(struct xhci_hcd *xhci, |
3619 | struct usb_device *udev) | ||
3618 | { | 3620 | { |
3619 | int hird; | 3621 | int u2del, besl, besl_host; |
3622 | int besl_device = 0; | ||
3623 | u32 field; | ||
3624 | |||
3625 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | ||
3626 | field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); | ||
3620 | 3627 | ||
3621 | if (use_besl) { | 3628 | if (field & USB_BESL_SUPPORT) { |
3622 | for (hird = 0; hird < 16; hird++) { | 3629 | for (besl_host = 0; besl_host < 16; besl_host++) { |
3623 | if (xhci_besl_encoding[hird] >= u2del) | 3630 | if (xhci_besl_encoding[besl_host] >= u2del) |
3624 | break; | 3631 | break; |
3625 | } | 3632 | } |
3633 | /* Use baseline BESL value as default */ | ||
3634 | if (field & USB_BESL_BASELINE_VALID) | ||
3635 | besl_device = USB_GET_BESL_BASELINE(field); | ||
3636 | else if (field & USB_BESL_DEEP_VALID) | ||
3637 | besl_device = USB_GET_BESL_DEEP(field); | ||
3626 | } else { | 3638 | } else { |
3627 | if (u2del <= 50) | 3639 | if (u2del <= 50) |
3628 | hird = 0; | 3640 | besl_host = 0; |
3629 | else | 3641 | else |
3630 | hird = (u2del - 51) / 75 + 1; | 3642 | besl_host = (u2del - 51) / 75 + 1; |
3631 | |||
3632 | if (hird > 15) | ||
3633 | hird = 15; | ||
3634 | } | 3643 | } |
3635 | 3644 | ||
3636 | return hird; | 3645 | besl = besl_host + besl_device; |
3646 | if (besl > 15) | ||
3647 | besl = 15; | ||
3648 | |||
3649 | return besl; | ||
3637 | } | 3650 | } |
3638 | 3651 | ||
3639 | static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | 3652 | static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, |
@@ -3646,7 +3659,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
3646 | u32 temp, dev_id; | 3659 | u32 temp, dev_id; |
3647 | unsigned int port_num; | 3660 | unsigned int port_num; |
3648 | unsigned long flags; | 3661 | unsigned long flags; |
3649 | int u2del, hird; | 3662 | int hird; |
3650 | int ret; | 3663 | int ret; |
3651 | 3664 | ||
3652 | if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support || | 3665 | if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support || |
@@ -3692,12 +3705,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
3692 | * HIRD or BESL shoule be used. See USB2.0 LPM errata. | 3705 | * HIRD or BESL shoule be used. See USB2.0 LPM errata. |
3693 | */ | 3706 | */ |
3694 | pm_addr = port_array[port_num] + 1; | 3707 | pm_addr = port_array[port_num] + 1; |
3695 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | 3708 | hird = xhci_calculate_hird_besl(xhci, udev); |
3696 | if (le32_to_cpu(udev->bos->ext_cap->bmAttributes) & (1 << 2)) | ||
3697 | hird = xhci_calculate_hird_besl(u2del, 1); | ||
3698 | else | ||
3699 | hird = xhci_calculate_hird_besl(u2del, 0); | ||
3700 | |||
3701 | temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); | 3709 | temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); |
3702 | xhci_writel(xhci, temp, pm_addr); | 3710 | xhci_writel(xhci, temp, pm_addr); |
3703 | 3711 | ||
@@ -3776,7 +3784,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, | |||
3776 | u32 temp; | 3784 | u32 temp; |
3777 | unsigned int port_num; | 3785 | unsigned int port_num; |
3778 | unsigned long flags; | 3786 | unsigned long flags; |
3779 | int u2del, hird; | 3787 | int hird; |
3780 | 3788 | ||
3781 | if (hcd->speed == HCD_USB3 || !xhci->hw_lpm_support || | 3789 | if (hcd->speed == HCD_USB3 || !xhci->hw_lpm_support || |
3782 | !udev->lpm_capable) | 3790 | !udev->lpm_capable) |
@@ -3799,11 +3807,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, | |||
3799 | xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", | 3807 | xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", |
3800 | enable ? "enable" : "disable", port_num); | 3808 | enable ? "enable" : "disable", port_num); |
3801 | 3809 | ||
3802 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | 3810 | hird = xhci_calculate_hird_besl(xhci, udev); |
3803 | if (le32_to_cpu(udev->bos->ext_cap->bmAttributes) & (1 << 2)) | ||
3804 | hird = xhci_calculate_hird_besl(u2del, 1); | ||
3805 | else | ||
3806 | hird = xhci_calculate_hird_besl(u2del, 0); | ||
3807 | 3811 | ||
3808 | if (enable) { | 3812 | if (enable) { |
3809 | temp &= ~PORT_HIRD_MASK; | 3813 | temp &= ~PORT_HIRD_MASK; |
@@ -3964,7 +3968,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) | |||
3964 | int retval; | 3968 | int retval; |
3965 | u32 temp; | 3969 | u32 temp; |
3966 | 3970 | ||
3967 | hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2; | 3971 | /* Accept arbitrarily long scatter-gather lists */ |
3972 | hcd->self.sg_tablesize = ~0; | ||
3968 | 3973 | ||
3969 | if (usb_hcd_is_primary_hcd(hcd)) { | 3974 | if (usb_hcd_is_primary_hcd(hcd)) { |
3970 | xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL); | 3975 | xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL); |
@@ -4059,6 +4064,11 @@ static int __init xhci_hcd_init(void) | |||
4059 | printk(KERN_DEBUG "Problem registering PCI driver."); | 4064 | printk(KERN_DEBUG "Problem registering PCI driver."); |
4060 | return retval; | 4065 | return retval; |
4061 | } | 4066 | } |
4067 | retval = xhci_register_plat(); | ||
4068 | if (retval < 0) { | ||
4069 | printk(KERN_DEBUG "Problem registering platform driver."); | ||
4070 | goto unreg_pci; | ||
4071 | } | ||
4062 | /* | 4072 | /* |
4063 | * Check the compiler generated sizes of structures that must be laid | 4073 | * Check the compiler generated sizes of structures that must be laid |
4064 | * out in specific ways for hardware access. | 4074 | * out in specific ways for hardware access. |
@@ -4078,11 +4088,15 @@ static int __init xhci_hcd_init(void) | |||
4078 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); | 4088 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); |
4079 | BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8); | 4089 | BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8); |
4080 | return 0; | 4090 | return 0; |
4091 | unreg_pci: | ||
4092 | xhci_unregister_pci(); | ||
4093 | return retval; | ||
4081 | } | 4094 | } |
4082 | module_init(xhci_hcd_init); | 4095 | module_init(xhci_hcd_init); |
4083 | 4096 | ||
4084 | static void __exit xhci_hcd_cleanup(void) | 4097 | static void __exit xhci_hcd_cleanup(void) |
4085 | { | 4098 | { |
4086 | xhci_unregister_pci(); | 4099 | xhci_unregister_pci(); |
4100 | xhci_unregister_plat(); | ||
4087 | } | 4101 | } |
4088 | module_exit(xhci_hcd_cleanup); | 4102 | module_exit(xhci_hcd_cleanup); |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fb99c8379142..91074fdab3eb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1223,10 +1223,7 @@ union xhci_trb { | |||
1223 | /* Allow two commands + a link TRB, along with any reserved command TRBs */ | 1223 | /* Allow two commands + a link TRB, along with any reserved command TRBs */ |
1224 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) | 1224 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) |
1225 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) | 1225 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) |
1226 | /* SEGMENT_SHIFT should be log2(SEGMENT_SIZE). | 1226 | #define SEGMENT_SHIFT (__ffs(SEGMENT_SIZE)) |
1227 | * Change this if you change TRBS_PER_SEGMENT! | ||
1228 | */ | ||
1229 | #define SEGMENT_SHIFT 10 | ||
1230 | /* TRB buffer pointers can't cross 64KB boundaries */ | 1227 | /* TRB buffer pointers can't cross 64KB boundaries */ |
1231 | #define TRB_MAX_BUFF_SHIFT 16 | 1228 | #define TRB_MAX_BUFF_SHIFT 16 |
1232 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) | 1229 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) |
@@ -1253,8 +1250,19 @@ struct xhci_dequeue_state { | |||
1253 | int new_cycle_state; | 1250 | int new_cycle_state; |
1254 | }; | 1251 | }; |
1255 | 1252 | ||
1253 | enum xhci_ring_type { | ||
1254 | TYPE_CTRL = 0, | ||
1255 | TYPE_ISOC, | ||
1256 | TYPE_BULK, | ||
1257 | TYPE_INTR, | ||
1258 | TYPE_STREAM, | ||
1259 | TYPE_COMMAND, | ||
1260 | TYPE_EVENT, | ||
1261 | }; | ||
1262 | |||
1256 | struct xhci_ring { | 1263 | struct xhci_ring { |
1257 | struct xhci_segment *first_seg; | 1264 | struct xhci_segment *first_seg; |
1265 | struct xhci_segment *last_seg; | ||
1258 | union xhci_trb *enqueue; | 1266 | union xhci_trb *enqueue; |
1259 | struct xhci_segment *enq_seg; | 1267 | struct xhci_segment *enq_seg; |
1260 | unsigned int enq_updates; | 1268 | unsigned int enq_updates; |
@@ -1269,6 +1277,10 @@ struct xhci_ring { | |||
1269 | */ | 1277 | */ |
1270 | u32 cycle_state; | 1278 | u32 cycle_state; |
1271 | unsigned int stream_id; | 1279 | unsigned int stream_id; |
1280 | unsigned int num_segs; | ||
1281 | unsigned int num_trbs_free; | ||
1282 | unsigned int num_trbs_free_temp; | ||
1283 | enum xhci_ring_type type; | ||
1272 | bool last_td_was_short; | 1284 | bool last_td_was_short; |
1273 | }; | 1285 | }; |
1274 | 1286 | ||
@@ -1344,6 +1356,7 @@ struct xhci_bus_state { | |||
1344 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ | 1356 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ |
1345 | u32 port_c_suspend; | 1357 | u32 port_c_suspend; |
1346 | u32 suspended_ports; | 1358 | u32 suspended_ports; |
1359 | u32 port_remote_wakeup; | ||
1347 | unsigned long resume_done[USB_MAXCHILDREN]; | 1360 | unsigned long resume_done[USB_MAXCHILDREN]; |
1348 | }; | 1361 | }; |
1349 | 1362 | ||
@@ -1609,6 +1622,8 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, | |||
1609 | struct usb_device *udev, struct usb_host_endpoint *ep, | 1622 | struct usb_device *udev, struct usb_host_endpoint *ep, |
1610 | gfp_t mem_flags); | 1623 | gfp_t mem_flags); |
1611 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); | 1624 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); |
1625 | int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
1626 | unsigned int num_trbs, gfp_t flags); | ||
1612 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | 1627 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, |
1613 | struct xhci_virt_device *virt_dev, | 1628 | struct xhci_virt_device *virt_dev, |
1614 | unsigned int ep_index); | 1629 | unsigned int ep_index); |
@@ -1648,6 +1663,17 @@ static inline int xhci_register_pci(void) { return 0; } | |||
1648 | static inline void xhci_unregister_pci(void) {} | 1663 | static inline void xhci_unregister_pci(void) {} |
1649 | #endif | 1664 | #endif |
1650 | 1665 | ||
1666 | #if defined(CONFIG_USB_XHCI_PLATFORM) \ | ||
1667 | || defined(CONFIG_USB_XHCI_PLATFORM_MODULE) | ||
1668 | int xhci_register_plat(void); | ||
1669 | void xhci_unregister_plat(void); | ||
1670 | #else | ||
1671 | static inline int xhci_register_plat(void) | ||
1672 | { return 0; } | ||
1673 | static inline void xhci_unregister_plat(void) | ||
1674 | { } | ||
1675 | #endif | ||
1676 | |||
1651 | /* xHCI host controller glue */ | 1677 | /* xHCI host controller glue */ |
1652 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); | 1678 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
1653 | void xhci_quiesce(struct xhci_hcd *xhci); | 1679 | void xhci_quiesce(struct xhci_hcd *xhci); |