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

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

 



Hi,

On Wed, May 30, 2012 at 02:11:17PM +0800, Bob Liu wrote:
> Bf60x uses new musb ip which is a little different from before.

which RTL revision ?

> Now it's the same as most of other arch without a lot of blackfin specific
> anomaly.

s/anomaly/anomalies

> Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx>
> ---
>  drivers/usb/musb/Kconfig     |    3 ++-
>  drivers/usb/musb/blackfin.c  |   35 +++++++++++++++++++++++------------
>  drivers/usb/musb/blackfin.h  |    6 ++++++
>  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 +-
>  10 files changed, 40 insertions(+), 21 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..deda82a 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,10 @@ static void musb_conn_timer_handler(unsigned long _musb)
>  		val = musb_readw(musb->mregs, MUSB_DEVCTL);
>  
>  		if (!(val & MUSB_DEVCTL_BDEVICE)) {
> -			gpio_set_value(musb->config->gpio_vrsel, 1);
> +			vrsel_set_value(1);
>  			musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
>  		} else {
> -			gpio_set_value(musb->config->gpio_vrsel, 0);
> +			vrsel_set_value(0);
>  			/* Ignore VBUSERROR and SUSPEND IRQ */
>  			val = musb_readb(musb->mregs, MUSB_INTRUSBE);
>  			val &= ~MUSB_INTR_VBUSERROR;
> @@ -247,11 +248,10 @@ static void musb_conn_timer_handler(unsigned long _musb)
>  		val = musb_readw(musb->mregs, MUSB_DEVCTL);
>  
>  		if (!(val & MUSB_DEVCTL_BDEVICE)) {
> -			gpio_set_value(musb->config->gpio_vrsel, 1);
> +			vrsel_set_value(1);
>  			musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
>  		} else {
> -			gpio_set_value(musb->config->gpio_vrsel, 0);
> -
> +			vrsel_set_value(0);
>  			/* Ignore VBUSERROR and SUSPEND IRQ */
>  			val = musb_readb(musb->mregs, MUSB_INTRUSBE);
>  			val &= ~MUSB_INTR_VBUSERROR;
> @@ -309,7 +309,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)
>  	int value = musb->config->gpio_vrsel_active;
>  	if (!is_on)
>  		value = !value;
> -	gpio_set_value(musb->config->gpio_vrsel, value);
> +	vrsel_set_value(value);
>  
>  	dev_dbg(musb->controller, "VBUS %s, devctl %02x "
>  		/* otg %3x conf %08x prcm %08x */ "\n",
> @@ -361,6 +361,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 +396,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 +423,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 +432,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;
>  }
> @@ -549,7 +560,7 @@ static int bfin_suspend(struct device *dev)
>  		 * immediately.  Set it to 0 before hibernate to avoid this
>  		 * wakeup event.
>  		 */
> -		gpio_set_value(musb->config->gpio_vrsel, 0);
> +		vrsel_set_value(0);
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
> index c84dae5..eeba330 100644
> --- a/drivers/usb/musb/blackfin.h
> +++ b/drivers/usb/musb/blackfin.h
> @@ -84,4 +84,10 @@ static void dump_fifo_data(u8 *buf, u16 len)
>  
>  static struct timer_list musb_conn_timer;
>  
> +#ifndef CONFIG_BF60x
> +#define vrsel_set_value(val) gpio_set_value(musb->config->gpio_vrsel, val)
> +#else
> +#define vrsel_set_value(val) do { } while (0)
> +#endif

this obfuscation is unnacceptable and it won't even work if you want to
have support for both blackfins on the same kernel.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux