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 */ |
| 18 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
| 20 | # define SCIF0 0xA4400000 |
| 21 | # define SCIF2 0xA4410000 |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 22 | # define SCSMR_Ir 0xA44A0000 |
| 23 | # define IRDA_SCIF SCIF0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | # define SCPCR 0xA4000116 |
| 25 | # define SCPDR 0xA4000136 |
| 26 | |
| 27 | /* Set the clock source, |
| 28 | * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input |
| 29 | * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output |
| 30 | */ |
| 31 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 32 | #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 33 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 34 | defined(CONFIG_ARCH_SH7367) || \ |
| 35 | defined(CONFIG_ARCH_SH7377) || \ |
| 36 | defined(CONFIG_ARCH_SH7372) |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 37 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ |
Paul Mundt | fd88cac | 2009-01-09 16:32:08 +0900 | [diff] [blame] | 38 | # define PORT_PTCR 0xA405011EUL |
| 39 | # define PORT_PVCR 0xA4050122UL |
| 40 | # define SCIF_ORER 0x0200 /* overrun error bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #elif defined(CONFIG_SH_RTS7751R2D) |
Matt Fleming | 7abc404 | 2008-10-29 07:16:02 +0000 | [diff] [blame] | 42 | # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 44 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 45 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 46 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 47 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 48 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
| 49 | defined(CONFIG_CPU_SUBTYPE_SH7091) || \ |
| 50 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 51 | defined(CONFIG_CPU_SUBTYPE_SH7751R) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
| 53 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 54 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 55 | # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ |
| 56 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ |
| 57 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 59 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ |
| 60 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ |
| 61 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 63 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 64 | #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 65 | # define SCSPTR0 0xA4400000 /* 16 bit SCIF */ |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 66 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 67 | # define PACR 0xa4050100 |
| 68 | # define PBCR 0xa4050102 |
| 69 | # define SCSCR_INIT(port) 0x3B |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 70 | #elif defined(CONFIG_CPU_SUBTYPE_SH7343) |
| 71 | # define SCSPTR0 0xffe00010 /* 16 bit SCIF */ |
| 72 | # define SCSPTR1 0xffe10010 /* 16 bit SCIF */ |
| 73 | # define SCSPTR2 0xffe20010 /* 16 bit SCIF */ |
| 74 | # define SCSPTR3 0xffe30010 /* 16 bit SCIF */ |
| 75 | # define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */ |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 76 | #elif defined(CONFIG_CPU_SUBTYPE_SH7722) |
Magnus Damm | 346b746 | 2008-04-23 21:25:29 +0900 | [diff] [blame] | 77 | # define PADR 0xA4050120 |
| 78 | # define PSDR 0xA405013e |
| 79 | # define PWDR 0xA4050166 |
| 80 | # define PSCR 0xA405011E |
Paul Mundt | 41504c3 | 2006-12-11 20:28:03 +0900 | [diff] [blame] | 81 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 82 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Magnus Damm | 9109a30 | 2008-02-08 17:31:24 +0900 | [diff] [blame] | 83 | #elif defined(CONFIG_CPU_SUBTYPE_SH7366) |
| 84 | # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ |
| 85 | # define SCSPTR0 SCPDR0 |
| 86 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 87 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 88 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) |
| 89 | # define SCSPTR0 0xa4050160 |
| 90 | # define SCSPTR1 0xa405013e |
| 91 | # define SCSPTR2 0xa4050160 |
| 92 | # define SCSPTR3 0xa405013e |
| 93 | # define SCSPTR4 0xa4050128 |
| 94 | # define SCSPTR5 0xa4050128 |
| 95 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 96 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 97 | #elif defined(CONFIG_CPU_SUBTYPE_SH7724) |
| 98 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Guennadi Liakhovetski | d7bbf7f | 2010-03-19 13:52:35 +0000 | [diff] [blame] | 99 | # define SCSCR_INIT(port) ((port)->type == PORT_SCIFA ? \ |
| 100 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ |
| 101 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
| 104 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 105 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | #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] | 107 | # define SCIF_BASE_ADDR 0x01030000 |
| 108 | # define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR |
| 109 | # define SCIF_PTR2_OFFS 0x0000020 |
| 110 | # define SCIF_LSR2_OFFS 0x0000024 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | # define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ |
| 112 | # define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ |
Paul Mundt | f966918 | 2007-11-07 11:05:32 +0900 | [diff] [blame] | 113 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) |
| 117 | #elif defined(CONFIG_H8S2678) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | # 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] | 120 | #elif defined(CONFIG_CPU_SUBTYPE_SH7757) |
| 121 | # define SCSPTR0 0xfe4b0020 |
| 122 | # define SCSPTR1 0xfe4b0020 |
| 123 | # define SCSPTR2 0xfe4b0020 |
| 124 | # define SCIF_ORER 0x0001 |
| 125 | # define SCSCR_INIT(port) 0x38 |
| 126 | # define SCIF_ONLY |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 127 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 128 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 129 | # define SCSPTR1 0xffe08024 /* 16 bit SCIF */ |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 130 | # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 131 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 132 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 133 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) |
| 134 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ |
| 135 | # define SCSPTR1 0xff924020 /* 16 bit SCIF */ |
| 136 | # define SCSPTR2 0xff925020 /* 16 bit SCIF */ |
| 137 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 138 | # define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 139 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) |
| 140 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 141 | # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ |
Paul Mundt | e108b2c | 2006-09-27 16:32:13 +0900 | [diff] [blame] | 142 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 143 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 144 | #elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 145 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 146 | # define SCSPTR0 0xffea0024 /* 16 bit SCIF */ |
| 147 | # define SCSPTR1 0xffeb0024 /* 16 bit SCIF */ |
| 148 | # define SCSPTR2 0xffec0024 /* 16 bit SCIF */ |
| 149 | # define SCSPTR3 0xffed0024 /* 16 bit SCIF */ |
| 150 | # define SCSPTR4 0xffee0024 /* 16 bit SCIF */ |
| 151 | # define SCSPTR5 0xffef0024 /* 16 bit SCIF */ |
Kuninori Morimoto | 34aeb43 | 2009-02-10 09:04:00 +0000 | [diff] [blame] | 152 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 153 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Peter Griffin | 2825999 | 2008-11-28 22:48:20 +0900 | [diff] [blame] | 154 | #elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \ |
| 155 | defined(CONFIG_CPU_SUBTYPE_SH7203) || \ |
Paul Mundt | a8f67f4 | 2007-11-26 19:54:02 +0900 | [diff] [blame] | 156 | defined(CONFIG_CPU_SUBTYPE_SH7206) || \ |
| 157 | defined(CONFIG_CPU_SUBTYPE_SH7263) |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 158 | # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */ |
| 159 | # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */ |
| 160 | # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */ |
| 161 | # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */ |
Peter Griffin | 2825999 | 2008-11-28 22:48:20 +0900 | [diff] [blame] | 162 | # if defined(CONFIG_CPU_SUBTYPE_SH7201) |
| 163 | # define SCSPTR4 0xfffeA020 /* 16 bit SCIF */ |
| 164 | # define SCSPTR5 0xfffeA820 /* 16 bit SCIF */ |
| 165 | # define SCSPTR6 0xfffeB020 /* 16 bit SCIF */ |
| 166 | # define SCSPTR7 0xfffeB820 /* 16 bit SCIF */ |
| 167 | # endif |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 168 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Yoshinori Sato | 9d4436a | 2006-11-05 15:40:13 +0900 | [diff] [blame] | 169 | #elif defined(CONFIG_CPU_SUBTYPE_SH7619) |
| 170 | # define SCSPTR0 0xf8400020 /* 16 bit SCIF */ |
| 171 | # define SCSPTR1 0xf8410020 /* 16 bit SCIF */ |
| 172 | # define SCSPTR2 0xf8420020 /* 16 bit SCIF */ |
| 173 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 174 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 175 | #elif defined(CONFIG_CPU_SUBTYPE_SHX3) |
| 176 | # define SCSPTR0 0xffc30020 /* 16 bit SCIF */ |
| 177 | # define SCSPTR1 0xffc40020 /* 16 bit SCIF */ |
| 178 | # define SCSPTR2 0xffc50020 /* 16 bit SCIF */ |
| 179 | # define SCSPTR3 0xffc60020 /* 16 bit SCIF */ |
| 180 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
| 181 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | #else |
| 183 | # error CPU subtype not defined |
| 184 | #endif |
| 185 | |
| 186 | /* SCSCR */ |
| 187 | #define SCI_CTRL_FLAGS_TIE 0x80 /* all */ |
| 188 | #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ |
| 189 | #define SCI_CTRL_FLAGS_TE 0x20 /* all */ |
| 190 | #define SCI_CTRL_FLAGS_RE 0x10 /* all */ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 191 | #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 192 | defined(CONFIG_CPU_SUBTYPE_SH7091) || \ |
| 193 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
Michael Trimarchi | a8884e3 | 2008-10-31 16:10:23 +0900 | [diff] [blame] | 194 | defined(CONFIG_CPU_SUBTYPE_SH7722) || \ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 195 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
| 196 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 197 | defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 198 | defined(CONFIG_CPU_SUBTYPE_SH7763) || \ |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 199 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 200 | defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 201 | defined(CONFIG_CPU_SUBTYPE_SH7786) || \ |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 202 | defined(CONFIG_CPU_SUBTYPE_SHX3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ |
Guennadi Liakhovetski | d7bbf7f | 2010-03-19 13:52:35 +0000 | [diff] [blame] | 204 | #elif defined(CONFIG_CPU_SUBTYPE_SH7724) |
| 205 | #define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | #else |
| 207 | #define SCI_CTRL_FLAGS_REIE 0 |
| 208 | #endif |
| 209 | /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 210 | /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 211 | /* SCI_CTRL_FLAGS_CKE1 0x02 * all */ |
| 212 | /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */ |
| 213 | |
| 214 | /* SCxSR SCI */ |
| 215 | #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 216 | #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 217 | #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 218 | #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 219 | #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 220 | #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 221 | /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 222 | /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 223 | |
| 224 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) |
| 225 | |
| 226 | /* SCxSR SCIF */ |
| 227 | #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 228 | #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 229 | #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 230 | #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 231 | #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 232 | #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 233 | #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 234 | #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 235 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 236 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 237 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 238 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 239 | defined(CONFIG_ARCH_SH7367) || \ |
| 240 | defined(CONFIG_ARCH_SH7377) || \ |
| 241 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 242 | # define SCIF_ORER 0x0200 |
| 243 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
| 244 | # define SCIF_RFDC_MASK 0x007f |
| 245 | # define SCIF_TXROOM_MAX 64 |
| 246 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
| 247 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK ) |
| 248 | # define SCIF_RFDC_MASK 0x007f |
| 249 | # define SCIF_TXROOM_MAX 64 |
| 250 | /* SH7763 SCIF2 support */ |
| 251 | # define SCIF2_RFDC_MASK 0x001f |
| 252 | # define SCIF2_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | #else |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 254 | # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 255 | # define SCIF_RFDC_MASK 0x001f |
| 256 | # define SCIF_TXROOM_MAX 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | #endif |
| 258 | |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 259 | #ifndef SCIF_ORER |
| 260 | #define SCIF_ORER 0x0000 |
| 261 | #endif |
| 262 | |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 263 | #define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
| 264 | #define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) |
| 265 | #define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) |
| 266 | #define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) |
| 267 | #define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) |
| 268 | #define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) |
| 269 | #define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) |
Paul Mundt | d830fa4 | 2008-12-16 19:29:38 +0900 | [diff] [blame] | 270 | #define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 271 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 272 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 273 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 274 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 275 | defined(CONFIG_ARCH_SH7367) || \ |
| 276 | defined(CONFIG_ARCH_SH7377) || \ |
| 277 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | 15c73aa | 2008-10-02 19:47:12 +0900 | [diff] [blame] | 278 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
| 279 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
| 280 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
| 281 | # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) |
| 284 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) |
| 285 | # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) |
| 286 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) |
| 287 | #endif |
| 288 | |
| 289 | /* SCFCR */ |
| 290 | #define SCFCR_RFRST 0x0002 |
| 291 | #define SCFCR_TFRST 0x0004 |
| 292 | #define SCFCR_TCRST 0x4000 |
| 293 | #define SCFCR_MCE 0x0008 |
| 294 | |
| 295 | #define SCI_MAJOR 204 |
| 296 | #define SCI_MINOR_START 8 |
| 297 | |
| 298 | /* Generic serial flags */ |
| 299 | #define SCI_RX_THROTTLE 0x0000001 |
| 300 | |
| 301 | #define SCI_MAGIC 0xbabeface |
| 302 | |
| 303 | /* |
| 304 | * Events are used to schedule things to happen at timer-interrupt |
| 305 | * time, instead of at rs interrupt time. |
| 306 | */ |
| 307 | #define SCI_EVENT_WRITE_WAKEUP 0 |
| 308 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | #define SCI_IN(size, offset) \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 310 | if ((size) == 8) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 311 | return ioread8(port->membase + (offset)); \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 312 | } else { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 313 | return ioread16(port->membase + (offset)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | #define SCI_OUT(size, offset, value) \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 316 | if ((size) == 8) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 317 | iowrite8(value, port->membase + (offset)); \ |
Magnus Damm | 3d2c2f3 | 2008-04-23 21:37:39 +0900 | [diff] [blame] | 318 | } else if ((size) == 16) { \ |
Paul Mundt | 7ff731a | 2008-10-01 15:46:58 +0900 | [diff] [blame] | 319 | iowrite16(value, port->membase + (offset)); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
| 323 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 324 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 325 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 326 | SCI_IN(scif_size, scif_offset) \ |
| 327 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
| 328 | SCI_IN(sci_size, sci_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } \ |
| 330 | } \ |
| 331 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 332 | { \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 333 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB) { \ |
Yoshihiro Shimoda | 1a22f08 | 2008-11-11 12:19:05 +0900 | [diff] [blame] | 334 | SCI_OUT(scif_size, scif_offset, value) \ |
| 335 | } else { /* PORT_SCI or PORT_SCIFA */ \ |
| 336 | SCI_OUT(sci_size, sci_offset, value); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } \ |
| 338 | } |
| 339 | |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 340 | #ifdef CONFIG_H8300 |
| 341 | /* h8300 don't have SCIF */ |
| 342 | #define CPU_SCIF_FNS(name) \ |
| 343 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 344 | { \ |
| 345 | return 0; \ |
| 346 | } \ |
| 347 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 348 | { \ |
| 349 | } |
| 350 | #else |
| 351 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
| 353 | { \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 354 | SCI_IN(scif_size, scif_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } \ |
| 356 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
| 357 | { \ |
| 358 | SCI_OUT(scif_size, scif_offset, value); \ |
| 359 | } |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 360 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
| 362 | #define CPU_SCI_FNS(name, sci_offset, sci_size) \ |
| 363 | static inline unsigned int sci_##name##_in(struct uart_port* port) \ |
| 364 | { \ |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 365 | SCI_IN(sci_size, sci_offset); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } \ |
| 367 | static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ |
| 368 | { \ |
| 369 | SCI_OUT(sci_size, sci_offset, value); \ |
| 370 | } |
| 371 | |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 372 | #if defined(CONFIG_CPU_SH3) || \ |
| 373 | defined(CONFIG_ARCH_SH7367) || \ |
| 374 | defined(CONFIG_ARCH_SH7377) || \ |
| 375 | defined(CONFIG_ARCH_SH7372) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 376 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) |
| 377 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 378 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 379 | h8_sci_offset, h8_sci_size) \ |
| 380 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 381 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 382 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 383 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 384 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 385 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 386 | defined(CONFIG_ARCH_SH7367) || \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 387 | defined(CONFIG_ARCH_SH7377) |
| 388 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 389 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 390 | #elif defined(CONFIG_ARCH_SH7372) |
| 391 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scifb_offset, sh4_scifb_size) \ |
| 392 | 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] | 393 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 394 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 395 | #else |
| 396 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 397 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 398 | h8_sci_offset, h8_sci_size) \ |
| 399 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size) |
| 400 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 401 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) |
| 402 | #endif |
| 403 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 404 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 405 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 406 | h8_sci_offset, h8_sci_size) \ |
| 407 | CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) |
Yoshinori Sato | 168f362 | 2009-04-28 04:40:15 +0000 | [diff] [blame] | 408 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 409 | CPU_SCIF_FNS(name) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 410 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 411 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 412 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \ |
| 413 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) |
| 414 | #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ |
| 415 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | #else |
| 417 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ |
| 418 | sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ |
| 419 | h8_sci_offset, h8_sci_size) \ |
| 420 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) |
| 421 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ |
| 422 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 423 | #endif |
| 424 | |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 425 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 426 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 427 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 428 | defined(CONFIG_ARCH_SH7367) || \ |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 429 | defined(CONFIG_ARCH_SH7377) |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 430 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | SCIF_FNS(SCSMR, 0x00, 16) |
| 432 | SCIF_FNS(SCBRR, 0x04, 8) |
| 433 | SCIF_FNS(SCSCR, 0x08, 16) |
| 434 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 435 | SCIF_FNS(SCFER, 0x10, 16) |
| 436 | SCIF_FNS(SCxSR, 0x14, 16) |
| 437 | SCIF_FNS(SCFCR, 0x18, 16) |
| 438 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 439 | SCIF_FNS(SCxTDR, 0x20, 8) |
| 440 | SCIF_FNS(SCxRDR, 0x24, 8) |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 441 | SCIF_FNS(SCLSR, 0x00, 0) |
Guennadi Liakhovetski | d1d4b10 | 2010-05-23 16:39:09 +0000 | [diff] [blame] | 442 | #elif defined(CONFIG_ARCH_SH7372) |
| 443 | SCIF_FNS(SCSMR, 0x00, 16) |
| 444 | SCIF_FNS(SCBRR, 0x04, 8) |
| 445 | SCIF_FNS(SCSCR, 0x08, 16) |
| 446 | SCIF_FNS(SCTDSR, 0x0c, 16) |
| 447 | SCIF_FNS(SCFER, 0x10, 16) |
| 448 | SCIF_FNS(SCxSR, 0x14, 16) |
| 449 | SCIF_FNS(SCFCR, 0x18, 16) |
| 450 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 451 | SCIF_FNS(SCTFDR, 0x38, 16) |
| 452 | SCIF_FNS(SCRFDR, 0x3c, 16) |
| 453 | SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8) |
| 454 | SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8) |
| 455 | SCIF_FNS(SCLSR, 0x00, 0) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 456 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 457 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 458 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
| 459 | SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) |
| 460 | SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) |
| 461 | SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) |
| 462 | SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) |
| 463 | SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) |
Magnus Damm | f686359 | 2009-01-20 12:18:22 +0900 | [diff] [blame] | 464 | SCIx_FNS(SCSPTR, 0, 0, 0, 0) |
Paul Mundt | 178dd0c | 2008-04-09 17:56:18 +0900 | [diff] [blame] | 465 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 466 | SCIF_FNS(SCFER, 0x10, 16) |
| 467 | SCIF_FNS(SCFCR, 0x18, 16) |
| 468 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 469 | SCIF_FNS(SCLSR, 0x24, 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | #else |
| 471 | /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ |
| 472 | /* name off sz off sz off sz off sz off sz*/ |
| 473 | SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8) |
| 474 | SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8) |
| 475 | SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8) |
| 476 | SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) |
| 477 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) |
| 478 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
| 479 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 480 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ |
| 481 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 482 | defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 483 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 484 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 485 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 486 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 487 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 488 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 489 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 490 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
| 491 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) |
Paul Mundt | c269796 | 2008-07-30 00:56:39 +0900 | [diff] [blame] | 492 | SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) |
| 493 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 494 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 495 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 496 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 497 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 499 | #if defined(CONFIG_CPU_SUBTYPE_SH7722) |
| 500 | SCIF_FNS(SCSPTR, 0, 0, 0, 0) |
| 501 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
Magnus Damm | 9b4e466 | 2008-04-23 21:31:14 +0900 | [diff] [blame] | 503 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
| 505 | #endif |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 506 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | #define sci_in(port, reg) sci_##reg##_in(port) |
| 508 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
| 509 | |
| 510 | /* H8/300 series SCI pins assignment */ |
| 511 | #if defined(__H8300H__) || defined(__H8300S__) |
| 512 | static const struct __attribute__((packed)) { |
| 513 | int port; /* GPIO port no */ |
| 514 | unsigned short rx,tx; /* GPIO bit no */ |
| 515 | } h8300_sci_pins[] = { |
| 516 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
| 517 | { /* SCI0 */ |
| 518 | .port = H8300_GPIO_P9, |
| 519 | .rx = H8300_GPIO_B2, |
| 520 | .tx = H8300_GPIO_B0, |
| 521 | }, |
| 522 | { /* SCI1 */ |
| 523 | .port = H8300_GPIO_P9, |
| 524 | .rx = H8300_GPIO_B3, |
| 525 | .tx = H8300_GPIO_B1, |
| 526 | }, |
| 527 | { /* SCI2 */ |
| 528 | .port = H8300_GPIO_PB, |
| 529 | .rx = H8300_GPIO_B7, |
| 530 | .tx = H8300_GPIO_B6, |
| 531 | } |
| 532 | #elif defined(CONFIG_H8S2678) |
| 533 | { /* SCI0 */ |
| 534 | .port = H8300_GPIO_P3, |
| 535 | .rx = H8300_GPIO_B2, |
| 536 | .tx = H8300_GPIO_B0, |
| 537 | }, |
| 538 | { /* SCI1 */ |
| 539 | .port = H8300_GPIO_P3, |
| 540 | .rx = H8300_GPIO_B3, |
| 541 | .tx = H8300_GPIO_B1, |
| 542 | }, |
| 543 | { /* SCI2 */ |
| 544 | .port = H8300_GPIO_P5, |
| 545 | .rx = H8300_GPIO_B1, |
| 546 | .tx = H8300_GPIO_B0, |
| 547 | } |
| 548 | #endif |
| 549 | }; |
| 550 | #endif |
| 551 | |
Magnus Damm | 0fbde95 | 2007-07-26 10:14:16 +0900 | [diff] [blame] | 552 | #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ |
| 553 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ |
| 554 | defined(CONFIG_CPU_SUBTYPE_SH7708) || \ |
| 555 | defined(CONFIG_CPU_SUBTYPE_SH7709) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | static inline int sci_rxd_in(struct uart_port *port) |
| 557 | { |
| 558 | if (port->mapbase == 0xfffffe80) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 559 | return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */ |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 560 | return 1; |
| 561 | } |
Paul Mundt | 0562748 | 2007-05-15 16:25:47 +0900 | [diff] [blame] | 562 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ |
| 563 | defined(CONFIG_CPU_SUBTYPE_SH7751) || \ |
| 564 | defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ |
| 565 | defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ |
| 566 | defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ |
Nobuhiro Iwamatsu | 961e9ff | 2008-10-29 13:33:45 +0900 | [diff] [blame] | 567 | defined(CONFIG_CPU_SUBTYPE_SH7091) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | static inline int sci_rxd_in(struct uart_port *port) |
| 569 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | if (port->mapbase == 0xffe00000) |
Paul Mundt | 32b5307 | 2009-12-24 14:52:43 +0900 | [diff] [blame] | 571 | return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | return 1; |
| 573 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | #elif defined(__H8300H__) || defined(__H8300S__) |
| 575 | static inline int sci_rxd_in(struct uart_port *port) |
| 576 | { |
| 577 | int ch = (port->mapbase - SMR0) >> 3; |
| 578 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; |
| 579 | } |
Magnus Damm | 9e9622d | 2010-02-08 11:47:44 +0900 | [diff] [blame] | 580 | #else /* default case for non-SCI processors */ |
Yoshihiro Shimoda | 7d740a0 | 2008-01-07 14:40:07 +0900 | [diff] [blame] | 581 | static inline int sci_rxd_in(struct uart_port *port) |
| 582 | { |
Paul Mundt | 1760b7d7 | 2007-08-08 16:57:05 +0900 | [diff] [blame] | 583 | return 1; |
Paul Mundt | 2b1bd1a | 2007-06-20 18:27:10 +0900 | [diff] [blame] | 584 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | #endif |
| 586 | |
| 587 | /* |
| 588 | * Values for the BitRate Register (SCBRR) |
| 589 | * |
| 590 | * The values are actually divisors for a frequency which can |
| 591 | * be internal to the SH3 (14.7456MHz) or derived from an external |
| 592 | * clock source. This driver assumes the internal clock is used; |
| 593 | * to support using an external clock source, config options or |
| 594 | * possibly command-line options would need to be added. |
| 595 | * |
| 596 | * Also, to support speeds below 2400 (why?) the lower 2 bits of |
| 597 | * the SCSMR register would also need to be set to non-zero values. |
| 598 | * |
| 599 | * -- Greg Banks 27Feb2000 |
| 600 | * |
| 601 | * Answer: The SCBRR register is only eight bits, and the value in |
| 602 | * it gets larger with lower baud rates. At around 2400 (depending on |
| 603 | * the peripherial module clock) you run out of bits. However the |
| 604 | * lower two bits of SCSMR allow the module clock to be divided down, |
| 605 | * scaling the value which is needed in SCBRR. |
| 606 | * |
| 607 | * -- Stuart Menefy - 23 May 2000 |
| 608 | * |
| 609 | * I meant, why would anyone bother with bitrates below 2400. |
| 610 | * |
| 611 | * -- Greg Banks - 7Jul2000 |
| 612 | * |
| 613 | * You "speedist"! How will I use my 110bps ASR-33 teletype with paper |
| 614 | * tape reader as a console! |
| 615 | * |
| 616 | * -- Mitch Davis - 15 Jul 2000 |
| 617 | */ |
| 618 | |
Nobuhiro Iwamatsu | c63847a | 2008-06-06 17:04:08 +0900 | [diff] [blame] | 619 | #if defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
Kuninori Morimoto | 55ba99e | 2009-03-03 15:40:25 +0900 | [diff] [blame] | 620 | defined(CONFIG_CPU_SUBTYPE_SH7785) || \ |
| 621 | defined(CONFIG_CPU_SUBTYPE_SH7786) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 622 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 623 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ |
Yoshihiro Shimoda | 31a49c4 | 2007-12-26 11:45:06 +0900 | [diff] [blame] | 624 | defined(CONFIG_CPU_SUBTYPE_SH7720) || \ |
Magnus Damm | 8a77b8d | 2010-02-05 11:15:33 +0000 | [diff] [blame] | 625 | defined(CONFIG_CPU_SUBTYPE_SH7721) || \ |
Magnus Damm | 8d099d4 | 2010-03-16 11:21:07 +0000 | [diff] [blame] | 626 | defined(CONFIG_ARCH_SH7367) || \ |
| 627 | defined(CONFIG_ARCH_SH7377) || \ |
| 628 | defined(CONFIG_ARCH_SH7372) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 629 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) |
Kuninori Morimoto | 47948d2 | 2009-04-15 11:42:47 +0900 | [diff] [blame] | 630 | #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ |
| 631 | defined(CONFIG_CPU_SUBTYPE_SH7724) |
Nobuhiro Iwamatsu | ba1d281 | 2008-10-03 17:37:31 +0900 | [diff] [blame] | 632 | static inline int scbrr_calc(struct uart_port *port, int bps, int clk) |
| 633 | { |
| 634 | if (port->type == PORT_SCIF) |
| 635 | return (clk+16*bps)/(32*bps)-1; |
| 636 | else |
| 637 | return ((clk*2)+16*bps)/(16*bps)-1; |
| 638 | } |
| 639 | #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 640 | #elif defined(__H8300H__) || defined(__H8300S__) |
Paul Mundt | a2159b5 | 2008-10-02 19:09:13 +0900 | [diff] [blame] | 641 | #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1) |
Paul Mundt | b7a76e4 | 2006-02-01 03:06:06 -0800 | [diff] [blame] | 642 | #else /* Generic SH */ |
| 643 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | #endif |