sh-sci.h 29 KB

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