| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: sh-sci.h,v 1.4 2004/02/19 16:43:56 lethal Exp $ | 
|  | 2 | * | 
|  | 3 | *  linux/drivers/serial/sh-sci.h | 
|  | 4 | * | 
|  | 5 | *  SuperH on-chip serial module support.  (SCI with no FIFO / with FIFO) | 
|  | 6 | *  Copyright (C) 1999, 2000  Niibe Yutaka | 
|  | 7 | *  Copyright (C) 2000  Greg Banks | 
|  | 8 | *  Copyright (C) 2002, 2003  Paul Mundt | 
|  | 9 | *  Modified to support multiple serial ports. Stuart Menefy (May 2000). | 
|  | 10 | *  Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003). | 
|  | 11 | *  Modified to support H8/300 Series Yoshinori Sato (Feb 2004). | 
|  | 12 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/serial_core.h> | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 14 | #include <asm/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  | 
|  | 16 | #if defined(__H8300H__) || defined(__H8300S__) | 
|  | 17 | #include <asm/gpio.h> | 
|  | 18 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) | 
|  | 19 | #include <asm/regs306x.h> | 
|  | 20 | #endif | 
|  | 21 | #if defined(CONFIG_H8S2678) | 
|  | 22 | #include <asm/regs267x.h> | 
|  | 23 | #endif | 
|  | 24 | #endif | 
|  | 25 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | # define SCSPTR 0xffffff7c /* 8 bit */ | 
|  | 28 | # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 29 | # define SCI_ONLY | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 30 | #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \ | 
|  | 31 | defined(CONFIG_CPU_SUBTYPE_SH7709) || \ | 
|  | 32 | defined(CONFIG_CPU_SUBTYPE_SH7706) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | # define SCPCR  0xA4000116 /* 16 bit SCI and SCIF */ | 
|  | 34 | # define SCPDR  0xA4000136 /* 8  bit SCI and SCIF */ | 
|  | 35 | # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 36 | # define SCI_AND_SCIF | 
|  | 37 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 
|  | 38 | # define SCIF0		0xA4400000 | 
|  | 39 | # define SCIF2		0xA4410000 | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 40 | # define SCSMR_Ir	0xA44A0000 | 
|  | 41 | # define IRDA_SCIF	SCIF0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | # define SCPCR 0xA4000116 | 
|  | 43 | # define SCPDR 0xA4000136 | 
|  | 44 |  | 
|  | 45 | /* Set the clock source, | 
|  | 46 | * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input | 
|  | 47 | * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output | 
|  | 48 | */ | 
|  | 49 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 | 
|  | 50 | # define SCIF_ONLY | 
|  | 51 | #elif defined(CONFIG_SH_RTS7751R2D) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ | 
|  | 53 | # define SCIF_ORER 0x0001   /* overrun error bit */ | 
|  | 54 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 55 | # define SCIF_ONLY | 
|  | 56 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | # define SCSPTR1 0xffe0001c /* 8  bit SCI */ | 
|  | 58 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ | 
|  | 59 | # define SCIF_ORER 0x0001   /* overrun error bit */ | 
|  | 60 | # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ | 
|  | 61 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ | 
|  | 62 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) | 
|  | 63 | # define SCI_AND_SCIF | 
|  | 64 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 65 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ | 
|  | 66 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ | 
|  | 67 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | # define SCIF_ORER 0x0001  /* overrun error bit */ | 
|  | 69 | # define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 70 | # define SCIF_ONLY | 
|  | 71 | #elif defined(CONFIG_CPU_SUBTYPE_SH7300) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | # define SCPCR  0xA4050116        /* 16 bit SCIF */ | 
|  | 73 | # define SCPDR  0xA4050136        /* 16 bit SCIF */ | 
|  | 74 | # define SCSCR_INIT(port)  0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 75 | # define SCIF_ONLY | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 76 | #elif defined(CONFIG_CPU_SUBTYPE_SH7710) | 
|  | 77 | # define SCSPTR0 0xA4400000	  /* 16 bit SCIF */ | 
|  | 78 | # define SCSCR_INIT(port)  0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 79 | # define SCIF_ONLY | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #elif defined(CONFIG_CPU_SUBTYPE_SH73180) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | # define SCPDR  0xA4050138        /* 16 bit SCIF */ | 
|  | 82 | # define SCSPTR2 SCPDR | 
|  | 83 | # define SCIF_ORER 0x0001   /* overrun error bit */ | 
|  | 84 | # define SCSCR_INIT(port)  0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 85 | # define SCIF_ONLY | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 86 | #elif defined(CONFIG_CPU_SUBTYPE_SH7343) | 
|  | 87 | # define SCSPTR0 0xffe00010	/* 16 bit SCIF */ | 
|  | 88 | # define SCSPTR1 0xffe10010	/* 16 bit SCIF */ | 
|  | 89 | # define SCSPTR2 0xffe20010	/* 16 bit SCIF */ | 
|  | 90 | # define SCSPTR3 0xffe30010	/* 16 bit SCIF */ | 
|  | 91 | # define SCSCR_INIT(port) 0x32	/* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */ | 
|  | 92 | # define SCIF_ONLY | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ | 
|  | 95 | # define SCIF_ORER 0x0001   /* overrun error bit */ | 
|  | 96 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 97 | # define SCIF_ONLY | 
|  | 98 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | # define SCSPTR1 0xffe00020 /* 16 bit SCIF */ | 
|  | 100 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ | 
|  | 101 | # define SCIF_ORER 0x0001   /* overrun error bit */ | 
|  | 102 | # define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 103 | # define SCIF_ONLY | 
|  | 104 | #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) | 
|  | 105 | # include <asm/hardware.h> | 
|  | 106 | # define SCIF_BASE_ADDR    0x01030000 | 
|  | 107 | # define SCIF_ADDR_SH5     PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR | 
|  | 108 | # define SCIF_PTR2_OFFS    0x0000020 | 
|  | 109 | # define SCIF_LSR2_OFFS    0x0000024 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | # define SCSPTR2           ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ | 
|  | 111 | # define SCLSR2            ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ | 
|  | 112 | # define SCSCR_INIT(port)  0x38                           /* TIE=0,RIE=0, | 
|  | 113 | TE=1,RE=1,REIE=1 */ | 
|  | 114 | # define SCIF_ONLY | 
|  | 115 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 117 | # define SCI_ONLY | 
|  | 118 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) | 
|  | 119 | #elif defined(CONFIG_H8S2678) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 
|  | 121 | # define SCI_ONLY | 
|  | 122 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 123 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) | 
|  | 124 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ | 
|  | 125 | # define SCSPTR1 0xff924020 /* 16 bit SCIF */ | 
|  | 126 | # define SCSPTR2 0xff925020 /* 16 bit SCIF */ | 
|  | 127 | # define SCIF_ORER 0x0001  /* overrun error bit */ | 
|  | 128 | # define SCSCR_INIT(port)	0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */ | 
|  | 129 | # define SCIF_ONLY | 
|  | 130 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | 
|  | 131 | # define SCSPTR0	0xffe00024	/* 16 bit SCIF */ | 
|  | 132 | # define SCSPTR1	0xffe10024	/* 16 bit SCIF */ | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 133 | # define SCIF_ORER	0x0001		/* Overrun error bit */ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 134 | # define SCSCR_INIT(port)	0x3a	/* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 135 | # define SCIF_ONLY | 
| Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 136 | #elif defined(CONFIG_CPU_SUBTYPE_SH7206) | 
|  | 137 | # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ | 
|  | 138 | # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */ | 
|  | 139 | # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */ | 
|  | 140 | # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */ | 
|  | 141 | # define SCSCR_INIT(port)	0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 142 | # define SCIF_ONLY | 
|  | 143 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) | 
|  | 144 | # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ | 
|  | 145 | # define SCSPTR1 0xf8410020 /* 16 bit SCIF */ | 
|  | 146 | # define SCSPTR2 0xf8420020 /* 16 bit SCIF */ | 
|  | 147 | # define SCIF_ORER 0x0001  /* overrun error bit */ | 
|  | 148 | # define SCSCR_INIT(port)	0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 
|  | 149 | # define SCIF_ONLY | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | #else | 
|  | 151 | # error CPU subtype not defined | 
|  | 152 | #endif | 
|  | 153 |  | 
|  | 154 | /* SCSCR */ | 
|  | 155 | #define SCI_CTRL_FLAGS_TIE  0x80 /* all */ | 
|  | 156 | #define SCI_CTRL_FLAGS_RIE  0x40 /* all */ | 
|  | 157 | #define SCI_CTRL_FLAGS_TE   0x20 /* all */ | 
|  | 158 | #define SCI_CTRL_FLAGS_RE   0x10 /* all */ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 159 | #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7780) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ | 
|  | 161 | #else | 
|  | 162 | #define SCI_CTRL_FLAGS_REIE 0 | 
|  | 163 | #endif | 
|  | 164 | /*      SCI_CTRL_FLAGS_MPIE 0x08  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 165 | /*      SCI_CTRL_FLAGS_TEIE 0x04  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 166 | /*      SCI_CTRL_FLAGS_CKE1 0x02  * all */ | 
|  | 167 | /*      SCI_CTRL_FLAGS_CKE0 0x01  * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */ | 
|  | 168 |  | 
|  | 169 | /* SCxSR SCI */ | 
|  | 170 | #define SCI_TDRE  0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 171 | #define SCI_RDRF  0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 172 | #define SCI_ORER  0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 173 | #define SCI_FER   0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 174 | #define SCI_PER   0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 175 | #define SCI_TEND  0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 176 | /*      SCI_MPB   0x02  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 177 | /*      SCI_MPBT  0x01  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ | 
|  | 178 |  | 
|  | 179 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) | 
|  | 180 |  | 
|  | 181 | /* SCxSR SCIF */ | 
|  | 182 | #define SCIF_ER    0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 183 | #define SCIF_TEND  0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 184 | #define SCIF_TDFE  0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 185 | #define SCIF_BRK   0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 186 | #define SCIF_FER   0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 187 | #define SCIF_PER   0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 188 | #define SCIF_RDF   0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 189 | #define SCIF_DR    0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ | 
|  | 190 |  | 
|  | 191 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) | 
|  | 192 | #define SCIF_ORER    0x0200 | 
|  | 193 | #define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) | 
|  | 194 | #define SCIF_RFDC_MASK 0x007f | 
|  | 195 | #define SCIF_TXROOM_MAX 64 | 
|  | 196 | #else | 
|  | 197 | #define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) | 
|  | 198 | #define SCIF_RFDC_MASK 0x001f | 
|  | 199 | #define SCIF_TXROOM_MAX 16 | 
|  | 200 | #endif | 
|  | 201 |  | 
|  | 202 | #if defined(SCI_ONLY) | 
|  | 203 | # define SCxSR_TEND(port)		SCI_TEND | 
|  | 204 | # define SCxSR_ERRORS(port)		SCI_ERRORS | 
|  | 205 | # define SCxSR_RDxF(port)               SCI_RDRF | 
|  | 206 | # define SCxSR_TDxE(port)               SCI_TDRE | 
|  | 207 | # define SCxSR_ORER(port)		SCI_ORER | 
|  | 208 | # define SCxSR_FER(port)		SCI_FER | 
|  | 209 | # define SCxSR_PER(port)		SCI_PER | 
|  | 210 | # define SCxSR_BRK(port)		0x00 | 
|  | 211 | # define SCxSR_RDxF_CLEAR(port)		0xbc | 
|  | 212 | # define SCxSR_ERROR_CLEAR(port)	0xc4 | 
|  | 213 | # define SCxSR_TDxE_CLEAR(port)		0x78 | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 214 | # define SCxSR_BREAK_CLEAR(port)	0xc4 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | #elif defined(SCIF_ONLY) | 
|  | 216 | # define SCxSR_TEND(port)		SCIF_TEND | 
|  | 217 | # define SCxSR_ERRORS(port)		SCIF_ERRORS | 
|  | 218 | # define SCxSR_RDxF(port)               SCIF_RDF | 
|  | 219 | # define SCxSR_TDxE(port)               SCIF_TDFE | 
|  | 220 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) | 
|  | 221 | # define SCxSR_ORER(port)		SCIF_ORER | 
|  | 222 | #else | 
|  | 223 | # define SCxSR_ORER(port)		0x0000 | 
|  | 224 | #endif | 
|  | 225 | # define SCxSR_FER(port)		SCIF_FER | 
|  | 226 | # define SCxSR_PER(port)		SCIF_PER | 
|  | 227 | # define SCxSR_BRK(port)		SCIF_BRK | 
|  | 228 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) | 
|  | 229 | # define SCxSR_RDxF_CLEAR(port)         (sci_in(port,SCxSR)&0xfffc) | 
|  | 230 | # define SCxSR_ERROR_CLEAR(port)        (sci_in(port,SCxSR)&0xfd73) | 
|  | 231 | # define SCxSR_TDxE_CLEAR(port)         (sci_in(port,SCxSR)&0xffdf) | 
|  | 232 | # define SCxSR_BREAK_CLEAR(port)        (sci_in(port,SCxSR)&0xffe3) | 
|  | 233 | #else | 
|  | 234 | /* SH7705 can also use this, clearing is same between 7705 and 7709 and 7300 */ | 
|  | 235 | # define SCxSR_RDxF_CLEAR(port)		0x00fc | 
|  | 236 | # define SCxSR_ERROR_CLEAR(port)	0x0073 | 
|  | 237 | # define SCxSR_TDxE_CLEAR(port)		0x00df | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 238 | # define SCxSR_BREAK_CLEAR(port)	0x00e3 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | #endif | 
|  | 240 | #else | 
|  | 241 | # define SCxSR_TEND(port)	 (((port)->type == PORT_SCI) ? SCI_TEND   : SCIF_TEND) | 
|  | 242 | # define SCxSR_ERRORS(port)	 (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) | 
|  | 243 | # define SCxSR_RDxF(port)        (((port)->type == PORT_SCI) ? SCI_RDRF   : SCIF_RDF) | 
|  | 244 | # define SCxSR_TDxE(port)        (((port)->type == PORT_SCI) ? SCI_TDRE   : SCIF_TDFE) | 
|  | 245 | # define SCxSR_ORER(port)        (((port)->type == PORT_SCI) ? SCI_ORER   : 0x0000) | 
|  | 246 | # define SCxSR_FER(port)         (((port)->type == PORT_SCI) ? SCI_FER    : SCIF_FER) | 
|  | 247 | # define SCxSR_PER(port)         (((port)->type == PORT_SCI) ? SCI_PER    : SCIF_PER) | 
|  | 248 | # define SCxSR_BRK(port)         (((port)->type == PORT_SCI) ? 0x00       : SCIF_BRK) | 
|  | 249 | # define SCxSR_RDxF_CLEAR(port)	 (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) | 
|  | 250 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) | 
|  | 251 | # define SCxSR_TDxE_CLEAR(port)  (((port)->type == PORT_SCI) ? 0x78 : 0x00df) | 
|  | 252 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) | 
|  | 253 | #endif | 
|  | 254 |  | 
|  | 255 | /* SCFCR */ | 
|  | 256 | #define SCFCR_RFRST 0x0002 | 
|  | 257 | #define SCFCR_TFRST 0x0004 | 
|  | 258 | #define SCFCR_TCRST 0x4000 | 
|  | 259 | #define SCFCR_MCE   0x0008 | 
|  | 260 |  | 
|  | 261 | #define SCI_MAJOR		204 | 
|  | 262 | #define SCI_MINOR_START		8 | 
|  | 263 |  | 
|  | 264 | /* Generic serial flags */ | 
|  | 265 | #define SCI_RX_THROTTLE		0x0000001 | 
|  | 266 |  | 
|  | 267 | #define SCI_MAGIC 0xbabeface | 
|  | 268 |  | 
|  | 269 | /* | 
|  | 270 | * Events are used to schedule things to happen at timer-interrupt | 
|  | 271 | * time, instead of at rs interrupt time. | 
|  | 272 | */ | 
|  | 273 | #define SCI_EVENT_WRITE_WAKEUP	0 | 
|  | 274 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | #define SCI_IN(size, offset)					\ | 
|  | 276 | unsigned int addr = port->mapbase + (offset);			\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 277 | if ((size) == 8) {						\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | return ctrl_inb(addr);					\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 279 | } else {							\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | return ctrl_inw(addr);					\ | 
|  | 281 | } | 
|  | 282 | #define SCI_OUT(size, offset, value)				\ | 
|  | 283 | unsigned int addr = port->mapbase + (offset);			\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 284 | if ((size) == 8) {						\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | ctrl_outb(value, addr);					\ | 
|  | 286 | } else {							\ | 
|  | 287 | ctrl_outw(value, addr);					\ | 
|  | 288 | } | 
|  | 289 |  | 
|  | 290 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ | 
|  | 291 | static inline unsigned int sci_##name##_in(struct uart_port *port)	\ | 
|  | 292 | {									\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 293 | if (port->type == PORT_SCI) {					\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | SCI_IN(sci_size, sci_offset)					\ | 
|  | 295 | } else {								\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 296 | SCI_IN(scif_size, scif_offset);					\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | }									\ | 
|  | 298 | }									\ | 
|  | 299 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ | 
|  | 300 | {									\ | 
|  | 301 | if (port->type == PORT_SCI) {					\ | 
|  | 302 | SCI_OUT(sci_size, sci_offset, value)				\ | 
|  | 303 | } else {								\ | 
|  | 304 | SCI_OUT(scif_size, scif_offset, value);				\ | 
|  | 305 | }									\ | 
|  | 306 | } | 
|  | 307 |  | 
|  | 308 | #define CPU_SCIF_FNS(name, scif_offset, scif_size)				\ | 
|  | 309 | static inline unsigned int sci_##name##_in(struct uart_port *port)	\ | 
|  | 310 | {									\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 311 | SCI_IN(scif_size, scif_offset);					\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | }									\ | 
|  | 313 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ | 
|  | 314 | {									\ | 
|  | 315 | SCI_OUT(scif_size, scif_offset, value);				\ | 
|  | 316 | } | 
|  | 317 |  | 
|  | 318 | #define CPU_SCI_FNS(name, sci_offset, sci_size)				\ | 
|  | 319 | static inline unsigned int sci_##name##_in(struct uart_port* port)	\ | 
|  | 320 | {									\ | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 321 | SCI_IN(sci_size, sci_offset);					\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | }									\ | 
|  | 323 | static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ | 
|  | 324 | {									\ | 
|  | 325 | SCI_OUT(sci_size, sci_offset, value);				\ | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | #ifdef CONFIG_CPU_SH3 | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 329 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || \ | 
|  | 330 | defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 
|  | 331 | defined(CONFIG_CPU_SUBTYPE_SH7710) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | #define SCIF_FNS(name, scif_offset, scif_size) \ | 
|  | 333 | CPU_SCIF_FNS(name, scif_offset, scif_size) | 
|  | 334 | #else | 
|  | 335 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ | 
|  | 336 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ | 
|  | 337 | h8_sci_offset, h8_sci_size) \ | 
|  | 338 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size) | 
|  | 339 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ | 
|  | 340 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) | 
|  | 341 | #endif | 
|  | 342 | #elif defined(__H8300H__) || defined(__H8300S__) | 
|  | 343 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ | 
|  | 344 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ | 
|  | 345 | h8_sci_offset, h8_sci_size) \ | 
|  | 346 | CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) | 
|  | 347 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) | 
|  | 348 | #else | 
|  | 349 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ | 
|  | 350 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ | 
|  | 351 | h8_sci_offset, h8_sci_size) \ | 
|  | 352 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) | 
|  | 353 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ | 
|  | 354 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) | 
|  | 355 | #endif | 
|  | 356 |  | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 357 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || \ | 
|  | 358 | defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 
|  | 359 | defined(CONFIG_CPU_SUBTYPE_SH7710) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | SCIF_FNS(SCSMR,  0x00, 16) | 
|  | 361 | SCIF_FNS(SCBRR,  0x04,  8) | 
|  | 362 | SCIF_FNS(SCSCR,  0x08, 16) | 
|  | 363 | SCIF_FNS(SCTDSR, 0x0c,  8) | 
|  | 364 | SCIF_FNS(SCFER,  0x10, 16) | 
|  | 365 | SCIF_FNS(SCxSR,  0x14, 16) | 
|  | 366 | SCIF_FNS(SCFCR,  0x18, 16) | 
|  | 367 | SCIF_FNS(SCFDR,  0x1c, 16) | 
|  | 368 | SCIF_FNS(SCxTDR, 0x20,  8) | 
|  | 369 | SCIF_FNS(SCxRDR, 0x24,  8) | 
|  | 370 | SCIF_FNS(SCLSR,  0x24, 16) | 
|  | 371 | #else | 
|  | 372 | /*      reg      SCI/SH3   SCI/SH4  SCIF/SH3   SCIF/SH4  SCI/H8*/ | 
|  | 373 | /*      name     off  sz   off  sz   off  sz   off  sz   off  sz*/ | 
|  | 374 | SCIx_FNS(SCSMR,  0x00,  8, 0x00,  8, 0x00,  8, 0x00, 16, 0x00,  8) | 
|  | 375 | SCIx_FNS(SCBRR,  0x02,  8, 0x04,  8, 0x02,  8, 0x04,  8, 0x01,  8) | 
|  | 376 | SCIx_FNS(SCSCR,  0x04,  8, 0x08,  8, 0x04,  8, 0x08, 16, 0x02,  8) | 
|  | 377 | SCIx_FNS(SCxTDR, 0x06,  8, 0x0c,  8, 0x06,  8, 0x0C,  8, 0x03,  8) | 
|  | 378 | SCIx_FNS(SCxSR,  0x08,  8, 0x10,  8, 0x08, 16, 0x10, 16, 0x04,  8) | 
|  | 379 | SCIx_FNS(SCxRDR, 0x0a,  8, 0x14,  8, 0x0A,  8, 0x14,  8, 0x05,  8) | 
|  | 380 | SCIF_FNS(SCFCR,                      0x0c,  8, 0x18, 16) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 381 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) | 
| Paul Mundt | 6fc21b8 | 2006-11-27 12:10:23 +0900 | [diff] [blame] | 382 | SCIF_FNS(SCFDR,			     0x0e, 16, 0x1C, 16) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 383 | SCIF_FNS(SCTFDR,		     0x0e, 16, 0x1C, 16) | 
|  | 384 | SCIF_FNS(SCRFDR,		     0x0e, 16, 0x20, 16) | 
|  | 385 | SCIF_FNS(SCSPTR,			0,  0, 0x24, 16) | 
|  | 386 | SCIF_FNS(SCLSR,				0,  0, 0x28, 16) | 
|  | 387 | #else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | SCIF_FNS(SCFDR,                      0x0e, 16, 0x1C, 16) | 
|  | 389 | SCIF_FNS(SCSPTR,                        0,  0, 0x20, 16) | 
|  | 390 | SCIF_FNS(SCLSR,                         0,  0, 0x24, 16) | 
|  | 391 | #endif | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 392 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | #define sci_in(port, reg) sci_##reg##_in(port) | 
|  | 394 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) | 
|  | 395 |  | 
|  | 396 | /* H8/300 series SCI pins assignment */ | 
|  | 397 | #if defined(__H8300H__) || defined(__H8300S__) | 
|  | 398 | static const struct __attribute__((packed)) { | 
|  | 399 | int port;             /* GPIO port no */ | 
|  | 400 | unsigned short rx,tx; /* GPIO bit no */ | 
|  | 401 | } h8300_sci_pins[] = { | 
|  | 402 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) | 
|  | 403 | {    /* SCI0 */ | 
|  | 404 | .port = H8300_GPIO_P9, | 
|  | 405 | .rx   = H8300_GPIO_B2, | 
|  | 406 | .tx   = H8300_GPIO_B0, | 
|  | 407 | }, | 
|  | 408 | {    /* SCI1 */ | 
|  | 409 | .port = H8300_GPIO_P9, | 
|  | 410 | .rx   = H8300_GPIO_B3, | 
|  | 411 | .tx   = H8300_GPIO_B1, | 
|  | 412 | }, | 
|  | 413 | {    /* SCI2 */ | 
|  | 414 | .port = H8300_GPIO_PB, | 
|  | 415 | .rx   = H8300_GPIO_B7, | 
|  | 416 | .tx   = H8300_GPIO_B6, | 
|  | 417 | } | 
|  | 418 | #elif defined(CONFIG_H8S2678) | 
|  | 419 | {    /* SCI0 */ | 
|  | 420 | .port = H8300_GPIO_P3, | 
|  | 421 | .rx   = H8300_GPIO_B2, | 
|  | 422 | .tx   = H8300_GPIO_B0, | 
|  | 423 | }, | 
|  | 424 | {    /* SCI1 */ | 
|  | 425 | .port = H8300_GPIO_P3, | 
|  | 426 | .rx   = H8300_GPIO_B3, | 
|  | 427 | .tx   = H8300_GPIO_B1, | 
|  | 428 | }, | 
|  | 429 | {    /* SCI2 */ | 
|  | 430 | .port = H8300_GPIO_P5, | 
|  | 431 | .rx   = H8300_GPIO_B1, | 
|  | 432 | .tx   = H8300_GPIO_B0, | 
|  | 433 | } | 
|  | 434 | #endif | 
|  | 435 | }; | 
|  | 436 | #endif | 
|  | 437 |  | 
|  | 438 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) | 
|  | 439 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 440 | { | 
|  | 441 | if (port->mapbase == 0xfffffe80) | 
|  | 442 | return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */ | 
|  | 443 | return 1; | 
|  | 444 | } | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 445 | #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \ | 
|  | 446 | defined(CONFIG_CPU_SUBTYPE_SH7709) || \ | 
|  | 447 | defined(CONFIG_CPU_SUBTYPE_SH7706) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 449 | { | 
|  | 450 | if (port->mapbase == 0xfffffe80) | 
|  | 451 | return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */ | 
|  | 452 | if (port->mapbase == 0xa4000150) | 
|  | 453 | return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */ | 
|  | 454 | if (port->mapbase == 0xa4000140) | 
|  | 455 | return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */ | 
|  | 456 | return 1; | 
|  | 457 | } | 
|  | 458 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 
|  | 459 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 460 | { | 
|  | 461 | if (port->mapbase == SCIF0) | 
|  | 462 | return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */ | 
|  | 463 | if (port->mapbase == SCIF2) | 
|  | 464 | return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */ | 
|  | 465 | return 1; | 
|  | 466 | } | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 467 | #elif defined(CONFIG_CPU_SUBTYPE_SH7710) | 
|  | 468 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 469 | { | 
|  | 470 | if (port->mapbase == SCSPTR0) | 
|  | 471 | return ctrl_inw(SCSPTR0 + 0x10) & 0x01 ? 1 : 0; | 
|  | 472 | return 1; | 
|  | 473 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ | 
|  | 475 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ | 
|  | 476 | defined(CONFIG_CPU_SUBTYPE_SH4_202) | 
|  | 477 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 478 | { | 
|  | 479 | #ifndef SCIF_ONLY | 
|  | 480 | if (port->mapbase == 0xffe00000) | 
|  | 481 | return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ | 
|  | 482 | #endif | 
|  | 483 | #ifndef SCI_ONLY | 
|  | 484 | if (port->mapbase == 0xffe80000) | 
|  | 485 | return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */ | 
|  | 486 | #endif | 
|  | 487 | return 1; | 
|  | 488 | } | 
|  | 489 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) | 
|  | 490 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 491 | { | 
|  | 492 | if (port->mapbase == 0xfe600000) | 
|  | 493 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 494 | if (port->mapbase == 0xfe610000) | 
|  | 495 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 496 | if (port->mapbase == 0xfe620000) | 
|  | 497 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 498 | } | 
|  | 499 | #elif defined(CONFIG_CPU_SUBTYPE_SH7300) | 
|  | 500 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 501 | { | 
|  | 502 | if (port->mapbase == 0xa4430000) | 
|  | 503 | return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */ | 
|  | 504 | return 1; | 
|  | 505 | } | 
|  | 506 | #elif defined(CONFIG_CPU_SUBTYPE_SH73180) | 
|  | 507 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 508 | { | 
|  | 509 | return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */ | 
|  | 510 | } | 
| Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 511 | #elif defined(CONFIG_CPU_SUBTYPE_SH7343) | 
|  | 512 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 513 | { | 
|  | 514 | if (port->mapbase == 0xffe00000) | 
|  | 515 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 516 | if (port->mapbase == 0xffe10000) | 
|  | 517 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 518 | if (port->mapbase == 0xffe20000) | 
|  | 519 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 520 | if (port->mapbase == 0xffe30000) | 
|  | 521 | return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 522 | return 1; | 
|  | 523 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) | 
|  | 525 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 526 | { | 
|  | 527 | if (port->mapbase == 0xffe00000) | 
|  | 528 | return ctrl_inw(SCSPTR1)&0x0001 ? 1 : 0; /* SCIF */ | 
|  | 529 | else | 
|  | 530 | return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */ | 
|  | 531 |  | 
|  | 532 | } | 
|  | 533 | #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) | 
|  | 534 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 535 | { | 
|  | 536 | return sci_in(port, SCSPTR)&0x0001 ? 1 : 0; /* SCIF */ | 
|  | 537 | } | 
|  | 538 | #elif defined(__H8300H__) || defined(__H8300S__) | 
|  | 539 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 540 | { | 
|  | 541 | int ch = (port->mapbase - SMR0) >> 3; | 
|  | 542 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; | 
|  | 543 | } | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 544 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) | 
|  | 545 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 546 | { | 
|  | 547 | if (port->mapbase == 0xff923000) | 
|  | 548 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 549 | if (port->mapbase == 0xff924000) | 
|  | 550 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 551 | if (port->mapbase == 0xff925000) | 
|  | 552 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 553 | } | 
|  | 554 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | 
|  | 555 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 556 | { | 
|  | 557 | if (port->mapbase == 0xffe00000) | 
|  | 558 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 559 | if (port->mapbase == 0xffe10000) | 
|  | 560 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 561 | } | 
| Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 562 | #elif defined(CONFIG_CPU_SUBTYPE_SH7206) | 
|  | 563 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 564 | { | 
|  | 565 | if (port->mapbase == 0xfffe8000) | 
|  | 566 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 567 | if (port->mapbase == 0xfffe8800) | 
|  | 568 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 569 | if (port->mapbase == 0xfffe9000) | 
|  | 570 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 571 | if (port->mapbase == 0xfffe9800) | 
|  | 572 | return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 573 | } | 
|  | 574 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) | 
|  | 575 | static inline int sci_rxd_in(struct uart_port *port) | 
|  | 576 | { | 
|  | 577 | if (port->mapbase == 0xf8400000) | 
|  | 578 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 579 | if (port->mapbase == 0xf8410000) | 
|  | 580 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 581 | if (port->mapbase == 0xf8420000) | 
|  | 582 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | 
|  | 583 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | #endif | 
|  | 585 |  | 
|  | 586 | /* | 
|  | 587 | * Values for the BitRate Register (SCBRR) | 
|  | 588 | * | 
|  | 589 | * The values are actually divisors for a frequency which can | 
|  | 590 | * be internal to the SH3 (14.7456MHz) or derived from an external | 
|  | 591 | * clock source.  This driver assumes the internal clock is used; | 
|  | 592 | * to support using an external clock source, config options or | 
|  | 593 | * possibly command-line options would need to be added. | 
|  | 594 | * | 
|  | 595 | * Also, to support speeds below 2400 (why?) the lower 2 bits of | 
|  | 596 | * the SCSMR register would also need to be set to non-zero values. | 
|  | 597 | * | 
|  | 598 | * -- Greg Banks 27Feb2000 | 
|  | 599 | * | 
|  | 600 | * Answer: The SCBRR register is only eight bits, and the value in | 
|  | 601 | * it gets larger with lower baud rates. At around 2400 (depending on | 
|  | 602 | * the peripherial module clock) you run out of bits. However the | 
|  | 603 | * lower two bits of SCSMR allow the module clock to be divided down, | 
|  | 604 | * scaling the value which is needed in SCBRR. | 
|  | 605 | * | 
|  | 606 | * -- Stuart Menefy - 23 May 2000 | 
|  | 607 | * | 
|  | 608 | * I meant, why would anyone bother with bitrates below 2400. | 
|  | 609 | * | 
|  | 610 | * -- Greg Banks - 7Jul2000 | 
|  | 611 | * | 
|  | 612 | * You "speedist"!  How will I use my 110bps ASR-33 teletype with paper | 
|  | 613 | * tape reader as a console! | 
|  | 614 | * | 
|  | 615 | * -- Mitch Davis - 15 Jul 2000 | 
|  | 616 | */ | 
|  | 617 |  | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 618 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7780) | 
|  | 619 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 621 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) | 
|  | 622 | #elif defined(__H8300H__) || defined(__H8300S__) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) | 
| Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 624 | #elif defined(CONFIG_SUPERH64) | 
|  | 625 | #define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1) | 
|  | 626 | #else /* Generic SH */ | 
|  | 627 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | #endif |