mps2-uart.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * MPS2 UART driver
  4. *
  5. * Copyright (C) 2015 ARM Limited
  6. *
  7. * Author: Vladimir Murzin <vladimir.murzin@arm.com>
  8. *
  9. * TODO: support for SysRq
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/bitops.h>
  13. #include <linux/clk.h>
  14. #include <linux/console.h>
  15. #include <linux/io.h>
  16. #include <linux/kernel.h>
  17. #include <linux/of_device.h>
  18. #include <linux/of.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/tty_flip.h>
  22. #include <linux/types.h>
  23. #include <linux/idr.h>
  24. #define SERIAL_NAME "ttyMPS"
  25. #define DRIVER_NAME "mps2-uart"
  26. #define MAKE_NAME(x) (DRIVER_NAME # x)
  27. #define UARTn_DATA 0x00
  28. #define UARTn_STATE 0x04
  29. #define UARTn_STATE_TX_FULL BIT(0)
  30. #define UARTn_STATE_RX_FULL BIT(1)
  31. #define UARTn_STATE_TX_OVERRUN BIT(2)
  32. #define UARTn_STATE_RX_OVERRUN BIT(3)
  33. #define UARTn_CTRL 0x08
  34. #define UARTn_CTRL_TX_ENABLE BIT(0)
  35. #define UARTn_CTRL_RX_ENABLE BIT(1)
  36. #define UARTn_CTRL_TX_INT_ENABLE BIT(2)
  37. #define UARTn_CTRL_RX_INT_ENABLE BIT(3)
  38. #define UARTn_CTRL_TX_OVERRUN_INT_ENABLE BIT(4)
  39. #define UARTn_CTRL_RX_OVERRUN_INT_ENABLE BIT(5)
  40. #define UARTn_INT 0x0c
  41. #define UARTn_INT_TX BIT(0)
  42. #define UARTn_INT_RX BIT(1)
  43. #define UARTn_INT_TX_OVERRUN BIT(2)
  44. #define UARTn_INT_RX_OVERRUN BIT(3)
  45. #define UARTn_BAUDDIV 0x10
  46. #define UARTn_BAUDDIV_MASK GENMASK(20, 0)
  47. /*
  48. * Helpers to make typical enable/disable operations more readable.
  49. */
  50. #define UARTn_CTRL_TX_GRP (UARTn_CTRL_TX_ENABLE |\
  51. UARTn_CTRL_TX_INT_ENABLE |\
  52. UARTn_CTRL_TX_OVERRUN_INT_ENABLE)
  53. #define UARTn_CTRL_RX_GRP (UARTn_CTRL_RX_ENABLE |\
  54. UARTn_CTRL_RX_INT_ENABLE |\
  55. UARTn_CTRL_RX_OVERRUN_INT_ENABLE)
  56. #define MPS2_MAX_PORTS 3
  57. #define UART_PORT_COMBINED_IRQ BIT(0)
  58. struct mps2_uart_port {
  59. struct uart_port port;
  60. struct clk *clk;
  61. unsigned int tx_irq;
  62. unsigned int rx_irq;
  63. unsigned int flags;
  64. };
  65. static inline struct mps2_uart_port *to_mps2_port(struct uart_port *port)
  66. {
  67. return container_of(port, struct mps2_uart_port, port);
  68. }
  69. static void mps2_uart_write8(struct uart_port *port, u8 val, unsigned int off)
  70. {
  71. struct mps2_uart_port *mps_port = to_mps2_port(port);
  72. writeb(val, mps_port->port.membase + off);
  73. }
  74. static u8 mps2_uart_read8(struct uart_port *port, unsigned int off)
  75. {
  76. struct mps2_uart_port *mps_port = to_mps2_port(port);
  77. return readb(mps_port->port.membase + off);
  78. }
  79. static void mps2_uart_write32(struct uart_port *port, u32 val, unsigned int off)
  80. {
  81. struct mps2_uart_port *mps_port = to_mps2_port(port);
  82. writel_relaxed(val, mps_port->port.membase + off);
  83. }
  84. static unsigned int mps2_uart_tx_empty(struct uart_port *port)
  85. {
  86. u8 status = mps2_uart_read8(port, UARTn_STATE);
  87. return (status & UARTn_STATE_TX_FULL) ? 0 : TIOCSER_TEMT;
  88. }
  89. static void mps2_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
  90. {
  91. }
  92. static unsigned int mps2_uart_get_mctrl(struct uart_port *port)
  93. {
  94. return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR;
  95. }
  96. static void mps2_uart_stop_tx(struct uart_port *port)
  97. {
  98. u8 control = mps2_uart_read8(port, UARTn_CTRL);
  99. control &= ~UARTn_CTRL_TX_INT_ENABLE;
  100. mps2_uart_write8(port, control, UARTn_CTRL);
  101. }
  102. static void mps2_uart_tx_chars(struct uart_port *port)
  103. {
  104. struct circ_buf *xmit = &port->state->xmit;
  105. while (!(mps2_uart_read8(port, UARTn_STATE) & UARTn_STATE_TX_FULL)) {
  106. if (port->x_char) {
  107. mps2_uart_write8(port, port->x_char, UARTn_DATA);
  108. port->x_char = 0;
  109. port->icount.tx++;
  110. continue;
  111. }
  112. if (uart_circ_empty(xmit) || uart_tx_stopped(port))
  113. break;
  114. mps2_uart_write8(port, xmit->buf[xmit->tail], UARTn_DATA);
  115. xmit->tail = (xmit->tail + 1) % UART_XMIT_SIZE;
  116. port->icount.tx++;
  117. }
  118. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  119. uart_write_wakeup(port);
  120. if (uart_circ_empty(xmit))
  121. mps2_uart_stop_tx(port);
  122. }
  123. static void mps2_uart_start_tx(struct uart_port *port)
  124. {
  125. u8 control = mps2_uart_read8(port, UARTn_CTRL);
  126. control |= UARTn_CTRL_TX_INT_ENABLE;
  127. mps2_uart_write8(port, control, UARTn_CTRL);
  128. /*
  129. * We've just unmasked the TX IRQ and now slow-starting via
  130. * polling; if there is enough data to fill up the internal
  131. * write buffer in one go, the TX IRQ should assert, at which
  132. * point we switch to fully interrupt-driven TX.
  133. */
  134. mps2_uart_tx_chars(port);
  135. }
  136. static void mps2_uart_stop_rx(struct uart_port *port)
  137. {
  138. u8 control = mps2_uart_read8(port, UARTn_CTRL);
  139. control &= ~UARTn_CTRL_RX_GRP;
  140. mps2_uart_write8(port, control, UARTn_CTRL);
  141. }
  142. static void mps2_uart_break_ctl(struct uart_port *port, int ctl)
  143. {
  144. }
  145. static void mps2_uart_rx_chars(struct uart_port *port)
  146. {
  147. struct tty_port *tport = &port->state->port;
  148. while (mps2_uart_read8(port, UARTn_STATE) & UARTn_STATE_RX_FULL) {
  149. u8 rxdata = mps2_uart_read8(port, UARTn_DATA);
  150. port->icount.rx++;
  151. tty_insert_flip_char(&port->state->port, rxdata, TTY_NORMAL);
  152. }
  153. tty_flip_buffer_push(tport);
  154. }
  155. static irqreturn_t mps2_uart_rxirq(int irq, void *data)
  156. {
  157. struct uart_port *port = data;
  158. u8 irqflag = mps2_uart_read8(port, UARTn_INT);
  159. if (unlikely(!(irqflag & UARTn_INT_RX)))
  160. return IRQ_NONE;
  161. spin_lock(&port->lock);
  162. mps2_uart_write8(port, UARTn_INT_RX, UARTn_INT);
  163. mps2_uart_rx_chars(port);
  164. spin_unlock(&port->lock);
  165. return IRQ_HANDLED;
  166. }
  167. static irqreturn_t mps2_uart_txirq(int irq, void *data)
  168. {
  169. struct uart_port *port = data;
  170. u8 irqflag = mps2_uart_read8(port, UARTn_INT);
  171. if (unlikely(!(irqflag & UARTn_INT_TX)))
  172. return IRQ_NONE;
  173. spin_lock(&port->lock);
  174. mps2_uart_write8(port, UARTn_INT_TX, UARTn_INT);
  175. mps2_uart_tx_chars(port);
  176. spin_unlock(&port->lock);
  177. return IRQ_HANDLED;
  178. }
  179. static irqreturn_t mps2_uart_oerrirq(int irq, void *data)
  180. {
  181. irqreturn_t handled = IRQ_NONE;
  182. struct uart_port *port = data;
  183. u8 irqflag = mps2_uart_read8(port, UARTn_INT);
  184. spin_lock(&port->lock);
  185. if (irqflag & UARTn_INT_RX_OVERRUN) {
  186. struct tty_port *tport = &port->state->port;
  187. mps2_uart_write8(port, UARTn_INT_RX_OVERRUN, UARTn_INT);
  188. port->icount.overrun++;
  189. tty_insert_flip_char(tport, 0, TTY_OVERRUN);
  190. tty_flip_buffer_push(tport);
  191. handled = IRQ_HANDLED;
  192. }
  193. /*
  194. * It's never been seen in practice and it never *should* happen since
  195. * we check if there is enough room in TX buffer before sending data.
  196. * So we keep this check in case something suspicious has happened.
  197. */
  198. if (irqflag & UARTn_INT_TX_OVERRUN) {
  199. mps2_uart_write8(port, UARTn_INT_TX_OVERRUN, UARTn_INT);
  200. handled = IRQ_HANDLED;
  201. }
  202. spin_unlock(&port->lock);
  203. return handled;
  204. }
  205. static irqreturn_t mps2_uart_combinedirq(int irq, void *data)
  206. {
  207. if (mps2_uart_rxirq(irq, data) == IRQ_HANDLED)
  208. return IRQ_HANDLED;
  209. if (mps2_uart_txirq(irq, data) == IRQ_HANDLED)
  210. return IRQ_HANDLED;
  211. if (mps2_uart_oerrirq(irq, data) == IRQ_HANDLED)
  212. return IRQ_HANDLED;
  213. return IRQ_NONE;
  214. }
  215. static int mps2_uart_startup(struct uart_port *port)
  216. {
  217. struct mps2_uart_port *mps_port = to_mps2_port(port);
  218. u8 control = mps2_uart_read8(port, UARTn_CTRL);
  219. int ret;
  220. control &= ~(UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP);
  221. mps2_uart_write8(port, control, UARTn_CTRL);
  222. if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
  223. ret = request_irq(port->irq, mps2_uart_combinedirq, 0,
  224. MAKE_NAME(-combined), mps_port);
  225. if (ret) {
  226. dev_err(port->dev, "failed to register combinedirq (%d)\n", ret);
  227. return ret;
  228. }
  229. } else {
  230. ret = request_irq(port->irq, mps2_uart_oerrirq, IRQF_SHARED,
  231. MAKE_NAME(-overrun), mps_port);
  232. if (ret) {
  233. dev_err(port->dev, "failed to register oerrirq (%d)\n", ret);
  234. return ret;
  235. }
  236. ret = request_irq(mps_port->rx_irq, mps2_uart_rxirq, 0,
  237. MAKE_NAME(-rx), mps_port);
  238. if (ret) {
  239. dev_err(port->dev, "failed to register rxirq (%d)\n", ret);
  240. goto err_free_oerrirq;
  241. }
  242. ret = request_irq(mps_port->tx_irq, mps2_uart_txirq, 0,
  243. MAKE_NAME(-tx), mps_port);
  244. if (ret) {
  245. dev_err(port->dev, "failed to register txirq (%d)\n", ret);
  246. goto err_free_rxirq;
  247. }
  248. }
  249. control |= UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP;
  250. mps2_uart_write8(port, control, UARTn_CTRL);
  251. return 0;
  252. err_free_rxirq:
  253. free_irq(mps_port->rx_irq, mps_port);
  254. err_free_oerrirq:
  255. free_irq(port->irq, mps_port);
  256. return ret;
  257. }
  258. static void mps2_uart_shutdown(struct uart_port *port)
  259. {
  260. struct mps2_uart_port *mps_port = to_mps2_port(port);
  261. u8 control = mps2_uart_read8(port, UARTn_CTRL);
  262. control &= ~(UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP);
  263. mps2_uart_write8(port, control, UARTn_CTRL);
  264. if (!(mps_port->flags & UART_PORT_COMBINED_IRQ)) {
  265. free_irq(mps_port->rx_irq, mps_port);
  266. free_irq(mps_port->tx_irq, mps_port);
  267. }
  268. free_irq(port->irq, mps_port);
  269. }
  270. static void
  271. mps2_uart_set_termios(struct uart_port *port, struct ktermios *termios,
  272. struct ktermios *old)
  273. {
  274. unsigned long flags;
  275. unsigned int baud, bauddiv;
  276. termios->c_cflag &= ~(CRTSCTS | CMSPAR);
  277. termios->c_cflag &= ~CSIZE;
  278. termios->c_cflag |= CS8;
  279. termios->c_cflag &= ~PARENB;
  280. termios->c_cflag &= ~CSTOPB;
  281. baud = uart_get_baud_rate(port, termios, old,
  282. DIV_ROUND_CLOSEST(port->uartclk, UARTn_BAUDDIV_MASK),
  283. DIV_ROUND_CLOSEST(port->uartclk, 16));
  284. bauddiv = DIV_ROUND_CLOSEST(port->uartclk, baud);
  285. spin_lock_irqsave(&port->lock, flags);
  286. uart_update_timeout(port, termios->c_cflag, baud);
  287. mps2_uart_write32(port, bauddiv, UARTn_BAUDDIV);
  288. spin_unlock_irqrestore(&port->lock, flags);
  289. if (tty_termios_baud_rate(termios))
  290. tty_termios_encode_baud_rate(termios, baud, baud);
  291. }
  292. static const char *mps2_uart_type(struct uart_port *port)
  293. {
  294. return (port->type == PORT_MPS2UART) ? DRIVER_NAME : NULL;
  295. }
  296. static void mps2_uart_release_port(struct uart_port *port)
  297. {
  298. }
  299. static int mps2_uart_request_port(struct uart_port *port)
  300. {
  301. return 0;
  302. }
  303. static void mps2_uart_config_port(struct uart_port *port, int type)
  304. {
  305. if (type & UART_CONFIG_TYPE && !mps2_uart_request_port(port))
  306. port->type = PORT_MPS2UART;
  307. }
  308. static int mps2_uart_verify_port(struct uart_port *port, struct serial_struct *serinfo)
  309. {
  310. return -EINVAL;
  311. }
  312. static const struct uart_ops mps2_uart_pops = {
  313. .tx_empty = mps2_uart_tx_empty,
  314. .set_mctrl = mps2_uart_set_mctrl,
  315. .get_mctrl = mps2_uart_get_mctrl,
  316. .stop_tx = mps2_uart_stop_tx,
  317. .start_tx = mps2_uart_start_tx,
  318. .stop_rx = mps2_uart_stop_rx,
  319. .break_ctl = mps2_uart_break_ctl,
  320. .startup = mps2_uart_startup,
  321. .shutdown = mps2_uart_shutdown,
  322. .set_termios = mps2_uart_set_termios,
  323. .type = mps2_uart_type,
  324. .release_port = mps2_uart_release_port,
  325. .request_port = mps2_uart_request_port,
  326. .config_port = mps2_uart_config_port,
  327. .verify_port = mps2_uart_verify_port,
  328. };
  329. static DEFINE_IDR(ports_idr);
  330. #ifdef CONFIG_SERIAL_MPS2_UART_CONSOLE
  331. static void mps2_uart_console_putchar(struct uart_port *port, int ch)
  332. {
  333. while (mps2_uart_read8(port, UARTn_STATE) & UARTn_STATE_TX_FULL)
  334. cpu_relax();
  335. mps2_uart_write8(port, ch, UARTn_DATA);
  336. }
  337. static void mps2_uart_console_write(struct console *co, const char *s, unsigned int cnt)
  338. {
  339. struct mps2_uart_port *mps_port = idr_find(&ports_idr, co->index);
  340. struct uart_port *port = &mps_port->port;
  341. uart_console_write(port, s, cnt, mps2_uart_console_putchar);
  342. }
  343. static int mps2_uart_console_setup(struct console *co, char *options)
  344. {
  345. struct mps2_uart_port *mps_port;
  346. int baud = 9600;
  347. int bits = 8;
  348. int parity = 'n';
  349. int flow = 'n';
  350. if (co->index < 0 || co->index >= MPS2_MAX_PORTS)
  351. return -ENODEV;
  352. mps_port = idr_find(&ports_idr, co->index);
  353. if (!mps_port)
  354. return -ENODEV;
  355. if (options)
  356. uart_parse_options(options, &baud, &parity, &bits, &flow);
  357. return uart_set_options(&mps_port->port, co, baud, parity, bits, flow);
  358. }
  359. static struct uart_driver mps2_uart_driver;
  360. static struct console mps2_uart_console = {
  361. .name = SERIAL_NAME,
  362. .device = uart_console_device,
  363. .write = mps2_uart_console_write,
  364. .setup = mps2_uart_console_setup,
  365. .flags = CON_PRINTBUFFER,
  366. .index = -1,
  367. .data = &mps2_uart_driver,
  368. };
  369. #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
  370. static void mps2_early_putchar(struct uart_port *port, int ch)
  371. {
  372. while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
  373. cpu_relax();
  374. writeb((unsigned char)ch, port->membase + UARTn_DATA);
  375. }
  376. static void mps2_early_write(struct console *con, const char *s, unsigned int n)
  377. {
  378. struct earlycon_device *dev = con->data;
  379. uart_console_write(&dev->port, s, n, mps2_early_putchar);
  380. }
  381. static int __init mps2_early_console_setup(struct earlycon_device *device,
  382. const char *opt)
  383. {
  384. if (!device->port.membase)
  385. return -ENODEV;
  386. device->con->write = mps2_early_write;
  387. return 0;
  388. }
  389. OF_EARLYCON_DECLARE(mps2, "arm,mps2-uart", mps2_early_console_setup);
  390. #else
  391. #define MPS2_SERIAL_CONSOLE NULL
  392. #endif
  393. static struct uart_driver mps2_uart_driver = {
  394. .driver_name = DRIVER_NAME,
  395. .dev_name = SERIAL_NAME,
  396. .nr = MPS2_MAX_PORTS,
  397. .cons = MPS2_SERIAL_CONSOLE,
  398. };
  399. static int mps2_of_get_port(struct platform_device *pdev,
  400. struct mps2_uart_port *mps_port)
  401. {
  402. struct device_node *np = pdev->dev.of_node;
  403. int id;
  404. if (!np)
  405. return -ENODEV;
  406. id = of_alias_get_id(np, "serial");
  407. if (id < 0)
  408. id = idr_alloc_cyclic(&ports_idr, (void *)mps_port, 0, MPS2_MAX_PORTS, GFP_KERNEL);
  409. else
  410. id = idr_alloc(&ports_idr, (void *)mps_port, id, MPS2_MAX_PORTS, GFP_KERNEL);
  411. if (id < 0)
  412. return id;
  413. /* Only combined irq is presesnt */
  414. if (platform_irq_count(pdev) == 1)
  415. mps_port->flags |= UART_PORT_COMBINED_IRQ;
  416. mps_port->port.line = id;
  417. return 0;
  418. }
  419. static int mps2_init_port(struct platform_device *pdev,
  420. struct mps2_uart_port *mps_port)
  421. {
  422. struct resource *res;
  423. int ret;
  424. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  425. mps_port->port.membase = devm_ioremap_resource(&pdev->dev, res);
  426. if (IS_ERR(mps_port->port.membase))
  427. return PTR_ERR(mps_port->port.membase);
  428. mps_port->port.mapbase = res->start;
  429. mps_port->port.mapsize = resource_size(res);
  430. mps_port->port.iotype = UPIO_MEM;
  431. mps_port->port.flags = UPF_BOOT_AUTOCONF;
  432. mps_port->port.fifosize = 1;
  433. mps_port->port.ops = &mps2_uart_pops;
  434. mps_port->port.dev = &pdev->dev;
  435. mps_port->clk = devm_clk_get(&pdev->dev, NULL);
  436. if (IS_ERR(mps_port->clk))
  437. return PTR_ERR(mps_port->clk);
  438. ret = clk_prepare_enable(mps_port->clk);
  439. if (ret)
  440. return ret;
  441. mps_port->port.uartclk = clk_get_rate(mps_port->clk);
  442. clk_disable_unprepare(mps_port->clk);
  443. if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
  444. mps_port->port.irq = platform_get_irq(pdev, 0);
  445. } else {
  446. mps_port->rx_irq = platform_get_irq(pdev, 0);
  447. mps_port->tx_irq = platform_get_irq(pdev, 1);
  448. mps_port->port.irq = platform_get_irq(pdev, 2);
  449. }
  450. return ret;
  451. }
  452. static int mps2_serial_probe(struct platform_device *pdev)
  453. {
  454. struct mps2_uart_port *mps_port;
  455. int ret;
  456. mps_port = devm_kzalloc(&pdev->dev, sizeof(struct mps2_uart_port), GFP_KERNEL);
  457. if (!mps_port)
  458. return -ENOMEM;
  459. ret = mps2_of_get_port(pdev, mps_port);
  460. if (ret)
  461. return ret;
  462. ret = mps2_init_port(pdev, mps_port);
  463. if (ret)
  464. return ret;
  465. ret = uart_add_one_port(&mps2_uart_driver, &mps_port->port);
  466. if (ret)
  467. return ret;
  468. platform_set_drvdata(pdev, mps_port);
  469. return 0;
  470. }
  471. #ifdef CONFIG_OF
  472. static const struct of_device_id mps2_match[] = {
  473. { .compatible = "arm,mps2-uart", },
  474. {},
  475. };
  476. #endif
  477. static struct platform_driver mps2_serial_driver = {
  478. .probe = mps2_serial_probe,
  479. .driver = {
  480. .name = DRIVER_NAME,
  481. .of_match_table = of_match_ptr(mps2_match),
  482. .suppress_bind_attrs = true,
  483. },
  484. };
  485. static int __init mps2_uart_init(void)
  486. {
  487. int ret;
  488. ret = uart_register_driver(&mps2_uart_driver);
  489. if (ret)
  490. return ret;
  491. ret = platform_driver_register(&mps2_serial_driver);
  492. if (ret)
  493. uart_unregister_driver(&mps2_uart_driver);
  494. return ret;
  495. }
  496. arch_initcall(mps2_uart_init);