Skip to contentSkip to conversation

serial: mxs-auart: add DMA support for auart in mx28

PATCH New Huang Shijie 3 participants 6 messages Nov 16, 2012 – Nov 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover serial: mxs-auart: add DMA support for auart in mx28

This patch set adds the DMA support for auart in mx28.
patch 1:
In mx23, the DMA has a bug(see errata:2836). We can not add the DMA support in mx23, but we can add DMA support to auart in mx28. So in order to add the DMA support for the auart in mx28, we should add the platform_device_id to distinguish the distinguish SOCs.

patch 2: add the DMA support for mx28
Only we meet the following conditions, we can enable the DMA support for auart:
(1) We enable the DMA support in the dts file, such as arch/arm/boot/dts/imx28.dtsi.
(2) We enable the hardware flow control.
(3) We use the mx28, not the mx23. Due to hardware bug(see errata: 2836), we can not add the DMA support to mx23.

patch 3: enable the DMA support in dts for mx28
You can use the /ttyAPP0 to test this patch set. I tested this patch in mx28-evk board.

To Lauri: Please try this patch set. thanks.

v2 --> v3:
[1] fix a multi-open issue found by Lauri.

v1 --> v2:
[1] use the inline function, not a macro, to distinguish the SOCs.
[2] remove the "inline" for mxs_auart_tx_chars().
[3] use the pio, not the pio[1] to fill the DMA descriptor.
[4] use bit operation to serialize the DMA TX.
[5] use the RX/TX DMA channel to enable the DMA support, remove the "fsl,auart-enable-dma".

Huang Shijie (3):
serial: mxs-auart: distinguish the different SOCs
serial: mxs-auart: add the DMA support for mx28
ARM: dts: enable dma support for auart0 in mx28

 .../bindings/tty/serial/fsl-mxs-auart.txt          |    8 +
 arch/arm/boot/dts/imx28.dtsi                       |    1 +
 drivers/tty/serial/mxs-auart.c                     |  364 +++++++++++++++++++-
 3 files changed, 362 insertions(+), 11 deletions(-)
#1 lore raw

PATCH v3 1/3 serial: mxs-auart: distinguish the different SOCs

The current mxs-auart driver is used for both mx23 and mx28.

But in mx23, the DMA has a bug(see errata:2836). We can not add the DMA support in mx23, but we can add DMA support to auart in mx28.

So in order to add the DMA support for the auart in mx28, we should distinguish the distinguish SOCs.

This patch adds a new platform_device_id table and a inline function is_imx28_auart() to distinguish the mx23 and mx28.

---
 drivers/tty/serial/mxs-auart.c |   42 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 6 deletions(-)
drivers/tty/serial/mxs-auart.c +36 -6
index 6db3baa..06d7271 100644
@@ -114,11 +114,17 @@
 
 static struct uart_driver auart_driver;
 
