From patchwork Wed Oct 31 19:28:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Cartwright X-Patchwork-Id: 1717471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 48EBA3FCDF for ; Thu, 8 Nov 2012 19:57:18 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TWYBk-0004XO-4Z; Thu, 08 Nov 2012 19:54:56 +0000 Received: from mailserver5.natinst.com ([130.164.80.5] helo=spamkiller05.natinst.com) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TWYB1-0004PM-Ax for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2012 19:54:14 +0000 Received: from mailserv59-us.natinst.com (nb-hsrp-1338.natinst.com [130.164.19.133]) by spamkiller05.natinst.com (8.14.5/8.14.5) with ESMTP id qA8Js7R5018269; Thu, 8 Nov 2012 13:54:07 -0600 Received: from beefymiracle.amer.corp.natinst.com ([130.164.14.197]) by mailserv59-us.natinst.com (Lotus Domino Release 8.5.3FP2 HF169) with ESMTP id 2012110813540731-1110007 ; Thu, 8 Nov 2012 13:54:07 -0600 Received: by beefymiracle.amer.corp.natinst.com (Postfix, from userid 1000) id 4BDA96032E; Thu, 8 Nov 2012 13:54:17 -0600 (CST) Message-Id: <80ce7f830bd3fd131da4aff9e33d6c0dc2c359a8.1352400580.git.josh.cartwright@ni.com> In-Reply-To: References: From: Josh Cartwright Date: Wed, 31 Oct 2012 13:28:49 -0600 Subject: [PATCH v2 4/5] serial: xilinx_uartps: get clock rate info from dts To: Alan Cox , Grant Likely , Rob Herring X-MIMETrack: Itemize by SMTP Server on MailServ59-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 11/08/2012 01:54:07 PM, Serialize by Router on MailServ59-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 11/08/2012 01:54:07 PM, Serialize complete at 11/08/2012 01:54:07 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.9.8185, 1.0.431, 0.0.0000 definitions=2012-11-08_04:2012-11-08, 2012-11-08, 1970-01-01 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121108_145411_710461_9919119E X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: 1.5 (+) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (1.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.4 DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Michal Simek , linux-kernel@vger.kernel.org, arm@kernel.org, linux-serial@vger.kernel.org, John Linn , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support for specifying clock information for the uart clk via the device tree. This eliminates the need to hardcode rates in the device tree. Signed-off-by: Josh Cartwright --- arch/arm/boot/dts/zynq-7000.dtsi | 4 ++-- drivers/tty/serial/xilinx_uartps.c | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi index bb3085c..c975c2d 100644 --- a/arch/arm/boot/dts/zynq-7000.dtsi +++ b/arch/arm/boot/dts/zynq-7000.dtsi @@ -44,14 +44,14 @@ compatible = "xlnx,xuartps"; reg = <0xE0000000 0x1000>; interrupts = <0 27 4>; - clock = <50000000>; + clocks = <&uart_clk 0>; }; uart1: uart@e0001000 { compatible = "xlnx,xuartps"; reg = <0xE0001000 0x1000>; interrupts = <0 50 4>; - clock = <50000000>; + clocks = <&uart_clk 1>; }; slcr: slcr@f8000000 { diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 23efe17..adfecbc 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -944,18 +945,20 @@ static int __devinit xuartps_probe(struct platform_device *pdev) int rc; struct uart_port *port; struct resource *res, *res2; - int clk = 0; + struct clk *clk; - const unsigned int *prop; - - prop = of_get_property(pdev->dev.of_node, "clock", NULL); - if (prop) - clk = be32_to_cpup(prop); + clk = of_clk_get(pdev->dev.of_node, 0); if (!clk) { dev_err(&pdev->dev, "no clock specified\n"); return -ENODEV; } + rc = clk_prepare_enable(clk); + if (rc) { + dev_err(&pdev->dev, "could not enable clock\n"); + return -EBUSY; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; @@ -978,7 +981,8 @@ static int __devinit xuartps_probe(struct platform_device *pdev) port->mapbase = res->start; port->irq = res2->start; port->dev = &pdev->dev; - port->uartclk = clk; + port->uartclk = clk_get_rate(clk); + port->private_data = clk; dev_set_drvdata(&pdev->dev, port); rc = uart_add_one_port(&xuartps_uart_driver, port); if (rc) { @@ -1000,14 +1004,14 @@ static int __devinit xuartps_probe(struct platform_device *pdev) static int __devexit xuartps_remove(struct platform_device *pdev) { struct uart_port *port = dev_get_drvdata(&pdev->dev); - int rc = 0; + struct clk *clk = port->private_data; + int rc; /* Remove the xuartps port from the serial core */ - if (port) { - rc = uart_remove_one_port(&xuartps_uart_driver, port); - dev_set_drvdata(&pdev->dev, NULL); - port->mapbase = 0; - } + rc = uart_remove_one_port(&xuartps_uart_driver, port); + dev_set_drvdata(&pdev->dev, NULL); + port->mapbase = 0; + clk_disable_unprepare(clk); return rc; }