serial_ks8695.c 16 KB

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