Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'musb-v2.6.37-rc2' of git://gitorious.org/usb/usb into work-linus

+114 -69
+54 -26
drivers/usb/musb/blackfin.c
··· 171 171 } 172 172 173 173 /* Start sampling ID pin, when plug is removed from MUSB */ 174 - if (is_otg_enabled(musb) && (musb->xceiv->state == OTG_STATE_B_IDLE 175 - || musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { 174 + if ((is_otg_enabled(musb) && (musb->xceiv->state == OTG_STATE_B_IDLE 175 + || musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) || 176 + (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { 176 177 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 177 178 musb->a_wait_bcon = TIMER_DELAY; 178 179 } ··· 324 323 return -EIO; 325 324 } 326 325 327 - int __init musb_platform_init(struct musb *musb, void *board_data) 326 + static void musb_platform_reg_init(struct musb *musb) 328 327 { 329 - 330 - /* 331 - * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE 332 - * and OTG HOST modes, while rev 1.1 and greater require PE7 to 333 - * be low for DEVICE mode and high for HOST mode. We set it high 334 - * here because we are in host mode 335 - */ 336 - 337 - if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { 338 - printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n", 339 - musb->config->gpio_vrsel); 340 - return -ENODEV; 341 - } 342 - gpio_direction_output(musb->config->gpio_vrsel, 0); 343 - 344 - usb_nop_xceiv_register(); 345 - musb->xceiv = otg_get_transceiver(); 346 - if (!musb->xceiv) { 347 - gpio_free(musb->config->gpio_vrsel); 348 - return -ENODEV; 349 - } 350 - 351 328 if (ANOMALY_05000346) { 352 329 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); 353 330 SSYNC(); ··· 337 358 } 338 359 339 360 /* Configure PLL oscillator register */ 340 - bfin_write_USB_PLLOSC_CTRL(0x30a8); 361 + bfin_write_USB_PLLOSC_CTRL(0x3080 | 362 + ((480/musb->config->clkin) << 1)); 341 363 SSYNC(); 342 364 343 365 bfin_write_USB_SRP_CLKDIV((get_sclk()/1000) / 32 - 1); ··· 360 380 EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | 361 381 EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); 362 382 SSYNC(); 383 + } 384 + 385 + int __init musb_platform_init(struct musb *musb, void *board_data) 386 + { 387 + 388 + /* 389 + * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE 390 + * and OTG HOST modes, while rev 1.1 and greater require PE7 to 391 + * be low for DEVICE mode and high for HOST mode. We set it high 392 + * here because we are in host mode 393 + */ 394 + 395 + if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { 396 + printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n", 397 + musb->config->gpio_vrsel); 398 + return -ENODEV; 399 + } 400 + gpio_direction_output(musb->config->gpio_vrsel, 0); 401 + 402 + usb_nop_xceiv_register(); 403 + musb->xceiv = otg_get_transceiver(); 404 + if (!musb->xceiv) { 405 + gpio_free(musb->config->gpio_vrsel); 406 + return -ENODEV; 407 + } 408 + 409 + musb_platform_reg_init(musb); 363 410 364 411 if (is_host_enabled(musb)) { 365 412 musb->board_set_vbus = bfin_set_vbus; ··· 400 393 401 394 return 0; 402 395 } 396 + 397 + #ifdef CONFIG_PM 398 + void musb_platform_save_context(struct musb *musb, 399 + struct musb_context_registers *musb_context) 400 + { 401 + if (is_host_active(musb)) 402 + /* 403 + * During hibernate gpio_vrsel will change from high to low 404 + * low which will generate wakeup event resume the system 405 + * immediately. Set it to 0 before hibernate to avoid this 406 + * wakeup event. 407 + */ 408 + gpio_set_value(musb->config->gpio_vrsel, 0); 409 + } 410 + 411 + void musb_platform_restore_context(struct musb *musb, 412 + struct musb_context_registers *musb_context) 413 + { 414 + musb_platform_reg_init(musb); 415 + } 416 + #endif 403 417 404 418 int musb_platform_exit(struct musb *musb) 405 419 {
+19 -22
drivers/usb/musb/musb_core.c
··· 552 552 if (int_usb & MUSB_INTR_SESSREQ) { 553 553 void __iomem *mbase = musb->mregs; 554 554 555 - if (devctl & MUSB_DEVCTL_BDEVICE) { 555 + if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS 556 + && (devctl & MUSB_DEVCTL_BDEVICE)) { 556 557 DBG(3, "SessReq while on B state\n"); 557 558 return IRQ_HANDLED; 558 559 } ··· 1052 1051 if (musb->clock) 1053 1052 clk_put(musb->clock); 1054 1053 spin_unlock_irqrestore(&musb->lock, flags); 1054 + 1055 + if (!is_otg_enabled(musb) && is_host_enabled(musb)) 1056 + usb_remove_hcd(musb_to_hcd(musb)); 1057 + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 1058 + musb_platform_exit(musb); 1055 1059 1056 1060 /* FIXME power down */ 1057 1061 } ··· 2250 2244 */ 2251 2245 musb_exit_debugfs(musb); 2252 2246 musb_shutdown(pdev); 2253 - #ifdef CONFIG_USB_MUSB_HDRC_HCD 2254 - if (musb->board_mode == MUSB_HOST) 2255 - usb_remove_hcd(musb_to_hcd(musb)); 2256 - #endif 2257 - musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2258 - musb_platform_exit(musb); 2259 - musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2260 2247 2261 2248 musb_free(musb); 2262 2249 iounmap(ctrl_base); ··· 2410 2411 unsigned long flags; 2411 2412 struct musb *musb = dev_to_musb(&pdev->dev); 2412 2413 2413 - if (!musb->clock) 2414 - return 0; 2415 - 2416 2414 spin_lock_irqsave(&musb->lock, flags); 2417 2415 2418 2416 if (is_peripheral_active(musb)) { ··· 2424 2428 2425 2429 musb_save_context(musb); 2426 2430 2427 - if (musb->set_clock) 2428 - musb->set_clock(musb->clock, 0); 2429 - else 2430 - clk_disable(musb->clock); 2431 + if (musb->clock) { 2432 + if (musb->set_clock) 2433 + musb->set_clock(musb->clock, 0); 2434 + else 2435 + clk_disable(musb->clock); 2436 + } 2431 2437 spin_unlock_irqrestore(&musb->lock, flags); 2432 2438 return 0; 2433 2439 } ··· 2439 2441 struct platform_device *pdev = to_platform_device(dev); 2440 2442 struct musb *musb = dev_to_musb(&pdev->dev); 2441 2443 2442 - if (!musb->clock) 2443 - return 0; 2444 - 2445 - if (musb->set_clock) 2446 - musb->set_clock(musb->clock, 1); 2447 - else 2448 - clk_enable(musb->clock); 2444 + if (musb->clock) { 2445 + if (musb->set_clock) 2446 + musb->set_clock(musb->clock, 1); 2447 + else 2448 + clk_enable(musb->clock); 2449 + } 2449 2450 2450 2451 musb_restore_context(musb); 2451 2452
+1 -1
drivers/usb/musb/musb_core.h
··· 487 487 }; 488 488 489 489 #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 490 - defined(CONFIG_ARCH_OMAP4) 490 + defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) 491 491 extern void musb_platform_save_context(struct musb *musb, 492 492 struct musb_context_registers *musb_context); 493 493 extern void musb_platform_restore_context(struct musb *musb,
+22 -19
drivers/usb/musb/musb_gadget.c
··· 644 644 */ 645 645 646 646 csr |= MUSB_RXCSR_DMAENAB; 647 - if (!musb_ep->hb_mult && 648 - musb_ep->hw_ep->rx_double_buffered) 649 - csr |= MUSB_RXCSR_AUTOCLEAR; 650 647 #ifdef USE_MODE1 648 + csr |= MUSB_RXCSR_AUTOCLEAR; 651 649 /* csr |= MUSB_RXCSR_DMAMODE; */ 652 650 653 651 /* this special sequence (enabling and then ··· 654 656 */ 655 657 musb_writew(epio, MUSB_RXCSR, 656 658 csr | MUSB_RXCSR_DMAMODE); 659 + #else 660 + if (!musb_ep->hb_mult && 661 + musb_ep->hw_ep->rx_double_buffered) 662 + csr |= MUSB_RXCSR_AUTOCLEAR; 657 663 #endif 658 664 musb_writew(epio, MUSB_RXCSR, csr); 659 665 ··· 809 807 810 808 #if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA) 811 809 /* Autoclear doesn't clear RxPktRdy for short packets */ 812 - if ((dma->desired_mode == 0) 810 + if ((dma->desired_mode == 0 && !hw_ep->rx_double_buffered) 813 811 || (dma->actual_len 814 812 & (musb_ep->packet_sz - 1))) { 815 813 /* ack the read! */ ··· 820 818 /* incomplete, and not short? wait for next IN packet */ 821 819 if ((request->actual < request->length) 822 820 && (musb_ep->dma->actual_len 823 - == musb_ep->packet_sz)) 821 + == musb_ep->packet_sz)) { 822 + /* In double buffer case, continue to unload fifo if 823 + * there is Rx packet in FIFO. 824 + **/ 825 + csr = musb_readw(epio, MUSB_RXCSR); 826 + if ((csr & MUSB_RXCSR_RXPKTRDY) && 827 + hw_ep->rx_double_buffered) 828 + goto exit; 824 829 return; 830 + } 825 831 #endif 826 832 musb_g_giveback(musb_ep, request, 0); 827 833 ··· 837 827 if (!request) 838 828 return; 839 829 } 840 - 830 + exit: 841 831 /* Analyze request */ 842 832 rxstate(musb, to_musb_request(request)); 843 833 } ··· 926 916 * likewise high bandwidth periodic tx 927 917 */ 928 918 /* Set TXMAXP with the FIFO size of the endpoint 929 - * to disable double buffering mode. Currently, It seems that double 930 - * buffering has problem if musb RTL revision number < 2.0. 919 + * to disable double buffering mode. 931 920 */ 932 - if (musb->hwvers < MUSB_HWVERS_2000) 933 - musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); 934 - else 935 - musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11)); 921 + musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11)); 936 922 937 923 csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG; 938 924 if (musb_readw(regs, MUSB_TXCSR) ··· 964 958 /* Set RXMAXP with the FIFO size of the endpoint 965 959 * to disable double buffering mode. 966 960 */ 967 - if (musb->hwvers < MUSB_HWVERS_2000) 968 - musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx); 969 - else 970 - musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11)); 961 + musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11)); 971 962 972 963 /* force shared fifo to OUT-only mode */ 973 964 if (hw_ep->is_shared_fifo) { ··· 1169 1166 : DMA_FROM_DEVICE); 1170 1167 request->mapped = 0; 1171 1168 } 1172 - } else if (!req->buf) { 1173 - return -ENODATA; 1174 1169 } else 1175 1170 request->mapped = 0; 1176 1171 ··· 1696 1695 musb_platform_try_idle(musb, 0); 1697 1696 1698 1697 status = device_register(&musb->g.dev); 1699 - if (status != 0) 1698 + if (status != 0) { 1699 + put_device(&musb->g.dev); 1700 1700 the_gadget = NULL; 1701 + } 1701 1702 return status; 1702 1703 } 1703 1704
+2 -1
drivers/usb/musb/musb_regs.h
··· 633 633 return 0; 634 634 } 635 635 636 - static inline void musb_read_txhubport(void __iomem *mbase, u8 epnum) 636 + static inline u8 musb_read_txhubport(void __iomem *mbase, u8 epnum) 637 637 { 638 + return 0; 638 639 } 639 640 640 641 #endif /* CONFIG_BLACKFIN */
+14
drivers/usb/musb/musbhsdma.c
··· 158 158 dma_addr_t dma_addr, u32 len) 159 159 { 160 160 struct musb_dma_channel *musb_channel = channel->private_data; 161 + struct musb_dma_controller *controller = musb_channel->controller; 162 + struct musb *musb = controller->private_data; 161 163 162 164 DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", 163 165 musb_channel->epnum, ··· 168 166 169 167 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || 170 168 channel->status == MUSB_DMA_STATUS_BUSY); 169 + 170 + /* 171 + * The DMA engine in RTL1.8 and above cannot handle 172 + * DMA addresses that are not aligned to a 4 byte boundary. 173 + * It ends up masking the last two bits of the address 174 + * programmed in DMA_ADDR. 175 + * 176 + * Fail such DMA transfers, so that the backup PIO mode 177 + * can carry out the transfer 178 + */ 179 + if ((musb->hwvers >= MUSB_HWVERS_1800) && (dma_addr % 4)) 180 + return false; 171 181 172 182 channel->actual_len = 0; 173 183 musb_channel->start_addr = dma_addr;
+2
include/linux/usb/musb.h
··· 89 89 /* A GPIO controlling VRSEL in Blackfin */ 90 90 unsigned int gpio_vrsel; 91 91 unsigned int gpio_vrsel_active; 92 + /* musb CLKIN in Blackfin in MHZ */ 93 + unsigned char clkin; 92 94 #endif 93 95 94 96 };