X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fserial%2Fvr41xx_siu.c;h=865d4dea65df9b4d131bac4f50fe496246c9b535;hb=388f7ef720a982f49925e7b4e96f216f208f8c03;hp=5d2ceb623e6fcebe34319cac6c4bcd72d2c78739;hpb=79121839aad7153907b92462759675266f1f2ac4;p=powerpc.git diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 5d2ceb623e..865d4dea65 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c @@ -26,7 +26,7 @@ #endif #include -#include +#include #include #include #include @@ -234,7 +234,7 @@ static inline const char *siu_type_name(struct uart_port *port) return "DSIU"; } - return "unknown"; + return NULL; } static unsigned int siu_tx_empty(struct uart_port *port) @@ -284,7 +284,7 @@ static unsigned int siu_get_mctrl(struct uart_port *port) return mctrl; } -static void siu_stop_tx(struct uart_port *port, unsigned int tty_stop) +static void siu_stop_tx(struct uart_port *port) { unsigned long flags; uint8_t ier; @@ -298,7 +298,7 @@ static void siu_stop_tx(struct uart_port *port, unsigned int tty_stop) spin_unlock_irqrestore(&port->lock, flags); } -static void siu_start_tx(struct uart_port *port, unsigned int tty_start) +static void siu_start_tx(struct uart_port *port) { unsigned long flags; uint8_t ier; @@ -458,7 +458,7 @@ static inline void transmit_chars(struct uart_port *port) } if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { - siu_stop_tx(port, 0); + siu_stop_tx(port); return; } @@ -474,7 +474,7 @@ static inline void transmit_chars(struct uart_port *port) uart_write_wakeup(port); if (uart_circ_empty(xmit)) - siu_stop_tx(port, 0); + siu_stop_tx(port); } static irqreturn_t siu_interrupt(int irq, void *dev_id, struct pt_regs *regs) @@ -482,9 +482,6 @@ static irqreturn_t siu_interrupt(int irq, void *dev_id, struct pt_regs *regs) struct uart_port *port; uint8_t iir, lsr; - if (dev_id == NULL) - return IRQ_NONE; - port = (struct uart_port *)dev_id; iir = siu_read(port, UART_IIR); @@ -507,6 +504,9 @@ static int siu_startup(struct uart_port *port) { int retval; + if (port->membase == NULL) + return -ENODEV; + siu_clear_fifo(port); (void)siu_read(port, UART_LSR); @@ -545,9 +545,6 @@ static void siu_shutdown(struct uart_port *port) unsigned long flags; uint8_t lcr; - if (port->membase == NULL) - return; - siu_write(port, UART_IER, 0); spin_lock_irqsave(&port->lock, flags); @@ -802,53 +799,6 @@ static int siu_init_ports(void) #ifdef CONFIG_SERIAL_VR41XX_CONSOLE -static void early_set_termios(struct uart_port *port, struct termios *new, - struct termios *old) -{ - tcflag_t c_cflag; - uint8_t lcr; - unsigned int baud, quot; - - c_cflag = new->c_cflag; - switch (c_cflag & CSIZE) { - case CS5: - lcr = UART_LCR_WLEN5; - break; - case CS6: - lcr = UART_LCR_WLEN6; - break; - case CS7: - lcr = UART_LCR_WLEN7; - break; - default: - lcr = UART_LCR_WLEN8; - break; - } - - if (c_cflag & CSTOPB) - lcr |= UART_LCR_STOP; - if (c_cflag & PARENB) - lcr |= UART_LCR_PARITY; - if ((c_cflag & PARODD) != PARODD) - lcr |= UART_LCR_EPAR; - if (c_cflag & CMSPAR) - lcr |= UART_LCR_SPAR; - - baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); - quot = uart_get_divisor(port, baud); - - siu_write(port, UART_LCR, lcr | UART_LCR_DLAB); - - siu_write(port, UART_DLL, (uint8_t)quot); - siu_write(port, UART_DLM, (uint8_t)(quot >> 8)); - - siu_write(port, UART_LCR, lcr); -} - -static struct uart_ops early_uart_ops = { - .set_termios = early_set_termios, -}; - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) static void wait_for_xmitr(struct uart_port *port) @@ -915,7 +865,7 @@ static int siu_console_setup(struct console *con, char *options) if (port->membase == NULL) { if (port->mapbase == 0) return -ENODEV; - port->membase = (unsigned char __iomem *)KSEG1ADDR(port->mapbase); + port->membase = ioremap(port->mapbase, siu_port_size(port)); } vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); @@ -949,7 +899,7 @@ static int __devinit siu_console_init(void) for (i = 0; i < num; i++) { port = &siu_uart_ports[i]; - port->ops = &early_uart_ops; + port->ops = &siu_uart_ops; } register_console(&siu_console); @@ -974,7 +924,7 @@ static struct uart_driver siu_uart_driver = { .cons = SERIAL_VR41XX_CONSOLE, }; -static int siu_probe(struct device *dev) +static int siu_probe(struct platform_device *dev) { struct uart_port *port; int num, i, retval; @@ -991,11 +941,13 @@ static int siu_probe(struct device *dev) for (i = 0; i < num; i++) { port = &siu_uart_ports[i]; port->ops = &siu_uart_ops; - port->dev = dev; + port->dev = &dev->dev; retval = uart_add_one_port(&siu_uart_driver, port); - if (retval) + if (retval < 0) { + port->dev = NULL; break; + } } if (i == 0 && retval < 0) { @@ -1006,14 +958,14 @@ static int siu_probe(struct device *dev) return 0; } -static int siu_remove(struct device *dev) +static int siu_remove(struct platform_device *dev) { struct uart_port *port; int i; for (i = 0; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i]; - if (port->dev == dev) { + if (port->dev == &dev->dev) { uart_remove_one_port(&siu_uart_driver, port); port->dev = NULL; } @@ -1024,18 +976,15 @@ static int siu_remove(struct device *dev) return 0; } -static int siu_suspend(struct device *dev, pm_message_t state, u32 level) +static int siu_suspend(struct platform_device *dev, pm_message_t state) { struct uart_port *port; int i; - if (level != SUSPEND_DISABLE) - return 0; - for (i = 0; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i]; if ((port->type == PORT_VR41XX_SIU || - port->type == PORT_VR41XX_DSIU) && port->dev == dev) + port->type == PORT_VR41XX_DSIU) && port->dev == &dev->dev) uart_suspend_port(&siu_uart_driver, port); } @@ -1043,18 +992,15 @@ static int siu_suspend(struct device *dev, pm_message_t state, u32 level) return 0; } -static int siu_resume(struct device *dev, u32 level) +static int siu_resume(struct platform_device *dev) { struct uart_port *port; int i; - if (level != RESUME_ENABLE) - return 0; - for (i = 0; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i]; if ((port->type == PORT_VR41XX_SIU || - port->type == PORT_VR41XX_DSIU) && port->dev == dev) + port->type == PORT_VR41XX_DSIU) && port->dev == &dev->dev) uart_resume_port(&siu_uart_driver, port); } @@ -1063,13 +1009,14 @@ static int siu_resume(struct device *dev, u32 level) static struct platform_device *siu_platform_device; -static struct device_driver siu_device_driver = { - .name = "SIU", - .bus = &platform_bus_type, +static struct platform_driver siu_device_driver = { .probe = siu_probe, .remove = siu_remove, .suspend = siu_suspend, .resume = siu_resume, + .driver = { + .name = "SIU", + }, }; static int __devinit vr41xx_siu_init(void) @@ -1080,7 +1027,7 @@ static int __devinit vr41xx_siu_init(void) if (IS_ERR(siu_platform_device)) return PTR_ERR(siu_platform_device); - retval = driver_register(&siu_device_driver); + retval = platform_driver_register(&siu_device_driver); if (retval < 0) platform_device_unregister(siu_platform_device); @@ -1089,7 +1036,7 @@ static int __devinit vr41xx_siu_init(void) static void __devexit vr41xx_siu_exit(void) { - driver_unregister(&siu_device_driver); + platform_driver_unregister(&siu_device_driver); platform_device_unregister(siu_platform_device); }