vserver 1.9.5.x5
[linux-2.6.git] / drivers / serial / sn_console.c
index 98b96c5..57aa612 100644 (file)
@@ -50,8 +50,8 @@
 #include <linux/miscdevice.h>
 #include <linux/serial_core.h>
 
+#include <asm/io.h>
 #include <asm/sn/simulator.h>
-#include <asm/sn/sn2/sn_private.h>
 #include <asm/sn/sn_sal.h>
 
 /* number of characters we can transmit to the SAL console at a time */
 
 /* To use dynamic numbers only and not use the assigned major and minor,
  * define the following.. */
-/* #define USE_DYNAMIC_MINOR 1 */ /* use dynamic minor number */
-#define USE_DYNAMIC_MINOR 0 /* Don't rely on misc_register dynamic minor */
+                                 /* #define USE_DYNAMIC_MINOR 1 *//* use dynamic minor number */
+#define USE_DYNAMIC_MINOR 0    /* Don't rely on misc_register dynamic minor */
 
 /* Device name we're using */
 #define DEVICE_NAME "ttySG"
-#define DEVICE_NAME_DYNAMIC "ttySG0"  /* need full name for misc_register */
+#define DEVICE_NAME_DYNAMIC "ttySG0"   /* need full name for misc_register */
 /* The major/minor we are using, ignored for USE_DYNAMIC_MINOR */
 #define DEVICE_MAJOR 204
 #define DEVICE_MINOR 40
 
+#ifdef CONFIG_MAGIC_SYSRQ
+static char sysrq_serial_str[] = "\eSYS";
+static char *sysrq_serial_ptr = sysrq_serial_str;
+static unsigned long sysrq_requested;
+#endif /* CONFIG_MAGIC_SYSRQ */
+
 /*
  * Port definition - this kinda drives it all
  */
