From 5668545a08c80e0d9dc325bd6c79028b19227e5d Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 1 Sep 2008 21:25:33 +0100 Subject: [ARM] omap: improve is_omap_port() Make is_omap_port() take the uart_8250_port structure so it can do whatever test it desires. Convert the test to compare the physical addresses rather than virtual addresses. Signed-off-by: Russell King --- drivers/serial/8250.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 9ccc563d8730..47a60960bb1c 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -2213,7 +2213,7 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, #ifdef CONFIG_ARCH_OMAP15XX /* Workaround to enable 115200 baud on OMAP1510 internal ports */ - if (cpu_is_omap1510() && is_omap_port((unsigned int)up->port.membase)) { + if (cpu_is_omap1510() && is_omap_port(up)) { if (baud == 115200) { quot = 1; serial_out(up, UART_OMAP_OSC_12M_SEL, 1); -- cgit v1.2.3 From f2eda27d1cd218f6544cd9367be47fb01c70a95d Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 1 Sep 2008 21:47:59 +0100 Subject: [SERIAL] 8250: serial8250_port_size() - omap ports are larger A function to contain common code for the size of the resource we need to allocate or free. OMAP ports need 22 bytes rather than the standard 8 bytes. Signed-off-by: Russell King --- drivers/serial/8250.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 47a60960bb1c..8058533f8418 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -2211,7 +2211,7 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, serial_outp(up, UART_EFR, efr); } -#ifdef CONFIG_ARCH_OMAP15XX +#ifdef CONFIG_ARCH_OMAP /* Workaround to enable 115200 baud on OMAP1510 internal ports */ if (cpu_is_omap1510() && is_omap_port(up)) { if (baud == 115200) { @@ -2266,18 +2266,27 @@ serial8250_pm(struct uart_port *port, unsigned int state, p->pm(port, state, oldstate); } +static unsigned int serial8250_port_size(struct uart_8250_port *pt) +{ + if (pt->port.iotype == UPIO_AU) + return 0x100000; +#ifdef CONFIG_ARCH_OMAP + if (is_omap_port(pt)) + return 0x16 << pt->port.regshift; +#endif + return 8 << pt->port.regshift; +} + /* * Resource handling. */ static int serial8250_request_std_resource(struct uart_8250_port *up) { - unsigned int size = 8 << up->port.regshift; + unsigned int size = serial8250_port_size(up); int ret = 0; switch (up->port.iotype) { case UPIO_AU: - size = 0x100000; - /* fall thru */ case UPIO_TSI: case UPIO_MEM32: case UPIO_MEM: @@ -2311,12 +2320,10 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) static void serial8250_release_std_resource(struct uart_8250_port *up) { - unsigned int size = 8 << up->port.regshift; + unsigned int size = serial8250_port_size(up); switch (up->port.iotype) { case UPIO_AU: - size = 0x100000; - /* fall thru */ case UPIO_TSI: case UPIO_MEM32: case UPIO_MEM: -- cgit v1.2.3 From b5d674abcffeacaf83038bbf7c0caf24edd497dd Mon Sep 17 00:00:00 2001 From: Will Newton Date: Mon, 13 Oct 2008 10:36:21 +0100 Subject: 8250: remove a few inlines of dubious value Remove some inlines from various functions that are called once, are too big to inline, or are called only from slow path code. This saves around 300 bytes of code for me. Signed-off-by: Will Newton Signed-off-by: Andrew Morton Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/serial/8250.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 9ccc563d8730..ed593c4b6e7d 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -536,7 +536,7 @@ static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) /* * FIFO support. */ -static inline void serial8250_clear_fifos(struct uart_8250_port *p) +static void serial8250_clear_fifos(struct uart_8250_port *p) { if (p->capabilities & UART_CAP_FIFO) { serial_outp(p, UART_FCR, UART_FCR_ENABLE_FIFO); @@ -551,7 +551,7 @@ static inline void serial8250_clear_fifos(struct uart_8250_port *p) * capability" bit enabled. Note that on XR16C850s, we need to * reset LCR to write to IER. */ -static inline void serial8250_set_sleep(struct uart_8250_port *p, int sleep) +static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) { if (p->capabilities & UART_CAP_SLEEP) { if (p->capabilities & UART_CAP_EFR) { @@ -1424,8 +1424,7 @@ static unsigned int check_modem_status(struct uart_8250_port *up) /* * This handles the interrupt from one port. */ -static inline void -serial8250_handle_port(struct uart_8250_port *up) +static void serial8250_handle_port(struct uart_8250_port *up) { unsigned int status; unsigned long flags; @@ -1719,7 +1718,7 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) /* * Wait for transmitter & holding register to empty */ -static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) +static void wait_for_xmitr(struct uart_8250_port *up, int bits) { unsigned int status, tmout = 10000; -- cgit v1.2.3 From b70ac7718579b5cbf3bdd74fd01132d1c91596f4 Mon Sep 17 00:00:00 2001 From: David Miller Date: Mon, 13 Oct 2008 10:36:31 +0100 Subject: serial: allow 8250 to be used on sparc This requires three changes: 1) Remove !SPARC restriction in Kconfig. 2) Move Sparc specific serial drivers before 8250, so that serial console devices don't change names on us, even if 8250 finds devices. 3) Since the Sparc specific serial drivers try to use the same major/minor device namespace as 8250, some coordination is necessary. Use the sunserial_*() layer routines to allocate minor number space within TTY_MAJOR when CONFIG_SPARC. This has no effect on other platforms. Thanks to Josip Rodin for bringing up this issue and testing plus debugging various revisions of this patch. Signed-off-by: David S. Miller Signed-off-by: Andrew Morton Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/serial/8250.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index ed593c4b6e7d..db2cdc103c88 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -44,6 +44,10 @@ #include "8250.h" +#ifdef CONFIG_SPARC +#include "suncore.h" +#endif + /* * Configuration: * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option @@ -2676,7 +2680,6 @@ static struct uart_driver serial8250_reg = { .dev_name = "ttyS", .major = TTY_MAJOR, .minor = 64, - .nr = UART_NR, .cons = SERIAL8250_CONSOLE, }; @@ -2958,10 +2961,12 @@ static int __init serial8250_init(void) "%d ports, IRQ sharing %sabled\n", nr_uarts, share_irqs ? "en" : "dis"); - for (i = 0; i < NR_IRQS; i++) - spin_lock_init(&irq_lists[i].lock); - +#ifdef CONFIG_SPARC + ret = sunserial_register_minors(&serial8250_reg, UART_NR); +#else + serial8250_reg.nr = UART_NR; ret = uart_register_driver(&serial8250_reg); +#endif if (ret) goto out; @@ -2986,7 +2991,11 @@ static int __init serial8250_init(void) put_dev: platform_device_put(serial8250_isa_devs); unreg_uart_drv: +#ifdef CONFIG_SPARC + sunserial_unregister_minors(&serial8250_reg, UART_NR); +#else uart_unregister_driver(&serial8250_reg); +#endif out: return ret; } @@ -3005,7 +3014,11 @@ static void __exit serial8250_exit(void) platform_driver_unregister(&serial8250_isa_driver); platform_device_unregister(isa_dev); +#ifdef CONFIG_SPARC + sunserial_unregister_minors(&serial8250_reg, UART_NR); +#else uart_unregister_driver(&serial8250_reg); +#endif } module_init(serial8250_init); -- cgit v1.2.3 From 8440838bc5337243917f13bc14ea2445da5e0197 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 13 Oct 2008 10:45:26 +0100 Subject: serial: fix device name reporting when minor space is shared between drivers The multiple drivers share the minor space occupied by a particular major number, the actual index within the device name's space is indicated by the tty_driver->name_base + uart_port->line Another usable formula is (uart_driver->minor - MINOR_BASE) + port->line Use those to print the device names properly in such situations in serial_core.c and 8250.c Signed-off-by: David S. Miller Signed-off-by: Andrew Morton Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- drivers/serial/8250.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index db2cdc103c88..d4104a3bbe87 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -57,6 +57,13 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; +static struct uart_driver serial8250_reg; + +static int serial_index(struct uart_port *port) +{ + return (serial8250_reg.minor - 64) + port->line; +} + /* * Debugging. */ @@ -997,7 +1004,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) return; DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", - up->port.line, up->port.iobase, up->port.membase); + serial_index(&up->port), up->port.iobase, up->port.membase); /* * We really do need global IRQs disabled here - we're going to @@ -1132,8 +1139,8 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) if (up->capabilities != uart_config[up->port.type].flags) { printk(KERN_WARNING "ttyS%d: detected caps %08x should be %08x\n", - up->port.line, up->capabilities, - uart_config[up->port.type].flags); + serial_index(&up->port), up->capabilities, + uart_config[up->port.type].flags); } up->port.fifosize = uart_config[up->port.type].fifo_size; @@ -1857,7 +1864,8 @@ static int serial8250_startup(struct uart_port *port) */ if (!(up->port.flags & UPF_BUGGY_UART) && (serial_inp(up, UART_LSR) == 0xff)) { - printk("ttyS%d: LSR safety check engaged!\n", up->port.line); + printk(KERN_INFO "ttyS%d: LSR safety check engaged!\n", + serial_index(&up->port)); return -ENODEV; } @@ -1912,7 +1920,8 @@ static int serial8250_startup(struct uart_port *port) */ if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { up->bugs |= UART_BUG_THRE; - pr_debug("ttyS%d - using backup timer\n", port->line); + pr_debug("ttyS%d - using backup timer\n", + serial_index(port)); } } @@ -1972,7 +1981,7 @@ static int serial8250_startup(struct uart_port *port) if (!(up->bugs & UART_BUG_TXEN)) { up->bugs |= UART_BUG_TXEN; pr_debug("ttyS%d - enabling bad tx status workarounds\n", - port->line); + serial_index(port)); } } else { up->bugs &= ~UART_BUG_TXEN; @@ -2633,7 +2642,6 @@ static int serial8250_console_early_setup(void) return serial8250_find_port_for_earlycon(); } -static struct uart_driver serial8250_reg; static struct console serial8250_console = { .name = "ttyS", .write = serial8250_console_write, -- cgit v1.2.3 From 4aba41ea8bdc1b475861f5e5c1649ab20251090c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 14 Oct 2008 11:29:06 +0100 Subject: 8250: Fix lock warning (and possible crash) Splitting the 8250 code back up to avoid a clash with the NR_IRQS removal patch introduced a last minute bug. Put back the additional needed lines for the old lock init Signed-off-by: Alan Cox [ Ingo also reports that this can cause a spontaneous reboot crash with certain configs, and sends in an identical patch ] Tested-by: Kamalesh Babulal Signed-off-by: Linus Torvalds --- drivers/serial/8250.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/serial/8250.c') diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index d4104a3bbe87..d3ca7d32abe0 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -2969,6 +2969,9 @@ static int __init serial8250_init(void) "%d ports, IRQ sharing %sabled\n", nr_uarts, share_irqs ? "en" : "dis"); + for (i = 0; i < NR_IRQS; i++) + spin_lock_init(&irq_lists[i].lock); + #ifdef CONFIG_SPARC ret = sunserial_register_minors(&serial8250_reg, UART_NR); #else -- cgit v1.2.3