serial_ks8695.c 15 KB

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