Commit a562c020 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: net2280 minor fixes

Collection of small net2280 driver fixes:

    - Byteswap bug for big-endian PIO paths
	From:  Jon Neal <jon@ballardtech.com>
    - Highspeed electrical conformance fix
	From:  Alex Sanks <alex@netchip.com>
    - Support new usb_gadget_{connect,disconnect}() API calls so
      that gadget drivers have softconnect control over the D+ pullup
	From:  Alex Sanks <alex@netchip.com>

And minor cleanups by me.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 6f9da3ca
...@@ -7,13 +7,9 @@ ...@@ -7,13 +7,9 @@
* *
* CODE STATUS HIGHLIGHTS * CODE STATUS HIGHLIGHTS
* *
* Used with a gadget driver like "zero.c" this enumerates fine to Windows * This driver should work well with most "gadget" drivers, including
* or Linux hosts; handles disconnect, reconnect, and reset, for full or * the File Storage, Serial, and Ethernet/RNDIS gadget drivers
* high speed operation; and passes USB-IF "chapter 9" tests. * as well as Gadget Zero and Gadgetfs.
*
* Handles standard stress loads from the Linux "usbtest" driver, with
* either DMA (default) or PIO (use_dma=n) used for ep-{a,b,c,d}. Testing
* with "ttcp" (and the "ether.c" driver) behaves nicely too.
* *
* DMA is enabled by default. Drivers using transfer queues might use * DMA is enabled by default. Drivers using transfer queues might use
* DMA chaining to remove IRQ latencies between transfers. (Except when * DMA chaining to remove IRQ latencies between transfers. (Except when
...@@ -678,7 +674,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req) ...@@ -678,7 +674,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
} }
if (count) { if (count) {
tmp = readl (&regs->ep_data); tmp = readl (&regs->ep_data);
cpu_to_le32s (&tmp); /* LE conversion is implicit here: */
do { do {
*buf++ = (u8) tmp; *buf++ = (u8) tmp;
tmp >>= 8; tmp >>= 8;
...@@ -1419,10 +1415,34 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value) ...@@ -1419,10 +1415,34 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
return 0; return 0;
} }
static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
{
struct net2280 *dev;
u32 tmp;
unsigned long flags;
if (!_gadget)
return -ENODEV;
dev = container_of (_gadget, struct net2280, gadget);
spin_lock_irqsave (&dev->lock, flags);
tmp = readl (&dev->usb->usbctl);
dev->softconnect = (is_on != 0);
if (is_on)
tmp |= (1 << USB_DETECT_ENABLE);
else
tmp &= ~(1 << USB_DETECT_ENABLE);
writel (tmp, &dev->usb->usbctl);
spin_unlock_irqrestore (&dev->lock, flags);
return 0;
}
static const struct usb_gadget_ops net2280_ops = { static const struct usb_gadget_ops net2280_ops = {
.get_frame = net2280_get_frame, .get_frame = net2280_get_frame,
.wakeup = net2280_wakeup, .wakeup = net2280_wakeup,
.set_selfpowered = net2280_set_selfpowered, .set_selfpowered = net2280_set_selfpowered,
.pullup = net2280_pullup,
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -1807,8 +1827,6 @@ static void usb_reset (struct net2280 *dev) ...@@ -1807,8 +1827,6 @@ static void usb_reset (struct net2280 *dev)
{ {
u32 tmp; u32 tmp;
/* force immediate bus disconnect, and synch through pci */
writel (0, &dev->usb->usbctl);
dev->gadget.speed = USB_SPEED_UNKNOWN; dev->gadget.speed = USB_SPEED_UNKNOWN;
(void) readl (&dev->usb->usbctl); (void) readl (&dev->usb->usbctl);
...@@ -1905,7 +1923,7 @@ static void ep0_start (struct net2280 *dev) ...@@ -1905,7 +1923,7 @@ static void ep0_start (struct net2280 *dev)
/* erratum 0102 workaround */ /* erratum 0102 workaround */
| ((dev->chiprev == 0100) ? 0 : 1) << SUSPEND_IMMEDIATELY | ((dev->chiprev == 0100) ? 0 : 1) << SUSPEND_IMMEDIATELY
| (1 << REMOTE_WAKEUP_SUPPORT) | (1 << REMOTE_WAKEUP_SUPPORT)
| (1 << USB_DETECT_ENABLE) | (dev->softconnect << USB_DETECT_ENABLE)
| (1 << SELF_POWERED_STATUS) | (1 << SELF_POWERED_STATUS)
, &dev->usb->usbctl); , &dev->usb->usbctl);
...@@ -1957,6 +1975,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) ...@@ -1957,6 +1975,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
dev->ep [i].irqs = 0; dev->ep [i].irqs = 0;
/* hook up the driver ... */ /* hook up the driver ... */
dev->softconnect = 1;
driver->driver.bus = NULL; driver->driver.bus = NULL;
dev->driver = driver; dev->driver = driver;
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
...@@ -2788,6 +2807,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2788,6 +2807,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->epregs = (struct net2280_ep_regs *) (base + 0x0300); dev->epregs = (struct net2280_ep_regs *) (base + 0x0300);
/* put into initial config, link up all endpoints */ /* put into initial config, link up all endpoints */
writel (0, &dev->usb->usbctl);
usb_reset (dev); usb_reset (dev);
usb_reinit (dev); usb_reinit (dev);
......
...@@ -559,6 +559,7 @@ struct net2280 { ...@@ -559,6 +559,7 @@ struct net2280 {
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
unsigned enabled : 1, unsigned enabled : 1,
protocol_stall : 1, protocol_stall : 1,
softconnect : 1,
got_irq : 1, got_irq : 1,
region : 1; region : 1;
u16 chiprev; u16 chiprev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment