]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/serial/sh-sci.c
Merge branch 'sony' into release
[karo-tx-linux.git] / drivers / serial / sh-sci.c
index ac658a7a27becaaf253101a1d2176ce434237a80..5c0f32c7fbf6b20c8e20fba1ec32f7e08af29909 100644 (file)
@@ -79,7 +79,7 @@ struct sci_port {
        struct timer_list       break_timer;
        int                     break_flag;
 
-#ifdef CONFIG_SUPERH
+#ifdef CONFIG_HAVE_CLK
        /* Port clock */
        struct clk              *clk;
 #endif
@@ -250,8 +250,7 @@ static inline void h8300_sci_disable(struct uart_port *port)
 }
 #endif
 
-#if defined(SCI_ONLY) || defined(SCI_AND_SCIF) && \
-    defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__)
 static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
 {
        int ch = (port->mapbase - SMR0) >> 3;
@@ -285,11 +284,6 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
 #define sci_init_pins_irda NULL
 #endif
 
-#ifdef SCI_ONLY
-#define sci_init_pins_scif NULL
-#endif
-
-#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
 #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
 static void sci_init_pins_scif(struct uart_port* port, unsigned int cflag)
 {
@@ -449,7 +443,6 @@ static inline int scif_rxroom(struct uart_port *port)
        return sci_in(port, SCFDR) & SCIF_RFDC_MASK;
 }
 #endif
-#endif /* SCIF_ONLY || SCI_AND_SCIF */
 
 static inline int sci_txroom(struct uart_port *port)
 {
@@ -485,11 +478,9 @@ static void sci_transmit_chars(struct uart_port *port)
                return;
        }
 
-#ifndef SCI_ONLY
        if (port->type == PORT_SCIF)
                count = scif_txroom(port);
        else
-#endif
                count = sci_txroom(port);
 
        do {
@@ -519,12 +510,10 @@ static void sci_transmit_chars(struct uart_port *port)
        } else {
                ctrl = sci_in(port, SCSCR);
 
-#if !defined(SCI_ONLY)
                if (port->type == PORT_SCIF) {
                        sci_in(port, SCxSR); /* Dummy read */
                        sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
                }
-#endif
 
                ctrl |= SCI_CTRL_FLAGS_TIE;
                sci_out(port, SCSCR, ctrl);
@@ -547,11 +536,9 @@ static inline void sci_receive_chars(struct uart_port *port)
                return;
 
        while (1) {
-#if !defined(SCI_ONLY)
                if (port->type == PORT_SCIF)
                        count = scif_rxroom(port);
                else
-#endif
                        count = sci_rxroom(port);
 
                /* Don't copy more bytes than there is room for in the buffer */
@@ -810,29 +797,30 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr)
 
 static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
 {
-        unsigned short ssr_status, scr_status;
-        struct uart_port *port = ptr;
+       unsigned short ssr_status, scr_status;
+       struct uart_port *port = ptr;
+       irqreturn_t ret = IRQ_NONE;
 
         ssr_status = sci_in(port,SCxSR);
         scr_status = sci_in(port,SCSCR);
 
        /* Tx Interrupt */
-        if ((ssr_status & 0x0020) && (scr_status & 0x0080))
-                sci_tx_interrupt(irq, ptr);
+       if ((ssr_status & 0x0020) && (scr_status & SCI_CTRL_FLAGS_TIE))
+               ret = sci_tx_interrupt(irq, ptr);
        /* Rx Interrupt */
-        if ((ssr_status & 0x0002) && (scr_status & 0x0040))
-                sci_rx_interrupt(irq, ptr);
+       if ((ssr_status & 0x0002) && (scr_status & SCI_CTRL_FLAGS_RIE))
+               ret = sci_rx_interrupt(irq, ptr);
        /* Error Interrupt */
-        if ((ssr_status & 0x0080) && (scr_status & 0x0400))
-                sci_er_interrupt(irq, ptr);
+       if ((ssr_status & 0x0080) && (scr_status & SCI_CTRL_FLAGS_REIE))
+               ret = sci_er_interrupt(irq, ptr);
        /* Break Interrupt */
-        if ((ssr_status & 0x0010) && (scr_status & 0x0200))
-                sci_br_interrupt(irq, ptr);
+       if ((ssr_status & 0x0010) && (scr_status & SCI_CTRL_FLAGS_REIE))
+               ret = sci_br_interrupt(irq, ptr);
 
-       return IRQ_HANDLED;
+       return ret;
 }
 
-#ifdef CONFIG_CPU_FREQ
+#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
 /*
  * Here we define a transistion notifier so that we can update all of our
  * ports' baud rate when the peripheral clock changes.
@@ -861,7 +849,7 @@ static int sci_notifier(struct notifier_block *self,
                         * Clean this up later..
                         */
                        clk = clk_get(NULL, "module_clk");
-                       port->uartclk = clk_get_rate(clk) * 16;
+                       port->uartclk = clk_get_rate(clk);
                        clk_put(clk);
                }
 
@@ -874,7 +862,7 @@ static int sci_notifier(struct notifier_block *self,
 }
 
 static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
-#endif /* CONFIG_CPU_FREQ */
+#endif /* CONFIG_CPU_FREQ && CONFIG_HAVE_CLK */
 
 static int sci_request_irq(struct sci_port *port)
 {
@@ -1009,7 +997,7 @@ static int sci_startup(struct uart_port *port)
        if (s->enable)
                s->enable(port);
 
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
+#ifdef CONFIG_HAVE_CLK
        s->clk = clk_get(NULL, "module_clk");
 #endif
 
@@ -1031,7 +1019,7 @@ static void sci_shutdown(struct uart_port *port)
        if (s->disable)
                s->disable(port);
 
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
+#ifdef CONFIG_HAVE_CLK
        clk_put(s->clk);
        s->clk = NULL;
 #endif
@@ -1042,24 +1030,11 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 {
        struct sci_port *s = &sci_ports[port->line];
        unsigned int status, baud, smr_val;
-       int t;
+       int t = -1;
 
        baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
-
-       switch (baud) {
-               case 0:
-                       t = -1;
-                       break;
-               default:
-               {
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
-                       t = SCBRR_VALUE(baud, clk_get_rate(s->clk));
-#else
-                       t = SCBRR_VALUE(baud);
-#endif
-                       break;
-               }
-       }
+       if (likely(baud))
+               t = SCBRR_VALUE(baud, port->uartclk);
 
        do {
                status = sci_in(port, SCxSR);
@@ -1067,10 +1042,8 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 
        sci_out(port, SCSCR, 0x00);     /* TE=0, RE=0, CKE1=0 */
 
-#if !defined(SCI_ONLY)
        if (port->type == PORT_SCIF)
                sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
-#endif
 
        smr_val = sci_in(port, SCSMR) & 3;
        if ((termios->c_cflag & CSIZE) == CS7)
@@ -1162,7 +1135,7 @@ static int sci_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
        struct sci_port *s = &sci_ports[port->line];
 
-       if (ser->irq != s->irqs[SCIx_TXI_IRQ] || ser->irq > NR_IRQS)
+       if (ser->irq != s->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs)
                return -EINVAL;
        if (ser->baud_base < 2400)
                /* No paper tape reader for Mitch.. */
@@ -1212,17 +1185,17 @@ static void __init sci_init_ports(void)
                sci_ports[i].disable    = h8300_sci_disable;
 #endif
                sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK;
-#elif defined(CONFIG_SUPERH64)
-               sci_ports[i].port.uartclk = current_cpu_data.module_clock * 16;
-#else
+#elif defined(CONFIG_HAVE_CLK)
                /*
                 * XXX: We should use a proper SCI/SCIF clock
                 */
                {
                        struct clk *clk = clk_get(NULL, "module_clk");
-                       sci_ports[i].port.uartclk = clk_get_rate(clk) * 16;
+                       sci_ports[i].port.uartclk = clk_get_rate(clk);
                        clk_put(clk);
                }
+#else
+#error "Need a valid uartclk"
 #endif
 
                sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i];
@@ -1290,7 +1263,7 @@ static int __init serial_console_setup(struct console *co, char *options)
 
        port->type = serial_console_port->type;
 
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
+#ifdef CONFIG_HAVE_CLK
        if (!serial_console_port->clk)
                serial_console_port->clk = clk_get(NULL, "module_clk");
 #endif
@@ -1494,7 +1467,7 @@ static int __devinit sci_probe(struct platform_device *dev)
        kgdb_putchar    = kgdb_sci_putchar;
 #endif
 
-#ifdef CONFIG_CPU_FREQ
+#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
        cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
        dev_info(&dev->dev, "CPU frequency notifier registered\n");
 #endif