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