+enum mxs_auart_type {
+	IMX23_AUART,
+	IMX28_AUART,
+};
+
 struct mxs_auart_port {
 	struct uart_port port;
 
 	unsigned int flags;
 	unsigned int ctrl;
+	enum mxs_auart_type devtype;
 
 	unsigned int irq;
 
@@ -126,6 +132,29 @@ struct mxs_auart_port {
 	struct device *dev;
 };
 
+static struct platform_device_id mxs_auart_devtype[] = {
+	{ .name = "mxs-auart-imx23", .driver_data = IMX23_AUART },
+	{ .name = "mxs-auart-imx28", .driver_data = IMX28_AUART },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);
+
+static struct of_device_id mxs_auart_dt_ids[] = {
+	{
+		.compatible = "fsl,imx28-auart",
+		.data = &mxs_auart_devtype[IMX28_AUART]
+	}, {
+		.compatible = "fsl,imx23-auart",
+		.data = &mxs_auart_devtype[IMX23_AUART]
+	}, { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_auart_dt_ids);
+
+static inline int is_imx28_auart(struct mxs_auart_port *s)
+{
+	return s->devtype == IMX28_AUART;
+}
+
 static void mxs_auart_stop_tx(struct uart_port *u);
 
 #define to_auart_port(u) container_of(u, struct mxs_auart_port, port)
@@ -706,6 +735,8 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,
 
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *of_id =
+			of_match_device(mxs_auart_dt_ids, &pdev->dev);
 	struct mxs_auart_port *s;
 	u32 version;
 	int ret = 0;
@@ -730,6 +761,11 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 		goto out_free;
 	}
 
+	if (of_id) {
+		pdev->id_entry = of_id->data;
+		s->devtype = pdev->id_entry->driver_data;
+	}
+
 	s->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(s->clk)) {
 		ret = PTR_ERR(s->clk);
@@ -805,12 +841,6 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static struct of_device_id mxs_auart_dt_ids[] = {
-	{ .compatible = "fsl,imx23-auart", },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, mxs_auart_dt_ids);
-
 static struct platform_driver mxs_auart_driver = {
 	.probe = mxs_auart_probe,
 	.remove = __devexit_p(mxs_auart_remove),
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v3 2/3 serial: mxs-auart: add the DMA support for mx28

In reply to Huang Shijie

Only we meet the following conditions, we can enable the DMA support for auart:

(1) We enable the DMA support in the dts file, such as

      arch/arm/boot/dts/imx28.dtsi.

(2) We enable the hardware flow control.

(3) We use the mx28, not the mx23. Due to hardware bug(see errata: 2836), we can not add the DMA support to mx23.

---
 .../bindings/tty/serial/fsl-mxs-auart.txt          |    8 +
 drivers/tty/serial/mxs-auart.c                     |  322 +++++++++++++++++++-
 2 files changed, 325 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt +8 -0
index 2ee903f..273a8d5 100644
@@ -6,11 +6,19 @@ Required properties:
 - reg : Address and length of the register set for the device
 - interrupts : Should contain the auart interrupt numbers
 
+Optional properties:
+- fsl,auart-dma-channel : The DMA channels, the first is for RX, the other
+		is for TX. If you add this property, it also means that you
+		will enable the DMA support for the auart.
+		Note: due to the hardware bug in imx23(see errata : 2836),
+		only the imx28 can enable the DMA support for the auart.
+
 Example:
 auart0: serial at 8006a000 {
 	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 	reg = <0x8006a000 0x2000>;
 	interrupts = <112 70 71>;
+	fsl,auart-dma-channel = <8 9>;
 };
 
 Note: Each auart port should have an alias correctly numbered in "aliases"
drivers/tty/serial/mxs-auart.c +317 -5

413 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#3 lore raw

PATCH v3 3/3 ARM: dts: enable dma support for auart0 in mx28

In reply to Huang Shijie

enable the dma support for auart0 in mx28.

---
 arch/arm/boot/dts/imx28.dtsi |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/imx28.dtsi +1 -0
index 55c57ea..b4587b2 100644
@@ -799,6 +799,7 @@
 				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x8006a000 0x2000>;
 				interrupts = <112 70 71>;
+				fsl,auart-dma-channel = <8 9>;
 				clocks = <&clks 45>;
 				status = "disabled";
 			};
Signature · 1 line
1.7.0.4
#4 lore raw

v3 cover serial: mxs-auart: add DMA support for auart in mx28

In reply to Huang Shijie

Hi Huang,

Thanks for new version. Now I don't get any errors and the CPU doesn't freeze any more but:

1) AUART corrupts data with baudrate over 1Mbits/s

2) We would need DMA support without flow control.

By the way, how do you test drivers? Is there any standard tools for uart data and throughput testing?

Lauri

Quoted 46 lines · Huang Shijie

This patch set adds the DMA support for auart in mx28.
patch 1:
In mx23, the DMA has a bug(see errata:2836). We can not add the DMA support in mx23, but we can add DMA support to auart in mx28. So in order to add the DMA support for the auart in mx28, we should add the platform_device_id to distinguish the distinguish SOCs.

patch 2: add the DMA support for mx28
Only we meet the following conditions, we can enable the DMA support for auart:
(1) We enable the DMA support in the dts file, such as arch/arm/boot/dts/imx28.dtsi.
(2) We enable the hardware flow control.
(3) We use the mx28, not the mx23. Due to hardware bug(see errata: 2836), we can not add the DMA support to mx23.

