]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Merge 4.14-rc4 into tty-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Oct 2017 07:05:05 +0000 (09:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Oct 2017 07:05:05 +0000 (09:05 +0200)
We want the tty/serial fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
44 files changed:
Documentation/devicetree/bindings/dma/stm32-dma.txt
Documentation/devicetree/bindings/serial/atmel-usart.txt
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
Documentation/devicetree/bindings/serial/fsl-lpuart.txt
Documentation/devicetree/bindings/serial/omap_serial.txt
Documentation/devicetree/bindings/serial/st,stm32-usart.txt
arch/arm/boot/dts/stm32f429.dtsi
arch/arm/boot/dts/stm32f746.dtsi
arch/arm/boot/dts/stm32h743.dtsi
drivers/tty/mxser.c
drivers/tty/n_gsm.c
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/8250/8250_dw.c
drivers/tty/serial/8250/8250_fintek.c
drivers/tty/serial/8250/8250_mid.c
drivers/tty/serial/8250/8250_mtk.c
drivers/tty/serial/8250/8250_omap.c
drivers/tty/serial/8250/8250_pci.c
drivers/tty/serial/8250/8250_port.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/bfin_sport_uart.c
drivers/tty/serial/fsl_lpuart.c
drivers/tty/serial/ifx6x60.c
drivers/tty/serial/imx.c
drivers/tty/serial/jsm/jsm_tty.c
drivers/tty/serial/max3100.c
drivers/tty/serial/meson_uart.c
drivers/tty/serial/mux.c
drivers/tty/serial/omap-serial.c
drivers/tty/serial/pnx8xxx_uart.c
drivers/tty/serial/sa1100.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/sh-sci.c
drivers/tty/serial/sh-sci.h
drivers/tty/serial/sn_console.c
drivers/tty/serial/stm32-usart.c
drivers/tty/serial/xilinx_uartps.c
drivers/tty/synclink.c
drivers/tty/sysrq.c
drivers/tty/tty_port.c
drivers/tty/vcc.c
drivers/tty/vt/vt.c
include/linux/serial_core.h
include/uapi/linux/serial_reg.h

index 4408af693d0cc75298e66c3c56af8f7521d3eb23..6f44df94101cbc610ec037bacba6be8d0e2f3776 100644 (file)
@@ -71,7 +71,7 @@ channel: a phandle to the DMA controller plus the following four integer cells:
 Example:
 
        usart1: serial@40011000 {
-               compatible = "st,stm32-usart", "st,stm32-uart";
+               compatible = "st,stm32-uart";
                reg = <0x40011000 0x400>;
                interrupts = <37>;
                clocks = <&clk_pclk2>;
index e6e6142e33ac8187f71822ab33467bd1da9c155b..7c0d6b2f53e4c96ae8855746733cbbf1cbeaa11a 100644 (file)
@@ -24,6 +24,7 @@ Optional properties:
        - dma-names: "rx" for RX channel, "tx" for TX channel.
 - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
   capable USARTs.
+- rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt
 
 <chip> compatible description:
 - at91rm9200:  legacy USART support
index 574c3a2c77d5cd28570e1272488703f0852ec2eb..860a9559839a40dffc7ceb273424abe55df9926b 100644 (file)
@@ -9,6 +9,7 @@ Optional properties:
 - fsl,irda-mode : Indicate the uart supports irda mode
 - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works
                   in DCE mode by default.
+- rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt
 
 Please check Documentation/devicetree/bindings/serial/serial.txt
 for the complete list of generic properties.
index a1252a047f78d75e14fa41d4dabdbca96b35781d..59567b51cf098bfa963fee4283b63e01d226bb31 100644 (file)
@@ -16,6 +16,7 @@ Required properties:
 Optional properties:
 - dmas: A list of two dma specifiers, one for each entry in dma-names.
 - dma-names: should contain "tx" and "rx".
+- rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt
 
 Note: Optional properties for DMA support. Write them both or both not.
 
index 7a71b5de77d69b12f58a4d0d26b559fe7fa078fc..43eac675f21f5fd58cda23535facab5b82903957 100644 (file)
@@ -19,6 +19,7 @@ Optional properties:
 - dmas : DMA specifier, consisting of a phandle to the DMA controller
          node and a DMA channel number.
 - dma-names : "rx" for receive channel, "tx" for transmit channel.
+- rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt
 
 Example:
 
index 3657f9f9d17a98302e873c7c75bbd0ee312e13b0..d150b04a62291f788c0d6658f80382726038a5cf 100644 (file)
@@ -2,14 +2,10 @@
 
 Required properties:
 - compatible: can be either:
-  - "st,stm32-usart",
   - "st,stm32-uart",
-  - "st,stm32f7-usart",
   - "st,stm32f7-uart",
-  - "st,stm32h7-usart"
   - "st,stm32h7-uart".
-  depending on whether the device supports synchronous mode
-  and is compatible with stm32(f4), stm32f7 or stm32h7.
+  depending is compatible with stm32(f4), stm32f7 or stm32h7.
 - reg: The address and length of the peripheral registers space
 - interrupts:
   - The interrupt line for the USART instance,
@@ -33,7 +29,7 @@ usart4: serial@40004c00 {
 };
 
 usart2: serial@40004400 {
-       compatible = "st,stm32-usart", "st,stm32-uart";
+       compatible = "st,stm32-uart";
        reg = <0x40004400 0x400>;
        interrupts = <38>;
        clocks = <&clk_pclk1>;
@@ -43,7 +39,7 @@ usart2: serial@40004400 {
 };
 
 usart1: serial@40011000 {
-       compatible = "st,stm32-usart", "st,stm32-uart";
+       compatible = "st,stm32-uart";
        reg = <0x40011000 0x400>;
        interrupts = <37>;
        clocks = <&rcc 0 164>;
index 5b36eb114ddc953067904afbd08497b2286c3785..10099df8b73ef39621685efe017dfd08958ca4d1 100644 (file)
                };
 
                usart2: serial@40004400 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40004400 0x400>;
                        interrupts = <38>;
                        clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART2)>;
                };
 
                usart3: serial@40004800 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40004800 0x400>;
                        interrupts = <39>;
                        clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART3)>;
                };
 
                usart7: serial@40007800 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40007800 0x400>;
                        interrupts = <82>;
                        clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART7)>;
                };
 
                usart8: serial@40007c00 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40007c00 0x400>;
                        interrupts = <83>;
                        clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART8)>;
                };
 
                usart1: serial@40011000 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40011000 0x400>;
                        interrupts = <37>;
                        clocks = <&rcc 0 STM32F4_APB2_CLOCK(USART1)>;
                };
 
                usart6: serial@40011400 {
-                       compatible = "st,stm32-usart", "st,stm32-uart";
+                       compatible = "st,stm32-uart";
                        reg = <0x40011400 0x400>;
                        interrupts = <71>;
                        clocks = <&rcc 0 STM32F4_APB2_CLOCK(USART6)>;
index 5633860037d23397379b092a4cf5bba353abb367..5f941789405903f08db94c632c84279e0944ad39 100644 (file)
                };
 
                usart2: serial@40004400 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40004400 0x400>;
                        interrupts = <38>;
                        clocks = <&rcc 1 CLK_USART2>;
                };
 
                usart3: serial@40004800 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40004800 0x400>;
                        interrupts = <39>;
                        clocks = <&rcc 1 CLK_USART3>;
                };
 
                usart7: serial@40007800 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40007800 0x400>;
                        interrupts = <82>;
                        clocks = <&rcc 1 CLK_UART7>;
                };
 
                usart8: serial@40007c00 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40007c00 0x400>;
                        interrupts = <83>;
                        clocks = <&rcc 1 CLK_UART8>;
                };
 
                usart1: serial@40011000 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40011000 0x400>;
                        interrupts = <37>;
                        clocks = <&rcc 1 CLK_USART1>;
                };
 
                usart6: serial@40011400 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40011400 0x400>;
                        interrupts = <71>;
                        clocks = <&rcc 1 CLK_USART6>;
