serial_ks8695.c 16 KB

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