diff options
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 20 | ||||
-rw-r--r-- | drivers/usb/host/ehci-mxc.c | 13 | ||||
-rw-r--r-- | drivers/usb/host/ehci-xilinx-of.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/isp1362-hcd.c | 15 | ||||
-rw-r--r-- | drivers/usb/host/isp1362.h | 2 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597.h | 26 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 93 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 57 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 12 |
11 files changed, 194 insertions, 54 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index ef3e88f0b3c3..a3ef2a9d9dc2 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1135,7 +1135,7 @@ MODULE_LICENSE ("GPL"); | |||
1135 | 1135 | ||
1136 | #ifdef CONFIG_XPS_USB_HCD_XILINX | 1136 | #ifdef CONFIG_XPS_USB_HCD_XILINX |
1137 | #include "ehci-xilinx-of.c" | 1137 | #include "ehci-xilinx-of.c" |
1138 | #define OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver | 1138 | #define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver |
1139 | #endif | 1139 | #endif |
1140 | 1140 | ||
1141 | #ifdef CONFIG_PLAT_ORION | 1141 | #ifdef CONFIG_PLAT_ORION |
@@ -1159,7 +1159,8 @@ MODULE_LICENSE ("GPL"); | |||
1159 | #endif | 1159 | #endif |
1160 | 1160 | ||
1161 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1161 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1162 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) | 1162 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1163 | !defined(XILINX_OF_PLATFORM_DRIVER) | ||
1163 | #error "missing bus glue for ehci-hcd" | 1164 | #error "missing bus glue for ehci-hcd" |
1164 | #endif | 1165 | #endif |
1165 | 1166 | ||
@@ -1213,10 +1214,20 @@ static int __init ehci_hcd_init(void) | |||
1213 | if (retval < 0) | 1214 | if (retval < 0) |
1214 | goto clean3; | 1215 | goto clean3; |
1215 | #endif | 1216 | #endif |
1217 | |||
1218 | #ifdef XILINX_OF_PLATFORM_DRIVER | ||
1219 | retval = of_register_platform_driver(&XILINX_OF_PLATFORM_DRIVER); | ||
1220 | if (retval < 0) | ||
1221 | goto clean4; | ||
1222 | #endif | ||
1216 | return retval; | 1223 | return retval; |
1217 | 1224 | ||
1225 | #ifdef XILINX_OF_PLATFORM_DRIVER | ||
1226 | /* of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER); */ | ||
1227 | clean4: | ||
1228 | #endif | ||
1218 | #ifdef OF_PLATFORM_DRIVER | 1229 | #ifdef OF_PLATFORM_DRIVER |
1219 | /* of_unregister_platform_driver(&OF_PLATFORM_DRIVER); */ | 1230 | of_unregister_platform_driver(&OF_PLATFORM_DRIVER); |
1220 | clean3: | 1231 | clean3: |
1221 | #endif | 1232 | #endif |
1222 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1233 | #ifdef PS3_SYSTEM_BUS_DRIVER |
@@ -1243,6 +1254,9 @@ module_init(ehci_hcd_init); | |||
1243 | 1254 | ||
1244 | static void __exit ehci_hcd_cleanup(void) | 1255 | static void __exit ehci_hcd_cleanup(void) |
1245 | { | 1256 | { |
1257 | #ifdef XILINX_OF_PLATFORM_DRIVER | ||
1258 | of_unregister_platform_driver(&XILINX_OF_PLATFORM_DRIVER); | ||
1259 | #endif | ||
1246 | #ifdef OF_PLATFORM_DRIVER | 1260 | #ifdef OF_PLATFORM_DRIVER |
1247 | of_unregister_platform_driver(&OF_PLATFORM_DRIVER); | 1261 | of_unregister_platform_driver(&OF_PLATFORM_DRIVER); |
1248 | #endif | 1262 | #endif |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 544ccfd7056e..bd4027745aa7 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -207,10 +207,17 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
207 | /* Initialize the transceiver */ | 207 | /* Initialize the transceiver */ |
208 | if (pdata->otg) { | 208 | if (pdata->otg) { |
209 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; | 209 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; |
210 | if (otg_init(pdata->otg) != 0) | 210 | ret = otg_init(pdata->otg); |
211 | dev_err(dev, "unable to init transceiver\n"); | 211 | if (ret) { |
212 | else if (otg_set_vbus(pdata->otg, 1) != 0) | 212 | dev_err(dev, "unable to init transceiver, probably missing\n"); |
213 | ret = -ENODEV; | ||
214 | goto err_add; | ||
215 | } | ||
216 | ret = otg_set_vbus(pdata->otg, 1); | ||
217 | if (ret) { | ||
213 | dev_err(dev, "unable to enable vbus on transceiver\n"); | 218 | dev_err(dev, "unable to enable vbus on transceiver\n"); |
219 | goto err_add; | ||
220 | } | ||
214 | } | 221 | } |
215 | 222 | ||
216 | priv->hcd = hcd; | 223 | priv->hcd = hcd; |
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index 013972bbde57..4899f451add9 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c | |||
@@ -151,7 +151,7 @@ static const struct hc_driver ehci_xilinx_of_hc_driver = { | |||
151 | static int __devinit | 151 | static int __devinit |
152 | ehci_hcd_xilinx_of_probe(struct of_device *op, const struct of_device_id *match) | 152 | ehci_hcd_xilinx_of_probe(struct of_device *op, const struct of_device_id *match) |
153 | { | 153 | { |
154 | struct device_node *dn = op->node; | 154 | struct device_node *dn = op->dev.of_node; |
155 | struct usb_hcd *hcd; | 155 | struct usb_hcd *hcd; |
156 | struct ehci_hcd *ehci; | 156 | struct ehci_hcd *ehci; |
157 | struct resource res; | 157 | struct resource res; |
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 20a0dfe0fe36..0587ad4ce5c2 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c | |||
@@ -2224,12 +2224,9 @@ static void remove_debug_file(struct isp1362_hcd *isp1362_hcd) | |||
2224 | 2224 | ||
2225 | /*-------------------------------------------------------------------------*/ | 2225 | /*-------------------------------------------------------------------------*/ |
2226 | 2226 | ||
2227 | static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) | 2227 | static void __isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) |
2228 | { | 2228 | { |
2229 | int tmp = 20; | 2229 | int tmp = 20; |
2230 | unsigned long flags; | ||
2231 | |||
2232 | spin_lock_irqsave(&isp1362_hcd->lock, flags); | ||
2233 | 2230 | ||
2234 | isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC); | 2231 | isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC); |
2235 | isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR); | 2232 | isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR); |
@@ -2240,6 +2237,14 @@ static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) | |||
2240 | } | 2237 | } |
2241 | if (!tmp) | 2238 | if (!tmp) |
2242 | pr_err("Software reset timeout\n"); | 2239 | pr_err("Software reset timeout\n"); |
2240 | } | ||
2241 | |||
2242 | static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) | ||
2243 | { | ||
2244 | unsigned long flags; | ||
2245 | |||
2246 | spin_lock_irqsave(&isp1362_hcd->lock, flags); | ||
2247 | __isp1362_sw_reset(isp1362_hcd); | ||
2243 | spin_unlock_irqrestore(&isp1362_hcd->lock, flags); | 2248 | spin_unlock_irqrestore(&isp1362_hcd->lock, flags); |
2244 | } | 2249 | } |
2245 | 2250 | ||
@@ -2418,7 +2423,7 @@ static void isp1362_hc_stop(struct usb_hcd *hcd) | |||
2418 | if (isp1362_hcd->board && isp1362_hcd->board->reset) | 2423 | if (isp1362_hcd->board && isp1362_hcd->board->reset) |
2419 | isp1362_hcd->board->reset(hcd->self.controller, 1); | 2424 | isp1362_hcd->board->reset(hcd->self.controller, 1); |
2420 | else | 2425 | else |
2421 | isp1362_sw_reset(isp1362_hcd); | 2426 | __isp1362_sw_reset(isp1362_hcd); |
2422 | 2427 | ||
2423 | if (isp1362_hcd->board && isp1362_hcd->board->clock) | 2428 | if (isp1362_hcd->board && isp1362_hcd->board->clock) |
2424 | isp1362_hcd->board->clock(hcd->self.controller, 0); | 2429 | isp1362_hcd->board->clock(hcd->self.controller, 0); |
diff --git a/drivers/usb/host/isp1362.h b/drivers/usb/host/isp1362.h index 5151516ea1de..d995351f9bed 100644 --- a/drivers/usb/host/isp1362.h +++ b/drivers/usb/host/isp1362.h | |||
@@ -65,7 +65,7 @@ static inline void delayed_insw(unsigned int addr, void *buf, int len) | |||
65 | unsigned short *bp = (unsigned short *)buf; | 65 | unsigned short *bp = (unsigned short *)buf; |
66 | while (len--) { | 66 | while (len--) { |
67 | DUMMY_DELAY_ACCESS; | 67 | DUMMY_DELAY_ACCESS; |
68 | *bp++ = inw((void *)addr); | 68 | *bp++ = inw(addr); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 6db57ab6079d..77be3c24a427 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -1065,7 +1065,7 @@ static void r8a66597_usb_connect(struct r8a66597 *r8a66597, int port) | |||
1065 | else if (speed == LSMODE) | 1065 | else if (speed == LSMODE) |
1066 | rh->port |= USB_PORT_STAT_LOW_SPEED; | 1066 | rh->port |= USB_PORT_STAT_LOW_SPEED; |
1067 | 1067 | ||
1068 | rh->port &= USB_PORT_STAT_RESET; | 1068 | rh->port &= ~USB_PORT_STAT_RESET; |
1069 | rh->port |= USB_PORT_STAT_ENABLE; | 1069 | rh->port |= USB_PORT_STAT_ENABLE; |
1070 | } | 1070 | } |
1071 | 1071 | ||
@@ -2404,7 +2404,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2404 | 2404 | ||
2405 | del_timer_sync(&r8a66597->rh_timer); | 2405 | del_timer_sync(&r8a66597->rh_timer); |
2406 | usb_remove_hcd(hcd); | 2406 | usb_remove_hcd(hcd); |
2407 | iounmap((void *)r8a66597->reg); | 2407 | iounmap(r8a66597->reg); |
2408 | #ifdef CONFIG_HAVE_CLK | 2408 | #ifdef CONFIG_HAVE_CLK |
2409 | if (r8a66597->pdata->on_chip) | 2409 | if (r8a66597->pdata->on_chip) |
2410 | clk_put(r8a66597->clk); | 2410 | clk_put(r8a66597->clk); |
@@ -2496,7 +2496,7 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2496 | init_timer(&r8a66597->rh_timer); | 2496 | init_timer(&r8a66597->rh_timer); |
2497 | r8a66597->rh_timer.function = r8a66597_timer; | 2497 | r8a66597->rh_timer.function = r8a66597_timer; |
2498 | r8a66597->rh_timer.data = (unsigned long)r8a66597; | 2498 | r8a66597->rh_timer.data = (unsigned long)r8a66597; |
2499 | r8a66597->reg = (unsigned long)reg; | 2499 | r8a66597->reg = reg; |
2500 | 2500 | ||
2501 | /* make sure no interrupts are pending */ | 2501 | /* make sure no interrupts are pending */ |
2502 | ret = r8a66597_clock_enable(r8a66597); | 2502 | ret = r8a66597_clock_enable(r8a66597); |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 228e3fb23854..95d0f5adfdcf 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -112,7 +112,7 @@ struct r8a66597_root_hub { | |||
112 | 112 | ||
113 | struct r8a66597 { | 113 | struct r8a66597 { |
114 | spinlock_t lock; | 114 | spinlock_t lock; |
115 | unsigned long reg; | 115 | void __iomem *reg; |
116 | #ifdef CONFIG_HAVE_CLK | 116 | #ifdef CONFIG_HAVE_CLK |
117 | struct clk *clk; | 117 | struct clk *clk; |
118 | #endif | 118 | #endif |
@@ -170,67 +170,67 @@ static inline struct urb *r8a66597_get_urb(struct r8a66597 *r8a66597, | |||
170 | 170 | ||
171 | static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset) | 171 | static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset) |
172 | { | 172 | { |
173 | return inw(r8a66597->reg + offset); | 173 | return ioread16(r8a66597->reg + offset); |
174 | } | 174 | } |
175 | 175 | ||
176 | static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, | 176 | static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, |
177 | unsigned long offset, u16 *buf, | 177 | unsigned long offset, u16 *buf, |
178 | int len) | 178 | int len) |
179 | { | 179 | { |
180 | unsigned long fifoaddr = r8a66597->reg + offset; | 180 | void __iomem *fifoaddr = r8a66597->reg + offset; |
181 | unsigned long count; | 181 | unsigned long count; |
182 | 182 | ||
183 | if (r8a66597->pdata->on_chip) { | 183 | if (r8a66597->pdata->on_chip) { |
184 | count = len / 4; | 184 | count = len / 4; |
185 | insl(fifoaddr, buf, count); | 185 | ioread32_rep(fifoaddr, buf, count); |
186 | 186 | ||
187 | if (len & 0x00000003) { | 187 | if (len & 0x00000003) { |
188 | unsigned long tmp = inl(fifoaddr); | 188 | unsigned long tmp = ioread32(fifoaddr); |
189 | memcpy((unsigned char *)buf + count * 4, &tmp, | 189 | memcpy((unsigned char *)buf + count * 4, &tmp, |
190 | len & 0x03); | 190 | len & 0x03); |
191 | } | 191 | } |
192 | } else { | 192 | } else { |
193 | len = (len + 1) / 2; | 193 | len = (len + 1) / 2; |
194 | insw(fifoaddr, buf, len); | 194 | ioread16_rep(fifoaddr, buf, len); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | 198 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, |
199 | unsigned long offset) | 199 | unsigned long offset) |
200 | { | 200 | { |
201 | outw(val, r8a66597->reg + offset); | 201 | iowrite16(val, r8a66597->reg + offset); |
202 | } | 202 | } |
203 | 203 | ||
204 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | 204 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, |
205 | unsigned long offset, u16 *buf, | 205 | unsigned long offset, u16 *buf, |
206 | int len) | 206 | int len) |
207 | { | 207 | { |
208 | unsigned long fifoaddr = r8a66597->reg + offset; | 208 | void __iomem *fifoaddr = r8a66597->reg + offset; |
209 | unsigned long count; | 209 | unsigned long count; |
210 | unsigned char *pb; | 210 | unsigned char *pb; |
211 | int i; | 211 | int i; |
212 | 212 | ||
213 | if (r8a66597->pdata->on_chip) { | 213 | if (r8a66597->pdata->on_chip) { |
214 | count = len / 4; | 214 | count = len / 4; |
215 | outsl(fifoaddr, buf, count); | 215 | iowrite32_rep(fifoaddr, buf, count); |
216 | 216 | ||
217 | if (len & 0x00000003) { | 217 | if (len & 0x00000003) { |
218 | pb = (unsigned char *)buf + count * 4; | 218 | pb = (unsigned char *)buf + count * 4; |
219 | for (i = 0; i < (len & 0x00000003); i++) { | 219 | for (i = 0; i < (len & 0x00000003); i++) { |
220 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | 220 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) |
221 | outb(pb[i], fifoaddr + i); | 221 | iowrite8(pb[i], fifoaddr + i); |
222 | else | 222 | else |
223 | outb(pb[i], fifoaddr + 3 - i); | 223 | iowrite8(pb[i], fifoaddr + 3 - i); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } else { | 226 | } else { |
227 | int odd = len & 0x0001; | 227 | int odd = len & 0x0001; |
228 | 228 | ||
229 | len = len / 2; | 229 | len = len / 2; |
230 | outsw(fifoaddr, buf, len); | 230 | ioread16_rep(fifoaddr, buf, len); |
231 | if (unlikely(odd)) { | 231 | if (unlikely(odd)) { |
232 | buf = &buf[len]; | 232 | buf = &buf[len]; |
233 | outb((unsigned char)*buf, fifoaddr); | 233 | iowrite8((unsigned char)*buf, fifoaddr); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | } | 236 | } |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index edffd81fc253..11482b6b9381 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -78,6 +78,8 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
78 | xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" | 78 | xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" |
79 | " endpoint cmd after reset endpoint\n"); | 79 | " endpoint cmd after reset endpoint\n"); |
80 | } | 80 | } |
81 | if (pdev->vendor == PCI_VENDOR_ID_NEC) | ||
82 | xhci->quirks |= XHCI_NEC_HOST; | ||
81 | 83 | ||
82 | /* Make sure the HC is halted. */ | 84 | /* Make sure the HC is halted. */ |
83 | retval = xhci_halt(xhci); | 85 | retval = xhci_halt(xhci); |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 36c858e5b529..94e6934edb09 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -182,8 +182,12 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer | |||
182 | * set, but other sections talk about dealing with the chain bit set. This was | 182 | * set, but other sections talk about dealing with the chain bit set. This was |
183 | * fixed in the 0.96 specification errata, but we have to assume that all 0.95 | 183 | * fixed in the 0.96 specification errata, but we have to assume that all 0.95 |
184 | * xHCI hardware can't handle the chain bit being cleared on a link TRB. | 184 | * xHCI hardware can't handle the chain bit being cleared on a link TRB. |
185 | * | ||
186 | * @more_trbs_coming: Will you enqueue more TRBs before calling | ||
187 | * prepare_transfer()? | ||
185 | */ | 188 | */ |
186 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) | 189 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, |
190 | bool consumer, bool more_trbs_coming) | ||
187 | { | 191 | { |
188 | u32 chain; | 192 | u32 chain; |
189 | union xhci_trb *next; | 193 | union xhci_trb *next; |
@@ -199,15 +203,28 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer | |||
199 | while (last_trb(xhci, ring, ring->enq_seg, next)) { | 203 | while (last_trb(xhci, ring, ring->enq_seg, next)) { |
200 | if (!consumer) { | 204 | if (!consumer) { |
201 | if (ring != xhci->event_ring) { | 205 | if (ring != xhci->event_ring) { |
202 | if (chain) { | 206 | /* |
203 | next->link.control |= TRB_CHAIN; | 207 | * If the caller doesn't plan on enqueueing more |
204 | 208 | * TDs before ringing the doorbell, then we | |
205 | /* Give this link TRB to the hardware */ | 209 | * don't want to give the link TRB to the |
206 | wmb(); | 210 | * hardware just yet. We'll give the link TRB |
207 | next->link.control ^= TRB_CYCLE; | 211 | * back in prepare_ring() just before we enqueue |
208 | } else { | 212 | * the TD at the top of the ring. |
213 | */ | ||
214 | if (!chain && !more_trbs_coming) | ||
209 | break; | 215 | break; |
216 | |||
217 | /* If we're not dealing with 0.95 hardware, | ||
218 | * carry over the chain bit of the previous TRB | ||
219 | * (which may mean the chain bit is cleared). | ||
220 | */ | ||
221 | if (!xhci_link_trb_quirk(xhci)) { | ||
222 | next->link.control &= ~TRB_CHAIN; | ||
223 | next->link.control |= chain; | ||
210 | } | 224 | } |
225 | /* Give this link TRB to the hardware */ | ||
226 | wmb(); | ||
227 | next->link.control ^= TRB_CYCLE; | ||
211 | } | 228 | } |
212 | /* Toggle the cycle bit after the last ring segment. */ | 229 | /* Toggle the cycle bit after the last ring segment. */ |
213 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 230 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
@@ -1071,6 +1088,15 @@ bandwidth_change: | |||
1071 | xhci_warn(xhci, "Reset device command completion " | 1088 | xhci_warn(xhci, "Reset device command completion " |
1072 | "for disabled slot %u\n", slot_id); | 1089 | "for disabled slot %u\n", slot_id); |
1073 | break; | 1090 | break; |
1091 | case TRB_TYPE(TRB_NEC_GET_FW): | ||
1092 | if (!(xhci->quirks & XHCI_NEC_HOST)) { | ||
1093 | xhci->error_bitmask |= 1 << 6; | ||
1094 | break; | ||
1095 | } | ||
1096 | xhci_dbg(xhci, "NEC firmware version %2x.%02x\n", | ||
1097 | NEC_FW_MAJOR(event->status), | ||
1098 | NEC_FW_MINOR(event->status)); | ||
1099 | break; | ||
1074 | default: | 1100 | default: |
1075 | /* Skip over unknown commands on the event ring */ | 1101 | /* Skip over unknown commands on the event ring */ |
1076 | xhci->error_bitmask |= 1 << 6; | 1102 | xhci->error_bitmask |= 1 << 6; |
@@ -1079,6 +1105,17 @@ bandwidth_change: | |||
1079 | inc_deq(xhci, xhci->cmd_ring, false); | 1105 | inc_deq(xhci, xhci->cmd_ring, false); |
1080 | } | 1106 | } |
1081 | 1107 | ||
1108 | static void handle_vendor_event(struct xhci_hcd *xhci, | ||
1109 | union xhci_trb *event) | ||
1110 | { | ||
1111 | u32 trb_type; | ||
1112 | |||
1113 | trb_type = TRB_FIELD_TO_TYPE(event->generic.field[3]); | ||
1114 | xhci_dbg(xhci, "Vendor specific event TRB type = %u\n", trb_type); | ||
1115 | if (trb_type == TRB_NEC_CMD_COMP && (xhci->quirks & XHCI_NEC_HOST)) | ||
1116 | handle_cmd_completion(xhci, &event->event_cmd); | ||
1117 | } | ||
1118 | |||
1082 | static void handle_port_status(struct xhci_hcd *xhci, | 1119 | static void handle_port_status(struct xhci_hcd *xhci, |
1083 | union xhci_trb *event) | 1120 | union xhci_trb *event) |
1084 | { | 1121 | { |
@@ -1659,7 +1696,10 @@ void xhci_handle_event(struct xhci_hcd *xhci) | |||
1659 | update_ptrs = 0; | 1696 | update_ptrs = 0; |
1660 | break; | 1697 | break; |
1661 | default: | 1698 | default: |
1662 | xhci->error_bitmask |= 1 << 3; | 1699 | if ((event->event_cmd.flags & TRB_TYPE_BITMASK) >= TRB_TYPE(48)) |
1700 | handle_vendor_event(xhci, event); | ||
1701 | else | ||
1702 | xhci->error_bitmask |= 1 << 3; | ||
1663 | } | 1703 | } |
1664 | /* Any of the above functions may drop and re-acquire the lock, so check | 1704 | /* Any of the above functions may drop and re-acquire the lock, so check |
1665 | * to make sure a watchdog timer didn't mark the host as non-responsive. | 1705 | * to make sure a watchdog timer didn't mark the host as non-responsive. |
@@ -1684,9 +1724,12 @@ void xhci_handle_event(struct xhci_hcd *xhci) | |||
1684 | /* | 1724 | /* |
1685 | * Generic function for queueing a TRB on a ring. | 1725 | * Generic function for queueing a TRB on a ring. |
1686 | * The caller must have checked to make sure there's room on the ring. | 1726 | * The caller must have checked to make sure there's room on the ring. |
1727 | * | ||
1728 | * @more_trbs_coming: Will you enqueue more TRBs before calling | ||
1729 | * prepare_transfer()? | ||
1687 | */ | 1730 | */ |
1688 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | 1731 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, |
1689 | bool consumer, | 1732 | bool consumer, bool more_trbs_coming, |
1690 | u32 field1, u32 field2, u32 field3, u32 field4) | 1733 | u32 field1, u32 field2, u32 field3, u32 field4) |
1691 | { | 1734 | { |
1692 | struct xhci_generic_trb *trb; | 1735 | struct xhci_generic_trb *trb; |
@@ -1696,7 +1739,7 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
1696 | trb->field[1] = field2; | 1739 | trb->field[1] = field2; |
1697 | trb->field[2] = field3; | 1740 | trb->field[2] = field3; |
1698 | trb->field[3] = field4; | 1741 | trb->field[3] = field4; |
1699 | inc_enq(xhci, ring, consumer); | 1742 | inc_enq(xhci, ring, consumer, more_trbs_coming); |
1700 | } | 1743 | } |
1701 | 1744 | ||
1702 | /* | 1745 | /* |
@@ -1965,6 +2008,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
1965 | int trb_buff_len, this_sg_len, running_total; | 2008 | int trb_buff_len, this_sg_len, running_total; |
1966 | bool first_trb; | 2009 | bool first_trb; |
1967 | u64 addr; | 2010 | u64 addr; |
2011 | bool more_trbs_coming; | ||
1968 | 2012 | ||
1969 | struct xhci_generic_trb *start_trb; | 2013 | struct xhci_generic_trb *start_trb; |
1970 | int start_cycle; | 2014 | int start_cycle; |
@@ -2050,7 +2094,11 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2050 | length_field = TRB_LEN(trb_buff_len) | | 2094 | length_field = TRB_LEN(trb_buff_len) | |
2051 | remainder | | 2095 | remainder | |
2052 | TRB_INTR_TARGET(0); | 2096 | TRB_INTR_TARGET(0); |
2053 | queue_trb(xhci, ep_ring, false, | 2097 | if (num_trbs > 1) |
2098 | more_trbs_coming = true; | ||
2099 | else | ||
2100 | more_trbs_coming = false; | ||
2101 | queue_trb(xhci, ep_ring, false, more_trbs_coming, | ||
2054 | lower_32_bits(addr), | 2102 | lower_32_bits(addr), |
2055 | upper_32_bits(addr), | 2103 | upper_32_bits(addr), |
2056 | length_field, | 2104 | length_field, |
@@ -2101,6 +2149,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2101 | int num_trbs; | 2149 | int num_trbs; |
2102 | struct xhci_generic_trb *start_trb; | 2150 | struct xhci_generic_trb *start_trb; |
2103 | bool first_trb; | 2151 | bool first_trb; |
2152 | bool more_trbs_coming; | ||
2104 | int start_cycle; | 2153 | int start_cycle; |
2105 | u32 field, length_field; | 2154 | u32 field, length_field; |
2106 | 2155 | ||
@@ -2189,7 +2238,11 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2189 | length_field = TRB_LEN(trb_buff_len) | | 2238 | length_field = TRB_LEN(trb_buff_len) | |
2190 | remainder | | 2239 | remainder | |
2191 | TRB_INTR_TARGET(0); | 2240 | TRB_INTR_TARGET(0); |
2192 | queue_trb(xhci, ep_ring, false, | 2241 | if (num_trbs > 1) |
2242 | more_trbs_coming = true; | ||
2243 | else | ||
2244 | more_trbs_coming = false; | ||
2245 | queue_trb(xhci, ep_ring, false, more_trbs_coming, | ||
2193 | lower_32_bits(addr), | 2246 | lower_32_bits(addr), |
2194 | upper_32_bits(addr), | 2247 | upper_32_bits(addr), |
2195 | length_field, | 2248 | length_field, |
@@ -2268,7 +2321,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2268 | /* Queue setup TRB - see section 6.4.1.2.1 */ | 2321 | /* Queue setup TRB - see section 6.4.1.2.1 */ |
2269 | /* FIXME better way to translate setup_packet into two u32 fields? */ | 2322 | /* FIXME better way to translate setup_packet into two u32 fields? */ |
2270 | setup = (struct usb_ctrlrequest *) urb->setup_packet; | 2323 | setup = (struct usb_ctrlrequest *) urb->setup_packet; |
2271 | queue_trb(xhci, ep_ring, false, | 2324 | queue_trb(xhci, ep_ring, false, true, |
2272 | /* FIXME endianness is probably going to bite my ass here. */ | 2325 | /* FIXME endianness is probably going to bite my ass here. */ |
2273 | setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16, | 2326 | setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16, |
2274 | setup->wIndex | setup->wLength << 16, | 2327 | setup->wIndex | setup->wLength << 16, |
@@ -2284,7 +2337,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2284 | if (urb->transfer_buffer_length > 0) { | 2337 | if (urb->transfer_buffer_length > 0) { |
2285 | if (setup->bRequestType & USB_DIR_IN) | 2338 | if (setup->bRequestType & USB_DIR_IN) |
2286 | field |= TRB_DIR_IN; | 2339 | field |= TRB_DIR_IN; |
2287 | queue_trb(xhci, ep_ring, false, | 2340 | queue_trb(xhci, ep_ring, false, true, |
2288 | lower_32_bits(urb->transfer_dma), | 2341 | lower_32_bits(urb->transfer_dma), |
2289 | upper_32_bits(urb->transfer_dma), | 2342 | upper_32_bits(urb->transfer_dma), |
2290 | length_field, | 2343 | length_field, |
@@ -2301,7 +2354,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2301 | field = 0; | 2354 | field = 0; |
2302 | else | 2355 | else |
2303 | field = TRB_DIR_IN; | 2356 | field = TRB_DIR_IN; |
2304 | queue_trb(xhci, ep_ring, false, | 2357 | queue_trb(xhci, ep_ring, false, false, |
2305 | 0, | 2358 | 0, |
2306 | 0, | 2359 | 0, |
2307 | TRB_INTR_TARGET(0), | 2360 | TRB_INTR_TARGET(0), |
@@ -2338,7 +2391,7 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
2338 | "unfailable commands failed.\n"); | 2391 | "unfailable commands failed.\n"); |
2339 | return -ENOMEM; | 2392 | return -ENOMEM; |
2340 | } | 2393 | } |
2341 | queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, | 2394 | queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3, |
2342 | field4 | xhci->cmd_ring->cycle_state); | 2395 | field4 | xhci->cmd_ring->cycle_state); |
2343 | return 0; | 2396 | return 0; |
2344 | } | 2397 | } |
@@ -2378,6 +2431,12 @@ int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | |||
2378 | false); | 2431 | false); |
2379 | } | 2432 | } |
2380 | 2433 | ||
2434 | int xhci_queue_vendor_command(struct xhci_hcd *xhci, | ||
2435 | u32 field1, u32 field2, u32 field3, u32 field4) | ||
2436 | { | ||
2437 | return queue_command(xhci, field1, field2, field3, field4, false); | ||
2438 | } | ||
2439 | |||
2381 | /* Queue a reset device command TRB */ | 2440 | /* Queue a reset device command TRB */ |
2382 | int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id) | 2441 | int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id) |
2383 | { | 2442 | { |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 40e0a0c221b8..27345cd04da0 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -106,6 +106,33 @@ int xhci_halt(struct xhci_hcd *xhci) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | /* |
109 | * Set the run bit and wait for the host to be running. | ||
110 | */ | ||
111 | int xhci_start(struct xhci_hcd *xhci) | ||
112 | { | ||
113 | u32 temp; | ||
114 | int ret; | ||
115 | |||
116 | temp = xhci_readl(xhci, &xhci->op_regs->command); | ||
117 | temp |= (CMD_RUN); | ||
118 | xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n", | ||
119 | temp); | ||
120 | xhci_writel(xhci, temp, &xhci->op_regs->command); | ||
121 | |||
122 | /* | ||
123 | * Wait for the HCHalted Status bit to be 0 to indicate the host is | ||
124 | * running. | ||
125 | */ | ||
126 | ret = handshake(xhci, &xhci->op_regs->status, | ||
127 | STS_HALT, 0, XHCI_MAX_HALT_USEC); | ||
128 | if (ret == -ETIMEDOUT) | ||
129 | xhci_err(xhci, "Host took too long to start, " | ||
130 | "waited %u microseconds.\n", | ||
131 | XHCI_MAX_HALT_USEC); | ||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | /* | ||
109 | * Reset a halted HC, and set the internal HC state to HC_STATE_HALT. | 136 | * Reset a halted HC, and set the internal HC state to HC_STATE_HALT. |
110 | * | 137 | * |
111 | * This resets pipelines, timers, counters, state machines, etc. | 138 | * This resets pipelines, timers, counters, state machines, etc. |
@@ -116,6 +143,7 @@ int xhci_reset(struct xhci_hcd *xhci) | |||
116 | { | 143 | { |
117 | u32 command; | 144 | u32 command; |
118 | u32 state; | 145 | u32 state; |
146 | int ret; | ||
119 | 147 | ||
120 | state = xhci_readl(xhci, &xhci->op_regs->status); | 148 | state = xhci_readl(xhci, &xhci->op_regs->status); |
121 | if ((state & STS_HALT) == 0) { | 149 | if ((state & STS_HALT) == 0) { |
@@ -130,7 +158,17 @@ int xhci_reset(struct xhci_hcd *xhci) | |||
130 | /* XXX: Why does EHCI set this here? Shouldn't other code do this? */ | 158 | /* XXX: Why does EHCI set this here? Shouldn't other code do this? */ |
131 | xhci_to_hcd(xhci)->state = HC_STATE_HALT; | 159 | xhci_to_hcd(xhci)->state = HC_STATE_HALT; |
132 | 160 | ||
133 | return handshake(xhci, &xhci->op_regs->command, CMD_RESET, 0, 250 * 1000); | 161 | ret = handshake(xhci, &xhci->op_regs->command, |
162 | CMD_RESET, 0, 250 * 1000); | ||
163 | if (ret) | ||
164 | return ret; | ||
165 | |||
166 | xhci_dbg(xhci, "Wait for controller to be ready for doorbell rings\n"); | ||
167 | /* | ||
168 | * xHCI cannot write to any doorbells or operational registers other | ||
169 | * than status until the "Controller Not Ready" flag is cleared. | ||
170 | */ | ||
171 | return handshake(xhci, &xhci->op_regs->status, STS_CNR, 0, 250 * 1000); | ||
134 | } | 172 | } |
135 | 173 | ||
136 | 174 | ||
@@ -448,17 +486,20 @@ int xhci_run(struct usb_hcd *hcd) | |||
448 | 486 | ||
449 | if (NUM_TEST_NOOPS > 0) | 487 | if (NUM_TEST_NOOPS > 0) |
450 | doorbell = xhci_setup_one_noop(xhci); | 488 | doorbell = xhci_setup_one_noop(xhci); |
489 | if (xhci->quirks & XHCI_NEC_HOST) | ||
490 | xhci_queue_vendor_command(xhci, 0, 0, 0, | ||
491 | TRB_TYPE(TRB_NEC_GET_FW)); | ||
492 | |||
493 | if (xhci_start(xhci)) { | ||
494 | xhci_halt(xhci); | ||
495 | return -ENODEV; | ||
496 | } | ||
451 | 497 | ||
452 | temp = xhci_readl(xhci, &xhci->op_regs->command); | ||
453 | temp |= (CMD_RUN); | ||
454 | xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n", | ||
455 | temp); | ||
456 | xhci_writel(xhci, temp, &xhci->op_regs->command); | ||
457 | /* Flush PCI posted writes */ | ||
458 | temp = xhci_readl(xhci, &xhci->op_regs->command); | ||
459 | xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp); | 498 | xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp); |
460 | if (doorbell) | 499 | if (doorbell) |
461 | (*doorbell)(xhci); | 500 | (*doorbell)(xhci); |
501 | if (xhci->quirks & XHCI_NEC_HOST) | ||
502 | xhci_ring_cmd_db(xhci); | ||
462 | 503 | ||
463 | xhci_dbg(xhci, "Finished xhci_run\n"); | 504 | xhci_dbg(xhci, "Finished xhci_run\n"); |
464 | return 0; | 505 | return 0; |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index dada2fb59261..8b4b7d39f79c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -925,6 +925,7 @@ union xhci_trb { | |||
925 | /* TRB bit mask */ | 925 | /* TRB bit mask */ |
926 | #define TRB_TYPE_BITMASK (0xfc00) | 926 | #define TRB_TYPE_BITMASK (0xfc00) |
927 | #define TRB_TYPE(p) ((p) << 10) | 927 | #define TRB_TYPE(p) ((p) << 10) |
928 | #define TRB_FIELD_TO_TYPE(p) (((p) & TRB_TYPE_BITMASK) >> 10) | ||
928 | /* TRB type IDs */ | 929 | /* TRB type IDs */ |
929 | /* bulk, interrupt, isoc scatter/gather, and control data stage */ | 930 | /* bulk, interrupt, isoc scatter/gather, and control data stage */ |
930 | #define TRB_NORMAL 1 | 931 | #define TRB_NORMAL 1 |
@@ -992,6 +993,14 @@ union xhci_trb { | |||
992 | #define TRB_MFINDEX_WRAP 39 | 993 | #define TRB_MFINDEX_WRAP 39 |
993 | /* TRB IDs 40-47 reserved, 48-63 is vendor-defined */ | 994 | /* TRB IDs 40-47 reserved, 48-63 is vendor-defined */ |
994 | 995 | ||
996 | /* Nec vendor-specific command completion event. */ | ||
997 | #define TRB_NEC_CMD_COMP 48 | ||
998 | /* Get NEC firmware revision. */ | ||
999 | #define TRB_NEC_GET_FW 49 | ||
1000 | |||
1001 | #define NEC_FW_MINOR(p) (((p) >> 0) & 0xff) | ||
1002 | #define NEC_FW_MAJOR(p) (((p) >> 8) & 0xff) | ||
1003 | |||
995 | /* | 1004 | /* |
996 | * TRBS_PER_SEGMENT must be a multiple of 4, | 1005 | * TRBS_PER_SEGMENT must be a multiple of 4, |
997 | * since the command ring is 64-byte aligned. | 1006 | * since the command ring is 64-byte aligned. |
@@ -1172,6 +1181,7 @@ struct xhci_hcd { | |||
1172 | unsigned int quirks; | 1181 | unsigned int quirks; |
1173 | #define XHCI_LINK_TRB_QUIRK (1 << 0) | 1182 | #define XHCI_LINK_TRB_QUIRK (1 << 0) |
1174 | #define XHCI_RESET_EP_QUIRK (1 << 1) | 1183 | #define XHCI_RESET_EP_QUIRK (1 << 1) |
1184 | #define XHCI_NEC_HOST (1 << 2) | ||
1175 | }; | 1185 | }; |
1176 | 1186 | ||
1177 | /* For testing purposes */ | 1187 | /* For testing purposes */ |
@@ -1379,6 +1389,8 @@ void xhci_set_hc_event_deq(struct xhci_hcd *xhci); | |||
1379 | int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); | 1389 | int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); |
1380 | int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | 1390 | int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
1381 | u32 slot_id); | 1391 | u32 slot_id); |
1392 | int xhci_queue_vendor_command(struct xhci_hcd *xhci, | ||
1393 | u32 field1, u32 field2, u32 field3, u32 field4); | ||
1382 | int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, | 1394 | int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, |
1383 | unsigned int ep_index); | 1395 | unsigned int ep_index); |
1384 | int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, | 1396 | int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, |