From: Marek Vasut <marex@denx.de>
To: Fabio Estevam <fabio.estevam@freescale.com>
Cc: linux-arm-kernel@lists.infradead.org, shawn.guo@linaro.org,
kernel@pengutronix.de, matt@grid-net.com, snijsure@grid-net.com,
rob.herring@calxeda.com, Grant Likely <grant.likely@secretlab.ca>,
Alan Cox <alan@linux.intel.com>,
linux-serial@vger.kernel.org
Subject: Re: [PATCH v3 2/2] serial: mxs-auart: Allow device tree probing
Date: Fri, 15 Jun 2012 17:48:22 +0200 [thread overview]
Message-ID: <201206151748.22324.marex@denx.de> (raw)
In-Reply-To: <1339774557-23588-2-git-send-email-fabio.estevam@freescale.com>
Dear Fabio Estevam,
> 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>
Acked-by: Marek Vasut <marex@denx.de>
> ---
> 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
>
> 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
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/fsl-mxs-auart.txt
> @@ -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;
> +};
> diff --git a/drivers/tty/serial/mxs-auart.c
> b/drivers/tty/serial/mxs-auart.c index ec56d83..87bbe9c 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,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,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)
> @@ -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
next prev parent reply other threads:[~2012-06-15 15:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1339774557-23588-1-git-send-email-fabio.estevam@freescale.com>
2012-06-15 15:35 ` [PATCH v3 2/2] serial: mxs-auart: Allow device tree probing Fabio Estevam
2012-06-15 15:48 ` Marek Vasut [this message]
2012-06-15 16:06 ` Shawn Guo
2012-06-15 16:11 ` Fabio Estevam
2012-06-15 16:16 ` Marek Vasut
2012-06-15 16:18 ` Fabio Estevam
2012-06-15 17:00 ` Marek Vasut
2012-06-16 2:01 ` Shawn Guo
2012-06-16 1:59 ` Shawn Guo
2012-06-18 13:06 ` [PATCH v4 " Fabio Estevam
2012-06-18 13:33 ` Shawn Guo
2012-06-18 13:36 ` Marek Vasut
2012-06-18 15:25 ` Greg Kroah-Hartman
2012-06-18 20:42 ` Subodh Nijsure
2012-06-18 20:50 ` Fabio Estevam
2012-07-13 10:33 ` Marc Kleine-Budde
2012-07-13 10:35 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201206151748.22324.marex@denx.de \
--to=marex@denx.de \
--cc=alan@linux.intel.com \
--cc=fabio.estevam@freescale.com \
--cc=grant.likely@secretlab.ca \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=matt@grid-net.com \
--cc=rob.herring@calxeda.com \
--cc=shawn.guo@linaro.org \
--cc=snijsure@grid-net.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).