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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 6 | #include <asm/regs306x.h> |
| 7 | #endif |
| 8 | #if defined(CONFIG_H8S2678) |
| 9 | #include <asm/regs267x.h> |
| 10 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Magnus Damm | 0fbde95 | 2007-07-26 10:14:16 +0900 | [diff] [blame] | 12 | #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ |
| 13 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ |
| 14 | defined(CONFIG_CPU_SUBTYPE_SH7708) || \ |
| 15 | defined(CONFIG_CPU_SUBTYPE_SH7709) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ |
| 17 | # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
| 19 | # define SCIF0 0xA4400000 |
| 20 | # define SCIF2 0xA4410000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | # define SCPCR 0xA4000116 |
| 22 | # define SCPDR 0xA4000136 |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 23 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 24 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 25 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 26 | defined(CONFIG_ARCH_SH7367) || \ |
| 27 | defined(CONFIG_ARCH_SH7377) || \ |
| 28 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | fd88cac | 2009-01-09 16:32:08 +0900 | [diff] [blame] | 29 | # define PORT_PTCR 0xA405011EUL |
| 30 | # define PORT_PVCR 0xA4050122UL |
| 31 | # define SCIF_ORER 0x0200 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #elif defined(CONFIG_SH_RTS7751R2D) |
Matt Fleming | 7abc404 | 2008-10-29 07:16:02 +0000 | [diff] [blame] | 33 | # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 35 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 36 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 37 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 38 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
| 39 | defined(CONFIG_CPU_SUBTYPE_SH7091) || \ |
| 40 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 41 | defined(CONFIG_CPU_SUBTYPE_SH7751R) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
| 43 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 44 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 46 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ |
| 47 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ |
| 48 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 50 | #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 51 | # define SCSPTR0 0xA4400000 /* 16 bit SCIF */ |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 52 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 53 | # define PACR 0xa4050100 |
| 54 | # define PBCR 0xa4050102 |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 55 | #elif defined(CONFIG_CPU_SUBTYPE_SH7343) |
| 56 | # define SCSPTR0 0xffe00010 /* 16 bit SCIF */ |
| 57 | # define SCSPTR1 0xffe10010 /* 16 bit SCIF */ |
| 58 | # define SCSPTR2 0xffe20010 /* 16 bit SCIF */ |
| 59 | # define SCSPTR3 0xffe30010 /* 16 bit SCIF */ |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 60 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) |
Magnus Damm | 346b746 | 2008-04-23 21:25:29 +0900 | [diff] [blame] | 61 | # define PADR 0xA4050120 |
| 62 | # define PSDR 0xA405013e |
| 63 | # define PWDR 0xA4050166 |
| 64 | # define PSCR 0xA405011E |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 65 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Magnus Damm | 9109a30 | 2008-02-08 17:31:24 +0900 | [diff] [blame] | 66 | #elif defined(CONFIG_CPU_SUBTYPE_SH7366) |
| 67 | # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ |
| 68 | # define SCSPTR0 SCPDR0 |
| 69 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 70 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) |
| 71 | # define SCSPTR0 0xa4050160 |
| 72 | # define SCSPTR1 0xa405013e |
| 73 | # define SCSPTR2 0xa4050160 |
| 74 | # define SCSPTR3 0xa405013e |
| 75 | # define SCSPTR4 0xa4050128 |
| 76 | # define SCSPTR5 0xa4050128 |
| 77 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 78 | #elif defined(CONFIG_CPU_SUBTYPE_SH7724) |
| 79 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
| 82 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | # define SCIF_PTR2_OFFS 0x0000020 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | # define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) |
| 88 | #elif defined(CONFIG_H8S2678) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) |
Yoshihiro Shimoda | c01f0f1 | 2009-08-21 16:30:28 +0900 | [diff] [blame] | 90 | #elif defined(CONFIG_CPU_SUBTYPE_SH7757) |
| 91 | # define SCSPTR0 0xfe4b0020 |
| 92 | # define SCSPTR1 0xfe4b0020 |
| 93 | # define SCSPTR2 0xfe4b0020 |
| 94 | # define SCIF_ORER 0x0001 |
Yoshihiro Shimoda | c01f0f1 | 2009-08-21 16:30:28 +0900 | [diff] [blame] | 95 | # define SCIF_ONLY |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 96 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 97 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 98 | # define SCSPTR1 0xffe08024 /* 16 bit SCIF */ |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 99 | # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 100 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 101 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) |
| 102 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ |
| 103 | # define SCSPTR1 0xff924020 /* 16 bit SCIF */ |
| 104 | # define SCSPTR2 0xff925020 /* 16 bit SCIF */ |
| 105 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 106 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) |
| 107 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 108 | # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 109 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 110 | #elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 111 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 112 | # define SCSPTR0 0xffea0024 /* 16 bit SCIF */ |
| 113 | # define SCSPTR1 0xffeb0024 /* 16 bit SCIF */ |
| 114 | # define SCSPTR2 0xffec0024 /* 16 bit SCIF */ |
| 115 | # define SCSPTR3 0xffed0024 /* 16 bit SCIF */ |
| 116 | # define SCSPTR4 0xffee0024 /* 16 bit SCIF */ |
| 117 | # define SCSPTR5 0xffef0024 /* 16 bit SCIF */ |
Kuninori Morimoto | 34aeb43 | 2009-02-10 09:04:00 +0000 | [diff] [blame] | 118 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Peter Griffin | 2825999 | 2008-11-28 22:48:20 +0900 | [diff] [blame] | 119 | #elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \ |
| 120 | defined(CONFIG_CPU_SUBTYPE_SH7203) || \ |
Paul Mundt | a8f67f4 | 2007-11-26 19:54:02 +0900 | [diff] [blame] | 121 | defined(CONFIG_CPU_SUBTYPE_SH7206) || \ |
| 122 | defined(CONFIG_CPU_SUBTYPE_SH7263) |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 123 | # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ |
| 124 | # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */ |
| 125 | # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */ |
| 126 | # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */ |
Peter Griffin | 2825999 | 2008-11-28 22:48:20 +0900 | [diff] [blame] | 127 | # if defined(CONFIG_CPU_SUBTYPE_SH7201) |
| 128 | # define SCSPTR4 0xfffeA020 /* 16 bit SCIF */ |
| 129 | # define SCSPTR5 0xfffeA820 /* 16 bit SCIF */ |
| 130 | # define SCSPTR6 0xfffeB020 /* 16 bit SCIF */ |
| 131 | # define SCSPTR7 0xfffeB820 /* 16 bit SCIF */ |
| 132 | # endif |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 133 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) |
| 134 | # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ |
| 135 | # define SCSPTR1 0xf8410020 /* 16 bit SCIF */ |
| 136 | # define SCSPTR2 0xf8420020 /* 16 bit SCIF */ |
| 137 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 138 | #elif defined(CONFIG_CPU_SUBTYPE_SHX3) |
| 139 | # define SCSPTR0 0xffc30020 /* 16 bit SCIF */ |
| 140 | # define SCSPTR1 0xffc40020 /* 16 bit SCIF */ |
| 141 | # define SCSPTR2 0xffc50020 /* 16 bit SCIF */ |
| 142 | # define SCSPTR3 0xffc60020 /* 16 bit SCIF */ |
| 143 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | #else |
| 145 | # error CPU subtype not defined |
| 146 | #endif |
| 147 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | /* SCxSR SCI */ |
| 149 | #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 150 | #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 151 | #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 152 | #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 153 | #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 154 | #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 155 | /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 156 | /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 157 | |
| 158 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) |
| 159 | |
| 160 | /* SCxSR SCIF */ |
| 161 | #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 162 | #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 163 | #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 164 | #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 165 | #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 166 | #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 167 | #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 168 | #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 169 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 170 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 171 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 172 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 173 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 174 | defined(CONFIG_ARCH_SH7367) || \ |
| 175 | defined(CONFIG_ARCH_SH7377) || \ |
| 176 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 177 | # define SCIF_ORER 0x0200 |
| 178 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
| 179 | # define SCIF_RFDC_MASK 0x007f |
| 180 | # define SCIF_TXROOM_MAX 64 |
| 181 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 182 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK ) |
| 183 | # define SCIF_RFDC_MASK 0x007f |
| 184 | # define SCIF_TXROOM_MAX 64 |
| 185 | /* SH7763 SCIF2 support */ |
| 186 | # define SCIF2_RFDC_MASK 0x001f |
| 187 | # define SCIF2_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | #else |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 189 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 190 | # define SCIF_RFDC_MASK 0x001f |
| 191 | # define SCIF_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #endif |
| 193 | |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 194 | #ifndef SCIF_ORER |
| 195 | #define SCIF_ORER 0x0000 |
| 196 | #endif |
| 197 | |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 198 | #define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
| 199 | #define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) |
| 200 | #define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) |
| 201 | #define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) |
| 202 | #define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) |
| 203 | #define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) |
| 204 | #define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 205 | #define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 206 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 207 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 208 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 209 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 210 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 211 | defined(CONFIG_ARCH_SH7367) || \ |
| 212 | defined(CONFIG_ARCH_SH7377) || \ |
| 213 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 214 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
| 215 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
| 216 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
| 217 | # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) |
| 220 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) |
| 221 | # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) |
| 222 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) |
| 223 | #endif |
| 224 | |
| 225 | /* SCFCR */ |
| 226 | #define SCFCR_RFRST 0x0002 |
| 227 | #define SCFCR_TFRST 0x0004 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #define SCFCR_MCE 0x0008 |
| 229 | |
| 230 | #define SCI_MAJOR 204 |
| 231 | #define SCI_MINOR_START 8 |
| 232 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | #define SCI_IN(size, offset) \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 234 | if ((size) == 8) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 235 | return ioread8(port->membase + (offset)); \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 236 | } else { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 237 | return ioread16(port->membase + (offset)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | } |
| 239 | #define SCI_OUT(size, offset, value) \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 240 | if ((size) == 8) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 241 | iowrite8(value, port->membase + (offset)); \ |
Magnus Damm | 3d2c2f3 | 2008-04-23 21:37:39 +0900 | [diff] [blame] | 242 | } else if ((size) == 16) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 243 | iowrite16(value, port->membase + (offset)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
| 247 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 248 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 249 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 250 | SCI_IN(scif_size, scif_offset) \ |
| 251 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
| 252 | SCI_IN(sci_size, sci_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } \ |
| 254 | } \ |
| 255 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 256 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 257 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 258 | SCI_OUT(scif_size, scif_offset, value) \ |
| 259 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
| 260 | SCI_OUT(sci_size, sci_offset, value); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | } \ |
| 262 | } |
| 263 | |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 264 | #ifdef CONFIG_H8300 |
| 265 | /* h8300 don't have SCIF */ |
| 266 | #define CPU_SCIF_FNS(name) \ |
| 267 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 268 | { \ |
| 269 | return 0; \ |
| 270 | } \ |
| 271 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 272 | { \ |
| 273 | } |
| 274 | #else |
| 275 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 277 | { \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 278 | SCI_IN(scif_size, scif_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } \ |
| 280 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 281 | { \ |
| 282 | SCI_OUT(scif_size, scif_offset, value); \ |
| 283 | } |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 284 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
| 286 | #define CPU_SCI_FNS(name, sci_offset, sci_size) \ |
| 287 | static inline unsigned int sci_##name##_in(struct uart_port* port) \ |
| 288 | { \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 289 | SCI_IN(sci_size, sci_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } \ |
| 291 | static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ |
| 292 | { \ |
| 293 | SCI_OUT(sci_size, sci_offset, value); \ |
| 294 | } |
| 295 | |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 296 | #if defined(CONFIG_CPU_SH3) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 297 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 298 | defined(CONFIG_ARCH_SH7367) || \ |
| 299 | defined(CONFIG_ARCH_SH7377) || \ |
| 300 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 301 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
| 302 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 303 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 304 | h8_sci_offset, h8_sci_size) \ |
| 305 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 306 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 307 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 308 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 309 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 310 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 311 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 312 | defined(CONFIG_ARCH_SH7367) || \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 313 | defined(CONFIG_ARCH_SH7377) |
| 314 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 315 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 316 | #elif defined(CONFIG_ARCH_SH7372) |
| 317 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \ |
| 318 | 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] | 319 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 320 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 321 | #else |
| 322 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 323 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 324 | h8_sci_offset, h8_sci_size) \ |
| 325 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size) |
| 326 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 327 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) |
| 328 | #endif |
| 329 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 330 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 331 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 332 | h8_sci_offset, h8_sci_size) \ |
| 333 | CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 334 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 335 | CPU_SCIF_FNS(name) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 336 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 337 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 338 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \ |
| 339 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) |
| 340 | #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ |
| 341 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | #else |
| 343 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 344 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 345 | h8_sci_offset, h8_sci_size) \ |
| 346 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 347 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 348 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 349 | #endif |
| 350 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 351 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 352 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 353 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 354 | defined(CONFIG_ARCH_SH73A0) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 355 | defined(CONFIG_ARCH_SH7367) || \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 356 | defined(CONFIG_ARCH_SH7377) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | SCIF_FNS(SCSMR, 0x00, 16) |
| 359 | SCIF_FNS(SCBRR, 0x04, 8) |
| 360 | SCIF_FNS(SCSCR, 0x08, 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | SCIF_FNS(SCxSR, 0x14, 16) |
| 362 | SCIF_FNS(SCFCR, 0x18, 16) |
| 363 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 364 | SCIF_FNS(SCxTDR, 0x20, 8) |
| 365 | SCIF_FNS(SCxRDR, 0x24, 8) |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 366 | SCIF_FNS(SCLSR, 0x00, 0) |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 367 | #elif defined(CONFIG_ARCH_SH7372) |
| 368 | SCIF_FNS(SCSMR, 0x00, 16) |
| 369 | SCIF_FNS(SCBRR, 0x04, 8) |
| 370 | SCIF_FNS(SCSCR, 0x08, 16) |
| 371 | SCIF_FNS(SCTDSR, 0x0c, 16) |
| 372 | SCIF_FNS(SCFER, 0x10, 16) |
| 373 | SCIF_FNS(SCxSR, 0x14, 16) |
| 374 | SCIF_FNS(SCFCR, 0x18, 16) |
| 375 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 376 | SCIF_FNS(SCTFDR, 0x38, 16) |
| 377 | SCIF_FNS(SCRFDR, 0x3c, 16) |
| 378 | SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8) |
| 379 | SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8) |
| 380 | SCIF_FNS(SCLSR, 0x00, 0) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 381 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 382 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 383 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
| 384 | SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) |
| 385 | SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) |
| 386 | SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) |
| 387 | SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) |
| 388 | SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) |
Magnus Damm | f686359 | 2009-01-20 12:18:22 +0900 | [diff] [blame] | 389 | SCIx_FNS(SCSPTR, 0, 0, 0, 0) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 390 | SCIF_FNS(SCFCR, 0x18, 16) |
| 391 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 392 | SCIF_FNS(SCLSR, 0x24, 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | #else |
| 394 | /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ |
| 395 | /* name off sz off sz off sz off sz off sz*/ |
| 396 | SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8) |
| 397 | SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8) |
| 398 | SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8) |
| 399 | SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) |
| 400 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) |
| 401 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
| 402 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 403 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ |
| 404 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 405 | defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 406 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 407 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 408 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 409 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 410 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 411 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 412 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 413 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
| 414 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 415 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 416 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 417 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 418 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 419 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 421 | #if defined(CONFIG_CPU_SUBTYPE_SH7722) |
| 422 | SCIF_FNS(SCSPTR, 0, 0, 0, 0) |
| 423 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 425 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
| 427 | #endif |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 428 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | #define sci_in(port, reg) sci_##reg##_in(port) |
| 430 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
| 431 | |
| 432 | /* H8/300 series SCI pins assignment */ |
| 433 | #if defined(__H8300H__) || defined(__H8300S__) |
| 434 | static const struct __attribute__((packed)) { |
| 435 | int port; /* GPIO port no */ |
| 436 | unsigned short rx,tx; /* GPIO bit no */ |
| 437 | } h8300_sci_pins[] = { |
| 438 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 439 | { /* SCI0 */ |
| 440 | .port = H8300_GPIO_P9, |
| 441 | .rx = H8300_GPIO_B2, |
| 442 | .tx = H8300_GPIO_B0, |
| 443 | }, |
| 444 | { /* SCI1 */ |
| 445 | .port = H8300_GPIO_P9, |
| 446 | .rx = H8300_GPIO_B3, |
| 447 | .tx = H8300_GPIO_B1, |
| 448 | }, |
| 449 | { /* SCI2 */ |
| 450 | .port = H8300_GPIO_PB, |
| 451 | .rx = H8300_GPIO_B7, |
| 452 | .tx = H8300_GPIO_B6, |
| 453 | } |
| 454 | #elif defined(CONFIG_H8S2678) |
| 455 | { /* SCI0 */ |
| 456 | .port = H8300_GPIO_P3, |
| 457 | .rx = H8300_GPIO_B2, |
| 458 | .tx = H8300_GPIO_B0, |
| 459 | }, |
| 460 | { /* SCI1 */ |
| 461 | .port = H8300_GPIO_P3, |
| 462 | .rx = H8300_GPIO_B3, |
| 463 | .tx = H8300_GPIO_B1, |
| 464 | }, |
| 465 | { /* SCI2 */ |
| 466 | .port = H8300_GPIO_P5, |
| 467 | .rx = H8300_GPIO_B1, |
| 468 | .tx = H8300_GPIO_B0, |
| 469 | } |
| 470 | #endif |
| 471 | }; |
| 472 | #endif |
| 473 | |
Magnus Damm | 0fbde95 | 2007-07-26 10:14:16 +0900 | [diff] [blame] | 474 | #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ |
| 475 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ |
| 476 | defined(CONFIG_CPU_SUBTYPE_SH7708) || \ |
| 477 | defined(CONFIG_CPU_SUBTYPE_SH7709) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | static inline int sci_rxd_in(struct uart_port *port) |
| 479 | { |
| 480 | if (port->mapbase == 0xfffffe80) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 481 | return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */ |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 482 | return 1; |
| 483 | } |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 484 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 485 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 486 | defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ |
| 487 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 488 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
Nobuhiro Iwamatsu | 961e9ff | 2008-10-29 13:33:45 +0900 | [diff] [blame] | 489 | defined(CONFIG_CPU_SUBTYPE_SH7091) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | static inline int sci_rxd_in(struct uart_port *port) |
| 491 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | if (port->mapbase == 0xffe00000) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 493 | return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | return 1; |
| 495 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 497 | static inline int sci_rxd_in(struct uart_port *port) |
| 498 | { |
| 499 | int ch = (port->mapbase - SMR0) >> 3; |
| 500 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; |
| 501 | } |
Magnus Damm | 9e9622d | 2010-02-08 11:47:44 +0900 | [diff] [blame] | 502 | #else /* default case for non-SCI processors */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 503 | static inline int sci_rxd_in(struct uart_port *port) |
| 504 | { |
Paul Mundt | 1760b7d7 | 2007-08-08 16:57:05 +0900 | [diff] [blame] | 505 | return 1; |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 506 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | #endif |