@@ -100,9 +106,8 @@ struct sn_cons_port {
 static struct sn_cons_port sal_console_port;
 
 /* Only used if USE_DYNAMIC_MINOR is set to 1 */
-static struct miscdevice misc; /* used with misc_register for dynamic */
+static struct miscdevice misc; /* used with misc_register for dynamic */
 
-extern u64 master_node_bedrock_address;
 extern void early_sn_setup(void);
 
 #undef DEBUG
@@ -118,9 +123,6 @@ static int snt_hw_puts_raw(const char *, int);
 static int snt_hw_puts_buffered(const char *, int);
 static int snt_poll_getc(void);
 static int snt_poll_input_pending(void);
-static int snt_sim_puts(const char *, int);
-static int snt_sim_getc(void);
-static int snt_sim_input_pending(void);
 static int snt_intr_getc(void);
 static int snt_intr_input_pending(void);
 static void sn_transmit_chars(struct sn_cons_port *, int);
@@ -134,14 +136,6 @@ static struct sn_sal_ops poll_ops = {
        .sal_input_pending = snt_poll_input_pending
 };
 
-/* A table for the simulator */
-static struct sn_sal_ops sim_ops = {
-       .sal_puts_raw = snt_sim_puts,
-       .sal_puts = snt_sim_puts,
-       .sal_getc = snt_sim_getc,
-       .sal_input_pending = snt_sim_input_pending
-};
-
 /* A table for interrupts enabled */
 static struct sn_sal_ops intr_ops = {
        .sal_puts_raw = snt_hw_puts_raw,
@@ -162,15 +156,13 @@ static struct sn_sal_ops intr_ops = {
  * output is buffered and sent to the SAL asynchronously (either by
  * timer callback or by UART interrupt) */
 
-
 /* routines for running the console in polling mode */
 
 /**
  * snt_poll_getc - Get a character from the console in polling mode
  *
  */
-static int
-snt_poll_getc(void)
+static int snt_poll_getc(void)
 {
        int ch;
 
@@ -182,8 +174,7 @@ snt_poll_getc(void)
  * snt_poll_input_pending - Check if any input is waiting - polling mode.
  *
  */
-static int
-snt_poll_input_pending(void)
+static int snt_poll_input_pending(void)
 {
        int status, input;
 
@@ -191,64 +182,13 @@ snt_poll_input_pending(void)
        return !status && input;
 }
 
-/* routines for running the console on the simulator */
-
-/**
- * snt_sim_puts - send to the console, used in simulator mode
- * @str: String to send
- * @count: length of string
- *
- */
-static int
-snt_sim_puts(const char *str, int count)
-{
-       int counter = count;
-
-#ifdef FLAG_DIRECT_CONSOLE_WRITES
-       /* This is an easy way to pre-pend the output to know whether the output
-        * was done via sal or directly */
-       writeb('[', master_node_bedrock_address + (UART_TX << 3));
-       writeb('+', master_node_bedrock_address + (UART_TX << 3));
-       writeb(']', master_node_bedrock_address + (UART_TX << 3));
-       writeb(' ', master_node_bedrock_address + (UART_TX << 3));
-#endif                         /* FLAG_DIRECT_CONSOLE_WRITES */
-       while (counter > 0) {
-               writeb(*str, master_node_bedrock_address + (UART_TX << 3));
-               counter--;
-               str++;
-       }
-       return count;
-}
-
-/**
- * snt_sim_getc - Get character from console in simulator mode
- *
- */
-static int
-snt_sim_getc(void)
-{
-       return readb(master_node_bedrock_address + (UART_RX << 3));
-}
-
-/**
- * snt_sim_input_pending - Check if there is input pending in simulator mode
- *
- */
-static int
-snt_sim_input_pending(void)
-{
-       return readb(master_node_bedrock_address +
-                    (UART_LSR << 3)) & UART_LSR_DR;
-}
-
 /* routines for an interrupt driven console (normal) */
 
 /**
  * snt_intr_getc - Get a character from the console, interrupt mode
  *
  */
-static int
-snt_intr_getc(void)
+static int snt_intr_getc(void)
 {
        return ia64_sn_console_readc();
 }
@@ -257,8 +197,7 @@ snt_intr_getc(void)
  * snt_intr_input_pending - Check if input is pending, interrupt mode
  *
  */
-static int
-snt_intr_input_pending(void)
+static int snt_intr_input_pending(void)
 {
        return ia64_sn_console_intr_status() & SAL_CONSOLE_INTR_RECV;
 }
@@ -271,8 +210,7 @@ snt_intr_input_pending(void)
  * @len: Length
  *
  */
-static int
-snt_hw_puts_raw(const char *s, int len)
+static int snt_hw_puts_raw(const char *s, int len)
 {
        /* this will call the PROM and not return until this is done */
        return ia64_sn_console_putb(s, len);
@@ -284,8 +222,7 @@ snt_hw_puts_raw(const char *s, int len)
  * @len: Length
  *
  */
-static int
-snt_hw_puts_buffered(const char *s, int len)
+static int snt_hw_puts_buffered(const char *s, int len)
 {
        /* queue data to the PROM */
        return ia64_sn_console_xmit_chars((char *)s, len);
@@ -303,8 +240,7 @@ snt_hw_puts_buffered(const char *s, int len)
  * @port: Port to operate with (we ignore since we only have one port)
  *
  */
-static const char *
-snp_type(struct uart_port *port)
+static const char *snp_type(struct uart_port *port)
 {
        return ("SGI SN L1");
 }
@@ -314,8 +250,7 @@ snp_type(struct uart_port *port)
  * @port: Port to operate on (we ignore since we only have one port)
  *
  */
-static unsigned int
-snp_tx_empty(struct uart_port *port)
+static unsigned int snp_tx_empty(struct uart_port *port)
 {
        return 1;
 }
@@ -326,8 +261,7 @@ snp_tx_empty(struct uart_port *port)
  * @tty_stop: Set to 1 if called via uart_stop
  *
  */
-static void
-snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
 {
 }
 
@@ -336,8 +270,7 @@ snp_stop_tx(struct uart_port *port, unsigned int tty_stop)
  * @port: Port to operate on - we ignore - no-op function
  *
  */
-static void
-snp_release_port(struct uart_port *port)
+static void snp_release_port(struct uart_port *port)
 {
 }
 
@@ -346,8 +279,7 @@ snp_release_port(struct uart_port *port)
  * @port: Port to operate on - we ignore - no-op function
  *
  */
-static void
-snp_enable_ms(struct uart_port *port)
+static void snp_enable_ms(struct uart_port *port)
 {
 }
 
@@ -356,8 +288,7 @@ snp_enable_ms(struct uart_port *port)
  * @port: Port to shut down - we ignore
  *
  */
-static void
-snp_shutdown(struct uart_port *port)
+static void snp_shutdown(struct uart_port *port)
 {
 }
 
@@ -367,8 +298,7 @@ snp_shutdown(struct uart_port *port)
  * @mctrl: Lines to set/unset - we ignore
  *
  */
-static void
-snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
+static void snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
 }
 
@@ -377,8 +307,7 @@ snp_set_mctrl(struct uart_port *port, unsigned int mctrl)
  * @port: port to operate on - we only have one port so we ignore this
  *
  */
-static unsigned int
-snp_get_mctrl(struct uart_port *port)
+static unsigned int snp_get_mctrl(struct uart_port *port)
 {
        return TIOCM_CAR | TIOCM_RNG | TIOCM_DSR | TIOCM_CTS;
 }
@@ -388,8 +317,7 @@ snp_get_mctrl(struct uart_port *port)
  * @port: Port to operate on - we ignore
  *
  */
-static void
-snp_stop_rx(struct uart_port *port)
+static void snp_stop_rx(struct uart_port *port)
 {
 }
 
@@ -399,11 +327,11 @@ snp_stop_rx(struct uart_port *port)
  * @tty_stop: Set to 1 if called via uart_start
  *
  */
-static void
-snp_start_tx(struct uart_port *port, unsigned int tty_stop)
+static void snp_start_tx(struct uart_port *port, unsigned int tty_stop)
 {
        if (sal_console_port.sc_ops->sal_wakeup_transmit)
-               sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port, TRANSMIT_BUFFERED);
+               sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port,
+                                                            TRANSMIT_BUFFERED);
 
 }
 
@@ -413,8 +341,7 @@ snp_start_tx(struct uart_port *port, unsigned int tty_stop)
  * @break_state: Break state
  *
  */
-static void
-snp_break_ctl(struct uart_port *port, int break_state)
+static void snp_break_ctl(struct uart_port *port, int break_state)
 {
 }
 
@@ -423,8 +350,7 @@ snp_break_ctl(struct uart_port *port, int break_state)
  * @port: Port to operate on
  *
  */
-static int
-snp_startup(struct uart_port *port)
+static int snp_startup(struct uart_port *port)
 {
        return 0;
 }
@@ -447,8 +373,7 @@ snp_set_termios(struct uart_port *port, struct termios *termios,
  * @port: port to operate on
  *
  */
-static int
-snp_request_port(struct uart_port *port)
+static int snp_request_port(struct uart_port *port)
 {
        return 0;
 }
@@ -459,8 +384,7 @@ snp_request_port(struct uart_port *port)
  * @flags: flags used for port setup
  *
  */
-static void
-snp_config_port(struct uart_port *port, int flags)
+static void snp_config_port(struct uart_port *port, int flags)
 {
 }
 
@@ -498,22 +422,17 @@ static struct uart_ops sn_console_ops = {
  * itself may be broken.
  *
  */
-static int
-sn_debug_printf(const char *fmt, ...)
+static int sn_debug_printf(const char *fmt, ...)
 {
        static char printk_buf[1024];
        int printed_len;
        va_list args;
 
        va_start(args, fmt);
-       printed_len = vsnprintf(printk_buf, sizeof (printk_buf), fmt, args);
+       printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
 
        if (!sal_console_port.sc_ops) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       sal_console_port.sc_ops = &sim_ops;
-               else
-                       sal_console_port.sc_ops = &poll_ops;
-
+               sal_console_port.sc_ops = &poll_ops;
                early_sn_setup();
        }
        sal_console_port.sc_ops->sal_puts_raw(printk_buf, printed_len);
@@ -521,24 +440,25 @@ sn_debug_printf(const char *fmt, ...)
        va_end(args);
        return printed_len;
 }
-#endif /* DEBUG */
+#endif                         /* DEBUG */
 
 /*
  * Interrupt handling routines.
  */
 
-
 /**
  * sn_receive_chars - Grab characters, pass them to tty layer
  * @port: Port to operate on
  * @regs: Saved registers (needed by uart_handle_sysrq_char)
+ * @flags: irq flags
  *
  * Note: If we're not registered with the serial core infrastructure yet,
  * we don't try to send characters to it...
  *
  */
 static void
-sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs)
+sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs,
+                unsigned long flags)
 {
        int ch;
        struct tty_struct *tty;
@@ -569,10 +489,34 @@ sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs)
                               "obtaining data from the console (0x%0x)\n", ch);
                        break;
                }
