serial_8250.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:49k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/drivers/char/serial_8250.c
  3.  *
  4.  *  Driver for 8250/16550-type serial ports
  5.  *
  6.  *  Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
  7.  *
  8.  *  Copyright (C) 2001 Russell King.
  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.  *  $Id: serial_8250.c,v 1.14.2.6 2002/02/04 17:51:22 rmk Exp $
  16.  *
  17.  * A note about mapbase / membase
  18.  *
  19.  *  mapbase is the physical address of the IO port.  Currently, we don't
  20.  *  support this very well, and it may well be dropped from this driver
  21.  *  in future.  As such, mapbase should be NULL.
  22.  *
  23.  *  membase is an 'ioremapped' cookie.  This is compatible with the old
  24.  *  serial.c driver, and is currently the preferred form.
  25.  */
  26. #include <linux/config.h>
  27. #include <linux/module.h>
  28. #include <linux/errno.h>
  29. #include <linux/sched.h>
  30. #include <linux/tty.h>
  31. #include <linux/tty_flip.h>
  32. #include <linux/major.h>
  33. #include <linux/ptrace.h>
  34. #include <linux/ioport.h>
  35. #include <linux/init.h>
  36. #include <linux/serial.h>
  37. #include <linux/console.h>
  38. #include <linux/sysrq.h>
  39. #include <linux/serial_reg.h>
  40. #include <linux/serialP.h>
  41. #include <linux/delay.h>
  42. #include <linux/serial_core.h>
  43. #include <linux/kmod.h>
  44. #include <asm/system.h>
  45. #include <asm/io.h>
  46. #include <asm/irq.h>
  47. #include <asm/uaccess.h>
  48. #include <asm/bitops.h>
  49. #include "serial_8250.h"
  50. /*
  51.  * This converts from our new CONFIG_ symbols to the symbols
  52.  * that asm/serial.h expects.  You _NEED_ to comment out the
  53.  * linux/config.h include contained inside asm/serial.h for
  54.  * this to work.
  55.  */
  56. #undef CONFIG_SERIAL_MANY_PORTS
  57. #undef CONFIG_SERIAL_DETECT_IRQ
  58. #undef CONFIG_SERIAL_MULTIPORT
  59. #undef CONFIG_HUB6
  60. #ifdef CONFIG_SERIAL_8250_MANY_PORTS
  61. #define CONFIG_SERIAL_MANY_PORTS 1
  62. #endif
  63. #ifdef CONFIG_SERIAL_8250_DETECT_IRQ
  64. #define CONFIG_SERIAL_DETECT_IRQ 1
  65. #endif
  66. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  67. #define CONFIG_SERIAL_MULTIPORT 1
  68. #endif
  69. #ifdef CONFIG_SERIAL_8250_HUB6
  70. #define CONFIG_HUB6 1
  71. #endif
  72. #include <asm/serial.h>
  73. static struct old_serial_port old_serial_port[] = {
  74. SERIAL_PORT_DFNS /* defined in asm/serial.h */
  75. };
  76. #define UART_NR ARRAY_SIZE(old_serial_port)
  77. static struct tty_driver normal, callout;
  78. static struct tty_struct *serial8250_table[UART_NR];
  79. static struct termios *serial8250_termios[UART_NR], *serial8250_termios_locked[UART_NR];
  80. #ifdef CONFIG_SERIAL_8250_CONSOLE
  81. static struct console serial8250_console;
  82. static unsigned int lsr_break_flag;
  83. #endif
  84. static struct uart_info *IRQ_ports[NR_IRQS];
  85. #if defined(CONFIG_SERIAL_RSA) && defined(MODULE)
  86. #define PORT_RSA_MAX 4
  87. static int probe_rsa[PORT_RSA_MAX];
  88. static int force_rsa[PORT_RSA_MAX];
  89. MODULE_PARM(probe_rsa, "1-" __MODULE_STRING(PORT_RSA_MAX) "i");
  90. MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
  91. MODULE_PARM(force_rsa, "1-" __MODULE_STRING(PORT_RSA_MAX) "i");
  92. MODULE_PARM_DESC(force_rsa, "Force I/O ports for RSA");
  93. #endif /* CONFIG_SERIAL_RSA  */
  94. #define port_acr unused[0] /* 8bit */
  95. #define port_ier unused[1] /* 8bit */
  96. #define port_rev unused[2] /* 8bit */
  97. #define port_lcr unused[3] /* 8bit */
  98. /*
  99.  * Here we define the default xmit fifo size used for each type of UART.
  100.  */
  101. static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
  102. { "unknown", 1, 0 },
  103. { "8250", 1, 0 },
  104. { "16450", 1, 0 },
  105. { "16550", 1, 0 },
  106. { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
  107. { "Cirrus", 1,  0 },
  108. { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
  109. { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
  110. { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO },
  111. { "Startech", 1, 0 },
  112. { "16C950/954", 128, UART_CLEAR_FIFO | UART_USE_FIFO },
  113. { "ST16654", 64, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
  114. { "XR16850", 128, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
  115. { "RSA", 2048, UART_CLEAR_FIFO | UART_USE_FIFO }
  116. };
  117. static _INLINE_ unsigned int serial_in(struct uart_port *port, int offset)
  118. {
  119. offset <<= port->regshift;
  120. switch (port->iotype) {
  121. #ifdef CONFIG_SERIAL_8250_HUB6
  122. case SERIAL_IO_HUB6:
  123. outb(port->hub6 - 1 + offset, port->iobase);
  124. return inb(port->iobase + 1);
  125. #endif
  126. case SERIAL_IO_MEM:
  127. return readb((unsigned long)port->membase + offset);
  128. default:
  129. return inb(port->iobase + offset);
  130. }
  131. }
  132. static _INLINE_ void
  133. serial_out(struct uart_port *port, int offset, int value)
  134. {
  135. offset <<= port->regshift;
  136. switch (port->iotype) {
  137. #ifdef CONFIG_SERIAL_8250_HUB6
  138. case SERIAL_IO_HUB6:
  139. outb(port->hub6 - 1 + offset, port->iobase);
  140. outb(value, port->iobase + 1);
  141. break;
  142. #endif
  143. case SERIAL_IO_MEM:
  144. writeb(value, (unsigned long)port->membase + offset);
  145. break;
  146. default:
  147. outb(value, port->iobase + offset);
  148. }
  149. }
  150. /*
  151.  * We used to support using pause I/O for certain machines.  We
  152.  * haven't supported this for a while, but just in case it's badly
  153.  * needed for certain old 386 machines, I've left these #define's
  154.  * in....
  155.  */
  156. #define serial_inp(port, offset) serial_in(port, offset)
  157. #define serial_outp(port, offset, value) serial_out(port, offset, value)
  158. /*
  159.  * For the 16C950
  160.  */
  161. static void serial_icr_write(struct uart_port *port, int offset, int  value)
  162. {
  163. serial_out(port, UART_SCR, offset);
  164. serial_out(port, UART_ICR, value);
  165. }
  166. static unsigned int serial_icr_read(struct uart_port *port, int offset)
  167. {
  168. unsigned int value;
  169. serial_icr_write(port, UART_ACR, port->port_acr | UART_ACR_ICRRD);
  170. serial_out(port, UART_SCR, offset);
  171. value = serial_in(port, UART_ICR);
  172. serial_icr_write(port, UART_ACR, port->port_acr);
  173. return value;
  174. }
  175. #ifdef CONFIG_SERIAL_RSA
  176. /* Attempts to turn on the RSA FIFO.  Returns zero on failure */
  177. static int enable_rsa(struct uart_port *port)
  178. {
  179. unsigned char mode;
  180. int result;
  181. unsigned long flags;
  182. save_flags(flags); cli();
  183. mode = serial_inp(port, UART_RSA_MSR);
  184. result = mode & UART_RSA_MSR_FIFO;
  185. if (!result) {
  186. serial_outp(port, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO);
  187. mode = serial_inp(port, UART_RSA_MSR);
  188. result = mode & UART_RSA_MSR_FIFO;
  189. }
  190. restore_flags(flags);
  191. return result;
  192. }
  193. /* Attempts to turn off the RSA FIFO.  Returns zero on failure */
  194. static int disable_rsa(struct uart_port *port)
  195. {
  196. unsigned char mode;
  197. int result;
  198. unsigned long flags;
  199. save_flags(flags); cli();
  200. mode = serial_inp(port, UART_RSA_MSR);
  201. result = !(mode & UART_RSA_MSR_FIFO);
  202. if (!result) {
  203. serial_outp(port, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO);
  204. mode = serial_inp(port, UART_RSA_MSR);
  205. result = !(mode & UART_RSA_MSR_FIFO);
  206. }
  207. restore_flags(flags);
  208. return result;
  209. }
  210. #endif /* CONFIG_SERIAL_RSA */
  211. /*
  212.  * This is a quickie test to see how big the FIFO is.
  213.  * It doesn't work at all the time, more's the pity.
  214.  */
  215. static int size_fifo(struct uart_port *port)
  216. {
  217. unsigned char old_fcr, old_mcr, old_dll, old_dlm;
  218. int count;
  219. old_fcr = serial_inp(port, UART_FCR);
  220. old_mcr = serial_inp(port, UART_MCR);
  221. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO |
  222.     UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
  223. serial_outp(port, UART_MCR, UART_MCR_LOOP);
  224. serial_outp(port, UART_LCR, UART_LCR_DLAB);
  225. old_dll = serial_inp(port, UART_DLL);
  226. old_dlm = serial_inp(port, UART_DLM);
  227. serial_outp(port, UART_DLL, 0x01);
  228. serial_outp(port, UART_DLM, 0x00);
  229. serial_outp(port, UART_LCR, 0x03);
  230. for (count = 0; count < 256; count++)
  231. serial_outp(port, UART_TX, count);
  232. mdelay(20);
  233. for (count = 0; (serial_inp(port, UART_LSR) & UART_LSR_DR) &&
  234.      (count < 256); count++)
  235. serial_inp(port, UART_RX);
  236. serial_outp(port, UART_FCR, old_fcr);
  237. serial_outp(port, UART_MCR, old_mcr);
  238. serial_outp(port, UART_LCR, UART_LCR_DLAB);
  239. serial_outp(port, UART_DLL, old_dll);
  240. serial_outp(port, UART_DLM, old_dlm);
  241. return count;
  242. }
  243. /*
  244.  * This is a helper routine to autodetect StarTech/Exar/Oxsemi UART's.
  245.  * When this function is called we know it is at least a StarTech
  246.  * 16650 V2, but it might be one of several StarTech UARTs, or one of
  247.  * its clones.  (We treat the broken original StarTech 16650 V1 as a
  248.  * 16550, and why not?  Startech doesn't seem to even acknowledge its
  249.  * existence.)
  250.  * 
  251.  * What evil have men's minds wrought...
  252.  */
  253. static void
  254. autoconfig_startech_uarts(struct uart_port *port)
  255. {
  256. unsigned char scratch, scratch2, scratch3, scratch4;
  257. /*
  258.  * First we check to see if it's an Oxford Semiconductor UART.
  259.  *
  260.  * If we have to do this here because some non-National
  261.  * Semiconductor clone chips lock up if you try writing to the
  262.  * LSR register (which serial_icr_read does)
  263.  */
  264. if (port->type == PORT_16550A) {
  265. /*
  266.  * EFR [4] must be set else this test fails
  267.  *
  268.  * This shouldn't be necessary, but Mike Hudson
  269.  * (Exoray@isys.ca) claims that it's needed for 952
  270.  * dual UART's (which are not recommended for new designs).
  271.  */
  272. port->port_acr = 0;
  273. serial_out(port, UART_LCR, 0xBF);
  274. serial_out(port, UART_EFR, 0x10);
  275. serial_out(port, UART_LCR, 0x00);
  276. /* Check for Oxford Semiconductor 16C950 */
  277. scratch = serial_icr_read(port, UART_ID1);
  278. scratch2 = serial_icr_read(port, UART_ID2);
  279. scratch3 = serial_icr_read(port, UART_ID3);
  280. if (scratch == 0x16 && scratch2 == 0xC9 &&
  281.     (scratch3 == 0x50 || scratch3 == 0x52 ||
  282.      scratch3 == 0x54)) {
  283. port->type = PORT_16C950;
  284. port->port_rev = serial_icr_read(port, UART_REV) |
  285. (scratch3 << 8);
  286. return;
  287. }
  288. }
  289. /*
  290.  * We check for a XR16C850 by setting DLL and DLM to 0, and then
  291.  * reading back DLL and DLM.  The chip type depends on the DLM
  292.  * value read back:
  293.  *  0x10 - XR16C850 and the DLL contains the chip revision.
  294.  *  0x12 - XR16C2850.
  295.  *  0x14 - XR16C854.
  296.  */
  297. /* Save the DLL and DLM */
  298. serial_outp(port, UART_LCR, UART_LCR_DLAB);
  299. scratch3 = serial_inp(port, UART_DLL);
  300. scratch4 = serial_inp(port, UART_DLM);
  301. serial_outp(port, UART_DLL, 0);
  302. serial_outp(port, UART_DLM, 0);
  303. scratch2 = serial_inp(port, UART_DLL);
  304. scratch = serial_inp(port, UART_DLM);
  305. serial_outp(port, UART_LCR, 0);
  306. if (scratch == 0x10 || scratch == 0x12 || scratch == 0x14) {
  307. if (scratch == 0x10)
  308. port->port_rev = scratch2;
  309. port->type = PORT_16850;
  310. return;
  311. }
  312. /* Restore the DLL and DLM */
  313. serial_outp(port, UART_LCR, UART_LCR_DLAB);
  314. serial_outp(port, UART_DLL, scratch3);
  315. serial_outp(port, UART_DLM, scratch4);
  316. serial_outp(port, UART_LCR, 0);
  317. /*
  318.  * We distinguish between the '654 and the '650 by counting
  319.  * how many bytes are in the FIFO.  I'm using this for now,
  320.  * since that's the technique that was sent to me in the
  321.  * serial driver update, but I'm not convinced this works.
  322.  * I've had problems doing this in the past.  -TYT
  323.  */
  324. if (size_fifo(port) == 64)
  325. port->type = PORT_16654;
  326. else
  327. port->type = PORT_16650V2;
  328. }
  329. /*
  330.  * This routine is called by rs_init() to initialize a specific serial
  331.  * port.  It determines what type of UART chip this serial port is
  332.  * using: 8250, 16450, 16550, 16550A.  The important question is
  333.  * whether or not this UART is a 16550A or not, since this will
  334.  * determine whether or not we can use its FIFO features or not.
  335.  */
  336. static void autoconfig(struct uart_port *port, unsigned int probeflags)
  337. {
  338. unsigned char status1, status2, scratch, scratch2, scratch3;
  339. unsigned char save_lcr, save_mcr;
  340. unsigned long flags;
  341. #ifdef SERIAL_DEBUG_AUTOCONF
  342. printk("Testing ttyS%d (0x%04x, 0x%08lx)...n",
  343. port->line, port->iobase, port->membase);
  344. #endif
  345. if (!port->iobase && !port->membase)
  346. return;
  347. save_flags(flags); cli();
  348. if (!(port->flags & ASYNC_BUGGY_UART)) {
  349. /*
  350.  * Do a simple existence test first; if we fail this,
  351.  * there's no point trying anything else.
  352.  * 
  353.  * 0x80 is used as a nonsense port to prevent against
  354.  * false positives due to ISA bus float.  The
  355.  * assumption is that 0x80 is a non-existent port;
  356.  * which should be safe since include/asm/io.h also
  357.  * makes this assumption.
  358.  */
  359. scratch = serial_inp(port, UART_IER);
  360. serial_outp(port, UART_IER, 0);
  361. #ifdef __i386__
  362. outb(0xff, 0x080);
  363. #endif
  364. scratch2 = serial_inp(port, UART_IER);
  365. serial_outp(port, UART_IER, 0x0F);
  366. #ifdef __i386__
  367. outb(0, 0x080);
  368. #endif
  369. scratch3 = serial_inp(port, UART_IER);
  370. serial_outp(port, UART_IER, scratch);
  371. if (scratch2 || scratch3 != 0x0F) {
  372. #ifdef SERIAL_DEBUG_AUTOCONF
  373. printk("serial: ttyS%d: simple autoconfig failed "
  374.        "(%02x, %02x)n", port->line, 
  375.        scratch2, scratch3);
  376. #endif
  377. restore_flags(flags);
  378. return; /* We failed; there's nothing here */
  379. }
  380. }
  381. save_mcr = serial_in(port, UART_MCR);
  382. save_lcr = serial_in(port, UART_LCR);
  383. /* 
  384.  * Check to see if a UART is really there.  Certain broken
  385.  * internal modems based on the Rockwell chipset fail this
  386.  * test, because they apparently don't implement the loopback
  387.  * test mode.  So this test is skipped on the COM 1 through
  388.  * COM 4 ports.  This *should* be safe, since no board
  389.  * manufacturer would be stupid enough to design a board
  390.  * that conflicts with COM 1-4 --- we hope!
  391.  */
  392. if (!(port->flags & ASYNC_SKIP_TEST)) {
  393. serial_outp(port, UART_MCR, UART_MCR_LOOP | 0x0A);
  394. status1 = serial_inp(port, UART_MSR) & 0xF0;
  395. serial_outp(port, UART_MCR, save_mcr);
  396. if (status1 != 0x90) {
  397. #ifdef SERIAL_DEBUG_AUTOCONF
  398. printk("serial: ttyS%d: no UART loopback failedn",
  399.        port->line);
  400. #endif
  401. restore_flags(flags);
  402. return;
  403. }
  404. }
  405. serial_outp(port, UART_LCR, 0xBF); /* set up for StarTech test */
  406. serial_outp(port, UART_EFR, 0); /* EFR is the same as FCR */
  407. serial_outp(port, UART_LCR, 0);
  408. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO);
  409. scratch = serial_in(port, UART_IIR) >> 6;
  410. switch (scratch) {
  411. case 0:
  412. port->type = PORT_16450;
  413. break;
  414. case 1:
  415. port->type = PORT_UNKNOWN;
  416. break;
  417. case 2:
  418. port->type = PORT_16550;
  419. break;
  420. case 3:
  421. port->type = PORT_16550A;
  422. break;
  423. }
  424. if (port->type == PORT_16550A) {
  425. /* Check for Startech UART's */
  426. serial_outp(port, UART_LCR, UART_LCR_DLAB);
  427. if (serial_in(port, UART_EFR) == 0) {
  428. port->type = PORT_16650;
  429. } else {
  430. serial_outp(port, UART_LCR, 0xBF);
  431. if (serial_in(port, UART_EFR) == 0)
  432. autoconfig_startech_uarts(port);
  433. }
  434. }
  435. if (port->type == PORT_16550A) {
  436. /* Check for TI 16750 */
  437. serial_outp(port, UART_LCR, save_lcr | UART_LCR_DLAB);
  438. serial_outp(port, UART_FCR,
  439.     UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
  440. scratch = serial_in(port, UART_IIR) >> 5;
  441. if (scratch == 7) {
  442. /*
  443.  * If this is a 16750, and not a cheap UART
  444.  * clone, then it should only go into 64 byte
  445.  * mode if the UART_FCR7_64BYTE bit was set
  446.  * while UART_LCR_DLAB was latched.
  447.  */
  448.   serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO);
  449. serial_outp(port, UART_LCR, 0);
  450. serial_outp(port, UART_FCR,
  451.     UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
  452. scratch = serial_in(port, UART_IIR) >> 5;
  453. if (scratch == 6)
  454. port->type = PORT_16750;
  455. }
  456. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO);
  457. }
  458. #if defined(CONFIG_SERIAL_RSA) && defined(MODULE)
  459. /*
  460.  * Only probe for RSA ports if we got the region.
  461.  */
  462. if (port->type == PORT_16550A && probeflags & PROBE_RSA) {
  463. int i;
  464. for (i = 0 ; i < PORT_RSA_MAX ; ++i) {
  465. if (!probe_rsa[i] && !force_rsa[i])
  466. break;
  467. if (((probe_rsa[i] != port->iobase) ||
  468.      check_region(port->iobase + UART_RSA_BASE, 16)) &&
  469.     (force_rsa[i] != port->iobase))
  470. continue;
  471. if (!enable_rsa(port))
  472. continue;
  473. port->type = PORT_RSA;
  474. port->uartclk = SERIAL_RSA_BAUD_BASE * 16;
  475. break;
  476. }
  477. }
  478. #endif
  479. serial_outp(port, UART_LCR, save_lcr);
  480. if (port->type == PORT_16450) {
  481. scratch = serial_in(port, UART_SCR);
  482. serial_outp(port, UART_SCR, 0xa5);
  483. status1 = serial_in(port, UART_SCR);
  484. serial_outp(port, UART_SCR, 0x5a);
  485. status2 = serial_in(port, UART_SCR);
  486. serial_outp(port, UART_SCR, scratch);
  487. if ((status1 != 0xa5) || (status2 != 0x5a))
  488. port->type = PORT_8250;
  489. }
  490. port->fifosize = uart_config[port->type].dfl_xmit_fifo_size;
  491. if (port->type == PORT_UNKNOWN) {
  492. restore_flags(flags);
  493. return;
  494. }
  495. #ifdef CONFIG_SERIAL_RSA
  496. if (port->iobase && port->type == PORT_RSA) {
  497. release_region(port->iobase, 8);
  498. request_region(port->iobase + UART_RSA_BASE, 16,
  499.        "serial_rsa");
  500. }
  501. #endif
  502. /*
  503.  * Reset the UART.
  504.  */
  505. #ifdef CONFIG_SERIAL_RSA
  506. if (port->type == PORT_RSA)
  507. serial_outp(port, UART_RSA_FRR, 0);
  508. #endif
  509. serial_outp(port, UART_MCR, save_mcr);
  510. serial_outp(port, UART_FCR, (UART_FCR_ENABLE_FIFO |
  511.      UART_FCR_CLEAR_RCVR |
  512.      UART_FCR_CLEAR_XMIT));
  513. serial_outp(port, UART_FCR, 0);
  514. (void)serial_in(port, UART_RX);
  515. serial_outp(port, UART_IER, 0);
  516. restore_flags(flags);
  517. }
  518. static void autoconfig_irq(struct uart_port *port)
  519. {
  520. unsigned char save_mcr, save_ier;
  521. unsigned long irqs;
  522. int irq;
  523. #ifdef CONFIG_SERIAL_MANY_PORTS
  524. unsigned char save_ICP = 0;
  525. unsigned short ICP = 0;
  526. if (port->flags & ASYNC_FOURPORT) {
  527. ICP = (port->iobase & 0xfe0) | 0x1f;
  528. save_ICP = inb_p(ICP);
  529. outb_p(0x80, ICP);
  530. (void) inb_p(ICP);
  531. }
  532. #endif
  533. /* forget possible initially masked and pending IRQ */
  534. probe_irq_off(probe_irq_on());
  535. save_mcr = serial_inp(port, UART_MCR);
  536. save_ier = serial_inp(port, UART_IER);
  537. serial_outp(port, UART_MCR, UART_MCR_OUT1 | UART_MCR_OUT2);
  538. irqs = probe_irq_on();
  539. serial_outp(port, UART_MCR, 0);
  540. udelay (10);
  541. if (port->flags & ASYNC_FOURPORT)  {
  542. serial_outp(port, UART_MCR,
  543.     UART_MCR_DTR | UART_MCR_RTS);
  544. } else {
  545. serial_outp(port, UART_MCR,
  546.     UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2);
  547. }
  548. serial_outp(port, UART_IER, 0x0f); /* enable all intrs */
  549. (void)serial_inp(port, UART_LSR);
  550. (void)serial_inp(port, UART_RX);
  551. (void)serial_inp(port, UART_IIR);
  552. (void)serial_inp(port, UART_MSR);
  553. serial_outp(port, UART_TX, 0xFF);
  554. udelay (20);
  555. irq = probe_irq_off(irqs);
  556. serial_outp(port, UART_MCR, save_mcr);
  557. serial_outp(port, UART_IER, save_ier);
  558. #ifdef CONFIG_SERIAL_MANY_PORTS
  559. if (port->flags & ASYNC_FOURPORT)
  560. outb_p(save_ICP, ICP);
  561. #endif
  562. port->irq = (irq > 0)? irq : 0;
  563. }
  564. static void serial8250_stop_tx(struct uart_port *port, u_int from_tty)
  565. {
  566. if (port->port_ier & UART_IER_THRI) {
  567. port->port_ier &= ~UART_IER_THRI;
  568. serial_out(port, UART_IER, port->port_ier);
  569. }
  570. if (port->type == PORT_16C950) {
  571. port->port_acr |= UART_ACR_TXDIS;
  572. serial_icr_write(port, UART_ACR, port->port_acr);
  573. }
  574. }
  575. static void serial8250_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty)
  576. {
  577. if (nonempty && !(port->port_ier & UART_IER_THRI)) {
  578. port->port_ier |= UART_IER_THRI;
  579. serial_out(port, UART_IER, port->port_ier);
  580. }
  581. /*
  582.  * We only do this from uart_start
  583.  */
  584. if (from_tty && port->type == PORT_16C950) {
  585. port->port_acr &= ~UART_ACR_TXDIS;
  586. serial_icr_write(port, UART_ACR, port->port_acr);
  587. }
  588. }
  589. static void serial8250_stop_rx(struct uart_port *port)
  590. {
  591. port->port_ier &= ~UART_IER_RLSI;
  592. port->read_status_mask &= ~UART_LSR_DR;
  593. serial_out(port, UART_IER, port->port_ier);
  594. }
  595. static void serial8250_enable_ms(struct uart_port *port)
  596. {
  597. port->port_ier |= UART_IER_MSI;
  598. serial_out(port, UART_IER, port->port_ier);
  599. }
  600. static _INLINE_ void
  601. receive_chars(struct uart_info *info, int *status, struct pt_regs *regs)
  602. {
  603. struct tty_struct *tty = info->tty;
  604. struct uart_port *port = info->port;
  605. unsigned char ch;
  606. int max_count = 256;
  607. do {
  608. if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
  609. tty->flip.tqueue.routine((void *)tty);
  610. if (tty->flip.count >= TTY_FLIPBUF_SIZE)
  611. return; // if TTY_DONT_FLIP is set
  612. }
  613. ch = serial_inp(port, UART_RX);
  614. *tty->flip.char_buf_ptr = ch;
  615. *tty->flip.flag_buf_ptr = TTY_NORMAL;
  616. port->icount.rx++;
  617. if (*status & (UART_LSR_BI | UART_LSR_PE |
  618.        UART_LSR_FE | UART_LSR_OE)) {
  619. /*
  620.  * For statistics only
  621.  */
  622. if (*status & UART_LSR_BI) {
  623. *status &= ~(UART_LSR_FE | UART_LSR_PE);
  624. port->icount.brk++;
  625. /*
  626.  * We do the SysRQ and SAK checking
  627.  * here because otherwise the break
  628.  * may get masked by ignore_status_mask
  629.  * or read_status_mask.
  630.  */
  631. uart_handle_break(info, &serial8250_console);
  632. } else if (*status & UART_LSR_PE)
  633. port->icount.parity++;
  634. else if (*status & UART_LSR_FE)
  635. port->icount.frame++;
  636. if (*status & UART_LSR_OE)
  637. port->icount.overrun++;
  638. /*
  639.  * Mask off conditions which should be ingored.
  640.  */
  641. *status &= port->read_status_mask;
  642. #ifdef CONFIG_SERIAL_8250_CONSOLE
  643. if (port->line == serial8250_console.index) {
  644. /* Recover the break flag from console xmit */
  645. *status |= lsr_break_flag;
  646. lsr_break_flag = 0;
  647. }
  648. #endif
  649. if (*status & UART_LSR_BI) {
  650. #ifdef SERIAL_DEBUG_INTR
  651. printk("handling break....");
  652. #endif
  653. *tty->flip.flag_buf_ptr = TTY_BREAK;
  654. } else if (*status & UART_LSR_PE)
  655. *tty->flip.flag_buf_ptr = TTY_PARITY;
  656. else if (*status & UART_LSR_FE)
  657. *tty->flip.flag_buf_ptr = TTY_FRAME;
  658. }
  659. if (uart_handle_sysrq_char(info, ch, regs))
  660. goto ignore_char;
  661. if ((*status & port->ignore_status_mask) == 0) {
  662. tty->flip.flag_buf_ptr++;
  663. tty->flip.char_buf_ptr++;
  664. tty->flip.count++;
  665. }
  666. if ((*status & UART_LSR_OE) &&
  667.     tty->flip.count < TTY_FLIPBUF_SIZE) {
  668. /*
  669.  * Overrun is special, since it's reported
  670.  * immediately, and doesn't affect the current
  671.  * character.
  672.  */
  673. *tty->flip.flag_buf_ptr = TTY_OVERRUN;
  674. tty->flip.flag_buf_ptr++;
  675. tty->flip.char_buf_ptr++;
  676. tty->flip.count++;
  677. }
  678. ignore_char:
  679. *status = serial_inp(port, UART_LSR);
  680. } while ((*status & UART_LSR_DR) && (max_count-- > 0));
  681. tty_flip_buffer_push(tty);
  682. }
  683. static _INLINE_ void transmit_chars(struct uart_info *info, int *intr_done)
  684. {
  685. struct uart_port *port = info->port;
  686. int count;
  687. if (port->x_char) {
  688. serial_outp(port, UART_TX, port->x_char);
  689. port->icount.tx++;
  690. port->x_char = 0;
  691. if (intr_done)
  692. *intr_done = 0;
  693. return;
  694. }
  695. if (info->xmit.head == info->xmit.tail
  696.     || info->tty->stopped
  697.     || info->tty->hw_stopped) {
  698. serial8250_stop_tx(port, 0);
  699. return;
  700. }
  701. count = port->fifosize;
  702. do {
  703. serial_out(port, UART_TX, info->xmit.buf[info->xmit.tail]);
  704. info->xmit.tail = (info->xmit.tail + 1) & (UART_XMIT_SIZE - 1);
  705. port->icount.tx++;
  706. if (info->xmit.head == info->xmit.tail)
  707. break;
  708. } while (--count > 0);
  709. if (CIRC_CNT(info->xmit.head, info->xmit.tail, UART_XMIT_SIZE) <
  710. WAKEUP_CHARS)
  711. uart_event(info, EVT_WRITE_WAKEUP);
  712. #ifdef SERIAL_DEBUG_INTR
  713. printk("THRE...");
  714. #endif
  715. if (intr_done)
  716. *intr_done = 0;
  717. if (info->xmit.head == info->xmit.tail)
  718. serial8250_stop_tx(info->port, 0);
  719. }
  720. static _INLINE_ void check_modem_status(struct uart_info *info)
  721. {
  722. struct uart_port *port = info->port;
  723. int status;
  724. status = serial_in(port, UART_MSR);
  725. if (status & UART_MSR_ANY_DELTA) {
  726. if (status & UART_MSR_TERI)
  727. port->icount.rng++;
  728. if (status & UART_MSR_DDSR)
  729. port->icount.dsr++;
  730. if (status & UART_MSR_DDCD)
  731. uart_handle_dcd_change(info, status & UART_MSR_DCD);
  732. if (status & UART_MSR_DCTS)
  733. uart_handle_cts_change(info, status & UART_MSR_CTS);
  734. wake_up_interruptible(&info->delta_msr_wait);
  735. }
  736. }
  737. /*
  738.  * This handles the interrupt from one port.
  739.  */
  740. static inline void
  741. serial8250_handle_port(struct uart_info *info, struct pt_regs *regs)
  742. {
  743. int status = serial_inp(info->port, UART_LSR);
  744. #ifdef SERIAL_DEBUG_INTR
  745. printk("status = %x...", status);
  746. #endif
  747. if (status & UART_LSR_DR)
  748. receive_chars(info, &status, regs);
  749. check_modem_status(info);
  750. if (status & UART_LSR_THRE)
  751. transmit_chars(info, 0);
  752. }
  753. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  754. /*
  755.  * This is the serial driver's generic interrupt routine
  756.  */
  757. static void rs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  758. {
  759. struct uart_info *info, *end_mark = NULL;
  760. int pass_counter = 0;
  761. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  762. int first_multi = 0;
  763. unsigned long port_monitor = rs_multiport[irq].port_monitor;
  764. #endif
  765. #ifdef SERIAL_DEBUG_INTR
  766. printk("rs_interrupt(%d)...", irq);
  767. #endif
  768. info = *(struct uart_info **)dev_id;
  769. if (!info)
  770. return;
  771. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  772. if (port_monitor)
  773. first_multi = inb(port_monitor);
  774. #endif
  775. do {
  776. if (!info->tty ||
  777.     (serial_in(info->port, UART_IIR) & UART_IIR_NO_INT)) {
  778.      if (!end_mark)
  779.      end_mark = info;
  780. goto next;
  781. }
  782. #ifdef SERIAL_DEBUG_INTR
  783. printk("IIR = %x...", serial_in(info->port, UART_IIR));
  784. #endif
  785. end_mark = NULL;
  786. serial8250_handle_port(info, regs);
  787. next:
  788. info = info->next_info;
  789. if (info)
  790. continue;
  791. info = *(struct uart_info **)dev_id;
  792. if (pass_counter++ > RS_ISR_PASS_LIMIT) {
  793. #if 0
  794. printk("rs loop breakn");
  795. #endif
  796. break; /* Prevent infinite loops */
  797. }
  798. } while (end_mark != info);
  799. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  800. if (port_monitor)
  801. printk("rs port monitor (normal) irq %d: 0x%x, 0x%xn",
  802. info->port->irq, first_multi, inb(port_monitor));
  803. #endif
  804. #ifdef SERIAL_DEBUG_INTR
  805. printk("end.n");
  806. #endif
  807. }
  808. #endif
  809. /*
  810.  * This is the serial driver's interrupt routine for a single port
  811.  */
  812. static void rs_interrupt_single(int irq, void *dev_id, struct pt_regs *regs)
  813. {
  814. struct uart_info *info;
  815. int pass_counter = 0;
  816. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  817. int first_multi = 0;
  818. unsigned long port_monitor = rs_multiport[irq].port_monitor;
  819. #endif
  820. #ifdef SERIAL_DEBUG_INTR
  821. printk("rs_interrupt_single(%d)...", irq);
  822. #endif
  823. info = *(struct uart_info **)dev_id;
  824. if (!info || !info->tty)
  825. return;
  826. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  827. if (port_monitor)
  828. first_multi = inb(port_monitor);
  829. #endif
  830. do {
  831. serial8250_handle_port(info, regs);
  832. if (pass_counter++ > RS_ISR_PASS_LIMIT) {
  833. #if 0
  834. printk("rs_single loop break.n");
  835. #endif
  836. break;
  837. }
  838. #ifdef SERIAL_DEBUG_INTR
  839. printk("IIR = %x...", serial_in(info->port, UART_IIR));
  840. #endif
  841. } while (!(serial_in(info->port, UART_IIR) & UART_IIR_NO_INT));
  842. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  843. if (port_monitor)
  844. printk("rs port monitor (single) irq %d: 0x%x, 0x%xn",
  845. info->port->irq, first_multi, inb(port_monitor));
  846. #endif
  847. #ifdef SERIAL_DEBUG_INTR
  848. printk("end.n");
  849. #endif
  850. }
  851. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  852. /*
  853.  * This is the serial driver's interrupt routine for multiport boards
  854.  */
  855. static void rs_interrupt_multi(int irq, void *dev_id, struct pt_regs *regs)
  856. {
  857. struct uart_info *info;
  858. int pass_counter = 0;
  859. struct rs_multiport_struct *multi = &rs_multiport[irq];
  860. int first_multi = 0;
  861. #ifdef SERIAL_DEBUG_INTR
  862. printk("rs_interrupt_multi(%d)...", irq);
  863. #endif
  864. info = *(struct uart_info **)dev_id;
  865. if (!info)
  866. return;
  867. if (!multi->port1) {
  868. /* should never happen */
  869. printk("rs_interrupt_multi: port1 NULL!n");
  870. return;
  871. }
  872. if (multi->port_monitor)
  873. first_multi = inb(multi->port_monitor);
  874. while (1) {
  875. if (!info->tty ||
  876.     (serial_in(info->port, UART_IIR) & UART_IIR_NO_INT))
  877. goto next;
  878. serial8250_handle_port(info, regs);
  879. next:
  880. info = info->next;
  881. if (info)
  882. continue;
  883. info = *(struct uart_info **)dev_id;
  884. /*
  885.  * The user was a bonehead, and misconfigured their
  886.  * multiport info.  Rather than lock up the kernel
  887.  * in an infinite loop, if we loop too many times,
  888.  * print a message and break out of the loop.
  889.  */
  890. if (pass_counter++ > RS_ISR_PASS_LIMIT) {
  891. printk("Misconfigured multiport serial info "
  892.        "for irq %d.  Breaking out irq loopn", irq);
  893. break;
  894. }
  895. if (multi->port_monitor)
  896. printk("rs port monitor irq %d: 0x%x, 0x%xn",
  897. info->port->irq, first_multi,
  898. inb(multi->port_monitor));
  899. if ((inb(multi->port1) & multi->mask1) != multi->match1)
  900. continue;
  901. if (!multi->port2)
  902. break;
  903. if ((inb(multi->port2) & multi->mask2) != multi->match2)
  904. continue;
  905. if (!multi->port3)
  906. break;
  907. if ((inb(multi->port3) & multi->mask3) != multi->match3)
  908. continue;
  909. if (!multi->port4)
  910. break;
  911. if ((inb(multi->port4) & multi->mask4) != multi->match4)
  912. continue;
  913. break;
  914. }
  915. #ifdef SERIAL_DEBUG_INTR
  916. printk("end.n");
  917. #endif
  918. }
  919. #endif
  920. static u_int serial8250_tx_empty(struct uart_port *port)
  921. {
  922. return serial_in(port, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
  923. }
  924. static u_int serial8250_get_mctrl(struct uart_port *port)
  925. {
  926. unsigned long flags;
  927. unsigned char status;
  928. unsigned int ret;
  929. save_flags(flags); cli();
  930. status = serial_in(port, UART_MSR);
  931. restore_flags(flags);
  932. ret = 0;
  933. if (status & UART_MSR_DCD)
  934. ret |= TIOCM_CAR;
  935. if (status & UART_MSR_RI)
  936. ret |= TIOCM_RNG;
  937. if (status & UART_MSR_DSR)
  938. ret |= TIOCM_DSR;
  939. if (status & UART_MSR_CTS)
  940. ret |= TIOCM_CTS;
  941. return ret;
  942. }
  943. static void serial8250_set_mctrl(struct uart_port *port, u_int mctrl)
  944. {
  945. unsigned char mcr = 0;
  946. if (mctrl & TIOCM_RTS)
  947. mcr |= UART_MCR_RTS;
  948. if (mctrl & TIOCM_DTR)
  949. mcr |= UART_MCR_DTR;
  950. if (mctrl & TIOCM_OUT1)
  951. mcr |= UART_MCR_OUT1;
  952. if (mctrl & TIOCM_OUT2)
  953. mcr |= UART_MCR_OUT2;
  954. if (mctrl & TIOCM_LOOP)
  955. mcr |= UART_MCR_LOOP;
  956. serial_out(port, UART_MCR, mcr);
  957. }
  958. static void serial8250_break_ctl(struct uart_port *port, int break_state)
  959. {
  960. if (break_state == -1)
  961. port->port_lcr |= UART_LCR_SBC;
  962. else
  963. port->port_lcr &= ~UART_LCR_SBC;
  964. serial_out(port, UART_LCR, port->port_lcr);
  965. }
  966. static int serial8250_startup(struct uart_port *port, struct uart_info *info)
  967. {
  968. void (*handler)(int, void *, struct pt_regs *);
  969. unsigned long flags;
  970. int retval;
  971. if (port->type == PORT_16C950) {
  972. /* Wake up and initialize UART */
  973. port->port_acr = 0;
  974. serial_outp(port, UART_LCR, 0xBF);
  975. serial_outp(port, UART_EFR, UART_EFR_ECB);
  976. serial_outp(port, UART_IER, 0);
  977. serial_outp(port, UART_LCR, 0);
  978. serial_icr_write(port, UART_CSR, 0); /* Reset the UART */
  979. serial_outp(port, UART_LCR, 0xBF);
  980. serial_outp(port, UART_EFR, UART_EFR_ECB);
  981. serial_outp(port, UART_LCR, 0);
  982. }
  983. #ifdef CONFIG_SERIAL_RSA
  984. /*
  985.  * If this is an RSA port, see if we can kick it up to the
  986.  * higher speed clock.
  987.  */
  988. if (port->type == PORT_RSA) {
  989. if (port->uartclk != SERIAL_RSA_BAUD_BASE * 16 &&
  990.     enable_rsa(port))
  991. port->uartclk = SERIAL_RSA_BAUD_BASE * 16;
  992. if (port->uartclk == SERIAL_RSA_BAUD_BASE * 16)
  993. serial_outp(port, UART_RSA_FRR, 0);
  994. }
  995. #endif
  996. /*
  997.  * Clear the FIFO buffers and disable them.
  998.  * (they will be reeanbled in change_speed())
  999.  */
  1000. if (uart_config[port->type].flags & UART_CLEAR_FIFO) {
  1001. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO);
  1002. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO |
  1003. UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
  1004. serial_outp(port, UART_FCR, 0);
  1005. }
  1006. /*
  1007.  * Clear the interrupt registers.
  1008.  */
  1009. (void) serial_inp(port, UART_LSR);
  1010. (void) serial_inp(port, UART_RX);
  1011. (void) serial_inp(port, UART_IIR);
  1012. (void) serial_inp(port, UART_MSR);
  1013. /*
  1014.  * At this point, there's no way the LSR could still be 0xff;
  1015.  * if it is, then bail out, because there's likely no UART
  1016.  * here.
  1017.  */
  1018. if (!(port->flags & ASYNC_BUGGY_UART) &&
  1019.     (serial_inp(port, UART_LSR) == 0xff)) {
  1020. printk("ttyS%d: LSR safety check engaged!n", port->line);
  1021. return -ENODEV;
  1022. }
  1023. /*
  1024.  * Allocate the IRQ if necessary
  1025.  */
  1026. if (port->irq && (!IRQ_ports[port->irq] ||
  1027.   !IRQ_ports[port->irq]->next_info)) {
  1028. handler = rs_interrupt_single;
  1029. if (IRQ_ports[port->irq]) {
  1030. #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
  1031. handler = rs_interrupt;
  1032. free_irq(port->irq, &IRQ_ports[port->irq]);
  1033. #ifdef CONFIG_SERIAL_8250_MULTIPORT
  1034. if (rs_multiport[port->irq].port1)
  1035. handler = serial8250_interrupt_multi;
  1036. #endif
  1037. #else
  1038. return -EBUSY;
  1039. #endif /* CONFIG_SERIAL_8250_SHARE_IRQ */
  1040. }
  1041. retval = request_irq(port->irq, handler, SA_SHIRQ,
  1042.      "serial", &IRQ_ports[port->irq]);
  1043. if (retval)
  1044. return retval;
  1045. }
  1046. /*
  1047.  * Insert serial port into IRQ chain.
  1048.  */
  1049. info->next_info = IRQ_ports[port->irq];
  1050. IRQ_ports[port->irq] = info;
  1051. /*
  1052.  * Now, initialize the UART
  1053.  */
  1054. serial_outp(port, UART_LCR, UART_LCR_WLEN8);
  1055. #ifdef CONFIG_SERIAL_MANY_PORTS
  1056. if (port->flags & ASYNC_FOURPORT) {
  1057. if (port->irq == 0)
  1058. info->mctrl |= TIOCM_OUT1;
  1059. } else
  1060. #endif
  1061. /*
  1062.  * Most PC uarts need OUT2 raised to enable interrupts.
  1063.  */
  1064. if (port->irq != 0)
  1065. info->mctrl |= TIOCM_OUT2;
  1066. /* FIXME: ALPHA_KLUDGE_MCR; */
  1067. serial8250_set_mctrl(port, info->mctrl);
  1068. /*
  1069.  * Finally, enable interrupts.  Note: Modem status interrupts
  1070.  * are set via change_speed(), which will be occuring imminently
  1071.  * anyway, so we don't enable them here.
  1072.  */
  1073. port->port_ier = UART_IER_RLSI | UART_IER_RDI;
  1074. serial_outp(port, UART_IER, port->port_ier);
  1075. #ifdef CONFIG_SERIAL_MANY_PORTS
  1076. if (port->flags & ASYNC_FOURPORT) {
  1077. unsigned int ICP;
  1078. /*
  1079.  * Enable interrupts on the AST Fourport board
  1080.  */
  1081. ICP = (port->iobase & 0xfe0) | 0x01f;
  1082. outb_p(0x80, ICP);
  1083. (void) inb_p(ICP);
  1084. }
  1085. #endif
  1086. /*
  1087.  * And clear the interrupt registers again for luck.
  1088.  */
  1089. (void) serial_inp(port, UART_LSR);
  1090. (void) serial_inp(port, UART_RX);
  1091. (void) serial_inp(port, UART_IIR);
  1092. (void) serial_inp(port, UART_MSR);
  1093. return 0;
  1094. }
  1095. static void serial8250_shutdown(struct uart_port *port, struct uart_info *info)
  1096. {
  1097. struct uart_info **infop;
  1098. unsigned long flags;
  1099. int retval;
  1100. /*
  1101.  * First, disable all intrs from the port.
  1102.  */
  1103. port->port_ier = 0;
  1104. serial_outp(port, UART_IER, 0);
  1105. synchronize_irq();
  1106. /*
  1107.  * unlink the serial port from the IRQ chain...
  1108.  */
  1109. for (infop = &IRQ_ports[port->irq]; *infop; infop = &(*infop)->next_info)
  1110. if (*infop == info)
  1111. break;
  1112. if (*infop == info)
  1113. *infop = info->next_info;
  1114. /*
  1115.  * Free the IRQ, if necessary
  1116.  */
  1117. if (port->irq && (!IRQ_ports[port->irq] ||
  1118.   !IRQ_ports[port->irq]->next_info)) {
  1119. free_irq(port->irq, &IRQ_ports[port->irq]);
  1120. if (IRQ_ports[port->irq]) {
  1121. retval = request_irq(port->irq, rs_interrupt_single,
  1122.      SA_SHIRQ, "serial", &IRQ_ports[port->irq]);
  1123. if (retval)
  1124. printk("serial shutdown: request_irq: error %d"
  1125.        " couldn't reacquire IRQ.n", retval);
  1126. }
  1127. }
  1128. #ifdef CONFIG_SERIAL_MANY_PORTS
  1129. if (port->flags & ASYNC_FOURPORT) {
  1130. /* reset interrupts on the AST Fourport board */
  1131. inb((port->iobase & 0xfe0) | 0x1f);
  1132. info->mctrl |= TIOCM_OUT1;
  1133. } else
  1134. #endif
  1135. info->mctrl &= ~TIOCM_OUT2;
  1136. /* FIXME: ALPHA_KLUDGE_MCR; */
  1137. serial8250_set_mctrl(port, info->mctrl);
  1138. /*
  1139.  * Disable break condition and FIFOs
  1140.  */
  1141. serial_out(port, UART_LCR, serial_inp(port, UART_LCR) & ~UART_LCR_SBC);
  1142. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO |
  1143.     UART_FCR_CLEAR_RCVR |
  1144.     UART_FCR_CLEAR_XMIT);
  1145. serial_outp(port, UART_FCR, 0);
  1146. #ifdef CONFIG_SERIAL_RSA
  1147. /*
  1148.  * Reset the RSA board back to 115kbps compat mode.
  1149.  */
  1150. if (port->type == PORT_RSA &&
  1151.     port->uartclk == SERIAL_RSA_BAUD_BASE * 16 &&
  1152.     disable_rsa(port))
  1153. port->uartclk = SERIAL_RSA_BAUD_BASE_LO * 16;
  1154. #endif
  1155. /*
  1156.  * Read data port to reset things
  1157.  */
  1158. (void) serial_in(port, UART_RX);
  1159. }
  1160. static void serial8250_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
  1161. {
  1162. unsigned char cval, fcr = 0;
  1163. unsigned long flags;
  1164. switch (cflag & CSIZE) {
  1165. case CS5: cval = 0x00; break;
  1166. case CS6: cval = 0x01; break;
  1167. case CS7: cval = 0x02; break;
  1168. default:
  1169. case CS8: cval = 0x03; break;
  1170. }
  1171. if (cflag & CSTOPB)
  1172. cval |= 0x04;
  1173. if (cflag & PARENB)
  1174. cval |= UART_LCR_PARITY;
  1175. if (!(cflag & PARODD))
  1176. cval |= UART_LCR_EPAR;
  1177. #ifdef CMSPAR
  1178. if (cflag & CMSPAR)
  1179. cval |= UART_LCR_SPAR;
  1180. #endif
  1181. /*
  1182.  * Work around a bug in the Oxford Semiconductor 952 rev B
  1183.  * chip which causes it to seriously miscalculate baud rates
  1184.  * when DLL is 0.
  1185.  */
  1186. if ((quot & 0xff) == 0 && port->type == PORT_16C950 &&
  1187.     port->port_rev == 0x5201)
  1188. quot ++;
  1189. if (uart_config[port->type].flags & UART_USE_FIFO) {
  1190. if ((port->uartclk / quot) < (2400 * 16))
  1191. fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
  1192. #ifdef CONFIG_SERIAL_RSA
  1193. else if (port->type == PORT_RSA)
  1194. fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14;
  1195. #endif
  1196. else
  1197. fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
  1198. }
  1199. if (port->type == PORT_16750)
  1200. fcr |= UART_FCR7_64BYTE;
  1201. port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
  1202. if (iflag & IGNPAR)
  1203. port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
  1204. if (iflag & (BRKINT | PARMRK))
  1205. port->read_status_mask |= UART_LSR_BI;
  1206. /*
  1207.  * Characteres to ignore
  1208.  */
  1209. port->ignore_status_mask = 0;
  1210. if (iflag & IGNPAR)
  1211. port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
  1212. if (iflag & IGNBRK) {
  1213. port->ignore_status_mask |= UART_LSR_BI;
  1214. /*
  1215.  * If we're ignoring parity and break indicators,
  1216.  * ignore overruns too (for real raw support).
  1217.  */
  1218. if (iflag & IGNPAR)
  1219. port->ignore_status_mask |= UART_LSR_OE;
  1220. }
  1221. /*
  1222.  * ignore all characters if CREAD is not set
  1223.  */
  1224. if ((cflag & CREAD) == 0)
  1225. port->ignore_status_mask |= UART_LSR_DR;
  1226. /*
  1227.  * CTS flow control flag and modem status interrupts
  1228.  */
  1229. port->port_ier &= ~UART_IER_MSI;
  1230. if (port->flags & ASYNC_HARDPPS_CD || cflag & CRTSCTS ||
  1231.     !(cflag & CLOCAL))
  1232. port->port_ier |= UART_IER_MSI;
  1233. /*
  1234.  * Ok, we're now changing the port state.  Do it with
  1235.  * interrupts disabled.
  1236.  */
  1237. save_flags(flags); cli();
  1238. serial_out(port, UART_IER, port->port_ier);
  1239. if (uart_config[port->type].flags & UART_STARTECH) {
  1240. serial_outp(port, UART_LCR, 0xBF);
  1241. serial_outp(port, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0);
  1242. }
  1243. serial_outp(port, UART_LCR, cval | UART_LCR_DLAB); /* set DLAB */
  1244. serial_outp(port, UART_DLL, quot & 0xff); /* LS of divisor */
  1245. serial_outp(port, UART_DLM, quot >> 8); /* MS of divisor */
  1246. if (port->type == PORT_16750)
  1247. serial_outp(port, UART_FCR, fcr); /* set fcr */
  1248. serial_outp(port, UART_LCR, cval); /* reset DLAB */
  1249. port->port_lcr = cval; /* Save LCR */
  1250. if (port->type != PORT_16750) {
  1251. if (fcr & UART_FCR_ENABLE_FIFO) {
  1252. /* emulated UARTs (Lucent Venus 167x) need two steps */
  1253. serial_outp(port, UART_FCR, UART_FCR_ENABLE_FIFO);
  1254. }
  1255. serial_outp(port, UART_FCR, fcr); /* set fcr */
  1256. }
  1257. restore_flags(flags);
  1258. }
  1259. static void serial8250_pm(struct uart_port *port, u_int state, u_int oldstate)
  1260. {
  1261. if (state) {
  1262. /* sleep */
  1263. if (uart_config[port->type].flags & UART_STARTECH) {
  1264. /* Arrange to enter sleep mode */
  1265. serial_outp(port, UART_LCR, 0xBF);
  1266. serial_outp(port, UART_EFR, UART_EFR_ECB);
  1267. serial_outp(port, UART_LCR, 0);
  1268. serial_outp(port, UART_IER, UART_IERX_SLEEP);
  1269. serial_outp(port, UART_LCR, 0xBF);
  1270. serial_outp(port, UART_EFR, 0);
  1271. serial_outp(port, UART_LCR, 0);
  1272. }
  1273. if (port->type == PORT_16750) {
  1274. /* Arrange to enter sleep mode */
  1275. serial_outp(port, UART_IER, UART_IERX_SLEEP);
  1276. }
  1277. } else {
  1278. /* wake */
  1279. if (uart_config[port->type].flags & UART_STARTECH) {
  1280. /* Wake up UART */
  1281. serial_outp(port, UART_LCR, 0xBF);
  1282. serial_outp(port, UART_EFR, UART_EFR_ECB);
  1283. /*
  1284.  * Turn off LCR == 0xBF so we actually set the IER
  1285.  * register on the XR16C850
  1286.  */
  1287. serial_outp(port, UART_LCR, 0);
  1288. serial_outp(port, UART_IER, 0);
  1289. /*
  1290.  * Now reset LCR so we can turn off the ECB bit
  1291.  */
  1292. serial_outp(port, UART_LCR, 0xBF);
  1293. serial_outp(port, UART_EFR, 0);
  1294. /*
  1295.  * For a XR16C850, we need to set the trigger levels
  1296.  */
  1297. if (port->type == PORT_16850) {
  1298. unsigned char fctr;
  1299. fctr = serial_inp(port, UART_FCTR) &
  1300.  ~(UART_FCTR_RX | UART_FCTR_TX);
  1301. serial_outp(port, UART_FCTR, fctr |
  1302. UART_FCTR_TRGD |
  1303. UART_FCTR_RX);
  1304. serial_outp(port, UART_TRG, UART_TRG_96);
  1305. serial_outp(port, UART_FCTR, fctr |
  1306. UART_FCTR_TRGD |
  1307. UART_FCTR_TX);
  1308. serial_outp(port, UART_TRG, UART_TRG_96);
  1309. }
  1310. serial_outp(port, UART_LCR, 0);
  1311. }
  1312. if (port->type == PORT_16750) {
  1313. /* Wake up UART */
  1314. serial_outp(port, UART_IER, 0);
  1315. }
  1316. }
  1317. }
  1318. /*
  1319.  * Resource handling.  This is complicated by the fact that resources
  1320.  * depend on the port type.  Maybe we should be claiming the standard
  1321.  * 8250 ports, and then trying to get other resources as necessary?
  1322.  */
  1323. static int
  1324. serial8250_request_std_resource(struct uart_port *port, struct resource **res)
  1325. {
  1326. unsigned int size = 8 << port->regshift;
  1327. int ret = 0;
  1328. switch (port->iotype) {
  1329. case SERIAL_IO_MEM:
  1330. if (port->mapbase) {
  1331. *res = request_mem_region(port->mapbase, size, "serial");
  1332. if (!*res)
  1333. ret = -EBUSY;
  1334. }
  1335. break;
  1336. case SERIAL_IO_HUB6:
  1337. case SERIAL_IO_PORT:
  1338. *res = request_region(port->iobase, size, "serial");
  1339. if (!*res)
  1340. ret = -EBUSY;
  1341. break;
  1342. }
  1343. return ret;
  1344. }
  1345. static int
  1346. serial8250_request_rsa_resource(struct uart_port *port, struct resource **res)
  1347. {
  1348. unsigned long start, size = 8 << port->regshift;
  1349. int ret = 0;
  1350. switch (port->iotype) {
  1351. case SERIAL_IO_MEM:
  1352. if (port->mapbase) {
  1353. start = port->mapbase;
  1354. start += UART_RSA_BASE << port->regshift;
  1355. *res = request_mem_region(start, size, "serial-rsa");
  1356. if (!*res)
  1357. ret = -EBUSY;
  1358. }
  1359. break;
  1360. case SERIAL_IO_HUB6:
  1361. case SERIAL_IO_PORT:
  1362. start = port->iobase;
  1363. start += UART_RSA_BASE << port->regshift;
  1364. *res = request_region(start, size, "serial-rsa");
  1365. if (!*res)
  1366. ret = -EBUSY;
  1367. break;
  1368. }
  1369. return ret;
  1370. }
  1371. static void serial8250_release_port(struct uart_port *port)
  1372. {
  1373. unsigned long start, offset = 0, size = 0;
  1374. if (port->type == PORT_RSA) {
  1375. offset = UART_RSA_BASE << port->regshift;
  1376. size = 8;
  1377. }
  1378. offset <<= port->regshift;
  1379. size <<= port->regshift;
  1380. switch (port->iotype) {
  1381. case SERIAL_IO_MEM:
  1382. if (port->mapbase) {
  1383. /*
  1384.  * Unmap the area.
  1385.  */
  1386. iounmap(port->membase);
  1387. port->membase = NULL;
  1388. start = port->mapbase;
  1389. if (size)
  1390. release_mem_region(start + offset, size);
  1391. release_mem_region(start, 8 << port->regshift);
  1392. }
  1393. break;
  1394. case SERIAL_IO_HUB6:
  1395. case SERIAL_IO_PORT:
  1396. start = port->iobase;
  1397. if (size)
  1398. release_region(start + offset, size);
  1399. release_region(start + offset, 8 << port->regshift);
  1400. break;
  1401. default:
  1402. break;
  1403. }
  1404. }
  1405. static int serial8250_request_port(struct uart_port *port)
  1406. {
  1407. struct resource *res = NULL, *res_rsa = NULL;
  1408. int ret = -EBUSY;
  1409. if (port->type == PORT_RSA) {
  1410. ret = serial8250_request_rsa_resource(port, &res_rsa);
  1411. if (ret)
  1412. return ret;
  1413. }
  1414. ret = serial8250_request_std_resource(port, &res);
  1415. /*
  1416.  * If we have a mapbase, then request that as well.
  1417.  */
  1418. if (res != NULL && port->iotype == SERIAL_IO_MEM &&
  1419.     port->mapbase) {
  1420. int size = res->end - res->start + 1;
  1421. port->membase = ioremap(port->mapbase, size);
  1422. if (!port->membase)
  1423. ret = -ENOMEM;
  1424. }
  1425. if (ret) {
  1426. if (res_rsa)
  1427. release_resource(res_rsa);
  1428. if (res)
  1429. release_resource(res);
  1430. }
  1431. return ret;
  1432. }
  1433. static void serial8250_config_port(struct uart_port *port, int flags)
  1434. {
  1435. struct resource *res_std = NULL, *res_rsa = NULL;
  1436. int probeflags = PROBE_ANY;
  1437. int ret;
  1438. #ifdef CONFIG_MCA
  1439. /*
  1440.  * Don't probe for MCA ports on non-MCA machines.
  1441.  */
  1442. if (port->flags & ASYNC_BOOT_ONLYMCA && !MCA_bus)
  1443. return;
  1444. #endif
  1445. /*
  1446.  * Find the region that we can probe for.  This in turn
  1447.  * tells us whether we can probe for the type of port.
  1448.  */
  1449. ret = serial8250_request_std_resource(port, &res_std);
  1450. if (ret)
  1451. return;
  1452. ret = serial8250_request_rsa_resource(port, &res_rsa);
  1453. if (ret)
  1454. probeflags &= ~PROBE_RSA;
  1455. if (flags & UART_CONFIG_TYPE)
  1456. autoconfig(port, probeflags);
  1457. if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
  1458. autoconfig_irq(port);
  1459. /*
  1460.  * If the port wasn't an RSA port, release the resource.
  1461.  */
  1462. if (port->type != PORT_RSA && res_rsa)
  1463. release_resource(res_rsa);
  1464. if (port->type == PORT_UNKNOWN)
  1465. release_resource(res_std);
  1466. }
  1467. static int
  1468. serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
  1469. {
  1470. if (ser->irq >= NR_IRQS || ser->irq < 0 ||
  1471.     ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
  1472.     ser->type > PORT_MAX_8250 || ser->type == PORT_CIRRUS ||
  1473.     ser->type == PORT_STARTECH)
  1474. return -EINVAL;
  1475. return 0;
  1476. }
  1477. static const char *
  1478. serial8250_type(struct uart_port *port)
  1479. {
  1480. int type = port->type;
  1481. if (type >= PORT_MAX_8250)
  1482. type = 0;
  1483. return uart_config[type].name;
  1484. }
  1485. static struct uart_ops serial8250_pops = {
  1486. tx_empty: serial8250_tx_empty,
  1487. set_mctrl: serial8250_set_mctrl,
  1488. get_mctrl: serial8250_get_mctrl,
  1489. stop_tx: serial8250_stop_tx,
  1490. start_tx: serial8250_start_tx,
  1491. stop_rx: serial8250_stop_rx,
  1492. enable_ms: serial8250_enable_ms,
  1493. break_ctl: serial8250_break_ctl,
  1494. startup: serial8250_startup,
  1495. shutdown: serial8250_shutdown,
  1496. change_speed: serial8250_change_speed,
  1497. pm: serial8250_pm,
  1498. type: serial8250_type,
  1499. release_port: serial8250_release_port,
  1500. request_port: serial8250_request_port,
  1501. config_port: serial8250_config_port,
  1502. verify_port: serial8250_verify_port,
  1503. };
  1504. static struct uart_port serial8250_ports[UART_NR];
  1505. static void __init serial8250_isa_init_ports(void)
  1506. {
  1507. static int first = 1;
  1508. int i;
  1509. if (!first)
  1510. return;
  1511. first = 0;
  1512. for (i = 0; i < ARRAY_SIZE(old_serial_port); i++) {
  1513. serial8250_ports[i].iobase  = old_serial_port[i].port;
  1514. serial8250_ports[i].irq     = irq_cannonicalize(old_serial_port[i].irq);
  1515. serial8250_ports[i].uartclk = old_serial_port[i].base_baud * 16;
  1516. serial8250_ports[i].flags   = old_serial_port[i].flags;
  1517. serial8250_ports[i].ops     = &serial8250_pops;
  1518. }
  1519. }
  1520. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1521. #ifdef used_and_not_const_char_pointer
  1522. static int serial8250_console_read(struct uart_port *port, char *s, u_int count)
  1523. {
  1524. }
  1525. #endif
  1526. #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
  1527. /*
  1528.  * Wait for transmitter & holding register to empty
  1529.  */
  1530. static inline void wait_for_xmitr(struct uart_port *port)
  1531. {
  1532. unsigned int status, tmout = 1000000;
  1533. do {
  1534. status = serial_in(port, UART_LSR);
  1535. if (status & UART_LSR_BI)
  1536. lsr_break_flag = UART_LSR_BI;
  1537. if (--tmout == 0)
  1538. break;
  1539. } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
  1540. /* Wait for flow control if necessary */
  1541. if (port->flags & ASYNC_CONS_FLOW) {
  1542. tmout = 1000000;
  1543. while (--tmout &&
  1544.        ((serial_in(port, UART_MSR) & UART_MSR_CTS) == 0));
  1545. }
  1546. }
  1547. /*
  1548.  * Print a string to the serial port trying not to disturb
  1549.  * any possible real use of the port...
  1550.  *
  1551.  * The console_lock must be held when we get here.
  1552.  */
  1553. static void serial8250_console_write(struct console *co, const char *s, u_int count)
  1554. {
  1555. struct uart_port *port = serial8250_ports + co->index;
  1556. unsigned int ier;
  1557. int i;
  1558. /*
  1559.  * First save the UER then disable the interrupts
  1560.  */
  1561. ier = serial_in(port, UART_IER);
  1562. serial_out(port, UART_IER, 0);
  1563. /*
  1564.  * Now, do each character
  1565.  */
  1566. for (i = 0; i < count; i++, s++) {
  1567. wait_for_xmitr(port);
  1568. /*
  1569.  * Send the character out.
  1570.  * If a LF, also do CR...
  1571.  */
  1572. serial_out(port, UART_TX, *s);
  1573. if (*s == 10) {
  1574. wait_for_xmitr(port);
  1575. serial_out(port, UART_TX, 13);
  1576. }
  1577. }
  1578. /*
  1579.  * Finally, wait for transmitter to become empty
  1580.  * and restore the IER
  1581.  */
  1582. wait_for_xmitr(port);
  1583. serial_out(port, UART_IER, ier);
  1584. }
  1585. static kdev_t serial8250_console_device(struct console *co)
  1586. {
  1587. return MKDEV(TTY_MAJOR, 64 + co->index);
  1588. }
  1589. static int serial8250_console_wait_key(struct console *co)
  1590. {
  1591. struct uart_port *port = serial8250_ports + co->index;
  1592. int ier, c;
  1593. /*
  1594.  * First save the IER then disable the interrupts so
  1595.  * that the real driver for the port does not get the
  1596.  * character.
  1597.  */
  1598. ier = serial_in(port, UART_IER);
  1599. serial_out(port, UART_IER, 0);
  1600. while ((serial_in(port, UART_LSR) & UART_LSR_DR) == 0);
  1601. c = serial_in(port, UART_RX);
  1602. /*
  1603.  * Restore the interrupts
  1604.  */
  1605. serial_out(port, UART_IER, ier);
  1606. return c;
  1607. }
  1608. static int __init serial8250_console_setup(struct console *co, char *options)
  1609. {
  1610. struct uart_port *port;
  1611. int baud = 9600;
  1612. int bits = 8;
  1613. int parity = 'n';
  1614. int flow = 'n';
  1615. /*
  1616.  * Check whether an invalid uart number has been specified, and
  1617.  * if so, search for the first available port that does have
  1618.  * console support.
  1619.  */
  1620. port = uart_get_console(serial8250_ports, UART_NR, co);
  1621. if (options)
  1622. uart_parse_options(options, &baud, &parity, &bits, &flow);
  1623. return uart_set_options(port, co, baud, parity, bits, flow);
  1624. }
  1625. static struct console serial8250_console = {
  1626. name: "ttyS",
  1627. write: serial8250_console_write,
  1628. #ifdef used_and_not_const_char_pointer
  1629. read: serial8250_console_read,
  1630. #endif
  1631. device: serial8250_console_device,
  1632. wait_key: serial8250_console_wait_key,
  1633. setup: serial8250_console_setup,
  1634. flags: CON_PRINTBUFFER,
  1635. index: -1,
  1636. };
  1637. void __init serial8250_console_init(void)
  1638. {
  1639. serial8250_isa_init_ports();
  1640. register_console(&serial8250_console);
  1641. }
  1642. #define SERIAL8250_CONSOLE &serial8250_console
  1643. #else
  1644. #define SERIAL8250_CONSOLE NULL
  1645. #endif
  1646. static struct uart_driver serial8250_reg = {
  1647. owner: THIS_MODULE,
  1648. #ifdef CONFIG_DEVFS_FS
  1649. normal_name: "tts/%d",
  1650. callout_name: "cua/%d",
  1651. #else
  1652. normal_name: "ttyS",
  1653. callout_name: "cua",
  1654. #endif
  1655. normal_major: TTY_MAJOR,
  1656. callout_major: TTYAUX_MAJOR,
  1657. normal_driver: &normal,
  1658. callout_driver: &callout,
  1659. table: serial8250_table,
  1660. termios: serial8250_termios,
  1661. termios_locked: serial8250_termios_locked,
  1662. minor: 64,
  1663. nr: ARRAY_SIZE(old_serial_port),
  1664. port: serial8250_ports,
  1665. cons: SERIAL8250_CONSOLE,
  1666. };
  1667. /*
  1668.  * register_serial and unregister_serial allows for 16x50 serial ports to be
  1669.  * configured at run-time, to support PCMCIA modems.
  1670.  */
  1671.  
  1672. /**
  1673.  * register_serial - configure a 16x50 serial port at runtime
  1674.  * @req: request structure
  1675.  *
  1676.  * Configure the serial port specified by the request. If the
  1677.  * port exists and is in use an error is returned. If the port
  1678.  * is not currently in the table it is added.
  1679.  *
  1680.  * The port is then probed and if neccessary the IRQ is autodetected
  1681.  * If this fails an error is returned.
  1682.  *
  1683.  * On success the port is ready to use and the line number is returned.
  1684.  */
  1685. int register_serial(struct serial_struct *req)
  1686. {
  1687. struct uart_port port;
  1688. port.iobase   = req->port;
  1689. port.membase  = req->iomem_base;
  1690. port.irq      = req->irq;
  1691. port.uartclk  = req->baud_base * 16;
  1692. port.fifosize = req->xmit_fifo_size;
  1693. port.regshift = req->iomem_reg_shift;
  1694. port.iotype   = req->io_type;
  1695. port.flags    = req->flags | ASYNC_BOOT_AUTOCONF;
  1696. if (HIGH_BITS_OFFSET)
  1697. port.iobase |= req->port_high << HIGH_BITS_OFFSET;
  1698. /*
  1699.  * If a clock rate wasn't specified by the low level
  1700.  * driver, then default to the standard clock rate.
  1701.  */
  1702. if (port.uartclk == 0)
  1703. port.uartclk = BASE_BAUD * 16;
  1704. return uart_register_port(&serial8250_reg, &port);
  1705. }
  1706. void unregister_serial(int line)
  1707. {
  1708. uart_unregister_port(&serial8250_reg, line);
  1709. }
  1710. static int __init serial8250_init(void)
  1711. {
  1712. serial8250_isa_init_ports();
  1713. return uart_register_driver(&serial8250_reg);
  1714. }
  1715. static void __exit serial8250_exit(void)
  1716. {
  1717. uart_unregister_driver(&serial8250_reg);
  1718. }
  1719. module_init(serial8250_init);
  1720. module_exit(serial8250_exit);
  1721. EXPORT_SYMBOL(register_serial);
  1722. EXPORT_SYMBOL(unregister_serial);
  1723. MODULE_LICENSE("GPL");
  1724. MODULE_DESCRIPTION("Generic 8250/16x50 serial driver");