ping.. On Mon, Feb 4, 2013 at 2:57 PM, Bob Liu <lliubbo@xxxxxxxxx> wrote: > This patch makes musb can work on blackfin bf60x series soc platform. > Bf60x uses MHDRC RTL version 2.0 musb ip core which don't need a lot of > blackfin specific anomalies anymore. > > Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx> > --- > drivers/usb/musb/Kconfig | 2 +- > drivers/usb/musb/blackfin.c | 70 ++++++++++++++++++++++++++---------------- > drivers/usb/musb/musb_core.c | 7 +++-- > drivers/usb/musb/musb_core.h | 2 +- > drivers/usb/musb/musb_dma.h | 2 +- > drivers/usb/musb/musb_io.h | 2 +- > drivers/usb/musb/musb_regs.h | 2 +- > drivers/usb/musb/musbhsdma.c | 2 +- > drivers/usb/musb/musbhsdma.h | 2 +- > 9 files changed, 56 insertions(+), 35 deletions(-) > > diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig > index 23a0b7f..d8633c0 100644 > --- a/drivers/usb/musb/Kconfig > +++ b/drivers/usb/musb/Kconfig > @@ -60,7 +60,7 @@ config USB_MUSB_DSPS > > config USB_MUSB_BLACKFIN > tristate "Blackfin" > - depends on (BF54x && !BF544) || (BF52x && ! BF522 && !BF523) > + depends on (BF54x && !BF544) || (BF52x && ! BF522 && !BF523) || BF60x > > config USB_MUSB_UX500 > tristate "U8500 and U5500" > diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c > index 14dab9f..ffbb4f5 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,9 @@ 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)) > + bfin_write_USB_VBUS_CTL(0x00); > spin_unlock_irqrestore(&musb->lock, flags); > > return retval; > @@ -349,6 +354,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 +389,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 +432,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; > } > @@ -525,16 +540,13 @@ static int bfin_suspend(struct device *dev) > { > struct bfin_glue *glue = dev_get_drvdata(dev); > struct musb *musb = glue_to_musb(glue); > + int aphy; > > - 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) { > + aphy = bfin_read_USB_APHY_CNTRL(); > + bfin_write_USB_APHY_CNTRL(aphy | 0x1); > + SSYNC(); > + } > return 0; > } > > @@ -542,7 +554,13 @@ static int bfin_resume(struct device *dev) > { > struct bfin_glue *glue = dev_get_drvdata(dev); > struct musb *musb = glue_to_musb(glue); > + int aphy; > > + if (musb->hwvers >= MUSB_HWVERS_2000) { > + aphy = bfin_read_USB_APHY_CNTRL(); > + bfin_write_USB_APHY_CNTRL(aphy | 0x2); > + SSYNC(); > + } > bfin_musb_reg_init(musb); > > return 0; > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index fd34867..7b49d57 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -226,7 +226,8 @@ static struct usb_phy_io_ops musb_ulpi_access = { > > /*-------------------------------------------------------------------------*/ > > -#if !defined(CONFIG_USB_MUSB_TUSB6010) && !defined(CONFIG_USB_MUSB_BLACKFIN) > +#if !defined(CONFIG_USB_MUSB_TUSB6010) \ > + && (!defined(CONFIG_USB_MUSB_BLACKFIN) || defined(CONFIG_BF60x)) > > /* > * Load an endpoint's FIFO > @@ -1039,7 +1040,9 @@ static void musb_shutdown(struct platform_device *pdev) > || defined(CONFIG_USB_MUSB_AM35X) \ > || defined(CONFIG_USB_MUSB_AM35X_MODULE) \ > || defined(CONFIG_USB_MUSB_DSPS) \ > - || defined(CONFIG_USB_MUSB_DSPS_MODULE) > + || defined(CONFIG_USB_MUSB_DSPS_MODULE) \ > + || defined(CONFIG_USB_MUSB_BLACKFIN) > + > static ushort fifo_mode = 4; > #elif defined(CONFIG_USB_MUSB_UX500) \ > || defined(CONFIG_USB_MUSB_UX500_MODULE) > diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h > index 7fb4819..a46ec5d 100644 > --- a/drivers/usb/musb/musb_core.h > +++ b/drivers/usb/musb/musb_core.h > @@ -449,7 +449,7 @@ static inline struct musb *gadget_to_musb(struct usb_gadget *g) > return container_of(g, struct musb, g); > } > > -#ifdef CONFIG_BLACKFIN > +#if defined(CONFIG_BLACKFIN) && !defined(CONFIG_BF60x) > static inline int musb_read_fifosize(struct musb *musb, > struct musb_hw_ep *hw_ep, u8 epnum) > { > diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h > index 1b6b827..6bb84df 100644 > --- a/drivers/usb/musb/musb_dma.h > +++ b/drivers/usb/musb/musb_dma.h > @@ -84,7 +84,7 @@ struct musb_hw_ep; > * Only allow DMA mode 1 to be used when the USB will actually generate the > * interrupts we expect. > */ > -#ifdef CONFIG_BLACKFIN > +#if defined(CONFIG_BLACKFIN) && !defined(CONFIG_BF60x) > # undef USE_MODE1 > # if !ANOMALY_05000456 > # define USE_MODE1 > diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h > index eebeed7..d28b789 100644 > --- a/drivers/usb/musb/musb_io.h > +++ b/drivers/usb/musb/musb_io.h > @@ -37,7 +37,7 @@ > > #include <linux/io.h> > > -#ifndef CONFIG_BLACKFIN > +#if !defined(CONFIG_BLACKFIN) || defined(CONFIG_BF60x) > > /* NOTE: these offsets are all in bytes */ > > diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h > index 03f2655..bffa4a1 100644 > --- a/drivers/usb/musb/musb_regs.h > +++ b/drivers/usb/musb/musb_regs.h > @@ -214,7 +214,7 @@ > #define MUSB_HUBADDR_MULTI_TT 0x80 > > > -#ifndef CONFIG_BLACKFIN > +#if !defined(CONFIG_BLACKFIN) || defined(CONFIG_BF60x) > > /* > * Common USB registers > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c > index 3d1fd52..d53715f 100644 > --- a/drivers/usb/musb/musbhsdma.c > +++ b/drivers/usb/musb/musbhsdma.c > @@ -269,7 +269,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data) > > int_hsdma = musb_readb(mbase, MUSB_HSDMA_INTR); > > -#ifdef CONFIG_BLACKFIN > +#if defined(CONFIG_BLACKFIN) && !defined(CONFIG_BF60x) > /* Clear DMA interrupt flags */ > musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma); > #endif > diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h > index f7b13fd2..2a8e082 100644 > --- a/drivers/usb/musb/musbhsdma.h > +++ b/drivers/usb/musb/musbhsdma.h > @@ -31,7 +31,7 @@ > * > */ > > -#ifndef CONFIG_BLACKFIN > +#if !defined(CONFIG_BLACKFIN) || defined(CONFIG_BF60x) > > #define MUSB_HSDMA_BASE 0x200 > #define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) > -- > 1.7.9.5 > > -- Regards, --Bob -- 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