aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/mxs-auart.c52
1 files changed, 4 insertions, 48 deletions
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index d549fe1fa42a..269a27caff33 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -35,7 +35,7 @@
35#include <linux/pinctrl/consumer.h> 35#include <linux/pinctrl/consumer.h>
36#include <linux/of_device.h> 36#include <linux/of_device.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/fsl/mxs-dma.h> 38#include <linux/dmaengine.h>
39 39
40#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
41 41
@@ -148,11 +148,6 @@ struct mxs_auart_port {
148 struct device *dev; 148 struct device *dev;
149 149
150 /* for DMA */ 150 /* for DMA */
151 struct mxs_dma_data dma_data;
152 int dma_channel_rx, dma_channel_tx;
153 int dma_irq_rx, dma_irq_tx;
154 int dma_channel;
155
156 struct scatterlist tx_sgl; 151 struct scatterlist tx_sgl;
157 struct dma_chan *tx_dma_chan; 152 struct dma_chan *tx_dma_chan;
158 void *tx_dma_buf; 153 void *tx_dma_buf;
@@ -440,20 +435,6 @@ static u32 mxs_auart_get_mctrl(struct uart_port *u)
440 return mctrl; 435 return mctrl;
441} 436}
442 437
443static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
444{
445 struct mxs_auart_port *s = param;
446
447 if (!mxs_dma_is_apbx(chan))
448 return false;
449
450 if (s->dma_channel == chan->chan_id) {
451 chan->private = &s->dma_data;
452 return true;
453 }
454 return false;
455}
456
457static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s); 438static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s);
458static void dma_rx_callback(void *arg) 439static void dma_rx_callback(void *arg)
459{ 440{
@@ -545,21 +526,11 @@ static void mxs_auart_dma_exit(struct mxs_auart_port *s)
545 526
546static int mxs_auart_dma_init(struct mxs_auart_port *s) 527static int mxs_auart_dma_init(struct mxs_auart_port *s)
547{ 528{
548 dma_cap_mask_t mask;
549
550 if (auart_dma_enabled(s)) 529 if (auart_dma_enabled(s))
551 return 0; 530 return 0;
552 531
553 /* We do not get the right DMA channels. */
554 if (s->dma_channel_rx == -1 || s->dma_channel_tx == -1)
555 return -EINVAL;
556
557 /* init for RX */ 532 /* init for RX */
558 dma_cap_zero(mask); 533 s->rx_dma_chan = dma_request_slave_channel(s->dev, "rx");
559 dma_cap_set(DMA_SLAVE, mask);
560 s->dma_channel = s->dma_channel_rx;
561 s->dma_data.chan_irq = s->dma_irq_rx;
562 s->rx_dma_chan = dma_request_channel(mask, mxs_auart_dma_filter, s);
563 if (!s->rx_dma_chan) 534 if (!s->rx_dma_chan)
564 goto err_out; 535 goto err_out;
565 s->rx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA); 536 s->rx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA);
@@ -567,9 +538,7 @@ static int mxs_auart_dma_init(struct mxs_auart_port *s)
567 goto err_out; 538 goto err_out;
568 539
569 /* init for TX */ 540 /* init for TX */
570 s->dma_channel = s->dma_channel_tx; 541 s->tx_dma_chan = dma_request_slave_channel(s->dev, "tx");
571 s->dma_data.chan_irq = s->dma_irq_tx;
572 s->tx_dma_chan = dma_request_channel(mask, mxs_auart_dma_filter, s);
573 if (!s->tx_dma_chan) 542 if (!s->tx_dma_chan)
574 goto err_out; 543 goto err_out;
575 s->tx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA); 544 s->tx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA);
@@ -1020,7 +989,6 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,
1020 struct platform_device *pdev) 989 struct platform_device *pdev)
1021{ 990{
1022 struct device_node *np = pdev->dev.of_node; 991 struct device_node *np = pdev->dev.of_node;
1023 u32 dma_channel[2];
1024 int ret; 992 int ret;
1025 993
1026 if (!np) 994 if (!np)
@@ -1034,20 +1002,8 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,
1034 } 1002 }
1035 s->port.line = ret; 1003 s->port.line = ret;
1036 1004
1037 s->dma_irq_rx = platform_get_irq(pdev, 1); 1005 s->flags |= MXS_AUART_DMA_CONFIG;
1038 s->dma_irq_tx = platform_get_irq(pdev, 2);
1039 1006
1040 ret = of_property_read_u32_array(np, "fsl,auart-dma-channel",
1041 dma_channel, 2);
1042 if (ret == 0) {
1043 s->dma_channel_rx = dma_channel[0];
1044 s->dma_channel_tx = dma_channel[1];
1045
1046 s->flags |= MXS_AUART_DMA_CONFIG;
1047 } else {
1048 s->dma_channel_rx = -1;
1049 s->dma_channel_tx = -1;
1050 }
1051 return 0; 1007 return 0;
1052} 1008}
1053 1009