forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/tty/serial/msm_serial.c
....@@ -7,10 +7,6 @@
77 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
88 */
99
10
-#if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
11
-# define SUPPORT_SYSRQ
12
-#endif
13
-
1410 #include <linux/kernel.h>
1511 #include <linux/atomic.h>
1612 #include <linux/dma-mapping.h>
....@@ -301,7 +297,7 @@
301297 dma = &msm_port->tx_dma;
302298
303299 /* allocate DMA resources, if available */
304
- dma->chan = dma_request_slave_channel_reason(dev, "tx");
300
+ dma->chan = dma_request_chan(dev, "tx");
305301 if (IS_ERR(dma->chan))
306302 goto no_tx;
307303
....@@ -344,7 +340,7 @@
344340 dma = &msm_port->rx_dma;
345341
346342 /* allocate DMA resources, if available */
347
- dma->chan = dma_request_slave_channel_reason(dev, "rx");
343
+ dma->chan = dma_request_chan(dev, "rx");
348344 if (IS_ERR(dma->chan))
349345 goto no_rx;
350346
....@@ -613,7 +609,7 @@
613609 UARTDM_RX_SIZE, dma->dir);
614610 ret = dma_mapping_error(uart->dev, dma->phys);
615611 if (ret)
616
- return;
612
+ goto sw_mode;
617613
618614 dma->desc = dmaengine_prep_slave_single(dma->chan, dma->phys,
619615 UARTDM_RX_SIZE, DMA_DEV_TO_MEM,
....@@ -664,6 +660,22 @@
664660 return;
665661 unmap:
666662 dma_unmap_single(uart->dev, dma->phys, UARTDM_RX_SIZE, dma->dir);
663
+
664
+sw_mode:
665
+ /*
666
+ * Switch from DMA to SW/FIFO mode. After clearing Rx BAM (UARTDM_DMEN),
667
+ * receiver must be reset.
668
+ */
669
+ msm_write(uart, UART_CR_CMD_RESET_RX, UART_CR);
670
+ msm_write(uart, UART_CR_RX_ENABLE, UART_CR);
671
+
672
+ msm_write(uart, UART_CR_CMD_RESET_STALE_INT, UART_CR);
673
+ msm_write(uart, 0xFFFFFF, UARTDM_DMRX);
674
+ msm_write(uart, UART_CR_CMD_STALE_EVENT_ENABLE, UART_CR);
675
+
676
+ /* Re-enable RX interrupts */
677
+ msm_port->imr |= (UART_IMR_RXLEV | UART_IMR_RXSTALE);
678
+ msm_write(uart, msm_port->imr, UART_IMR);
667679 }
668680
669681 static void msm_stop_rx(struct uart_port *port)
....@@ -687,6 +699,7 @@
687699 }
688700
689701 static void msm_handle_rx_dm(struct uart_port *port, unsigned int misr)
702
+ __must_hold(&port->lock)
690703 {
691704 struct tty_port *tport = &port->state->port;
692705 unsigned int sr;
....@@ -762,6 +775,7 @@
762775 }
763776
764777 static void msm_handle_rx(struct uart_port *port)
778
+ __must_hold(&port->lock)
765779 {
766780 struct tty_port *tport = &port->state->port;
767781 unsigned int sr;
....@@ -1579,6 +1593,7 @@
15791593 static void __msm_console_write(struct uart_port *port, const char *s,
15801594 unsigned int count, bool is_uartdm)
15811595 {
1596
+ unsigned long flags;
15821597 int i;
15831598 int num_newlines = 0;
15841599 bool replaced = false;
....@@ -1595,6 +1610,8 @@
15951610 if (s[i] == '\n')
15961611 num_newlines++;
15971612 count += num_newlines;
1613
+
1614
+ local_irq_save(flags);
15981615
15991616 if (port->sysrq)
16001617 locked = 0;
....@@ -1641,6 +1658,8 @@
16411658
16421659 if (locked)
16431660 spin_unlock(&port->lock);
1661
+
1662
+ local_irq_restore(flags);
16441663 }
16451664
16461665 static void msm_console_write(struct console *co, const char *s,
....@@ -1657,7 +1676,7 @@
16571676 __msm_console_write(port, s, count, msm_port->is_uartdm);
16581677 }
16591678
1660
-static int __init msm_console_setup(struct console *co, char *options)
1679
+static int msm_console_setup(struct console *co, char *options)
16611680 {
16621681 struct uart_port *port;
16631682 int baud = 115200;
....@@ -1813,6 +1832,7 @@
18131832 if (unlikely(irq < 0))
18141833 return -ENXIO;
18151834 port->irq = irq;
1835
+ port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MSM_CONSOLE);
18161836
18171837 platform_set_drvdata(pdev, port);
18181838