index 58ec2275181ef7c196087ba8ba2ac6d05da6524a..26de3157870110d22aa6c2508df4ba6ad7fbd871 100644 (file)
@@ -67,7 +67,7 @@
                };
 
                usart2: serial@40004400 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40004400 0x400>;
                        interrupts = <38>;
                        status = "disabled";
@@ -99,7 +99,7 @@
                };
 
                usart1: serial@40011000 {
-                       compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+                       compatible = "st,stm32f7-uart";
                        reg = <0x40011000 0x400>;
                        interrupts = <37>;
                        status = "disabled";
index 7dd38047ba2352d5dde2845170ecfc3e149ec27d..2497be8a2190bd64da085d40854148c4055d1be9 100644 (file)
@@ -642,8 +642,7 @@ static int mxser_set_baud(struct tty_struct *tty, long newspd)
  * This routine is called to set the UART divisor registers to match
  * the specified baud rate for a serial port.
  */
-static int mxser_change_speed(struct tty_struct *tty,
-                                       struct ktermios *old_termios)
+static int mxser_change_speed(struct tty_struct *tty)
 {
        struct mxser_port *info = tty->driver_data;
        unsigned cflag, cval, fcr;
@@ -945,7 +944,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
        /*
         * and set the speed of the serial port
         */
-       mxser_change_speed(tty, NULL);
+       mxser_change_speed(tty);
        spin_unlock_irqrestore(&info->slock, flags);
 
        return 0;
@@ -1288,7 +1287,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
        if (tty_port_initialized(port)) {
                if (flags != (port->flags & ASYNC_SPD_MASK)) {
                        spin_lock_irqsave(&info->slock, sl_flags);
-                       mxser_change_speed(tty, NULL);
+                       mxser_change_speed(tty);
                        spin_unlock_irqrestore(&info->slock, sl_flags);
                }
        } else {
@@ -1946,7 +1945,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
        unsigned long flags;
 
        spin_lock_irqsave(&info->slock, flags);
-       mxser_change_speed(tty, old_termios);
+       mxser_change_speed(tty);
        spin_unlock_irqrestore(&info->slock, flags);
 
        if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
@@ -2375,8 +2374,7 @@ static void mxser_release_ISA_res(struct mxser_board *brd)
        mxser_release_vector(brd);
 }
 
-static int mxser_initbrd(struct mxser_board *brd,
-               struct pci_dev *pdev)
+static int mxser_initbrd(struct mxser_board *brd)
 {
        struct mxser_port *info;
        unsigned int i;
@@ -2640,7 +2638,7 @@ static int mxser_probe(struct pci_dev *pdev,
        }
 
        /* mxser_initbrd will hook ISR. */
-       retval = mxser_initbrd(brd, pdev);
+       retval = mxser_initbrd(brd);
        if (retval)
                goto err_rel3;
 
@@ -2746,7 +2744,7 @@ static int __init mxser_module_init(void)
                                brd->info->name, ioaddr[b]);
 
                /* mxser_initbrd will hook ISR. */
-               if (mxser_initbrd(brd, NULL) < 0) {
+               if (mxser_initbrd(brd) < 0) {
                        mxser_release_ISA_res(brd);
                        brd->info = NULL;
                        continue;
index 0a3c9665e015492f7fbeae5c33e1900961b817c6..33530d8cb81d89c6e22e31c13b33fcffb74fdeb1 100644 (file)
@@ -1646,9 +1646,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
        }
 
        skb_queue_head_init(&dlci->skb_list);
-       init_timer(&dlci->t1);
-       dlci->t1.function = gsm_dlci_t1;
-       dlci->t1.data = (unsigned long)dlci;
+       setup_timer(&dlci->t1, gsm_dlci_t1, (unsigned long)dlci);
        tty_port_init(&dlci->port);
        dlci->port.ops = &gsm_port_ops;
        dlci->gsm = gsm;
index d29b512a7d9fac1b182d1f63a0a34d3c181fc46d..00d4b114f1bf3c945432a6a9faac7100229f49e3 100644 (file)
@@ -525,8 +525,7 @@ static void __init serial8250_isa_init_ports(void)
                        base_ops = port->ops;
                port->ops = &univ8250_port_ops;
 
-               init_timer(&up->timer);
-               up->timer.function = serial8250_timeout;
+               setup_timer(&up->timer, serial8250_timeout, 0UL);
 
                up->ops = &univ8250_driver_ops;
 
index 7e638997bfc2ca18b20ad3e97aec5656d4477755..10b0aca8ae19ac12042627bfb4b13fbede5089a5 100644 (file)
@@ -256,25 +256,31 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
                               struct ktermios *old)
 {
        unsigned int baud = tty_termios_baud_rate(termios);
+       unsigned int target_rate, min_rate, max_rate;
        struct dw8250_data *d = p->private_data;
        long rate;
-       int ret;
+       int i, ret;
 
        if (IS_ERR(d->clk) || !old)
                goto out;
 
-       clk_disable_unprepare(d->clk);
-       rate = clk_round_rate(d->clk, baud * 16);
-       if (rate < 0)
-               ret = rate;
-       else if (rate == 0)
-               ret = -ENOENT;
-       else
-               ret = clk_set_rate(d->clk, rate);
-       clk_prepare_enable(d->clk);
+       /* Find a clk rate within +/-1.6% of an integer multiple of baudx16 */
+       target_rate = baud * 16;
+       min_rate = target_rate - (target_rate >> 6);
+       max_rate = target_rate + (target_rate >> 6);
 
-       if (!ret)
-               p->uartclk = rate;
+       for (i = 1; i <= UART_DIV_MAX; i++) {
+               rate = clk_round_rate(d->clk, i * target_rate);
+               if (rate >= i * min_rate && rate <= i * max_rate)
+                       break;
+       }
+       if (i <= UART_DIV_MAX) {
+               clk_disable_unprepare(d->clk);
+               ret = clk_set_rate(d->clk, rate);
+               clk_prepare_enable(d->clk);
+               if (!ret)
+                       p->uartclk = rate;
+       }
 
 out:
        p->status &= ~UPSTAT_AUTOCTS;
index e500f7dd2470a28254b1d8d57374a4fbd0fc02fa..96cc45f25ee90dbd952dabc36f3d35a4e11cdd22 100644 (file)
 #define IRQ_LEVEL_LOW  0
 #define IRQ_EDGE_HIGH  BIT(5)
 
+/*
+ * F81216H clock source register, the value and mask is the same with F81866,
+ * but it's on F0h.
+ *
+ * Clock speeds for UART (register F0h)
+ * 00: 1.8432MHz.
+ * 01: 18.432MHz.
+ * 10: 24MHz.
+ * 11: 14.769MHz.
+ */
 #define RS485  0xF0
 #define RTS_INVERT BIT(5)
 #define RS485_URA BIT(4)
@@ -280,13 +290,84 @@ static void fintek_8250_goto_highspeed(struct uart_8250_port *uart,
                        F81866_UART_CLK_MASK,
                        F81866_UART_CLK_14_769MHZ);
 
-                       uart->port.uartclk = 921600 * 16;
+               uart->port.uartclk = 921600 * 16;
                break;
        default: /* leave clock speed untouched */
                break;
        }
 }
 
+void fintek_8250_set_termios(struct uart_port *port, struct ktermios *termios,
+                       struct ktermios *old)
+{
+       struct fintek_8250 *pdata = port->private_data;
+       unsigned int baud = tty_termios_baud_rate(termios);
+       int i;
+       u8 reg;
+       static u32 baudrate_table[] = {115200, 921600, 1152000, 1500000};
+       static u8 clock_table[] = { F81866_UART_CLK_1_8432MHZ,
+                       F81866_UART_CLK_14_769MHZ, F81866_UART_CLK_18_432MHZ,
+                       F81866_UART_CLK_24MHZ };
+
+       switch (pdata->pid) {
+       case CHIP_ID_F81216H:
+               reg = RS485;
+               break;
+       case CHIP_ID_F81866:
+               reg = F81866_UART_CLK;
+               break;
+       default:
+               /* Don't change clocksource with unknown PID */
+               dev_warn(port->dev,
+                       "%s: pid: %x Not support. use default set_termios.\n",
+                       __func__, pdata->pid);
+               serial8250_do_set_termios(port, termios, old);
+               return;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(baudrate_table); ++i) {
+               if (baud > baudrate_table[i] || baudrate_table[i] % baud != 0)
+                       continue;
+
+               if (port->uartclk == baudrate_table[i] * 16)
+                       break;
+
+               if (fintek_8250_enter_key(pdata->base_port, pdata->key))
+                       continue;
+
+               port->uartclk = baudrate_table[i] * 16;
+
+               sio_write_reg(pdata, LDN, pdata->index);
+               sio_write_mask_reg(pdata, reg, F81866_UART_CLK_MASK,
+                               clock_table[i]);
+
+               fintek_8250_exit_key(pdata->base_port);
+               break;
+       }
+
+       if (i == ARRAY_SIZE(baudrate_table)) {
+               baud = tty_termios_baud_rate(old);
+               tty_termios_encode_baud_rate(termios, baud, baud);
+       }
+
+       serial8250_do_set_termios(port, termios, old);
+}
+
+static void fintek_8250_set_termios_handler(struct uart_8250_port *uart)
+{
+       struct fintek_8250 *pdata = uart->port.private_data;
+
+       switch (pdata->pid) {
+       case CHIP_ID_F81216H:
+       case CHIP_ID_F81866:
+               uart->port.set_termios = fintek_8250_set_termios;
+               break;
+
+       default:
+               break;
+       }
+}
+
 static int probe_setup_port(struct fintek_8250 *pdata,
                                        struct uart_8250_port *uart)
 {
@@ -373,6 +454,7 @@ int fintek_8250_probe(struct uart_8250_port *uart)
        memcpy(pdata, &probe_data, sizeof(probe_data));
        uart->port.private_data = pdata;
        fintek_8250_set_rs485_handler(uart);
+       fintek_8250_set_termios_handler(uart);
 
        return 0;
 }
index ec957cce8c9a72662d838edf3b915e50b4524da4..b8f0b7f70d5a4eeed061b150eebfee39ec540607 100644 (file)
 #define PCI_DEVICE_ID_INTEL_PNW_UART2  0x081c
 #define PCI_DEVICE_ID_INTEL_PNW_UART3  0x081d
 #define PCI_DEVICE_ID_INTEL_TNG_UART   0x1191
+#define PCI_DEVICE_ID_INTEL_CDF_UART   0x18d8
 #define PCI_DEVICE_ID_INTEL_DNV_UART   0x19d8
 
 /* Intel MID Specific registers */
-#define INTEL_MID_UART_DNV_FISR                0x08
+#define INTEL_MID_UART_FISR            0x08
 #define INTEL_MID_UART_PS              0x30
 #define INTEL_MID_UART_MUL             0x34
 #define INTEL_MID_UART_DIV             0x38
@@ -130,7 +131,7 @@ static int dnv_handle_irq(struct uart_port *p)
 {
        struct mid8250 *mid = p->private_data;
        struct uart_8250_port *up = up_to_u8250p(p);
-       unsigned int fisr = serial_port_in(p, INTEL_MID_UART_DNV_FISR);
+       unsigned int fisr = serial_port_in(p, INTEL_MID_UART_FISR);
        u32 status;
        int ret = 0;
        int err;
@@ -377,6 +378,7 @@ static const struct pci_device_id pci_ids[] = {
        MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART2, pnw_board),
        MID_DEVICE(PCI_DEVICE_ID_INTEL_PNW_UART3, pnw_board),
        MID_DEVICE(PCI_DEVICE_ID_INTEL_TNG_UART, tng_board),
+       MID_DEVICE(PCI_DEVICE_ID_INTEL_CDF_UART, dnv_board),
        MID_DEVICE(PCI_DEVICE_ID_INTEL_DNV_UART, dnv_board),
        { },
 };
index fb45770d47aa2adb4166c5b58564e1cad3718acc..fef9823d7b4c6548b3379ee37a4af34880d926cc 100644 (file)
@@ -61,7 +61,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
         * registers to their default values.
         */
        baud = uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk);
 
        if (baud <= 115200) {
index 833771bca0a593008967905d259c6780cb512cae..4938d338e01fce724cb81c1d1906b1a696808f03 100644 (file)
@@ -199,7 +199,7 @@ static void omap_8250_get_divisor(struct uart_port *port, unsigned int baud,
         * Old custom speed handling.
         */
        if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) {
-               priv->quot = port->custom_divisor & 0xffff;
+               priv->quot = port->custom_divisor & UART_DIV_MAX;
                /*
                 * I assume that nobody is using this. But hey, if somebody
                 * would like to specify the divisor _and_ the mode then the
@@ -358,7 +358,7 @@ static void omap_8250_set_termios(struct uart_port *port,
         * Ask the core to calculate the divisor for us.
         */
        baud = uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk / 13);
        omap_8250_get_divisor(port, baud, priv);
 
index 0c101a7470b0eedb6306f3bca609b097ecac7b27..a6bf59d8b1d65cc353357cdb0d4a3f27a0467dc3 100644 (file)
@@ -3368,6 +3368,7 @@ static const struct pci_device_id blacklist[] = {
        { PCI_VDEVICE(INTEL, 0x081c), },
        { PCI_VDEVICE(INTEL, 0x081d), },
        { PCI_VDEVICE(INTEL, 0x1191), },
+       { PCI_VDEVICE(INTEL, 0x18d8), },
        { PCI_VDEVICE(INTEL, 0x19d8), },
 
        /* Intel platforms with DesignWare UART */
index f0cc04f62b676870551e757b8f006b3e3ff4fa4a..01ab2188a151d713a30e912212cd524b06808e0e 100644 (file)
@@ -2601,7 +2601,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
         * causing transmission errors.
         */
        return uart_get_baud_rate(port, termios, old,
-                                 port->uartclk / 16 / 0xffff,
+                                 port->uartclk / 16 / UART_DIV_MAX,
                                  port->uartclk);
 }
 
index 7551cab438ff848d767b60295cad3efc3ce353cf..82d9c8eae04f74049e31f6ad66daebea57d12438 100644 (file)
@@ -171,6 +171,7 @@ struct atmel_uart_port {
        bool                    has_hw_timer;
        struct timer_list       uart_timer;
 
+       bool                    tx_stopped;
        bool                    suspended;
        unsigned int            pending;
        unsigned int            pending_status;
@@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,
  */
 static u_int atmel_tx_empty(struct uart_port *port)
 {
+       struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+       if (atmel_port->tx_stopped)
+               return TIOCSER_TEMT;
        return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
                TIOCSER_TEMT :
                0;
@@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)
         * is fully transmitted.
         */
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
+       atmel_port->tx_stopped = true;
 
        /* Disable interrupts */
        atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
@@ -521,6 +527,7 @@ static void atmel_start_tx(struct uart_port *port)
 
        /* re-enable the transmitter */
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+       atmel_port->tx_stopped = false;
 }
 
 /*
@@ -1667,29 +1674,6 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port,
        }
 }
 
-static void atmel_init_rs485(struct uart_port *port,
-                               struct platform_device *pdev)
-{
-       struct device_node *np = pdev->dev.of_node;
-
-       struct serial_rs485 *rs485conf = &port->rs485;
-       u32 rs485_delay[2];
-
-       /* rs485 properties */
-       if (of_property_read_u32_array(np, "rs485-rts-delay",
-                                      rs485_delay, 2) == 0) {
-               rs485conf->delay_rts_before_send = rs485_delay[0];
-               rs485conf->delay_rts_after_send = rs485_delay[1];
-               rs485conf->flags = 0;
-       }
-
-       if (of_get_property(np, "rs485-rx-during-tx", NULL))
-               rs485conf->flags |= SER_RS485_RX_DURING_TX;
-
-       if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL))
-               rs485conf->flags |= SER_RS485_ENABLED;
-}
-
 static void atmel_set_ops(struct uart_port *port)
 {
        struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
@@ -1866,6 +1850,7 @@ static int atmel_startup(struct uart_port *port)
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
        /* enable xmit & rcvr */
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+       atmel_port->tx_stopped = false;
 
        setup_timer(&atmel_port->uart_timer,
                        atmel_uart_timer_callback,
@@ -2122,6 +2107,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 
        /* disable receiver and transmitter */
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
+       atmel_port->tx_stopped = true;
 
        /* mode */
        if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -2207,6 +2193,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
        atmel_uart_writel(port, ATMEL_US_BRGR, quot);
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+       atmel_port->tx_stopped = false;
 
        /* restore interrupts */
        atmel_uart_writel(port, ATMEL_US_IER, imr);
@@ -2373,7 +2360,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
        atmel_init_property(atmel_port, pdev);
        atmel_set_ops(port);
 
-       atmel_init_rs485(port, pdev);
+       of_get_rs485_mode(pdev->dev.of_node, &port->rs485);
 
        port->iotype            = UPIO_MEM;
        port->flags             = UPF_BOOT_AUTOCONF | UPF_IOREMAP;
@@ -2450,6 +2437,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
 
        /* Make sure that tx path is actually able to send characters */
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+       atmel_port->tx_stopped = false;
 
        uart_console_write(port, s, count, atmel_console_putchar);
 
@@ -2511,6 +2499,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
 {
        int ret;
        struct uart_port *port = &atmel_ports[co->index].uart;
+       struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
        int baud = 115200;
        int bits = 8;
        int parity = 'n';
@@ -2528,6 +2517,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
        atmel_uart_writel(port, ATMEL_US_IDR, -1);
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
        atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+       atmel_port->tx_stopped = false;
 
        if (options)
                uart_parse_options(options, &baud, &parity, &bits, &flow);
index 6b03fb12cd197529992a6978178a45894c518acb..6525378a75b632890f2805aabadc76331dfd38b8 100644 (file)
@@ -584,7 +584,7 @@ static void sport_set_termios(struct uart_port *port,
        spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
-struct uart_ops sport_uart_ops = {
+static const struct uart_ops sport_uart_ops = {
        .tx_empty       = sport_tx_empty,
        .set_mctrl      = sport_set_mctrl,
        .get_mctrl      = sport_get_mctrl,
index f0252184291ed4a3ab49ab03ce634e7be8588bf4..73d6a7c3874e6fe54d0581319cf3169b8647e6ab 100644 (file)
@@ -1632,12 +1632,11 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
 {
        struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
        unsigned long flags;
-       unsigned long ctrl, old_ctrl, bd, modem;
+       unsigned long ctrl, old_ctrl, modem;
        unsigned int  baud;
        unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
 
        ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL);
-       bd = lpuart32_read(&sport->port, UARTBAUD);
        modem = lpuart32_read(&sport->port, UARTMODIR);
        /*
         * only support CS8 and CS7, and for CS7 must enable PE.
@@ -2212,6 +2211,24 @@ static int lpuart_probe(struct platform_device *pdev)
        if (ret)
                goto failed_attach_port;
 
+       of_get_rs485_mode(np, &sport->port.rs485);
+
+       if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) {
+               dev_err(&pdev->dev, "driver doesn't support RX during TX\n");
+               return -ENOSYS;
+       }
+
+       if (sport->port.rs485.delay_rts_before_send ||
+           sport->port.rs485.delay_rts_after_send) {
+               dev_err(&pdev->dev, "driver doesn't support RTS delays\n");
+               return -ENOSYS;
+       }
+
+       if (sport->port.rs485.flags & SER_RS485_ENABLED) {
+               sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
+               writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
+       }
+
        sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx");
        if (!sport->dma_tx_chan)
                dev_info(sport->port.dev, "DMA tx channel request failed, "
@@ -2222,12 +2239,6 @@ static int lpuart_probe(struct platform_device *pdev)
                dev_info(sport->port.dev, "DMA rx channel request failed, "
                                "operating without rx DMA\n");
 
-       if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
-               sport->port.rs485.flags |= SER_RS485_ENABLED;
-               sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
-               writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
-       }
-
        return 0;
 
 failed_attach_port:
index f190a84a02465668d64f3b6a57d6462588d781ad..596b738ec122b91ead9afb23bf61aa979c5e15d5 100644 (file)
@@ -1029,9 +1029,8 @@ static int ifx_spi_spi_probe(struct spi_device *spi)
        spin_lock_init(&ifx_dev->write_lock);
        spin_lock_init(&ifx_dev->power_lock);
        ifx_dev->power_status = 0;
-       init_timer(&ifx_dev->spi_timer);
-       ifx_dev->spi_timer.function = ifx_spi_timeout;
-       ifx_dev->spi_timer.data = (unsigned long)ifx_dev;
+       setup_timer(&ifx_dev->spi_timer, ifx_spi_timeout,
+                   (unsigned long)ifx_dev);
        ifx_dev->modem = pl_data->modem_type;
        ifx_dev->use_dma = pl_data->use_dma;
        ifx_dev->max_hz = pl_data->max_hz;
index dfeff3951f934627f8ed45e892ee5d30cec3216b..b697c1eefa74915a8508f46a1b4e99ee79bb12ff 100644 (file)
@@ -334,7 +334,8 @@ static void imx_port_rts_active(struct imx_port *sport, unsigned long *ucr2)
 {
        *ucr2 &= ~(UCR2_CTSC | UCR2_CTS);
 
-       mctrl_gpio_set(sport->gpios, sport->port.mctrl | TIOCM_RTS);
+       sport->port.mctrl |= TIOCM_RTS;
+       mctrl_gpio_set(sport->gpios, sport->port.mctrl);
 }
 
 static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
@@ -342,7 +343,8 @@ static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2)
        *ucr2 &= ~UCR2_CTSC;
        *ucr2 |= UCR2_CTS;
 
-       mctrl_gpio_set(sport->gpios, sport->port.mctrl & ~TIOCM_RTS);
+       sport->port.mctrl &= ~TIOCM_RTS;
+       mctrl_gpio_set(sport->gpios, sport->port.mctrl);
 }
 
 static void imx_port_rts_auto(struct imx_port *sport, unsigned long *ucr2)
@@ -714,8 +716,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
 {
        unsigned long temp;
 
-       sport->dma_is_rxing = 1;
-
        /* disable the receiver ready and aging timer interrupts */
        temp = readl(sport->port.membase + UCR1);
        temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1074,7 @@ static int start_rx_dma(struct imx_port *sport)
        desc->callback_param = sport;
 
        dev_dbg(dev, "RX: prepare for the DMA.\n");
+       sport->dma_is_rxing = 1;
        sport->rx_cookie = dmaengine_submit(desc);
        dma_async_issue_pending(chan);
        return 0;
@@ -1165,7 +1166,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
                goto err;
        }
 
-       sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+       sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
        if (!sport->rx_buf) {
                ret = -ENOMEM;
                goto err;
@@ -1411,7 +1412,7 @@ static void imx_flush_buffer(struct uart_port *port)
                temp = readl(sport->port.membase + UCR1);
                temp &= ~UCR1_TDMAEN;
                writel(temp, sport->port.membase + UCR1);
-               sport->dma_is_txing = false;
+               sport->dma_is_txing = 0;
        }
 
        /*
@@ -2051,6 +2052,8 @@ static int serial_imx_probe_dt(struct imx_port *sport,
        if (of_get_property(np, "rts-gpios", NULL))
                sport->have_rtsgpio = 1;
 
+       of_get_rs485_mode(np, &sport->port.rs485);
+
        return 0;
 }
 #else
@@ -2112,12 +2115,9 @@ static int serial_imx_probe(struct platform_device *pdev)
        sport->port.fifosize = 32;
        sport->port.ops = &imx_pops;
        sport->port.rs485_config = imx_rs485_config;
-       sport->port.rs485.flags =
-               SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX;
+       sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
        sport->port.flags = UPF_BOOT_AUTOCONF;
-       init_timer(&sport->timer);
-       sport->timer.function = imx_timeout;
-       sport->timer.data     = (unsigned long)sport;
+       setup_timer(&sport->timer, imx_timeout, (unsigned long)sport);
 
        sport->gpios = mctrl_gpio_init(&sport->port, 0);
        if (IS_ERR(sport->gpios))
index ec7d8383900fc742b9bc889c964809eb005ca2b3..e69227cc3827c66b3137c6c1ef75cdbb29975401 100644 (file)
@@ -474,7 +474,7 @@ int jsm_uart_port_init(struct jsm_board *brd)
                        set_bit(line, linemap);
                brd->channels[i]->uart_port.line = line;
                rc = uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port);
-               if (rc){
+               if (rc) {
                        printk(KERN_INFO "jsm: Port %d failed. Aborting...\n", i);
                        return rc;
                }
index ace82645b1237928d5b87bd118f5c10852566265..b6b3453e8c1f0a0345a8f37a0746ca3c0bb8d623 100644 (file)
@@ -787,9 +787,8 @@ static int max3100_probe(struct spi_device *spi)
                max3100s[i]->poll_time = 1;
        max3100s[i]->max3100_hw_suspend = pdata->max3100_hw_suspend;
        max3100s[i]->minor = i;
-       init_timer(&max3100s[i]->timer);
-       max3100s[i]->timer.function = max3100_timeout;
-       max3100s[i]->timer.data = (unsigned long) max3100s[i];
+       setup_timer(&max3100s[i]->timer, max3100_timeout,
+                   (unsigned long)max3100s[i]);
 
        dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i);
        max3100s[i]->port.irq = max3100s[i]->irq;
index 07c0f98be3acedcd77183f0e1a6c9207db429ee0..95d242a7dae1de960b3d7691a47dfa3cf7f3cf65 100644 (file)
  *
  */
 
+#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -183,12 +187,12 @@ static void meson_receive_chars(struct uart_port *port)
 {
        struct tty_port *tport = &port->state->port;
        char flag;
-       u32 status, ch, mode;
+       u32 ostatus, status, ch, mode;
 
        do {
                flag = TTY_NORMAL;
                port->icount.rx++;
-               status = readl(port->membase + AML_UART_STATUS);
+               ostatus = status = readl(port->membase + AML_UART_STATUS);
 
                if (status & AML_UART_ERR) {
                        if (status & AML_UART_TX_FIFO_WERR)
@@ -216,6 +220,16 @@ static void meson_receive_chars(struct uart_port *port)
                ch = readl(port->membase + AML_UART_RFIFO);
                ch &= 0xff;
 
+               if ((ostatus & AML_UART_FRAME_ERR) && (ch == 0)) {
+                       port->icount.brk++;
+                       flag = TTY_BREAK;
+                       if (uart_handle_break(port))
+                               continue;
+               }
+
+               if (uart_handle_sysrq_char(port, ch))
+                       continue;
+
                if ((status & port->ignore_status_mask) == 0)
                        tty_insert_flip_char(tport, ch, flag);
 
index 2bff69e70e4bcc65b6e7dc4433079959c401772d..a78983734825945957102570dc394c4bf5a2313e 100644 (file)
@@ -576,8 +576,7 @@ static int __init mux_init(void)
 
        if(port_cnt > 0) {
                /* Start the Mux timer */
-               init_timer(&mux_timer);
-               mux_timer.function = mux_poll;
+               setup_timer(&mux_timer, mux_poll, 0UL);
                mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
 
 #ifdef CONFIG_SERIAL_MUX_CONSOLE
index 7754053deedac9064316dd74c290f29ec154f597..580f56754699acdf53d9ed38deb01876c25490dc 100644 (file)
@@ -1606,7 +1606,6 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up,
                                   struct device_node *np)
 {
        struct serial_rs485 *rs485conf = &up->port.rs485;
-       u32 rs485_delay[2];
        enum of_gpio_flags flags;
        int ret;
 
@@ -1637,17 +1636,7 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up,
                up->rts_gpio = -EINVAL;
        }
 
-       if (of_property_read_u32_array(np, "rs485-rts-delay",
-                                   rs485_delay, 2) == 0) {
-               rs485conf->delay_rts_before_send = rs485_delay[0];
-               rs485conf->delay_rts_after_send = rs485_delay[1];
-       }
-
-       if (of_property_read_bool(np, "rs485-rx-during-tx"))
-               rs485conf->flags |= SER_RS485_RX_DURING_TX;
-
-       if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
-               rs485conf->flags |= SER_RS485_ENABLED;
+       of_get_rs485_mode(np, rs485conf);
 
        return 0;
 }
index dab2668d3879ed4fa73de8bc860ab09bdbb1019c..a05508a3e1a7d6ca4685db2a0427587de36e076e 100644 (file)
@@ -666,9 +666,8 @@ static void __init pnx8xxx_init_ports(void)
        first = 0;
 
        for (i = 0; i < NR_PORTS; i++) {
-               init_timer(&pnx8xxx_ports[i].timer);
-               pnx8xxx_ports[i].timer.function = pnx8xxx_timeout;
-               pnx8xxx_ports[i].timer.data     = (unsigned long)&pnx8xxx_ports[i];
+               setup_timer(&pnx8xxx_ports[i].timer, pnx8xxx_timeout,
+                           (unsigned long)&pnx8xxx_ports[i]);
                pnx8xxx_ports[i].port.ops = &pnx8xxx_pops;
        }
 }
index fd3d1329d48c38a63929a02b020d82b3f916b889..75bd1e058b8763555d49b3a940214413bd2d1516 100644 (file)
@@ -640,9 +640,8 @@ static void __init sa1100_init_ports(void)
                sa1100_ports[i].port.fifosize  = 8;
                sa1100_ports[i].port.line      = i;
                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];
+               setup_timer(&sa1100_ports[i].timer, sa1100_timeout,
+                           (unsigned long)&sa1100_ports[i]);
        }
 
        /*
index 3a14cccbd7fffd6428d0a833afabe3045d017d09..f4e6c866298794be94596659562a33fd952ac14c 100644 (file)
@@ -3026,5 +3026,41 @@ EXPORT_SYMBOL(uart_resume_port);
 EXPORT_SYMBOL(uart_add_one_port);
 EXPORT_SYMBOL(uart_remove_one_port);
 
+/**
+ * of_get_rs485_mode() - Implement parsing rs485 properties
+ * @np: uart node
+ * @rs485conf: output parameter
+ *
+ * This function implements the device tree binding described in
+ * Documentation/devicetree/bindings/serial/rs485.txt.
+ */
+void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf)
+{
+       u32 rs485_delay[2];
+       int ret;
+
+       ret = of_property_read_u32_array(np, "rs485-rts-delay", rs485_delay, 2);
+       if (!ret) {
+               rs485conf->delay_rts_before_send = rs485_delay[0];
+               rs485conf->delay_rts_after_send = rs485_delay[1];
+       } else {
+               rs485conf->delay_rts_before_send = 0;
+               rs485conf->delay_rts_after_send = 0;
+       }
+
+       /*
+        * clear full-duplex and enabled flags to get to a defined state with
+        * the two following properties.
+        */
+       rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED);
+
+       if (of_property_read_bool(np, "rs485-rx-during-tx"))
+               rs485conf->flags |= SER_RS485_RX_DURING_TX;
+
+       if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
+               rs485conf->flags |= SER_RS485_ENABLED;
+}
+EXPORT_SYMBOL_GPL(of_get_rs485_mode);
+
 MODULE_DESCRIPTION("Serial driver core");
 MODULE_LICENSE("GPL");
index 784dd42002eadbeb98bb15c23c776ffa10b483ef..9fde3df1b3a835c4192695880383fbcbf874e62d 100644 (file)
@@ -152,6 +152,7 @@ struct sci_port {
        int                             rx_trigger;
        struct timer_list               rx_fifo_timer;
        int                             rx_fifo_timeout;
+       u16                             hscif_tot;
 
        bool has_rtscts;
        bool autorts;
@@ -1107,8 +1108,14 @@ static ssize_t rx_fifo_timeout_show(struct device *dev,
 {
        struct uart_port *port = dev_get_drvdata(dev);
        struct sci_port *sci = to_sci_port(port);
+       int v;
 
-       return sprintf(buf, "%d\n", sci->rx_fifo_timeout);
+       if (port->type == PORT_HSCIF)
+               v = sci->hscif_tot >> HSSCR_TOT_SHIFT;
+       else
+               v = sci->rx_fifo_timeout;
+
+       return sprintf(buf, "%d\n", v);
 }
 
 static ssize_t rx_fifo_timeout_store(struct device *dev,
@@ -1124,11 +1131,19 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
        ret = kstrtol(buf, 0, &r);
        if (ret)
                return ret;
-       sci->rx_fifo_timeout = r;
-       scif_set_rtrg(port, 1);
-       if (r > 0)
-               setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn,
-                           (unsigned long)sci);
+
+       if (port->type == PORT_HSCIF) {
+               if (r < 0 || r > 3)
+                       return -EINVAL;
+               sci->hscif_tot = r << HSSCR_TOT_SHIFT;
+       } else {
+               sci->rx_fifo_timeout = r;
+               scif_set_rtrg(port, 1);
+               if (r > 0)
+                       setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn,
+                                   (unsigned long)sci);
+       }
+
        return count;
 }
 
@@ -1491,6 +1506,14 @@ static void sci_request_dma(struct uart_port *port)
                return;
 
        s->cookie_tx = -EINVAL;
+
+       /*
+        * Don't request a dma channel if no channel was specified
+        * in the device tree.
+        */
+       if (!of_find_property(port->dev->of_node, "dmas", NULL))
+               return;
+
        chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV);
        dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan);
        if (chan) {
@@ -2037,9 +2060,13 @@ static void sci_shutdown(struct uart_port *port)
        spin_lock_irqsave(&port->lock, flags);
        sci_stop_rx(port);
        sci_stop_tx(port);
-       /* Stop RX and TX, disable related interrupts, keep clock source */
+       /*
+        * Stop RX and TX, disable related interrupts, keep clock source
+        * and HSCIF TOT bits
+        */
        scr = serial_port_in(port, SCSCR);
-       serial_port_out(port, SCSCR, scr & (SCSCR_CKE1 | SCSCR_CKE0));
+       serial_port_out(port, SCSCR, scr &
+                       (SCSCR_CKE1 | SCSCR_CKE0 | s->hscif_tot));
        spin_unlock_irqrestore(&port->lock, flags);
 
 #ifdef CONFIG_SERIAL_SH_SCI_DMA
@@ -2186,7 +2213,7 @@ static void sci_reset(struct uart_port *port)
        unsigned int status;
        struct sci_port *s = to_sci_port(port);
 
-       serial_port_out(port, SCSCR, 0x00);     /* TE=0, RE=0, CKE1=0 */
+       serial_port_out(port, SCSCR, s->hscif_tot);     /* TE=0, RE=0, CKE1=0 */
 
        reg = sci_getreg(port, SCFCR);
        if (reg->size)
@@ -2356,7 +2383,7 @@ done:
                dev_dbg(port->dev,
                         "SCR 0x%x SMR 0x%x BRR %u CKS 0x%x DL %u SRR %u\n",
                         scr_val, smr_val, brr, sccks, dl, srr);
-               serial_port_out(port, SCSCR, scr_val);
+               serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
                serial_port_out(port, SCSMR, smr_val);
                serial_port_out(port, SCBRR, brr);
                if (sci_getreg(port, HSSRR)->size)
@@ -2370,7 +2397,7 @@ done:
                smr_val |= serial_port_in(port, SCSMR) &
                           (SCSMR_CKEDG | SCSMR_SRC_MASK | SCSMR_CKS);
                dev_dbg(port->dev, "SCR 0x%x SMR 0x%x\n", scr_val, smr_val);
-               serial_port_out(port, SCSCR, scr_val);
+               serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
                serial_port_out(port, SCSMR, smr_val);
        }
 