-#if defined(CONFIG_SERIAL_SGI_L1_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-               if (uart_handle_sysrq_char(&port->sc_port, ch, regs))
-                       continue;
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE && CONFIG_MAGIC_SYSRQ */
+#ifdef CONFIG_MAGIC_SYSRQ
+                if (sysrq_requested) {
+                        unsigned long sysrq_timeout = sysrq_requested + HZ*5;
+
+                        sysrq_requested = 0;
+                        if (ch && time_before(jiffies, sysrq_timeout)) {
+                                spin_unlock_irqrestore(&port->sc_port.lock, flags);
+                                handle_sysrq(ch, regs, NULL);
+                                spin_lock_irqsave(&port->sc_port.lock, flags);
+                                /* ignore actual sysrq command char */
+                                continue;
+                        }
+                }
+                if (ch == *sysrq_serial_ptr) {
+                        if (!(*++sysrq_serial_ptr)) {
+                                sysrq_requested = jiffies;
+                                sysrq_serial_ptr = sysrq_serial_str;
+                        }
+                       /*
+                        * ignore the whole sysrq string except for the
+                        * leading escape
+                        */
+                       if (ch != '\e')
+                               continue;
+                }
+                else
+                       sysrq_serial_ptr = sysrq_serial_str;
+#endif /* CONFIG_MAGIC_SYSRQ */
 
                /* record the character to pass up to the tty layer */
                if (tty) {
@@ -583,8 +527,6 @@ sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs)
                        if (tty->flip.count == TTY_FLIPBUF_SIZE)
                                break;
                }
