Skip to contentSkip to conversation

ARM: dts: mx28evk: Add auart0 and auart3 support

PATCH New Fabio Estevam 7 participants 20 messages Jun 15, 2012 – Jul 13, 2012

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

PATCH v3 1/2 ARM: dts: mx28evk: Add auart0 and auart3 support

Add auart0 and auart3 support.

---
Changes since v2:
- Fix compatible property
Changes since v1:
- Merged patches 1 and 2 from v1 into this one

 arch/arm/boot/dts/imx28-evk.dts |   12 ++++++++++++
 arch/arm/boot/dts/imx28.dtsi    |   26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/arm/boot/dts/imx28-evk.dts +12 -0
index ee520a5..4353f48 100644
@@ -73,6 +73,18 @@
 				pinctrl-0 = <&duart_pins_a>;
 				status = "okay";
 			};
+
+			auart0: serial at 8006a000 {
+				pinctrl-names = "default";
+				pinctrl-0 = <&auart0_pins_a>;
+				status = "okay";
+			};
+
+			auart3: serial at 80070000 {
+				pinctrl-names = "default";
+				pinctrl-0 = <&auart3_pins_a>;
+				status = "okay";
+			};
 		};
 	};
 
arch/arm/boot/dts/imx28.dtsi +26 -0
index 4634cb8..f26e0d6 100644
@@ -22,6 +22,11 @@
 		gpio4 = &gpio4;
 		saif0 = &saif0;
 		saif1 = &saif1;
+		serial0 = &auart0;
+		serial1 = &auart1;
+		serial2 = &auart2;
+		serial3 = &auart3;
+		serial4 = &auart4;
 	};
 
 	cpus {
@@ -167,6 +172,22 @@
 					fsl,pull-up = <0>;
 				};
 
+				auart0_pins_a: auart0 at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x3000 0x3010 0x3020 0x3030>;
+					fsl,drive-strength = <0>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <0>;
+				};
+
+				auart3_pins_a: auart3 at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x30c0 0x30d0 0x30e0 0x30f0>;
+					fsl,drive-strength = <0>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <0>;
+				};
+
 				mac0_pins_a: mac0 at 0 {
 					reg = <0>;
 					fsl,pinmux-ids = <0x4000 0x4010 0x4020
@@ -404,30 +425,35 @@
 			};
 
 			auart0: serial@8006a000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x8006a000 0x2000>;
 				interrupts = <112 70 71>;
 				status = "disabled";
 			};
 
 			auart1: serial at 8006c000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x8006c000 0x2000>;
 				interrupts = <113 72 73>;
 				status = "disabled";
 			};
 
 			auart2: serial at 8006e000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x8006e000 0x2000>;
 				interrupts = <114 74 75>;
 				status = "disabled";
 			};
 
 			auart3: serial at 80070000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x80070000 0x2000>;
 				interrupts = <115 76 77>;
 				status = "disabled";
 			};
 
 			auart4: serial at 80072000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-auart";
 				reg = <0x80072000 0x2000>;
 				interrupts = <116 78 79>;
 				status = "disabled";
Signature · 1 line
1.7.1
#1 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Allow device tree probing.

---
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

 .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++
 drivers/tty/serial/mxs-auart.c                     |   49 +++++++++++++++++++-
 2 files changed, 75 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +27 -0
new file mode 100644
index 0000000..2ee903f
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial at 8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in "aliases"
+node.
+
+Example:
+
+aliases {
+	serial0 = &auart0;
+	serial1 = &auart1;
+	serial2 = &auart2;
+	serial3 = &auart3;
+	serial4 = &auart4;
+};
drivers/tty/serial/mxs-auart.c +48 -1

89 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Dear Fabio Estevam,

Quoted 7 lines

Allow device tree probing.

Quoted 145 lines

---
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

 .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++
 drivers/tty/serial/mxs-auart.c                     |   49
+++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file mode 100644
index 0000000..2ee903f

Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +27 -0
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial at 8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in "aliases"
+node.
+
+Example:
+
+aliases {
+	serial0 = &auart0;
+	serial1 = &auart1;
+	serial2 = &auart2;
+	serial3 = &auart3;
+	serial4 = &auart4;
+};
(quoted diff) +0 -0

