diff options
Diffstat (limited to 'drivers/usb/musb/musb_gadget.c')
| -rw-r--r-- | drivers/usb/musb/musb_gadget.c | 156 | 
1 files changed, 16 insertions, 140 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 83eddedcd9b..ba7092349fa 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -46,48 +46,6 @@  #include "musb_core.h" -/* MUSB PERIPHERAL status 3-mar-2006: - * - * - EP0 seems solid.  It passes both USBCV and usbtest control cases. - *   Minor glitches: - * - *     + remote wakeup to Linux hosts work, but saw USBCV failures; - *       in one test run (operator error?) - *     + endpoint halt tests -- in both usbtest and usbcv -- seem - *       to break when dma is enabled ... is something wrongly - *       clearing SENDSTALL? - * - * - Mass storage behaved ok when last tested.  Network traffic patterns - *   (with lots of short transfers etc) need retesting; they turn up the - *   worst cases of the DMA, since short packets are typical but are not - *   required. - * - * - TX/IN - *     + both pio and dma behave in with network and g_zero tests - *     + no cppi throughput issues other than no-hw-queueing - *     + failed with FLAT_REG (DaVinci) - *     + seems to behave with double buffering, PIO -and- CPPI - *     + with gadgetfs + AIO, requests got lost? - * - * - RX/OUT - *     + both pio and dma behave in with network and g_zero tests - *     + dma is slow in typical case (short_not_ok is clear) - *     + double buffering ok with PIO - *     + double buffering *FAILS* with CPPI, wrong data bytes sometimes - *     + request lossage observed with gadgetfs - * - * - ISO not tested ... might work, but only weakly isochronous - * - * - Gadget driver disabling of softconnect during bind() is ignored; so - *   drivers can't hold off host requests until userspace is ready. - *   (Workaround:  they can turn it off later.) - * - * - PORTABILITY (assumes PIO works): - *     + DaVinci, basically works with cppi dma - *     + OMAP 2430, ditto with mentor dma - *     + TUSB 6010, platform-specific dma in the works - */ -  /* ----------------------------------------------------------------------- */  #define is_buffer_mapped(req) (is_dma_capable() && \ @@ -280,41 +238,6 @@ static inline int max_ep_writesize(struct musb *musb, struct musb_ep *ep)  		return ep->packet_sz;  } - -#ifdef CONFIG_USB_INVENTRA_DMA - -/* Peripheral tx (IN) using Mentor DMA works as follows: -	Only mode 0 is used for transfers <= wPktSize, -	mode 1 is used for larger transfers, - -	One of the following happens: -	- Host sends IN token which causes an endpoint interrupt -		-> TxAvail -			-> if DMA is currently busy, exit. -			-> if queue is non-empty, txstate(). - -	- Request is queued by the gadget driver. -		-> if queue was previously empty, txstate() - -	txstate() -		-> start -		  /\	-> setup DMA -		  |     (data is transferred to the FIFO, then sent out when -		  |	IN token(s) are recd from Host. -		  |		-> DMA interrupt on completion -		  |		   calls TxAvail. -		  |		      -> stop DMA, ~DMAENAB, -		  |		      -> set TxPktRdy for last short pkt or zlp -		  |		      -> Complete Request -		  |		      -> Continue next request (call txstate) -		  |___________________________________| - - * Non-Mentor DMA engines can of course work differently, such as by - * upleveling from irq-per-packet to irq-per-buffer. - */ - -#endif -  /*   * An endpoint is transmitting data. This can be called either from   * the IRQ routine or from ep.queue() to kickstart a request on an @@ -621,37 +544,6 @@ void musb_g_tx(struct musb *musb, u8 epnum)  /* ------------------------------------------------------------ */ -#ifdef CONFIG_USB_INVENTRA_DMA - -/* Peripheral rx (OUT) using Mentor DMA works as follows: -	- Only mode 0 is used. - -	- Request is queued by the gadget class driver. -		-> if queue was previously empty, rxstate() - -	- Host sends OUT token which causes an endpoint interrupt -	  /\      -> RxReady -	  |	      -> if request queued, call rxstate -	  |		/\	-> setup DMA -	  |		|	     -> DMA interrupt on completion -	  |		|		-> RxReady -	  |		|		      -> stop DMA -	  |		|		      -> ack the read -	  |		|		      -> if data recd = max expected -	  |		|				by the request, or host -	  |		|				sent a short packet, -	  |		|				complete the request, -	  |		|				and start the next one. -	  |		|_____________________________________| -	  |					 else just wait for the host -	  |					    to send the next OUT token. -	  |__________________________________________________| - - * Non-Mentor DMA engines can of course work differently. - */ - -#endif -  /*   * Context: controller locked, IRQs blocked, endpoint selected   */ @@ -740,7 +632,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)  				struct dma_controller	*c;  				struct dma_channel	*channel;  				int			use_dma = 0; -				int transfer_size; +				unsigned int transfer_size;  				c = musb->dma_controller;  				channel = musb_ep->dma; @@ -782,10 +674,11 @@ static void rxstate(struct musb *musb, struct musb_request *req)  						csr | MUSB_RXCSR_DMAMODE);  					musb_writew(epio, MUSB_RXCSR, csr); -					transfer_size = min(request->length - request->actual, +					transfer_size = min_t(unsigned int, +							request->length - +							request->actual,  							channel->max_len);  					musb_ep->dma->desired_mode = 1; -  				} else {  					if (!musb_ep->hb_mult &&  						musb_ep->hw_ep->rx_double_buffered) @@ -815,7 +708,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)  				struct dma_controller *c;  				struct dma_channel *channel; -				int transfer_size = 0; +				unsigned int transfer_size = 0;  				c = musb->dma_controller;  				channel = musb_ep->dma; @@ -824,11 +717,13 @@ static void rxstate(struct musb *musb, struct musb_request *req)  				if (fifo_count < musb_ep->packet_sz)  					transfer_size = fifo_count;  				else if (request->short_not_ok) -					transfer_size =	min(request->length - +					transfer_size =	min_t(unsigned int, +							request->length -  							request->actual,  							channel->max_len);  				else -					transfer_size = min(request->length - +					transfer_size = min_t(unsigned int, +							request->length -  							request->actual,  							(unsigned)fifo_count); @@ -1681,7 +1576,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)  		goto done;  	default:  		dev_dbg(musb->controller, "Unhandled wake: %s\n", -			otg_state_string(musb->xceiv->state)); +			usb_otg_state_string(musb->xceiv->state));  		goto done;  	} @@ -1801,13 +1696,6 @@ static const struct usb_gadget_ops musb_gadget_operations = {   * all peripheral ports are external...   */ -static void musb_gadget_release(struct device *dev) -{ -	/* kref_put(WHAT) */ -	dev_dbg(dev, "%s\n", __func__); -} - -  static void  init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in)  { @@ -1892,12 +1780,7 @@ int musb_gadget_setup(struct musb *musb)  	musb->g.speed = USB_SPEED_UNKNOWN;  	/* this "gadget" abstracts/virtualizes the controller */ -	dev_set_name(&musb->g.dev, "gadget"); -	musb->g.dev.parent = musb->controller; -	musb->g.dev.dma_mask = musb->controller->dma_mask; -	musb->g.dev.release = musb_gadget_release;  	musb->g.name = musb_driver_name; -  	musb->g.is_otg = 1;  	musb_g_init_endpoints(musb); @@ -1905,11 +1788,6 @@ int musb_gadget_setup(struct musb *musb)  	musb->is_active = 0;  	musb_platform_try_idle(musb, 0); -	status = device_register(&musb->g.dev); -	if (status != 0) { -		put_device(&musb->g.dev); -		return status; -	}  	status = usb_add_gadget_udc(musb->controller, &musb->g);  	if (status)  		goto err; @@ -1924,8 +1802,6 @@ err:  void musb_gadget_cleanup(struct musb *musb)  {  	usb_del_gadget_udc(&musb->g); -	if (musb->g.dev.parent) -		device_unregister(&musb->g.dev);  }  /* @@ -1977,9 +1853,8 @@ static int musb_gadget_start(struct usb_gadget *g,  		goto err;  	} -	if ((musb->xceiv->last_event == USB_EVENT_ID) -				&& otg->set_vbus) -		otg_set_vbus(otg, 1); +	if (musb->xceiv->last_event == USB_EVENT_ID) +		musb_platform_set_vbus(musb, 1);  	hcd->self.uses_pio_for_control = 1; @@ -2063,6 +1938,7 @@ static int musb_gadget_stop(struct usb_gadget *g,  	dev_dbg(musb->controller, "unregistering driver %s\n", driver->function);  	musb->is_active = 0; +	musb->gadget_driver = NULL;  	musb_platform_try_idle(musb, 0);  	spin_unlock_irqrestore(&musb->lock, flags); @@ -2099,7 +1975,7 @@ void musb_g_resume(struct musb *musb)  		break;  	default:  		WARNING("unhandled RESUME transition (%s)\n", -				otg_state_string(musb->xceiv->state)); +				usb_otg_state_string(musb->xceiv->state));  	}  } @@ -2129,7 +2005,7 @@ void musb_g_suspend(struct musb *musb)  		 * A_PERIPHERAL may need care too  		 */  		WARNING("unhandled SUSPEND transition (%s)\n", -				otg_state_string(musb->xceiv->state)); +				usb_otg_state_string(musb->xceiv->state));  	}  } @@ -2163,7 +2039,7 @@ void musb_g_disconnect(struct musb *musb)  	switch (musb->xceiv->state) {  	default:  		dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", -			otg_state_string(musb->xceiv->state)); +			usb_otg_state_string(musb->xceiv->state));  		musb->xceiv->state = OTG_STATE_A_IDLE;  		MUSB_HST_MODE(musb);  		break;  |