blob: caab353a98b5d160174d5f37bb931a6080aa2dd8 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#elif defined(CONFIG_SH_RTS7751R2D)
Matt Fleming7abc4042008-10-29 07:16:02 +000023# define SCSPTR1 0xFFE0001C /* 8 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
Paul Mundt05627482007-05-15 16:25:47 +090025#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
26 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
27 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
28 defined(CONFIG_CPU_SUBTYPE_SH7091) || \
29 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
30 defined(CONFIG_CPU_SUBTYPE_SH7751R)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031# define SCSPTR1 0xffe0001c /* 8 bit SCI */
32# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
Paul Mundtb7a76e42006-02-01 03:06:06 -080034# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
35# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
36# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090037#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
Paul Mundte108b2c2006-09-27 16:32:13 +090038# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +090039# define PACR 0xa4050100
40# define PBCR 0xa4050102
Paul Mundte108b2c2006-09-27 16:32:13 +090041#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
42# define SCSPTR0 0xffe00010 /* 16 bit SCIF */
Paul Mundt41504c32006-12-11 20:28:03 +090043#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
Magnus Damm346b7462008-04-23 21:25:29 +090044# define PWDR 0xA4050166
45# define PSCR 0xA405011E
Magnus Damm9109a302008-02-08 17:31:24 +090046#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
47# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
48# define SCSPTR0 SCPDR0
Paul Mundt178dd0c2008-04-09 17:56:18 +090049#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
50# define SCSPTR0 0xa4050160
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
Yoshihiro Shimodac01f0f12009-08-21 16:30:28 +090053#elif defined(CONFIG_CPU_SUBTYPE_SH7757)
54# define SCSPTR0 0xfe4b0020
Yoshihiro Shimoda7d740a02008-01-07 14:40:07 +090055#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
56# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
Paul Mundtb7a76e42006-02-01 03:06:06 -080057#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
58# define SCSPTR0 0xff923020 /* 16 bit SCIF */
Paul Mundtb7a76e42006-02-01 03:06:06 -080059#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
60# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
Kuninori Morimoto55ba99e2009-03-03 15:40:25 +090061#elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
62 defined(CONFIG_CPU_SUBTYPE_SH7786)
Paul Mundt32351a22007-03-12 14:38:59 +090063# define SCSPTR0 0xffea0024 /* 16 bit SCIF */
Peter Griffin28259992008-11-28 22:48:20 +090064#elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \
65 defined(CONFIG_CPU_SUBTYPE_SH7203) || \
Paul Mundta8f67f42007-11-26 19:54:02 +090066 defined(CONFIG_CPU_SUBTYPE_SH7206) || \
67 defined(CONFIG_CPU_SUBTYPE_SH7263)
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090068# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
Yoshinori Sato9d4436a2006-11-05 15:40:13 +090069#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
70# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
Paul Mundt2b1bd1a2007-06-20 18:27:10 +090071#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
72# define SCSPTR0 0xffc30020 /* 16 bit SCIF */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#else
74# error CPU subtype not defined
75#endif
76
Markus Brunner3ea6bc32007-08-20 08:59:33 +090077#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +090078 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +000079 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +000080 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +000081 defined(CONFIG_ARCH_SH7367) || \
82 defined(CONFIG_ARCH_SH7377) || \
83 defined(CONFIG_ARCH_SH7372)
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +090084# define SCIF_RFDC_MASK 0x007f
85# define SCIF_TXROOM_MAX 64
86#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +090087# define SCIF_RFDC_MASK 0x007f
88# define SCIF_TXROOM_MAX 64
89/* SH7763 SCIF2 support */
90# define SCIF2_RFDC_MASK 0x001f
91# define SCIF2_TXROOM_MAX 16
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#else
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +090093# define SCIF_RFDC_MASK 0x001f
94# define SCIF_TXROOM_MAX 16
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#endif
96
Paul Mundt15c73aa2008-10-02 19:47:12 +090097#define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
Paul Mundt15c73aa2008-10-02 19:47:12 +090098#define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
99#define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
100#define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
101#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
102#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
Paul Mundtdebf9502011-06-08 18:19:37 +0900103
104#define SCxSR_ERRORS(port) (to_sci_port(port)->cfg->error_mask)
Paul Mundt15c73aa2008-10-02 19:47:12 +0900105
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900106#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900107 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000108 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +0000109 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +0000110 defined(CONFIG_ARCH_SH7367) || \
111 defined(CONFIG_ARCH_SH7377) || \
112 defined(CONFIG_ARCH_SH7372)
Paul Mundt15c73aa2008-10-02 19:47:12 +0900113# define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
114# define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
115# define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
116# define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
119# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
120# define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
121# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
122#endif
123
124/* SCFCR */
125#define SCFCR_RFRST 0x0002
126#define SCFCR_TFRST 0x0004
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127#define SCFCR_MCE 0x0008
128
129#define SCI_MAJOR 204
130#define SCI_MINOR_START 8
131
Paul Mundta01cdc12011-06-08 17:06:25 +0900132#define SCI_IN(size, offset) \
133 ioread##size(port->membase + (offset))
134
135#define SCI_OUT(size, offset, value) \
136 iowrite##size(value, port->membase + (offset))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
139 static inline unsigned int sci_##name##_in(struct uart_port *port) \
140 { \
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000141 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900142 return SCI_IN(scif_size, scif_offset); \
Yoshihiro Shimoda1a22f082008-11-11 12:19:05 +0900143 } else { /* PORT_SCI or PORT_SCIFA */ \
Paul Mundta01cdc12011-06-08 17:06:25 +0900144 return SCI_IN(sci_size, sci_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 } \
146 } \
147 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
148 { \
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000149 if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900150 SCI_OUT(scif_size, scif_offset, value); \
Yoshihiro Shimoda1a22f082008-11-11 12:19:05 +0900151 } else { /* PORT_SCI or PORT_SCIFA */ \
152 SCI_OUT(sci_size, sci_offset, value); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 } \
154 }
155
Yoshinori Sato168f3622009-04-28 04:40:15 +0000156#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 static inline unsigned int sci_##name##_in(struct uart_port *port) \
158 { \
Paul Mundta01cdc12011-06-08 17:06:25 +0900159 return SCI_IN(scif_size, scif_offset); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 } \
161 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
162 { \
163 SCI_OUT(scif_size, scif_offset, value); \
164 }
165
Magnus Damm8d099d42010-03-16 11:21:07 +0000166#if defined(CONFIG_CPU_SH3) || \
Magnus Damm6d9598e2010-11-17 10:59:31 +0000167 defined(CONFIG_ARCH_SH73A0) || \
Magnus Damm8d099d42010-03-16 11:21:07 +0000168 defined(CONFIG_ARCH_SH7367) || \
169 defined(CONFIG_ARCH_SH7377) || \
170 defined(CONFIG_ARCH_SH7372)
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900171#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
172#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900173 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900174 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
175#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
176 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900177#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900178 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000179 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm5b02c512011-04-28 03:10:35 +0000180 defined(CONFIG_ARCH_SH7367)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000181#define SCIF_FNS(name, scif_offset, scif_size) \
182 CPU_SCIF_FNS(name, scif_offset, scif_size)
Magnus Damm5b02c512011-04-28 03:10:35 +0000183#elif defined(CONFIG_ARCH_SH7377) || \
184 defined(CONFIG_ARCH_SH7372) || \
185 defined(CONFIG_ARCH_SH73A0)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000186#define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \
187 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188#define SCIF_FNS(name, scif_offset, scif_size) \
189 CPU_SCIF_FNS(name, scif_offset, scif_size)
190#else
191#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900192 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
194#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
195 CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
196#endif
Kuninori Morimoto47948d22009-04-15 11:42:47 +0900197#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
198 defined(CONFIG_CPU_SUBTYPE_SH7724)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900199 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \
200 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size)
201 #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
202 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#else
204#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
Paul Mundtab7cfb52011-06-01 14:47:42 +0900205 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
207#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
208 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
209#endif
210
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900211#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
Yoshihiro Shimoda31a49c42007-12-26 11:45:06 +0900212 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000213 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
Magnus Damm5b02c512011-04-28 03:10:35 +0000214 defined(CONFIG_ARCH_SH7367)
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900215
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216SCIF_FNS(SCSMR, 0x00, 16)
217SCIF_FNS(SCBRR, 0x04, 8)
218SCIF_FNS(SCSCR, 0x08, 16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219SCIF_FNS(SCxSR, 0x14, 16)
220SCIF_FNS(SCFCR, 0x18, 16)
221SCIF_FNS(SCFDR, 0x1c, 16)
222SCIF_FNS(SCxTDR, 0x20, 8)
223SCIF_FNS(SCxRDR, 0x24, 8)
Magnus Damm8a77b8d2010-02-05 11:15:33 +0000224SCIF_FNS(SCLSR, 0x00, 0)
Magnus Damm5b02c512011-04-28 03:10:35 +0000225#elif defined(CONFIG_ARCH_SH7377) || \
226 defined(CONFIG_ARCH_SH7372) || \
227 defined(CONFIG_ARCH_SH73A0)
Guennadi Liakhovetskid1d4b102010-05-23 16:39:09 +0000228SCIF_FNS(SCSMR, 0x00, 16)
229SCIF_FNS(SCBRR, 0x04, 8)
230SCIF_FNS(SCSCR, 0x08, 16)
231SCIF_FNS(SCTDSR, 0x0c, 16)
232SCIF_FNS(SCFER, 0x10, 16)
233SCIF_FNS(SCxSR, 0x14, 16)
234SCIF_FNS(SCFCR, 0x18, 16)
235SCIF_FNS(SCFDR, 0x1c, 16)
236SCIF_FNS(SCTFDR, 0x38, 16)
237SCIF_FNS(SCRFDR, 0x3c, 16)
238SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8)
239SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8)
240SCIF_FNS(SCLSR, 0x00, 0)
Kuninori Morimoto47948d22009-04-15 11:42:47 +0900241#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
242 defined(CONFIG_CPU_SUBTYPE_SH7724)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900243SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
244SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
245SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
246SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
247SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
248SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
Magnus Dammf6863592009-01-20 12:18:22 +0900249SCIx_FNS(SCSPTR, 0, 0, 0, 0)
Paul Mundt178dd0c2008-04-09 17:56:18 +0900250SCIF_FNS(SCFCR, 0x18, 16)
251SCIF_FNS(SCFDR, 0x1c, 16)
252SCIF_FNS(SCLSR, 0x24, 16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253#else
Paul Mundtab7cfb52011-06-01 14:47:42 +0900254/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 */
255/* name off sz off sz off sz off sz */
256SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16)
257SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8)
258SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16)
259SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8)
260SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16)
261SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
Paul Mundt32351a22007-03-12 14:38:59 +0900263#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
264 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
Kuninori Morimoto55ba99e2009-03-03 15:40:25 +0900265 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
266 defined(CONFIG_CPU_SUBTYPE_SH7786)
Paul Mundtc2697962008-07-30 00:56:39 +0900267SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800268SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
269SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
270SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
271SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
Paul Mundtc2697962008-07-30 00:56:39 +0900272#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
Nobuhiro Iwamatsuc63847a2008-06-06 17:04:08 +0900273SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
Paul Mundtc2697962008-07-30 00:56:39 +0900274SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
275SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
276SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
277SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
Paul Mundtb7a76e42006-02-01 03:06:06 -0800278#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
Magnus Damm9b4e4662008-04-23 21:31:14 +0900280#if defined(CONFIG_CPU_SUBTYPE_SH7722)
281SCIF_FNS(SCSPTR, 0, 0, 0, 0)
282#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
Magnus Damm9b4e4662008-04-23 21:31:14 +0900284#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
286#endif
Paul Mundtb7a76e42006-02-01 03:06:06 -0800287#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288#define sci_in(port, reg) sci_##reg##_in(port)
289#define sci_out(port, reg, value) sci_##reg##_out(port, value)
290
Magnus Damm0fbde952007-07-26 10:14:16 +0900291#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
292 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
293 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
294 defined(CONFIG_CPU_SUBTYPE_SH7709)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295static inline int sci_rxd_in(struct uart_port *port)
296{
297 if (port->mapbase == 0xfffffe80)
Paul Mundt32b53072009-12-24 14:52:43 +0900298 return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
Markus Brunner3ea6bc32007-08-20 08:59:33 +0900299 return 1;
300}
Paul Mundt05627482007-05-15 16:25:47 +0900301#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
302 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
303 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
304 defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
305 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
Nobuhiro Iwamatsu961e9ff2008-10-29 13:33:45 +0900306 defined(CONFIG_CPU_SUBTYPE_SH7091)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307static inline int sci_rxd_in(struct uart_port *port)
308{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 if (port->mapbase == 0xffe00000)
Paul Mundt32b53072009-12-24 14:52:43 +0900310 return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 return 1;
312}
Magnus Damm9e9622d2010-02-08 11:47:44 +0900313#else /* default case for non-SCI processors */
Yoshihiro Shimoda7d740a02008-01-07 14:40:07 +0900314static inline int sci_rxd_in(struct uart_port *port)
315{
Paul Mundt1760b7d72007-08-08 16:57:05 +0900316 return 1;
Paul Mundt2b1bd1a2007-06-20 18:27:10 +0900317}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318#endif