uartlite.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * uartlite.c: Serial driver for Xilinx uartlite serial controller
  3. *
  4. * Copyright (C) 2006 Peter Korsgaard <jacmet@sunsite.dk>
  5. * Copyright (C) 2007 Secret Lab Technologies Ltd.
  6. *
  7. * This file is licensed under the terms of the GNU General Public License
  8. * version 2. This program is licensed "as is" without any warranty of any
  9. * kind, whether express or implied.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/module.h>
  13. #include <linux/console.h>
  14. #include <linux/serial.h>
  15. #include <linux/serial_core.h>
  16. #include <linux/tty.h>
  17. #include <linux/tty_flip.h>
  18. #include <linux/delay.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/of.h>
  23. #include <linux/of_address.h>
  24. #include <linux/of_device.h>
  25. #include <linux/of_platform.h>
  26. #define ULITE_NAME "ttyUL"
  27. #define ULITE_MAJOR 204
  28. #define ULITE_MINOR 187
  29. #define ULITE_NR_UARTS 4
  30. /* ---------------------------------------------------------------------
  31. * Register definitions
  32. *
  33. * For register details see datasheet:
  34. * http://www.xilinx.com/support/documentation/ip_documentation/opb_uartlite.pdf
  35. */
  36. #define ULITE_RX 0x00
  37. #define ULITE_TX 0x04
  38. #define ULITE_STATUS 0x08
  39. #define ULITE_CONTROL 0x0c
  40. #define ULITE_REGION 16
  41. #define ULITE_STATUS_RXVALID 0x01
  42. #define ULITE_STATUS_RXFULL 0x02
  43. #define ULITE_STATUS_TXEMPTY 0x04
  44. #define ULITE_STATUS_TXFULL 0x08
  45. #define ULITE_STATUS_IE 0x10
  46. #define ULITE_STATUS_OVERRUN 0x20
  47. #define ULITE_STATUS_FRAME 0x40
  48. #define ULITE_STATUS_PARITY 0x80
  49. #define ULITE_CONTROL_RST_TX 0x01
  50. #define ULITE_CONTROL_RST_RX 0x02
  51. #define ULITE_CONTROL_IE 0x10
  52. struct uartlite_reg_ops {
  53. u32 (*in)(void __iomem *addr);
  54. void (*out)(u32 val, void __iomem *addr);
  55. };
  56. static u32 uartlite_inbe32(void __iomem *addr)
  57. {
  58. return ioread32be(addr);
  59. }
  60. static void uartlite_outbe32(u32 val, void __iomem *addr)
  61. {
  62. iowrite32be(val, addr);
  63. }
  64. static struct uartlite_reg_ops uartlite_be = {
  65. .in = uartlite_inbe32,
  66. .out = uartlite_outbe32,
  67. };
  68. static u32 uartlite_inle32(void __iomem *addr)
  69. {
  70. return ioread32(addr);
  71. }
  72. static void uartlite_outle32(u32 val, void __iomem *addr)
  73. {
  74. iowrite32(val, addr);
  75. }
  76. static struct uartlite_reg_ops uartlite_le = {
  77. .in = uartlite_inle32,
  78. .out = uartlite_outle32,
  79. };
  80. static inline u32 uart_in32(u32 offset, struct uart_port *port)
  81. {
  82. struct uartlite_reg_ops *reg_ops = port->private_data;
  83. return reg_ops->in(port->membase + offset);
  84. }
  85. static inline void uart_out32(u32 val, u32 offset, struct uart_port *port)
  86. {
  87. struct uartlite_reg_ops *reg_ops = port->private_data;
  88. reg_ops->out(val, port->membase + offset);
  89. }
  90. static struct uart_port ulite_ports[ULITE_NR_UARTS];
  91. /* ---------------------------------------------------------------------
  92. * Core UART driver operations
  93. */
  94. static int ulite_receive(struct uart_port *port, int stat)
  95. {
  96. struct tty_port *tport = &port->state->port;
  97. unsigned char ch = 0;
  98. char flag = TTY_NORMAL;
  99. if ((stat & (ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
  100. | ULITE_STATUS_FRAME)) == 0)
  101. return 0;
  102. /* stats */
  103. if (stat & ULITE_STATUS_RXVALID) {
  104. port->icount.rx++;
  105. ch = uart_in32(ULITE_RX, port);
  106. if (stat & ULITE_STATUS_PARITY)
  107. port->icount.parity++;
  108. }
  109. if (stat & ULITE_STATUS_OVERRUN)
  110. port->icount.overrun++;
  111. if (stat & ULITE_STATUS_FRAME)
  112. port->icount.frame++;
  113. /* drop byte with parity error if IGNPAR specificed */
  114. if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY)
  115. stat &= ~ULITE_STATUS_RXVALID;
  116. stat &= port->read_status_mask;
  117. if (stat & ULITE_STATUS_PARITY)
  118. flag = TTY_PARITY;
  119. stat &= ~port->ignore_status_mask;
  120. if (stat & ULITE_STATUS_RXVALID)
  121. tty_insert_flip_char(tport, ch, flag);
  122. if (stat & ULITE_STATUS_FRAME)
  123. tty_insert_flip_char(tport, 0, TTY_FRAME);
  124. if (stat & ULITE_STATUS_OVERRUN)
  125. tty_insert_flip_char(tport, 0, TTY_OVERRUN);
  126. return 1;
  127. }
  128. static int ulite_transmit(struct uart_port *port, int stat)
  129. {
  130. struct circ_buf *xmit = &port->state->xmit;
  131. if (stat & ULITE_STATUS_TXFULL)
  132. return 0;
  133. if (port->x_char) {
  134. uart_out32(port->x_char, ULITE_TX, port);
  135. port->x_char = 0;
  136. port->icount.tx++;
  137. return 1;
  138. }
  139. if (uart_circ_empty(xmit) || uart_tx_stopped(port))
  140. return 0;
  141. uart_out32(xmit->buf[xmit->tail], ULITE_TX, port);
  142. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
  143. port->icount.tx++;
  144. /* wake up */
  145. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  146. uart_write_wakeup(port);
  147. return 1;
  148. }
  149. static irqreturn_t ulite_isr(int irq, void *dev_id)
  150. {
  151. struct uart_port *port = dev_id;
  152. int busy, n = 0;
  153. do {
  154. int stat = uart_in32(ULITE_STATUS, port);
  155. busy = ulite_receive(port, stat);
  156. busy |= ulite_transmit(port, stat);
  157. n++;
  158. } while (busy);
  159. /* work done? */
  160. if (n > 1) {
  161. tty_flip_buffer_push(&port->state->port);
  162. return IRQ_HANDLED;
  163. } else {
  164. return IRQ_NONE;
  165. }
  166. }
  167. static unsigned int ulite_tx_empty(struct uart_port *port)
  168. {
  169. unsigned long flags;
  170. unsigned int ret;
  171. spin_lock_irqsave(&port->lock, flags);
  172. ret = uart_in32(ULITE_STATUS, port);
  173. spin_unlock_irqrestore(&port->lock, flags);
  174. return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
  175. }
  176. static unsigned int ulite_get_mctrl(struct uart_port *port)
  177. {
  178. return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
  179. }
  180. static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl)
  181. {
  182. /* N/A */
  183. }
  184. static void ulite_stop_tx(struct uart_port *port)
  185. {
  186. /* N/A */
  187. }
  188. static void ulite_start_tx(struct uart_port *port)
  189. {
  190. ulite_transmit(port, uart_in32(ULITE_STATUS, port));
  191. }
  192. static void ulite_stop_rx(struct uart_port *port)
  193. {
  194. /* don't forward any more data (like !CREAD) */
  195. port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
  196. | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
  197. }
  198. static void ulite_break_ctl(struct uart_port *port, int ctl)
  199. {
  200. /* N/A */
  201. }
  202. static int ulite_startup(struct uart_port *port)
  203. {
  204. int ret;
  205. ret = request_irq(port->irq, ulite_isr, IRQF_SHARED, "uartlite", port);
  206. if (ret)
  207. return ret;
  208. uart_out32(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
  209. ULITE_CONTROL, port);
  210. uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port);
  211. return 0;
  212. }
  213. static void ulite_shutdown(struct uart_port *port)
  214. {
  215. uart_out32(0, ULITE_CONTROL, port);
  216. uart_in32(ULITE_CONTROL, port); /* dummy */
  217. free_irq(port->irq, port);
  218. }
  219. static void ulite_set_termios(struct uart_port *port, struct ktermios *termios,
  220. struct ktermios *old)
  221. {
  222. unsigned long flags;
  223. unsigned int baud;
  224. spin_lock_irqsave(&port->lock, flags);
  225. port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
  226. | ULITE_STATUS_TXFULL;
  227. if (termios->c_iflag & INPCK)
  228. port->read_status_mask |=
  229. ULITE_STATUS_PARITY | ULITE_STATUS_FRAME;
  230. port->ignore_status_mask = 0;
  231. if (termios->c_iflag & IGNPAR)
  232. port->ignore_status_mask |= ULITE_STATUS_PARITY
  233. | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
  234. /* ignore all characters if CREAD is not set */
  235. if ((termios->c_cflag & CREAD) == 0)
  236. port->ignore_status_mask |=
  237. ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
  238. | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
  239. /* update timeout */
  240. baud = uart_get_baud_rate(port, termios, old, 0, 460800);
  241. uart_update_timeout(port, termios->c_cflag, baud);
  242. spin_unlock_irqrestore(&port->lock, flags);
  243. }
  244. static const char *ulite_type(struct uart_port *port)
  245. {
  246. return port->type == PORT_UARTLITE ? "uartlite" : NULL;
  247. }
  248. static void ulite_release_port(struct uart_port *port)
  249. {
  250. release_mem_region(port->mapbase, ULITE_REGION);
  251. iounmap(port->membase);
  252. port->membase = NULL;
  253. }
  254. static int ulite_request_port(struct uart_port *port)
  255. {
  256. int ret;
  257. pr_debug("ulite console: port=%p; port->mapbase=%llx\n",
  258. port, (unsigned long long) port->mapbase);
  259. if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
  260. dev_err(port->dev, "Memory region busy\n");
  261. return -EBUSY;
  262. }
  263. port->membase = ioremap(port->mapbase, ULITE_REGION);
  264. if (!port->membase) {
  265. dev_err(port->dev, "Unable to map registers\n");
  266. release_mem_region(port->mapbase, ULITE_REGION);
  267. return -EBUSY;
  268. }
  269. port->private_data = &uartlite_be;
  270. ret = uart_in32(ULITE_CONTROL, port);
  271. uart_out32(ULITE_CONTROL_RST_TX, ULITE_CONTROL, port);
  272. ret = uart_in32(ULITE_STATUS, port);
  273. /* Endianess detection */
  274. if ((ret & ULITE_STATUS_TXEMPTY) != ULITE_STATUS_TXEMPTY)
  275. port->private_data = &uartlite_le;
  276. return 0;
  277. }
  278. static void ulite_config_port(struct uart_port *port, int flags)
  279. {
  280. if (!ulite_request_port(port))
  281. port->type = PORT_UARTLITE;
  282. }
  283. static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
  284. {
  285. /* we don't want the core code to modify any port params */
  286. return -EINVAL;
  287. }
  288. #ifdef CONFIG_CONSOLE_POLL
  289. static int ulite_get_poll_char(struct uart_port *port)
  290. {
  291. if (!(uart_in32(ULITE_STATUS, port) & ULITE_STATUS_RXVALID))
  292. return NO_POLL_CHAR;
  293. return uart_in32(ULITE_RX, port);
  294. }
  295. static void ulite_put_poll_char(struct uart_port *port, unsigned char ch)
  296. {
  297. while (uart_in32(ULITE_STATUS, port) & ULITE_STATUS_TXFULL)
  298. cpu_relax();
  299. /* write char to device */
  300. uart_out32(ch, ULITE_TX, port);
  301. }
  302. #endif
  303. static struct uart_ops ulite_ops = {
  304. .tx_empty = ulite_tx_empty,
  305. .set_mctrl = ulite_set_mctrl,
  306. .get_mctrl = ulite_get_mctrl,
  307. .stop_tx = ulite_stop_tx,
  308. .start_tx = ulite_start_tx,
  309. .stop_rx = ulite_stop_rx,
  310. .break_ctl = ulite_break_ctl,
  311. .startup = ulite_startup,
  312. .shutdown = ulite_shutdown,
  313. .set_termios = ulite_set_termios,
  314. .type = ulite_type,
  315. .release_port = ulite_release_port,
  316. .request_port = ulite_request_port,
  317. .config_port = ulite_config_port,
  318. .verify_port = ulite_verify_port,
  319. #ifdef CONFIG_CONSOLE_POLL
  320. .poll_get_char = ulite_get_poll_char,
  321. .poll_put_char = ulite_put_poll_char,
  322. #endif
  323. };
  324. /* ---------------------------------------------------------------------
  325. * Console driver operations
  326. */
  327. #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
  328. static void ulite_console_wait_tx(struct uart_port *port)
  329. {
  330. u8 val;
  331. unsigned long timeout;
  332. /*
  333. * Spin waiting for TX fifo to have space available.
  334. * When using the Microblaze Debug Module this can take up to 1s
  335. */
  336. timeout = jiffies + msecs_to_jiffies(1000);
  337. while (1) {
  338. val = uart_in32(ULITE_STATUS, port);
  339. if ((val & ULITE_STATUS_TXFULL) == 0)
  340. break;
  341. if (time_after(jiffies, timeout)) {
  342. dev_warn(port->dev,
  343. "timeout waiting for TX buffer empty\n");
  344. break;
  345. }
  346. cpu_relax();
  347. }
  348. }
  349. static void ulite_console_putchar(struct uart_port *port, int ch)
  350. {
  351. ulite_console_wait_tx(port);
  352. uart_out32(ch, ULITE_TX, port);
  353. }
  354. static void ulite_console_write(struct console *co, const char *s,
  355. unsigned int count)
  356. {
  357. struct uart_port *port = &ulite_ports[co->index];
  358. unsigned long flags;
  359. unsigned int ier;
  360. int locked = 1;
  361. if (oops_in_progress) {
  362. locked = spin_trylock_irqsave(&port->lock, flags);
  363. } else
  364. spin_lock_irqsave(&port->lock, flags);
  365. /* save and disable interrupt */
  366. ier = uart_in32(ULITE_STATUS, port) & ULITE_STATUS_IE;
  367. uart_out32(0, ULITE_CONTROL, port);
  368. uart_console_write(port, s, count, ulite_console_putchar);
  369. ulite_console_wait_tx(port);
  370. /* restore interrupt state */
  371. if (ier)
  372. uart_out32(ULITE_CONTROL_IE, ULITE_CONTROL, port);
  373. if (locked)
  374. spin_unlock_irqrestore(&port->lock, flags);
  375. }
  376. static int ulite_console_setup(struct console *co, char *options)
  377. {
  378. struct uart_port *port;
  379. int baud = 9600;
  380. int bits = 8;
  381. int parity = 'n';
  382. int flow = 'n';
  383. if (co->index < 0 || co->index >= ULITE_NR_UARTS)
  384. return -EINVAL;
  385. port = &ulite_ports[co->index];
  386. /* Has the device been initialized yet? */
  387. if (!port->mapbase) {
  388. pr_debug("console on ttyUL%i not present\n", co->index);
  389. return -ENODEV;
  390. }
  391. /* not initialized yet? */
  392. if (!port->membase) {
  393. if (ulite_request_port(port))
  394. return -ENODEV;
  395. }
  396. if (options)
  397. uart_parse_options(options, &baud, &parity, &bits, &flow);
  398. return uart_set_options(port, co, baud, parity, bits, flow);
  399. }
  400. static struct uart_driver ulite_uart_driver;
  401. static struct console ulite_console = {
  402. .name = ULITE_NAME,
  403. .write = ulite_console_write,
  404. .device = uart_console_device,
  405. .setup = ulite_console_setup,
  406. .flags = CON_PRINTBUFFER,
  407. .index = -1, /* Specified on the cmdline (e.g. console=ttyUL0 ) */
  408. .data = &ulite_uart_driver,
  409. };
  410. static int __init ulite_console_init(void)
  411. {
  412. register_console(&ulite_console);
  413. return 0;
  414. }
  415. console_initcall(ulite_console_init);
  416. #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
  417. static struct uart_driver ulite_uart_driver = {
  418. .owner = THIS_MODULE,
  419. .driver_name = "uartlite",
  420. .dev_name = ULITE_NAME,
  421. .major = ULITE_MAJOR,
  422. .minor = ULITE_MINOR,
  423. .nr = ULITE_NR_UARTS,
  424. #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
  425. .cons = &ulite_console,
  426. #endif
  427. };
  428. /* ---------------------------------------------------------------------
  429. * Port assignment functions (mapping devices to uart_port structures)
  430. */
  431. /** ulite_assign: register a uartlite device with the driver
  432. *
  433. * @dev: pointer to device structure
  434. * @id: requested id number. Pass -1 for automatic port assignment
  435. * @base: base address of uartlite registers
  436. * @irq: irq number for uartlite
  437. *
  438. * Returns: 0 on success, <0 otherwise
  439. */
  440. static int ulite_assign(struct device *dev, int id, u32 base, int irq)
  441. {
  442. struct uart_port *port;
  443. int rc;
  444. /* if id = -1; then scan for a free id and use that */
  445. if (id < 0) {
  446. for (id = 0; id < ULITE_NR_UARTS; id++)
  447. if (ulite_ports[id].mapbase == 0)
  448. break;
  449. }
  450. if (id < 0 || id >= ULITE_NR_UARTS) {
  451. dev_err(dev, "%s%i too large\n", ULITE_NAME, id);
  452. return -EINVAL;
  453. }
  454. if ((ulite_ports[id].mapbase) && (ulite_ports[id].mapbase != base)) {
  455. dev_err(dev, "cannot assign to %s%i; it is already in use\n",
  456. ULITE_NAME, id);
  457. return -EBUSY;
  458. }
  459. port = &ulite_ports[id];
  460. spin_lock_init(&port->lock);
  461. port->fifosize = 16;
  462. port->regshift = 2;
  463. port->iotype = UPIO_MEM;
  464. port->iobase = 1; /* mark port in use */
  465. port->mapbase = base;
  466. port->membase = NULL;
  467. port->ops = &ulite_ops;
  468. port->irq = irq;
  469. port->flags = UPF_BOOT_AUTOCONF;
  470. port->dev = dev;
  471. port->type = PORT_UNKNOWN;
  472. port->line = id;
  473. dev_set_drvdata(dev, port);
  474. /* Register the port */
  475. rc = uart_add_one_port(&ulite_uart_driver, port);
  476. if (rc) {
  477. dev_err(dev, "uart_add_one_port() failed; err=%i\n", rc);
  478. port->mapbase = 0;
  479. dev_set_drvdata(dev, NULL);
  480. return rc;
  481. }
  482. return 0;
  483. }
  484. /** ulite_release: register a uartlite device with the driver
  485. *
  486. * @dev: pointer to device structure
  487. */
  488. static int ulite_release(struct device *dev)
  489. {
  490. struct uart_port *port = dev_get_drvdata(dev);
  491. int rc = 0;
  492. if (port) {
  493. rc = uart_remove_one_port(&ulite_uart_driver, port);
  494. dev_set_drvdata(dev, NULL);
  495. port->mapbase = 0;
  496. }
  497. return rc;
  498. }
  499. /* ---------------------------------------------------------------------
  500. * Platform bus binding
  501. */
  502. #if defined(CONFIG_OF)
  503. /* Match table for of_platform binding */
  504. static const struct of_device_id ulite_of_match[] = {
  505. { .compatible = "xlnx,opb-uartlite-1.00.b", },
  506. { .compatible = "xlnx,xps-uartlite-1.00.a", },
  507. {}
  508. };
  509. MODULE_DEVICE_TABLE(of, ulite_of_match);
  510. #endif /* CONFIG_OF */
  511. static int ulite_probe(struct platform_device *pdev)
  512. {
  513. struct resource *res;
  514. int irq;
  515. int id = pdev->id;
  516. #ifdef CONFIG_OF
  517. const __be32 *prop;
  518. prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
  519. if (prop)
  520. id = be32_to_cpup(prop);
  521. #endif
  522. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  523. if (!res)
  524. return -ENODEV;
  525. irq = platform_get_irq(pdev, 0);
  526. if (irq <= 0)
  527. return -ENXIO;
  528. return ulite_assign(&pdev->dev, id, res->start, irq);
  529. }
  530. static int ulite_remove(struct platform_device *pdev)
  531. {
  532. return ulite_release(&pdev->dev);
  533. }
  534. /* work with hotplug and coldplug */
  535. MODULE_ALIAS("platform:uartlite");
  536. static struct platform_driver ulite_platform_driver = {
  537. .probe = ulite_probe,
  538. .remove = ulite_remove,
  539. .driver = {
  540. .name = "uartlite",
  541. .of_match_table = of_match_ptr(ulite_of_match),
  542. },
  543. };
  544. /* ---------------------------------------------------------------------
  545. * Module setup/teardown
  546. */
  547. static int __init ulite_init(void)
  548. {
  549. int ret;
  550. pr_debug("uartlite: calling uart_register_driver()\n");
  551. ret = uart_register_driver(&ulite_uart_driver);
  552. if (ret)
  553. goto err_uart;
  554. pr_debug("uartlite: calling platform_driver_register()\n");
  555. ret = platform_driver_register(&ulite_platform_driver);
  556. if (ret)
  557. goto err_plat;
  558. return 0;
  559. err_plat:
  560. uart_unregister_driver(&ulite_uart_driver);
  561. err_uart:
  562. pr_err("registering uartlite driver failed: err=%i", ret);
  563. return ret;
  564. }
  565. static void __exit ulite_exit(void)
  566. {
  567. platform_driver_unregister(&ulite_platform_driver);
  568. uart_unregister_driver(&ulite_uart_driver);
  569. }
  570. module_init(ulite_init);
  571. module_exit(ulite_exit);
  572. MODULE_AUTHOR("Peter Korsgaard <jacmet@sunsite.dk>");
  573. MODULE_DESCRIPTION("Xilinx uartlite serial driver");
  574. MODULE_LICENSE("GPL");