patch 3: enable the DMA support in dts for mx28
You can use the /ttyAPP0 to test this patch set. I tested this patch in mx28-evk board.

To Lauri: Please try this patch set. thanks.

v2 --> v3:
[1] fix a multi-open issue found by Lauri.

v1 --> v2:
[1] use the inline function, not a macro, to distinguish the SOCs.
[2] remove the "inline" for mxs_auart_tx_chars().
[3] use the pio, not the pio[1] to fill the DMA descriptor.
[4] use bit operation to serialize the DMA TX.
[5] use the RX/TX DMA channel to enable the DMA support, remove the "fsl,auart-enable-dma".

Huang Shijie (3):
serial: mxs-auart: distinguish the different SOCs
serial: mxs-auart: add the DMA support for mx28
ARM: dts: enable dma support for auart0 in mx28

  .../bindings/tty/serial/fsl-mxs-auart.txt          |    8 +
  arch/arm/boot/dts/imx28.dtsi                       |    1 +
  drivers/tty/serial/mxs-auart.c                     |  364 +++++++++++++++++++-
  3 files changed, 362 insertions(+), 11 deletions(-)
#5 lore raw

v3 cover serial: mxs-auart: add DMA support for auart in mx28

Quoted 6 lines · Lauri Hintsala

Hi Huang,

Thanks for new version. Now I don't get any errors and the CPU doesn't freeze any more but:

1) AUART corrupts data with baudrate over 1Mbits/s

The tranceivers, such as MAX3380E, will limit the speed. i ever removed it, and tested the AUART in 3M bits/s.

Quoted 2 lines

2) We would need DMA support without flow control.

:)
I really think it's not wise to support the DMA withou flow control. it will losts the data in some case.
Even use the FREESCALE's bsp code, I also recomand to use the flow control.

Quoted 3 lines

By the way, how do you test drivers? Is there any standard tools for uart data and throughput testing?

I tested the driver with our own small tool.
If you want to test it too, I can send you the resource next monday. You can use it to test if you have received the right data.

thanks
Huang Shijie

Quoted 61 lines

Lauri

Quoted 45 lines · Huang Shijie

This patch set adds the DMA support for auart in mx28.
patch 1:
In mx23, the DMA has a bug(see errata:2836). We can not add the DMA support in mx23, but we can add DMA support to auart in mx28. So in order to add the DMA support for the auart in mx28, we
should add
the platform_device_id to distinguish the distinguish SOCs.

patch 2: add the DMA support for mx28
Only we meet the following conditions, we can enable the DMA
support
for auart:
(1) We enable the DMA support in the dts file, such as arch/arm/boot/dts/imx28.dtsi.
(2) We enable the hardware flow control.
(3) We use the mx28, not the mx23. Due to hardware bug(see
errata: 2836),
we can not add the DMA support to mx23.

patch 3: enable the DMA support in dts for mx28
You can use the /ttyAPP0 to test this patch set. I tested this patch in mx28-evk board.

To Lauri: Please try this patch set. thanks.

v2 --> v3:
[1] fix a multi-open issue found by Lauri.

v1 --> v2:
[1] use the inline function, not a macro, to distinguish the SOCs.
[2] remove the "inline" for mxs_auart_tx_chars().
[3] use the pio, not the pio[1] to fill the DMA descriptor.
[4] use bit operation to serialize the DMA TX.
[5] use the RX/TX DMA channel to enable the DMA support, remove
the

            "fsl,auart-enable-dma".

Huang Shijie (3):
serial: mxs-auart: distinguish the different SOCs
serial: mxs-auart: add the DMA support for mx28
ARM: dts: enable dma support for auart0 in mx28

Quoted 7 lines
  .../bindings/tty/serial/fsl-mxs-auart.txt          |    8 +
  arch/arm/boot/dts/imx28.dtsi                       |    1 +
  drivers/tty/serial/mxs-auart.c                     |  364
+++++++++++++++++++-
  3 files changed, 362 insertions(+), 11 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html