Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/serial_core.h> |
Paul Mundt | edad1f2 | 2009-11-25 16:23:35 +0900 | [diff] [blame] | 2 | #include <linux/io.h> |
Magnus Damm | 69edbba | 2008-12-25 18:17:34 +0900 | [diff] [blame] | 3 | #include <linux/gpio.h> |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 4 | |
Magnus Damm | 0fbde95 | 2007-07-26 10:14:16 +0900 | [diff] [blame] | 5 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ |
| 10 | # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
| 12 | # define SCIF0 0xA4400000 |
| 13 | # define SCIF2 0xA4410000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | # define SCPCR 0xA4000116 |
| 15 | # define SCPDR 0xA4000136 |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 16 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 17 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 18 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 19 | defined(CONFIG_ARCH_SH7367) || \ |
| 20 | defined(CONFIG_ARCH_SH7377) || \ |
| 21 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | fd88cac | 2009-01-09 16:32:08 +0900 | [diff] [blame] | 22 | # define PORT_PTCR 0xA405011EUL |
| 23 | # define PORT_PVCR 0xA4050122UL |
| 24 | # define SCIF_ORER 0x0200 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #elif defined(CONFIG_SH_RTS7751R2D) |
Matt Fleming | 7abc404 | 2008-10-29 07:16:02 +0000 | [diff] [blame] | 26 | # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 28 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 29 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 30 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 31 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
| 32 | defined(CONFIG_CPU_SUBTYPE_SH7091) || \ |
| 33 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 34 | defined(CONFIG_CPU_SUBTYPE_SH7751R) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
| 36 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 37 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 39 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ |
| 40 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ |
| 41 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 43 | #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 44 | # define SCSPTR0 0xA4400000 /* 16 bit SCIF */ |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 45 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 46 | # define PACR 0xa4050100 |
| 47 | # define PBCR 0xa4050102 |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 48 | #elif defined(CONFIG_CPU_SUBTYPE_SH7343) |
| 49 | # define SCSPTR0 0xffe00010 /* 16 bit SCIF */ |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 50 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) |
Magnus Damm | 346b746 | 2008-04-23 21:25:29 +0900 | [diff] [blame] | 51 | # define PADR 0xA4050120 |
| 52 | # define PSDR 0xA405013e |
| 53 | # define PWDR 0xA4050166 |
| 54 | # define PSCR 0xA405011E |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 55 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Magnus Damm | 9109a30 | 2008-02-08 17:31:24 +0900 | [diff] [blame] | 56 | #elif defined(CONFIG_CPU_SUBTYPE_SH7366) |
| 57 | # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ |
| 58 | # define SCSPTR0 SCPDR0 |
| 59 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 60 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) |
| 61 | # define SCSPTR0 0xa4050160 |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 62 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 63 | #elif defined(CONFIG_CPU_SUBTYPE_SH7724) |
| 64 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
| 67 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Yoshihiro Shimoda | c01f0f1 | 2009-08-21 16:30:28 +0900 | [diff] [blame] | 68 | #elif defined(CONFIG_CPU_SUBTYPE_SH7757) |
| 69 | # define SCSPTR0 0xfe4b0020 |
Yoshihiro Shimoda | c01f0f1 | 2009-08-21 16:30:28 +0900 | [diff] [blame] | 70 | # define SCIF_ORER 0x0001 |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 71 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 72 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 73 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 74 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) |
| 75 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 76 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 77 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) |
| 78 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 79 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 80 | #elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 81 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 82 | # define SCSPTR0 0xffea0024 /* 16 bit SCIF */ |
Kuninori Morimoto | 34aeb43 | 2009-02-10 09:04:00 +0000 | [diff] [blame] | 83 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Peter Griffin | 2825999 | 2008-11-28 22:48:20 +0900 | [diff] [blame] | 84 | #elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \ |
| 85 | defined(CONFIG_CPU_SUBTYPE_SH7203) || \ |
Paul Mundt | a8f67f4 | 2007-11-26 19:54:02 +0900 | [diff] [blame] | 86 | defined(CONFIG_CPU_SUBTYPE_SH7206) || \ |
| 87 | defined(CONFIG_CPU_SUBTYPE_SH7263) |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 88 | # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 89 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) |
| 90 | # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 91 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 92 | #elif defined(CONFIG_CPU_SUBTYPE_SHX3) |
| 93 | # define SCSPTR0 0xffc30020 /* 16 bit SCIF */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 94 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #else |
| 96 | # error CPU subtype not defined |
| 97 | #endif |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* SCxSR SCI */ |
| 100 | #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 101 | #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 102 | #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 103 | #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 104 | #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 105 | #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 106 | /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 107 | /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 108 | |
| 109 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) |
| 110 | |
| 111 | /* SCxSR SCIF */ |
| 112 | #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 113 | #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 114 | #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 115 | #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 116 | #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 117 | #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 118 | #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 119 | #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 120 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 121 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 122 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 123 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 124 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 125 | defined(CONFIG_ARCH_SH7367) || \ |
| 126 | defined(CONFIG_ARCH_SH7377) || \ |
| 127 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 128 | # define SCIF_ORER 0x0200 |
| 129 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
| 130 | # define SCIF_RFDC_MASK 0x007f |
| 131 | # define SCIF_TXROOM_MAX 64 |
| 132 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 133 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK ) |
| 134 | # define SCIF_RFDC_MASK 0x007f |
| 135 | # define SCIF_TXROOM_MAX 64 |
| 136 | /* SH7763 SCIF2 support */ |
| 137 | # define SCIF2_RFDC_MASK 0x001f |
| 138 | # define SCIF2_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | #else |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 140 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 141 | # define SCIF_RFDC_MASK 0x001f |
| 142 | # define SCIF_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #endif |
| 144 | |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 145 | #ifndef SCIF_ORER |
| 146 | #define SCIF_ORER 0x0000 |
| 147 | #endif |
| 148 | |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 149 | #define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
| 150 | #define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) |
| 151 | #define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) |
| 152 | #define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) |
| 153 | #define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) |
| 154 | #define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) |
| 155 | #define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 156 | #define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 157 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 158 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 159 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 160 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 161 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 162 | defined(CONFIG_ARCH_SH7367) || \ |
| 163 | defined(CONFIG_ARCH_SH7377) || \ |
| 164 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 165 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
| 166 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
| 167 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
| 168 | # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) |
| 171 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) |
| 172 | # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) |
| 173 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) |
| 174 | #endif |
| 175 | |
| 176 | /* SCFCR */ |
| 177 | #define SCFCR_RFRST 0x0002 |
| 178 | #define SCFCR_TFRST 0x0004 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #define SCFCR_MCE 0x0008 |
| 180 | |
| 181 | #define SCI_MAJOR 204 |
| 182 | #define SCI_MINOR_START 8 |
| 183 | |
Paul Mundt | a01cdc1 | 2011-06-08 17:06:25 +0900 | [diff] [blame^] | 184 | #define SCI_IN(size, offset) \ |
| 185 | ioread##size(port->membase + (offset)) |
| 186 | |
| 187 | #define SCI_OUT(size, offset, value) \ |
| 188 | iowrite##size(value, port->membase + (offset)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
| 191 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 192 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 193 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Paul Mundt | a01cdc1 | 2011-06-08 17:06:25 +0900 | [diff] [blame^] | 194 | return SCI_IN(scif_size, scif_offset); \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 195 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
Paul Mundt | a01cdc1 | 2011-06-08 17:06:25 +0900 | [diff] [blame^] | 196 | return SCI_IN(sci_size, sci_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } \ |
| 198 | } \ |
| 199 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 200 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 201 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Paul Mundt | a01cdc1 | 2011-06-08 17:06:25 +0900 | [diff] [blame^] | 202 | SCI_OUT(scif_size, scif_offset, value); \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 203 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
| 204 | SCI_OUT(sci_size, sci_offset, value); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | } \ |
| 206 | } |
| 207 | |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 208 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 210 | { \ |
Paul Mundt | a01cdc1 | 2011-06-08 17:06:25 +0900 | [diff] [blame^] | 211 | return SCI_IN(scif_size, scif_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | } \ |
| 213 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 214 | { \ |
| 215 | SCI_OUT(scif_size, scif_offset, value); \ |
| 216 | } |
| 217 | |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 218 | #if defined(CONFIG_CPU_SH3) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 219 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 220 | defined(CONFIG_ARCH_SH7367) || \ |
| 221 | defined(CONFIG_ARCH_SH7377) || \ |
| 222 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 223 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
| 224 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
Paul Mundt | ab7cfb5 | 2011-06-01 14:47:42 +0900 | [diff] [blame] | 225 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 226 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 227 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 228 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 229 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 230 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 231 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 5b02c51 | 2011-04-28 03:10:35 +0000 | [diff] [blame] | 232 | defined(CONFIG_ARCH_SH7367) |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 233 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 234 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
Magnus Damm | 5b02c51 | 2011-04-28 03:10:35 +0000 | [diff] [blame] | 235 | #elif defined(CONFIG_ARCH_SH7377) || \ |
| 236 | defined(CONFIG_ARCH_SH7372) || \ |
| 237 | defined(CONFIG_ARCH_SH73A0) |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 238 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \ |
| 239 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 241 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 242 | #else |
| 243 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
Paul Mundt | ab7cfb5 | 2011-06-01 14:47:42 +0900 | [diff] [blame] | 244 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size) |
| 246 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 247 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) |
| 248 | #endif |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 249 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 250 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 251 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \ |
| 252 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) |
| 253 | #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ |
| 254 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | #else |
| 256 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
Paul Mundt | ab7cfb5 | 2011-06-01 14:47:42 +0900 | [diff] [blame] | 257 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 259 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 260 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 261 | #endif |
| 262 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 263 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 264 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 265 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 5b02c51 | 2011-04-28 03:10:35 +0000 | [diff] [blame] | 266 | defined(CONFIG_ARCH_SH7367) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | SCIF_FNS(SCSMR, 0x00, 16) |
| 269 | SCIF_FNS(SCBRR, 0x04, 8) |
| 270 | SCIF_FNS(SCSCR, 0x08, 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | SCIF_FNS(SCxSR, 0x14, 16) |
| 272 | SCIF_FNS(SCFCR, 0x18, 16) |
| 273 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 274 | SCIF_FNS(SCxTDR, 0x20, 8) |
| 275 | SCIF_FNS(SCxRDR, 0x24, 8) |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 276 | SCIF_FNS(SCLSR, 0x00, 0) |
Magnus Damm | 5b02c51 | 2011-04-28 03:10:35 +0000 | [diff] [blame] | 277 | #elif defined(CONFIG_ARCH_SH7377) || \ |
| 278 | defined(CONFIG_ARCH_SH7372) || \ |
| 279 | defined(CONFIG_ARCH_SH73A0) |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 280 | SCIF_FNS(SCSMR, 0x00, 16) |
| 281 | SCIF_FNS(SCBRR, 0x04, 8) |
| 282 | SCIF_FNS(SCSCR, 0x08, 16) |
| 283 | SCIF_FNS(SCTDSR, 0x0c, 16) |
| 284 | SCIF_FNS(SCFER, 0x10, 16) |
| 285 | SCIF_FNS(SCxSR, 0x14, 16) |
| 286 | SCIF_FNS(SCFCR, 0x18, 16) |
| 287 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 288 | SCIF_FNS(SCTFDR, 0x38, 16) |
| 289 | SCIF_FNS(SCRFDR, 0x3c, 16) |
| 290 | SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8) |
| 291 | SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8) |
| 292 | SCIF_FNS(SCLSR, 0x00, 0) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 293 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 294 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 295 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
| 296 | SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) |
| 297 | SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) |
| 298 | SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) |
| 299 | SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) |
| 300 | SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) |
Magnus Damm | f686359 | 2009-01-20 12:18:22 +0900 | [diff] [blame] | 301 | SCIx_FNS(SCSPTR, 0, 0, 0, 0) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 302 | SCIF_FNS(SCFCR, 0x18, 16) |
| 303 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 304 | SCIF_FNS(SCLSR, 0x24, 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | #else |
Paul Mundt | ab7cfb5 | 2011-06-01 14:47:42 +0900 | [diff] [blame] | 306 | /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 */ |
| 307 | /* name off sz off sz off sz off sz */ |
| 308 | SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16) |
| 309 | SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8) |
| 310 | SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16) |
| 311 | SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8) |
| 312 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16) |
| 313 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 315 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ |
| 316 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 317 | defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 318 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 319 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 320 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 321 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 322 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 323 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 324 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 325 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 326 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 327 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 328 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 329 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 330 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 332 | #if defined(CONFIG_CPU_SUBTYPE_SH7722) |
| 333 | SCIF_FNS(SCSPTR, 0, 0, 0, 0) |
| 334 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 336 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
| 338 | #endif |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 339 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | #define sci_in(port, reg) sci_##reg##_in(port) |
| 341 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
| 342 | |
Magnus Damm | 0fbde95 | 2007-07-26 10:14:16 +0900 | [diff] [blame] | 343 | #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ |
| 344 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ |
| 345 | defined(CONFIG_CPU_SUBTYPE_SH7708) || \ |
| 346 | defined(CONFIG_CPU_SUBTYPE_SH7709) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | static inline int sci_rxd_in(struct uart_port *port) |
| 348 | { |
| 349 | if (port->mapbase == 0xfffffe80) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 350 | return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */ |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 351 | return 1; |
| 352 | } |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 353 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 354 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 355 | defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ |
| 356 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 357 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
Nobuhiro Iwamatsu | 961e9ff | 2008-10-29 13:33:45 +0900 | [diff] [blame] | 358 | defined(CONFIG_CPU_SUBTYPE_SH7091) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | static inline int sci_rxd_in(struct uart_port *port) |
| 360 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | if (port->mapbase == 0xffe00000) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 362 | return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | return 1; |
| 364 | } |
Magnus Damm | 9e9622d | 2010-02-08 11:47:44 +0900 | [diff] [blame] | 365 | #else /* default case for non-SCI processors */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 366 | static inline int sci_rxd_in(struct uart_port *port) |
| 367 | { |
Paul Mundt | 1760b7d7 | 2007-08-08 16:57:05 +0900 | [diff] [blame] | 368 | return 1; |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 369 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | #endif |