@@ -2407,7 +2434,7 @@ done:
        scr_val |= SCSCR_RE | SCSCR_TE |
                   (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
        dev_dbg(port->dev, "SCSCR 0x%x\n", scr_val);
-       serial_port_out(port, SCSCR, scr_val);
+       serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
        if ((srr + 1 == 5) &&
            (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) {
                /*
@@ -2773,6 +2800,7 @@ static int sci_init_single(struct platform_device *dev,
        }
 
        sci_port->rx_fifo_timeout = 0;
+       sci_port->hscif_tot = 0;
 
        /* SCIFA on sh7723 and sh7724 need a custom sampling rate that doesn't
         * match the SoC datasheet, this should be investigated. Let platform
@@ -2860,7 +2888,7 @@ static void serial_console_write(struct console *co, const char *s,
        ctrl_temp = SCSCR_RE | SCSCR_TE |
                    (sci_port->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)) |
                    (ctrl & (SCSCR_CKE1 | SCSCR_CKE0));
-       serial_port_out(port, SCSCR, ctrl_temp);
+       serial_port_out(port, SCSCR, ctrl_temp | sci_port->hscif_tot);
 
        uart_console_write(port, s, count, serial_console_putchar);
 
@@ -2988,7 +3016,8 @@ static int sci_remove(struct platform_device *dev)
                sysfs_remove_file(&dev->dev.kobj,
                                  &dev_attr_rx_fifo_trigger.attr);
        }
-       if (port->port.type == PORT_SCIFA || port->port.type == PORT_SCIFB) {
+       if (port->port.type == PORT_SCIFA || port->port.type == PORT_SCIFB ||
+           port->port.type == PORT_HSCIF) {
                sysfs_remove_file(&dev->dev.kobj,
                                  &dev_attr_rx_fifo_timeout.attr);
        }
@@ -3173,7 +3202,8 @@ static int sci_probe(struct platform_device *dev)
                if (ret)
                        return ret;
        }
-       if (sp->port.type == PORT_SCIFA || sp->port.type ==  PORT_SCIFB) {
+       if (sp->port.type == PORT_SCIFA || sp->port.type == PORT_SCIFB ||
+           sp->port.type == PORT_HSCIF) {
                ret = sysfs_create_file(&dev->dev.kobj,
                                &dev_attr_rx_fifo_timeout.attr);
                if (ret) {
index 971b2ab088d847af9d3d2b4e4c0c2dd820eee653..2b708cc0e66ce42dbfdf8e0c9e7f4ec64a729730 100644 (file)
@@ -62,6 +62,9 @@ enum {
 #define SCSCR_TDRQE    BIT(15) /* Tx Data Transfer Request Enable */
 #define SCSCR_RDRQE    BIT(14) /* Rx Data Transfer Request Enable */
 
+/* Serial Control Register, HSCIF-only bits */
+#define HSSCR_TOT_SHIFT        14
+
 /* SCxSR (Serial Status Register) on SCI */
 #define SCI_TDRE       BIT(7)  /* Transmit Data Register Empty */
 #define SCI_RDRF       BIT(6)  /* Receive Data Register Full */
index 9e0e6586c6987e3d22fdc73c9694858bfa1e5e77..81d506d28469097151d1197879b3a4b06f9343e2 100644 (file)
@@ -687,9 +687,7 @@ static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
         * timer to poll for input and push data from the console
         * buffer.
         */
-       init_timer(&port->sc_timer);
-       port->sc_timer.function = sn_sal_timer_poll;
-       port->sc_timer.data = (unsigned long)port;
+       setup_timer(&port->sc_timer, sn_sal_timer_poll, (unsigned long)port);
 
        if (IS_RUNNING_ON_SIMULATOR())
                port->sc_interrupt_timeout = 6;
index 03a583264d9ec78eec786930c7783b1047c82596..46a1f8617314ede0b7206ba364dbdcda3c3d209a 100644 (file)
@@ -736,11 +736,8 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id stm32_match[] = {
-       { .compatible = "st,stm32-usart", .data = &stm32f4_info},
        { .compatible = "st,stm32-uart", .data = &stm32f4_info},
-       { .compatible = "st,stm32f7-usart", .data = &stm32f7_info},
        { .compatible = "st,stm32f7-uart", .data = &stm32f7_info},
-       { .compatible = "st,stm32h7-usart", .data = &stm32h7_info},
        { .compatible = "st,stm32h7-uart", .data = &stm32h7_info},
        {},
 };
index 31a630ae0870efec120ec63cdb15464dc947682a..7c1c6fb96ea0f92ed9816c595d9cd43784b386d4 100644 (file)
@@ -1673,7 +1673,7 @@ static void __exit cdns_uart_exit(void)
        uart_unregister_driver(&cdns_uart_uart_driver);
 }
 
-module_init(cdns_uart_init);
+arch_initcall(cdns_uart_init);
 module_exit(cdns_uart_exit);
 
 MODULE_DESCRIPTION("Driver for Cadence UART");
index 3be9811012979cdcab809adbde204d74f9a8c472..27db7818b673dd7be39624afe8781c3edebc3d27 100644 (file)
@@ -4098,8 +4098,7 @@ static int mgsl_claim_resources(struct mgsl_struct *info)
                if (request_dma(info->dma_level,info->device_name) < 0){
                        printk( "%s(%d):Can't request DMA channel on device %s DMA=%d\n",
                                __FILE__,__LINE__,info->device_name, info->dma_level );
-                       mgsl_release_resources( info );
-                       return -ENODEV;
+                       goto errout;
                }
                info->dma_requested = true;
 
index 3ffc1ce29023b5f6476d0006aa94b8b1b858c480..6ed8c47312a8ccd93ded8277a9d12541f0f5a0c5 100644 (file)
@@ -245,8 +245,10 @@ static void sysrq_handle_showallcpus(int key)
         * architecture has no support for it:
         */
        if (!trigger_all_cpu_backtrace()) {
-               struct pt_regs *regs = get_irq_regs();
+               struct pt_regs *regs = NULL;
 
+               if (in_irq())
+                       regs = get_irq_regs();
                if (regs) {
                        pr_info("CPU%d:\n", smp_processor_id());
                        show_regs(regs);
@@ -265,7 +267,10 @@ static struct sysrq_key_op sysrq_showallcpus_op = {
 
 static void sysrq_handle_showregs(int key)
 {
-       struct pt_regs *regs = get_irq_regs();
+       struct pt_regs *regs = NULL;
+
+       if (in_irq())
+               regs = get_irq_regs();
        if (regs)
                show_regs(regs);
        perf_event_print_debug();
index 6b137194069fee47bc45b1866865ee27adfd33c5..1286f2478bcefd44e3e85140fb0da7102559e8f9 100644 (file)
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(tty_port_init);
  * @driver: tty_driver for this device
  * @index: index of the tty
  *
- * Provide the tty layer wit ha link from a tty (specified by @index) to a
+ * Provide the tty layer wita link from a tty (specified by @index) to a
  * tty_port (@port). Use this only if neither tty_port_register_device nor
  * tty_port_install is used in the driver. If used, this has to be called before
  * tty_register_driver.
@@ -235,7 +235,7 @@ EXPORT_SYMBOL(tty_port_free_xmit_buf);
 
 /**
  * tty_port_destroy -- destroy inited port
- * @port: tty port to be doestroyed
+ * @port: tty port to be destroyed
  *
  * When a port was initialized using tty_port_init, one has to destroy the
  * port by this function. Either indirectly by using tty_port refcounting
index ef01d24858cd659b9d667c964536fe6798bde6bb..954b190526e78e0396f8a69c178a7f0abd25b130 100644 (file)
@@ -645,13 +645,8 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        if (rv)
                goto free_domain;
 
-       init_timer(&port->rx_timer);
-       port->rx_timer.function = vcc_rx_timer;
-       port->rx_timer.data = port->index;
-
-       init_timer(&port->tx_timer);
-       port->tx_timer.function = vcc_tx_timer;
-       port->tx_timer.data = port->index;
+       setup_timer(&port->rx_timer, vcc_rx_timer, port->index);
+       setup_timer(&port->tx_timer, vcc_tx_timer, port->index);
 
        dev_set_drvdata(&vdev->dev, port);
 
index 2ebaba16f7858ec2ac0b0395af2c16d5d98a8273..5e41fac5816f424fa64f12ef3dec9813d4eb7218 100644 (file)
 #include <linux/uaccess.h>
 #include <linux/kdb.h>
 #include <linux/ctype.h>
+#include <linux/bsearch.h>
 
 #define MAX_NR_CON_DRIVER 16
 
@@ -2142,22 +2143,15 @@ struct interval {
        uint32_t last;
 };
 
-static int bisearch(uint32_t ucs, const struct interval *table, int max)
+static int ucs_cmp(const void *key, const void *elt)
 {
-       int min = 0;
-       int mid;
+       uint32_t ucs = *(uint32_t *)key;
+       struct interval e = *(struct interval *) elt;
 
-       if (ucs < table[0].first || ucs > table[max].last)
-               return 0;
-       while (max >= min) {
-               mid = (min + max) / 2;
-               if (ucs > table[mid].last)
-                       min = mid + 1;
-               else if (ucs < table[mid].first)
-                       max = mid - 1;
-               else
-                       return 1;
-       }
+       if (ucs > e.last)
+               return 1;
+       else if (ucs < e.first)
+               return -1;
        return 0;
 }
 
@@ -2169,7 +2163,12 @@ static int is_double_width(uint32_t ucs)
                { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 },
                { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD }
        };
-       return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
+       if (ucs < double_width[0].first ||
+           ucs > double_width[ARRAY_SIZE(double_width) - 1].last)
+               return 0;
+
+       return bsearch(&ucs, double_width, ARRAY_SIZE(double_width),
+                       sizeof(struct interval), ucs_cmp) != NULL;
 }
 
 static void con_flush(struct vc_data *vc, unsigned long draw_from,
@@ -2205,7 +2204,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
        console_lock();
        vc = tty->driver_data;
        if (vc == NULL) {
-               printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
+               pr_err("vt: argh, driver_data is NULL !\n");
                console_unlock();
                return 0;
        }
@@ -3190,20 +3189,21 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
 
        pr_info("Console: switching ");
        if (!deflt)
-               printk(KERN_CONT "consoles %d-%d ", first+1, last+1);
+               pr_cont("consoles %d-%d ", first + 1, last + 1);
        if (j >= 0) {
                struct vc_data *vc = vc_cons[j].d;
 
-               printk(KERN_CONT "to %s %s %dx%d\n",
-                      vc->vc_can_do_color ? "colour" : "mono",
-                      desc, vc->vc_cols, vc->vc_rows);
+               pr_cont("to %s %s %dx%d\n",
+                       vc->vc_can_do_color ? "colour" : "mono",
+                       desc, vc->vc_cols, vc->vc_rows);
 
                if (k >= 0) {
                        vc = vc_cons[k].d;
                        update_screen(vc);
                }
-       } else
-               printk(KERN_CONT "to %s\n", desc);
+       } else {
+               pr_cont("to %s\n", desc);
+       }
 
        retval = 0;
 err:
@@ -3622,9 +3622,8 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
                                          con_driver, con_dev_groups,
                                          "vtcon%i", con_driver->node);
        if (IS_ERR(con_driver->dev)) {
-               printk(KERN_WARNING "Unable to create device for %s; "
-                      "errno = %ld\n", con_driver->desc,
-                      PTR_ERR(con_driver->dev));
+               pr_warn("Unable to create device for %s; errno = %ld\n",
+                       con_driver->desc, PTR_ERR(con_driver->dev));
                con_driver->dev = NULL;
        } else {
                vtconsole_init_device(con_driver);
@@ -3761,8 +3760,8 @@ static int __init vtconsole_class_init(void)
 
        vtconsole_class = class_create(THIS_MODULE, "vtconsole");
        if (IS_ERR(vtconsole_class)) {
-               printk(KERN_WARNING "Unable to create vt console class; "
-                      "errno = %ld\n", PTR_ERR(vtconsole_class));
+               pr_warn("Unable to create vt console class; errno = %ld\n",
+                       PTR_ERR(vtconsole_class));
                vtconsole_class = NULL;
        }
 
@@ -3778,9 +3777,8 @@ static int __init vtconsole_class_init(void)
                                                          "vtcon%i", con->node);
 
                        if (IS_ERR(con->dev)) {
-                               printk(KERN_WARNING "Unable to create "
-                                      "device for %s; errno = %ld\n",
-                                      con->desc, PTR_ERR(con->dev));
+                               pr_warn("Unable to create device for %s; errno = %ld\n",
+                                       con->desc, PTR_ERR(con->dev));
                                con->dev = NULL;
                        } else {
                                vtconsole_init_device(con);
index 5553e04e59c9fb932c6d91ff71e0e9ddbe0bb640..37b044e78333ab28b01c6460e5f00484658cc20e 100644 (file)
@@ -501,4 +501,9 @@ static inline int uart_handle_break(struct uart_port *port)
                                         (cflag) & CRTSCTS || \
                                         !((cflag) & CLOCAL))
 
+/*
+ * Common device tree parsing helpers
+ */
+void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf);
+
 #endif /* LINUX_SERIAL_CORE_H */
index 5db76880b4adfc23fc86487d9816ad28df291973..dea05724c7606280162dc84d2d835721b2336eed 100644 (file)
  */
 #define UART_DLL       0       /* Out: Divisor Latch Low */
 #define UART_DLM       1       /* Out: Divisor Latch High */
+#define UART_DIV_MAX   0xFFFF  /* Max divisor value */
 
 /*
  * LCR=0xBF (or DLAB=1 for 16C660)