提交 259127ba 编写于 作者: P Peter Senna Tschudin 提交者: Greg Kroah-Hartman

usb/host/fotg210: Fix coding style issues

This patch fix coding style issues reported by checkpatch that do not
change semantics of the code.
Signed-off-by: NPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 34e51ba6
/* /* Faraday FOTG210 EHCI-like driver
* Faraday FOTG210 EHCI-like driver
* *
* Copyright (c) 2013 Faraday Technology Corporation * Copyright (c) 2013 Faraday Technology Corporation
* *
...@@ -50,32 +49,29 @@ ...@@ -50,32 +49,29 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
/*-------------------------------------------------------------------------*/
#define DRIVER_AUTHOR "Yuan-Hsin Chen" #define DRIVER_AUTHOR "Yuan-Hsin Chen"
#define DRIVER_DESC "FOTG210 Host Controller (EHCI) Driver" #define DRIVER_DESC "FOTG210 Host Controller (EHCI) Driver"
static const char hcd_name[] = "fotg210_hcd";
static const char hcd_name[] = "fotg210_hcd";
#undef FOTG210_URB_TRACE #undef FOTG210_URB_TRACE
#define FOTG210_STATS #define FOTG210_STATS
/* magic numbers that can affect system performance */ /* magic numbers that can affect system performance */
#define FOTG210_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ #define FOTG210_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
#define FOTG210_TUNE_RL_HS 4 /* nak throttle; see 4.9 */ #define FOTG210_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
#define FOTG210_TUNE_RL_TT 0 #define FOTG210_TUNE_RL_TT 0
#define FOTG210_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ #define FOTG210_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
#define FOTG210_TUNE_MULT_TT 1 #define FOTG210_TUNE_MULT_TT 1
/*
* Some drivers think it's safe to schedule isochronous transfers more than /* Some drivers think it's safe to schedule isochronous transfers more than 256
* 256 ms into the future (partly as a result of an old bug in the scheduling * ms into the future (partly as a result of an old bug in the scheduling
* code). In an attempt to avoid trouble, we will use a minimum scheduling * code). In an attempt to avoid trouble, we will use a minimum scheduling
* length of 512 frames instead of 256. * length of 512 frames instead of 256.
*/ */
#define FOTG210_TUNE_FLS 1 /* (medium) 512-frame schedule */ #define FOTG210_TUNE_FLS 1 /* (medium) 512-frame schedule */
/* Initial IRQ latency: faster than hw default */ /* Initial IRQ latency: faster than hw default */
static int log2_irq_thresh; /* 0 to 6 */ static int log2_irq_thresh; /* 0 to 6 */
module_param(log2_irq_thresh, int, S_IRUGO); module_param(log2_irq_thresh, int, S_IRUGO);
MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes"); MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
...@@ -89,66 +85,57 @@ static unsigned int hird; ...@@ -89,66 +85,57 @@ static unsigned int hird;
module_param(hird, int, S_IRUGO); module_param(hird, int, S_IRUGO);
MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
#include "fotg210.h" #include "fotg210.h"
/*-------------------------------------------------------------------------*/
#define fotg210_dbg(fotg210, fmt, args...) \ #define fotg210_dbg(fotg210, fmt, args...) \
dev_dbg(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_dbg(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_err(fotg210, fmt, args...) \ #define fotg210_err(fotg210, fmt, args...) \
dev_err(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_err(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_info(fotg210, fmt, args...) \ #define fotg210_info(fotg210, fmt, args...) \
dev_info(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_info(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_warn(fotg210, fmt, args...) \ #define fotg210_warn(fotg210, fmt, args...) \
dev_warn(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_warn(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
/* check the values in the HCSPARAMS register /* check the values in the HCSPARAMS register (host controller _Structural_
* (host controller _Structural_ parameters) * parameters) see EHCI spec, Table 2-4 for each value
* see EHCI spec, Table 2-4 for each value
*/ */
static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label) static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label)
{ {
u32 params = fotg210_readl(fotg210, &fotg210->caps->hcs_params); u32 params = fotg210_readl(fotg210, &fotg210->caps->hcs_params);
fotg210_dbg(fotg210, fotg210_dbg(fotg210, "%s hcs_params 0x%x ports=%d\n", label, params,
"%s hcs_params 0x%x ports=%d\n", HCS_N_PORTS(params));
label, params,
HCS_N_PORTS(params)
);
} }
/* check the values in the HCCPARAMS register /* check the values in the HCCPARAMS register (host controller _Capability_
* (host controller _Capability_ parameters) * parameters) see EHCI Spec, Table 2-5 for each value
* see EHCI Spec, Table 2-5 for each value */
* */
static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label) static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label)
{ {
u32 params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); u32 params = fotg210_readl(fotg210, &fotg210->caps->hcc_params);
fotg210_dbg(fotg210, fotg210_dbg(fotg210, "%s hcc_params %04x uframes %s%s\n", label,
"%s hcc_params %04x uframes %s%s\n", params,
label, HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
params, HCC_CANPARK(params) ? " park" : "");
HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
HCC_CANPARK(params) ? " park" : "");
} }
static void __maybe_unused static void __maybe_unused
dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd) dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd)
{ {
fotg210_dbg(fotg210, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd, fotg210_dbg(fotg210, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd,
hc32_to_cpup(fotg210, &qtd->hw_next), hc32_to_cpup(fotg210, &qtd->hw_next),
hc32_to_cpup(fotg210, &qtd->hw_alt_next), hc32_to_cpup(fotg210, &qtd->hw_alt_next),
hc32_to_cpup(fotg210, &qtd->hw_token), hc32_to_cpup(fotg210, &qtd->hw_token),
hc32_to_cpup(fotg210, &qtd->hw_buf[0])); hc32_to_cpup(fotg210, &qtd->hw_buf[0]));
if (qtd->hw_buf[1]) if (qtd->hw_buf[1])
fotg210_dbg(fotg210, " p1=%08x p2=%08x p3=%08x p4=%08x\n", fotg210_dbg(fotg210, " p1=%08x p2=%08x p3=%08x p4=%08x\n",
hc32_to_cpup(fotg210, &qtd->hw_buf[1]), hc32_to_cpup(fotg210, &qtd->hw_buf[1]),
hc32_to_cpup(fotg210, &qtd->hw_buf[2]), hc32_to_cpup(fotg210, &qtd->hw_buf[2]),
hc32_to_cpup(fotg210, &qtd->hw_buf[3]), hc32_to_cpup(fotg210, &qtd->hw_buf[3]),
hc32_to_cpup(fotg210, &qtd->hw_buf[4])); hc32_to_cpup(fotg210, &qtd->hw_buf[4]));
} }
static void __maybe_unused static void __maybe_unused
...@@ -156,101 +143,100 @@ dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -156,101 +143,100 @@ dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, qh,
qh, hw->hw_next, hw->hw_info1, hw->hw_info2, hw->hw_current); hw->hw_next, hw->hw_info1, hw->hw_info2,
hw->hw_current);
dbg_qtd("overlay", fotg210, (struct fotg210_qtd *) &hw->hw_qtd_next); dbg_qtd("overlay", fotg210, (struct fotg210_qtd *) &hw->hw_qtd_next);
} }
static void __maybe_unused static void __maybe_unused
dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
{ {
fotg210_dbg(fotg210, "%s[%d] itd %p, next %08x, urb %p\n", fotg210_dbg(fotg210, "%s[%d] itd %p, next %08x, urb %p\n", label,
label, itd->frame, itd, hc32_to_cpu(fotg210, itd->hw_next), itd->frame, itd, hc32_to_cpu(fotg210, itd->hw_next),
itd->urb); itd->urb);
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
" trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n",
hc32_to_cpu(fotg210, itd->hw_transaction[0]), hc32_to_cpu(fotg210, itd->hw_transaction[0]),
hc32_to_cpu(fotg210, itd->hw_transaction[1]), hc32_to_cpu(fotg210, itd->hw_transaction[1]),
hc32_to_cpu(fotg210, itd->hw_transaction[2]), hc32_to_cpu(fotg210, itd->hw_transaction[2]),
hc32_to_cpu(fotg210, itd->hw_transaction[3]), hc32_to_cpu(fotg210, itd->hw_transaction[3]),
hc32_to_cpu(fotg210, itd->hw_transaction[4]), hc32_to_cpu(fotg210, itd->hw_transaction[4]),
hc32_to_cpu(fotg210, itd->hw_transaction[5]), hc32_to_cpu(fotg210, itd->hw_transaction[5]),
hc32_to_cpu(fotg210, itd->hw_transaction[6]), hc32_to_cpu(fotg210, itd->hw_transaction[6]),
hc32_to_cpu(fotg210, itd->hw_transaction[7])); hc32_to_cpu(fotg210, itd->hw_transaction[7]));
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
" buf: %08x %08x %08x %08x %08x %08x %08x\n", " buf: %08x %08x %08x %08x %08x %08x %08x\n",
hc32_to_cpu(fotg210, itd->hw_bufp[0]), hc32_to_cpu(fotg210, itd->hw_bufp[0]),
hc32_to_cpu(fotg210, itd->hw_bufp[1]), hc32_to_cpu(fotg210, itd->hw_bufp[1]),
hc32_to_cpu(fotg210, itd->hw_bufp[2]), hc32_to_cpu(fotg210, itd->hw_bufp[2]),
hc32_to_cpu(fotg210, itd->hw_bufp[3]), hc32_to_cpu(fotg210, itd->hw_bufp[3]),
hc32_to_cpu(fotg210, itd->hw_bufp[4]), hc32_to_cpu(fotg210, itd->hw_bufp[4]),
hc32_to_cpu(fotg210, itd->hw_bufp[5]), hc32_to_cpu(fotg210, itd->hw_bufp[5]),
hc32_to_cpu(fotg210, itd->hw_bufp[6])); hc32_to_cpu(fotg210, itd->hw_bufp[6]));
fotg210_dbg(fotg210, " index: %d %d %d %d %d %d %d %d\n", fotg210_dbg(fotg210, " index: %d %d %d %d %d %d %d %d\n",
itd->index[0], itd->index[1], itd->index[2], itd->index[0], itd->index[1], itd->index[2],
itd->index[3], itd->index[4], itd->index[5], itd->index[3], itd->index[4], itd->index[5],
itd->index[6], itd->index[7]); itd->index[6], itd->index[7]);
} }
static int __maybe_unused static int __maybe_unused
dbg_status_buf(char *buf, unsigned len, const char *label, u32 status) dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
{ {
return scnprintf(buf, len, return scnprintf(buf, len, "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s", label, label[0] ? " " : "", status,
label, label[0] ? " " : "", status, (status & STS_ASS) ? " Async" : "",
(status & STS_ASS) ? " Async" : "", (status & STS_PSS) ? " Periodic" : "",
(status & STS_PSS) ? " Periodic" : "", (status & STS_RECL) ? " Recl" : "",
(status & STS_RECL) ? " Recl" : "", (status & STS_HALT) ? " Halt" : "",
(status & STS_HALT) ? " Halt" : "", (status & STS_IAA) ? " IAA" : "",
(status & STS_IAA) ? " IAA" : "", (status & STS_FATAL) ? " FATAL" : "",
(status & STS_FATAL) ? " FATAL" : "", (status & STS_FLR) ? " FLR" : "",
(status & STS_FLR) ? " FLR" : "", (status & STS_PCD) ? " PCD" : "",
(status & STS_PCD) ? " PCD" : "", (status & STS_ERR) ? " ERR" : "",
(status & STS_ERR) ? " ERR" : "", (status & STS_INT) ? " INT" : "");
(status & STS_INT) ? " INT" : ""
);
} }
static int __maybe_unused static int __maybe_unused
dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable) dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
{ {
return scnprintf(buf, len, return scnprintf(buf, len, "%s%sintrenable %02x%s%s%s%s%s%s",
"%s%sintrenable %02x%s%s%s%s%s%s", label, label[0] ? " " : "", enable,
label, label[0] ? " " : "", enable, (enable & STS_IAA) ? " IAA" : "",
(enable & STS_IAA) ? " IAA" : "", (enable & STS_FATAL) ? " FATAL" : "",
(enable & STS_FATAL) ? " FATAL" : "", (enable & STS_FLR) ? " FLR" : "",
(enable & STS_FLR) ? " FLR" : "", (enable & STS_PCD) ? " PCD" : "",
(enable & STS_PCD) ? " PCD" : "", (enable & STS_ERR) ? " ERR" : "",
(enable & STS_ERR) ? " ERR" : "", (enable & STS_INT) ? " INT" : "");
(enable & STS_INT) ? " INT" : ""
);
} }
static const char *const fls_strings[] = { "1024", "512", "256", "??" }; static const char *const fls_strings[] = { "1024", "512", "256", "??" };
static int static int dbg_command_buf(char *buf, unsigned len, const char *label,
dbg_command_buf(char *buf, unsigned len, const char *label, u32 command) u32 command)
{ {
return scnprintf(buf, len, return scnprintf(buf, len,
"%s%scommand %07x %s=%d ithresh=%d%s%s%s " "%s%scommand %07x %s=%d ithresh=%d%s%s%s period=%s%s %s",
"period=%s%s %s", label, label[0] ? " " : "", command,
label, label[0] ? " " : "", command, (command & CMD_PARK) ? " park" : "(park)",
(command & CMD_PARK) ? " park" : "(park)", CMD_PARK_CNT(command),
CMD_PARK_CNT(command), (command >> 16) & 0x3f,
(command >> 16) & 0x3f, (command & CMD_IAAD) ? " IAAD" : "",
(command & CMD_IAAD) ? " IAAD" : "", (command & CMD_ASE) ? " Async" : "",
(command & CMD_ASE) ? " Async" : "", (command & CMD_PSE) ? " Periodic" : "",
(command & CMD_PSE) ? " Periodic" : "", fls_strings[(command >> 2) & 0x3],
fls_strings[(command >> 2) & 0x3], (command & CMD_RESET) ? " Reset" : "",
(command & CMD_RESET) ? " Reset" : "", (command & CMD_RUN) ? "RUN" : "HALT");
(command & CMD_RUN) ? "RUN" : "HALT" }
);
} static char *dbg_port_buf(char *buf, unsigned len, const char *label, int port,
u32 status)
static char {
*dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status) char *sig;
{
char *sig;
/* signaling state */ /* signaling state */
switch (status & (3 << 10)) { switch (status & (3 << 10)) {
...@@ -268,44 +254,41 @@ static char ...@@ -268,44 +254,41 @@ static char
break; break;
} }
scnprintf(buf, len, scnprintf(buf, len, "%s%sport:%d status %06x %d sig=%s%s%s%s%s%s%s%s",
"%s%sport:%d status %06x %d " label, label[0] ? " " : "", port, status,
"sig=%s%s%s%s%s%s%s%s", status >> 25, /*device address */
label, label[0] ? " " : "", port, status, sig,
status>>25,/*device address */ (status & PORT_RESET) ? " RESET" : "",
sig, (status & PORT_SUSPEND) ? " SUSPEND" : "",
(status & PORT_RESET) ? " RESET" : "", (status & PORT_RESUME) ? " RESUME" : "",
(status & PORT_SUSPEND) ? " SUSPEND" : "", (status & PORT_PEC) ? " PEC" : "",
(status & PORT_RESUME) ? " RESUME" : "", (status & PORT_PE) ? " PE" : "",
(status & PORT_PEC) ? " PEC" : "", (status & PORT_CSC) ? " CSC" : "",
(status & PORT_PE) ? " PE" : "", (status & PORT_CONNECT) ? " CONNECT" : "");
(status & PORT_CSC) ? " CSC" : "",
(status & PORT_CONNECT) ? " CONNECT" : "");
return buf; return buf;
} }
/* functions have the "wrong" filename when they're output... */ /* functions have the "wrong" filename when they're output... */
#define dbg_status(fotg210, label, status) { \ #define dbg_status(fotg210, label, status) { \
char _buf[80]; \ char _buf[80]; \
dbg_status_buf(_buf, sizeof(_buf), label, status); \ dbg_status_buf(_buf, sizeof(_buf), label, status); \
fotg210_dbg(fotg210, "%s\n", _buf); \ fotg210_dbg(fotg210, "%s\n", _buf); \
} }
#define dbg_cmd(fotg210, label, command) { \ #define dbg_cmd(fotg210, label, command) { \
char _buf[80]; \ char _buf[80]; \
dbg_command_buf(_buf, sizeof(_buf), label, command); \ dbg_command_buf(_buf, sizeof(_buf), label, command); \
fotg210_dbg(fotg210, "%s\n", _buf); \ fotg210_dbg(fotg210, "%s\n", _buf); \
} }
#define dbg_port(fotg210, label, port, status) { \ #define dbg_port(fotg210, label, port, status) { \
char _buf[80]; \ char _buf[80]; \
fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \ fotg210_dbg(fotg210, "%s\n", \
dbg_port_buf(_buf, sizeof(_buf), label, port, status));\
} }
/*-------------------------------------------------------------------------*/
/* troubleshooting help: expose state in debugfs */ /* troubleshooting help: expose state in debugfs */
static int debug_async_open(struct inode *, struct file *); static int debug_async_open(struct inode *, struct file *);
static int debug_periodic_open(struct inode *, struct file *); static int debug_periodic_open(struct inode *, struct file *);
static int debug_registers_open(struct inode *, struct file *); static int debug_registers_open(struct inode *, struct file *);
...@@ -373,33 +356,29 @@ static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token) ...@@ -373,33 +356,29 @@ static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token)
return '/'; return '/';
} }
static void qh_lines( static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
struct fotg210_hcd *fotg210, char **nextp, unsigned *sizep)
struct fotg210_qh *qh, {
char **nextp, u32 scratch;
unsigned *sizep u32 hw_curr;
) struct fotg210_qtd *td;
{ unsigned temp;
u32 scratch; unsigned size = *sizep;
u32 hw_curr; char *next = *nextp;
struct fotg210_qtd *td; char mark;
unsigned temp; __le32 list_end = FOTG210_LIST_END(fotg210);
unsigned size = *sizep; struct fotg210_qh_hw *hw = qh->hw;
char *next = *nextp;
char mark; if (hw->hw_qtd_next == list_end) /* NEC does this */
__le32 list_end = FOTG210_LIST_END(fotg210);
struct fotg210_qh_hw *hw = qh->hw;
if (hw->hw_qtd_next == list_end) /* NEC does this */
mark = '@'; mark = '@';
else else
mark = token_mark(fotg210, hw->hw_token); mark = token_mark(fotg210, hw->hw_token);
if (mark == '/') { /* qh_alt_next controls qh advance? */ if (mark == '/') { /* qh_alt_next controls qh advance? */
if ((hw->hw_alt_next & QTD_MASK(fotg210)) if ((hw->hw_alt_next & QTD_MASK(fotg210)) ==
== fotg210->async->hw->hw_alt_next) fotg210->async->hw->hw_alt_next)
mark = '#'; /* blocked */ mark = '#'; /* blocked */
else if (hw->hw_alt_next == list_end) else if (hw->hw_alt_next == list_end)
mark = '.'; /* use hw_qtd_next */ mark = '.'; /* use hw_qtd_next */
/* else alt_next points to some other qtd */ /* else alt_next points to some other qtd */
} }
scratch = hc32_to_cpup(fotg210, &hw->hw_info1); scratch = hc32_to_cpup(fotg210, &hw->hw_info1);
...@@ -462,6 +441,7 @@ static void qh_lines( ...@@ -462,6 +441,7 @@ static void qh_lines(
temp = snprintf(next, size, "\n"); temp = snprintf(next, size, "\n");
if (size < temp) if (size < temp)
temp = size; temp = size;
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -472,12 +452,12 @@ static void qh_lines( ...@@ -472,12 +452,12 @@ static void qh_lines(
static ssize_t fill_async_buffer(struct debug_buffer *buf) static ssize_t fill_async_buffer(struct debug_buffer *buf)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
unsigned long flags; unsigned long flags;
unsigned temp, size; unsigned temp, size;
char *next; char *next;
struct fotg210_qh *qh; struct fotg210_qh *qh;
hcd = bus_to_hcd(buf->bus); hcd = bus_to_hcd(buf->bus);
fotg210 = hcd_to_fotg210(hcd); fotg210 = hcd_to_fotg210(hcd);
...@@ -492,7 +472,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) ...@@ -492,7 +472,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
*/ */
spin_lock_irqsave(&fotg210->lock, flags); spin_lock_irqsave(&fotg210->lock, flags);
for (qh = fotg210->async->qh_next.qh; size > 0 && qh; for (qh = fotg210->async->qh_next.qh; size > 0 && qh;
qh = qh->qh_next.qh) qh = qh->qh_next.qh)
qh_lines(fotg210, qh, &next, &size); qh_lines(fotg210, qh, &next, &size);
if (fotg210->async_unlink && size > 0) { if (fotg210->async_unlink && size > 0) {
temp = scnprintf(next, size, "\nunlink =\n"); temp = scnprintf(next, size, "\nunlink =\n");
...@@ -511,18 +491,19 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) ...@@ -511,18 +491,19 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
#define DBG_SCHED_LIMIT 64 #define DBG_SCHED_LIMIT 64
static ssize_t fill_periodic_buffer(struct debug_buffer *buf) static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
unsigned long flags; unsigned long flags;
union fotg210_shadow p, *seen; union fotg210_shadow p, *seen;
unsigned temp, size, seen_count; unsigned temp, size, seen_count;
char *next; char *next;
unsigned i; unsigned i;
__hc32 tag; __hc32 tag;
seen = kmalloc(DBG_SCHED_LIMIT * sizeof(*seen), GFP_ATOMIC); seen = kmalloc(DBG_SCHED_LIMIT * sizeof(*seen), GFP_ATOMIC);
if (!seen) if (!seen)
return 0; return 0;
seen_count = 0; seen_count = 0;
hcd = bus_to_hcd(buf->bus); hcd = bus_to_hcd(buf->bus);
...@@ -542,6 +523,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -542,6 +523,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
p = fotg210->pshadow[i]; p = fotg210->pshadow[i];
if (likely(!p.ptr)) if (likely(!p.ptr))
continue; continue;
tag = Q_NEXT_TYPE(fotg210, fotg210->periodic[i]); tag = Q_NEXT_TYPE(fotg210, fotg210->periodic[i]);
temp = scnprintf(next, size, "%4d: ", i); temp = scnprintf(next, size, "%4d: ", i);
...@@ -569,7 +551,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -569,7 +551,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
continue; continue;
if (p.qh->qh_next.ptr) { if (p.qh->qh_next.ptr) {
temp = scnprintf(next, size, temp = scnprintf(next, size,
" ..."); " ...");
size -= temp; size -= temp;
next += temp; next += temp;
} }
...@@ -577,10 +559,10 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -577,10 +559,10 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
} }
/* show more info the first time around */ /* show more info the first time around */
if (temp == seen_count) { if (temp == seen_count) {
u32 scratch = hc32_to_cpup(fotg210, u32 scratch = hc32_to_cpup(fotg210,
&hw->hw_info1); &hw->hw_info1);
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
char *type = ""; char *type = "";
/* count tds, get ep direction */ /* count tds, get ep direction */
temp = 0; temp = 0;
...@@ -601,8 +583,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -601,8 +583,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
} }
temp = scnprintf(next, size, temp = scnprintf(next, size,
"(%c%d ep%d%s " "(%c%d ep%d%s [%d/%d] q%d p%d)",
"[%d/%d] q%d p%d)",
speed_char(scratch), speed_char(scratch),
scratch & 0x007f, scratch & 0x007f,
(scratch >> 8) & 0x000f, type, (scratch >> 8) & 0x000f, type,
...@@ -619,14 +600,14 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -619,14 +600,14 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
break; break;
case Q_TYPE_FSTN: case Q_TYPE_FSTN:
temp = scnprintf(next, size, temp = scnprintf(next, size,
" fstn-%8x/%p", p.fstn->hw_prev, " fstn-%8x/%p",
p.fstn); p.fstn->hw_prev, p.fstn);
tag = Q_NEXT_TYPE(fotg210, p.fstn->hw_next); tag = Q_NEXT_TYPE(fotg210, p.fstn->hw_next);
p = p.fstn->fstn_next; p = p.fstn->fstn_next;
break; break;
case Q_TYPE_ITD: case Q_TYPE_ITD:
temp = scnprintf(next, size, temp = scnprintf(next, size,
" itd/%p", p.itd); " itd/%p", p.itd);
tag = Q_NEXT_TYPE(fotg210, p.itd->hw_next); tag = Q_NEXT_TYPE(fotg210, p.itd->hw_next);
p = p.itd->itd_next; p = p.itd->itd_next;
break; break;
...@@ -663,13 +644,13 @@ static const char *rh_state_string(struct fotg210_hcd *fotg210) ...@@ -663,13 +644,13 @@ static const char *rh_state_string(struct fotg210_hcd *fotg210)
static ssize_t fill_registers_buffer(struct debug_buffer *buf) static ssize_t fill_registers_buffer(struct debug_buffer *buf)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
unsigned long flags; unsigned long flags;
unsigned temp, size, i; unsigned temp, size, i;
char *next, scratch[80]; char *next, scratch[80];
static const char fmt[] = "%*s\n"; static const char fmt[] = "%*s\n";
static const char label[] = ""; static const char label[] = "";
hcd = bus_to_hcd(buf->bus); hcd = bus_to_hcd(buf->bus);
fotg210 = hcd_to_fotg210(hcd); fotg210 = hcd_to_fotg210(hcd);
...@@ -680,26 +661,26 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) ...@@ -680,26 +661,26 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
if (!HCD_HW_ACCESSIBLE(hcd)) { if (!HCD_HW_ACCESSIBLE(hcd)) {
size = scnprintf(next, size, size = scnprintf(next, size,
"bus %s, device %s\n" "bus %s, device %s\n"
"%s\n" "%s\n"
"SUSPENDED(no register access)\n", "SUSPENDED(no register access)\n",
hcd->self.controller->bus->name, hcd->self.controller->bus->name,
dev_name(hcd->self.controller), dev_name(hcd->self.controller),
hcd->product_desc); hcd->product_desc);
goto done; goto done;
} }
/* Capability Registers */ /* Capability Registers */
i = HC_VERSION(fotg210, fotg210_readl(fotg210, i = HC_VERSION(fotg210, fotg210_readl(fotg210,
&fotg210->caps->hc_capbase)); &fotg210->caps->hc_capbase));
temp = scnprintf(next, size, temp = scnprintf(next, size,
"bus %s, device %s\n" "bus %s, device %s\n"
"%s\n" "%s\n"
"EHCI %x.%02x, rh state %s\n", "EHCI %x.%02x, rh state %s\n",
hcd->self.controller->bus->name, hcd->self.controller->bus->name,
dev_name(hcd->self.controller), dev_name(hcd->self.controller),
hcd->product_desc, hcd->product_desc,
i >> 8, i & 0x0ff, rh_state_string(fotg210)); i >> 8, i & 0x0ff, rh_state_string(fotg210));
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -747,14 +728,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) ...@@ -747,14 +728,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
#ifdef FOTG210_STATS #ifdef FOTG210_STATS
temp = scnprintf(next, size, temp = scnprintf(next, size,
"irq normal %ld err %ld iaa %ld(lost %ld)\n", "irq normal %ld err %ld iaa %ld(lost %ld)\n",
fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, fotg210->stats.normal, fotg210->stats.error,
fotg210->stats.lost_iaa); fotg210->stats.iaa, fotg210->stats.lost_iaa);
size -= temp; size -= temp;
next += temp; next += temp;
temp = scnprintf(next, size, "complete %ld unlink %ld\n", temp = scnprintf(next, size, "complete %ld unlink %ld\n",
fotg210->stats.complete, fotg210->stats.unlink); fotg210->stats.complete, fotg210->stats.unlink);
size -= temp; size -= temp;
next += temp; next += temp;
#endif #endif
...@@ -765,8 +746,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) ...@@ -765,8 +746,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
return buf->alloc_size - size; return buf->alloc_size - size;
} }
static struct debug_buffer *alloc_buffer(struct usb_bus *bus, static struct debug_buffer
ssize_t (*fill_func)(struct debug_buffer *)) *alloc_buffer(struct usb_bus *bus, ssize_t (*fill_func)(struct debug_buffer *))
{ {
struct debug_buffer *buf; struct debug_buffer *buf;
...@@ -806,7 +787,7 @@ static int fill_buffer(struct debug_buffer *buf) ...@@ -806,7 +787,7 @@ static int fill_buffer(struct debug_buffer *buf)
} }
static ssize_t debug_output(struct file *file, char __user *user_buf, static ssize_t debug_output(struct file *file, char __user *user_buf,
size_t len, loff_t *offset) size_t len, loff_t *offset)
{ {
struct debug_buffer *buf = file->private_data; struct debug_buffer *buf = file->private_data;
int ret = 0; int ret = 0;
...@@ -822,7 +803,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf, ...@@ -822,7 +803,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
mutex_unlock(&buf->mutex); mutex_unlock(&buf->mutex);
ret = simple_read_from_buffer(user_buf, len, offset, ret = simple_read_from_buffer(user_buf, len, offset,
buf->output_buf, buf->count); buf->output_buf, buf->count);
out: out:
return ret; return ret;
...@@ -850,6 +831,7 @@ static int debug_async_open(struct inode *inode, struct file *file) ...@@ -850,6 +831,7 @@ static int debug_async_open(struct inode *inode, struct file *file)
static int debug_periodic_open(struct inode *inode, struct file *file) static int debug_periodic_open(struct inode *inode, struct file *file)
{ {
struct debug_buffer *buf; struct debug_buffer *buf;
buf = alloc_buffer(inode->i_private, fill_periodic_buffer); buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -862,7 +844,7 @@ static int debug_periodic_open(struct inode *inode, struct file *file) ...@@ -862,7 +844,7 @@ static int debug_periodic_open(struct inode *inode, struct file *file)
static int debug_registers_open(struct inode *inode, struct file *file) static int debug_registers_open(struct inode *inode, struct file *file)
{ {
file->private_data = alloc_buffer(inode->i_private, file->private_data = alloc_buffer(inode->i_private,
fill_registers_buffer); fill_registers_buffer);
return file->private_data ? 0 : -ENOMEM; return file->private_data ? 0 : -ENOMEM;
} }
...@@ -872,20 +854,20 @@ static inline void create_debug_files(struct fotg210_hcd *fotg210) ...@@ -872,20 +854,20 @@ static inline void create_debug_files(struct fotg210_hcd *fotg210)
struct usb_bus *bus = &fotg210_to_hcd(fotg210)->self; struct usb_bus *bus = &fotg210_to_hcd(fotg210)->self;
fotg210->debug_dir = debugfs_create_dir(bus->bus_name, fotg210->debug_dir = debugfs_create_dir(bus->bus_name,
fotg210_debug_root); fotg210_debug_root);
if (!fotg210->debug_dir) if (!fotg210->debug_dir)
return; return;
if (!debugfs_create_file("async", S_IRUGO, fotg210->debug_dir, bus, if (!debugfs_create_file("async", S_IRUGO, fotg210->debug_dir, bus,
&debug_async_fops)) &debug_async_fops))
goto file_error; goto file_error;
if (!debugfs_create_file("periodic", S_IRUGO, fotg210->debug_dir, bus, if (!debugfs_create_file("periodic", S_IRUGO, fotg210->debug_dir, bus,
&debug_periodic_fops)) &debug_periodic_fops))
goto file_error; goto file_error;
if (!debugfs_create_file("registers", S_IRUGO, fotg210->debug_dir, bus, if (!debugfs_create_file("registers", S_IRUGO, fotg210->debug_dir, bus,
&debug_registers_fops)) &debug_registers_fops))
goto file_error; goto file_error;
return; return;
...@@ -899,10 +881,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210) ...@@ -899,10 +881,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210)
debugfs_remove_recursive(fotg210->debug_dir); debugfs_remove_recursive(fotg210->debug_dir);
} }
/*-------------------------------------------------------------------------*/ /* handshake - spin reading hc until handshake completes or fails
/*
* handshake - spin reading hc until handshake completes or fails
* @ptr: address of hc register to be read * @ptr: address of hc register to be read
* @mask: bits to look at in result of read * @mask: bits to look at in result of read
* @done: value of those bits when handshake succeeds * @done: value of those bits when handshake succeeds
...@@ -919,9 +898,9 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210) ...@@ -919,9 +898,9 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210)
* bridge shutdown: shutting down the bridge before the devices using it. * bridge shutdown: shutting down the bridge before the devices using it.
*/ */
static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr,
u32 mask, u32 done, int usec) u32 mask, u32 done, int usec)
{ {
u32 result; u32 result;
do { do {
result = fotg210_readl(fotg210, ptr); result = fotg210_readl(fotg210, ptr);
...@@ -936,13 +915,12 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, ...@@ -936,13 +915,12 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr,
return -ETIMEDOUT; return -ETIMEDOUT;
} }
/* /* Force HC to halt state from unknown (EHCI spec section 2.3).
* Force HC to halt state from unknown (EHCI spec section 2.3).
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static int fotg210_halt(struct fotg210_hcd *fotg210) static int fotg210_halt(struct fotg210_hcd *fotg210)
{ {
u32 temp; u32 temp;
spin_lock_irq(&fotg210->lock); spin_lock_irq(&fotg210->lock);
...@@ -962,20 +940,20 @@ static int fotg210_halt(struct fotg210_hcd *fotg210) ...@@ -962,20 +940,20 @@ static int fotg210_halt(struct fotg210_hcd *fotg210)
synchronize_irq(fotg210_to_hcd(fotg210)->irq); synchronize_irq(fotg210_to_hcd(fotg210)->irq);
return handshake(fotg210, &fotg210->regs->status, return handshake(fotg210, &fotg210->regs->status,
STS_HALT, STS_HALT, 16 * 125); STS_HALT, STS_HALT, 16 * 125);
} }
/* /* Reset a non-running (STS_HALT == 1) controller.
* Reset a non-running (STS_HALT == 1) controller.
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static int fotg210_reset(struct fotg210_hcd *fotg210) static int fotg210_reset(struct fotg210_hcd *fotg210)
{ {
int retval; int retval;
u32 command = fotg210_readl(fotg210, &fotg210->regs->command); u32 command = fotg210_readl(fotg210, &fotg210->regs->command);
/* If the EHCI debug controller is active, special care must be /* If the EHCI debug controller is active, special care must be
* taken before and after a host controller reset */ * taken before and after a host controller reset
*/
if (fotg210->debug && !dbgp_reset_prep(fotg210_to_hcd(fotg210))) if (fotg210->debug && !dbgp_reset_prep(fotg210_to_hcd(fotg210)))
fotg210->debug = NULL; fotg210->debug = NULL;
...@@ -985,7 +963,7 @@ static int fotg210_reset(struct fotg210_hcd *fotg210) ...@@ -985,7 +963,7 @@ static int fotg210_reset(struct fotg210_hcd *fotg210)
fotg210->rh_state = FOTG210_RH_HALTED; fotg210->rh_state = FOTG210_RH_HALTED;
fotg210->next_statechange = jiffies; fotg210->next_statechange = jiffies;
retval = handshake(fotg210, &fotg210->regs->command, retval = handshake(fotg210, &fotg210->regs->command,
CMD_RESET, 0, 250 * 1000); CMD_RESET, 0, 250 * 1000);
if (retval) if (retval)
return retval; return retval;
...@@ -998,13 +976,12 @@ static int fotg210_reset(struct fotg210_hcd *fotg210) ...@@ -998,13 +976,12 @@ static int fotg210_reset(struct fotg210_hcd *fotg210)
return retval; return retval;
} }
/* /* Idle the controller (turn off the schedules).
* Idle the controller (turn off the schedules).
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static void fotg210_quiesce(struct fotg210_hcd *fotg210) static void fotg210_quiesce(struct fotg210_hcd *fotg210)
{ {
u32 temp; u32 temp;
if (fotg210->rh_state != FOTG210_RH_RUNNING) if (fotg210->rh_state != FOTG210_RH_RUNNING)
return; return;
...@@ -1012,7 +989,7 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210) ...@@ -1012,7 +989,7 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210)
/* wait for any schedule enables/disables to take effect */ /* wait for any schedule enables/disables to take effect */
temp = (fotg210->command << 10) & (STS_ASS | STS_PSS); temp = (fotg210->command << 10) & (STS_ASS | STS_PSS);
handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, temp, handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, temp,
16 * 125); 16 * 125);
/* then disable anything that's still active */ /* then disable anything that's still active */
spin_lock_irq(&fotg210->lock); spin_lock_irq(&fotg210->lock);
...@@ -1022,11 +999,9 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210) ...@@ -1022,11 +999,9 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210)
/* hardware can take 16 microframes to turn off ... */ /* hardware can take 16 microframes to turn off ... */
handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, 0, handshake(fotg210, &fotg210->regs->status, STS_ASS | STS_PSS, 0,
16 * 125); 16 * 125);
} }
/*-------------------------------------------------------------------------*/
static void end_unlink_async(struct fotg210_hcd *fotg210); static void end_unlink_async(struct fotg210_hcd *fotg210);
static void unlink_empty_async(struct fotg210_hcd *fotg210); static void unlink_empty_async(struct fotg210_hcd *fotg210);
static void fotg210_work(struct fotg210_hcd *fotg210); static void fotg210_work(struct fotg210_hcd *fotg210);
...@@ -1034,8 +1009,6 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210, ...@@ -1034,8 +1009,6 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh); struct fotg210_qh *qh);
static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
/*-------------------------------------------------------------------------*/
/* Set a bit in the USBCMD register */ /* Set a bit in the USBCMD register */
static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit) static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit)
{ {
...@@ -1056,10 +1029,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit) ...@@ -1056,10 +1029,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit)
fotg210_readl(fotg210, &fotg210->regs->command); fotg210_readl(fotg210, &fotg210->regs->command);
} }
/*-------------------------------------------------------------------------*/ /* EHCI timer support... Now using hrtimers.
/*
* EHCI timer support... Now using hrtimers.
* *
* Lots of different events are triggered from fotg210->hrtimer. Whenever * Lots of different events are triggered from fotg210->hrtimer. Whenever
* the timer routine runs, it checks each possible event; events that are * the timer routine runs, it checks each possible event; events that are
...@@ -1081,8 +1051,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit) ...@@ -1081,8 +1051,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit)
* allow for an expiration range of 1 ms. * allow for an expiration range of 1 ms.
*/ */
/* /* Delay lengths for the hrtimer event types.
* Delay lengths for the hrtimer event types.
* Keep this list sorted by delay length, in the same order as * Keep this list sorted by delay length, in the same order as
* the event types indexed by enum fotg210_hrtimer_event in fotg210.h. * the event types indexed by enum fotg210_hrtimer_event in fotg210.h.
*/ */
...@@ -1103,7 +1072,7 @@ static unsigned event_delays_ns[] = { ...@@ -1103,7 +1072,7 @@ static unsigned event_delays_ns[] = {
static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event, static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event,
bool resched) bool resched)
{ {
ktime_t *timeout = &fotg210->hr_timeouts[event]; ktime_t *timeout = &fotg210->hr_timeouts[event];
if (resched) if (resched)
*timeout = ktime_add(ktime_get(), *timeout = ktime_add(ktime_get(),
...@@ -1122,7 +1091,7 @@ static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event, ...@@ -1122,7 +1091,7 @@ static void fotg210_enable_event(struct fotg210_hcd *fotg210, unsigned event,
/* Poll the STS_ASS status bit; see when it agrees with CMD_ASE */ /* Poll the STS_ASS status bit; see when it agrees with CMD_ASE */
static void fotg210_poll_ASS(struct fotg210_hcd *fotg210) static void fotg210_poll_ASS(struct fotg210_hcd *fotg210)
{ {
unsigned actual, want; unsigned actual, want;
/* Don't enable anything if the controller isn't running (e.g., died) */ /* Don't enable anything if the controller isn't running (e.g., died) */
if (fotg210->rh_state != FOTG210_RH_RUNNING) if (fotg210->rh_state != FOTG210_RH_RUNNING)
...@@ -1136,7 +1105,7 @@ static void fotg210_poll_ASS(struct fotg210_hcd *fotg210) ...@@ -1136,7 +1105,7 @@ static void fotg210_poll_ASS(struct fotg210_hcd *fotg210)
/* Poll again later, but give up after about 20 ms */ /* Poll again later, but give up after about 20 ms */
if (fotg210->ASS_poll_count++ < 20) { if (fotg210->ASS_poll_count++ < 20) {
fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_ASS, fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_ASS,
true); true);
return; return;
} }
fotg210_dbg(fotg210, "Waited too long for the async schedule status (%x/%x), giving up\n", fotg210_dbg(fotg210, "Waited too long for the async schedule status (%x/%x), giving up\n",
...@@ -1154,8 +1123,8 @@ static void fotg210_poll_ASS(struct fotg210_hcd *fotg210) ...@@ -1154,8 +1123,8 @@ static void fotg210_poll_ASS(struct fotg210_hcd *fotg210)
/* Turn off the schedule after a while */ /* Turn off the schedule after a while */
fotg210_enable_event(fotg210, fotg210_enable_event(fotg210,
FOTG210_HRTIMER_DISABLE_ASYNC, FOTG210_HRTIMER_DISABLE_ASYNC,
true); true);
} }
} }
} }
...@@ -1170,7 +1139,7 @@ static void fotg210_disable_ASE(struct fotg210_hcd *fotg210) ...@@ -1170,7 +1139,7 @@ static void fotg210_disable_ASE(struct fotg210_hcd *fotg210)
/* Poll the STS_PSS status bit; see when it agrees with CMD_PSE */ /* Poll the STS_PSS status bit; see when it agrees with CMD_PSE */
static void fotg210_poll_PSS(struct fotg210_hcd *fotg210) static void fotg210_poll_PSS(struct fotg210_hcd *fotg210)
{ {
unsigned actual, want; unsigned actual, want;
/* Don't do anything if the controller isn't running (e.g., died) */ /* Don't do anything if the controller isn't running (e.g., died) */
if (fotg210->rh_state != FOTG210_RH_RUNNING) if (fotg210->rh_state != FOTG210_RH_RUNNING)
...@@ -1184,7 +1153,7 @@ static void fotg210_poll_PSS(struct fotg210_hcd *fotg210) ...@@ -1184,7 +1153,7 @@ static void fotg210_poll_PSS(struct fotg210_hcd *fotg210)
/* Poll again later, but give up after about 20 ms */ /* Poll again later, but give up after about 20 ms */
if (fotg210->PSS_poll_count++ < 20) { if (fotg210->PSS_poll_count++ < 20) {
fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_PSS, fotg210_enable_event(fotg210, FOTG210_HRTIMER_POLL_PSS,
true); true);
return; return;
} }
fotg210_dbg(fotg210, "Waited too long for the periodic schedule status (%x/%x), giving up\n", fotg210_dbg(fotg210, "Waited too long for the periodic schedule status (%x/%x), giving up\n",
...@@ -1202,8 +1171,8 @@ static void fotg210_poll_PSS(struct fotg210_hcd *fotg210) ...@@ -1202,8 +1171,8 @@ static void fotg210_poll_PSS(struct fotg210_hcd *fotg210)
/* Turn off the schedule after a while */ /* Turn off the schedule after a while */
fotg210_enable_event(fotg210, fotg210_enable_event(fotg210,
FOTG210_HRTIMER_DISABLE_PERIODIC, FOTG210_HRTIMER_DISABLE_PERIODIC,
true); true);
} }
} }
} }
...@@ -1224,7 +1193,7 @@ static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210) ...@@ -1224,7 +1193,7 @@ static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210)
if (fotg210->died_poll_count++ < 5) { if (fotg210->died_poll_count++ < 5) {
/* Try again later */ /* Try again later */
fotg210_enable_event(fotg210, fotg210_enable_event(fotg210,
FOTG210_HRTIMER_POLL_DEAD, true); FOTG210_HRTIMER_POLL_DEAD, true);
return; return;
} }
fotg210_warn(fotg210, "Waited too long for the controller to stop, giving up\n"); fotg210_warn(fotg210, "Waited too long for the controller to stop, giving up\n");
...@@ -1243,7 +1212,7 @@ static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210) ...@@ -1243,7 +1212,7 @@ static void fotg210_handle_controller_death(struct fotg210_hcd *fotg210)
/* Handle unlinked interrupt QHs once they are gone from the hardware */ /* Handle unlinked interrupt QHs once they are gone from the hardware */
static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210) static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210)
{ {
bool stopped = (fotg210->rh_state < FOTG210_RH_RUNNING); bool stopped = (fotg210->rh_state < FOTG210_RH_RUNNING);
/* /*
* Process all the QHs on the intr_unlink list that were added * Process all the QHs on the intr_unlink list that were added
...@@ -1254,7 +1223,7 @@ static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210) ...@@ -1254,7 +1223,7 @@ static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210)
*/ */
fotg210->intr_unlinking = true; fotg210->intr_unlinking = true;
while (fotg210->intr_unlink) { while (fotg210->intr_unlink) {
struct fotg210_qh *qh = fotg210->intr_unlink; struct fotg210_qh *qh = fotg210->intr_unlink;
if (!stopped && qh->unlink_cycle == fotg210->intr_unlink_cycle) if (!stopped && qh->unlink_cycle == fotg210->intr_unlink_cycle)
break; break;
...@@ -1266,7 +1235,7 @@ static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210) ...@@ -1266,7 +1235,7 @@ static void fotg210_handle_intr_unlinks(struct fotg210_hcd *fotg210)
/* Handle remaining entries later */ /* Handle remaining entries later */
if (fotg210->intr_unlink) { if (fotg210->intr_unlink) {
fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR, fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR,
true); true);
++fotg210->intr_unlink_cycle; ++fotg210->intr_unlink_cycle;
} }
fotg210->intr_unlinking = false; fotg210->intr_unlinking = false;
...@@ -1288,7 +1257,7 @@ static void start_free_itds(struct fotg210_hcd *fotg210) ...@@ -1288,7 +1257,7 @@ static void start_free_itds(struct fotg210_hcd *fotg210)
/* Wait for controller to stop using old iTDs and siTDs */ /* Wait for controller to stop using old iTDs and siTDs */
static void end_free_itds(struct fotg210_hcd *fotg210) static void end_free_itds(struct fotg210_hcd *fotg210)
{ {
struct fotg210_itd *itd, *n; struct fotg210_itd *itd, *n;
if (fotg210->rh_state < FOTG210_RH_RUNNING) if (fotg210->rh_state < FOTG210_RH_RUNNING)
fotg210->last_itd_to_free = NULL; fotg210->last_itd_to_free = NULL;
...@@ -1339,7 +1308,7 @@ static void fotg210_iaa_watchdog(struct fotg210_hcd *fotg210) ...@@ -1339,7 +1308,7 @@ static void fotg210_iaa_watchdog(struct fotg210_hcd *fotg210)
if ((status & STS_IAA) || !(cmd & CMD_IAAD)) { if ((status & STS_IAA) || !(cmd & CMD_IAAD)) {
COUNT(fotg210->stats.lost_iaa); COUNT(fotg210->stats.lost_iaa);
fotg210_writel(fotg210, STS_IAA, fotg210_writel(fotg210, STS_IAA,
&fotg210->regs->status); &fotg210->regs->status);
} }
fotg210_dbg(fotg210, "IAA watchdog: status %x cmd %x\n", fotg210_dbg(fotg210, "IAA watchdog: status %x cmd %x\n",
...@@ -1355,7 +1324,7 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210) ...@@ -1355,7 +1324,7 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210)
/* Not needed if the controller isn't running or it's already enabled */ /* Not needed if the controller isn't running or it's already enabled */
if (fotg210->rh_state != FOTG210_RH_RUNNING || if (fotg210->rh_state != FOTG210_RH_RUNNING ||
(fotg210->enabled_hrtimer_events & (fotg210->enabled_hrtimer_events &
BIT(FOTG210_HRTIMER_IO_WATCHDOG))) BIT(FOTG210_HRTIMER_IO_WATCHDOG)))
return; return;
/* /*
...@@ -1365,12 +1334,11 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210) ...@@ -1365,12 +1334,11 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210)
if (fotg210->isoc_count > 0 || (fotg210->need_io_watchdog && if (fotg210->isoc_count > 0 || (fotg210->need_io_watchdog &&
fotg210->async_count + fotg210->intr_count > 0)) fotg210->async_count + fotg210->intr_count > 0))
fotg210_enable_event(fotg210, FOTG210_HRTIMER_IO_WATCHDOG, fotg210_enable_event(fotg210, FOTG210_HRTIMER_IO_WATCHDOG,
true); true);
} }
/* /* Handler functions for the hrtimer event types.
* Handler functions for the hrtimer event types.
* Keep this array in the same order as the event types indexed by * Keep this array in the same order as the event types indexed by
* enum fotg210_hrtimer_event in fotg210.h. * enum fotg210_hrtimer_event in fotg210.h.
*/ */
...@@ -1391,10 +1359,10 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t) ...@@ -1391,10 +1359,10 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t)
{ {
struct fotg210_hcd *fotg210 = struct fotg210_hcd *fotg210 =
container_of(t, struct fotg210_hcd, hrtimer); container_of(t, struct fotg210_hcd, hrtimer);
ktime_t now; ktime_t now;
unsigned long events; unsigned long events;
unsigned long flags; unsigned long flags;
unsigned e; unsigned e;
spin_lock_irqsave(&fotg210->lock, flags); spin_lock_irqsave(&fotg210->lock, flags);
...@@ -1418,19 +1386,12 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t) ...@@ -1418,19 +1386,12 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t)
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
} }
/*-------------------------------------------------------------------------*/ #define fotg210_bus_suspend NULL
#define fotg210_bus_resume NULL
#define fotg210_bus_suspend NULL
#define fotg210_bus_resume NULL
/*-------------------------------------------------------------------------*/
static int check_reset_complete( static int check_reset_complete(struct fotg210_hcd *fotg210, int index,
struct fotg210_hcd *fotg210, u32 __iomem *status_reg, int port_status)
int index, {
u32 __iomem *status_reg,
int port_status
) {
if (!(port_status & PORT_CONNECT)) if (!(port_status & PORT_CONNECT))
return port_status; return port_status;
...@@ -1438,30 +1399,27 @@ static int check_reset_complete( ...@@ -1438,30 +1399,27 @@ static int check_reset_complete(
if (!(port_status & PORT_PE)) { if (!(port_status & PORT_PE)) {
/* with integrated TT, there's nobody to hand it to! */ /* with integrated TT, there's nobody to hand it to! */
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"Failed to enable port %d on root hub TT\n", "Failed to enable port %d on root hub TT\n",
index+1); index + 1);
return port_status; return port_status;
} else { } else {
fotg210_dbg(fotg210, "port %d reset complete, port enabled\n", fotg210_dbg(fotg210, "port %d reset complete, port enabled\n",
index + 1); index + 1);
} }
return port_status; return port_status;
} }
/*-------------------------------------------------------------------------*/
/* build "status change" packet (one or two bytes) from HC registers */ /* build "status change" packet (one or two bytes) from HC registers */
static int static int fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u32 temp, status; u32 temp, status;
u32 mask; u32 mask;
int retval = 1; int retval = 1;
unsigned long flags; unsigned long flags;
/* init status to no-changes */ /* init status to no-changes */
buf[0] = 0; buf[0] = 0;
...@@ -1488,9 +1446,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1488,9 +1446,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
* controller by the user. * controller by the user.
*/ */
if ((temp & mask) != 0 || test_bit(0, &fotg210->port_c_suspend) if ((temp & mask) != 0 || test_bit(0, &fotg210->port_c_suspend) ||
|| (fotg210->reset_done[0] && time_after_eq( (fotg210->reset_done[0] &&
jiffies, fotg210->reset_done[0]))) { time_after_eq(jiffies, fotg210->reset_done[0]))) {
buf[0] |= 1 << 1; buf[0] |= 1 << 1;
status = STS_PCD; status = STS_PCD;
} }
...@@ -1499,15 +1457,11 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1499,15 +1457,11 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
return status ? retval : 0; return status ? retval : 0;
} }
/*-------------------------------------------------------------------------*/ static void fotg210_hub_descriptor(struct fotg210_hcd *fotg210,
struct usb_hub_descriptor *desc)
static void {
fotg210_hub_descriptor( int ports = HCS_N_PORTS(fotg210->hcs_params);
struct fotg210_hcd *fotg210, u16 temp;
struct usb_hub_descriptor *desc
) {
int ports = HCS_N_PORTS(fotg210->hcs_params);
u16 temp;
desc->bDescriptorType = USB_DT_HUB; desc->bDescriptorType = USB_DT_HUB;
desc->bPwrOn2PwrGood = 10; /* fotg210 1.0, 2.3.9 says 20ms max */ desc->bPwrOn2PwrGood = 10; /* fotg210 1.0, 2.3.9 says 20ms max */
...@@ -1526,23 +1480,16 @@ fotg210_hub_descriptor( ...@@ -1526,23 +1480,16 @@ fotg210_hub_descriptor(
desc->wHubCharacteristics = cpu_to_le16(temp); desc->wHubCharacteristics = cpu_to_le16(temp);
} }
/*-------------------------------------------------------------------------*/ static int fotg210_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
static int fotg210_hub_control( {
struct usb_hcd *hcd, struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u16 typeReq, int ports = HCS_N_PORTS(fotg210->hcs_params);
u16 wValue, u32 __iomem *status_reg = &fotg210->regs->port_status;
u16 wIndex, u32 temp, temp1, status;
char *buf, unsigned long flags;
u16 wLength int retval = 0;
) { unsigned selector;
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
int ports = HCS_N_PORTS(fotg210->hcs_params);
u32 __iomem *status_reg = &fotg210->regs->port_status;
u32 temp, temp1, status;
unsigned long flags;
int retval = 0;
unsigned selector;
/* /*
* FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
...@@ -1605,7 +1552,7 @@ static int fotg210_hub_control( ...@@ -1605,7 +1552,7 @@ static int fotg210_hub_control(
break; break;
case USB_PORT_FEAT_C_OVER_CURRENT: case USB_PORT_FEAT_C_OVER_CURRENT:
fotg210_writel(fotg210, temp | OTGISR_OVC, fotg210_writel(fotg210, temp | OTGISR_OVC,
&fotg210->regs->otgisr); &fotg210->regs->otgisr);
break; break;
case USB_PORT_FEAT_C_RESET: case USB_PORT_FEAT_C_RESET:
/* GetPortStatus clears reset */ /* GetPortStatus clears reset */
...@@ -1617,7 +1564,7 @@ static int fotg210_hub_control( ...@@ -1617,7 +1564,7 @@ static int fotg210_hub_control(
break; break;
case GetHubDescriptor: case GetHubDescriptor:
fotg210_hub_descriptor(fotg210, (struct usb_hub_descriptor *) fotg210_hub_descriptor(fotg210, (struct usb_hub_descriptor *)
buf); buf);
break; break;
case GetHubStatus: case GetHubStatus:
/* no hub-wide feature/status flags */ /* no hub-wide feature/status flags */
...@@ -1663,16 +1610,16 @@ static int fotg210_hub_control( ...@@ -1663,16 +1610,16 @@ static int fotg210_hub_control(
/* stop resume signaling */ /* stop resume signaling */
temp = fotg210_readl(fotg210, status_reg); temp = fotg210_readl(fotg210, status_reg);
fotg210_writel(fotg210, fotg210_writel(fotg210, temp &
temp & ~(PORT_RWC_BITS | PORT_RESUME), ~(PORT_RWC_BITS | PORT_RESUME),
status_reg); status_reg);
clear_bit(wIndex, &fotg210->resuming_ports); clear_bit(wIndex, &fotg210->resuming_ports);
retval = handshake(fotg210, status_reg, retval = handshake(fotg210, status_reg,
PORT_RESUME, 0, 2000 /* 2msec */); PORT_RESUME, 0, 2000);/* 2ms */
if (retval != 0) { if (retval != 0) {
fotg210_err(fotg210, fotg210_err(fotg210,
"port %d resume error %d\n", "port %d resume error %d\n",
wIndex + 1, retval); wIndex + 1, retval);
goto error; goto error;
} }
temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10)); temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
...@@ -1680,17 +1627,16 @@ static int fotg210_hub_control( ...@@ -1680,17 +1627,16 @@ static int fotg210_hub_control(
} }
/* whoever resets must GetPortStatus to complete it!! */ /* whoever resets must GetPortStatus to complete it!! */
if ((temp & PORT_RESET) if ((temp & PORT_RESET) && time_after_eq(jiffies,
&& time_after_eq(jiffies, fotg210->reset_done[wIndex])) {
fotg210->reset_done[wIndex])) {
status |= USB_PORT_STAT_C_RESET << 16; status |= USB_PORT_STAT_C_RESET << 16;
fotg210->reset_done[wIndex] = 0; fotg210->reset_done[wIndex] = 0;
clear_bit(wIndex, &fotg210->resuming_ports); clear_bit(wIndex, &fotg210->resuming_ports);
/* force reset to complete */ /* force reset to complete */
fotg210_writel(fotg210, fotg210_writel(fotg210,
temp & ~(PORT_RWC_BITS | PORT_RESET), temp & ~(PORT_RWC_BITS | PORT_RESET),
status_reg); status_reg);
/* REVISIT: some hardware needs 550+ usec to clear /* REVISIT: some hardware needs 550+ usec to clear
* this bit; seems too long to spin routinely... * this bit; seems too long to spin routinely...
*/ */
...@@ -1698,7 +1644,7 @@ static int fotg210_hub_control( ...@@ -1698,7 +1644,7 @@ static int fotg210_hub_control(
PORT_RESET, 0, 1000); PORT_RESET, 0, 1000);
if (retval != 0) { if (retval != 0) {
fotg210_err(fotg210, "port %d reset error %d\n", fotg210_err(fotg210, "port %d reset error %d\n",
wIndex + 1, retval); wIndex + 1, retval);
goto error; goto error;
} }
...@@ -1718,7 +1664,7 @@ static int fotg210_hub_control( ...@@ -1718,7 +1664,7 @@ static int fotg210_hub_control(
temp &= ~PORT_RWC_BITS; temp &= ~PORT_RWC_BITS;
fotg210_writel(fotg210, temp, status_reg); fotg210_writel(fotg210, temp, status_reg);
fotg210_dbg(fotg210, "port %d --> companion\n", fotg210_dbg(fotg210, "port %d --> companion\n",
wIndex + 1); wIndex + 1);
temp = fotg210_readl(fotg210, status_reg); temp = fotg210_readl(fotg210, status_reg);
} }
...@@ -1788,7 +1734,7 @@ static int fotg210_hub_control( ...@@ -1788,7 +1734,7 @@ static int fotg210_hub_control(
* mode if we have hostpc feature * mode if we have hostpc feature
*/ */
fotg210_writel(fotg210, temp | PORT_SUSPEND, fotg210_writel(fotg210, temp | PORT_SUSPEND,
status_reg); status_reg);
set_bit(wIndex, &fotg210->suspended_ports); set_bit(wIndex, &fotg210->suspended_ports);
break; break;
case USB_PORT_FEAT_RESET: case USB_PORT_FEAT_RESET:
...@@ -1866,9 +1812,8 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd, ...@@ -1866,9 +1812,8 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd,
{ {
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/
/* /* There's basically three types of memory:
* There's basically three types of memory:
* - data used only by the HCD ... kmalloc is fine * - data used only by the HCD ... kmalloc is fine
* - async and periodic schedules, shared by HC and HCD ... these * - async and periodic schedules, shared by HC and HCD ... these
* need to use dma_pool or dma_alloc_coherent * need to use dma_pool or dma_alloc_coherent
...@@ -1878,12 +1823,9 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd, ...@@ -1878,12 +1823,9 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd,
* No memory seen by this driver is pageable. * No memory seen by this driver is pageable.
*/ */
/*-------------------------------------------------------------------------*/
/* Allocate the key transfer structures from the previously allocated pool */ /* Allocate the key transfer structures from the previously allocated pool */
static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210, static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210,
struct fotg210_qtd *qtd, dma_addr_t dma) struct fotg210_qtd *qtd, dma_addr_t dma)
{ {
memset(qtd, 0, sizeof(*qtd)); memset(qtd, 0, sizeof(*qtd));
qtd->qtd_dma = dma; qtd->qtd_dma = dma;
...@@ -1894,10 +1836,10 @@ static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210, ...@@ -1894,10 +1836,10 @@ static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210,
} }
static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210, static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210,
gfp_t flags) gfp_t flags)
{ {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
dma_addr_t dma; dma_addr_t dma;
qtd = dma_pool_alloc(fotg210->qtd_pool, flags, &dma); qtd = dma_pool_alloc(fotg210->qtd_pool, flags, &dma);
if (qtd != NULL) if (qtd != NULL)
...@@ -1907,7 +1849,7 @@ static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210, ...@@ -1907,7 +1849,7 @@ static struct fotg210_qtd *fotg210_qtd_alloc(struct fotg210_hcd *fotg210,
} }
static inline void fotg210_qtd_free(struct fotg210_hcd *fotg210, static inline void fotg210_qtd_free(struct fotg210_hcd *fotg210,
struct fotg210_qtd *qtd) struct fotg210_qtd *qtd)
{ {
dma_pool_free(fotg210->qtd_pool, qtd, qtd->qtd_dma); dma_pool_free(fotg210->qtd_pool, qtd, qtd->qtd_dma);
} }
...@@ -1927,10 +1869,10 @@ static void qh_destroy(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -1927,10 +1869,10 @@ static void qh_destroy(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
} }
static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210, static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210,
gfp_t flags) gfp_t flags)
{ {
struct fotg210_qh *qh; struct fotg210_qh *qh;
dma_addr_t dma; dma_addr_t dma;
qh = kzalloc(sizeof(*qh), GFP_ATOMIC); qh = kzalloc(sizeof(*qh), GFP_ATOMIC);
if (!qh) if (!qh)
...@@ -1958,8 +1900,6 @@ static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210, ...@@ -1958,8 +1900,6 @@ static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210,
return NULL; return NULL;
} }
/*-------------------------------------------------------------------------*/
/* The queue heads and transfer descriptors are managed from pools tied /* The queue heads and transfer descriptors are managed from pools tied
* to each of the "per device" structures. * to each of the "per device" structures.
* This is the initialisation and cleanup code. * This is the initialisation and cleanup code.
...@@ -1987,8 +1927,8 @@ static void fotg210_mem_cleanup(struct fotg210_hcd *fotg210) ...@@ -1987,8 +1927,8 @@ static void fotg210_mem_cleanup(struct fotg210_hcd *fotg210)
if (fotg210->periodic) if (fotg210->periodic)
dma_free_coherent(fotg210_to_hcd(fotg210)->self.controller, dma_free_coherent(fotg210_to_hcd(fotg210)->self.controller,
fotg210->periodic_size * sizeof(u32), fotg210->periodic_size * sizeof(u32),
fotg210->periodic, fotg210->periodic_dma); fotg210->periodic, fotg210->periodic_dma);
fotg210->periodic = NULL; fotg210->periodic = NULL;
/* shadow periodic table */ /* shadow periodic table */
...@@ -2035,8 +1975,8 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2035,8 +1975,8 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
/* Hardware periodic table */ /* Hardware periodic table */
fotg210->periodic = (__le32 *) fotg210->periodic = (__le32 *)
dma_alloc_coherent(fotg210_to_hcd(fotg210)->self.controller, dma_alloc_coherent(fotg210_to_hcd(fotg210)->self.controller,
fotg210->periodic_size * sizeof(__le32), fotg210->periodic_size * sizeof(__le32),
&fotg210->periodic_dma, 0); &fotg210->periodic_dma, 0);
if (fotg210->periodic == NULL) if (fotg210->periodic == NULL)
goto fail; goto fail;
...@@ -2045,7 +1985,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2045,7 +1985,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
/* software shadow of hardware table */ /* software shadow of hardware table */
fotg210->pshadow = kcalloc(fotg210->periodic_size, sizeof(void *), fotg210->pshadow = kcalloc(fotg210->periodic_size, sizeof(void *),
flags); flags);
if (fotg210->pshadow != NULL) if (fotg210->pshadow != NULL)
return 0; return 0;
...@@ -2054,9 +1994,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2054,9 +1994,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
fotg210_mem_cleanup(fotg210); fotg210_mem_cleanup(fotg210);
return -ENOMEM; return -ENOMEM;
} }
/*-------------------------------------------------------------------------*/ /* EHCI hardware queue manipulation ... the core. QH/QTD manipulation.
/*
* EHCI hardware queue manipulation ... the core. QH/QTD manipulation.
* *
* Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd" * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
* entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned * entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned
...@@ -2073,16 +2011,12 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2073,16 +2011,12 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
* buffer low/full speed data so the host collects it at high speed. * buffer low/full speed data so the host collects it at high speed.
*/ */
/*-------------------------------------------------------------------------*/
/* fill a qtd, returning how much of the buffer we were able to queue up */ /* fill a qtd, returning how much of the buffer we were able to queue up */
static int qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd,
static int dma_addr_t buf, size_t len, int token, int maxpacket)
qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf,
size_t len, int token, int maxpacket)
{ {
int i, count; int i, count;
u64 addr = buf; u64 addr = buf;
/* one buffer entry per 4K ... first might be short or unaligned */ /* one buffer entry per 4K ... first might be short or unaligned */
qtd->hw_buf[0] = cpu_to_hc32(fotg210, (u32)addr); qtd->hw_buf[0] = cpu_to_hc32(fotg210, (u32)addr);
...@@ -2117,11 +2051,8 @@ qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf, ...@@ -2117,11 +2051,8 @@ qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf,
return count; return count;
} }
/*-------------------------------------------------------------------------*/ static inline void qh_update(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct fotg210_qtd *qtd)
static inline void
qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
struct fotg210_qtd *qtd)
{ {
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
...@@ -2137,7 +2068,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, ...@@ -2137,7 +2068,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
* ever clear it. * ever clear it.
*/ */
if (!(hw->hw_info1 & cpu_to_hc32(fotg210, QH_TOGGLE_CTL))) { if (!(hw->hw_info1 & cpu_to_hc32(fotg210, QH_TOGGLE_CTL))) {
unsigned is_out, epnum; unsigned is_out, epnum;
is_out = qh->is_out; is_out = qh->is_out;
epnum = (hc32_to_cpup(fotg210, &hw->hw_info1) >> 8) & 0x0f; epnum = (hc32_to_cpup(fotg210, &hw->hw_info1) >> 8) & 0x0f;
...@@ -2154,8 +2085,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, ...@@ -2154,8 +2085,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
* overlay, so qh->hw_token wrongly becomes inactive/halted), only fault * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
* recovery (including urb dequeue) would need software changes to a QH... * recovery (including urb dequeue) would need software changes to a QH...
*/ */
static void static void qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
...@@ -2181,16 +2111,14 @@ qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2181,16 +2111,14 @@ qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh_update(fotg210, qh, qtd); qh_update(fotg210, qh, qtd);
} }
/*-------------------------------------------------------------------------*/
static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd, static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd,
struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct fotg210_qh *qh = ep->hcpriv; struct fotg210_qh *qh = ep->hcpriv;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&fotg210->lock, flags); spin_lock_irqsave(&fotg210->lock, flags);
qh->clearing_tt = 0; qh->clearing_tt = 0;
...@@ -2201,8 +2129,7 @@ static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd, ...@@ -2201,8 +2129,7 @@ static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd,
} }
static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct fotg210_qh *qh, struct urb *urb, u32 token)
struct urb *urb, u32 token)
{ {
/* If an async split transaction gets an error or is unlinked, /* If an async split transaction gets an error or is unlinked,
...@@ -2213,27 +2140,24 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, ...@@ -2213,27 +2140,24 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
*/ */
if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
struct usb_device *tt = urb->dev->tt->hub; struct usb_device *tt = urb->dev->tt->hub;
dev_dbg(&tt->dev, dev_dbg(&tt->dev,
"clear tt buffer port %d, a%d ep%d t%08x\n", "clear tt buffer port %d, a%d ep%d t%08x\n",
urb->dev->ttport, urb->dev->devnum, urb->dev->ttport, urb->dev->devnum,
usb_pipeendpoint(urb->pipe), token); usb_pipeendpoint(urb->pipe), token);
if (urb->dev->tt->hub != if (urb->dev->tt->hub !=
fotg210_to_hcd(fotg210)->self.root_hub) { fotg210_to_hcd(fotg210)->self.root_hub) {
if (usb_hub_clear_tt_buffer(urb) == 0) if (usb_hub_clear_tt_buffer(urb) == 0)
qh->clearing_tt = 1; qh->clearing_tt = 1;
} }
} }
} }
static int qtd_copy_status( static int qtd_copy_status(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, size_t length, u32 token)
struct urb *urb,
size_t length,
u32 token
)
{ {
int status = -EINPROGRESS; int status = -EINPROGRESS;
/* count IN/OUT bytes, not SETUP (even short packets) */ /* count IN/OUT bytes, not SETUP (even short packets) */
if (likely(QTD_PID(token) != 2)) if (likely(QTD_PID(token) != 2))
...@@ -2270,32 +2194,32 @@ static int qtd_copy_status( ...@@ -2270,32 +2194,32 @@ static int qtd_copy_status(
} else if (token & QTD_STS_XACT) { } else if (token & QTD_STS_XACT) {
/* timeout, bad CRC, wrong PID, etc */ /* timeout, bad CRC, wrong PID, etc */
fotg210_dbg(fotg210, "devpath %s ep%d%s 3strikes\n", fotg210_dbg(fotg210, "devpath %s ep%d%s 3strikes\n",
urb->dev->devpath, urb->dev->devpath,
usb_pipeendpoint(urb->pipe), usb_pipeendpoint(urb->pipe),
usb_pipein(urb->pipe) ? "in" : "out"); usb_pipein(urb->pipe) ? "in" : "out");
status = -EPROTO; status = -EPROTO;
} else { /* unknown */ } else { /* unknown */
status = -EPROTO; status = -EPROTO;
} }
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"dev%d ep%d%s qtd token %08x --> status %d\n", "dev%d ep%d%s qtd token %08x --> status %d\n",
usb_pipedevice(urb->pipe), usb_pipedevice(urb->pipe),
usb_pipeendpoint(urb->pipe), usb_pipeendpoint(urb->pipe),
usb_pipein(urb->pipe) ? "in" : "out", usb_pipein(urb->pipe) ? "in" : "out",
token, status); token, status);
} }
return status; return status;
} }
static void static void fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb,
fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb, int status) int status)
__releases(fotg210->lock) __releases(fotg210->lock)
__acquires(fotg210->lock) __acquires(fotg210->lock)
{ {
if (likely(urb->hcpriv != NULL)) { if (likely(urb->hcpriv != NULL)) {
struct fotg210_qh *qh = (struct fotg210_qh *) urb->hcpriv; struct fotg210_qh *qh = (struct fotg210_qh *) urb->hcpriv;
/* S-mask in a QH means it's an interrupt urb */ /* S-mask in a QH means it's an interrupt urb */
if ((qh->hw->hw_info2 & cpu_to_hc32(fotg210, QH_SMASK)) != 0) { if ((qh->hw->hw_info2 & cpu_to_hc32(fotg210, QH_SMASK)) != 0) {
...@@ -2316,12 +2240,12 @@ __acquires(fotg210->lock) ...@@ -2316,12 +2240,12 @@ __acquires(fotg210->lock)
#ifdef FOTG210_URB_TRACE #ifdef FOTG210_URB_TRACE
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"%s %s urb %p ep%d%s status %d len %d/%d\n", "%s %s urb %p ep%d%s status %d len %d/%d\n",
__func__, urb->dev->devpath, urb, __func__, urb->dev->devpath, urb,
usb_pipeendpoint(urb->pipe), usb_pipeendpoint(urb->pipe),
usb_pipein(urb->pipe) ? "in" : "out", usb_pipein(urb->pipe) ? "in" : "out",
status, status,
urb->actual_length, urb->transfer_buffer_length); urb->actual_length, urb->transfer_buffer_length);
#endif #endif
/* complete() can reenter this HCD */ /* complete() can reenter this HCD */
...@@ -2333,21 +2257,20 @@ __acquires(fotg210->lock) ...@@ -2333,21 +2257,20 @@ __acquires(fotg210->lock)
static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
/* /* Process and free completed qtds for a qh, returning URBs to drivers.
* Process and free completed qtds for a qh, returning URBs to drivers.
* Chases up to qh->hw_current. Returns number of completions called, * Chases up to qh->hw_current. Returns number of completions called,
* indicating how much "real" work we did. * indicating how much "real" work we did.
*/ */
static unsigned static unsigned qh_completions(struct fotg210_hcd *fotg210,
qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
struct fotg210_qtd *last, *end = qh->dummy; struct fotg210_qtd *last, *end = qh->dummy;
struct list_head *entry, *tmp; struct list_head *entry, *tmp;
int last_status; int last_status;
int stopped; int stopped;
unsigned count = 0; unsigned count = 0;
u8 state; u8 state;
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
if (unlikely(list_empty(&qh->qtd_list))) if (unlikely(list_empty(&qh->qtd_list)))
return count; return count;
...@@ -2366,7 +2289,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2366,7 +2289,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh->qh_state = QH_STATE_COMPLETING; qh->qh_state = QH_STATE_COMPLETING;
stopped = (state == QH_STATE_IDLE); stopped = (state == QH_STATE_IDLE);
rescan: rescan:
last = NULL; last = NULL;
last_status = -EINPROGRESS; last_status = -EINPROGRESS;
qh->needs_rescan = 0; qh->needs_rescan = 0;
...@@ -2377,9 +2300,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2377,9 +2300,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
* if queue is stopped, handles unlinks. * if queue is stopped, handles unlinks.
*/ */
list_for_each_safe(entry, tmp, &qh->qtd_list) { list_for_each_safe(entry, tmp, &qh->qtd_list) {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
struct urb *urb; struct urb *urb;
u32 token = 0; u32 token = 0;
qtd = list_entry(entry, struct fotg210_qtd, qtd_list); qtd = list_entry(entry, struct fotg210_qtd, qtd_list);
urb = qtd->urb; urb = qtd->urb;
...@@ -2388,7 +2311,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2388,7 +2311,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
if (last) { if (last) {
if (likely(last->urb != urb)) { if (likely(last->urb != urb)) {
fotg210_urb_done(fotg210, last->urb, fotg210_urb_done(fotg210, last->urb,
last_status); last_status);
count++; count++;
last_status = -EINPROGRESS; last_status = -EINPROGRESS;
} }
...@@ -2405,20 +2328,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2405,20 +2328,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
token = hc32_to_cpu(fotg210, qtd->hw_token); token = hc32_to_cpu(fotg210, qtd->hw_token);
/* always clean up qtds the hc de-activated */ /* always clean up qtds the hc de-activated */
retry_xacterr: retry_xacterr:
if ((token & QTD_STS_ACTIVE) == 0) { if ((token & QTD_STS_ACTIVE) == 0) {
/* Report Data Buffer Error: non-fatal but useful */ /* Report Data Buffer Error: non-fatal but useful */
if (token & QTD_STS_DBE) if (token & QTD_STS_DBE)
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n", "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n",
urb, urb, usb_endpoint_num(&urb->ep->desc),
usb_endpoint_num(&urb->ep->desc),
usb_endpoint_dir_in(&urb->ep->desc) usb_endpoint_dir_in(&urb->ep->desc)
? "in" : "out", ? "in" : "out",
urb->transfer_buffer_length, urb->transfer_buffer_length, qtd, qh);
qtd,
qh);
/* on STALL, error, and short reads this urb must /* on STALL, error, and short reads this urb must
* complete and all its qtds must be recycled. * complete and all its qtds must be recycled.
...@@ -2429,12 +2349,14 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2429,12 +2349,14 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
* reach the software xacterr limit * reach the software xacterr limit
*/ */
if ((token & QTD_STS_XACT) && if ((token & QTD_STS_XACT) &&
QTD_CERR(token) == 0 && QTD_CERR(token) == 0 &&
++qh->xacterrs < QH_XACTERR_MAX && ++qh->xacterrs < QH_XACTERR_MAX &&
!urb->unlinked) { !urb->unlinked) {
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"detected XactErr len %zu/%zu retry %d\n", "detected XactErr len %zu/%zu retry %d\n",
qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs); qtd->length - QTD_LENGTH(token),
qtd->length,
qh->xacterrs);
/* reset the token in the qtd and the /* reset the token in the qtd and the
* qh overlay (which still contains * qh overlay (which still contains
...@@ -2462,9 +2384,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2462,9 +2384,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
* URB_SHORT_NOT_OK was set so the driver submitting * URB_SHORT_NOT_OK was set so the driver submitting
* the urbs could clean it up. * the urbs could clean it up.
*/ */
} else if (IS_SHORT_READ(token) } else if (IS_SHORT_READ(token) &&
&& !(qtd->hw_alt_next !(qtd->hw_alt_next &
& FOTG210_LIST_END(fotg210))) { FOTG210_LIST_END(fotg210))) {
stopped = 1; stopped = 1;
} }
...@@ -2488,9 +2410,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2488,9 +2410,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
continue; continue;
/* qh unlinked; token in overlay may be most current */ /* qh unlinked; token in overlay may be most current */
if (state == QH_STATE_IDLE if (state == QH_STATE_IDLE &&
&& cpu_to_hc32(fotg210, qtd->qtd_dma) cpu_to_hc32(fotg210, qtd->qtd_dma)
== hw->hw_current) { == hw->hw_current) {
token = hc32_to_cpu(fotg210, hw->hw_token); token = hc32_to_cpu(fotg210, hw->hw_token);
/* An unlink may leave an incomplete /* An unlink may leave an incomplete
...@@ -2498,7 +2420,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2498,7 +2420,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
* We have to clear it. * We have to clear it.
*/ */
fotg210_clear_tt_buffer(fotg210, qh, urb, fotg210_clear_tt_buffer(fotg210, qh, urb,
token); token);
} }
} }
...@@ -2512,9 +2434,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2512,9 +2434,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
if (last_status == -EINPROGRESS) { if (last_status == -EINPROGRESS) {
last_status = qtd_copy_status(fotg210, urb, last_status = qtd_copy_status(fotg210, urb,
qtd->length, token); qtd->length, token);
if (last_status == -EREMOTEIO if (last_status == -EREMOTEIO &&
&& (qtd->hw_alt_next (qtd->hw_alt_next &
& FOTG210_LIST_END(fotg210))) FOTG210_LIST_END(fotg210)))
last_status = -EINPROGRESS; last_status = -EINPROGRESS;
/* As part of low/full-speed endpoint-halt processing /* As part of low/full-speed endpoint-halt processing
...@@ -2533,7 +2455,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2533,7 +2455,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
*/ */
if (last_status != -EPIPE) if (last_status != -EPIPE)
fotg210_clear_tt_buffer(fotg210, qh, fotg210_clear_tt_buffer(fotg210, qh,
urb, token); urb, token);
} }
} }
...@@ -2611,26 +2533,21 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2611,26 +2533,21 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
return count; return count;
} }
/*-------------------------------------------------------------------------*/
/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
/* ... and packet size, for any kind of endpoint descriptor */ /* ... and packet size, for any kind of endpoint descriptor */
#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff) #define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
/* /* reverse of qh_urb_transaction: free a list of TDs.
* reverse of qh_urb_transaction: free a list of TDs.
* used for cleanup after errors, before HC sees an URB's TDs. * used for cleanup after errors, before HC sees an URB's TDs.
*/ */
static void qtd_list_free( static void qtd_list_free(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, struct list_head *qtd_list)
struct urb *urb, {
struct list_head *qtd_list struct list_head *entry, *temp;
) {
struct list_head *entry, *temp;
list_for_each_safe(entry, temp, qtd_list) { list_for_each_safe(entry, temp, qtd_list) {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
qtd = list_entry(entry, struct fotg210_qtd, qtd_list); qtd = list_entry(entry, struct fotg210_qtd, qtd_list);
list_del(&qtd->qtd_list); list_del(&qtd->qtd_list);
...@@ -2638,23 +2555,18 @@ static void qtd_list_free( ...@@ -2638,23 +2555,18 @@ static void qtd_list_free(
} }
} }
/* /* create a list of filled qtds for this URB; won't link into qh.
* create a list of filled qtds for this URB; won't link into qh.
*/ */
static struct list_head * static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
qh_urb_transaction( struct urb *urb, struct list_head *head, gfp_t flags)
struct fotg210_hcd *fotg210, {
struct urb *urb, struct fotg210_qtd *qtd, *qtd_prev;
struct list_head *head, dma_addr_t buf;
gfp_t flags int len, this_sg_len, maxpacket;
) { int is_input;
struct fotg210_qtd *qtd, *qtd_prev; u32 token;
dma_addr_t buf; int i;
int len, this_sg_len, maxpacket; struct scatterlist *sg;
int is_input;
u32 token;
int i;
struct scatterlist *sg;
/* /*
* URBs map to sequences of QTDs: one logical transaction * URBs map to sequences of QTDs: one logical transaction
...@@ -2764,8 +2676,8 @@ qh_urb_transaction( ...@@ -2764,8 +2676,8 @@ qh_urb_transaction(
* have the alt_next mechanism keep the queue running after the * have the alt_next mechanism keep the queue running after the
* last data qtd (the only one, for control and most other cases). * last data qtd (the only one, for control and most other cases).
*/ */
if (likely((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 if (likely((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 ||
|| usb_pipecontrol(urb->pipe))) usb_pipecontrol(urb->pipe)))
qtd->hw_alt_next = FOTG210_LIST_END(fotg210); qtd->hw_alt_next = FOTG210_LIST_END(fotg210);
/* /*
...@@ -2774,7 +2686,7 @@ qh_urb_transaction( ...@@ -2774,7 +2686,7 @@ qh_urb_transaction(
* (zero length). * (zero length).
*/ */
if (likely(urb->transfer_buffer_length != 0)) { if (likely(urb->transfer_buffer_length != 0)) {
int one_more = 0; int one_more = 0;
if (usb_pipecontrol(urb->pipe)) { if (usb_pipecontrol(urb->pipe)) {
one_more = 1; one_more = 1;
...@@ -2809,9 +2721,7 @@ qh_urb_transaction( ...@@ -2809,9 +2721,7 @@ qh_urb_transaction(
return NULL; return NULL;
} }
/*-------------------------------------------------------------------------*/ /* Would be best to create all qh's from config descriptors,
/*
* Would be best to create all qh's from config descriptors,
* when each interface/altsetting is established. Unlink * when each interface/altsetting is established. Unlink
* any previous qh and cancel its urbs first; endpoints are * any previous qh and cancel its urbs first; endpoints are
* implicitly reset then (data toggle too). * implicitly reset then (data toggle too).
...@@ -2819,26 +2729,22 @@ qh_urb_transaction( ...@@ -2819,26 +2729,22 @@ qh_urb_transaction(
*/ */
/* /* Each QH holds a qtd list; a QH is used for everything except iso.
* Each QH holds a qtd list; a QH is used for everything except iso.
* *
* For interrupt urbs, the scheduler must set the microframe scheduling * For interrupt urbs, the scheduler must set the microframe scheduling
* mask(s) each time the QH gets scheduled. For highspeed, that's * mask(s) each time the QH gets scheduled. For highspeed, that's
* just one microframe in the s-mask. For split interrupt transactions * just one microframe in the s-mask. For split interrupt transactions
* there are additional complications: c-mask, maybe FSTNs. * there are additional complications: c-mask, maybe FSTNs.
*/ */
static struct fotg210_qh * static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
qh_make( gfp_t flags)
struct fotg210_hcd *fotg210, {
struct urb *urb, struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
gfp_t flags u32 info1 = 0, info2 = 0;
) { int is_input, type;
struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags); int maxp = 0;
u32 info1 = 0, info2 = 0; struct usb_tt *tt = urb->dev->tt;
int is_input, type; struct fotg210_qh_hw *hw;
int maxp = 0;
struct usb_tt *tt = urb->dev->tt;
struct fotg210_qh_hw *hw;
if (!qh) if (!qh)
return qh; return qh;
...@@ -2858,7 +2764,7 @@ qh_make( ...@@ -2858,7 +2764,7 @@ qh_make(
*/ */
if (max_packet(maxp) > 1024) { if (max_packet(maxp) > 1024) {
fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", fotg210_dbg(fotg210, "bogus qh maxpacket %d\n",
max_packet(maxp)); max_packet(maxp));
goto done; goto done;
} }
...@@ -2892,7 +2798,7 @@ qh_make( ...@@ -2892,7 +2798,7 @@ qh_make(
urb->interval = qh->period << 3; urb->interval = qh->period << 3;
} }
} else { } else {
int think_time; int think_time;
/* gap is f(FS/LS transfer times) */ /* gap is f(FS/LS transfer times) */
qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed, qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed,
...@@ -2982,7 +2888,7 @@ qh_make( ...@@ -2982,7 +2888,7 @@ qh_make(
break; break;
default: default:
fotg210_dbg(fotg210, "bogus dev %p speed %d\n", urb->dev, fotg210_dbg(fotg210, "bogus dev %p speed %d\n", urb->dev,
urb->dev->speed); urb->dev->speed);
done: done:
qh_destroy(fotg210, qh); qh_destroy(fotg210, qh);
return NULL; return NULL;
...@@ -3001,8 +2907,6 @@ qh_make( ...@@ -3001,8 +2907,6 @@ qh_make(
return qh; return qh;
} }
/*-------------------------------------------------------------------------*/
static void enable_async(struct fotg210_hcd *fotg210) static void enable_async(struct fotg210_hcd *fotg210)
{ {
if (fotg210->async_count++) if (fotg210->async_count++)
...@@ -3032,8 +2936,8 @@ static void disable_async(struct fotg210_hcd *fotg210) ...@@ -3032,8 +2936,8 @@ static void disable_async(struct fotg210_hcd *fotg210)
static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
__hc32 dma = QH_NEXT(fotg210, qh->qh_dma); __hc32 dma = QH_NEXT(fotg210, qh->qh_dma);
struct fotg210_qh *head; struct fotg210_qh *head;
/* Don't link a QH if there's a Clear-TT-Buffer pending */ /* Don't link a QH if there's a Clear-TT-Buffer pending */
if (unlikely(qh->clearing_tt)) if (unlikely(qh->clearing_tt))
...@@ -3060,24 +2964,17 @@ static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3060,24 +2964,17 @@ static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
enable_async(fotg210); enable_async(fotg210);
} }
/*-------------------------------------------------------------------------*/ /* For control/bulk/interrupt, return QH with these TDs appended.
/*
* For control/bulk/interrupt, return QH with these TDs appended.
* Allocates and initializes the QH if necessary. * Allocates and initializes the QH if necessary.
* Returns null if it can't allocate a QH it needs to. * Returns null if it can't allocate a QH it needs to.
* If the QH has TDs (urbs) already, that's great. * If the QH has TDs (urbs) already, that's great.
*/ */
static struct fotg210_qh *qh_append_tds( static struct fotg210_qh *qh_append_tds(struct fotg210_hcd *fotg210,
struct fotg210_hcd *fotg210, struct urb *urb, struct list_head *qtd_list,
struct urb *urb, int epnum, void **ptr)
struct list_head *qtd_list,
int epnum,
void **ptr
)
{ {
struct fotg210_qh *qh = NULL; struct fotg210_qh *qh = NULL;
__hc32 qh_addr_mask = cpu_to_hc32(fotg210, 0x7f); __hc32 qh_addr_mask = cpu_to_hc32(fotg210, 0x7f);
qh = (struct fotg210_qh *) *ptr; qh = (struct fotg210_qh *) *ptr;
if (unlikely(qh == NULL)) { if (unlikely(qh == NULL)) {
...@@ -3086,7 +2983,7 @@ static struct fotg210_qh *qh_append_tds( ...@@ -3086,7 +2983,7 @@ static struct fotg210_qh *qh_append_tds(
*ptr = qh; *ptr = qh;
} }
if (likely(qh != NULL)) { if (likely(qh != NULL)) {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
if (unlikely(list_empty(qtd_list))) if (unlikely(list_empty(qtd_list)))
qtd = NULL; qtd = NULL;
...@@ -3105,9 +3002,9 @@ static struct fotg210_qh *qh_append_tds( ...@@ -3105,9 +3002,9 @@ static struct fotg210_qh *qh_append_tds(
* only hc or qh_refresh() ever modify the overlay. * only hc or qh_refresh() ever modify the overlay.
*/ */
if (likely(qtd != NULL)) { if (likely(qtd != NULL)) {
struct fotg210_qtd *dummy; struct fotg210_qtd *dummy;
dma_addr_t dma; dma_addr_t dma;
__hc32 token; __hc32 token;
/* to avoid racing the HC, use the dummy td instead of /* to avoid racing the HC, use the dummy td instead of
* the first td of our list (becomes new dummy). both * the first td of our list (becomes new dummy). both
...@@ -3146,32 +3043,28 @@ static struct fotg210_qh *qh_append_tds( ...@@ -3146,32 +3043,28 @@ static struct fotg210_qh *qh_append_tds(
return qh; return qh;
} }
/*-------------------------------------------------------------------------*/ static int submit_async(struct fotg210_hcd *fotg210, struct urb *urb,
struct list_head *qtd_list, gfp_t mem_flags)
static int {
submit_async( int epnum;
struct fotg210_hcd *fotg210, unsigned long flags;
struct urb *urb, struct fotg210_qh *qh = NULL;
struct list_head *qtd_list, int rc;
gfp_t mem_flags
) {
int epnum;
unsigned long flags;
struct fotg210_qh *qh = NULL;
int rc;
epnum = urb->ep->desc.bEndpointAddress; epnum = urb->ep->desc.bEndpointAddress;
#ifdef FOTG210_URB_TRACE #ifdef FOTG210_URB_TRACE
{ {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
qtd = list_entry(qtd_list->next, struct fotg210_qtd, qtd_list); qtd = list_entry(qtd_list->next, struct fotg210_qtd, qtd_list);
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
__func__, urb->dev->devpath, urb, __func__, urb->dev->devpath, urb,
epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", epnum & 0x0f, (epnum & USB_DIR_IN)
urb->transfer_buffer_length, ? "in" : "out",
qtd, urb->ep->hcpriv); urb->transfer_buffer_length,
qtd, urb->ep->hcpriv);
} }
#endif #endif
...@@ -3196,19 +3089,17 @@ submit_async( ...@@ -3196,19 +3089,17 @@ submit_async(
*/ */
if (likely(qh->qh_state == QH_STATE_IDLE)) if (likely(qh->qh_state == QH_STATE_IDLE))
qh_link_async(fotg210, qh); qh_link_async(fotg210, qh);
done: done:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
if (unlikely(qh == NULL)) if (unlikely(qh == NULL))
qtd_list_free(fotg210, urb, qtd_list); qtd_list_free(fotg210, urb, qtd_list);
return rc; return rc;
} }
/*-------------------------------------------------------------------------*/
static void single_unlink_async(struct fotg210_hcd *fotg210, static void single_unlink_async(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
struct fotg210_qh *prev; struct fotg210_qh *prev;
/* Add to the end of the list of QHs waiting for the next IAAD */ /* Add to the end of the list of QHs waiting for the next IAAD */
qh->qh_state = QH_STATE_UNLINK; qh->qh_state = QH_STATE_UNLINK;
...@@ -3256,7 +3147,7 @@ static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested) ...@@ -3256,7 +3147,7 @@ static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested)
&fotg210->regs->command); &fotg210->regs->command);
fotg210_readl(fotg210, &fotg210->regs->command); fotg210_readl(fotg210, &fotg210->regs->command);
fotg210_enable_event(fotg210, FOTG210_HRTIMER_IAA_WATCHDOG, fotg210_enable_event(fotg210, FOTG210_HRTIMER_IAA_WATCHDOG,
true); true);
} }
} }
...@@ -3264,10 +3155,10 @@ static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested) ...@@ -3264,10 +3155,10 @@ static void start_iaa_cycle(struct fotg210_hcd *fotg210, bool nested)
static void end_unlink_async(struct fotg210_hcd *fotg210) static void end_unlink_async(struct fotg210_hcd *fotg210)
{ {
struct fotg210_qh *qh; struct fotg210_qh *qh;
/* Process the idle QHs */ /* Process the idle QHs */
restart: restart:
fotg210->async_unlinking = true; fotg210->async_unlinking = true;
while (fotg210->async_iaa) { while (fotg210->async_iaa) {
qh = fotg210->async_iaa; qh = fotg210->async_iaa;
...@@ -3322,7 +3213,7 @@ static void unlink_empty_async(struct fotg210_hcd *fotg210) ...@@ -3322,7 +3213,7 @@ static void unlink_empty_async(struct fotg210_hcd *fotg210)
/* QHs that haven't been empty for long enough will be handled later */ /* QHs that haven't been empty for long enough will be handled later */
if (check_unlinks_later) { if (check_unlinks_later) {
fotg210_enable_event(fotg210, FOTG210_HRTIMER_ASYNC_UNLINKS, fotg210_enable_event(fotg210, FOTG210_HRTIMER_ASYNC_UNLINKS,
true); true);
++fotg210->async_unlink_cycle; ++fotg210->async_unlink_cycle;
} }
} }
...@@ -3331,7 +3222,7 @@ static void unlink_empty_async(struct fotg210_hcd *fotg210) ...@@ -3331,7 +3222,7 @@ static void unlink_empty_async(struct fotg210_hcd *fotg210)
/* caller must own fotg210->lock */ /* caller must own fotg210->lock */
static void start_unlink_async(struct fotg210_hcd *fotg210, static void start_unlink_async(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
/* /*
* If the QH isn't linked then there's nothing we can do * If the QH isn't linked then there's nothing we can do
...@@ -3348,18 +3239,16 @@ static void start_unlink_async(struct fotg210_hcd *fotg210, ...@@ -3348,18 +3239,16 @@ static void start_unlink_async(struct fotg210_hcd *fotg210,
start_iaa_cycle(fotg210, false); start_iaa_cycle(fotg210, false);
} }
/*-------------------------------------------------------------------------*/
static void scan_async(struct fotg210_hcd *fotg210) static void scan_async(struct fotg210_hcd *fotg210)
{ {
struct fotg210_qh *qh; struct fotg210_qh *qh;
bool check_unlinks_later = false; bool check_unlinks_later = false;
fotg210->qh_scan_next = fotg210->async->qh_next.qh; fotg210->qh_scan_next = fotg210->async->qh_next.qh;
while (fotg210->qh_scan_next) { while (fotg210->qh_scan_next) {
qh = fotg210->qh_scan_next; qh = fotg210->qh_scan_next;
fotg210->qh_scan_next = qh->qh_next.qh; fotg210->qh_scan_next = qh->qh_next.qh;
rescan: rescan:
/* clean any finished work for this qh */ /* clean any finished work for this qh */
if (!list_empty(&qh->qtd_list)) { if (!list_empty(&qh->qtd_list)) {
int temp; int temp;
...@@ -3391,15 +3280,13 @@ static void scan_async(struct fotg210_hcd *fotg210) ...@@ -3391,15 +3280,13 @@ static void scan_async(struct fotg210_hcd *fotg210)
*/ */
if (check_unlinks_later && fotg210->rh_state == FOTG210_RH_RUNNING && if (check_unlinks_later && fotg210->rh_state == FOTG210_RH_RUNNING &&
!(fotg210->enabled_hrtimer_events & !(fotg210->enabled_hrtimer_events &
BIT(FOTG210_HRTIMER_ASYNC_UNLINKS))) { BIT(FOTG210_HRTIMER_ASYNC_UNLINKS))) {
fotg210_enable_event(fotg210, fotg210_enable_event(fotg210,
FOTG210_HRTIMER_ASYNC_UNLINKS, true); FOTG210_HRTIMER_ASYNC_UNLINKS, true);
++fotg210->async_unlink_cycle; ++fotg210->async_unlink_cycle;
} }
} }
/*-------------------------------------------------------------------------*/ /* EHCI scheduled transaction support: interrupt, iso, split iso
/*
* EHCI scheduled transaction support: interrupt, iso, split iso
* These are called "periodic" transactions in the EHCI spec. * These are called "periodic" transactions in the EHCI spec.
* *
* Note that for interrupt transfers, the QH/QTD manipulation is shared * Note that for interrupt transfers, the QH/QTD manipulation is shared
...@@ -3410,19 +3297,14 @@ static void scan_async(struct fotg210_hcd *fotg210) ...@@ -3410,19 +3297,14 @@ static void scan_async(struct fotg210_hcd *fotg210)
* It keeps track of every ITD (or SITD) that's linked, and holds enough * It keeps track of every ITD (or SITD) that's linked, and holds enough
* pre-calculated schedule data to make appending to the queue be quick. * pre-calculated schedule data to make appending to the queue be quick.
*/ */
static int fotg210_get_frame(struct usb_hcd *hcd); static int fotg210_get_frame(struct usb_hcd *hcd);
/*-------------------------------------------------------------------------*/ /* periodic_next_shadow - return "next" pointer on shadow list
/*
* periodic_next_shadow - return "next" pointer on shadow list
* @periodic: host pointer to qh/itd * @periodic: host pointer to qh/itd
* @tag: hardware tag for type of this record * @tag: hardware tag for type of this record
*/ */
static union fotg210_shadow * static union fotg210_shadow *periodic_next_shadow(struct fotg210_hcd *fotg210,
periodic_next_shadow(struct fotg210_hcd *fotg210, union fotg210_shadow *periodic, __hc32 tag)
union fotg210_shadow *periodic, __hc32 tag)
{ {
switch (hc32_to_cpu(fotg210, tag)) { switch (hc32_to_cpu(fotg210, tag)) {
case Q_TYPE_QH: case Q_TYPE_QH:
...@@ -3434,9 +3316,8 @@ periodic_next_shadow(struct fotg210_hcd *fotg210, ...@@ -3434,9 +3316,8 @@ periodic_next_shadow(struct fotg210_hcd *fotg210,
} }
} }
static __hc32 * static __hc32 *shadow_next_periodic(struct fotg210_hcd *fotg210,
shadow_next_periodic(struct fotg210_hcd *fotg210, union fotg210_shadow *periodic, __hc32 tag)
union fotg210_shadow *periodic, __hc32 tag)
{ {
switch (hc32_to_cpu(fotg210, tag)) { switch (hc32_to_cpu(fotg210, tag)) {
/* our fotg210_shadow.qh is actually software part */ /* our fotg210_shadow.qh is actually software part */
...@@ -3450,11 +3331,11 @@ shadow_next_periodic(struct fotg210_hcd *fotg210, ...@@ -3450,11 +3331,11 @@ shadow_next_periodic(struct fotg210_hcd *fotg210,
/* caller must hold fotg210->lock */ /* caller must hold fotg210->lock */
static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame, static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame,
void *ptr) void *ptr)
{ {
union fotg210_shadow *prev_p = &fotg210->pshadow[frame]; union fotg210_shadow *prev_p = &fotg210->pshadow[frame];
__hc32 *hw_p = &fotg210->periodic[frame]; __hc32 *hw_p = &fotg210->periodic[frame];
union fotg210_shadow here = *prev_p; union fotg210_shadow here = *prev_p;
/* find predecessor of "ptr"; hw and shadow lists are in sync */ /* find predecessor of "ptr"; hw and shadow lists are in sync */
while (here.ptr && here.ptr != ptr) { while (here.ptr && here.ptr != ptr) {
...@@ -3475,17 +3356,17 @@ static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame, ...@@ -3475,17 +3356,17 @@ static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame,
Q_NEXT_TYPE(fotg210, *hw_p)); Q_NEXT_TYPE(fotg210, *hw_p));
*hw_p = *shadow_next_periodic(fotg210, &here, *hw_p = *shadow_next_periodic(fotg210, &here,
Q_NEXT_TYPE(fotg210, *hw_p)); Q_NEXT_TYPE(fotg210, *hw_p));
} }
/* how many of the uframe's 125 usecs are allocated? */ /* how many of the uframe's 125 usecs are allocated? */
static unsigned short static unsigned short periodic_usecs(struct fotg210_hcd *fotg210,
periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe) unsigned frame, unsigned uframe)
{ {
__hc32 *hw_p = &fotg210->periodic[frame]; __hc32 *hw_p = &fotg210->periodic[frame];
union fotg210_shadow *q = &fotg210->pshadow[frame]; union fotg210_shadow *q = &fotg210->pshadow[frame];
unsigned usecs = 0; unsigned usecs = 0;
struct fotg210_qh_hw *hw; struct fotg210_qh_hw *hw;
while (q->ptr) { while (q->ptr) {
switch (hc32_to_cpu(fotg210, Q_NEXT_TYPE(fotg210, *hw_p))) { switch (hc32_to_cpu(fotg210, Q_NEXT_TYPE(fotg210, *hw_p))) {
...@@ -3522,12 +3403,10 @@ periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe) ...@@ -3522,12 +3403,10 @@ periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe)
} }
if (usecs > fotg210->uframe_periodic_max) if (usecs > fotg210->uframe_periodic_max)
fotg210_err(fotg210, "uframe %d sched overrun: %d usecs\n", fotg210_err(fotg210, "uframe %d sched overrun: %d usecs\n",
frame * 8 + uframe, usecs); frame * 8 + uframe, usecs);
return usecs; return usecs;
} }
/*-------------------------------------------------------------------------*/
static int same_tt(struct usb_device *dev1, struct usb_device *dev2) static int same_tt(struct usb_device *dev1, struct usb_device *dev2)
{ {
if (!dev1->tt || !dev2->tt) if (!dev1->tt || !dev2->tt)
...@@ -3544,13 +3423,8 @@ static int same_tt(struct usb_device *dev1, struct usb_device *dev2) ...@@ -3544,13 +3423,8 @@ static int same_tt(struct usb_device *dev1, struct usb_device *dev2)
* for a periodic transfer starting at the specified frame, using * for a periodic transfer starting at the specified frame, using
* all the uframes in the mask. * all the uframes in the mask.
*/ */
static int tt_no_collision( static int tt_no_collision(struct fotg210_hcd *fotg210, unsigned period,
struct fotg210_hcd *fotg210, struct usb_device *dev, unsigned frame, u32 uf_mask)
unsigned period,
struct usb_device *dev,
unsigned frame,
u32 uf_mask
)
{ {
if (period == 0) /* error */ if (period == 0) /* error */
return 0; return 0;
...@@ -3560,9 +3434,9 @@ static int tt_no_collision( ...@@ -3560,9 +3434,9 @@ static int tt_no_collision(
* calling convention doesn't make that distinction. * calling convention doesn't make that distinction.
*/ */
for (; frame < fotg210->periodic_size; frame += period) { for (; frame < fotg210->periodic_size; frame += period) {
union fotg210_shadow here; union fotg210_shadow here;
__hc32 type; __hc32 type;
struct fotg210_qh_hw *hw; struct fotg210_qh_hw *hw;
here = fotg210->pshadow[frame]; here = fotg210->pshadow[frame];
type = Q_NEXT_TYPE(fotg210, fotg210->periodic[frame]); type = Q_NEXT_TYPE(fotg210, fotg210->periodic[frame]);
...@@ -3575,7 +3449,7 @@ static int tt_no_collision( ...@@ -3575,7 +3449,7 @@ static int tt_no_collision(
case Q_TYPE_QH: case Q_TYPE_QH:
hw = here.qh->hw; hw = here.qh->hw;
if (same_tt(dev, here.qh->dev)) { if (same_tt(dev, here.qh->dev)) {
u32 mask; u32 mask;
mask = hc32_to_cpu(fotg210, mask = hc32_to_cpu(fotg210,
hw->hw_info2); hw->hw_info2);
...@@ -3590,8 +3464,8 @@ static int tt_no_collision( ...@@ -3590,8 +3464,8 @@ static int tt_no_collision(
/* case Q_TYPE_FSTN: */ /* case Q_TYPE_FSTN: */
default: default:
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"periodic frame %d bogus type %d\n", "periodic frame %d bogus type %d\n",
frame, type); frame, type);
} }
/* collision or error */ /* collision or error */
...@@ -3603,8 +3477,6 @@ static int tt_no_collision( ...@@ -3603,8 +3477,6 @@ static int tt_no_collision(
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/
static void enable_periodic(struct fotg210_hcd *fotg210) static void enable_periodic(struct fotg210_hcd *fotg210)
{ {
if (fotg210->periodic_count++) if (fotg210->periodic_count++)
...@@ -3628,8 +3500,6 @@ static void disable_periodic(struct fotg210_hcd *fotg210) ...@@ -3628,8 +3500,6 @@ static void disable_periodic(struct fotg210_hcd *fotg210)
fotg210_poll_PSS(fotg210); fotg210_poll_PSS(fotg210);
} }
/*-------------------------------------------------------------------------*/
/* periodic schedule slots have iso tds (normal or split) first, then a /* periodic schedule slots have iso tds (normal or split) first, then a
* sparse tree for active interrupt transfers. * sparse tree for active interrupt transfers.
* *
...@@ -3638,24 +3508,24 @@ static void disable_periodic(struct fotg210_hcd *fotg210) ...@@ -3638,24 +3508,24 @@ static void disable_periodic(struct fotg210_hcd *fotg210)
*/ */
static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
unsigned i; unsigned i;
unsigned period = qh->period; unsigned period = qh->period;
dev_dbg(&qh->dev->dev, dev_dbg(&qh->dev->dev,
"link qh%d-%04x/%p start %d [%d/%d us]\n", "link qh%d-%04x/%p start %d [%d/%d us]\n", period,
period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
& (QH_CMASK | QH_SMASK), (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
qh, qh->start, qh->usecs, qh->c_usecs); qh->c_usecs);
/* high bandwidth, or otherwise every microframe */ /* high bandwidth, or otherwise every microframe */
if (period == 0) if (period == 0)
period = 1; period = 1;
for (i = qh->start; i < fotg210->periodic_size; i += period) { for (i = qh->start; i < fotg210->periodic_size; i += period) {
union fotg210_shadow *prev = &fotg210->pshadow[i]; union fotg210_shadow *prev = &fotg210->pshadow[i];
__hc32 *hw_p = &fotg210->periodic[i]; __hc32 *hw_p = &fotg210->periodic[i];
union fotg210_shadow here = *prev; union fotg210_shadow here = *prev;
__hc32 type = 0; __hc32 type = 0;
/* skip the iso nodes at list head */ /* skip the iso nodes at list head */
while (here.ptr) { while (here.ptr) {
...@@ -3703,10 +3573,10 @@ static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3703,10 +3573,10 @@ static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
} }
static void qh_unlink_periodic(struct fotg210_hcd *fotg210, static void qh_unlink_periodic(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
unsigned i; unsigned i;
unsigned period; unsigned period;
/* /*
* If qh is for a low/full-speed device, simply unlinking it * If qh is for a low/full-speed device, simply unlinking it
...@@ -3737,10 +3607,10 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210, ...@@ -3737,10 +3607,10 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210,
: (qh->usecs * 8); : (qh->usecs * 8);
dev_dbg(&qh->dev->dev, dev_dbg(&qh->dev->dev,
"unlink qh%d-%04x/%p start %d [%d/%d us]\n", "unlink qh%d-%04x/%p start %d [%d/%d us]\n",
qh->period, qh->period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
hc32_to_cpup(fotg210, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
(QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs, qh->c_usecs); qh->c_usecs);
/* qh->qh_next still "live" to HC */ /* qh->qh_next still "live" to HC */
qh->qh_state = QH_STATE_UNLINK; qh->qh_state = QH_STATE_UNLINK;
...@@ -3753,7 +3623,7 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210, ...@@ -3753,7 +3623,7 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210,
} }
static void start_unlink_intr(struct fotg210_hcd *fotg210, static void start_unlink_intr(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
/* If the QH isn't linked then there's nothing we can do /* If the QH isn't linked then there's nothing we can do
* unless we were called during a giveback, in which case * unless we were called during a giveback, in which case
...@@ -3790,15 +3660,15 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210, ...@@ -3790,15 +3660,15 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210,
fotg210_handle_intr_unlinks(fotg210); fotg210_handle_intr_unlinks(fotg210);
else if (fotg210->intr_unlink == qh) { else if (fotg210->intr_unlink == qh) {
fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR, fotg210_enable_event(fotg210, FOTG210_HRTIMER_UNLINK_INTR,
true); true);
++fotg210->intr_unlink_cycle; ++fotg210->intr_unlink_cycle;
} }
} }
static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
int rc; int rc;
qh->qh_state = QH_STATE_IDLE; qh->qh_state = QH_STATE_IDLE;
hw->hw_next = FOTG210_LIST_END(fotg210); hw->hw_next = FOTG210_LIST_END(fotg210);
...@@ -3807,7 +3677,7 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3807,7 +3677,7 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
/* reschedule QH iff another request is queued */ /* reschedule QH iff another request is queued */
if (!list_empty(&qh->qtd_list) && if (!list_empty(&qh->qtd_list) &&
fotg210->rh_state == FOTG210_RH_RUNNING) { fotg210->rh_state == FOTG210_RH_RUNNING) {
rc = qh_schedule(fotg210, qh); rc = qh_schedule(fotg210, qh);
/* An error here likely indicates handshake failure /* An error here likely indicates handshake failure
...@@ -3826,16 +3696,10 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3826,16 +3696,10 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
disable_periodic(fotg210); disable_periodic(fotg210);
} }
/*-------------------------------------------------------------------------*/ static int check_period(struct fotg210_hcd *fotg210, unsigned frame,
unsigned uframe, unsigned period, unsigned usecs)
static int check_period( {
struct fotg210_hcd *fotg210, int claimed;
unsigned frame,
unsigned uframe,
unsigned period,
unsigned usecs
) {
int claimed;
/* complete split running into next frame? /* complete split running into next frame?
* given FSTN support, we could sometimes check... * given FSTN support, we could sometimes check...
...@@ -3853,7 +3717,7 @@ static int check_period( ...@@ -3853,7 +3717,7 @@ static int check_period(
do { do {
for (uframe = 0; uframe < 7; uframe++) { for (uframe = 0; uframe < 7; uframe++) {
claimed = periodic_usecs(fotg210, frame, claimed = periodic_usecs(fotg210, frame,
uframe); uframe);
if (claimed > usecs) if (claimed > usecs)
return 0; return 0;
} }
...@@ -3872,16 +3736,11 @@ static int check_period( ...@@ -3872,16 +3736,11 @@ static int check_period(
return 1; return 1;
} }
static int check_intr_schedule( static int check_intr_schedule(struct fotg210_hcd *fotg210, unsigned frame,
struct fotg210_hcd *fotg210, unsigned uframe, const struct fotg210_qh *qh, __hc32 *c_maskp)
unsigned frame,
unsigned uframe,
const struct fotg210_qh *qh,
__hc32 *c_maskp
)
{ {
int retval = -ENOSPC; int retval = -ENOSPC;
u8 mask = 0; u8 mask = 0;
if (qh->c_usecs && uframe >= 6) /* FSTN territory? */ if (qh->c_usecs && uframe >= 6) /* FSTN territory? */
goto done; goto done;
...@@ -3907,10 +3766,10 @@ static int check_intr_schedule( ...@@ -3907,10 +3766,10 @@ static int check_intr_schedule(
mask |= 1 << uframe; mask |= 1 << uframe;
if (tt_no_collision(fotg210, qh->period, qh->dev, frame, mask)) { if (tt_no_collision(fotg210, qh->period, qh->dev, frame, mask)) {
if (!check_period(fotg210, frame, uframe + qh->gap_uf + 1, if (!check_period(fotg210, frame, uframe + qh->gap_uf + 1,
qh->period, qh->c_usecs)) qh->period, qh->c_usecs))
goto done; goto done;
if (!check_period(fotg210, frame, uframe + qh->gap_uf, if (!check_period(fotg210, frame, uframe + qh->gap_uf,
qh->period, qh->c_usecs)) qh->period, qh->c_usecs))
goto done; goto done;
retval = 0; retval = 0;
} }
...@@ -3923,11 +3782,11 @@ static int check_intr_schedule( ...@@ -3923,11 +3782,11 @@ static int check_intr_schedule(
*/ */
static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
int status; int status;
unsigned uframe; unsigned uframe;
__hc32 c_mask; __hc32 c_mask;
unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */ unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
qh_refresh(fotg210, qh); qh_refresh(fotg210, qh);
hw->hw_next = FOTG210_LIST_END(fotg210); hw->hw_next = FOTG210_LIST_END(fotg210);
...@@ -3950,7 +3809,7 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3950,7 +3809,7 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
if (status) { if (status) {
/* "normal" case, uframing flexible except with splits */ /* "normal" case, uframing flexible except with splits */
if (qh->period) { if (qh->period) {
int i; int i;
for (i = qh->period; status && i > 0; --i) { for (i = qh->period; status && i > 0; --i) {
frame = ++fotg210->random_frame % qh->period; frame = ++fotg210->random_frame % qh->period;
...@@ -3967,7 +3826,7 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3967,7 +3826,7 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
} else { } else {
frame = 0; frame = 0;
status = check_intr_schedule(fotg210, 0, 0, qh, status = check_intr_schedule(fotg210, 0, 0, qh,
&c_mask); &c_mask);
} }
if (status) if (status)
goto done; goto done;
...@@ -3988,17 +3847,14 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3988,17 +3847,14 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
return status; return status;
} }
static int intr_submit( static int intr_submit(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, struct list_head *qtd_list, gfp_t mem_flags)
struct urb *urb, {
struct list_head *qtd_list, unsigned epnum;
gfp_t mem_flags unsigned long flags;
) { struct fotg210_qh *qh;
unsigned epnum; int status;
unsigned long flags; struct list_head empty;
struct fotg210_qh *qh;
int status;
struct list_head empty;
/* get endpoint and transfer/schedule data */ /* get endpoint and transfer/schedule data */
epnum = urb->ep->desc.bEndpointAddress; epnum = urb->ep->desc.bEndpointAddress;
...@@ -4046,11 +3902,11 @@ static int intr_submit( ...@@ -4046,11 +3902,11 @@ static int intr_submit(
static void scan_intr(struct fotg210_hcd *fotg210) static void scan_intr(struct fotg210_hcd *fotg210)
{ {
struct fotg210_qh *qh; struct fotg210_qh *qh;
list_for_each_entry_safe(qh, fotg210->qh_scan_next, list_for_each_entry_safe(qh, fotg210->qh_scan_next,
&fotg210->intr_qh_list, intr_node) { &fotg210->intr_qh_list, intr_node) {
rescan: rescan:
/* clean any finished work for this qh */ /* clean any finished work for this qh */
if (!list_empty(&qh->qtd_list)) { if (!list_empty(&qh->qtd_list)) {
int temp; int temp;
...@@ -4065,7 +3921,7 @@ static void scan_intr(struct fotg210_hcd *fotg210) ...@@ -4065,7 +3921,7 @@ static void scan_intr(struct fotg210_hcd *fotg210)
temp = qh_completions(fotg210, qh); temp = qh_completions(fotg210, qh);
if (unlikely(qh->needs_rescan || if (unlikely(qh->needs_rescan ||
(list_empty(&qh->qtd_list) && (list_empty(&qh->qtd_list) &&
qh->qh_state == QH_STATE_LINKED))) qh->qh_state == QH_STATE_LINKED)))
start_unlink_intr(fotg210, qh); start_unlink_intr(fotg210, qh);
else if (temp != 0) else if (temp != 0)
goto rescan; goto rescan;
...@@ -4073,12 +3929,9 @@ static void scan_intr(struct fotg210_hcd *fotg210) ...@@ -4073,12 +3929,9 @@ static void scan_intr(struct fotg210_hcd *fotg210)
} }
} }
/*-------------------------------------------------------------------------*/
/* fotg210_iso_stream ops work with both ITD and SITD */ /* fotg210_iso_stream ops work with both ITD and SITD */
static struct fotg210_iso_stream * static struct fotg210_iso_stream *iso_stream_alloc(gfp_t mem_flags)
iso_stream_alloc(gfp_t mem_flags)
{ {
struct fotg210_iso_stream *stream; struct fotg210_iso_stream *stream;
...@@ -4091,20 +3944,15 @@ iso_stream_alloc(gfp_t mem_flags) ...@@ -4091,20 +3944,15 @@ iso_stream_alloc(gfp_t mem_flags)
return stream; return stream;
} }
static void static void iso_stream_init(struct fotg210_hcd *fotg210,
iso_stream_init( struct fotg210_iso_stream *stream, struct usb_device *dev,
struct fotg210_hcd *fotg210, int pipe, unsigned interval)
struct fotg210_iso_stream *stream,
struct usb_device *dev,
int pipe,
unsigned interval
)
{ {
u32 buf1; u32 buf1;
unsigned epnum, maxp; unsigned epnum, maxp;
int is_input; int is_input;
long bandwidth; long bandwidth;
unsigned multi; unsigned multi;
/* /*
* this might be a "high bandwidth" highspeed endpoint, * this might be a "high bandwidth" highspeed endpoint,
...@@ -4149,13 +3997,13 @@ iso_stream_init( ...@@ -4149,13 +3997,13 @@ iso_stream_init(
stream->maxp = maxp; stream->maxp = maxp;
} }
static struct fotg210_iso_stream * static struct fotg210_iso_stream *iso_stream_find(struct fotg210_hcd *fotg210,
iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) struct urb *urb)
{ {
unsigned epnum; unsigned epnum;
struct fotg210_iso_stream *stream; struct fotg210_iso_stream *stream;
struct usb_host_endpoint *ep; struct usb_host_endpoint *ep;
unsigned long flags; unsigned long flags;
epnum = usb_pipeendpoint(urb->pipe); epnum = usb_pipeendpoint(urb->pipe);
if (usb_pipein(urb->pipe)) if (usb_pipein(urb->pipe))
...@@ -4178,8 +4026,8 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) ...@@ -4178,8 +4026,8 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb)
/* if dev->ep[epnum] is a QH, hw is set */ /* if dev->ep[epnum] is a QH, hw is set */
} else if (unlikely(stream->hw != NULL)) { } else if (unlikely(stream->hw != NULL)) {
fotg210_dbg(fotg210, "dev %s ep%d%s, not iso??\n", fotg210_dbg(fotg210, "dev %s ep%d%s, not iso??\n",
urb->dev->devpath, epnum, urb->dev->devpath, epnum,
usb_pipein(urb->pipe) ? "in" : "out"); usb_pipein(urb->pipe) ? "in" : "out");
stream = NULL; stream = NULL;
} }
...@@ -4187,15 +4035,13 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) ...@@ -4187,15 +4035,13 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb)
return stream; return stream;
} }
/*-------------------------------------------------------------------------*/
/* fotg210_iso_sched ops can be ITD-only or SITD-only */ /* fotg210_iso_sched ops can be ITD-only or SITD-only */
static struct fotg210_iso_sched * static struct fotg210_iso_sched *iso_sched_alloc(unsigned packets,
iso_sched_alloc(unsigned packets, gfp_t mem_flags) gfp_t mem_flags)
{ {
struct fotg210_iso_sched *iso_sched; struct fotg210_iso_sched *iso_sched;
int size = sizeof(*iso_sched); int size = sizeof(*iso_sched);
size += packets * sizeof(struct fotg210_iso_packet); size += packets * sizeof(struct fotg210_iso_packet);
iso_sched = kzalloc(size, mem_flags); iso_sched = kzalloc(size, mem_flags);
...@@ -4205,16 +4051,12 @@ iso_sched_alloc(unsigned packets, gfp_t mem_flags) ...@@ -4205,16 +4051,12 @@ iso_sched_alloc(unsigned packets, gfp_t mem_flags)
return iso_sched; return iso_sched;
} }
static inline void static inline void itd_sched_init(struct fotg210_hcd *fotg210,
itd_sched_init( struct fotg210_iso_sched *iso_sched,
struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream, struct urb *urb)
struct fotg210_iso_sched *iso_sched,
struct fotg210_iso_stream *stream,
struct urb *urb
)
{ {
unsigned i; unsigned i;
dma_addr_t dma = urb->transfer_dma; dma_addr_t dma = urb->transfer_dma;
/* how many uframes are needed for these transfers */ /* how many uframes are needed for these transfers */
iso_sched->span = urb->number_of_packets * stream->interval; iso_sched->span = urb->number_of_packets * stream->interval;
...@@ -4223,10 +4065,10 @@ itd_sched_init( ...@@ -4223,10 +4065,10 @@ itd_sched_init(
* when we fit new itds into the schedule. * when we fit new itds into the schedule.
*/ */
for (i = 0; i < urb->number_of_packets; i++) { for (i = 0; i < urb->number_of_packets; i++) {
struct fotg210_iso_packet *uframe = &iso_sched->packet[i]; struct fotg210_iso_packet *uframe = &iso_sched->packet[i];
unsigned length; unsigned length;
dma_addr_t buf; dma_addr_t buf;
u32 trans; u32 trans;
length = urb->iso_frame_desc[i].length; length = urb->iso_frame_desc[i].length;
buf = dma + urb->iso_frame_desc[i].offset; buf = dma + urb->iso_frame_desc[i].offset;
...@@ -4247,11 +4089,8 @@ itd_sched_init( ...@@ -4247,11 +4089,8 @@ itd_sched_init(
} }
} }
static void static void iso_sched_free(struct fotg210_iso_stream *stream,
iso_sched_free( struct fotg210_iso_sched *iso_sched)
struct fotg210_iso_stream *stream,
struct fotg210_iso_sched *iso_sched
)
{ {
if (!iso_sched) if (!iso_sched)
return; return;
...@@ -4260,20 +4099,15 @@ iso_sched_free( ...@@ -4260,20 +4099,15 @@ iso_sched_free(
kfree(iso_sched); kfree(iso_sched);
} }
static int static int itd_urb_transaction(struct fotg210_iso_stream *stream,
itd_urb_transaction( struct fotg210_hcd *fotg210, struct urb *urb, gfp_t mem_flags)
struct fotg210_iso_stream *stream,
struct fotg210_hcd *fotg210,
struct urb *urb,
gfp_t mem_flags
)
{ {
struct fotg210_itd *itd; struct fotg210_itd *itd;
dma_addr_t itd_dma; dma_addr_t itd_dma;
int i; int i;
unsigned num_itds; unsigned num_itds;
struct fotg210_iso_sched *sched; struct fotg210_iso_sched *sched;
unsigned long flags; unsigned long flags;
sched = iso_sched_alloc(urb->number_of_packets, mem_flags); sched = iso_sched_alloc(urb->number_of_packets, mem_flags);
if (unlikely(sched == NULL)) if (unlikely(sched == NULL))
...@@ -4302,7 +4136,7 @@ itd_urb_transaction( ...@@ -4302,7 +4136,7 @@ itd_urb_transaction(
list_del(&itd->itd_list); list_del(&itd->itd_list);
itd_dma = itd->itd_dma; itd_dma = itd->itd_dma;
} else { } else {
alloc_itd: alloc_itd:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
itd = dma_pool_alloc(fotg210->itd_pool, mem_flags, itd = dma_pool_alloc(fotg210->itd_pool, mem_flags,
&itd_dma); &itd_dma);
...@@ -4326,16 +4160,8 @@ itd_urb_transaction( ...@@ -4326,16 +4160,8 @@ itd_urb_transaction(
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/ static inline int itd_slot_ok(struct fotg210_hcd *fotg210, u32 mod, u32 uframe,
u8 usecs, u32 period)
static inline int
itd_slot_ok(
struct fotg210_hcd *fotg210,
u32 mod,
u32 uframe,
u8 usecs,
u32 period
)
{ {
uframe %= period; uframe %= period;
do { do {
...@@ -4350,8 +4176,7 @@ itd_slot_ok( ...@@ -4350,8 +4176,7 @@ itd_slot_ok(
return 1; return 1;
} }
/* /* This scheduler plans almost as far into the future as it has actual
* This scheduler plans almost as far into the future as it has actual
* periodic schedule slots. (Affected by TUNE_FLS, which defaults to * periodic schedule slots. (Affected by TUNE_FLS, which defaults to
* "as small as possible" to be cache-friendlier.) That limits the size * "as small as possible" to be cache-friendlier.) That limits the size
* transfers you can stream reliably; avoid more than 64 msec per urb. * transfers you can stream reliably; avoid more than 64 msec per urb.
...@@ -4361,19 +4186,15 @@ itd_slot_ok( ...@@ -4361,19 +4186,15 @@ itd_slot_ok(
* given FOTG210_TUNE_FLS and the slop). Or, write a smarter scheduler! * given FOTG210_TUNE_FLS and the slop). Or, write a smarter scheduler!
*/ */
#define SCHEDULE_SLOP 80 /* microframes */ #define SCHEDULE_SLOP 80 /* microframes */
static int static int iso_stream_schedule(struct fotg210_hcd *fotg210, struct urb *urb,
iso_stream_schedule( struct fotg210_iso_stream *stream)
struct fotg210_hcd *fotg210,
struct urb *urb,
struct fotg210_iso_stream *stream
)
{ {
u32 now, next, start, period, span; u32 now, next, start, period, span;
int status; int status;
unsigned mod = fotg210->periodic_size << 3; unsigned mod = fotg210->periodic_size << 3;
struct fotg210_iso_sched *sched = urb->hcpriv; struct fotg210_iso_sched *sched = urb->hcpriv;
period = urb->interval; period = urb->interval;
span = sched->span; span = sched->span;
...@@ -4392,7 +4213,7 @@ iso_stream_schedule( ...@@ -4392,7 +4213,7 @@ iso_stream_schedule(
* slot in the schedule, implicitly assuming URB_ISO_ASAP. * slot in the schedule, implicitly assuming URB_ISO_ASAP.
*/ */
if (likely(!list_empty(&stream->td_list))) { if (likely(!list_empty(&stream->td_list))) {
u32 excess; u32 excess;
/* For high speed devices, allow scheduling within the /* For high speed devices, allow scheduling within the
* isochronous scheduling threshold. For full speed devices * isochronous scheduling threshold. For full speed devices
...@@ -4431,6 +4252,7 @@ iso_stream_schedule( ...@@ -4431,6 +4252,7 @@ iso_stream_schedule(
*/ */
else { else {
int done = 0; int done = 0;
start = SCHEDULE_SLOP + (now & ~0x07); start = SCHEDULE_SLOP + (now & ~0x07);
/* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */
...@@ -4453,15 +4275,15 @@ iso_stream_schedule( ...@@ -4453,15 +4275,15 @@ iso_stream_schedule(
/* no room in the schedule */ /* no room in the schedule */
if (!done) { if (!done) {
fotg210_dbg(fotg210, "iso resched full %p (now %d max %d)\n", fotg210_dbg(fotg210, "iso resched full %p (now %d max %d)\n",
urb, now, now + mod); urb, now, now + mod);
status = -ENOSPC; status = -ENOSPC;
goto fail; goto fail;
} }
} }
/* Tried to schedule too far into the future? */ /* Tried to schedule too far into the future? */
if (unlikely(start - now + span - period if (unlikely(start - now + span - period >=
>= mod - 2 * SCHEDULE_SLOP)) { mod - 2 * SCHEDULE_SLOP)) {
fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n", fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n",
urb, start - now, span - period, urb, start - now, span - period,
mod - 2 * SCHEDULE_SLOP); mod - 2 * SCHEDULE_SLOP);
...@@ -4481,17 +4303,14 @@ iso_stream_schedule( ...@@ -4481,17 +4303,14 @@ iso_stream_schedule(
fotg210->next_frame = now >> 3; fotg210->next_frame = now >> 3;
return 0; return 0;
fail: fail:
iso_sched_free(stream, sched); iso_sched_free(stream, sched);
urb->hcpriv = NULL; urb->hcpriv = NULL;
return status; return status;
} }
/*-------------------------------------------------------------------------*/ static inline void itd_init(struct fotg210_hcd *fotg210,
struct fotg210_iso_stream *stream, struct fotg210_itd *itd)
static inline void
itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream,
struct fotg210_itd *itd)
{ {
int i; int i;
...@@ -4507,17 +4326,12 @@ itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream, ...@@ -4507,17 +4326,12 @@ itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream,
/* All other fields are filled when scheduling */ /* All other fields are filled when scheduling */
} }
static inline void static inline void itd_patch(struct fotg210_hcd *fotg210,
itd_patch( struct fotg210_itd *itd, struct fotg210_iso_sched *iso_sched,
struct fotg210_hcd *fotg210, unsigned index, u16 uframe)
struct fotg210_itd *itd,
struct fotg210_iso_sched *iso_sched,
unsigned index,
u16 uframe
)
{ {
struct fotg210_iso_packet *uf = &iso_sched->packet[index]; struct fotg210_iso_packet *uf = &iso_sched->packet[index];
unsigned pg = itd->pg; unsigned pg = itd->pg;
uframe &= 0x07; uframe &= 0x07;
itd->index[uframe] = index; itd->index[uframe] = index;
...@@ -4529,7 +4343,7 @@ itd_patch( ...@@ -4529,7 +4343,7 @@ itd_patch(
/* iso_frame_desc[].offset must be strictly increasing */ /* iso_frame_desc[].offset must be strictly increasing */
if (unlikely(uf->cross)) { if (unlikely(uf->cross)) {
u64 bufp = uf->bufp + 4096; u64 bufp = uf->bufp + 4096;
itd->pg = ++pg; itd->pg = ++pg;
itd->hw_bufp[pg] |= cpu_to_hc32(fotg210, bufp & ~(u32)0); itd->hw_bufp[pg] |= cpu_to_hc32(fotg210, bufp & ~(u32)0);
...@@ -4537,13 +4351,13 @@ itd_patch( ...@@ -4537,13 +4351,13 @@ itd_patch(
} }
} }
static inline void static inline void itd_link(struct fotg210_hcd *fotg210, unsigned frame,
itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd) struct fotg210_itd *itd)
{ {
union fotg210_shadow *prev = &fotg210->pshadow[frame]; union fotg210_shadow *prev = &fotg210->pshadow[frame];
__hc32 *hw_p = &fotg210->periodic[frame]; __hc32 *hw_p = &fotg210->periodic[frame];
union fotg210_shadow here = *prev; union fotg210_shadow here = *prev;
__hc32 type = 0; __hc32 type = 0;
/* skip any iso nodes which might belong to previous microframes */ /* skip any iso nodes which might belong to previous microframes */
while (here.ptr) { while (here.ptr) {
...@@ -4564,17 +4378,13 @@ itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd) ...@@ -4564,17 +4378,13 @@ itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd)
} }
/* fit urb's itds into the selected schedule slot; activate as needed */ /* fit urb's itds into the selected schedule slot; activate as needed */
static void itd_link_urb( static void itd_link_urb(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, unsigned mod, struct fotg210_iso_stream *stream)
struct urb *urb, {
unsigned mod, int packet;
struct fotg210_iso_stream *stream unsigned next_uframe, uframe, frame;
) struct fotg210_iso_sched *iso_sched = urb->hcpriv;
{ struct fotg210_itd *itd;
int packet;
unsigned next_uframe, uframe, frame;
struct fotg210_iso_sched *iso_sched = urb->hcpriv;
struct fotg210_itd *itd;
next_uframe = stream->next_uframe & (mod - 1); next_uframe = stream->next_uframe & (mod - 1);
...@@ -4617,7 +4427,7 @@ static void itd_link_urb( ...@@ -4617,7 +4427,7 @@ static void itd_link_urb(
if (((next_uframe >> 3) != frame) if (((next_uframe >> 3) != frame)
|| packet == urb->number_of_packets) { || packet == urb->number_of_packets) {
itd_link(fotg210, frame & (fotg210->periodic_size - 1), itd_link(fotg210, frame & (fotg210->periodic_size - 1),
itd); itd);
itd = NULL; itd = NULL;
} }
} }
...@@ -4631,8 +4441,8 @@ static void itd_link_urb( ...@@ -4631,8 +4441,8 @@ static void itd_link_urb(
enable_periodic(fotg210); enable_periodic(fotg210);
} }
#define ISO_ERRS (FOTG210_ISOC_BUF_ERR | FOTG210_ISOC_BABBLE |\ #define ISO_ERRS (FOTG210_ISOC_BUF_ERR | FOTG210_ISOC_BABBLE |\
FOTG210_ISOC_XACTERR) FOTG210_ISOC_XACTERR)
/* Process and recycle a completed ITD. Return true iff its urb completed, /* Process and recycle a completed ITD. Return true iff its urb completed,
* and hence its completion callback probably added things to the hardware * and hence its completion callback probably added things to the hardware
...@@ -4646,14 +4456,14 @@ static void itd_link_urb( ...@@ -4646,14 +4456,14 @@ static void itd_link_urb(
*/ */
static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
{ {
struct urb *urb = itd->urb; struct urb *urb = itd->urb;
struct usb_iso_packet_descriptor *desc; struct usb_iso_packet_descriptor *desc;
u32 t; u32 t;
unsigned uframe; unsigned uframe;
int urb_index = -1; int urb_index = -1;
struct fotg210_iso_stream *stream = itd->stream; struct fotg210_iso_stream *stream = itd->stream;
struct usb_device *dev; struct usb_device *dev;
bool retval = false; bool retval = false;
/* for each uframe with a packet */ /* for each uframe with a packet */
for (uframe = 0; uframe < 8; uframe++) { for (uframe = 0; uframe < 8; uframe++) {
...@@ -4698,8 +4508,8 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -4698,8 +4508,8 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
goto done; goto done;
/* ASSERT: it's really the last itd for this urb /* ASSERT: it's really the last itd for this urb
list_for_each_entry (itd, &stream->td_list, itd_list) * list_for_each_entry (itd, &stream->td_list, itd_list)
BUG_ON (itd->urb == urb); * BUG_ON (itd->urb == urb);
*/ */
/* give urb back to the driver; completion often (re)submits */ /* give urb back to the driver; completion often (re)submits */
...@@ -4736,14 +4546,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -4736,14 +4546,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
return retval; return retval;
} }
/*-------------------------------------------------------------------------*/
static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
gfp_t mem_flags) gfp_t mem_flags)
{ {
int status = -EINVAL; int status = -EINVAL;
unsigned long flags; unsigned long flags;
struct fotg210_iso_stream *stream; struct fotg210_iso_stream *stream;
/* Get iso_stream head */ /* Get iso_stream head */
stream = iso_stream_find(fotg210, urb); stream = iso_stream_find(fotg210, urb);
...@@ -4752,22 +4560,22 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, ...@@ -4752,22 +4560,22 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
return -ENOMEM; return -ENOMEM;
} }
if (unlikely(urb->interval != stream->interval && if (unlikely(urb->interval != stream->interval &&
fotg210_port_speed(fotg210, 0) == fotg210_port_speed(fotg210, 0) ==
USB_PORT_STAT_HIGH_SPEED)) { USB_PORT_STAT_HIGH_SPEED)) {
fotg210_dbg(fotg210, "can't change iso interval %d --> %d\n", fotg210_dbg(fotg210, "can't change iso interval %d --> %d\n",
stream->interval, urb->interval); stream->interval, urb->interval);
goto done; goto done;
} }
#ifdef FOTG210_URB_TRACE #ifdef FOTG210_URB_TRACE
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"%s %s urb %p ep%d%s len %d, %d pkts %d uframes[%p]\n", "%s %s urb %p ep%d%s len %d, %d pkts %d uframes[%p]\n",
__func__, urb->dev->devpath, urb, __func__, urb->dev->devpath, urb,
usb_pipeendpoint(urb->pipe), usb_pipeendpoint(urb->pipe),
usb_pipein(urb->pipe) ? "in" : "out", usb_pipein(urb->pipe) ? "in" : "out",
urb->transfer_buffer_length, urb->transfer_buffer_length,
urb->number_of_packets, urb->interval, urb->number_of_packets, urb->interval,
stream); stream);
#endif #endif
/* allocate ITDs w/o locking anything */ /* allocate ITDs w/o locking anything */
...@@ -4791,9 +4599,9 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, ...@@ -4791,9 +4599,9 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
itd_link_urb(fotg210, urb, fotg210->periodic_size << 3, stream); itd_link_urb(fotg210, urb, fotg210->periodic_size << 3, stream);
else else
usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb);
done_not_linked: done_not_linked:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
done: done:
return status; return status;
} }
...@@ -4872,7 +4680,7 @@ static void scan_isoc(struct fotg210_hcd *fotg210) ...@@ -4872,7 +4680,7 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
break; break;
default: default:
fotg210_dbg(fotg210, "corrupt type %d frame %d shadow %p\n", fotg210_dbg(fotg210, "corrupt type %d frame %d shadow %p\n",
type, frame, q.ptr); type, frame, q.ptr);
/* FALL THROUGH */ /* FALL THROUGH */
case Q_TYPE_QH: case Q_TYPE_QH:
case Q_TYPE_FSTN: case Q_TYPE_FSTN:
...@@ -4893,16 +4701,14 @@ static void scan_isoc(struct fotg210_hcd *fotg210) ...@@ -4893,16 +4701,14 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
} }
fotg210->next_frame = now_frame; fotg210->next_frame = now_frame;
} }
/*-------------------------------------------------------------------------*/
/* /* Display / Set uframe_periodic_max
* Display / Set uframe_periodic_max
*/ */
static ssize_t show_uframe_periodic_max(struct device *dev, static ssize_t show_uframe_periodic_max(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, char *buf)
char *buf)
{ {
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
int n; int n;
fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev))); fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev)));
n = scnprintf(buf, PAGE_SIZE, "%d\n", fotg210->uframe_periodic_max); n = scnprintf(buf, PAGE_SIZE, "%d\n", fotg210->uframe_periodic_max);
...@@ -4911,15 +4717,14 @@ static ssize_t show_uframe_periodic_max(struct device *dev, ...@@ -4911,15 +4717,14 @@ static ssize_t show_uframe_periodic_max(struct device *dev,
static ssize_t store_uframe_periodic_max(struct device *dev, static ssize_t store_uframe_periodic_max(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, const char *buf, size_t count)
const char *buf, size_t count)
{ {
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
unsigned uframe_periodic_max; unsigned uframe_periodic_max;
unsigned frame, uframe; unsigned frame, uframe;
unsigned short allocated_max; unsigned short allocated_max;
unsigned long flags; unsigned long flags;
ssize_t ret; ssize_t ret;
fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev))); fotg210 = hcd_to_fotg210(bus_to_hcd(dev_get_drvdata(dev)));
if (kstrtouint(buf, 0, &uframe_periodic_max) < 0) if (kstrtouint(buf, 0, &uframe_periodic_max) < 0)
...@@ -4927,7 +4732,7 @@ static ssize_t store_uframe_periodic_max(struct device *dev, ...@@ -4927,7 +4732,7 @@ static ssize_t store_uframe_periodic_max(struct device *dev,
if (uframe_periodic_max < 100 || uframe_periodic_max >= 125) { if (uframe_periodic_max < 100 || uframe_periodic_max >= 125) {
fotg210_info(fotg210, "rejecting invalid request for uframe_periodic_max=%u\n", fotg210_info(fotg210, "rejecting invalid request for uframe_periodic_max=%u\n",
uframe_periodic_max); uframe_periodic_max);
return -EINVAL; return -EINVAL;
} }
...@@ -4950,22 +4755,22 @@ static ssize_t store_uframe_periodic_max(struct device *dev, ...@@ -4950,22 +4755,22 @@ static ssize_t store_uframe_periodic_max(struct device *dev,
for (frame = 0; frame < fotg210->periodic_size; ++frame) for (frame = 0; frame < fotg210->periodic_size; ++frame)
for (uframe = 0; uframe < 7; ++uframe) for (uframe = 0; uframe < 7; ++uframe)
allocated_max = max(allocated_max, allocated_max = max(allocated_max,
periodic_usecs(fotg210, frame, uframe)); periodic_usecs(fotg210, frame,
uframe));
if (allocated_max > uframe_periodic_max) { if (allocated_max > uframe_periodic_max) {
fotg210_info(fotg210, fotg210_info(fotg210,
"cannot decrease uframe_periodic_max because " "cannot decrease uframe_periodic_max because periodic bandwidth is already allocated (%u > %u)\n",
"periodic bandwidth is already allocated " allocated_max, uframe_periodic_max);
"(%u > %u)\n",
allocated_max, uframe_periodic_max);
goto out_unlock; goto out_unlock;
} }
} }
/* increasing is always ok */ /* increasing is always ok */
fotg210_info(fotg210, "setting max periodic bandwidth to %u%% (== %u usec/uframe)\n", fotg210_info(fotg210,
100 * uframe_periodic_max/125, uframe_periodic_max); "setting max periodic bandwidth to %u%% (== %u usec/uframe)\n",
100 * uframe_periodic_max/125, uframe_periodic_max);
if (uframe_periodic_max != 100) if (uframe_periodic_max != 100)
fotg210_warn(fotg210, "max periodic bandwidth set is non-standard\n"); fotg210_warn(fotg210, "max periodic bandwidth set is non-standard\n");
...@@ -4983,8 +4788,8 @@ static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max, ...@@ -4983,8 +4788,8 @@ static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max,
static inline int create_sysfs_files(struct fotg210_hcd *fotg210) static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
{ {
struct device *controller = fotg210_to_hcd(fotg210)->self.controller; struct device *controller = fotg210_to_hcd(fotg210)->self.controller;
int i = 0; int i = 0;
if (i) if (i)
goto out; goto out;
...@@ -4996,12 +4801,10 @@ static inline int create_sysfs_files(struct fotg210_hcd *fotg210) ...@@ -4996,12 +4801,10 @@ static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
static inline void remove_sysfs_files(struct fotg210_hcd *fotg210) static inline void remove_sysfs_files(struct fotg210_hcd *fotg210)
{ {
struct device *controller = fotg210_to_hcd(fotg210)->self.controller; struct device *controller = fotg210_to_hcd(fotg210)->self.controller;
device_remove_file(controller, &dev_attr_uframe_periodic_max); device_remove_file(controller, &dev_attr_uframe_periodic_max);
} }
/*-------------------------------------------------------------------------*/
/* On some systems, leaving remote wakeup enabled prevents system shutdown. /* On some systems, leaving remote wakeup enabled prevents system shutdown.
* The firmware seems to think that powering off is a wakeup event! * The firmware seems to think that powering off is a wakeup event!
* This routine turns off remote wakeup and everything else, on all ports. * This routine turns off remote wakeup and everything else, on all ports.
...@@ -5013,8 +4816,7 @@ static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210) ...@@ -5013,8 +4816,7 @@ static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210)
fotg210_writel(fotg210, PORT_RWC_BITS, status_reg); fotg210_writel(fotg210, PORT_RWC_BITS, status_reg);
} }
/* /* Halt HC, turn off all ports, and let the BIOS use the companion controllers.
* Halt HC, turn off all ports, and let the BIOS use the companion controllers.
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static void fotg210_silence_controller(struct fotg210_hcd *fotg210) static void fotg210_silence_controller(struct fotg210_hcd *fotg210)
...@@ -5033,7 +4835,7 @@ static void fotg210_silence_controller(struct fotg210_hcd *fotg210) ...@@ -5033,7 +4835,7 @@ static void fotg210_silence_controller(struct fotg210_hcd *fotg210)
*/ */
static void fotg210_shutdown(struct usb_hcd *hcd) static void fotg210_shutdown(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
spin_lock_irq(&fotg210->lock); spin_lock_irq(&fotg210->lock);
fotg210->shutdown = true; fotg210->shutdown = true;
...@@ -5046,10 +4848,7 @@ static void fotg210_shutdown(struct usb_hcd *hcd) ...@@ -5046,10 +4848,7 @@ static void fotg210_shutdown(struct usb_hcd *hcd)
hrtimer_cancel(&fotg210->hrtimer); hrtimer_cancel(&fotg210->hrtimer);
} }
/*-------------------------------------------------------------------------*/ /* fotg210_work is called from some interrupts, timers, and so on.
/*
* fotg210_work is called from some interrupts, timers, and so on.
* it calls driver completion functions, after dropping fotg210->lock. * it calls driver completion functions, after dropping fotg210->lock.
*/ */
static void fotg210_work(struct fotg210_hcd *fotg210) static void fotg210_work(struct fotg210_hcd *fotg210)
...@@ -5064,7 +4863,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210) ...@@ -5064,7 +4863,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210)
} }
fotg210->scanning = true; fotg210->scanning = true;
rescan: rescan:
fotg210->need_rescan = false; fotg210->need_rescan = false;
if (fotg210->async_count) if (fotg210->async_count)
scan_async(fotg210); scan_async(fotg210);
...@@ -5083,12 +4882,11 @@ static void fotg210_work(struct fotg210_hcd *fotg210) ...@@ -5083,12 +4882,11 @@ static void fotg210_work(struct fotg210_hcd *fotg210)
turn_on_io_watchdog(fotg210); turn_on_io_watchdog(fotg210);
} }
/* /* Called when the fotg210_hcd module is removed.
* Called when the fotg210_hcd module is removed.
*/ */
static void fotg210_stop(struct usb_hcd *hcd) static void fotg210_stop(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
fotg210_dbg(fotg210, "stop\n"); fotg210_dbg(fotg210, "stop\n");
...@@ -5112,26 +4910,26 @@ static void fotg210_stop(struct usb_hcd *hcd) ...@@ -5112,26 +4910,26 @@ static void fotg210_stop(struct usb_hcd *hcd)
spin_unlock_irq(&fotg210->lock); spin_unlock_irq(&fotg210->lock);
fotg210_mem_cleanup(fotg210); fotg210_mem_cleanup(fotg210);
#ifdef FOTG210_STATS #ifdef FOTG210_STATS
fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n", fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, fotg210->stats.normal, fotg210->stats.error,
fotg210->stats.lost_iaa); fotg210->stats.iaa, fotg210->stats.lost_iaa);
fotg210_dbg(fotg210, "complete %ld unlink %ld\n", fotg210_dbg(fotg210, "complete %ld unlink %ld\n",
fotg210->stats.complete, fotg210->stats.unlink); fotg210->stats.complete, fotg210->stats.unlink);
#endif #endif
dbg_status(fotg210, "fotg210_stop completed", dbg_status(fotg210, "fotg210_stop completed",
fotg210_readl(fotg210, &fotg210->regs->status)); fotg210_readl(fotg210, &fotg210->regs->status));
} }
/* one-time init, only for memory state */ /* one-time init, only for memory state */
static int hcd_fotg210_init(struct usb_hcd *hcd) static int hcd_fotg210_init(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u32 temp; u32 temp;
int retval; int retval;
u32 hcc_params; u32 hcc_params;
struct fotg210_qh_hw *hw; struct fotg210_qh_hw *hw;
spin_lock_init(&fotg210->lock); spin_lock_init(&fotg210->lock);
...@@ -5234,18 +5032,18 @@ static int hcd_fotg210_init(struct usb_hcd *hcd) ...@@ -5234,18 +5032,18 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
/* start HC running; it's halted, hcd_fotg210_init() has been run (once) */ /* start HC running; it's halted, hcd_fotg210_init() has been run (once) */
static int fotg210_run(struct usb_hcd *hcd) static int fotg210_run(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u32 temp; u32 temp;
u32 hcc_params; u32 hcc_params;
hcd->uses_new_polling = 1; hcd->uses_new_polling = 1;
/* EHCI spec section 4.1 */ /* EHCI spec section 4.1 */
fotg210_writel(fotg210, fotg210->periodic_dma, fotg210_writel(fotg210, fotg210->periodic_dma,
&fotg210->regs->frame_list); &fotg210->regs->frame_list);
fotg210_writel(fotg210, (u32)fotg210->async->qh_dma, fotg210_writel(fotg210, (u32)fotg210->async->qh_dma,
&fotg210->regs->async_next); &fotg210->regs->async_next);
/* /*
* hcc_params controls whether fotg210->regs->segment must (!!!) * hcc_params controls whether fotg210->regs->segment must (!!!)
...@@ -5293,14 +5091,14 @@ static int fotg210_run(struct usb_hcd *hcd) ...@@ -5293,14 +5091,14 @@ static int fotg210_run(struct usb_hcd *hcd)
fotg210->last_periodic_enable = ktime_get_real(); fotg210->last_periodic_enable = ktime_get_real();
temp = HC_VERSION(fotg210, temp = HC_VERSION(fotg210,
fotg210_readl(fotg210, &fotg210->caps->hc_capbase)); fotg210_readl(fotg210, &fotg210->caps->hc_capbase));
fotg210_info(fotg210, fotg210_info(fotg210,
"USB %x.%x started, EHCI %x.%02x\n", "USB %x.%x started, EHCI %x.%02x\n",
((fotg210->sbrn & 0xf0)>>4), (fotg210->sbrn & 0x0f), ((fotg210->sbrn & 0xf0) >> 4), (fotg210->sbrn & 0x0f),
temp >> 8, temp & 0xff); temp >> 8, temp & 0xff);
fotg210_writel(fotg210, INTR_MASK, fotg210_writel(fotg210, INTR_MASK,
&fotg210->regs->intr_enable); /* Turn On Interrupts */ &fotg210->regs->intr_enable); /* Turn On Interrupts */
/* GRR this is run-once init(), being done every time the HC starts. /* GRR this is run-once init(), being done every time the HC starts.
* So long as they're part of class devices, we can't do it init() * So long as they're part of class devices, we can't do it init()
...@@ -5318,14 +5116,14 @@ static int fotg210_setup(struct usb_hcd *hcd) ...@@ -5318,14 +5116,14 @@ static int fotg210_setup(struct usb_hcd *hcd)
int retval; int retval;
fotg210->regs = (void __iomem *)fotg210->caps + fotg210->regs = (void __iomem *)fotg210->caps +
HC_LENGTH(fotg210, HC_LENGTH(fotg210,
fotg210_readl(fotg210, &fotg210->caps->hc_capbase)); fotg210_readl(fotg210, &fotg210->caps->hc_capbase));
dbg_hcs_params(fotg210, "reset"); dbg_hcs_params(fotg210, "reset");
dbg_hcc_params(fotg210, "reset"); dbg_hcc_params(fotg210, "reset");
/* cache this readonly data; minimize chip reads */ /* cache this readonly data; minimize chip reads */
fotg210->hcs_params = fotg210_readl(fotg210, fotg210->hcs_params = fotg210_readl(fotg210,
&fotg210->caps->hcs_params); &fotg210->caps->hcs_params);
fotg210->sbrn = HCD_USB2; fotg210->sbrn = HCD_USB2;
...@@ -5343,13 +5141,11 @@ static int fotg210_setup(struct usb_hcd *hcd) ...@@ -5343,13 +5141,11 @@ static int fotg210_setup(struct usb_hcd *hcd)
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/
static irqreturn_t fotg210_irq(struct usb_hcd *hcd) static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u32 status, masked_status, pcd_status = 0, cmd; u32 status, masked_status, pcd_status = 0, cmd;
int bh; int bh;
spin_lock(&fotg210->lock); spin_lock(&fotg210->lock);
...@@ -5369,7 +5165,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5369,7 +5165,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
/* Shared IRQ? */ /* Shared IRQ? */
if (!masked_status || if (!masked_status ||
unlikely(fotg210->rh_state == FOTG210_RH_HALTED)) { unlikely(fotg210->rh_state == FOTG210_RH_HALTED)) {
spin_unlock(&fotg210->lock); spin_unlock(&fotg210->lock);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -5436,7 +5232,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5436,7 +5232,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
if (test_bit(0, &fotg210->suspended_ports) && if (test_bit(0, &fotg210->suspended_ports) &&
((pstatus & PORT_RESUME) || ((pstatus & PORT_RESUME) ||
!(pstatus & PORT_SUSPEND)) && !(pstatus & PORT_SUSPEND)) &&
(pstatus & PORT_PE) && (pstatus & PORT_PE) &&
fotg210->reset_done[0] == 0) { fotg210->reset_done[0] == 0) {
...@@ -5465,7 +5261,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5465,7 +5261,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
fotg210->rh_state = FOTG210_RH_STOPPING; fotg210->rh_state = FOTG210_RH_STOPPING;
fotg210->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE); fotg210->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE);
fotg210_writel(fotg210, fotg210->command, fotg210_writel(fotg210, fotg210->command,
&fotg210->regs->command); &fotg210->regs->command);
fotg210_writel(fotg210, 0, &fotg210->regs->intr_enable); fotg210_writel(fotg210, 0, &fotg210->regs->intr_enable);
fotg210_handle_controller_death(fotg210); fotg210_handle_controller_death(fotg210);
...@@ -5481,10 +5277,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5481,10 +5277,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/*-------------------------------------------------------------------------*/ /* non-error returns are a promise to giveback() the urb later
/*
* non-error returns are a promise to giveback() the urb later
* we drop ownership so next owner (or urb unlink) can get it * we drop ownership so next owner (or urb unlink) can get it
* *
* urb + dev is in hcd.self.controller.urb_list * urb + dev is in hcd.self.controller.urb_list
...@@ -5495,13 +5288,11 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5495,13 +5288,11 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
* NOTE: control, bulk, and interrupt share the same code to append TDs * NOTE: control, bulk, and interrupt share the same code to append TDs
* to a (possibly active) QH, and the same QH scanning code. * to a (possibly active) QH, and the same QH scanning code.
*/ */
static int fotg210_urb_enqueue( static int fotg210_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
struct usb_hcd *hcd, gfp_t mem_flags)
struct urb *urb, {
gfp_t mem_flags struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
) { struct list_head qtd_list;
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct list_head qtd_list;
INIT_LIST_HEAD(&qtd_list); INIT_LIST_HEAD(&qtd_list);
...@@ -5535,10 +5326,10 @@ static int fotg210_urb_enqueue( ...@@ -5535,10 +5326,10 @@ static int fotg210_urb_enqueue(
static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct fotg210_qh *qh; struct fotg210_qh *qh;
unsigned long flags; unsigned long flags;
int rc; int rc;
spin_lock_irqsave(&fotg210->lock, flags); spin_lock_irqsave(&fotg210->lock, flags);
rc = usb_hcd_check_unlink_urb(hcd, urb, status); rc = usb_hcd_check_unlink_urb(hcd, urb, status);
...@@ -5599,16 +5390,14 @@ static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -5599,16 +5390,14 @@ static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
return rc; return rc;
} }
/*-------------------------------------------------------------------------*/
/* bulk qh holds the data toggle */ /* bulk qh holds the data toggle */
static void static void fotg210_endpoint_disable(struct usb_hcd *hcd,
fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
unsigned long flags; unsigned long flags;
struct fotg210_qh *qh, *tmp; struct fotg210_qh *qh, *tmp;
/* ASSERT: any requests/urbs are being unlinked */ /* ASSERT: any requests/urbs are being unlinked */
/* ASSERT: nobody can be submitting urbs for this any more */ /* ASSERT: nobody can be submitting urbs for this any more */
...@@ -5623,7 +5412,7 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) ...@@ -5623,7 +5412,7 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
* accelerate iso completions ... so spin a while. * accelerate iso completions ... so spin a while.
*/ */
if (qh->hw == NULL) { if (qh->hw == NULL) {
struct fotg210_iso_stream *stream = ep->hcpriv; struct fotg210_iso_stream *stream = ep->hcpriv;
if (!list_empty(&stream->td_list)) if (!list_empty(&stream->td_list))
goto idle_timeout; goto idle_timeout;
...@@ -5667,24 +5456,24 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) ...@@ -5667,24 +5456,24 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
* that's not our job. just leak this memory. * that's not our job. just leak this memory.
*/ */
fotg210_err(fotg210, "qh %p (#%02x) state %d%s\n", fotg210_err(fotg210, "qh %p (#%02x) state %d%s\n",
qh, ep->desc.bEndpointAddress, qh->qh_state, qh, ep->desc.bEndpointAddress, qh->qh_state,
list_empty(&qh->qtd_list) ? "" : "(has tds)"); list_empty(&qh->qtd_list) ? "" : "(has tds)");
break; break;
} }
done: done:
ep->hcpriv = NULL; ep->hcpriv = NULL;
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
} }
static void static void fotg210_endpoint_reset(struct usb_hcd *hcd,
fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct fotg210_qh *qh; struct fotg210_qh *qh;
int eptype = usb_endpoint_type(&ep->desc); int eptype = usb_endpoint_type(&ep->desc);
int epnum = usb_endpoint_num(&ep->desc); int epnum = usb_endpoint_num(&ep->desc);
int is_out = usb_endpoint_dir_out(&ep->desc); int is_out = usb_endpoint_dir_out(&ep->desc);
unsigned long flags; unsigned long flags;
if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT) if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT)
return; return;
...@@ -5719,15 +5508,13 @@ fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) ...@@ -5719,15 +5508,13 @@ fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
static int fotg210_get_frame(struct usb_hcd *hcd) static int fotg210_get_frame(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
return (fotg210_read_frame_index(fotg210) >> 3) % return (fotg210_read_frame_index(fotg210) >> 3) %
fotg210->periodic_size; fotg210->periodic_size;
} }
/*-------------------------------------------------------------------------*/ /* The EHCI in ChipIdea HDRC cannot be a separate module or device,
/*
* The EHCI in ChipIdea HDRC cannot be a separate module or device,
* because its registers (and irq) are shared between host/gadget/otg * because its registers (and irq) are shared between host/gadget/otg
* functions and in order to facilitate role switching we cannot * functions and in order to facilitate role switching we cannot
* give the fotg210 driver exclusive access to those. * give the fotg210 driver exclusive access to those.
...@@ -5787,7 +5574,7 @@ static void fotg210_init(struct fotg210_hcd *fotg210) ...@@ -5787,7 +5574,7 @@ static void fotg210_init(struct fotg210_hcd *fotg210)
u32 value; u32 value;
iowrite32(GMIR_MDEV_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY, iowrite32(GMIR_MDEV_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY,
&fotg210->regs->gmir); &fotg210->regs->gmir);
value = ioread32(&fotg210->regs->otgcsr); value = ioread32(&fotg210->regs->otgcsr);
value &= ~OTGCSR_A_BUS_DROP; value &= ~OTGCSR_A_BUS_DROP;
...@@ -5804,12 +5591,12 @@ static void fotg210_init(struct fotg210_hcd *fotg210) ...@@ -5804,12 +5591,12 @@ static void fotg210_init(struct fotg210_hcd *fotg210)
*/ */
static int fotg210_hcd_probe(struct platform_device *pdev) static int fotg210_hcd_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct resource *res; struct resource *res;
int irq; int irq;
int retval = -ENODEV; int retval = -ENODEV;
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
if (usb_disabled()) if (usb_disabled())
return -ENODEV; return -ENODEV;
...@@ -5818,9 +5605,8 @@ static int fotg210_hcd_probe(struct platform_device *pdev) ...@@ -5818,9 +5605,8 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) { if (!res) {
dev_err(dev, dev_err(dev, "Found HC with no IRQ. Check %s setup!\n",
"Found HC with no IRQ. Check %s setup!\n", dev_name(dev));
dev_name(dev));
return -ENODEV; return -ENODEV;
} }
...@@ -5879,8 +5665,8 @@ static int fotg210_hcd_probe(struct platform_device *pdev) ...@@ -5879,8 +5665,8 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
*/ */
static int fotg210_hcd_remove(struct platform_device *pdev) static int fotg210_hcd_remove(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct usb_hcd *hcd = dev_get_drvdata(dev); struct usb_hcd *hcd = dev_get_drvdata(dev);
if (!hcd) if (!hcd)
return 0; return 0;
...@@ -5913,9 +5699,9 @@ static int __init fotg210_hcd_init(void) ...@@ -5913,9 +5699,9 @@ static int __init fotg210_hcd_init(void)
pr_warn(KERN_WARNING "Warning! fotg210_hcd should always be loaded before uhci_hcd and ohci_hcd, not after\n"); pr_warn(KERN_WARNING "Warning! fotg210_hcd should always be loaded before uhci_hcd and ohci_hcd, not after\n");
pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd\n", pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd\n",
hcd_name, hcd_name, sizeof(struct fotg210_qh),
sizeof(struct fotg210_qh), sizeof(struct fotg210_qtd), sizeof(struct fotg210_qtd),
sizeof(struct fotg210_itd)); sizeof(struct fotg210_itd));
fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root); fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root);
if (!fotg210_debug_root) { if (!fotg210_debug_root) {
......
...@@ -137,19 +137,25 @@ struct fotg210_hcd { /* one per controller */ ...@@ -137,19 +137,25 @@ struct fotg210_hcd { /* one per controller */
/* per root hub port */ /* per root hub port */
unsigned long reset_done[FOTG210_MAX_ROOT_PORTS]; unsigned long reset_done[FOTG210_MAX_ROOT_PORTS];
/* bit vectors (one bit per port) */ /* bit vectors (one bit per port)
unsigned long bus_suspended; /* which ports were * which ports were already suspended at the start of a bus suspend
already suspended at the start of a bus suspend */ */
unsigned long companion_ports; /* which ports are unsigned long bus_suspended;
dedicated to the companion controller */
unsigned long owned_ports; /* which ports are /* which ports are edicated to the companion controller */
owned by the companion during a bus suspend */ unsigned long companion_ports;
unsigned long port_c_suspend; /* which ports have
the change-suspend feature turned on */ /* which ports are owned by the companion during a bus suspend */
unsigned long suspended_ports; /* which ports are unsigned long owned_ports;
suspended */
unsigned long resuming_ports; /* which ports have /* which ports have the change-suspend feature turned on */
started to resume */ unsigned long port_c_suspend;
/* which ports are suspended */
unsigned long suspended_ports;
/* which ports have started to resume */
unsigned long resuming_ports;
/* per-HC memory pools (could be per-bus, but ...) */ /* per-HC memory pools (could be per-bus, but ...) */
struct dma_pool *qh_pool; /* qh per active urb */ struct dma_pool *qh_pool; /* qh per active urb */
...@@ -585,10 +591,10 @@ struct fotg210_fstn { ...@@ -585,10 +591,10 @@ struct fotg210_fstn {
/* Prepare the PORTSC wakeup flags during controller suspend/resume */ /* Prepare the PORTSC wakeup flags during controller suspend/resume */
#define fotg210_prepare_ports_for_controller_suspend(fotg210, do_wakeup) \ #define fotg210_prepare_ports_for_controller_suspend(fotg210, do_wakeup) \
fotg210_adjust_port_wakeup_flags(fotg210, true, do_wakeup); fotg210_adjust_port_wakeup_flags(fotg210, true, do_wakeup)
#define fotg210_prepare_ports_for_controller_resume(fotg210) \ #define fotg210_prepare_ports_for_controller_resume(fotg210) \
fotg210_adjust_port_wakeup_flags(fotg210, false, false); fotg210_adjust_port_wakeup_flags(fotg210, false, false)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册