serial_sh.h 27 KB

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