blob: ed1c09c0454a0d3db302092a1b30d7f996baeb18 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/serial_core.h>
Paul Mundtedad1f22009-11-25 16:23:35 +09002#include <linux/io.h>
Magnus Damm69edbba2008-12-25 18:17:34 +09003#include <linux/gpio.h>
Markus Brunner3ea6bc32007-08-20 08:59:33 +09004
Magnus Damm0fbde952007-07-26 10:14:16 +09005#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
6 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
7 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
8 defined(CONFIG_CPU_SUBTYPE_SH7709)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
10# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012# define SCPCR 0xA4000116
13# define SCPDR 0xA4000136
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +090014#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +000015 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +000016 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +000017 defined(CONFIG_ARCH_SH7367) || \
18 defined(CONFIG_ARCH_SH7377) || \
19 defined(CONFIG_ARCH_SH7372)
Paul Mundtfd88cac2009-01-09 16:32:08 +090020# define PORT_PTCR 0xA405011EUL
21# define PORT_PVCR 0xA4050122UL
22# define SCIF_ORER 0x0200 /* overrun error bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#elif defined(CONFIG_SH_RTS7751R2D)
Matt Fleming7abc4042008-10-29 07:16:02 +000024# define SCSPTR1 0xFFE0001C /* 8 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
26# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundt05627482007-05-15 16:25:47 +090027#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
28 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
29 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
30 defined(CONFIG_CPU_SUBTYPE_SH7091) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7751R)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033# define SCSPTR1 0xffe0001c /* 8 bit SCI */
34# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
35# define SCIF_ORER 0x0001 /* overrun error bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
Paul Mundtb7a76e42006-02-01 03:06:06 -080037# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
38# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
39# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090041#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
Paul Mundte108b2c2006-09-27 16:32:13 +090042# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +090043# define SCIF_ORER 0x0001 /* overrun error bit */
44# define PACR 0xa4050100
45# define PBCR 0xa4050102
Paul Mundte108b2c2006-09-27 16:32:13 +090046#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
47# define SCSPTR0 0xffe00010 /* 16 bit SCIF */
Paul Mundt41504c32006-12-11 20:28:03 +090048#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
Magnus Damm346b7462008-04-23 21:25:29 +090049# define PWDR 0xA4050166
50# define PSCR 0xA405011E
Paul Mundt41504c32006-12-11 20:28:03 +090051# define SCIF_ORER 0x0001 /* overrun error bit */
Magnus Damm9109a302008-02-08 17:31:24 +090052#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
53# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
54# define SCSPTR0 SCPDR0
55# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundt178dd0c2008-04-09 17:56:18 +090056#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
57# define SCSPTR0 0xa4050160
Paul Mundt178dd0c2008-04-09 17:56:18 +090058# define SCIF_ORER 0x0001 /* overrun error bit */
Kuninori Morimoto47948d22009-04-15 11:42:47 +090059#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
60# define SCIF_ORER 0x0001 /* overrun error bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
63# define SCIF_ORER 0x0001 /* overrun error bit */
Yoshihiro Shimodac01f0f12009-08-21 16:30:28 +090064#elif defined(CONFIG_CPU_SUBTYPE_SH7757)
65# define SCSPTR0 0xfe4b0020
Yoshihiro Shimodac01f0f12009-08-21 16:30:28 +090066# define SCIF_ORER 0x0001
Yoshihiro Shimoda7d740a02008-01-07 14:40:07 +090067#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
68# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
Yoshihiro Shimoda7d740a02008-01-07 14:40:07 +090069# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundtb7a76e42006-02-01 03:06:06 -080070#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
71# define SCSPTR0 0xff923020 /* 16 bit SCIF */
Paul Mundtb7a76e42006-02-01 03:06:06 -080072# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundtb7a76e42006-02-01 03:06:06 -080073#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
74# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
Paul Mundte108b2c2006-09-27 16:32:13 +090075# define SCIF_ORER 0x0001 /* Overrun error bit */
Kuninori Morimoto55ba99e2009-03-03 15:40:25 +090076#elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
77 defined(CONFIG_CPU_SUBTYPE_SH7786)
Paul Mundt32351a22007-03-12 14:38:59 +090078# define SCSPTR0 0xffea0024 /* 16 bit SCIF */
Kuninori Morimoto34aeb432009-02-10 09:04:00 +000079# define SCIF_ORER 0x0001 /* Overrun error bit */
Peter Griffin28259992008-11-28 22:48:20 +090080#elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \
81 defined(CONFIG_CPU_SUBTYPE_SH7203) || \
Paul Mundta8f67f42007-11-26 19:54:02 +090082 defined(CONFIG_CPU_SUBTYPE_SH7206) || \
83 defined(CONFIG_CPU_SUBTYPE_SH7263)
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090084# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090085#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
86# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090087# define SCIF_ORER 0x0001 /* overrun error bit */
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090088#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
89# define SCSPTR0 0xffc30020 /* 16 bit SCIF */
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090090# define SCIF_ORER 0x0001 /* Overrun error bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#else
92# error CPU subtype not defined
93#endif
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095/* SCxSR SCI */
96#define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
97#define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
98#define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
99#define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
100#define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
101#define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
102/* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
103/* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
104
105#define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
106
107/* SCxSR SCIF */
108#define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
109#define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
110#define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
111#define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
112#define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
113#define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
114#define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
115#define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
116
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900117#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900118 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000119 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +0000120 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +0000121 defined(CONFIG_ARCH_SH7367) || \
122 defined(CONFIG_ARCH_SH7377) || \
123 defined(CONFIG_ARCH_SH7372)
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +0900124# define SCIF_ORER 0x0200
125# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
126# define SCIF_RFDC_MASK 0x007f
127# define SCIF_TXROOM_MAX 64
128#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
129# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK )
130# define SCIF_RFDC_MASK 0x007f
131# define SCIF_TXROOM_MAX 64
132/* SH7763 SCIF2 support */
133# define SCIF2_RFDC_MASK 0x001f
134# define SCIF2_TXROOM_MAX 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#else
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +0900136# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
137# define SCIF_RFDC_MASK 0x001f
138# define SCIF_TXROOM_MAX 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif
140
Paul Mundtd830fa42008-12-16 19:29:38 +0900141#ifndef SCIF_ORER
142#define SCIF_ORER 0x0000
143#endif
144
Paul Mundt15c73aa2008-10-02 19:47:12 +0900145#define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
146#define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
147#define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
148#define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
149#define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
150#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
151#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
Paul Mundtd830fa42008-12-16 19:29:38 +0900152#define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
Paul Mundt15c73aa2008-10-02 19:47:12 +0900153
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900154#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900155 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000156 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +0000157 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +0000158 defined(CONFIG_ARCH_SH7367) || \
159 defined(CONFIG_ARCH_SH7377) || \
160 defined(CONFIG_ARCH_SH7372)
Paul Mundt15c73aa2008-10-02 19:47:12 +0900161# define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
162# define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
163# define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
164# define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
167# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
168# define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
169# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
170#endif
171
172/* SCFCR */
173#define SCFCR_RFRST 0x0002
174#define SCFCR_TFRST 0x0004
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175#define SCFCR_MCE 0x0008
176
177#define SCI_MAJOR 204
178#define SCI_MINOR_START 8
179
Paul Mundta01cdc12011-06-08 17:06:25 +0900180#define SCI_IN(size, offset) \
181 ioread##size(port->membase + (offset))
182
183#define SCI_OUT(size, offset, value) \
184 iowrite##size(value, port->membase + (offset))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
187 static inline unsigned int sci_##name##_in(struct uart_port *port) \
188 { \
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000189 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900190 return SCI_IN(scif_size, scif_offset); \
Yoshihiro Shimoda1a22f082008-11-11 12:19:05 +0900191 } else { /* PORT_SCI or PORT_SCIFA */ \
Paul Mundta01cdc12011-06-08 17:06:25 +0900192 return SCI_IN(sci_size, sci_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 } \
194 } \
195 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
196 { \
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000197 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900198 SCI_OUT(scif_size, scif_offset, value); \
Yoshihiro Shimoda1a22f082008-11-11 12:19:05 +0900199 } else { /* PORT_SCI or PORT_SCIFA */ \
200 SCI_OUT(sci_size, sci_offset, value); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 } \
202 }
203
Yoshinori Sato168f3622009-04-28 04:40:15 +0000204#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 static inline unsigned int sci_##name##_in(struct uart_port *port) \
206 { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900207 return SCI_IN(scif_size, scif_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 } \
209 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
210 { \
211 SCI_OUT(scif_size, scif_offset, value); \
212 }
213
Magnus Damm8d099d42010-03-16 11:21:07 +0000214#if defined(CONFIG_CPU_SH3) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +0000215 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +0000216 defined(CONFIG_ARCH_SH7367) || \
217 defined(CONFIG_ARCH_SH7377) || \
218 defined(CONFIG_ARCH_SH7372)
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900219#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
220#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900221 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900222 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
223#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
224 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900225#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900226 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000227 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm5b02c512011-04-28 03:10:35 +0000228 defined(CONFIG_ARCH_SH7367)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000229#define SCIF_FNS(name, scif_offset, scif_size) \
230 CPU_SCIF_FNS(name, scif_offset, scif_size)
Magnus Damm5b02c512011-04-28 03:10:35 +0000231#elif defined(CONFIG_ARCH_SH7377) || \
232 defined(CONFIG_ARCH_SH7372) || \
233 defined(CONFIG_ARCH_SH73A0)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000234#define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \
235 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236#define SCIF_FNS(name, scif_offset, scif_size) \
237 CPU_SCIF_FNS(name, scif_offset, scif_size)
238#else
239#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900240 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
242#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
243 CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
244#endif
Kuninori Morimoto47948d22009-04-15 11:42:47 +0900245#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
246 defined(CONFIG_CPU_SUBTYPE_SH7724)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900247 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \
248 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size)
249 #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
250 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251#else
252#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900253 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
255#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
256 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
257#endif
258
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900259#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900260 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000261 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm5b02c512011-04-28 03:10:35 +0000262 defined(CONFIG_ARCH_SH7367)
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264SCIF_FNS(SCSMR, 0x00, 16)
265SCIF_FNS(SCBRR, 0x04, 8)
266SCIF_FNS(SCSCR, 0x08, 16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267SCIF_FNS(SCxSR, 0x14, 16)
268SCIF_FNS(SCFCR, 0x18, 16)
269SCIF_FNS(SCFDR, 0x1c, 16)
270SCIF_FNS(SCxTDR, 0x20, 8)
271SCIF_FNS(SCxRDR, 0x24, 8)
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000272SCIF_FNS(SCLSR, 0x00, 0)
Magnus Damm5b02c512011-04-28 03:10:35 +0000273#elif defined(CONFIG_ARCH_SH7377) || \
274 defined(CONFIG_ARCH_SH7372) || \
275 defined(CONFIG_ARCH_SH73A0)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000276SCIF_FNS(SCSMR, 0x00, 16)
277SCIF_FNS(SCBRR, 0x04, 8)
278SCIF_FNS(SCSCR, 0x08, 16)
279SCIF_FNS(SCTDSR, 0x0c, 16)
280SCIF_FNS(SCFER, 0x10, 16)
281SCIF_FNS(SCxSR, 0x14, 16)
282SCIF_FNS(SCFCR, 0x18, 16)
283SCIF_FNS(SCFDR, 0x1c, 16)
284SCIF_FNS(SCTFDR, 0x38, 16)
285SCIF_FNS(SCRFDR, 0x3c, 16)
286SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8)
287SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8)
288SCIF_FNS(SCLSR, 0x00, 0)
Kuninori Morimoto47948d22009-04-15 11:42:47 +0900289#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
290 defined(CONFIG_CPU_SUBTYPE_SH7724)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900291SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
292SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
293SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
294SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
295SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
296SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
Magnus Dammf6863592009-01-20 12:18:22 +0900297SCIx_FNS(SCSPTR, 0, 0, 0, 0)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900298SCIF_FNS(SCFCR, 0x18, 16)
299SCIF_FNS(SCFDR, 0x1c, 16)
300SCIF_FNS(SCLSR, 0x24, 16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301#else
Paul Mundtab7cfb52011-06-01 14:47:42 +0900302/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 */
303/* name off sz off sz off sz off sz */
304SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16)
305SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8)
306SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16)
307SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8)
308SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16)
309SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
Paul Mundt32351a22007-03-12 14:38:59 +0900311#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
312 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
Kuninori Morimoto55ba99e2009-03-03 15:40:25 +0900313 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
314 defined(CONFIG_CPU_SUBTYPE_SH7786)
Paul Mundtc2697962008-07-30 00:56:39 +0900315SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800316SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
317SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
318SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
319SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
Paul Mundtc2697962008-07-30 00:56:39 +0900320#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +0900321SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
Paul Mundtc2697962008-07-30 00:56:39 +0900322SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
323SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
324SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
325SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800326#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
Magnus Damm9b4e4662008-04-23 21:31:14 +0900328#if defined(CONFIG_CPU_SUBTYPE_SH7722)
329SCIF_FNS(SCSPTR, 0, 0, 0, 0)
330#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
Magnus Damm9b4e4662008-04-23 21:31:14 +0900332#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
334#endif
Paul Mundtb7a76e42006-02-01 03:06:06 -0800335#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336#define sci_in(port, reg) sci_##reg##_in(port)
337#define sci_out(port, reg, value) sci_##reg##_out(port, value)
338
Magnus Damm0fbde952007-07-26 10:14:16 +0900339#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
340 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
341 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
342 defined(CONFIG_CPU_SUBTYPE_SH7709)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343static inline int sci_rxd_in(struct uart_port *port)
344{
345 if (port->mapbase == 0xfffffe80)
Paul Mundt32b53072009-12-24 14:52:43 +0900346 return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900347 return 1;
348}
Paul Mundt05627482007-05-15 16:25:47 +0900349#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
350 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
351 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
352 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
353 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
Nobuhiro Iwamatsu961e9ff2008-10-29 13:33:45 +0900354 defined(CONFIG_CPU_SUBTYPE_SH7091)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355static inline int sci_rxd_in(struct uart_port *port)
356{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 if (port->mapbase == 0xffe00000)
Paul Mundt32b53072009-12-24 14:52:43 +0900358 return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 return 1;
360}
Magnus Damm9e9622d2010-02-08 11:47:44 +0900361#else /* default case for non-SCI processors */
Yoshihiro Shimoda7d740a02008-01-07 14:40:07 +0900362static inline int sci_rxd_in(struct uart_port *port)
363{
Paul Mundt1760b7d72007-08-08 16:57:05 +0900364 return 1;
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900365}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366#endif