* [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code
@ 2014-05-20 16:30 Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 01/10 v5.1] usb: gadget: net2280: Add support for PLX USB338X Ricardo Ribalda Delgado
` (10 more replies)
0 siblings, 11 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
Controller. It shares a lot functionatily with the net228x family.
This series of patches includes some resend of previous patches.
Please check the changelog for every patch. This time it has been placed
under the tear line
Ricardo Ribalda Delgado (10):
usb: gadget: net2280: Add support for PLX USB338X
usb: gadget: net2280: Dont use magic numbers
usb: gadget: net2280: Use BIT() macro
usb: gadget: net2280: Use true/false instead of 1/0
usb: gadget: net2280: Use module_pci_driver macro
usb: gadget: net2280: Refactor queues_show
usb: gadget: net2280: Pass checkpacth.pl test
usb: gadget: net2280: Code Cleanup
usb: gadget: net2280: Use pr_* function
usb: gadget: net2280: Use quirks instead of pci id
drivers/usb/gadget/Kconfig | 10 +-
drivers/usb/gadget/net2280.c | 2752 ++++++++++++++++++++++++++++--------------
drivers/usb/gadget/net2280.h | 285 +++--
include/linux/usb/usb338x.h | 199 +++
4 files changed, 2235 insertions(+), 1011 deletions(-)
create mode 100644 include/linux/usb/usb338x.h
--
2.0.0.rc2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 01/10 v5.1] usb: gadget: net2280: Add support for PLX USB338X
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 02/10] usb: gadget: net2280: Dont use magic numbers Ricardo Ribalda Delgado
` (9 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
This patch adds support for the PLX USB3380 and USB3382.
This driver is based on the driver from the manufacturer.
Since USB338X is register compatible with NET2280, I thought that it
would be better to include this hardware into net2280 driver.
Manufacturer's driver only supported the USB33X, did not follow the
Kernel Style and contain some trivial errors. This patch has tried to
address this issues.
This patch has only been tested on USB338x hardware, but the merge has
been done trying to not affect the behaviour of NET2280.
Tested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
v5: -Consistent warning messages
-Comments by Joe Perches
-Create enable_pciirqenb inline
-Create set_max_speed inline
-Merge error messages
v4: -Fix bug with usb_ep_set_maxpacket_limit
v3: -Fix Double parenthesis
-Comments by Joe Perches
- declare ep_bit as global const
- logical continuations at end of line
- fix multiline comment
v2:
-use usb_ep_set_maxpacket_limit
-usb338x: Fix support for high speed
drivers/usb/gadget/Kconfig | 10 +-
drivers/usb/gadget/net2280.c | 1119 ++++++++++++++++++++++++++++++++++++++----
drivers/usb/gadget/net2280.h | 121 ++++-
include/linux/usb/usb338x.h | 199 ++++++++
4 files changed, 1351 insertions(+), 98 deletions(-)
create mode 100644 include/linux/usb/usb338x.h
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 3557c7e..831af8f 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -415,7 +415,7 @@ config USB_NET2272_DMA
If unsure, say "N" here. The driver works fine in PIO mode.
config USB_NET2280
- tristate "NetChip 228x"
+ tristate "NetChip 228x / PLX USB338x"
depends on PCI
help
NetChip 2280 / 2282 is a PCI based USB peripheral controller which
@@ -425,6 +425,14 @@ config USB_NET2280
(for control transfers) and several endpoints with dedicated
functions.
+ PLX 3380 / 3382 is a PCIe based USB peripheral controller which
+ supports full, high speed USB 2.0 and super speed USB 3.0
+ data transfers.
+
+ It has eight configurable endpoints, as well as endpoint zero
+ (for control transfers) and several endpoints with dedicated
+ functions.
+
Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "net2280" and force all
gadget drivers to also be dynamically linked.
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 300b3a7..8112d91 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -18,6 +18,9 @@
* hint to completely eliminate some IRQs, if a later IRQ is guaranteed
* and DMA chaining is enabled.
*
+ * MSI is enabled by default. The legacy IRQ is used if MSI couldn't
+ * be enabled.
+ *
* Note that almost all the errata workarounds here are only needed for
* rev1 chips. Rev1a silicon (0110) fixes almost all of them.
*/
@@ -25,10 +28,14 @@
/*
* Copyright (C) 2003 David Brownell
* Copyright (C) 2003-2005 PLX Technology, Inc.
+ * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
*
* Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility
* with 2282 chip
*
+ * Modified Ricardo Ribalda Qtechnology AS to provide compatibility
+ * with usb 338x chip. Based on PLX driver
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -61,9 +68,8 @@
#include <asm/irq.h>
#include <asm/unaligned.h>
-
-#define DRIVER_DESC "PLX NET228x USB Peripheral Controller"
-#define DRIVER_VERSION "2005 Sept 27"
+#define DRIVER_DESC "PLX NET228x/USB338x USB Peripheral Controller"
+#define DRIVER_VERSION "2005 Sept 27/v3.0"
#define EP_DONTUSE 13 /* nonzero */
@@ -73,11 +79,12 @@
static const char driver_name [] = "net2280";
static const char driver_desc [] = DRIVER_DESC;
+static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 };
static const char ep0name [] = "ep0";
static const char *const ep_name [] = {
ep0name,
"ep-a", "ep-b", "ep-c", "ep-d",
- "ep-e", "ep-f",
+ "ep-e", "ep-f", "ep-g", "ep-h",
};
/* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
@@ -90,11 +97,12 @@ static const char *const ep_name [] = {
*/
static bool use_dma = 1;
static bool use_dma_chaining = 0;
+static bool use_msi = 1;
/* "modprobe net2280 use_dma=n" etc */
module_param (use_dma, bool, S_IRUGO);
module_param (use_dma_chaining, bool, S_IRUGO);
-
+module_param(use_msi, bool, S_IRUGO);
/* mode 0 == ep-{a,b,c,d} 1K fifo each
* mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -140,6 +148,18 @@ static char *type_string (u8 bmAttributes)
#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE)
/*-------------------------------------------------------------------------*/
+static inline void enable_pciirqenb(struct net2280_ep *ep)
+{
+ u32 tmp = readl(&ep->dev->regs->pciirqenb0);
+
+ if (ep->dev->pdev->vendor == 0x17cc)
+ tmp |= 1 << ep->num;
+ else
+ tmp |= 1 << ep_bit[ep->num];
+ writel(tmp, &ep->dev->regs->pciirqenb0);
+
+ return;
+}
static int
net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
@@ -148,6 +168,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
struct net2280_ep *ep;
u32 max, tmp;
unsigned long flags;
+ static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
ep = container_of (_ep, struct net2280_ep, ep);
if (!_ep || !desc || ep->desc || _ep->name == ep0name
@@ -161,9 +182,17 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE)
return -EDOM;
+ if (dev->pdev->vendor == 0x10b5) {
+ if ((desc->bEndpointAddress & 0x0f) >= 0x0c)
+ return -EDOM;
+ ep->is_in = !!usb_endpoint_dir_in(desc);
+ if (dev->enhanced_mode && ep->is_in && ep_key[ep->num])
+ return -EINVAL;
+ }
+
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp (desc) & 0x1fff;
- if (ep->num > 4 && max > 64)
+ if (ep->num > 4 && max > 64 && (dev->pdev->vendor == 0x17cc))
return -ERANGE;
spin_lock_irqsave (&dev->lock, flags);
@@ -176,7 +205,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
ep->out_overflow = 0;
/* set speed-dependent max packet; may kick in high bandwidth */
- set_idx_reg (dev->regs, REG_EP_MAXPKT (dev, ep->num), max);
+ set_max_speed(ep, max);
/* FIFO lines can't go to different packets. PIO is ok, so
* use it instead of troublesome (non-bulk) multi-packet DMA.
@@ -199,23 +228,43 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
&ep->regs->ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
/* catch some particularly blatant driver bugs */
- if ((dev->gadget.speed == USB_SPEED_HIGH
- && max != 512)
- || (dev->gadget.speed == USB_SPEED_FULL
- && max > 64)) {
- spin_unlock_irqrestore (&dev->lock, flags);
+ if ((dev->gadget.speed == USB_SPEED_SUPER && max != 1024) ||
+ (dev->gadget.speed == USB_SPEED_HIGH && max != 512) ||
+ (dev->gadget.speed == USB_SPEED_FULL && max > 64)) {
+ spin_unlock_irqrestore(&dev->lock, flags);
return -ERANGE;
}
}
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
- tmp <<= ENDPOINT_TYPE;
- tmp |= desc->bEndpointAddress;
- tmp |= (4 << ENDPOINT_BYTE_COUNT); /* default full fifo lines */
- tmp |= 1 << ENDPOINT_ENABLE;
- wmb ();
+ /* Enable this endpoint */
+ if (dev->pdev->vendor == 0x17cc) {
+ tmp <<= ENDPOINT_TYPE;
+ tmp |= desc->bEndpointAddress;
+ /* default full fifo lines */
+ tmp |= (4 << ENDPOINT_BYTE_COUNT);
+ tmp |= 1 << ENDPOINT_ENABLE;
+ ep->is_in = (tmp & USB_DIR_IN) != 0;
+ } else {
+ /* In Legacy mode, only OUT endpoints are used */
+ if (dev->enhanced_mode && ep->is_in) {
+ tmp <<= IN_ENDPOINT_TYPE;
+ tmp |= (1 << IN_ENDPOINT_ENABLE);
+ /* Not applicable to Legacy */
+ tmp |= (1 << ENDPOINT_DIRECTION);
+ } else {
+ tmp <<= OUT_ENDPOINT_TYPE;
+ tmp |= (1 << OUT_ENDPOINT_ENABLE);
+ tmp |= (ep->is_in << ENDPOINT_DIRECTION);
+ }
+
+ tmp |= usb_endpoint_num(desc);
+ tmp |= (ep->ep.maxburst << MAX_BURST_SIZE);
+ }
+
+ /* Make sure all the registers are written before ep_rsp*/
+ wmb();
/* for OUT transfers, block the rx fifo until a read is posted */
- ep->is_in = (tmp & USB_DIR_IN) != 0;
if (!ep->is_in)
writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
else if (dev->pdev->device != 0x2280) {
@@ -226,12 +275,11 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
| (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
}
- writel (tmp, &ep->regs->ep_cfg);
+ writel(tmp, &ep->cfg->ep_cfg);
/* enable irqs */
if (!ep->dma) { /* pio, per-packet */
- tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0);
- writel (tmp, &dev->regs->pciirqenb0);
+ enable_pciirqenb(ep);
tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE)
| (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
@@ -251,8 +299,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
writel (tmp, &ep->regs->ep_irqenb);
- tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0);
- writel (tmp, &dev->regs->pciirqenb0);
+ enable_pciirqenb(ep);
}
}
@@ -286,7 +333,8 @@ static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec)
static const struct usb_ep_ops net2280_ep_ops;
-static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep)
+static void ep_reset_228x(struct net2280_regs __iomem *regs,
+ struct net2280_ep *ep)
{
u32 tmp;
@@ -361,6 +409,55 @@ static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep)
/* fifo size is handled separately */
}
+static void ep_reset_338x(struct net2280_regs __iomem *regs,
+ struct net2280_ep *ep)
+{
+ u32 tmp, dmastat;
+
+ ep->desc = NULL;
+ INIT_LIST_HEAD(&ep->queue);
+
+ usb_ep_set_maxpacket_limit(&ep->ep, ~0);
+ ep->ep.ops = &net2280_ep_ops;
+
+ /* disable the dma, irqs, endpoint... */
+ if (ep->dma) {
+ writel(0, &ep->dma->dmactl);
+ writel((1 << DMA_ABORT_DONE_INTERRUPT) |
+ (1 << DMA_PAUSE_DONE_INTERRUPT) |
+ (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) |
+ (1 << DMA_TRANSACTION_DONE_INTERRUPT)
+ /* | (1 << DMA_ABORT) */
+ , &ep->dma->dmastat);
+
+ dmastat = readl(&ep->dma->dmastat);
+ if (dmastat == 0x5002) {
+ WARNING(ep->dev, "The dmastat return = %x!!\n",
+ dmastat);
+ writel(0x5a, &ep->dma->dmastat);
+ }
+
+ tmp = readl(®s->pciirqenb0);
+ tmp &= ~(1 << ep_bit[ep->num]);
+ writel(tmp, ®s->pciirqenb0);
+ } else {
+ if (ep->num < 5) {
+ tmp = readl(®s->pciirqenb1);
+ tmp &= ~(1 << (8 + ep->num)); /* completion */
+ writel(tmp, ®s->pciirqenb1);
+ }
+ }
+ writel(0, &ep->regs->ep_irqenb);
+
+ writel((1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
+ (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
+ (1 << FIFO_OVERFLOW) |
+ (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
+ (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ (1 << DATA_OUT_PING_TOKEN_INTERRUPT) |
+ (1 << DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
+}
+
static void nuke (struct net2280_ep *);
static int net2280_disable (struct usb_ep *_ep)
@@ -374,13 +471,17 @@ static int net2280_disable (struct usb_ep *_ep)
spin_lock_irqsave (&ep->dev->lock, flags);
nuke (ep);
- ep_reset (ep->dev->regs, ep);
+
+ if (ep->dev->pdev->vendor == 0x10b5)
+ ep_reset_338x(ep->dev->regs, ep);
+ else
+ ep_reset_228x(ep->dev->regs, ep);
VDEBUG (ep->dev, "disabled %s %s\n",
ep->dma ? "dma" : "pio", _ep->name);
/* synch memory views with the device */
- (void) readl (&ep->regs->ep_cfg);
+ (void)readl(&ep->cfg->ep_cfg);
if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4)
ep->dma = &ep->dev->dma [ep->num - 1];
@@ -698,6 +799,8 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
writel (readl (&dma->dmastat), &dma->dmastat);
writel (td_dma, &dma->dmadesc);
+ if (ep->dev->pdev->vendor == 0x10b5)
+ dmactl |= (0x01 << DMA_REQUEST_OUTSTANDING);
writel (dmactl, &dma->dmactl);
/* erratum 0116 workaround part 3: pci arbiter away from net2280 */
@@ -772,6 +875,21 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
start_queue (ep, tmp, req->td_dma);
}
+static inline void resume_dma(struct net2280_ep *ep)
+{
+ writel(readl(&ep->dma->dmactl) | (1 << DMA_ENABLE), &ep->dma->dmactl);
+
+ ep->dma_started = true;
+}
+
+static inline void ep_stop_dma(struct net2280_ep *ep)
+{
+ writel(readl(&ep->dma->dmactl) & ~(1 << DMA_ENABLE), &ep->dma->dmactl);
+ spin_stop_dma(ep->dma);
+
+ ep->dma_started = false;
+}
+
static inline void
queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid)
{
@@ -874,8 +992,23 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* kickstart this i/o queue? */
if (list_empty (&ep->queue) && !ep->stopped) {
+ /* DMA request while EP halted */
+ if (ep->dma &&
+ (readl(&ep->regs->ep_rsp) & (1 << CLEAR_ENDPOINT_HALT)) &&
+ (dev->pdev->vendor == 0x10b5)) {
+ int valid = 1;
+ if (ep->is_in) {
+ int expect;
+ expect = likely(req->req.zero ||
+ ((req->req.length %
+ ep->ep.maxpacket) != 0));
+ if (expect != ep->in_fifo_validate)
+ valid = 0;
+ }
+ queue_dma(ep, req, valid);
+ }
/* use DMA if the endpoint supports it, else pio */
- if (ep->dma)
+ else if (ep->dma)
start_dma (ep, req);
else {
/* maybe there's no control data, just status ack */
@@ -993,6 +1126,8 @@ static void scan_dma_completions (struct net2280_ep *ep)
} else if (!ep->is_in
&& (req->req.length % ep->ep.maxpacket) != 0) {
tmp = readl (&ep->regs->ep_stat);
+ if (ep->dev->pdev->vendor == 0x10b5)
+ return dma_done(ep, req, tmp, 0);
/* AVOID TROUBLE HERE by not issuing short reads from
* your gadget driver. That helps avoids errata 0121,
@@ -1079,7 +1214,7 @@ static void restart_dma (struct net2280_ep *ep)
start_queue (ep, dmactl, req->td_dma);
}
-static void abort_dma (struct net2280_ep *ep)
+static void abort_dma_228x(struct net2280_ep *ep)
{
/* abort the current transfer */
if (likely (!list_empty (&ep->queue))) {
@@ -1091,6 +1226,19 @@ static void abort_dma (struct net2280_ep *ep)
scan_dma_completions (ep);
}
+static void abort_dma_338x(struct net2280_ep *ep)
+{
+ writel((1 << DMA_ABORT), &ep->dma->dmastat);
+ spin_stop_dma(ep->dma);
+}
+
+static void abort_dma(struct net2280_ep *ep)
+{
+ if (ep->dev->pdev->vendor == 0x17cc)
+ return abort_dma_228x(ep);
+ return abort_dma_338x(ep);
+}
+
/* dequeue ALL requests */
static void nuke (struct net2280_ep *ep)
{
@@ -1244,6 +1392,9 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
ep->wedged = 1;
} else {
clear_halt (ep);
+ if (ep->dev->pdev->vendor == 0x10b5 &&
+ !list_empty(&ep->queue) && ep->td_dma)
+ restart_dma(ep);
ep->wedged = 0;
}
(void) readl (&ep->regs->ep_rsp);
@@ -1367,10 +1518,13 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
spin_lock_irqsave (&dev->lock, flags);
tmp = readl (&dev->usb->usbctl);
- if (value)
+ if (value) {
tmp |= (1 << SELF_POWERED_STATUS);
- else
+ dev->selfpowered = 1;
+ } else {
tmp &= ~(1 << SELF_POWERED_STATUS);
+ dev->selfpowered = 0;
+ }
writel (tmp, &dev->usb->usbctl);
spin_unlock_irqrestore (&dev->lock, flags);
@@ -1504,14 +1658,14 @@ static ssize_t registers_show(struct device *_dev,
/* DMA Control Registers */
/* Configurable EP Control Registers */
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < dev->n_ep; i++) {
struct net2280_ep *ep;
ep = &dev->ep [i];
if (i && !ep->desc)
continue;
- t1 = readl (&ep->regs->ep_cfg);
+ t1 = readl(&ep->cfg->ep_cfg);
t2 = readl (&ep->regs->ep_rsp) & 0xff;
t = scnprintf (next, size,
"\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
@@ -1571,7 +1725,7 @@ static ssize_t registers_show(struct device *_dev,
t = scnprintf (next, size, "\nirqs: ");
size -= t;
next += t;
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < dev->n_ep; i++) {
struct net2280_ep *ep;
ep = &dev->ep [i];
@@ -1606,7 +1760,7 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
size = PAGE_SIZE;
spin_lock_irqsave (&dev->lock, flags);
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < dev->n_ep; i++) {
struct net2280_ep *ep = &dev->ep [i];
struct net2280_request *req;
int t;
@@ -1735,6 +1889,121 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list);
}
+static void defect7374_disable_data_eps(struct net2280 *dev)
+{
+ /*
+ * For Defect 7374, disable data EPs (and more):
+ * - This phase undoes the earlier phase of the Defect 7374 workaround,
+ * returing ep regs back to normal.
+ */
+ struct net2280_ep *ep;
+ int i;
+ unsigned char ep_sel;
+ u32 tmp_reg;
+
+ for (i = 1; i < 5; i++) {
+ ep = &dev->ep[i];
+ writel(0, &ep->cfg->ep_cfg);
+ }
+
+ /* CSROUT, CSRIN, PCIOUT, PCIIN, STATIN, RCIN */
+ for (i = 0; i < 6; i++)
+ writel(0, &dev->dep[i].dep_cfg);
+
+ for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
+ /* Select an endpoint for subsequent operations: */
+ tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
+ writel(((tmp_reg & ~0x1f) | ep_sel), &dev->plregs->pl_ep_ctrl);
+
+ if (ep_sel < 2 || (ep_sel > 9 && ep_sel < 14) ||
+ ep_sel == 18 || ep_sel == 20)
+ continue;
+
+ /* Change settings on some selected endpoints */
+ tmp_reg = readl(&dev->plregs->pl_ep_cfg_4);
+ tmp_reg &= ~(1 << NON_CTRL_IN_TOLERATE_BAD_DIR);
+ writel(tmp_reg, &dev->plregs->pl_ep_cfg_4);
+ tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
+ tmp_reg |= (1 << EP_INITIALIZED);
+ writel(tmp_reg, &dev->plregs->pl_ep_ctrl);
+ }
+}
+
+static void defect7374_enable_data_eps_zero(struct net2280 *dev)
+{
+ u32 tmp = 0, tmp_reg;
+ u32 fsmvalue, scratch;
+ int i;
+ unsigned char ep_sel;
+
+ scratch = get_idx_reg(dev->regs, SCRATCH);
+ fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
+ scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
+
+ /*See if firmware needs to set up for workaround*/
+ if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
+ WARNING(dev, "Operate Defect 7374 workaround soft this time");
+ WARNING(dev, "It will operate on cold-reboot and SS connect");
+
+ /*GPEPs:*/
+ tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_DIRECTION) |
+ (2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
+ ((dev->enhanced_mode) ?
+ 1 << OUT_ENDPOINT_ENABLE : 1 << ENDPOINT_ENABLE) |
+ (1 << IN_ENDPOINT_ENABLE));
+
+ for (i = 1; i < 5; i++)
+ writel(tmp, &dev->ep[i].cfg->ep_cfg);
+
+ /* CSRIN, PCIIN, STATIN, RCIN*/
+ tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_ENABLE));
+ writel(tmp, &dev->dep[1].dep_cfg);
+ writel(tmp, &dev->dep[3].dep_cfg);
+ writel(tmp, &dev->dep[4].dep_cfg);
+ writel(tmp, &dev->dep[5].dep_cfg);
+
+ /*Implemented for development and debug.
+ * Can be refined/tuned later.*/
+ for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
+ /* Select an endpoint for subsequent operations: */
+ tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
+ writel(((tmp_reg & ~0x1f) | ep_sel),
+ &dev->plregs->pl_ep_ctrl);
+
+ if (ep_sel == 1) {
+ tmp =
+ (readl(&dev->plregs->pl_ep_ctrl) |
+ (1 << CLEAR_ACK_ERROR_CODE) | 0);
+ writel(tmp, &dev->plregs->pl_ep_ctrl);
+ continue;
+ }
+
+ if (ep_sel == 0 || (ep_sel > 9 && ep_sel < 14) ||
+ ep_sel == 18 || ep_sel == 20)
+ continue;
+
+ tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
+ (1 << NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
+ writel(tmp, &dev->plregs->pl_ep_cfg_4);
+
+ tmp = readl(&dev->plregs->pl_ep_ctrl) &
+ ~(1 << EP_INITIALIZED);
+ writel(tmp, &dev->plregs->pl_ep_ctrl);
+
+ }
+
+ /* Set FSM to focus on the first Control Read:
+ * - Tip: Connection speed is known upon the first
+ * setup request.*/
+ scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ;
+ set_idx_reg(dev->regs, SCRATCH, scratch);
+
+ } else{
+ WARNING(dev, "Defect 7374 workaround soft will NOT operate");
+ WARNING(dev, "It will operate on cold-reboot and SS connect");
+ }
+}
+
/* keeping it simple:
* - one bus driver, initted first;
* - one function driver, initted second
@@ -1744,7 +2013,7 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
* perhaps to bind specific drivers to specific devices.
*/
-static void usb_reset (struct net2280 *dev)
+static void usb_reset_228x(struct net2280 *dev)
{
u32 tmp;
@@ -1760,11 +2029,11 @@ static void usb_reset (struct net2280 *dev)
/* clear old dma and irq state */
for (tmp = 0; tmp < 4; tmp++) {
- struct net2280_ep *ep = &dev->ep [tmp + 1];
-
+ struct net2280_ep *ep = &dev->ep[tmp + 1];
if (ep->dma)
- abort_dma (ep);
+ abort_dma(ep);
}
+
writel (~0, &dev->regs->irqstat0),
writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
@@ -1780,7 +2049,67 @@ static void usb_reset (struct net2280 *dev)
set_fifo_mode (dev, (fifo_mode <= 2) ? fifo_mode : 0);
}
-static void usb_reinit (struct net2280 *dev)
+static void usb_reset_338x(struct net2280 *dev)
+{
+ u32 tmp;
+ u32 fsmvalue;
+
+ dev->gadget.speed = USB_SPEED_UNKNOWN;
+ (void)readl(&dev->usb->usbctl);
+
+ net2280_led_init(dev);
+
+ fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
+ (0xf << DEFECT7374_FSM_FIELD);
+
+ /* See if firmware needs to set up for workaround: */
+ if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
+ INFO(dev, "%s: Defect 7374 FsmValue 0x%08x\n", __func__,
+ fsmvalue);
+ } else {
+ /* disable automatic responses, and irqs */
+ writel(0, &dev->usb->stdrsp);
+ writel(0, &dev->regs->pciirqenb0);
+ writel(0, &dev->regs->pciirqenb1);
+ }
+
+ /* clear old dma and irq state */
+ for (tmp = 0; tmp < 4; tmp++) {
+ struct net2280_ep *ep = &dev->ep[tmp + 1];
+
+ if (ep->dma)
+ abort_dma(ep);
+ }
+
+ writel(~0, &dev->regs->irqstat0), writel(~0, &dev->regs->irqstat1);
+
+ if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
+ /* reset, and enable pci */
+ tmp = readl(&dev->regs->devinit) |
+ (1 << PCI_ENABLE) |
+ (1 << FIFO_SOFT_RESET) |
+ (1 << USB_SOFT_RESET) |
+ (1 << M8051_RESET);
+
+ writel(tmp, &dev->regs->devinit);
+ }
+
+ /* always ep-{1,2,3,4} ... maybe not ep-3 or ep-4 */
+ INIT_LIST_HEAD(&dev->gadget.ep_list);
+
+ for (tmp = 1; tmp < dev->n_ep; tmp++)
+ list_add_tail(&dev->ep[tmp].ep.ep_list, &dev->gadget.ep_list);
+
+}
+
+static void usb_reset(struct net2280 *dev)
+{
+ if (dev->pdev->vendor == 0x17cc)
+ return usb_reset_228x(dev);
+ return usb_reset_338x(dev);
+}
+
+static void usb_reinit_228x(struct net2280 *dev)
{
u32 tmp;
int init_dma;
@@ -1803,7 +2132,8 @@ static void usb_reinit (struct net2280 *dev)
} else
ep->fifo_size = 64;
ep->regs = &dev->epregs [tmp];
- ep_reset (dev->regs, ep);
+ ep->cfg = &dev->epregs[tmp];
+ ep_reset_228x(dev->regs, ep);
}
usb_ep_set_maxpacket_limit(&dev->ep [0].ep, 64);
usb_ep_set_maxpacket_limit(&dev->ep [5].ep, 64);
@@ -1820,7 +2150,122 @@ static void usb_reinit (struct net2280 *dev)
writel (EP_DONTUSE, &dev->dep [tmp].dep_cfg);
}
-static void ep0_start (struct net2280 *dev)
+static void usb_reinit_338x(struct net2280 *dev)
+{
+ int init_dma;
+ int i;
+ u32 tmp, val;
+ u32 fsmvalue;
+ static const u32 ne[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
+ static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
+ 0x00, 0xC0, 0x00, 0xC0 };
+
+ /* use_dma changes are ignored till next device re-init */
+ init_dma = use_dma;
+
+ /* basic endpoint init */
+ for (i = 0; i < dev->n_ep; i++) {
+ struct net2280_ep *ep = &dev->ep[i];
+
+ ep->ep.name = ep_name[i];
+ ep->dev = dev;
+ ep->num = i;
+
+ if (i > 0 && i <= 4 && init_dma)
+ ep->dma = &dev->dma[i - 1];
+
+ if (dev->enhanced_mode) {
+ ep->cfg = &dev->epregs[ne[i]];
+ ep->regs = (struct net2280_ep_regs __iomem *)
+ (((void *)&dev->epregs[ne[i]]) +
+ ep_reg_addr[i]);
+ ep->fiforegs = &dev->fiforegs[i];
+ } else {
+ ep->cfg = &dev->epregs[i];
+ ep->regs = &dev->epregs[i];
+ ep->fiforegs = &dev->fiforegs[i];
+ }
+
+ ep->fifo_size = (i != 0) ? 2048 : 512;
+
+ ep_reset_338x(dev->regs, ep);
+ }
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 512);
+
+ dev->gadget.ep0 = &dev->ep[0].ep;
+ dev->ep[0].stopped = 0;
+
+ /* Link layer set up */
+ fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
+ (0xf << DEFECT7374_FSM_FIELD);
+
+ /* See if driver needs to set up for workaround: */
+ if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
+ INFO(dev, "%s: Defect 7374 FsmValue %08x\n",
+ __func__, fsmvalue);
+ else {
+ tmp = readl(&dev->usb_ext->usbctl2) &
+ ~((1 << U1_ENABLE) | (1 << U2_ENABLE) | (1 << LTM_ENABLE));
+ writel(tmp, &dev->usb_ext->usbctl2);
+ }
+
+ /* Hardware Defect and Workaround */
+ val = readl(&dev->ll_lfps_regs->ll_lfps_5);
+ val &= ~(0xf << TIMER_LFPS_6US);
+ val |= 0x5 << TIMER_LFPS_6US;
+ writel(val, &dev->ll_lfps_regs->ll_lfps_5);
+
+ val = readl(&dev->ll_lfps_regs->ll_lfps_6);
+ val &= ~(0xffff << TIMER_LFPS_80US);
+ val |= 0x0100 << TIMER_LFPS_80US;
+ writel(val, &dev->ll_lfps_regs->ll_lfps_6);
+
+ /*
+ * AA_AB Errata. Issue 4. Workaround for SuperSpeed USB
+ * Hot Reset Exit Handshake may Fail in Specific Case using
+ * Default Register Settings. Workaround for Enumeration test.
+ */
+ val = readl(&dev->ll_tsn_regs->ll_tsn_counters_2);
+ val &= ~(0x1f << HOT_TX_NORESET_TS2);
+ val |= 0x10 << HOT_TX_NORESET_TS2;
+ writel(val, &dev->ll_tsn_regs->ll_tsn_counters_2);
+
+ val = readl(&dev->ll_tsn_regs->ll_tsn_counters_3);
+ val &= ~(0x1f << HOT_RX_RESET_TS2);
+ val |= 0x3 << HOT_RX_RESET_TS2;
+ writel(val, &dev->ll_tsn_regs->ll_tsn_counters_3);
+
+ /*
+ * Set Recovery Idle to Recover bit:
+ * - On SS connections, setting Recovery Idle to Recover Fmw improves
+ * link robustness with various hosts and hubs.
+ * - It is safe to set for all connection speeds; all chip revisions.
+ * - R-M-W to leave other bits undisturbed.
+ * - Reference PLX TT-7372
+ */
+ val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit);
+ val |= (1 << RECOVERY_IDLE_TO_RECOVER_FMW);
+ writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit);
+
+ INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
+
+ /* disable dedicated endpoints */
+ writel(0x0D, &dev->dep[0].dep_cfg);
+ writel(0x0D, &dev->dep[1].dep_cfg);
+ writel(0x0E, &dev->dep[2].dep_cfg);
+ writel(0x0E, &dev->dep[3].dep_cfg);
+ writel(0x0F, &dev->dep[4].dep_cfg);
+ writel(0x0C, &dev->dep[5].dep_cfg);
+}
+
+static void usb_reinit(struct net2280 *dev)
+{
+ if (dev->pdev->vendor == 0x17cc)
+ return usb_reinit_228x(dev);
+ return usb_reinit_338x(dev);
+}
+
+static void ep0_start_228x(struct net2280 *dev)
{
writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE)
| (1 << CLEAR_NAK_OUT_PACKETS)
@@ -1863,6 +2308,61 @@ static void ep0_start (struct net2280 *dev)
(void) readl (&dev->usb->usbctl);
}
+static void ep0_start_338x(struct net2280 *dev)
+{
+ u32 fsmvalue;
+
+ fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
+ (0xf << DEFECT7374_FSM_FIELD);
+
+ if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
+ INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
+ fsmvalue);
+ else
+ writel((1 << CLEAR_NAK_OUT_PACKETS_MODE) |
+ (1 << SET_EP_HIDE_STATUS_PHASE),
+ &dev->epregs[0].ep_rsp);
+
+ /*
+ * hardware optionally handles a bunch of standard requests
+ * that the API hides from drivers anyway. have it do so.
+ * endpoint status/features are handled in software, to
+ * help pass tests for some dubious behavior.
+ */
+ writel((1 << SET_ISOCHRONOUS_DELAY) |
+ (1 << SET_SEL) |
+ (1 << SET_TEST_MODE) |
+ (1 << SET_ADDRESS) |
+ (1 << GET_INTERFACE_STATUS) |
+ (1 << GET_DEVICE_STATUS),
+ &dev->usb->stdrsp);
+ dev->wakeup_enable = 1;
+ writel((1 << USB_ROOT_PORT_WAKEUP_ENABLE) |
+ (dev->softconnect << USB_DETECT_ENABLE) |
+ (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ &dev->usb->usbctl);
+
+ /* enable irqs so we can see ep0 and general operation */
+ writel((1 << SETUP_PACKET_INTERRUPT_ENABLE) |
+ (1 << ENDPOINT_0_INTERRUPT_ENABLE)
+ , &dev->regs->pciirqenb0);
+ writel((1 << PCI_INTERRUPT_ENABLE) |
+ (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) |
+ (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
+ (1 << VBUS_INTERRUPT_ENABLE),
+ &dev->regs->pciirqenb1);
+
+ /* don't leave any writes posted */
+ (void)readl(&dev->usb->usbctl);
+}
+
+static void ep0_start(struct net2280 *dev)
+{
+ if (dev->pdev->vendor == 0x17cc)
+ return ep0_start_228x(dev);
+ return ep0_start_338x(dev);
+}
+
/* when a driver is successfully registered, it will receive
* control requests including set_configuration(), which enables
* non-control requests. then usb traffic follows until a
@@ -1886,7 +2386,7 @@ static int net2280_start(struct usb_gadget *_gadget,
dev = container_of (_gadget, struct net2280, gadget);
- for (i = 0; i < 7; i++)
+ for (i = 0; i < dev->n_ep; i++)
dev->ep [i].irqs = 0;
/* hook up the driver ... */
@@ -1900,13 +2400,17 @@ static int net2280_start(struct usb_gadget *_gadget,
if (retval) goto err_func;
/* Enable force-full-speed testing mode, if desired */
- if (full_speed)
+ if (full_speed && dev->pdev->vendor == 0x17cc)
writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag);
/* ... then enable host detection and ep0; and we're ready
* for set_configuration as well as eventual disconnect.
*/
net2280_led_active (dev, 1);
+
+ if (dev->pdev->vendor == 0x10b5)
+ defect7374_enable_data_eps_zero(dev);
+
ep0_start (dev);
DEBUG (dev, "%s ready, usbctl %08x stdrsp %08x\n",
@@ -1937,7 +2441,7 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
* and kill any outstanding requests.
*/
usb_reset (dev);
- for (i = 0; i < 7; i++)
+ for (i = 0; i < dev->n_ep; i++)
nuke (&dev->ep [i]);
/* report disconnect; the driver is already quiesced */
@@ -1967,7 +2471,8 @@ static int net2280_stop(struct usb_gadget *_gadget,
net2280_led_active (dev, 0);
/* Disable full-speed test mode */
- writel(0, &dev->usb->xcvrdiag);
+ if (dev->pdev->vendor == 0x17cc)
+ writel(0, &dev->usb->xcvrdiag);
device_remove_file (&dev->pdev->dev, &dev_attr_function);
device_remove_file (&dev->pdev->dev, &dev_attr_queues);
@@ -2219,6 +2724,350 @@ get_ep_by_addr (struct net2280 *dev, u16 wIndex)
return NULL;
}
+static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
+{
+ u32 scratch, fsmvalue;
+ u32 ack_wait_timeout, state;
+
+ /* Workaround for Defect 7374 (U1/U2 erroneously rejected): */
+ scratch = get_idx_reg(dev->regs, SCRATCH);
+ fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
+ scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
+
+ if (!((fsmvalue == DEFECT7374_FSM_WAITING_FOR_CONTROL_READ) &&
+ (r.bRequestType & USB_DIR_IN)))
+ return;
+
+ /* This is the first Control Read for this connection: */
+ if (!(readl(&dev->usb->usbstat) & (1 << SUPER_SPEED_MODE))) {
+ /*
+ * Connection is NOT SS:
+ * - Connection must be FS or HS.
+ * - This FSM state should allow workaround software to
+ * run after the next USB connection.
+ */
+ scratch |= DEFECT7374_FSM_NON_SS_CONTROL_READ;
+ goto restore_data_eps;
+ }
+
+ /* Connection is SS: */
+ for (ack_wait_timeout = 0;
+ ack_wait_timeout < DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS;
+ ack_wait_timeout++) {
+
+ state = readl(&dev->plregs->pl_ep_status_1)
+ & (0xff << STATE);
+ if ((state >= (ACK_GOOD_NORMAL << STATE)) &&
+ (state <= (ACK_GOOD_MORE_ACKS_TO_COME << STATE))) {
+ scratch |= DEFECT7374_FSM_SS_CONTROL_READ;
+ break;
+ }
+
+ /*
+ * We have not yet received host's Data Phase ACK
+ * - Wait and try again.
+ */
+ udelay(DEFECT_7374_PROCESSOR_WAIT_TIME);
+
+ continue;
+ }
+
+
+ if (ack_wait_timeout >= DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS) {
+ ERROR(dev, "FAIL: Defect 7374 workaround waited but failed "
+ "to detect SS host's data phase ACK.");
+ ERROR(dev, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16"
+ "got 0x%2.2x.\n", state >> STATE);
+ } else {
+ WARNING(dev, "INFO: Defect 7374 workaround waited about\n"
+ "%duSec for Control Read Data Phase ACK\n",
+ DEFECT_7374_PROCESSOR_WAIT_TIME * ack_wait_timeout);
+ }
+
+restore_data_eps:
+ /*
+ * Restore data EPs to their pre-workaround settings (disabled,
+ * initialized, and other details).
+ */
+ defect7374_disable_data_eps(dev);
+
+ set_idx_reg(dev->regs, SCRATCH, scratch);
+
+ return;
+}
+
+static void ep_stall(struct net2280_ep *ep, int stall)
+{
+ struct net2280 *dev = ep->dev;
+ u32 val;
+ static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
+
+ if (stall) {
+ writel((1 << SET_ENDPOINT_HALT) |
+ /* (1 << SET_NAK_PACKETS) | */
+ (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
+ &ep->regs->ep_rsp);
+ ep->is_halt = 1;
+ } else {
+ if (dev->gadget.speed == USB_SPEED_SUPER) {
+ /*
+ * Workaround for SS SeqNum not cleared via
+ * Endpoint Halt (Clear) bit. select endpoint
+ */
+ val = readl(&dev->plregs->pl_ep_ctrl);
+ val = (val & ~0x1f) | ep_pl[ep->num];
+ writel(val, &dev->plregs->pl_ep_ctrl);
+
+ val |= (1 << SEQUENCE_NUMBER_RESET);
+ writel(val, &dev->plregs->pl_ep_ctrl);
+ }
+ val = readl(&ep->regs->ep_rsp);
+ val |= (1 << CLEAR_ENDPOINT_HALT) |
+ (1 << CLEAR_ENDPOINT_TOGGLE);
+ writel(val
+ /* | (1 << CLEAR_NAK_PACKETS)*/
+ , &ep->regs->ep_rsp);
+ ep->is_halt = 0;
+ val = readl(&ep->regs->ep_rsp);
+ }
+}
+
+static void ep_stdrsp(struct net2280_ep *ep, int value, int wedged)
+{
+ /* set/clear, then synch memory views with the device */
+ if (value) {
+ ep->stopped = 1;
+ if (ep->num == 0)
+ ep->dev->protocol_stall = 1;
+ else {
+ if (ep->dma)
+ ep_stop_dma(ep);
+ ep_stall(ep, true);
+ }
+
+ if (wedged)
+ ep->wedged = 1;
+ } else {
+ ep->stopped = 0;
+ ep->wedged = 0;
+
+ ep_stall(ep, false);
+
+ /* Flush the queue */
+ if (!list_empty(&ep->queue)) {
+ struct net2280_request *req =
+ list_entry(ep->queue.next, struct net2280_request,
+ queue);
+ if (ep->dma)
+ resume_dma(ep);
+ else {
+ if (ep->is_in)
+ write_fifo(ep, &req->req);
+ else {
+ if (read_fifo(ep, req))
+ done(ep, req, 0);
+ }
+ }
+ }
+ }
+}
+
+static void handle_stat0_irqs_superspeed(struct net2280 *dev,
+ struct net2280_ep *ep, struct usb_ctrlrequest r)
+{
+ int tmp = 0;
+
+#define w_value le16_to_cpu(r.wValue)
+#define w_index le16_to_cpu(r.wIndex)
+#define w_length le16_to_cpu(r.wLength)
+
+ switch (r.bRequest) {
+ struct net2280_ep *e;
+ u16 status;
+
+ case USB_REQ_SET_CONFIGURATION:
+ dev->addressed_state = !w_value;
+ goto usb3_delegate;
+
+ case USB_REQ_GET_STATUS:
+ switch (r.bRequestType) {
+ case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
+ status = dev->wakeup_enable ? 0x02 : 0x00;
+ if (dev->selfpowered)
+ status |= 1 << 0;
+ status |= (dev->u1_enable << 2 | dev->u2_enable << 3 |
+ dev->ltm_enable << 4);
+ writel(0, &dev->epregs[0].ep_irqenb);
+ set_fifo_bytecount(ep, sizeof(status));
+ writel((__force u32) status, &dev->epregs[0].ep_data);
+ allow_status_338x(ep);
+ break;
+
+ case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
+ e = get_ep_by_addr(dev, w_index);
+ if (!e)
+ goto do_stall3;
+ status = readl(&e->regs->ep_rsp) &
+ (1 << CLEAR_ENDPOINT_HALT);
+ writel(0, &dev->epregs[0].ep_irqenb);
+ set_fifo_bytecount(ep, sizeof(status));
+ writel((__force u32) status, &dev->epregs[0].ep_data);
+ allow_status_338x(ep);
+ break;
+
+ default:
+ goto usb3_delegate;
+ }
+ break;
+
+ case USB_REQ_CLEAR_FEATURE:
+ switch (r.bRequestType) {
+ case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
+ if (!dev->addressed_state) {
+ switch (w_value) {
+ case USB_DEVICE_U1_ENABLE:
+ dev->u1_enable = 0;
+ writel(readl(&dev->usb_ext->usbctl2) &
+ ~(1 << U1_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+
+ case USB_DEVICE_U2_ENABLE:
+ dev->u2_enable = 0;
+ writel(readl(&dev->usb_ext->usbctl2) &
+ ~(1 << U2_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+
+ case USB_DEVICE_LTM_ENABLE:
+ dev->ltm_enable = 0;
+ writel(readl(&dev->usb_ext->usbctl2) &
+ ~(1 << LTM_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+
+ default:
+ break;
+ }
+ }
+ if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
+ dev->wakeup_enable = 0;
+ writel(readl(&dev->usb->usbctl) &
+ ~(1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ &dev->usb->usbctl);
+ allow_status_338x(ep);
+ break;
+ }
+ goto usb3_delegate;
+
+ case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
+ e = get_ep_by_addr(dev, w_index);
+ if (!e)
+ goto do_stall3;
+ if (w_value != USB_ENDPOINT_HALT)
+ goto do_stall3;
+ VDEBUG(dev, "%s clear halt\n", e->ep.name);
+ ep_stall(e, false);
+ if (!list_empty(&e->queue) && e->td_dma)
+ restart_dma(e);
+ allow_status(ep);
+ ep->stopped = 1;
+ break;
+
+ default:
+ goto usb3_delegate;
+ }
+ break;
+ case USB_REQ_SET_FEATURE:
+ switch (r.bRequestType) {
+ case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
+ if (!dev->addressed_state) {
+ switch (w_value) {
+ case USB_DEVICE_U1_ENABLE:
+ dev->u1_enable = 1;
+ writel(readl(&dev->usb_ext->usbctl2) |
+ (1 << U1_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+
+ case USB_DEVICE_U2_ENABLE:
+ dev->u2_enable = 1;
+ writel(readl(&dev->usb_ext->usbctl2) |
+ (1 << U2_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+
+ case USB_DEVICE_LTM_ENABLE:
+ dev->ltm_enable = 1;
+ writel(readl(&dev->usb_ext->usbctl2) |
+ (1 << LTM_ENABLE),
+ &dev->usb_ext->usbctl2);
+ allow_status_338x(ep);
+ goto next_endpoints3;
+ default:
+ break;
+ }
+ }
+
+ if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
+ dev->wakeup_enable = 1;
+ writel(readl(&dev->usb->usbctl) |
+ (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ &dev->usb->usbctl);
+ allow_status_338x(ep);
+ break;
+ }
+ goto usb3_delegate;
+
+ case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
+ e = get_ep_by_addr(dev, w_index);
+ if (!e || (w_value != USB_ENDPOINT_HALT))
+ goto do_stall3;
+ ep_stdrsp(e, true, false);
+ allow_status_338x(ep);
+ break;
+
+ default:
+ goto usb3_delegate;
+ }
+
+ break;
+ default:
+
+usb3_delegate:
+ VDEBUG(dev, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
+ r.bRequestType, r.bRequest,
+ w_value, w_index, w_length,
+ readl(&ep->cfg->ep_cfg));
+
+ ep->responded = 0;
+ spin_unlock(&dev->lock);
+ tmp = dev->driver->setup(&dev->gadget, &r);
+ spin_lock(&dev->lock);
+ }
+do_stall3:
+ if (tmp < 0) {
+ VDEBUG(dev, "req %02x.%02x protocol STALL; stat %d\n",
+ r.bRequestType, r.bRequest, tmp);
+ dev->protocol_stall = 1;
+ /* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
+ ep_stall(ep, true);
+ }
+
+next_endpoints3:
+
+#undef w_value
+#undef w_index
+#undef w_length
+
+ return;
+}
+
static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
{
struct net2280_ep *ep;
@@ -2240,10 +3089,20 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
struct net2280_request *req;
if (dev->gadget.speed == USB_SPEED_UNKNOWN) {
- if (readl (&dev->usb->usbstat) & (1 << HIGH_SPEED))
+ u32 val = readl(&dev->usb->usbstat);
+ if (val & (1 << SUPER_SPEED)) {
+ dev->gadget.speed = USB_SPEED_SUPER;
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
+ EP0_SS_MAX_PACKET_SIZE);
+ } else if (val & (1 << HIGH_SPEED)) {
dev->gadget.speed = USB_SPEED_HIGH;
- else
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
+ EP0_HS_MAX_PACKET_SIZE);
+ } else {
dev->gadget.speed = USB_SPEED_FULL;
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
+ EP0_HS_MAX_PACKET_SIZE);
+ }
net2280_led_speed (dev, dev->gadget.speed);
DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed));
}
@@ -2261,32 +3120,38 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
}
ep->stopped = 0;
dev->protocol_stall = 0;
-
- if (ep->dev->pdev->device == 0x2280)
- tmp = (1 << FIFO_OVERFLOW)
- | (1 << FIFO_UNDERFLOW);
- else
- tmp = 0;
-
- writel (tmp | (1 << TIMEOUT)
- | (1 << USB_STALL_SENT)
- | (1 << USB_IN_NAK_SENT)
- | (1 << USB_IN_ACK_RCVD)
- | (1 << USB_OUT_PING_NAK_SENT)
- | (1 << USB_OUT_ACK_SENT)
- | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT)
- | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)
- | (1 << DATA_PACKET_RECEIVED_INTERRUPT)
- | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)
- | (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
- | (1 << DATA_IN_TOKEN_INTERRUPT)
- , &ep->regs->ep_stat);
- u.raw [0] = readl (&dev->usb->setup0123);
- u.raw [1] = readl (&dev->usb->setup4567);
+ if (dev->pdev->vendor == 0x10b5)
+ ep->is_halt = 0;
+ else{
+ if (ep->dev->pdev->device == 0x2280)
+ tmp = (1 << FIFO_OVERFLOW) |
+ (1 << FIFO_UNDERFLOW);
+ else
+ tmp = 0;
+
+ writel(tmp | (1 << TIMEOUT) |
+ (1 << USB_STALL_SENT) |
+ (1 << USB_IN_NAK_SENT) |
+ (1 << USB_IN_ACK_RCVD) |
+ (1 << USB_OUT_PING_NAK_SENT) |
+ (1 << USB_OUT_ACK_SENT) |
+ (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
+ (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
+ (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
+ (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ (1 << DATA_OUT_PING_TOKEN_INTERRUPT) |
+ (1 << DATA_IN_TOKEN_INTERRUPT)
+ , &ep->regs->ep_stat);
+ }
+ u.raw[0] = readl(&dev->usb->setup0123);
+ u.raw[1] = readl(&dev->usb->setup4567);
cpu_to_le32s (&u.raw [0]);
cpu_to_le32s (&u.raw [1]);
+ if (dev->pdev->vendor == 0x10b5)
+ defect7374_workaround(dev, u.r);
+
tmp = 0;
#define w_value le16_to_cpu(u.r.wValue)
@@ -2318,6 +3183,12 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
* everything else goes uplevel to the gadget code.
*/
ep->responded = 1;
+
+ if (dev->gadget.speed == USB_SPEED_SUPER) {
+ handle_stat0_irqs_superspeed(dev, ep, u.r);
+ goto next_endpoints;
+ }
+
switch (u.r.bRequest) {
case USB_REQ_GET_STATUS: {
struct net2280_ep *e;
@@ -2360,8 +3231,11 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
VDEBUG(dev, "%s wedged, halt not cleared\n",
ep->ep.name);
} else {
- VDEBUG(dev, "%s clear halt\n", ep->ep.name);
+ VDEBUG(dev, "%s clear halt\n", e->ep.name);
clear_halt(e);
+ if (ep->dev->pdev->vendor == 0x10b5 &&
+ !list_empty(&e->queue) && e->td_dma)
+ restart_dma(e);
}
allow_status (ep);
goto next_endpoints;
@@ -2381,6 +3255,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
if (e->ep.name == ep0name)
goto do_stall;
set_halt (e);
+ if (dev->pdev->vendor == 0x10b5 && e->dma)
+ abort_dma(e);
allow_status (ep);
VDEBUG (dev, "%s set halt\n", ep->ep.name);
goto next_endpoints;
@@ -2392,7 +3268,7 @@ delegate:
"ep_cfg %08x\n",
u.r.bRequestType, u.r.bRequest,
w_value, w_index, w_length,
- readl (&ep->regs->ep_cfg));
+ readl(&ep->cfg->ep_cfg));
ep->responded = 0;
spin_unlock (&dev->lock);
tmp = dev->driver->setup (&dev->gadget, &u.r);
@@ -2455,7 +3331,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
/* after disconnect there's nothing else to do! */
tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT);
- mask = (1 << HIGH_SPEED) | (1 << FULL_SPEED);
+ mask = (1 << SUPER_SPEED) | (1 << HIGH_SPEED) | (1 << FULL_SPEED);
/* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
* Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
@@ -2546,12 +3422,19 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
tmp = readl (&dma->dmastat);
writel (tmp, &dma->dmastat);
+ /* dma sync*/
+ if (dev->pdev->vendor == 0x10b5) {
+ u32 r_dmacount = readl(&dma->dmacount);
+ if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
+ (tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT)))
+ continue;
+ }
+
/* chaining should stop on abort, short OUT from fifo,
* or (stat0 codepath) short OUT transfer.
*/
if (!use_dma_chaining) {
- if ((tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))
- == 0) {
+ if (!(tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))) {
DEBUG (ep->dev, "%s no xact done? %08x\n",
ep->ep.name, tmp);
continue;
@@ -2625,7 +3508,8 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
struct net2280 *dev = _dev;
/* shared interrupt, not ours */
- if (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED)))
+ if (dev->pdev->vendor == 0x17cc &&
+ (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))))
return IRQ_NONE;
spin_lock (&dev->lock);
@@ -2636,6 +3520,13 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
/* control requests and PIO */
handle_stat0_irqs (dev, readl (&dev->regs->irqstat0));
+ if (dev->pdev->vendor == 0x10b5) {
+ /* re-enable interrupt to trigger any possible new interrupt */
+ u32 pciirqenb1 = readl(&dev->regs->pciirqenb1);
+ writel(pciirqenb1 & 0x7FFFFFFF, &dev->regs->pciirqenb1);
+ writel(pciirqenb1, &dev->regs->pciirqenb1);
+ }
+
spin_unlock (&dev->lock);
return IRQ_HANDLED;
@@ -2674,6 +3565,8 @@ static void net2280_remove (struct pci_dev *pdev)
}
if (dev->got_irq)
free_irq (pdev->irq, dev);
+ if (use_msi && dev->pdev->vendor == 0x10b5)
+ pci_disable_msi(pdev);
if (dev->regs)
iounmap (dev->regs);
if (dev->region)
@@ -2708,7 +3601,8 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
spin_lock_init (&dev->lock);
dev->pdev = pdev;
dev->gadget.ops = &net2280_ops;
- dev->gadget.max_speed = USB_SPEED_HIGH;
+ dev->gadget.max_speed = (dev->pdev->vendor == 0x10b5) ?
+ USB_SPEED_SUPER : USB_SPEED_HIGH;
/* the "gadget" abstracts/virtualizes the controller */
dev->gadget.name = driver_name;
@@ -2750,8 +3644,39 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200);
dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300);
- /* put into initial config, link up all endpoints */
- writel (0, &dev->usb->usbctl);
+ if (dev->pdev->vendor == 0x10b5) {
+ u32 fsmvalue;
+ u32 usbstat;
+ dev->usb_ext = (struct usb338x_usb_ext_regs __iomem *)
+ (base + 0x00b4);
+ dev->fiforegs = (struct usb338x_fifo_regs __iomem *)
+ (base + 0x0500);
+ dev->llregs = (struct usb338x_ll_regs __iomem *)
+ (base + 0x0700);
+ dev->ll_lfps_regs = (struct usb338x_ll_lfps_regs __iomem *)
+ (base + 0x0748);
+ dev->ll_tsn_regs = (struct usb338x_ll_tsn_regs __iomem *)
+ (base + 0x077c);
+ dev->ll_chicken_reg = (struct usb338x_ll_chi_regs __iomem *)
+ (base + 0x079c);
+ dev->plregs = (struct usb338x_pl_regs __iomem *)
+ (base + 0x0800);
+ usbstat = readl(&dev->usb->usbstat);
+ dev->enhanced_mode = (usbstat & (1 << 11)) ? 1 : 0;
+ dev->n_ep = (dev->enhanced_mode) ? 9 : 5;
+ /* put into initial config, link up all endpoints */
+ fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
+ (0xf << DEFECT7374_FSM_FIELD);
+ /* See if firmware needs to set up for workaround: */
+ if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ)
+ writel(0, &dev->usb->usbctl);
+ } else{
+ dev->enhanced_mode = 0;
+ dev->n_ep = 7;
+ /* put into initial config, link up all endpoints */
+ writel(0, &dev->usb->usbctl);
+ }
+
usb_reset (dev);
usb_reinit (dev);
@@ -2762,6 +3687,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
goto done;
}
+ if (use_msi && dev->pdev->vendor == 0x10b5)
+ if (pci_enable_msi(pdev))
+ ERROR(dev, "Failed to enable MSI mode\n");
+
if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev)
!= 0) {
ERROR (dev, "request interrupt %d failed\n", pdev->irq);
@@ -2797,7 +3726,8 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
}
/* enable lower-overhead pci memory bursts during DMA */
- writel ( (1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
+ if (dev->pdev->vendor == 0x17cc)
+ writel((1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
// 256 write retries may not be enough...
// | (1 << PCI_RETRY_ABORT_ENABLE)
| (1 << DMA_READ_MULTIPLE_ENABLE)
@@ -2814,10 +3744,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
INFO (dev, "%s\n", driver_desc);
INFO (dev, "irq %d, pci mem %p, chip rev %04x\n",
pdev->irq, base, dev->chiprev);
- INFO (dev, "version: " DRIVER_VERSION "; dma %s\n",
- use_dma
- ? (use_dma_chaining ? "chaining" : "enabled")
- : "disabled");
+ INFO(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
+ use_dma ? (use_dma_chaining ? "chaining" : "enabled")
+ : "disabled",
+ dev->enhanced_mode ? "enhanced mode" : "legacy mode");
retval = device_create_file (&pdev->dev, &dev_attr_registers);
if (retval) goto done;
@@ -2849,7 +3779,8 @@ static void net2280_shutdown (struct pci_dev *pdev)
writel (0, &dev->usb->usbctl);
/* Disable full-speed test mode */
- writel(0, &dev->usb->xcvrdiag);
+ if (dev->pdev->vendor == 0x17cc)
+ writel(0, &dev->usb->xcvrdiag);
}
@@ -2869,8 +3800,24 @@ static const struct pci_device_id pci_ids [] = { {
.device = 0x2282,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
-
-}, { /* end: all zeroes */ }
+},
+ {
+ .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
+ .class_mask = ~0,
+ .vendor = 0x10b5,
+ .device = 0x3380,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ },
+ {
+ .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
+ .class_mask = ~0,
+ .vendor = 0x10b5,
+ .device = 0x3382,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ },
+{ /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE (pci, pci_ids);
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index a844be0..a257516 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -6,6 +6,7 @@
/*
* Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
* Copyright (C) 2003 David Brownell
+ * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,6 +15,7 @@
*/
#include <linux/usb/net2280.h>
+#include <linux/usb/usb338x.h>
/*-------------------------------------------------------------------------*/
@@ -59,13 +61,14 @@ set_idx_reg (struct net2280_regs __iomem *regs, u32 index, u32 value)
#define CHIPREV_1 0x0100
#define CHIPREV_1A 0x0110
-#ifdef __KERNEL__
+/* DEFECT 7374 */
+#define DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS 200
+#define DEFECT_7374_PROCESSOR_WAIT_TIME 10
-/* ep a-f highspeed and fullspeed maxpacket, addresses
- * computed from ep->num
- */
-#define REG_EP_MAXPKT(dev,num) (((num) + 1) * 0x10 + \
- (((dev)->gadget.speed == USB_SPEED_HIGH) ? 0 : 1))
+/* ep0 max packet size */
+#define EP0_SS_MAX_PACKET_SIZE 0x200
+#define EP0_HS_MAX_PACKET_SIZE 0x40
+#ifdef __KERNEL__
/*-------------------------------------------------------------------------*/
@@ -85,12 +88,15 @@ struct net2280_dma {
struct net2280_ep {
struct usb_ep ep;
+ struct net2280_ep_regs __iomem *cfg;
struct net2280_ep_regs __iomem *regs;
struct net2280_dma_regs __iomem *dma;
struct net2280_dma *dummy;
+ struct usb338x_fifo_regs __iomem *fiforegs;
dma_addr_t td_dma; /* of dummy */
struct net2280 *dev;
unsigned long irqs;
+ unsigned is_halt:1, dma_started:1;
/* analogous to a host-side qh */
struct list_head queue;
@@ -116,10 +122,19 @@ static inline void allow_status (struct net2280_ep *ep)
ep->stopped = 1;
}
-/* count (<= 4) bytes in the next fifo write will be valid */
-static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count)
+static void allow_status_338x(struct net2280_ep *ep)
{
- writeb (count, 2 + (u8 __iomem *) &ep->regs->ep_cfg);
+ /*
+ * Control Status Phase Handshake was set by the chip when the setup
+ * packet arrived. While set, the chip automatically NAKs the host's
+ * Status Phase tokens.
+ */
+ writel(1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE, &ep->regs->ep_rsp);
+
+ ep->stopped = 1;
+
+ /* TD 9.9 Halt Endpoint test. TD 9.22 set feature test. */
+ ep->responded = 0;
}
struct net2280_request {
@@ -135,23 +150,38 @@ struct net2280 {
/* each pci device provides one gadget, several endpoints */
struct usb_gadget gadget;
spinlock_t lock;
- struct net2280_ep ep [7];
+ struct net2280_ep ep[9];
struct usb_gadget_driver *driver;
unsigned enabled : 1,
protocol_stall : 1,
softconnect : 1,
got_irq : 1,
- region : 1;
+ region:1,
+ u1_enable:1,
+ u2_enable:1,
+ ltm_enable:1,
+ wakeup_enable:1,
+ selfpowered:1,
+ addressed_state:1;
u16 chiprev;
+ int enhanced_mode;
+ int n_ep;
/* pci state used to access those endpoints */
struct pci_dev *pdev;
struct net2280_regs __iomem *regs;
struct net2280_usb_regs __iomem *usb;
+ struct usb338x_usb_ext_regs __iomem *usb_ext;
struct net2280_pci_regs __iomem *pci;
struct net2280_dma_regs __iomem *dma;
struct net2280_dep_regs __iomem *dep;
struct net2280_ep_regs __iomem *epregs;
+ struct usb338x_fifo_regs __iomem *fiforegs;
+ struct usb338x_ll_regs __iomem *llregs;
+ struct usb338x_ll_lfps_regs __iomem *ll_lfps_regs;
+ struct usb338x_ll_tsn_regs __iomem *ll_tsn_regs;
+ struct usb338x_ll_chi_regs __iomem *ll_chicken_reg;
+ struct usb338x_pl_regs __iomem *plregs;
struct pci_pool *requests;
// statistics...
@@ -179,6 +209,43 @@ static inline void clear_halt (struct net2280_ep *ep)
, &ep->regs->ep_rsp);
}
+/*
+ * FSM value for Defect 7374 (U1U2 Test) is managed in
+ * chip's SCRATCH register:
+ */
+#define DEFECT7374_FSM_FIELD 28
+
+/* Waiting for Control Read:
+ * - A transition to this state indicates a fresh USB connection,
+ * before the first Setup Packet. The connection speed is not
+ * known. Firmware is waiting for the first Control Read.
+ * - Starting state: This state can be thought of as the FSM's typical
+ * starting state.
+ * - Tip: Upon the first SS Control Read the FSM never
+ * returns to this state.
+ */
+#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ (1 << DEFECT7374_FSM_FIELD)
+
+/* Non-SS Control Read:
+ * - A transition to this state indicates detection of the first HS
+ * or FS Control Read.
+ * - Tip: Upon the first SS Control Read the FSM never
+ * returns to this state.
+ */
+#define DEFECT7374_FSM_NON_SS_CONTROL_READ (2 << DEFECT7374_FSM_FIELD)
+
+/* SS Control Read:
+ * - A transition to this state indicates detection of the
+ * first SS Control Read.
+ * - This state indicates workaround completion. Workarounds no longer
+ * need to be applied (as long as the chip remains powered up).
+ * - Tip: Once in this state the FSM state does not change (until
+ * the chip's power is lost and restored).
+ * - This can be thought of as the final state of the FSM;
+ * the FSM 'locks-up' in this state until the chip loses power.
+ */
+#define DEFECT7374_FSM_SS_CONTROL_READ (3 << DEFECT7374_FSM_FIELD)
+
#ifdef USE_RDK_LEDS
static inline void net2280_led_init (struct net2280 *dev)
@@ -198,6 +265,9 @@ void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
{
u32 val = readl (&dev->regs->gpioctl);
switch (speed) {
+ case USB_SPEED_SUPER: /* green + red */
+ val |= (1 << GPIO0_DATA) | (1 << GPIO1_DATA);
+ break;
case USB_SPEED_HIGH: /* green */
val &= ~(1 << GPIO0_DATA);
val |= (1 << GPIO1_DATA);
@@ -271,6 +341,17 @@ static inline void net2280_led_shutdown (struct net2280 *dev)
/*-------------------------------------------------------------------------*/
+static inline void set_fifo_bytecount(struct net2280_ep *ep, unsigned count)
+{
+ if (ep->dev->pdev->vendor == 0x17cc)
+ writeb(count, 2 + (u8 __iomem *) &ep->regs->ep_cfg);
+ else{
+ u32 tmp = readl(&ep->cfg->ep_cfg) &
+ (~(0x07 << EP_FIFO_BYTE_COUNT));
+ writel(tmp | (count << EP_FIFO_BYTE_COUNT), &ep->cfg->ep_cfg);
+ }
+}
+
static inline void start_out_naking (struct net2280_ep *ep)
{
/* NOTE: hardware races lurk here, and PING protocol issues */
@@ -305,4 +386,22 @@ static inline void stop_out_naking (struct net2280_ep *ep)
writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
}
+
+static inline void set_max_speed(struct net2280_ep *ep, u32 max)
+{
+ u32 reg;
+ static const u32 ep_enhanced[9] = { 0x10, 0x60, 0x30, 0x80,
+ 0x50, 0x20, 0x70, 0x40, 0x90 };
+
+ if (ep->dev->enhanced_mode)
+ reg = ep_enhanced[ep->num];
+ else{
+ reg = (ep->num + 1) * 0x10;
+ if (ep->dev->gadget.speed != USB_SPEED_HIGH)
+ reg += 1;
+ }
+
+ set_idx_reg(ep->dev->regs, reg, max);
+}
+
#endif /* __KERNEL__ */
diff --git a/include/linux/usb/usb338x.h b/include/linux/usb/usb338x.h
new file mode 100644
index 0000000..f92eb63
--- /dev/null
+++ b/include/linux/usb/usb338x.h
@@ -0,0 +1,199 @@
+/*
+ * USB 338x super/high/full speed USB device controller.
+ * Unlike many such controllers, this one talks PCI.
+ *
+ * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
+ * Copyright (C) 2003 David Brownell
+ * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __LINUX_USB_USB338X_H
+#define __LINUX_USB_USB338X_H
+
+#include <linux/usb/net2280.h>
+
+/*
+ * Extra defined bits for net2280 registers
+ */
+#define SCRATCH 0x0b
+
+#define DEFECT7374_FSM_FIELD 28
+#define SUPER_SPEED 8
+#define DMA_REQUEST_OUTSTANDING 5
+#define DMA_PAUSE_DONE_INTERRUPT 26
+#define SET_ISOCHRONOUS_DELAY 24
+#define SET_SEL 22
+#define SUPER_SPEED_MODE 8
+
+/*ep_cfg*/
+#define MAX_BURST_SIZE 24
+#define EP_FIFO_BYTE_COUNT 16
+#define IN_ENDPOINT_ENABLE 14
+#define IN_ENDPOINT_TYPE 12
+#define OUT_ENDPOINT_ENABLE 10
+#define OUT_ENDPOINT_TYPE 8
+
+struct usb338x_usb_ext_regs {
+ u32 usbclass;
+#define DEVICE_PROTOCOL 16
+#define DEVICE_SUB_CLASS 8
+#define DEVICE_CLASS 0
+ u32 ss_sel;
+#define U2_SYSTEM_EXIT_LATENCY 8
+#define U1_SYSTEM_EXIT_LATENCY 0
+ u32 ss_del;
+#define U2_DEVICE_EXIT_LATENCY 8
+#define U1_DEVICE_EXIT_LATENCY 0
+ u32 usb2lpm;
+#define USB_L1_LPM_HIRD 2
+#define USB_L1_LPM_REMOTE_WAKE 1
+#define USB_L1_LPM_SUPPORT 0
+ u32 usb3belt;
+#define BELT_MULTIPLIER 10
+#define BEST_EFFORT_LATENCY_TOLERANCE 0
+ u32 usbctl2;
+#define LTM_ENABLE 7
+#define U2_ENABLE 6
+#define U1_ENABLE 5
+#define FUNCTION_SUSPEND 4
+#define USB3_CORE_ENABLE 3
+#define USB2_CORE_ENABLE 2
+#define SERIAL_NUMBER_STRING_ENABLE 0
+ u32 in_timeout;
+#define GPEP3_TIMEOUT 19
+#define GPEP2_TIMEOUT 18
+#define GPEP1_TIMEOUT 17
+#define GPEP0_TIMEOUT 16
+#define GPEP3_TIMEOUT_VALUE 13
+#define GPEP3_TIMEOUT_ENABLE 12
+#define GPEP2_TIMEOUT_VALUE 9
+#define GPEP2_TIMEOUT_ENABLE 8
+#define GPEP1_TIMEOUT_VALUE 5
+#define GPEP1_TIMEOUT_ENABLE 4
+#define GPEP0_TIMEOUT_VALUE 1
+#define GPEP0_TIMEOUT_ENABLE 0
+ u32 isodelay;
+#define ISOCHRONOUS_DELAY 0
+} __packed;
+
+struct usb338x_fifo_regs {
+ /* offset 0x0500, 0x0520, 0x0540, 0x0560, 0x0580 */
+ u32 ep_fifo_size_base;
+#define IN_FIFO_BASE_ADDRESS 22
+#define IN_FIFO_SIZE 16
+#define OUT_FIFO_BASE_ADDRESS 6
+#define OUT_FIFO_SIZE 0
+ u32 ep_fifo_out_wrptr;
+ u32 ep_fifo_out_rdptr;
+ u32 ep_fifo_in_wrptr;
+ u32 ep_fifo_in_rdptr;
+ u32 unused[3];
+} __packed;
+
+
+/* Link layer */
+struct usb338x_ll_regs {
+ /* offset 0x700 */
+ u32 ll_ltssm_ctrl1;
+ u32 ll_ltssm_ctrl2;
+ u32 ll_ltssm_ctrl3;
+ u32 unused[2];
+ u32 ll_general_ctrl0;
+ u32 ll_general_ctrl1;
+#define PM_U3_AUTO_EXIT 29
+#define PM_U2_AUTO_EXIT 28
+#define PM_U1_AUTO_EXIT 27
+#define PM_FORCE_U2_ENTRY 26
+#define PM_FORCE_U1_ENTRY 25
+#define PM_LGO_COLLISION_SEND_LAU 24
+#define PM_DIR_LINK_REJECT 23
+#define PM_FORCE_LINK_ACCEPT 22
+#define PM_DIR_ENTRY_U3 20
+#define PM_DIR_ENTRY_U2 19
+#define PM_DIR_ENTRY_U1 18
+#define PM_U2_ENABLE 17
+#define PM_U1_ENABLE 16
+#define SKP_THRESHOLD_ADJUST_FMW 8
+#define RESEND_DPP_ON_LRTY_FMW 7
+#define DL_BIT_VALUE_FMW 6
+#define FORCE_DL_BIT 5
+ u32 ll_general_ctrl2;
+#define SELECT_INVERT_LANE_POLARITY 7
+#define FORCE_INVERT_LANE_POLARITY 6
+ u32 ll_general_ctrl3;
+ u32 ll_general_ctrl4;
+ u32 ll_error_gen;
+} __packed;
+
+struct usb338x_ll_lfps_regs {
+ /* offset 0x748 */
+ u32 ll_lfps_5;
+#define TIMER_LFPS_6US 16
+ u32 ll_lfps_6;
+#define TIMER_LFPS_80US 0
+} __packed;
+
+struct usb338x_ll_tsn_regs {
+ /* offset 0x77C */
+ u32 ll_tsn_counters_2;
+#define HOT_TX_NORESET_TS2 24
+ u32 ll_tsn_counters_3;
+#define HOT_RX_RESET_TS2 0
+} __packed;
+
+struct usb338x_ll_chi_regs {
+ /* offset 0x79C */
+ u32 ll_tsn_chicken_bit;
+#define RECOVERY_IDLE_TO_RECOVER_FMW 3
+} __packed;
+
+/* protocol layer */
+struct usb338x_pl_regs {
+ /* offset 0x800 */
+ u32 pl_reg_1;
+ u32 pl_reg_2;
+ u32 pl_reg_3;
+ u32 pl_reg_4;
+ u32 pl_ep_ctrl;
+ /* Protocol Layer Endpoint Control*/
+#define PL_EP_CTRL 0x810
+#define ENDPOINT_SELECT 0
+ /* [4:0] */
+#define EP_INITIALIZED 16
+#define SEQUENCE_NUMBER_RESET 17
+#define CLEAR_ACK_ERROR_CODE 20
+ u32 pl_reg_6;
+ u32 pl_reg_7;
+ u32 pl_reg_8;
+ u32 pl_ep_status_1;
+ /* Protocol Layer Endpoint Status 1*/
+#define PL_EP_STATUS_1 0x820
+#define STATE 16
+#define ACK_GOOD_NORMAL 0x11
+#define ACK_GOOD_MORE_ACKS_TO_COME 0x16
+ u32 pl_ep_status_2;
+ u32 pl_ep_status_3;
+ /* Protocol Layer Endpoint Status 3*/
+#define PL_EP_STATUS_3 0x828
+#define SEQUENCE_NUMBER 0
+ u32 pl_ep_status_4;
+ /* Protocol Layer Endpoint Status 4*/
+#define PL_EP_STATUS_4 0x82c
+ u32 pl_ep_cfg_4;
+ /* Protocol Layer Endpoint Configuration 4*/
+#define PL_EP_CFG_4 0x830
+#define NON_CTRL_IN_TOLERATE_BAD_DIR 6
+} __packed;
+
+#endif /* __LINUX_USB_USB338X_H */
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/10] usb: gadget: net2280: Dont use magic numbers
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 01/10 v5.1] usb: gadget: net2280: Add support for PLX USB338X Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 03/10] usb: gadget: net2280: Use BIT() macro Ricardo Ribalda Delgado
` (8 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Instead of using magic numbers use #defines
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 68 +++++++++++++++++++++++---------------------
drivers/usb/gadget/net2280.h | 1 +
2 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 8112d91..ba1fdd8 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -152,7 +152,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
{
u32 tmp = readl(&ep->dev->regs->pciirqenb0);
- if (ep->dev->pdev->vendor == 0x17cc)
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
tmp |= 1 << ep->num;
else
tmp |= 1 << ep_bit[ep->num];
@@ -182,7 +182,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE)
return -EDOM;
- if (dev->pdev->vendor == 0x10b5) {
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
if ((desc->bEndpointAddress & 0x0f) >= 0x0c)
return -EDOM;
ep->is_in = !!usb_endpoint_dir_in(desc);
@@ -192,7 +192,8 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp (desc) & 0x1fff;
- if (ep->num > 4 && max > 64 && (dev->pdev->vendor == 0x17cc))
+ if (ep->num > 4 && max > 64 &&
+ (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY))
return -ERANGE;
spin_lock_irqsave (&dev->lock, flags);
@@ -237,7 +238,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
}
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
/* Enable this endpoint */
- if (dev->pdev->vendor == 0x17cc) {
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) {
tmp <<= ENDPOINT_TYPE;
tmp |= desc->bEndpointAddress;
/* default full fifo lines */
@@ -472,7 +473,7 @@ static int net2280_disable (struct usb_ep *_ep)
spin_lock_irqsave (&ep->dev->lock, flags);
nuke (ep);
- if (ep->dev->pdev->vendor == 0x10b5)
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
ep_reset_338x(ep->dev->regs, ep);
else
ep_reset_228x(ep->dev->regs, ep);
@@ -799,7 +800,7 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
writel (readl (&dma->dmastat), &dma->dmastat);
writel (td_dma, &dma->dmadesc);
- if (ep->dev->pdev->vendor == 0x10b5)
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
dmactl |= (0x01 << DMA_REQUEST_OUTSTANDING);
writel (dmactl, &dma->dmactl);
@@ -995,7 +996,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* DMA request while EP halted */
if (ep->dma &&
(readl(&ep->regs->ep_rsp) & (1 << CLEAR_ENDPOINT_HALT)) &&
- (dev->pdev->vendor == 0x10b5)) {
+ (dev->pdev->vendor == PCI_VENDOR_ID_PLX)) {
int valid = 1;
if (ep->is_in) {
int expect;
@@ -1126,7 +1127,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
} else if (!ep->is_in
&& (req->req.length % ep->ep.maxpacket) != 0) {
tmp = readl (&ep->regs->ep_stat);
- if (ep->dev->pdev->vendor == 0x10b5)
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
/* AVOID TROUBLE HERE by not issuing short reads from
@@ -1234,7 +1235,7 @@ static void abort_dma_338x(struct net2280_ep *ep)
static void abort_dma(struct net2280_ep *ep)
{
- if (ep->dev->pdev->vendor == 0x17cc)
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
return abort_dma_228x(ep);
return abort_dma_338x(ep);
}
@@ -1392,7 +1393,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
ep->wedged = 1;
} else {
clear_halt (ep);
- if (ep->dev->pdev->vendor == 0x10b5 &&
+ if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX &&
!list_empty(&ep->queue) && ep->td_dma)
restart_dma(ep);
ep->wedged = 0;
@@ -2104,7 +2105,7 @@ static void usb_reset_338x(struct net2280 *dev)
static void usb_reset(struct net2280 *dev)
{
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
return usb_reset_228x(dev);
return usb_reset_338x(dev);
}
@@ -2260,7 +2261,7 @@ static void usb_reinit_338x(struct net2280 *dev)
static void usb_reinit(struct net2280 *dev)
{
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
return usb_reinit_228x(dev);
return usb_reinit_338x(dev);
}
@@ -2358,7 +2359,7 @@ static void ep0_start_338x(struct net2280 *dev)
static void ep0_start(struct net2280 *dev)
{
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
return ep0_start_228x(dev);
return ep0_start_338x(dev);
}
@@ -2400,7 +2401,7 @@ static int net2280_start(struct usb_gadget *_gadget,
if (retval) goto err_func;
/* Enable force-full-speed testing mode, if desired */
- if (full_speed && dev->pdev->vendor == 0x17cc)
+ if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag);
/* ... then enable host detection and ep0; and we're ready
@@ -2408,7 +2409,7 @@ static int net2280_start(struct usb_gadget *_gadget,
*/
net2280_led_active (dev, 1);
- if (dev->pdev->vendor == 0x10b5)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
defect7374_enable_data_eps_zero(dev);
ep0_start (dev);
@@ -2471,7 +2472,7 @@ static int net2280_stop(struct usb_gadget *_gadget,
net2280_led_active (dev, 0);
/* Disable full-speed test mode */
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
writel(0, &dev->usb->xcvrdiag);
device_remove_file (&dev->pdev->dev, &dev_attr_function);
@@ -3120,7 +3121,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
}
ep->stopped = 0;
dev->protocol_stall = 0;
- if (dev->pdev->vendor == 0x10b5)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
ep->is_halt = 0;
else{
if (ep->dev->pdev->device == 0x2280)
@@ -3149,7 +3150,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
cpu_to_le32s (&u.raw [0]);
cpu_to_le32s (&u.raw [1]);
- if (dev->pdev->vendor == 0x10b5)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
defect7374_workaround(dev, u.r);
tmp = 0;
@@ -3233,7 +3234,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
} else {
VDEBUG(dev, "%s clear halt\n", e->ep.name);
clear_halt(e);
- if (ep->dev->pdev->vendor == 0x10b5 &&
+ if (ep->dev->pdev->vendor ==
+ PCI_VENDOR_ID_PLX &&
!list_empty(&e->queue) && e->td_dma)
restart_dma(e);
}
@@ -3255,7 +3257,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
if (e->ep.name == ep0name)
goto do_stall;
set_halt (e);
- if (dev->pdev->vendor == 0x10b5 && e->dma)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX && e->dma)
abort_dma(e);
allow_status (ep);
VDEBUG (dev, "%s set halt\n", ep->ep.name);
@@ -3423,7 +3425,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
writel (tmp, &dma->dmastat);
/* dma sync*/
- if (dev->pdev->vendor == 0x10b5) {
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
u32 r_dmacount = readl(&dma->dmacount);
if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
(tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT)))
@@ -3508,7 +3510,7 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
struct net2280 *dev = _dev;
/* shared interrupt, not ours */
- if (dev->pdev->vendor == 0x17cc &&
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY &&
(!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))))
return IRQ_NONE;
@@ -3520,7 +3522,7 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
/* control requests and PIO */
handle_stat0_irqs (dev, readl (&dev->regs->irqstat0));
- if (dev->pdev->vendor == 0x10b5) {
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
/* re-enable interrupt to trigger any possible new interrupt */
u32 pciirqenb1 = readl(&dev->regs->pciirqenb1);
writel(pciirqenb1 & 0x7FFFFFFF, &dev->regs->pciirqenb1);
@@ -3565,7 +3567,7 @@ static void net2280_remove (struct pci_dev *pdev)
}
if (dev->got_irq)
free_irq (pdev->irq, dev);
- if (use_msi && dev->pdev->vendor == 0x10b5)
+ if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
pci_disable_msi(pdev);
if (dev->regs)
iounmap (dev->regs);
@@ -3601,7 +3603,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
spin_lock_init (&dev->lock);
dev->pdev = pdev;
dev->gadget.ops = &net2280_ops;
- dev->gadget.max_speed = (dev->pdev->vendor == 0x10b5) ?
+ dev->gadget.max_speed = (dev->pdev->vendor == PCI_VENDOR_ID_PLX) ?
USB_SPEED_SUPER : USB_SPEED_HIGH;
/* the "gadget" abstracts/virtualizes the controller */
@@ -3644,7 +3646,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200);
dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300);
- if (dev->pdev->vendor == 0x10b5) {
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
u32 fsmvalue;
u32 usbstat;
dev->usb_ext = (struct usb338x_usb_ext_regs __iomem *)
@@ -3687,7 +3689,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
goto done;
}
- if (use_msi && dev->pdev->vendor == 0x10b5)
+ if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
if (pci_enable_msi(pdev))
ERROR(dev, "Failed to enable MSI mode\n");
@@ -3726,7 +3728,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
}
/* enable lower-overhead pci memory bursts during DMA */
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
writel((1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
// 256 write retries may not be enough...
// | (1 << PCI_RETRY_ABORT_ENABLE)
@@ -3779,7 +3781,7 @@ static void net2280_shutdown (struct pci_dev *pdev)
writel (0, &dev->usb->usbctl);
/* Disable full-speed test mode */
- if (dev->pdev->vendor == 0x17cc)
+ if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
writel(0, &dev->usb->xcvrdiag);
}
@@ -3789,14 +3791,14 @@ static void net2280_shutdown (struct pci_dev *pdev)
static const struct pci_device_id pci_ids [] = { {
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
- .vendor = 0x17cc,
+ .vendor = PCI_VENDOR_ID_PLX_LEGACY,
.device = 0x2280,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
}, {
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
- .vendor = 0x17cc,
+ .vendor = PCI_VENDOR_ID_PLX_LEGACY,
.device = 0x2282,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
@@ -3804,7 +3806,7 @@ static const struct pci_device_id pci_ids [] = { {
{
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
- .vendor = 0x10b5,
+ .vendor = PCI_VENDOR_ID_PLX,
.device = 0x3380,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
@@ -3812,7 +3814,7 @@ static const struct pci_device_id pci_ids [] = { {
{
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
- .vendor = 0x10b5,
+ .vendor = PCI_VENDOR_ID_PLX,
.device = 0x3382,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index a257516..30478c8 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -43,6 +43,7 @@ set_idx_reg (struct net2280_regs __iomem *regs, u32 index, u32 value)
#endif /* __KERNEL__ */
+#define PCI_VENDOR_ID_PLX_LEGACY 0x17cc
#define REG_DIAG 0x0
#define RETRY_COUNTER 16
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/10] usb: gadget: net2280: Use BIT() macro
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 01/10 v5.1] usb: gadget: net2280: Add support for PLX USB338X Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 02/10] usb: gadget: net2280: Dont use magic numbers Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 04/10] usb: gadget: net2280: Use true/false instead of 1/0 Ricardo Ribalda Delgado
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Improves readability of the code
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 572 +++++++++++++++++++++----------------------
drivers/usb/gadget/net2280.h | 65 ++---
2 files changed, 318 insertions(+), 319 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index ba1fdd8..5b9368d 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -144,8 +144,8 @@ static char *type_string (u8 bmAttributes)
#include "net2280.h"
-#define valid_bit cpu_to_le32 (1 << VALID_BIT)
-#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE)
+#define valid_bit cpu_to_le32(BIT(VALID_BIT))
+#define dma_done_ie cpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
/*-------------------------------------------------------------------------*/
static inline void enable_pciirqenb(struct net2280_ep *ep)
@@ -153,9 +153,9 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
u32 tmp = readl(&ep->dev->regs->pciirqenb0);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
- tmp |= 1 << ep->num;
+ tmp |= BIT(ep->num);
else
- tmp |= 1 << ep_bit[ep->num];
+ tmp |= BIT(ep_bit[ep->num]);
writel(tmp, &ep->dev->regs->pciirqenb0);
return;
@@ -218,14 +218,14 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
}
/* set type, direction, address; reset fifo counters */
- writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat);
+ writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
if (dev->chiprev == 0100
&& dev->gadget.speed == USB_SPEED_HIGH
&& !(desc->bEndpointAddress & USB_DIR_IN))
- writel ((1 << CLEAR_NAK_OUT_PACKETS_MODE),
+ writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
&ep->regs->ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
/* catch some particularly blatant driver bugs */
@@ -243,18 +243,18 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
tmp |= desc->bEndpointAddress;
/* default full fifo lines */
tmp |= (4 << ENDPOINT_BYTE_COUNT);
- tmp |= 1 << ENDPOINT_ENABLE;
+ tmp |= BIT(ENDPOINT_ENABLE);
ep->is_in = (tmp & USB_DIR_IN) != 0;
} else {
/* In Legacy mode, only OUT endpoints are used */
if (dev->enhanced_mode && ep->is_in) {
tmp <<= IN_ENDPOINT_TYPE;
- tmp |= (1 << IN_ENDPOINT_ENABLE);
+ tmp |= BIT(IN_ENDPOINT_ENABLE);
/* Not applicable to Legacy */
- tmp |= (1 << ENDPOINT_DIRECTION);
+ tmp |= BIT(ENDPOINT_DIRECTION);
} else {
tmp <<= OUT_ENDPOINT_TYPE;
- tmp |= (1 << OUT_ENDPOINT_ENABLE);
+ tmp |= BIT(OUT_ENDPOINT_ENABLE);
tmp |= (ep->is_in << ENDPOINT_DIRECTION);
}
@@ -267,13 +267,13 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* for OUT transfers, block the rx fifo until a read is posted */
if (!ep->is_in)
- writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
+ writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
else if (dev->pdev->device != 0x2280) {
/* Added for 2282, Don't use nak packets on an in endpoint,
* this was ignored on 2280
*/
- writel ((1 << CLEAR_NAK_OUT_PACKETS)
- | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
+ writel(BIT(CLEAR_NAK_OUT_PACKETS) |
+ BIT(CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
}
writel(tmp, &ep->cfg->ep_cfg);
@@ -282,13 +282,13 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
if (!ep->dma) { /* pio, per-packet */
enable_pciirqenb(ep);
- tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE)
- | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
+ tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
+ BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
if (dev->pdev->device == 0x2280)
tmp |= readl (&ep->regs->ep_irqenb);
writel (tmp, &ep->regs->ep_irqenb);
} else { /* dma, per-request */
- tmp = (1 << (8 + ep->num)); /* completion */
+ tmp = BIT((8 + ep->num)); /* completion */
tmp |= readl (&dev->regs->pciirqenb1);
writel (tmp, &dev->regs->pciirqenb1);
@@ -297,7 +297,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
* NOTE erratum 0112 workaround #2
*/
if ((desc->bEndpointAddress & USB_DIR_IN) == 0) {
- tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
+ tmp = BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
writel (tmp, &ep->regs->ep_irqenb);
enable_pciirqenb(ep);
@@ -348,17 +348,17 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
/* disable the dma, irqs, endpoint... */
if (ep->dma) {
writel (0, &ep->dma->dmactl);
- writel ( (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT)
- | (1 << DMA_TRANSACTION_DONE_INTERRUPT)
- | (1 << DMA_ABORT)
- , &ep->dma->dmastat);
+ writel(BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
+ BIT(DMA_TRANSACTION_DONE_INTERRUPT) |
+ BIT(DMA_ABORT),
+ &ep->dma->dmastat);
tmp = readl (®s->pciirqenb0);
- tmp &= ~(1 << ep->num);
+ tmp &= ~BIT(ep->num);
writel (tmp, ®s->pciirqenb0);
} else {
tmp = readl (®s->pciirqenb1);
- tmp &= ~(1 << (8 + ep->num)); /* completion */
+ tmp &= ~BIT((8 + ep->num)); /* completion */
writel (tmp, ®s->pciirqenb1);
}
writel (0, &ep->regs->ep_irqenb);
@@ -367,44 +367,44 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
* packets until the driver queues a read (+note erratum 0112)
*/
if (!ep->is_in || ep->dev->pdev->device == 0x2280) {
- tmp = (1 << SET_NAK_OUT_PACKETS_MODE)
- | (1 << SET_NAK_OUT_PACKETS)
- | (1 << CLEAR_EP_HIDE_STATUS_PHASE)
- | (1 << CLEAR_INTERRUPT_MODE);
+ tmp = BIT(SET_NAK_OUT_PACKETS_MODE) |
+ BIT(SET_NAK_OUT_PACKETS) |
+ BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
+ BIT(CLEAR_INTERRUPT_MODE);
} else {
/* added for 2282 */
- tmp = (1 << CLEAR_NAK_OUT_PACKETS_MODE)
- | (1 << CLEAR_NAK_OUT_PACKETS)
- | (1 << CLEAR_EP_HIDE_STATUS_PHASE)
- | (1 << CLEAR_INTERRUPT_MODE);
+ tmp = BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
+ BIT(CLEAR_NAK_OUT_PACKETS) |
+ BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
+ BIT(CLEAR_INTERRUPT_MODE);
}
if (ep->num != 0) {
- tmp |= (1 << CLEAR_ENDPOINT_TOGGLE)
- | (1 << CLEAR_ENDPOINT_HALT);
+ tmp |= BIT(CLEAR_ENDPOINT_TOGGLE) |
+ BIT(CLEAR_ENDPOINT_HALT);
}
writel (tmp, &ep->regs->ep_rsp);
/* scrub most status bits, and flush any fifo state */
if (ep->dev->pdev->device == 0x2280)
- tmp = (1 << FIFO_OVERFLOW)
- | (1 << FIFO_UNDERFLOW);
+ tmp = BIT(FIFO_OVERFLOW) |
+ BIT(FIFO_UNDERFLOW);
else
tmp = 0;
- writel (tmp | (1 << TIMEOUT)
- | (1 << USB_STALL_SENT)
- | (1 << USB_IN_NAK_SENT)
- | (1 << USB_IN_ACK_RCVD)
- | (1 << USB_OUT_PING_NAK_SENT)
- | (1 << USB_OUT_ACK_SENT)
- | (1 << FIFO_FLUSH)
- | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT)
- | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)
- | (1 << DATA_PACKET_RECEIVED_INTERRUPT)
- | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)
- | (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
- | (1 << DATA_IN_TOKEN_INTERRUPT)
+ writel(tmp | BIT(TIMEOUT) |
+ BIT(USB_STALL_SENT) |
+ BIT(USB_IN_NAK_SENT) |
+ BIT(USB_IN_ACK_RCVD) |
+ BIT(USB_OUT_PING_NAK_SENT) |
+ BIT(USB_OUT_ACK_SENT) |
+ BIT(FIFO_FLUSH) |
+ BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
+ BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
+ BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
+ BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_IN_TOKEN_INTERRUPT)
, &ep->regs->ep_stat);
/* fifo size is handled separately */
@@ -424,11 +424,11 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
/* disable the dma, irqs, endpoint... */
if (ep->dma) {
writel(0, &ep->dma->dmactl);
- writel((1 << DMA_ABORT_DONE_INTERRUPT) |
- (1 << DMA_PAUSE_DONE_INTERRUPT) |
- (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) |
- (1 << DMA_TRANSACTION_DONE_INTERRUPT)
- /* | (1 << DMA_ABORT) */
+ writel(BIT(DMA_ABORT_DONE_INTERRUPT) |
+ BIT(DMA_PAUSE_DONE_INTERRUPT) |
+ BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
+ BIT(DMA_TRANSACTION_DONE_INTERRUPT)
+ /* | BIT(DMA_ABORT) */
, &ep->dma->dmastat);
dmastat = readl(&ep->dma->dmastat);
@@ -439,24 +439,24 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
}
tmp = readl(®s->pciirqenb0);
- tmp &= ~(1 << ep_bit[ep->num]);
+ tmp &= ~BIT(ep_bit[ep->num]);
writel(tmp, ®s->pciirqenb0);
} else {
if (ep->num < 5) {
tmp = readl(®s->pciirqenb1);
- tmp &= ~(1 << (8 + ep->num)); /* completion */
+ tmp &= ~BIT((8 + ep->num)); /* completion */
writel(tmp, ®s->pciirqenb1);
}
}
writel(0, &ep->regs->ep_irqenb);
- writel((1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
- (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
- (1 << FIFO_OVERFLOW) |
- (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
- (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) |
- (1 << DATA_OUT_PING_TOKEN_INTERRUPT) |
- (1 << DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
+ writel(BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
+ BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
+ BIT(FIFO_OVERFLOW) |
+ BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
+ BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
}
static void nuke (struct net2280_ep *);
@@ -621,20 +621,20 @@ static void out_flush (struct net2280_ep *ep)
ASSERT_OUT_NAKING (ep);
statp = &ep->regs->ep_stat;
- writel ( (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
- | (1 << DATA_PACKET_RECEIVED_INTERRUPT)
+ writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_PACKET_RECEIVED_INTERRUPT)
, statp);
- writel ((1 << FIFO_FLUSH), statp);
+ writel(BIT(FIFO_FLUSH), statp);
mb ();
tmp = readl (statp);
- if (tmp & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
+ if (tmp & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
/* high speed did bulk NYET; fifo isn't filling */
&& ep->dev->gadget.speed == USB_SPEED_FULL) {
unsigned usec;
usec = 50; /* 64 byte bulk/interrupt */
- handshake (statp, (1 << USB_OUT_PING_NAK_SENT),
- (1 << USB_OUT_PING_NAK_SENT), usec);
+ handshake(statp, BIT(USB_OUT_PING_NAK_SENT),
+ BIT(USB_OUT_PING_NAK_SENT), usec);
/* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */
}
}
@@ -661,9 +661,9 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
&& ep->dev->gadget.speed == USB_SPEED_FULL) {
udelay (1);
tmp = readl (&ep->regs->ep_stat);
- if ((tmp & (1 << NAK_OUT_PACKETS)))
+ if ((tmp & BIT(NAK_OUT_PACKETS)))
cleanup = 1;
- else if ((tmp & (1 << FIFO_FULL))) {
+ else if ((tmp & BIT(FIFO_FULL))) {
start_out_naking (ep);
prevent = 1;
}
@@ -680,7 +680,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
tmp = readl (&ep->regs->ep_stat);
count = readl (®s->ep_avail);
/* handled that data already? */
- if (count == 0 && (tmp & (1 << NAK_OUT_PACKETS)) == 0)
+ if (count == 0 && (tmp & BIT(NAK_OUT_PACKETS)) == 0)
return 0;
}
@@ -726,7 +726,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
if (cleanup)
out_flush (ep);
if (prevent) {
- writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
+ writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
(void) readl (&ep->regs->ep_rsp);
}
@@ -747,16 +747,16 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
* stop the fifo from filling but we can flush it.
*/
if (ep->is_in)
- dmacount |= (1 << DMA_DIRECTION);
+ dmacount |= BIT(DMA_DIRECTION);
if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0)
|| ep->dev->pdev->device != 0x2280)
- dmacount |= (1 << END_OF_CHAIN);
+ dmacount |= BIT(END_OF_CHAIN);
req->valid = valid;
if (valid)
- dmacount |= (1 << VALID_BIT);
+ dmacount |= BIT(VALID_BIT);
if (likely(!req->req.no_interrupt || !use_dma_chaining))
- dmacount |= (1 << DMA_DONE_INTERRUPT_ENABLE);
+ dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
/* td->dmadesc = previously set by caller */
td->dmaaddr = cpu_to_le32 (req->req.dma);
@@ -767,47 +767,47 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
}
static const u32 dmactl_default =
- (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT)
- | (1 << DMA_CLEAR_COUNT_ENABLE)
+ BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
+ BIT(DMA_CLEAR_COUNT_ENABLE) |
/* erratum 0116 workaround part 1 (use POLLING) */
- | (POLL_100_USEC << DESCRIPTOR_POLLING_RATE)
- | (1 << DMA_VALID_BIT_POLLING_ENABLE)
- | (1 << DMA_VALID_BIT_ENABLE)
- | (1 << DMA_SCATTER_GATHER_ENABLE)
+ (POLL_100_USEC << DESCRIPTOR_POLLING_RATE) |
+ BIT(DMA_VALID_BIT_POLLING_ENABLE) |
+ BIT(DMA_VALID_BIT_ENABLE) |
+ BIT(DMA_SCATTER_GATHER_ENABLE) |
/* erratum 0116 workaround part 2 (no AUTOSTART) */
- | (1 << DMA_ENABLE);
+ BIT(DMA_ENABLE);
static inline void spin_stop_dma (struct net2280_dma_regs __iomem *dma)
{
- handshake (&dma->dmactl, (1 << DMA_ENABLE), 0, 50);
+ handshake(&dma->dmactl, BIT(DMA_ENABLE), 0, 50);
}
static inline void stop_dma (struct net2280_dma_regs __iomem *dma)
{
- writel (readl (&dma->dmactl) & ~(1 << DMA_ENABLE), &dma->dmactl);
+ writel(readl(&dma->dmactl) & ~BIT(DMA_ENABLE), &dma->dmactl);
spin_stop_dma (dma);
}
static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
{
struct net2280_dma_regs __iomem *dma = ep->dma;
- unsigned int tmp = (1 << VALID_BIT) | (ep->is_in << DMA_DIRECTION);
+ unsigned int tmp = BIT(VALID_BIT) | (ep->is_in << DMA_DIRECTION);
if (ep->dev->pdev->device != 0x2280)
- tmp |= (1 << END_OF_CHAIN);
+ tmp |= BIT(END_OF_CHAIN);
writel (tmp, &dma->dmacount);
writel (readl (&dma->dmastat), &dma->dmastat);
writel (td_dma, &dma->dmadesc);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
- dmactl |= (0x01 << DMA_REQUEST_OUTSTANDING);
+ dmactl |= BIT(DMA_REQUEST_OUTSTANDING);
writel (dmactl, &dma->dmactl);
/* erratum 0116 workaround part 3: pci arbiter away from net2280 */
(void) readl (&ep->dev->pci->pcimstctl);
- writel ((1 << DMA_START), &dma->dmastat);
+ writel(BIT(DMA_START), &dma->dmastat);
if (!ep->is_in)
stop_out_naking (ep);
@@ -821,13 +821,13 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
/* FIXME can't use DMA for ZLPs */
/* on this path we "know" there's no dma active (yet) */
- WARN_ON (readl (&dma->dmactl) & (1 << DMA_ENABLE));
+ WARN_ON(readl(&dma->dmactl) & BIT(DMA_ENABLE));
writel (0, &ep->dma->dmactl);
/* previous OUT packet might have been short */
if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat))
- & (1 << NAK_OUT_PACKETS)) != 0) {
- writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT),
+ & BIT(NAK_OUT_PACKETS)) != 0) {
+ writel(BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT),
&ep->regs->ep_stat);
tmp = readl (&ep->regs->ep_avail);
@@ -840,13 +840,13 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
/* dma irq, faking scatterlist status */
req->td->dmacount = cpu_to_le32 (req->req.length - tmp);
- writel ((1 << DMA_DONE_INTERRUPT_ENABLE)
+ writel(BIT(DMA_DONE_INTERRUPT_ENABLE)
| tmp, &dma->dmacount);
req->td->dmadesc = 0;
req->valid = 1;
- writel ((1 << DMA_ENABLE), &dma->dmactl);
- writel ((1 << DMA_START), &dma->dmastat);
+ writel(BIT(DMA_ENABLE), &dma->dmactl);
+ writel(BIT(DMA_START), &dma->dmastat);
return;
}
}
@@ -860,7 +860,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
if (ep->is_in) {
if (likely ((req->req.length % ep->ep.maxpacket) != 0
|| req->req.zero)) {
- tmp |= (1 << DMA_FIFO_VALIDATE);
+ tmp |= BIT(DMA_FIFO_VALIDATE);
ep->in_fifo_validate = 1;
} else
ep->in_fifo_validate = 0;
@@ -871,21 +871,21 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
fill_dma_desc (ep, req, 1);
if (!use_dma_chaining)
- req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN);
+ req->td->dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
start_queue (ep, tmp, req->td_dma);
}
static inline void resume_dma(struct net2280_ep *ep)
{
- writel(readl(&ep->dma->dmactl) | (1 << DMA_ENABLE), &ep->dma->dmactl);
+ writel(readl(&ep->dma->dmactl) | BIT(DMA_ENABLE), &ep->dma->dmactl);
ep->dma_started = true;
}
static inline void ep_stop_dma(struct net2280_ep *ep)
{
- writel(readl(&ep->dma->dmactl) & ~(1 << DMA_ENABLE), &ep->dma->dmactl);
+ writel(readl(&ep->dma->dmactl) & ~BIT(DMA_ENABLE), &ep->dma->dmactl);
spin_stop_dma(ep->dma);
ep->dma_started = false;
@@ -995,7 +995,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
if (list_empty (&ep->queue) && !ep->stopped) {
/* DMA request while EP halted */
if (ep->dma &&
- (readl(&ep->regs->ep_rsp) & (1 << CLEAR_ENDPOINT_HALT)) &&
+ (readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)) &&
(dev->pdev->vendor == PCI_VENDOR_ID_PLX)) {
int valid = 1;
if (ep->is_in) {
@@ -1028,7 +1028,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* OUT FIFO might have packet(s) buffered */
s = readl (&ep->regs->ep_stat);
- if ((s & (1 << FIFO_EMPTY)) == 0) {
+ if ((s & BIT(FIFO_EMPTY)) == 0) {
/* note: _req->short_not_ok is
* ignored here since PIO _always_
* stops queue advance here, and
@@ -1046,8 +1046,8 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
}
/* don't NAK, let the fifo fill */
- if (req && (s & (1 << NAK_OUT_PACKETS)))
- writel ((1 << CLEAR_NAK_OUT_PACKETS),
+ if (req && (s & BIT(NAK_OUT_PACKETS)))
+ writel(BIT(CLEAR_NAK_OUT_PACKETS),
&ep->regs->ep_rsp);
}
}
@@ -1109,7 +1109,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
break;
rmb ();
tmp = le32_to_cpup (&req->td->dmacount);
- if ((tmp & (1 << VALID_BIT)) != 0)
+ if ((tmp & BIT(VALID_BIT)) != 0)
break;
/* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short"
@@ -1134,7 +1134,7 @@ static void scan_dma_completions (struct net2280_ep *ep)
* your gadget driver. That helps avoids errata 0121,
* 0122, and 0124; not all cases trigger the warning.
*/
- if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) {
+ if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
WARNING (ep->dev, "%s lost packet sync!\n",
ep->ep.name);
req->req.status = -EOVERFLOW;
@@ -1179,7 +1179,7 @@ static void restart_dma (struct net2280_ep *ep)
ep->in_fifo_validate = likely (req->req.zero
|| (req->req.length % ep->ep.maxpacket) != 0);
if (ep->in_fifo_validate)
- dmactl |= (1 << DMA_FIFO_VALIDATE);
+ dmactl |= BIT(DMA_FIFO_VALIDATE);
list_for_each_entry (entry, &ep->queue, queue) {
__le32 dmacount;
@@ -1220,7 +1220,7 @@ static void abort_dma_228x(struct net2280_ep *ep)
/* abort the current transfer */
if (likely (!list_empty (&ep->queue))) {
/* FIXME work around errata 0121, 0122, 0124 */
- writel ((1 << DMA_ABORT), &ep->dma->dmastat);
+ writel(BIT(DMA_ABORT), &ep->dma->dmastat);
spin_stop_dma (ep->dma);
} else
stop_dma (ep->dma);
@@ -1229,7 +1229,7 @@ static void abort_dma_228x(struct net2280_ep *ep)
static void abort_dma_338x(struct net2280_ep *ep)
{
- writel((1 << DMA_ABORT), &ep->dma->dmastat);
+ writel(BIT(DMA_ABORT), &ep->dma->dmastat);
spin_stop_dma(ep->dma);
}
@@ -1431,7 +1431,7 @@ net2280_fifo_status (struct usb_ep *_ep)
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
- avail = readl (&ep->regs->ep_avail) & ((1 << 12) - 1);
+ avail = readl(&ep->regs->ep_avail) & (BIT(12) - 1);
if (avail > ep->fifo_size)
return -EOVERFLOW;
if (ep->is_in)
@@ -1450,7 +1450,7 @@ net2280_fifo_flush (struct usb_ep *_ep)
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
return;
- writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat);
+ writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
(void) readl (&ep->regs->ep_rsp);
}
@@ -1499,8 +1499,8 @@ static int net2280_wakeup (struct usb_gadget *_gadget)
spin_lock_irqsave (&dev->lock, flags);
tmp = readl (&dev->usb->usbctl);
- if (tmp & (1 << DEVICE_REMOTE_WAKEUP_ENABLE))
- writel (1 << GENERATE_RESUME, &dev->usb->usbstat);
+ if (tmp & BIT(DEVICE_REMOTE_WAKEUP_ENABLE))
+ writel(BIT(GENERATE_RESUME), &dev->usb->usbstat);
spin_unlock_irqrestore (&dev->lock, flags);
/* pci writes may still be posted */
@@ -1520,10 +1520,10 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
spin_lock_irqsave (&dev->lock, flags);
tmp = readl (&dev->usb->usbctl);
if (value) {
- tmp |= (1 << SELF_POWERED_STATUS);
+ tmp |= BIT(SELF_POWERED_STATUS);
dev->selfpowered = 1;
} else {
- tmp &= ~(1 << SELF_POWERED_STATUS);
+ tmp &= ~BIT(SELF_POWERED_STATUS);
dev->selfpowered = 0;
}
writel (tmp, &dev->usb->usbctl);
@@ -1546,9 +1546,9 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
tmp = readl (&dev->usb->usbctl);
dev->softconnect = (is_on != 0);
if (is_on)
- tmp |= (1 << USB_DETECT_ENABLE);
+ tmp |= BIT(USB_DETECT_ENABLE);
else
- tmp &= ~(1 << USB_DETECT_ENABLE);
+ tmp &= ~BIT(USB_DETECT_ENABLE);
writel (tmp, &dev->usb->usbctl);
spin_unlock_irqrestore (&dev->lock, flags);
@@ -1636,8 +1636,8 @@ static ssize_t registers_show(struct device *_dev,
/* USB Control Registers */
t1 = readl (&dev->usb->usbctl);
t2 = readl (&dev->usb->usbstat);
- if (t1 & (1 << VBUS_PIN)) {
- if (t2 & (1 << HIGH_SPEED))
+ if (t1 & BIT(VBUS_PIN)) {
+ if (t2 & BIT(HIGH_SPEED))
s = "high speed";
else if (dev->gadget.speed == USB_SPEED_UNKNOWN)
s = "powered";
@@ -1672,21 +1672,21 @@ static ssize_t registers_show(struct device *_dev,
"\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
"irqenb %02x\n",
ep->ep.name, t1, t2,
- (t2 & (1 << CLEAR_NAK_OUT_PACKETS))
+ (t2 & BIT(CLEAR_NAK_OUT_PACKETS))
? "NAK " : "",
- (t2 & (1 << CLEAR_EP_HIDE_STATUS_PHASE))
+ (t2 & BIT(CLEAR_EP_HIDE_STATUS_PHASE))
? "hide " : "",
- (t2 & (1 << CLEAR_EP_FORCE_CRC_ERROR))
+ (t2 & BIT(CLEAR_EP_FORCE_CRC_ERROR))
? "CRC " : "",
- (t2 & (1 << CLEAR_INTERRUPT_MODE))
+ (t2 & BIT(CLEAR_INTERRUPT_MODE))
? "interrupt " : "",
- (t2 & (1<<CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE))
+ (t2 & BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE))
? "status " : "",
- (t2 & (1 << CLEAR_NAK_OUT_PACKETS_MODE))
+ (t2 & BIT(CLEAR_NAK_OUT_PACKETS_MODE))
? "NAKmode " : "",
- (t2 & (1 << CLEAR_ENDPOINT_TOGGLE))
+ (t2 & BIT(CLEAR_ENDPOINT_TOGGLE))
? "DATA1 " : "DATA0 ",
- (t2 & (1 << CLEAR_ENDPOINT_HALT))
+ (t2 & BIT(CLEAR_ENDPOINT_HALT))
? "HALT " : "",
readl (&ep->regs->ep_irqenb));
size -= t;
@@ -1922,10 +1922,10 @@ static void defect7374_disable_data_eps(struct net2280 *dev)
/* Change settings on some selected endpoints */
tmp_reg = readl(&dev->plregs->pl_ep_cfg_4);
- tmp_reg &= ~(1 << NON_CTRL_IN_TOLERATE_BAD_DIR);
+ tmp_reg &= ~BIT(NON_CTRL_IN_TOLERATE_BAD_DIR);
writel(tmp_reg, &dev->plregs->pl_ep_cfg_4);
tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
- tmp_reg |= (1 << EP_INITIALIZED);
+ tmp_reg |= BIT(EP_INITIALIZED);
writel(tmp_reg, &dev->plregs->pl_ep_ctrl);
}
}
@@ -1947,17 +1947,17 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
WARNING(dev, "It will operate on cold-reboot and SS connect");
/*GPEPs:*/
- tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_DIRECTION) |
+ tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
(2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
((dev->enhanced_mode) ?
- 1 << OUT_ENDPOINT_ENABLE : 1 << ENDPOINT_ENABLE) |
- (1 << IN_ENDPOINT_ENABLE));
+ BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
+ BIT(IN_ENDPOINT_ENABLE));
for (i = 1; i < 5; i++)
writel(tmp, &dev->ep[i].cfg->ep_cfg);
/* CSRIN, PCIIN, STATIN, RCIN*/
- tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_ENABLE));
+ tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
writel(tmp, &dev->dep[1].dep_cfg);
writel(tmp, &dev->dep[3].dep_cfg);
writel(tmp, &dev->dep[4].dep_cfg);
@@ -1974,7 +1974,7 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
if (ep_sel == 1) {
tmp =
(readl(&dev->plregs->pl_ep_ctrl) |
- (1 << CLEAR_ACK_ERROR_CODE) | 0);
+ BIT(CLEAR_ACK_ERROR_CODE) | 0);
writel(tmp, &dev->plregs->pl_ep_ctrl);
continue;
}
@@ -1984,11 +1984,11 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
continue;
tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
- (1 << NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
+ BIT(NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
writel(tmp, &dev->plregs->pl_ep_cfg_4);
tmp = readl(&dev->plregs->pl_ep_ctrl) &
- ~(1 << EP_INITIALIZED);
+ ~BIT(EP_INITIALIZED);
writel(tmp, &dev->plregs->pl_ep_ctrl);
}
@@ -2036,14 +2036,14 @@ static void usb_reset_228x(struct net2280 *dev)
}
writel (~0, &dev->regs->irqstat0),
- writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
+ writel(~(u32)BIT(SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
/* reset, and enable pci */
- tmp = readl (&dev->regs->devinit)
- | (1 << PCI_ENABLE)
- | (1 << FIFO_SOFT_RESET)
- | (1 << USB_SOFT_RESET)
- | (1 << M8051_RESET);
+ tmp = readl(&dev->regs->devinit) |
+ BIT(PCI_ENABLE) |
+ BIT(FIFO_SOFT_RESET) |
+ BIT(USB_SOFT_RESET) |
+ BIT(M8051_RESET);
writel (tmp, &dev->regs->devinit);
/* standard fifo and endpoint allocations */
@@ -2087,10 +2087,10 @@ static void usb_reset_338x(struct net2280 *dev)
if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
/* reset, and enable pci */
tmp = readl(&dev->regs->devinit) |
- (1 << PCI_ENABLE) |
- (1 << FIFO_SOFT_RESET) |
- (1 << USB_SOFT_RESET) |
- (1 << M8051_RESET);
+ BIT(PCI_ENABLE) |
+ BIT(FIFO_SOFT_RESET) |
+ BIT(USB_SOFT_RESET) |
+ BIT(M8051_RESET);
writel(tmp, &dev->regs->devinit);
}
@@ -2206,7 +2206,7 @@ static void usb_reinit_338x(struct net2280 *dev)
__func__, fsmvalue);
else {
tmp = readl(&dev->usb_ext->usbctl2) &
- ~((1 << U1_ENABLE) | (1 << U2_ENABLE) | (1 << LTM_ENABLE));
+ ~(BIT(U1_ENABLE) | BIT(U2_ENABLE) | BIT(LTM_ENABLE));
writel(tmp, &dev->usb_ext->usbctl2);
}
@@ -2245,7 +2245,7 @@ static void usb_reinit_338x(struct net2280 *dev)
* - Reference PLX TT-7372
*/
val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit);
- val |= (1 << RECOVERY_IDLE_TO_RECOVER_FMW);
+ val |= BIT(RECOVERY_IDLE_TO_RECOVER_FMW);
writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit);
INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
@@ -2268,9 +2268,9 @@ static void usb_reinit(struct net2280 *dev)
static void ep0_start_228x(struct net2280 *dev)
{
- writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE)
- | (1 << CLEAR_NAK_OUT_PACKETS)
- | (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
+ writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
+ BIT(CLEAR_NAK_OUT_PACKETS) |
+ BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
, &dev->epregs [0].ep_rsp);
/*
@@ -2279,31 +2279,31 @@ static void ep0_start_228x(struct net2280 *dev)
* endpoint status/features are handled in software, to
* help pass tests for some dubious behavior.
*/
- writel ( (1 << SET_TEST_MODE)
- | (1 << SET_ADDRESS)
- | (1 << DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP)
- | (1 << GET_DEVICE_STATUS)
- | (1 << GET_INTERFACE_STATUS)
+ writel(BIT(SET_TEST_MODE) |
+ BIT(SET_ADDRESS) |
+ BIT(DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP) |
+ BIT(GET_DEVICE_STATUS) |
+ BIT(GET_INTERFACE_STATUS)
, &dev->usb->stdrsp);
- writel ( (1 << USB_ROOT_PORT_WAKEUP_ENABLE)
- | (1 << SELF_POWERED_USB_DEVICE)
- | (1 << REMOTE_WAKEUP_SUPPORT)
- | (dev->softconnect << USB_DETECT_ENABLE)
- | (1 << SELF_POWERED_STATUS)
- , &dev->usb->usbctl);
+ writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE) |
+ BIT(SELF_POWERED_USB_DEVICE) |
+ BIT(REMOTE_WAKEUP_SUPPORT) |
+ (dev->softconnect << USB_DETECT_ENABLE) |
+ BIT(SELF_POWERED_STATUS),
+ &dev->usb->usbctl);
/* enable irqs so we can see ep0 and general operation */
- writel ( (1 << SETUP_PACKET_INTERRUPT_ENABLE)
- | (1 << ENDPOINT_0_INTERRUPT_ENABLE)
- , &dev->regs->pciirqenb0);
- writel ( (1 << PCI_INTERRUPT_ENABLE)
- | (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE)
- | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE)
- | (1 << PCI_RETRY_ABORT_INTERRUPT_ENABLE)
- | (1 << VBUS_INTERRUPT_ENABLE)
- | (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE)
- | (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE)
- , &dev->regs->pciirqenb1);
+ writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE) |
+ BIT(ENDPOINT_0_INTERRUPT_ENABLE),
+ &dev->regs->pciirqenb0);
+ writel(BIT(PCI_INTERRUPT_ENABLE) |
+ BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE) |
+ BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE) |
+ BIT(PCI_RETRY_ABORT_INTERRUPT_ENABLE) |
+ BIT(VBUS_INTERRUPT_ENABLE) |
+ BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE) |
+ BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE),
+ &dev->regs->pciirqenb1);
/* don't leave any writes posted */
(void) readl (&dev->usb->usbctl);
@@ -2320,8 +2320,8 @@ static void ep0_start_338x(struct net2280 *dev)
INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
fsmvalue);
else
- writel((1 << CLEAR_NAK_OUT_PACKETS_MODE) |
- (1 << SET_EP_HIDE_STATUS_PHASE),
+ writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
+ BIT(SET_EP_HIDE_STATUS_PHASE),
&dev->epregs[0].ep_rsp);
/*
@@ -2330,27 +2330,27 @@ static void ep0_start_338x(struct net2280 *dev)
* endpoint status/features are handled in software, to
* help pass tests for some dubious behavior.
*/
- writel((1 << SET_ISOCHRONOUS_DELAY) |
- (1 << SET_SEL) |
- (1 << SET_TEST_MODE) |
- (1 << SET_ADDRESS) |
- (1 << GET_INTERFACE_STATUS) |
- (1 << GET_DEVICE_STATUS),
+ writel(BIT(SET_ISOCHRONOUS_DELAY) |
+ BIT(SET_SEL) |
+ BIT(SET_TEST_MODE) |
+ BIT(SET_ADDRESS) |
+ BIT(GET_INTERFACE_STATUS) |
+ BIT(GET_DEVICE_STATUS),
&dev->usb->stdrsp);
dev->wakeup_enable = 1;
- writel((1 << USB_ROOT_PORT_WAKEUP_ENABLE) |
+ writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE) |
(dev->softconnect << USB_DETECT_ENABLE) |
- (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
&dev->usb->usbctl);
/* enable irqs so we can see ep0 and general operation */
- writel((1 << SETUP_PACKET_INTERRUPT_ENABLE) |
- (1 << ENDPOINT_0_INTERRUPT_ENABLE)
+ writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE) |
+ BIT(ENDPOINT_0_INTERRUPT_ENABLE)
, &dev->regs->pciirqenb0);
- writel((1 << PCI_INTERRUPT_ENABLE) |
- (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) |
- (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
- (1 << VBUS_INTERRUPT_ENABLE),
+ writel(BIT(PCI_INTERRUPT_ENABLE) |
+ BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE) |
+ BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
+ BIT(VBUS_INTERRUPT_ENABLE),
&dev->regs->pciirqenb1);
/* don't leave any writes posted */
@@ -2402,7 +2402,7 @@ static int net2280_start(struct usb_gadget *_gadget,
/* Enable force-full-speed testing mode, if desired */
if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
- writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag);
+ writel(BIT(FORCE_FULL_SPEED_MODE), &dev->usb->xcvrdiag);
/* ... then enable host detection and ep0; and we're ready
* for set_configuration as well as eventual disconnect.
@@ -2511,7 +2511,7 @@ static void handle_ep_small (struct net2280_ep *ep)
ep->ep.name, t, req ? &req->req : 0);
#endif
if (!ep->is_in || ep->dev->pdev->device == 0x2280)
- writel (t & ~(1 << NAK_OUT_PACKETS), &ep->regs->ep_stat);
+ writel(t & ~BIT(NAK_OUT_PACKETS), &ep->regs->ep_stat);
else
/* Added for 2282 */
writel (t, &ep->regs->ep_stat);
@@ -2529,7 +2529,7 @@ static void handle_ep_small (struct net2280_ep *ep)
if (unlikely (ep->num == 0)) {
if (ep->is_in) {
/* status; stop NAKing */
- if (t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) {
+ if (t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
set_halt (ep);
@@ -2538,7 +2538,7 @@ static void handle_ep_small (struct net2280_ep *ep)
allow_status (ep);
mode = 2;
/* reply to extra IN data tokens with a zlp */
- } else if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) {
+ } else if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
set_halt (ep);
@@ -2549,14 +2549,14 @@ static void handle_ep_small (struct net2280_ep *ep)
}
} else {
/* status; stop NAKing */
- if (t & (1 << DATA_IN_TOKEN_INTERRUPT)) {
+ if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
set_halt (ep);
}
mode = 2;
/* an extra OUT token is an error */
- } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT))
+ } else if (((t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT))
&& req
&& req->req.actual == req->req.length)
|| (ep->responded && !req)) {
@@ -2575,7 +2575,7 @@ static void handle_ep_small (struct net2280_ep *ep)
/* manual DMA queue advance after short OUT */
if (likely (ep->dma)) {
- if (t & (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
+ if (t & BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
u32 count;
int stopped = ep->stopped;
@@ -2601,7 +2601,7 @@ static void handle_ep_small (struct net2280_ep *ep)
/* here either (M < N), a "real" short rx;
* or (M == N) and the queue didn't empty
*/
- if (likely (t & (1 << FIFO_EMPTY))) {
+ if (likely(t & BIT(FIFO_EMPTY))) {
count = readl (&ep->dma->dmacount);
count &= DMA_BYTE_COUNT_MASK;
if (readl (&ep->dma->dmadesc)
@@ -2613,7 +2613,7 @@ static void handle_ep_small (struct net2280_ep *ep)
}
/* stop DMA, leave ep NAKing */
- writel ((1 << DMA_ABORT), &ep->dma->dmastat);
+ writel(BIT(DMA_ABORT), &ep->dma->dmastat);
spin_stop_dma (ep->dma);
if (likely (req)) {
@@ -2643,12 +2643,12 @@ static void handle_ep_small (struct net2280_ep *ep)
return;
/* data packet(s) received (in the fifo, OUT) */
- } else if (t & (1 << DATA_PACKET_RECEIVED_INTERRUPT)) {
+ } else if (t & BIT(DATA_PACKET_RECEIVED_INTERRUPT)) {
if (read_fifo (ep, req) && ep->num != 0)
mode = 2;
/* data packet(s) transmitted (IN) */
- } else if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)) {
+ } else if (t & BIT(DATA_PACKET_TRANSMITTED_INTERRUPT)) {
unsigned len;
len = req->req.length - req->req.actual;
@@ -2699,7 +2699,7 @@ static void handle_ep_small (struct net2280_ep *ep)
if (req && !ep->stopped) {
/* load IN fifo with next packet (may be zlp) */
- if (t & (1 << DATA_PACKET_TRANSMITTED_INTERRUPT))
+ if (t & BIT(DATA_PACKET_TRANSMITTED_INTERRUPT))
write_fifo (ep, &req->req);
}
}
@@ -2740,7 +2740,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
return;
/* This is the first Control Read for this connection: */
- if (!(readl(&dev->usb->usbstat) & (1 << SUPER_SPEED_MODE))) {
+ if (!(readl(&dev->usb->usbstat) & BIT(SUPER_SPEED_MODE))) {
/*
* Connection is NOT SS:
* - Connection must be FS or HS.
@@ -2804,9 +2804,9 @@ static void ep_stall(struct net2280_ep *ep, int stall)
static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
if (stall) {
- writel((1 << SET_ENDPOINT_HALT) |
- /* (1 << SET_NAK_PACKETS) | */
- (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
+ writel(BIT(SET_ENDPOINT_HALT) |
+ /* BIT(SET_NAK_PACKETS) | */
+ BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
&ep->regs->ep_rsp);
ep->is_halt = 1;
} else {
@@ -2819,14 +2819,14 @@ static void ep_stall(struct net2280_ep *ep, int stall)
val = (val & ~0x1f) | ep_pl[ep->num];
writel(val, &dev->plregs->pl_ep_ctrl);
- val |= (1 << SEQUENCE_NUMBER_RESET);
+ val |= BIT(SEQUENCE_NUMBER_RESET);
writel(val, &dev->plregs->pl_ep_ctrl);
}
val = readl(&ep->regs->ep_rsp);
- val |= (1 << CLEAR_ENDPOINT_HALT) |
- (1 << CLEAR_ENDPOINT_TOGGLE);
+ val |= BIT(CLEAR_ENDPOINT_HALT) |
+ BIT(CLEAR_ENDPOINT_TOGGLE);
writel(val
- /* | (1 << CLEAR_NAK_PACKETS)*/
+ /* | BIT(CLEAR_NAK_PACKETS)*/
, &ep->regs->ep_rsp);
ep->is_halt = 0;
val = readl(&ep->regs->ep_rsp);
@@ -2895,7 +2895,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
status = dev->wakeup_enable ? 0x02 : 0x00;
if (dev->selfpowered)
- status |= 1 << 0;
+ status |= BIT(0);
status |= (dev->u1_enable << 2 | dev->u2_enable << 3 |
dev->ltm_enable << 4);
writel(0, &dev->epregs[0].ep_irqenb);
@@ -2909,7 +2909,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
if (!e)
goto do_stall3;
status = readl(&e->regs->ep_rsp) &
- (1 << CLEAR_ENDPOINT_HALT);
+ BIT(CLEAR_ENDPOINT_HALT);
writel(0, &dev->epregs[0].ep_irqenb);
set_fifo_bytecount(ep, sizeof(status));
writel((__force u32) status, &dev->epregs[0].ep_data);
@@ -2929,7 +2929,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_U1_ENABLE:
dev->u1_enable = 0;
writel(readl(&dev->usb_ext->usbctl2) &
- ~(1 << U1_ENABLE),
+ ~BIT(U1_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -2937,7 +2937,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_U2_ENABLE:
dev->u2_enable = 0;
writel(readl(&dev->usb_ext->usbctl2) &
- ~(1 << U2_ENABLE),
+ ~BIT(U2_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -2945,7 +2945,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_LTM_ENABLE:
dev->ltm_enable = 0;
writel(readl(&dev->usb_ext->usbctl2) &
- ~(1 << LTM_ENABLE),
+ ~BIT(LTM_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -2957,7 +2957,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
dev->wakeup_enable = 0;
writel(readl(&dev->usb->usbctl) &
- ~(1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ ~BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
&dev->usb->usbctl);
allow_status_338x(ep);
break;
@@ -2990,7 +2990,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_U1_ENABLE:
dev->u1_enable = 1;
writel(readl(&dev->usb_ext->usbctl2) |
- (1 << U1_ENABLE),
+ BIT(U1_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -2998,7 +2998,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_U2_ENABLE:
dev->u2_enable = 1;
writel(readl(&dev->usb_ext->usbctl2) |
- (1 << U2_ENABLE),
+ BIT(U2_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -3006,7 +3006,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
case USB_DEVICE_LTM_ENABLE:
dev->ltm_enable = 1;
writel(readl(&dev->usb_ext->usbctl2) |
- (1 << LTM_ENABLE),
+ BIT(LTM_ENABLE),
&dev->usb_ext->usbctl2);
allow_status_338x(ep);
goto next_endpoints3;
@@ -3018,7 +3018,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
dev->wakeup_enable = 1;
writel(readl(&dev->usb->usbctl) |
- (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
+ BIT(DEVICE_REMOTE_WAKEUP_ENABLE),
&dev->usb->usbctl);
allow_status_338x(ep);
break;
@@ -3075,13 +3075,13 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
u32 num, scratch;
/* most of these don't need individual acks */
- stat &= ~(1 << INTA_ASSERTED);
+ stat &= ~BIT(INTA_ASSERTED);
if (!stat)
return;
// DEBUG (dev, "irqstat0 %04x\n", stat);
/* starting a control request? */
- if (unlikely (stat & (1 << SETUP_PACKET_INTERRUPT))) {
+ if (unlikely(stat & BIT(SETUP_PACKET_INTERRUPT))) {
union {
u32 raw [2];
struct usb_ctrlrequest r;
@@ -3091,11 +3091,11 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
if (dev->gadget.speed == USB_SPEED_UNKNOWN) {
u32 val = readl(&dev->usb->usbstat);
- if (val & (1 << SUPER_SPEED)) {
+ if (val & BIT(SUPER_SPEED)) {
dev->gadget.speed = USB_SPEED_SUPER;
usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
EP0_SS_MAX_PACKET_SIZE);
- } else if (val & (1 << HIGH_SPEED)) {
+ } else if (val & BIT(HIGH_SPEED)) {
dev->gadget.speed = USB_SPEED_HIGH;
usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
EP0_HS_MAX_PACKET_SIZE);
@@ -3112,7 +3112,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
ep->irqs++;
/* make sure any leftover request state is cleared */
- stat &= ~(1 << ENDPOINT_0_INTERRUPT);
+ stat &= ~BIT(ENDPOINT_0_INTERRUPT);
while (!list_empty (&ep->queue)) {
req = list_entry (ep->queue.next,
struct net2280_request, queue);
@@ -3125,23 +3125,23 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
ep->is_halt = 0;
else{
if (ep->dev->pdev->device == 0x2280)
- tmp = (1 << FIFO_OVERFLOW) |
- (1 << FIFO_UNDERFLOW);
+ tmp = BIT(FIFO_OVERFLOW) |
+ BIT(FIFO_UNDERFLOW);
else
tmp = 0;
- writel(tmp | (1 << TIMEOUT) |
- (1 << USB_STALL_SENT) |
- (1 << USB_IN_NAK_SENT) |
- (1 << USB_IN_ACK_RCVD) |
- (1 << USB_OUT_PING_NAK_SENT) |
- (1 << USB_OUT_ACK_SENT) |
- (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
- (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
- (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
- (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) |
- (1 << DATA_OUT_PING_TOKEN_INTERRUPT) |
- (1 << DATA_IN_TOKEN_INTERRUPT)
+ writel(tmp | BIT(TIMEOUT) |
+ BIT(USB_STALL_SENT) |
+ BIT(USB_IN_NAK_SENT) |
+ BIT(USB_IN_ACK_RCVD) |
+ BIT(USB_OUT_PING_NAK_SENT) |
+ BIT(USB_OUT_ACK_SENT) |
+ BIT(SHORT_PACKET_OUT_DONE_INTERRUPT) |
+ BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT) |
+ BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
+ BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_IN_TOKEN_INTERRUPT)
, &ep->regs->ep_stat);
}
u.raw[0] = readl(&dev->usb->setup0123);
@@ -3160,8 +3160,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
#define w_length le16_to_cpu(u.r.wLength)
/* ack the irq */
- writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0);
- stat ^= (1 << SETUP_PACKET_INTERRUPT);
+ writel(BIT(SETUP_PACKET_INTERRUPT), &dev->regs->irqstat0);
+ stat ^= BIT(SETUP_PACKET_INTERRUPT);
/* watch control traffic at the token level, and force
* synchronization before letting the status stage happen.
@@ -3170,14 +3170,14 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
*/
ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0;
if (ep->is_in) {
- scratch = (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)
- | (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
- | (1 << DATA_IN_TOKEN_INTERRUPT);
+ scratch = BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
+ BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_IN_TOKEN_INTERRUPT);
stop_out_naking (ep);
} else
- scratch = (1 << DATA_PACKET_RECEIVED_INTERRUPT)
- | (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
- | (1 << DATA_IN_TOKEN_INTERRUPT);
+ scratch = BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
+ BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
+ BIT(DATA_IN_TOKEN_INTERRUPT);
writel (scratch, &dev->epregs [0].ep_irqenb);
/* we made the hardware handle most lowlevel requests;
@@ -3202,8 +3202,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
|| w_length > 2)
goto do_stall;
- if (readl (&e->regs->ep_rsp)
- & (1 << SET_ENDPOINT_HALT))
+ if (readl(&e->regs->ep_rsp) & BIT(SET_ENDPOINT_HALT))
status = cpu_to_le32 (1);
else
status = cpu_to_le32 (0);
@@ -3303,7 +3302,7 @@ next_endpoints:
u32 t;
/* do this endpoint's FIFO and queue need tending? */
- t = 1 << num;
+ t = BIT(num);
if ((scratch & t) == 0)
continue;
scratch ^= t;
@@ -3316,15 +3315,14 @@ next_endpoints:
DEBUG (dev, "unhandled irqstat0 %08x\n", stat);
}
-#define DMA_INTERRUPTS ( \
- (1 << DMA_D_INTERRUPT) \
- | (1 << DMA_C_INTERRUPT) \
- | (1 << DMA_B_INTERRUPT) \
- | (1 << DMA_A_INTERRUPT))
+#define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
+ BIT(DMA_C_INTERRUPT) | \
+ BIT(DMA_B_INTERRUPT) | \
+ BIT(DMA_A_INTERRUPT))
#define PCI_ERROR_INTERRUPTS ( \
- (1 << PCI_MASTER_ABORT_RECEIVED_INTERRUPT) \
- | (1 << PCI_TARGET_ABORT_RECEIVED_INTERRUPT) \
- | (1 << PCI_RETRY_ABORT_INTERRUPT))
+ BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT) | \
+ BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT) | \
+ BIT(PCI_RETRY_ABORT_INTERRUPT))
static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
{
@@ -3332,8 +3330,8 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
u32 tmp, num, mask, scratch;
/* after disconnect there's nothing else to do! */
- tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT);
- mask = (1 << SUPER_SPEED) | (1 << HIGH_SPEED) | (1 << FULL_SPEED);
+ tmp = BIT(VBUS_INTERRUPT) | BIT(ROOT_PORT_RESET_INTERRUPT);
+ mask = BIT(SUPER_SPEED) | BIT(HIGH_SPEED) | BIT(FULL_SPEED);
/* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
* Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
@@ -3342,11 +3340,11 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
*/
if (stat & tmp) {
writel (tmp, &dev->regs->irqstat1);
- if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT))
+ if ((((stat & BIT(ROOT_PORT_RESET_INTERRUPT))
&& ((readl (&dev->usb->usbstat) & mask)
== 0))
|| ((readl (&dev->usb->usbctl)
- & (1 << VBUS_PIN)) == 0)
+ & BIT(VBUS_PIN)) == 0)
) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) {
DEBUG (dev, "disconnect %s\n",
dev->driver->driver.name);
@@ -3366,14 +3364,14 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
/* NOTE: chip stays in PCI D0 state for now, but it could
* enter D1 to save more power
*/
- tmp = (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT);
+ tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT);
if (stat & tmp) {
writel (tmp, &dev->regs->irqstat1);
- if (stat & (1 << SUSPEND_REQUEST_INTERRUPT)) {
+ if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) {
if (dev->driver->suspend)
dev->driver->suspend (&dev->gadget);
if (!enable_suspend)
- stat &= ~(1 << SUSPEND_REQUEST_INTERRUPT);
+ stat &= ~BIT(SUSPEND_REQUEST_INTERRUPT);
} else {
if (dev->driver->resume)
dev->driver->resume (&dev->gadget);
@@ -3388,15 +3386,15 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
/* some status we can just ignore */
if (dev->pdev->device == 0x2280)
- stat &= ~((1 << CONTROL_STATUS_INTERRUPT)
- | (1 << SUSPEND_REQUEST_INTERRUPT)
- | (1 << RESUME_INTERRUPT)
- | (1 << SOF_INTERRUPT));
+ stat &= ~(BIT(CONTROL_STATUS_INTERRUPT) |
+ BIT(SUSPEND_REQUEST_INTERRUPT) |
+ BIT(RESUME_INTERRUPT) |
+ BIT(SOF_INTERRUPT));
else
- stat &= ~((1 << CONTROL_STATUS_INTERRUPT)
- | (1 << RESUME_INTERRUPT)
- | (1 << SOF_DOWN_INTERRUPT)
- | (1 << SOF_INTERRUPT));
+ stat &= ~(BIT(CONTROL_STATUS_INTERRUPT) |
+ BIT(RESUME_INTERRUPT) |
+ BIT(SOF_DOWN_INTERRUPT) |
+ BIT(SOF_INTERRUPT));
if (!stat)
return;
@@ -3409,7 +3407,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
for (num = 0; scratch; num++) {
struct net2280_dma_regs __iomem *dma;
- tmp = 1 << num;
+ tmp = BIT(num);
if ((tmp & scratch) == 0)
continue;
scratch ^= tmp;
@@ -3428,7 +3426,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
u32 r_dmacount = readl(&dma->dmacount);
if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
- (tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT)))
+ (tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT)))
continue;
}
@@ -3436,7 +3434,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
* or (stat0 codepath) short OUT transfer.
*/
if (!use_dma_chaining) {
- if (!(tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))) {
+ if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
DEBUG (ep->dev, "%s no xact done? %08x\n",
ep->ep.name, tmp);
continue;
@@ -3462,8 +3460,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
stop_dma (ep->dma);
} else {
tmp = readl (&dma->dmactl);
- if (!use_dma_chaining
- || (tmp & (1 << DMA_ENABLE)) == 0)
+ if (!use_dma_chaining || (tmp & BIT(DMA_ENABLE)) == 0)
restart_dma (ep);
else if (ep->is_in && use_dma_chaining) {
struct net2280_request *req;
@@ -3477,9 +3474,8 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
req = list_entry (ep->queue.next,
struct net2280_request, queue);
dmacount = req->td->dmacount;
- dmacount &= cpu_to_le32 (
- (1 << VALID_BIT)
- | DMA_BYTE_COUNT_MASK);
+ dmacount &= cpu_to_le32(BIT(VALID_BIT) |
+ DMA_BYTE_COUNT_MASK);
if (dmacount && (dmacount & valid_bit) == 0)
restart_dma (ep);
}
@@ -3511,7 +3507,7 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
/* shared interrupt, not ours */
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY &&
- (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))))
+ (!(readl(&dev->regs->irqstat0) & BIT(INTA_ASSERTED))))
return IRQ_NONE;
spin_lock (&dev->lock);
@@ -3664,7 +3660,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->plregs = (struct usb338x_pl_regs __iomem *)
(base + 0x0800);
usbstat = readl(&dev->usb->usbstat);
- dev->enhanced_mode = (usbstat & (1 << 11)) ? 1 : 0;
+ dev->enhanced_mode = (usbstat & BIT(11)) ? 1 : 0;
dev->n_ep = (dev->enhanced_mode) ? 9 : 5;
/* put into initial config, link up all endpoints */
fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
@@ -3729,12 +3725,14 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
/* enable lower-overhead pci memory bursts during DMA */
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
- writel((1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
- // 256 write retries may not be enough...
- // | (1 << PCI_RETRY_ABORT_ENABLE)
- | (1 << DMA_READ_MULTIPLE_ENABLE)
- | (1 << DMA_READ_LINE_ENABLE)
- , &dev->pci->pcimstctl);
+ writel(BIT(DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE) |
+ /*
+ * 256 write retries may not be enough...
+ BIT(PCI_RETRY_ABORT_ENABLE) |
+ */
+ BIT(DMA_READ_MULTIPLE_ENABLE) |
+ BIT(DMA_READ_LINE_ENABLE),
+ &dev->pci->pcimstctl);
/* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
pci_set_master (pdev);
pci_try_set_mwi (pdev);
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 30478c8..e1c5d1a 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -116,9 +116,9 @@ struct net2280_ep {
static inline void allow_status (struct net2280_ep *ep)
{
/* ep0 only */
- writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
- | (1 << CLEAR_NAK_OUT_PACKETS)
- | (1 << CLEAR_NAK_OUT_PACKETS_MODE)
+ writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
+ BIT(CLEAR_NAK_OUT_PACKETS) |
+ BIT(CLEAR_NAK_OUT_PACKETS_MODE)
, &ep->regs->ep_rsp);
ep->stopped = 1;
}
@@ -130,7 +130,7 @@ static void allow_status_338x(struct net2280_ep *ep)
* packet arrived. While set, the chip automatically NAKs the host's
* Status Phase tokens.
*/
- writel(1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE, &ep->regs->ep_rsp);
+ writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE), &ep->regs->ep_rsp);
ep->stopped = 1;
@@ -191,23 +191,24 @@ struct net2280 {
static inline void set_halt (struct net2280_ep *ep)
{
/* ep0 and bulk/intr endpoints */
- writel ( (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
- /* set NAK_OUT for erratum 0114 */
- | ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS)
- | (1 << SET_ENDPOINT_HALT)
- , &ep->regs->ep_rsp);
+ writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
+ /* set NAK_OUT for erratum 0114 */
+ ((ep->dev->chiprev == CHIPREV_1) << SET_NAK_OUT_PACKETS) |
+ BIT(SET_ENDPOINT_HALT),
+ &ep->regs->ep_rsp);
}
static inline void clear_halt (struct net2280_ep *ep)
{
/* ep0 and bulk/intr endpoints */
- writel ( (1 << CLEAR_ENDPOINT_HALT)
- | (1 << CLEAR_ENDPOINT_TOGGLE)
- /* unless the gadget driver left a short packet in the
+ writel(BIT(CLEAR_ENDPOINT_HALT) |
+ BIT(CLEAR_ENDPOINT_TOGGLE) |
+ /*
+ * unless the gadget driver left a short packet in the
* fifo, this reverses the erratum 0114 workaround.
*/
- | ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS)
- , &ep->regs->ep_rsp);
+ ((ep->dev->chiprev == CHIPREV_1) << CLEAR_NAK_OUT_PACKETS),
+ &ep->regs->ep_rsp);
}
/*
@@ -225,7 +226,7 @@ static inline void clear_halt (struct net2280_ep *ep)
* - Tip: Upon the first SS Control Read the FSM never
* returns to this state.
*/
-#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ (1 << DEFECT7374_FSM_FIELD)
+#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ BIT(DEFECT7374_FSM_FIELD)
/* Non-SS Control Read:
* - A transition to this state indicates detection of the first HS
@@ -252,12 +253,12 @@ static inline void clear_halt (struct net2280_ep *ep)
static inline void net2280_led_init (struct net2280 *dev)
{
/* LED3 (green) is on during USB activity. note erratum 0113. */
- writel ((1 << GPIO3_LED_SELECT)
- | (1 << GPIO3_OUTPUT_ENABLE)
- | (1 << GPIO2_OUTPUT_ENABLE)
- | (1 << GPIO1_OUTPUT_ENABLE)
- | (1 << GPIO0_OUTPUT_ENABLE)
- , &dev->regs->gpioctl);
+ writel(BIT(GPIO3_LED_SELECT) |
+ BIT(GPIO3_OUTPUT_ENABLE) |
+ BIT(GPIO2_OUTPUT_ENABLE) |
+ BIT(GPIO1_OUTPUT_ENABLE) |
+ BIT(GPIO0_OUTPUT_ENABLE),
+ &dev->regs->gpioctl);
}
/* indicate speed with bi-color LED 0/1 */
@@ -267,18 +268,18 @@ void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
u32 val = readl (&dev->regs->gpioctl);
switch (speed) {
case USB_SPEED_SUPER: /* green + red */
- val |= (1 << GPIO0_DATA) | (1 << GPIO1_DATA);
+ val |= BIT(GPIO0_DATA) | BIT(GPIO1_DATA);
break;
case USB_SPEED_HIGH: /* green */
- val &= ~(1 << GPIO0_DATA);
- val |= (1 << GPIO1_DATA);
+ val &= ~BIT(GPIO0_DATA);
+ val |= BIT(GPIO1_DATA);
break;
case USB_SPEED_FULL: /* red */
- val &= ~(1 << GPIO1_DATA);
- val |= (1 << GPIO0_DATA);
+ val &= ~BIT(GPIO1_DATA);
+ val |= BIT(GPIO0_DATA);
break;
default: /* (off/black) */
- val &= ~((1 << GPIO1_DATA) | (1 << GPIO0_DATA));
+ val &= ~(BIT(GPIO1_DATA) | BIT(GPIO0_DATA));
break;
}
writel (val, &dev->regs->gpioctl);
@@ -356,7 +357,7 @@ static inline void set_fifo_bytecount(struct net2280_ep *ep, unsigned count)
static inline void start_out_naking (struct net2280_ep *ep)
{
/* NOTE: hardware races lurk here, and PING protocol issues */
- writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
+ writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
/* synch with device */
readl (&ep->regs->ep_rsp);
}
@@ -366,10 +367,10 @@ static inline void assert_out_naking (struct net2280_ep *ep, const char *where)
{
u32 tmp = readl (&ep->regs->ep_stat);
- if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) {
+ if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
DEBUG (ep->dev, "%s %s %08x !NAK\n",
ep->ep.name, where, tmp);
- writel ((1 << SET_NAK_OUT_PACKETS),
+ writel(BIT(SET_NAK_OUT_PACKETS),
&ep->regs->ep_rsp);
}
}
@@ -383,8 +384,8 @@ static inline void stop_out_naking (struct net2280_ep *ep)
u32 tmp;
tmp = readl (&ep->regs->ep_stat);
- if ((tmp & (1 << NAK_OUT_PACKETS)) != 0)
- writel ((1 << CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
+ if ((tmp & BIT(NAK_OUT_PACKETS)) != 0)
+ writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
}
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/10] usb: gadget: net2280: Use true/false instead of 1/0
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (2 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 03/10] usb: gadget: net2280: Use BIT() macro Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 05/10] usb: gadget: net2280: Use module_pci_driver macro Ricardo Ribalda Delgado
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
For bool variables
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 5b9368d..b43725a 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -95,9 +95,9 @@ static const char *const ep_name [] = {
* Some gadget drivers work better with the dma support here than others.
* These two parameters let you use PIO or more aggressive DMA.
*/
-static bool use_dma = 1;
-static bool use_dma_chaining = 0;
-static bool use_msi = 1;
+static bool use_dma = true;
+static bool use_dma_chaining;
+static bool use_msi = true;
/* "modprobe net2280 use_dma=n" etc */
module_param (use_dma, bool, S_IRUGO);
@@ -118,7 +118,7 @@ module_param (fifo_mode, ushort, 0644);
* USB suspend requests will be ignored. This is acceptable for
* self-powered devices
*/
-static bool enable_suspend = 0;
+static bool enable_suspend;
/* "modprobe net2280 enable_suspend=1" etc */
module_param (enable_suspend, bool, S_IRUGO);
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/10] usb: gadget: net2280: Use module_pci_driver macro
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (3 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 04/10] usb: gadget: net2280: Use true/false instead of 1/0 Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 06/10] usb: gadget: net2280: Refactor queues_show Ricardo Ribalda Delgado
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index b43725a..bd851de 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -3588,6 +3588,9 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
void __iomem *base = NULL;
int retval, i;
+ if (!use_dma)
+ use_dma_chaining = 0;
+
/* alloc, and start init */
dev = kzalloc (sizeof *dev, GFP_KERNEL);
if (dev == NULL){
@@ -3833,20 +3836,8 @@ static struct pci_driver net2280_pci_driver = {
/* FIXME add power management support */
};
+module_pci_driver(net2280_pci_driver);
+
MODULE_DESCRIPTION (DRIVER_DESC);
MODULE_AUTHOR ("David Brownell");
MODULE_LICENSE ("GPL");
-
-static int __init init (void)
-{
- if (!use_dma)
- use_dma_chaining = 0;
- return pci_register_driver (&net2280_pci_driver);
-}
-module_init (init);
-
-static void __exit cleanup (void)
-{
- pci_unregister_driver (&net2280_pci_driver);
-}
-module_exit (cleanup);
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/10] usb: gadget: net2280: Refactor queues_show
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (4 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 05/10] usb: gadget: net2280: Use module_pci_driver macro Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 07/10 v3] usb: gadget: net2280: Pass checkpacth.pl test Ricardo Ribalda Delgado
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Replace a long and ugly expresion with an already available function.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index bd851de..c3205ec 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1777,15 +1777,7 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
"\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK,
(t & USB_DIR_IN) ? "in" : "out",
- ({ char *val;
- switch (d->bmAttributes & 0x03) {
- case USB_ENDPOINT_XFER_BULK:
- val = "bulk"; break;
- case USB_ENDPOINT_XFER_INT:
- val = "intr"; break;
- default:
- val = "iso"; break;
- } val; }),
+ type_string(d->bmAttributes),
usb_endpoint_maxp (d) & 0x1fff,
ep->dma ? "dma" : "pio", ep->fifo_size
);
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/10 v3] usb: gadget: net2280: Pass checkpacth.pl test
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (5 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 06/10] usb: gadget: net2280: Refactor queues_show Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 08/10 v2.1] usb: gadget: net2280: Code Cleanup Ricardo Ribalda Delgado
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Fix Code Style using checkpatch.pl criteria
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
v3: Comments by Alan Stern and David Laight
-Replace "extreme identation" with function names starting at
first column.
v2: Comments by Alan Stern
-Remove unneeded !!
-Fix typos on comment
drivers/usb/gadget/net2280.c | 1119 +++++++++++++++++++++---------------------
drivers/usb/gadget/net2280.h | 90 ++--
2 files changed, 602 insertions(+), 607 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index c3205ec..d1d4f4f 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -62,9 +62,9 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/prefetch.h>
+#include <linux/io.h>
#include <asm/byteorder.h>
-#include <asm/io.h>
#include <asm/irq.h>
#include <asm/unaligned.h>
@@ -76,12 +76,12 @@
#define USE_RDK_LEDS /* GPIO pins control three LEDs */
-static const char driver_name [] = "net2280";
-static const char driver_desc [] = DRIVER_DESC;
+static const char driver_name[] = "net2280";
+static const char driver_desc[] = DRIVER_DESC;
static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 };
-static const char ep0name [] = "ep0";
-static const char *const ep_name [] = {
+static const char ep0name[] = "ep0";
+static const char *const ep_name[] = {
ep0name,
"ep-a", "ep-b", "ep-c", "ep-d",
"ep-e", "ep-f", "ep-g", "ep-h",
@@ -100,15 +100,15 @@ static bool use_dma_chaining;
static bool use_msi = true;
/* "modprobe net2280 use_dma=n" etc */
-module_param (use_dma, bool, S_IRUGO);
-module_param (use_dma_chaining, bool, S_IRUGO);
+module_param(use_dma, bool, S_IRUGO);
+module_param(use_dma_chaining, bool, S_IRUGO);
module_param(use_msi, bool, S_IRUGO);
/* mode 0 == ep-{a,b,c,d} 1K fifo each
* mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
* mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
*/
-static ushort fifo_mode = 0;
+static ushort fifo_mode;
/* "modprobe net2280 fifo_mode=1" etc */
module_param (fifo_mode, ushort, 0644);
@@ -121,7 +121,7 @@ module_param (fifo_mode, ushort, 0644);
static bool enable_suspend;
/* "modprobe net2280 enable_suspend=1" etc */
-module_param (enable_suspend, bool, S_IRUGO);
+module_param(enable_suspend, bool, S_IRUGO);
/* force full-speed operation */
static bool full_speed;
@@ -130,8 +130,7 @@ MODULE_PARM_DESC(full_speed, "force full-speed mode -- for testing only!");
#define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
-#if defined(CONFIG_USB_GADGET_DEBUG_FILES) || defined (DEBUG)
-static char *type_string (u8 bmAttributes)
+static char *type_string(u8 bmAttributes)
{
switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) {
case USB_ENDPOINT_XFER_BULK: return "bulk";
@@ -140,7 +139,6 @@ static char *type_string (u8 bmAttributes)
}
return "control";
}
-#endif
#include "net2280.h"
@@ -162,7 +160,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
}
static int
-net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
+net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
{
struct net2280 *dev;
struct net2280_ep *ep;
@@ -170,7 +168,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
unsigned long flags;
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || !desc || ep->desc || _ep->name == ep0name
|| desc->bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL;
@@ -191,12 +189,12 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
}
/* sanity check ep-e/ep-f since their fifos are small */
- max = usb_endpoint_maxp (desc) & 0x1fff;
+ max = usb_endpoint_maxp(desc) & 0x1fff;
if (ep->num > 4 && max > 64 &&
(dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY))
return -ERANGE;
- spin_lock_irqsave (&dev->lock, flags);
+ spin_lock_irqsave(&dev->lock, flags);
_ep->maxpacket = max & 0x7ff;
ep->desc = desc;
@@ -212,7 +210,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
* use it instead of troublesome (non-bulk) multi-packet DMA.
*/
if (ep->dma && (max % 4) != 0 && use_dma_chaining) {
- DEBUG (ep->dev, "%s, no dma for maxpacket %d\n",
+ DEBUG(ep->dev, "%s, no dma for maxpacket %d\n",
ep->ep.name, ep->ep.maxpacket);
ep->dma = NULL;
}
@@ -236,7 +234,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
return -ERANGE;
}
}
- ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
+ ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
/* Enable this endpoint */
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) {
tmp <<= ENDPOINT_TYPE;
@@ -285,12 +283,12 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
if (dev->pdev->device == 0x2280)
- tmp |= readl (&ep->regs->ep_irqenb);
- writel (tmp, &ep->regs->ep_irqenb);
+ tmp |= readl(&ep->regs->ep_irqenb);
+ writel(tmp, &ep->regs->ep_irqenb);
} else { /* dma, per-request */
tmp = BIT((8 + ep->num)); /* completion */
- tmp |= readl (&dev->regs->pciirqenb1);
- writel (tmp, &dev->regs->pciirqenb1);
+ tmp |= readl(&dev->regs->pciirqenb1);
+ writel(tmp, &dev->regs->pciirqenb1);
/* for short OUT transfers, dma completions can't
* advance the queue; do it pio-style, by hand.
@@ -298,35 +296,35 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
*/
if ((desc->bEndpointAddress & USB_DIR_IN) == 0) {
tmp = BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
- writel (tmp, &ep->regs->ep_irqenb);
+ writel(tmp, &ep->regs->ep_irqenb);
enable_pciirqenb(ep);
}
}
tmp = desc->bEndpointAddress;
- DEBUG (dev, "enabled %s (ep%d%s-%s) %s max %04x\n",
- _ep->name, tmp & 0x0f, DIR_STRING (tmp),
- type_string (desc->bmAttributes),
+ DEBUG(dev, "enabled %s (ep%d%s-%s) %s max %04x\n",
+ _ep->name, tmp & 0x0f, DIR_STRING(tmp),
+ type_string(desc->bmAttributes),
ep->dma ? "dma" : "pio", max);
/* pci writes may still be posted */
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_unlock_irqrestore(&dev->lock, flags);
return 0;
}
-static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec)
+static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec)
{
u32 result;
do {
- result = readl (ptr);
+ result = readl(ptr);
if (result == ~(u32)0) /* "device unplugged" */
return -ENODEV;
result &= mask;
if (result == done)
return 0;
- udelay (1);
+ udelay(1);
usec--;
} while (usec > 0);
return -ETIMEDOUT;
@@ -340,28 +338,28 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
u32 tmp;
ep->desc = NULL;
- INIT_LIST_HEAD (&ep->queue);
+ INIT_LIST_HEAD(&ep->queue);
usb_ep_set_maxpacket_limit(&ep->ep, ~0);
ep->ep.ops = &net2280_ep_ops;
/* disable the dma, irqs, endpoint... */
if (ep->dma) {
- writel (0, &ep->dma->dmactl);
+ writel(0, &ep->dma->dmactl);
writel(BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
BIT(DMA_TRANSACTION_DONE_INTERRUPT) |
BIT(DMA_ABORT),
&ep->dma->dmastat);
- tmp = readl (®s->pciirqenb0);
+ tmp = readl(®s->pciirqenb0);
tmp &= ~BIT(ep->num);
- writel (tmp, ®s->pciirqenb0);
+ writel(tmp, ®s->pciirqenb0);
} else {
- tmp = readl (®s->pciirqenb1);
+ tmp = readl(®s->pciirqenb1);
tmp &= ~BIT((8 + ep->num)); /* completion */
- writel (tmp, ®s->pciirqenb1);
+ writel(tmp, ®s->pciirqenb1);
}
- writel (0, &ep->regs->ep_irqenb);
+ writel(0, &ep->regs->ep_irqenb);
/* init to our chosen defaults, notably so that we NAK OUT
* packets until the driver queues a read (+note erratum 0112)
@@ -383,7 +381,7 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
tmp |= BIT(CLEAR_ENDPOINT_TOGGLE) |
BIT(CLEAR_ENDPOINT_HALT);
}
- writel (tmp, &ep->regs->ep_rsp);
+ writel(tmp, &ep->regs->ep_rsp);
/* scrub most status bits, and flush any fifo state */
if (ep->dev->pdev->device == 0x2280)
@@ -459,64 +457,64 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
BIT(DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
}
-static void nuke (struct net2280_ep *);
+static void nuke(struct net2280_ep *);
-static int net2280_disable (struct usb_ep *_ep)
+static int net2280_disable(struct usb_ep *_ep)
{
struct net2280_ep *ep;
unsigned long flags;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || !ep->desc || _ep->name == ep0name)
return -EINVAL;
- spin_lock_irqsave (&ep->dev->lock, flags);
- nuke (ep);
+ spin_lock_irqsave(&ep->dev->lock, flags);
+ nuke(ep);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
ep_reset_338x(ep->dev->regs, ep);
else
ep_reset_228x(ep->dev->regs, ep);
- VDEBUG (ep->dev, "disabled %s %s\n",
+ VDEBUG(ep->dev, "disabled %s %s\n",
ep->dma ? "dma" : "pio", _ep->name);
/* synch memory views with the device */
(void)readl(&ep->cfg->ep_cfg);
if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4)
- ep->dma = &ep->dev->dma [ep->num - 1];
+ ep->dma = &ep->dev->dma[ep->num - 1];
- spin_unlock_irqrestore (&ep->dev->lock, flags);
+ spin_unlock_irqrestore(&ep->dev->lock, flags);
return 0;
}
/*-------------------------------------------------------------------------*/
-static struct usb_request *
-net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
+static struct usb_request
+*net2280_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
{
struct net2280_ep *ep;
struct net2280_request *req;
if (!_ep)
return NULL;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
req = kzalloc(sizeof(*req), gfp_flags);
if (!req)
return NULL;
- INIT_LIST_HEAD (&req->queue);
+ INIT_LIST_HEAD(&req->queue);
/* this dma descriptor may be swapped with the previous dummy */
if (ep->dma) {
struct net2280_dma *td;
- td = pci_pool_alloc (ep->dev->requests, gfp_flags,
+ td = pci_pool_alloc(ep->dev->requests, gfp_flags,
&req->td_dma);
if (!td) {
- kfree (req);
+ kfree(req);
return NULL;
}
td->dmacount = 0; /* not VALID */
@@ -526,21 +524,20 @@ net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
return &req->req;
}
-static void
-net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
+static void net2280_free_request(struct usb_ep *_ep, struct usb_request *_req)
{
struct net2280_ep *ep;
struct net2280_request *req;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || !_req)
return;
- req = container_of (_req, struct net2280_request, req);
- WARN_ON (!list_empty (&req->queue));
+ req = container_of(_req, struct net2280_request, req);
+ WARN_ON(!list_empty(&req->queue));
if (req->td)
- pci_pool_free (ep->dev->requests, req->td, req->td_dma);
- kfree (req);
+ pci_pool_free(ep->dev->requests, req->td, req->td_dma);
+ kfree(req);
}
/*-------------------------------------------------------------------------*/
@@ -552,8 +549,7 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
* at a time, but this code is simpler because it knows it only writes
* one packet. ep-a..ep-d should use dma instead.
*/
-static void
-write_fifo (struct net2280_ep *ep, struct usb_request *req)
+static void write_fifo(struct net2280_ep *ep, struct usb_request *req)
{
struct net2280_ep_regs __iomem *regs = ep->regs;
u8 *buf;
@@ -564,7 +560,7 @@ write_fifo (struct net2280_ep *ep, struct usb_request *req)
if (req) {
buf = req->buf + req->actual;
- prefetch (buf);
+ prefetch(buf);
total = req->length - req->actual;
} else {
total = 0;
@@ -576,7 +572,7 @@ write_fifo (struct net2280_ep *ep, struct usb_request *req)
if (count > total) /* min() cannot be used on a bitfield */
count = total;
- VDEBUG (ep->dev, "write %s fifo (IN) %d bytes%s req %p\n",
+ VDEBUG(ep->dev, "write %s fifo (IN) %d bytes%s req %p\n",
ep->ep.name, count,
(count != ep->ep.maxpacket) ? " (short)" : "",
req);
@@ -585,9 +581,9 @@ write_fifo (struct net2280_ep *ep, struct usb_request *req)
* should normally be full (4 bytes) and successive partial
* lines are ok only in certain cases.
*/
- tmp = get_unaligned ((u32 *)buf);
- cpu_to_le32s (&tmp);
- writel (tmp, ®s->ep_data);
+ tmp = get_unaligned((u32 *)buf);
+ cpu_to_le32s(&tmp);
+ writel(tmp, ®s->ep_data);
buf += 4;
count -= 4;
}
@@ -597,10 +593,10 @@ write_fifo (struct net2280_ep *ep, struct usb_request *req)
* when maxpacket is not a multiple of 4 bytes.
*/
if (count || total < ep->ep.maxpacket) {
- tmp = count ? get_unaligned ((u32 *)buf) : count;
- cpu_to_le32s (&tmp);
- set_fifo_bytecount (ep, count & 0x03);
- writel (tmp, ®s->ep_data);
+ tmp = count ? get_unaligned((u32 *)buf) : count;
+ cpu_to_le32s(&tmp);
+ set_fifo_bytecount(ep, count & 0x03);
+ writel(tmp, ®s->ep_data);
}
/* pci writes may still be posted */
@@ -613,20 +609,21 @@ write_fifo (struct net2280_ep *ep, struct usb_request *req)
* NOTE: also used in cases where that erratum doesn't apply:
* where the host wrote "too much" data to us.
*/
-static void out_flush (struct net2280_ep *ep)
+static void out_flush(struct net2280_ep *ep)
{
u32 __iomem *statp;
u32 tmp;
- ASSERT_OUT_NAKING (ep);
+ ASSERT_OUT_NAKING(ep);
statp = &ep->regs->ep_stat;
writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
BIT(DATA_PACKET_RECEIVED_INTERRUPT)
, statp);
writel(BIT(FIFO_FLUSH), statp);
- mb ();
- tmp = readl (statp);
+ /* Make sure that stap is written */
+ mb();
+ tmp = readl(statp);
if (tmp & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
/* high speed did bulk NYET; fifo isn't filling */
&& ep->dev->gadget.speed == USB_SPEED_FULL) {
@@ -646,8 +643,7 @@ static void out_flush (struct net2280_ep *ep)
* for ep-a..ep-d this will read multiple packets out when they
* have been accepted.
*/
-static int
-read_fifo (struct net2280_ep *ep, struct net2280_request *req)
+static int read_fifo(struct net2280_ep *ep, struct net2280_request *req)
{
struct net2280_ep_regs __iomem *regs = ep->regs;
u8 *buf = req->req.buf + req->req.actual;
@@ -659,12 +655,12 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
*/
if (ep->dev->chiprev == 0x0100
&& ep->dev->gadget.speed == USB_SPEED_FULL) {
- udelay (1);
- tmp = readl (&ep->regs->ep_stat);
+ udelay(1);
+ tmp = readl(&ep->regs->ep_stat);
if ((tmp & BIT(NAK_OUT_PACKETS)))
cleanup = 1;
else if ((tmp & BIT(FIFO_FULL))) {
- start_out_naking (ep);
+ start_out_naking(ep);
prevent = 1;
}
/* else: hope we don't see the problem */
@@ -673,12 +669,12 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
/* never overflow the rx buffer. the fifo reads packets until
* it sees a short one; we might not be ready for them all.
*/
- prefetchw (buf);
- count = readl (®s->ep_avail);
- if (unlikely (count == 0)) {
- udelay (1);
- tmp = readl (&ep->regs->ep_stat);
- count = readl (®s->ep_avail);
+ prefetchw(buf);
+ count = readl(®s->ep_avail);
+ if (unlikely(count == 0)) {
+ udelay(1);
+ tmp = readl(&ep->regs->ep_stat);
+ count = readl(®s->ep_avail);
/* handled that data already? */
if (count == 0 && (tmp & BIT(NAK_OUT_PACKETS)) == 0)
return 0;
@@ -688,7 +684,7 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
if (count > tmp) {
/* as with DMA, data overflow gets flushed */
if ((tmp % ep->ep.maxpacket) != 0) {
- ERROR (ep->dev,
+ ERROR(ep->dev,
"%s out fifo %d bytes, expected %d\n",
ep->ep.name, count, tmp);
req->req.status = -EOVERFLOW;
@@ -703,20 +699,20 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
is_short = (count == 0) || ((count % ep->ep.maxpacket) != 0);
- VDEBUG (ep->dev, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
+ VDEBUG(ep->dev, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
ep->ep.name, count, is_short ? " (short)" : "",
cleanup ? " flush" : "", prevent ? " nak" : "",
req, req->req.actual, req->req.length);
while (count >= 4) {
- tmp = readl (®s->ep_data);
- cpu_to_le32s (&tmp);
- put_unaligned (tmp, (u32 *)buf);
+ tmp = readl(®s->ep_data);
+ cpu_to_le32s(&tmp);
+ put_unaligned(tmp, (u32 *)buf);
buf += 4;
count -= 4;
}
if (count) {
- tmp = readl (®s->ep_data);
+ tmp = readl(®s->ep_data);
/* LE conversion is implicit here: */
do {
*buf++ = (u8) tmp;
@@ -724,10 +720,10 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
} while (--count);
}
if (cleanup)
- out_flush (ep);
+ out_flush(ep);
if (prevent) {
writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
- (void) readl (&ep->regs->ep_rsp);
+ (void) readl(&ep->regs->ep_rsp);
}
return is_short || ((req->req.actual == req->req.length)
@@ -735,8 +731,8 @@ read_fifo (struct net2280_ep *ep, struct net2280_request *req)
}
/* fill out dma descriptor to match a given request */
-static void
-fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
+static void fill_dma_desc(struct net2280_ep *ep,
+ struct net2280_request *req, int valid)
{
struct net2280_dma *td = req->td;
u32 dmacount = req->req.length;
@@ -762,7 +758,7 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
td->dmaaddr = cpu_to_le32 (req->req.dma);
/* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
- wmb ();
+ wmb();
td->dmacount = cpu_to_le32(dmacount);
}
@@ -777,18 +773,18 @@ static const u32 dmactl_default =
/* erratum 0116 workaround part 2 (no AUTOSTART) */
BIT(DMA_ENABLE);
-static inline void spin_stop_dma (struct net2280_dma_regs __iomem *dma)
+static inline void spin_stop_dma(struct net2280_dma_regs __iomem *dma)
{
handshake(&dma->dmactl, BIT(DMA_ENABLE), 0, 50);
}
-static inline void stop_dma (struct net2280_dma_regs __iomem *dma)
+static inline void stop_dma(struct net2280_dma_regs __iomem *dma)
{
writel(readl(&dma->dmactl) & ~BIT(DMA_ENABLE), &dma->dmactl);
- spin_stop_dma (dma);
+ spin_stop_dma(dma);
}
-static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
+static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma)
{
struct net2280_dma_regs __iomem *dma = ep->dma;
unsigned int tmp = BIT(VALID_BIT) | (ep->is_in << DMA_DIRECTION);
@@ -796,24 +792,24 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
if (ep->dev->pdev->device != 0x2280)
tmp |= BIT(END_OF_CHAIN);
- writel (tmp, &dma->dmacount);
- writel (readl (&dma->dmastat), &dma->dmastat);
+ writel(tmp, &dma->dmacount);
+ writel(readl(&dma->dmastat), &dma->dmastat);
- writel (td_dma, &dma->dmadesc);
+ writel(td_dma, &dma->dmadesc);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
dmactl |= BIT(DMA_REQUEST_OUTSTANDING);
- writel (dmactl, &dma->dmactl);
+ writel(dmactl, &dma->dmactl);
/* erratum 0116 workaround part 3: pci arbiter away from net2280 */
- (void) readl (&ep->dev->pci->pcimstctl);
+ (void) readl(&ep->dev->pci->pcimstctl);
writel(BIT(DMA_START), &dma->dmastat);
if (!ep->is_in)
- stop_out_naking (ep);
+ stop_out_naking(ep);
}
-static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
+static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
{
u32 tmp;
struct net2280_dma_regs __iomem *dma = ep->dma;
@@ -822,24 +818,24 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
/* on this path we "know" there's no dma active (yet) */
WARN_ON(readl(&dma->dmactl) & BIT(DMA_ENABLE));
- writel (0, &ep->dma->dmactl);
+ writel(0, &ep->dma->dmactl);
/* previous OUT packet might have been short */
- if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat))
- & BIT(NAK_OUT_PACKETS)) != 0) {
+ if (!ep->is_in && (readl(&ep->regs->ep_stat) &
+ BIT(NAK_OUT_PACKETS))) {
writel(BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT),
&ep->regs->ep_stat);
- tmp = readl (&ep->regs->ep_avail);
+ tmp = readl(&ep->regs->ep_avail);
if (tmp) {
- writel (readl (&dma->dmastat), &dma->dmastat);
+ writel(readl(&dma->dmastat), &dma->dmastat);
/* transfer all/some fifo data */
- writel (req->req.dma, &dma->dmaaddr);
- tmp = min (tmp, req->req.length);
+ writel(req->req.dma, &dma->dmaaddr);
+ tmp = min(tmp, req->req.length);
/* dma irq, faking scatterlist status */
- req->td->dmacount = cpu_to_le32 (req->req.length - tmp);
+ req->td->dmacount = cpu_to_le32(req->req.length - tmp);
writel(BIT(DMA_DONE_INTERRUPT_ENABLE)
| tmp, &dma->dmacount);
req->td->dmadesc = 0;
@@ -858,8 +854,8 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
* (zero length) unless the driver explicitly said to do that.
*/
if (ep->is_in) {
- if (likely ((req->req.length % ep->ep.maxpacket) != 0
- || req->req.zero)) {
+ if (likely((req->req.length % ep->ep.maxpacket) ||
+ req->req.zero)){
tmp |= BIT(DMA_FIFO_VALIDATE);
ep->in_fifo_validate = 1;
} else
@@ -868,12 +864,12 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
/* init req->td, pointing to the current dummy */
req->td->dmadesc = cpu_to_le32 (ep->td_dma);
- fill_dma_desc (ep, req, 1);
+ fill_dma_desc(ep, req, 1);
if (!use_dma_chaining)
req->td->dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
- start_queue (ep, tmp, req->td_dma);
+ start_queue(ep, tmp, req->td_dma);
}
static inline void resume_dma(struct net2280_ep *ep)
@@ -892,7 +888,7 @@ static inline void ep_stop_dma(struct net2280_ep *ep)
}
static inline void
-queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid)
+queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
{
struct net2280_dma *end;
dma_addr_t tmp;
@@ -908,16 +904,16 @@ queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid)
end->dmadesc = cpu_to_le32 (ep->td_dma);
- fill_dma_desc (ep, req, valid);
+ fill_dma_desc(ep, req, valid);
}
static void
-done (struct net2280_ep *ep, struct net2280_request *req, int status)
+done(struct net2280_ep *ep, struct net2280_request *req, int status)
{
struct net2280 *dev;
unsigned stopped = ep->stopped;
- list_del_init (&req->queue);
+ list_del_init(&req->queue);
if (req->req.status == -EINPROGRESS)
req->req.status = status;
@@ -929,22 +925,22 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status)
usb_gadget_unmap_request(&dev->gadget, &req->req, ep->is_in);
if (status && status != -ESHUTDOWN)
- VDEBUG (dev, "complete %s req %p stat %d len %u/%u\n",
+ VDEBUG(dev, "complete %s req %p stat %d len %u/%u\n",
ep->ep.name, &req->req, status,
req->req.actual, req->req.length);
/* don't modify queue heads during completion callback */
ep->stopped = 1;
- spin_unlock (&dev->lock);
- req->req.complete (&ep->ep, &req->req);
- spin_lock (&dev->lock);
+ spin_unlock(&dev->lock);
+ req->req.complete(&ep->ep, &req->req);
+ spin_lock(&dev->lock);
ep->stopped = stopped;
}
/*-------------------------------------------------------------------------*/
static int
-net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
+net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
{
struct net2280_request *req;
struct net2280_ep *ep;
@@ -954,13 +950,13 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* we always require a cpu-view buffer, so that we can
* always use pio (as fallback or whatever).
*/
- req = container_of (_req, struct net2280_request, req);
- if (!_req || !_req->complete || !_req->buf
- || !list_empty (&req->queue))
+ req = container_of(_req, struct net2280_request, req);
+ if (!_req || !_req->complete || !_req->buf ||
+ !list_empty(&req->queue))
return -EINVAL;
if (_req->length > (~0 & DMA_BYTE_COUNT_MASK))
return -EDOM;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0))
return -EINVAL;
dev = ep->dev;
@@ -982,17 +978,17 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
}
#if 0
- VDEBUG (dev, "%s queue req %p, len %d buf %p\n",
+ VDEBUG(dev, "%s queue req %p, len %d buf %p\n",
_ep->name, _req, _req->length, _req->buf);
#endif
- spin_lock_irqsave (&dev->lock, flags);
+ spin_lock_irqsave(&dev->lock, flags);
_req->status = -EINPROGRESS;
_req->actual = 0;
/* kickstart this i/o queue? */
- if (list_empty (&ep->queue) && !ep->stopped) {
+ if (list_empty(&ep->queue) && !ep->stopped) {
/* DMA request while EP halted */
if (ep->dma &&
(readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)) &&
@@ -1010,24 +1006,24 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
}
/* use DMA if the endpoint supports it, else pio */
else if (ep->dma)
- start_dma (ep, req);
+ start_dma(ep, req);
else {
/* maybe there's no control data, just status ack */
if (ep->num == 0 && _req->length == 0) {
- allow_status (ep);
- done (ep, req, 0);
- VDEBUG (dev, "%s status ack\n", ep->ep.name);
+ allow_status(ep);
+ done(ep, req, 0);
+ VDEBUG(dev, "%s status ack\n", ep->ep.name);
goto done;
}
/* PIO ... stuff the fifo, or unblock it. */
if (ep->is_in)
- write_fifo (ep, _req);
- else if (list_empty (&ep->queue)) {
+ write_fifo(ep, _req);
+ else if (list_empty(&ep->queue)) {
u32 s;
/* OUT FIFO might have packet(s) buffered */
- s = readl (&ep->regs->ep_stat);
+ s = readl(&ep->regs->ep_stat);
if ((s & BIT(FIFO_EMPTY)) == 0) {
/* note: _req->short_not_ok is
* ignored here since PIO _always_
@@ -1035,14 +1031,18 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
* _req->status doesn't change for
* short reads (only _req->actual)
*/
- if (read_fifo (ep, req)) {
- done (ep, req, 0);
- if (ep->num == 0)
- allow_status (ep);
+ if (read_fifo(ep, req) &&
+ ep->num == 0) {
+ done(ep, req, 0);
+ allow_status(ep);
/* don't queue it */
req = NULL;
+ } else if (read_fifo(ep, req) &&
+ ep->num != 0) {
+ done(ep, req, 0);
+ req = NULL;
} else
- s = readl (&ep->regs->ep_stat);
+ s = readl(&ep->regs->ep_stat);
}
/* don't NAK, let the fifo fill */
@@ -1061,54 +1061,50 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* preventing magic zlps is per-engine state, not
* per-transfer; irq logic must recover hiccups.
*/
- expect = likely (req->req.zero
- || (req->req.length % ep->ep.maxpacket) != 0);
+ expect = likely(req->req.zero ||
+ (req->req.length % ep->ep.maxpacket));
if (expect != ep->in_fifo_validate)
valid = 0;
}
- queue_dma (ep, req, valid);
+ queue_dma(ep, req, valid);
} /* else the irq handler advances the queue. */
ep->responded = 1;
if (req)
- list_add_tail (&req->queue, &ep->queue);
+ list_add_tail(&req->queue, &ep->queue);
done:
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_unlock_irqrestore(&dev->lock, flags);
/* pci writes may still be posted */
return 0;
}
static inline void
-dma_done (
- struct net2280_ep *ep,
- struct net2280_request *req,
- u32 dmacount,
- int status
-)
+dma_done(struct net2280_ep *ep, struct net2280_request *req, u32 dmacount,
+ int status)
{
req->req.actual = req->req.length - (DMA_BYTE_COUNT_MASK & dmacount);
- done (ep, req, status);
+ done(ep, req, status);
}
-static void restart_dma (struct net2280_ep *ep);
+static void restart_dma(struct net2280_ep *ep);
-static void scan_dma_completions (struct net2280_ep *ep)
+static void scan_dma_completions(struct net2280_ep *ep)
{
/* only look at descriptors that were "naturally" retired,
* so fifo and list head state won't matter
*/
- while (!list_empty (&ep->queue)) {
+ while (!list_empty(&ep->queue)) {
struct net2280_request *req;
u32 tmp;
- req = list_entry (ep->queue.next,
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
if (!req->valid)
break;
- rmb ();
- tmp = le32_to_cpup (&req->td->dmacount);
+ rmb();
+ tmp = le32_to_cpup(&req->td->dmacount);
if ((tmp & BIT(VALID_BIT)) != 0)
break;
@@ -1116,17 +1112,17 @@ static void scan_dma_completions (struct net2280_ep *ep)
* cases where DMA must be aborted; this code handles
* all non-abort DMA completions.
*/
- if (unlikely (req->td->dmadesc == 0)) {
+ if (unlikely(req->td->dmadesc == 0)) {
/* paranoia */
- tmp = readl (&ep->dma->dmacount);
+ tmp = readl(&ep->dma->dmacount);
if (tmp & DMA_BYTE_COUNT_MASK)
break;
/* single transfer mode */
- dma_done (ep, req, tmp, 0);
+ dma_done(ep, req, tmp, 0);
break;
} else if (!ep->is_in
&& (req->req.length % ep->ep.maxpacket) != 0) {
- tmp = readl (&ep->regs->ep_stat);
+ tmp = readl(&ep->regs->ep_stat);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
@@ -1135,33 +1131,37 @@ static void scan_dma_completions (struct net2280_ep *ep)
* 0122, and 0124; not all cases trigger the warning.
*/
if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
- WARNING (ep->dev, "%s lost packet sync!\n",
+ WARNING(ep->dev, "%s lost packet sync!\n",
ep->ep.name);
req->req.status = -EOVERFLOW;
- } else if ((tmp = readl (&ep->regs->ep_avail)) != 0) {
- /* fifo gets flushed later */
- ep->out_overflow = 1;
- DEBUG (ep->dev, "%s dma, discard %d len %d\n",
+ } else {
+ tmp = readl(&ep->regs->ep_avail);
+ if (tmp) {
+ /* fifo gets flushed later */
+ ep->out_overflow = 1;
+ DEBUG(ep->dev,
+ "%s dma, discard %d len %d\n",
ep->ep.name, tmp,
req->req.length);
- req->req.status = -EOVERFLOW;
+ req->req.status = -EOVERFLOW;
+ }
}
}
- dma_done (ep, req, tmp, 0);
+ dma_done(ep, req, tmp, 0);
}
}
-static void restart_dma (struct net2280_ep *ep)
+static void restart_dma(struct net2280_ep *ep)
{
struct net2280_request *req;
u32 dmactl = dmactl_default;
if (ep->stopped)
return;
- req = list_entry (ep->queue.next, struct net2280_request, queue);
+ req = list_entry(ep->queue.next, struct net2280_request, queue);
if (!use_dma_chaining) {
- start_dma (ep, req);
+ start_dma(ep, req);
return;
}
@@ -1175,21 +1175,20 @@ static void restart_dma (struct net2280_ep *ep)
struct net2280_request *entry, *prev = NULL;
int reqmode, done = 0;
- DEBUG (ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td);
- ep->in_fifo_validate = likely (req->req.zero
- || (req->req.length % ep->ep.maxpacket) != 0);
+ DEBUG(ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td);
+ ep->in_fifo_validate = likely(req->req.zero ||
+ (req->req.length % ep->ep.maxpacket) != 0);
if (ep->in_fifo_validate)
dmactl |= BIT(DMA_FIFO_VALIDATE);
- list_for_each_entry (entry, &ep->queue, queue) {
+ list_for_each_entry(entry, &ep->queue, queue) {
__le32 dmacount;
if (entry == req)
continue;
dmacount = entry->td->dmacount;
if (!done) {
- reqmode = likely (entry->req.zero
- || (entry->req.length
- % ep->ep.maxpacket) != 0);
+ reqmode = likely(entry->req.zero ||
+ (entry->req.length % ep->ep.maxpacket));
if (reqmode == ep->in_fifo_validate) {
entry->valid = 1;
dmacount |= valid_bit;
@@ -1211,20 +1210,20 @@ static void restart_dma (struct net2280_ep *ep)
}
}
- writel (0, &ep->dma->dmactl);
- start_queue (ep, dmactl, req->td_dma);
+ writel(0, &ep->dma->dmactl);
+ start_queue(ep, dmactl, req->td_dma);
}
static void abort_dma_228x(struct net2280_ep *ep)
{
/* abort the current transfer */
- if (likely (!list_empty (&ep->queue))) {
+ if (likely(!list_empty(&ep->queue))) {
/* FIXME work around errata 0121, 0122, 0124 */
writel(BIT(DMA_ABORT), &ep->dma->dmastat);
- spin_stop_dma (ep->dma);
+ spin_stop_dma(ep->dma);
} else
- stop_dma (ep->dma);
- scan_dma_completions (ep);
+ stop_dma(ep->dma);
+ scan_dma_completions(ep);
}
static void abort_dma_338x(struct net2280_ep *ep)
@@ -1241,24 +1240,24 @@ static void abort_dma(struct net2280_ep *ep)
}
/* dequeue ALL requests */
-static void nuke (struct net2280_ep *ep)
+static void nuke(struct net2280_ep *ep)
{
struct net2280_request *req;
/* called with spinlock held */
ep->stopped = 1;
if (ep->dma)
- abort_dma (ep);
- while (!list_empty (&ep->queue)) {
- req = list_entry (ep->queue.next,
+ abort_dma(ep);
+ while (!list_empty(&ep->queue)) {
+ req = list_entry(ep->queue.next,
struct net2280_request,
queue);
- done (ep, req, -ESHUTDOWN);
+ done(ep, req, -ESHUTDOWN);
}
}
/* dequeue JUST ONE request */
-static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req)
+static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{
struct net2280_ep *ep;
struct net2280_request *req;
@@ -1266,65 +1265,65 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req)
u32 dmactl;
int stopped;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0) || !_req)
return -EINVAL;
- spin_lock_irqsave (&ep->dev->lock, flags);
+ spin_lock_irqsave(&ep->dev->lock, flags);
stopped = ep->stopped;
/* quiesce dma while we patch the queue */
dmactl = 0;
ep->stopped = 1;
if (ep->dma) {
- dmactl = readl (&ep->dma->dmactl);
+ dmactl = readl(&ep->dma->dmactl);
/* WARNING erratum 0127 may kick in ... */
- stop_dma (ep->dma);
- scan_dma_completions (ep);
+ stop_dma(ep->dma);
+ scan_dma_completions(ep);
}
/* make sure it's still queued on this endpoint */
- list_for_each_entry (req, &ep->queue, queue) {
+ list_for_each_entry(req, &ep->queue, queue) {
if (&req->req == _req)
break;
}
if (&req->req != _req) {
- spin_unlock_irqrestore (&ep->dev->lock, flags);
+ spin_unlock_irqrestore(&ep->dev->lock, flags);
return -EINVAL;
}
/* queue head may be partially complete. */
if (ep->queue.next == &req->queue) {
if (ep->dma) {
- DEBUG (ep->dev, "unlink (%s) dma\n", _ep->name);
+ DEBUG(ep->dev, "unlink (%s) dma\n", _ep->name);
_req->status = -ECONNRESET;
- abort_dma (ep);
- if (likely (ep->queue.next == &req->queue)) {
- // NOTE: misreports single-transfer mode
+ abort_dma(ep);
+ if (likely(ep->queue.next == &req->queue)) {
+ /* NOTE: misreports single-transfer mode*/
req->td->dmacount = 0; /* invalidate */
- dma_done (ep, req,
- readl (&ep->dma->dmacount),
+ dma_done(ep, req,
+ readl(&ep->dma->dmacount),
-ECONNRESET);
}
} else {
- DEBUG (ep->dev, "unlink (%s) pio\n", _ep->name);
- done (ep, req, -ECONNRESET);
+ DEBUG(ep->dev, "unlink (%s) pio\n", _ep->name);
+ done(ep, req, -ECONNRESET);
}
req = NULL;
/* patch up hardware chaining data */
} else if (ep->dma && use_dma_chaining) {
if (req->queue.prev == ep->queue.next) {
- writel (le32_to_cpu (req->td->dmadesc),
+ writel(le32_to_cpu(req->td->dmadesc),
&ep->dma->dmadesc);
if (req->td->dmacount & dma_done_ie)
- writel (readl (&ep->dma->dmacount)
+ writel(readl(&ep->dma->dmacount)
| le32_to_cpu(dma_done_ie),
&ep->dma->dmacount);
} else {
struct net2280_request *prev;
- prev = list_entry (req->queue.prev,
+ prev = list_entry(req->queue.prev,
struct net2280_request, queue);
prev->td->dmadesc = req->td->dmadesc;
if (req->td->dmacount & dma_done_ie)
@@ -1333,30 +1332,30 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req)
}
if (req)
- done (ep, req, -ECONNRESET);
+ done(ep, req, -ECONNRESET);
ep->stopped = stopped;
if (ep->dma) {
/* turn off dma on inactive queues */
- if (list_empty (&ep->queue))
- stop_dma (ep->dma);
+ if (list_empty(&ep->queue))
+ stop_dma(ep->dma);
else if (!ep->stopped) {
/* resume current request, or start new one */
if (req)
- writel (dmactl, &ep->dma->dmactl);
+ writel(dmactl, &ep->dma->dmactl);
else
- start_dma (ep, list_entry (ep->queue.next,
+ start_dma(ep, list_entry(ep->queue.next,
struct net2280_request, queue));
}
}
- spin_unlock_irqrestore (&ep->dev->lock, flags);
+ spin_unlock_irqrestore(&ep->dev->lock, flags);
return 0;
}
/*-------------------------------------------------------------------------*/
-static int net2280_fifo_status (struct usb_ep *_ep);
+static int net2280_fifo_status(struct usb_ep *_ep);
static int
net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
@@ -1365,7 +1364,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
unsigned long flags;
int retval = 0;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0))
return -EINVAL;
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
@@ -1374,13 +1373,13 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
== USB_ENDPOINT_XFER_ISOC)
return -EINVAL;
- spin_lock_irqsave (&ep->dev->lock, flags);
- if (!list_empty (&ep->queue))
+ spin_lock_irqsave(&ep->dev->lock, flags);
+ if (!list_empty(&ep->queue))
retval = -EAGAIN;
- else if (ep->is_in && value && net2280_fifo_status (_ep) != 0)
+ else if (ep->is_in && value && net2280_fifo_status(_ep) != 0)
retval = -EAGAIN;
else {
- VDEBUG (ep->dev, "%s %s %s\n", _ep->name,
+ VDEBUG(ep->dev, "%s %s %s\n", _ep->name,
value ? "set" : "clear",
wedged ? "wedge" : "halt");
/* set/clear, then synch memory views with the device */
@@ -1388,44 +1387,41 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
if (ep->num == 0)
ep->dev->protocol_stall = 1;
else
- set_halt (ep);
+ set_halt(ep);
if (wedged)
ep->wedged = 1;
} else {
- clear_halt (ep);
+ clear_halt(ep);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX &&
!list_empty(&ep->queue) && ep->td_dma)
restart_dma(ep);
ep->wedged = 0;
}
- (void) readl (&ep->regs->ep_rsp);
+ (void) readl(&ep->regs->ep_rsp);
}
- spin_unlock_irqrestore (&ep->dev->lock, flags);
+ spin_unlock_irqrestore(&ep->dev->lock, flags);
return retval;
}
-static int
-net2280_set_halt(struct usb_ep *_ep, int value)
+static int net2280_set_halt(struct usb_ep *_ep, int value)
{
return net2280_set_halt_and_wedge(_ep, value, 0);
}
-static int
-net2280_set_wedge(struct usb_ep *_ep)
+static int net2280_set_wedge(struct usb_ep *_ep)
{
if (!_ep || _ep->name == ep0name)
return -EINVAL;
return net2280_set_halt_and_wedge(_ep, 1, 1);
}
-static int
-net2280_fifo_status (struct usb_ep *_ep)
+static int net2280_fifo_status(struct usb_ep *_ep)
{
struct net2280_ep *ep;
u32 avail;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0))
return -ENODEV;
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
@@ -1439,19 +1435,18 @@ net2280_fifo_status (struct usb_ep *_ep)
return avail;
}
-static void
-net2280_fifo_flush (struct usb_ep *_ep)
+static void net2280_fifo_flush(struct usb_ep *_ep)
{
struct net2280_ep *ep;
- ep = container_of (_ep, struct net2280_ep, ep);
+ ep = container_of(_ep, struct net2280_ep, ep);
if (!_ep || (!ep->desc && ep->num != 0))
return;
if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
return;
writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
- (void) readl (&ep->regs->ep_rsp);
+ (void) readl(&ep->regs->ep_rsp);
}
static const struct usb_ep_ops net2280_ep_ops = {
@@ -1472,7 +1467,7 @@ static const struct usb_ep_ops net2280_ep_ops = {
/*-------------------------------------------------------------------------*/
-static int net2280_get_frame (struct usb_gadget *_gadget)
+static int net2280_get_frame(struct usb_gadget *_gadget)
{
struct net2280 *dev;
unsigned long flags;
@@ -1480,14 +1475,14 @@ static int net2280_get_frame (struct usb_gadget *_gadget)
if (!_gadget)
return -ENODEV;
- dev = container_of (_gadget, struct net2280, gadget);
- spin_lock_irqsave (&dev->lock, flags);
- retval = get_idx_reg (dev->regs, REG_FRAME) & 0x03ff;
- spin_unlock_irqrestore (&dev->lock, flags);
+ dev = container_of(_gadget, struct net2280, gadget);
+ spin_lock_irqsave(&dev->lock, flags);
+ retval = get_idx_reg(dev->regs, REG_FRAME) & 0x03ff;
+ spin_unlock_irqrestore(&dev->lock, flags);
return retval;
}
-static int net2280_wakeup (struct usb_gadget *_gadget)
+static int net2280_wakeup(struct usb_gadget *_gadget)
{
struct net2280 *dev;
u32 tmp;
@@ -1495,19 +1490,19 @@ static int net2280_wakeup (struct usb_gadget *_gadget)
if (!_gadget)
return 0;
- dev = container_of (_gadget, struct net2280, gadget);
+ dev = container_of(_gadget, struct net2280, gadget);
- spin_lock_irqsave (&dev->lock, flags);
- tmp = readl (&dev->usb->usbctl);
+ spin_lock_irqsave(&dev->lock, flags);
+ tmp = readl(&dev->usb->usbctl);
if (tmp & BIT(DEVICE_REMOTE_WAKEUP_ENABLE))
writel(BIT(GENERATE_RESUME), &dev->usb->usbstat);
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_unlock_irqrestore(&dev->lock, flags);
/* pci writes may still be posted */
return 0;
}
-static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
+static int net2280_set_selfpowered(struct usb_gadget *_gadget, int value)
{
struct net2280 *dev;
u32 tmp;
@@ -1515,10 +1510,10 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
if (!_gadget)
return 0;
- dev = container_of (_gadget, struct net2280, gadget);
+ dev = container_of(_gadget, struct net2280, gadget);
- spin_lock_irqsave (&dev->lock, flags);
- tmp = readl (&dev->usb->usbctl);
+ spin_lock_irqsave(&dev->lock, flags);
+ tmp = readl(&dev->usb->usbctl);
if (value) {
tmp |= BIT(SELF_POWERED_STATUS);
dev->selfpowered = 1;
@@ -1526,8 +1521,8 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
tmp &= ~BIT(SELF_POWERED_STATUS);
dev->selfpowered = 0;
}
- writel (tmp, &dev->usb->usbctl);
- spin_unlock_irqrestore (&dev->lock, flags);
+ writel(tmp, &dev->usb->usbctl);
+ spin_unlock_irqrestore(&dev->lock, flags);
return 0;
}
@@ -1540,17 +1535,17 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
if (!_gadget)
return -ENODEV;
- dev = container_of (_gadget, struct net2280, gadget);
+ dev = container_of(_gadget, struct net2280, gadget);
- spin_lock_irqsave (&dev->lock, flags);
- tmp = readl (&dev->usb->usbctl);
+ spin_lock_irqsave(&dev->lock, flags);
+ tmp = readl(&dev->usb->usbctl);
dev->softconnect = (is_on != 0);
if (is_on)
tmp |= BIT(USB_DETECT_ENABLE);
else
tmp &= ~BIT(USB_DETECT_ENABLE);
- writel (tmp, &dev->usb->usbctl);
- spin_unlock_irqrestore (&dev->lock, flags);
+ writel(tmp, &dev->usb->usbctl);
+ spin_unlock_irqrestore(&dev->lock, flags);
return 0;
}
@@ -1582,13 +1577,12 @@ static const struct usb_gadget_ops net2280_ops = {
static ssize_t function_show(struct device *_dev, struct device_attribute *attr,
char *buf)
{
- struct net2280 *dev = dev_get_drvdata (_dev);
+ struct net2280 *dev = dev_get_drvdata(_dev);
- if (!dev->driver
- || !dev->driver->function
- || strlen (dev->driver->function) > PAGE_SIZE)
+ if (!dev->driver || !dev->driver->function ||
+ strlen(dev->driver->function) > PAGE_SIZE)
return 0;
- return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function);
+ return scnprintf(buf, PAGE_SIZE, "%s\n", dev->driver->function);
}
static DEVICE_ATTR_RO(function);
@@ -1603,10 +1597,10 @@ static ssize_t registers_show(struct device *_dev,
u32 t1, t2;
const char *s;
- dev = dev_get_drvdata (_dev);
+ dev = dev_get_drvdata(_dev);
next = buf;
size = PAGE_SIZE;
- spin_lock_irqsave (&dev->lock, flags);
+ spin_lock_irqsave(&dev->lock, flags);
if (dev->driver)
s = dev->driver->driver.name;
@@ -1614,7 +1608,7 @@ static ssize_t registers_show(struct device *_dev,
s = "(none)";
/* Main Control Registers */
- t = scnprintf (next, size, "%s version " DRIVER_VERSION
+ t = scnprintf(next, size, "%s version " DRIVER_VERSION
", chiprev %04x, dma %s\n\n"
"devinit %03x fifoctl %08x gadget '%s'\n"
"pci irqenb0 %02x irqenb1 %08x "
@@ -1623,19 +1617,19 @@ static ssize_t registers_show(struct device *_dev,
use_dma
? (use_dma_chaining ? "chaining" : "enabled")
: "disabled",
- readl (&dev->regs->devinit),
- readl (&dev->regs->fifoctl),
+ readl(&dev->regs->devinit),
+ readl(&dev->regs->fifoctl),
s,
- readl (&dev->regs->pciirqenb0),
- readl (&dev->regs->pciirqenb1),
- readl (&dev->regs->irqstat0),
- readl (&dev->regs->irqstat1));
+ readl(&dev->regs->pciirqenb0),
+ readl(&dev->regs->pciirqenb1),
+ readl(&dev->regs->irqstat0),
+ readl(&dev->regs->irqstat1));
size -= t;
next += t;
/* USB Control Registers */
- t1 = readl (&dev->usb->usbctl);
- t2 = readl (&dev->usb->usbstat);
+ t1 = readl(&dev->usb->usbctl);
+ t2 = readl(&dev->usb->usbstat);
if (t1 & BIT(VBUS_PIN)) {
if (t2 & BIT(HIGH_SPEED))
s = "high speed";
@@ -1646,11 +1640,11 @@ static ssize_t registers_show(struct device *_dev,
/* full speed bit (6) not working?? */
} else
s = "not attached";
- t = scnprintf (next, size,
+ t = scnprintf(next, size,
"stdrsp %08x usbctl %08x usbstat %08x "
"addr 0x%02x (%s)\n",
- readl (&dev->usb->stdrsp), t1, t2,
- readl (&dev->usb->ouraddr), s);
+ readl(&dev->usb->stdrsp), t1, t2,
+ readl(&dev->usb->ouraddr), s);
size -= t;
next += t;
@@ -1662,13 +1656,13 @@ static ssize_t registers_show(struct device *_dev,
for (i = 0; i < dev->n_ep; i++) {
struct net2280_ep *ep;
- ep = &dev->ep [i];
+ ep = &dev->ep[i];
if (i && !ep->desc)
continue;
t1 = readl(&ep->cfg->ep_cfg);
- t2 = readl (&ep->regs->ep_rsp) & 0xff;
- t = scnprintf (next, size,
+ t2 = readl(&ep->regs->ep_rsp) & 0xff;
+ t = scnprintf(next, size,
"\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
"irqenb %02x\n",
ep->ep.name, t1, t2,
@@ -1688,17 +1682,17 @@ static ssize_t registers_show(struct device *_dev,
? "DATA1 " : "DATA0 ",
(t2 & BIT(CLEAR_ENDPOINT_HALT))
? "HALT " : "",
- readl (&ep->regs->ep_irqenb));
+ readl(&ep->regs->ep_irqenb));
size -= t;
next += t;
- t = scnprintf (next, size,
+ t = scnprintf(next, size,
"\tstat %08x avail %04x "
"(ep%d%s-%s)%s\n",
- readl (&ep->regs->ep_stat),
- readl (&ep->regs->ep_avail),
- t1 & 0x0f, DIR_STRING (t1),
- type_string (t1 >> 8),
+ readl(&ep->regs->ep_stat),
+ readl(&ep->regs->ep_avail),
+ t1 & 0x0f, DIR_STRING(t1),
+ type_string(t1 >> 8),
ep->stopped ? "*" : "");
size -= t;
next += t;
@@ -1706,42 +1700,41 @@ static ssize_t registers_show(struct device *_dev,
if (!ep->dma)
continue;
- t = scnprintf (next, size,
+ t = scnprintf(next, size,
" dma\tctl %08x stat %08x count %08x\n"
"\taddr %08x desc %08x\n",
- readl (&ep->dma->dmactl),
- readl (&ep->dma->dmastat),
- readl (&ep->dma->dmacount),
- readl (&ep->dma->dmaaddr),
- readl (&ep->dma->dmadesc));
+ readl(&ep->dma->dmactl),
+ readl(&ep->dma->dmastat),
+ readl(&ep->dma->dmacount),
+ readl(&ep->dma->dmaaddr),
+ readl(&ep->dma->dmadesc));
size -= t;
next += t;
}
- /* Indexed Registers */
- // none yet
+ /* Indexed Registers (none yet) */
/* Statistics */
- t = scnprintf (next, size, "\nirqs: ");
+ t = scnprintf(next, size, "\nirqs: ");
size -= t;
next += t;
for (i = 0; i < dev->n_ep; i++) {
struct net2280_ep *ep;
- ep = &dev->ep [i];
+ ep = &dev->ep[i];
if (i && !ep->irqs)
continue;
- t = scnprintf (next, size, " %s/%lu", ep->ep.name, ep->irqs);
+ t = scnprintf(next, size, " %s/%lu", ep->ep.name, ep->irqs);
size -= t;
next += t;
}
- t = scnprintf (next, size, "\n");
+ t = scnprintf(next, size, "\n");
size -= t;
next += t;
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_unlock_irqrestore(&dev->lock, flags);
return PAGE_SIZE - size;
}
@@ -1756,13 +1749,13 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
unsigned long flags;
int i;
- dev = dev_get_drvdata (_dev);
+ dev = dev_get_drvdata(_dev);
next = buf;
size = PAGE_SIZE;
- spin_lock_irqsave (&dev->lock, flags);
+ spin_lock_irqsave(&dev->lock, flags);
for (i = 0; i < dev->n_ep; i++) {
- struct net2280_ep *ep = &dev->ep [i];
+ struct net2280_ep *ep = &dev->ep[i];
struct net2280_request *req;
int t;
@@ -1773,40 +1766,40 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
if (!d)
continue;
t = d->bEndpointAddress;
- t = scnprintf (next, size,
+ t = scnprintf(next, size,
"\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK,
(t & USB_DIR_IN) ? "in" : "out",
type_string(d->bmAttributes),
- usb_endpoint_maxp (d) & 0x1fff,
+ usb_endpoint_maxp(d) & 0x1fff,
ep->dma ? "dma" : "pio", ep->fifo_size
);
} else /* ep0 should only have one transfer queued */
- t = scnprintf (next, size, "ep0 max 64 pio %s\n",
+ t = scnprintf(next, size, "ep0 max 64 pio %s\n",
ep->is_in ? "in" : "out");
if (t <= 0 || t > size)
goto done;
size -= t;
next += t;
- if (list_empty (&ep->queue)) {
- t = scnprintf (next, size, "\t(nothing queued)\n");
+ if (list_empty(&ep->queue)) {
+ t = scnprintf(next, size, "\t(nothing queued)\n");
if (t <= 0 || t > size)
goto done;
size -= t;
next += t;
continue;
}
- list_for_each_entry (req, &ep->queue, queue) {
- if (ep->dma && req->td_dma == readl (&ep->dma->dmadesc))
- t = scnprintf (next, size,
+ list_for_each_entry(req, &ep->queue, queue) {
+ if (ep->dma && req->td_dma == readl(&ep->dma->dmadesc))
+ t = scnprintf(next, size,
"\treq %p len %d/%d "
"buf %p (dmacount %08x)\n",
&req->req, req->req.actual,
req->req.length, req->req.buf,
- readl (&ep->dma->dmacount));
+ readl(&ep->dma->dmacount));
else
- t = scnprintf (next, size,
+ t = scnprintf(next, size,
"\treq %p len %d/%d buf %p\n",
&req->req, req->req.actual,
req->req.length, req->req.buf);
@@ -1819,12 +1812,12 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
struct net2280_dma *td;
td = req->td;
- t = scnprintf (next, size, "\t td %08x "
+ t = scnprintf(next, size, "\t td %08x "
" count %08x buf %08x desc %08x\n",
(u32) req->td_dma,
- le32_to_cpu (td->dmacount),
- le32_to_cpu (td->dmaaddr),
- le32_to_cpu (td->dmadesc));
+ le32_to_cpu(td->dmacount),
+ le32_to_cpu(td->dmaaddr),
+ le32_to_cpu(td->dmadesc));
if (t <= 0 || t > size)
goto done;
size -= t;
@@ -1834,7 +1827,7 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
}
done:
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_unlock_irqrestore(&dev->lock, flags);
return PAGE_SIZE - size;
}
static DEVICE_ATTR_RO(queues);
@@ -1842,8 +1835,8 @@ static DEVICE_ATTR_RO(queues);
#else
-#define device_create_file(a,b) (0)
-#define device_remove_file(a,b) do { } while (0)
+#define device_create_file(a, b) (0)
+#define device_remove_file(a, b) do { } while (0)
#endif
@@ -1853,33 +1846,33 @@ static DEVICE_ATTR_RO(queues);
* to/from another device fifo instead of to/from memory.
*/
-static void set_fifo_mode (struct net2280 *dev, int mode)
+static void set_fifo_mode(struct net2280 *dev, int mode)
{
/* keeping high bits preserves BAR2 */
- writel ((0xffff << PCI_BASE2_RANGE) | mode, &dev->regs->fifoctl);
+ writel((0xffff << PCI_BASE2_RANGE) | mode, &dev->regs->fifoctl);
/* always ep-{a,b,e,f} ... maybe not ep-c or ep-d */
- INIT_LIST_HEAD (&dev->gadget.ep_list);
- list_add_tail (&dev->ep [1].ep.ep_list, &dev->gadget.ep_list);
- list_add_tail (&dev->ep [2].ep.ep_list, &dev->gadget.ep_list);
+ INIT_LIST_HEAD(&dev->gadget.ep_list);
+ list_add_tail(&dev->ep[1].ep.ep_list, &dev->gadget.ep_list);
+ list_add_tail(&dev->ep[2].ep.ep_list, &dev->gadget.ep_list);
switch (mode) {
case 0:
- list_add_tail (&dev->ep [3].ep.ep_list, &dev->gadget.ep_list);
- list_add_tail (&dev->ep [4].ep.ep_list, &dev->gadget.ep_list);
- dev->ep [1].fifo_size = dev->ep [2].fifo_size = 1024;
+ list_add_tail(&dev->ep[3].ep.ep_list, &dev->gadget.ep_list);
+ list_add_tail(&dev->ep[4].ep.ep_list, &dev->gadget.ep_list);
+ dev->ep[1].fifo_size = dev->ep[2].fifo_size = 1024;
break;
case 1:
- dev->ep [1].fifo_size = dev->ep [2].fifo_size = 2048;
+ dev->ep[1].fifo_size = dev->ep[2].fifo_size = 2048;
break;
case 2:
- list_add_tail (&dev->ep [3].ep.ep_list, &dev->gadget.ep_list);
- dev->ep [1].fifo_size = 2048;
- dev->ep [2].fifo_size = 1024;
+ list_add_tail(&dev->ep[3].ep.ep_list, &dev->gadget.ep_list);
+ dev->ep[1].fifo_size = 2048;
+ dev->ep[2].fifo_size = 1024;
break;
}
/* fifo sizes for ep0, ep-c, ep-d, ep-e, and ep-f never change */
- list_add_tail (&dev->ep [5].ep.ep_list, &dev->gadget.ep_list);
- list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list);
+ list_add_tail(&dev->ep[5].ep.ep_list, &dev->gadget.ep_list);
+ list_add_tail(&dev->ep[6].ep.ep_list, &dev->gadget.ep_list);
}
static void defect7374_disable_data_eps(struct net2280 *dev)
@@ -2011,14 +2004,14 @@ static void usb_reset_228x(struct net2280 *dev)
u32 tmp;
dev->gadget.speed = USB_SPEED_UNKNOWN;
- (void) readl (&dev->usb->usbctl);
+ (void) readl(&dev->usb->usbctl);
- net2280_led_init (dev);
+ net2280_led_init(dev);
/* disable automatic responses, and irqs */
- writel (0, &dev->usb->stdrsp);
- writel (0, &dev->regs->pciirqenb0);
- writel (0, &dev->regs->pciirqenb1);
+ writel(0, &dev->usb->stdrsp);
+ writel(0, &dev->regs->pciirqenb0);
+ writel(0, &dev->regs->pciirqenb1);
/* clear old dma and irq state */
for (tmp = 0; tmp < 4; tmp++) {
@@ -2027,7 +2020,7 @@ static void usb_reset_228x(struct net2280 *dev)
abort_dma(ep);
}
- writel (~0, &dev->regs->irqstat0),
+ writel(~0, &dev->regs->irqstat0),
writel(~(u32)BIT(SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
/* reset, and enable pci */
@@ -2036,10 +2029,10 @@ static void usb_reset_228x(struct net2280 *dev)
BIT(FIFO_SOFT_RESET) |
BIT(USB_SOFT_RESET) |
BIT(M8051_RESET);
- writel (tmp, &dev->regs->devinit);
+ writel(tmp, &dev->regs->devinit);
/* standard fifo and endpoint allocations */
- set_fifo_mode (dev, (fifo_mode <= 2) ? fifo_mode : 0);
+ set_fifo_mode(dev, (fifo_mode <= 2) ? fifo_mode : 0);
}
static void usb_reset_338x(struct net2280 *dev)
@@ -2112,35 +2105,35 @@ static void usb_reinit_228x(struct net2280 *dev)
/* basic endpoint init */
for (tmp = 0; tmp < 7; tmp++) {
- struct net2280_ep *ep = &dev->ep [tmp];
+ struct net2280_ep *ep = &dev->ep[tmp];
- ep->ep.name = ep_name [tmp];
+ ep->ep.name = ep_name[tmp];
ep->dev = dev;
ep->num = tmp;
if (tmp > 0 && tmp <= 4) {
ep->fifo_size = 1024;
if (init_dma)
- ep->dma = &dev->dma [tmp - 1];
+ ep->dma = &dev->dma[tmp - 1];
} else
ep->fifo_size = 64;
- ep->regs = &dev->epregs [tmp];
+ ep->regs = &dev->epregs[tmp];
ep->cfg = &dev->epregs[tmp];
ep_reset_228x(dev->regs, ep);
}
- usb_ep_set_maxpacket_limit(&dev->ep [0].ep, 64);
- usb_ep_set_maxpacket_limit(&dev->ep [5].ep, 64);
- usb_ep_set_maxpacket_limit(&dev->ep [6].ep, 64);
+ usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 64);
+ usb_ep_set_maxpacket_limit(&dev->ep[5].ep, 64);
+ usb_ep_set_maxpacket_limit(&dev->ep[6].ep, 64);
- dev->gadget.ep0 = &dev->ep [0].ep;
- dev->ep [0].stopped = 0;
- INIT_LIST_HEAD (&dev->gadget.ep0->ep_list);
+ dev->gadget.ep0 = &dev->ep[0].ep;
+ dev->ep[0].stopped = 0;
+ INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
/* we want to prevent lowlevel/insecure access from the USB host,
* but erratum 0119 means this enable bit is ignored
*/
for (tmp = 0; tmp < 5; tmp++)
- writel (EP_DONTUSE, &dev->dep [tmp].dep_cfg);
+ writel(EP_DONTUSE, &dev->dep[tmp].dep_cfg);
}
static void usb_reinit_338x(struct net2280 *dev)
@@ -2263,7 +2256,7 @@ static void ep0_start_228x(struct net2280 *dev)
writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
BIT(CLEAR_NAK_OUT_PACKETS) |
BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
- , &dev->epregs [0].ep_rsp);
+ , &dev->epregs[0].ep_rsp);
/*
* hardware optionally handles a bunch of standard requests
@@ -2298,7 +2291,7 @@ static void ep0_start_228x(struct net2280 *dev)
&dev->regs->pciirqenb1);
/* don't leave any writes posted */
- (void) readl (&dev->usb->usbctl);
+ (void) readl(&dev->usb->usbctl);
}
static void ep0_start_338x(struct net2280 *dev)
@@ -2377,20 +2370,22 @@ static int net2280_start(struct usb_gadget *_gadget,
|| !driver->setup)
return -EINVAL;
- dev = container_of (_gadget, struct net2280, gadget);
+ dev = container_of(_gadget, struct net2280, gadget);
for (i = 0; i < dev->n_ep; i++)
- dev->ep [i].irqs = 0;
+ dev->ep[i].irqs = 0;
/* hook up the driver ... */
dev->softconnect = 1;
driver->driver.bus = NULL;
dev->driver = driver;
- retval = device_create_file (&dev->pdev->dev, &dev_attr_function);
- if (retval) goto err_unbind;
- retval = device_create_file (&dev->pdev->dev, &dev_attr_queues);
- if (retval) goto err_func;
+ retval = device_create_file(&dev->pdev->dev, &dev_attr_function);
+ if (retval)
+ goto err_unbind;
+ retval = device_create_file(&dev->pdev->dev, &dev_attr_queues);
+ if (retval)
+ goto err_func;
/* Enable force-full-speed testing mode, if desired */
if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
@@ -2399,30 +2394,29 @@ static int net2280_start(struct usb_gadget *_gadget,
/* ... then enable host detection and ep0; and we're ready
* for set_configuration as well as eventual disconnect.
*/
- net2280_led_active (dev, 1);
+ net2280_led_active(dev, 1);
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
defect7374_enable_data_eps_zero(dev);
- ep0_start (dev);
+ ep0_start(dev);
- DEBUG (dev, "%s ready, usbctl %08x stdrsp %08x\n",
+ DEBUG(dev, "%s ready, usbctl %08x stdrsp %08x\n",
driver->driver.name,
- readl (&dev->usb->usbctl),
- readl (&dev->usb->stdrsp));
+ readl(&dev->usb->usbctl),
+ readl(&dev->usb->stdrsp));
/* pci writes may still be posted */
return 0;
err_func:
- device_remove_file (&dev->pdev->dev, &dev_attr_function);
+ device_remove_file(&dev->pdev->dev, &dev_attr_function);
err_unbind:
dev->driver = NULL;
return retval;
}
-static void
-stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
+static void stop_activity(struct net2280 *dev, struct usb_gadget_driver *driver)
{
int i;
@@ -2433,9 +2427,9 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
/* stop hardware; prevent new request submissions;
* and kill any outstanding requests.
*/
- usb_reset (dev);
+ usb_reset(dev);
for (i = 0; i < dev->n_ep; i++)
- nuke (&dev->ep [i]);
+ nuke(&dev->ep[i]);
/* report disconnect; the driver is already quiesced */
if (driver) {
@@ -2444,7 +2438,7 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
spin_lock(&dev->lock);
}
- usb_reinit (dev);
+ usb_reinit(dev);
}
static int net2280_stop(struct usb_gadget *_gadget,
@@ -2453,22 +2447,22 @@ static int net2280_stop(struct usb_gadget *_gadget,
struct net2280 *dev;
unsigned long flags;
- dev = container_of (_gadget, struct net2280, gadget);
+ dev = container_of(_gadget, struct net2280, gadget);
- spin_lock_irqsave (&dev->lock, flags);
- stop_activity (dev, driver);
- spin_unlock_irqrestore (&dev->lock, flags);
+ spin_lock_irqsave(&dev->lock, flags);
+ stop_activity(dev, driver);
+ spin_unlock_irqrestore(&dev->lock, flags);
dev->driver = NULL;
- net2280_led_active (dev, 0);
+ net2280_led_active(dev, 0);
/* Disable full-speed test mode */
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
writel(0, &dev->usb->xcvrdiag);
- device_remove_file (&dev->pdev->dev, &dev_attr_function);
- device_remove_file (&dev->pdev->dev, &dev_attr_queues);
+ device_remove_file(&dev->pdev->dev, &dev_attr_function);
+ device_remove_file(&dev->pdev->dev, &dev_attr_queues);
DEBUG(dev, "unregistered driver '%s'\n",
driver ? driver->driver.name : "");
@@ -2482,31 +2476,31 @@ static int net2280_stop(struct usb_gadget *_gadget,
* also works for dma-capable endpoints, in pio mode or just
* to manually advance the queue after short OUT transfers.
*/
-static void handle_ep_small (struct net2280_ep *ep)
+static void handle_ep_small(struct net2280_ep *ep)
{
struct net2280_request *req;
u32 t;
/* 0 error, 1 mid-data, 2 done */
int mode = 1;
- if (!list_empty (&ep->queue))
- req = list_entry (ep->queue.next,
+ if (!list_empty(&ep->queue))
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
else
req = NULL;
/* ack all, and handle what we care about */
- t = readl (&ep->regs->ep_stat);
+ t = readl(&ep->regs->ep_stat);
ep->irqs++;
#if 0
- VDEBUG (ep->dev, "%s ack ep_stat %08x, req %p\n",
+ VDEBUG(ep->dev, "%s ack ep_stat %08x, req %p\n",
ep->ep.name, t, req ? &req->req : 0);
#endif
if (!ep->is_in || ep->dev->pdev->device == 0x2280)
writel(t & ~BIT(NAK_OUT_PACKETS), &ep->regs->ep_stat);
else
/* Added for 2282 */
- writel (t, &ep->regs->ep_stat);
+ writel(t, &ep->regs->ep_stat);
/* for ep0, monitor token irqs to catch data stage length errors
* and to synchronize on status.
@@ -2518,33 +2512,33 @@ static void handle_ep_small (struct net2280_ep *ep)
* control requests could be slightly faster without token synch for
* status, but status can jam up that way.
*/
- if (unlikely (ep->num == 0)) {
+ if (unlikely(ep->num == 0)) {
if (ep->is_in) {
/* status; stop NAKing */
if (t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
- set_halt (ep);
+ set_halt(ep);
}
if (!req)
- allow_status (ep);
+ allow_status(ep);
mode = 2;
/* reply to extra IN data tokens with a zlp */
} else if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
- set_halt (ep);
+ set_halt(ep);
mode = 2;
} else if (ep->responded &&
!req && !ep->stopped)
- write_fifo (ep, NULL);
+ write_fifo(ep, NULL);
}
} else {
/* status; stop NAKing */
if (t & BIT(DATA_IN_TOKEN_INTERRUPT)) {
if (ep->dev->protocol_stall) {
ep->stopped = 1;
- set_halt (ep);
+ set_halt(ep);
}
mode = 2;
/* an extra OUT token is an error */
@@ -2553,20 +2547,20 @@ static void handle_ep_small (struct net2280_ep *ep)
&& req->req.actual == req->req.length)
|| (ep->responded && !req)) {
ep->dev->protocol_stall = 1;
- set_halt (ep);
+ set_halt(ep);
ep->stopped = 1;
if (req)
- done (ep, req, -EOVERFLOW);
+ done(ep, req, -EOVERFLOW);
req = NULL;
}
}
}
- if (unlikely (!req))
+ if (unlikely(!req))
return;
/* manual DMA queue advance after short OUT */
- if (likely (ep->dma)) {
+ if (likely(ep->dma)) {
if (t & BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT)) {
u32 count;
int stopped = ep->stopped;
@@ -2576,27 +2570,27 @@ static void handle_ep_small (struct net2280_ep *ep)
* iff (M < N) we won't ever see a DMA interrupt.
*/
ep->stopped = 1;
- for (count = 0; ; t = readl (&ep->regs->ep_stat)) {
+ for (count = 0; ; t = readl(&ep->regs->ep_stat)) {
/* any preceding dma transfers must finish.
* dma handles (M >= N), may empty the queue
*/
- scan_dma_completions (ep);
- if (unlikely (list_empty (&ep->queue)
+ scan_dma_completions(ep);
+ if (unlikely(list_empty(&ep->queue)
|| ep->out_overflow)) {
req = NULL;
break;
}
- req = list_entry (ep->queue.next,
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
/* here either (M < N), a "real" short rx;
* or (M == N) and the queue didn't empty
*/
if (likely(t & BIT(FIFO_EMPTY))) {
- count = readl (&ep->dma->dmacount);
+ count = readl(&ep->dma->dmacount);
count &= DMA_BYTE_COUNT_MASK;
- if (readl (&ep->dma->dmadesc)
+ if (readl(&ep->dma->dmadesc)
!= req->td_dma)
req = NULL;
break;
@@ -2606,37 +2600,37 @@ static void handle_ep_small (struct net2280_ep *ep)
/* stop DMA, leave ep NAKing */
writel(BIT(DMA_ABORT), &ep->dma->dmastat);
- spin_stop_dma (ep->dma);
+ spin_stop_dma(ep->dma);
- if (likely (req)) {
+ if (likely(req)) {
req->td->dmacount = 0;
- t = readl (&ep->regs->ep_avail);
- dma_done (ep, req, count,
+ t = readl(&ep->regs->ep_avail);
+ dma_done(ep, req, count,
(ep->out_overflow || t)
? -EOVERFLOW : 0);
}
/* also flush to prevent erratum 0106 trouble */
- if (unlikely (ep->out_overflow
+ if (unlikely(ep->out_overflow
|| (ep->dev->chiprev == 0x0100
&& ep->dev->gadget.speed
== USB_SPEED_FULL))) {
- out_flush (ep);
+ out_flush(ep);
ep->out_overflow = 0;
}
/* (re)start dma if needed, stop NAKing */
ep->stopped = stopped;
- if (!list_empty (&ep->queue))
- restart_dma (ep);
+ if (!list_empty(&ep->queue))
+ restart_dma(ep);
} else
- DEBUG (ep->dev, "%s dma ep_stat %08x ??\n",
+ DEBUG(ep->dev, "%s dma ep_stat %08x ??\n",
ep->ep.name, t);
return;
/* data packet(s) received (in the fifo, OUT) */
} else if (t & BIT(DATA_PACKET_RECEIVED_INTERRUPT)) {
- if (read_fifo (ep, req) && ep->num != 0)
+ if (read_fifo(ep, req) && ep->num != 0)
mode = 2;
/* data packet(s) transmitted (IN) */
@@ -2649,12 +2643,10 @@ static void handle_ep_small (struct net2280_ep *ep)
req->req.actual += len;
/* if we wrote it all, we're usually done */
- if (req->req.actual == req->req.length) {
- if (ep->num == 0) {
- /* send zlps until the status stage */
- } else if (!req->req.zero || len != ep->ep.maxpacket)
+ /* send zlps until the status stage */
+ if ((req->req.actual == req->req.length) &&
+ (!req->req.zero || len != ep->ep.maxpacket) && ep->num)
mode = 2;
- }
/* there was nothing to do ... */
} else if (mode == 1)
@@ -2663,7 +2655,7 @@ static void handle_ep_small (struct net2280_ep *ep)
/* done */
if (mode == 2) {
/* stream endpoints often resubmit/unlink in completion */
- done (ep, req, 0);
+ done(ep, req, 0);
/* maybe advance queue to next request */
if (ep->num == 0) {
@@ -2672,16 +2664,16 @@ static void handle_ep_small (struct net2280_ep *ep)
* them control that, the api doesn't (yet) allow it.
*/
if (!ep->stopped)
- allow_status (ep);
+ allow_status(ep);
req = NULL;
} else {
- if (!list_empty (&ep->queue) && !ep->stopped)
- req = list_entry (ep->queue.next,
+ if (!list_empty(&ep->queue) && !ep->stopped)
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
else
req = NULL;
if (req && !ep->is_in)
- stop_out_naking (ep);
+ stop_out_naking(ep);
}
}
@@ -2692,18 +2684,17 @@ static void handle_ep_small (struct net2280_ep *ep)
/* load IN fifo with next packet (may be zlp) */
if (t & BIT(DATA_PACKET_TRANSMITTED_INTERRUPT))
- write_fifo (ep, &req->req);
+ write_fifo(ep, &req->req);
}
}
-static struct net2280_ep *
-get_ep_by_addr (struct net2280 *dev, u16 wIndex)
+static struct net2280_ep *get_ep_by_addr(struct net2280 *dev, u16 wIndex)
{
struct net2280_ep *ep;
if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0)
- return &dev->ep [0];
- list_for_each_entry (ep, &dev->gadget.ep_list, ep.ep_list) {
+ return &dev->ep[0];
+ list_for_each_entry(ep, &dev->gadget.ep_list, ep.ep_list) {
u8 bEndpointAddress;
if (!ep->desc)
@@ -3061,7 +3052,7 @@ next_endpoints3:
return;
}
-static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
+static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
{
struct net2280_ep *ep;
u32 num, scratch;
@@ -3070,12 +3061,12 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
stat &= ~BIT(INTA_ASSERTED);
if (!stat)
return;
- // DEBUG (dev, "irqstat0 %04x\n", stat);
+ /* DEBUG(dev, "irqstat0 %04x\n", stat); */
/* starting a control request? */
if (unlikely(stat & BIT(SETUP_PACKET_INTERRUPT))) {
union {
- u32 raw [2];
+ u32 raw[2];
struct usb_ctrlrequest r;
} u;
int tmp;
@@ -3096,19 +3087,20 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
EP0_HS_MAX_PACKET_SIZE);
}
- net2280_led_speed (dev, dev->gadget.speed);
- DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed));
+ net2280_led_speed(dev, dev->gadget.speed);
+ DEBUG(dev, "%s\n",
+ usb_speed_string(dev->gadget.speed));
}
- ep = &dev->ep [0];
+ ep = &dev->ep[0];
ep->irqs++;
/* make sure any leftover request state is cleared */
stat &= ~BIT(ENDPOINT_0_INTERRUPT);
- while (!list_empty (&ep->queue)) {
- req = list_entry (ep->queue.next,
+ while (!list_empty(&ep->queue)) {
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
- done (ep, req, (req->req.actual == req->req.length)
+ done(ep, req, (req->req.actual == req->req.length)
? 0 : -EPROTO);
}
ep->stopped = 0;
@@ -3139,8 +3131,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
u.raw[0] = readl(&dev->usb->setup0123);
u.raw[1] = readl(&dev->usb->setup4567);
- cpu_to_le32s (&u.raw [0]);
- cpu_to_le32s (&u.raw [1]);
+ cpu_to_le32s(&u.raw[0]);
+ cpu_to_le32s(&u.raw[1]);
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
defect7374_workaround(dev, u.r);
@@ -3165,12 +3157,12 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
scratch = BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
BIT(DATA_IN_TOKEN_INTERRUPT);
- stop_out_naking (ep);
+ stop_out_naking(ep);
} else
scratch = BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
BIT(DATA_IN_TOKEN_INTERRUPT);
- writel (scratch, &dev->epregs [0].ep_irqenb);
+ writel(scratch, &dev->epregs[0].ep_irqenb);
/* we made the hardware handle most lowlevel requests;
* everything else goes uplevel to the gadget code.
@@ -3190,21 +3182,21 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
/* hw handles device and interface status */
if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))
goto delegate;
- if ((e = get_ep_by_addr (dev, w_index)) == NULL
- || w_length > 2)
+ e = get_ep_by_addr(dev, w_index);
+ if (!e || w_length > 2)
goto do_stall;
if (readl(&e->regs->ep_rsp) & BIT(SET_ENDPOINT_HALT))
- status = cpu_to_le32 (1);
+ status = cpu_to_le32(1);
else
- status = cpu_to_le32 (0);
+ status = cpu_to_le32(0);
/* don't bother with a request object! */
- writel (0, &dev->epregs [0].ep_irqenb);
- set_fifo_bytecount (ep, w_length);
- writel ((__force u32)status, &dev->epregs [0].ep_data);
- allow_status (ep);
- VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status);
+ writel(0, &dev->epregs[0].ep_irqenb);
+ set_fifo_bytecount(ep, w_length);
+ writel((__force u32)status, &dev->epregs[0].ep_data);
+ allow_status(ep);
+ VDEBUG(dev, "%s stat %02x\n", ep->ep.name, status);
goto next_endpoints;
}
break;
@@ -3217,7 +3209,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
if (w_value != USB_ENDPOINT_HALT
|| w_length != 0)
goto do_stall;
- if ((e = get_ep_by_addr (dev, w_index)) == NULL)
+ e = get_ep_by_addr(dev, w_index);
+ if (!e)
goto do_stall;
if (e->wedged) {
VDEBUG(dev, "%s wedged, halt not cleared\n",
@@ -3230,7 +3223,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
!list_empty(&e->queue) && e->td_dma)
restart_dma(e);
}
- allow_status (ep);
+ allow_status(ep);
goto next_endpoints;
}
break;
@@ -3243,35 +3236,36 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
if (w_value != USB_ENDPOINT_HALT
|| w_length != 0)
goto do_stall;
- if ((e = get_ep_by_addr (dev, w_index)) == NULL)
+ e = get_ep_by_addr(dev, w_index);
+ if (!e)
goto do_stall;
if (e->ep.name == ep0name)
goto do_stall;
- set_halt (e);
+ set_halt(e);
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX && e->dma)
abort_dma(e);
- allow_status (ep);
- VDEBUG (dev, "%s set halt\n", ep->ep.name);
+ allow_status(ep);
+ VDEBUG(dev, "%s set halt\n", ep->ep.name);
goto next_endpoints;
}
break;
default:
delegate:
- VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x "
+ VDEBUG(dev, "setup %02x.%02x v%04x i%04x l%04x "
"ep_cfg %08x\n",
u.r.bRequestType, u.r.bRequest,
w_value, w_index, w_length,
readl(&ep->cfg->ep_cfg));
ep->responded = 0;
- spin_unlock (&dev->lock);
- tmp = dev->driver->setup (&dev->gadget, &u.r);
- spin_lock (&dev->lock);
+ spin_unlock(&dev->lock);
+ tmp = dev->driver->setup(&dev->gadget, &u.r);
+ spin_lock(&dev->lock);
}
/* stall ep0 on error */
if (tmp < 0) {
do_stall:
- VDEBUG (dev, "req %02x.%02x protocol STALL; stat %d\n",
+ VDEBUG(dev, "req %02x.%02x protocol STALL; stat %d\n",
u.r.bRequestType, u.r.bRequest, tmp);
dev->protocol_stall = 1;
}
@@ -3299,12 +3293,12 @@ next_endpoints:
continue;
scratch ^= t;
- ep = &dev->ep [num];
- handle_ep_small (ep);
+ ep = &dev->ep[num];
+ handle_ep_small(ep);
}
if (stat)
- DEBUG (dev, "unhandled irqstat0 %08x\n", stat);
+ DEBUG(dev, "unhandled irqstat0 %08x\n", stat);
}
#define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
@@ -3316,7 +3310,7 @@ next_endpoints:
BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT) | \
BIT(PCI_RETRY_ABORT_INTERRUPT))
-static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
+static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
{
struct net2280_ep *ep;
u32 tmp, num, mask, scratch;
@@ -3331,17 +3325,17 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
* only indicates a change in the reset state).
*/
if (stat & tmp) {
- writel (tmp, &dev->regs->irqstat1);
+ writel(tmp, &dev->regs->irqstat1);
if ((((stat & BIT(ROOT_PORT_RESET_INTERRUPT))
- && ((readl (&dev->usb->usbstat) & mask)
+ && ((readl(&dev->usb->usbstat) & mask)
== 0))
- || ((readl (&dev->usb->usbctl)
+ || ((readl(&dev->usb->usbctl)
& BIT(VBUS_PIN)) == 0)
- ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) {
- DEBUG (dev, "disconnect %s\n",
+ ) && (dev->gadget.speed != USB_SPEED_UNKNOWN)) {
+ DEBUG(dev, "disconnect %s\n",
dev->driver->driver.name);
- stop_activity (dev, dev->driver);
- ep0_start (dev);
+ stop_activity(dev, dev->driver);
+ ep0_start(dev);
return;
}
stat &= ~tmp;
@@ -3358,15 +3352,15 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
*/
tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT);
if (stat & tmp) {
- writel (tmp, &dev->regs->irqstat1);
+ writel(tmp, &dev->regs->irqstat1);
if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) {
if (dev->driver->suspend)
- dev->driver->suspend (&dev->gadget);
+ dev->driver->suspend(&dev->gadget);
if (!enable_suspend)
stat &= ~BIT(SUSPEND_REQUEST_INTERRUPT);
} else {
if (dev->driver->resume)
- dev->driver->resume (&dev->gadget);
+ dev->driver->resume(&dev->gadget);
/* at high speed, note erratum 0133 */
}
stat &= ~tmp;
@@ -3374,7 +3368,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
/* clear any other status/irqs */
if (stat)
- writel (stat, &dev->regs->irqstat1);
+ writel(stat, &dev->regs->irqstat1);
/* some status we can just ignore */
if (dev->pdev->device == 0x2280)
@@ -3390,7 +3384,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
if (!stat)
return;
- // DEBUG (dev, "irqstat1 %08x\n", stat);
+ /* DEBUG(dev, "irqstat1 %08x\n", stat);*/
/* DMA status, for ep-{a,b,c,d} */
scratch = stat & DMA_INTERRUPTS;
@@ -3404,15 +3398,15 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
continue;
scratch ^= tmp;
- ep = &dev->ep [num + 1];
+ ep = &dev->ep[num + 1];
dma = ep->dma;
if (!dma)
continue;
/* clear ep's dma status */
- tmp = readl (&dma->dmastat);
- writel (tmp, &dma->dmastat);
+ tmp = readl(&dma->dmastat);
+ writel(tmp, &dma->dmastat);
/* dma sync*/
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
@@ -3427,11 +3421,11 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
*/
if (!use_dma_chaining) {
if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
- DEBUG (ep->dev, "%s no xact done? %08x\n",
+ DEBUG(ep->dev, "%s no xact done? %08x\n",
ep->ep.name, tmp);
continue;
}
- stop_dma (ep->dma);
+ stop_dma(ep->dma);
}
/* OUT transfers terminate when the data from the
@@ -3444,16 +3438,16 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
* long time ... we ignore that for now, accounting
* precisely (like PIO does) needs per-packet irqs
*/
- scan_dma_completions (ep);
+ scan_dma_completions(ep);
/* disable dma on inactive queues; else maybe restart */
- if (list_empty (&ep->queue)) {
+ if (list_empty(&ep->queue)) {
if (use_dma_chaining)
- stop_dma (ep->dma);
+ stop_dma(ep->dma);
} else {
- tmp = readl (&dma->dmactl);
+ tmp = readl(&dma->dmactl);
if (!use_dma_chaining || (tmp & BIT(DMA_ENABLE)) == 0)
- restart_dma (ep);
+ restart_dma(ep);
else if (ep->is_in && use_dma_chaining) {
struct net2280_request *req;
__le32 dmacount;
@@ -3463,13 +3457,13 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
* used to trigger changing DMA_FIFO_VALIDATE
* (affects automagic zlp writes).
*/
- req = list_entry (ep->queue.next,
+ req = list_entry(ep->queue.next,
struct net2280_request, queue);
dmacount = req->td->dmacount;
dmacount &= cpu_to_le32(BIT(VALID_BIT) |
DMA_BYTE_COUNT_MASK);
if (dmacount && (dmacount & valid_bit) == 0)
- restart_dma (ep);
+ restart_dma(ep);
}
}
ep->irqs++;
@@ -3479,21 +3473,21 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
* if they appear very often, here's where to try recovering.
*/
if (stat & PCI_ERROR_INTERRUPTS) {
- ERROR (dev, "pci dma error; stat %08x\n", stat);
+ ERROR(dev, "pci dma error; stat %08x\n", stat);
stat &= ~PCI_ERROR_INTERRUPTS;
/* these are fatal errors, but "maybe" they won't
* happen again ...
*/
- stop_activity (dev, dev->driver);
- ep0_start (dev);
+ stop_activity(dev, dev->driver);
+ ep0_start(dev);
stat = 0;
}
if (stat)
- DEBUG (dev, "unhandled irqstat1 %08x\n", stat);
+ DEBUG(dev, "unhandled irqstat1 %08x\n", stat);
}
-static irqreturn_t net2280_irq (int irq, void *_dev)
+static irqreturn_t net2280_irq(int irq, void *_dev)
{
struct net2280 *dev = _dev;
@@ -3502,13 +3496,13 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
(!(readl(&dev->regs->irqstat0) & BIT(INTA_ASSERTED))))
return IRQ_NONE;
- spin_lock (&dev->lock);
+ spin_lock(&dev->lock);
/* handle disconnect, dma, and more */
- handle_stat1_irqs (dev, readl (&dev->regs->irqstat1));
+ handle_stat1_irqs(dev, readl(&dev->regs->irqstat1));
/* control requests and PIO */
- handle_stat0_irqs (dev, readl (&dev->regs->irqstat0));
+ handle_stat0_irqs(dev, readl(&dev->regs->irqstat0));
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
/* re-enable interrupt to trigger any possible new interrupt */
@@ -3517,54 +3511,54 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
writel(pciirqenb1, &dev->regs->pciirqenb1);
}
- spin_unlock (&dev->lock);
+ spin_unlock(&dev->lock);
return IRQ_HANDLED;
}
/*-------------------------------------------------------------------------*/
-static void gadget_release (struct device *_dev)
+static void gadget_release(struct device *_dev)
{
- struct net2280 *dev = dev_get_drvdata (_dev);
+ struct net2280 *dev = dev_get_drvdata(_dev);
- kfree (dev);
+ kfree(dev);
}
/* tear down the binding between this driver and the pci device */
-static void net2280_remove (struct pci_dev *pdev)
+static void net2280_remove(struct pci_dev *pdev)
{
- struct net2280 *dev = pci_get_drvdata (pdev);
+ struct net2280 *dev = pci_get_drvdata(pdev);
usb_del_gadget_udc(&dev->gadget);
BUG_ON(dev->driver);
/* then clean up the resources we allocated during probe() */
- net2280_led_shutdown (dev);
+ net2280_led_shutdown(dev);
if (dev->requests) {
int i;
for (i = 1; i < 5; i++) {
- if (!dev->ep [i].dummy)
+ if (!dev->ep[i].dummy)
continue;
- pci_pool_free (dev->requests, dev->ep [i].dummy,
- dev->ep [i].td_dma);
+ pci_pool_free(dev->requests, dev->ep[i].dummy,
+ dev->ep[i].td_dma);
}
- pci_pool_destroy (dev->requests);
+ pci_pool_destroy(dev->requests);
}
if (dev->got_irq)
- free_irq (pdev->irq, dev);
+ free_irq(pdev->irq, dev);
if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
pci_disable_msi(pdev);
if (dev->regs)
- iounmap (dev->regs);
+ iounmap(dev->regs);
if (dev->region)
- release_mem_region (pci_resource_start (pdev, 0),
- pci_resource_len (pdev, 0));
+ release_mem_region(pci_resource_start(pdev, 0),
+ pci_resource_len(pdev, 0));
if (dev->enabled)
- pci_disable_device (pdev);
- device_remove_file (&pdev->dev, &dev_attr_registers);
+ pci_disable_device(pdev);
+ device_remove_file(&pdev->dev, &dev_attr_registers);
INFO (dev, "unbind\n");
}
@@ -3573,7 +3567,7 @@ static void net2280_remove (struct pci_dev *pdev)
* don't respond over USB until a gadget driver binds to us.
*/
-static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
+static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct net2280 *dev;
unsigned long resource, len;
@@ -3584,14 +3578,14 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
use_dma_chaining = 0;
/* alloc, and start init */
- dev = kzalloc (sizeof *dev, GFP_KERNEL);
- if (dev == NULL){
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (dev == NULL) {
retval = -ENOMEM;
goto done;
}
- pci_set_drvdata (pdev, dev);
- spin_lock_init (&dev->lock);
+ pci_set_drvdata(pdev, dev);
+ spin_lock_init(&dev->lock);
dev->pdev = pdev;
dev->gadget.ops = &net2280_ops;
dev->gadget.max_speed = (dev->pdev->vendor == PCI_VENDOR_ID_PLX) ?
@@ -3601,8 +3595,8 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->gadget.name = driver_name;
/* now all the pci goodies ... */
- if (pci_enable_device (pdev) < 0) {
- retval = -ENODEV;
+ if (pci_enable_device(pdev) < 0) {
+ retval = -ENODEV;
goto done;
}
dev->enabled = 1;
@@ -3611,10 +3605,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
* BAR 1 is 8051 memory; unused here (note erratum 0103)
* BAR 2 is fifo memory; unused here
*/
- resource = pci_resource_start (pdev, 0);
- len = pci_resource_len (pdev, 0);
- if (!request_mem_region (resource, len, driver_name)) {
- DEBUG (dev, "controller already in use\n");
+ resource = pci_resource_start(pdev, 0);
+ len = pci_resource_len(pdev, 0);
+ if (!request_mem_region(resource, len, driver_name)) {
+ DEBUG(dev, "controller already in use\n");
retval = -EBUSY;
goto done;
}
@@ -3624,9 +3618,9 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
* 8051 code into the chip, e.g. to turn on PCI PM.
*/
- base = ioremap_nocache (resource, len);
+ base = ioremap_nocache(resource, len);
if (base == NULL) {
- DEBUG (dev, "can't map memory\n");
+ DEBUG(dev, "can't map memory\n");
retval = -EFAULT;
goto done;
}
@@ -3655,7 +3649,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
dev->plregs = (struct usb338x_pl_regs __iomem *)
(base + 0x0800);
usbstat = readl(&dev->usb->usbstat);
- dev->enhanced_mode = (usbstat & BIT(11)) ? 1 : 0;
+ dev->enhanced_mode = !!(usbstat & BIT(11));
dev->n_ep = (dev->enhanced_mode) ? 9 : 5;
/* put into initial config, link up all endpoints */
fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
@@ -3670,12 +3664,12 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
writel(0, &dev->usb->usbctl);
}
- usb_reset (dev);
- usb_reinit (dev);
+ usb_reset(dev);
+ usb_reinit(dev);
/* irq setup after old hardware is cleaned up */
if (!pdev->irq) {
- ERROR (dev, "No IRQ. Check PCI setup!\n");
+ ERROR(dev, "No IRQ. Check PCI setup!\n");
retval = -ENODEV;
goto done;
}
@@ -3684,9 +3678,9 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
if (pci_enable_msi(pdev))
ERROR(dev, "Failed to enable MSI mode\n");
- if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev)
- != 0) {
- ERROR (dev, "request interrupt %d failed\n", pdev->irq);
+ if (request_irq(pdev->irq, net2280_irq, IRQF_SHARED,
+ driver_name, dev)) {
+ ERROR(dev, "request interrupt %d failed\n", pdev->irq);
retval = -EBUSY;
goto done;
}
@@ -3694,28 +3688,28 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
/* DMA setup */
/* NOTE: we know only the 32 LSBs of dma addresses may be nonzero */
- dev->requests = pci_pool_create ("requests", pdev,
- sizeof (struct net2280_dma),
+ dev->requests = pci_pool_create("requests", pdev,
+ sizeof(struct net2280_dma),
0 /* no alignment requirements */,
0 /* or page-crossing issues */);
if (!dev->requests) {
- DEBUG (dev, "can't get request pool\n");
+ DEBUG(dev, "can't get request pool\n");
retval = -ENOMEM;
goto done;
}
for (i = 1; i < 5; i++) {
struct net2280_dma *td;
- td = pci_pool_alloc (dev->requests, GFP_KERNEL,
- &dev->ep [i].td_dma);
+ td = pci_pool_alloc(dev->requests, GFP_KERNEL,
+ &dev->ep[i].td_dma);
if (!td) {
- DEBUG (dev, "can't get dummy %d\n", i);
+ DEBUG(dev, "can't get dummy %d\n", i);
retval = -ENOMEM;
goto done;
}
td->dmacount = 0; /* not VALID */
td->dmadesc = td->dmaaddr;
- dev->ep [i].dummy = td;
+ dev->ep[i].dummy = td;
}
/* enable lower-overhead pci memory bursts during DMA */
@@ -3729,22 +3723,23 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
BIT(DMA_READ_LINE_ENABLE),
&dev->pci->pcimstctl);
/* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
- pci_set_master (pdev);
- pci_try_set_mwi (pdev);
+ pci_set_master(pdev);
+ pci_try_set_mwi(pdev);
/* ... also flushes any posted pci writes */
- dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff;
+ dev->chiprev = get_idx_reg(dev->regs, REG_CHIPREV) & 0xffff;
/* done */
- INFO (dev, "%s\n", driver_desc);
- INFO (dev, "irq %d, pci mem %p, chip rev %04x\n",
+ INFO(dev, "%s\n", driver_desc);
+ INFO(dev, "irq %d, pci mem %p, chip rev %04x\n",
pdev->irq, base, dev->chiprev);
INFO(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
use_dma ? (use_dma_chaining ? "chaining" : "enabled")
: "disabled",
dev->enhanced_mode ? "enhanced mode" : "legacy mode");
- retval = device_create_file (&pdev->dev, &dev_attr_registers);
- if (retval) goto done;
+ retval = device_create_file(&pdev->dev, &dev_attr_registers);
+ if (retval)
+ goto done;
retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget,
gadget_release);
@@ -3754,7 +3749,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
done:
if (dev)
- net2280_remove (pdev);
+ net2280_remove(pdev);
return retval;
}
@@ -3762,16 +3757,16 @@ done:
* generating IRQs across the upcoming reboot.
*/
-static void net2280_shutdown (struct pci_dev *pdev)
+static void net2280_shutdown(struct pci_dev *pdev)
{
- struct net2280 *dev = pci_get_drvdata (pdev);
+ struct net2280 *dev = pci_get_drvdata(pdev);
/* disable IRQs */
- writel (0, &dev->regs->pciirqenb0);
- writel (0, &dev->regs->pciirqenb1);
+ writel(0, &dev->regs->pciirqenb0);
+ writel(0, &dev->regs->pciirqenb1);
/* disable the pullup so the host will think we're gone */
- writel (0, &dev->usb->usbctl);
+ writel(0, &dev->usb->usbctl);
/* Disable full-speed test mode */
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
@@ -3781,7 +3776,7 @@ static void net2280_shutdown (struct pci_dev *pdev)
/*-------------------------------------------------------------------------*/
-static const struct pci_device_id pci_ids [] = { {
+static const struct pci_device_id pci_ids[] = { {
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
.vendor = PCI_VENDOR_ID_PLX_LEGACY,
@@ -3814,7 +3809,7 @@ static const struct pci_device_id pci_ids [] = { {
},
{ /* end: all zeroes */ }
};
-MODULE_DEVICE_TABLE (pci, pci_ids);
+MODULE_DEVICE_TABLE(pci, pci_ids);
/* pci driver glue; this is a "new style" PCI driver module */
static struct pci_driver net2280_pci_driver = {
@@ -3830,6 +3825,6 @@ static struct pci_driver net2280_pci_driver = {
module_pci_driver(net2280_pci_driver);
-MODULE_DESCRIPTION (DRIVER_DESC);
-MODULE_AUTHOR ("David Brownell");
-MODULE_LICENSE ("GPL");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("David Brownell");
+MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index e1c5d1a..f019d6c 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -25,19 +25,18 @@
* caller must own the device lock.
*/
-static inline u32
-get_idx_reg (struct net2280_regs __iomem *regs, u32 index)
+static inline u32 get_idx_reg(struct net2280_regs __iomem *regs, u32 index)
{
- writel (index, ®s->idxaddr);
+ writel(index, ®s->idxaddr);
/* NOTE: synchs device/cpu memory views */
- return readl (®s->idxdata);
+ return readl(®s->idxdata);
}
static inline void
-set_idx_reg (struct net2280_regs __iomem *regs, u32 index, u32 value)
+set_idx_reg(struct net2280_regs __iomem *regs, u32 index, u32 value)
{
- writel (index, ®s->idxaddr);
- writel (value, ®s->idxdata);
+ writel(index, ®s->idxaddr);
+ writel(value, ®s->idxdata);
/* posted, may not be visible yet */
}
@@ -81,7 +80,7 @@ struct net2280_dma {
__le32 dmaaddr; /* the buffer */
__le32 dmadesc; /* next dma descriptor */
__le32 _reserved;
-} __attribute__ ((aligned (16)));
+} __aligned(16);
/*-------------------------------------------------------------------------*/
@@ -113,7 +112,7 @@ struct net2280_ep {
responded : 1;
};
-static inline void allow_status (struct net2280_ep *ep)
+static inline void allow_status(struct net2280_ep *ep)
{
/* ep0 only */
writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
@@ -152,7 +151,7 @@ struct net2280 {
struct usb_gadget gadget;
spinlock_t lock;
struct net2280_ep ep[9];
- struct usb_gadget_driver *driver;
+ struct usb_gadget_driver *driver;
unsigned enabled : 1,
protocol_stall : 1,
softconnect : 1,
@@ -185,10 +184,10 @@ struct net2280 {
struct usb338x_pl_regs __iomem *plregs;
struct pci_pool *requests;
- // statistics...
+ /* statistics...*/
};
-static inline void set_halt (struct net2280_ep *ep)
+static inline void set_halt(struct net2280_ep *ep)
{
/* ep0 and bulk/intr endpoints */
writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
@@ -198,7 +197,7 @@ static inline void set_halt (struct net2280_ep *ep)
&ep->regs->ep_rsp);
}
-static inline void clear_halt (struct net2280_ep *ep)
+static inline void clear_halt(struct net2280_ep *ep)
{
/* ep0 and bulk/intr endpoints */
writel(BIT(CLEAR_ENDPOINT_HALT) |
@@ -250,7 +249,7 @@ static inline void clear_halt (struct net2280_ep *ep)
#ifdef USE_RDK_LEDS
-static inline void net2280_led_init (struct net2280 *dev)
+static inline void net2280_led_init(struct net2280 *dev)
{
/* LED3 (green) is on during USB activity. note erratum 0113. */
writel(BIT(GPIO3_LED_SELECT) |
@@ -263,9 +262,9 @@ static inline void net2280_led_init (struct net2280 *dev)
/* indicate speed with bi-color LED 0/1 */
static inline
-void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
+void net2280_led_speed(struct net2280 *dev, enum usb_device_speed speed)
{
- u32 val = readl (&dev->regs->gpioctl);
+ u32 val = readl(&dev->regs->gpioctl);
switch (speed) {
case USB_SPEED_SUPER: /* green + red */
val |= BIT(GPIO0_DATA) | BIT(GPIO1_DATA);
@@ -282,25 +281,26 @@ void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
val &= ~(BIT(GPIO1_DATA) | BIT(GPIO0_DATA));
break;
}
- writel (val, &dev->regs->gpioctl);
+ writel(val, &dev->regs->gpioctl);
}
/* indicate power with LED 2 */
-static inline void net2280_led_active (struct net2280 *dev, int is_active)
+static inline void net2280_led_active(struct net2280 *dev, int is_active)
{
- u32 val = readl (&dev->regs->gpioctl);
+ u32 val = readl(&dev->regs->gpioctl);
- // FIXME this LED never seems to turn on.
+ /* FIXME this LED never seems to turn on.*/
if (is_active)
val |= GPIO2_DATA;
else
val &= ~GPIO2_DATA;
- writel (val, &dev->regs->gpioctl);
+ writel(val, &dev->regs->gpioctl);
}
-static inline void net2280_led_shutdown (struct net2280 *dev)
+
+static inline void net2280_led_shutdown(struct net2280 *dev)
{
/* turn off all four GPIO*_DATA bits */
- writel (readl (&dev->regs->gpioctl) & ~0x0f,
+ writel(readl(&dev->regs->gpioctl) & ~0x0f,
&dev->regs->gpioctl);
}
@@ -314,32 +314,32 @@ static inline void net2280_led_shutdown (struct net2280 *dev)
/*-------------------------------------------------------------------------*/
-#define xprintk(dev,level,fmt,args...) \
- printk(level "%s %s: " fmt , driver_name , \
- pci_name(dev->pdev) , ## args)
+#define xprintk(dev, level, fmt, args...) \
+ printk(level "%s %s: " fmt, driver_name, \
+ pci_name(dev->pdev), ## args)
#ifdef DEBUG
#undef DEBUG
-#define DEBUG(dev,fmt,args...) \
- xprintk(dev , KERN_DEBUG , fmt , ## args)
+#define DEBUG(dev, fmt, args...) \
+ xprintk(dev, KERN_DEBUG, fmt, ## args)
#else
-#define DEBUG(dev,fmt,args...) \
+#define DEBUG(dev, fmt, args...) \
do { } while (0)
-#endif /* DEBUG */
+#endif /* DEBUG*/
#ifdef VERBOSE
#define VDEBUG DEBUG
#else
-#define VDEBUG(dev,fmt,args...) \
+#define VDEBUG(dev, fmt, args...) \
do { } while (0)
#endif /* VERBOSE */
-#define ERROR(dev,fmt,args...) \
- xprintk(dev , KERN_ERR , fmt , ## args)
-#define WARNING(dev,fmt,args...) \
- xprintk(dev , KERN_WARNING , fmt , ## args)
-#define INFO(dev,fmt,args...) \
- xprintk(dev , KERN_INFO , fmt , ## args)
+#define ERROR(dev, fmt, args...) \
+ xprintk(dev, KERN_ERR, fmt, ## args)
+#define WARNING(dev, fmt, args...) \
+ xprintk(dev, KERN_WARNING, fmt, ## args)
+#define INFO(dev, fmt, args...) \
+ xprintk(dev, KERN_INFO, fmt, ## args)
/*-------------------------------------------------------------------------*/
@@ -354,36 +354,36 @@ static inline void set_fifo_bytecount(struct net2280_ep *ep, unsigned count)
}
}
-static inline void start_out_naking (struct net2280_ep *ep)
+static inline void start_out_naking(struct net2280_ep *ep)
{
/* NOTE: hardware races lurk here, and PING protocol issues */
writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
/* synch with device */
- readl (&ep->regs->ep_rsp);
+ readl(&ep->regs->ep_rsp);
}
#ifdef DEBUG
-static inline void assert_out_naking (struct net2280_ep *ep, const char *where)
+static inline void assert_out_naking(struct net2280_ep *ep, const char *where)
{
- u32 tmp = readl (&ep->regs->ep_stat);
+ u32 tmp = readl(&ep->regs->ep_stat);
if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
- DEBUG (ep->dev, "%s %s %08x !NAK\n",
+ DEBUG(ep->dev, "%s %s %08x !NAK\n",
ep->ep.name, where, tmp);
writel(BIT(SET_NAK_OUT_PACKETS),
&ep->regs->ep_rsp);
}
}
-#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep,__func__)
+#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep, __func__)
#else
#define ASSERT_OUT_NAKING(ep) do {} while (0)
#endif
-static inline void stop_out_naking (struct net2280_ep *ep)
+static inline void stop_out_naking(struct net2280_ep *ep)
{
u32 tmp;
- tmp = readl (&ep->regs->ep_stat);
+ tmp = readl(&ep->regs->ep_stat);
if ((tmp & BIT(NAK_OUT_PACKETS)) != 0)
writel(BIT(CLEAR_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
}
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/10 v2.1] usb: gadget: net2280: Code Cleanup
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (6 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 07/10 v3] usb: gadget: net2280: Pass checkpacth.pl test Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 09/10 v2.1] usb: gadget: net2280: Use pr_* function Ricardo Ribalda Delgado
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
- Move logical continuations to end of line
- Improve spacing
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
v2: Comments by Alan Stern
-Use octal notation istead of S_I
drivers/usb/gadget/net2280.c | 155 +++++++++++++++++++++----------------------
drivers/usb/gadget/net2280.h | 4 +-
2 files changed, 78 insertions(+), 81 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d1d4f4f..d506c83 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -100,9 +100,9 @@ static bool use_dma_chaining;
static bool use_msi = true;
/* "modprobe net2280 use_dma=n" etc */
-module_param(use_dma, bool, S_IRUGO);
-module_param(use_dma_chaining, bool, S_IRUGO);
-module_param(use_msi, bool, S_IRUGO);
+module_param(use_dma, bool, 0444);
+module_param(use_dma_chaining, bool, 0444);
+module_param(use_msi, bool, 0444);
/* mode 0 == ep-{a,b,c,d} 1K fifo each
* mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -111,7 +111,7 @@ module_param(use_msi, bool, S_IRUGO);
static ushort fifo_mode;
/* "modprobe net2280 fifo_mode=1" etc */
-module_param (fifo_mode, ushort, 0644);
+module_param(fifo_mode, ushort, 0644);
/* enable_suspend -- When enabled, the driver will respond to
* USB suspend requests by powering down the NET2280. Otherwise,
@@ -121,7 +121,7 @@ module_param (fifo_mode, ushort, 0644);
static bool enable_suspend;
/* "modprobe net2280 enable_suspend=1" etc */
-module_param(enable_suspend, bool, S_IRUGO);
+module_param(enable_suspend, bool, 0444);
/* force full-speed operation */
static bool full_speed;
@@ -169,8 +169,8 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
ep = container_of(_ep, struct net2280_ep, ep);
- if (!_ep || !desc || ep->desc || _ep->name == ep0name
- || desc->bDescriptorType != USB_DT_ENDPOINT)
+ if (!_ep || !desc || ep->desc || _ep->name == ep0name ||
+ desc->bDescriptorType != USB_DT_ENDPOINT)
return -EINVAL;
dev = ep->dev;
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
@@ -220,9 +220,9 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
if (tmp == USB_ENDPOINT_XFER_INT) {
/* erratum 0105 workaround prevents hs NYET */
- if (dev->chiprev == 0100
- && dev->gadget.speed == USB_SPEED_HIGH
- && !(desc->bEndpointAddress & USB_DIR_IN))
+ if (dev->chiprev == 0100 &&
+ dev->gadget.speed == USB_SPEED_HIGH &&
+ !(desc->bEndpointAddress & USB_DIR_IN))
writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE),
&ep->regs->ep_rsp);
} else if (tmp == USB_ENDPOINT_XFER_BULK) {
@@ -402,8 +402,8 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
- BIT(DATA_IN_TOKEN_INTERRUPT)
- , &ep->regs->ep_stat);
+ BIT(DATA_IN_TOKEN_INTERRUPT),
+ &ep->regs->ep_stat);
/* fifo size is handled separately */
}
@@ -425,9 +425,9 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
writel(BIT(DMA_ABORT_DONE_INTERRUPT) |
BIT(DMA_PAUSE_DONE_INTERRUPT) |
BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT) |
- BIT(DMA_TRANSACTION_DONE_INTERRUPT)
- /* | BIT(DMA_ABORT) */
- , &ep->dma->dmastat);
+ BIT(DMA_TRANSACTION_DONE_INTERRUPT),
+ /* | BIT(DMA_ABORT), */
+ &ep->dma->dmastat);
dmastat = readl(&ep->dma->dmastat);
if (dmastat == 0x5002) {
@@ -618,15 +618,15 @@ static void out_flush(struct net2280_ep *ep)
statp = &ep->regs->ep_stat;
writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
- BIT(DATA_PACKET_RECEIVED_INTERRUPT)
- , statp);
+ BIT(DATA_PACKET_RECEIVED_INTERRUPT),
+ statp);
writel(BIT(FIFO_FLUSH), statp);
/* Make sure that stap is written */
mb();
tmp = readl(statp);
- if (tmp & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)
+ if (tmp & BIT(DATA_OUT_PING_TOKEN_INTERRUPT) &&
/* high speed did bulk NYET; fifo isn't filling */
- && ep->dev->gadget.speed == USB_SPEED_FULL) {
+ ep->dev->gadget.speed == USB_SPEED_FULL) {
unsigned usec;
usec = 50; /* 64 byte bulk/interrupt */
@@ -653,8 +653,8 @@ static int read_fifo(struct net2280_ep *ep, struct net2280_request *req)
/* erratum 0106 ... packets coming in during fifo reads might
* be incompletely rejected. not all cases have workarounds.
*/
- if (ep->dev->chiprev == 0x0100
- && ep->dev->gadget.speed == USB_SPEED_FULL) {
+ if (ep->dev->chiprev == 0x0100 &&
+ ep->dev->gadget.speed == USB_SPEED_FULL) {
udelay(1);
tmp = readl(&ep->regs->ep_stat);
if ((tmp & BIT(NAK_OUT_PACKETS)))
@@ -726,8 +726,8 @@ static int read_fifo(struct net2280_ep *ep, struct net2280_request *req)
(void) readl(&ep->regs->ep_rsp);
}
- return is_short || ((req->req.actual == req->req.length)
- && !req->req.zero);
+ return is_short || ((req->req.actual == req->req.length) &&
+ !req->req.zero);
}
/* fill out dma descriptor to match a given request */
@@ -744,8 +744,8 @@ static void fill_dma_desc(struct net2280_ep *ep,
*/
if (ep->is_in)
dmacount |= BIT(DMA_DIRECTION);
- if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0)
- || ep->dev->pdev->device != 0x2280)
+ if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) ||
+ ep->dev->pdev->device != 0x2280)
dmacount |= BIT(END_OF_CHAIN);
req->valid = valid;
@@ -836,8 +836,8 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
/* dma irq, faking scatterlist status */
req->td->dmacount = cpu_to_le32(req->req.length - tmp);
- writel(BIT(DMA_DONE_INTERRUPT_ENABLE)
- | tmp, &dma->dmacount);
+ writel(BIT(DMA_DONE_INTERRUPT_ENABLE) | tmp,
+ &dma->dmacount);
req->td->dmadesc = 0;
req->valid = 1;
@@ -1120,8 +1120,8 @@ static void scan_dma_completions(struct net2280_ep *ep)
/* single transfer mode */
dma_done(ep, req, tmp, 0);
break;
- } else if (!ep->is_in
- && (req->req.length % ep->ep.maxpacket) != 0) {
+ } else if (!ep->is_in &&
+ (req->req.length % ep->ep.maxpacket) != 0) {
tmp = readl(&ep->regs->ep_stat);
if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
return dma_done(ep, req, tmp, 0);
@@ -1317,8 +1317,8 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
writel(le32_to_cpu(req->td->dmadesc),
&ep->dma->dmadesc);
if (req->td->dmacount & dma_done_ie)
- writel(readl(&ep->dma->dmacount)
- | le32_to_cpu(dma_done_ie),
+ writel(readl(&ep->dma->dmacount) |
+ le32_to_cpu(dma_done_ie),
&ep->dma->dmacount);
} else {
struct net2280_request *prev;
@@ -2255,8 +2255,8 @@ static void ep0_start_228x(struct net2280 *dev)
{
writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
BIT(CLEAR_NAK_OUT_PACKETS) |
- BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE)
- , &dev->epregs[0].ep_rsp);
+ BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
+ &dev->epregs[0].ep_rsp);
/*
* hardware optionally handles a bunch of standard requests
@@ -2268,8 +2268,8 @@ static void ep0_start_228x(struct net2280 *dev)
BIT(SET_ADDRESS) |
BIT(DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP) |
BIT(GET_DEVICE_STATUS) |
- BIT(GET_INTERFACE_STATUS)
- , &dev->usb->stdrsp);
+ BIT(GET_INTERFACE_STATUS),
+ &dev->usb->stdrsp);
writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE) |
BIT(SELF_POWERED_USB_DEVICE) |
BIT(REMOTE_WAKEUP_SUPPORT) |
@@ -2330,8 +2330,8 @@ static void ep0_start_338x(struct net2280 *dev)
/* enable irqs so we can see ep0 and general operation */
writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE) |
- BIT(ENDPOINT_0_INTERRUPT_ENABLE)
- , &dev->regs->pciirqenb0);
+ BIT(ENDPOINT_0_INTERRUPT_ENABLE),
+ &dev->regs->pciirqenb0);
writel(BIT(PCI_INTERRUPT_ENABLE) |
BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE) |
BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
@@ -2366,8 +2366,8 @@ static int net2280_start(struct usb_gadget *_gadget,
* (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
* "must not be used in normal operation"
*/
- if (!driver || driver->max_speed < USB_SPEED_HIGH
- || !driver->setup)
+ if (!driver || driver->max_speed < USB_SPEED_HIGH ||
+ !driver->setup)
return -EINVAL;
dev = container_of(_gadget, struct net2280, gadget);
@@ -2542,10 +2542,10 @@ static void handle_ep_small(struct net2280_ep *ep)
}
mode = 2;
/* an extra OUT token is an error */
- } else if (((t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT))
- && req
- && req->req.actual == req->req.length)
- || (ep->responded && !req)) {
+ } else if (((t & BIT(DATA_OUT_PING_TOKEN_INTERRUPT)) &&
+ req &&
+ req->req.actual == req->req.length) ||
+ (ep->responded && !req)) {
ep->dev->protocol_stall = 1;
set_halt(ep);
ep->stopped = 1;
@@ -2576,8 +2576,8 @@ static void handle_ep_small(struct net2280_ep *ep)
* dma handles (M >= N), may empty the queue
*/
scan_dma_completions(ep);
- if (unlikely(list_empty(&ep->queue)
- || ep->out_overflow)) {
+ if (unlikely(list_empty(&ep->queue) ||
+ ep->out_overflow)) {
req = NULL;
break;
}
@@ -2611,10 +2611,10 @@ static void handle_ep_small(struct net2280_ep *ep)
}
/* also flush to prevent erratum 0106 trouble */
- if (unlikely(ep->out_overflow
- || (ep->dev->chiprev == 0x0100
- && ep->dev->gadget.speed
- == USB_SPEED_FULL))) {
+ if (unlikely(ep->out_overflow ||
+ (ep->dev->chiprev == 0x0100 &&
+ ep->dev->gadget.speed
+ == USB_SPEED_FULL))) {
out_flush(ep);
ep->out_overflow = 0;
}
@@ -2808,9 +2808,9 @@ static void ep_stall(struct net2280_ep *ep, int stall)
val = readl(&ep->regs->ep_rsp);
val |= BIT(CLEAR_ENDPOINT_HALT) |
BIT(CLEAR_ENDPOINT_TOGGLE);
- writel(val
- /* | BIT(CLEAR_NAK_PACKETS)*/
- , &ep->regs->ep_rsp);
+ writel(val,
+ /* | BIT(CLEAR_NAK_PACKETS),*/
+ &ep->regs->ep_rsp);
ep->is_halt = 0;
val = readl(&ep->regs->ep_rsp);
}
@@ -3125,8 +3125,8 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
BIT(DATA_PACKET_RECEIVED_INTERRUPT) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT) |
BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
- BIT(DATA_IN_TOKEN_INTERRUPT)
- , &ep->regs->ep_stat);
+ BIT(DATA_IN_TOKEN_INTERRUPT),
+ &ep->regs->ep_stat);
}
u.raw[0] = readl(&dev->usb->setup0123);
u.raw[1] = readl(&dev->usb->setup4567);
@@ -3206,8 +3206,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
/* hw handles device features */
if (u.r.bRequestType != USB_RECIP_ENDPOINT)
goto delegate;
- if (w_value != USB_ENDPOINT_HALT
- || w_length != 0)
+ if (w_value != USB_ENDPOINT_HALT || w_length != 0)
goto do_stall;
e = get_ep_by_addr(dev, w_index);
if (!e)
@@ -3233,8 +3232,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
/* hw handles device features */
if (u.r.bRequestType != USB_RECIP_ENDPOINT)
goto delegate;
- if (w_value != USB_ENDPOINT_HALT
- || w_length != 0)
+ if (w_value != USB_ENDPOINT_HALT || w_length != 0)
goto do_stall;
e = get_ep_by_addr(dev, w_index);
if (!e)
@@ -3326,12 +3324,11 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
*/
if (stat & tmp) {
writel(tmp, &dev->regs->irqstat1);
- if ((((stat & BIT(ROOT_PORT_RESET_INTERRUPT))
- && ((readl(&dev->usb->usbstat) & mask)
- == 0))
- || ((readl(&dev->usb->usbctl)
- & BIT(VBUS_PIN)) == 0)
- ) && (dev->gadget.speed != USB_SPEED_UNKNOWN)) {
+ if ((((stat & BIT(ROOT_PORT_RESET_INTERRUPT)) &&
+ (readl(&dev->usb->usbstat) & mask)) ||
+ ((readl(&dev->usb->usbctl) &
+ BIT(VBUS_PIN)) == 0)) &&
+ (dev->gadget.speed != USB_SPEED_UNKNOWN)) {
DEBUG(dev, "disconnect %s\n",
dev->driver->driver.name);
stop_activity(dev, dev->driver);
@@ -3560,7 +3557,7 @@ static void net2280_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
device_remove_file(&pdev->dev, &dev_attr_registers);
- INFO (dev, "unbind\n");
+ INFO(dev, "unbind\n");
}
/* wrap this driver around the specified device, but
@@ -3783,29 +3780,29 @@ static const struct pci_device_id pci_ids[] = { {
.device = 0x2280,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
-}, {
+ }, {
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
.vendor = PCI_VENDOR_ID_PLX_LEGACY,
.device = 0x2282,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
-},
+ },
{
- .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
- .class_mask = ~0,
- .vendor = PCI_VENDOR_ID_PLX,
- .device = 0x3380,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
+ .class_mask = ~0,
+ .vendor = PCI_VENDOR_ID_PLX,
+ .device = 0x3380,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
},
{
- .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
- .class_mask = ~0,
- .vendor = PCI_VENDOR_ID_PLX,
- .device = 0x3382,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
+ .class_mask = ~0,
+ .vendor = PCI_VENDOR_ID_PLX,
+ .device = 0x3382,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
},
{ /* end: all zeroes */ }
};
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index f019d6c..77c39d9 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -117,8 +117,8 @@ static inline void allow_status(struct net2280_ep *ep)
/* ep0 only */
writel(BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE) |
BIT(CLEAR_NAK_OUT_PACKETS) |
- BIT(CLEAR_NAK_OUT_PACKETS_MODE)
- , &ep->regs->ep_rsp);
+ BIT(CLEAR_NAK_OUT_PACKETS_MODE),
+ &ep->regs->ep_rsp);
ep->stopped = 1;
}
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/10 v2.1] usb: gadget: net2280: Use pr_* function
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (7 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 08/10 v2.1] usb: gadget: net2280: Code Cleanup Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 10/10] usb: gadget: net2280: Use quirks instead of pci id Ricardo Ribalda Delgado
2014-06-10 20:19 ` [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Driver was using custom functions WARNING, ERROR, DEBUG, instead of
pr_err, pr_dgb...
New ep_* macros have been created that use standard pr_* functions.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
v2: Comment by Joe Perches and Alan Stern
-Use ep_* instead of custom DETDEV macro
drivers/usb/gadget/net2280.c | 121 +++++++++++++++++++++----------------------
drivers/usb/gadget/net2280.h | 36 +++++--------
2 files changed, 71 insertions(+), 86 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d506c83..9ced9ff 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -42,9 +42,6 @@
* (at your option) any later version.
*/
-#undef DEBUG /* messages on error and most fault paths */
-#undef VERBOSE /* extra debug messages (success too) */
-
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
@@ -210,7 +207,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
* use it instead of troublesome (non-bulk) multi-packet DMA.
*/
if (ep->dma && (max % 4) != 0 && use_dma_chaining) {
- DEBUG(ep->dev, "%s, no dma for maxpacket %d\n",
+ ep_dbg(ep->dev, "%s, no dma for maxpacket %d\n",
ep->ep.name, ep->ep.maxpacket);
ep->dma = NULL;
}
@@ -303,7 +300,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
}
tmp = desc->bEndpointAddress;
- DEBUG(dev, "enabled %s (ep%d%s-%s) %s max %04x\n",
+ ep_dbg(dev, "enabled %s (ep%d%s-%s) %s max %04x\n",
_ep->name, tmp & 0x0f, DIR_STRING(tmp),
type_string(desc->bmAttributes),
ep->dma ? "dma" : "pio", max);
@@ -431,7 +428,7 @@ static void ep_reset_338x(struct net2280_regs __iomem *regs,
dmastat = readl(&ep->dma->dmastat);
if (dmastat == 0x5002) {
- WARNING(ep->dev, "The dmastat return = %x!!\n",
+ ep_warn(ep->dev, "The dmastat return = %x!!\n",
dmastat);
writel(0x5a, &ep->dma->dmastat);
}
@@ -476,7 +473,7 @@ static int net2280_disable(struct usb_ep *_ep)
else
ep_reset_228x(ep->dev->regs, ep);
- VDEBUG(ep->dev, "disabled %s %s\n",
+ ep_vdbg(ep->dev, "disabled %s %s\n",
ep->dma ? "dma" : "pio", _ep->name);
/* synch memory views with the device */
@@ -572,7 +569,7 @@ static void write_fifo(struct net2280_ep *ep, struct usb_request *req)
if (count > total) /* min() cannot be used on a bitfield */
count = total;
- VDEBUG(ep->dev, "write %s fifo (IN) %d bytes%s req %p\n",
+ ep_vdbg(ep->dev, "write %s fifo (IN) %d bytes%s req %p\n",
ep->ep.name, count,
(count != ep->ep.maxpacket) ? " (short)" : "",
req);
@@ -684,7 +681,7 @@ static int read_fifo(struct net2280_ep *ep, struct net2280_request *req)
if (count > tmp) {
/* as with DMA, data overflow gets flushed */
if ((tmp % ep->ep.maxpacket) != 0) {
- ERROR(ep->dev,
+ ep_err(ep->dev,
"%s out fifo %d bytes, expected %d\n",
ep->ep.name, count, tmp);
req->req.status = -EOVERFLOW;
@@ -699,7 +696,7 @@ static int read_fifo(struct net2280_ep *ep, struct net2280_request *req)
is_short = (count == 0) || ((count % ep->ep.maxpacket) != 0);
- VDEBUG(ep->dev, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
+ ep_vdbg(ep->dev, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
ep->ep.name, count, is_short ? " (short)" : "",
cleanup ? " flush" : "", prevent ? " nak" : "",
req, req->req.actual, req->req.length);
@@ -925,7 +922,7 @@ done(struct net2280_ep *ep, struct net2280_request *req, int status)
usb_gadget_unmap_request(&dev->gadget, &req->req, ep->is_in);
if (status && status != -ESHUTDOWN)
- VDEBUG(dev, "complete %s req %p stat %d len %u/%u\n",
+ ep_vdbg(dev, "complete %s req %p stat %d len %u/%u\n",
ep->ep.name, &req->req, status,
req->req.actual, req->req.length);
@@ -978,7 +975,7 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
}
#if 0
- VDEBUG(dev, "%s queue req %p, len %d buf %p\n",
+ ep_vdbg(dev, "%s queue req %p, len %d buf %p\n",
_ep->name, _req, _req->length, _req->buf);
#endif
@@ -1012,7 +1009,7 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
if (ep->num == 0 && _req->length == 0) {
allow_status(ep);
done(ep, req, 0);
- VDEBUG(dev, "%s status ack\n", ep->ep.name);
+ ep_vdbg(dev, "%s status ack\n", ep->ep.name);
goto done;
}
@@ -1131,7 +1128,7 @@ static void scan_dma_completions(struct net2280_ep *ep)
* 0122, and 0124; not all cases trigger the warning.
*/
if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
- WARNING(ep->dev, "%s lost packet sync!\n",
+ ep_warn(ep->dev, "%s lost packet sync!\n",
ep->ep.name);
req->req.status = -EOVERFLOW;
} else {
@@ -1139,7 +1136,7 @@ static void scan_dma_completions(struct net2280_ep *ep)
if (tmp) {
/* fifo gets flushed later */
ep->out_overflow = 1;
- DEBUG(ep->dev,
+ ep_dbg(ep->dev,
"%s dma, discard %d len %d\n",
ep->ep.name, tmp,
req->req.length);
@@ -1175,7 +1172,7 @@ static void restart_dma(struct net2280_ep *ep)
struct net2280_request *entry, *prev = NULL;
int reqmode, done = 0;
- DEBUG(ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td);
+ ep_dbg(ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td);
ep->in_fifo_validate = likely(req->req.zero ||
(req->req.length % ep->ep.maxpacket) != 0);
if (ep->in_fifo_validate)
@@ -1295,7 +1292,7 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
/* queue head may be partially complete. */
if (ep->queue.next == &req->queue) {
if (ep->dma) {
- DEBUG(ep->dev, "unlink (%s) dma\n", _ep->name);
+ ep_dbg(ep->dev, "unlink (%s) dma\n", _ep->name);
_req->status = -ECONNRESET;
abort_dma(ep);
if (likely(ep->queue.next == &req->queue)) {
@@ -1306,7 +1303,7 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
-ECONNRESET);
}
} else {
- DEBUG(ep->dev, "unlink (%s) pio\n", _ep->name);
+ ep_dbg(ep->dev, "unlink (%s) pio\n", _ep->name);
done(ep, req, -ECONNRESET);
}
req = NULL;
@@ -1379,7 +1376,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
else if (ep->is_in && value && net2280_fifo_status(_ep) != 0)
retval = -EAGAIN;
else {
- VDEBUG(ep->dev, "%s %s %s\n", _ep->name,
+ ep_vdbg(ep->dev, "%s %s %s\n", _ep->name,
value ? "set" : "clear",
wedged ? "wedge" : "halt");
/* set/clear, then synch memory views with the device */
@@ -1566,7 +1563,7 @@ static const struct usb_gadget_ops net2280_ops = {
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
+#ifdef CONFIG_USB_GADGET_PDEBUG_FILES
/* FIXME move these into procfs, and use seq_file.
* Sysfs _still_ doesn't behave for arbitrarily sized files,
@@ -1928,8 +1925,8 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
/*See if firmware needs to set up for workaround*/
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
- WARNING(dev, "Operate Defect 7374 workaround soft this time");
- WARNING(dev, "It will operate on cold-reboot and SS connect");
+ ep_warn(dev, "Operate Defect 7374 workaround soft this time");
+ ep_warn(dev, "It will operate on cold-reboot and SS connect");
/*GPEPs:*/
tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
@@ -1985,8 +1982,8 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
set_idx_reg(dev->regs, SCRATCH, scratch);
} else{
- WARNING(dev, "Defect 7374 workaround soft will NOT operate");
- WARNING(dev, "It will operate on cold-reboot and SS connect");
+ ep_warn(dev, "Defect 7374 workaround soft will NOT operate");
+ ep_warn(dev, "It will operate on cold-reboot and SS connect");
}
}
@@ -2050,7 +2047,7 @@ static void usb_reset_338x(struct net2280 *dev)
/* See if firmware needs to set up for workaround: */
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
- INFO(dev, "%s: Defect 7374 FsmValue 0x%08x\n", __func__,
+ ep_info(dev, "%s: Defect 7374 FsmValue 0x%08x\n", __func__,
fsmvalue);
} else {
/* disable automatic responses, and irqs */
@@ -2187,7 +2184,7 @@ static void usb_reinit_338x(struct net2280 *dev)
/* See if driver needs to set up for workaround: */
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
- INFO(dev, "%s: Defect 7374 FsmValue %08x\n",
+ ep_info(dev, "%s: Defect 7374 FsmValue %08x\n",
__func__, fsmvalue);
else {
tmp = readl(&dev->usb_ext->usbctl2) &
@@ -2302,7 +2299,7 @@ static void ep0_start_338x(struct net2280 *dev)
(0xf << DEFECT7374_FSM_FIELD);
if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
- INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
+ ep_info(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
fsmvalue);
else
writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
@@ -2401,7 +2398,7 @@ static int net2280_start(struct usb_gadget *_gadget,
ep0_start(dev);
- DEBUG(dev, "%s ready, usbctl %08x stdrsp %08x\n",
+ ep_dbg(dev, "%s ready, usbctl %08x stdrsp %08x\n",
driver->driver.name,
readl(&dev->usb->usbctl),
readl(&dev->usb->stdrsp));
@@ -2464,7 +2461,7 @@ static int net2280_stop(struct usb_gadget *_gadget,
device_remove_file(&dev->pdev->dev, &dev_attr_function);
device_remove_file(&dev->pdev->dev, &dev_attr_queues);
- DEBUG(dev, "unregistered driver '%s'\n",
+ ep_dbg(dev, "unregistered driver '%s'\n",
driver ? driver->driver.name : "");
return 0;
@@ -2493,7 +2490,7 @@ static void handle_ep_small(struct net2280_ep *ep)
t = readl(&ep->regs->ep_stat);
ep->irqs++;
#if 0
- VDEBUG(ep->dev, "%s ack ep_stat %08x, req %p\n",
+ ep_vdbg(ep->dev, "%s ack ep_stat %08x, req %p\n",
ep->ep.name, t, req ? &req->req : 0);
#endif
if (!ep->is_in || ep->dev->pdev->device == 0x2280)
@@ -2624,7 +2621,7 @@ static void handle_ep_small(struct net2280_ep *ep)
if (!list_empty(&ep->queue))
restart_dma(ep);
} else
- DEBUG(ep->dev, "%s dma ep_stat %08x ??\n",
+ ep_dbg(ep->dev, "%s dma ep_stat %08x ??\n",
ep->ep.name, t);
return;
@@ -2758,12 +2755,12 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
if (ack_wait_timeout >= DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS) {
- ERROR(dev, "FAIL: Defect 7374 workaround waited but failed "
+ ep_err(dev, "FAIL: Defect 7374 workaround waited but failed "
"to detect SS host's data phase ACK.");
- ERROR(dev, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16"
+ ep_err(dev, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16"
"got 0x%2.2x.\n", state >> STATE);
} else {
- WARNING(dev, "INFO: Defect 7374 workaround waited about\n"
+ ep_warn(dev, "INFO: Defect 7374 workaround waited about\n"
"%duSec for Control Read Data Phase ACK\n",
DEFECT_7374_PROCESSOR_WAIT_TIME * ack_wait_timeout);
}
@@ -2953,7 +2950,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
goto do_stall3;
if (w_value != USB_ENDPOINT_HALT)
goto do_stall3;
- VDEBUG(dev, "%s clear halt\n", e->ep.name);
+ ep_vdbg(dev, "%s clear halt\n", e->ep.name);
ep_stall(e, false);
if (!list_empty(&e->queue) && e->td_dma)
restart_dma(e);
@@ -3024,7 +3021,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
default:
usb3_delegate:
- VDEBUG(dev, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
+ ep_vdbg(dev, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
r.bRequestType, r.bRequest,
w_value, w_index, w_length,
readl(&ep->cfg->ep_cfg));
@@ -3036,7 +3033,7 @@ usb3_delegate:
}
do_stall3:
if (tmp < 0) {
- VDEBUG(dev, "req %02x.%02x protocol STALL; stat %d\n",
+ ep_vdbg(dev, "req %02x.%02x protocol STALL; stat %d\n",
r.bRequestType, r.bRequest, tmp);
dev->protocol_stall = 1;
/* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
@@ -3061,7 +3058,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
stat &= ~BIT(INTA_ASSERTED);
if (!stat)
return;
- /* DEBUG(dev, "irqstat0 %04x\n", stat); */
+ /* ep_dbg(dev, "irqstat0 %04x\n", stat); */
/* starting a control request? */
if (unlikely(stat & BIT(SETUP_PACKET_INTERRUPT))) {
@@ -3088,7 +3085,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
EP0_HS_MAX_PACKET_SIZE);
}
net2280_led_speed(dev, dev->gadget.speed);
- DEBUG(dev, "%s\n",
+ ep_dbg(dev, "%s\n",
usb_speed_string(dev->gadget.speed));
}
@@ -3196,7 +3193,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
set_fifo_bytecount(ep, w_length);
writel((__force u32)status, &dev->epregs[0].ep_data);
allow_status(ep);
- VDEBUG(dev, "%s stat %02x\n", ep->ep.name, status);
+ ep_vdbg(dev, "%s stat %02x\n", ep->ep.name, status);
goto next_endpoints;
}
break;
@@ -3212,10 +3209,10 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
if (!e)
goto do_stall;
if (e->wedged) {
- VDEBUG(dev, "%s wedged, halt not cleared\n",
+ ep_vdbg(dev, "%s wedged, halt not cleared\n",
ep->ep.name);
} else {
- VDEBUG(dev, "%s clear halt\n", e->ep.name);
+ ep_vdbg(dev, "%s clear halt\n", e->ep.name);
clear_halt(e);
if (ep->dev->pdev->vendor ==
PCI_VENDOR_ID_PLX &&
@@ -3243,13 +3240,13 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
if (dev->pdev->vendor == PCI_VENDOR_ID_PLX && e->dma)
abort_dma(e);
allow_status(ep);
- VDEBUG(dev, "%s set halt\n", ep->ep.name);
+ ep_vdbg(dev, "%s set halt\n", ep->ep.name);
goto next_endpoints;
}
break;
default:
delegate:
- VDEBUG(dev, "setup %02x.%02x v%04x i%04x l%04x "
+ ep_vdbg(dev, "setup %02x.%02x v%04x i%04x l%04x "
"ep_cfg %08x\n",
u.r.bRequestType, u.r.bRequest,
w_value, w_index, w_length,
@@ -3263,7 +3260,7 @@ delegate:
/* stall ep0 on error */
if (tmp < 0) {
do_stall:
- VDEBUG(dev, "req %02x.%02x protocol STALL; stat %d\n",
+ ep_vdbg(dev, "req %02x.%02x protocol STALL; stat %d\n",
u.r.bRequestType, u.r.bRequest, tmp);
dev->protocol_stall = 1;
}
@@ -3296,7 +3293,7 @@ next_endpoints:
}
if (stat)
- DEBUG(dev, "unhandled irqstat0 %08x\n", stat);
+ ep_dbg(dev, "unhandled irqstat0 %08x\n", stat);
}
#define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
@@ -3329,7 +3326,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
((readl(&dev->usb->usbctl) &
BIT(VBUS_PIN)) == 0)) &&
(dev->gadget.speed != USB_SPEED_UNKNOWN)) {
- DEBUG(dev, "disconnect %s\n",
+ ep_dbg(dev, "disconnect %s\n",
dev->driver->driver.name);
stop_activity(dev, dev->driver);
ep0_start(dev);
@@ -3381,7 +3378,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
if (!stat)
return;
- /* DEBUG(dev, "irqstat1 %08x\n", stat);*/
+ /* ep_dbg(dev, "irqstat1 %08x\n", stat);*/
/* DMA status, for ep-{a,b,c,d} */
scratch = stat & DMA_INTERRUPTS;
@@ -3418,7 +3415,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
*/
if (!use_dma_chaining) {
if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
- DEBUG(ep->dev, "%s no xact done? %08x\n",
+ ep_dbg(ep->dev, "%s no xact done? %08x\n",
ep->ep.name, tmp);
continue;
}
@@ -3470,7 +3467,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
* if they appear very often, here's where to try recovering.
*/
if (stat & PCI_ERROR_INTERRUPTS) {
- ERROR(dev, "pci dma error; stat %08x\n", stat);
+ ep_err(dev, "pci dma error; stat %08x\n", stat);
stat &= ~PCI_ERROR_INTERRUPTS;
/* these are fatal errors, but "maybe" they won't
* happen again ...
@@ -3481,7 +3478,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
}
if (stat)
- DEBUG(dev, "unhandled irqstat1 %08x\n", stat);
+ ep_dbg(dev, "unhandled irqstat1 %08x\n", stat);
}
static irqreturn_t net2280_irq(int irq, void *_dev)
@@ -3557,7 +3554,7 @@ static void net2280_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
device_remove_file(&pdev->dev, &dev_attr_registers);
- INFO(dev, "unbind\n");
+ ep_info(dev, "unbind\n");
}
/* wrap this driver around the specified device, but
@@ -3605,7 +3602,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
resource = pci_resource_start(pdev, 0);
len = pci_resource_len(pdev, 0);
if (!request_mem_region(resource, len, driver_name)) {
- DEBUG(dev, "controller already in use\n");
+ ep_dbg(dev, "controller already in use\n");
retval = -EBUSY;
goto done;
}
@@ -3617,7 +3614,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
base = ioremap_nocache(resource, len);
if (base == NULL) {
- DEBUG(dev, "can't map memory\n");
+ ep_dbg(dev, "can't map memory\n");
retval = -EFAULT;
goto done;
}
@@ -3666,18 +3663,18 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* irq setup after old hardware is cleaned up */
if (!pdev->irq) {
- ERROR(dev, "No IRQ. Check PCI setup!\n");
+ ep_err(dev, "No IRQ. Check PCI setup!\n");
retval = -ENODEV;
goto done;
}
if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
if (pci_enable_msi(pdev))
- ERROR(dev, "Failed to enable MSI mode\n");
+ ep_err(dev, "Failed to enable MSI mode\n");
if (request_irq(pdev->irq, net2280_irq, IRQF_SHARED,
driver_name, dev)) {
- ERROR(dev, "request interrupt %d failed\n", pdev->irq);
+ ep_err(dev, "request interrupt %d failed\n", pdev->irq);
retval = -EBUSY;
goto done;
}
@@ -3690,7 +3687,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
0 /* no alignment requirements */,
0 /* or page-crossing issues */);
if (!dev->requests) {
- DEBUG(dev, "can't get request pool\n");
+ ep_dbg(dev, "can't get request pool\n");
retval = -ENOMEM;
goto done;
}
@@ -3700,7 +3697,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
td = pci_pool_alloc(dev->requests, GFP_KERNEL,
&dev->ep[i].td_dma);
if (!td) {
- DEBUG(dev, "can't get dummy %d\n", i);
+ ep_dbg(dev, "can't get dummy %d\n", i);
retval = -ENOMEM;
goto done;
}
@@ -3727,10 +3724,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev->chiprev = get_idx_reg(dev->regs, REG_CHIPREV) & 0xffff;
/* done */
- INFO(dev, "%s\n", driver_desc);
- INFO(dev, "irq %d, pci mem %p, chip rev %04x\n",
+ ep_info(dev, "%s\n", driver_desc);
+ ep_info(dev, "irq %d, pci mem %p, chip rev %04x\n",
pdev->irq, base, dev->chiprev);
- INFO(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
+ ep_info(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
use_dma ? (use_dma_chaining ? "chaining" : "enabled")
: "disabled",
dev->enhanced_mode ? "enhanced mode" : "legacy mode");
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 77c39d9..dc9ca1d 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -314,32 +314,20 @@ static inline void net2280_led_shutdown(struct net2280 *dev)
/*-------------------------------------------------------------------------*/
-#define xprintk(dev, level, fmt, args...) \
- printk(level "%s %s: " fmt, driver_name, \
- pci_name(dev->pdev), ## args)
+#define ep_dbg(ndev, fmt, args...) \
+ dev_dbg((&((ndev)->pdev->dev)), fmt, ##args)
-#ifdef DEBUG
-#undef DEBUG
-#define DEBUG(dev, fmt, args...) \
- xprintk(dev, KERN_DEBUG, fmt, ## args)
-#else
-#define DEBUG(dev, fmt, args...) \
- do { } while (0)
-#endif /* DEBUG*/
+#define ep_vdbg(ndev, fmt, args...) \
+ dev_vdbg((&((ndev)->pdev->dev)), fmt, ##args)
-#ifdef VERBOSE
-#define VDEBUG DEBUG
-#else
-#define VDEBUG(dev, fmt, args...) \
- do { } while (0)
-#endif /* VERBOSE */
+#define ep_info(ndev, fmt, args...) \
+ dev_info((&((ndev)->pdev->dev)), fmt, ##args)
+
+#define ep_warn(ndev, fmt, args...) \
+ dev_warn((&((ndev)->pdev->dev)), fmt, ##args)
-#define ERROR(dev, fmt, args...) \
- xprintk(dev, KERN_ERR, fmt, ## args)
-#define WARNING(dev, fmt, args...) \
- xprintk(dev, KERN_WARNING, fmt, ## args)
-#define INFO(dev, fmt, args...) \
- xprintk(dev, KERN_INFO, fmt, ## args)
+#define ep_err(ndev, fmt, args...) \
+ dev_err((&((ndev)->pdev->dev)), fmt, ##args)
/*-------------------------------------------------------------------------*/
@@ -368,7 +356,7 @@ static inline void assert_out_naking(struct net2280_ep *ep, const char *where)
u32 tmp = readl(&ep->regs->ep_stat);
if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
- DEBUG(ep->dev, "%s %s %08x !NAK\n",
+ ep_dbg(ep->dev, "%s %s %08x !NAK\n",
ep->ep.name, where, tmp);
writel(BIT(SET_NAK_OUT_PACKETS),
&ep->regs->ep_rsp);
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/10] usb: gadget: net2280: Use quirks instead of pci id
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (8 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 09/10 v2.1] usb: gadget: net2280: Use pr_* function Ricardo Ribalda Delgado
@ 2014-05-20 16:30 ` Ricardo Ribalda Delgado
2014-06-10 20:19 ` [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
10 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-05-20 16:30 UTC (permalink / raw)
To: balbi, gregkh, linux-kernel, linux-usb, joe, auttamchandani,
stern
Cc: Ricardo Ribalda Delgado
Use of quirks improve readability and will be easier to add new devices
to this driver.
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/usb/gadget/net2280.c | 83 +++++++++++++++++++++++---------------------
drivers/usb/gadget/net2280.h | 6 ++++
2 files changed, 49 insertions(+), 40 deletions(-)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 9ced9ff..ce8bc86 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -147,7 +147,7 @@ static inline void enable_pciirqenb(struct net2280_ep *ep)
{
u32 tmp = readl(&ep->dev->regs->pciirqenb0);
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (ep->dev->quirks & PLX_LEGACY)
tmp |= BIT(ep->num);
else
tmp |= BIT(ep_bit[ep->num]);
@@ -177,7 +177,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE)
return -EDOM;
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
+ if (dev->quirks & PLX_SUPERSPEED) {
if ((desc->bEndpointAddress & 0x0f) >= 0x0c)
return -EDOM;
ep->is_in = !!usb_endpoint_dir_in(desc);
@@ -187,8 +187,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* sanity check ep-e/ep-f since their fifos are small */
max = usb_endpoint_maxp(desc) & 0x1fff;
- if (ep->num > 4 && max > 64 &&
- (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY))
+ if (ep->num > 4 && max > 64 && (dev->quirks & PLX_LEGACY))
return -ERANGE;
spin_lock_irqsave(&dev->lock, flags);
@@ -233,7 +232,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
}
ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC);
/* Enable this endpoint */
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY) {
+ if (dev->quirks & PLX_LEGACY) {
tmp <<= ENDPOINT_TYPE;
tmp |= desc->bEndpointAddress;
/* default full fifo lines */
@@ -263,7 +262,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* for OUT transfers, block the rx fifo until a read is posted */
if (!ep->is_in)
writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
- else if (dev->pdev->device != 0x2280) {
+ else if (!(dev->quirks & PLX_2280)) {
/* Added for 2282, Don't use nak packets on an in endpoint,
* this was ignored on 2280
*/
@@ -279,7 +278,7 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
tmp = BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE);
- if (dev->pdev->device == 0x2280)
+ if (dev->quirks & PLX_2280)
tmp |= readl(&ep->regs->ep_irqenb);
writel(tmp, &ep->regs->ep_irqenb);
} else { /* dma, per-request */
@@ -361,7 +360,7 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
/* init to our chosen defaults, notably so that we NAK OUT
* packets until the driver queues a read (+note erratum 0112)
*/
- if (!ep->is_in || ep->dev->pdev->device == 0x2280) {
+ if (!ep->is_in || (ep->dev->quirks & PLX_2280)) {
tmp = BIT(SET_NAK_OUT_PACKETS_MODE) |
BIT(SET_NAK_OUT_PACKETS) |
BIT(CLEAR_EP_HIDE_STATUS_PHASE) |
@@ -381,7 +380,7 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
writel(tmp, &ep->regs->ep_rsp);
/* scrub most status bits, and flush any fifo state */
- if (ep->dev->pdev->device == 0x2280)
+ if (ep->dev->quirks & PLX_2280)
tmp = BIT(FIFO_OVERFLOW) |
BIT(FIFO_UNDERFLOW);
else
@@ -468,7 +467,7 @@ static int net2280_disable(struct usb_ep *_ep)
spin_lock_irqsave(&ep->dev->lock, flags);
nuke(ep);
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (ep->dev->quirks & PLX_SUPERSPEED)
ep_reset_338x(ep->dev->regs, ep);
else
ep_reset_228x(ep->dev->regs, ep);
@@ -742,7 +741,7 @@ static void fill_dma_desc(struct net2280_ep *ep,
if (ep->is_in)
dmacount |= BIT(DMA_DIRECTION);
if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) ||
- ep->dev->pdev->device != 0x2280)
+ !(ep->dev->quirks & PLX_2280))
dmacount |= BIT(END_OF_CHAIN);
req->valid = valid;
@@ -786,14 +785,14 @@ static void start_queue(struct net2280_ep *ep, u32 dmactl, u32 td_dma)
struct net2280_dma_regs __iomem *dma = ep->dma;
unsigned int tmp = BIT(VALID_BIT) | (ep->is_in << DMA_DIRECTION);
- if (ep->dev->pdev->device != 0x2280)
+ if (!(ep->dev->quirks & PLX_2280))
tmp |= BIT(END_OF_CHAIN);
writel(tmp, &dma->dmacount);
writel(readl(&dma->dmastat), &dma->dmastat);
writel(td_dma, &dma->dmadesc);
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (ep->dev->quirks & PLX_SUPERSPEED)
dmactl |= BIT(DMA_REQUEST_OUTSTANDING);
writel(dmactl, &dma->dmactl);
@@ -989,7 +988,7 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* DMA request while EP halted */
if (ep->dma &&
(readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)) &&
- (dev->pdev->vendor == PCI_VENDOR_ID_PLX)) {
+ (dev->quirks & PLX_SUPERSPEED)) {
int valid = 1;
if (ep->is_in) {
int expect;
@@ -1120,7 +1119,7 @@ static void scan_dma_completions(struct net2280_ep *ep)
} else if (!ep->is_in &&
(req->req.length % ep->ep.maxpacket) != 0) {
tmp = readl(&ep->regs->ep_stat);
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (ep->dev->quirks & PLX_SUPERSPEED)
return dma_done(ep, req, tmp, 0);
/* AVOID TROUBLE HERE by not issuing short reads from
@@ -1231,7 +1230,7 @@ static void abort_dma_338x(struct net2280_ep *ep)
static void abort_dma(struct net2280_ep *ep)
{
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (ep->dev->quirks & PLX_LEGACY)
return abort_dma_228x(ep);
return abort_dma_338x(ep);
}
@@ -1389,7 +1388,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
ep->wedged = 1;
} else {
clear_halt(ep);
- if (ep->dev->pdev->vendor == PCI_VENDOR_ID_PLX &&
+ if (ep->dev->quirks & PLX_SUPERSPEED &&
!list_empty(&ep->queue) && ep->td_dma)
restart_dma(ep);
ep->wedged = 0;
@@ -2087,7 +2086,7 @@ static void usb_reset_338x(struct net2280 *dev)
static void usb_reset(struct net2280 *dev)
{
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
return usb_reset_228x(dev);
return usb_reset_338x(dev);
}
@@ -2243,7 +2242,7 @@ static void usb_reinit_338x(struct net2280 *dev)
static void usb_reinit(struct net2280 *dev)
{
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
return usb_reinit_228x(dev);
return usb_reinit_338x(dev);
}
@@ -2341,7 +2340,7 @@ static void ep0_start_338x(struct net2280 *dev)
static void ep0_start(struct net2280 *dev)
{
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
return ep0_start_228x(dev);
return ep0_start_338x(dev);
}
@@ -2385,7 +2384,7 @@ static int net2280_start(struct usb_gadget *_gadget,
goto err_func;
/* Enable force-full-speed testing mode, if desired */
- if (full_speed && dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (full_speed && (dev->quirks & PLX_LEGACY))
writel(BIT(FORCE_FULL_SPEED_MODE), &dev->usb->xcvrdiag);
/* ... then enable host detection and ep0; and we're ready
@@ -2393,7 +2392,7 @@ static int net2280_start(struct usb_gadget *_gadget,
*/
net2280_led_active(dev, 1);
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (dev->quirks & PLX_SUPERSPEED)
defect7374_enable_data_eps_zero(dev);
ep0_start(dev);
@@ -2455,7 +2454,7 @@ static int net2280_stop(struct usb_gadget *_gadget,
net2280_led_active(dev, 0);
/* Disable full-speed test mode */
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
writel(0, &dev->usb->xcvrdiag);
device_remove_file(&dev->pdev->dev, &dev_attr_function);
@@ -2493,7 +2492,7 @@ static void handle_ep_small(struct net2280_ep *ep)
ep_vdbg(ep->dev, "%s ack ep_stat %08x, req %p\n",
ep->ep.name, t, req ? &req->req : 0);
#endif
- if (!ep->is_in || ep->dev->pdev->device == 0x2280)
+ if (!ep->is_in || (ep->dev->quirks & PLX_2280))
writel(t & ~BIT(NAK_OUT_PACKETS), &ep->regs->ep_stat);
else
/* Added for 2282 */
@@ -3102,10 +3101,10 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
}
ep->stopped = 0;
dev->protocol_stall = 0;
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (dev->quirks & PLX_SUPERSPEED)
ep->is_halt = 0;
else{
- if (ep->dev->pdev->device == 0x2280)
+ if (ep->dev->quirks & PLX_2280)
tmp = BIT(FIFO_OVERFLOW) |
BIT(FIFO_UNDERFLOW);
else
@@ -3131,7 +3130,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
cpu_to_le32s(&u.raw[0]);
cpu_to_le32s(&u.raw[1]);
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (dev->quirks & PLX_SUPERSPEED)
defect7374_workaround(dev, u.r);
tmp = 0;
@@ -3214,8 +3213,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
} else {
ep_vdbg(dev, "%s clear halt\n", e->ep.name);
clear_halt(e);
- if (ep->dev->pdev->vendor ==
- PCI_VENDOR_ID_PLX &&
+ if ((ep->dev->quirks & PLX_SUPERSPEED) &&
!list_empty(&e->queue) && e->td_dma)
restart_dma(e);
}
@@ -3237,7 +3235,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
if (e->ep.name == ep0name)
goto do_stall;
set_halt(e);
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX && e->dma)
+ if ((dev->quirks & PLX_SUPERSPEED) && e->dma)
abort_dma(e);
allow_status(ep);
ep_vdbg(dev, "%s set halt\n", ep->ep.name);
@@ -3365,7 +3363,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
writel(stat, &dev->regs->irqstat1);
/* some status we can just ignore */
- if (dev->pdev->device == 0x2280)
+ if (dev->quirks & PLX_2280)
stat &= ~(BIT(CONTROL_STATUS_INTERRUPT) |
BIT(SUSPEND_REQUEST_INTERRUPT) |
BIT(RESUME_INTERRUPT) |
@@ -3403,7 +3401,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
writel(tmp, &dma->dmastat);
/* dma sync*/
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
+ if (dev->quirks & PLX_SUPERSPEED) {
u32 r_dmacount = readl(&dma->dmacount);
if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT)))
@@ -3486,7 +3484,7 @@ static irqreturn_t net2280_irq(int irq, void *_dev)
struct net2280 *dev = _dev;
/* shared interrupt, not ours */
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY &&
+ if ((dev->quirks & PLX_LEGACY) &&
(!(readl(&dev->regs->irqstat0) & BIT(INTA_ASSERTED))))
return IRQ_NONE;
@@ -3498,7 +3496,7 @@ static irqreturn_t net2280_irq(int irq, void *_dev)
/* control requests and PIO */
handle_stat0_irqs(dev, readl(&dev->regs->irqstat0));
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
+ if (dev->quirks & PLX_SUPERSPEED) {
/* re-enable interrupt to trigger any possible new interrupt */
u32 pciirqenb1 = readl(&dev->regs->pciirqenb1);
writel(pciirqenb1 & 0x7FFFFFFF, &dev->regs->pciirqenb1);
@@ -3543,7 +3541,7 @@ static void net2280_remove(struct pci_dev *pdev)
}
if (dev->got_irq)
free_irq(pdev->irq, dev);
- if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (use_msi && dev->quirks & PLX_SUPERSPEED)
pci_disable_msi(pdev);
if (dev->regs)
iounmap(dev->regs);
@@ -3580,9 +3578,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_drvdata(pdev, dev);
spin_lock_init(&dev->lock);
+ dev->quirks = id->driver_data;
dev->pdev = pdev;
dev->gadget.ops = &net2280_ops;
- dev->gadget.max_speed = (dev->pdev->vendor == PCI_VENDOR_ID_PLX) ?
+ dev->gadget.max_speed = (dev->quirks & PLX_SUPERSPEED) ?
USB_SPEED_SUPER : USB_SPEED_HIGH;
/* the "gadget" abstracts/virtualizes the controller */
@@ -3625,7 +3624,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200);
dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300);
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX) {
+ if (dev->quirks & PLX_SUPERSPEED) {
u32 fsmvalue;
u32 usbstat;
dev->usb_ext = (struct usb338x_usb_ext_regs __iomem *)
@@ -3668,7 +3667,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto done;
}
- if (use_msi && dev->pdev->vendor == PCI_VENDOR_ID_PLX)
+ if (use_msi && (dev->quirks & PLX_SUPERSPEED))
if (pci_enable_msi(pdev))
ep_err(dev, "Failed to enable MSI mode\n");
@@ -3707,7 +3706,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
/* enable lower-overhead pci memory bursts during DMA */
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
writel(BIT(DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE) |
/*
* 256 write retries may not be enough...
@@ -3763,7 +3762,7 @@ static void net2280_shutdown(struct pci_dev *pdev)
writel(0, &dev->usb->usbctl);
/* Disable full-speed test mode */
- if (dev->pdev->vendor == PCI_VENDOR_ID_PLX_LEGACY)
+ if (dev->quirks & PLX_LEGACY)
writel(0, &dev->usb->xcvrdiag);
}
@@ -3777,6 +3776,7 @@ static const struct pci_device_id pci_ids[] = { {
.device = 0x2280,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .driver_data = PLX_LEGACY | PLX_2280,
}, {
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
.class_mask = ~0,
@@ -3784,6 +3784,7 @@ static const struct pci_device_id pci_ids[] = { {
.device = 0x2282,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .driver_data = PLX_LEGACY,
},
{
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
@@ -3792,6 +3793,7 @@ static const struct pci_device_id pci_ids[] = { {
.device = 0x3380,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .driver_data = PLX_SUPERSPEED,
},
{
.class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
@@ -3800,6 +3802,7 @@ static const struct pci_device_id pci_ids[] = { {
.device = 0x3382,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .driver_data = PLX_SUPERSPEED,
},
{ /* end: all zeroes */ }
};
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index dc9ca1d..03f1524 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -44,6 +44,10 @@ set_idx_reg(struct net2280_regs __iomem *regs, u32 index, u32 value)
#define PCI_VENDOR_ID_PLX_LEGACY 0x17cc
+#define PLX_LEGACY BIT(0)
+#define PLX_2280 BIT(1)
+#define PLX_SUPERSPEED BIT(2)
+
#define REG_DIAG 0x0
#define RETRY_COUNTER 16
#define FORCE_PCI_SERR 11
@@ -166,6 +170,8 @@ struct net2280 {
u16 chiprev;
int enhanced_mode;
int n_ep;
+ kernel_ulong_t quirks;
+
/* pci state used to access those endpoints */
struct pci_dev *pdev;
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
` (9 preceding siblings ...)
2014-05-20 16:30 ` [PATCH 10/10] usb: gadget: net2280: Use quirks instead of pci id Ricardo Ribalda Delgado
@ 2014-06-10 20:19 ` Ricardo Ribalda Delgado
2014-06-30 19:30 ` Ricardo Ribalda Delgado
10 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-06-10 20:19 UTC (permalink / raw)
To: balbi@ti.com, Greg Kroah-Hartman, LKML, Linux USB Mailing List,
Joe Perches, Amit Uttamchandani, Alan Stern
Cc: Ricardo Ribalda Delgado
Ping...
On Tue, May 20, 2014 at 6:30 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@gmail.com> wrote:
> The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
> Controller. It shares a lot functionatily with the net228x family.
>
> This series of patches includes some resend of previous patches.
>
> Please check the changelog for every patch. This time it has been placed
> under the tear line
>
>
>
> Ricardo Ribalda Delgado (10):
> usb: gadget: net2280: Add support for PLX USB338X
> usb: gadget: net2280: Dont use magic numbers
> usb: gadget: net2280: Use BIT() macro
> usb: gadget: net2280: Use true/false instead of 1/0
> usb: gadget: net2280: Use module_pci_driver macro
> usb: gadget: net2280: Refactor queues_show
> usb: gadget: net2280: Pass checkpacth.pl test
> usb: gadget: net2280: Code Cleanup
> usb: gadget: net2280: Use pr_* function
> usb: gadget: net2280: Use quirks instead of pci id
>
> drivers/usb/gadget/Kconfig | 10 +-
> drivers/usb/gadget/net2280.c | 2752 ++++++++++++++++++++++++++++--------------
> drivers/usb/gadget/net2280.h | 285 +++--
> include/linux/usb/usb338x.h | 199 +++
> 4 files changed, 2235 insertions(+), 1011 deletions(-)
> create mode 100644 include/linux/usb/usb338x.h
>
> --
> 2.0.0.rc2
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code
2014-06-10 20:19 ` [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
@ 2014-06-30 19:30 ` Ricardo Ribalda Delgado
2014-06-30 19:38 ` Felipe Balbi
0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-06-30 19:30 UTC (permalink / raw)
To: balbi@ti.com, Greg Kroah-Hartman, LKML, Linux USB Mailing List,
Joe Perches, Amit Uttamchandani, Alan Stern
Cc: Ricardo Ribalda Delgado
Hello Felipe
Any comment on this patchset? Shall I resend it rebased on v3.16-rc2?
Regards
On Tue, Jun 10, 2014 at 10:19 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@gmail.com> wrote:
> Ping...
>
> On Tue, May 20, 2014 at 6:30 PM, Ricardo Ribalda Delgado
> <ricardo.ribalda@gmail.com> wrote:
>> The USB 3380 is a PCI Express Gen 2 to USB 3.0 SuperSpeed Peripheral
>> Controller. It shares a lot functionatily with the net228x family.
>>
>> This series of patches includes some resend of previous patches.
>>
>> Please check the changelog for every patch. This time it has been placed
>> under the tear line
>>
>>
>>
>> Ricardo Ribalda Delgado (10):
>> usb: gadget: net2280: Add support for PLX USB338X
>> usb: gadget: net2280: Dont use magic numbers
>> usb: gadget: net2280: Use BIT() macro
>> usb: gadget: net2280: Use true/false instead of 1/0
>> usb: gadget: net2280: Use module_pci_driver macro
>> usb: gadget: net2280: Refactor queues_show
>> usb: gadget: net2280: Pass checkpacth.pl test
>> usb: gadget: net2280: Code Cleanup
>> usb: gadget: net2280: Use pr_* function
>> usb: gadget: net2280: Use quirks instead of pci id
>>
>> drivers/usb/gadget/Kconfig | 10 +-
>> drivers/usb/gadget/net2280.c | 2752 ++++++++++++++++++++++++++++--------------
>> drivers/usb/gadget/net2280.h | 285 +++--
>> include/linux/usb/usb338x.h | 199 +++
>> 4 files changed, 2235 insertions(+), 1011 deletions(-)
>> create mode 100644 include/linux/usb/usb338x.h
>>
>> --
>> 2.0.0.rc2
>>
>
>
>
> --
> Ricardo Ribalda
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code
2014-06-30 19:30 ` Ricardo Ribalda Delgado
@ 2014-06-30 19:38 ` Felipe Balbi
0 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2014-06-30 19:38 UTC (permalink / raw)
To: Ricardo Ribalda Delgado
Cc: balbi@ti.com, Greg Kroah-Hartman, LKML, Linux USB Mailing List,
Joe Perches, Amit Uttamchandani, Alan Stern
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
On Mon, Jun 30, 2014 at 09:30:49PM +0200, Ricardo Ribalda Delgado wrote:
> Hello Felipe
>
> Any comment on this patchset? Shall I resend it rebased on v3.16-rc2?
they are all in my 'testing/next' branch. Should be available on 'next'
next week if nothing wrong is found.
cheers
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-06-30 19:39 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 16:30 [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 01/10 v5.1] usb: gadget: net2280: Add support for PLX USB338X Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 02/10] usb: gadget: net2280: Dont use magic numbers Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 03/10] usb: gadget: net2280: Use BIT() macro Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 04/10] usb: gadget: net2280: Use true/false instead of 1/0 Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 05/10] usb: gadget: net2280: Use module_pci_driver macro Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 06/10] usb: gadget: net2280: Refactor queues_show Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 07/10 v3] usb: gadget: net2280: Pass checkpacth.pl test Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 08/10 v2.1] usb: gadget: net2280: Code Cleanup Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 09/10 v2.1] usb: gadget: net2280: Use pr_* function Ricardo Ribalda Delgado
2014-05-20 16:30 ` [PATCH 10/10] usb: gadget: net2280: Use quirks instead of pci id Ricardo Ribalda Delgado
2014-06-10 20:19 ` [PATCH 00/10] net2280: Support for PLX USB338x and cleanout code Ricardo Ribalda Delgado
2014-06-30 19:30 ` Ricardo Ribalda Delgado
2014-06-30 19:38 ` Felipe Balbi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox