blob: cde06a4818292401f07df0cbd50f76448fb568e9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $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).
Magnus Dammd89ddd12007-07-25 11:42:56 +090012 * Removed SH7300 support (Jul 2007).
Markus Brunner3ea6bc32007-08-20 08:59:33 +090013 * Modified to support SH7720 SCIF. Markus Brunner, Mark Jonas (Aug 2007).
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/serial_core.h>
Paul Mundte108b2c2006-09-27 16:32:13 +090016#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/gpio.h>
Markus Brunner3ea6bc32007-08-20 08:59:33 +090019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
21#include <asm/regs306x.h>
22#endif
23#if defined(CONFIG_H8S2678)
24#include <asm/regs267x.h>
25#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Magnus Damm0fbde952007-07-26 10:14:16 +090027#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
28 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
29 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
30 defined(CONFIG_CPU_SUBTYPE_SH7709)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
32# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
33# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
34# define SCI_AND_SCIF
35#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
36# define SCIF0 0xA4400000
37# define SCIF2 0xA4410000
Paul Mundtb7a76e42006-02-01 03:06:06 -080038# define SCSMR_Ir 0xA44A0000
39# define IRDA_SCIF SCIF0
Linus Torvalds1da177e2005-04-16 15:20:36 -070040# define SCPCR 0xA4000116
41# define SCPDR 0xA4000136
42
43/* Set the clock source,
44 * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input
45 * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output
46 */
47# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
48# define SCIF_ONLY
Markus Brunner3ea6bc32007-08-20 08:59:33 +090049#elif defined(CONFIG_CPU_SUBTYPE_SH7720)
50# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
51# define SCIF_ONLY
52#define SCIF_ORER 0x0200 /* overrun error bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#elif defined(CONFIG_SH_RTS7751R2D)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
55# define SCIF_ORER 0x0001 /* overrun error bit */
56# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
57# define SCIF_ONLY
Paul Mundt05627482007-05-15 16:25:47 +090058#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
59 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
60 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
61 defined(CONFIG_CPU_SUBTYPE_SH7091) || \
62 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
63 defined(CONFIG_CPU_SUBTYPE_SH7751R)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064# define SCSPTR1 0xffe0001c /* 8 bit SCI */
65# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
66# define SCIF_ORER 0x0001 /* overrun error bit */
67# define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
68 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
69 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
70# define SCI_AND_SCIF
71#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
Paul Mundtb7a76e42006-02-01 03:06:06 -080072# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
73# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
74# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075# define SCIF_ORER 0x0001 /* overrun error bit */
76# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
77# define SCIF_ONLY
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090078#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
Paul Mundte108b2c2006-09-27 16:32:13 +090079# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +090080# define SCIF_ORER 0x0001 /* overrun error bit */
81# define PACR 0xa4050100
82# define PBCR 0xa4050102
83# define SCSCR_INIT(port) 0x3B
Paul Mundte108b2c2006-09-27 16:32:13 +090084# define SCIF_ONLY
Paul Mundte108b2c2006-09-27 16:32:13 +090085#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
86# define SCSPTR0 0xffe00010 /* 16 bit SCIF */
87# define SCSPTR1 0xffe10010 /* 16 bit SCIF */
88# define SCSPTR2 0xffe20010 /* 16 bit SCIF */
89# define SCSPTR3 0xffe30010 /* 16 bit SCIF */
90# define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */
91# define SCIF_ONLY
Paul Mundt41504c32006-12-11 20:28:03 +090092#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
93# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
94# define SCSPTR0 SCPDR0
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# define SCIF_ONLY
98# define PORT_PSCR 0xA405011E
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100# 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#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 Torvalds1da177e2005-04-16 15:20:36 -0700110# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */
111# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */
Paul Mundtf9669182007-11-07 11:05:32 +0900112# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113# define SCIF_ONLY
114#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
116# define SCI_ONLY
117# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
118#elif defined(CONFIG_H8S2678)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
120# define SCI_ONLY
121# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800122#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
123# define SCSPTR0 0xff923020 /* 16 bit SCIF */
124# define SCSPTR1 0xff924020 /* 16 bit SCIF */
125# define SCSPTR2 0xff925020 /* 16 bit SCIF */
126# define SCIF_ORER 0x0001 /* overrun error bit */
127# define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */
128# define SCIF_ONLY
129#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
130# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
131# define SCSPTR1 0xffe10024 /* 16 bit SCIF */
Paul Mundte108b2c2006-09-27 16:32:13 +0900132# define SCIF_ORER 0x0001 /* Overrun error bit */
Paul Mundtb7a76e42006-02-01 03:06:06 -0800133# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
134# define SCIF_ONLY
Paul Mundt32351a22007-03-12 14:38:59 +0900135#elif defined(CONFIG_CPU_SUBTYPE_SH7785)
136# define SCSPTR0 0xffea0024 /* 16 bit SCIF */
137# define SCSPTR1 0xffeb0024 /* 16 bit SCIF */
138# define SCSPTR2 0xffec0024 /* 16 bit SCIF */
139# define SCSPTR3 0xffed0024 /* 16 bit SCIF */
140# define SCSPTR4 0xffee0024 /* 16 bit SCIF */
141# define SCSPTR5 0xffef0024 /* 16 bit SCIF */
142# define SCIF_OPER 0x0001 /* Overrun error bit */
143# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
144# define SCIF_ONLY
Paul Mundt6d01f512007-11-26 18:17:21 +0900145#elif defined(CONFIG_CPU_SUBTYPE_SH7203) || \
146 defined(CONFIG_CPU_SUBTYPE_SH7206)
Yoshinori Sato9d4436a2006-11-05 15:40:13 +0900147# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
148# define SCSPTR1 0xfffe8820 /* 16 bit SCIF */
149# define SCSPTR2 0xfffe9020 /* 16 bit SCIF */
150# define SCSPTR3 0xfffe9820 /* 16 bit SCIF */
151# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
152# define SCIF_ONLY
153#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
154# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
155# define SCSPTR1 0xf8410020 /* 16 bit SCIF */
156# define SCSPTR2 0xf8420020 /* 16 bit SCIF */
157# define SCIF_ORER 0x0001 /* overrun error bit */
158# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
159# define SCIF_ONLY
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900160#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
161# define SCSPTR0 0xffc30020 /* 16 bit SCIF */
162# define SCSPTR1 0xffc40020 /* 16 bit SCIF */
163# define SCSPTR2 0xffc50020 /* 16 bit SCIF */
164# define SCSPTR3 0xffc60020 /* 16 bit SCIF */
165# define SCIF_ORER 0x0001 /* Overrun error bit */
166# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
167# define SCIF_ONLY
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168#else
169# error CPU subtype not defined
170#endif
171
172/* SCSCR */
173#define SCI_CTRL_FLAGS_TIE 0x80 /* all */
174#define SCI_CTRL_FLAGS_RIE 0x40 /* all */
175#define SCI_CTRL_FLAGS_TE 0x20 /* all */
176#define SCI_CTRL_FLAGS_RE 0x10 /* all */
Paul Mundt05627482007-05-15 16:25:47 +0900177#if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
178 defined(CONFIG_CPU_SUBTYPE_SH7091) || \
179 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
180 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
181 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
182 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
183 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900184 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
185 defined(CONFIG_CPU_SUBTYPE_SHX3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
187#else
188#define SCI_CTRL_FLAGS_REIE 0
189#endif
190/* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
191/* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
192/* SCI_CTRL_FLAGS_CKE1 0x02 * all */
193/* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
194
195/* SCxSR SCI */
196#define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
197#define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
198#define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
199#define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
200#define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
201#define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
202/* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
203/* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
204
205#define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
206
207/* SCxSR SCIF */
208#define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
209#define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
210#define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
211#define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
212#define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
213#define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
214#define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
215#define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
216
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900217#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
218 defined(CONFIG_CPU_SUBTYPE_SH7720)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219#define SCIF_ORER 0x0200
220#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
221#define SCIF_RFDC_MASK 0x007f
222#define SCIF_TXROOM_MAX 64
223#else
224#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
225#define SCIF_RFDC_MASK 0x001f
226#define SCIF_TXROOM_MAX 16
227#endif
228
229#if defined(SCI_ONLY)
230# define SCxSR_TEND(port) SCI_TEND
231# define SCxSR_ERRORS(port) SCI_ERRORS
232# define SCxSR_RDxF(port) SCI_RDRF
233# define SCxSR_TDxE(port) SCI_TDRE
234# define SCxSR_ORER(port) SCI_ORER
235# define SCxSR_FER(port) SCI_FER
236# define SCxSR_PER(port) SCI_PER
237# define SCxSR_BRK(port) 0x00
238# define SCxSR_RDxF_CLEAR(port) 0xbc
239# define SCxSR_ERROR_CLEAR(port) 0xc4
240# define SCxSR_TDxE_CLEAR(port) 0x78
Paul Mundtb7a76e42006-02-01 03:06:06 -0800241# define SCxSR_BREAK_CLEAR(port) 0xc4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242#elif defined(SCIF_ONLY)
243# define SCxSR_TEND(port) SCIF_TEND
244# define SCxSR_ERRORS(port) SCIF_ERRORS
245# define SCxSR_RDxF(port) SCIF_RDF
246# define SCxSR_TDxE(port) SCIF_TDFE
Magnus Dammd89ddd12007-07-25 11:42:56 +0900247#if defined(CONFIG_CPU_SUBTYPE_SH7705)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248# define SCxSR_ORER(port) SCIF_ORER
249#else
250# define SCxSR_ORER(port) 0x0000
251#endif
252# define SCxSR_FER(port) SCIF_FER
253# define SCxSR_PER(port) SCIF_PER
254# define SCxSR_BRK(port) SCIF_BRK
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900255#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
256 defined(CONFIG_CPU_SUBTYPE_SH7720)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257# define SCxSR_RDxF_CLEAR(port) (sci_in(port,SCxSR)&0xfffc)
258# define SCxSR_ERROR_CLEAR(port) (sci_in(port,SCxSR)&0xfd73)
259# define SCxSR_TDxE_CLEAR(port) (sci_in(port,SCxSR)&0xffdf)
260# define SCxSR_BREAK_CLEAR(port) (sci_in(port,SCxSR)&0xffe3)
261#else
Magnus Dammd89ddd12007-07-25 11:42:56 +0900262/* SH7705 can also use this, clearing is same between 7705 and 7709 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263# define SCxSR_RDxF_CLEAR(port) 0x00fc
264# define SCxSR_ERROR_CLEAR(port) 0x0073
265# define SCxSR_TDxE_CLEAR(port) 0x00df
Paul Mundtb7a76e42006-02-01 03:06:06 -0800266# define SCxSR_BREAK_CLEAR(port) 0x00e3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267#endif
268#else
269# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
270# define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
271# define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
272# define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
273# define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : 0x0000)
274# define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
275# define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
276# define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
277# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
278# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
279# define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
280# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
281#endif
282
283/* SCFCR */
284#define SCFCR_RFRST 0x0002
285#define SCFCR_TFRST 0x0004
286#define SCFCR_TCRST 0x4000
287#define SCFCR_MCE 0x0008
288
289#define SCI_MAJOR 204
290#define SCI_MINOR_START 8
291
292/* Generic serial flags */
293#define SCI_RX_THROTTLE 0x0000001
294
295#define SCI_MAGIC 0xbabeface
296
297/*
298 * Events are used to schedule things to happen at timer-interrupt
299 * time, instead of at rs interrupt time.
300 */
301#define SCI_EVENT_WRITE_WAKEUP 0
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303#define SCI_IN(size, offset) \
304 unsigned int addr = port->mapbase + (offset); \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800305 if ((size) == 8) { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 return ctrl_inb(addr); \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800307 } else { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 return ctrl_inw(addr); \
309 }
310#define SCI_OUT(size, offset, value) \
311 unsigned int addr = port->mapbase + (offset); \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800312 if ((size) == 8) { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 ctrl_outb(value, addr); \
314 } else { \
315 ctrl_outw(value, addr); \
316 }
317
318#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
319 static inline unsigned int sci_##name##_in(struct uart_port *port) \
320 { \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800321 if (port->type == PORT_SCI) { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 SCI_IN(sci_size, sci_offset) \
323 } else { \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800324 SCI_IN(scif_size, scif_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 } \
326 } \
327 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
328 { \
329 if (port->type == PORT_SCI) { \
330 SCI_OUT(sci_size, sci_offset, value) \
331 } else { \
332 SCI_OUT(scif_size, scif_offset, value); \
333 } \
334 }
335
336#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
337 static inline unsigned int sci_##name##_in(struct uart_port *port) \
338 { \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800339 SCI_IN(scif_size, scif_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 } \
341 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
342 { \
343 SCI_OUT(scif_size, scif_offset, value); \
344 }
345
346#define CPU_SCI_FNS(name, sci_offset, sci_size) \
347 static inline unsigned int sci_##name##_in(struct uart_port* port) \
348 { \
Paul Mundtb7a76e42006-02-01 03:06:06 -0800349 SCI_IN(sci_size, sci_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 } \
351 static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \
352 { \
353 SCI_OUT(sci_size, sci_offset, value); \
354 }
355
356#ifdef CONFIG_CPU_SH3
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900357#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
358#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
359 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
360 h8_sci_offset, h8_sci_size) \
361 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
362#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
363 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900364#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
365 defined(CONFIG_CPU_SUBTYPE_SH7720)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366#define SCIF_FNS(name, scif_offset, scif_size) \
367 CPU_SCIF_FNS(name, scif_offset, scif_size)
368#else
369#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
370 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
371 h8_sci_offset, h8_sci_size) \
372 CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
373#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
374 CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
375#endif
376#elif defined(__H8300H__) || defined(__H8300S__)
377#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
378 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
379 h8_sci_offset, h8_sci_size) \
380 CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
381#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
382#else
383#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
384 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
385 h8_sci_offset, h8_sci_size) \
386 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
387#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
388 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
389#endif
390
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900391#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
392 defined(CONFIG_CPU_SUBTYPE_SH7720)
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394SCIF_FNS(SCSMR, 0x00, 16)
395SCIF_FNS(SCBRR, 0x04, 8)
396SCIF_FNS(SCSCR, 0x08, 16)
397SCIF_FNS(SCTDSR, 0x0c, 8)
398SCIF_FNS(SCFER, 0x10, 16)
399SCIF_FNS(SCxSR, 0x14, 16)
400SCIF_FNS(SCFCR, 0x18, 16)
401SCIF_FNS(SCFDR, 0x1c, 16)
402SCIF_FNS(SCxTDR, 0x20, 8)
403SCIF_FNS(SCxRDR, 0x24, 8)
404SCIF_FNS(SCLSR, 0x24, 16)
405#else
406/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
407/* name off sz off sz off sz off sz off sz*/
408SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8)
409SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8)
410SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8)
411SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
412SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
413SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
414SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
Paul Mundt32351a22007-03-12 14:38:59 +0900415#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
416 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
417 defined(CONFIG_CPU_SUBTYPE_SH7785)
Paul Mundt6fc21b82006-11-27 12:10:23 +0900418SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800419SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
420SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
421SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
422SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
423#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
425SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
426SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
427#endif
Paul Mundtb7a76e42006-02-01 03:06:06 -0800428#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429#define sci_in(port, reg) sci_##reg##_in(port)
430#define sci_out(port, reg, value) sci_##reg##_out(port, value)
431
432/* H8/300 series SCI pins assignment */
433#if defined(__H8300H__) || defined(__H8300S__)
434static const struct __attribute__((packed)) {
435 int port; /* GPIO port no */
436 unsigned short rx,tx; /* GPIO bit no */
437} h8300_sci_pins[] = {
438#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
439 { /* SCI0 */
440 .port = H8300_GPIO_P9,
441 .rx = H8300_GPIO_B2,
442 .tx = H8300_GPIO_B0,
443 },
444 { /* SCI1 */
445 .port = H8300_GPIO_P9,
446 .rx = H8300_GPIO_B3,
447 .tx = H8300_GPIO_B1,
448 },
449 { /* SCI2 */
450 .port = H8300_GPIO_PB,
451 .rx = H8300_GPIO_B7,
452 .tx = H8300_GPIO_B6,
453 }
454#elif defined(CONFIG_H8S2678)
455 { /* SCI0 */
456 .port = H8300_GPIO_P3,
457 .rx = H8300_GPIO_B2,
458 .tx = H8300_GPIO_B0,
459 },
460 { /* SCI1 */
461 .port = H8300_GPIO_P3,
462 .rx = H8300_GPIO_B3,
463 .tx = H8300_GPIO_B1,
464 },
465 { /* SCI2 */
466 .port = H8300_GPIO_P5,
467 .rx = H8300_GPIO_B1,
468 .tx = H8300_GPIO_B0,
469 }
470#endif
471};
472#endif
473
Magnus Damm0fbde952007-07-26 10:14:16 +0900474#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
475 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
476 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
477 defined(CONFIG_CPU_SUBTYPE_SH7709)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478static inline int sci_rxd_in(struct uart_port *port)
479{
480 if (port->mapbase == 0xfffffe80)
481 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
482 if (port->mapbase == 0xa4000150)
483 return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
484 if (port->mapbase == 0xa4000140)
485 return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
486 return 1;
487}
488#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
489static inline int sci_rxd_in(struct uart_port *port)
490{
491 if (port->mapbase == SCIF0)
492 return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
493 if (port->mapbase == SCIF2)
494 return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
495 return 1;
496}
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900497#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
Paul Mundte108b2c2006-09-27 16:32:13 +0900498static inline int sci_rxd_in(struct uart_port *port)
499{
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900500 return sci_in(port,SCxSR)&0x0010 ? 1 : 0;
Paul Mundte108b2c2006-09-27 16:32:13 +0900501}
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900502static inline void set_sh771x_scif_pfc(struct uart_port *port)
503{
504 if (port->mapbase == 0xA4400000){
505 ctrl_outw(ctrl_inw(PACR)&0xffc0,PACR);
506 ctrl_outw(ctrl_inw(PBCR)&0x0fff,PBCR);
507 return;
508 }
509 if (port->mapbase == 0xA4410000){
510 ctrl_outw(ctrl_inw(PBCR)&0xf003,PBCR);
511 return;
512 }
513}
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900514#elif defined(CONFIG_CPU_SUBTYPE_SH7720)
515static inline int sci_rxd_in(struct uart_port *port)
516{
517 if (port->mapbase == 0xa4430000)
518 return sci_in(port, SCxSR) & 0x0003 ? 1 : 0;
519 else if (port->mapbase == 0xa4438000)
520 return sci_in(port, SCxSR) & 0x0003 ? 1 : 0;
521 return 1;
522}
Paul Mundt05627482007-05-15 16:25:47 +0900523#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
524 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
525 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
526 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
527 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
528 defined(CONFIG_CPU_SUBTYPE_SH7091) || \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 defined(CONFIG_CPU_SUBTYPE_SH4_202)
530static inline int sci_rxd_in(struct uart_port *port)
531{
532#ifndef SCIF_ONLY
533 if (port->mapbase == 0xffe00000)
534 return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
535#endif
536#ifndef SCI_ONLY
537 if (port->mapbase == 0xffe80000)
538 return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
539#endif
540 return 1;
541}
542#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
543static inline int sci_rxd_in(struct uart_port *port)
544{
545 if (port->mapbase == 0xfe600000)
546 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
547 if (port->mapbase == 0xfe610000)
548 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
549 if (port->mapbase == 0xfe620000)
550 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt31388752006-12-08 14:26:19 +0900551 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552}
Paul Mundte108b2c2006-09-27 16:32:13 +0900553#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
554static inline int sci_rxd_in(struct uart_port *port)
555{
556 if (port->mapbase == 0xffe00000)
557 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
558 if (port->mapbase == 0xffe10000)
559 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
560 if (port->mapbase == 0xffe20000)
561 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
562 if (port->mapbase == 0xffe30000)
563 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
564 return 1;
565}
Paul Mundt41504c32006-12-11 20:28:03 +0900566#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
567static inline int sci_rxd_in(struct uart_port *port)
568{
569 if (port->mapbase == 0xffe00000)
570 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
571 return 1;
572}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
574static inline int sci_rxd_in(struct uart_port *port)
575{
576 return sci_in(port, SCSPTR)&0x0001 ? 1 : 0; /* SCIF */
577}
578#elif defined(__H8300H__) || defined(__H8300S__)
579static inline int sci_rxd_in(struct uart_port *port)
580{
581 int ch = (port->mapbase - SMR0) >> 3;
582 return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
583}
Paul Mundtb7a76e42006-02-01 03:06:06 -0800584#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
585static inline int sci_rxd_in(struct uart_port *port)
586{
587 if (port->mapbase == 0xff923000)
588 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
589 if (port->mapbase == 0xff924000)
590 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
591 if (port->mapbase == 0xff925000)
592 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt31388752006-12-08 14:26:19 +0900593 return 1;
Paul Mundtb7a76e42006-02-01 03:06:06 -0800594}
595#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
596static inline int sci_rxd_in(struct uart_port *port)
597{
598 if (port->mapbase == 0xffe00000)
599 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
600 if (port->mapbase == 0xffe10000)
601 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt31388752006-12-08 14:26:19 +0900602 return 1;
Paul Mundtb7a76e42006-02-01 03:06:06 -0800603}
Paul Mundt32351a22007-03-12 14:38:59 +0900604#elif defined(CONFIG_CPU_SUBTYPE_SH7785)
605static inline int sci_rxd_in(struct uart_port *port)
606{
607 if (port->mapbase == 0xffea0000)
608 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
609 if (port->mapbase == 0xffeb0000)
610 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
611 if (port->mapbase == 0xffec0000)
612 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
613 if (port->mapbase == 0xffed0000)
614 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
615 if (port->mapbase == 0xffee0000)
616 return ctrl_inw(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF */
617 if (port->mapbase == 0xffef0000)
618 return ctrl_inw(SCSPTR5) & 0x0001 ? 1 : 0; /* SCIF */
619 return 1;
620}
Paul Mundt6d01f512007-11-26 18:17:21 +0900621#elif defined(CONFIG_CPU_SUBTYPE_SH7203) || \
622 defined(CONFIG_CPU_SUBTYPE_SH7206)
Yoshinori Sato9d4436a2006-11-05 15:40:13 +0900623static inline int sci_rxd_in(struct uart_port *port)
624{
625 if (port->mapbase == 0xfffe8000)
626 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
627 if (port->mapbase == 0xfffe8800)
628 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
629 if (port->mapbase == 0xfffe9000)
630 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
631 if (port->mapbase == 0xfffe9800)
632 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt31388752006-12-08 14:26:19 +0900633 return 1;
Yoshinori Sato9d4436a2006-11-05 15:40:13 +0900634}
635#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
636static inline int sci_rxd_in(struct uart_port *port)
637{
638 if (port->mapbase == 0xf8400000)
639 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
640 if (port->mapbase == 0xf8410000)
641 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
642 if (port->mapbase == 0xf8420000)
643 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt31388752006-12-08 14:26:19 +0900644 return 1;
Yoshinori Sato9d4436a2006-11-05 15:40:13 +0900645}
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900646#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
647static inline int sci_rxd_in(struct uart_port *port)
648{
649 if (port->mapbase == 0xffc30000)
650 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
651 if (port->mapbase == 0xffc40000)
652 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
653 if (port->mapbase == 0xffc50000)
654 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
655 if (port->mapbase == 0xffc60000)
656 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
Paul Mundt1760b7d72007-08-08 16:57:05 +0900657 return 1;
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900658}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659#endif
660
661/*
662 * Values for the BitRate Register (SCBRR)
663 *
664 * The values are actually divisors for a frequency which can
665 * be internal to the SH3 (14.7456MHz) or derived from an external
666 * clock source. This driver assumes the internal clock is used;
667 * to support using an external clock source, config options or
668 * possibly command-line options would need to be added.
669 *
670 * Also, to support speeds below 2400 (why?) the lower 2 bits of
671 * the SCSMR register would also need to be set to non-zero values.
672 *
673 * -- Greg Banks 27Feb2000
674 *
675 * Answer: The SCBRR register is only eight bits, and the value in
676 * it gets larger with lower baud rates. At around 2400 (depending on
677 * the peripherial module clock) you run out of bits. However the
678 * lower two bits of SCSMR allow the module clock to be divided down,
679 * scaling the value which is needed in SCBRR.
680 *
681 * -- Stuart Menefy - 23 May 2000
682 *
683 * I meant, why would anyone bother with bitrates below 2400.
684 *
685 * -- Greg Banks - 7Jul2000
686 *
687 * You "speedist"! How will I use my 110bps ASR-33 teletype with paper
688 * tape reader as a console!
689 *
690 * -- Mitch Davis - 15 Jul 2000
691 */
692
Magnus Dammd89ddd12007-07-25 11:42:56 +0900693#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
Paul Mundt32351a22007-03-12 14:38:59 +0900694 defined(CONFIG_CPU_SUBTYPE_SH7785)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800695#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900696#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
697 defined(CONFIG_CPU_SUBTYPE_SH7720)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800698#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
699#elif defined(__H8300H__) || defined(__H8300S__)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800701#elif defined(CONFIG_SUPERH64)
702#define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1)
703#else /* Generic SH */
704#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705#endif