All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support
@ 2012-06-15 11:32 Fabio Estevam
  2012-06-15 11:32   ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Fabio Estevam <fabio.estevam@freescale.com>

Add auart0 and auart3 support.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
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(-)

diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts
index ee520a5..4353f48 100644
--- a/arch/arm/boot/dts/imx28-evk.dts
+++ b/arch/arm/boot/dts/imx28-evk.dts
@@ -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";
+			};
 		};
 	};
 
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 4634cb8..f26e0d6 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -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,mxs-auart";
 				reg = <0x8006a000 0x2000>;
 				interrupts = <112 70 71>;
 				status = "disabled";
 			};
 
 			auart1: serial at 8006c000 {
+				compatible = "fsl,mxs-auart";
 				reg = <0x8006c000 0x2000>;
 				interrupts = <113 72 73>;
 				status = "disabled";
 			};
 
 			auart2: serial at 8006e000 {
+				compatible = "fsl,mxs-auart";
 				reg = <0x8006e000 0x2000>;
 				interrupts = <114 74 75>;
 				status = "disabled";
 			};
 
 			auart3: serial at 80070000 {
+				compatible = "fsl,mxs-auart";
 				reg = <0x80070000 0x2000>;
 				interrupts = <115 76 77>;
 				status = "disabled";
 			};
 
 			auart4: serial at 80072000 {
+				compatible = "fsl,mxs-auart";
 				reg = <0x80072000 0x2000>;
 				interrupts = <116 78 79>;
 				status = "disabled";
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
  2012-06-15 11:32 [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Fabio Estevam
@ 2012-06-15 11:32   ` Fabio Estevam
  2012-06-15 11:32 ` [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default Fabio Estevam
  2012-06-15 11:47 ` [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Marek Vasut
  2 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 11:32 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: shawn.guo, kernel, marex, matt, snijsure, rob.herring,
	Fabio Estevam, Grant Likely, Alan Cox, linux-serial

From: Fabio Estevam <fabio.estevam@freescale.com>

Allow device tree probing.

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: <linux-serial@vger.kernel.org>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Merged patches 3 and 5 from v1 into this one
 .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
 drivers/tty/serial/mxs-auart.c                     |   55 +++++++++++++++++++-
 2 files changed, 67 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..1b28b1c
--- /dev/null
+++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
@@ -0,0 +1,13 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,mxs-uart"
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt
+
+Example:
+auart0: serial@8006a000 {
+	compatible = "fsl,mxs-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index ec56d83..21e2ce7 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -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,44 @@ static struct uart_driver auart_driver = {
 #endif
 };
 
+#ifdef CONFIG_OF
+/*
+ * 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;
+}
+#else
+static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	return 1;
+}
+#endif
+
+static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	s->port.line = pdev->id < 0 ? 0 : pdev->id;
+}
+
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
 	struct mxs_auart_port *s;
@@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret > 0)
+		mxs_auart_probe_pdev(s, pdev);
+	else if (ret < 0) {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
@@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static struct of_device_id mxs_auart_dt_ids[] = {
+	{.compatible = "fsl,mxs-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 = of_match_ptr(mxs_auart_dt_ids),
 	},
 };
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
@ 2012-06-15 11:32   ` Fabio Estevam
  0 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Fabio Estevam <fabio.estevam@freescale.com>

Allow device tree probing.

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: <linux-serial@vger.kernel.org>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Merged patches 3 and 5 from v1 into this one
 .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
 drivers/tty/serial/mxs-auart.c                     |   55 +++++++++++++++++++-
 2 files changed, 67 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..1b28b1c
--- /dev/null
+++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
@@ -0,0 +1,13 @@
+* Freescale MXS Application UART (AUART)
+
+Required properties:
+- compatible : Should be "fsl,mxs-uart"
+- reg : Address and length of the register set for the device
+- interrupts : Should contain the auart interrupt
+
+Example:
+auart0: serial at 8006a000 {
+	compatible = "fsl,mxs-auart";
+	reg = <0x8006a000 0x2000>;
+	interrupts = <112 70 71>;
+};
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index ec56d83..21e2ce7 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -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,44 @@ static struct uart_driver auart_driver = {
 #endif
 };
 
+#ifdef CONFIG_OF
+/*
+ * 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;
+}
+#else
+static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	return 1;
+}
+#endif
+
+static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
+		struct platform_device *pdev)
+{
+	s->port.line = pdev->id < 0 ? 0 : pdev->id;
+}
+
 static int __devinit mxs_auart_probe(struct platform_device *pdev)
 {
 	struct mxs_auart_port *s;
@@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
 		goto out;
 	}
 
+	ret = serial_mxs_probe_dt(s, pdev);
+	if (ret > 0)
+		mxs_auart_probe_pdev(s, pdev);
+	else if (ret < 0) {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
 		ret = PTR_ERR(pinctrl);
@@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static struct of_device_id mxs_auart_dt_ids[] = {
+	{.compatible = "fsl,mxs-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 = of_match_ptr(mxs_auart_dt_ids),
 	},
 };
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 11:32 [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Fabio Estevam
  2012-06-15 11:32   ` Fabio Estevam
@ 2012-06-15 11:32 ` Fabio Estevam
  2012-06-15 11:49   ` Marek Vasut
  2012-06-15 12:33   ` Shawn Guo
  2012-06-15 11:47 ` [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Marek Vasut
  2 siblings, 2 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Fabio Estevam <fabio.estevam@freescale.com>

Let AUART driver be built by default.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- No changes
 arch/arm/configs/mxs_defconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig
index 5406c23..66b76c1 100644
--- a/arch/arm/configs/mxs_defconfig
+++ b/arch/arm/configs/mxs_defconfig
@@ -77,6 +77,7 @@ CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
 # CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
+CONFIG_SERIAL_MXS_AUART=y
 # CONFIG_HW_RANDOM is not set
 CONFIG_I2C=y
 # CONFIG_I2C_COMPAT is not set
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support
  2012-06-15 11:32 [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Fabio Estevam
  2012-06-15 11:32   ` Fabio Estevam
  2012-06-15 11:32 ` [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default Fabio Estevam
@ 2012-06-15 11:47 ` Marek Vasut
  2 siblings, 0 replies; 18+ messages in thread
From: Marek Vasut @ 2012-06-15 11:47 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Fabio Estevam,

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Add auart0 and auart3 support.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Reviewed-by: Marek Vasut <marex@denx.de>

> ---
> 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(-)
> 
> diff --git a/arch/arm/boot/dts/imx28-evk.dts
> b/arch/arm/boot/dts/imx28-evk.dts index ee520a5..4353f48 100644
> --- a/arch/arm/boot/dts/imx28-evk.dts
> +++ b/arch/arm/boot/dts/imx28-evk.dts
> @@ -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";
> +			};
>  		};
>  	};
> 
> diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
> index 4634cb8..f26e0d6 100644
> --- a/arch/arm/boot/dts/imx28.dtsi
> +++ b/arch/arm/boot/dts/imx28.dtsi
> @@ -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 at 8006a000 {
> +				compatible = "fsl,mxs-auart";
>  				reg = <0x8006a000 0x2000>;
>  				interrupts = <112 70 71>;
>  				status = "disabled";
>  			};
> 
>  			auart1: serial at 8006c000 {
> +				compatible = "fsl,mxs-auart";
>  				reg = <0x8006c000 0x2000>;
>  				interrupts = <113 72 73>;
>  				status = "disabled";
>  			};
> 
>  			auart2: serial at 8006e000 {
> +				compatible = "fsl,mxs-auart";
>  				reg = <0x8006e000 0x2000>;
>  				interrupts = <114 74 75>;
>  				status = "disabled";
>  			};
> 
>  			auart3: serial at 80070000 {
> +				compatible = "fsl,mxs-auart";
>  				reg = <0x80070000 0x2000>;
>  				interrupts = <115 76 77>;
>  				status = "disabled";
>  			};
> 
>  			auart4: serial at 80072000 {
> +				compatible = "fsl,mxs-auart";
>  				reg = <0x80072000 0x2000>;
>  				interrupts = <116 78 79>;
>  				status = "disabled";

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
  2012-06-15 11:32   ` Fabio Estevam
@ 2012-06-15 11:49     ` Marek Vasut
  -1 siblings, 0 replies; 18+ messages in thread
From: Marek Vasut @ 2012-06-15 11:49 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: linux-arm-kernel, shawn.guo, kernel, matt, snijsure, rob.herring,
	Fabio Estevam, Grant Likely, Alan Cox, linux-serial

Dear Fabio Estevam,

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Allow device tree probing.
> 
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Merged patches 3 and 5 from v1 into this one
>  .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
>  drivers/tty/serial/mxs-auart.c                     |   55
> +++++++++++++++++++- 2 files changed, 67 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..1b28b1c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
> @@ -0,0 +1,13 @@
> +* Freescale MXS Application UART (AUART)
> +
> +Required properties:
> +- compatible : Should be "fsl,mxs-uart"
> +- reg : Address and length of the register set for the device
> +- interrupts : Should contain the auart interrupt
> +
> +Example:
> +auart0: serial@8006a000 {
> +	compatible = "fsl,mxs-auart";
> +	reg = <0x8006a000 0x2000>;
> +	interrupts = <112 70 71>;
> +};
> diff --git a/drivers/tty/serial/mxs-auart.c
> b/drivers/tty/serial/mxs-auart.c index ec56d83..21e2ce7 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -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,44 @@ static struct uart_driver auart_driver = {
>  #endif
>  };
> 
> +#ifdef CONFIG_OF

Isn't CONFIG_OF always enabled?

> +/*
> + * 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;
> +}
> +#else
> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	return 1;
> +}
> +#endif

So drop this whole ifdef stuff ...

> +
> +static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	s->port.line = pdev->id < 0 ? 0 : pdev->id;
> +}
> +
>  static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  {
>  	struct mxs_auart_port *s;
> @@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct
> platform_device *pdev) goto out;
>  	}
> 
> +	ret = serial_mxs_probe_dt(s, pdev);
> +	if (ret > 0)
> +		mxs_auart_probe_pdev(s, pdev);
> +	else if (ret < 0) {
> +		ret = -EINVAL;
> +		goto out_free;
> +	}
> +
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> @@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct
> platform_device *pdev) return 0;
>  }
> 
> +static struct of_device_id mxs_auart_dt_ids[] = {
> +	{.compatible = "fsl,mxs-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 = of_match_ptr(mxs_auart_dt_ids),
>  	},
>  };

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
@ 2012-06-15 11:49     ` Marek Vasut
  0 siblings, 0 replies; 18+ messages in thread
From: Marek Vasut @ 2012-06-15 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Fabio Estevam,

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Allow device tree probing.
> 
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Merged patches 3 and 5 from v1 into this one
>  .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
>  drivers/tty/serial/mxs-auart.c                     |   55
> +++++++++++++++++++- 2 files changed, 67 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..1b28b1c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
> @@ -0,0 +1,13 @@
> +* Freescale MXS Application UART (AUART)
> +
> +Required properties:
> +- compatible : Should be "fsl,mxs-uart"
> +- reg : Address and length of the register set for the device
> +- interrupts : Should contain the auart interrupt
> +
> +Example:
> +auart0: serial at 8006a000 {
> +	compatible = "fsl,mxs-auart";
> +	reg = <0x8006a000 0x2000>;
> +	interrupts = <112 70 71>;
> +};
> diff --git a/drivers/tty/serial/mxs-auart.c
> b/drivers/tty/serial/mxs-auart.c index ec56d83..21e2ce7 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -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,44 @@ static struct uart_driver auart_driver = {
>  #endif
>  };
> 
> +#ifdef CONFIG_OF

Isn't CONFIG_OF always enabled?

> +/*
> + * 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;
> +}
> +#else
> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	return 1;
> +}
> +#endif

So drop this whole ifdef stuff ...

> +
> +static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	s->port.line = pdev->id < 0 ? 0 : pdev->id;
> +}
> +
>  static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  {
>  	struct mxs_auart_port *s;
> @@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct
> platform_device *pdev) goto out;
>  	}
> 
> +	ret = serial_mxs_probe_dt(s, pdev);
> +	if (ret > 0)
> +		mxs_auart_probe_pdev(s, pdev);
> +	else if (ret < 0) {
> +		ret = -EINVAL;
> +		goto out_free;
> +	}
> +
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> @@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct
> platform_device *pdev) return 0;
>  }
> 
> +static struct of_device_id mxs_auart_dt_ids[] = {
> +	{.compatible = "fsl,mxs-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 = of_match_ptr(mxs_auart_dt_ids),
>  	},
>  };

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 11:32 ` [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default Fabio Estevam
@ 2012-06-15 11:49   ` Marek Vasut
  2012-06-15 12:33   ` Shawn Guo
  1 sibling, 0 replies; 18+ messages in thread
From: Marek Vasut @ 2012-06-15 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Fabio Estevam,

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Let AUART driver be built by default.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Not much to review, but ...

Reviewed-by: Marek Vasut <marex@denx.de>

> ---
> Changes since v1:
> - No changes
>  arch/arm/configs/mxs_defconfig |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/configs/mxs_defconfig
> b/arch/arm/configs/mxs_defconfig index 5406c23..66b76c1 100644
> --- a/arch/arm/configs/mxs_defconfig
> +++ b/arch/arm/configs/mxs_defconfig
> @@ -77,6 +77,7 @@ CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
>  # CONFIG_DEVKMEM is not set
>  CONFIG_SERIAL_AMBA_PL011=y
>  CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
> +CONFIG_SERIAL_MXS_AUART=y
>  # CONFIG_HW_RANDOM is not set
>  CONFIG_I2C=y
>  # CONFIG_I2C_COMPAT is not set

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
  2012-06-15 11:49     ` Marek Vasut
@ 2012-06-15 12:01       ` Fabio Estevam
  -1 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 12:01 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-arm-kernel, shawn.guo, kernel, matt, snijsure, rob.herring,
	Fabio Estevam, Grant Likely, Alan Cox, linux-serial

Hi Marek,

On Fri, Jun 15, 2012 at 8:49 AM, Marek Vasut <marex@denx.de> wrote:

>> +#ifdef CONFIG_OF
>
> Isn't CONFIG_OF always enabled?

Not always necessarily. You can boot mx23/mx28 via non-DT kernel.

The serial imx driver also does the same thing about this.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
@ 2012-06-15 12:01       ` Fabio Estevam
  0 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 12:01 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Marek,

On Fri, Jun 15, 2012 at 8:49 AM, Marek Vasut <marex@denx.de> wrote:

>> +#ifdef CONFIG_OF
>
> Isn't CONFIG_OF always enabled?

Not always necessarily. You can boot mx23/mx28 via non-DT kernel.

The serial imx driver also does the same thing about this.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
  2012-06-15 11:49     ` Marek Vasut
@ 2012-06-15 12:13       ` Fabio Estevam
  -1 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 12:13 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-arm-kernel, shawn.guo, kernel, matt, snijsure, rob.herring,
	Fabio Estevam, Grant Likely, Alan Cox, linux-serial

On Fri, Jun 15, 2012 at 8:49 AM, Marek Vasut <marex@denx.de> wrote:

>> +/*
>> + * 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;
>> +}
>> +#else
>> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
>> +             struct platform_device *pdev)
>> +{
>> +     return 1;
>> +}
>> +#endif
>
> So drop this whole ifdef stuff ...

Yes, you are right. We can safely remove it. Just tested and it worked fine.

I will drop the ifdef in the next revision.

Thanks,

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
@ 2012-06-15 12:13       ` Fabio Estevam
  0 siblings, 0 replies; 18+ messages in thread
From: Fabio Estevam @ 2012-06-15 12:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2012 at 8:49 AM, Marek Vasut <marex@denx.de> wrote:

>> +/*
>> + * 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;
>> +}
>> +#else
>> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
>> + ? ? ? ? ? ? struct platform_device *pdev)
>> +{
>> + ? ? return 1;
>> +}
>> +#endif
>
> So drop this whole ifdef stuff ...

Yes, you are right. We can safely remove it. Just tested and it worked fine.

I will drop the ifdef in the next revision.

Thanks,

Fabio Estevam

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 11:32 ` [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default Fabio Estevam
  2012-06-15 11:49   ` Marek Vasut
@ 2012-06-15 12:33   ` Shawn Guo
  2012-06-15 12:50     ` Subodh Nijsure
  1 sibling, 1 reply; 18+ messages in thread
From: Shawn Guo @ 2012-06-15 12:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2012 at 08:32:30AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Let AUART driver be built by default.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Applied, thanks.

Regards,
Shawn

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 12:33   ` Shawn Guo
@ 2012-06-15 12:50     ` Subodh Nijsure
  2012-06-15 12:53       ` Marek Vasut
  0 siblings, 1 reply; 18+ messages in thread
From: Subodh Nijsure @ 2012-06-15 12:50 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/15/2012 05:33 AM, Shawn Guo wrote:
> On Fri, Jun 15, 2012 at 08:32:30AM -0300, Fabio Estevam wrote:
>> From: Fabio Estevam<fabio.estevam@freescale.com>
>>
>> Let AUART driver be built by default.
>>
>> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
> Applied, thanks.
Applied to what? arm-soc/for-next ?

/Subodh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 12:50     ` Subodh Nijsure
@ 2012-06-15 12:53       ` Marek Vasut
  2012-06-15 13:13         ` Shawn Guo
  0 siblings, 1 reply; 18+ messages in thread
From: Marek Vasut @ 2012-06-15 12:53 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Subodh Nijsure,

> On 06/15/2012 05:33 AM, Shawn Guo wrote:
> > On Fri, Jun 15, 2012 at 08:32:30AM -0300, Fabio Estevam wrote:
> >> From: Fabio Estevam<fabio.estevam@freescale.com>
> >> 
> >> Let AUART driver be built by default.
> >> 
> >> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
> > 
> > Applied, thanks.
> 
> Applied to what? arm-soc/for-next ?

git://git.linaro.org/people/shawnguo/linux-2.6.git

OR (probably later)

git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

> 
> /Subodh

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
  2012-06-15 11:32   ` Fabio Estevam
@ 2012-06-15 13:10     ` Shawn Guo
  -1 siblings, 0 replies; 18+ messages in thread
From: Shawn Guo @ 2012-06-15 13:10 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: linux-arm-kernel, kernel, marex, matt, snijsure, rob.herring,
	Fabio Estevam, Grant Likely, Alan Cox, linux-serial

On Fri, Jun 15, 2012 at 08:32:29AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Allow device tree probing.
> 
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Merged patches 3 and 5 from v1 into this one
>  .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
>  drivers/tty/serial/mxs-auart.c                     |   55 +++++++++++++++++++-
>  2 files changed, 67 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..1b28b1c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
> @@ -0,0 +1,13 @@
> +* Freescale MXS Application UART (AUART)
> +
> +Required properties:
> +- compatible : Should be "fsl,mxs-uart"

The compatible property is to specify the compatibility between
different versions of the hardware block.  One general way to do that
is using SoC name to specific the version.  We know the auart block
works for both imx23 and imx28 without any tweaking in the driver,
so we should have something like the following to tell that the auart
block used on imx28 is completely compatible with the one on imx23.

static struct of_device_id mxs_auart_dt_ids[] = {
	{ .compatible = "fsl,imx23-auart", },
	{ /* sentinel */ }
};

imx23.dtsi:

auart0: serial@8006a000 {
	compatible = "fsl,imx23-auart";
	...
};

imx28.dtsi:

auart0: serial@8006a000 {
	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
	...
};

> +- reg : Address and length of the register set for the device
> +- interrupts : Should contain the auart interrupt

The binding relies on alias to work with the driver, so we may need to
note it here.  See Documentation/devicetree/bindings/gpio/gpio-mxs.txt
for example.

> +
> +Example:
> +auart0: serial@8006a000 {
> +	compatible = "fsl,mxs-auart";
> +	reg = <0x8006a000 0x2000>;
> +	interrupts = <112 70 71>;
> +};
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index ec56d83..21e2ce7 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -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,44 @@ static struct uart_driver auart_driver = {
>  #endif
>  };
>  
> +#ifdef CONFIG_OF
> +/*
> + * 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;
> +}
> +#else
> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	return 1;
> +}
> +#endif
> +
> +static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	s->port.line = pdev->id < 0 ? 0 : pdev->id;
> +}
> +
Do we really need such a simple function?

>  static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  {
>  	struct mxs_auart_port *s;
> @@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  		goto out;
>  	}
>  
> +	ret = serial_mxs_probe_dt(s, pdev);
> +	if (ret > 0)
> +		mxs_auart_probe_pdev(s, pdev);
> +	else if (ret < 0) {
> +		ret = -EINVAL;

Why changing the error code here?

> +		goto out_free;
> +	}
> +
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> @@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static struct of_device_id mxs_auart_dt_ids[] = {
> +	{.compatible = "fsl,mxs-auart", },

Nit: put a space after "{".

> +	{ /* 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 = of_match_ptr(mxs_auart_dt_ids),

As Marek already pointed out, we have ARCH_MXS select USE_OF to have
CONFIG_OF always enabled, the of_match_ptr wrapper is not really needed
here.

>  	},
>  };
>  
> -- 
> 1.7.1
> 

-- 
Regards,
Shawn


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing
@ 2012-06-15 13:10     ` Shawn Guo
  0 siblings, 0 replies; 18+ messages in thread
From: Shawn Guo @ 2012-06-15 13:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2012 at 08:32:29AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Allow device tree probing.
> 
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: <linux-serial@vger.kernel.org>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Merged patches 3 and 5 from v1 into this one
>  .../bindings/tty/serial/fsl-mxs-auart.txt          |   13 +++++
>  drivers/tty/serial/mxs-auart.c                     |   55 +++++++++++++++++++-
>  2 files changed, 67 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..1b28b1c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
> @@ -0,0 +1,13 @@
> +* Freescale MXS Application UART (AUART)
> +
> +Required properties:
> +- compatible : Should be "fsl,mxs-uart"

The compatible property is to specify the compatibility between
different versions of the hardware block.  One general way to do that
is using SoC name to specific the version.  We know the auart block
works for both imx23 and imx28 without any tweaking in the driver,
so we should have something like the following to tell that the auart
block used on imx28 is completely compatible with the one on imx23.

static struct of_device_id mxs_auart_dt_ids[] = {
	{ .compatible = "fsl,imx23-auart", },
	{ /* sentinel */ }
};

imx23.dtsi:

auart0: serial at 8006a000 {
	compatible = "fsl,imx23-auart";
	...
};

imx28.dtsi:

auart0: serial at 8006a000 {
	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
	...
};

> +- reg : Address and length of the register set for the device
> +- interrupts : Should contain the auart interrupt

The binding relies on alias to work with the driver, so we may need to
note it here.  See Documentation/devicetree/bindings/gpio/gpio-mxs.txt
for example.

> +
> +Example:
> +auart0: serial at 8006a000 {
> +	compatible = "fsl,mxs-auart";
> +	reg = <0x8006a000 0x2000>;
> +	interrupts = <112 70 71>;
> +};
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index ec56d83..21e2ce7 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -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,44 @@ static struct uart_driver auart_driver = {
>  #endif
>  };
>  
> +#ifdef CONFIG_OF
> +/*
> + * 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;
> +}
> +#else
> +static inline int serial_mxs_probe_dt(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	return 1;
> +}
> +#endif
> +
> +static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
> +		struct platform_device *pdev)
> +{
> +	s->port.line = pdev->id < 0 ? 0 : pdev->id;
> +}
> +
Do we really need such a simple function?

>  static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  {
>  	struct mxs_auart_port *s;
> @@ -689,6 +728,14 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
>  		goto out;
>  	}
>  
> +	ret = serial_mxs_probe_dt(s, pdev);
> +	if (ret > 0)
> +		mxs_auart_probe_pdev(s, pdev);
> +	else if (ret < 0) {
> +		ret = -EINVAL;

Why changing the error code here?

> +		goto out_free;
> +	}
> +
>  	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>  	if (IS_ERR(pinctrl)) {
>  		ret = PTR_ERR(pinctrl);
> @@ -711,7 +758,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 +815,19 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static struct of_device_id mxs_auart_dt_ids[] = {
> +	{.compatible = "fsl,mxs-auart", },

Nit: put a space after "{".

> +	{ /* 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 = of_match_ptr(mxs_auart_dt_ids),

As Marek already pointed out, we have ARCH_MXS select USE_OF to have
CONFIG_OF always enabled, the of_match_ptr wrapper is not really needed
here.

>  	},
>  };
>  
> -- 
> 1.7.1
> 

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default
  2012-06-15 12:53       ` Marek Vasut
@ 2012-06-15 13:13         ` Shawn Guo
  0 siblings, 0 replies; 18+ messages in thread
From: Shawn Guo @ 2012-06-15 13:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2012 at 02:53:11PM +0200, Marek Vasut wrote:
> Dear Subodh Nijsure,
> 
> > On 06/15/2012 05:33 AM, Shawn Guo wrote:
> > > On Fri, Jun 15, 2012 at 08:32:30AM -0300, Fabio Estevam wrote:
> > >> From: Fabio Estevam<fabio.estevam@freescale.com>
> > >> 
> > >> Let AUART driver be built by default.
> > >> 
> > >> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
> > > 
> > > Applied, thanks.
> > 
> > Applied to what? arm-soc/for-next ?
> 
> git://git.linaro.org/people/shawnguo/linux-2.6.git
> 
Yes, I collect patches there, and will send them to arm-soc at some
point.

> OR (probably later)
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
> 
I do not have my branch included into linux-next and rely on
arm-soc/for-next to have the patches exposed on linux-next.

-- 
Regards,
Shawn

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-06-15 13:13 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15 11:32 [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Fabio Estevam
2012-06-15 11:32 ` [PATCH v2 2/3] serial: mxs-auart: Allow device tree probing Fabio Estevam
2012-06-15 11:32   ` Fabio Estevam
2012-06-15 11:49   ` Marek Vasut
2012-06-15 11:49     ` Marek Vasut
2012-06-15 12:01     ` Fabio Estevam
2012-06-15 12:01       ` Fabio Estevam
2012-06-15 12:13     ` Fabio Estevam
2012-06-15 12:13       ` Fabio Estevam
2012-06-15 13:10   ` Shawn Guo
2012-06-15 13:10     ` Shawn Guo
2012-06-15 11:32 ` [PATCH v2 3/3] ARM: mxs_defconfig: Let AUART driver be built by default Fabio Estevam
2012-06-15 11:49   ` Marek Vasut
2012-06-15 12:33   ` Shawn Guo
2012-06-15 12:50     ` Subodh Nijsure
2012-06-15 12:53       ` Marek Vasut
2012-06-15 13:13         ` Shawn Guo
2012-06-15 11:47 ` [PATCH v2 1/3] ARM: dts: mx28evk: Add auart0 and auart3 support Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.