diff options
Diffstat (limited to 'drivers/serial/8250.c')
-rw-r--r-- | drivers/serial/8250.c | 72 |
1 files changed, 51 insertions, 21 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 9ccc563d8730..1528de23a650 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -44,6 +44,10 @@ | |||
44 | 44 | ||
45 | #include "8250.h" | 45 | #include "8250.h" |
46 | 46 | ||
47 | #ifdef CONFIG_SPARC | ||
48 | #include "suncore.h" | ||
49 | #endif | ||
50 | |||
47 | /* | 51 | /* |
48 | * Configuration: | 52 | * Configuration: |
49 | * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option | 53 | * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option |
@@ -53,6 +57,13 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; | |||
53 | 57 | ||
54 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; | 58 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; |
55 | 59 | ||
60 | static struct uart_driver serial8250_reg; | ||
61 | |||
62 | static int serial_index(struct uart_port *port) | ||
63 | { | ||
64 | return (serial8250_reg.minor - 64) + port->line; | ||
65 | } | ||
66 | |||
56 | /* | 67 | /* |
57 | * Debugging. | 68 | * Debugging. |
58 | */ | 69 | */ |
@@ -536,7 +547,7 @@ static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) | |||
536 | /* | 547 | /* |
537 | * FIFO support. | 548 | * FIFO support. |
538 | */ | 549 | */ |
539 | static inline void serial8250_clear_fifos(struct uart_8250_port *p) | 550 | static void serial8250_clear_fifos(struct uart_8250_port *p) |
540 | { | 551 | { |
541 | if (p->capabilities & UART_CAP_FIFO) { | 552 | if (p->capabilities & UART_CAP_FIFO) { |
542 | serial_outp(p, UART_FCR, UART_FCR_ENABLE_FIFO); | 553 | serial_outp(p, UART_FCR, UART_FCR_ENABLE_FIFO); |
@@ -551,7 +562,7 @@ static inline void serial8250_clear_fifos(struct uart_8250_port *p) | |||
551 | * capability" bit enabled. Note that on XR16C850s, we need to | 562 | * capability" bit enabled. Note that on XR16C850s, we need to |
552 | * reset LCR to write to IER. | 563 | * reset LCR to write to IER. |
553 | */ | 564 | */ |
554 | static inline void serial8250_set_sleep(struct uart_8250_port *p, int sleep) | 565 | static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) |
555 | { | 566 | { |
556 | if (p->capabilities & UART_CAP_SLEEP) { | 567 | if (p->capabilities & UART_CAP_SLEEP) { |
557 | if (p->capabilities & UART_CAP_EFR) { | 568 | if (p->capabilities & UART_CAP_EFR) { |
@@ -993,7 +1004,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
993 | return; | 1004 | return; |
994 | 1005 | ||
995 | DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", | 1006 | DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", |
996 | up->port.line, up->port.iobase, up->port.membase); | 1007 | serial_index(&up->port), up->port.iobase, up->port.membase); |
997 | 1008 | ||
998 | /* | 1009 | /* |
999 | * We really do need global IRQs disabled here - we're going to | 1010 | * We really do need global IRQs disabled here - we're going to |
@@ -1128,8 +1139,8 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
1128 | if (up->capabilities != uart_config[up->port.type].flags) { | 1139 | if (up->capabilities != uart_config[up->port.type].flags) { |
1129 | printk(KERN_WARNING | 1140 | printk(KERN_WARNING |
1130 | "ttyS%d: detected caps %08x should be %08x\n", | 1141 | "ttyS%d: detected caps %08x should be %08x\n", |
1131 | up->port.line, up->capabilities, | 1142 | serial_index(&up->port), up->capabilities, |
1132 | uart_config[up->port.type].flags); | 1143 | uart_config[up->port.type].flags); |
1133 | } | 1144 | } |
1134 | 1145 | ||
1135 | up->port.fifosize = uart_config[up->port.type].fifo_size; | 1146 | up->port.fifosize = uart_config[up->port.type].fifo_size; |
@@ -1424,8 +1435,7 @@ static unsigned int check_modem_status(struct uart_8250_port *up) | |||
1424 | /* | 1435 | /* |
1425 | * This handles the interrupt from one port. | 1436 | * This handles the interrupt from one port. |
1426 | */ | 1437 | */ |
1427 | static inline void | 1438 | static void serial8250_handle_port(struct uart_8250_port *up) |
1428 | serial8250_handle_port(struct uart_8250_port *up) | ||
1429 | { | 1439 | { |
1430 | unsigned int status; | 1440 | unsigned int status; |
1431 | unsigned long flags; | 1441 | unsigned long flags; |
@@ -1719,7 +1729,7 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) | |||
1719 | /* | 1729 | /* |
1720 | * Wait for transmitter & holding register to empty | 1730 | * Wait for transmitter & holding register to empty |
1721 | */ | 1731 | */ |
1722 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | 1732 | static void wait_for_xmitr(struct uart_8250_port *up, int bits) |
1723 | { | 1733 | { |
1724 | unsigned int status, tmout = 10000; | 1734 | unsigned int status, tmout = 10000; |
1725 | 1735 | ||
@@ -1854,7 +1864,8 @@ static int serial8250_startup(struct uart_port *port) | |||
1854 | */ | 1864 | */ |
1855 | if (!(up->port.flags & UPF_BUGGY_UART) && | 1865 | if (!(up->port.flags & UPF_BUGGY_UART) && |
1856 | (serial_inp(up, UART_LSR) == 0xff)) { | 1866 | (serial_inp(up, UART_LSR) == 0xff)) { |
1857 | printk("ttyS%d: LSR safety check engaged!\n", up->port.line); | 1867 | printk(KERN_INFO "ttyS%d: LSR safety check engaged!\n", |
1868 | serial_index(&up->port)); | ||
1858 | return -ENODEV; | 1869 | return -ENODEV; |
1859 | } | 1870 | } |
1860 | 1871 | ||
@@ -1909,7 +1920,8 @@ static int serial8250_startup(struct uart_port *port) | |||
1909 | */ | 1920 | */ |
1910 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { | 1921 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { |
1911 | up->bugs |= UART_BUG_THRE; | 1922 | up->bugs |= UART_BUG_THRE; |
1912 | pr_debug("ttyS%d - using backup timer\n", port->line); | 1923 | pr_debug("ttyS%d - using backup timer\n", |
1924 | serial_index(port)); | ||
1913 | } | 1925 | } |
1914 | } | 1926 | } |
1915 | 1927 | ||
@@ -1969,7 +1981,7 @@ static int serial8250_startup(struct uart_port *port) | |||
1969 | if (!(up->bugs & UART_BUG_TXEN)) { | 1981 | if (!(up->bugs & UART_BUG_TXEN)) { |
1970 | up->bugs |= UART_BUG_TXEN; | 1982 | up->bugs |= UART_BUG_TXEN; |
1971 | pr_debug("ttyS%d - enabling bad tx status workarounds\n", | 1983 | pr_debug("ttyS%d - enabling bad tx status workarounds\n", |
1972 | port->line); | 1984 | serial_index(port)); |
1973 | } | 1985 | } |
1974 | } else { | 1986 | } else { |
1975 | up->bugs &= ~UART_BUG_TXEN; | 1987 | up->bugs &= ~UART_BUG_TXEN; |
@@ -2211,9 +2223,9 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, | |||
2211 | serial_outp(up, UART_EFR, efr); | 2223 | serial_outp(up, UART_EFR, efr); |
2212 | } | 2224 | } |
2213 | 2225 | ||
2214 | #ifdef CONFIG_ARCH_OMAP15XX | 2226 | #ifdef CONFIG_ARCH_OMAP |
2215 | /* Workaround to enable 115200 baud on OMAP1510 internal ports */ | 2227 | /* Workaround to enable 115200 baud on OMAP1510 internal ports */ |
2216 | if (cpu_is_omap1510() && is_omap_port((unsigned int)up->port.membase)) { | 2228 | if (cpu_is_omap1510() && is_omap_port(up)) { |
2217 | if (baud == 115200) { | 2229 | if (baud == 115200) { |
2218 | quot = 1; | 2230 | quot = 1; |
2219 | serial_out(up, UART_OMAP_OSC_12M_SEL, 1); | 2231 | serial_out(up, UART_OMAP_OSC_12M_SEL, 1); |
@@ -2266,18 +2278,27 @@ serial8250_pm(struct uart_port *port, unsigned int state, | |||
2266 | p->pm(port, state, oldstate); | 2278 | p->pm(port, state, oldstate); |
2267 | } | 2279 | } |
2268 | 2280 | ||
2281 | static unsigned int serial8250_port_size(struct uart_8250_port *pt) | ||
2282 | { | ||
2283 | if (pt->port.iotype == UPIO_AU) | ||
2284 | return 0x100000; | ||
2285 | #ifdef CONFIG_ARCH_OMAP | ||
2286 | if (is_omap_port(pt)) | ||
2287 | return 0x16 << pt->port.regshift; | ||
2288 | #endif | ||
2289 | return 8 << pt->port.regshift; | ||
2290 | } | ||
2291 | |||
2269 | /* | 2292 | /* |
2270 | * Resource handling. | 2293 | * Resource handling. |
2271 | */ | 2294 | */ |
2272 | static int serial8250_request_std_resource(struct uart_8250_port *up) | 2295 | static int serial8250_request_std_resource(struct uart_8250_port *up) |
2273 | { | 2296 | { |
2274 | unsigned int size = 8 << up->port.regshift; | 2297 | unsigned int size = serial8250_port_size(up); |
2275 | int ret = 0; | 2298 | int ret = 0; |
2276 | 2299 | ||
2277 | switch (up->port.iotype) { | 2300 | switch (up->port.iotype) { |
2278 | case UPIO_AU: | 2301 | case UPIO_AU: |
2279 | size = 0x100000; | ||
2280 | /* fall thru */ | ||
2281 | case UPIO_TSI: | 2302 | case UPIO_TSI: |
2282 | case UPIO_MEM32: | 2303 | case UPIO_MEM32: |
2283 | case UPIO_MEM: | 2304 | case UPIO_MEM: |
@@ -2311,12 +2332,10 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) | |||
2311 | 2332 | ||
2312 | static void serial8250_release_std_resource(struct uart_8250_port *up) | 2333 | static void serial8250_release_std_resource(struct uart_8250_port *up) |
2313 | { | 2334 | { |
2314 | unsigned int size = 8 << up->port.regshift; | 2335 | unsigned int size = serial8250_port_size(up); |
2315 | 2336 | ||
2316 | switch (up->port.iotype) { | 2337 | switch (up->port.iotype) { |
2317 | case UPIO_AU: | 2338 | case UPIO_AU: |
2318 | size = 0x100000; | ||
2319 | /* fall thru */ | ||
2320 | case UPIO_TSI: | 2339 | case UPIO_TSI: |
2321 | case UPIO_MEM32: | 2340 | case UPIO_MEM32: |
2322 | case UPIO_MEM: | 2341 | case UPIO_MEM: |
@@ -2630,7 +2649,6 @@ static int serial8250_console_early_setup(void) | |||
2630 | return serial8250_find_port_for_earlycon(); | 2649 | return serial8250_find_port_for_earlycon(); |
2631 | } | 2650 | } |
2632 | 2651 | ||
2633 | static struct uart_driver serial8250_reg; | ||
2634 | static struct console serial8250_console = { | 2652 | static struct console serial8250_console = { |
2635 | .name = "ttyS", | 2653 | .name = "ttyS", |
2636 | .write = serial8250_console_write, | 2654 | .write = serial8250_console_write, |
@@ -2677,7 +2695,6 @@ static struct uart_driver serial8250_reg = { | |||
2677 | .dev_name = "ttyS", | 2695 | .dev_name = "ttyS", |
2678 | .major = TTY_MAJOR, | 2696 | .major = TTY_MAJOR, |
2679 | .minor = 64, | 2697 | .minor = 64, |
2680 | .nr = UART_NR, | ||
2681 | .cons = SERIAL8250_CONSOLE, | 2698 | .cons = SERIAL8250_CONSOLE, |
2682 | }; | 2699 | }; |
2683 | 2700 | ||
@@ -2962,7 +2979,12 @@ static int __init serial8250_init(void) | |||
2962 | for (i = 0; i < NR_IRQS; i++) | 2979 | for (i = 0; i < NR_IRQS; i++) |
2963 | spin_lock_init(&irq_lists[i].lock); | 2980 | spin_lock_init(&irq_lists[i].lock); |
2964 | 2981 | ||
2982 | #ifdef CONFIG_SPARC | ||
2983 | ret = sunserial_register_minors(&serial8250_reg, UART_NR); | ||
2984 | #else | ||
2985 | serial8250_reg.nr = UART_NR; | ||
2965 | ret = uart_register_driver(&serial8250_reg); | 2986 | ret = uart_register_driver(&serial8250_reg); |
2987 | #endif | ||
2966 | if (ret) | 2988 | if (ret) |
2967 | goto out; | 2989 | goto out; |
2968 | 2990 | ||
@@ -2987,7 +3009,11 @@ static int __init serial8250_init(void) | |||
2987 | put_dev: | 3009 | put_dev: |
2988 | platform_device_put(serial8250_isa_devs); | 3010 | platform_device_put(serial8250_isa_devs); |
2989 | unreg_uart_drv: | 3011 | unreg_uart_drv: |
3012 | #ifdef CONFIG_SPARC | ||
3013 | sunserial_unregister_minors(&serial8250_reg, UART_NR); | ||
3014 | #else | ||
2990 | uart_unregister_driver(&serial8250_reg); | 3015 | uart_unregister_driver(&serial8250_reg); |
3016 | #endif | ||
2991 | out: | 3017 | out: |
2992 | return ret; | 3018 | return ret; |
2993 | } | 3019 | } |
@@ -3006,7 +3032,11 @@ static void __exit serial8250_exit(void) | |||
3006 | platform_driver_unregister(&serial8250_isa_driver); | 3032 | platform_driver_unregister(&serial8250_isa_driver); |
3007 | platform_device_unregister(isa_dev); | 3033 | platform_device_unregister(isa_dev); |
3008 | 3034 | ||
3035 | #ifdef CONFIG_SPARC | ||
3036 | sunserial_unregister_minors(&serial8250_reg, UART_NR); | ||
3037 | #else | ||
3009 | uart_unregister_driver(&serial8250_reg); | 3038 | uart_unregister_driver(&serial8250_reg); |
3039 | #endif | ||
3010 | } | 3040 | } |
3011 | 3041 | ||
3012 | module_init(serial8250_init); | 3042 | module_init(serial8250_init); |