ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / serial / sh-sci.h
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 H8/300 Series Yoshinori Sato (Feb 2004).
11  */
12 #include <linux/config.h>
13 #include <linux/serial_core.h>
14
15 #if defined(__H8300H__) || defined(__H8300S__)
16 #include <asm/gpio.h>
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 #endif
24
25 /* Offsets into the sci_port->irqs array */
26 #define SCIx_ERI_IRQ 0
27 #define SCIx_RXI_IRQ 1
28 #define SCIx_TXI_IRQ 2
29
30 /*                     ERI, RXI, TXI, BRI */
31 #define SCI_IRQS      { 23,  24,  25,   0 }
32 #define SH3_SCIF_IRQS { 56,  57,  59,  58 }
33 #define SH3_IRDA_IRQS { 52,  53,  55,  54 }
34 #define SH4_SCIF_IRQS { 40,  41,  43,  42 }
35 #define STB1_SCIF1_IRQS {23, 24,  26,  25 }
36 #define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }
37 #define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
38 #define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
39 #define H8300H_SCI_IRQS0 {52, 53, 54,   0 }
40 #define H8300H_SCI_IRQS1 {56, 57, 58,   0 }
41 #define H8300H_SCI_IRQS2 {60, 61, 62,   0 }
42 #define H8S_SCI_IRQS0 {88, 89, 90,   0 }
43 #define H8S_SCI_IRQS1 {92, 93, 94,   0 }
44 #define H8S_SCI_IRQS2 {96, 97, 98,   0 }
45
46 #if defined(CONFIG_CPU_SUBTYPE_SH7708)
47 # define SCI_NPORTS 1
48 # define SCSPTR 0xffffff7c /* 8 bit */
49 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
50 # define SCI_ONLY
51 #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
52 # define SCI_NPORTS 3
53 # define SCPCR  0xA4000116 /* 16 bit SCI and SCIF */
54 # define SCPDR  0xA4000136 /* 8  bit SCI and SCIF */
55 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
56 # define SCI_AND_SCIF
57 #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
58 # define SCI_NPORTS 2
59 # define SCSPTR1 0xffe0001c /* 8  bit SCI */
60 # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
61 # define SCIF_ORER 0x0001   /* overrun error bit */
62 # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
63         0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
64         0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
65 # define SCI_AND_SCIF
66 #elif defined(CONFIG_CPU_SUBTYPE_SH7760)
67 # define SCI_NPORTS 3
68 # define SCSPTR0 0xfe600000 /* 16 bit SCIF */
69 # define SCSPTR1 0xfe610000 /* 16 bit SCIF */
70 # define SCSPTR2 0xfe620000 /* 16 bit SCIF */
71 # define SCIF_ORDER 0x0001  /* overrun error bit */
72 # define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
73 # define SCIF_ONLY
74 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
75 # define SCI_NPORTS 2
76 # define SCSPTR1 0xffe00020 /* 16 bit SCIF */
77 # define SCSPTR2 0xffe80020 /* 16 bit SCIF */
78 # define SCIF_ORER 0x0001   /* overrun error bit */
79 # define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
80 # define SCIF_ONLY
81 #elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
82 # define SCI_NPORTS 3
83 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
84 # define SCI_ONLY
85 # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
86 #elif defined(CONFIG_H8S2678)
87 # define SCI_NPORTS 3
88 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
89 # define SCI_ONLY
90 # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
91 #else
92 # error CPU subtype not defined
93 #endif
94
95 /* SCSCR */
96 #define SCI_CTRL_FLAGS_TIE  0x80 /* all */
97 #define SCI_CTRL_FLAGS_RIE  0x40 /* all */
98 #define SCI_CTRL_FLAGS_TE   0x20 /* all */
99 #define SCI_CTRL_FLAGS_RE   0x10 /* all */
100 /*      SCI_CTRL_FLAGS_REIE 0x08  * 7750 SCIF */
101 /*      SCI_CTRL_FLAGS_MPIE 0x08  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
102 /*      SCI_CTRL_FLAGS_TEIE 0x04  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
103 /*      SCI_CTRL_FLAGS_CKE1 0x02  * all */
104 /*      SCI_CTRL_FLAGS_CKE0 0x01  * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
105
106 /* SCxSR SCI */
107 #define SCI_TDRE  0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
108 #define SCI_RDRF  0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
109 #define SCI_ORER  0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
110 #define SCI_FER   0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
111 #define SCI_PER   0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
112 #define SCI_TEND  0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
113 /*      SCI_MPB   0x02  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
114 /*      SCI_MPBT  0x01  * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
115
116 #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
117
118 /* SCxSR SCIF */
119 #define SCIF_ER    0x0080 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
120 #define SCIF_TEND  0x0040 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
121 #define SCIF_TDFE  0x0020 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
122 #define SCIF_BRK   0x0010 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
123 #define SCIF_FER   0x0008 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
124 #define SCIF_PER   0x0004 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
125 #define SCIF_RDF   0x0002 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
126 #define SCIF_DR    0x0001 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
127
128 #define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
129
130 #if defined(SCI_ONLY)
131 # define SCxSR_TEND(port)               SCI_TEND
132 # define SCxSR_ERRORS(port)             SCI_ERRORS
133 # define SCxSR_RDxF(port)               SCI_RDRF
134 # define SCxSR_TDxE(port)               SCI_TDRE
135 # define SCxSR_ORER(port)               SCI_ORER
136 # define SCxSR_FER(port)                SCI_FER
137 # define SCxSR_PER(port)                SCI_PER
138 # define SCxSR_BRK(port)                0x00
139 # define SCxSR_RDxF_CLEAR(port)         0xbc
140 # define SCxSR_ERROR_CLEAR(port)        0xc4
141 # define SCxSR_TDxE_CLEAR(port)         0x78
142 # define SCxSR_BREAK_CLEAR(port)        0xc4
143 #elif defined(SCIF_ONLY)
144 # define SCxSR_TEND(port)               SCIF_TEND
145 # define SCxSR_ERRORS(port)             SCIF_ERRORS
146 # define SCxSR_RDxF(port)               SCIF_RDF
147 # define SCxSR_TDxE(port)               SCIF_TDFE
148 # define SCxSR_ORER(port)               0x0000
149 # define SCxSR_FER(port)                SCIF_FER
150 # define SCxSR_PER(port)                SCIF_PER
151 # define SCxSR_BRK(port)                SCIF_BRK
152 # define SCxSR_RDxF_CLEAR(port)         0x00fc
153 # define SCxSR_ERROR_CLEAR(port)        0x0073
154 # define SCxSR_TDxE_CLEAR(port)         0x00df
155 # define SCxSR_BREAK_CLEAR(port)        0x00e3
156 #else
157 # define SCxSR_TEND(port)        (((port)->type == PORT_SCI) ? SCI_TEND   : SCIF_TEND)
158 # define SCxSR_ERRORS(port)      (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
159 # define SCxSR_RDxF(port)        (((port)->type == PORT_SCI) ? SCI_RDRF   : SCIF_RDF)
160 # define SCxSR_TDxE(port)        (((port)->type == PORT_SCI) ? SCI_TDRE   : SCIF_TDFE)
161 # define SCxSR_ORER(port)        (((port)->type == PORT_SCI) ? SCI_ORER   : 0x0000)
162 # define SCxSR_FER(port)         (((port)->type == PORT_SCI) ? SCI_FER    : SCIF_FER)
163 # define SCxSR_PER(port)         (((port)->type == PORT_SCI) ? SCI_PER    : SCIF_PER)
164 # define SCxSR_BRK(port)         (((port)->type == PORT_SCI) ? 0x00       : SCIF_BRK)
165 # define SCxSR_RDxF_CLEAR(port)  (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
166 # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
167 # define SCxSR_TDxE_CLEAR(port)  (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
168 # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
169 #endif
170
171 /* SCFCR */
172 #define SCFCR_RFRST 0x0002
173 #define SCFCR_TFRST 0x0004
174 #define SCFCR_MCE   0x0008
175
176 #define SCI_MAJOR               204
177 #define SCI_MINOR_START         8
178
179 /* Generic serial flags */
180 #define SCI_RX_THROTTLE         0x0000001
181
182 #define SCI_MAGIC 0xbabeface
183
184 /*
185  * Events are used to schedule things to happen at timer-interrupt
186  * time, instead of at rs interrupt time.
187  */
188 #define SCI_EVENT_WRITE_WAKEUP  0
189
190 struct sci_port {
191         struct uart_port port;
192         int type;
193         unsigned char irqs[4]; /* ERI, RXI, TXI, BRI */
194         void (*init_pins)(struct uart_port *port, unsigned int cflag);
195         int break_flag;
196         struct timer_list break_timer;
197 };
198
199 #define SCI_IN(size, offset)                                    \
200   unsigned int addr = port->mapbase + (offset);                 \
201   if ((size) == 8) {                                            \
202     return ctrl_inb(addr);                                      \
203   } else {                                                      \
204     return ctrl_inw(addr);                                      \
205   }
206 #define SCI_OUT(size, offset, value)                            \
207   unsigned int addr = port->mapbase + (offset);                 \
208   if ((size) == 8) {                                            \
209     ctrl_outb(value, addr);                                     \
210   } else {                                                      \
211     ctrl_outw(value, addr);                                     \
212   }
213
214 #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
215   static inline unsigned int sci_##name##_in(struct uart_port *port)    \
216   {                                                                     \
217     if (port->type == PORT_SCI) {                                       \
218       SCI_IN(sci_size, sci_offset)                                      \
219     } else {                                                            \
220       SCI_IN(scif_size, scif_offset);                                   \
221     }                                                                   \
222   }                                                                     \
223   static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
224   {                                                                     \
225     if (port->type == PORT_SCI) {                                       \
226       SCI_OUT(sci_size, sci_offset, value)                              \
227     } else {                                                            \
228       SCI_OUT(scif_size, scif_offset, value);                           \
229     }                                                                   \
230   }
231
232 #define CPU_SCIF_FNS(name, scif_offset, scif_size)                              \
233   static inline unsigned int sci_##name##_in(struct uart_port *port)    \
234   {                                                                     \
235     SCI_IN(scif_size, scif_offset);                                     \
236   }                                                                     \
237   static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
238   {                                                                     \
239     SCI_OUT(scif_size, scif_offset, value);                             \
240   }
241
242 #define CPU_SCI_FNS(name, sci_offset, sci_size)                         \
243   static inline unsigned int sci_##name##_in(struct uart_port* port)    \
244   {                                                                     \
245     SCI_IN(sci_size, sci_offset);                                       \
246   }                                                                     \
247   static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \
248   {                                                                     \
249     SCI_OUT(sci_size, sci_offset, value);                               \
250   }
251
252 #ifdef CONFIG_CPU_SH3
253 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
254                  sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
255                  h8_sci_offset, h8_sci_size) \
256   CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
257 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
258   CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
259 #elif defined(__H8300H__) || defined(__H8300S__)
260 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
261                  sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
262                  h8_sci_offset, h8_sci_size) \
263   CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
264 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
265 #else
266 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
267                  sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
268                  h8_sci_offset, h8_sci_size) \
269   CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
270 #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
271   CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
272 #endif
273
274 /*      reg      SCI/SH3   SCI/SH4  SCIF/SH3   SCIF/SH4  SCI/H8*/
275 /*      name     off  sz   off  sz   off  sz   off  sz   off  sz*/
276 SCIx_FNS(SCSMR,  0x00,  8, 0x00,  8, 0x00,  8, 0x00, 16, 0x00,  8)
277 SCIx_FNS(SCBRR,  0x02,  8, 0x04,  8, 0x02,  8, 0x04,  8, 0x01,  8)
278 SCIx_FNS(SCSCR,  0x04,  8, 0x08,  8, 0x04,  8, 0x08, 16, 0x02,  8)
279 SCIx_FNS(SCxTDR, 0x06,  8, 0x0c,  8, 0x06,  8, 0x0C,  8, 0x03,  8)
280 SCIx_FNS(SCxSR,  0x08,  8, 0x10,  8, 0x08, 16, 0x10, 16, 0x04,  8)
281 SCIx_FNS(SCxRDR, 0x0a,  8, 0x14,  8, 0x0A,  8, 0x14,  8, 0x05,  8)
282 SCIF_FNS(SCFCR,                      0x0c,  8, 0x18, 16)
283 SCIF_FNS(SCFDR,                      0x0e, 16, 0x1C, 16)
284 SCIF_FNS(SCLSR,                         0,  0, 0x24, 16)
285
286 #define sci_in(port, reg) sci_##reg##_in(port)
287 #define sci_out(port, reg, value) sci_##reg##_out(port, value)
288
289 /* H8/300 series SCI pins assignment */
290 #if defined(__H8300H__) || defined(__H8300S__)
291 static const struct __attribute__((packed)) {
292         int port;             /* GPIO port no */
293         unsigned short rx,tx; /* GPIO bit no */
294 } h8300_sci_pins[] = {
295 #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
296         {    /* SCI0 */
297                 .port = H8300_GPIO_P9,
298                 .rx   = H8300_GPIO_B2,
299                 .tx   = H8300_GPIO_B0,
300         },
301         {    /* SCI1 */
302                 .port = H8300_GPIO_P9,
303                 .rx   = H8300_GPIO_B3,
304                 .tx   = H8300_GPIO_B1,
305         },
306         {    /* SCI2 */
307                 .port = H8300_GPIO_PB,
308                 .rx   = H8300_GPIO_B7,
309                 .tx   = H8300_GPIO_B6,
310         }
311 #elif defined(CONFIG_H8S2678)
312         {    /* SCI0 */
313                 .port = H8300_GPIO_P3,
314                 .rx   = H8300_GPIO_B2,
315                 .tx   = H8300_GPIO_B0,
316         },
317         {    /* SCI1 */
318                 .port = H8300_GPIO_P3,
319                 .rx   = H8300_GPIO_B3,
320                 .tx   = H8300_GPIO_B1,
321         },
322         {    /* SCI2 */
323                 .port = H8300_GPIO_P5,
324                 .rx   = H8300_GPIO_B1,
325                 .tx   = H8300_GPIO_B0,
326         }
327 #endif
328 };
329 #endif
330
331 #if defined(CONFIG_CPU_SUBTYPE_SH7708)
332 static inline int sci_rxd_in(struct uart_port *port)
333 {
334         if (port->mapbase == 0xfffffe80)
335                 return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */
336         return 1;
337 }
338 #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
339 static inline int sci_rxd_in(struct uart_port *port)
340 {
341         if (port->mapbase == 0xfffffe80)
342                 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
343         if (port->mapbase == 0xa4000150)
344                 return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
345         if (port->mapbase == 0xa4000140)
346                 return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
347         return 1;
348 }
349 #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
350 static inline int sci_rxd_in(struct uart_port *port)
351 {
352 #ifndef SCIF_ONLY
353         if (port->mapbase == 0xffe00000)
354                 return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
355 #endif
356 #ifndef SCI_ONLY
357         if (port->mapbase == 0xffe80000)
358                 return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
359 #endif
360         return 1;
361 }
362 #elif defined(CONFIG_CPU_SUBTYPE_SH7760)
363 static inline int sci_rxd_in(struct uart_port *port)
364 {
365         if (port->mapbase == 0xfe600000)
366                 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
367         if (port->mapbase == 0xfe610000)
368                 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
369         if (port->mapbase == 0xfe620000)
370                 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
371 }
372 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
373 static inline int sci_rxd_in(struct uart_port *port)
374 {
375         if (port->mapbase == 0xffe00000)
376                 return ctrl_inw(SCSPTR1)&0x0001 ? 1 : 0; /* SCIF */
377         else
378                 return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
379
380 }
381 #elif defined(__H8300H__) || defined(__H8300S__)
382 static inline int sci_rxd_in(struct uart_port *port)
383 {
384         int ch = (port->mapbase - SMR0) >> 3;
385         return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
386 }
387 #endif
388
389 /*
390  * Values for the BitRate Register (SCBRR)
391  *
392  * The values are actually divisors for a frequency which can
393  * be internal to the SH3 (14.7456MHz) or derived from an external
394  * clock source.  This driver assumes the internal clock is used;
395  * to support using an external clock source, config options or
396  * possibly command-line options would need to be added.
397  *
398  * Also, to support speeds below 2400 (why?) the lower 2 bits of
399  * the SCSMR register would also need to be set to non-zero values.
400  *
401  * -- Greg Banks 27Feb2000
402  *
403  * Answer: The SCBRR register is only eight bits, and the value in
404  * it gets larger with lower baud rates. At around 2400 (depending on
405  * the peripherial module clock) you run out of bits. However the
406  * lower two bits of SCSMR allow the module clock to be divided down,
407  * scaling the value which is needed in SCBRR.
408  *
409  * -- Stuart Menefy - 23 May 2000
410  *
411  * I meant, why would anyone bother with bitrates below 2400.
412  *
413  * -- Greg Banks - 7Jul2000
414  *
415  * You "speedist"!  How will I use my 110bps ASR-33 teletype with paper
416  * tape reader as a console!
417  *
418  * -- Mitch Davis - 15 Jul 2000
419  */
420
421 #define PCLK           (current_cpu_data.module_clock)
422
423 #if !defined(__H8300H__) && !defined(__H8300S__)
424 #define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
425 #else
426 #define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
427 #endif
428 #define BPS_2400       SCBRR_VALUE(2400)
429 #define BPS_4800       SCBRR_VALUE(4800)
430 #define BPS_9600       SCBRR_VALUE(9600)
431 #define BPS_19200      SCBRR_VALUE(19200)
432 #define BPS_38400      SCBRR_VALUE(38400)
433 #define BPS_57600      SCBRR_VALUE(57600)
434 #define BPS_115200     SCBRR_VALUE(115200)
435