Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / cris / arch-v10 / kernel / debugport.c
index 2b536ca..3dc6e91 100644 (file)
@@ -1,6 +1,6 @@
 /* Serialport functions for debugging
  *
- * Copyright (c) 2000 Axis Communications AB
+ * Copyright (c) 2000-2007 Axis Communications AB
  *
  * Authors:  Bjorn Wesen
  *
  *    enableDebugIRQ()
  *    init_etrax_debug()
  *
- * $Log: debugport.c,v $
- * Revision 1.27  2005/06/10 10:34:14  starvik
- * Real console support
- *
- * Revision 1.26  2005/06/07 07:06:07  starvik
- * Added LF->CR translation to make ETRAX customers happy.
- *
- * Revision 1.25  2005/03/08 08:56:47  mikaelam
- * Do only set index as port->index if port is defined, otherwise use the index from the command line
- *
- * Revision 1.24  2005/01/19 10:26:33  mikaelam
- * Return the cris serial driver in console device driver callback function
- *
- * Revision 1.23  2005/01/14 10:12:17  starvik
- * KGDB on separate port.
- * Console fixes from 2.4.
- *
- * Revision 1.22  2005/01/11 16:06:13  starvik
- * typo
- *
- * Revision 1.21  2005/01/11 13:49:14  starvik
- * Added raw_printk to be used where we don't trust the console.
- *
- * Revision 1.20  2004/12/27 11:18:32  starvik
- * Merge of Linux 2.6.10 (not functional yet).
- *
- * Revision 1.19  2004/10/21 07:26:16  starvik
- * Made it possible to specify console settings on kernel command line.
- *
- * Revision 1.18  2004/10/19 13:07:37  starvik
- * Merge of Linux 2.6.9
- *
- * Revision 1.17  2004/09/29 10:33:46  starvik
- * Resolved a dealock when printing debug from kernel.
- *
- * Revision 1.16  2004/08/24 06:12:19  starvik
- * Whitespace cleanup
- *
- * Revision 1.15  2004/08/16 12:37:19  starvik
- * Merge of Linux 2.6.8
- *
- * Revision 1.14  2004/05/17 13:11:29  starvik
- * Disable DMA until real serial driver is up
- *
- * Revision 1.13  2004/05/14 07:58:01  starvik
- * Merge of changes from 2.4
- *
- * Revision 1.12  2003/09/11 07:29:49  starvik
- * Merge of Linux 2.6.0-test5
- *
- * Revision 1.11  2003/07/07 09:53:36  starvik
- * Revert all the 2.5.74 merge changes to make the console work again
- *
- * Revision 1.9  2003/02/17 17:07:23  starvik
- * Solved the problem with corrupted debug output (from Linux 2.4)
- *   * Wait until DMA, FIFO and pipe is empty before and after transmissions
- *   * Buffer data until a FIFO flush can be triggered.
- *
- * Revision 1.8  2003/01/22 06:48:36  starvik
- * Fixed warnings issued by GCC 3.2.1
- *
- * Revision 1.7  2002/12/12 08:26:32  starvik
- * Don't use C-comments inside CVS comments
- *
- * Revision 1.6  2002/12/11 15:42:02  starvik
- * Extracted v10 (ETRAX 100LX) specific stuff from arch/cris/kernel/
- *
- * Revision 1.5  2002/11/20 06:58:03  starvik
- * Compiles with kgdb
- *
- * Revision 1.4  2002/11/19 14:35:24  starvik
- * Changes from linux 2.4
- * Changed struct initializer syntax to the currently prefered notation
- *
- * Revision 1.3  2002/11/06 09:47:03  starvik
- * Modified for new interrupt macros
- *
- * Revision 1.2  2002/01/21 15:21:50  bjornw
- * Update for kdev_t changes
- *
- * Revision 1.6  2001/04/17 13:58:39  orjanf
- * * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB.
- *
- * Revision 1.5  2001/03/26 14:22:05  bjornw
- * Namechange of some config options
- *
- * Revision 1.4  2000/10/06 12:37:26  bjornw
- * Use physical addresses when talking to DMA
- *
- *
  */
 
 #include <linux/console.h>
 #include <asm/arch/svinto.h>
 #include <asm/io.h>             /* Get SIMCOUT. */
 
