sh: use the common ascii hex helpers
[safe/jmp/linux-2.6] / drivers / serial / sh-sci.c
index 9ce12cb..ce6ee92 100644 (file)
 #include <linux/delay.h>
 #include <linux/console.h>
 #include <linux/platform_device.h>
-
-#ifdef CONFIG_CPU_FREQ
+#include <linux/serial_sci.h>
 #include <linux/notifier.h>
 #include <linux/cpufreq.h>
-#endif
-
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
+#include <linux/clk.h>
 #include <linux/ctype.h>
+
+#ifdef CONFIG_SUPERH
 #include <asm/clock.h>
 #include <asm/sh_bios.h>
 #include <asm/kgdb.h>
 #endif
 
-#include <asm/sci.h>
 #include "sh-sci.h"
 
 struct sci_port {
@@ -80,7 +78,7 @@ struct sci_port {
        struct timer_list       break_timer;
        int                     break_flag;
 
-#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
+#ifdef CONFIG_SUPERH
        /* Port clock */
        struct clk              *clk;
 #endif
@@ -186,15 +184,15 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
                        int h, l;
 
                        c = *p++;
-                       h = highhex(c);
-                       l = lowhex(c);
+                       h = hex_asc_hi(c);
+                       l = hex_asc_lo(c);
                        put_char(port, h);
                        put_char(port, l);
                        checksum += h + l;
                }
                put_char(port, '#');
-               put_char(port, highhex(checksum));
-               put_char(port, lowhex(checksum));
+               put_char(port, hex_asc_hi(checksum));
+               put_char(port, hex_asc_lo(checksum));
            } while  (get_char(port) != '+');
        } else
 #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
@@ -333,7 +331,6 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
        }
        sci_out(port, SCFCR, fcr_val);
 }
-
 #elif defined(CONFIG_CPU_SH3)
 /* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */
 static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
@@ -366,24 +363,28 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
 static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
 {
        unsigned int fcr_val = 0;
+       unsigned short data;
 
-       if (cflag & CRTSCTS) {
-               fcr_val |= SCFCR_MCE;
-
-               ctrl_outw(0x0000, PORT_PSCR);
-       } else {
-               unsigned short data;
-
-               data = ctrl_inw(PORT_PSCR);
-               data &= 0x033f;
-               data |= 0x0400;
-               ctrl_outw(data, PORT_PSCR);
+       if (port->mapbase == 0xffe00000) {
+               data = ctrl_inw(PSCR);
+               data &= ~0x03cf;
+               if (cflag & CRTSCTS)
+                       fcr_val |= SCFCR_MCE;
+               else
+                       data |= 0x0340;
 
-               ctrl_outw(ctrl_inw(SCSPTR0) & 0x17, SCSPTR0);
+               ctrl_outw(data, PSCR);
        }
+       /* SCIF1 and SCIF2 should be setup by board code */
 
        sci_out(port, SCFCR, fcr_val);
 }
+#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
+static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
+{
+       /* Nothing to do here.. */
+       sci_out(port, SCFCR, 0);
+}
 #else
 /* For SH7750 */
 static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
@@ -414,12 +415,12 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
     defined(CONFIG_CPU_SUBTYPE_SH7785)
 static inline int scif_txroom(struct uart_port *port)
 {
-       return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f);
+       return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
 }
 
 static inline int scif_rxroom(struct uart_port *port)
 {
-       return sci_in(port, SCRFDR) & 0x7f;
+       return sci_in(port, SCRFDR) & 0xff;
 }
 #else
 static inline int scif_txroom(struct uart_port *port)
@@ -850,7 +851,7 @@ static int sci_notifier(struct notifier_block *self,
 
                printk(KERN_INFO "%s: got a postchange notification "
                       "for cpu %d (old %d, new %d)\n",
-                      __FUNCTION__, freqs->cpu, freqs->old, freqs->new);
+                      __func__, freqs->cpu, freqs->old, freqs->new);
        }
 
        return NOTIFY_OK;
@@ -1552,3 +1553,4 @@ module_init(sci_init);
 module_exit(sci_exit);
 
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:sh-sci");