Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copy and modify from linux/drivers/serial/sh-sci.h |
| 3 | */ |
| 4 | |
| 5 | struct uart_port { |
| 6 | unsigned long iobase; /* in/out[bwl] */ |
| 7 | unsigned char *membase; /* read/write[bwl] */ |
| 8 | unsigned long mapbase; /* for ioremap */ |
| 9 | unsigned int type; /* port type */ |
| 10 | }; |
| 11 | |
| 12 | #define PORT_SCI 52 |
| 13 | #define PORT_SCIF 53 |
| 14 | #define PORT_SCIFA 83 |
| 15 | #define PORT_SCIFB 93 |
| 16 | |
| 17 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 18 | #include <asm/regs306x.h> |
| 19 | #endif |
| 20 | #if defined(CONFIG_H8S2678) |
| 21 | #include <asm/regs267x.h> |
| 22 | #endif |
| 23 | |
| 24 | #if defined(CONFIG_CPU_SH7706) || \ |
| 25 | defined(CONFIG_CPU_SH7707) || \ |
| 26 | defined(CONFIG_CPU_SH7708) || \ |
| 27 | defined(CONFIG_CPU_SH7709) |
| 28 | # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ |
| 29 | # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ |
| 30 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
| 31 | #elif defined(CONFIG_CPU_SH7705) |
| 32 | # define SCIF0 0xA4400000 |
| 33 | # define SCIF2 0xA4410000 |
| 34 | # define SCSMR_Ir 0xA44A0000 |
| 35 | # define IRDA_SCIF SCIF0 |
| 36 | # define SCPCR 0xA4000116 |
| 37 | # define SCPDR 0xA4000136 |
| 38 | |
| 39 | /* Set the clock source, |
| 40 | * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input |
| 41 | * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output |
| 42 | */ |
| 43 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 |
| 44 | #elif defined(CONFIG_CPU_SH7720) || \ |
| 45 | defined(CONFIG_CPU_SH7721) || \ |
| 46 | defined(CONFIG_ARCH_SH7367) || \ |
| 47 | defined(CONFIG_ARCH_SH7377) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 48 | defined(CONFIG_ARCH_SH7372) || \ |
| 49 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 50 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ |
| 51 | # define PORT_PTCR 0xA405011EUL |
| 52 | # define PORT_PVCR 0xA4050122UL |
| 53 | # define SCIF_ORER 0x0200 /* overrun error bit */ |
| 54 | #elif defined(CONFIG_SH_RTS7751R2D) |
| 55 | # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */ |
| 56 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 57 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 58 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 59 | #elif defined(CONFIG_CPU_SH7750) || \ |
| 60 | defined(CONFIG_CPU_SH7750R) || \ |
| 61 | defined(CONFIG_CPU_SH7750S) || \ |
| 62 | defined(CONFIG_CPU_SH7091) || \ |
| 63 | defined(CONFIG_CPU_SH7751) || \ |
| 64 | defined(CONFIG_CPU_SH7751R) |
| 65 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
| 66 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 67 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 68 | # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ |
| 69 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ |
| 70 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */) |
| 71 | #elif defined(CONFIG_CPU_SH7760) |
| 72 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ |
| 73 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ |
| 74 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ |
| 75 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 76 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 77 | #elif defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712) |
| 78 | # define SCSPTR0 0xA4400000 /* 16 bit SCIF */ |
| 79 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 80 | # define PACR 0xa4050100 |
| 81 | # define PBCR 0xa4050102 |
| 82 | # define SCSCR_INIT(port) 0x3B |
| 83 | #elif defined(CONFIG_CPU_SH7343) |
| 84 | # define SCSPTR0 0xffe00010 /* 16 bit SCIF */ |
| 85 | # define SCSPTR1 0xffe10010 /* 16 bit SCIF */ |
| 86 | # define SCSPTR2 0xffe20010 /* 16 bit SCIF */ |
| 87 | # define SCSPTR3 0xffe30010 /* 16 bit SCIF */ |
| 88 | # define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */ |
| 89 | #elif defined(CONFIG_CPU_SH7722) |
| 90 | # define PADR 0xA4050120 |
Nobuhiro Iwamatsu | 9905706 | 2010-11-24 13:24:33 +0900 | [diff] [blame] | 91 | # undef PSDR |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 92 | # define PSDR 0xA405013e |
| 93 | # define PWDR 0xA4050166 |
| 94 | # define PSCR 0xA405011E |
| 95 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 96 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 97 | #elif defined(CONFIG_CPU_SH7366) |
| 98 | # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ |
| 99 | # define SCSPTR0 SCPDR0 |
| 100 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 101 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 102 | #elif defined(CONFIG_CPU_SH7723) |
| 103 | # define SCSPTR0 0xa4050160 |
| 104 | # define SCSPTR1 0xa405013e |
| 105 | # define SCSPTR2 0xa4050160 |
| 106 | # define SCSPTR3 0xa405013e |
| 107 | # define SCSPTR4 0xa4050128 |
| 108 | # define SCSPTR5 0xa4050128 |
| 109 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 110 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 111 | #elif defined(CONFIG_CPU_SH7724) |
| 112 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 113 | # define SCSCR_INIT(port) ((port)->type == PORT_SCIFA ? \ |
| 114 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ |
| 115 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */) |
Nobuhiro Iwamatsu | 2a57e7e | 2012-01-11 10:45:01 +0900 | [diff] [blame] | 116 | #elif defined(CONFIG_CPU_SH7734) |
| 117 | # define SCSPTR0 0xFFE40020 |
| 118 | # define SCSPTR1 0xFFE41020 |
| 119 | # define SCSPTR2 0xFFE42020 |
| 120 | # define SCSPTR3 0xFFE43020 |
| 121 | # define SCSPTR4 0xFFE44020 |
| 122 | # define SCSPTR5 0xFFE45020 |
| 123 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 124 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 125 | #elif defined(CONFIG_CPU_SH4_202) |
| 126 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
| 127 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 128 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 129 | #elif defined(CONFIG_CPU_SH5_101) || defined(CONFIG_CPU_SH5_103) |
| 130 | # define SCIF_BASE_ADDR 0x01030000 |
| 131 | # define SCIF_ADDR_SH5 (PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR) |
| 132 | # define SCIF_PTR2_OFFS 0x0000020 |
| 133 | # define SCIF_LSR2_OFFS 0x0000024 |
| 134 | # define SCSPTR\ |
| 135 | ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ |
| 136 | # define SCLSR2\ |
| 137 | ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ |
| 138 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */ |
| 139 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 140 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
| 141 | # define H8300_SCI_DR(ch) (*(volatile char *)(P1DR + h8300_sci_pins[ch].port)) |
| 142 | #elif defined(CONFIG_H8S2678) |
| 143 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
| 144 | # define H8300_SCI_DR(ch) (*(volatile char *)(P1DR + h8300_sci_pins[ch].port)) |
| 145 | #elif defined(CONFIG_CPU_SH7757) |
| 146 | # define SCSPTR0 0xfe4b0020 |
| 147 | # define SCSPTR1 0xfe4b0020 |
| 148 | # define SCSPTR2 0xfe4b0020 |
| 149 | # define SCIF_ORER 0x0001 |
| 150 | # define SCSCR_INIT(port) 0x38 |
| 151 | # define SCIF_ONLY |
| 152 | #elif defined(CONFIG_CPU_SH7763) |
| 153 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 154 | # define SCSPTR1 0xffe08024 /* 16 bit SCIF */ |
| 155 | # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */ |
| 156 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 157 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 158 | #elif defined(CONFIG_CPU_SH7770) |
| 159 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ |
| 160 | # define SCSPTR1 0xff924020 /* 16 bit SCIF */ |
| 161 | # define SCSPTR2 0xff925020 /* 16 bit SCIF */ |
| 162 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 163 | # define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */ |
| 164 | #elif defined(CONFIG_CPU_SH7780) |
| 165 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 166 | # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ |
| 167 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
| 168 | |
| 169 | #if defined(CONFIG_SH_SH2007) |
| 170 | /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=0 */ |
| 171 | # define SCSCR_INIT(port) 0x38 |
| 172 | #else |
| 173 | /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=1 */ |
| 174 | # define SCSCR_INIT(port) 0x3a |
| 175 | #endif |
| 176 | |
| 177 | #elif defined(CONFIG_CPU_SH7785) || \ |
| 178 | defined(CONFIG_CPU_SH7786) |
| 179 | # define SCSPTR0 0xffea0024 /* 16 bit SCIF */ |
| 180 | # define SCSPTR1 0xffeb0024 /* 16 bit SCIF */ |
| 181 | # define SCSPTR2 0xffec0024 /* 16 bit SCIF */ |
| 182 | # define SCSPTR3 0xffed0024 /* 16 bit SCIF */ |
| 183 | # define SCSPTR4 0xffee0024 /* 16 bit SCIF */ |
| 184 | # define SCSPTR5 0xffef0024 /* 16 bit SCIF */ |
| 185 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
| 186 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 187 | #elif defined(CONFIG_CPU_SH7201) || \ |
| 188 | defined(CONFIG_CPU_SH7203) || \ |
| 189 | defined(CONFIG_CPU_SH7206) || \ |
Phil Edworthy | 7fbeb64 | 2011-06-01 07:35:13 +0100 | [diff] [blame] | 190 | defined(CONFIG_CPU_SH7263) || \ |
| 191 | defined(CONFIG_CPU_SH7264) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 192 | # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ |
| 193 | # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */ |
| 194 | # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */ |
| 195 | # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */ |
| 196 | # if defined(CONFIG_CPU_SH7201) |
| 197 | # define SCSPTR4 0xfffeA020 /* 16 bit SCIF */ |
| 198 | # define SCSPTR5 0xfffeA820 /* 16 bit SCIF */ |
| 199 | # define SCSPTR6 0xfffeB020 /* 16 bit SCIF */ |
| 200 | # define SCSPTR7 0xfffeB820 /* 16 bit SCIF */ |
| 201 | # endif |
| 202 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Phil Edworthy | 99744b7 | 2012-05-15 22:15:51 +0000 | [diff] [blame] | 203 | #elif defined(CONFIG_CPU_SH7269) |
| 204 | # define SCSPTR0 0xe8007020 /* 16 bit SCIF */ |
| 205 | # define SCSPTR1 0xe8007820 /* 16 bit SCIF */ |
| 206 | # define SCSPTR2 0xe8008020 /* 16 bit SCIF */ |
| 207 | # define SCSPTR3 0xe8008820 /* 16 bit SCIF */ |
| 208 | # define SCSPTR4 0xe8009020 /* 16 bit SCIF */ |
| 209 | # define SCSPTR5 0xe8009820 /* 16 bit SCIF */ |
| 210 | # define SCSPTR6 0xe800a020 /* 16 bit SCIF */ |
| 211 | # define SCSPTR7 0xe800a820 /* 16 bit SCIF */ |
| 212 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 213 | #elif defined(CONFIG_CPU_SH7619) |
| 214 | # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ |
| 215 | # define SCSPTR1 0xf8410020 /* 16 bit SCIF */ |
| 216 | # define SCSPTR2 0xf8420020 /* 16 bit SCIF */ |
| 217 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 218 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 219 | #elif defined(CONFIG_CPU_SHX3) |
| 220 | # define SCSPTR0 0xffc30020 /* 16 bit SCIF */ |
| 221 | # define SCSPTR1 0xffc40020 /* 16 bit SCIF */ |
| 222 | # define SCSPTR2 0xffc50020 /* 16 bit SCIF */ |
| 223 | # define SCSPTR3 0xffc60020 /* 16 bit SCIF */ |
| 224 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
| 225 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
| 226 | #else |
| 227 | # error CPU subtype not defined |
| 228 | #endif |
| 229 | |
| 230 | /* SCSCR */ |
| 231 | #define SCI_CTRL_FLAGS_TIE 0x80 /* all */ |
| 232 | #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ |
| 233 | #define SCI_CTRL_FLAGS_TE 0x20 /* all */ |
| 234 | #define SCI_CTRL_FLAGS_RE 0x10 /* all */ |
| 235 | #if defined(CONFIG_CPU_SH7750) || \ |
| 236 | defined(CONFIG_CPU_SH7091) || \ |
| 237 | defined(CONFIG_CPU_SH7750R) || \ |
| 238 | defined(CONFIG_CPU_SH7722) || \ |
Nobuhiro Iwamatsu | 2a57e7e | 2012-01-11 10:45:01 +0900 | [diff] [blame] | 239 | defined(CONFIG_CPU_SH7734) || \ |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 240 | defined(CONFIG_CPU_SH7750S) || \ |
| 241 | defined(CONFIG_CPU_SH7751) || \ |
| 242 | defined(CONFIG_CPU_SH7751R) || \ |
| 243 | defined(CONFIG_CPU_SH7763) || \ |
| 244 | defined(CONFIG_CPU_SH7780) || \ |
| 245 | defined(CONFIG_CPU_SH7785) || \ |
| 246 | defined(CONFIG_CPU_SH7786) || \ |
| 247 | defined(CONFIG_CPU_SHX3) |
| 248 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ |
| 249 | #elif defined(CONFIG_CPU_SH7724) |
| 250 | #define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8) |
| 251 | #else |
| 252 | #define SCI_CTRL_FLAGS_REIE 0 |
| 253 | #endif |
| 254 | /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 255 | /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 256 | /* SCI_CTRL_FLAGS_CKE1 0x02 * all */ |
| 257 | /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */ |
| 258 | |
| 259 | /* SCxSR SCI */ |
| 260 | #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 261 | #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 262 | #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 263 | #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 264 | #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 265 | #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 266 | /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 267 | /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 268 | |
| 269 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) |
| 270 | |
| 271 | /* SCxSR SCIF */ |
| 272 | #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 273 | #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 274 | #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 275 | #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 276 | #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 277 | #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 278 | #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 279 | #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 280 | |
| 281 | #if defined(CONFIG_CPU_SH7705) || \ |
| 282 | defined(CONFIG_CPU_SH7720) || \ |
| 283 | defined(CONFIG_CPU_SH7721) || \ |
| 284 | defined(CONFIG_ARCH_SH7367) || \ |
| 285 | defined(CONFIG_ARCH_SH7377) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 286 | defined(CONFIG_ARCH_SH7372) || \ |
| 287 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 288 | # define SCIF_ORER 0x0200 |
| 289 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
| 290 | # define SCIF_RFDC_MASK 0x007f |
| 291 | # define SCIF_TXROOM_MAX 64 |
| 292 | #elif defined(CONFIG_CPU_SH7763) |
| 293 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 294 | # define SCIF_RFDC_MASK 0x007f |
| 295 | # define SCIF_TXROOM_MAX 64 |
| 296 | /* SH7763 SCIF2 support */ |
| 297 | # define SCIF2_RFDC_MASK 0x001f |
| 298 | # define SCIF2_TXROOM_MAX 16 |
| 299 | #else |
| 300 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 301 | # define SCIF_RFDC_MASK 0x001f |
| 302 | # define SCIF_TXROOM_MAX 16 |
| 303 | #endif |
| 304 | |
| 305 | #ifndef SCIF_ORER |
| 306 | #define SCIF_ORER 0x0000 |
| 307 | #endif |
| 308 | |
| 309 | #define SCxSR_TEND(port)\ |
| 310 | (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
| 311 | #define SCxSR_ERRORS(port)\ |
| 312 | (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) |
| 313 | #define SCxSR_RDxF(port)\ |
| 314 | (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) |
| 315 | #define SCxSR_TDxE(port)\ |
| 316 | (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) |
| 317 | #define SCxSR_FER(port)\ |
| 318 | (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) |
| 319 | #define SCxSR_PER(port)\ |
| 320 | (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) |
| 321 | #define SCxSR_BRK(port)\ |
| 322 | ((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) |
| 323 | #define SCxSR_ORER(port)\ |
| 324 | (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) |
| 325 | |
| 326 | #if defined(CONFIG_CPU_SH7705) || \ |
| 327 | defined(CONFIG_CPU_SH7720) || \ |
| 328 | defined(CONFIG_CPU_SH7721) || \ |
| 329 | defined(CONFIG_ARCH_SH7367) || \ |
| 330 | defined(CONFIG_ARCH_SH7377) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 331 | defined(CONFIG_ARCH_SH7372) || \ |
| 332 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 333 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
| 334 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
| 335 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
| 336 | # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) |
| 337 | #else |
| 338 | # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) |
| 339 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) |
| 340 | # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) |
| 341 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) |
| 342 | #endif |
| 343 | |
| 344 | /* SCFCR */ |
| 345 | #define SCFCR_RFRST 0x0002 |
| 346 | #define SCFCR_TFRST 0x0004 |
| 347 | #define SCFCR_TCRST 0x4000 |
| 348 | #define SCFCR_MCE 0x0008 |
| 349 | |
| 350 | #define SCI_MAJOR 204 |
| 351 | #define SCI_MINOR_START 8 |
| 352 | |
| 353 | /* Generic serial flags */ |
| 354 | #define SCI_RX_THROTTLE 0x0000001 |
| 355 | |
| 356 | #define SCI_MAGIC 0xbabeface |
| 357 | |
| 358 | /* |
| 359 | * Events are used to schedule things to happen at timer-interrupt |
| 360 | * time, instead of at rs interrupt time. |
| 361 | */ |
| 362 | #define SCI_EVENT_WRITE_WAKEUP 0 |
| 363 | |
| 364 | #define SCI_IN(size, offset)\ |
| 365 | if ((size) == 8) {\ |
| 366 | return readb(port->membase + (offset));\ |
| 367 | } else {\ |
| 368 | return readw(port->membase + (offset));\ |
| 369 | } |
| 370 | #define SCI_OUT(size, offset, value)\ |
| 371 | if ((size) == 8) {\ |
| 372 | writeb(value, port->membase + (offset));\ |
| 373 | } else if ((size) == 16) {\ |
| 374 | writew(value, port->membase + (offset));\ |
| 375 | } |
| 376 | |
| 377 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
| 378 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 379 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\ |
| 380 | SCI_IN(scif_size, scif_offset)\ |
| 381 | } else { /* PORT_SCI or PORT_SCIFA */\ |
| 382 | SCI_IN(sci_size, sci_offset);\ |
| 383 | }\ |
| 384 | }\ |
| 385 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 386 | unsigned int value) {\ |
| 387 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\ |
| 388 | SCI_OUT(scif_size, scif_offset, value)\ |
| 389 | } else { /* PORT_SCI or PORT_SCIFA */\ |
| 390 | SCI_OUT(sci_size, sci_offset, value);\ |
| 391 | }\ |
| 392 | } |
| 393 | |
| 394 | #ifdef CONFIG_H8300 |
| 395 | /* h8300 don't have SCIF */ |
| 396 | #define CPU_SCIF_FNS(name) \ |
| 397 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 398 | return 0;\ |
| 399 | }\ |
| 400 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 401 | unsigned int value) {\ |
| 402 | } |
| 403 | #else |
| 404 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
| 405 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 406 | SCI_IN(scif_size, scif_offset);\ |
| 407 | }\ |
| 408 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 409 | unsigned int value) {\ |
| 410 | SCI_OUT(scif_size, scif_offset, value);\ |
| 411 | } |
| 412 | #endif |
| 413 | |
| 414 | #define CPU_SCI_FNS(name, sci_offset, sci_size)\ |
| 415 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 416 | SCI_IN(sci_size, sci_offset);\ |
| 417 | }\ |
| 418 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 419 | unsigned int value) {\ |
| 420 | SCI_OUT(sci_size, sci_offset, value);\ |
| 421 | } |
| 422 | |
| 423 | #if defined(CONFIG_SH3) || \ |
| 424 | defined(CONFIG_ARCH_SH7367) || \ |
| 425 | defined(CONFIG_ARCH_SH7377) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 426 | defined(CONFIG_ARCH_SH7372) || \ |
| 427 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 428 | #if defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712) |
| 429 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 430 | sh4_sci_offset, sh4_sci_size, \ |
| 431 | sh3_scif_offset, sh3_scif_size, \ |
| 432 | sh4_scif_offset, sh4_scif_size, \ |
| 433 | h8_sci_offset, h8_sci_size) \ |
| 434 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\ |
| 435 | sh4_scif_offset, sh4_scif_size) |
| 436 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\ |
| 437 | sh4_scif_offset, sh4_scif_size) \ |
| 438 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 439 | #elif defined(CONFIG_CPU_SH7705) || \ |
| 440 | defined(CONFIG_CPU_SH7720) || \ |
| 441 | defined(CONFIG_CPU_SH7721) || \ |
| 442 | defined(CONFIG_ARCH_SH7367) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 443 | defined(CONFIG_ARCH_SH7377) || \ |
| 444 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 445 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 446 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 447 | #elif defined(CONFIG_ARCH_SH7372) |
| 448 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 449 | sh4_scifb_offset, sh4_scifb_size) \ |
| 450 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 451 | sh4_scifb_offset, sh4_scifb_size) |
| 452 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 453 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 454 | #else |
| 455 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 456 | sh4_sci_offset, sh4_sci_size, \ |
| 457 | sh3_scif_offset, sh3_scif_size,\ |
| 458 | sh4_scif_offset, sh4_scif_size, \ |
| 459 | h8_sci_offset, h8_sci_size) \ |
| 460 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 461 | sh3_scif_offset, sh3_scif_size) |
| 462 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\ |
| 463 | sh4_scif_offset, sh4_scif_size) \ |
| 464 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) |
| 465 | #endif |
| 466 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 467 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 468 | sh4_sci_offset, sh4_sci_size, \ |
| 469 | sh3_scif_offset, sh3_scif_size,\ |
| 470 | sh4_scif_offset, sh4_scif_size, \ |
| 471 | h8_sci_offset, h8_sci_size) \ |
| 472 | CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) |
| 473 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\ |
| 474 | sh4_scif_offset, sh4_scif_size) \ |
| 475 | CPU_SCIF_FNS(name) |
| 476 | #elif defined(CONFIG_CPU_SH7723) || defined(CONFIG_CPU_SH7724) |
| 477 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 478 | sh4_scif_offset, sh4_scif_size) \ |
| 479 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 480 | sh4_scif_offset, sh4_scif_size) |
| 481 | #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ |
| 482 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 483 | #else |
| 484 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 485 | sh4_sci_offset, sh4_sci_size, \ |
| 486 | sh3_scif_offset, sh3_scif_size,\ |
| 487 | sh4_scif_offset, sh4_scif_size, \ |
| 488 | h8_sci_offset, h8_sci_size) \ |
| 489 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\ |
| 490 | sh4_scif_offset, sh4_scif_size) |
| 491 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, \ |
| 492 | sh4_scif_offset, sh4_scif_size) \ |
| 493 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 494 | #endif |
| 495 | |
| 496 | #if defined(CONFIG_CPU_SH7705) || \ |
| 497 | defined(CONFIG_CPU_SH7720) || \ |
| 498 | defined(CONFIG_CPU_SH7721) || \ |
| 499 | defined(CONFIG_ARCH_SH7367) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 500 | defined(CONFIG_ARCH_SH7377) || \ |
| 501 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 502 | |
| 503 | SCIF_FNS(SCSMR, 0x00, 16) |
| 504 | SCIF_FNS(SCBRR, 0x04, 8) |
| 505 | SCIF_FNS(SCSCR, 0x08, 16) |
| 506 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 507 | SCIF_FNS(SCFER, 0x10, 16) |
| 508 | SCIF_FNS(SCxSR, 0x14, 16) |
| 509 | SCIF_FNS(SCFCR, 0x18, 16) |
| 510 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 511 | SCIF_FNS(SCxTDR, 0x20, 8) |
| 512 | SCIF_FNS(SCxRDR, 0x24, 8) |
| 513 | SCIF_FNS(SCLSR, 0x00, 0) |
| 514 | #elif defined(CONFIG_ARCH_SH7372) |
| 515 | SCIF_FNS(SCSMR, 0x00, 16) |
| 516 | SCIF_FNS(SCBRR, 0x04, 8) |
| 517 | SCIF_FNS(SCSCR, 0x08, 16) |
| 518 | SCIF_FNS(SCTDSR, 0x0c, 16) |
| 519 | SCIF_FNS(SCFER, 0x10, 16) |
| 520 | SCIF_FNS(SCxSR, 0x14, 16) |
| 521 | SCIF_FNS(SCFCR, 0x18, 16) |
| 522 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 523 | SCIF_FNS(SCTFDR, 0x38, 16) |
| 524 | SCIF_FNS(SCRFDR, 0x3c, 16) |
| 525 | SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8) |
| 526 | SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8) |
| 527 | SCIF_FNS(SCLSR, 0x00, 0) |
| 528 | #elif defined(CONFIG_CPU_SH7723) ||\ |
| 529 | defined(CONFIG_CPU_SH7724) |
| 530 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
| 531 | SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) |
| 532 | SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) |
| 533 | SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) |
| 534 | SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) |
| 535 | SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) |
| 536 | SCIx_FNS(SCSPTR, 0, 0, 0, 0) |
| 537 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 538 | SCIF_FNS(SCFER, 0x10, 16) |
| 539 | SCIF_FNS(SCFCR, 0x18, 16) |
| 540 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 541 | SCIF_FNS(SCLSR, 0x24, 16) |
| 542 | #else |
| 543 | /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ |
| 544 | /* name off sz off sz off sz off sz off sz*/ |
| 545 | SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8) |
| 546 | SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8) |
| 547 | SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8) |
| 548 | SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) |
| 549 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) |
| 550 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
| 551 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
| 552 | #if defined(CONFIG_CPU_SH7760) || \ |
| 553 | defined(CONFIG_CPU_SH7780) || \ |
| 554 | defined(CONFIG_CPU_SH7785) || \ |
| 555 | defined(CONFIG_CPU_SH7786) |
| 556 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
| 557 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 558 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 559 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 560 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
| 561 | #elif defined(CONFIG_CPU_SH7763) |
| 562 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
| 563 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) |
| 564 | SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) |
| 565 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 566 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 567 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 568 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
| 569 | #else |
| 570 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
| 571 | #if defined(CONFIG_CPU_SH7722) |
| 572 | SCIF_FNS(SCSPTR, 0, 0, 0, 0) |
| 573 | #else |
| 574 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
| 575 | #endif |
| 576 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
| 577 | #endif |
| 578 | #endif |
| 579 | #define sci_in(port, reg) sci_##reg##_in(port) |
| 580 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
| 581 | |
| 582 | /* H8/300 series SCI pins assignment */ |
| 583 | #if defined(__H8300H__) || defined(__H8300S__) |
| 584 | static const struct __attribute__((packed)) { |
| 585 | int port; /* GPIO port no */ |
| 586 | unsigned short rx, tx; /* GPIO bit no */ |
| 587 | } h8300_sci_pins[] = { |
| 588 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 589 | { /* SCI0 */ |
| 590 | .port = H8300_GPIO_P9, |
| 591 | .rx = H8300_GPIO_B2, |
| 592 | .tx = H8300_GPIO_B0, |
| 593 | }, |
| 594 | { /* SCI1 */ |
| 595 | .port = H8300_GPIO_P9, |
| 596 | .rx = H8300_GPIO_B3, |
| 597 | .tx = H8300_GPIO_B1, |
| 598 | }, |
| 599 | { /* SCI2 */ |
| 600 | .port = H8300_GPIO_PB, |
| 601 | .rx = H8300_GPIO_B7, |
| 602 | .tx = H8300_GPIO_B6, |
| 603 | } |
| 604 | #elif defined(CONFIG_H8S2678) |
| 605 | { /* SCI0 */ |
| 606 | .port = H8300_GPIO_P3, |
| 607 | .rx = H8300_GPIO_B2, |
| 608 | .tx = H8300_GPIO_B0, |
| 609 | }, |
| 610 | { /* SCI1 */ |
| 611 | .port = H8300_GPIO_P3, |
| 612 | .rx = H8300_GPIO_B3, |
| 613 | .tx = H8300_GPIO_B1, |
| 614 | }, |
| 615 | { /* SCI2 */ |
| 616 | .port = H8300_GPIO_P5, |
| 617 | .rx = H8300_GPIO_B1, |
| 618 | .tx = H8300_GPIO_B0, |
| 619 | } |
| 620 | #endif |
| 621 | }; |
| 622 | #endif |
| 623 | |
| 624 | #if defined(CONFIG_CPU_SH7706) || \ |
| 625 | defined(CONFIG_CPU_SH7707) || \ |
| 626 | defined(CONFIG_CPU_SH7708) || \ |
| 627 | defined(CONFIG_CPU_SH7709) |
| 628 | static inline int sci_rxd_in(struct uart_port *port) |
| 629 | { |
| 630 | if (port->mapbase == 0xfffffe80) |
| 631 | return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */ |
| 632 | return 1; |
| 633 | } |
| 634 | #elif defined(CONFIG_CPU_SH7750) || \ |
| 635 | defined(CONFIG_CPU_SH7751) || \ |
| 636 | defined(CONFIG_CPU_SH7751R) || \ |
| 637 | defined(CONFIG_CPU_SH7750R) || \ |
| 638 | defined(CONFIG_CPU_SH7750S) || \ |
| 639 | defined(CONFIG_CPU_SH7091) |
| 640 | static inline int sci_rxd_in(struct uart_port *port) |
| 641 | { |
| 642 | if (port->mapbase == 0xffe00000) |
| 643 | return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ |
| 644 | return 1; |
| 645 | } |
| 646 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 647 | static inline int sci_rxd_in(struct uart_port *port) |
| 648 | { |
| 649 | int ch = (port->mapbase - SMR0) >> 3; |
| 650 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; |
| 651 | } |
| 652 | #else /* default case for non-SCI processors */ |
| 653 | static inline int sci_rxd_in(struct uart_port *port) |
| 654 | { |
| 655 | return 1; |
| 656 | } |
| 657 | #endif |
| 658 | |
| 659 | /* |
| 660 | * Values for the BitRate Register (SCBRR) |
| 661 | * |
| 662 | * The values are actually divisors for a frequency which can |
| 663 | * be internal to the SH3 (14.7456MHz) or derived from an external |
| 664 | * clock source. This driver assumes the internal clock is used; |
| 665 | * to support using an external clock source, config options or |
| 666 | * possibly command-line options would need to be added. |
| 667 | * |
| 668 | * Also, to support speeds below 2400 (why?) the lower 2 bits of |
| 669 | * the SCSMR register would also need to be set to non-zero values. |
| 670 | * |
| 671 | * -- Greg Banks 27Feb2000 |
| 672 | * |
| 673 | * Answer: The SCBRR register is only eight bits, and the value in |
| 674 | * it gets larger with lower baud rates. At around 2400 (depending on |
| 675 | * the peripherial module clock) you run out of bits. However the |
| 676 | * lower two bits of SCSMR allow the module clock to be divided down, |
| 677 | * scaling the value which is needed in SCBRR. |
| 678 | * |
| 679 | * -- Stuart Menefy - 23 May 2000 |
| 680 | * |
| 681 | * I meant, why would anyone bother with bitrates below 2400. |
| 682 | * |
| 683 | * -- Greg Banks - 7Jul2000 |
| 684 | * |
| 685 | * You "speedist"! How will I use my 110bps ASR-33 teletype with paper |
| 686 | * tape reader as a console! |
| 687 | * |
| 688 | * -- Mitch Davis - 15 Jul 2000 |
| 689 | */ |
| 690 | |
| 691 | #if (defined(CONFIG_CPU_SH7780) || \ |
| 692 | defined(CONFIG_CPU_SH7785) || \ |
| 693 | defined(CONFIG_CPU_SH7786)) && \ |
| 694 | !defined(CONFIG_SH_SH2007) |
| 695 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) |
| 696 | #elif defined(CONFIG_CPU_SH7705) || \ |
| 697 | defined(CONFIG_CPU_SH7720) || \ |
| 698 | defined(CONFIG_CPU_SH7721) || \ |
| 699 | defined(CONFIG_ARCH_SH7367) || \ |
| 700 | defined(CONFIG_ARCH_SH7377) || \ |
Nobuhiro Iwamatsu | c3d6a35 | 2012-06-21 13:21:32 +0900 | [diff] [blame^] | 701 | defined(CONFIG_ARCH_SH7372) || \ |
| 702 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 703 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) |
| 704 | #elif defined(CONFIG_CPU_SH7723) ||\ |
| 705 | defined(CONFIG_CPU_SH7724) |
Nobuhiro Iwamatsu | f3038cd | 2010-11-24 13:42:13 +0900 | [diff] [blame] | 706 | static inline int scbrr_calc(struct uart_port port, int bps, int clk) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 707 | { |
Nobuhiro Iwamatsu | f3038cd | 2010-11-24 13:42:13 +0900 | [diff] [blame] | 708 | if (port.type == PORT_SCIF) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 709 | return (clk+16*bps)/(32*bps)-1; |
| 710 | else |
| 711 | return ((clk*2)+16*bps)/(16*bps)-1; |
| 712 | } |
Nobuhiro Iwamatsu | f3038cd | 2010-11-24 13:42:13 +0900 | [diff] [blame] | 713 | #define SCBRR_VALUE(bps, clk) scbrr_calc(sh_sci, bps, clk) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 714 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 715 | #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) |
Nobuhiro Iwamatsu | 3f6c8e3 | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 716 | #else /* Generic SH */ |
| 717 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) |
| 718 | #endif |