From patchwork Thu Jun 14 16:49:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Burtch X-Patchwork-Id: 164964 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8519E1007D1 for ; Fri, 15 Jun 2012 02:54:50 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SfDEY-0005tt-N3; Thu, 14 Jun 2012 16:49:22 +0000 Received: from mail.grid-net.com ([97.65.115.2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SfDEW-0005t3-8Y for linux-arm-kernel@lists.infradead.org; Thu, 14 Jun 2012 16:49:21 +0000 Received: from MX2.grid-net.com ([::1]) by mx2.grid-net.com ([::1]) with mapi id 14.02.0283.003; Thu, 14 Jun 2012 09:49:18 -0700 From: Matt Burtch To: Fabio Estevam , Subodh Nijsure Subject: RE: MXS getting AUART to work with DT. Thread-Topic: MXS getting AUART to work with DT. Thread-Index: AQHNSefVNG8KwVS5f0CAjFNPnqu+Lpb5tTWAgABRHv0= Date: Thu, 14 Jun 2012 16:49:18 +0000 Message-ID: <2CC96C7FBBE82548A0B1766B8D8348AD9C169E@mx2.grid-net.com> References: <4FD7EFFC.8010204@grid-net.com> <4FD96B3E.6080806@grid-net.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.10.0.168] MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: =?Windows-1252?Q?Marek_Va=9Aut?= , Shawn Guo , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Here is the patch I put together to get the AUART recognized with the dt. I'm pretty new to dt development, so this was a quick first pass. I'm sure there are more proper ways to get the device id and pass literals between the dt and probe function...but this works for now. Regards, -Matt Burtch diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi index fd67809..0b72bf6 100644 --- a/arch/arm/boot/dts/imx28.dtsi +++ b/arch/arm/boot/dts/imx28.dtsi @@ -440,6 +448,7 @@ reg = <0x8006a000 0x2000>; interrupts = <112 70 71>; status = "disabled"; + id = "0"; }; auart1: serial@8006c000 { @@ -447,6 +456,7 @@ reg = <0x8006c000 0x2000>; interrupts = <113 72 73>; status = "disabled"; + id = "1"; }; auart2: serial@8006e000 { @@ -454,6 +464,7 @@ reg = <0x8006e000 0x2000>; interrupts = <114 74 75>; status = "disabled"; + id = "2"; }; auart3: serial@80070000 { @@ -461,6 +472,7 @@ reg = <0x80070000 0x2000>; interrupts = <115 76 77>; status = "disabled"; + id = "3"; }; auart4: serial@80072000 { @@ -468,6 +480,7 @@ reg = <0x80072000 0x2000>; interrupts = <116 78 79>; status = "disabled"; + id = "4"; }; duart: serial@80074000 { diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index aaae433..315aebd 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #include @@ -675,6 +678,50 @@ static struct uart_driver auart_driver = { #endif }; +static struct of_device_id mxs_auart_dt_ids[] = { + { .compatible = "fsl,imx28-auart", }, + { /* sentinel */ } +}; + + +static int mxs_auart_probe_dt(struct mxs_auart_port *s, + struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *of_id = + of_match_device(mxs_auart_dt_ids, &pdev->dev); + int *ret; + int copy; + + if (!np) + /* no device tree device */ + return 1; + + ret = of_get_property(np, "id", NULL); + if (ret == NULL) { + dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); + return ret; + } + + copy = *ret - 48; + s->port.line = copy; + + return 0; +} + +static void mxs_auart_probe_pdev(struct mxs_auart_port *s, + struct platform_device *pdev) +{ + struct imxuart_platform_data *pdata = pdev->dev.platform_data; + + s->port.line = pdev->id < 0 ? 0 : pdev->id; + + if (!pdata) + return; +} + static int __devinit mxs_auart_probe(struct platform_device *pdev) { struct mxs_auart_port *s; @@ -688,6 +735,15 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev) ret = -ENOMEM; goto out; } + + ret = mxs_auart_probe_dt(s, pdev); + if (ret > 0) + mxs_auart_probe_pdev(s, pdev); + else if (ret < 0) { + ret - EINVAL; + goto out; + } + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); if (IS_ERR(pinctrl)) { @@ -711,7 +767,7 @@ 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;