This patch change blackfin.c to support musb for blackfin bf60x series soc platform. Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx> --- drivers/usb/musb/blackfin.c | 72 +++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 14dab9f..933dd1d 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -36,6 +36,7 @@ struct bfin_glue { /* * Load an endpoint's FIFO */ +#ifndef CONFIG_BF60x void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) { struct musb *musb = hw_ep->musb; @@ -164,6 +165,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) dump_fifo_data(dst, len); } +#endif static irqreturn_t blackfin_interrupt(int irq, void *__hci) { @@ -192,6 +194,11 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci) musb->a_wait_bcon = TIMER_DELAY; } + if (musb->hwvers >= MUSB_HWVERS_2000) + if (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb)) { + musb->xceiv->state = OTG_STATE_B_IDLE; + bfin_write_USB_VBUS_CTL(0x00); + } spin_unlock_irqrestore(&musb->lock, flags); return retval; @@ -349,6 +356,7 @@ static int bfin_musb_adjust_channel_params(struct dma_channel *channel, static void bfin_musb_reg_init(struct musb *musb) { +#ifndef CONFIG_BF60x if (ANOMALY_05000346) { bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); SSYNC(); @@ -383,29 +391,41 @@ static void bfin_musb_reg_init(struct musb *musb) EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); SSYNC(); +#else + bfin_write_USB_PLLOSC_CTRL((480/musb->config->clkin) << 1); + SSYNC(); + + bfin_write_USB_VBUS_CTL(0x00); + bfin_write_USB_APHY_CNTRL(0x80); + SSYNC(); + musb->config->ram_bits = musb_readb(musb->mregs, MUSB_RAMINFO) & 0xf; +#endif } static int bfin_musb_init(struct musb *musb) { + if (musb->hwvers < MUSB_HWVERS_2000) { + /* + * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE + * and OTG HOST modes, while rev 1.1 and greater require PE7 to + * be low for DEVICE mode and high for HOST mode. We set it high + * here because we are in host mode + */ - /* - * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE - * and OTG HOST modes, while rev 1.1 and greater require PE7 to - * be low for DEVICE mode and high for HOST mode. We set it high - * here because we are in host mode - */ - - if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { - printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n", - musb->config->gpio_vrsel); - return -ENODEV; + if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { + printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n", + musb->config->gpio_vrsel); + return -ENODEV; + } + gpio_direction_output(musb->config->gpio_vrsel, 0); + musb->xceiv->set_power = bfin_musb_set_power; + musb->double_buffer_not_ok = true; } - gpio_direction_output(musb->config->gpio_vrsel, 0); - usb_nop_xceiv_register(); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb->xceiv)) { - gpio_free(musb->config->gpio_vrsel); + if (musb->hwvers < MUSB_HWVERS_2000) + gpio_free(musb->config->gpio_vrsel); return -ENODEV; } @@ -414,10 +434,7 @@ static int bfin_musb_init(struct musb *musb) setup_timer(&musb_conn_timer, musb_conn_timer_handler, (unsigned long) musb); - musb->xceiv->set_power = bfin_musb_set_power; - musb->isr = blackfin_interrupt; - musb->double_buffer_not_ok = true; return 0; } @@ -526,15 +543,12 @@ static int bfin_suspend(struct device *dev) struct bfin_glue *glue = dev_get_drvdata(dev); struct musb *musb = glue_to_musb(glue); - if (is_host_active(musb)) - /* - * During hibernate gpio_vrsel will change from high to low - * low which will generate wakeup event resume the system - * immediately. Set it to 0 before hibernate to avoid this - * wakeup event. - */ - gpio_set_value(musb->config->gpio_vrsel, 0); - + if (musb->hwvers >= MUSB_HWVERS_2000) { + int aphy = 0; + aphy = bfin_read_USB_APHY_CNTRL(); + bfin_write_USB_APHY_CNTRL(aphy | 0x1); + SSYNC(); + } return 0; } @@ -543,6 +557,12 @@ static int bfin_resume(struct device *dev) struct bfin_glue *glue = dev_get_drvdata(dev); struct musb *musb = glue_to_musb(glue); + if (musb->hwvers >= MUSB_HWVERS_2000) { + int aphy; + aphy = bfin_read_USB_APHY_CNTRL(); + bfin_write_USB_APHY_CNTRL(aphy | 0x2); + SSYNC(); + } bfin_musb_reg_init(musb); return 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html