diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-02-26 00:47:41 -0500 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-04 09:22:45 -0400 |
commit | bcc20f9e40bdfa6c3f254bcb90d8657fe7bba04d (patch) | |
tree | d8c956576f9fb3e2466a29957d0a4c1cdedd732b | |
parent | 5fac0e18bd3dbd7e23276efa0e5d2b945b1165e8 (diff) |
serial: mxs-auart: move to use generic DMA helper
With the generic DMA device tree helper supported by mxs-dma driver,
client devices only need to call dma_request_slave_channel() for
requesting a DMA channel from dmaengine.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt | 16 | ||||
-rw-r--r-- | drivers/tty/serial/mxs-auart.c | 52 |
2 files changed, 11 insertions, 57 deletions
diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt index 273a8d5b3300..2c00ec64628e 100644 --- a/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt | |||
@@ -5,20 +5,18 @@ Required properties: | |||
5 | imx23 and imx28. | 5 | imx23 and imx28. |
6 | - reg : Address and length of the register set for the device | 6 | - reg : Address and length of the register set for the device |
7 | - interrupts : Should contain the auart interrupt numbers | 7 | - interrupts : Should contain the auart interrupt numbers |
8 | 8 | - dmas: DMA specifier, consisting of a phandle to DMA controller node | |
9 | Optional properties: | 9 | and AUART DMA channel ID. |
10 | - fsl,auart-dma-channel : The DMA channels, the first is for RX, the other | 10 | Refer to dma.txt and fsl-mxs-dma.txt for details. |
11 | is for TX. If you add this property, it also means that you | 11 | - dma-names: "rx" for RX channel, "tx" for TX channel. |
12 | will enable the DMA support for the auart. | ||
13 | Note: due to the hardware bug in imx23(see errata : 2836), | ||
14 | only the imx28 can enable the DMA support for the auart. | ||
15 | 12 | ||
16 | Example: | 13 | Example: |
17 | auart0: serial@8006a000 { | 14 | auart0: serial@8006a000 { |
18 | compatible = "fsl,imx28-auart", "fsl,imx23-auart"; | 15 | compatible = "fsl,imx28-auart", "fsl,imx23-auart"; |
19 | reg = <0x8006a000 0x2000>; | 16 | reg = <0x8006a000 0x2000>; |
20 | interrupts = <112 70 71>; | 17 | interrupts = <112>; |
21 | fsl,auart-dma-channel = <8 9>; | 18 | dmas = <&dma_apbx 8>, <&dma_apbx 9>; |
19 | dma-names = "rx", "tx"; | ||
22 | }; | 20 | }; |
23 | 21 | ||
24 | Note: Each auart port should have an alias correctly numbered in "aliases" | 22 | Note: Each auart port should have an alias correctly numbered in "aliases" |
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 | ||
443 | static 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 | |||
457 | static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s); | 438 | static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s); |
458 | static void dma_rx_callback(void *arg) | 439 | static 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 | ||
546 | static int mxs_auart_dma_init(struct mxs_auart_port *s) | 527 | static 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 | ||