b/drivers/tty/serial/mxs-auart.c index ec56d83..87bbe9c 100644

drivers/tty/serial/mxs-auart.c +3 -0
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/of_device.h>
 
 #include <asm/cacheflush.h>
 
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
 #endif
 };
 
+/*
+ * This function returns 1 if pdev isn't a device instatiated by dt, 0 if

it + * could successfully get all information from dt or a negative errno.
+ */

drivers/tty/serial/mxs-auart.c +26 -1
+static int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (!np)
+		/* no device tree device */
+		return 1;
+
+	ret = of_alias_get_id(np, "serial");
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
+		return ret;
+	}
+	s->port.line = ret;
+
+	return 0;
+}
+
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
 	struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct
 platform_device *pdev) goto out;
 	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret > 0)
+		s->port.line = pdev->id < 0 ? 0 : pdev->id;
+	else if (ret < 0)
+		goto out_free;
+
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct
 platform_device *pdev) s->port.membase = ioremap(r->start,
 resource_size(r));
 	s->port.ops = &mxs_auart_ops;
 	s->port.iotype = UPIO_MEM;
-	s->port.line = pdev->id < 0 ? 0 : pdev->id;
 	s->port.fifosize = 16;
 	s->port.uartclk = clk_get_rate(s->clk);
drivers/tty/serial/mxs-auart.c +16 -0
 	s->port.type = PORT_IMX;
@@ -769,13 +799,29 @@ static int __devexit mxs_auart_remove(struct
 platform_device *pdev) return 0;
 }
 
+static struct platform_device_id mxs_auart_devtype[] = {
+	{
+		.name = "mxs-auart",
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);
+
+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),
 	.driver = {
 		.name = "mxs-auart",
 		.owner = THIS_MODULE,
+		.of_match_table = mxs_auart_dt_ids,
 	},
+		.id_table = mxs_auart_devtype,
 };
 
 static int __init mxs_auart_init(void)

drivers/tty/serial/mxs-auart.c module_init(mxs_auart_init); · line 856

