[PATCH] drivers: usb: musb: add bf60x support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bf60x uses new musb ip which is a little different from old blackfin boards.
Now it's the same as most of other arch without a lot of blackfin specific
anomaly.

Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx>
---
 drivers/usb/musb/Kconfig     |    3 ++-
 drivers/usb/musb/blackfin.c  |   31 +++++++++++++++++++++++++------
 drivers/usb/musb/musb_core.c |    5 +++--
 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, 36 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index f70cab3..0fb1466 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -7,6 +7,7 @@
 config USB_MUSB_HDRC
 	tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
 	depends on USB && USB_GADGET
+	depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523) || (BF60x))
 	select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
 	select TWL4030_USB if MACH_OMAP_3430SDP
 	select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
@@ -56,7 +57,7 @@ config USB_MUSB_AM35X
 
 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 a087ed6..0f31690 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -34,6 +34,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;
@@ -162,6 +163,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)
 {
@@ -174,7 +176,6 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
 	musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
 	musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
 	musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
-
 	if (musb->int_usb || musb->int_tx || musb->int_rx) {
 		musb_writeb(musb->mregs, MUSB_INTRUSB, musb->int_usb);
 		musb_writew(musb->mregs, MUSB_INTRTX, musb->int_tx);
@@ -216,10 +217,14 @@ static void musb_conn_timer_handler(unsigned long _musb)
 		val = musb_readw(musb->mregs, MUSB_DEVCTL);
 
 		if (!(val & MUSB_DEVCTL_BDEVICE)) {
+#ifndef CONFIG_BF60x
 			gpio_set_value(musb->config->gpio_vrsel, 1);
+#endif
 			musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
 		} else {
+#ifndef CONFIG_BF60x
 			gpio_set_value(musb->config->gpio_vrsel, 0);
+#endif
 			/* Ignore VBUSERROR and SUSPEND IRQ */
 			val = musb_readb(musb->mregs, MUSB_INTRUSBE);
 			val &= ~MUSB_INTR_VBUSERROR;
@@ -247,11 +252,14 @@ static void musb_conn_timer_handler(unsigned long _musb)
 		val = musb_readw(musb->mregs, MUSB_DEVCTL);
 
 		if (!(val & MUSB_DEVCTL_BDEVICE)) {
+#ifndef CONFIG_BF60x
 			gpio_set_value(musb->config->gpio_vrsel, 1);
+#endif
 			musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
 		} else {
+#ifndef CONFIG_BF60x
 			gpio_set_value(musb->config->gpio_vrsel, 0);
-
+#endif
 			/* Ignore VBUSERROR and SUSPEND IRQ */
 			val = musb_readb(musb->mregs, MUSB_INTRUSBE);
 			val &= ~MUSB_INTR_VBUSERROR;
@@ -361,6 +369,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();
@@ -395,11 +404,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
@@ -413,7 +431,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_transceiver();
 	if (!musb->xceiv) {
@@ -422,16 +440,17 @@ static int bfin_musb_init(struct musb *musb)
 	}
 
 	bfin_musb_reg_init(musb);
-
 	if (is_host_enabled(musb)) {
 		setup_timer(&musb_conn_timer,
 			musb_conn_timer_handler, (unsigned long) musb);
 	}
+#ifndef CONFIG_BF60x
 	if (is_peripheral_enabled(musb))
 		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;
 }
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 66aaccf..f1cdee4 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -224,7 +224,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
@@ -1034,7 +1034,8 @@ static void musb_shutdown(struct platform_device *pdev)
 	|| defined(CONFIG_USB_MUSB_OMAP2PLUS)		\
 	|| defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE)	\
 	|| defined(CONFIG_USB_MUSB_AM35X)		\
-	|| defined(CONFIG_USB_MUSB_AM35X_MODULE)
+	|| defined(CONFIG_USB_MUSB_AM35X_MODULE)	\
+	|| defined(CONFIG_USB_MUSB_BLACKFIN)
 static ushort __devinitdata 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 f4a40f0..e93476e 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -463,7 +463,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 3a97c4e..8357407 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 1d5eda2..d12874b 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -57,7 +57,7 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len)
 
 #endif
 
-#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 57a6085..25379bc 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 320fd4a..f971d07 100644
--- a/drivers/usb/musb/musbhsdma.h
+++ b/drivers/usb/musb/musbhsdma.h
@@ -35,7 +35,7 @@
 #include "omap2430.h"
 #endif
 
-#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.0.4


--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux