Some one-liners sent to me yesterday, plus support for the new usb_gadget_disconnect() and usb_gadget_connect() softconnect calls.
- Dave
Collection of small net2280 driver fixes:
- Byteswap bug for big-endian PIO paths
From: Jon Neal <[EMAIL PROTECTED]>
- Highspeed electrical conformance fix
From: Alex Sanks <[EMAIL PROTECTED]>
- Support new usb_gadget_{connect,disconnect}() API calls so
that gadget drivers have softconnect control over the D+ pullup
From: Alex Sanks <[EMAIL PROTECTED]>
And minor cleanups by me.
Signed-off-by: David Brownell <[EMAIL PROTECTED]>
--- a/drivers/usb/gadget/net2280.c Tue Aug 3 13:48:10 2004
+++ b/drivers/usb/gadget/net2280.c Tue Aug 3 13:48:10 2004
@@ -7,13 +7,9 @@
*
* CODE STATUS HIGHLIGHTS
*
- * Used with a gadget driver like "zero.c" this enumerates fine to Windows
- * or Linux hosts; handles disconnect, reconnect, and reset, for full or
- * high speed operation; and passes USB-IF "chapter 9" tests.
- *
- * 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.
+ * This driver should work well with most "gadget" drivers, including
+ * the File Storage, Serial, and Ethernet/RNDIS gadget drivers
+ * as well as Gadget Zero and Gadgetfs.
*
* DMA is enabled by default. Drivers using transfer queues might use
* DMA chaining to remove IRQ latencies between transfers. (Except when
@@ -678,7 +674,7 @@
}
if (count) {
tmp = readl (®s->ep_data);
- cpu_to_le32s (&tmp);
+ /* LE conversion is implicit here: */
do {
*buf++ = (u8) tmp;
tmp >>= 8;
@@ -1419,10 +1415,34 @@
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 = {
.get_frame = net2280_get_frame,
.wakeup = net2280_wakeup,
.set_selfpowered = net2280_set_selfpowered,
+ .pullup = net2280_pullup,
};
/*-------------------------------------------------------------------------*/
@@ -1807,8 +1827,6 @@
{
u32 tmp;
- /* force immediate bus disconnect, and synch through pci */
- writel (0, &dev->usb->usbctl);
dev->gadget.speed = USB_SPEED_UNKNOWN;
(void) readl (&dev->usb->usbctl);
@@ -1905,7 +1923,7 @@
/* erratum 0102 workaround */
| ((dev->chiprev == 0100) ? 0 : 1) << SUSPEND_IMMEDIATELY
| (1 << REMOTE_WAKEUP_SUPPORT)
- | (1 << USB_DETECT_ENABLE)
+ | (dev->softconnect << USB_DETECT_ENABLE)
| (1 << SELF_POWERED_STATUS)
, &dev->usb->usbctl);
@@ -1957,6 +1975,7 @@
dev->ep [i].irqs = 0;
/* hook up the driver ... */
+ dev->softconnect = 1;
driver->driver.bus = NULL;
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
@@ -2788,6 +2807,7 @@
dev->epregs = (struct net2280_ep_regs *) (base + 0x0300);
/* put into initial config, link up all endpoints */
+ writel (0, &dev->usb->usbctl);
usb_reset (dev);
usb_reinit (dev);
--- a/drivers/usb/gadget/net2280.h Tue Aug 3 13:48:10 2004
+++ b/drivers/usb/gadget/net2280.h Tue Aug 3 13:48:10 2004
@@ -559,6 +559,7 @@
struct usb_gadget_driver *driver;
unsigned enabled : 1,
protocol_stall : 1,
+ softconnect : 1,
got_irq : 1,
region : 1;
u16 chiprev;