Quoted 4 lines
drivers/tty/serial/mxs-auart.c +1 -0
@@ -807,3 +853,4 @@ module_init(mxs_auart_init);
 module_exit(mxs_auart_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Freescale MXS application uart driver");
+MODULE_ALIAS("platform:mxs-auart");

Best regards,
Marek Vasut

#3 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

In reply to Fabio Estevam
Quoted 7 lines · Fabio Estevam
drivers/tty/serial/mxs-auart.c +7 -0
+static struct platform_device_id mxs_auart_devtype[] = {
+	{
+		.name = "mxs-auart",
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

drivers/tty/serial/mxs-auart.c static int __devexit mxs_auart_remove(struct platform_device *pdev) · line 824

Quoted 1 line
drivers/tty/serial/mxs-auart.c +1 -0
+		.id_table = mxs_auart_devtype,

I do not think we need these.

Signature · 2 lines
Regards,
Shawn
reviewer
#4 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Quoted 5 lines · Shawn Guo
Quoted 1 line

+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

Quoted 1 line

+ ? ? ? ? ? ? .id_table = mxs_auart_devtype,

I do not think we need these.

WIthout this, the non-dt kernel does not probe correctly.

#5 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Dear Fabio Estevam,

Quoted 10 lines · Shawn Guo
Quoted 7 lines
Quoted 1 line

+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

Quoted 1 line

+ .id_table = mxs_auart_devtype,

I do not think we need these.

WIthout this, the non-dt kernel does not probe correctly.

But we don't support non-DT kernel anymore.

Best regards,
Marek Vasut

reviewer
#6 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Quoted 7 lines · Marek Vasut

Dear Fabio Estevam,

Quoted 5 lines · Shawn Guo
Quoted 4 lines
Quoted 1 line

+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ ? ? ? ? ? ? .id_table = mxs_auart_devtype,

I do not think we need these.

WIthout this, the non-dt kernel does not probe correctly.

But we don't support non-DT kernel anymore.

but I don't want my patch to break something that has been working for a long time.

#7 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Dear Fabio Estevam,

Quoted 10 lines · Marek Vasut
Quoted 9 lines

Dear Fabio Estevam,

Quoted 7 lines · Shawn Guo
Quoted 6 lines
Quoted 1 line

+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

Quoted 1 line

+ .id_table = mxs_auart_devtype,

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I do not think we need these.

WIthout this, the non-dt kernel does not probe correctly.

But we don't support non-DT kernel anymore.

but I don't want my patch to break something that has been working for a long time.

But we don't care if the non-DT case gets broken anyway *. It's unsupported and will be removed.

* that's how I understand it.

Best regards,
Marek Vasut

#8 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

Quoted 3 lines · Marek Vasut

But we don't care if the non-DT case gets broken anyway *. It's unsupported and will be removed.

We have to care about non-DT case before all those non-DT users (board files) get removed from the tree.

Signature · 2 lines
Regards,
Shawn
#9 lore raw

PATCH v3 2/2 serial: mxs-auart: Allow device tree probing

In reply to Fabio Estevam
Quoted 9 lines · Fabio Estevam
Quoted 5 lines · Shawn Guo
Quoted 1 line

+MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);

...

Quoted 1 line

+             .id_table = mxs_auart_devtype,

I do not think we need these.

WIthout this, the non-dt kernel does not probe correctly.

Are you sure about that? I just tried to removed those and still saw the following with non-DT boot.

[    0.810000] mxs-auart.0: ttyAPP0 at MMIO 0x8006a000 (irq = 112) is a mxs-auar t.0
[    0.820000] mxs-auart mxs-auart.0: Found APPUART 3.1.0
[    0.830000] mxs-auart.3: ttyAPP3 at MMIO 0x80070000 (irq = 115) is a mxs-auar t.3
[    0.840000] mxs-auart mxs-auart.3: Found APPUART 3.1.0
Signature · 7 lines
Regards,
Shawn

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH v3 1/2 ARM: dts: mx28evk: Add auart0 and auart3 support

In reply to Fabio Estevam

Dear Fabio Estevam,

Quoted 3 lines

Add auart0 and auart3 support.

Quoted 49 lines

---
Changes since v2:
- Fix compatible property
Changes since v1:
- Merged patches 1 and 2 from v1 into this one

 arch/arm/boot/dts/imx28-evk.dts |   12 ++++++++++++
 arch/arm/boot/dts/imx28.dtsi    |   26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx28-evk.dts index ee520a5..4353f48 100644

arch/arm/boot/dts/imx28-evk.dts +12 -0
@@ -73,6 +73,18 @@
 				pinctrl-0 = <&duart_pins_a>;
 				status = "okay";
 			};
+
+			auart0: serial at 8006a000 {
+				pinctrl-names = "default";
+				pinctrl-0 = <&auart0_pins_a>;
+				status = "okay";
+			};
+
+			auart3: serial at 80070000 {
+				pinctrl-names = "default";
+				pinctrl-0 = <&auart3_pins_a>;
+				status = "okay";
+			};
 		};
 	};
 
arch/arm/boot/dts/imx28.dtsi +5 -0
index 4634cb8..f26e0d6 100644
@@ -22,6 +22,11 @@
 		gpio4 = &gpio4;
 		saif0 = &saif0;
 		saif1 = &saif1;
+		serial0 = &auart0;
+		serial1 = &auart1;
+		serial2 = &auart2;
+		serial3 = &auart3;
+		serial4 = &auart4;
 	};
 
 	cpus {

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

Quoted 6 lines
arch/arm/boot/dts/imx28.dtsi +3 -0
@@ -167,6 +172,22 @@
 					fsl,pull-up = <0>;
 				};
 
+				auart0_pins_a: auart0 at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x3000 0x3010 0x3020 

0x3030>;

arch/arm/boot/dts/imx28.dtsi

Quoted 8 lines
arch/arm/boot/dts/imx28.dtsi +8 -0
+					fsl,drive-strength = <0>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <0>;
+				};
+
+				auart3_pins_a: auart3 at 0 {
+					reg = <0>;
+					fsl,pinmux-ids = <0x30c0 0x30d0 0x30e0 

0x30f0>;

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

Quoted 13 lines
arch/arm/boot/dts/imx28.dtsi +6 -0
+					fsl,drive-strength = <0>;
+					fsl,voltage = <1>;
+					fsl,pull-up = <0>;
+				};
+
 				mac0_pins_a: mac0 at 0 {
 					reg = <0>;
 					fsl,pinmux-ids = <0x4000 0x4010 0x4020
@@ -404,30 +425,35 @@
 			};
 
 			auart0: serial at 8006a000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-

