--- zzzz-none-000/linux-3.10.107/drivers/tty/serial/mcf.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/tty/serial/mcf.c 2021-02-04 17:41:59.000000000 +0000 @@ -3,7 +3,7 @@ /* * mcf.c -- Freescale ColdFire UART driver * - * (C) Copyright 2003-2007, Greg Ungerer + * (C) Copyright 2003-2007, Greg Ungerer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,6 @@ struct uart_port port; unsigned int sigs; /* Local copy of line sigs */ unsigned char imr; /* Local IMR mirror */ - struct serial_rs485 rs485; /* RS485 settings */ }; /****************************************************************************/ @@ -103,7 +103,7 @@ { struct mcf_uart *pp = container_of(port, struct mcf_uart, port); - if (pp->rs485.flags & SER_RS485_ENABLED) { + if (port->rs485.flags & SER_RS485_ENABLED) { /* Enable Transmitter */ writeb(MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR); /* Manually assert RTS */ @@ -149,12 +149,6 @@ /****************************************************************************/ -static void mcf_enable_ms(struct uart_port *port) -{ -} - -/****************************************************************************/ - static int mcf_startup(struct uart_port *port) { struct mcf_uart *pp = container_of(port, struct mcf_uart, port); @@ -204,7 +198,6 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { - struct mcf_uart *pp = container_of(port, struct mcf_uart, port); unsigned long flags; unsigned int baud, baudclk; #if defined(CONFIG_M5272) @@ -247,6 +240,12 @@ mr1 |= MCFUART_MR1_PARITYNONE; } + /* + * FIXME: port->read_status_mask and port->ignore_status_mask + * need to be initialized based on termios settings for + * INPCK, IGNBRK, IGNPAR, PARMRK, BRKINT + */ + if (termios->c_cflag & CSTOPB) mr2 |= MCFUART_MR2_STOP2; else @@ -257,12 +256,12 @@ mr2 |= MCFUART_MR2_TXCTS; } - if (pp->rs485.flags & SER_RS485_ENABLED) { + spin_lock_irqsave(&port->lock, flags); + if (port->rs485.flags & SER_RS485_ENABLED) { dev_dbg(port->dev, "Setting UART to RS485\n"); mr2 |= MCFUART_MR2_TXRTS; } - spin_lock_irqsave(&port->lock, flags); uart_update_timeout(port, termios->c_cflag, baud); writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); @@ -324,7 +323,9 @@ uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); } + spin_unlock(&port->lock); tty_flip_buffer_push(&port->state->port); + spin_lock(&port->lock); } /****************************************************************************/ @@ -357,7 +358,7 @@ pp->imr &= ~MCFUART_UIR_TXREADY; writeb(pp->imr, port->membase + MCFUART_UIMR); /* Disable TX to negate RTS automatically */ - if (pp->rs485.flags & SER_RS485_ENABLED) + if (port->rs485.flags & SER_RS485_ENABLED) writeb(MCFUART_UCR_TXDISABLE, port->membase + MCFUART_UCR); } @@ -437,13 +438,10 @@ /****************************************************************************/ /* Enable or disable the RS485 support */ -static void mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) +static int mcf_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) { - struct mcf_uart *pp = container_of(port, struct mcf_uart, port); - unsigned long flags; unsigned char mr1, mr2; - spin_lock_irqsave(&port->lock, flags); /* Get mode registers */ mr1 = readb(port->membase + MCFUART_UMR); mr2 = readb(port->membase + MCFUART_UMR); @@ -457,32 +455,8 @@ } writeb(mr1, port->membase + MCFUART_UMR); writeb(mr2, port->membase + MCFUART_UMR); - pp->rs485 = *rs485; - spin_unlock_irqrestore(&port->lock, flags); -} + port->rs485 = *rs485; -static int mcf_ioctl(struct uart_port *port, unsigned int cmd, - unsigned long arg) -{ - switch (cmd) { - case TIOCSRS485: { - struct serial_rs485 rs485; - if (copy_from_user(&rs485, (struct serial_rs485 *)arg, - sizeof(struct serial_rs485))) - return -EFAULT; - mcf_config_rs485(port, &rs485); - break; - } - case TIOCGRS485: { - struct mcf_uart *pp = container_of(port, struct mcf_uart, port); - if (copy_to_user((struct serial_rs485 *)arg, &pp->rs485, - sizeof(struct serial_rs485))) - return -EFAULT; - break; - } - default: - return -ENOIOCTLCMD; - } return 0; } @@ -498,7 +472,6 @@ .start_tx = mcf_start_tx, .stop_tx = mcf_stop_tx, .stop_rx = mcf_stop_rx, - .enable_ms = mcf_enable_ms, .break_ctl = mcf_break_ctl, .startup = mcf_startup, .shutdown = mcf_shutdown, @@ -508,7 +481,6 @@ .release_port = mcf_release_port, .config_port = mcf_config_port, .verify_port = mcf_verify_port, - .ioctl = mcf_ioctl, }; static struct mcf_uart mcf_ports[4]; @@ -535,7 +507,8 @@ port->iotype = SERIAL_IO_MEM; port->irq = platp[i].irq; port->uartclk = MCF_BUSCLK; - port->flags = ASYNC_BOOT_AUTOCONF; + port->flags = UPF_BOOT_AUTOCONF; + port->rs485_config = mcf_config_rs485; port->ops = &mcf_uart_ops; } @@ -624,7 +597,7 @@ #define MCF_CONSOLE NULL /****************************************************************************/ -#endif /* CONFIG_MCF_CONSOLE */ +#endif /* CONFIG_SERIAL_MCF_CONSOLE */ /****************************************************************************/ /* @@ -644,7 +617,7 @@ static int mcf_probe(struct platform_device *pdev) { - struct mcf_platform_uart *platp = pdev->dev.platform_data; + struct mcf_platform_uart *platp = dev_get_platdata(&pdev->dev); struct uart_port *port; int i; @@ -656,11 +629,13 @@ port->mapbase = platp[i].mapbase; port->membase = (platp[i].membase) ? platp[i].membase : (unsigned char __iomem *) platp[i].mapbase; + port->dev = &pdev->dev; port->iotype = SERIAL_IO_MEM; port->irq = platp[i].irq; port->uartclk = MCF_BUSCLK; port->ops = &mcf_uart_ops; - port->flags = ASYNC_BOOT_AUTOCONF; + port->flags = UPF_BOOT_AUTOCONF; + port->rs485_config = mcf_config_rs485; uart_add_one_port(&mcf_driver, port); } @@ -691,7 +666,6 @@ .remove = mcf_remove, .driver = { .name = "mcfuart", - .owner = THIS_MODULE, }, }; @@ -727,7 +701,7 @@ module_init(mcf_init); module_exit(mcf_exit); -MODULE_AUTHOR("Greg Ungerer "); +MODULE_AUTHOR("Greg Ungerer "); MODULE_DESCRIPTION("Freescale ColdFire UART driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:mcfuart");