serial_sh.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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. defined(CONFIG_R8A7796)
  224. # if defined(CONFIG_SCIF_A)
  225. # define SCIF_ORER 0x0200
  226. # else
  227. # define SCIF_ORER 0x0001
  228. # endif
  229. # define SCSCR_INIT(port) (port->clk_mode == EXT_CLK ? 0x32 : 0x30)
  230. /* TIE=0,RIE=0,TE=1,RE=1,REIE=0, */
  231. #else
  232. # error CPU subtype not defined
  233. #endif
  234. /* SCSCR */
  235. #define SCI_CTRL_FLAGS_TIE 0x80 /* all */
  236. #define SCI_CTRL_FLAGS_RIE 0x40 /* all */
  237. #define SCI_CTRL_FLAGS_TE 0x20 /* all */
  238. #define SCI_CTRL_FLAGS_RE 0x10 /* all */
  239. #if defined(CONFIG_CPU_SH7750) || \
  240. defined(CONFIG_CPU_SH7091) || \
  241. defined(CONFIG_CPU_SH7750R) || \
  242. defined(CONFIG_CPU_SH7722) || \
  243. defined(CONFIG_CPU_SH7734) || \
  244. defined(CONFIG_CPU_SH7750S) || \
  245. defined(CONFIG_CPU_SH7751) || \
  246. defined(CONFIG_CPU_SH7751R) || \
  247. defined(CONFIG_CPU_SH7763) || \
  248. defined(CONFIG_CPU_SH7780) || \
  249. defined(CONFIG_CPU_SH7785) || \
  250. defined(CONFIG_CPU_SH7786) || \
  251. defined(CONFIG_CPU_SHX3)
  252. #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
  253. #elif defined(CONFIG_CPU_SH7724)
  254. #define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8)
  255. #else
  256. #define SCI_CTRL_FLAGS_REIE 0
  257. #endif
  258. /* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  259. /* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  260. /* SCI_CTRL_FLAGS_CKE1 0x02 * all */
  261. /* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
  262. /* SCxSR SCI */
  263. #define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  264. #define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  265. #define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  266. #define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  267. #define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  268. #define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  269. /* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  270. /* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
  271. #define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
  272. /* SCxSR SCIF */
  273. #define SCIF_ER 0x0080 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  274. #define SCIF_TEND 0x0040 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  275. #define SCIF_TDFE 0x0020 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  276. #define SCIF_BRK 0x0010 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  277. #define SCIF_FER 0x0008 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  278. #define SCIF_PER 0x0004 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  279. #define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  280. #define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
  281. #if defined(CONFIG_CPU_SH7705) || \
  282. defined(CONFIG_CPU_SH7720) || \
  283. defined(CONFIG_CPU_SH7721) || \
  284. defined(CONFIG_ARCH_SH7367) || \
  285. defined(CONFIG_ARCH_SH7377) || \
  286. defined(CONFIG_ARCH_SH7372) || \
  287. defined(CONFIG_SH73A0) || \
  288. defined(CONFIG_R8A7740)
  289. # define SCIF_ORER 0x0200
  290. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
  291. # define SCIF_RFDC_MASK 0x007f
  292. # define SCIF_TXROOM_MAX 64
  293. #elif defined(CONFIG_CPU_SH7763)
  294. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  295. # define SCIF_RFDC_MASK 0x007f
  296. # define SCIF_TXROOM_MAX 64
  297. /* SH7763 SCIF2 support */
  298. # define SCIF2_RFDC_MASK 0x001f
  299. # define SCIF2_TXROOM_MAX 16
  300. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  301. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  302. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  303. # if defined(CONFIG_SCIF_A)
  304. # define SCIF_RFDC_MASK 0x007f
  305. # else
  306. # define SCIF_RFDC_MASK 0x001f
  307. # endif
  308. #else
  309. # define SCIF_ERRORS (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
  310. # define SCIF_RFDC_MASK 0x001f
  311. # define SCIF_TXROOM_MAX 16
  312. #endif
  313. #ifndef SCIF_ORER
  314. #define SCIF_ORER 0x0000
  315. #endif
  316. #define SCxSR_TEND(port)\
  317. (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
  318. #define SCxSR_ERRORS(port)\
  319. (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
  320. #define SCxSR_RDxF(port)\
  321. (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
  322. #define SCxSR_TDxE(port)\
  323. (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
  324. #define SCxSR_FER(port)\
  325. (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
  326. #define SCxSR_PER(port)\
  327. (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
  328. #define SCxSR_BRK(port)\
  329. ((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
  330. #define SCxSR_ORER(port)\
  331. (((port)->type == PORT_SCI) ? SCI_ORER : SCIF_ORER)
  332. #if defined(CONFIG_CPU_SH7705) || \
  333. defined(CONFIG_CPU_SH7720) || \
  334. defined(CONFIG_CPU_SH7721) || \
  335. defined(CONFIG_ARCH_SH7367) || \
  336. defined(CONFIG_ARCH_SH7377) || \
  337. defined(CONFIG_ARCH_SH7372) || \
  338. defined(CONFIG_SH73A0) || \
  339. defined(CONFIG_R8A7740)
  340. # define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
  341. # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
  342. # define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
  343. # define SCxSR_BREAK_CLEAR(port) (sci_in(port, SCxSR) & 0xffe3)
  344. #else
  345. # define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
  346. # define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
  347. # define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
  348. # define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
  349. #endif
  350. /* SCFCR */
  351. #define SCFCR_RFRST 0x0002
  352. #define SCFCR_TFRST 0x0004
  353. #define SCFCR_TCRST 0x4000
  354. #define SCFCR_MCE 0x0008
  355. #define SCI_MAJOR 204
  356. #define SCI_MINOR_START 8
  357. /* Generic serial flags */
  358. #define SCI_RX_THROTTLE 0x0000001
  359. #define SCI_MAGIC 0xbabeface
  360. /*
  361. * Events are used to schedule things to happen at timer-interrupt
  362. * time, instead of at rs interrupt time.
  363. */
  364. #define SCI_EVENT_WRITE_WAKEUP 0
  365. #define SCI_IN(size, offset)\
  366. if ((size) == 8) {\
  367. return readb(port->membase + (offset));\
  368. } else {\
  369. return readw(port->membase + (offset));\
  370. }
  371. #define SCI_OUT(size, offset, value)\
  372. if ((size) == 8) {\
  373. writeb(value, port->membase + (offset));\
  374. } else if ((size) == 16) {\
  375. writew(value, port->membase + (offset));\
  376. }
  377. #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
  378. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  379. if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
  380. SCI_IN(scif_size, scif_offset)\
  381. } else { /* PORT_SCI or PORT_SCIFA */\
  382. SCI_IN(sci_size, sci_offset);\
  383. }\
  384. }\
  385. static inline void sci_##name##_out(struct uart_port *port,\
  386. unsigned int value) {\
  387. if (port->type == PORT_SCIF || port->type == PORT_SCIFB) {\
  388. SCI_OUT(scif_size, scif_offset, value)\
  389. } else { /* PORT_SCI or PORT_SCIFA */\
  390. SCI_OUT(sci_size, sci_offset, value);\
  391. }\
  392. }
  393. #ifdef CONFIG_H8300
  394. /* h8300 don't have SCIF */
  395. #define CPU_SCIF_FNS(name) \
  396. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  397. return 0;\
  398. }\
  399. static inline void sci_##name##_out(struct uart_port *port,\
  400. unsigned int value) {\
  401. }
  402. #else
  403. #define CPU_SCIF_FNS(name, scif_offset, scif_size) \
  404. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  405. SCI_IN(scif_size, scif_offset);\
  406. }\
  407. static inline void sci_##name##_out(struct uart_port *port,\
  408. unsigned int value) {\
  409. SCI_OUT(scif_size, scif_offset, value);\
  410. }
  411. #endif
  412. #define CPU_SCI_FNS(name, sci_offset, sci_size)\
  413. static inline unsigned int sci_##name##_in(struct uart_port *port) {\
  414. SCI_IN(sci_size, sci_offset);\
  415. }\
  416. static inline void sci_##name##_out(struct uart_port *port,\
  417. unsigned int value) {\
  418. SCI_OUT(sci_size, sci_offset, value);\
  419. }
  420. #if defined(CONFIG_CPU_SH3) || \
  421. defined(CONFIG_ARCH_SH7367) || \
  422. defined(CONFIG_ARCH_SH7377) || \
  423. defined(CONFIG_ARCH_SH7372) || \
  424. defined(CONFIG_SH73A0) || \
  425. defined(CONFIG_R8A7740)
  426. #if defined(CONFIG_CPU_SH7710) || defined(CONFIG_CPU_SH7712)
  427. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  428. sh4_sci_offset, sh4_sci_size, \
  429. sh3_scif_offset, sh3_scif_size, \
  430. sh4_scif_offset, sh4_scif_size, \
  431. h8_sci_offset, h8_sci_size) \
  432. CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
  433. sh4_scif_offset, sh4_scif_size)
  434. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  435. sh4_scif_offset, sh4_scif_size) \
  436. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  437. #elif defined(CONFIG_CPU_SH7705) || \
  438. defined(CONFIG_CPU_SH7720) || \
  439. defined(CONFIG_CPU_SH7721) || \
  440. defined(CONFIG_ARCH_SH7367) || \
  441. defined(CONFIG_ARCH_SH7377) || \
  442. defined(CONFIG_SH73A0)
  443. #define SCIF_FNS(name, scif_offset, scif_size) \
  444. CPU_SCIF_FNS(name, scif_offset, scif_size)
  445. #elif defined(CONFIG_ARCH_SH7372) || \
  446. defined(CONFIG_R8A7740)
  447. #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  448. sh4_scifb_offset, sh4_scifb_size) \
  449. CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  450. sh4_scifb_offset, sh4_scifb_size)
  451. #define SCIF_FNS(name, scif_offset, scif_size) \
  452. CPU_SCIF_FNS(name, scif_offset, scif_size)
  453. #else
  454. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  455. sh4_sci_offset, sh4_sci_size, \
  456. sh3_scif_offset, sh3_scif_size,\
  457. sh4_scif_offset, sh4_scif_size, \
  458. h8_sci_offset, h8_sci_size) \
  459. CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  460. sh3_scif_offset, sh3_scif_size)
  461. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  462. sh4_scif_offset, sh4_scif_size) \
  463. CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
  464. #endif
  465. #elif defined(__H8300H__) || defined(__H8300S__)
  466. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  467. sh4_sci_offset, sh4_sci_size, \
  468. sh3_scif_offset, sh3_scif_size,\
  469. sh4_scif_offset, sh4_scif_size, \
  470. h8_sci_offset, h8_sci_size) \
  471. CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
  472. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size,\
  473. sh4_scif_offset, sh4_scif_size) \
  474. CPU_SCIF_FNS(name)
  475. #elif defined(CONFIG_CPU_SH7723) || defined(CONFIG_CPU_SH7724)
  476. #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  477. sh4_scif_offset, sh4_scif_size) \
  478. CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size,\
  479. sh4_scif_offset, sh4_scif_size)
  480. #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
  481. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  482. #else
  483. #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size,\
  484. sh4_sci_offset, sh4_sci_size, \
  485. sh3_scif_offset, sh3_scif_size,\
  486. sh4_scif_offset, sh4_scif_size, \
  487. h8_sci_offset, h8_sci_size) \
  488. CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size,\
  489. sh4_scif_offset, sh4_scif_size)
  490. #define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, \
  491. sh4_scif_offset, sh4_scif_size) \
  492. CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
  493. #endif
  494. #if defined(CONFIG_CPU_SH7705) || \
  495. defined(CONFIG_CPU_SH7720) || \
  496. defined(CONFIG_CPU_SH7721) || \
  497. defined(CONFIG_ARCH_SH7367) || \
  498. defined(CONFIG_ARCH_SH7377) || \
  499. defined(CONFIG_SH73A0)
  500. SCIF_FNS(SCSMR, 0x00, 16)
  501. SCIF_FNS(SCBRR, 0x04, 8)
  502. SCIF_FNS(SCSCR, 0x08, 16)
  503. SCIF_FNS(SCTDSR, 0x0c, 8)
  504. SCIF_FNS(SCFER, 0x10, 16)
  505. SCIF_FNS(SCxSR, 0x14, 16)
  506. SCIF_FNS(SCFCR, 0x18, 16)
  507. SCIF_FNS(SCFDR, 0x1c, 16)
  508. SCIF_FNS(SCxTDR, 0x20, 8)
  509. SCIF_FNS(SCxRDR, 0x24, 8)
  510. SCIF_FNS(SCLSR, 0x00, 0)
  511. SCIF_FNS(DL, 0x00, 0) /* dummy */
  512. #elif defined(CONFIG_ARCH_SH7372) || \
  513. defined(CONFIG_R8A7740)
  514. SCIF_FNS(SCSMR, 0x00, 16)
  515. SCIF_FNS(SCBRR, 0x04, 8)
  516. SCIF_FNS(SCSCR, 0x08, 16)
  517. SCIF_FNS(SCTDSR, 0x0c, 16)
  518. SCIF_FNS(SCFER, 0x10, 16)
  519. SCIF_FNS(SCxSR, 0x14, 16)
  520. SCIF_FNS(SCFCR, 0x18, 16)
  521. SCIF_FNS(SCFDR, 0x1c, 16)
  522. SCIF_FNS(SCTFDR, 0x38, 16)
  523. SCIF_FNS(SCRFDR, 0x3c, 16)
  524. SCIx_FNS(SCxTDR, 0x20, 8, 0x40, 8)
  525. SCIx_FNS(SCxRDR, 0x24, 8, 0x60, 8)
  526. SCIF_FNS(SCLSR, 0x00, 0)
  527. SCIF_FNS(DL, 0x00, 0) /* dummy */
  528. #elif defined(CONFIG_CPU_SH7723) ||\
  529. defined(CONFIG_CPU_SH7724)
  530. SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
  531. SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
  532. SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
  533. SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
  534. SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
  535. SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
  536. SCIx_FNS(SCSPTR, 0, 0, 0, 0)
  537. SCIF_FNS(SCTDSR, 0x0c, 8)
  538. SCIF_FNS(SCFER, 0x10, 16)
  539. SCIF_FNS(SCFCR, 0x18, 16)
  540. SCIF_FNS(SCFDR, 0x1c, 16)
  541. SCIF_FNS(SCLSR, 0x24, 16)
  542. SCIF_FNS(DL, 0x00, 0) /* dummy */
  543. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  544. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  545. /* SCIFA and SCIF register offsets and size */
  546. SCIx_FNS(SCSMR, 0, 0, 0x00, 16, 0, 0, 0x00, 16, 0, 0)
  547. SCIx_FNS(SCBRR, 0, 0, 0x04, 8, 0, 0, 0x04, 8, 0, 0)
  548. SCIx_FNS(SCSCR, 0, 0, 0x08, 16, 0, 0, 0x08, 16, 0, 0)
  549. SCIx_FNS(SCxTDR, 0, 0, 0x20, 8, 0, 0, 0x0C, 8, 0, 0)
  550. SCIx_FNS(SCxSR, 0, 0, 0x14, 16, 0, 0, 0x10, 16, 0, 0)
  551. SCIx_FNS(SCxRDR, 0, 0, 0x24, 8, 0, 0, 0x14, 8, 0, 0)
  552. SCIF_FNS(SCFCR, 0, 0, 0x18, 16)
  553. SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
  554. SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
  555. SCIF_FNS(DL, 0, 0, 0x30, 16)
  556. SCIF_FNS(CKS, 0, 0, 0x34, 16)
  557. #if defined(CONFIG_SCIF_A)
  558. SCIF_FNS(SCLSR, 0, 0, 0x14, 16)
  559. #else
  560. SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
  561. #endif
  562. #else
  563. /* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
  564. /* name off sz off sz off sz off sz off sz*/
  565. SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8)
  566. SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8)
  567. SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8)
  568. SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
  569. SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
  570. SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
  571. SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
  572. #if defined(CONFIG_CPU_SH7760) || \
  573. defined(CONFIG_CPU_SH7780) || \
  574. defined(CONFIG_CPU_SH7785) || \
  575. defined(CONFIG_CPU_SH7786)
  576. SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
  577. SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
  578. SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
  579. SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
  580. SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
  581. #elif defined(CONFIG_CPU_SH7763)
  582. SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
  583. SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
  584. SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
  585. SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
  586. SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
  587. SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
  588. SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
  589. #else
  590. SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
  591. #if defined(CONFIG_CPU_SH7722)
  592. SCIF_FNS(SCSPTR, 0, 0, 0, 0)
  593. #else
  594. SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
  595. #endif
  596. SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
  597. #endif
  598. SCIF_FNS(DL, 0, 0, 0x0, 0) /* dummy */
  599. #endif
  600. #define sci_in(port, reg) sci_##reg##_in(port)
  601. #define sci_out(port, reg, value) sci_##reg##_out(port, value)
  602. /* H8/300 series SCI pins assignment */
  603. #if defined(__H8300H__) || defined(__H8300S__)
  604. static const struct __attribute__((packed)) {
  605. int port; /* GPIO port no */
  606. unsigned short rx, tx; /* GPIO bit no */
  607. } h8300_sci_pins[] = {
  608. #if defined(CONFIG_H83007) || defined(CONFIG_H83068)
  609. { /* SCI0 */
  610. .port = H8300_GPIO_P9,
  611. .rx = H8300_GPIO_B2,
  612. .tx = H8300_GPIO_B0,
  613. },
  614. { /* SCI1 */
  615. .port = H8300_GPIO_P9,
  616. .rx = H8300_GPIO_B3,
  617. .tx = H8300_GPIO_B1,
  618. },
  619. { /* SCI2 */
  620. .port = H8300_GPIO_PB,
  621. .rx = H8300_GPIO_B7,
  622. .tx = H8300_GPIO_B6,
  623. }
  624. #elif defined(CONFIG_H8S2678)
  625. { /* SCI0 */
  626. .port = H8300_GPIO_P3,
  627. .rx = H8300_GPIO_B2,
  628. .tx = H8300_GPIO_B0,
  629. },
  630. { /* SCI1 */
  631. .port = H8300_GPIO_P3,
  632. .rx = H8300_GPIO_B3,
  633. .tx = H8300_GPIO_B1,
  634. },
  635. { /* SCI2 */
  636. .port = H8300_GPIO_P5,
  637. .rx = H8300_GPIO_B1,
  638. .tx = H8300_GPIO_B0,
  639. }
  640. #endif
  641. };
  642. #endif
  643. #if defined(CONFIG_CPU_SH7706) || \
  644. defined(CONFIG_CPU_SH7707) || \
  645. defined(CONFIG_CPU_SH7708) || \
  646. defined(CONFIG_CPU_SH7709)
  647. static inline int sci_rxd_in(struct uart_port *port)
  648. {
  649. if (port->mapbase == 0xfffffe80)
  650. return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
  651. return 1;
  652. }
  653. #elif defined(CONFIG_CPU_SH7750) || \
  654. defined(CONFIG_CPU_SH7751) || \
  655. defined(CONFIG_CPU_SH7751R) || \
  656. defined(CONFIG_CPU_SH7750R) || \
  657. defined(CONFIG_CPU_SH7750S) || \
  658. defined(CONFIG_CPU_SH7091)
  659. static inline int sci_rxd_in(struct uart_port *port)
  660. {
  661. if (port->mapbase == 0xffe00000)
  662. return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
  663. return 1;
  664. }
  665. #elif defined(__H8300H__) || defined(__H8300S__)
  666. static inline int sci_rxd_in(struct uart_port *port)
  667. {
  668. int ch = (port->mapbase - SMR0) >> 3;
  669. return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
  670. }
  671. #else /* default case for non-SCI processors */
  672. static inline int sci_rxd_in(struct uart_port *port)
  673. {
  674. return 1;
  675. }
  676. #endif
  677. /*
  678. * Values for the BitRate Register (SCBRR)
  679. *
  680. * The values are actually divisors for a frequency which can
  681. * be internal to the SH3 (14.7456MHz) or derived from an external
  682. * clock source. This driver assumes the internal clock is used;
  683. * to support using an external clock source, config options or
  684. * possibly command-line options would need to be added.
  685. *
  686. * Also, to support speeds below 2400 (why?) the lower 2 bits of
  687. * the SCSMR register would also need to be set to non-zero values.
  688. *
  689. * -- Greg Banks 27Feb2000
  690. *
  691. * Answer: The SCBRR register is only eight bits, and the value in
  692. * it gets larger with lower baud rates. At around 2400 (depending on
  693. * the peripherial module clock) you run out of bits. However the
  694. * lower two bits of SCSMR allow the module clock to be divided down,
  695. * scaling the value which is needed in SCBRR.
  696. *
  697. * -- Stuart Menefy - 23 May 2000
  698. *
  699. * I meant, why would anyone bother with bitrates below 2400.
  700. *
  701. * -- Greg Banks - 7Jul2000
  702. *
  703. * You "speedist"! How will I use my 110bps ASR-33 teletype with paper
  704. * tape reader as a console!
  705. *
  706. * -- Mitch Davis - 15 Jul 2000
  707. */
  708. #if (defined(CONFIG_CPU_SH7780) || \
  709. defined(CONFIG_CPU_SH7785) || \
  710. defined(CONFIG_CPU_SH7786)) && \
  711. !defined(CONFIG_SH_SH2007)
  712. #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
  713. #elif defined(CONFIG_CPU_SH7705) || \
  714. defined(CONFIG_CPU_SH7720) || \
  715. defined(CONFIG_CPU_SH7721) || \
  716. defined(CONFIG_ARCH_SH7367) || \
  717. defined(CONFIG_ARCH_SH7377) || \
  718. defined(CONFIG_ARCH_SH7372) || \
  719. defined(CONFIG_SH73A0) || \
  720. defined(CONFIG_R8A7740)
  721. #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
  722. #elif defined(CONFIG_CPU_SH7723) ||\
  723. defined(CONFIG_CPU_SH7724)
  724. static inline int scbrr_calc(struct uart_port *port, int bps, int clk)
  725. {
  726. if (port->type == PORT_SCIF)
  727. return (clk+16*bps)/(32*bps)-1;
  728. else
  729. return ((clk*2)+16*bps)/(16*bps)-1;
  730. }
  731. #define SCBRR_VALUE(bps, clk) scbrr_calc(port, bps, clk)
  732. #elif defined(__H8300H__) || defined(__H8300S__)
  733. #define SCBRR_VALUE(bps, clk) (((clk*1000/32)/bps)-1)
  734. #elif defined(CONFIG_R8A7790) || defined(CONFIG_R8A7791) || defined(CONFIG_R8A7792) || \
  735. defined(CONFIG_R8A7793) || defined(CONFIG_R8A7794)
  736. #define DL_VALUE(bps, clk) (clk / bps / 16) /* External Clock */
  737. #if defined(CONFIG_SCIF_A)
  738. #define SCBRR_VALUE(bps, clk) (clk / bps / 16 - 1) /* Internal Clock */
  739. #else
  740. #define SCBRR_VALUE(bps, clk) (clk / bps / 32 - 1) /* Internal Clock */
  741. #endif
  742. #else /* Generic SH */
  743. #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
  744. #endif
  745. #ifndef DL_VALUE
  746. #define DL_VALUE(bps, clk) 0
  747. #endif