auart";

arch/arm/boot/dts/imx28.dtsi

Quoted 7 lines
arch/arm/boot/dts/imx28.dtsi +1 -0
 				reg = <0x8006a000 0x2000>;
 				interrupts = <112 70 71>;
 				status = "disabled";
 			};
 
 			auart1: serial at 8006c000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-

auart";

arch/arm/boot/dts/imx28.dtsi

Quoted 7 lines
arch/arm/boot/dts/imx28.dtsi +1 -0
 				reg = <0x8006c000 0x2000>;
 				interrupts = <113 72 73>;
 				status = "disabled";
 			};
 
 			auart2: serial at 8006e000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-

auart";

arch/arm/boot/dts/imx28.dtsi

Quoted 7 lines
arch/arm/boot/dts/imx28.dtsi +1 -0
 				reg = <0x8006e000 0x2000>;
 				interrupts = <114 74 75>;
 				status = "disabled";
 			};
 
 			auart3: serial at 80070000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-

auart";

arch/arm/boot/dts/imx28.dtsi

Quoted 7 lines
arch/arm/boot/dts/imx28.dtsi +1 -0
 				reg = <0x80070000 0x2000>;
 				interrupts = <115 76 77>;
 				status = "disabled";
 			};
 
 			auart4: serial at 80072000 {
+				compatible = "fsl,imx28-auart", "fsl,imx23-

auart";

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

Quoted 3 lines
arch/arm/boot/dts/imx28.dtsi +0 -0
 				reg = <0x80072000 0x2000>;
 				interrupts = <116 78 79>;
 				status = "disabled";

Best regards,
Marek Vasut

#12 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

In reply to Fabio Estevam

Allow device tree probing.

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

 .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++++
 drivers/tty/serial/mxs-auart.c                     |   40 +++++++++++++++++++-
 2 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +27 -0
new file mode 100644
index 0000000..2ee903f
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial at 8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in "aliases"
+node.
+
+Example:
+
+aliases {
+	serial0 = &auart0;
+	serial1 = &auart1;
+	serial2 = &auart2;
+	serial3 = &auart3;
+	serial4 = &auart4;
+};
drivers/tty/serial/mxs-auart.c +39 -1
index ec56d83..103087d 100644
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/of_device.h>
 
 #include <asm/cacheflush.h>
 
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
 #endif
 };
 
+/*
+ * This function returns 1 if pdev isn't a device instatiated by dt, 0 if it
+ * could successfully get all information from dt or a negative errno.
+ */
+static int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (!np)
+		/* no device tree device */
+		return 1;
+
+	ret = of_alias_get_id(np, "serial");
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
+		return ret;
+	}
+	s->port.line = ret;
+
+	return 0;
+}
+
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
 	struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret > 0)
+		s->port.line = pdev->id < 0 ? 0 : pdev->id;
+	else if (ret < 0)
+		goto out_free;
+
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 	s->port.membase = ioremap(r->start, resource_size(r));
 	s->port.ops = &mxs_auart_ops;
 	s->port.iotype = UPIO_MEM;
-	s->port.line = pdev->id < 0 ? 0 : pdev->id;
 	s->port.fifosize = 16;
 	s->port.uartclk = clk_get_rate(s->clk);
 	s->port.type = PORT_IMX;
@@ -769,12 +799,19 @@ 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),
 	.driver = {
 		.name = "mxs-auart",
 		.owner = THIS_MODULE,
+		.of_match_table = mxs_auart_dt_ids,
 	},
 };
 
