2 * Copy and modify from linux/drivers/serial/sh-sci.h
5 #include <dm/platform_data/serial_sh.h>
8 unsigned long iobase; /* in/out[bwl] */
9 unsigned char *membase; /* read/write[bwl] */
10 unsigned long mapbase; /* for ioremap */
11 enum sh_serial_type type; /* port type */
12 enum sh_clk_mode clk_mode; /* clock mode */
15 #if defined(CONFIG_CPU_SH7706) || \
16 defined(CONFIG_CPU_SH7707) || \
17 defined(CONFIG_CPU_SH7708) || \
18 defined(CONFIG_CPU_SH7709)
19 # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
20 # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
21 # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
22 #elif defined(CONFIG_CPU_SH7705)
23 # define SCIF0 0xA4400000
24 # define SCIF2 0xA4410000
25 # define SCSMR_Ir 0xA44A0000
26 # define IRDA_SCIF SCIF0
27 # define SCPCR 0xA4000116
28 # define SCPDR 0xA4000136
30 /* Set the clock source,
31 * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input
32 * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output
34 # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
35 #elif defined(CONFIG_CPU_SH7720) || \
36 defined(CONFIG_CPU_SH7721) || \
37 defined(CONFIG_SH73A0) || \
38 defined(CONFIG_R8A7740)
39 # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
40 # define PORT_PTCR 0xA405011EUL
41 # define PORT_PVCR 0xA4050122UL
42 # define SCIF_ORER 0x0200 /* overrun error bit */
43 #elif defined(CONFIG_CPU_SH7750) || \
44 defined(CONFIG_CPU_SH7750R) || \
45 defined(CONFIG_CPU_SH7750S) || \
46 defined(CONFIG_CPU_SH7751) || \
47 defined(CONFIG_CPU_SH7751R)
48 # define SCSPTR1 0xffe0001c /* 8 bit SCI */
49 # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
50 # define SCIF_ORER 0x0001 /* overrun error bit */
51 # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
52 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
53 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */)
54 #elif defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
55 # define SCSPTR0 0xA4400000 /* 16 bit SCIF */
56 # define SCIF_ORER 0x0001 /* overrun error bit */
57 # define PACR 0xa4050100
58 # define PBCR 0xa4050102
59 # define SCSCR_INIT(port) 0x3B
60 #elif defined(CONFIG_CPU_SH7722)
61 # define PADR 0xA4050120
63 # define PSDR 0xA405013e
64 # define PWDR 0xA4050166
65 # define PSCR 0xA405011E
66 # define SCIF_ORER 0x0001 /* overrun error bit */
67 # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
68 #elif defined(CONFIG_CPU_SH7723)
69 # define SCSPTR0 0xa4050160
70 # define SCSPTR1 0xa405013e
71 # define SCSPTR2 0xa4050160
72 # define SCSPTR3 0xa405013e
73 # define SCSPTR4 0xa4050128
74 # define SCSPTR5 0xa4050128
75 # define SCIF_ORER 0x0001 /* overrun error bit */
76 # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
77 #elif defined(CONFIG_CPU_SH7734)
78 # define SCSPTR0 0xFFE40020
79 # define SCSPTR1 0xFFE41020
80 # define SCSPTR2 0xFFE42020
81 # define SCSPTR3 0xFFE43020
82 # define SCSPTR4 0xFFE44020
83 # define SCSPTR5 0xFFE45020
84 # define SCIF_ORER 0x0001 /* overrun error bit */
85 # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
86 #elif defined(CONFIG_CPU_SH7757) || \
87 defined(CONFIG_CPU_SH7752) || \
88 defined(CONFIG_CPU_SH7753)
89 # define SCSPTR0 0xfe4b0020
90 # define SCSPTR1 0xfe4b0020
91 # define SCSPTR2 0xfe4b0020
92 # define SCIF_ORER 0x0001
93 # define SCSCR_INIT(port) 0x38
95 #elif defined(CONFIG_CPU_SH7763)
96 # define SCSPTR0 0xffe00024 /* 16 bit SCIF */
97 # define SCSPTR1 0xffe08024 /* 16 bit SCIF */
98 # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */
99 # define SCIF_ORER 0x0001 /* overrun error bit */
100 # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
101 #elif defined(CONFIG_CPU_SH7780)
102 # define SCSPTR0 0xffe00024 /* 16 bit SCIF */
103 # define SCSPTR1 0xffe10024 /* 16 bit SCIF */
104 # define SCIF_ORER 0x0001 /* Overrun error bit */
106 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=1 */
107 # define SCSCR_INIT(port) 0x3a
109 #elif defined(CONFIG_RZA1)
110 # define SCSPTR0 0xe8007020 /* 16 bit SCIF */
111 # define SCSPTR1 0xe8007820 /* 16 bit SCIF */
112 # define SCSPTR2 0xe8008020 /* 16 bit SCIF */
113 # define SCSPTR3 0xe8008820 /* 16 bit SCIF */
114 # define SCSPTR4 0xe8009020 /* 16 bit SCIF */
115 # define SCSPTR5 0xe8009820 /* 16 bit SCIF */
116 # define SCSPTR6 0xe800a020 /* 16 bit SCIF */
117 # define SCSPTR7 0xe800a820 /* 16 bit SCIF */
118 # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
119 # define SCIF_ORER 0x0001 /* overrun error bit */
120 #elif defined(CONFIG_RCAR_GEN2) || defined(CONFIG_RCAR_GEN3) || \
121 defined(CONFIG_R7S72100)
122 # if defined(CONFIG_SCIF_A)
123 # define SCIF_ORER 0x0200
125 # define SCIF_ORER 0x0001
127 # define SCSCR_INIT(port) (port->clk_mode == EXT_CLK ? 0x32 : 0x30)
128 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0, */
130 # error CPU subtype not defined
134 #define SCI_CTRL_FLAGS_TIE 0x80 /* all */
135 #define SCI_CTRL_FLAGS_RIE 0x40 /* all */
136 #define SCI_CTRL_FLAGS_TE 0x20 /* all */
137 #define SCI_CTRL_FLAGS_RE 0x10 /* all */
138 #if defined(CONFIG_CPU_SH7750) || \
139 defined(CONFIG_CPU_SH7750R) || \
140 defined(CONFIG_CPU_SH7722) || \
141 defined(CONFIG_CPU_SH7734) || \
142 defined(CONFIG_CPU_SH7750S) || \
143 defined(CONFIG_CPU_SH7751) || \
144 defined(CONFIG_CPU_SH7751R) || \
145 defined(CONFIG_CPU_SH7763) || \
146 defined(CONFIG_CPU_SH7780)
147 #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
149 #define SCI_CTRL_FLAGS_REIE 0
151 /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
152 /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
153 /* SCI_CTRL_FLAGS_CKE1 0x02 * all */
154 /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
157 #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
158 #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
159 #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
160 #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
161 #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
162 #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
163 /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
164 /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
166 #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
169 #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
170 #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
171 #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
172 #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
173 #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
174 #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
175 #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
176 #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
178 #if defined(CONFIG_CPU_SH7705) || \
179 defined(CONFIG_CPU_SH7720) || \
180 defined(CONFIG_CPU_SH7721) || \
181 defined(CONFIG_SH73A0) || \
182 defined(CONFIG_R8A7740)
183 # define SCIF_ORER 0x0200
184 # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
185 # define SCIF_RFDC_MASK 0x007f
186 # define SCIF_TXROOM_MAX 64
187 #elif defined(CONFIG_CPU_SH7763)
188 # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
189 # define SCIF_RFDC_MASK 0x007f
190 # define SCIF_TXROOM_MAX 64
191 /* SH7763 SCIF2 support */
192 # define SCIF2_RFDC_MASK 0x001f
193 # define SCIF2_TXROOM_MAX 16
194 #elif defined(CONFIG_RCAR_GEN2)
195 # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
196 # if defined(CONFIG_SCIF_A)
197 # define SCIF_RFDC_MASK 0x007f
199 # define SCIF_RFDC_MASK 0x001f
202 # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
203 # define SCIF_RFDC_MASK 0x001f
204 # define SCIF_TXROOM_MAX 16
208 #define SCIF_ORER 0x0000
211 #define SCxSR_TEND(port)\
212 (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
213 #define SCxSR_ERRORS(port)\
214 (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
215 #define SCxSR_RDxF(port)\
216 (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
217 #define SCxSR_TDxE(port)\
218 (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
219 #define SCxSR_FER(port)\
220 (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
221 #define SCxSR_PER(port)\
222 (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
223 #define SCxSR_BRK(port)\
224 ((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
225 #define SCxSR_ORER(port)\
226 (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
228 #if defined(CONFIG_CPU_SH7705) || \
229 defined(CONFIG_CPU_SH7720) || \
230 defined(CONFIG_CPU_SH7721) || \
231 defined(CONFIG_SH73A0) || \
232 defined(CONFIG_R8A7740)
233 # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
234 # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
235 # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
236 # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3)
238 # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
239 # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
240 # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
241 # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
245 #define SCFCR_RFRST 0x0002
246 #define SCFCR_TFRST 0x0004
247 #define SCFCR_TCRST 0x4000
248 #define SCFCR_MCE 0x0008
250 #define SCI_MAJOR 204
251 #define SCI_MINOR_START 8
253 /* Generic serial flags */
254 #define SCI_RX_THROTTLE 0x0000001
256 #define SCI_MAGIC 0xbabeface
259 * Events are used to schedule things to happen at timer-interrupt
260 * time, instead of at rs interrupt time.
262 #define SCI_EVENT_WRITE_WAKEUP 0
264 #define SCI_IN(size, offset)\
266 return readb(port->membase + (offset));\
268 return readw(port->membase + (offset));\
270 #define SCI_OUT(size, offset, value)\
272 writeb(value, port->membase + (offset));\
273 } else if ((size) == 16) {\
274 writew(value, port->membase + (offset));\
277 #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
278 static inline unsigned int sci_##name##_in(struct uart_port *port) {\
279 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
280 SCI_IN(scif_size, scif_offset)\
281 } else { /* PORT_SCI or PORT_SCIFA */\
282 SCI_IN(sci_size, sci_offset);\
285 static inline void sci_##name##_out(struct uart_port *port,\
286 unsigned int value) {\
287 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
288 SCI_OUT(scif_size, scif_offset, value)\
289 } else { /* PORT_SCI or PORT_SCIFA */\
290 SCI_OUT(sci_size, sci_offset, value);\
294 #define CPU_SCIF_FNS(name, scif_offset, scif_size) \
295 static inline unsigned int sci_##name##_in(struct uart_port *port) {\
296 SCI_IN(scif_size, scif_offset);\
298 static inline void sci_##name##_out(struct uart_port *port,\
299 unsigned int value) {\
300 SCI_OUT(scif_size, scif_offset, value);\
303 #define CPU_SCI_FNS(name, sci_offset, sci_size)\
304 static inline unsigned int sci_##name##_in(struct uart_port *port) {\
305 SCI_IN(sci_size, sci_offset);\
307 static inline void sci_##name##_out(struct uart_port *port,\
308 unsigned int value) {\
309 SCI_OUT(sci_size, sci_offset, value);\
312 #if defined(CONFIG_CPU_SH3) || \
313 defined(CONFIG_SH73A0) || \
314 defined(CONFIG_R8A7740)
315 #if defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
316 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
317 sh4_sci_offset, sh4_sci_size, \
318 sh3_scif_offset, sh3_scif_size, \
319 sh4_scif_offset, sh4_scif_size, \
320 h8_sci_offset, h8_sci_size) \
321 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
322 sh4_scif_offset, sh4_scif_size)
323 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
324 sh4_scif_offset, sh4_scif_size) \
325 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
326 #elif defined(CONFIG_CPU_SH7705) || \
327 defined(CONFIG_CPU_SH7720) || \
328 defined(CONFIG_CPU_SH7721) || \
329 defined(CONFIG_SH73A0)
330 #define SCIF_FNS(name, scif_offset, scif_size) \
331 CPU_SCIF_FNS(name, scif_offset, scif_size)
332 #elif defined(CONFIG_R8A7740)
333 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
334 sh4_scifb_offset, sh4_scifb_size) \
335 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
336 sh4_scifb_offset, sh4_scifb_size)
337 #define SCIF_FNS(name, scif_offset, scif_size) \
338 CPU_SCIF_FNS(name, scif_offset, scif_size)
340 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
341 sh4_sci_offset, sh4_sci_size, \
342 sh3_scif_offset, sh3_scif_size,\
343 sh4_scif_offset, sh4_scif_size, \
344 h8_sci_offset, h8_sci_size) \
345 CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
346 sh3_scif_offset, sh3_scif_size)
347 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
348 sh4_scif_offset, sh4_scif_size) \
349 CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
351 #elif defined(CONFIG_CPU_SH7723)
352 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
353 sh4_scif_offset, sh4_scif_size) \
354 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
355 sh4_scif_offset, sh4_scif_size)
356 #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
357 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
359 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
360 sh4_sci_offset, sh4_sci_size, \
361 sh3_scif_offset, sh3_scif_size,\
362 sh4_scif_offset, sh4_scif_size, \
363 h8_sci_offset, h8_sci_size) \
364 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
365 sh4_scif_offset, sh4_scif_size)
366 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, \
367 sh4_scif_offset, sh4_scif_size) \
368 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
371 #if defined(CONFIG_CPU_SH7705) || \
372 defined(CONFIG_CPU_SH7720) || \
373 defined(CONFIG_CPU_SH7721) || \
374 defined(CONFIG_SH73A0)
376 SCIF_FNS(SCSMR, 0x00, 16)
377 SCIF_FNS(SCBRR, 0x04, 8)
378 SCIF_FNS(SCSCR, 0x08, 16)
379 SCIF_FNS(SCTDSR, 0x0c, 8)
380 SCIF_FNS(SCFER, 0x10, 16)
381 SCIF_FNS(SCxSR, 0x14, 16)
382 SCIF_FNS(SCFCR, 0x18, 16)
383 SCIF_FNS(SCFDR, 0x1c, 16)
384 SCIF_FNS(SCxTDR, 0x20, 8)
385 SCIF_FNS(SCxRDR, 0x24, 8)
386 SCIF_FNS(SCLSR, 0x00, 0)
387 SCIF_FNS(DL, 0x00, 0) /* dummy */
388 #elif defined(CONFIG_R8A7740)
389 SCIF_FNS(SCSMR, 0x00, 16)
390 SCIF_FNS(SCBRR, 0x04, 8)
391 SCIF_FNS(SCSCR, 0x08, 16)
392 SCIF_FNS(SCTDSR, 0x0c, 16)
393 SCIF_FNS(SCFER, 0x10, 16)
394 SCIF_FNS(SCxSR, 0x14, 16)
395 SCIF_FNS(SCFCR, 0x18, 16)
396 SCIF_FNS(SCFDR, 0x1c, 16)
397 SCIF_FNS(SCTFDR, 0x38, 16)
398 SCIF_FNS(SCRFDR, 0x3c, 16)
399 SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8)
400 SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8)
401 SCIF_FNS(SCLSR, 0x00, 0)
402 SCIF_FNS(DL, 0x00, 0) /* dummy */
403 #elif defined(CONFIG_CPU_SH7723)
404 SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
405 SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
406 SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
407 SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
408 SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
409 SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
410 SCIx_FNS(SCSPTR, 0, 0, 0, 0)
411 SCIF_FNS(SCTDSR, 0x0c, 8)
412 SCIF_FNS(SCFER, 0x10, 16)
413 SCIF_FNS(SCFCR, 0x18, 16)
414 SCIF_FNS(SCFDR, 0x1c, 16)
415 SCIF_FNS(SCLSR, 0x24, 16)
416 SCIF_FNS(DL, 0x00, 0) /* dummy */
417 #elif defined(CONFIG_RCAR_GEN2)
418 /* SCIFA and SCIF register offsets and size */
419 SCIx_FNS(SCSMR, 0, 0, 0x00, 16, 0, 0, 0x00, 16, 0, 0)
420 SCIx_FNS(SCBRR, 0, 0, 0x04, 8, 0, 0, 0x04, 8, 0, 0)
421 SCIx_FNS(SCSCR, 0, 0, 0x08, 16, 0, 0, 0x08, 16, 0, 0)
422 SCIx_FNS(SCxTDR, 0, 0, 0x20, 8, 0, 0, 0x0C, 8, 0, 0)
423 SCIx_FNS(SCxSR, 0, 0, 0x14, 16, 0, 0, 0x10, 16, 0, 0)
424 SCIx_FNS(SCxRDR, 0, 0, 0x24, 8, 0, 0, 0x14, 8, 0, 0)
425 SCIF_FNS(SCFCR, 0, 0, 0x18, 16)
426 SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
427 SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
428 SCIF_FNS(DL, 0, 0, 0x30, 16)
429 SCIF_FNS(CKS, 0, 0, 0x34, 16)
430 #if defined(CONFIG_SCIF_A)
431 SCIF_FNS(SCLSR, 0, 0, 0x14, 16)
433 SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
436 /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
437 /* name off sz off sz off sz off sz off sz*/
438 SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8)
439 SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8)
440 SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8)
441 SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
442 SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
443 SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
444 SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
445 #if defined(CONFIG_CPU_SH7780)
446 SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
447 SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
448 SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
449 SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
450 SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
451 #elif defined(CONFIG_CPU_SH7763)
452 SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
453 SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
454 SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
455 SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
456 SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
457 SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
458 SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
461 SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
462 #if defined(CONFIG_CPU_SH7722)
463 SCIF_FNS(SCSPTR, 0, 0, 0, 0)
465 SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
467 SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
469 SCIF_FNS(DL, 0, 0, 0x0, 0) /* dummy */
471 #define sci_in(port, reg) sci_##reg##_in(port)
472 #define sci_out(port, reg, value) sci_##reg##_out(port, value)
474 #if defined(CONFIG_CPU_SH7706) || \
475 defined(CONFIG_CPU_SH7707) || \
476 defined(CONFIG_CPU_SH7708) || \
477 defined(CONFIG_CPU_SH7709)
478 static inline int sci_rxd_in(struct uart_port *port)
480 if (port->mapbase == 0xfffffe80)
481 return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
484 #elif defined(CONFIG_CPU_SH7750) || \
485 defined(CONFIG_CPU_SH7751) || \
486 defined(CONFIG_CPU_SH7751R) || \
487 defined(CONFIG_CPU_SH7750R) || \
488 defined(CONFIG_CPU_SH7750S)
489 static inline int sci_rxd_in(struct uart_port *port)
491 if (port->mapbase == 0xffe00000)
492 return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
495 #else /* default case for non-SCI processors */
496 static inline int sci_rxd_in(struct uart_port *port)
503 * Values for the BitRate Register (SCBRR)
505 * The values are actually divisors for a frequency which can
506 * be internal to the SH3 (14.7456MHz) or derived from an external
507 * clock source. This driver assumes the internal clock is used;
508 * to support using an external clock source, config options or
509 * possibly command-line options would need to be added.
511 * Also, to support speeds below 2400 (why?) the lower 2 bits of
512 * the SCSMR register would also need to be set to non-zero values.
514 * -- Greg Banks 27Feb2000
516 * Answer: The SCBRR register is only eight bits, and the value in
517 * it gets larger with lower baud rates. At around 2400 (depending on
518 * the peripherial module clock) you run out of bits. However the
519 * lower two bits of SCSMR allow the module clock to be divided down,
520 * scaling the value which is needed in SCBRR.
522 * -- Stuart Menefy - 23 May 2000
524 * I meant, why would anyone bother with bitrates below 2400.
526 * -- Greg Banks - 7Jul2000
528 * You "speedist"! How will I use my 110bps ASR-33 teletype with paper
529 * tape reader as a console!
531 * -- Mitch Davis - 15 Jul 2000
534 #if defined(CONFIG_CPU_SH7780)
535 #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
536 #elif defined(CONFIG_CPU_SH7705) || \
537 defined(CONFIG_CPU_SH7720) || \
538 defined(CONFIG_CPU_SH7721) || \
539 defined(CONFIG_SH73A0) || \
540 defined(CONFIG_R8A7740)
541 #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
542 #elif defined(CONFIG_CPU_SH7723)
543 static inline int scbrr_calc(struct uart_port *port, int bps, int clk)
545 if (port->type == PORT_SCIF)
546 return (clk+16*bps)/(32*bps)-1;
548 return ((clk*2)+16*bps)/(16*bps)-1;
550 #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk)
551 #elif defined(CONFIG_RCAR_GEN2)
552 #define DL_VALUE(bps, clk) (clk / bps / 16) /* External Clock */
553 #if defined(CONFIG_SCIF_A)
554 #define SCBRR_VALUE(bps, clk) (clk / bps / 16 - 1) /* Internal Clock */
556 #define SCBRR_VALUE(bps, clk) (clk / bps / 32 - 1) /* Internal Clock */
558 #else /* Generic SH */
559 #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
563 #define DL_VALUE(bps, clk) 0