serial_ks8695.c 16 KB

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