aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250/8250.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/8250/8250.c')
-rw-r--r--drivers/tty/serial/8250/8250.c156
1 files changed, 79 insertions, 77 deletions
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 8123f784bcda..3ba4234592bc 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -290,6 +290,9 @@ static const struct serial8250_config uart_config[] = {
290 UART_FCR_R_TRIG_00 | UART_FCR_T_TRIG_00, 290 UART_FCR_R_TRIG_00 | UART_FCR_T_TRIG_00,
291 .flags = UART_CAP_FIFO, 291 .flags = UART_CAP_FIFO,
292 }, 292 },
293 [PORT_8250_CIR] = {
294 .name = "CIR port"
295 }
293}; 296};
294 297
295/* Uart divisor latch read */ 298/* Uart divisor latch read */
@@ -1037,6 +1040,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1037 unsigned char save_lcr, save_mcr; 1040 unsigned char save_lcr, save_mcr;
1038 struct uart_port *port = &up->port; 1041 struct uart_port *port = &up->port;
1039 unsigned long flags; 1042 unsigned long flags;
1043 unsigned int old_capabilities;
1040 1044
1041 if (!port->iobase && !port->mapbase && !port->membase) 1045 if (!port->iobase && !port->mapbase && !port->membase)
1042 return; 1046 return;
@@ -1087,6 +1091,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1087 /* 1091 /*
1088 * We failed; there's nothing here 1092 * We failed; there's nothing here
1089 */ 1093 */
1094 spin_unlock_irqrestore(&port->lock, flags);
1090 DEBUG_AUTOCONF("IER test failed (%02x, %02x) ", 1095 DEBUG_AUTOCONF("IER test failed (%02x, %02x) ",
1091 scratch2, scratch3); 1096 scratch2, scratch3);
1092 goto out; 1097 goto out;
@@ -1110,6 +1115,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1110 status1 = serial_in(up, UART_MSR) & 0xF0; 1115 status1 = serial_in(up, UART_MSR) & 0xF0;
1111 serial_out(up, UART_MCR, save_mcr); 1116 serial_out(up, UART_MCR, save_mcr);
1112 if (status1 != 0x90) { 1117 if (status1 != 0x90) {
1118 spin_unlock_irqrestore(&port->lock, flags);
1113 DEBUG_AUTOCONF("LOOP test failed (%02x) ", 1119 DEBUG_AUTOCONF("LOOP test failed (%02x) ",
1114 status1); 1120 status1);
1115 goto out; 1121 goto out;
@@ -1132,8 +1138,6 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1132 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1138 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
1133 scratch = serial_in(up, UART_IIR) >> 6; 1139 scratch = serial_in(up, UART_IIR) >> 6;
1134 1140
1135 DEBUG_AUTOCONF("iir=%d ", scratch);
1136
1137 switch (scratch) { 1141 switch (scratch) {
1138 case 0: 1142 case 0:
1139 autoconfig_8250(up); 1143 autoconfig_8250(up);
@@ -1167,19 +1171,13 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1167 1171
1168 serial_out(up, UART_LCR, save_lcr); 1172 serial_out(up, UART_LCR, save_lcr);
1169 1173
1170 if (up->capabilities != uart_config[port->type].flags) {
1171 printk(KERN_WARNING
1172 "ttyS%d: detected caps %08x should be %08x\n",
1173 serial_index(port), up->capabilities,
1174 uart_config[port->type].flags);
1175 }
1176
1177 port->fifosize = uart_config[up->port.type].fifo_size; 1174 port->fifosize = uart_config[up->port.type].fifo_size;
1175 old_capabilities = up->capabilities;
1178 up->capabilities = uart_config[port->type].flags; 1176 up->capabilities = uart_config[port->type].flags;
1179 up->tx_loadsz = uart_config[port->type].tx_loadsz; 1177 up->tx_loadsz = uart_config[port->type].tx_loadsz;
1180 1178
1181 if (port->type == PORT_UNKNOWN) 1179 if (port->type == PORT_UNKNOWN)
1182 goto out; 1180 goto out_lock;
1183 1181
1184 /* 1182 /*
1185 * Reset the UART. 1183 * Reset the UART.
@@ -1196,8 +1194,16 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1196 else 1194 else
1197 serial_out(up, UART_IER, 0); 1195 serial_out(up, UART_IER, 0);
1198 1196
1199 out: 1197out_lock:
1200 spin_unlock_irqrestore(&port->lock, flags); 1198 spin_unlock_irqrestore(&port->lock, flags);
1199 if (up->capabilities != old_capabilities) {
1200 printk(KERN_WARNING
1201 "ttyS%d: detected caps %08x should be %08x\n",
1202 serial_index(port), old_capabilities,
1203 up->capabilities);
1204 }
1205out:
1206 DEBUG_AUTOCONF("iir=%d ", scratch);
1201 DEBUG_AUTOCONF("type=%s\n", uart_config[port->type].name); 1207 DEBUG_AUTOCONF("type=%s\n", uart_config[port->type].name);
1202} 1208}
1203 1209
@@ -1897,6 +1903,9 @@ static int serial8250_startup(struct uart_port *port)
1897 unsigned char lsr, iir; 1903 unsigned char lsr, iir;
1898 int retval; 1904 int retval;
1899 1905
1906 if (port->type == PORT_8250_CIR)
1907 return -ENODEV;
1908
1900 port->fifosize = uart_config[up->port.type].fifo_size; 1909 port->fifosize = uart_config[up->port.type].fifo_size;
1901 up->tx_loadsz = uart_config[up->port.type].tx_loadsz; 1910 up->tx_loadsz = uart_config[up->port.type].tx_loadsz;
1902 up->capabilities = uart_config[up->port.type].flags; 1911 up->capabilities = uart_config[up->port.type].flags;
@@ -2202,6 +2211,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2202 unsigned char cval, fcr = 0; 2211 unsigned char cval, fcr = 0;
2203 unsigned long flags; 2212 unsigned long flags;
2204 unsigned int baud, quot; 2213 unsigned int baud, quot;
2214 int fifo_bug = 0;
2205 2215
2206 switch (termios->c_cflag & CSIZE) { 2216 switch (termios->c_cflag & CSIZE) {
2207 case CS5: 2217 case CS5:
@@ -2221,8 +2231,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2221 2231
2222 if (termios->c_cflag & CSTOPB) 2232 if (termios->c_cflag & CSTOPB)
2223 cval |= UART_LCR_STOP; 2233 cval |= UART_LCR_STOP;
2224 if (termios->c_cflag & PARENB) 2234 if (termios->c_cflag & PARENB) {
2225 cval |= UART_LCR_PARITY; 2235 cval |= UART_LCR_PARITY;
2236 if (up->bugs & UART_BUG_PARITY)
2237 fifo_bug = 1;
2238 }
2226 if (!(termios->c_cflag & PARODD)) 2239 if (!(termios->c_cflag & PARODD))
2227 cval |= UART_LCR_EPAR; 2240 cval |= UART_LCR_EPAR;
2228#ifdef CMSPAR 2241#ifdef CMSPAR
@@ -2246,7 +2259,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2246 2259
2247 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { 2260 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) {
2248 fcr = uart_config[port->type].fcr; 2261 fcr = uart_config[port->type].fcr;
2249 if (baud < 2400) { 2262 if (baud < 2400 || fifo_bug) {
2250 fcr &= ~UART_FCR_TRIGGER_MASK; 2263 fcr &= ~UART_FCR_TRIGGER_MASK;
2251 fcr |= UART_FCR_TRIGGER_1; 2264 fcr |= UART_FCR_TRIGGER_1;
2252 } 2265 }
@@ -2336,7 +2349,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2336 serial_port_out(port, UART_EFR, efr); 2349 serial_port_out(port, UART_EFR, efr);
2337 } 2350 }
2338 2351
2339#ifdef CONFIG_ARCH_OMAP 2352#ifdef CONFIG_ARCH_OMAP1
2340 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ 2353 /* Workaround to enable 115200 baud on OMAP1510 internal ports */
2341 if (cpu_is_omap1510() && is_omap_port(up)) { 2354 if (cpu_is_omap1510() && is_omap_port(up)) {
2342 if (baud == 115200) { 2355 if (baud == 115200) {
@@ -2426,7 +2439,7 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
2426{ 2439{
2427 if (pt->port.iotype == UPIO_AU) 2440 if (pt->port.iotype == UPIO_AU)
2428 return 0x1000; 2441 return 0x1000;
2429#ifdef CONFIG_ARCH_OMAP 2442#ifdef CONFIG_ARCH_OMAP1
2430 if (is_omap_port(pt)) 2443 if (is_omap_port(pt))
2431 return 0x16 << pt->port.regshift; 2444 return 0x16 << pt->port.regshift;
2432#endif 2445#endif
@@ -2550,7 +2563,10 @@ static int serial8250_request_port(struct uart_port *port)
2550{ 2563{
2551 struct uart_8250_port *up = 2564 struct uart_8250_port *up =
2552 container_of(port, struct uart_8250_port, port); 2565 container_of(port, struct uart_8250_port, port);
2553 int ret = 0; 2566 int ret;
2567
2568 if (port->type == PORT_8250_CIR)
2569 return -ENODEV;
2554 2570
2555 ret = serial8250_request_std_resource(up); 2571 ret = serial8250_request_std_resource(up);
2556 if (ret == 0 && port->type == PORT_RSA) { 2572 if (ret == 0 && port->type == PORT_RSA) {
@@ -2569,6 +2585,9 @@ static void serial8250_config_port(struct uart_port *port, int flags)
2569 int probeflags = PROBE_ANY; 2585 int probeflags = PROBE_ANY;
2570 int ret; 2586 int ret;
2571 2587
2588 if (port->type == PORT_8250_CIR)
2589 return;
2590
2572 /* 2591 /*
2573 * Find the region that we can probe for. This in turn 2592 * Find the region that we can probe for. This in turn
2574 * tells us whether we can probe for the type of port. 2593 * tells us whether we can probe for the type of port.
@@ -2668,6 +2687,9 @@ static void __init serial8250_isa_init_ports(void)
2668 return; 2687 return;
2669 first = 0; 2688 first = 0;
2670 2689
2690 if (nr_uarts > UART_NR)
2691 nr_uarts = UART_NR;
2692
2671 for (i = 0; i < nr_uarts; i++) { 2693 for (i = 0; i < nr_uarts; i++) {
2672 struct uart_8250_port *up = &serial8250_ports[i]; 2694 struct uart_8250_port *up = &serial8250_ports[i];
2673 struct uart_port *port = &up->port; 2695 struct uart_port *port = &up->port;
@@ -2677,6 +2699,7 @@ static void __init serial8250_isa_init_ports(void)
2677 2699
2678 init_timer(&up->timer); 2700 init_timer(&up->timer);
2679 up->timer.function = serial8250_timeout; 2701 up->timer.function = serial8250_timeout;
2702 up->cur_iotype = 0xFF;
2680 2703
2681 /* 2704 /*
2682 * ALPHA_KLUDGE_MCR needs to be killed. 2705 * ALPHA_KLUDGE_MCR needs to be killed.
@@ -2728,13 +2751,9 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
2728 2751
2729 for (i = 0; i < nr_uarts; i++) { 2752 for (i = 0; i < nr_uarts; i++) {
2730 struct uart_8250_port *up = &serial8250_ports[i]; 2753 struct uart_8250_port *up = &serial8250_ports[i];
2731 up->cur_iotype = 0xFF;
2732 }
2733
2734 serial8250_isa_init_ports();
2735 2754
2736 for (i = 0; i < nr_uarts; i++) { 2755 if (up->port.dev)
2737 struct uart_8250_port *up = &serial8250_ports[i]; 2756 continue;
2738 2757
2739 up->port.dev = dev; 2758 up->port.dev = dev;
2740 2759
@@ -2859,9 +2878,6 @@ static struct console serial8250_console = {
2859 2878
2860static int __init serial8250_console_init(void) 2879static int __init serial8250_console_init(void)
2861{ 2880{
2862 if (nr_uarts > UART_NR)
2863 nr_uarts = UART_NR;
2864
2865 serial8250_isa_init_ports(); 2881 serial8250_isa_init_ports();
2866 register_console(&serial8250_console); 2882 register_console(&serial8250_console);
2867 return 0; 2883 return 0;
@@ -2979,36 +2995,36 @@ void serial8250_resume_port(int line)
2979static int __devinit serial8250_probe(struct platform_device *dev) 2995static int __devinit serial8250_probe(struct platform_device *dev)
2980{ 2996{
2981 struct plat_serial8250_port *p = dev->dev.platform_data; 2997 struct plat_serial8250_port *p = dev->dev.platform_data;
2982 struct uart_port port; 2998 struct uart_8250_port uart;
2983 int ret, i, irqflag = 0; 2999 int ret, i, irqflag = 0;
2984 3000
2985 memset(&port, 0, sizeof(struct uart_port)); 3001 memset(&uart, 0, sizeof(uart));
2986 3002
2987 if (share_irqs) 3003 if (share_irqs)
2988 irqflag = IRQF_SHARED; 3004 irqflag = IRQF_SHARED;
2989 3005
2990 for (i = 0; p && p->flags != 0; p++, i++) { 3006 for (i = 0; p && p->flags != 0; p++, i++) {
2991 port.iobase = p->iobase; 3007 uart.port.iobase = p->iobase;
2992 port.membase = p->membase; 3008 uart.port.membase = p->membase;
2993 port.irq = p->irq; 3009 uart.port.irq = p->irq;
2994 port.irqflags = p->irqflags; 3010 uart.port.irqflags = p->irqflags;
2995 port.uartclk = p->uartclk; 3011 uart.port.uartclk = p->uartclk;
2996 port.regshift = p->regshift; 3012 uart.port.regshift = p->regshift;
2997 port.iotype = p->iotype; 3013 uart.port.iotype = p->iotype;
2998 port.flags = p->flags; 3014 uart.port.flags = p->flags;
2999 port.mapbase = p->mapbase; 3015 uart.port.mapbase = p->mapbase;
3000 port.hub6 = p->hub6; 3016 uart.port.hub6 = p->hub6;
3001 port.private_data = p->private_data; 3017 uart.port.private_data = p->private_data;
3002 port.type = p->type; 3018 uart.port.type = p->type;
3003 port.serial_in = p->serial_in; 3019 uart.port.serial_in = p->serial_in;
3004 port.serial_out = p->serial_out; 3020 uart.port.serial_out = p->serial_out;
3005 port.handle_irq = p->handle_irq; 3021 uart.port.handle_irq = p->handle_irq;
3006 port.handle_break = p->handle_break; 3022 uart.port.handle_break = p->handle_break;
3007 port.set_termios = p->set_termios; 3023 uart.port.set_termios = p->set_termios;
3008 port.pm = p->pm; 3024 uart.port.pm = p->pm;
3009 port.dev = &dev->dev; 3025 uart.port.dev = &dev->dev;
3010 port.irqflags |= irqflag; 3026 uart.port.irqflags |= irqflag;
3011 ret = serial8250_register_port(&port); 3027 ret = serial8250_register_8250_port(&uart);
3012 if (ret < 0) { 3028 if (ret < 0) {
3013 dev_err(&dev->dev, "unable to register port at index %d " 3029 dev_err(&dev->dev, "unable to register port at index %d "
3014 "(IO%lx MEM%llx IRQ%d): %d\n", i, 3030 "(IO%lx MEM%llx IRQ%d): %d\n", i,
@@ -3081,7 +3097,7 @@ static struct platform_driver serial8250_isa_driver = {
3081static struct platform_device *serial8250_isa_devs; 3097static struct platform_device *serial8250_isa_devs;
3082 3098
3083/* 3099/*
3084 * serial8250_register_port and serial8250_unregister_port allows for 3100 * serial8250_register_8250_port and serial8250_unregister_port allows for
3085 * 16x50 serial ports to be configured at run-time, to support PCMCIA 3101 * 16x50 serial ports to be configured at run-time, to support PCMCIA
3086 * modems and PCI multiport cards. 3102 * modems and PCI multiport cards.
3087 */ 3103 */
@@ -3143,8 +3159,9 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
3143 mutex_lock(&serial_mutex); 3159 mutex_lock(&serial_mutex);
3144 3160
3145 uart = serial8250_find_match_or_unused(&up->port); 3161 uart = serial8250_find_match_or_unused(&up->port);
3146 if (uart) { 3162 if (uart && uart->port.type != PORT_8250_CIR) {
3147 uart_remove_one_port(&serial8250_reg, &uart->port); 3163 if (uart->port.dev)
3164 uart_remove_one_port(&serial8250_reg, &uart->port);
3148 3165
3149 uart->port.iobase = up->port.iobase; 3166 uart->port.iobase = up->port.iobase;
3150 uart->port.membase = up->port.membase; 3167 uart->port.membase = up->port.membase;
@@ -3155,6 +3172,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
3155 uart->port.regshift = up->port.regshift; 3172 uart->port.regshift = up->port.regshift;
3156 uart->port.iotype = up->port.iotype; 3173 uart->port.iotype = up->port.iotype;
3157 uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF; 3174 uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
3175 uart->bugs = up->bugs;
3158 uart->port.mapbase = up->port.mapbase; 3176 uart->port.mapbase = up->port.mapbase;
3159 uart->port.private_data = up->port.private_data; 3177 uart->port.private_data = up->port.private_data;
3160 if (up->port.dev) 3178 if (up->port.dev)
@@ -3198,29 +3216,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
3198EXPORT_SYMBOL(serial8250_register_8250_port); 3216EXPORT_SYMBOL(serial8250_register_8250_port);
3199 3217
3200/** 3218/**
3201 * serial8250_register_port - register a serial port
3202 * @port: serial port template
3203 *
3204 * Configure the serial port specified by the request. If the
3205 * port exists and is in use, it is hung up and unregistered
3206 * first.
3207 *
3208 * The port is then probed and if necessary the IRQ is autodetected
3209 * If this fails an error is returned.
3210 *
3211 * On success the port is ready to use and the line number is returned.
3212 */
3213int serial8250_register_port(struct uart_port *port)
3214{
3215 struct uart_8250_port up;
3216
3217 memset(&up, 0, sizeof(up));
3218 memcpy(&up.port, port, sizeof(*port));
3219 return serial8250_register_8250_port(&up);
3220}
3221EXPORT_SYMBOL(serial8250_register_port);
3222
3223/**
3224 * serial8250_unregister_port - remove a 16x50 serial port at runtime 3219 * serial8250_unregister_port - remove a 16x50 serial port at runtime
3225 * @line: serial line number 3220 * @line: serial line number
3226 * 3221 *
@@ -3250,8 +3245,7 @@ static int __init serial8250_init(void)
3250{ 3245{
3251 int ret; 3246 int ret;
3252 3247
3253 if (nr_uarts > UART_NR) 3248 serial8250_isa_init_ports();
3254 nr_uarts = UART_NR;
3255 3249
3256 printk(KERN_INFO "Serial: 8250/16550 driver, " 3250 printk(KERN_INFO "Serial: 8250/16550 driver, "
3257 "%d ports, IRQ sharing %sabled\n", nr_uarts, 3251 "%d ports, IRQ sharing %sabled\n", nr_uarts,
@@ -3266,11 +3260,15 @@ static int __init serial8250_init(void)
3266 if (ret) 3260 if (ret)
3267 goto out; 3261 goto out;
3268 3262
3263 ret = serial8250_pnp_init();
3264 if (ret)
3265 goto unreg_uart_drv;
3266
3269 serial8250_isa_devs = platform_device_alloc("serial8250", 3267 serial8250_isa_devs = platform_device_alloc("serial8250",
3270 PLAT8250_DEV_LEGACY); 3268 PLAT8250_DEV_LEGACY);
3271 if (!serial8250_isa_devs) { 3269 if (!serial8250_isa_devs) {
3272 ret = -ENOMEM; 3270 ret = -ENOMEM;
3273 goto unreg_uart_drv; 3271 goto unreg_pnp;
3274 } 3272 }
3275 3273
3276 ret = platform_device_add(serial8250_isa_devs); 3274 ret = platform_device_add(serial8250_isa_devs);
@@ -3286,6 +3284,8 @@ static int __init serial8250_init(void)
3286 platform_device_del(serial8250_isa_devs); 3284 platform_device_del(serial8250_isa_devs);
3287put_dev: 3285put_dev:
3288 platform_device_put(serial8250_isa_devs); 3286 platform_device_put(serial8250_isa_devs);
3287unreg_pnp:
3288 serial8250_pnp_exit();
3289unreg_uart_drv: 3289unreg_uart_drv:
3290#ifdef CONFIG_SPARC 3290#ifdef CONFIG_SPARC
3291 sunserial_unregister_minors(&serial8250_reg, UART_NR); 3291 sunserial_unregister_minors(&serial8250_reg, UART_NR);
@@ -3310,6 +3310,8 @@ static void __exit serial8250_exit(void)
3310 platform_driver_unregister(&serial8250_isa_driver); 3310 platform_driver_unregister(&serial8250_isa_driver);
3311 platform_device_unregister(isa_dev); 3311 platform_device_unregister(isa_dev);
3312 3312
3313 serial8250_pnp_exit();
3314
3313#ifdef CONFIG_SPARC 3315#ifdef CONFIG_SPARC
3314 sunserial_unregister_minors(&serial8250_reg, UART_NR); 3316 sunserial_unregister_minors(&serial8250_reg, UART_NR);
3315#else 3317#else