@@ -807,3 +844,4 @@ module_init(mxs_auart_init);
 module_exit(mxs_auart_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Freescale MXS application uart driver");
+MODULE_ALIAS("platform:mxs-auart");
Signature · 1 line
1.7.1
#13 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

Quoted 7 lines · Fabio Estevam

Allow device tree probing.

Quoted 11 lines

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

Hi Greg,

May I have your ack to have the patch go through arm-soc tree, so that we can possibly start converting those non-DT board files over to DT?

Regards,
Shawn

Quoted 131 lines
 .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++++
 drivers/tty/serial/mxs-auart.c                     |   40 +++++++++++++++++++-
 2 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +27 -0
new file mode 100644
index 0000000..2ee903f
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial@8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in "aliases"
+node.
+
+Example:
+
+aliases {
+	serial0 = &auart0;
+	serial1 = &auart1;
+	serial2 = &auart2;
+	serial3 = &auart3;
+	serial4 = &auart4;
+};
drivers/tty/serial/mxs-auart.c +39 -1
index ec56d83..103087d 100644
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/of_device.h>
 
 #include <asm/cacheflush.h>
 
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
 #endif
 };
 
+/*
+ * This function returns 1 if pdev isn't a device instatiated by dt, 0 if it
+ * could successfully get all information from dt or a negative errno.
+ */
+static int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (!np)
+		/* no device tree device */
+		return 1;
+
+	ret = of_alias_get_id(np, "serial");
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
+		return ret;
+	}
+	s->port.line = ret;
+
+	return 0;
+}
+
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
 	struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret > 0)
+		s->port.line = pdev->id < 0 ? 0 : pdev->id;
+	else if (ret < 0)
+		goto out_free;
+
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 	s->port.membase = ioremap(r->start, resource_size(r));
 	s->port.ops = &mxs_auart_ops;
 	s->port.iotype = UPIO_MEM;
-	s->port.line = pdev->id < 0 ? 0 : pdev->id;
 	s->port.fifosize = 16;
 	s->port.uartclk = clk_get_rate(s->clk);
 	s->port.type = PORT_IMX;
@@ -769,12 +799,19 @@ 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),
 	.driver = {
 		.name = "mxs-auart",
 		.owner = THIS_MODULE,
+		.of_match_table = mxs_auart_dt_ids,
 	},
 };
 
@@ -807,3 +844,4 @@ module_init(mxs_auart_init);
 module_exit(mxs_auart_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Freescale MXS application uart driver");
+MODULE_ALIAS("platform:mxs-auart");
Signature · 1 line
1.7.1
#14 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

Dear Shawn Guo,

Quoted 20 lines · Fabio Estevam
Quoted 7 lines

Allow device tree probing.

Quoted 11 lines

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

Quoted 7 lines

Hi Greg,

May I have your ack to have the patch go through arm-soc tree, so that we can possibly start converting those non-DT board files over to DT?

Regards,
Shawn

Good, I should be back on 20th to the denx board.

#15 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

In reply to Shawn Guo
Quoted 20 lines · Shawn Guo
Quoted 7 lines · Fabio Estevam

Allow device tree probing.

Quoted 11 lines

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

Quoted 4 lines

Hi Greg,

May I have your ack to have the patch go through arm-soc tree, so that we can possibly start converting those non-DT board files over to DT?

Fine with me:

#16 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

In reply to Fabio Estevam

If one were to try run console on one of the /dev/ttyAPP* ports, as is the case for hardware I am working with, console output wouldn't show up without the following diff:

Let me know if should send formal patch or we can include it as part of v5?

drivers/tty/serial/mxs-auart.c +0 -0
index ca3d25e..2ced332 100644
@@ -761,7 +761,7 @@ static int __devinit mxs_auart_probe(struct 

platform_device *pdev)

         platform_set_drvdata(pdev, s);

- auart_port[pdev->id] = s;
+ auart_port[s->port.line] = s;

         mxs_auart_reset(&s->port)

-Subodh

Quoted 145 lines · Fabio Estevam

Allow device tree probing.

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

  .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++++
  drivers/tty/serial/mxs-auart.c                     |   40 +++++++++++++++++++-
  2 files changed, 66 insertions(+), 1 deletions(-)

create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt

Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +27 -0
new file mode 100644
index 0000000..2ee903f
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial at 8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg =<0x8006a000 0x2000>;
+	interrupts =<112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in "aliases"
+node.
+
+Example:
+
+aliases {
+	serial0 =&auart0;
+	serial1 =&auart1;
+	serial2 =&auart2;
+	serial3 =&auart3;
+	serial4 =&auart4;
+};
drivers/tty/serial/mxs-auart.c +39 -1
index ec56d83..103087d 100644
@@ -33,6 +33,7 @@
  #include<linux/delay.h>
  #include<linux/io.h>
  #include<linux/pinctrl/consumer.h>
+#include<linux/of_device.h>
 
  #include<asm/cacheflush.h>
 
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
  #endif
  };
 
