Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux...
[pandora-kernel.git] / drivers / serial / sh-sci.h
index 1b2ce15..b223d6c 100644 (file)
@@ -1,5 +1,5 @@
 #include <linux/serial_core.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/gpio.h>
 
 #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
 # define SCPCR 0xA4000116
 # define SCPDR 0xA4000136
 #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7721)
+      defined(CONFIG_CPU_SUBTYPE_SH7721) || \
+      defined(CONFIG_ARCH_SH73A0) || \
+      defined(CONFIG_ARCH_SH7367) || \
+      defined(CONFIG_ARCH_SH7377) || \
+      defined(CONFIG_ARCH_SH7372)
 # define PORT_PTCR        0xA405011EUL
 # define PORT_PVCR        0xA4050122UL
 # define SCIF_ORER        0x0200   /* overrun error bit */
 # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
 #elif defined(CONFIG_H8S2678)
 # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
+#elif defined(CONFIG_CPU_SUBTYPE_SH7757)
+# define SCSPTR0 0xfe4b0020
+# define SCSPTR1 0xfe4b0020
+# define SCSPTR2 0xfe4b0020
+# define SCIF_ORER 0x0001
+# define SCIF_ONLY
 #elif defined(CONFIG_CPU_SUBTYPE_SH7763)
 # define SCSPTR0 0xffe00024 /* 16 bit SCIF */
 # define SCSPTR1 0xffe08024 /* 16 bit SCIF */
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7721)
+    defined(CONFIG_CPU_SUBTYPE_SH7721) || \
+    defined(CONFIG_ARCH_SH73A0) || \
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 # define SCIF_ORER    0x0200
 # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
 # define SCIF_RFDC_MASK 0x007f
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7721)
+    defined(CONFIG_CPU_SUBTYPE_SH7721) || \
+    defined(CONFIG_ARCH_SH73A0) || \
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 # define SCxSR_RDxF_CLEAR(port)         (sci_in(port, SCxSR) & 0xfffc)
 # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
 # define SCxSR_TDxE_CLEAR(port)         (sci_in(port, SCxSR) & 0xffdf)
 #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
   static inline unsigned int sci_##name##_in(struct uart_port *port)   \
   {                                                                    \
-    if (port->type == PORT_SCIF) {                                     \
+    if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {         \
       SCI_IN(scif_size, scif_offset)                                   \
     } else {   /* PORT_SCI or PORT_SCIFA */                            \
       SCI_IN(sci_size, sci_offset);                                    \
   }                                                                    \
   static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
   {                                                                    \
-    if (port->type == PORT_SCIF) {                                     \
+    if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {         \
       SCI_OUT(scif_size, scif_offset, value)                           \
     } else {   /* PORT_SCI or PORT_SCIFA */                            \
       SCI_OUT(sci_size, sci_offset, value);                            \
     SCI_OUT(sci_size, sci_offset, value);                              \
   }
 
-#ifdef CONFIG_CPU_SH3
+#if defined(CONFIG_CPU_SH3) || \
+    defined(CONFIG_ARCH_SH73A0) || \
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
                                sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
          CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
 #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
       defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7721)
+      defined(CONFIG_CPU_SUBTYPE_SH7721) || \
+      defined(CONFIG_ARCH_SH73A0) || \
+      defined(CONFIG_ARCH_SH7367) || \
+      defined(CONFIG_ARCH_SH7377)
+#define SCIF_FNS(name, scif_offset, scif_size) \
+  CPU_SCIF_FNS(name, scif_offset, scif_size)
+#elif defined(CONFIG_ARCH_SH7372)
+#define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \
+  CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size)
 #define SCIF_FNS(name, scif_offset, scif_size) \
   CPU_SCIF_FNS(name, scif_offset, scif_size)
 #else
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7721)
+    defined(CONFIG_CPU_SUBTYPE_SH7721) || \
+    defined(CONFIG_ARCH_SH73A0) || \
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377)
 
 SCIF_FNS(SCSMR,  0x00, 16)
 SCIF_FNS(SCBRR,  0x04,  8)
@@ -330,7 +363,21 @@ SCIF_FNS(SCFCR,  0x18, 16)
 SCIF_FNS(SCFDR,  0x1c, 16)
 SCIF_FNS(SCxTDR, 0x20,  8)
 SCIF_FNS(SCxRDR, 0x24,  8)
