X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fserial%2Fsa1100.c;h=67b2338913c2d08c7fd58a86836053b899cfbf0d;hb=dd5656e59ca7b25fb60a22f9079905ed0da5ed0c;hp=dd8aed242357c77e2043b53248c7ff00ec1cfaa8;hpb=2d93486c6c110cf81db720359b4ec20de9c91450;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c index dd8aed2..67b2338 100644 --- a/drivers/serial/sa1100.c +++ b/drivers/serial/sa1100.c @@ -24,7 +24,6 @@ * $Id: sa1100.c,v 1.50 2002/07/29 14:41:04 rmk Exp $ * */ -#include #if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) #define SUPPORT_SYSRQ @@ -35,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -156,19 +155,16 @@ static void sa1100_stop_tx(struct uart_port *port) } /* - * interrupts may not be disabled on entry + * port locked and interrupts disabled */ static void sa1100_start_tx(struct uart_port *port) { struct sa1100_port *sport = (struct sa1100_port *)port; - unsigned long flags; u32 utcr3; - spin_lock_irqsave(&sport->port.lock, flags); utcr3 = UART_GET_UTCR3(sport); sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS); UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE); - spin_unlock_irqrestore(&sport->port.lock, flags); } /* @@ -194,7 +190,7 @@ static void sa1100_enable_ms(struct uart_port *port) } static void -sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs) +sa1100_rx_chars(struct sa1100_port *sport) { struct tty_struct *tty = sport->port.info->tty; unsigned int status, ch, flg; @@ -204,8 +200,6 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs) while (status & UTSR1_TO_SM(UTSR1_RNE)) { ch = UART_GET_CHAR(sport); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; sport->port.icount.rx++; flg = TTY_NORMAL; @@ -234,7 +228,7 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs) #endif } - if (uart_handle_sysrq_char(&sport->port, ch, regs)) + if (uart_handle_sysrq_char(&sport->port, ch)) goto ignore_char; uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg); @@ -287,7 +281,7 @@ static void sa1100_tx_chars(struct sa1100_port *sport) sa1100_stop_tx(&sport->port); } -static irqreturn_t sa1100_int(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t sa1100_int(int irq, void *dev_id) { struct sa1100_port *sport = dev_id; unsigned int status, pass_counter = 0; @@ -300,7 +294,7 @@ static irqreturn_t sa1100_int(int irq, void *dev_id, struct pt_regs *regs) /* Clear the receiver idle bit, if set */ if (status & UTSR0_RID) UART_PUT_UTSR0(sport, UTSR0_RID); - sa1100_rx_chars(sport, regs); + sa1100_rx_chars(sport); } /* Clear the relevant break bits */ @@ -414,8 +408,8 @@ static void sa1100_shutdown(struct uart_port *port) } static void -sa1100_set_termios(struct uart_port *port, struct termios *termios, - struct termios *old) +sa1100_set_termios(struct uart_port *port, struct ktermios *termios, + struct ktermios *old) { struct sa1100_port *sport = (struct sa1100_port *)port; unsigned long flags; @@ -633,7 +627,7 @@ static void __init sa1100_init_ports(void) sa1100_ports[i].port.ops = &sa1100_pops; sa1100_ports[i].port.fifosize = 8; sa1100_ports[i].port.line = i; - sa1100_ports[i].port.iotype = SERIAL_IO_MEM; + sa1100_ports[i].port.iotype = UPIO_MEM; init_timer(&sa1100_ports[i].timer); sa1100_ports[i].timer.function = sa1100_timeout; sa1100_ports[i].timer.data = (unsigned long)&sa1100_ports[i]; @@ -670,21 +664,21 @@ void __init sa1100_register_uart(int idx, int port) sa1100_ports[idx].port.membase = (void __iomem *)&Ser1UTCR0; sa1100_ports[idx].port.mapbase = _Ser1UTCR0; sa1100_ports[idx].port.irq = IRQ_Ser1UART; - sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; + sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF; break; case 2: sa1100_ports[idx].port.membase = (void __iomem *)&Ser2UTCR0; sa1100_ports[idx].port.mapbase = _Ser2UTCR0; sa1100_ports[idx].port.irq = IRQ_Ser2ICP; - sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; + sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF; break; case 3: sa1100_ports[idx].port.membase = (void __iomem *)&Ser3UTCR0; sa1100_ports[idx].port.mapbase = _Ser3UTCR0; sa1100_ports[idx].port.irq = IRQ_Ser3UART; - sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; + sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF; break; default: @@ -694,6 +688,14 @@ void __init sa1100_register_uart(int idx, int port) #ifdef CONFIG_SERIAL_SA1100_CONSOLE +static void sa1100_console_putchar(struct uart_port *port, int ch) +{ + struct sa1100_port *sport = (struct sa1100_port *)port; + + while (!(UART_GET_UTSR1(sport) & UTSR1_TNF)) + barrier(); + UART_PUT_CHAR(sport, ch); +} /* * Interrupts are disabled on entering @@ -702,7 +704,7 @@ static void sa1100_console_write(struct console *co, const char *s, unsigned int count) { struct sa1100_port *sport = &sa1100_ports[co->index]; - unsigned int old_utcr3, status, i; + unsigned int old_utcr3, status; /* * First, save UTCR3 and then disable interrupts @@ -711,21 +713,7 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count) UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) | UTCR3_TXE); - /* - * Now, do each character - */ - for (i = 0; i < count; i++) { - do { - status = UART_GET_UTSR1(sport); - } while (!(status & UTSR1_TNF)); - UART_PUT_CHAR(sport, s[i]); - if (s[i] == '\n') { - do { - status = UART_GET_UTSR1(sport); - } while (!(status & UTSR1_TNF)); - UART_PUT_CHAR(sport, '\r'); - } - } + uart_console_write(&sport->port, s, count, sa1100_console_putchar); /* * Finally, wait for transmitter to become empty @@ -827,36 +815,34 @@ static struct uart_driver sa1100_reg = { .owner = THIS_MODULE, .driver_name = "ttySA", .dev_name = "ttySA", - .devfs_name = "ttySA", .major = SERIAL_SA1100_MAJOR, .minor = MINOR_START, .nr = NR_PORTS, .cons = SA1100_CONSOLE, }; -static int sa1100_serial_suspend(struct device *_dev, pm_message_t state, u32 level) +static int sa1100_serial_suspend(struct platform_device *dev, pm_message_t state) { - struct sa1100_port *sport = dev_get_drvdata(_dev); + struct sa1100_port *sport = platform_get_drvdata(dev); - if (sport && level == SUSPEND_DISABLE) + if (sport) uart_suspend_port(&sa1100_reg, &sport->port); return 0; } -static int sa1100_serial_resume(struct device *_dev, u32 level) +static int sa1100_serial_resume(struct platform_device *dev) { - struct sa1100_port *sport = dev_get_drvdata(_dev); + struct sa1100_port *sport = platform_get_drvdata(dev); - if (sport && level == RESUME_ENABLE) + if (sport) uart_resume_port(&sa1100_reg, &sport->port); return 0; } -static int sa1100_serial_probe(struct device *_dev) +static int sa1100_serial_probe(struct platform_device *dev) { - struct platform_device *dev = to_platform_device(_dev); struct resource *res = dev->resource; int i; @@ -869,9 +855,9 @@ static int sa1100_serial_probe(struct device *_dev) if (sa1100_ports[i].port.mapbase != res->start) continue; - sa1100_ports[i].port.dev = _dev; + sa1100_ports[i].port.dev = &dev->dev; uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port); - dev_set_drvdata(_dev, &sa1100_ports[i]); + platform_set_drvdata(dev, &sa1100_ports[i]); break; } } @@ -879,11 +865,11 @@ static int sa1100_serial_probe(struct device *_dev) return 0; } -static int sa1100_serial_remove(struct device *_dev) +static int sa1100_serial_remove(struct platform_device *pdev) { - struct sa1100_port *sport = dev_get_drvdata(_dev); + struct sa1100_port *sport = platform_get_drvdata(pdev); - dev_set_drvdata(_dev, NULL); + platform_set_drvdata(pdev, NULL); if (sport) uart_remove_one_port(&sa1100_reg, &sport->port); @@ -891,13 +877,15 @@ static int sa1100_serial_remove(struct device *_dev) return 0; } -static struct device_driver sa11x0_serial_driver = { - .name = "sa11x0-uart", - .bus = &platform_bus_type, +static struct platform_driver sa11x0_serial_driver = { .probe = sa1100_serial_probe, .remove = sa1100_serial_remove, .suspend = sa1100_serial_suspend, .resume = sa1100_serial_resume, + .driver = { + .name = "sa11x0-uart", + .owner = THIS_MODULE, + }, }; static int __init sa1100_serial_init(void) @@ -910,7 +898,7 @@ static int __init sa1100_serial_init(void) ret = uart_register_driver(&sa1100_reg); if (ret == 0) { - ret = driver_register(&sa11x0_serial_driver); + ret = platform_driver_register(&sa11x0_serial_driver); if (ret) uart_unregister_driver(&sa1100_reg); } @@ -919,7 +907,7 @@ static int __init sa1100_serial_init(void) static void __exit sa1100_serial_exit(void) { - driver_unregister(&sa11x0_serial_driver); + platform_driver_unregister(&sa11x0_serial_driver); uart_unregister_driver(&sa1100_reg); } @@ -930,3 +918,4 @@ MODULE_AUTHOR("Deep Blue Solutions Ltd"); MODULE_DESCRIPTION("SA1100 generic serial port driver $Revision: 1.50 $"); MODULE_LICENSE("GPL"); MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_SA1100_MAJOR); +MODULE_ALIAS("platform:sa11x0-uart");