ppc/8xxx: relocate cpu pointer in global data
[oweals/u-boot.git] / cpu / blackfin / jtag-console.c
index 44c0a839ecc518a347928d447904bcd7055c28c1..1cd619f10b02d016cab184a1d63d00feccff53ea 100644 (file)
@@ -7,11 +7,11 @@
  */
 
 #include <common.h>
-#include <devices.h>
+#include <stdio_dev.h>
 #include <asm/blackfin.h>
 
 #ifndef CONFIG_JTAG_CONSOLE_TIMEOUT
-# define CONFIG_JTAG_CONSOLE_TIMEOUT 100
+# define CONFIG_JTAG_CONSOLE_TIMEOUT 500
 #endif
 
 /* The Blackfin tends to be much much faster than the JTAG hardware. */
@@ -54,16 +54,23 @@ static void jtag_puts(const char *s)
        jtag_send(s, strlen(s));
 }
 
-static int jtag_tstc(void)
+static size_t inbound_len, leftovers_len;
+
+/* Lower layers want to know when jtag has data */
+static int jtag_tstc_dbg(void)
 {
        return (bfin_read_DBGSTAT() & 0x2);
 }
 
+/* Higher layers want to know when any data is available */
+static int jtag_tstc(void)
+{
+       return jtag_tstc_dbg() || leftovers_len;
+}
+
 /* Receive a buffer.  The format is:
  * [32bit length][actual data]
  */
-static size_t inbound_len;
-static int leftovers_len;
 static uint32_t leftovers;
 static int jtag_getc(void)
 {
@@ -79,7 +86,7 @@ static int jtag_getc(void)
        }
 
        /* wait for new data ! */
-       while (!jtag_tstc())
+       while (!jtag_tstc_dbg())
                continue;
        __asm__("%0 = emudat;" : "=d"(emudat));
 
@@ -98,7 +105,7 @@ static int jtag_getc(void)
 
 int drv_jtag_console_init(void)
 {
-       device_t dev;
+       struct stdio_dev dev;
        int ret;
 
        memset(&dev, 0x00, sizeof(dev));
@@ -109,7 +116,7 @@ int drv_jtag_console_init(void)
        dev.tstc = jtag_tstc;
        dev.getc = jtag_getc;
 
-       ret = device_register(&dev);
+       ret = stdio_register(&dev);
        return (ret == 0 ? 1 : ret);
 }