xilinx_uartps.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  1. /*
  2. * Xilinx PS UART driver
  3. *
  4. * 2011 (c) Xilinx Inc.
  5. *
  6. * This program is free software; you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public
  8. * License as published by the Free Software Foundation;
  9. * either version 2 of the License, or (at your option) any
  10. * later version.
  11. *
  12. */
  13. #if defined(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  14. #define SUPPORT_SYSRQ
  15. #endif
  16. #include <linux/platform_device.h>
  17. #include <linux/serial.h>
  18. #include <linux/console.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/slab.h>
  21. #include <linux/tty.h>
  22. #include <linux/tty_flip.h>
  23. #include <linux/clk.h>
  24. #include <linux/irq.h>
  25. #include <linux/io.h>
  26. #include <linux/of.h>
  27. #include <linux/module.h>
  28. #define XUARTPS_TTY_NAME "ttyPS"
  29. #define XUARTPS_NAME "xuartps"
  30. #define XUARTPS_MAJOR 0 /* use dynamic node allocation */
  31. #define XUARTPS_MINOR 0 /* works best with devtmpfs */
  32. #define XUARTPS_NR_PORTS 2
  33. #define XUARTPS_FIFO_SIZE 16 /* FIFO size */
  34. #define XUARTPS_REGISTER_SPACE 0xFFF
  35. #define xuartps_readl(offset) ioread32(port->membase + offset)
  36. #define xuartps_writel(val, offset) iowrite32(val, port->membase + offset)
  37. /********************************Register Map********************************/
  38. /** UART
  39. *
  40. * Register offsets for the UART.
  41. *
  42. */
  43. #define XUARTPS_CR_OFFSET 0x00 /* Control Register [8:0] */
  44. #define XUARTPS_MR_OFFSET 0x04 /* Mode Register [10:0] */
  45. #define XUARTPS_IER_OFFSET 0x08 /* Interrupt Enable [10:0] */
  46. #define XUARTPS_IDR_OFFSET 0x0C /* Interrupt Disable [10:0] */
  47. #define XUARTPS_IMR_OFFSET 0x10 /* Interrupt Mask [10:0] */
  48. #define XUARTPS_ISR_OFFSET 0x14 /* Interrupt Status [10:0]*/
  49. #define XUARTPS_BAUDGEN_OFFSET 0x18 /* Baud Rate Generator [15:0] */
  50. #define XUARTPS_RXTOUT_OFFSET 0x1C /* RX Timeout [7:0] */
  51. #define XUARTPS_RXWM_OFFSET 0x20 /* RX FIFO Trigger Level [5:0] */
  52. #define XUARTPS_MODEMCR_OFFSET 0x24 /* Modem Control [5:0] */
  53. #define XUARTPS_MODEMSR_OFFSET 0x28 /* Modem Status [8:0] */
  54. #define XUARTPS_SR_OFFSET 0x2C /* Channel Status [11:0] */
  55. #define XUARTPS_FIFO_OFFSET 0x30 /* FIFO [15:0] or [7:0] */
  56. #define XUARTPS_BAUDDIV_OFFSET 0x34 /* Baud Rate Divider [7:0] */
  57. #define XUARTPS_FLOWDEL_OFFSET 0x38 /* Flow Delay [15:0] */
  58. #define XUARTPS_IRRX_PWIDTH_OFFSET 0x3C /* IR Minimum Received Pulse
  59. Width [15:0] */
  60. #define XUARTPS_IRTX_PWIDTH_OFFSET 0x40 /* IR Transmitted pulse
  61. Width [7:0] */
  62. #define XUARTPS_TXWM_OFFSET 0x44 /* TX FIFO Trigger Level [5:0] */
  63. /** Control Register
  64. *
  65. * The Control register (CR) controls the major functions of the device.
  66. *
  67. * Control Register Bit Definitions
  68. */
  69. #define XUARTPS_CR_STOPBRK 0x00000100 /* Stop TX break */
  70. #define XUARTPS_CR_STARTBRK 0x00000080 /* Set TX break */
  71. #define XUARTPS_CR_TX_DIS 0x00000020 /* TX disabled. */
  72. #define XUARTPS_CR_TX_EN 0x00000010 /* TX enabled */
  73. #define XUARTPS_CR_RX_DIS 0x00000008 /* RX disabled. */
  74. #define XUARTPS_CR_RX_EN 0x00000004 /* RX enabled */
  75. #define XUARTPS_CR_TXRST 0x00000002 /* TX logic reset */
  76. #define XUARTPS_CR_RXRST 0x00000001 /* RX logic reset */
  77. #define XUARTPS_CR_RST_TO 0x00000040 /* Restart Timeout Counter */
  78. /** Mode Register
  79. *
  80. * The mode register (MR) defines the mode of transfer as well as the data
  81. * format. If this register is modified during transmission or reception,
  82. * data validity cannot be guaranteed.
  83. *
  84. * Mode Register Bit Definitions
  85. *
  86. */
  87. #define XUARTPS_MR_CLKSEL 0x00000001 /* Pre-scalar selection */
  88. #define XUARTPS_MR_CHMODE_L_LOOP 0x00000200 /* Local loop back mode */
  89. #define XUARTPS_MR_CHMODE_NORM 0x00000000 /* Normal mode */
  90. #define XUARTPS_MR_STOPMODE_2_BIT 0x00000080 /* 2 stop bits */
  91. #define XUARTPS_MR_STOPMODE_1_BIT 0x00000000 /* 1 stop bit */
  92. #define XUARTPS_MR_PARITY_NONE 0x00000020 /* No parity mode */
  93. #define XUARTPS_MR_PARITY_MARK 0x00000018 /* Mark parity mode */
  94. #define XUARTPS_MR_PARITY_SPACE 0x00000010 /* Space parity mode */
  95. #define XUARTPS_MR_PARITY_ODD 0x00000008 /* Odd parity mode */
  96. #define XUARTPS_MR_PARITY_EVEN 0x00000000 /* Even parity mode */
  97. #define XUARTPS_MR_CHARLEN_6_BIT 0x00000006 /* 6 bits data */
  98. #define XUARTPS_MR_CHARLEN_7_BIT 0x00000004 /* 7 bits data */
  99. #define XUARTPS_MR_CHARLEN_8_BIT 0x00000000 /* 8 bits data */
  100. /** Interrupt Registers
  101. *
  102. * Interrupt control logic uses the interrupt enable register (IER) and the
  103. * interrupt disable register (IDR) to set the value of the bits in the
  104. * interrupt mask register (IMR). The IMR determines whether to pass an
  105. * interrupt to the interrupt status register (ISR).
  106. * Writing a 1 to IER Enables an interrupt, writing a 1 to IDR disables an
  107. * interrupt. IMR and ISR are read only, and IER and IDR are write only.
  108. * Reading either IER or IDR returns 0x00.
  109. *
  110. * All four registers have the same bit definitions.
  111. */
  112. #define XUARTPS_IXR_TOUT 0x00000100 /* RX Timeout error interrupt */
  113. #define XUARTPS_IXR_PARITY 0x00000080 /* Parity error interrupt */
  114. #define XUARTPS_IXR_FRAMING 0x00000040 /* Framing error interrupt */
  115. #define XUARTPS_IXR_OVERRUN 0x00000020 /* Overrun error interrupt */
  116. #define XUARTPS_IXR_TXFULL 0x00000010 /* TX FIFO Full interrupt */
  117. #define XUARTPS_IXR_TXEMPTY 0x00000008 /* TX FIFO empty interrupt */
  118. #define XUARTPS_ISR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt */
  119. #define XUARTPS_IXR_RXTRIG 0x00000001 /* RX FIFO trigger interrupt */
  120. #define XUARTPS_IXR_RXFULL 0x00000004 /* RX FIFO full interrupt. */
  121. #define XUARTPS_IXR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt. */
  122. #define XUARTPS_IXR_MASK 0x00001FFF /* Valid bit mask */
  123. /* Goes in read_status_mask for break detection as the HW doesn't do it*/
  124. #define XUARTPS_IXR_BRK 0x80000000
  125. /** Channel Status Register
  126. *
  127. * The channel status register (CSR) is provided to enable the control logic
  128. * to monitor the status of bits in the channel interrupt status register,
  129. * even if these are masked out by the interrupt mask register.
  130. */
  131. #define XUARTPS_SR_RXEMPTY 0x00000002 /* RX FIFO empty */
  132. #define XUARTPS_SR_TXEMPTY 0x00000008 /* TX FIFO empty */
  133. #define XUARTPS_SR_TXFULL 0x00000010 /* TX FIFO full */
  134. #define XUARTPS_SR_RXTRIG 0x00000001 /* Rx Trigger */
  135. /**
  136. * struct xuartps - device data
  137. * @refclk Reference clock
  138. * @aperclk APB clock
  139. */
  140. struct xuartps {
  141. struct clk *refclk;
  142. struct clk *aperclk;
  143. };
  144. /**
  145. * xuartps_isr - Interrupt handler
  146. * @irq: Irq number
  147. * @dev_id: Id of the port
  148. *
  149. * Returns IRQHANDLED
  150. **/
  151. static irqreturn_t xuartps_isr(int irq, void *dev_id)
  152. {
  153. struct uart_port *port = (struct uart_port *)dev_id;
  154. unsigned long flags;
  155. unsigned int isrstatus, numbytes;
  156. unsigned int data;
  157. char status = TTY_NORMAL;
  158. spin_lock_irqsave(&port->lock, flags);
  159. /* Read the interrupt status register to determine which
  160. * interrupt(s) is/are active.
  161. */
  162. isrstatus = xuartps_readl(XUARTPS_ISR_OFFSET);
  163. /*
  164. * There is no hardware break detection, so we interpret framing
  165. * error with all-zeros data as a break sequence. Most of the time,
  166. * there's another non-zero byte at the end of the sequence.
  167. */
  168. if (isrstatus & XUARTPS_IXR_FRAMING) {
  169. while (!(xuartps_readl(XUARTPS_SR_OFFSET) &
  170. XUARTPS_SR_RXEMPTY)) {
  171. if (!xuartps_readl(XUARTPS_FIFO_OFFSET)) {
  172. port->read_status_mask |= XUARTPS_IXR_BRK;
  173. isrstatus &= ~XUARTPS_IXR_FRAMING;
  174. }
  175. }
  176. xuartps_writel(XUARTPS_IXR_FRAMING, XUARTPS_ISR_OFFSET);
  177. }
  178. /* drop byte with parity error if IGNPAR specified */
  179. if (isrstatus & port->ignore_status_mask & XUARTPS_IXR_PARITY)
  180. isrstatus &= ~(XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT);
  181. isrstatus &= port->read_status_mask;
  182. isrstatus &= ~port->ignore_status_mask;
  183. if ((isrstatus & XUARTPS_IXR_TOUT) ||
  184. (isrstatus & XUARTPS_IXR_RXTRIG)) {
  185. /* Receive Timeout Interrupt */
  186. while ((xuartps_readl(XUARTPS_SR_OFFSET) &
  187. XUARTPS_SR_RXEMPTY) != XUARTPS_SR_RXEMPTY) {
  188. data = xuartps_readl(XUARTPS_FIFO_OFFSET);
  189. /* Non-NULL byte after BREAK is garbage (99%) */
  190. if (data && (port->read_status_mask &
  191. XUARTPS_IXR_BRK)) {
  192. port->read_status_mask &= ~XUARTPS_IXR_BRK;
  193. port->icount.brk++;
  194. if (uart_handle_break(port))
  195. continue;
  196. }
  197. /*
  198. * uart_handle_sysrq_char() doesn't work if
  199. * spinlocked, for some reason
  200. */
  201. if (port->sysrq) {
  202. spin_unlock(&port->lock);
  203. if (uart_handle_sysrq_char(port,
  204. (unsigned char)data)) {
  205. spin_lock(&port->lock);
  206. continue;
  207. }
  208. spin_lock(&port->lock);
  209. }
  210. port->icount.rx++;
  211. if (isrstatus & XUARTPS_IXR_PARITY) {
  212. port->icount.parity++;
  213. status = TTY_PARITY;
  214. } else if (isrstatus & XUARTPS_IXR_FRAMING) {
  215. port->icount.frame++;
  216. status = TTY_FRAME;
  217. } else if (isrstatus & XUARTPS_IXR_OVERRUN)
  218. port->icount.overrun++;
  219. uart_insert_char(port, isrstatus, XUARTPS_IXR_OVERRUN,
  220. data, status);
  221. }
  222. spin_unlock(&port->lock);
  223. tty_flip_buffer_push(&port->state->port);
  224. spin_lock(&port->lock);
  225. }
  226. /* Dispatch an appropriate handler */
  227. if ((isrstatus & XUARTPS_IXR_TXEMPTY) == XUARTPS_IXR_TXEMPTY) {
  228. if (uart_circ_empty(&port->state->xmit)) {
  229. xuartps_writel(XUARTPS_IXR_TXEMPTY,
  230. XUARTPS_IDR_OFFSET);
  231. } else {
  232. numbytes = port->fifosize;
  233. /* Break if no more data available in the UART buffer */
  234. while (numbytes--) {
  235. if (uart_circ_empty(&port->state->xmit))
  236. break;
  237. /* Get the data from the UART circular buffer
  238. * and write it to the xuartps's TX_FIFO
  239. * register.
  240. */
  241. xuartps_writel(
  242. port->state->xmit.buf[port->state->xmit.
  243. tail], XUARTPS_FIFO_OFFSET);
  244. port->icount.tx++;
  245. /* Adjust the tail of the UART buffer and wrap
  246. * the buffer if it reaches limit.
  247. */
  248. port->state->xmit.tail =
  249. (port->state->xmit.tail + 1) & \
  250. (UART_XMIT_SIZE - 1);
  251. }
  252. if (uart_circ_chars_pending(
  253. &port->state->xmit) < WAKEUP_CHARS)
  254. uart_write_wakeup(port);
  255. }
  256. }
  257. xuartps_writel(isrstatus, XUARTPS_ISR_OFFSET);
  258. /* be sure to release the lock and tty before leaving */
  259. spin_unlock_irqrestore(&port->lock, flags);
  260. return IRQ_HANDLED;
  261. }
  262. /**
  263. * xuartps_set_baud_rate - Calculate and set the baud rate
  264. * @port: Handle to the uart port structure
  265. * @baud: Baud rate to set
  266. *
  267. * Returns baud rate, requested baud when possible, or actual baud when there
  268. * was too much error
  269. **/
  270. static unsigned int xuartps_set_baud_rate(struct uart_port *port,
  271. unsigned int baud)
  272. {
  273. unsigned int sel_clk;
  274. unsigned int calc_baud = 0;
  275. unsigned int brgr_val, brdiv_val;
  276. unsigned int bauderror;
  277. /* Formula to obtain baud rate is
  278. * baud_tx/rx rate = sel_clk/CD * (BDIV + 1)
  279. * input_clk = (Uart User Defined Clock or Apb Clock)
  280. * depends on UCLKEN in MR Reg
  281. * sel_clk = input_clk or input_clk/8;
  282. * depends on CLKS in MR reg
  283. * CD and BDIV depends on values in
  284. * baud rate generate register
  285. * baud rate clock divisor register
  286. */
  287. sel_clk = port->uartclk;
  288. if (xuartps_readl(XUARTPS_MR_OFFSET) & XUARTPS_MR_CLKSEL)
  289. sel_clk = sel_clk / 8;
  290. /* Find the best values for baud generation */
  291. for (brdiv_val = 4; brdiv_val < 255; brdiv_val++) {
  292. brgr_val = sel_clk / (baud * (brdiv_val + 1));
  293. if (brgr_val < 2 || brgr_val > 65535)
  294. continue;
  295. calc_baud = sel_clk / (brgr_val * (brdiv_val + 1));
  296. if (baud > calc_baud)
  297. bauderror = baud - calc_baud;
  298. else
  299. bauderror = calc_baud - baud;
  300. /* use the values when percent error is acceptable */
  301. if (((bauderror * 100) / baud) < 3) {
  302. calc_baud = baud;
  303. break;
  304. }
  305. }
  306. /* Set the values for the new baud rate */
  307. xuartps_writel(brgr_val, XUARTPS_BAUDGEN_OFFSET);
  308. xuartps_writel(brdiv_val, XUARTPS_BAUDDIV_OFFSET);
  309. return calc_baud;
  310. }
  311. /*----------------------Uart Operations---------------------------*/
  312. /**
  313. * xuartps_start_tx - Start transmitting bytes
  314. * @port: Handle to the uart port structure
  315. *
  316. **/
  317. static void xuartps_start_tx(struct uart_port *port)
  318. {
  319. unsigned int status, numbytes = port->fifosize;
  320. if (uart_circ_empty(&port->state->xmit) || uart_tx_stopped(port))
  321. return;
  322. status = xuartps_readl(XUARTPS_CR_OFFSET);
  323. /* Set the TX enable bit and clear the TX disable bit to enable the
  324. * transmitter.
  325. */
  326. xuartps_writel((status & ~XUARTPS_CR_TX_DIS) | XUARTPS_CR_TX_EN,
  327. XUARTPS_CR_OFFSET);
  328. while (numbytes-- && ((xuartps_readl(XUARTPS_SR_OFFSET)
  329. & XUARTPS_SR_TXFULL)) != XUARTPS_SR_TXFULL) {
  330. /* Break if no more data available in the UART buffer */
  331. if (uart_circ_empty(&port->state->xmit))
  332. break;
  333. /* Get the data from the UART circular buffer and
  334. * write it to the xuartps's TX_FIFO register.
  335. */
  336. xuartps_writel(
  337. port->state->xmit.buf[port->state->xmit.tail],
  338. XUARTPS_FIFO_OFFSET);
  339. port->icount.tx++;
  340. /* Adjust the tail of the UART buffer and wrap
  341. * the buffer if it reaches limit.
  342. */
  343. port->state->xmit.tail = (port->state->xmit.tail + 1) &
  344. (UART_XMIT_SIZE - 1);
  345. }
  346. /* Enable the TX Empty interrupt */
  347. xuartps_writel(XUARTPS_IXR_TXEMPTY, XUARTPS_IER_OFFSET);
  348. if (uart_circ_chars_pending(&port->state->xmit) < WAKEUP_CHARS)
  349. uart_write_wakeup(port);
  350. }
  351. /**
  352. * xuartps_stop_tx - Stop TX
  353. * @port: Handle to the uart port structure
  354. *
  355. **/
  356. static void xuartps_stop_tx(struct uart_port *port)
  357. {
  358. unsigned int regval;
  359. regval = xuartps_readl(XUARTPS_CR_OFFSET);
  360. regval |= XUARTPS_CR_TX_DIS;
  361. /* Disable the transmitter */
  362. xuartps_writel(regval, XUARTPS_CR_OFFSET);
  363. }
  364. /**
  365. * xuartps_stop_rx - Stop RX
  366. * @port: Handle to the uart port structure
  367. *
  368. **/
  369. static void xuartps_stop_rx(struct uart_port *port)
  370. {
  371. unsigned int regval;
  372. regval = xuartps_readl(XUARTPS_CR_OFFSET);
  373. regval |= XUARTPS_CR_RX_DIS;
  374. /* Disable the receiver */
  375. xuartps_writel(regval, XUARTPS_CR_OFFSET);
  376. }
  377. /**
  378. * xuartps_tx_empty - Check whether TX is empty
  379. * @port: Handle to the uart port structure
  380. *
  381. * Returns TIOCSER_TEMT on success, 0 otherwise
  382. **/
  383. static unsigned int xuartps_tx_empty(struct uart_port *port)
  384. {
  385. unsigned int status;
  386. status = xuartps_readl(XUARTPS_ISR_OFFSET) & XUARTPS_IXR_TXEMPTY;
  387. return status ? TIOCSER_TEMT : 0;
  388. }
  389. /**
  390. * xuartps_break_ctl - Based on the input ctl we have to start or stop
  391. * transmitting char breaks
  392. * @port: Handle to the uart port structure
  393. * @ctl: Value based on which start or stop decision is taken
  394. *
  395. **/
  396. static void xuartps_break_ctl(struct uart_port *port, int ctl)
  397. {
  398. unsigned int status;
  399. unsigned long flags;
  400. spin_lock_irqsave(&port->lock, flags);
  401. status = xuartps_readl(XUARTPS_CR_OFFSET);
  402. if (ctl == -1)
  403. xuartps_writel(XUARTPS_CR_STARTBRK | status,
  404. XUARTPS_CR_OFFSET);
  405. else {
  406. if ((status & XUARTPS_CR_STOPBRK) == 0)
  407. xuartps_writel(XUARTPS_CR_STOPBRK | status,
  408. XUARTPS_CR_OFFSET);
  409. }
  410. spin_unlock_irqrestore(&port->lock, flags);
  411. }
  412. /**
  413. * xuartps_set_termios - termios operations, handling data length, parity,
  414. * stop bits, flow control, baud rate
  415. * @port: Handle to the uart port structure
  416. * @termios: Handle to the input termios structure
  417. * @old: Values of the previously saved termios structure
  418. *
  419. **/
  420. static void xuartps_set_termios(struct uart_port *port,
  421. struct ktermios *termios, struct ktermios *old)
  422. {
  423. unsigned int cval = 0;
  424. unsigned int baud;
  425. unsigned long flags;
  426. unsigned int ctrl_reg, mode_reg;
  427. spin_lock_irqsave(&port->lock, flags);
  428. /* Empty the receive FIFO 1st before making changes */
  429. while ((xuartps_readl(XUARTPS_SR_OFFSET) &
  430. XUARTPS_SR_RXEMPTY) != XUARTPS_SR_RXEMPTY) {
  431. xuartps_readl(XUARTPS_FIFO_OFFSET);
  432. }
  433. /* Disable the TX and RX to set baud rate */
  434. xuartps_writel(xuartps_readl(XUARTPS_CR_OFFSET) |
  435. (XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS),
  436. XUARTPS_CR_OFFSET);
  437. /* Min baud rate = 6bps and Max Baud Rate is 10Mbps for 100Mhz clk */
  438. baud = uart_get_baud_rate(port, termios, old, 0, 10000000);
  439. baud = xuartps_set_baud_rate(port, baud);
  440. if (tty_termios_baud_rate(termios))
  441. tty_termios_encode_baud_rate(termios, baud, baud);
  442. /*
  443. * Update the per-port timeout.
  444. */
  445. uart_update_timeout(port, termios->c_cflag, baud);
  446. /* Set TX/RX Reset */
  447. xuartps_writel(xuartps_readl(XUARTPS_CR_OFFSET) |
  448. (XUARTPS_CR_TXRST | XUARTPS_CR_RXRST),
  449. XUARTPS_CR_OFFSET);
  450. ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET);
  451. /* Clear the RX disable and TX disable bits and then set the TX enable
  452. * bit and RX enable bit to enable the transmitter and receiver.
  453. */
  454. xuartps_writel(
  455. (ctrl_reg & ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS))
  456. | (XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN),
  457. XUARTPS_CR_OFFSET);
  458. xuartps_writel(10, XUARTPS_RXTOUT_OFFSET);
  459. port->read_status_mask = XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_RXTRIG |
  460. XUARTPS_IXR_OVERRUN | XUARTPS_IXR_TOUT;
  461. port->ignore_status_mask = 0;
  462. if (termios->c_iflag & INPCK)
  463. port->read_status_mask |= XUARTPS_IXR_PARITY |
  464. XUARTPS_IXR_FRAMING;
  465. if (termios->c_iflag & IGNPAR)
  466. port->ignore_status_mask |= XUARTPS_IXR_PARITY |
  467. XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN;
  468. /* ignore all characters if CREAD is not set */
  469. if ((termios->c_cflag & CREAD) == 0)
  470. port->ignore_status_mask |= XUARTPS_IXR_RXTRIG |
  471. XUARTPS_IXR_TOUT | XUARTPS_IXR_PARITY |
  472. XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN;
  473. mode_reg = xuartps_readl(XUARTPS_MR_OFFSET);
  474. /* Handling Data Size */
  475. switch (termios->c_cflag & CSIZE) {
  476. case CS6:
  477. cval |= XUARTPS_MR_CHARLEN_6_BIT;
  478. break;
  479. case CS7:
  480. cval |= XUARTPS_MR_CHARLEN_7_BIT;
  481. break;
  482. default:
  483. case CS8:
  484. cval |= XUARTPS_MR_CHARLEN_8_BIT;
  485. termios->c_cflag &= ~CSIZE;
  486. termios->c_cflag |= CS8;
  487. break;
  488. }
  489. /* Handling Parity and Stop Bits length */
  490. if (termios->c_cflag & CSTOPB)
  491. cval |= XUARTPS_MR_STOPMODE_2_BIT; /* 2 STOP bits */
  492. else
  493. cval |= XUARTPS_MR_STOPMODE_1_BIT; /* 1 STOP bit */
  494. if (termios->c_cflag & PARENB) {
  495. /* Mark or Space parity */
  496. if (termios->c_cflag & CMSPAR) {
  497. if (termios->c_cflag & PARODD)
  498. cval |= XUARTPS_MR_PARITY_MARK;
  499. else
  500. cval |= XUARTPS_MR_PARITY_SPACE;
  501. } else if (termios->c_cflag & PARODD)
  502. cval |= XUARTPS_MR_PARITY_ODD;
  503. else
  504. cval |= XUARTPS_MR_PARITY_EVEN;
  505. } else
  506. cval |= XUARTPS_MR_PARITY_NONE;
  507. xuartps_writel(cval , XUARTPS_MR_OFFSET);
  508. spin_unlock_irqrestore(&port->lock, flags);
  509. }
  510. /**
  511. * xuartps_startup - Called when an application opens a xuartps port
  512. * @port: Handle to the uart port structure
  513. *
  514. * Returns 0 on success, negative error otherwise
  515. **/
  516. static int xuartps_startup(struct uart_port *port)
  517. {
  518. unsigned int retval = 0, status = 0;
  519. retval = request_irq(port->irq, xuartps_isr, 0, XUARTPS_NAME,
  520. (void *)port);
  521. if (retval)
  522. return retval;
  523. /* Disable the TX and RX */
  524. xuartps_writel(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS,
  525. XUARTPS_CR_OFFSET);
  526. /* Set the Control Register with TX/RX Enable, TX/RX Reset,
  527. * no break chars.
  528. */
  529. xuartps_writel(XUARTPS_CR_TXRST | XUARTPS_CR_RXRST,
  530. XUARTPS_CR_OFFSET);
  531. status = xuartps_readl(XUARTPS_CR_OFFSET);
  532. /* Clear the RX disable and TX disable bits and then set the TX enable
  533. * bit and RX enable bit to enable the transmitter and receiver.
  534. */
  535. xuartps_writel((status & ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS))
  536. | (XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN |
  537. XUARTPS_CR_STOPBRK), XUARTPS_CR_OFFSET);
  538. /* Set the Mode Register with normal mode,8 data bits,1 stop bit,
  539. * no parity.
  540. */
  541. xuartps_writel(XUARTPS_MR_CHMODE_NORM | XUARTPS_MR_STOPMODE_1_BIT
  542. | XUARTPS_MR_PARITY_NONE | XUARTPS_MR_CHARLEN_8_BIT,
  543. XUARTPS_MR_OFFSET);
  544. /* Set the RX FIFO Trigger level to 14 assuming FIFO size as 16 */
  545. xuartps_writel(14, XUARTPS_RXWM_OFFSET);
  546. /* Receive Timeout register is enabled with value of 10 */
  547. xuartps_writel(10, XUARTPS_RXTOUT_OFFSET);
  548. /* Clear out any pending interrupts before enabling them */
  549. xuartps_writel(xuartps_readl(XUARTPS_ISR_OFFSET), XUARTPS_ISR_OFFSET);
  550. /* Set the Interrupt Registers with desired interrupts */
  551. xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY |
  552. XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN |
  553. XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET);
  554. return retval;
  555. }
  556. /**
  557. * xuartps_shutdown - Called when an application closes a xuartps port
  558. * @port: Handle to the uart port structure
  559. *
  560. **/
  561. static void xuartps_shutdown(struct uart_port *port)
  562. {
  563. int status;
  564. /* Disable interrupts */
  565. status = xuartps_readl(XUARTPS_IMR_OFFSET);
  566. xuartps_writel(status, XUARTPS_IDR_OFFSET);
  567. /* Disable the TX and RX */
  568. xuartps_writel(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS,
  569. XUARTPS_CR_OFFSET);
  570. free_irq(port->irq, port);
  571. }
  572. /**
  573. * xuartps_type - Set UART type to xuartps port
  574. * @port: Handle to the uart port structure
  575. *
  576. * Returns string on success, NULL otherwise
  577. **/
  578. static const char *xuartps_type(struct uart_port *port)
  579. {
  580. return port->type == PORT_XUARTPS ? XUARTPS_NAME : NULL;
  581. }
  582. /**
  583. * xuartps_verify_port - Verify the port params
  584. * @port: Handle to the uart port structure
  585. * @ser: Handle to the structure whose members are compared
  586. *
  587. * Returns 0 if success otherwise -EINVAL
  588. **/
  589. static int xuartps_verify_port(struct uart_port *port,
  590. struct serial_struct *ser)
  591. {
  592. if (ser->type != PORT_UNKNOWN && ser->type != PORT_XUARTPS)
  593. return -EINVAL;
  594. if (port->irq != ser->irq)
  595. return -EINVAL;
  596. if (ser->io_type != UPIO_MEM)
  597. return -EINVAL;
  598. if (port->iobase != ser->port)
  599. return -EINVAL;
  600. if (ser->hub6 != 0)
  601. return -EINVAL;
  602. return 0;
  603. }
  604. /**
  605. * xuartps_request_port - Claim the memory region attached to xuartps port,
  606. * called when the driver adds a xuartps port via
  607. * uart_add_one_port()
  608. * @port: Handle to the uart port structure
  609. *
  610. * Returns 0, -ENOMEM if request fails
  611. **/
  612. static int xuartps_request_port(struct uart_port *port)
  613. {
  614. if (!request_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE,
  615. XUARTPS_NAME)) {
  616. return -ENOMEM;
  617. }
  618. port->membase = ioremap(port->mapbase, XUARTPS_REGISTER_SPACE);
  619. if (!port->membase) {
  620. dev_err(port->dev, "Unable to map registers\n");
  621. release_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE);
  622. return -ENOMEM;
  623. }
  624. return 0;
  625. }
  626. /**
  627. * xuartps_release_port - Release the memory region attached to a xuartps
  628. * port, called when the driver removes a xuartps
  629. * port via uart_remove_one_port().
  630. * @port: Handle to the uart port structure
  631. *
  632. **/
  633. static void xuartps_release_port(struct uart_port *port)
  634. {
  635. release_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE);
  636. iounmap(port->membase);
  637. port->membase = NULL;
  638. }
  639. /**
  640. * xuartps_config_port - Configure xuartps, called when the driver adds a
  641. * xuartps port
  642. * @port: Handle to the uart port structure
  643. * @flags: If any
  644. *
  645. **/
  646. static void xuartps_config_port(struct uart_port *port, int flags)
  647. {
  648. if (flags & UART_CONFIG_TYPE && xuartps_request_port(port) == 0)
  649. port->type = PORT_XUARTPS;
  650. }
  651. /**
  652. * xuartps_get_mctrl - Get the modem control state
  653. *
  654. * @port: Handle to the uart port structure
  655. *
  656. * Returns the modem control state
  657. *
  658. **/
  659. static unsigned int xuartps_get_mctrl(struct uart_port *port)
  660. {
  661. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  662. }
  663. static void xuartps_set_mctrl(struct uart_port *port, unsigned int mctrl)
  664. {
  665. /* N/A */
  666. }
  667. static void xuartps_enable_ms(struct uart_port *port)
  668. {
  669. /* N/A */
  670. }
  671. /** The UART operations structure
  672. */
  673. static struct uart_ops xuartps_ops = {
  674. .set_mctrl = xuartps_set_mctrl,
  675. .get_mctrl = xuartps_get_mctrl,
  676. .enable_ms = xuartps_enable_ms,
  677. .start_tx = xuartps_start_tx, /* Start transmitting */
  678. .stop_tx = xuartps_stop_tx, /* Stop transmission */
  679. .stop_rx = xuartps_stop_rx, /* Stop reception */
  680. .tx_empty = xuartps_tx_empty, /* Transmitter busy? */
  681. .break_ctl = xuartps_break_ctl, /* Start/stop
  682. * transmitting break
  683. */
  684. .set_termios = xuartps_set_termios, /* Set termios */
  685. .startup = xuartps_startup, /* App opens xuartps */
  686. .shutdown = xuartps_shutdown, /* App closes xuartps */
  687. .type = xuartps_type, /* Set UART type */
  688. .verify_port = xuartps_verify_port, /* Verification of port
  689. * params
  690. */
  691. .request_port = xuartps_request_port, /* Claim resources
  692. * associated with a
  693. * xuartps port
  694. */
  695. .release_port = xuartps_release_port, /* Release resources
  696. * associated with a
  697. * xuartps port
  698. */
  699. .config_port = xuartps_config_port, /* Configure when driver
  700. * adds a xuartps port
  701. */
  702. };
  703. static struct uart_port xuartps_port[2];
  704. /**
  705. * xuartps_get_port - Configure the port from the platform device resource
  706. * info
  707. *
  708. * Returns a pointer to a uart_port or NULL for failure
  709. **/
  710. static struct uart_port *xuartps_get_port(void)
  711. {
  712. struct uart_port *port;
  713. int id;
  714. /* Find the next unused port */
  715. for (id = 0; id < XUARTPS_NR_PORTS; id++)
  716. if (xuartps_port[id].mapbase == 0)
  717. break;
  718. if (id >= XUARTPS_NR_PORTS)
  719. return NULL;
  720. port = &xuartps_port[id];
  721. /* At this point, we've got an empty uart_port struct, initialize it */
  722. spin_lock_init(&port->lock);
  723. port->membase = NULL;
  724. port->iobase = 1; /* mark port in use */
  725. port->irq = 0;
  726. port->type = PORT_UNKNOWN;
  727. port->iotype = UPIO_MEM32;
  728. port->flags = UPF_BOOT_AUTOCONF;
  729. port->ops = &xuartps_ops;
  730. port->fifosize = XUARTPS_FIFO_SIZE;
  731. port->line = id;
  732. port->dev = NULL;
  733. return port;
  734. }
  735. /*-----------------------Console driver operations--------------------------*/
  736. #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
  737. /**
  738. * xuartps_console_wait_tx - Wait for the TX to be full
  739. * @port: Handle to the uart port structure
  740. *
  741. **/
  742. static void xuartps_console_wait_tx(struct uart_port *port)
  743. {
  744. while ((xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY)
  745. != XUARTPS_SR_TXEMPTY)
  746. barrier();
  747. }
  748. /**
  749. * xuartps_console_putchar - write the character to the FIFO buffer
  750. * @port: Handle to the uart port structure
  751. * @ch: Character to be written
  752. *
  753. **/
  754. static void xuartps_console_putchar(struct uart_port *port, int ch)
  755. {
  756. xuartps_console_wait_tx(port);
  757. xuartps_writel(ch, XUARTPS_FIFO_OFFSET);
  758. }
  759. /**
  760. * xuartps_console_write - perform write operation
  761. * @port: Handle to the uart port structure
  762. * @s: Pointer to character array
  763. * @count: No of characters
  764. **/
  765. static void xuartps_console_write(struct console *co, const char *s,
  766. unsigned int count)
  767. {
  768. struct uart_port *port = &xuartps_port[co->index];
  769. unsigned long flags;
  770. unsigned int imr;
  771. int locked = 1;
  772. if (oops_in_progress)
  773. locked = spin_trylock_irqsave(&port->lock, flags);
  774. else
  775. spin_lock_irqsave(&port->lock, flags);
  776. /* save and disable interrupt */
  777. imr = xuartps_readl(XUARTPS_IMR_OFFSET);
  778. xuartps_writel(imr, XUARTPS_IDR_OFFSET);
  779. uart_console_write(port, s, count, xuartps_console_putchar);
  780. xuartps_console_wait_tx(port);
  781. /* restore interrupt state, it seems like there may be a h/w bug
  782. * in that the interrupt enable register should not need to be
  783. * written based on the data sheet
  784. */
  785. xuartps_writel(~imr, XUARTPS_IDR_OFFSET);
  786. xuartps_writel(imr, XUARTPS_IER_OFFSET);
  787. if (locked)
  788. spin_unlock_irqrestore(&port->lock, flags);
  789. }
  790. /**
  791. * xuartps_console_setup - Initialize the uart to default config
  792. * @co: Console handle
  793. * @options: Initial settings of uart
  794. *
  795. * Returns 0, -ENODEV if no device
  796. **/
  797. static int __init xuartps_console_setup(struct console *co, char *options)
  798. {
  799. struct uart_port *port = &xuartps_port[co->index];
  800. int baud = 9600;
  801. int bits = 8;
  802. int parity = 'n';
  803. int flow = 'n';
  804. if (co->index < 0 || co->index >= XUARTPS_NR_PORTS)
  805. return -EINVAL;
  806. if (!port->mapbase) {
  807. pr_debug("console on ttyPS%i not present\n", co->index);
  808. return -ENODEV;
  809. }
  810. if (options)
  811. uart_parse_options(options, &baud, &parity, &bits, &flow);
  812. return uart_set_options(port, co, baud, parity, bits, flow);
  813. }
  814. static struct uart_driver xuartps_uart_driver;
  815. static struct console xuartps_console = {
  816. .name = XUARTPS_TTY_NAME,
  817. .write = xuartps_console_write,
  818. .device = uart_console_device,
  819. .setup = xuartps_console_setup,
  820. .flags = CON_PRINTBUFFER,
  821. .index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */
  822. .data = &xuartps_uart_driver,
  823. };
  824. /**
  825. * xuartps_console_init - Initialization call
  826. *
  827. * Returns 0 on success, negative error otherwise
  828. **/
  829. static int __init xuartps_console_init(void)
  830. {
  831. register_console(&xuartps_console);
  832. return 0;
  833. }
  834. console_initcall(xuartps_console_init);
  835. #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */
  836. /** Structure Definitions
  837. */
  838. static struct uart_driver xuartps_uart_driver = {
  839. .owner = THIS_MODULE, /* Owner */
  840. .driver_name = XUARTPS_NAME, /* Driver name */
  841. .dev_name = XUARTPS_TTY_NAME, /* Node name */
  842. .major = XUARTPS_MAJOR, /* Major number */
  843. .minor = XUARTPS_MINOR, /* Minor number */
  844. .nr = XUARTPS_NR_PORTS, /* Number of UART ports */
  845. #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
  846. .cons = &xuartps_console, /* Console */
  847. #endif
  848. };
  849. /* ---------------------------------------------------------------------
  850. * Platform bus binding
  851. */
  852. /**
  853. * xuartps_probe - Platform driver probe
  854. * @pdev: Pointer to the platform device structure
  855. *
  856. * Returns 0 on success, negative error otherwise
  857. **/
  858. static int xuartps_probe(struct platform_device *pdev)
  859. {
  860. int rc;
  861. struct uart_port *port;
  862. struct resource *res, *res2;
  863. struct xuartps *xuartps_data;
  864. xuartps_data = devm_kzalloc(&pdev->dev, sizeof(*xuartps_data),
  865. GFP_KERNEL);
  866. if (!xuartps_data)
  867. return -ENOMEM;
  868. xuartps_data->aperclk = devm_clk_get(&pdev->dev, "aper_clk");
  869. if (IS_ERR(xuartps_data->aperclk)) {
  870. dev_err(&pdev->dev, "aper_clk clock not found.\n");
  871. return PTR_ERR(xuartps_data->aperclk);
  872. }
  873. xuartps_data->refclk = devm_clk_get(&pdev->dev, "ref_clk");
  874. if (IS_ERR(xuartps_data->refclk)) {
  875. dev_err(&pdev->dev, "ref_clk clock not found.\n");
  876. return PTR_ERR(xuartps_data->refclk);
  877. }
  878. rc = clk_prepare_enable(xuartps_data->aperclk);
  879. if (rc) {
  880. dev_err(&pdev->dev, "Unable to enable APER clock.\n");
  881. return rc;
  882. }
  883. rc = clk_prepare_enable(xuartps_data->refclk);
  884. if (rc) {
  885. dev_err(&pdev->dev, "Unable to enable device clock.\n");
  886. goto err_out_clk_dis_aper;
  887. }
  888. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  889. if (!res) {
  890. rc = -ENODEV;
  891. goto err_out_clk_disable;
  892. }
  893. res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  894. if (!res2) {
  895. rc = -ENODEV;
  896. goto err_out_clk_disable;
  897. }
  898. /* Initialize the port structure */
  899. port = xuartps_get_port();
  900. if (!port) {
  901. dev_err(&pdev->dev, "Cannot get uart_port structure\n");
  902. rc = -ENODEV;
  903. goto err_out_clk_disable;
  904. } else {
  905. /* Register the port.
  906. * This function also registers this device with the tty layer
  907. * and triggers invocation of the config_port() entry point.
  908. */
  909. port->mapbase = res->start;
  910. port->irq = res2->start;
  911. port->dev = &pdev->dev;
  912. port->uartclk = clk_get_rate(xuartps_data->refclk);
  913. port->private_data = xuartps_data;
  914. platform_set_drvdata(pdev, port);
  915. rc = uart_add_one_port(&xuartps_uart_driver, port);
  916. if (rc) {
  917. dev_err(&pdev->dev,
  918. "uart_add_one_port() failed; err=%i\n", rc);
  919. goto err_out_clk_disable;
  920. }
  921. return 0;
  922. }
  923. err_out_clk_disable:
  924. clk_disable_unprepare(xuartps_data->refclk);
  925. err_out_clk_dis_aper:
  926. clk_disable_unprepare(xuartps_data->aperclk);
  927. return rc;
  928. }
  929. /**
  930. * xuartps_remove - called when the platform driver is unregistered
  931. * @pdev: Pointer to the platform device structure
  932. *
  933. * Returns 0 on success, negative error otherwise
  934. **/
  935. static int xuartps_remove(struct platform_device *pdev)
  936. {
  937. struct uart_port *port = platform_get_drvdata(pdev);
  938. struct xuartps *xuartps_data = port->private_data;
  939. int rc;
  940. /* Remove the xuartps port from the serial core */
  941. rc = uart_remove_one_port(&xuartps_uart_driver, port);
  942. port->mapbase = 0;
  943. clk_disable_unprepare(xuartps_data->refclk);
  944. clk_disable_unprepare(xuartps_data->aperclk);
  945. return rc;
  946. }
  947. /* Match table for of_platform binding */
  948. static struct of_device_id xuartps_of_match[] = {
  949. { .compatible = "xlnx,xuartps", },
  950. {}
  951. };
  952. MODULE_DEVICE_TABLE(of, xuartps_of_match);
  953. static struct platform_driver xuartps_platform_driver = {
  954. .probe = xuartps_probe, /* Probe method */
  955. .remove = xuartps_remove, /* Detach method */
  956. .driver = {
  957. .owner = THIS_MODULE,
  958. .name = XUARTPS_NAME, /* Driver name */
  959. .of_match_table = xuartps_of_match,
  960. },
  961. };
  962. /* ---------------------------------------------------------------------
  963. * Module Init and Exit
  964. */
  965. /**
  966. * xuartps_init - Initial driver registration call
  967. *
  968. * Returns whether the registration was successful or not
  969. **/
  970. static int __init xuartps_init(void)
  971. {
  972. int retval = 0;
  973. /* Register the xuartps driver with the serial core */
  974. retval = uart_register_driver(&xuartps_uart_driver);
  975. if (retval)
  976. return retval;
  977. /* Register the platform driver */
  978. retval = platform_driver_register(&xuartps_platform_driver);
  979. if (retval)
  980. uart_unregister_driver(&xuartps_uart_driver);
  981. return retval;
  982. }
  983. /**
  984. * xuartps_exit - Driver unregistration call
  985. **/
  986. static void __exit xuartps_exit(void)
  987. {
  988. /* The order of unregistration is important. Unregister the
  989. * UART driver before the platform driver crashes the system.
  990. */
  991. /* Unregister the platform driver */
  992. platform_driver_unregister(&xuartps_platform_driver);
  993. /* Unregister the xuartps driver */
  994. uart_unregister_driver(&xuartps_uart_driver);
  995. }
  996. module_init(xuartps_init);
  997. module_exit(xuartps_exit);
  998. MODULE_DESCRIPTION("Driver for PS UART");
  999. MODULE_AUTHOR("Xilinx Inc.");
  1000. MODULE_LICENSE("GPL");