sirfsoc_uart.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /*
  2. * Drivers for CSR SiRFprimaII onboard UARTs.
  3. *
  4. * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #include <linux/bitops.h>
  9. #include <linux/log2.h>
  10. #include <linux/hrtimer.h>
  11. struct sirfsoc_uart_param {
  12. const char *uart_name;
  13. const char *port_name;
  14. };
  15. struct sirfsoc_register {
  16. /* hardware uart specific */
  17. u32 sirfsoc_line_ctrl;
  18. u32 sirfsoc_divisor;
  19. /* uart - usp common */
  20. u32 sirfsoc_tx_rx_en;
  21. u32 sirfsoc_int_en_reg;
  22. u32 sirfsoc_int_st_reg;
  23. u32 sirfsoc_int_en_clr_reg;
  24. u32 sirfsoc_tx_dma_io_ctrl;
  25. u32 sirfsoc_tx_dma_io_len;
  26. u32 sirfsoc_tx_fifo_ctrl;
  27. u32 sirfsoc_tx_fifo_level_chk;
  28. u32 sirfsoc_tx_fifo_op;
  29. u32 sirfsoc_tx_fifo_status;
  30. u32 sirfsoc_tx_fifo_data;
  31. u32 sirfsoc_rx_dma_io_ctrl;
  32. u32 sirfsoc_rx_dma_io_len;
  33. u32 sirfsoc_rx_fifo_ctrl;
  34. u32 sirfsoc_rx_fifo_level_chk;
  35. u32 sirfsoc_rx_fifo_op;
  36. u32 sirfsoc_rx_fifo_status;
  37. u32 sirfsoc_rx_fifo_data;
  38. u32 sirfsoc_afc_ctrl;
  39. u32 sirfsoc_swh_dma_io;
  40. /* hardware usp specific */
  41. u32 sirfsoc_mode1;
  42. u32 sirfsoc_mode2;
  43. u32 sirfsoc_tx_frame_ctrl;
  44. u32 sirfsoc_rx_frame_ctrl;
  45. u32 sirfsoc_async_param_reg;
  46. };
  47. typedef u32 (*fifo_full_mask)(struct uart_port *port);
  48. typedef u32 (*fifo_empty_mask)(struct uart_port *port);
  49. struct sirfsoc_fifo_status {
  50. fifo_full_mask ff_full;
  51. fifo_empty_mask ff_empty;
  52. };
  53. struct sirfsoc_int_en {
  54. u32 sirfsoc_rx_done_en;
  55. u32 sirfsoc_tx_done_en;
  56. u32 sirfsoc_rx_oflow_en;
  57. u32 sirfsoc_tx_allout_en;
  58. u32 sirfsoc_rx_io_dma_en;
  59. u32 sirfsoc_tx_io_dma_en;
  60. u32 sirfsoc_rxfifo_full_en;
  61. u32 sirfsoc_txfifo_empty_en;
  62. u32 sirfsoc_rxfifo_thd_en;
  63. u32 sirfsoc_txfifo_thd_en;
  64. u32 sirfsoc_frm_err_en;
  65. u32 sirfsoc_rxd_brk_en;
  66. u32 sirfsoc_rx_timeout_en;
  67. u32 sirfsoc_parity_err_en;
  68. u32 sirfsoc_cts_en;
  69. u32 sirfsoc_rts_en;
  70. };
  71. struct sirfsoc_int_status {
  72. u32 sirfsoc_rx_done;
  73. u32 sirfsoc_tx_done;
  74. u32 sirfsoc_rx_oflow;
  75. u32 sirfsoc_tx_allout;
  76. u32 sirfsoc_rx_io_dma;
  77. u32 sirfsoc_tx_io_dma;
  78. u32 sirfsoc_rxfifo_full;
  79. u32 sirfsoc_txfifo_empty;
  80. u32 sirfsoc_rxfifo_thd;
  81. u32 sirfsoc_txfifo_thd;
  82. u32 sirfsoc_frm_err;
  83. u32 sirfsoc_rxd_brk;
  84. u32 sirfsoc_rx_timeout;
  85. u32 sirfsoc_parity_err;
  86. u32 sirfsoc_cts;
  87. u32 sirfsoc_rts;
  88. };
  89. enum sirfsoc_uart_type {
  90. SIRF_REAL_UART,
  91. SIRF_USP_UART,
  92. };
  93. struct sirfsoc_uart_register {
  94. struct sirfsoc_register uart_reg;
  95. struct sirfsoc_int_en uart_int_en;
  96. struct sirfsoc_int_status uart_int_st;
  97. struct sirfsoc_fifo_status fifo_status;
  98. struct sirfsoc_uart_param uart_param;
  99. enum sirfsoc_uart_type uart_type;
  100. };
  101. u32 uart_usp_ff_full_mask(struct uart_port *port)
  102. {
  103. u32 full_bit;
  104. full_bit = ilog2(port->fifosize);
  105. return (1 << full_bit);
  106. }
  107. u32 uart_usp_ff_empty_mask(struct uart_port *port)
  108. {
  109. u32 empty_bit;
  110. empty_bit = ilog2(port->fifosize) + 1;
  111. return (1 << empty_bit);
  112. }
  113. struct sirfsoc_uart_register sirfsoc_usp = {
  114. .uart_reg = {
  115. .sirfsoc_mode1 = 0x0000,
  116. .sirfsoc_mode2 = 0x0004,
  117. .sirfsoc_tx_frame_ctrl = 0x0008,
  118. .sirfsoc_rx_frame_ctrl = 0x000c,
  119. .sirfsoc_tx_rx_en = 0x0010,
  120. .sirfsoc_int_en_reg = 0x0014,
  121. .sirfsoc_int_st_reg = 0x0018,
  122. .sirfsoc_async_param_reg = 0x0024,
  123. .sirfsoc_tx_dma_io_ctrl = 0x0100,
  124. .sirfsoc_tx_dma_io_len = 0x0104,
  125. .sirfsoc_tx_fifo_ctrl = 0x0108,
  126. .sirfsoc_tx_fifo_level_chk = 0x010c,
  127. .sirfsoc_tx_fifo_op = 0x0110,
  128. .sirfsoc_tx_fifo_status = 0x0114,
  129. .sirfsoc_tx_fifo_data = 0x0118,
  130. .sirfsoc_rx_dma_io_ctrl = 0x0120,
  131. .sirfsoc_rx_dma_io_len = 0x0124,
  132. .sirfsoc_rx_fifo_ctrl = 0x0128,
  133. .sirfsoc_rx_fifo_level_chk = 0x012c,
  134. .sirfsoc_rx_fifo_op = 0x0130,
  135. .sirfsoc_rx_fifo_status = 0x0134,
  136. .sirfsoc_rx_fifo_data = 0x0138,
  137. .sirfsoc_int_en_clr_reg = 0x140,
  138. },
  139. .uart_int_en = {
  140. .sirfsoc_rx_done_en = BIT(0),
  141. .sirfsoc_tx_done_en = BIT(1),
  142. .sirfsoc_rx_oflow_en = BIT(2),
  143. .sirfsoc_tx_allout_en = BIT(3),
  144. .sirfsoc_rx_io_dma_en = BIT(4),
  145. .sirfsoc_tx_io_dma_en = BIT(5),
  146. .sirfsoc_rxfifo_full_en = BIT(6),
  147. .sirfsoc_txfifo_empty_en = BIT(7),
  148. .sirfsoc_rxfifo_thd_en = BIT(8),
  149. .sirfsoc_txfifo_thd_en = BIT(9),
  150. .sirfsoc_frm_err_en = BIT(10),
  151. .sirfsoc_rx_timeout_en = BIT(11),
  152. .sirfsoc_rxd_brk_en = BIT(15),
  153. },
  154. .uart_int_st = {
  155. .sirfsoc_rx_done = BIT(0),
  156. .sirfsoc_tx_done = BIT(1),
  157. .sirfsoc_rx_oflow = BIT(2),
  158. .sirfsoc_tx_allout = BIT(3),
  159. .sirfsoc_rx_io_dma = BIT(4),
  160. .sirfsoc_tx_io_dma = BIT(5),
  161. .sirfsoc_rxfifo_full = BIT(6),
  162. .sirfsoc_txfifo_empty = BIT(7),
  163. .sirfsoc_rxfifo_thd = BIT(8),
  164. .sirfsoc_txfifo_thd = BIT(9),
  165. .sirfsoc_frm_err = BIT(10),
  166. .sirfsoc_rx_timeout = BIT(11),
  167. .sirfsoc_rxd_brk = BIT(15),
  168. },
  169. .fifo_status = {
  170. .ff_full = uart_usp_ff_full_mask,
  171. .ff_empty = uart_usp_ff_empty_mask,
  172. },
  173. .uart_param = {
  174. .uart_name = "ttySiRF",
  175. .port_name = "sirfsoc-uart",
  176. },
  177. };
  178. struct sirfsoc_uart_register sirfsoc_uart = {
  179. .uart_reg = {
  180. .sirfsoc_line_ctrl = 0x0040,
  181. .sirfsoc_tx_rx_en = 0x004c,
  182. .sirfsoc_divisor = 0x0050,
  183. .sirfsoc_int_en_reg = 0x0054,
  184. .sirfsoc_int_st_reg = 0x0058,
  185. .sirfsoc_int_en_clr_reg = 0x0060,
  186. .sirfsoc_tx_dma_io_ctrl = 0x0100,
  187. .sirfsoc_tx_dma_io_len = 0x0104,
  188. .sirfsoc_tx_fifo_ctrl = 0x0108,
  189. .sirfsoc_tx_fifo_level_chk = 0x010c,
  190. .sirfsoc_tx_fifo_op = 0x0110,
  191. .sirfsoc_tx_fifo_status = 0x0114,
  192. .sirfsoc_tx_fifo_data = 0x0118,
  193. .sirfsoc_rx_dma_io_ctrl = 0x0120,
  194. .sirfsoc_rx_dma_io_len = 0x0124,
  195. .sirfsoc_rx_fifo_ctrl = 0x0128,
  196. .sirfsoc_rx_fifo_level_chk = 0x012c,
  197. .sirfsoc_rx_fifo_op = 0x0130,
  198. .sirfsoc_rx_fifo_status = 0x0134,
  199. .sirfsoc_rx_fifo_data = 0x0138,
  200. .sirfsoc_afc_ctrl = 0x0140,
  201. .sirfsoc_swh_dma_io = 0x0148,
  202. },
  203. .uart_int_en = {
  204. .sirfsoc_rx_done_en = BIT(0),
  205. .sirfsoc_tx_done_en = BIT(1),
  206. .sirfsoc_rx_oflow_en = BIT(2),
  207. .sirfsoc_tx_allout_en = BIT(3),
  208. .sirfsoc_rx_io_dma_en = BIT(4),
  209. .sirfsoc_tx_io_dma_en = BIT(5),
  210. .sirfsoc_rxfifo_full_en = BIT(6),
  211. .sirfsoc_txfifo_empty_en = BIT(7),
  212. .sirfsoc_rxfifo_thd_en = BIT(8),
  213. .sirfsoc_txfifo_thd_en = BIT(9),
  214. .sirfsoc_frm_err_en = BIT(10),
  215. .sirfsoc_rxd_brk_en = BIT(11),
  216. .sirfsoc_rx_timeout_en = BIT(12),
  217. .sirfsoc_parity_err_en = BIT(13),
  218. .sirfsoc_cts_en = BIT(14),
  219. .sirfsoc_rts_en = BIT(15),
  220. },
  221. .uart_int_st = {
  222. .sirfsoc_rx_done = BIT(0),
  223. .sirfsoc_tx_done = BIT(1),
  224. .sirfsoc_rx_oflow = BIT(2),
  225. .sirfsoc_tx_allout = BIT(3),
  226. .sirfsoc_rx_io_dma = BIT(4),
  227. .sirfsoc_tx_io_dma = BIT(5),
  228. .sirfsoc_rxfifo_full = BIT(6),
  229. .sirfsoc_txfifo_empty = BIT(7),
  230. .sirfsoc_rxfifo_thd = BIT(8),
  231. .sirfsoc_txfifo_thd = BIT(9),
  232. .sirfsoc_frm_err = BIT(10),
  233. .sirfsoc_rxd_brk = BIT(11),
  234. .sirfsoc_rx_timeout = BIT(12),
  235. .sirfsoc_parity_err = BIT(13),
  236. .sirfsoc_cts = BIT(14),
  237. .sirfsoc_rts = BIT(15),
  238. },
  239. .fifo_status = {
  240. .ff_full = uart_usp_ff_full_mask,
  241. .ff_empty = uart_usp_ff_empty_mask,
  242. },
  243. .uart_param = {
  244. .uart_name = "ttySiRF",
  245. .port_name = "sirfsoc_uart",
  246. },
  247. };
  248. /* uart io ctrl */
  249. #define SIRFUART_DATA_BIT_LEN_MASK 0x3
  250. #define SIRFUART_DATA_BIT_LEN_5 BIT(0)
  251. #define SIRFUART_DATA_BIT_LEN_6 1
  252. #define SIRFUART_DATA_BIT_LEN_7 2
  253. #define SIRFUART_DATA_BIT_LEN_8 3
  254. #define SIRFUART_STOP_BIT_LEN_1 0
  255. #define SIRFUART_STOP_BIT_LEN_2 BIT(2)
  256. #define SIRFUART_PARITY_EN BIT(3)
  257. #define SIRFUART_EVEN_BIT BIT(4)
  258. #define SIRFUART_STICK_BIT_MASK (7 << 3)
  259. #define SIRFUART_STICK_BIT_NONE (0 << 3)
  260. #define SIRFUART_STICK_BIT_EVEN BIT(3)
  261. #define SIRFUART_STICK_BIT_ODD (3 << 3)
  262. #define SIRFUART_STICK_BIT_MARK (5 << 3)
  263. #define SIRFUART_STICK_BIT_SPACE (7 << 3)
  264. #define SIRFUART_SET_BREAK BIT(6)
  265. #define SIRFUART_LOOP_BACK BIT(7)
  266. #define SIRFUART_PARITY_MASK (7 << 3)
  267. #define SIRFUART_DUMMY_READ BIT(16)
  268. #define SIRFUART_AFC_CTRL_RX_THD 0x70
  269. #define SIRFUART_AFC_RX_EN BIT(8)
  270. #define SIRFUART_AFC_TX_EN BIT(9)
  271. #define SIRFUART_AFC_CTS_CTRL BIT(10)
  272. #define SIRFUART_AFC_RTS_CTRL BIT(11)
  273. #define SIRFUART_AFC_CTS_STATUS BIT(12)
  274. #define SIRFUART_AFC_RTS_STATUS BIT(13)
  275. /* UART FIFO Register */
  276. #define SIRFUART_FIFO_STOP 0x0
  277. #define SIRFUART_FIFO_RESET BIT(0)
  278. #define SIRFUART_FIFO_START BIT(1)
  279. #define SIRFUART_RX_EN BIT(0)
  280. #define SIRFUART_TX_EN BIT(1)
  281. #define SIRFUART_IO_MODE BIT(0)
  282. #define SIRFUART_DMA_MODE 0x0
  283. #define SIRFUART_RX_DMA_FLUSH 0x4
  284. #define SIRFUART_CLEAR_RX_ADDR_EN 0x2
  285. /* Baud Rate Calculation */
  286. #define SIRF_USP_MIN_SAMPLE_DIV 0x1
  287. #define SIRF_MIN_SAMPLE_DIV 0xf
  288. #define SIRF_MAX_SAMPLE_DIV 0x3f
  289. #define SIRF_IOCLK_DIV_MAX 0xffff
  290. #define SIRF_SAMPLE_DIV_SHIFT 16
  291. #define SIRF_IOCLK_DIV_MASK 0xffff
  292. #define SIRF_SAMPLE_DIV_MASK 0x3f0000
  293. #define SIRF_BAUD_RATE_SUPPORT_NR 18
  294. /* USP SPEC */
  295. #define SIRFSOC_USP_ENDIAN_CTRL_LSBF BIT(4)
  296. #define SIRFSOC_USP_EN BIT(5)
  297. #define SIRFSOC_USP_MODE2_RXD_DELAY_OFFSET 0
  298. #define SIRFSOC_USP_MODE2_TXD_DELAY_OFFSET 8
  299. #define SIRFSOC_USP_MODE2_CLK_DIVISOR_MASK 0x3ff
  300. #define SIRFSOC_USP_MODE2_CLK_DIVISOR_OFFSET 21
  301. #define SIRFSOC_USP_TX_DATA_LEN_OFFSET 0
  302. #define SIRFSOC_USP_TX_SYNC_LEN_OFFSET 8
  303. #define SIRFSOC_USP_TX_FRAME_LEN_OFFSET 16
  304. #define SIRFSOC_USP_TX_SHIFTER_LEN_OFFSET 24
  305. #define SIRFSOC_USP_TX_CLK_DIVISOR_OFFSET 30
  306. #define SIRFSOC_USP_RX_DATA_LEN_OFFSET 0
  307. #define SIRFSOC_USP_RX_FRAME_LEN_OFFSET 8
  308. #define SIRFSOC_USP_RX_SHIFTER_LEN_OFFSET 16
  309. #define SIRFSOC_USP_RX_CLK_DIVISOR_OFFSET 24
  310. #define SIRFSOC_USP_ASYNC_DIV2_MASK 0x3f
  311. #define SIRFSOC_USP_ASYNC_DIV2_OFFSET 16
  312. #define SIRFSOC_USP_LOOP_BACK_CTRL BIT(2)
  313. #define SIRFSOC_USP_FRADDR_CLR_EN BIT(1)
  314. /* USP-UART Common */
  315. #define SIRFSOC_UART_RX_TIMEOUT(br, to) (((br) * (((to) + 999) / 1000)) / 1000)
  316. #define SIRFUART_RECV_TIMEOUT_VALUE(x) \
  317. (((x) > 0xFFFF) ? 0xFFFF : ((x) & 0xFFFF))
  318. #define SIRFUART_USP_RECV_TIMEOUT(x) (x & 0xFFFF)
  319. #define SIRFUART_UART_RECV_TIMEOUT(x) ((x & 0xFFFF) << 16)
  320. #define SIRFUART_FIFO_THD(port) (port->fifosize >> 1)
  321. #define SIRFUART_ERR_INT_STAT(unit_st, uart_type) \
  322. (uint_st->sirfsoc_rx_oflow | \
  323. uint_st->sirfsoc_frm_err | \
  324. uint_st->sirfsoc_rxd_brk | \
  325. ((uart_type != SIRF_REAL_UART) ? \
  326. 0 : uint_st->sirfsoc_parity_err))
  327. #define SIRFUART_RX_IO_INT_EN(uint_en, uart_type) \
  328. (uint_en->sirfsoc_rx_done_en |\
  329. uint_en->sirfsoc_rxfifo_thd_en |\
  330. uint_en->sirfsoc_rxfifo_full_en |\
  331. uint_en->sirfsoc_frm_err_en |\
  332. uint_en->sirfsoc_rx_oflow_en |\
  333. uint_en->sirfsoc_rxd_brk_en |\
  334. ((uart_type != SIRF_REAL_UART) ? \
  335. 0 : uint_en->sirfsoc_parity_err_en))
  336. #define SIRFUART_RX_IO_INT_ST(uint_st) \
  337. (uint_st->sirfsoc_rxfifo_thd |\
  338. uint_st->sirfsoc_rxfifo_full|\
  339. uint_st->sirfsoc_rx_done |\
  340. uint_st->sirfsoc_rx_timeout)
  341. #define SIRFUART_CTS_INT_ST(uint_st) (uint_st->sirfsoc_cts)
  342. #define SIRFUART_RX_DMA_INT_EN(uint_en, uart_type) \
  343. (uint_en->sirfsoc_frm_err_en |\
  344. uint_en->sirfsoc_rx_oflow_en |\
  345. uint_en->sirfsoc_rxd_brk_en |\
  346. ((uart_type != SIRF_REAL_UART) ? \
  347. 0 : uint_en->sirfsoc_parity_err_en))
  348. /* Generic Definitions */
  349. #define SIRFSOC_UART_NAME "ttySiRF"
  350. #define SIRFSOC_UART_MAJOR 0
  351. #define SIRFSOC_UART_MINOR 0
  352. #define SIRFUART_PORT_NAME "sirfsoc-uart"
  353. #define SIRFUART_MAP_SIZE 0x200
  354. #define SIRFSOC_UART_NR 11
  355. #define SIRFSOC_PORT_TYPE 0xa5
  356. /* Uart Common Use Macro*/
  357. #define SIRFSOC_RX_DMA_BUF_SIZE (1024 * 32)
  358. #define BYTES_TO_ALIGN(dma_addr) ((unsigned long)(dma_addr) & 0x3)
  359. /* Uart Fifo Level Chk */
  360. #define SIRFUART_TX_FIFO_SC_OFFSET 0
  361. #define SIRFUART_TX_FIFO_LC_OFFSET 10
  362. #define SIRFUART_TX_FIFO_HC_OFFSET 20
  363. #define SIRFUART_TX_FIFO_CHK_SC(line, value) ((((line) == 1) ? (value & 0x3) :\
  364. (value & 0x1f)) << SIRFUART_TX_FIFO_SC_OFFSET)
  365. #define SIRFUART_TX_FIFO_CHK_LC(line, value) ((((line) == 1) ? (value & 0x3) :\
  366. (value & 0x1f)) << SIRFUART_TX_FIFO_LC_OFFSET)
  367. #define SIRFUART_TX_FIFO_CHK_HC(line, value) ((((line) == 1) ? (value & 0x3) :\
  368. (value & 0x1f)) << SIRFUART_TX_FIFO_HC_OFFSET)
  369. #define SIRFUART_RX_FIFO_CHK_SC SIRFUART_TX_FIFO_CHK_SC
  370. #define SIRFUART_RX_FIFO_CHK_LC SIRFUART_TX_FIFO_CHK_LC
  371. #define SIRFUART_RX_FIFO_CHK_HC SIRFUART_TX_FIFO_CHK_HC
  372. #define SIRFUART_RX_FIFO_MASK 0x7f
  373. /* Indicate how many buffers used */
  374. /* For Fast Baud Rate Calculation */
  375. struct sirfsoc_baudrate_to_regv {
  376. unsigned int baud_rate;
  377. unsigned int reg_val;
  378. };
  379. enum sirfsoc_tx_state {
  380. TX_DMA_IDLE,
  381. TX_DMA_RUNNING,
  382. TX_DMA_PAUSE,
  383. };
  384. struct sirfsoc_rx_buffer {
  385. struct circ_buf xmit;
  386. dma_cookie_t cookie;
  387. struct dma_async_tx_descriptor *desc;
  388. dma_addr_t dma_addr;
  389. };
  390. struct sirfsoc_uart_port {
  391. bool hw_flow_ctrl;
  392. bool ms_enabled;
  393. struct uart_port port;
  394. struct clk *clk;
  395. /* for SiRFatlas7, there are SET/CLR for UART_INT_EN */
  396. bool is_atlas7;
  397. struct sirfsoc_uart_register *uart_reg;
  398. struct dma_chan *rx_dma_chan;
  399. struct dma_chan *tx_dma_chan;
  400. dma_addr_t tx_dma_addr;
  401. struct dma_async_tx_descriptor *tx_dma_desc;
  402. unsigned long transfer_size;
  403. enum sirfsoc_tx_state tx_dma_state;
  404. unsigned int cts_gpio;
  405. unsigned int rts_gpio;
  406. struct sirfsoc_rx_buffer rx_dma_items;
  407. struct hrtimer hrt;
  408. bool is_hrt_enabled;
  409. unsigned long rx_period_time;
  410. unsigned long rx_last_pos;
  411. unsigned long pio_fetch_cnt;
  412. };
  413. /* Register Access Control */
  414. #define portaddr(port, reg) ((port)->membase + (reg))
  415. #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg)))
  416. #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg))
  417. /* UART Port Mask */
  418. #define SIRFUART_FIFOLEVEL_MASK(port) ((port->fifosize - 1) & 0xFFF)
  419. #define SIRFUART_FIFOFULL_MASK(port) (port->fifosize & 0xFFF)
  420. #define SIRFUART_FIFOEMPTY_MASK(port) ((port->fifosize & 0xFFF) << 1)