-SCIF_FNS(SCLSR,  0x24, 16)
+SCIF_FNS(SCLSR,  0x00,  0)
+#elif defined(CONFIG_ARCH_SH7372)
+SCIF_FNS(SCSMR,  0x00, 16)
+SCIF_FNS(SCBRR,  0x04,  8)
+SCIF_FNS(SCSCR,  0x08, 16)
+SCIF_FNS(SCTDSR, 0x0c, 16)
+SCIF_FNS(SCFER,  0x10, 16)
+SCIF_FNS(SCxSR,  0x14, 16)
+SCIF_FNS(SCFCR,  0x18, 16)
+SCIF_FNS(SCFDR,  0x1c, 16)
+SCIF_FNS(SCTFDR, 0x38, 16)
+SCIF_FNS(SCRFDR, 0x3c, 16)
+SCIx_FNS(SCxTDR, 0x20,  8, 0x40,  8)
+SCIx_FNS(SCxRDR, 0x24,  8, 0x60,  8)
+SCIF_FNS(SCLSR,  0x00,  0)
 #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
       defined(CONFIG_CPU_SUBTYPE_SH7724)
 SCIx_FNS(SCSMR,  0x00, 16, 0x00, 16)
@@ -431,35 +478,7 @@ static const struct __attribute__((packed)) {
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xfffffe80)
-               return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
-       if (port->mapbase == 0xa4000150)
-               return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xa4000140)
-               return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == SCIF0)
-               return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
-       if (port->mapbase == SCIF2)
-               return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-         return sci_in(port,SCxSR)&0x0010 ? 1 : 0;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7721)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xa4430000)
-               return sci_in(port, SCxSR) & 0x0003 ? 1 : 0;
-       else if (port->mapbase == 0xa4438000)
-               return sci_in(port, SCxSR) & 0x0003 ? 1 : 0;
+               return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7750)  || \
@@ -471,198 +490,18 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
-       if (port->mapbase == 0xffe80000)
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe80000)
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xfe600000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfe610000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfe620000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe20000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe30000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe00000)
-               return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe00000)
-               return ctrl_inb(PSDR) & 0x02 ? 1 : 0; /* SCIF0 */
-       if (port->mapbase == 0xffe10000)
-               return ctrl_inb(PADR) & 0x40 ? 1 : 0; /* SCIF1 */
-       if (port->mapbase == 0xffe20000)
-               return ctrl_inb(PWDR) & 0x04 ? 1 : 0; /* SCIF2 */
-
+               return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
        return 1;
 }
-#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-        if (port->mapbase == 0xffe00000)
-                return ctrl_inb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */
-        if (port->mapbase == 0xffe10000)
-                return ctrl_inb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */
-        if (port->mapbase == 0xffe20000)
-                return ctrl_inb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */
-        if (port->mapbase == 0xa4e30000)
-                return ctrl_inb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */
-        if (port->mapbase == 0xa4e40000)
-                return ctrl_inb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */
-        if (port->mapbase == 0xa4e50000)
-                return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
-        return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
-#  define SCFSR    0x0010
-#  define SCASSR   0x0014
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->type == PORT_SCIF)
-               return ctrl_inw((port->mapbase + SCFSR))  & SCIF_BRK ? 1 : 0;
-       if (port->type == PORT_SCIFA)
-               return ctrl_inw((port->mapbase + SCASSR)) & SCIF_BRK ? 1 : 0;
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-         return sci_in(port, SCSPTR)&0x0001 ? 1 : 0; /* SCIF */
-}
 #elif defined(__H8300H__) || defined(__H8300S__)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        int ch = (port->mapbase - SMR0) >> 3;
        return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
 }
-#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe08000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */
-
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xff923000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xff924000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xff925000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7786)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xffea0000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffeb0000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffec0000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffed0000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffee0000)
-               return ctrl_inw(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffef0000)
-               return ctrl_inw(SCSPTR5) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7203) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7206) || \
-      defined(CONFIG_CPU_SUBTYPE_SH7263)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xfffe8000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffe8800)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffe9000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffe9800)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
-#if defined(CONFIG_CPU_SUBTYPE_SH7201)
-       if (port->mapbase == 0xfffeA000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffeA800)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffeB000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xfffeB800)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
-#endif
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
-static inline int sci_rxd_in(struct uart_port *port)
-{
-       if (port->mapbase == 0xf8400000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xf8410000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xf8420000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
+#else /* default case for non-SCI processors */
 static inline int sci_rxd_in(struct uart_port *port)
 {
-       if (port->mapbase == 0xffc30000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffc40000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffc50000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-       if (port->mapbase == 0xffc60000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #endif