This patch makes musb can work on blackfin bf60x series 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 <lliu...@gmail.com>
---
 drivers/usb/musb/Kconfig     |    2 +-
 drivers/usb/musb/blackfin.c  |   52 ++++++++++++++++++++++++++++--------------
 drivers/usb/musb/musb_core.c |    6 +++--
 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 +-
 10 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f..4d416bc 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..74dd8cf 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,12 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
                musb->a_wait_bcon = TIMER_DELAY;
        }
 
+#ifdef CONFIG_BF60x
+       if (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb)) {
+               musb->xceiv->state = OTG_STATE_B_IDLE;
+               bfin_write_USB_VBUS_CTL(0x00);
+       }
+#endif
        spin_unlock_irqrestore(&musb->lock, flags);
 
        return retval;
@@ -349,6 +357,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,11 +392,20 @@ 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)
 {
-
+#ifndef CONFIG_BF60x
        /*
         * 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
@@ -401,7 +419,7 @@ static int bfin_musb_init(struct musb *musb)
                return -ENODEV;
        }
        gpio_direction_output(musb->config->gpio_vrsel, 0);
-
+#endif
        usb_nop_xceiv_register();
        musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
        if (IS_ERR_OR_NULL(musb->xceiv)) {
@@ -414,10 +432,11 @@ static int bfin_musb_init(struct musb *musb)
        setup_timer(&musb_conn_timer, musb_conn_timer_handler,
                        (unsigned long) musb);
 
+#ifndef CONFIG_BF60x
        musb->xceiv->set_power = bfin_musb_set_power;
-
-       musb->isr = blackfin_interrupt;
        musb->double_buffer_not_ok = true;
+#endif
+       musb->isr = blackfin_interrupt;
 
        return 0;
 }
@@ -523,18 +542,12 @@ static int bfin_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 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);
-
+#ifdef CONFIG_BF60x
+       int aphy = 0;
+       aphy = bfin_read_USB_APHY_CNTRL();
+       bfin_write_USB_APHY_CNTRL(aphy | 0x1);
+       SSYNC();
+#endif
        return 0;
 }
 
@@ -542,7 +555,12 @@ static int bfin_resume(struct device *dev)
 {
        struct bfin_glue        *glue = dev_get_drvdata(dev);
        struct musb             *musb = glue_to_musb(glue);
-
+#ifdef CONFIG_BF60x
+       int aphy;
+       aphy = bfin_read_USB_APHY_CNTRL();
+       bfin_write_USB_APHY_CNTRL(aphy | 0x2);
+       SSYNC();
+#endif
        bfin_musb_reg_init(musb);
 
        return 0;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f1c6c54..4dd18a9 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -226,7 +226,7 @@ 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) 
|| CONFIG_BF60x)
 
 /*
  * Load an endpoint's FIFO
@@ -1039,7 +1039,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


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to