serial_sh.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /*
  2. * Copy and modify from linux/drivers/serial/sh-sci.h
  3. */
  4. #include <dm/platform_data/serial_sh.h>
  5. struct uart_port {
  6. unsigned long iobase; /* in/out[bwl] */
  7. unsigned char *membase; /* read/write[bwl] */
  8. unsigned long mapbase; /* for ioremap */
  9. enum sh_serial_type type; /* port type */
  10. enum sh_clk_mode clk_mode; /* clock mode */
  11. };
  12. #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
  13. #include <asm/regs306x.h>
  14. #endif
  15. #if defined(CONFIG_H8S2678)
  16. #include <asm/regs267x.h>
  17. #endif
  18. #if defined(CONFIG_CPU_SH7706) || \
  19. defined(CONFIG_CPU_SH7707) || \
  20. defined(CONFIG_CPU_SH7708) || \
  21. defined(CONFIG_CPU_SH7709)
  22. # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
  23. # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
  24. # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
  25. #elif defined(CONFIG_CPU_SH7705)
  26. # define SCIF0 0xA4400000
  27. # define SCIF2 0xA4410000
  28. # define SCSMR_Ir 0xA44A0000
  29. # define IRDA_SCIF SCIF0
  30. # define SCPCR 0xA4000116
  31. # define SCPDR 0xA4000136
  32. /* Set the clock source,
  33. * SCIF2 (0xA4410000) -> External clock, SCK pin used as clock input
  34. * SCIF0 (0xA4400000) -> Internal clock, SCK pin as serial clock output
  35. */
  36. # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
  37. #elif defined(CONFIG_CPU_SH7720) || \
  38. defined(CONFIG_CPU_SH7721) || \
  39. defined(CONFIG_ARCH_SH7367) || \
  40. defined(CONFIG_ARCH_SH7377) || \
  41. defined(CONFIG_ARCH_SH7372) || \
  42. defined(CONFIG_SH73A0) || \
  43. defined(CONFIG_R8A7740)
  44. # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
  45. # define PORT_PTCR 0xA405011EUL
  46. # define PORT_PVCR 0xA4050122UL
  47. # define SCIF_ORER 0x0200 /* overrun error bit */
  48. #elif defined(CONFIG_SH_RTS7751R2D)
  49. # define SCSPTR1 0xFFE0001C /* 8 bit SCIF */
  50. # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
  51. # define SCIF_ORER 0x0001 /* overrun error bit */
  52. # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  53. #elif defined(CONFIG_CPU_SH7750) || \
  54. defined(CONFIG_CPU_SH7750R) || \
  55. defined(CONFIG_CPU_SH7750S) || \
  56. defined(CONFIG_CPU_SH7091) || \
  57. defined(CONFIG_CPU_SH7751) || \
  58. defined(CONFIG_CPU_SH7751R)
  59. # define SCSPTR1 0xffe0001c /* 8 bit SCI */
  60. # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
  61. # define SCIF_ORER 0x0001 /* overrun error bit */
  62. # define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
  63. 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
  64. 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */)
  65. #elif defined(CONFIG_CPU_SH7760)
  66. # define SCSPTR0 0xfe600024 /* 16 bit SCIF */
  67. # define SCSPTR1 0xfe610024 /* 16 bit SCIF */
  68. # define SCSPTR2 0xfe620024 /* 16 bit SCIF */
  69. # define SCIF_ORER 0x0001 /* overrun error bit */
  70. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  71. #elif defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
  72. # define SCSPTR0 0xA4400000 /* 16 bit SCIF */
  73. # define SCIF_ORER 0x0001 /* overrun error bit */
  74. # define PACR 0xa4050100
  75. # define PBCR 0xa4050102
  76. # define SCSCR_INIT(port) 0x3B
  77. #elif defined(CONFIG_CPU_SH7343)
  78. # define SCSPTR0 0xffe00010 /* 16 bit SCIF */
  79. # define SCSPTR1 0xffe10010 /* 16 bit SCIF */
  80. # define SCSPTR2 0xffe20010 /* 16 bit SCIF */
  81. # define SCSPTR3 0xffe30010 /* 16 bit SCIF */
  82. # define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */
  83. #elif defined(CONFIG_CPU_SH7722)
  84. # define PADR 0xA4050120
  85. # undef PSDR
  86. # define PSDR 0xA405013e
  87. # define PWDR 0xA4050166
  88. # define PSCR 0xA405011E
  89. # define SCIF_ORER 0x0001 /* overrun error bit */
  90. # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  91. #elif defined(CONFIG_CPU_SH7366)
  92. # define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
  93. # define SCSPTR0 SCPDR0
  94. # define SCIF_ORER 0x0001 /* overrun error bit */
  95. # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  96. #elif defined(CONFIG_CPU_SH7723)
  97. # define SCSPTR0 0xa4050160
  98. # define SCSPTR1 0xa405013e
  99. # define SCSPTR2 0xa4050160
  100. # define SCSPTR3 0xa405013e
  101. # define SCSPTR4 0xa4050128
  102. # define SCSPTR5 0xa4050128
  103. # define SCIF_ORER 0x0001 /* overrun error bit */
  104. # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  105. #elif defined(CONFIG_CPU_SH7724)
  106. # define SCIF_ORER 0x0001 /* overrun error bit */
  107. # define SCSCR_INIT(port) ((port)->type == PORT_SCIFA ? \
  108. 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
  109. 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */)
  110. #elif defined(CONFIG_CPU_SH7734)
  111. # define SCSPTR0 0xFFE40020
  112. # define SCSPTR1 0xFFE41020
  113. # define SCSPTR2 0xFFE42020
  114. # define SCSPTR3 0xFFE43020
  115. # define SCSPTR4 0xFFE44020
  116. # define SCSPTR5 0xFFE45020
  117. # define SCIF_ORER 0x0001 /* overrun error bit */
  118. # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  119. #elif defined(CONFIG_CPU_SH4_202)
  120. # define SCSPTR2 0xffe80020 /* 16 bit SCIF */
  121. # define SCIF_ORER 0x0001 /* overrun error bit */
  122. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  123. #elif defined(CONFIG_CPU_SH5_101) || defined(CONFIG_CPU_SH5_103)
  124. # define SCIF_BASE_ADDR 0x01030000
  125. # define SCIF_ADDR_SH5 (PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR)
  126. # define SCIF_PTR2_OFFS 0x0000020
  127. # define SCIF_LSR2_OFFS 0x0000024
  128. # define SCSPTR\
  129. ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */
  130. # define SCLSR2\
  131. ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */
  132. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */
  133. #elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
  134. # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
  135. # define H8300_SCI_DR(ch) (*(volatile char *)(P1DR + h8300_sci_pins[ch].port))
  136. #elif defined(CONFIG_H8S2678)
  137. # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
  138. # define H8300_SCI_DR(ch) (*(volatile char *)(P1DR + h8300_sci_pins[ch].port))
  139. #elif defined(CONFIG_CPU_SH7757) || \
  140. defined(CONFIG_CPU_SH7752) || \
  141. defined(CONFIG_CPU_SH7753)
  142. # define SCSPTR0 0xfe4b0020
  143. # define SCSPTR1 0xfe4b0020
  144. # define SCSPTR2 0xfe4b0020
  145. # define SCIF_ORER 0x0001
  146. # define SCSCR_INIT(port) 0x38
  147. # define SCIF_ONLY
  148. #elif defined(CONFIG_CPU_SH7763)
  149. # define SCSPTR0 0xffe00024 /* 16 bit SCIF */
  150. # define SCSPTR1 0xffe08024 /* 16 bit SCIF */
  151. # define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */
  152. # define SCIF_ORER 0x0001 /* overrun error bit */
  153. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  154. #elif defined(CONFIG_CPU_SH7770)
  155. # define SCSPTR0 0xff923020 /* 16 bit SCIF */
  156. # define SCSPTR1 0xff924020 /* 16 bit SCIF */
  157. # define SCSPTR2 0xff925020 /* 16 bit SCIF */
  158. # define SCIF_ORER 0x0001 /* overrun error bit */
  159. # define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */
  160. #elif defined(CONFIG_CPU_SH7780)
  161. # define SCSPTR0 0xffe00024 /* 16 bit SCIF */
  162. # define SCSPTR1 0xffe10024 /* 16 bit SCIF */
  163. # define SCIF_ORER 0x0001 /* Overrun error bit */
  164. #if defined(CONFIG_SH_SH2007)
  165. /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=0 */
  166. # define SCSCR_INIT(port) 0x38
  167. #else
  168. /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,CKE1=1 */
  169. # define SCSCR_INIT(port) 0x3a
  170. #endif
  171. #elif defined(CONFIG_CPU_SH7785) || \
  172. defined(CONFIG_CPU_SH7786)
  173. # define SCSPTR0 0xffea0024 /* 16 bit SCIF */
  174. # define SCSPTR1 0xffeb0024 /* 16 bit SCIF */
  175. # define SCSPTR2 0xffec0024 /* 16 bit SCIF */
  176. # define SCSPTR3 0xffed0024 /* 16 bit SCIF */
  177. # define SCSPTR4 0xffee0024 /* 16 bit SCIF */
  178. # define SCSPTR5 0xffef0024 /* 16 bit SCIF */
  179. # define SCIF_ORER 0x0001 /* Overrun error bit */
  180. # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  181. #elif defined(CONFIG_CPU_SH7201) || \
  182. defined(CONFIG_CPU_SH7203) || \
  183. defined(CONFIG_CPU_SH7206) || \
  184. defined(CONFIG_CPU_SH7263) || \
  185. defined(CONFIG_CPU_SH7264)
  186. # define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
  187. # define SCSPTR1 0xfffe8820 /* 16 bit SCIF */
  188. # define SCSPTR2 0xfffe9020 /* 16 bit SCIF */
  189. # define SCSPTR3 0xfffe9820 /* 16 bit SCIF */
  190. # if defined(CONFIG_CPU_SH7201)
  191. # define SCSPTR4 0xfffeA020 /* 16 bit SCIF */
  192. # define SCSPTR5 0xfffeA820 /* 16 bit SCIF */
  193. # define SCSPTR6 0xfffeB020 /* 16 bit SCIF */
  194. # define SCSPTR7 0xfffeB820 /* 16 bit SCIF */
  195. # endif
  196. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  197. #elif defined(CONFIG_CPU_SH7269)
  198. # define SCSPTR0 0xe8007020 /* 16 bit SCIF */
  199. # define SCSPTR1 0xe8007820 /* 16 bit SCIF */
  200. # define SCSPTR2 0xe8008020 /* 16 bit SCIF */
  201. # define SCSPTR3 0xe8008820 /* 16 bit SCIF */
  202. # define SCSPTR4 0xe8009020 /* 16 bit SCIF */
  203. # define SCSPTR5 0xe8009820 /* 16 bit SCIF */
  204. # define SCSPTR6 0xe800a020 /* 16 bit SCIF */
  205. # define SCSPTR7 0xe800a820 /* 16 bit SCIF */
  206. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  207. #elif defined(CONFIG_CPU_SH7619)
  208. # define SCSPTR0 0xf8400020 /* 16 bit SCIF */
  209. # define SCSPTR1 0xf8410020 /* 16 bit SCIF */
  210. # define SCSPTR2 0xf8420020 /* 16 bit SCIF */
  211. # define SCIF_ORER 0x0001 /* overrun error bit */
  212. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  213. #elif defined(CONFIG_CPU_SHX3)
  214. # define SCSPTR0 0xffc30020 /* 16 bit SCIF */
  215. # define SCSPTR1 0xffc40020 /* 16 bit SCIF */
  216. # define SCSPTR2 0xffc50020 /* 16 bit SCIF */
  217. # define SCSPTR3 0xffc60020 /* 16 bit SCIF */
  218. # define SCIF_ORER 0x0001 /* Overrun error bit */
  219. # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
  220. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || \
  221. defined(CONFIG_R8A7792) || defined(CONFIG_R8A7793) || \
  222. defined(CONFIG_R8A7794) || defined(CONFIG_R8A7795)
  223. # if defined(CONFIG_SCIF_A)
  224. # define SCIF_ORER 0x0200
  225. # else
  226. # define SCIF_ORER 0x0001
  227. # endif
  228. # define SCSCR_INIT(port) (port->clk_mode == EXT_CLK ? 0x32 : 0x30)
  229. /* TIE=0,RIE=0,TE=1,RE=1,REIE=0, */
  230. #else
  231. # error CPU subtype not defined
  232. #endif
  233. /* SCSCR */
  234. #define SCI_CTRL_FLAGS_TIE 0x80 /* all */
  235. #define SCI_CTRL_FLAGS_RIE 0x40 /* all */
  236. #define SCI_CTRL_FLAGS_TE 0x20 /* all */
  237. #define SCI_CTRL_FLAGS_RE 0x10 /* all */
  238. #if defined(CONFIG_CPU_SH7750) || \
  239. defined(CONFIG_CPU_SH7091) || \
  240. defined(CONFIG_CPU_SH7750R) || \
  241. defined(CONFIG_CPU_SH7722) || \
  242. defined(CONFIG_CPU_SH7734) || \
  243. defined(CONFIG_CPU_SH7750S) || \
  244. defined(CONFIG_CPU_SH7751) || \
  245. defined(CONFIG_CPU_SH7751R) || \
  246. defined(CONFIG_CPU_SH7763) || \
  247. defined(CONFIG_CPU_SH7780) || \
  248. defined(CONFIG_CPU_SH7785) || \
  249. defined(CONFIG_CPU_SH7786) || \
  250. defined(CONFIG_CPU_SHX3)
  251. #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
  252. #elif defined(CONFIG_CPU_SH7724)
  253. #define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8)
  254. #else
  255. #define SCI_CTRL_FLAGS_REIE 0
  256. #endif
  257. /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  258. /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  259. /* SCI_CTRL_FLAGS_CKE1 0x02 * all */
  260. /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
  261. /* SCxSR SCI */
  262. #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  263. #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  264. #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  265. #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  266. #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  267. #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  268. /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  269. /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  270. #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
  271. /* SCxSR SCIF */
  272. #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  273. #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  274. #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  275. #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  276. #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  277. #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  278. #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  279. #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  280. #if defined(CONFIG_CPU_SH7705) || \
  281. defined(CONFIG_CPU_SH7720) || \
  282. defined(CONFIG_CPU_SH7721) || \
  283. defined(CONFIG_ARCH_SH7367) || \
  284. defined(CONFIG_ARCH_SH7377) || \
  285. defined(CONFIG_ARCH_SH7372) || \
  286. defined(CONFIG_SH73A0) || \
  287. defined(CONFIG_R8A7740)
  288. # define SCIF_ORER 0x0200
  289. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
  290. # define SCIF_RFDC_MASK 0x007f
  291. # define SCIF_TXROOM_MAX 64
  292. #elif defined(CONFIG_CPU_SH7763)
  293. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  294. # define SCIF_RFDC_MASK 0x007f
  295. # define SCIF_TXROOM_MAX 64
  296. /* SH7763 SCIF2 support */
  297. # define SCIF2_RFDC_MASK 0x001f
  298. # define SCIF2_TXROOM_MAX 16
  299. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  300. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  301. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  302. # if defined(CONFIG_SCIF_A)
  303. # define SCIF_RFDC_MASK 0x007f
  304. # else
  305. # define SCIF_RFDC_MASK 0x001f
  306. # endif
  307. #else
  308. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  309. # define SCIF_RFDC_MASK 0x001f
  310. # define SCIF_TXROOM_MAX 16
  311. #endif
  312. #ifndef SCIF_ORER
  313. #define SCIF_ORER 0x0000
  314. #endif
  315. #define SCxSR_TEND(port)\
  316. (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
  317. #define SCxSR_ERRORS(port)\
  318. (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
  319. #define SCxSR_RDxF(port)\
  320. (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
  321. #define SCxSR_TDxE(port)\
  322. (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
  323. #define SCxSR_FER(port)\
  324. (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
  325. #define SCxSR_PER(port)\
  326. (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
  327. #define SCxSR_BRK(port)\
  328. ((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
  329. #define SCxSR_ORER(port)\
  330. (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
  331. #if defined(CONFIG_CPU_SH7705) || \
  332. defined(CONFIG_CPU_SH7720) || \
  333. defined(CONFIG_CPU_SH7721) || \
  334. defined(CONFIG_ARCH_SH7367) || \
  335. defined(CONFIG_ARCH_SH7377) || \
  336. defined(CONFIG_ARCH_SH7372) || \
  337. defined(CONFIG_SH73A0) || \
  338. defined(CONFIG_R8A7740)
  339. # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
  340. # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
  341. # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
  342. # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3)
  343. #else
  344. # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
  345. # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
  346. # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
  347. # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
  348. #endif
  349. /* SCFCR */
  350. #define SCFCR_RFRST 0x0002
  351. #define SCFCR_TFRST 0x0004
  352. #define SCFCR_TCRST 0x4000
  353. #define SCFCR_MCE 0x0008
  354. #define SCI_MAJOR 204
  355. #define SCI_MINOR_START 8
  356. /* Generic serial flags */
  357. #define SCI_RX_THROTTLE 0x0000001
  358. #define SCI_MAGIC 0xbabeface
  359. /*
  360. * Events are used to schedule things to happen at timer-interrupt
  361. * time, instead of at rs interrupt time.
  362. */
  363. #define SCI_EVENT_WRITE_WAKEUP 0
  364. #define SCI_IN(size, offset)\
  365. if ((size) == 8) {\
  366. return readb(port->membase + (offset));\
  367. } else {\
  368. return readw(port->membase + (offset));\
  369. }
  370. #define SCI_OUT(size, offset, value)\
  371. if ((size) == 8) {\
  372. writeb(value, port->membase + (offset));\
  373. } else if ((size) == 16) {\
  374. writew(value, port->membase + (offset));\
  375. }
  376. #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
  377. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  378. if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
  379. SCI_IN(scif_size, scif_offset)\
  380. } else { /* PORT_SCI or PORT_SCIFA */\
  381. SCI_IN(sci_size, sci_offset);\
  382. }\
  383. }\
  384. static inline void sci_##name##_out(struct uart_port *port,\
  385. unsigned int value) {\
  386. if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
  387. SCI_OUT(scif_size, scif_offset, value)\
  388. } else { /* PORT_SCI or PORT_SCIFA */\
  389. SCI_OUT(sci_size, sci_offset, value);\
  390. }\
  391. }
  392. #ifdef CONFIG_H8300
  393. /* h8300 don't have SCIF */
  394. #define CPU_SCIF_FNS(name) \
  395. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  396. return 0;\
  397. }\
  398. static inline void sci_##name##_out(struct uart_port *port,\
  399. unsigned int value) {\
  400. }
  401. #else
  402. #define CPU_SCIF_FNS(name, scif_offset, scif_size) \
  403. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  404. SCI_IN(scif_size, scif_offset);\
  405. }\
  406. static inline void sci_##name##_out(struct uart_port *port,\
  407. unsigned int value) {\
  408. SCI_OUT(scif_size, scif_offset, value);\
  409. }
  410. #endif
  411. #define CPU_SCI_FNS(name, sci_offset, sci_size)\
  412. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  413. SCI_IN(sci_size, sci_offset);\
  414. }\
  415. static inline void sci_##name##_out(struct uart_port *port,\
  416. unsigned int value) {\
  417. SCI_OUT(sci_size, sci_offset, value);\
  418. }
  419. #if defined(CONFIG_CPU_SH3) || \
  420. defined(CONFIG_ARCH_SH7367) || \
  421. defined(CONFIG_ARCH_SH7377) || \
  422. defined(CONFIG_ARCH_SH7372) || \
  423. defined(CONFIG_SH73A0) || \
  424. defined(CONFIG_R8A7740)
  425. #if defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
  426. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  427. sh4_sci_offset, sh4_sci_size, \
  428. sh3_scif_offset, sh3_scif_size, \
  429. sh4_scif_offset, sh4_scif_size, \
  430. h8_sci_offset, h8_sci_size) \
  431. CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
  432. sh4_scif_offset, sh4_scif_size)
  433. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  434. sh4_scif_offset, sh4_scif_size) \
  435. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  436. #elif defined(CONFIG_CPU_SH7705) || \
  437. defined(CONFIG_CPU_SH7720) || \
  438. defined(CONFIG_CPU_SH7721) || \
  439. defined(CONFIG_ARCH_SH7367) || \
  440. defined(CONFIG_ARCH_SH7377) || \
  441. defined(CONFIG_SH73A0)
  442. #define SCIF_FNS(name, scif_offset, scif_size) \
  443. CPU_SCIF_FNS(name, scif_offset, scif_size)
  444. #elif defined(CONFIG_ARCH_SH7372) || \
  445. defined(CONFIG_R8A7740)
  446. #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  447. sh4_scifb_offset, sh4_scifb_size) \
  448. CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  449. sh4_scifb_offset, sh4_scifb_size)
  450. #define SCIF_FNS(name, scif_offset, scif_size) \
  451. CPU_SCIF_FNS(name, scif_offset, scif_size)
  452. #else
  453. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  454. sh4_sci_offset, sh4_sci_size, \
  455. sh3_scif_offset, sh3_scif_size,\
  456. sh4_scif_offset, sh4_scif_size, \
  457. h8_sci_offset, h8_sci_size) \
  458. CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  459. sh3_scif_offset, sh3_scif_size)
  460. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  461. sh4_scif_offset, sh4_scif_size) \
  462. CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
  463. #endif
  464. #elif defined(__H8300H__) || defined(__H8300S__)
  465. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  466. sh4_sci_offset, sh4_sci_size, \
  467. sh3_scif_offset, sh3_scif_size,\
  468. sh4_scif_offset, sh4_scif_size, \
  469. h8_sci_offset, h8_sci_size) \
  470. CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
  471. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  472. sh4_scif_offset, sh4_scif_size) \
  473. CPU_SCIF_FNS(name)
  474. #elif defined(CONFIG_CPU_SH7723) || defined(CONFIG_CPU_SH7724)
  475. #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  476. sh4_scif_offset, sh4_scif_size) \
  477. CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  478. sh4_scif_offset, sh4_scif_size)
  479. #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
  480. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  481. #else
  482. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  483. sh4_sci_offset, sh4_sci_size, \
  484. sh3_scif_offset, sh3_scif_size,\
  485. sh4_scif_offset, sh4_scif_size, \
  486. h8_sci_offset, h8_sci_size) \
  487. CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
  488. sh4_scif_offset, sh4_scif_size)
  489. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, \
  490. sh4_scif_offset, sh4_scif_size) \
  491. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  492. #endif
  493. #if defined(CONFIG_CPU_SH7705) || \
  494. defined(CONFIG_CPU_SH7720) || \
  495. defined(CONFIG_CPU_SH7721) || \
  496. defined(CONFIG_ARCH_SH7367) || \
  497. defined(CONFIG_ARCH_SH7377) || \
  498. defined(CONFIG_SH73A0)
  499. SCIF_FNS(SCSMR, 0x00, 16)
  500. SCIF_FNS(SCBRR, 0x04, 8)
  501. SCIF_FNS(SCSCR, 0x08, 16)
  502. SCIF_FNS(SCTDSR, 0x0c, 8)
  503. SCIF_FNS(SCFER, 0x10, 16)
  504. SCIF_FNS(SCxSR, 0x14, 16)
  505. SCIF_FNS(SCFCR, 0x18, 16)
  506. SCIF_FNS(SCFDR, 0x1c, 16)
  507. SCIF_FNS(SCxTDR, 0x20, 8)
  508. SCIF_FNS(SCxRDR, 0x24, 8)
  509. SCIF_FNS(SCLSR, 0x00, 0)
  510. SCIF_FNS(DL, 0x00, 0) /* dummy */
  511. #elif defined(CONFIG_ARCH_SH7372) || \
  512. defined(CONFIG_R8A7740)
  513. SCIF_FNS(SCSMR, 0x00, 16)
  514. SCIF_FNS(SCBRR, 0x04, 8)
  515. SCIF_FNS(SCSCR, 0x08, 16)
  516. SCIF_FNS(SCTDSR, 0x0c, 16)
  517. SCIF_FNS(SCFER, 0x10, 16)
  518. SCIF_FNS(SCxSR, 0x14, 16)
  519. SCIF_FNS(SCFCR, 0x18, 16)
  520. SCIF_FNS(SCFDR, 0x1c, 16)
  521. SCIF_FNS(SCTFDR, 0x38, 16)
  522. SCIF_FNS(SCRFDR, 0x3c, 16)
  523. SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8)
  524. SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8)
  525. SCIF_FNS(SCLSR, 0x00, 0)
  526. SCIF_FNS(DL, 0x00, 0) /* dummy */
  527. #elif defined(CONFIG_CPU_SH7723) ||\
  528. defined(CONFIG_CPU_SH7724)
  529. SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
  530. SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
  531. SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
  532. SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
  533. SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
  534. SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
  535. SCIx_FNS(SCSPTR, 0, 0, 0, 0)
  536. SCIF_FNS(SCTDSR, 0x0c, 8)
  537. SCIF_FNS(SCFER, 0x10, 16)
  538. SCIF_FNS(SCFCR, 0x18, 16)
  539. SCIF_FNS(SCFDR, 0x1c, 16)
  540. SCIF_FNS(SCLSR, 0x24, 16)
  541. SCIF_FNS(DL, 0x00, 0) /* dummy */
  542. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  543. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  544. /* SCIFA and SCIF register offsets and size */
  545. SCIx_FNS(SCSMR, 0, 0, 0x00, 16, 0, 0, 0x00, 16, 0, 0)
  546. SCIx_FNS(SCBRR, 0, 0, 0x04, 8, 0, 0, 0x04, 8, 0, 0)
  547. SCIx_FNS(SCSCR, 0, 0, 0x08, 16, 0, 0, 0x08, 16, 0, 0)
  548. SCIx_FNS(SCxTDR, 0, 0, 0x20, 8, 0, 0, 0x0C, 8, 0, 0)
  549. SCIx_FNS(SCxSR, 0, 0, 0x14, 16, 0, 0, 0x10, 16, 0, 0)
  550. SCIx_FNS(SCxRDR, 0, 0, 0x24, 8, 0, 0, 0x14, 8, 0, 0)
  551. SCIF_FNS(SCFCR, 0, 0, 0x18, 16)
  552. SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
  553. SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
  554. SCIF_FNS(DL, 0, 0, 0x30, 16)
  555. SCIF_FNS(CKS, 0, 0, 0x34, 16)
  556. #if defined(CONFIG_SCIF_A)
  557. SCIF_FNS(SCLSR, 0, 0, 0x14, 16)
  558. #else
  559. SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
  560. #endif
  561. #else
  562. /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
  563. /* name off sz off sz off sz off sz off sz*/
  564. SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8)
  565. SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8)
  566. SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8)
  567. SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
  568. SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
  569. SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
  570. SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
  571. #if defined(CONFIG_CPU_SH7760) || \
  572. defined(CONFIG_CPU_SH7780) || \
  573. defined(CONFIG_CPU_SH7785) || \
  574. defined(CONFIG_CPU_SH7786)
  575. SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
  576. SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
  577. SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
  578. SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
  579. SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
  580. #elif defined(CONFIG_CPU_SH7763)
  581. SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
  582. SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
  583. SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
  584. SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
  585. SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
  586. SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
  587. SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
  588. #else
  589. SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
  590. #if defined(CONFIG_CPU_SH7722)
  591. SCIF_FNS(SCSPTR, 0, 0, 0, 0)
  592. #else
  593. SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
  594. #endif
  595. SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
  596. #endif
  597. SCIF_FNS(DL, 0, 0, 0x0, 0) /* dummy */
  598. #endif
  599. #define sci_in(port, reg) sci_##reg##_in(port)
  600. #define sci_out(port, reg, value) sci_##reg##_out(port, value)
  601. /* H8/300 series SCI pins assignment */
  602. #if defined(__H8300H__) || defined(__H8300S__)
  603. static const struct __attribute__((packed)) {
  604. int port; /* GPIO port no */
  605. unsigned short rx, tx; /* GPIO bit no */
  606. } h8300_sci_pins[] = {
  607. #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
  608. { /* SCI0 */
  609. .port = H8300_GPIO_P9,
  610. .rx = H8300_GPIO_B2,
  611. .tx = H8300_GPIO_B0,
  612. },
  613. { /* SCI1 */
  614. .port = H8300_GPIO_P9,
  615. .rx = H8300_GPIO_B3,
  616. .tx = H8300_GPIO_B1,
  617. },
  618. { /* SCI2 */
  619. .port = H8300_GPIO_PB,
  620. .rx = H8300_GPIO_B7,
  621. .tx = H8300_GPIO_B6,
  622. }
  623. #elif defined(CONFIG_H8S2678)
  624. { /* SCI0 */
  625. .port = H8300_GPIO_P3,
  626. .rx = H8300_GPIO_B2,
  627. .tx = H8300_GPIO_B0,
  628. },
  629. { /* SCI1 */
  630. .port = H8300_GPIO_P3,
  631. .rx = H8300_GPIO_B3,
  632. .tx = H8300_GPIO_B1,
  633. },
  634. { /* SCI2 */
  635. .port = H8300_GPIO_P5,
  636. .rx = H8300_GPIO_B1,
  637. .tx = H8300_GPIO_B0,
  638. }
  639. #endif
  640. };
  641. #endif
  642. #if defined(CONFIG_CPU_SH7706) || \
  643. defined(CONFIG_CPU_SH7707) || \
  644. defined(CONFIG_CPU_SH7708) || \
  645. defined(CONFIG_CPU_SH7709)
  646. static inline int sci_rxd_in(struct uart_port *port)
  647. {
  648. if (port->mapbase == 0xfffffe80)
  649. return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
  650. return 1;
  651. }
  652. #elif defined(CONFIG_CPU_SH7750) || \
  653. defined(CONFIG_CPU_SH7751) || \
  654. defined(CONFIG_CPU_SH7751R) || \
  655. defined(CONFIG_CPU_SH7750R) || \
  656. defined(CONFIG_CPU_SH7750S) || \
  657. defined(CONFIG_CPU_SH7091)
  658. static inline int sci_rxd_in(struct uart_port *port)
  659. {
  660. if (port->mapbase == 0xffe00000)
  661. return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
  662. return 1;
  663. }
  664. #elif defined(__H8300H__) || defined(__H8300S__)
  665. static inline int sci_rxd_in(struct uart_port *port)
  666. {
  667. int ch = (port->mapbase - SMR0) >> 3;
  668. return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
  669. }
  670. #else /* default case for non-SCI processors */
  671. static inline int sci_rxd_in(struct uart_port *port)
  672. {
  673. return 1;
  674. }
  675. #endif
  676. /*
  677. * Values for the BitRate Register (SCBRR)
  678. *
  679. * The values are actually divisors for a frequency which can
  680. * be internal to the SH3 (14.7456MHz) or derived from an external
  681. * clock source. This driver assumes the internal clock is used;
  682. * to support using an external clock source, config options or
  683. * possibly command-line options would need to be added.
  684. *
  685. * Also, to support speeds below 2400 (why?) the lower 2 bits of
  686. * the SCSMR register would also need to be set to non-zero values.
  687. *
  688. * -- Greg Banks 27Feb2000
  689. *
  690. * Answer: The SCBRR register is only eight bits, and the value in
  691. * it gets larger with lower baud rates. At around 2400 (depending on
  692. * the peripherial module clock) you run out of bits. However the
  693. * lower two bits of SCSMR allow the module clock to be divided down,
  694. * scaling the value which is needed in SCBRR.
  695. *
  696. * -- Stuart Menefy - 23 May 2000
  697. *
  698. * I meant, why would anyone bother with bitrates below 2400.
  699. *
  700. * -- Greg Banks - 7Jul2000
  701. *
  702. * You "speedist"! How will I use my 110bps ASR-33 teletype with paper
  703. * tape reader as a console!
  704. *
  705. * -- Mitch Davis - 15 Jul 2000
  706. */
  707. #if (defined(CONFIG_CPU_SH7780) || \
  708. defined(CONFIG_CPU_SH7785) || \
  709. defined(CONFIG_CPU_SH7786)) && \
  710. !defined(CONFIG_SH_SH2007)
  711. #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
  712. #elif defined(CONFIG_CPU_SH7705) || \
  713. defined(CONFIG_CPU_SH7720) || \
  714. defined(CONFIG_CPU_SH7721) || \
  715. defined(CONFIG_ARCH_SH7367) || \
  716. defined(CONFIG_ARCH_SH7377) || \
  717. defined(CONFIG_ARCH_SH7372) || \
  718. defined(CONFIG_SH73A0) || \
  719. defined(CONFIG_R8A7740)
  720. #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
  721. #elif defined(CONFIG_CPU_SH7723) ||\
  722. defined(CONFIG_CPU_SH7724)
  723. static inline int scbrr_calc(struct uart_port *port, int bps, int clk)
  724. {
  725. if (port->type == PORT_SCIF)
  726. return (clk+16*bps)/(32*bps)-1;
  727. else
  728. return ((clk*2)+16*bps)/(16*bps)-1;
  729. }
  730. #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk)
  731. #elif defined(__H8300H__) || defined(__H8300S__)
  732. #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1)
  733. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  734. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  735. #define DL_VALUE(bps, clk) (clk / bps / 16) /* External Clock */
  736. #if defined(CONFIG_SCIF_A)
  737. #define SCBRR_VALUE(bps, clk) (clk / bps / 16 - 1) /* Internal Clock */
  738. #else
  739. #define SCBRR_VALUE(bps, clk) (clk / bps / 32 - 1) /* Internal Clock */
  740. #endif
  741. #else /* Generic SH */
  742. #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
  743. #endif
  744. #ifndef DL_VALUE
  745. #define DL_VALUE(bps, clk) 0
  746. #endif