+extern void reset_watchdog(void);
+
 struct dbg_port
 {
   unsigned int index;
@@ -188,7 +100,9 @@ struct dbg_port ports[]=
   }
 };
 
+#ifdef CONFIG_ETRAX_SERIAL
 extern struct tty_driver *serial_driver;
+#endif
 
 struct dbg_port* port =
 #if defined(CONFIG_ETRAX_DEBUG_PORT0)
@@ -368,11 +282,12 @@ console_write_direct(struct console *co, const char *buf, unsigned int len)
 {
        int i;
        unsigned long flags;
-       local_irq_save(flags);
 
         if (!port)
                return;
 
+       local_irq_save(flags);
+
        /* Send data */
        for (i = 0; i < len; i++) {
                /* LF -> CRLF */
@@ -386,26 +301,16 @@ console_write_direct(struct console *co, const char *buf, unsigned int len)
                        ;
                *port->write = buf[i];
        }
-       local_irq_restore(flags);
-}
 
-int raw_printk(const char *fmt, ...)
-{
-       static char buf[1024];
-       int printed_len;
-       static int first = 1;
-       if (first) {
-               /* Force reinitialization of the port to get manual mode. */
-               port->started = 0;
-               start_port(port);
-               first = 0;
-       }
-       va_list args;
-       va_start(args, fmt);
-       printed_len = vsnprintf(buf, sizeof(buf), fmt, args);
-       va_end(args);
-       console_write_direct(NULL, buf, strlen(buf));
-       return printed_len;
+       /*
+        * Feed the watchdog, otherwise it will reset the chip during boot.
+        * The time to send an ordinary boot message line (10-90 chars)
+        * varies between 1-8ms at 115200. What makes up for the additional
+        * 90ms that allows the watchdog to bite?
+       */
+       reset_watchdog();
+
+       local_irq_restore(flags);
 }
 
 static void
@@ -500,6 +405,7 @@ console_setup(struct console *co, char *options)
        return 0;
 }
 
+
 /* This is a dummy serial device that throws away anything written to it.
  * This is used when no debug output is wanted.
  */
@@ -520,12 +426,18 @@ static int dummy_write(struct tty_struct * tty,
        return count;
 }
 
-static int
-dummy_write_room(struct tty_struct *tty)
+static int dummy_write_room(struct tty_struct *tty)
 {
        return 8192;
 }
 
+static const struct tty_operations dummy_ops = {
+       .open = dummy_open,
+       .close = dummy_close,
+       .write = dummy_write,
+       .write_room = dummy_write_room,
+};
+
 void __init
 init_dummy_console(void)
 {
@@ -538,14 +450,14 @@ init_dummy_console(void)
        dummy_driver.type = TTY_DRIVER_TYPE_SERIAL;
        dummy_driver.subtype = SERIAL_TYPE_NORMAL;
        dummy_driver.init_termios = tty_std_termios;
+       /* Normally B9600 default... */
        dummy_driver.init_termios.c_cflag =
-               B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
+               B115200 | CS8 | CREAD | HUPCL | CLOCAL;
        dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+       dummy_driver.init_termios.c_ispeed = 115200;
+       dummy_driver.init_termios.c_ospeed = 115200;
 
-       dummy_driver.open = dummy_open;
-       dummy_driver.close = dummy_close;
-       dummy_driver.write = dummy_write;
-       dummy_driver.write_room = dummy_write_room;
+       dummy_driver.ops = &dummy_ops;
        if (tty_register_driver(&dummy_driver))
                panic("Couldn't register dummy serial driver\n");
 }
@@ -555,7 +467,13 @@ etrax_console_device(struct console* co, int *index)
 {
        if (port)
                *index = port->index;
+       else
+               *index = 0;
+#ifdef CONFIG_ETRAX_SERIAL
         return port ? serial_driver : &dummy_driver;
+#else
+       return &dummy_driver;
+#endif
 }
 
 static struct console sercons = {