max3107.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. /*
  2. * max3107.h - spi uart protocol driver header for Maxim 3107
  3. *
  4. * Copyright (C) Aavamobile 2009
  5. * Based on serial_max3100.h by Christian Pellegrin
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef _MAX3107_H
  13. #define _MAX3107_H
  14. /* Serial error status definitions */
  15. #define MAX3107_PARITY_ERROR 1
  16. #define MAX3107_FRAME_ERROR 2
  17. #define MAX3107_OVERRUN_ERROR 4
  18. #define MAX3107_ALL_ERRORS (MAX3107_PARITY_ERROR | \
  19. MAX3107_FRAME_ERROR | \
  20. MAX3107_OVERRUN_ERROR)
  21. /* GPIO definitions */
  22. #define MAX3107_GPIO_BASE 88
  23. #define MAX3107_GPIO_COUNT 4
  24. /* GPIO connected to chip's reset pin */
  25. #define MAX3107_RESET_GPIO 87
  26. /* Chip reset delay */
  27. #define MAX3107_RESET_DELAY 10
  28. /* Chip wakeup delay */
  29. #define MAX3107_WAKEUP_DELAY 50
  30. /* Sleep mode definitions */
  31. #define MAX3107_DISABLE_FORCED_SLEEP 0
  32. #define MAX3107_ENABLE_FORCED_SLEEP 1
  33. #define MAX3107_DISABLE_AUTOSLEEP 2
  34. #define MAX3107_ENABLE_AUTOSLEEP 3
  35. /* Definitions for register access with SPI transfers
  36. *
  37. * SPI transfer format:
  38. *
  39. * Master to slave bits xzzzzzzzyyyyyyyy
  40. * Slave to master bits aaaaaaaabbbbbbbb
  41. *
  42. * where:
  43. * x = 0 for reads, 1 for writes
  44. * z = register address
  45. * y = new register value if write, 0 if read
  46. * a = unspecified
  47. * b = register value if read, unspecified if write
  48. */
  49. /* SPI speed */
  50. #define MAX3107_SPI_SPEED (3125000 * 2)
  51. /* Write bit */
  52. #define MAX3107_WRITE_BIT (1 << 15)
  53. /* SPI TX data mask */
  54. #define MAX3107_SPI_RX_DATA_MASK (0x00ff)
  55. /* SPI RX data mask */
  56. #define MAX3107_SPI_TX_DATA_MASK (0x00ff)
  57. /* Register access masks */
  58. #define MAX3107_RHR_REG (0x0000) /* RX FIFO */
  59. #define MAX3107_THR_REG (0x0000) /* TX FIFO */
  60. #define MAX3107_IRQEN_REG (0x0100) /* IRQ enable */
  61. #define MAX3107_IRQSTS_REG (0x0200) /* IRQ status */
  62. #define MAX3107_LSR_IRQEN_REG (0x0300) /* LSR IRQ enable */
  63. #define MAX3107_LSR_IRQSTS_REG (0x0400) /* LSR IRQ status */
  64. #define MAX3107_SPCHR_IRQEN_REG (0x0500) /* Special char IRQ enable */
  65. #define MAX3107_SPCHR_IRQSTS_REG (0x0600) /* Special char IRQ status */
  66. #define MAX3107_STS_IRQEN_REG (0x0700) /* Status IRQ enable */
  67. #define MAX3107_STS_IRQSTS_REG (0x0800) /* Status IRQ status */
  68. #define MAX3107_MODE1_REG (0x0900) /* MODE1 */
  69. #define MAX3107_MODE2_REG (0x0a00) /* MODE2 */
  70. #define MAX3107_LCR_REG (0x0b00) /* LCR */
  71. #define MAX3107_RXTO_REG (0x0c00) /* RX timeout */
  72. #define MAX3107_HDPIXDELAY_REG (0x0d00) /* Auto transceiver delays */
  73. #define MAX3107_IRDA_REG (0x0e00) /* IRDA settings */
  74. #define MAX3107_FLOWLVL_REG (0x0f00) /* Flow control levels */
  75. #define MAX3107_FIFOTRIGLVL_REG (0x1000) /* FIFO IRQ trigger levels */
  76. #define MAX3107_TXFIFOLVL_REG (0x1100) /* TX FIFO level */
  77. #define MAX3107_RXFIFOLVL_REG (0x1200) /* RX FIFO level */
  78. #define MAX3107_FLOWCTRL_REG (0x1300) /* Flow control */
  79. #define MAX3107_XON1_REG (0x1400) /* XON1 character */
  80. #define MAX3107_XON2_REG (0x1500) /* XON2 character */
  81. #define MAX3107_XOFF1_REG (0x1600) /* XOFF1 character */
  82. #define MAX3107_XOFF2_REG (0x1700) /* XOFF2 character */
  83. #define MAX3107_GPIOCFG_REG (0x1800) /* GPIO config */
  84. #define MAX3107_GPIODATA_REG (0x1900) /* GPIO data */
  85. #define MAX3107_PLLCFG_REG (0x1a00) /* PLL config */
  86. #define MAX3107_BRGCFG_REG (0x1b00) /* Baud rate generator conf */
  87. #define MAX3107_BRGDIVLSB_REG (0x1c00) /* Baud rate divisor LSB */
  88. #define MAX3107_BRGDIVMSB_REG (0x1d00) /* Baud rate divisor MSB */
  89. #define MAX3107_CLKSRC_REG (0x1e00) /* Clock source */
  90. #define MAX3107_REVID_REG (0x1f00) /* Revision identification */
  91. /* IRQ register bits */
  92. #define MAX3107_IRQ_LSR_BIT (1 << 0) /* LSR interrupt */
  93. #define MAX3107_IRQ_SPCHR_BIT (1 << 1) /* Special char interrupt */
  94. #define MAX3107_IRQ_STS_BIT (1 << 2) /* Status interrupt */
  95. #define MAX3107_IRQ_RXFIFO_BIT (1 << 3) /* RX FIFO interrupt */
  96. #define MAX3107_IRQ_TXFIFO_BIT (1 << 4) /* TX FIFO interrupt */
  97. #define MAX3107_IRQ_TXEMPTY_BIT (1 << 5) /* TX FIFO empty interrupt */
  98. #define MAX3107_IRQ_RXEMPTY_BIT (1 << 6) /* RX FIFO empty interrupt */
  99. #define MAX3107_IRQ_CTS_BIT (1 << 7) /* CTS interrupt */
  100. /* LSR register bits */
  101. #define MAX3107_LSR_RXTO_BIT (1 << 0) /* RX timeout */
  102. #define MAX3107_LSR_RXOVR_BIT (1 << 1) /* RX overrun */
  103. #define MAX3107_LSR_RXPAR_BIT (1 << 2) /* RX parity error */
  104. #define MAX3107_LSR_FRERR_BIT (1 << 3) /* Frame error */
  105. #define MAX3107_LSR_RXBRK_BIT (1 << 4) /* RX break */
  106. #define MAX3107_LSR_RXNOISE_BIT (1 << 5) /* RX noise */
  107. #define MAX3107_LSR_UNDEF6_BIT (1 << 6) /* Undefined/not used */
  108. #define MAX3107_LSR_CTS_BIT (1 << 7) /* CTS pin state */
  109. /* Special character register bits */
  110. #define MAX3107_SPCHR_XON1_BIT (1 << 0) /* XON1 character */
  111. #define MAX3107_SPCHR_XON2_BIT (1 << 1) /* XON2 character */
  112. #define MAX3107_SPCHR_XOFF1_BIT (1 << 2) /* XOFF1 character */
  113. #define MAX3107_SPCHR_XOFF2_BIT (1 << 3) /* XOFF2 character */
  114. #define MAX3107_SPCHR_BREAK_BIT (1 << 4) /* RX break */
  115. #define MAX3107_SPCHR_MULTIDROP_BIT (1 << 5) /* 9-bit multidrop addr char */
  116. #define MAX3107_SPCHR_UNDEF6_BIT (1 << 6) /* Undefined/not used */
  117. #define MAX3107_SPCHR_UNDEF7_BIT (1 << 7) /* Undefined/not used */
  118. /* Status register bits */
  119. #define MAX3107_STS_GPIO0_BIT (1 << 0) /* GPIO 0 interrupt */
  120. #define MAX3107_STS_GPIO1_BIT (1 << 1) /* GPIO 1 interrupt */
  121. #define MAX3107_STS_GPIO2_BIT (1 << 2) /* GPIO 2 interrupt */
  122. #define MAX3107_STS_GPIO3_BIT (1 << 3) /* GPIO 3 interrupt */
  123. #define MAX3107_STS_UNDEF4_BIT (1 << 4) /* Undefined/not used */
  124. #define MAX3107_STS_CLKREADY_BIT (1 << 5) /* Clock ready */
  125. #define MAX3107_STS_SLEEP_BIT (1 << 6) /* Sleep interrupt */
  126. #define MAX3107_STS_UNDEF7_BIT (1 << 7) /* Undefined/not used */
  127. /* MODE1 register bits */
  128. #define MAX3107_MODE1_RXDIS_BIT (1 << 0) /* RX disable */
  129. #define MAX3107_MODE1_TXDIS_BIT (1 << 1) /* TX disable */
  130. #define MAX3107_MODE1_TXHIZ_BIT (1 << 2) /* TX pin three-state */
  131. #define MAX3107_MODE1_RTSHIZ_BIT (1 << 3) /* RTS pin three-state */
  132. #define MAX3107_MODE1_TRNSCVCTRL_BIT (1 << 4) /* Transceiver ctrl enable */
  133. #define MAX3107_MODE1_FORCESLEEP_BIT (1 << 5) /* Force sleep mode */
  134. #define MAX3107_MODE1_AUTOSLEEP_BIT (1 << 6) /* Auto sleep enable */
  135. #define MAX3107_MODE1_IRQSEL_BIT (1 << 7) /* IRQ pin enable */
  136. /* MODE2 register bits */
  137. #define MAX3107_MODE2_RST_BIT (1 << 0) /* Chip reset */
  138. #define MAX3107_MODE2_FIFORST_BIT (1 << 1) /* FIFO reset */
  139. #define MAX3107_MODE2_RXTRIGINV_BIT (1 << 2) /* RX FIFO INT invert */
  140. #define MAX3107_MODE2_RXEMPTINV_BIT (1 << 3) /* RX FIFO empty INT invert */
  141. #define MAX3107_MODE2_SPCHR_BIT (1 << 4) /* Special chr detect enable */
  142. #define MAX3107_MODE2_LOOPBACK_BIT (1 << 5) /* Internal loopback enable */
  143. #define MAX3107_MODE2_MULTIDROP_BIT (1 << 6) /* 9-bit multidrop enable */
  144. #define MAX3107_MODE2_ECHOSUPR_BIT (1 << 7) /* ECHO suppression enable */
  145. /* LCR register bits */
  146. #define MAX3107_LCR_LENGTH0_BIT (1 << 0) /* Word length bit 0 */
  147. #define MAX3107_LCR_LENGTH1_BIT (1 << 1) /* Word length bit 1
  148. *
  149. * Word length bits table:
  150. * 00 -> 5 bit words
  151. * 01 -> 6 bit words
  152. * 10 -> 7 bit words
  153. * 11 -> 8 bit words
  154. */
  155. #define MAX3107_LCR_STOPLEN_BIT (1 << 2) /* STOP length bit
  156. *
  157. * STOP length bit table:
  158. * 0 -> 1 stop bit
  159. * 1 -> 1-1.5 stop bits if
  160. * word length is 5,
  161. * 2 stop bits otherwise
  162. */
  163. #define MAX3107_LCR_PARITY_BIT (1 << 3) /* Parity bit enable */
  164. #define MAX3107_LCR_EVENPARITY_BIT (1 << 4) /* Even parity bit enable */
  165. #define MAX3107_LCR_FORCEPARITY_BIT (1 << 5) /* 9-bit multidrop parity */
  166. #define MAX3107_LCR_TXBREAK_BIT (1 << 6) /* TX break enable */
  167. #define MAX3107_LCR_RTS_BIT (1 << 7) /* RTS pin control */
  168. #define MAX3107_LCR_WORD_LEN_5 (0x0000)
  169. #define MAX3107_LCR_WORD_LEN_6 (0x0001)
  170. #define MAX3107_LCR_WORD_LEN_7 (0x0002)
  171. #define MAX3107_LCR_WORD_LEN_8 (0x0003)
  172. /* IRDA register bits */
  173. #define MAX3107_IRDA_IRDAEN_BIT (1 << 0) /* IRDA mode enable */
  174. #define MAX3107_IRDA_SIR_BIT (1 << 1) /* SIR mode enable */
  175. #define MAX3107_IRDA_SHORTIR_BIT (1 << 2) /* Short SIR mode enable */
  176. #define MAX3107_IRDA_MIR_BIT (1 << 3) /* MIR mode enable */
  177. #define MAX3107_IRDA_RXINV_BIT (1 << 4) /* RX logic inversion enable */
  178. #define MAX3107_IRDA_TXINV_BIT (1 << 5) /* TX logic inversion enable */
  179. #define MAX3107_IRDA_UNDEF6_BIT (1 << 6) /* Undefined/not used */
  180. #define MAX3107_IRDA_UNDEF7_BIT (1 << 7) /* Undefined/not used */
  181. /* Flow control trigger level register masks */
  182. #define MAX3107_FLOWLVL_HALT_MASK (0x000f) /* Flow control halt level */
  183. #define MAX3107_FLOWLVL_RES_MASK (0x00f0) /* Flow control resume level */
  184. #define MAX3107_FLOWLVL_HALT(words) ((words/8) & 0x000f)
  185. #define MAX3107_FLOWLVL_RES(words) (((words/8) & 0x000f) << 4)
  186. /* FIFO interrupt trigger level register masks */
  187. #define MAX3107_FIFOTRIGLVL_TX_MASK (0x000f) /* TX FIFO trigger level */
  188. #define MAX3107_FIFOTRIGLVL_RX_MASK (0x00f0) /* RX FIFO trigger level */
  189. #define MAX3107_FIFOTRIGLVL_TX(words) ((words/8) & 0x000f)
  190. #define MAX3107_FIFOTRIGLVL_RX(words) (((words/8) & 0x000f) << 4)
  191. /* Flow control register bits */
  192. #define MAX3107_FLOWCTRL_AUTORTS_BIT (1 << 0) /* Auto RTS flow ctrl enable */
  193. #define MAX3107_FLOWCTRL_AUTOCTS_BIT (1 << 1) /* Auto CTS flow ctrl enable */
  194. #define MAX3107_FLOWCTRL_GPIADDR_BIT (1 << 2) /* Enables that GPIO inputs
  195. * are used in conjunction with
  196. * XOFF2 for definition of
  197. * special character */
  198. #define MAX3107_FLOWCTRL_SWFLOWEN_BIT (1 << 3) /* Auto SW flow ctrl enable */
  199. #define MAX3107_FLOWCTRL_SWFLOW0_BIT (1 << 4) /* SWFLOW bit 0 */
  200. #define MAX3107_FLOWCTRL_SWFLOW1_BIT (1 << 5) /* SWFLOW bit 1
  201. *
  202. * SWFLOW bits 1 & 0 table:
  203. * 00 -> no transmitter flow
  204. * control
  205. * 01 -> receiver compares
  206. * XON2 and XOFF2
  207. * and controls
  208. * transmitter
  209. * 10 -> receiver compares
  210. * XON1 and XOFF1
  211. * and controls
  212. * transmitter
  213. * 11 -> receiver compares
  214. * XON1, XON2, XOFF1 and
  215. * XOFF2 and controls
  216. * transmitter
  217. */
  218. #define MAX3107_FLOWCTRL_SWFLOW2_BIT (1 << 6) /* SWFLOW bit 2 */
  219. #define MAX3107_FLOWCTRL_SWFLOW3_BIT (1 << 7) /* SWFLOW bit 3
  220. *
  221. * SWFLOW bits 3 & 2 table:
  222. * 00 -> no received flow
  223. * control
  224. * 01 -> transmitter generates
  225. * XON2 and XOFF2
  226. * 10 -> transmitter generates
  227. * XON1 and XOFF1
  228. * 11 -> transmitter generates
  229. * XON1, XON2, XOFF1 and
  230. * XOFF2
  231. */
  232. /* GPIO configuration register bits */
  233. #define MAX3107_GPIOCFG_GP0OUT_BIT (1 << 0) /* GPIO 0 output enable */
  234. #define MAX3107_GPIOCFG_GP1OUT_BIT (1 << 1) /* GPIO 1 output enable */
  235. #define MAX3107_GPIOCFG_GP2OUT_BIT (1 << 2) /* GPIO 2 output enable */
  236. #define MAX3107_GPIOCFG_GP3OUT_BIT (1 << 3) /* GPIO 3 output enable */
  237. #define MAX3107_GPIOCFG_GP0OD_BIT (1 << 4) /* GPIO 0 open-drain enable */
  238. #define MAX3107_GPIOCFG_GP1OD_BIT (1 << 5) /* GPIO 1 open-drain enable */
  239. #define MAX3107_GPIOCFG_GP2OD_BIT (1 << 6) /* GPIO 2 open-drain enable */
  240. #define MAX3107_GPIOCFG_GP3OD_BIT (1 << 7) /* GPIO 3 open-drain enable */
  241. /* GPIO DATA register bits */
  242. #define MAX3107_GPIODATA_GP0OUT_BIT (1 << 0) /* GPIO 0 output value */
  243. #define MAX3107_GPIODATA_GP1OUT_BIT (1 << 1) /* GPIO 1 output value */
  244. #define MAX3107_GPIODATA_GP2OUT_BIT (1 << 2) /* GPIO 2 output value */
  245. #define MAX3107_GPIODATA_GP3OUT_BIT (1 << 3) /* GPIO 3 output value */
  246. #define MAX3107_GPIODATA_GP0IN_BIT (1 << 4) /* GPIO 0 input value */
  247. #define MAX3107_GPIODATA_GP1IN_BIT (1 << 5) /* GPIO 1 input value */
  248. #define MAX3107_GPIODATA_GP2IN_BIT (1 << 6) /* GPIO 2 input value */
  249. #define MAX3107_GPIODATA_GP3IN_BIT (1 << 7) /* GPIO 3 input value */
  250. /* PLL configuration register masks */
  251. #define MAX3107_PLLCFG_PREDIV_MASK (0x003f) /* PLL predivision value */
  252. #define MAX3107_PLLCFG_PLLFACTOR_MASK (0x00c0) /* PLL multiplication factor */
  253. /* Baud rate generator configuration register masks and bits */
  254. #define MAX3107_BRGCFG_FRACT_MASK (0x000f) /* Fractional portion of
  255. * Baud rate generator divisor
  256. */
  257. #define MAX3107_BRGCFG_2XMODE_BIT (1 << 4) /* Double baud rate */
  258. #define MAX3107_BRGCFG_4XMODE_BIT (1 << 5) /* Quadruple baud rate */
  259. #define MAX3107_BRGCFG_UNDEF6_BIT (1 << 6) /* Undefined/not used */
  260. #define MAX3107_BRGCFG_UNDEF7_BIT (1 << 7) /* Undefined/not used */
  261. /* Clock source register bits */
  262. #define MAX3107_CLKSRC_INTOSC_BIT (1 << 0) /* Internal osc enable */
  263. #define MAX3107_CLKSRC_CRYST_BIT (1 << 1) /* Crystal osc enable */
  264. #define MAX3107_CLKSRC_PLL_BIT (1 << 2) /* PLL enable */
  265. #define MAX3107_CLKSRC_PLLBYP_BIT (1 << 3) /* PLL bypass */
  266. #define MAX3107_CLKSRC_EXTCLK_BIT (1 << 4) /* External clock enable */
  267. #define MAX3107_CLKSRC_UNDEF5_BIT (1 << 5) /* Undefined/not used */
  268. #define MAX3107_CLKSRC_UNDEF6_BIT (1 << 6) /* Undefined/not used */
  269. #define MAX3107_CLKSRC_CLK2RTS_BIT (1 << 7) /* Baud clk to RTS pin */
  270. /* HW definitions */
  271. #define MAX3107_RX_FIFO_SIZE 128
  272. #define MAX3107_TX_FIFO_SIZE 128
  273. #define MAX3107_REVID1 0x00a0
  274. #define MAX3107_REVID2 0x00a1
  275. /* Baud rate generator configuration values for external clock 13MHz */
  276. #define MAX3107_BRG13_B300 (0x0A9400 | 0x05)
  277. #define MAX3107_BRG13_B600 (0x054A00 | 0x03)
  278. #define MAX3107_BRG13_B1200 (0x02A500 | 0x01)
  279. #define MAX3107_BRG13_B2400 (0x015200 | 0x09)
  280. #define MAX3107_BRG13_B4800 (0x00A900 | 0x04)
  281. #define MAX3107_BRG13_B9600 (0x005400 | 0x0A)
  282. #define MAX3107_BRG13_B19200 (0x002A00 | 0x05)
  283. #define MAX3107_BRG13_B38400 (0x001500 | 0x03)
  284. #define MAX3107_BRG13_B57600 (0x000E00 | 0x02)
  285. #define MAX3107_BRG13_B115200 (0x000700 | 0x01)
  286. #define MAX3107_BRG13_B230400 (0x000300 | 0x08)
  287. #define MAX3107_BRG13_B460800 (0x000100 | 0x0c)
  288. #define MAX3107_BRG13_B921600 (0x000100 | 0x1c)
  289. /* Baud rate generator configuration values for external clock 26MHz */
  290. #define MAX3107_BRG26_B300 (0x152800 | 0x0A)
  291. #define MAX3107_BRG26_B600 (0x0A9400 | 0x05)
  292. #define MAX3107_BRG26_B1200 (0x054A00 | 0x03)
  293. #define MAX3107_BRG26_B2400 (0x02A500 | 0x01)
  294. #define MAX3107_BRG26_B4800 (0x015200 | 0x09)
  295. #define MAX3107_BRG26_B9600 (0x00A900 | 0x04)
  296. #define MAX3107_BRG26_B19200 (0x005400 | 0x0A)
  297. #define MAX3107_BRG26_B38400 (0x002A00 | 0x05)
  298. #define MAX3107_BRG26_B57600 (0x001C00 | 0x03)
  299. #define MAX3107_BRG26_B115200 (0x000E00 | 0x02)
  300. #define MAX3107_BRG26_B230400 (0x000700 | 0x01)
  301. #define MAX3107_BRG26_B460800 (0x000300 | 0x08)
  302. #define MAX3107_BRG26_B921600 (0x000100 | 0x0C)
  303. /* Baud rate generator configuration values for internal clock */
  304. #define MAX3107_BRG13_IB300 (0x008000 | 0x00)
  305. #define MAX3107_BRG13_IB600 (0x004000 | 0x00)
  306. #define MAX3107_BRG13_IB1200 (0x002000 | 0x00)
  307. #define MAX3107_BRG13_IB2400 (0x001000 | 0x00)
  308. #define MAX3107_BRG13_IB4800 (0x000800 | 0x00)
  309. #define MAX3107_BRG13_IB9600 (0x000400 | 0x00)
  310. #define MAX3107_BRG13_IB19200 (0x000200 | 0x00)
  311. #define MAX3107_BRG13_IB38400 (0x000100 | 0x00)
  312. #define MAX3107_BRG13_IB57600 (0x000000 | 0x0B)
  313. #define MAX3107_BRG13_IB115200 (0x000000 | 0x05)
  314. #define MAX3107_BRG13_IB230400 (0x000000 | 0x03)
  315. #define MAX3107_BRG13_IB460800 (0x000000 | 0x00)
  316. #define MAX3107_BRG13_IB921600 (0x000000 | 0x00)
  317. struct baud_table {
  318. int baud;
  319. u32 new_brg;
  320. };
  321. struct max3107_port {
  322. /* UART port structure */
  323. struct uart_port port;
  324. /* SPI device structure */
  325. struct spi_device *spi;
  326. #if defined(CONFIG_GPIOLIB)
  327. /* GPIO chip structure */
  328. struct gpio_chip chip;
  329. #endif
  330. /* Workqueue that does all the magic */
  331. struct workqueue_struct *workqueue;
  332. struct work_struct work;
  333. /* Lock for shared data */
  334. spinlock_t data_lock;
  335. /* Device configuration */
  336. int ext_clk; /* 1 if external clock used */
  337. int loopback; /* Current loopback mode state */
  338. int baud; /* Current baud rate */
  339. /* State flags */
  340. int suspended; /* Indicates suspend mode */
  341. int tx_fifo_empty; /* Flag for TX FIFO state */
  342. int rx_enabled; /* Flag for receiver state */
  343. int tx_enabled; /* Flag for transmitter state */
  344. u16 irqen_reg; /* Current IRQ enable register value */
  345. /* Shared data */
  346. u16 mode1_reg; /* Current mode1 register value*/
  347. int mode1_commit; /* Flag for setting new mode1 register value */
  348. u16 lcr_reg; /* Current LCR register value */
  349. int lcr_commit; /* Flag for setting new LCR register value */
  350. u32 brg_cfg; /* Current Baud rate generator config */
  351. int brg_commit; /* Flag for setting new baud rate generator
  352. * config
  353. */
  354. struct baud_table *baud_tbl;
  355. int handle_irq; /* Indicates that IRQ should be handled */
  356. /* Rx buffer and str*/
  357. u16 *rxbuf;
  358. u8 *rxstr;
  359. /* Tx buffer*/
  360. u16 *txbuf;
  361. struct max3107_plat *pdata; /* Platform data */
  362. };
  363. /* Platform data structure */
  364. struct max3107_plat {
  365. /* Loopback mode enable */
  366. int loopback;
  367. /* External clock enable */
  368. int ext_clk;
  369. /* Called during the register initialisation */
  370. void (*init)(struct max3107_port *s);
  371. /* Called when the port is found and configured */
  372. int (*configure)(struct max3107_port *s);
  373. /* HW suspend function */
  374. void (*hw_suspend) (struct max3107_port *s, int suspend);
  375. /* Polling mode enable */
  376. int polled_mode;
  377. /* Polling period if polling mode enabled */
  378. int poll_time;
  379. };
  380. extern int max3107_rw(struct max3107_port *s, u8 *tx, u8 *rx, int len);
  381. extern void max3107_hw_susp(struct max3107_port *s, int suspend);
  382. extern int max3107_probe(struct spi_device *spi, struct max3107_plat *pdata);
  383. extern int max3107_remove(struct spi_device *spi);
  384. extern int max3107_suspend(struct spi_device *spi, pm_message_t state);
  385. extern int max3107_resume(struct spi_device *spi);
  386. #endif /* _LINUX_SERIAL_MAX3107_H */