ar933x_uart.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Atheros AR933X SoC built-in UART driver
  3. *
  4. * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
  5. *
  6. * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/ioport.h>
  14. #include <linux/init.h>
  15. #include <linux/console.h>
  16. #include <linux/sysrq.h>
  17. #include <linux/delay.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/tty.h>
  20. #include <linux/tty_flip.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/serial.h>
  23. #include <linux/slab.h>
  24. #include <linux/io.h>
  25. #include <linux/irq.h>
  26. #include <asm/mach-ath79/ar933x_uart.h>
  27. #include <asm/mach-ath79/ar933x_uart_platform.h>
  28. #define DRIVER_NAME "ar933x-uart"
  29. #define AR933X_DUMMY_STATUS_RD 0x01
  30. static struct uart_driver ar933x_uart_driver;
  31. struct ar933x_uart_port {
  32. struct uart_port port;
  33. unsigned int ier; /* shadow Interrupt Enable Register */
  34. };
  35. static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
  36. int offset)
  37. {
  38. return readl(up->port.membase + offset);
  39. }
  40. static inline void ar933x_uart_write(struct ar933x_uart_port *up,
  41. int offset, unsigned int value)
  42. {
  43. writel(value, up->port.membase + offset);
  44. }
  45. static inline void ar933x_uart_rmw(struct ar933x_uart_port *up,
  46. unsigned int offset,
  47. unsigned int mask,
  48. unsigned int val)
  49. {
  50. unsigned int t;
  51. t = ar933x_uart_read(up, offset);
  52. t &= ~mask;
  53. t |= val;
  54. ar933x_uart_write(up, offset, t);
  55. }
  56. static inline void ar933x_uart_rmw_set(struct ar933x_uart_port *up,
  57. unsigned int offset,
  58. unsigned int val)
  59. {
  60. ar933x_uart_rmw(up, offset, 0, val);
  61. }
  62. static inline void ar933x_uart_rmw_clear(struct ar933x_uart_port *up,
  63. unsigned int offset,
  64. unsigned int val)
  65. {
  66. ar933x_uart_rmw(up, offset, val, 0);
  67. }
  68. static inline void ar933x_uart_start_tx_interrupt(struct ar933x_uart_port *up)
  69. {
  70. up->ier |= AR933X_UART_INT_TX_EMPTY;
  71. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
  72. }
  73. static inline void ar933x_uart_stop_tx_interrupt(struct ar933x_uart_port *up)
  74. {
  75. up->ier &= ~AR933X_UART_INT_TX_EMPTY;
  76. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
  77. }
  78. static inline void ar933x_uart_putc(struct ar933x_uart_port *up, int ch)
  79. {
  80. unsigned int rdata;
  81. rdata = ch & AR933X_UART_DATA_TX_RX_MASK;
  82. rdata |= AR933X_UART_DATA_TX_CSR;
  83. ar933x_uart_write(up, AR933X_UART_DATA_REG, rdata);
  84. }
  85. static unsigned int ar933x_uart_tx_empty(struct uart_port *port)
  86. {
  87. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  88. unsigned long flags;
  89. unsigned int rdata;
  90. spin_lock_irqsave(&up->port.lock, flags);
  91. rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG);
  92. spin_unlock_irqrestore(&up->port.lock, flags);
  93. return (rdata & AR933X_UART_DATA_TX_CSR) ? 0 : TIOCSER_TEMT;
  94. }
  95. static unsigned int ar933x_uart_get_mctrl(struct uart_port *port)
  96. {
  97. return TIOCM_CAR;
  98. }
  99. static void ar933x_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
  100. {
  101. }
  102. static void ar933x_uart_start_tx(struct uart_port *port)
  103. {
  104. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  105. ar933x_uart_start_tx_interrupt(up);
  106. }
  107. static void ar933x_uart_stop_tx(struct uart_port *port)
  108. {
  109. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  110. ar933x_uart_stop_tx_interrupt(up);
  111. }
  112. static void ar933x_uart_stop_rx(struct uart_port *port)
  113. {
  114. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  115. up->ier &= ~AR933X_UART_INT_RX_VALID;
  116. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
  117. }
  118. static void ar933x_uart_break_ctl(struct uart_port *port, int break_state)
  119. {
  120. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  121. unsigned long flags;
  122. spin_lock_irqsave(&up->port.lock, flags);
  123. if (break_state == -1)
  124. ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
  125. AR933X_UART_CS_TX_BREAK);
  126. else
  127. ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG,
  128. AR933X_UART_CS_TX_BREAK);
  129. spin_unlock_irqrestore(&up->port.lock, flags);
  130. }
  131. static void ar933x_uart_enable_ms(struct uart_port *port)
  132. {
  133. }
  134. static void ar933x_uart_set_termios(struct uart_port *port,
  135. struct ktermios *new,
  136. struct ktermios *old)
  137. {
  138. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  139. unsigned int cs;
  140. unsigned long flags;
  141. unsigned int baud, scale;
  142. /* Only CS8 is supported */
  143. new->c_cflag &= ~CSIZE;
  144. new->c_cflag |= CS8;
  145. /* Only one stop bit is supported */
  146. new->c_cflag &= ~CSTOPB;
  147. cs = 0;
  148. if (new->c_cflag & PARENB) {
  149. if (!(new->c_cflag & PARODD))
  150. cs |= AR933X_UART_CS_PARITY_EVEN;
  151. else
  152. cs |= AR933X_UART_CS_PARITY_ODD;
  153. } else {
  154. cs |= AR933X_UART_CS_PARITY_NONE;
  155. }
  156. /* Mark/space parity is not supported */
  157. new->c_cflag &= ~CMSPAR;
  158. baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
  159. scale = (port->uartclk / (16 * baud)) - 1;
  160. /*
  161. * Ok, we're now changing the port state. Do it with
  162. * interrupts disabled.
  163. */
  164. spin_lock_irqsave(&up->port.lock, flags);
  165. /* Update the per-port timeout. */
  166. uart_update_timeout(port, new->c_cflag, baud);
  167. up->port.ignore_status_mask = 0;
  168. /* ignore all characters if CREAD is not set */
  169. if ((new->c_cflag & CREAD) == 0)
  170. up->port.ignore_status_mask |= AR933X_DUMMY_STATUS_RD;
  171. ar933x_uart_write(up, AR933X_UART_CLOCK_REG,
  172. scale << AR933X_UART_CLOCK_SCALE_S | 8192);
  173. /* setup configuration register */
  174. ar933x_uart_rmw(up, AR933X_UART_CS_REG, AR933X_UART_CS_PARITY_M, cs);
  175. /* enable host interrupt */
  176. ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
  177. AR933X_UART_CS_HOST_INT_EN);
  178. spin_unlock_irqrestore(&up->port.lock, flags);
  179. if (tty_termios_baud_rate(new))
  180. tty_termios_encode_baud_rate(new, baud, baud);
  181. }
  182. static void ar933x_uart_rx_chars(struct ar933x_uart_port *up)
  183. {
  184. struct tty_struct *tty;
  185. int max_count = 256;
  186. tty = tty_port_tty_get(&up->port.state->port);
  187. do {
  188. unsigned int rdata;
  189. unsigned char ch;
  190. rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG);
  191. if ((rdata & AR933X_UART_DATA_RX_CSR) == 0)
  192. break;
  193. /* remove the character from the FIFO */
  194. ar933x_uart_write(up, AR933X_UART_DATA_REG,
  195. AR933X_UART_DATA_RX_CSR);
  196. if (!tty) {
  197. /* discard the data if no tty available */
  198. continue;
  199. }
  200. up->port.icount.rx++;
  201. ch = rdata & AR933X_UART_DATA_TX_RX_MASK;
  202. if (uart_handle_sysrq_char(&up->port, ch))
  203. continue;
  204. if ((up->port.ignore_status_mask & AR933X_DUMMY_STATUS_RD) == 0)
  205. tty_insert_flip_char(tty, ch, TTY_NORMAL);
  206. } while (max_count-- > 0);
  207. if (tty) {
  208. tty_flip_buffer_push(tty);
  209. tty_kref_put(tty);
  210. }
  211. }
  212. static void ar933x_uart_tx_chars(struct ar933x_uart_port *up)
  213. {
  214. struct circ_buf *xmit = &up->port.state->xmit;
  215. int count;
  216. if (uart_tx_stopped(&up->port))
  217. return;
  218. count = up->port.fifosize;
  219. do {
  220. unsigned int rdata;
  221. rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG);
  222. if ((rdata & AR933X_UART_DATA_TX_CSR) == 0)
  223. break;
  224. if (up->port.x_char) {
  225. ar933x_uart_putc(up, up->port.x_char);
  226. up->port.icount.tx++;
  227. up->port.x_char = 0;
  228. continue;
  229. }
  230. if (uart_circ_empty(xmit))
  231. break;
  232. ar933x_uart_putc(up, xmit->buf[xmit->tail]);
  233. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  234. up->port.icount.tx++;
  235. } while (--count > 0);
  236. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  237. uart_write_wakeup(&up->port);
  238. if (!uart_circ_empty(xmit))
  239. ar933x_uart_start_tx_interrupt(up);
  240. }
  241. static irqreturn_t ar933x_uart_interrupt(int irq, void *dev_id)
  242. {
  243. struct ar933x_uart_port *up = dev_id;
  244. unsigned int status;
  245. status = ar933x_uart_read(up, AR933X_UART_CS_REG);
  246. if ((status & AR933X_UART_CS_HOST_INT) == 0)
  247. return IRQ_NONE;
  248. spin_lock(&up->port.lock);
  249. status = ar933x_uart_read(up, AR933X_UART_INT_REG);
  250. status &= ar933x_uart_read(up, AR933X_UART_INT_EN_REG);
  251. if (status & AR933X_UART_INT_RX_VALID) {
  252. ar933x_uart_write(up, AR933X_UART_INT_REG,
  253. AR933X_UART_INT_RX_VALID);
  254. ar933x_uart_rx_chars(up);
  255. }
  256. if (status & AR933X_UART_INT_TX_EMPTY) {
  257. ar933x_uart_write(up, AR933X_UART_INT_REG,
  258. AR933X_UART_INT_TX_EMPTY);
  259. ar933x_uart_stop_tx_interrupt(up);
  260. ar933x_uart_tx_chars(up);
  261. }
  262. spin_unlock(&up->port.lock);
  263. return IRQ_HANDLED;
  264. }
  265. static int ar933x_uart_startup(struct uart_port *port)
  266. {
  267. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  268. unsigned long flags;
  269. int ret;
  270. ret = request_irq(up->port.irq, ar933x_uart_interrupt,
  271. up->port.irqflags, dev_name(up->port.dev), up);
  272. if (ret)
  273. return ret;
  274. spin_lock_irqsave(&up->port.lock, flags);
  275. /* Enable HOST interrupts */
  276. ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
  277. AR933X_UART_CS_HOST_INT_EN);
  278. /* Enable RX interrupts */
  279. up->ier = AR933X_UART_INT_RX_VALID;
  280. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
  281. spin_unlock_irqrestore(&up->port.lock, flags);
  282. return 0;
  283. }
  284. static void ar933x_uart_shutdown(struct uart_port *port)
  285. {
  286. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  287. /* Disable all interrupts */
  288. up->ier = 0;
  289. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier);
  290. /* Disable break condition */
  291. ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG,
  292. AR933X_UART_CS_TX_BREAK);
  293. free_irq(up->port.irq, up);
  294. }
  295. static const char *ar933x_uart_type(struct uart_port *port)
  296. {
  297. return (port->type == PORT_AR933X) ? "AR933X UART" : NULL;
  298. }
  299. static void ar933x_uart_release_port(struct uart_port *port)
  300. {
  301. /* Nothing to release ... */
  302. }
  303. static int ar933x_uart_request_port(struct uart_port *port)
  304. {
  305. /* UARTs always present */
  306. return 0;
  307. }
  308. static void ar933x_uart_config_port(struct uart_port *port, int flags)
  309. {
  310. if (flags & UART_CONFIG_TYPE)
  311. port->type = PORT_AR933X;
  312. }
  313. static int ar933x_uart_verify_port(struct uart_port *port,
  314. struct serial_struct *ser)
  315. {
  316. if (ser->type != PORT_UNKNOWN &&
  317. ser->type != PORT_AR933X)
  318. return -EINVAL;
  319. if (ser->irq < 0 || ser->irq >= NR_IRQS)
  320. return -EINVAL;
  321. if (ser->baud_base < 28800)
  322. return -EINVAL;
  323. return 0;
  324. }
  325. static struct uart_ops ar933x_uart_ops = {
  326. .tx_empty = ar933x_uart_tx_empty,
  327. .set_mctrl = ar933x_uart_set_mctrl,
  328. .get_mctrl = ar933x_uart_get_mctrl,
  329. .stop_tx = ar933x_uart_stop_tx,
  330. .start_tx = ar933x_uart_start_tx,
  331. .stop_rx = ar933x_uart_stop_rx,
  332. .enable_ms = ar933x_uart_enable_ms,
  333. .break_ctl = ar933x_uart_break_ctl,
  334. .startup = ar933x_uart_startup,
  335. .shutdown = ar933x_uart_shutdown,
  336. .set_termios = ar933x_uart_set_termios,
  337. .type = ar933x_uart_type,
  338. .release_port = ar933x_uart_release_port,
  339. .request_port = ar933x_uart_request_port,
  340. .config_port = ar933x_uart_config_port,
  341. .verify_port = ar933x_uart_verify_port,
  342. };
  343. #ifdef CONFIG_SERIAL_AR933X_CONSOLE
  344. static struct ar933x_uart_port *
  345. ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
  346. static void ar933x_uart_wait_xmitr(struct ar933x_uart_port *up)
  347. {
  348. unsigned int status;
  349. unsigned int timeout = 60000;
  350. /* Wait up to 60ms for the character(s) to be sent. */
  351. do {
  352. status = ar933x_uart_read(up, AR933X_UART_DATA_REG);
  353. if (--timeout == 0)
  354. break;
  355. udelay(1);
  356. } while ((status & AR933X_UART_DATA_TX_CSR) == 0);
  357. }
  358. static void ar933x_uart_console_putchar(struct uart_port *port, int ch)
  359. {
  360. struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
  361. ar933x_uart_wait_xmitr(up);
  362. ar933x_uart_putc(up, ch);
  363. }
  364. static void ar933x_uart_console_write(struct console *co, const char *s,
  365. unsigned int count)
  366. {
  367. struct ar933x_uart_port *up = ar933x_console_ports[co->index];
  368. unsigned long flags;
  369. unsigned int int_en;
  370. int locked = 1;
  371. local_irq_save(flags);
  372. if (up->port.sysrq)
  373. locked = 0;
  374. else if (oops_in_progress)
  375. locked = spin_trylock(&up->port.lock);
  376. else
  377. spin_lock(&up->port.lock);
  378. /*
  379. * First save the IER then disable the interrupts
  380. */
  381. int_en = ar933x_uart_read(up, AR933X_UART_INT_EN_REG);
  382. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0);
  383. uart_console_write(&up->port, s, count, ar933x_uart_console_putchar);
  384. /*
  385. * Finally, wait for transmitter to become empty
  386. * and restore the IER
  387. */
  388. ar933x_uart_wait_xmitr(up);
  389. ar933x_uart_write(up, AR933X_UART_INT_EN_REG, int_en);
  390. ar933x_uart_write(up, AR933X_UART_INT_REG, AR933X_UART_INT_ALLINTS);
  391. if (locked)
  392. spin_unlock(&up->port.lock);
  393. local_irq_restore(flags);
  394. }
  395. static int ar933x_uart_console_setup(struct console *co, char *options)
  396. {
  397. struct ar933x_uart_port *up;
  398. int baud = 115200;
  399. int bits = 8;
  400. int parity = 'n';
  401. int flow = 'n';
  402. if (co->index < 0 || co->index >= CONFIG_SERIAL_AR933X_NR_UARTS)
  403. return -EINVAL;
  404. up = ar933x_console_ports[co->index];
  405. if (!up)
  406. return -ENODEV;
  407. if (options)
  408. uart_parse_options(options, &baud, &parity, &bits, &flow);
  409. return uart_set_options(&up->port, co, baud, parity, bits, flow);
  410. }
  411. static struct console ar933x_uart_console = {
  412. .name = "ttyATH",
  413. .write = ar933x_uart_console_write,
  414. .device = uart_console_device,
  415. .setup = ar933x_uart_console_setup,
  416. .flags = CON_PRINTBUFFER,
  417. .index = -1,
  418. .data = &ar933x_uart_driver,
  419. };
  420. static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
  421. {
  422. ar933x_console_ports[up->port.line] = up;
  423. }
  424. #define AR933X_SERIAL_CONSOLE (&ar933x_uart_console)
  425. #else
  426. static inline void ar933x_uart_add_console_port(struct ar933x_uart_port *up) {}
  427. #define AR933X_SERIAL_CONSOLE NULL
  428. #endif /* CONFIG_SERIAL_AR933X_CONSOLE */
  429. static struct uart_driver ar933x_uart_driver = {
  430. .owner = THIS_MODULE,
  431. .driver_name = DRIVER_NAME,
  432. .dev_name = "ttyATH",
  433. .nr = CONFIG_SERIAL_AR933X_NR_UARTS,
  434. .cons = AR933X_SERIAL_CONSOLE,
  435. };
  436. static int __devinit ar933x_uart_probe(struct platform_device *pdev)
  437. {
  438. struct ar933x_uart_platform_data *pdata;
  439. struct ar933x_uart_port *up;
  440. struct uart_port *port;
  441. struct resource *mem_res;
  442. struct resource *irq_res;
  443. int id;
  444. int ret;
  445. pdata = pdev->dev.platform_data;
  446. if (!pdata)
  447. return -EINVAL;
  448. id = pdev->id;
  449. if (id == -1)
  450. id = 0;
  451. if (id > CONFIG_SERIAL_AR933X_NR_UARTS)
  452. return -EINVAL;
  453. mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  454. if (!mem_res) {
  455. dev_err(&pdev->dev, "no MEM resource\n");
  456. return -EINVAL;
  457. }
  458. irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  459. if (!irq_res) {
  460. dev_err(&pdev->dev, "no IRQ resource\n");
  461. return -EINVAL;
  462. }
  463. up = kzalloc(sizeof(struct ar933x_uart_port), GFP_KERNEL);
  464. if (!up)
  465. return -ENOMEM;
  466. port = &up->port;
  467. port->mapbase = mem_res->start;
  468. port->membase = ioremap(mem_res->start, AR933X_UART_REGS_SIZE);
  469. if (!port->membase) {
  470. ret = -ENOMEM;
  471. goto err_free_up;
  472. }
  473. port->line = id;
  474. port->irq = irq_res->start;
  475. port->dev = &pdev->dev;
  476. port->type = PORT_AR933X;
  477. port->iotype = UPIO_MEM32;
  478. port->uartclk = pdata->uartclk;
  479. port->regshift = 2;
  480. port->fifosize = AR933X_UART_FIFO_SIZE;
  481. port->ops = &ar933x_uart_ops;
  482. ar933x_uart_add_console_port(up);
  483. ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
  484. if (ret)
  485. goto err_unmap;
  486. platform_set_drvdata(pdev, up);
  487. return 0;
  488. err_unmap:
  489. iounmap(up->port.membase);
  490. err_free_up:
  491. kfree(up);
  492. return ret;
  493. }
  494. static int __devexit ar933x_uart_remove(struct platform_device *pdev)
  495. {
  496. struct ar933x_uart_port *up;
  497. up = platform_get_drvdata(pdev);
  498. platform_set_drvdata(pdev, NULL);
  499. if (up) {
  500. uart_remove_one_port(&ar933x_uart_driver, &up->port);
  501. iounmap(up->port.membase);
  502. kfree(up);
  503. }
  504. return 0;
  505. }
  506. static struct platform_driver ar933x_uart_platform_driver = {
  507. .probe = ar933x_uart_probe,
  508. .remove = __devexit_p(ar933x_uart_remove),
  509. .driver = {
  510. .name = DRIVER_NAME,
  511. .owner = THIS_MODULE,
  512. },
  513. };
  514. static int __init ar933x_uart_init(void)
  515. {
  516. int ret;
  517. ar933x_uart_driver.nr = CONFIG_SERIAL_AR933X_NR_UARTS;
  518. ret = uart_register_driver(&ar933x_uart_driver);
  519. if (ret)
  520. goto err_out;
  521. ret = platform_driver_register(&ar933x_uart_platform_driver);
  522. if (ret)
  523. goto err_unregister_uart_driver;
  524. return 0;
  525. err_unregister_uart_driver:
  526. uart_unregister_driver(&ar933x_uart_driver);
  527. err_out:
  528. return ret;
  529. }
  530. static void __exit ar933x_uart_exit(void)
  531. {
  532. platform_driver_unregister(&ar933x_uart_platform_driver);
  533. uart_unregister_driver(&ar933x_uart_driver);
  534. }
  535. module_init(ar933x_uart_init);
  536. module_exit(ar933x_uart_exit);
  537. MODULE_DESCRIPTION("Atheros AR933X UART driver");
  538. MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  539. MODULE_LICENSE("GPL v2");
  540. MODULE_ALIAS("platform:" DRIVER_NAME);