[coreboot-gerrit] Patch set updated for coreboot: 357b925 usbdebug: Dump low-level protocol details

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Fri Aug 23 07:12:58 CEST 2013


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3866

-gerrit

commit 357b9254faa1a6dce814432480044b1d8b12be23
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sat Aug 10 10:50:43 2013 +0300

    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 at gmail.com>
---
 src/lib/usbdebug.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index c42140f..10fc0c5 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_US);
 
-	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, int timeout_ms)
 {
 	u32 rd_ctrl, rd_pids;
+	u32 ctrl_prev = 0, pids_prev = 0;
 	u8 lpid;
 	int ret, host_retries;
 	int loop, max_loop;
@@ -172,11 +177,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;
@@ -212,6 +227,8 @@ host_retry:
 		ret = -DBGP_ERR_BAD;
 	}
 
+	dbgp_print_data(ehci_debug);
+
 	return ret;
 }
 
@@ -244,6 +261,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)
 {



More information about the coreboot-gerrit mailing list