linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / serial / imx.c
index 4a142d6..4d53fb5 100644 (file)
@@ -25,6 +25,7 @@
  * [29-Mar-2005] Mike Lee
  * Added hardware handshake
  */
+#include <linux/config.h>
 
 #if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
@@ -44,7 +45,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hardware.h>
-#include <asm/arch/imx-uart.h>
 
 /* We've been assigned a range on the "Low-density serial ports" major */
 #define SERIAL_IMX_MAJOR       204
@@ -73,8 +73,7 @@ struct imx_port {
        struct uart_port        port;
        struct timer_list       timer;
        unsigned int            old_status;
-       int                     txirq,rxirq,rtsirq;
-       int                     have_rtscts:1;
+       int txirq,rxirq,rtsirq;
 };
 
 /*
@@ -404,7 +403,7 @@ static int imx_startup(struct uart_port *port)
        if (retval) goto error_out2;
 
        retval = request_irq(sport->rtsirq, imx_rtsint,
-                            IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
+                            SA_TRIGGER_FALLING | SA_TRIGGER_RISING,
                             DRIVER_NAME, sport);
        if (retval) goto error_out3;
 
@@ -492,12 +491,8 @@ imx_set_termios(struct uart_port *port, struct termios *termios,
                ucr2 = UCR2_SRST | UCR2_IRTS;
 
        if (termios->c_cflag & CRTSCTS) {
-               if( sport->have_rtscts ) {
-                       ucr2 &= ~UCR2_IRTS;
-                       ucr2 |= UCR2_CTSC;
-               } else {
-                       termios->c_cflag &= ~CRTSCTS;
-               }
+               ucr2 &= ~UCR2_IRTS;
+               ucr2 |= UCR2_CTSC;
        }
 
        if (termios->c_cflag & CSTOPB)
@@ -724,16 +719,30 @@ static void __init imx_init_ports(void)
                imx_ports[i].timer.function = imx_timeout;
                imx_ports[i].timer.data     = (unsigned long)&imx_ports[i];
        }
+
+       imx_gpio_mode(PC9_PF_UART1_CTS);
+       imx_gpio_mode(PC10_PF_UART1_RTS);
+       imx_gpio_mode(PC11_PF_UART1_TXD);
+       imx_gpio_mode(PC12_PF_UART1_RXD);
+       imx_gpio_mode(PB28_PF_UART2_CTS);
+       imx_gpio_mode(PB29_PF_UART2_RTS);
+
+       imx_gpio_mode(PB30_PF_UART2_TXD);
+       imx_gpio_mode(PB31_PF_UART2_RXD);
+
+#if 0 /* We don't need these, on the mx1 the _modem_ side of the uart
+       * is implemented.
+       */
+       imx_gpio_mode(PD7_AF_UART2_DTR);
+       imx_gpio_mode(PD8_AF_UART2_DCD);
+       imx_gpio_mode(PD9_AF_UART2_RI);
+       imx_gpio_mode(PD10_AF_UART2_DSR);
+#endif
+
+
 }
 
 #ifdef CONFIG_SERIAL_IMX_CONSOLE
-static void imx_console_putchar(struct uart_port *port, int ch)
-{
-       struct imx_port *sport = (struct imx_port *)port;
-       while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
-               barrier();
-       URTX0((u32)sport->port.membase) = ch;
-}
 
 /*
  * Interrupts are disabled on entering
@@ -742,7 +751,7 @@ static void
 imx_console_write(struct console *co, const char *s, unsigned int count)
 {
        struct imx_port *sport = &imx_ports[co->index];
-       unsigned int old_ucr1, old_ucr2;
+       unsigned int old_ucr1, old_ucr2, i;
 
        /*
         *      First, save UCR1/2 and then disable interrupts
@@ -755,7 +764,22 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
                           & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
        UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
 
-       uart_console_write(&sport->port, s, count, imx_console_putchar);
+       /*
+        *      Now, do each character
+        */
+       for (i = 0; i < count; i++) {
+
+               while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
+                       barrier();
+
+               URTX0((u32)sport->port.membase) = s[i];
+
+               if (s[i] == '\n') {
+                       while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
+                               barrier();
+                       URTX0((u32)sport->port.membase) = '\r';
+               }
+       }
 
        /*
         *      Finally, wait for transmitter to become empty
@@ -887,6 +911,7 @@ static struct uart_driver imx_reg = {
        .owner          = THIS_MODULE,
        .driver_name    = DRIVER_NAME,
        .dev_name       = "ttySMX",
+       .devfs_name     = "ttsmx/",
        .major          = SERIAL_IMX_MAJOR,
        .minor          = MINOR_START,
        .nr             = ARRAY_SIZE(imx_ports),
@@ -915,14 +940,7 @@ static int serial_imx_resume(struct platform_device *dev)
 
 static int serial_imx_probe(struct platform_device *dev)
 {
-       struct imxuart_platform_data *pdata;
-
        imx_ports[dev->id].port.dev = &dev->dev;
-
-       pdata = (struct imxuart_platform_data *)dev->dev.platform_data;
-       if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS))
-               imx_ports[dev->id].have_rtscts = 1;
-
        uart_add_one_port(&imx_reg, &imx_ports[dev->id].port);
        platform_set_drvdata(dev, &imx_ports[dev->id]);
        return 0;