uartlite.c 17 KB

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