summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2013-08-10 10:50:43 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2013-09-06 00:33:51 +0200
commite53cece07b14eab1912db3d18d2cb50423d996ec (patch)
tree88048cb3e26af54af1c01368c736c9eb6b7470e2 /src
parent5c87d2f17e162c40b9f43415ccc049ef482f9336 (diff)
downloadcoreboot-e53cece07b14eab1912db3d18d2cb50423d996ec.tar.xz
usbdebug: Dump low-level protocol details
Dumping these EHCI host controller registers is useful to solve problems with debug devices. Change-Id: I0610cecca57b1b952d4f87211dd00c8c0bc398b9 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/3866 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/usbdebug.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index 214751121f..3dc35f1088 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -63,10 +63,12 @@ struct ehci_debug_info {
};
#if CONFIG_DEBUG_USBDEBUG
+static void dbgp_print_data(struct ehci_dbg_port *ehci_debug);
static int dbgp_enabled(void);
# define dprintk(LEVEL, args...) \
do { if (!dbgp_enabled()) printk(LEVEL, ##args); } while (0)
#else
+# define dbgp_print_data(x) do {} while(0)
# define dprintk(LEVEL, args...) do {} while(0)
#endif
@@ -136,8 +138,10 @@ static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
break;
} while (++loop < DBGP_MICROFRAME_TIMEOUT_LOOPS);
- if (! (ctrl & DBGP_DONE))
+ if (! (ctrl & DBGP_DONE)) {
+ dprintk(BIOS_ERR, "dbgp_wait_until_complete: retry timeout.\n");
return -DBGP_ERR_SIGNAL;
+ }
/* Now that we have observed the completed transaction,
* clear the done bit.
@@ -155,6 +159,7 @@ static int dbgp_wait_until_done(struct ehci_dbg_port *ehci_debug, struct dbgp_pi
unsigned ctrl, const int timeout)
{
u32 rd_ctrl, rd_pids;
+ u32 ctrl_prev = 0, pids_prev = 0;
u8 lpid;
int ret, host_retries;
int loop;
@@ -168,11 +173,21 @@ device_retry:
host_retry:
if (host_retries++ >= DBGP_MICROFRAME_RETRIES)
return -DBGP_ERR_BAD;
+ if (loop == 1 || host_retries > 1)
+ dprintk(BIOS_SPEW, "dbgp: start (@ %3d,%d) ctrl=%08x\n",
+ loop, host_retries, ctrl | DBGP_GO);
write32((unsigned long)&ehci_debug->control, ctrl | DBGP_GO);
ret = dbgp_wait_until_complete(ehci_debug);
rd_ctrl = read32((unsigned long)&ehci_debug->control);
rd_pids = read32((unsigned long)&ehci_debug->pids);
+ if (rd_ctrl != ctrl_prev || rd_pids != pids_prev || (ret<0)) {
+ ctrl_prev = rd_ctrl;
+ pids_prev = rd_pids;
+ dprintk(BIOS_SPEW, "dbgp: status (@ %3d,%d) ctrl=%08x pids=%08x ret=%d\n",
+ loop, host_retries, rd_ctrl, rd_pids, ret);
+ }
+
/* Controller hardware failure. */
if (ret == -DBGP_ERR_SIGNAL) {
return ret;
@@ -208,6 +223,8 @@ host_retry:
ret = -DBGP_ERR_BAD;
}
+ dbgp_print_data(ehci_debug);
+
return ret;
}
@@ -240,6 +257,25 @@ static void dbgp_get_data(struct ehci_dbg_port *ehci_debug, void *buf, int size)
bytes[i] = (hi >> (8*(i - 4))) & 0xff;
}
+#if CONFIG_DEBUG_USBDEBUG
+static void dbgp_print_data(struct ehci_dbg_port *ehci_debug)
+{
+ u32 ctrl = read32((unsigned long)&ehci_debug->control);
+ u32 lo = read32((unsigned long)&ehci_debug->data03);
+ u32 hi = read32((unsigned long)&ehci_debug->data47);
+ int len = DBGP_LEN(ctrl);
+ if (len) {
+ int i;
+ dprintk(BIOS_SPEW, "dbgp: buf:");
+ for (i = 0; i < 4 && i < len; i++)
+ dprintk(BIOS_SPEW, " %02x", (lo >> (8*i)) & 0xff);
+ for (; i < 8 && i < len; i++)
+ dprintk(BIOS_SPEW, " %02x", (hi >> (8*(i - 4))) & 0xff);
+ dprintk(BIOS_SPEW, "\n");
+ }
+}
+#endif
+
static int dbgp_bulk_write(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe,
const char *bytes, int size)
{