-               else {
-               }
                port->sc_port.icount.rx++;
        }
 
@@ -604,8 +546,7 @@ sn_receive_chars(struct sn_cons_port *port, struct pt_regs *regs)
  * ignore them until we register with the serial core stuffs.
  *
  */
-static void
-sn_transmit_chars(struct sn_cons_port *port, int raw)
+static void sn_transmit_chars(struct sn_cons_port *port, int raw)
 {
        int xmit_count, tail, head, loops, ii;
        int result;
@@ -620,8 +561,7 @@ sn_transmit_chars(struct sn_cons_port *port, int raw)
        if (port->sc_port.info) {
                /* We're initilized, using serial core infrastructure */
                xmit = &port->sc_port.info->xmit;
-       }
-       else {
+       } else {
                /* Probably sn_sal_switch_to_asynch has been run but serial core isn't
                 * initilized yet.  Just return.  Writes are going through
                 * sn_sal_console_write (due to register_console) at this time.
@@ -673,7 +613,7 @@ sn_transmit_chars(struct sn_cons_port *port, int raw)
                uart_write_wakeup(&port->sc_port);
 
        if (uart_circ_empty(xmit))
-               snp_stop_tx(&port->sc_port, 0); /* no-op for us */
+               snp_stop_tx(&port->sc_port, 0); /* no-op for us */
 }
 
 /**
@@ -683,10 +623,9 @@ sn_transmit_chars(struct sn_cons_port *port, int raw)
  * @regs: Saved registers, used by sn_receive_chars for uart_handle_sysrq_char
  *
  */
-static irqreturn_t
-sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-       struct sn_cons_port *port = (struct sn_cons_port *) dev_id;
+       struct sn_cons_port *port = (struct sn_cons_port *)dev_id;
        unsigned long flags;
        int status = ia64_sn_console_intr_status();
 
@@ -695,7 +634,7 @@ sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 
        spin_lock_irqsave(&port->sc_port.lock, flags);
        if (status & SAL_CONSOLE_INTR_RECV) {
-               sn_receive_chars(port, regs);
+               sn_receive_chars(port, regs, flags);
        }
        if (status & SAL_CONSOLE_INTR_XMIT) {
                sn_transmit_chars(port, TRANSMIT_BUFFERED);
@@ -711,10 +650,10 @@ sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  * returns the console irq if interrupt is successfully registered, else 0
  *
  */
-static int
-sn_sal_connect_interrupt(struct sn_cons_port *port)
+static int sn_sal_connect_interrupt(struct sn_cons_port *port)
 {
-       if (request_irq(SGI_UART_VECTOR, sn_sal_interrupt, SA_INTERRUPT,
+       if (request_irq(SGI_UART_VECTOR, sn_sal_interrupt,
+                       SA_INTERRUPT | SA_SHIRQ,
                        "SAL console driver", port) >= 0) {
                return SGI_UART_VECTOR;
        }
@@ -732,10 +671,9 @@ sn_sal_connect_interrupt(struct sn_cons_port *port)
  * Obviously not used in interrupt mode
  *
  */
-static void
-sn_sal_timer_poll(unsigned long data)
+static void sn_sal_timer_poll(unsigned long data)
 {
-       struct sn_cons_port *port = (struct sn_cons_port *) data;
+       struct sn_cons_port *port = (struct sn_cons_port *)data;
        unsigned long flags;
 
        if (!port)
@@ -743,7 +681,7 @@ sn_sal_timer_poll(unsigned long data)
 
        if (!port->sc_port.irq) {
                spin_lock_irqsave(&port->sc_port.lock, flags);
-               sn_receive_chars(port, NULL);
+               sn_receive_chars(port, NULL, flags);
                sn_transmit_chars(port, TRANSMIT_RAW);
                spin_unlock_irqrestore(&port->sc_port.lock, flags);
                mod_timer(&port->sc_timer,
@@ -765,8 +703,7 @@ sn_sal_timer_poll(unsigned long data)
  * if we didn't already come through here via sn_sal_serial_console_init.
  *
  */
-static void __init
-sn_sal_switch_to_asynch(struct sn_cons_port *port)
+static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
 {
        unsigned long flags;
 
@@ -781,12 +718,8 @@ sn_sal_switch_to_asynch(struct sn_cons_port *port)
        spin_lock_irqsave(&port->sc_port.lock, flags);
 
        /* early_printk invocation may have done this for us */
-       if (!port->sc_ops) {
-               if (IS_RUNNING_ON_SIMULATOR())
-                       port->sc_ops = &sim_ops;
-               else
-                       port->sc_ops = &poll_ops;
-       }
+       if (!port->sc_ops)
+               port->sc_ops = &poll_ops;
 
        /* we can't turn on the console interrupt (as request_irq
         * calls kmalloc, which isn't set up yet), so we rely on a
@@ -795,7 +728,7 @@ sn_sal_switch_to_asynch(struct sn_cons_port *port)
         */
        init_timer(&port->sc_timer);
        port->sc_timer.function = sn_sal_timer_poll;
-       port->sc_timer.data = (unsigned long) port;
+       port->sc_timer.data = (unsigned long)port;
 
        if (IS_RUNNING_ON_SIMULATOR())
                port->sc_interrupt_timeout = 6;
@@ -822,8 +755,7 @@ sn_sal_switch_to_asynch(struct sn_cons_port *port)
  * We attempt to switch to interrupt mode here by calling
  * sn_sal_connect_interrupt.  If that works out, we enable receive interrupts.
  */
-static void __init
-sn_sal_switch_to_interrupts(struct sn_cons_port *port)
+static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port)
 {
        int irq;
        unsigned long flags;
@@ -851,7 +783,6 @@ sn_sal_switch_to_interrupts(struct sn_cons_port *port)
  * Kernel console definitions
  */
 
-#ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
 static void sn_sal_console_write(struct console *, const char *, unsigned);
 static int __init sn_sal_console_setup(struct console *, char *);
 extern struct uart_driver sal_console_uart;
@@ -862,22 +793,19 @@ static struct console sal_console = {
        .write = sn_sal_console_write,
        .device = uart_console_device,
        .setup = sn_sal_console_setup,
-       .index = -1, /* unspecified */
+       .index = -1,            /* unspecified */
        .data = &sal_console_uart,
 };
 
 #define SAL_CONSOLE    &sal_console
-#else
-#define SAL_CONSOLE    0
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE */
 
 static struct uart_driver sal_console_uart = {
        .owner = THIS_MODULE,
        .driver_name = "sn_console",
        .dev_name = DEVICE_NAME,
-       .major = 0, /* major/minor set at registration time per USE_DYNAMIC_MINOR */
+       .major = 0,             /* major/minor set at registration time per USE_DYNAMIC_MINOR */
        .minor = 0,
-       .nr = 1,        /* one port */
+       .nr = 1,                /* one port */
        .cons = SAL_CONSOLE,
 };
 
@@ -890,42 +818,42 @@ static struct uart_driver sal_console_uart = {
  * core and try to enable interrupt driven mode.
  *
  */
-static int __init
-sn_sal_module_init(void)
+static int __init sn_sal_module_init(void)
 {
        int retval;
 
-       printk(KERN_INFO "sn_console: Console driver init\n");
-
        if (!ia64_platform_is("sn2"))
                return -ENODEV;
 
+       printk(KERN_INFO "sn_console: Console driver init\n");
+
        if (USE_DYNAMIC_MINOR == 1) {
                misc.minor = MISC_DYNAMIC_MINOR;
                misc.name = DEVICE_NAME_DYNAMIC;
                retval = misc_register(&misc);
                if (retval != 0) {
-                       printk("Failed to register console device using misc_register.\n");
+                       printk
+                           ("Failed to register console device using misc_register.\n");
                        return -ENODEV;
                }
                sal_console_uart.major = MISC_MAJOR;
                sal_console_uart.minor = misc.minor;
-       }
-       else {
+       } else {
                sal_console_uart.major = DEVICE_MAJOR;
                sal_console_uart.minor = DEVICE_MINOR;
        }
 
        /* We register the driver and the port before switching to interrupts
-    * or async above so the proper uart structures are populated */
+        * or async above so the proper uart structures are populated */
 
        if (uart_register_driver(&sal_console_uart) < 0) {
-               printk("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
-                 __LINE__);
+               printk
+                   ("ERROR sn_sal_module_init failed uart_register_driver, line %d\n",
+                    __LINE__);
                return -ENODEV;
        }
 
-       sal_console_port.sc_port.lock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&sal_console_port.sc_port.lock);
 
        /* Setup the port struct with the minimum needed */
        sal_console_port.sc_port.membase = (char *)1;   /* just needs to be non-zero */
@@ -957,8 +885,7 @@ sn_sal_module_init(void)
  * sn_sal_module_exit - When we're unloaded, remove the driver/port
  *
  */
-static void __exit
-sn_sal_module_exit(void)
+static void __exit sn_sal_module_exit(void)
 {
        del_timer_sync(&sal_console_port.sc_timer);
        uart_remove_one_port(&sal_console_uart, &sal_console_port.sc_port);
@@ -969,8 +896,6 @@ sn_sal_module_exit(void)
 module_init(sn_sal_module_init);
 module_exit(sn_sal_module_exit);
 
-#ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
-
 /**
  * puts_raw_fixed - sn_sal_console_write helper for adding \r's as required
  * @puts_raw : puts function to do the writing
@@ -982,7 +907,8 @@ module_exit(sn_sal_module_exit);
  *
  */
 
-static void puts_raw_fixed(int (*puts_raw) (const char *s, int len), const char *s, int count)
+static void puts_raw_fixed(int (*puts_raw) (const char *s, int len),
+                          const char *s, int count)
 {
        const char *s1;
 
@@ -1030,7 +956,7 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
        if (port->sc_port.info) {
 
                /* somebody really wants this output, might be an
-               * oops, kdb, panic, etc.  make sure they get it. */
+                * oops, kdb, panic, etc.  make sure they get it. */
 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
                if (spin_is_locked(&port->sc_port.lock)) {
                        int lhead = port->sc_port.info->xmit.head;
@@ -1038,29 +964,39 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
                        int counter, got_lock = 0;
 
                        /*
-                        * We attempt to determine if someone has died with the
-                        * lock. We wait ~20 secs after the head and tail ptrs
-                        * stop moving and assume the lock holder is not functional
-                        * and plow ahead. If the lock is freed within the time out
-                        * period we re-get the lock and go ahead normally. We also
-                        * remember if we have plowed ahead so that we don't have
+                        * We attempt to determine if someone has died with the
+                        * lock. We wait ~20 secs after the head and tail ptrs
+                        * stop moving and assume the lock holder is not functional
+                        * and plow ahead. If the lock is freed within the time out
+                        * period we re-get the lock and go ahead normally. We also
+                        * remember if we have plowed ahead so that we don't have
                         * to wait out the time out period again - the asumption
-                        * is that we will time out again.
-                        */
+                        * is that we will time out again.
+                        */
 
                        for (counter = 0; counter < 150; mdelay(125), counter++) {
-                               if (!spin_is_locked(&port->sc_port.lock) || stole_lock) {
+                               if (!spin_is_locked(&port->sc_port.lock)
+                                   || stole_lock) {
                                        if (!stole_lock) {
-                                               spin_lock_irqsave(&port->sc_port.lock, flags);
+                                               spin_lock_irqsave(&port->
+                                                                 sc_port.lock,
+                                                                 flags);
                                                got_lock = 1;
                                        }
                                        break;
-                               }
-                               else {
+                               } else {
                                        /* still locked */
-                                       if ((lhead != port->sc_port.info->xmit.head) || (ltail != port->sc_port.info->xmit.tail)) {
-                                               lhead = port->sc_port.info->xmit.head;
-                                               ltail = port->sc_port.info->xmit.tail;
+                                       if ((lhead !=
+                                            port->sc_port.info->xmit.head)
+                                           || (ltail !=
+                                               port->sc_port.info->xmit.
+                                               tail)) {
+                                               lhead =
+                                                   port->sc_port.info->xmit.
+                                                   head;
+                                               ltail =
+                                                   port->sc_port.info->xmit.
+                                                   tail;
                                                counter = 0;
                                        }
                                }
@@ -1068,16 +1004,15 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
                        /* flush anything in the serial core xmit buffer, raw */
                        sn_transmit_chars(port, 1);
                        if (got_lock) {
-                               spin_unlock_irqrestore(&port->sc_port.lock, flags);
+                               spin_unlock_irqrestore(&port->sc_port.lock,
+                                                      flags);
                                stole_lock = 0;
-                       }
-                       else {
+                       } else {
                                /* fell thru */
                                stole_lock = 1;
                        }
                        puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
-               }
-               else {
+               } else {
                        stole_lock = 0;
 #endif
                        spin_lock_irqsave(&port->sc_port.lock, flags);
@@ -1085,7 +1020,9 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
                        spin_unlock_irqrestore(&port->sc_port.lock, flags);
 
                        puts_raw_fixed(port->sc_ops->sal_puts_raw, s, count);
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
                }
+#endif
        }
        else {
                /* Not yet registered with serial core - simple case */
@@ -1106,8 +1043,7 @@ sn_sal_console_write(struct console *co, const char *s, unsigned count)
  * here so providing it is easier.
  *
  */
-static int __init
-sn_sal_console_setup(struct console *co, char *options)
+static int __init sn_sal_console_setup(struct console *co, char *options)
 {
        return 0;
 }
@@ -1135,7 +1071,7 @@ static struct console sal_console_early __initdata = {
        .name = "sn_sal",
        .write = sn_sal_console_write_early,
        .flags = CON_PRINTBUFFER,
-       .index  = -1,
+       .index = -1,
 };
 
 /**
@@ -1147,24 +1083,18 @@ static struct console sal_console_early __initdata = {
  * sn_sal_serial_console_init is called, this console is unregistered
  * and a new one registered.
  */
-int __init
-sn_serial_console_early_setup(void)
+int __init sn_serial_console_early_setup(void)
 {
        if (!ia64_platform_is("sn2"))
                return -1;
 
-       if (IS_RUNNING_ON_SIMULATOR())
-               sal_console_port.sc_ops = &sim_ops;
-       else
-               sal_console_port.sc_ops = &poll_ops;
-
-       early_sn_setup(); /* Find SAL entry points */
+       sal_console_port.sc_ops = &poll_ops;
+       early_sn_setup();       /* Find SAL entry points */
        register_console(&sal_console_early);
 
        return 0;
 }
 
-
 /**
  * sn_sal_serial_console_init - Early console output - set up for register
  *
@@ -1177,12 +1107,11 @@ sn_serial_console_early_setup(void)
  * it here doesn't hurt anything.
  *
  */
-static int __init
-sn_sal_serial_console_init(void)
+static int __init sn_sal_serial_console_init(void)
 {
        if (ia64_platform_is("sn2")) {
                sn_sal_switch_to_asynch(&sal_console_port);
-               DPRINTF ("sn_sal_serial_console_init : register console\n");
+               DPRINTF("sn_sal_serial_console_init : register console\n");
                register_console(&sal_console);
                unregister_console(&sal_console_early);
        }
@@ -1190,5 +1119,3 @@ sn_sal_serial_console_init(void)
 }
 
 console_initcall(sn_sal_serial_console_init);
-
-#endif                         /* CONFIG_SERIAL_SGI_L1_CONSOLE */