serial_ks8695.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * drivers/serial/serial_ks8695.c
  3. *
  4. * Driver for KS8695 serial ports
  5. *
  6. * Based on drivers/serial/serial_amba.c, by Kam Lee.
  7. *
  8. * Copyright 2002-2005 Micrel Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. */
  16. #include <linux/module.h>
  17. #include <linux/tty.h>
  18. #include <linux/ioport.h>
  19. #include <linux/init.h>
  20. #include <linux/serial.h>
  21. #include <linux/console.h>
  22. #include <linux/sysrq.h>
  23. #include <linux/device.h>
  24. #include <asm/io.h>
  25. #include <asm/irq.h>
  26. #include <asm/mach/irq.h>
  27. #include <mach/regs-uart.h>
  28. #include <mach/regs-irq.h>
  29. #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  30. #define SUPPORT_SYSRQ
  31. #endif
  32. #include <linux/serial_core.h>
  33. #define SERIAL_KS8695_MAJOR 204
  34. #define SERIAL_KS8695_MINOR 16
  35. #define SERIAL_KS8695_DEVNAME "ttyAM"
  36. #define SERIAL_KS8695_NR 1
  37. /*
  38. * Access macros for the KS8695 UART
  39. */
  40. #define UART_GET_CHAR(p) (__raw_readl((p)->membase + KS8695_URRB) & 0xFF)
  41. #define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + KS8695_URTH)
  42. #define UART_GET_FCR(p) __raw_readl((p)->membase + KS8695_URFC)
  43. #define UART_PUT_FCR(p, c) __raw_writel((c), (p)->membase + KS8695_URFC)
  44. #define UART_GET_MSR(p) __raw_readl((p)->membase + KS8695_URMS)
  45. #define UART_GET_LSR(p) __raw_readl((p)->membase + KS8695_URLS)
  46. #define UART_GET_LCR(p) __raw_readl((p)->membase + KS8695_URLC)
  47. #define UART_PUT_LCR(p, c) __raw_writel((c), (p)->membase + KS8695_URLC)
  48. #define UART_GET_MCR(p) __raw_readl((p)->membase + KS8695_URMC)
  49. #define UART_PUT_MCR(p, c) __raw_writel((c), (p)->membase + KS8695_URMC)
  50. #define UART_GET_BRDR(p) __raw_readl((p)->membase + KS8695_URBD)
  51. #define UART_PUT_BRDR(p, c) __raw_writel((c), (p)->membase + KS8695_URBD)
  52. #define KS8695_CLR_TX_INT() __raw_writel(1 << KS8695_IRQ_UART_TX, KS8695_IRQ_VA + KS8695_INTST)
  53. #define UART_DUMMY_LSR_RX 0x100
  54. #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4)
  55. static inline int tx_enabled(struct uart_port *port)
  56. {
  57. return port->unused[0] & 1;
  58. }
  59. static inline int rx_enabled(struct uart_port *port)
  60. {
  61. return port->unused[0] & 2;
  62. }
  63. static inline int ms_enabled(struct uart_port *port)
  64. {
  65. return port->unused[0] & 4;
  66. }
  67. static inline void ms_enable(struct uart_port *port, int enabled)
  68. {
  69. if(enabled)
  70. port->unused[0] |= 4;
  71. else
  72. port->unused[0] &= ~4;
  73. }
  74. static inline void rx_enable(struct uart_port *port, int enabled)
  75. {
  76. if(enabled)
  77. port->unused[0] |= 2;
  78. else
  79. port->unused[0] &= ~2;
  80. }
  81. static inline void tx_enable(struct uart_port *port, int enabled)
  82. {
  83. if(enabled)
  84. port->unused[0] |= 1;
  85. else
  86. port->unused[0] &= ~1;
  87. }
  88. #ifdef SUPPORT_SYSRQ
  89. static struct console ks8695_console;
  90. #endif
  91. static void ks8695uart_stop_tx(struct uart_port *port)
  92. {
  93. if (tx_enabled(port)) {
  94. disable_irq(KS8695_IRQ_UART_TX);
  95. tx_enable(port, 0);
  96. }
  97. }
  98. static void ks8695uart_start_tx(struct uart_port *port)
  99. {
  100. if (!tx_enabled(port)) {
  101. enable_irq(KS8695_IRQ_UART_TX);
  102. tx_enable(port, 1);
  103. }
  104. }
  105. static void ks8695uart_stop_rx(struct uart_port *port)
  106. {
  107. if (rx_enabled(port)) {
  108. disable_irq(KS8695_IRQ_UART_RX);
  109. rx_enable(port, 0);
  110. }
  111. }
  112. static void ks8695uart_enable_ms(struct uart_port *port)
  113. {
  114. if (!ms_enabled(port)) {
  115. enable_irq(KS8695_IRQ_UART_MODEM_STATUS);
  116. ms_enable(port,1);
  117. }
  118. }
  119. static void ks8695uart_disable_ms(struct uart_port *port)
  120. {
  121. if (ms_enabled(port)) {
  122. disable_irq(KS8695_IRQ_UART_MODEM_STATUS);
  123. ms_enable(port,0);
  124. }
  125. }
  126. static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id)
  127. {
  128. struct uart_port *port = dev_id;
  129. struct tty_struct *tty = port->info->port.tty;
  130. unsigned int status, ch, lsr, flg, max_count = 256;
  131. status = UART_GET_LSR(port); /* clears pending LSR interrupts */
  132. while ((status & URLS_URDR) && max_count--) {
  133. ch = UART_GET_CHAR(port);
  134. flg = TTY_NORMAL;
  135. port->icount.rx++;
  136. /*
  137. * Note that the error handling code is
  138. * out of the main execution path
  139. */
  140. lsr = UART_GET_LSR(port) | UART_DUMMY_LSR_RX;
  141. if (unlikely(lsr & (URLS_URBI | URLS_URPE | URLS_URFE | URLS_URROE))) {
  142. if (lsr & URLS_URBI) {
  143. lsr &= ~(URLS_URFE | URLS_URPE);
  144. port->icount.brk++;
  145. if (uart_handle_break(port))
  146. goto ignore_char;
  147. }
  148. if (lsr & URLS_URPE)
  149. port->icount.parity++;
  150. if (lsr & URLS_URFE)
  151. port->icount.frame++;
  152. if (lsr & URLS_URROE)
  153. port->icount.overrun++;
  154. lsr &= port->read_status_mask;
  155. if (lsr & URLS_URBI)
  156. flg = TTY_BREAK;
  157. else if (lsr & URLS_URPE)
  158. flg = TTY_PARITY;
  159. else if (lsr & URLS_URFE)
  160. flg = TTY_FRAME;
  161. }
  162. if (uart_handle_sysrq_char(port, ch))
  163. goto ignore_char;
  164. uart_insert_char(port, lsr, URLS_URROE, ch, flg);
  165. ignore_char:
  166. status = UART_GET_LSR(port);
  167. }
  168. tty_flip_buffer_push(tty);
  169. return IRQ_HANDLED;
  170. }
  171. static irqreturn_t ks8695uart_tx_chars(int irq, void *dev_id)
  172. {
  173. struct uart_port *port = dev_id;
  174. struct circ_buf *xmit = &port->info->xmit;
  175. unsigned int count;
  176. if (port->x_char) {
  177. KS8695_CLR_TX_INT();
  178. UART_PUT_CHAR(port, port->x_char);
  179. port->icount.tx++;
  180. port->x_char = 0;
  181. return IRQ_HANDLED;
  182. }
  183. if (uart_tx_stopped(port) || uart_circ_empty(xmit)) {
  184. ks8695uart_stop_tx(port);
  185. return IRQ_HANDLED;
  186. }
  187. count = 16; /* fifo size */
  188. while (!uart_circ_empty(xmit) && (count-- > 0)) {
  189. KS8695_CLR_TX_INT();
  190. UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
  191. xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
  192. port->icount.tx++;
  193. }
  194. if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
  195. uart_write_wakeup(port);
  196. if (uart_circ_empty(xmit))
  197. ks8695uart_stop_tx(port);
  198. return IRQ_HANDLED;
  199. }
  200. static irqreturn_t ks8695uart_modem_status(int irq, void *dev_id)
  201. {
  202. struct uart_port *port = dev_id;
  203. unsigned int status;
  204. /*
  205. * clear modem interrupt by reading MSR
  206. */
  207. status = UART_GET_MSR(port);
  208. if (status & URMS_URDDCD)
  209. uart_handle_dcd_change(port, status & URMS_URDDCD);
  210. if (status & URMS_URDDST)
  211. port->icount.dsr++;
  212. if (status & URMS_URDCTS)
  213. uart_handle_cts_change(port, status & URMS_URDCTS);
  214. if (status & URMS_URTERI)
  215. port->icount.rng++;
  216. wake_up_interruptible(&port->info->delta_msr_wait);
  217. return IRQ_HANDLED;
  218. }
  219. static unsigned int ks8695uart_tx_empty(struct uart_port *port)
  220. {
  221. return (UART_GET_LSR(port) & URLS_URTE) ? TIOCSER_TEMT : 0;
  222. }
  223. static unsigned int ks8695uart_get_mctrl(struct uart_port *port)
  224. {
  225. unsigned int result = 0;
  226. unsigned int status;
  227. status = UART_GET_MSR(port);
  228. if (status & URMS_URDCD)
  229. result |= TIOCM_CAR;
  230. if (status & URMS_URDSR)
  231. result |= TIOCM_DSR;
  232. if (status & URMS_URCTS)
  233. result |= TIOCM_CTS;
  234. if (status & URMS_URRI)
  235. result |= TIOCM_RI;
  236. return result;
  237. }
  238. static void ks8695uart_set_mctrl(struct uart_port *port, u_int mctrl)
  239. {
  240. unsigned int mcr;
  241. mcr = UART_GET_MCR(port);
  242. if (mctrl & TIOCM_RTS)
  243. mcr |= URMC_URRTS;
  244. else
  245. mcr &= ~URMC_URRTS;
  246. if (mctrl & TIOCM_DTR)
  247. mcr |= URMC_URDTR;
  248. else
  249. mcr &= ~URMC_URDTR;
  250. UART_PUT_MCR(port, mcr);
  251. }
  252. static void ks8695uart_break_ctl(struct uart_port *port, int break_state)
  253. {
  254. unsigned int lcr;
  255. lcr = UART_GET_LCR(port);
  256. if (break_state == -1)
  257. lcr |= URLC_URSBC;
  258. else
  259. lcr &= ~URLC_URSBC;
  260. UART_PUT_LCR(port, lcr);
  261. }
  262. static int ks8695uart_startup(struct uart_port *port)
  263. {
  264. int retval;
  265. set_irq_flags(KS8695_IRQ_UART_TX, IRQF_VALID | IRQF_NOAUTOEN);
  266. tx_enable(port, 0);
  267. rx_enable(port, 1);
  268. ms_enable(port, 1);
  269. /*
  270. * Allocate the IRQ
  271. */
  272. retval = request_irq(KS8695_IRQ_UART_TX, ks8695uart_tx_chars, IRQF_DISABLED, "UART TX", port);
  273. if (retval)
  274. goto err_tx;
  275. retval = request_irq(KS8695_IRQ_UART_RX, ks8695uart_rx_chars, IRQF_DISABLED, "UART RX", port);
  276. if (retval)
  277. goto err_rx;
  278. retval = request_irq(KS8695_IRQ_UART_LINE_STATUS, ks8695uart_rx_chars, IRQF_DISABLED, "UART LineStatus", port);
  279. if (retval)
  280. goto err_ls;
  281. retval = request_irq(KS8695_IRQ_UART_MODEM_STATUS, ks8695uart_modem_status, IRQF_DISABLED, "UART ModemStatus", port);
  282. if (retval)
  283. goto err_ms;
  284. return 0;
  285. err_ms:
  286. free_irq(KS8695_IRQ_UART_LINE_STATUS, port);
  287. err_ls:
  288. free_irq(KS8695_IRQ_UART_RX, port);
  289. err_rx:
  290. free_irq(KS8695_IRQ_UART_TX, port);
  291. err_tx:
  292. return retval;
  293. }
  294. static void ks8695uart_shutdown(struct uart_port *port)
  295. {
  296. /*
  297. * Free the interrupt
  298. */
  299. free_irq(KS8695_IRQ_UART_RX, port);
  300. free_irq(KS8695_IRQ_UART_TX, port);
  301. free_irq(KS8695_IRQ_UART_MODEM_STATUS, port);
  302. free_irq(KS8695_IRQ_UART_LINE_STATUS, port);
  303. /* disable break condition and fifos */
  304. UART_PUT_LCR(port, UART_GET_LCR(port) & ~URLC_URSBC);
  305. UART_PUT_FCR(port, UART_GET_FCR(port) & ~URFC_URFE);
  306. }
  307. static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old)
  308. {
  309. unsigned int lcr, fcr = 0;
  310. unsigned long flags;
  311. unsigned int baud, quot;
  312. /*
  313. * Ask the core to calculate the divisor for us.
  314. */
  315. baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
  316. quot = uart_get_divisor(port, baud);
  317. switch (termios->c_cflag & CSIZE) {
  318. case CS5:
  319. lcr = URCL_5;
  320. break;
  321. case CS6:
  322. lcr = URCL_6;
  323. break;
  324. case CS7:
  325. lcr = URCL_7;
  326. break;
  327. default:
  328. lcr = URCL_8;
  329. break;
  330. }
  331. /* stop bits */
  332. if (termios->c_cflag & CSTOPB)
  333. lcr |= URLC_URSB;
  334. /* parity */
  335. if (termios->c_cflag & PARENB) {
  336. if (termios->c_cflag & CMSPAR) { /* Mark or Space parity */
  337. if (termios->c_cflag & PARODD)
  338. lcr |= URPE_MARK;
  339. else
  340. lcr |= URPE_SPACE;
  341. }
  342. else if (termios->c_cflag & PARODD)
  343. lcr |= URPE_ODD;
  344. else
  345. lcr |= URPE_EVEN;
  346. }
  347. if (port->fifosize > 1)
  348. fcr = URFC_URFRT_8 | URFC_URTFR | URFC_URRFR | URFC_URFE;
  349. spin_lock_irqsave(&port->lock, flags);
  350. /*
  351. * Update the per-port timeout.
  352. */
  353. uart_update_timeout(port, termios->c_cflag, baud);
  354. port->read_status_mask = URLS_URROE;
  355. if (termios->c_iflag & INPCK)
  356. port->read_status_mask |= (URLS_URFE | URLS_URPE);
  357. if (termios->c_iflag & (BRKINT | PARMRK))
  358. port->read_status_mask |= URLS_URBI;
  359. /*
  360. * Characters to ignore
  361. */
  362. port->ignore_status_mask = 0;
  363. if (termios->c_iflag & IGNPAR)
  364. port->ignore_status_mask |= (URLS_URFE | URLS_URPE);
  365. if (termios->c_iflag & IGNBRK) {
  366. port->ignore_status_mask |= URLS_URBI;
  367. /*
  368. * If we're ignoring parity and break indicators,
  369. * ignore overruns too (for real raw support).
  370. */
  371. if (termios->c_iflag & IGNPAR)
  372. port->ignore_status_mask |= URLS_URROE;
  373. }
  374. /*
  375. * Ignore all characters if CREAD is not set.
  376. */
  377. if ((termios->c_cflag & CREAD) == 0)
  378. port->ignore_status_mask |= UART_DUMMY_LSR_RX;
  379. /* first, disable everything */
  380. if (UART_ENABLE_MS(port, termios->c_cflag))
  381. ks8695uart_enable_ms(port);
  382. else
  383. ks8695uart_disable_ms(port);
  384. /* Set baud rate */
  385. UART_PUT_BRDR(port, quot);
  386. UART_PUT_LCR(port, lcr);
  387. UART_PUT_FCR(port, fcr);
  388. spin_unlock_irqrestore(&port->lock, flags);
  389. }
  390. static const char *ks8695uart_type(struct uart_port *port)
  391. {
  392. return port->type == PORT_KS8695 ? "KS8695" : NULL;
  393. }
  394. /*
  395. * Release the memory region(s) being used by 'port'
  396. */
  397. static void ks8695uart_release_port(struct uart_port *port)
  398. {
  399. release_mem_region(port->mapbase, UART_PORT_SIZE);
  400. }
  401. /*
  402. * Request the memory region(s) being used by 'port'
  403. */
  404. static int ks8695uart_request_port(struct uart_port *port)
  405. {
  406. return request_mem_region(port->mapbase, UART_PORT_SIZE,
  407. "serial_ks8695") != NULL ? 0 : -EBUSY;
  408. }
  409. /*
  410. * Configure/autoconfigure the port.
  411. */
  412. static void ks8695uart_config_port(struct uart_port *port, int flags)
  413. {
  414. if (flags & UART_CONFIG_TYPE) {
  415. port->type = PORT_KS8695;
  416. ks8695uart_request_port(port);
  417. }
  418. }
  419. /*
  420. * verify the new serial_struct (for TIOCSSERIAL).
  421. */
  422. static int ks8695uart_verify_port(struct uart_port *port, struct serial_struct *ser)
  423. {
  424. int ret = 0;
  425. if (ser->type != PORT_UNKNOWN && ser->type != PORT_KS8695)
  426. ret = -EINVAL;
  427. if (ser->irq != port->irq)
  428. ret = -EINVAL;
  429. if (ser->baud_base < 9600)
  430. ret = -EINVAL;
  431. return ret;
  432. }
  433. static struct uart_ops ks8695uart_pops = {
  434. .tx_empty = ks8695uart_tx_empty,
  435. .set_mctrl = ks8695uart_set_mctrl,
  436. .get_mctrl = ks8695uart_get_mctrl,
  437. .stop_tx = ks8695uart_stop_tx,
  438. .start_tx = ks8695uart_start_tx,
  439. .stop_rx = ks8695uart_stop_rx,
  440. .enable_ms = ks8695uart_enable_ms,
  441. .break_ctl = ks8695uart_break_ctl,
  442. .startup = ks8695uart_startup,
  443. .shutdown = ks8695uart_shutdown,
  444. .set_termios = ks8695uart_set_termios,
  445. .type = ks8695uart_type,
  446. .release_port = ks8695uart_release_port,
  447. .request_port = ks8695uart_request_port,
  448. .config_port = ks8695uart_config_port,
  449. .verify_port = ks8695uart_verify_port,
  450. };
  451. static struct uart_port ks8695uart_ports[SERIAL_KS8695_NR] = {
  452. {
  453. .membase = (void *) KS8695_UART_VA,
  454. .mapbase = KS8695_UART_VA,
  455. .iotype = SERIAL_IO_MEM,
  456. .irq = KS8695_IRQ_UART_TX,
  457. .uartclk = CLOCK_TICK_RATE * 16,
  458. .fifosize = 16,
  459. .ops = &ks8695uart_pops,
  460. .flags = ASYNC_BOOT_AUTOCONF,
  461. .line = 0,
  462. }
  463. };
  464. #ifdef CONFIG_SERIAL_KS8695_CONSOLE
  465. static void ks8695_console_putchar(struct uart_port *port, int ch)
  466. {
  467. while (!(UART_GET_LSR(port) & URLS_URTHRE))
  468. barrier();
  469. UART_PUT_CHAR(port, ch);
  470. }
  471. static void ks8695_console_write(struct console *co, const char *s, u_int count)
  472. {
  473. struct uart_port *port = ks8695uart_ports + co->index;
  474. uart_console_write(port, s, count, ks8695_console_putchar);
  475. }
  476. static void __init ks8695_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
  477. {
  478. unsigned int lcr;
  479. lcr = UART_GET_LCR(port);
  480. switch (lcr & URLC_PARITY) {
  481. case URPE_ODD:
  482. *parity = 'o';
  483. break;
  484. case URPE_EVEN:
  485. *parity = 'e';
  486. break;
  487. default:
  488. *parity = 'n';
  489. }
  490. switch (lcr & URLC_URCL) {
  491. case URCL_5:
  492. *bits = 5;
  493. break;
  494. case URCL_6:
  495. *bits = 6;
  496. break;
  497. case URCL_7:
  498. *bits = 7;
  499. break;
  500. default:
  501. *bits = 8;
  502. }
  503. *baud = port->uartclk / (UART_GET_BRDR(port) & 0x0FFF);
  504. *baud /= 16;
  505. *baud &= 0xFFFFFFF0;
  506. }
  507. static int __init ks8695_console_setup(struct console *co, char *options)
  508. {
  509. struct uart_port *port;
  510. int baud = 115200;
  511. int bits = 8;
  512. int parity = 'n';
  513. int flow = 'n';
  514. /*
  515. * Check whether an invalid uart number has been specified, and
  516. * if so, search for the first available port that does have
  517. * console support.
  518. */
  519. port = uart_get_console(ks8695uart_ports, SERIAL_KS8695_NR, co);
  520. if (options)
  521. uart_parse_options(options, &baud, &parity, &bits, &flow);
  522. else
  523. ks8695_console_get_options(port, &baud, &parity, &bits);
  524. return uart_set_options(port, co, baud, parity, bits, flow);
  525. }
  526. static struct uart_driver ks8695_reg;
  527. static struct console ks8695_console = {
  528. .name = SERIAL_KS8695_DEVNAME,
  529. .write = ks8695_console_write,
  530. .device = uart_console_device,
  531. .setup = ks8695_console_setup,
  532. .flags = CON_PRINTBUFFER,
  533. .index = -1,
  534. .data = &ks8695_reg,
  535. };
  536. static int __init ks8695_console_init(void)
  537. {
  538. register_console(&ks8695_console);
  539. return 0;
  540. }
  541. console_initcall(ks8695_console_init);
  542. #define KS8695_CONSOLE &ks8695_console
  543. #else
  544. #define KS8695_CONSOLE NULL
  545. #endif
  546. static struct uart_driver ks8695_reg = {
  547. .owner = THIS_MODULE,
  548. .driver_name = "serial_ks8695",
  549. .dev_name = SERIAL_KS8695_DEVNAME,
  550. .major = SERIAL_KS8695_MAJOR,
  551. .minor = SERIAL_KS8695_MINOR,
  552. .nr = SERIAL_KS8695_NR,
  553. .cons = KS8695_CONSOLE,
  554. };
  555. static int __init ks8695uart_init(void)
  556. {
  557. int i, ret;
  558. printk(KERN_INFO "Serial: Micrel KS8695 UART driver\n");
  559. ret = uart_register_driver(&ks8695_reg);
  560. if (ret)
  561. return ret;
  562. for (i = 0; i < SERIAL_KS8695_NR; i++)
  563. uart_add_one_port(&ks8695_reg, &ks8695uart_ports[0]);
  564. return 0;
  565. }
  566. static void __exit ks8695uart_exit(void)
  567. {
  568. int i;
  569. for (i = 0; i < SERIAL_KS8695_NR; i++)
  570. uart_remove_one_port(&ks8695_reg, &ks8695uart_ports[0]);
  571. uart_unregister_driver(&ks8695_reg);
  572. }
  573. module_init(ks8695uart_init);
  574. module_exit(ks8695uart_exit);
  575. MODULE_DESCRIPTION("KS8695 serial port driver");
  576. MODULE_AUTHOR("Micrel Inc.");
  577. MODULE_LICENSE("GPL");