+/*
+ * This function returns 1 if pdev isn't a device instatiated by dt, 0 if it
+ * could successfully get all information from dt or a negative errno.
+ */
+static int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (!np)
+		/* no device tree device */
+		return 1;
+
+	ret = of_alias_get_id(np, "serial");
+	if (ret<  0) {
+		dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
+		return ret;
+	}
+	s->port.line = ret;
+
+	return 0;
+}
+
  static int __devinit mxs_auart_probe(struct platform_device *pdev)
  {
  	struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
  		goto out;
  	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret>  0)
+		s->port.line = pdev->id<  0 ? 0 : pdev->id;
+	else if (ret<  0)
+		goto out_free;
+
  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
  	if (IS_ERR(pinctrl)) {
  		ret = PTR_ERR(pinctrl);
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
  	s->port.membase = ioremap(r->start, resource_size(r));
  	s->port.ops =&mxs_auart_ops;
  	s->port.iotype = UPIO_MEM;
-	s->port.line = pdev->id<  0 ? 0 : pdev->id;
  	s->port.fifosize = 16;
  	s->port.uartclk = clk_get_rate(s->clk);
  	s->port.type = PORT_IMX;
@@ -769,12 +799,19 @@ 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),
  	.driver = {
  		.name = "mxs-auart",
  		.owner = THIS_MODULE,
+		.of_match_table = mxs_auart_dt_ids,
  	},
  };
 
@@ -807,3 +844,4 @@ module_init(mxs_auart_init);
  module_exit(mxs_auart_exit);
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Freescale MXS application uart driver");
+MODULE_ALIAS("platform:mxs-auart");
reviewer
#17 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

Quoted 6 lines · Subodh Nijsure

If one were to try run console on one of the /dev/ttyAPP* ports, as is the case for hardware I am working with, console output wouldn't show up without the following diff:

Let me know if should send formal patch or we can include it as part of v5?

Please send a formal patch. Shawn has already applied my patch into his tree:
http://git.linaro.org/gitweb?p=people/shawnguo/linux-2.6.git;a=shortlog;h=refs/heads/mxs/for-next

#18 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

In reply to Subodh Nijsure
Quoted 6 lines · Subodh Nijsure

If one were to try run console on one of the /dev/ttyAPP* ports, as is the case for hardware I am working with, console output wouldn't show up without the following diff:

Let me know if should send formal patch or we can include it as part of v5?

Has this patch been applied?

Marc

Quoted 180 lines
drivers/tty/serial/mxs-auart.c +1 -2
index ca3d25e..2ced332 100644
@@ -761,7 +761,7 @@ static int __devinit mxs_auart_probe(struct
 platform_device *pdev)
 
        platform_set_drvdata(pdev, s);
 
-       auart_port[pdev->id] = s;
+       auart_port[s->port.line] = s;
 
        mxs_auart_reset(&s->port)
 
-Subodh
Quoted 151 lines · Fabio Estevam

Allow device tree probing.

---
Changes since v3:
- Remove unneeded mxs_auart_devtype
Changes since v2:
- Change compatible string
- Add aliases information in bindings doc
- Remove unneeded mxs_auart_probe_pdev function
- Remove "ifdef CONFIG_OF"
- Remove of_match_ptr wrapper
Changes since v1:
- Merged patches 3 and 5 from v1 into this one

  .../bindings/tty/serial/fsl-mxs-auart.txt          |   27 +++++++++++++
  drivers/tty/serial/mxs-auart.c                     |   40
+++++++++++++++++++-
  2 files changed, 66 insertions(+), 1 deletions(-)

create mode 100644
Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt

diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file mode 100644
index 0000000..2ee903f

Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +16 -0
@@ -0,0 +1,27 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,<soc>-auart". The supported SoCs include
+  imx23 and imx28.
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt numbers
+
+Example:
+auart0: serial at 8006a000 {
+    compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+    reg =<0x8006a000 0x2000>;
+    interrupts =<112 70 71>;
+};
+
+Note: Each auart port should have an alias correctly numbered in

"aliases"

Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt new file +11 -0
+node.
+
+Example:
+
+aliases {
+    serial0 =&auart0;
+    serial1 =&auart1;
+    serial2 =&auart2;
+    serial3 =&auart3;
+    serial4 =&auart4;
+};
drivers/tty/serial/mxs-auart.c +3 -0
index ec56d83..103087d 100644
@@ -33,6 +33,7 @@
  #include<linux/delay.h>
  #include<linux/io.h>
  #include<linux/pinctrl/consumer.h>
+#include<linux/of_device.h>
 
  #include<asm/cacheflush.h>
 
@@ -675,6 +676,30 @@ static struct uart_driver auart_driver = {
  #endif
  };
 
+/*
+ * This function returns 1 if pdev isn't a device instatiated by dt,

0 if it
+ * could successfully get all information from dt or a negative errno.
+ */

drivers/tty/serial/mxs-auart.c +26 -0
+static int serial_mxs_probe_dt(struct mxs_auart_port *s,
+        struct platform_device *pdev)
+{
+    struct device_node *np = pdev->dev.of_node;
+    int ret;
+
+    if (!np)
+        /* no device tree device */
+        return 1;
+
+    ret = of_alias_get_id(np, "serial");
+    if (ret<  0) {
+        dev_err(&pdev->dev, "failed to get alias id: %d\n", ret);
+        return ret;
+    }
+    s->port.line = ret;
+
+    return 0;
+}
+
  static int __devinit mxs_auart_probe(struct platform_device *pdev)
  {
      struct mxs_auart_port *s;
@@ -689,6 +714,12 @@ static int __devinit mxs_auart_probe(struct
 platform_device *pdev)
          goto out;
      }
 
+    ret = serial_mxs_probe_dt(s, pdev);
+    if (ret>  0)
+        s->port.line = pdev->id<  0 ? 0 : pdev->id;
+    else if (ret<  0)
+        goto out_free;
+
      pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
      if (IS_ERR(pinctrl)) {
          ret = PTR_ERR(pinctrl);
drivers/tty/serial/mxs-auart.c +0 -1
@@ -711,7 +742,6 @@ static int __devinit mxs_auart_probe(struct
 platform_device *pdev)
      s->port.membase = ioremap(r->start, resource_size(r));
      s->port.ops =&mxs_auart_ops;
      s->port.iotype = UPIO_MEM;
-    s->port.line = pdev->id<  0 ? 0 : pdev->id;
      s->port.fifosize = 16;
      s->port.uartclk = clk_get_rate(s->clk);
      s->port.type = PORT_IMX;
drivers/tty/serial/mxs-auart.c +7 -0
@@ -769,12 +799,19 @@ 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),
      .driver = {
          .name = "mxs-auart",
          .owner = THIS_MODULE,
+        .of_match_table = mxs_auart_dt_ids,
      },
  };

drivers/tty/serial/mxs-auart.c module_init(mxs_auart_init); · line 847

Quoted 4 lines
drivers/tty/serial/mxs-auart.c +1 -0
@@ -807,3 +844,4 @@ module_init(mxs_auart_init);
  module_exit(mxs_auart_exit);
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Freescale MXS application uart driver");
+MODULE_ALIAS("platform:mxs-auart");

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120713/6c8b519f/attachment.sig>
#19 lore raw

PATCH v4 2/2 serial: mxs-auart: Allow device tree probing

Quoted 9 lines · Marc Kleine-Budde
Quoted 6 lines · Subodh Nijsure

If one were to try run console on one of the /dev/ttyAPP* ports, as is the case for hardware I am working with, console output wouldn't show up without the following diff:

Let me know if should send formal patch or we can include it as part of v5?

Has this patch been applied?

Yes. [1]

Marc

[1]
http://git.linaro.org/gitweb?p=people/shawnguo/linux-2.6.git;a=commit;h=1ea6607d4cdc917987e7e6cfaafc4a630d97a297

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120713/211eb46e/attachment.sig>