Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copy and modify from linux/drivers/serial/sh-sci.h |
| 3 | */ |
| 4 | |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 5 | #include <dm/platform_data/serial_sh.h> |
| 6 | |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 7 | struct uart_port { |
| 8 | unsigned long iobase; /* in/out[bwl] */ |
| 9 | unsigned char *membase; /* read/write[bwl] */ |
| 10 | unsigned long mapbase; /* for ioremap */ |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 11 | enum sh_serial_type type; /* port type */ |
| 12 | enum sh_clk_mode clk_mode; /* clock mode */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 13 | }; |
| 14 | |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 15 | #if defined(CONFIG_CPU_SH7721) || \ |
Hideyuki Sano | dde220f | 2012-06-25 10:29:56 +0900 | [diff] [blame] | 16 | defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 17 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ |
| 18 | # define PORT_PTCR 0xA405011EUL |
| 19 | # define PORT_PVCR 0xA4050122UL |
| 20 | # define SCIF_ORER 0x0200 /* overrun error bit */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 21 | #elif defined(CONFIG_CPU_SH7750) || \ |
| 22 | defined(CONFIG_CPU_SH7750R) || \ |
| 23 | defined(CONFIG_CPU_SH7750S) || \ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 24 | defined(CONFIG_CPU_SH7751) || \ |
| 25 | defined(CONFIG_CPU_SH7751R) |
| 26 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
| 27 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
| 28 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 29 | # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \ |
| 30 | 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \ |
| 31 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 32 | #elif defined(CONFIG_CPU_SH7722) |
| 33 | # define PADR 0xA4050120 |
Nobuhiro Iwamatsu | 4df4ed6 | 2010-11-24 13:24:33 +0900 | [diff] [blame] | 34 | # undef PSDR |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 35 | # define PSDR 0xA405013e |
| 36 | # define PWDR 0xA4050166 |
| 37 | # define PSCR 0xA405011E |
| 38 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 39 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 40 | #elif defined(CONFIG_CPU_SH7723) |
| 41 | # define SCSPTR0 0xa4050160 |
| 42 | # define SCSPTR1 0xa405013e |
| 43 | # define SCSPTR2 0xa4050160 |
| 44 | # define SCSPTR3 0xa405013e |
| 45 | # define SCSPTR4 0xa4050128 |
| 46 | # define SCSPTR5 0xa4050128 |
| 47 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 48 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Nobuhiro Iwamatsu | 73bbe6d | 2012-01-11 10:45:01 +0900 | [diff] [blame] | 49 | #elif defined(CONFIG_CPU_SH7734) |
| 50 | # define SCSPTR0 0xFFE40020 |
| 51 | # define SCSPTR1 0xFFE41020 |
| 52 | # define SCSPTR2 0xFFE42020 |
| 53 | # define SCSPTR3 0xFFE43020 |
| 54 | # define SCSPTR4 0xFFE44020 |
| 55 | # define SCSPTR5 0xFFE45020 |
| 56 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 57 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Yoshihiro Shimoda | b94d0f6 | 2013-12-18 16:04:20 +0900 | [diff] [blame] | 58 | #elif defined(CONFIG_CPU_SH7757) || \ |
| 59 | defined(CONFIG_CPU_SH7752) || \ |
| 60 | defined(CONFIG_CPU_SH7753) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 61 | # define SCSPTR0 0xfe4b0020 |
| 62 | # define SCSPTR1 0xfe4b0020 |
| 63 | # define SCSPTR2 0xfe4b0020 |
| 64 | # define SCIF_ORER 0x0001 |
| 65 | # define SCSCR_INIT(port) 0x38 |
| 66 | # define SCIF_ONLY |
| 67 | #elif defined(CONFIG_CPU_SH7763) |
| 68 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 69 | # define SCSPTR1 0xffe08024 /* 16 bit SCIF */ |
| 70 | # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */ |
| 71 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
| 72 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 73 | #elif defined(CONFIG_CPU_SH7780) |
| 74 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ |
| 75 | # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ |
| 76 | # define SCIF_ORER 0x0001 /* Overrun error bit */ |
| 77 | |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 78 | /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=1 */ |
| 79 | # define SCSCR_INIT(port) 0x3a |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 80 | |
Marek Vasut | 5b54a94 | 2019-05-07 21:52:47 +0200 | [diff] [blame] | 81 | #elif defined(CONFIG_RZA1) |
Phil Edworthy | 04a6275 | 2012-05-15 22:15:51 +0000 | [diff] [blame] | 82 | # define SCSPTR0 0xe8007020 /* 16 bit SCIF */ |
| 83 | # define SCSPTR1 0xe8007820 /* 16 bit SCIF */ |
| 84 | # define SCSPTR2 0xe8008020 /* 16 bit SCIF */ |
| 85 | # define SCSPTR3 0xe8008820 /* 16 bit SCIF */ |
| 86 | # define SCSPTR4 0xe8009020 /* 16 bit SCIF */ |
| 87 | # define SCSPTR5 0xe8009820 /* 16 bit SCIF */ |
| 88 | # define SCSPTR6 0xe800a020 /* 16 bit SCIF */ |
| 89 | # define SCSPTR7 0xe800a820 /* 16 bit SCIF */ |
| 90 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
Marek Vasut | 2d2e3ff | 2019-05-01 18:20:00 +0200 | [diff] [blame] | 91 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
Hai Pham | 797e2a3 | 2023-02-28 22:29:18 +0100 | [diff] [blame] | 92 | #elif defined(CONFIG_RCAR_GEN2) || defined(CONFIG_RCAR_64) || \ |
Paul Barker | 327571c | 2023-10-19 15:30:44 +0100 | [diff] [blame] | 93 | defined(CONFIG_R7S72100) || defined(CONFIG_RZG2L) |
Tom Rini | 31b8b4d | 2022-12-04 10:13:43 -0500 | [diff] [blame] | 94 | # if defined(CFG_SCIF_A) |
Vladimir Barinov | 3ed0b62 | 2015-07-20 20:49:39 +0300 | [diff] [blame] | 95 | # define SCIF_ORER 0x0200 |
| 96 | # else |
| 97 | # define SCIF_ORER 0x0001 |
| 98 | # endif |
Vladimir Barinov | 51d3b40 | 2015-02-14 01:05:18 +0300 | [diff] [blame] | 99 | # define SCSCR_INIT(port) (port->clk_mode == EXT_CLK ? 0x32 : 0x30) |
| 100 | /* TIE=0,RIE=0,TE=1,RE=1,REIE=0, */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 101 | #else |
| 102 | # error CPU subtype not defined |
| 103 | #endif |
| 104 | |
| 105 | /* SCSCR */ |
| 106 | #define SCI_CTRL_FLAGS_TIE 0x80 /* all */ |
| 107 | #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ |
| 108 | #define SCI_CTRL_FLAGS_TE 0x20 /* all */ |
| 109 | #define SCI_CTRL_FLAGS_RE 0x10 /* all */ |
| 110 | #if defined(CONFIG_CPU_SH7750) || \ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 111 | defined(CONFIG_CPU_SH7750R) || \ |
| 112 | defined(CONFIG_CPU_SH7722) || \ |
Nobuhiro Iwamatsu | 73bbe6d | 2012-01-11 10:45:01 +0900 | [diff] [blame] | 113 | defined(CONFIG_CPU_SH7734) || \ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 114 | defined(CONFIG_CPU_SH7750S) || \ |
| 115 | defined(CONFIG_CPU_SH7751) || \ |
| 116 | defined(CONFIG_CPU_SH7751R) || \ |
| 117 | defined(CONFIG_CPU_SH7763) || \ |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 118 | defined(CONFIG_CPU_SH7780) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 119 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 120 | #else |
| 121 | #define SCI_CTRL_FLAGS_REIE 0 |
| 122 | #endif |
| 123 | /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 124 | /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 125 | /* SCI_CTRL_FLAGS_CKE1 0x02 * all */ |
| 126 | /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */ |
| 127 | |
| 128 | /* SCxSR SCI */ |
| 129 | #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 130 | #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 131 | #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 132 | #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 133 | #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 134 | #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 135 | /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 136 | /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */ |
| 137 | |
| 138 | #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER) |
| 139 | |
| 140 | /* SCxSR SCIF */ |
| 141 | #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 142 | #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 143 | #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 144 | #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 145 | #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 146 | #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 147 | #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 148 | #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ |
| 149 | |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 150 | #if defined(CONFIG_CPU_SH7721) || \ |
Hideyuki Sano | dde220f | 2012-06-25 10:29:56 +0900 | [diff] [blame] | 151 | defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 152 | # define SCIF_ORER 0x0200 |
| 153 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) |
| 154 | # define SCIF_RFDC_MASK 0x007f |
| 155 | # define SCIF_TXROOM_MAX 64 |
| 156 | #elif defined(CONFIG_CPU_SH7763) |
| 157 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 158 | # define SCIF_RFDC_MASK 0x007f |
| 159 | # define SCIF_TXROOM_MAX 64 |
| 160 | /* SH7763 SCIF2 support */ |
| 161 | # define SCIF2_RFDC_MASK 0x001f |
| 162 | # define SCIF2_TXROOM_MAX 16 |
Marek Vasut | aa329a8 | 2018-01-22 01:43:25 +0100 | [diff] [blame] | 163 | #elif defined(CONFIG_RCAR_GEN2) |
Nobuhiro Iwamatsu | 788b73f | 2013-07-23 13:58:20 +0900 | [diff] [blame] | 164 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
Tom Rini | 31b8b4d | 2022-12-04 10:13:43 -0500 | [diff] [blame] | 165 | # if defined(CFG_SCIF_A) |
Vladimir Barinov | 3ed0b62 | 2015-07-20 20:49:39 +0300 | [diff] [blame] | 166 | # define SCIF_RFDC_MASK 0x007f |
| 167 | # else |
| 168 | # define SCIF_RFDC_MASK 0x001f |
| 169 | # endif |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 170 | #else |
| 171 | # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) |
| 172 | # define SCIF_RFDC_MASK 0x001f |
| 173 | # define SCIF_TXROOM_MAX 16 |
| 174 | #endif |
| 175 | |
| 176 | #ifndef SCIF_ORER |
| 177 | #define SCIF_ORER 0x0000 |
| 178 | #endif |
| 179 | |
| 180 | #define SCxSR_TEND(port)\ |
| 181 | (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
| 182 | #define SCxSR_ERRORS(port)\ |
| 183 | (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS) |
| 184 | #define SCxSR_RDxF(port)\ |
| 185 | (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF) |
| 186 | #define SCxSR_TDxE(port)\ |
| 187 | (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE) |
| 188 | #define SCxSR_FER(port)\ |
| 189 | (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER) |
| 190 | #define SCxSR_PER(port)\ |
| 191 | (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) |
| 192 | #define SCxSR_BRK(port)\ |
| 193 | ((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) |
| 194 | #define SCxSR_ORER(port)\ |
| 195 | (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER) |
| 196 | |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 197 | #if defined(CONFIG_CPU_SH7721) || \ |
Hideyuki Sano | dde220f | 2012-06-25 10:29:56 +0900 | [diff] [blame] | 198 | defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 199 | # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) |
| 200 | # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) |
| 201 | # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) |
| 202 | # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3) |
| 203 | #else |
| 204 | # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc) |
| 205 | # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073) |
| 206 | # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df) |
| 207 | # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3) |
| 208 | #endif |
| 209 | |
| 210 | /* SCFCR */ |
| 211 | #define SCFCR_RFRST 0x0002 |
| 212 | #define SCFCR_TFRST 0x0004 |
| 213 | #define SCFCR_TCRST 0x4000 |
| 214 | #define SCFCR_MCE 0x0008 |
| 215 | |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 216 | /* HSSRR */ |
| 217 | #define HSSRR_SRE BIT(15) |
| 218 | #define HSSRR_SRCYC8 0x0007 |
| 219 | |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 220 | #define SCI_MAJOR 204 |
| 221 | #define SCI_MINOR_START 8 |
| 222 | |
| 223 | /* Generic serial flags */ |
| 224 | #define SCI_RX_THROTTLE 0x0000001 |
| 225 | |
| 226 | #define SCI_MAGIC 0xbabeface |
| 227 | |
| 228 | /* |
| 229 | * Events are used to schedule things to happen at timer-interrupt |
| 230 | * time, instead of at rs interrupt time. |
| 231 | */ |
| 232 | #define SCI_EVENT_WRITE_WAKEUP 0 |
| 233 | |
| 234 | #define SCI_IN(size, offset)\ |
| 235 | if ((size) == 8) {\ |
| 236 | return readb(port->membase + (offset));\ |
| 237 | } else {\ |
| 238 | return readw(port->membase + (offset));\ |
| 239 | } |
| 240 | #define SCI_OUT(size, offset, value)\ |
| 241 | if ((size) == 8) {\ |
| 242 | writeb(value, port->membase + (offset));\ |
| 243 | } else if ((size) == 16) {\ |
| 244 | writew(value, port->membase + (offset));\ |
| 245 | } |
| 246 | |
| 247 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
| 248 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 249 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB ||\ |
| 250 | port->type == PORT_HSCIF) {\ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 251 | SCI_IN(scif_size, scif_offset)\ |
| 252 | } else { /* PORT_SCI or PORT_SCIFA */\ |
| 253 | SCI_IN(sci_size, sci_offset);\ |
| 254 | }\ |
| 255 | }\ |
| 256 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 257 | unsigned int value) {\ |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 258 | if (port->type == PORT_SCIF || port->type == PORT_SCIFB ||\ |
| 259 | port->type == PORT_HSCIF) {\ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 260 | SCI_OUT(scif_size, scif_offset, value)\ |
| 261 | } else { /* PORT_SCI or PORT_SCIFA */\ |
| 262 | SCI_OUT(sci_size, sci_offset, value);\ |
| 263 | }\ |
| 264 | } |
| 265 | |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 266 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
| 267 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 268 | SCI_IN(scif_size, scif_offset);\ |
| 269 | }\ |
| 270 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 271 | unsigned int value) {\ |
| 272 | SCI_OUT(scif_size, scif_offset, value);\ |
| 273 | } |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 274 | |
| 275 | #define CPU_SCI_FNS(name, sci_offset, sci_size)\ |
| 276 | static inline unsigned int sci_##name##_in(struct uart_port *port) {\ |
| 277 | SCI_IN(sci_size, sci_offset);\ |
| 278 | }\ |
| 279 | static inline void sci_##name##_out(struct uart_port *port,\ |
| 280 | unsigned int value) {\ |
| 281 | SCI_OUT(sci_size, sci_offset, value);\ |
| 282 | } |
| 283 | |
Simon Glass | 403a838 | 2023-02-01 13:20:07 -0700 | [diff] [blame] | 284 | #if defined(CONFIG_R8A7740) |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 285 | #if defined(CONFIG_CPU_SH7721) || \ |
Nobuhiro Iwamatsu | 866515f | 2012-06-21 13:21:32 +0900 | [diff] [blame] | 286 | defined(CONFIG_SH73A0) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 287 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 288 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 289 | #elif defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 290 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 291 | sh4_scifb_offset, sh4_scifb_size) \ |
| 292 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 293 | sh4_scifb_offset, sh4_scifb_size) |
| 294 | #define SCIF_FNS(name, scif_offset, scif_size) \ |
| 295 | CPU_SCIF_FNS(name, scif_offset, scif_size) |
| 296 | #else |
| 297 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 298 | sh4_sci_offset, sh4_sci_size, \ |
| 299 | sh3_scif_offset, sh3_scif_size,\ |
| 300 | sh4_scif_offset, sh4_scif_size, \ |
| 301 | h8_sci_offset, h8_sci_size) \ |
| 302 | CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 303 | sh3_scif_offset, sh3_scif_size) |
| 304 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\ |
| 305 | sh4_scif_offset, sh4_scif_size) \ |
| 306 | CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size) |
| 307 | #endif |
Marek Vasut | a71ce47 | 2019-05-04 13:31:06 +0200 | [diff] [blame] | 308 | #elif defined(CONFIG_CPU_SH7723) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 309 | #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 310 | sh4_scif_offset, sh4_scif_size) \ |
| 311 | CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\ |
| 312 | sh4_scif_offset, sh4_scif_size) |
| 313 | #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \ |
| 314 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
Paul Barker | 327571c | 2023-10-19 15:30:44 +0100 | [diff] [blame] | 315 | #elif defined(CONFIG_RZG2L) |
| 316 | #define SCIF_FNS(reg_name, reg_offset, reg_size) \ |
| 317 | CPU_SCIF_FNS(reg_name, reg_offset, reg_size) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 318 | #else |
| 319 | #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\ |
| 320 | sh4_sci_offset, sh4_sci_size, \ |
| 321 | sh3_scif_offset, sh3_scif_size,\ |
| 322 | sh4_scif_offset, sh4_scif_size, \ |
| 323 | h8_sci_offset, h8_sci_size) \ |
| 324 | CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\ |
| 325 | sh4_scif_offset, sh4_scif_size) |
| 326 | #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, \ |
| 327 | sh4_scif_offset, sh4_scif_size) \ |
| 328 | CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) |
| 329 | #endif |
| 330 | |
Simon Glass | 403a838 | 2023-02-01 13:20:07 -0700 | [diff] [blame] | 331 | #if defined(CONFIG_CPU_SH7721) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 332 | |
| 333 | SCIF_FNS(SCSMR, 0x00, 16) |
| 334 | SCIF_FNS(SCBRR, 0x04, 8) |
| 335 | SCIF_FNS(SCSCR, 0x08, 16) |
| 336 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 337 | SCIF_FNS(SCFER, 0x10, 16) |
| 338 | SCIF_FNS(SCxSR, 0x14, 16) |
| 339 | SCIF_FNS(SCFCR, 0x18, 16) |
| 340 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 341 | SCIF_FNS(SCxTDR, 0x20, 8) |
| 342 | SCIF_FNS(SCxRDR, 0x24, 8) |
| 343 | SCIF_FNS(SCLSR, 0x00, 0) |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 344 | SCIF_FNS(DL, 0x00, 0) /* dummy */ |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 345 | #elif defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 346 | SCIF_FNS(SCSMR, 0x00, 16) |
| 347 | SCIF_FNS(SCBRR, 0x04, 8) |
| 348 | SCIF_FNS(SCSCR, 0x08, 16) |
| 349 | SCIF_FNS(SCTDSR, 0x0c, 16) |
| 350 | SCIF_FNS(SCFER, 0x10, 16) |
| 351 | SCIF_FNS(SCxSR, 0x14, 16) |
| 352 | SCIF_FNS(SCFCR, 0x18, 16) |
| 353 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 354 | SCIF_FNS(SCTFDR, 0x38, 16) |
| 355 | SCIF_FNS(SCRFDR, 0x3c, 16) |
| 356 | SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8) |
| 357 | SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8) |
| 358 | SCIF_FNS(SCLSR, 0x00, 0) |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 359 | SCIF_FNS(DL, 0x00, 0) /* dummy */ |
Marek Vasut | a71ce47 | 2019-05-04 13:31:06 +0200 | [diff] [blame] | 360 | #elif defined(CONFIG_CPU_SH7723) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 361 | SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16) |
| 362 | SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8) |
| 363 | SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16) |
| 364 | SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8) |
| 365 | SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16) |
| 366 | SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8) |
| 367 | SCIx_FNS(SCSPTR, 0, 0, 0, 0) |
| 368 | SCIF_FNS(SCTDSR, 0x0c, 8) |
| 369 | SCIF_FNS(SCFER, 0x10, 16) |
| 370 | SCIF_FNS(SCFCR, 0x18, 16) |
| 371 | SCIF_FNS(SCFDR, 0x1c, 16) |
| 372 | SCIF_FNS(SCLSR, 0x24, 16) |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 373 | SCIF_FNS(DL, 0x00, 0) /* dummy */ |
Marek Vasut | aa329a8 | 2018-01-22 01:43:25 +0100 | [diff] [blame] | 374 | #elif defined(CONFIG_RCAR_GEN2) |
Vladimir Barinov | 3ed0b62 | 2015-07-20 20:49:39 +0300 | [diff] [blame] | 375 | /* SCIFA and SCIF register offsets and size */ |
| 376 | SCIx_FNS(SCSMR, 0, 0, 0x00, 16, 0, 0, 0x00, 16, 0, 0) |
| 377 | SCIx_FNS(SCBRR, 0, 0, 0x04, 8, 0, 0, 0x04, 8, 0, 0) |
| 378 | SCIx_FNS(SCSCR, 0, 0, 0x08, 16, 0, 0, 0x08, 16, 0, 0) |
| 379 | SCIx_FNS(SCxTDR, 0, 0, 0x20, 8, 0, 0, 0x0C, 8, 0, 0) |
| 380 | SCIx_FNS(SCxSR, 0, 0, 0x14, 16, 0, 0, 0x10, 16, 0, 0) |
| 381 | SCIx_FNS(SCxRDR, 0, 0, 0x24, 8, 0, 0, 0x14, 8, 0, 0) |
| 382 | SCIF_FNS(SCFCR, 0, 0, 0x18, 16) |
| 383 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
| 384 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
| 385 | SCIF_FNS(DL, 0, 0, 0x30, 16) |
| 386 | SCIF_FNS(CKS, 0, 0, 0x34, 16) |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 387 | SCIF_FNS(HSSRR, 0, 0, 0x40, 16) /* HSCIF only */ |
Tom Rini | 31b8b4d | 2022-12-04 10:13:43 -0500 | [diff] [blame] | 388 | #if defined(CFG_SCIF_A) |
Vladimir Barinov | 3ed0b62 | 2015-07-20 20:49:39 +0300 | [diff] [blame] | 389 | SCIF_FNS(SCLSR, 0, 0, 0x14, 16) |
| 390 | #else |
| 391 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
| 392 | #endif |
Paul Barker | 327571c | 2023-10-19 15:30:44 +0100 | [diff] [blame] | 393 | #elif defined(CONFIG_RZG2L) |
| 394 | SCIF_FNS(SCSMR, 0x00, 16) |
| 395 | SCIF_FNS(SCBRR, 0x02, 8) |
| 396 | SCIF_FNS(SCSCR, 0x04, 16) |
| 397 | SCIF_FNS(SCxTDR, 0x06, 8) |
| 398 | SCIF_FNS(SCxSR, 0x08, 16) |
| 399 | SCIF_FNS(SCxRDR, 0x0A, 8) |
| 400 | SCIF_FNS(SCFCR, 0x0C, 16) |
| 401 | SCIF_FNS(SCFDR, 0x0E, 16) |
| 402 | SCIF_FNS(SCSPTR, 0x10, 16) |
| 403 | SCIF_FNS(SCLSR, 0x12, 16) |
| 404 | SCIF_FNS(SCSEMR, 0x14, 8) |
| 405 | SCIF_FNS(SCxTCR, 0x16, 16) |
| 406 | SCIF_FNS(DL, 0x00, 0) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 407 | #else |
| 408 | /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ |
| 409 | /* name off sz off sz off sz off sz off sz*/ |
| 410 | SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8) |
| 411 | SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8) |
| 412 | SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8) |
| 413 | SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) |
| 414 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) |
| 415 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
| 416 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 417 | #if defined(CONFIG_CPU_SH7780) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 418 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
| 419 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 420 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 421 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 422 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
| 423 | #elif defined(CONFIG_CPU_SH7763) |
| 424 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
| 425 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) |
| 426 | SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) |
| 427 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
| 428 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
| 429 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
| 430 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
| 431 | #else |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 432 | |
Marek Vasut | 6c17cd6 | 2023-02-28 22:19:30 +0100 | [diff] [blame] | 433 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 434 | #if defined(CONFIG_CPU_SH7722) |
Marek Vasut | 6c17cd6 | 2023-02-28 22:19:30 +0100 | [diff] [blame] | 435 | SCIF_FNS(SCSPTR, 0, 0, 0, 0) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 436 | #else |
Marek Vasut | 6c17cd6 | 2023-02-28 22:19:30 +0100 | [diff] [blame] | 437 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 438 | #endif |
Marek Vasut | 6c17cd6 | 2023-02-28 22:19:30 +0100 | [diff] [blame] | 439 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 440 | #endif |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 441 | SCIF_FNS(DL, 0, 0, 0x30, 16) |
| 442 | SCIF_FNS(CKS, 0, 0, 0x34, 16) |
| 443 | SCIF_FNS(HSSRR, 0, 0, 0x40, 16) /* HSCIF only */ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 444 | #endif |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 445 | #define sci_in(port, reg) sci_##reg##_in(port) |
| 446 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
| 447 | |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 448 | #if defined(CONFIG_CPU_SH7750) || \ |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 449 | defined(CONFIG_CPU_SH7751) || \ |
| 450 | defined(CONFIG_CPU_SH7751R) || \ |
| 451 | defined(CONFIG_CPU_SH7750R) || \ |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 452 | defined(CONFIG_CPU_SH7750S) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 453 | static inline int sci_rxd_in(struct uart_port *port) |
| 454 | { |
| 455 | if (port->mapbase == 0xffe00000) |
| 456 | return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */ |
| 457 | return 1; |
| 458 | } |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 459 | #else /* default case for non-SCI processors */ |
| 460 | static inline int sci_rxd_in(struct uart_port *port) |
| 461 | { |
| 462 | return 1; |
| 463 | } |
| 464 | #endif |
| 465 | |
| 466 | /* |
| 467 | * Values for the BitRate Register (SCBRR) |
| 468 | * |
| 469 | * The values are actually divisors for a frequency which can |
| 470 | * be internal to the SH3 (14.7456MHz) or derived from an external |
| 471 | * clock source. This driver assumes the internal clock is used; |
| 472 | * to support using an external clock source, config options or |
| 473 | * possibly command-line options would need to be added. |
| 474 | * |
| 475 | * Also, to support speeds below 2400 (why?) the lower 2 bits of |
| 476 | * the SCSMR register would also need to be set to non-zero values. |
| 477 | * |
| 478 | * -- Greg Banks 27Feb2000 |
| 479 | * |
| 480 | * Answer: The SCBRR register is only eight bits, and the value in |
| 481 | * it gets larger with lower baud rates. At around 2400 (depending on |
| 482 | * the peripherial module clock) you run out of bits. However the |
| 483 | * lower two bits of SCSMR allow the module clock to be divided down, |
| 484 | * scaling the value which is needed in SCBRR. |
| 485 | * |
| 486 | * -- Stuart Menefy - 23 May 2000 |
| 487 | * |
| 488 | * I meant, why would anyone bother with bitrates below 2400. |
| 489 | * |
| 490 | * -- Greg Banks - 7Jul2000 |
| 491 | * |
| 492 | * You "speedist"! How will I use my 110bps ASR-33 teletype with paper |
| 493 | * tape reader as a console! |
| 494 | * |
| 495 | * -- Mitch Davis - 15 Jul 2000 |
| 496 | */ |
| 497 | |
Marek Vasut | 39df77a | 2019-05-07 22:31:23 +0200 | [diff] [blame] | 498 | #if defined(CONFIG_CPU_SH7780) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 499 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) |
Marek Vasut | a1a61d6 | 2019-05-07 22:04:05 +0200 | [diff] [blame] | 500 | #elif defined(CONFIG_CPU_SH7721) || \ |
Hideyuki Sano | dde220f | 2012-06-25 10:29:56 +0900 | [diff] [blame] | 501 | defined(CONFIG_R8A7740) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 502 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) |
Marek Vasut | a71ce47 | 2019-05-04 13:31:06 +0200 | [diff] [blame] | 503 | #elif defined(CONFIG_CPU_SH7723) |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 504 | static inline int scbrr_calc(struct uart_port *port, int bps, int clk) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 505 | { |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 506 | if (port->type == PORT_SCIF) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 507 | return (clk+16*bps)/(32*bps)-1; |
| 508 | else |
| 509 | return ((clk*2)+16*bps)/(16*bps)-1; |
| 510 | } |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 511 | #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) |
Marek Vasut | aa329a8 | 2018-01-22 01:43:25 +0100 | [diff] [blame] | 512 | #elif defined(CONFIG_RCAR_GEN2) |
Nobuhiro Iwamatsu | 6565330 | 2014-07-28 15:07:44 +0900 | [diff] [blame] | 513 | #define DL_VALUE(bps, clk) (clk / bps / 16) /* External Clock */ |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 514 | #if defined(CFG_SCIF_A) || defined(CFG_HSCIF) |
Vladimir Barinov | 3ed0b62 | 2015-07-20 20:49:39 +0300 | [diff] [blame] | 515 | #define SCBRR_VALUE(bps, clk) (clk / bps / 16 - 1) /* Internal Clock */ |
| 516 | #else |
| 517 | #define SCBRR_VALUE(bps, clk) (clk / bps / 32 - 1) /* Internal Clock */ |
| 518 | #endif |
Hai Pham | 19923d8 | 2023-02-28 22:29:19 +0100 | [diff] [blame] | 519 | #elif defined(CONFIG_RCAR_64) |
| 520 | static inline int scbrr_calc(struct uart_port *port, int bps, int clk) |
| 521 | { |
| 522 | if (port->type == PORT_SCIF) |
| 523 | return (clk + 16 * bps) / (32 * bps) - 1; |
| 524 | else /* PORT_HSCIF */ |
| 525 | return clk / bps / 8 / 2 - 1; /* Internal Clock, Sampling rate = 8 */ |
| 526 | } |
| 527 | #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk) |
Nobuhiro Iwamatsu | a5579ca | 2010-10-26 03:55:15 +0900 | [diff] [blame] | 528 | #else /* Generic SH */ |
| 529 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) |
| 530 | #endif |
Nobuhiro Iwamatsu | 6d02035 | 2015-02-12 13:48:04 +0900 | [diff] [blame] | 531 | |
| 532 | #ifndef DL_VALUE |
| 533 | #define DL_VALUE(bps, clk) 0 |
| 534 | #endif |