2 #include <linux/device.h>
7 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
14 #include <linux/usb/ch9.h>
78 for (i = 0; i <
size; i++)
79 buf[i] = hw_read(ci, i *
sizeof(
u32), ~0);
102 hw_write(ci, addr, ~0, data);
113 static int hw_intr_clear(
struct ci13xxx *ci,
int n)
130 static int hw_intr_force(
struct ci13xxx *ci,
int n)
165 gadget_is_dualspeed(gadget));
177 (gadget->
name ? gadget->
name :
""));
196 dev_err(dev,
"[%s] EINVAL\n", __func__);
202 "There is no gadget attached!\n");
214 #define DBG_DATA_MSG 64UL
217 #define DBG_DATA_MAX 128UL
235 static void dbg_dec(
unsigned *
idx)
244 static void dbg_inc(
unsigned *idx)
265 stamp = tval.tv_sec & 0xFFFF;
266 stamp = stamp * 1000000 + tval.tv_usec;
269 "%04X\t? %02X %-7.7s %4i ?\t%s\n",
270 stamp, addr, name, status, extra);
272 dbg_inc(&dbg_data.idx);
276 if (dbg_data.tty != 0)
277 pr_notice(
"%04X\t? %02X %-7.7s %4i ?\t%s\n",
278 stamp, addr, name, status, extra);
293 (
int)(token &
TD_STATUS) >> ffs_nr(TD_STATUS));
294 dbg_print(addr,
"DONE", status, msg);
306 dbg_print(addr, name, status,
"");
322 dbg_print(addr,
"QUEUE", status, msg);
340 dbg_print(addr,
"SETUP", 0, msg);
353 unsigned i,
j, n = 0;
363 for (dbg_dec(&i); i != dbg_data.idx; dbg_dec(&i)) {
364 n +=
strlen(dbg_data.buf[i]);
366 n -=
strlen(dbg_data.buf[i]);
370 for (j = 0, dbg_inc(&i); j <
n; dbg_inc(&i))
372 "%s", dbg_data.buf[i]);
385 const char *buf,
size_t count)
390 dev_err(dev,
"[%s] EINVAL\n", __func__);
394 if (
sscanf(buf,
"%u", &tty) != 1 || tty > 1) {
395 dev_err(dev,
"<1|0>: enable|disable console log\n");
400 dev_info(dev,
"tty = %u", dbg_data.tty);
418 unsigned i,
j, n = 0;
474 spin_unlock_irqrestore(&ci->
lock, flags);
486 const char *buf,
size_t count)
497 if (
sscanf(buf,
"%u %u", &en, &bit) != 2 || en > 1) {
498 dev_err(ci->
dev,
"<1|0> <bit>: enable|disable interrupt\n");
504 if (hw_intr_force(ci, bit))
505 dev_err(dev,
"invalid bit number\n");
509 if (hw_intr_clear(ci, bit))
510 dev_err(dev,
"invalid bit number\n");
512 spin_unlock_irqrestore(&ci->
lock, flags);
538 spin_unlock_irqrestore(&ci->
lock, flags);
550 const char *buf,
size_t count)
561 if (
sscanf(buf,
"%u", &mode) != 1) {
562 dev_err(ci->
dev,
"<mode>: set port test mode");
569 spin_unlock_irqrestore(&ci->
lock, flags);
575 show_port_test, store_port_test);
587 unsigned i,
j, n = 0;
600 "EP=%02i: RX=%08X TX=%08X\n",
604 " %04X: %08X %08X\n", j,
605 *((
u32 *)mEpRx->
qh.ptr + j),
606 *((
u32 *)mEpTx->
qh.ptr + j));
609 spin_unlock_irqrestore(&ci->
lock, flags);
620 #define DUMP_ENTRIES 512
627 unsigned i,
k, n = 0;
636 dev_err(ci->
dev,
"%s: out of memory\n", __func__);
641 k = hw_register_read(ci, dump, DUMP_ENTRIES);
642 spin_unlock_irqrestore(&ci->
lock, flags);
644 for (i = 0; i <
k; i++) {
646 "reg[0x%04X] = 0x%08X\n",
647 i * (
unsigned)
sizeof(
u32), dump[i]);
661 const char *buf,
size_t count)
671 if (
sscanf(buf,
"%li %li", &addr, &data) != 2) {
673 "<addr> <data>: write data to register address\n");
678 if (hw_register_write(ci, addr, data))
680 spin_unlock_irqrestore(&ci->
lock, flags);
714 "EP=%02i: TD=%08X %s\n",
716 ((i < ci->hw_ep_max/2) ?
"RX" :
"TX"));
718 for (j = 0; j < qSize; j++)
723 spin_unlock_irqrestore(&ci->
lock, flags);