From patchwork Thu Mar 7 22:14:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 2233981 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 893803FC8F for ; Thu, 7 Mar 2013 22:19:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDj5k-0007VI-JN; Thu, 07 Mar 2013 22:15:13 +0000 Received: from mail.free-electrons.com ([94.23.35.102]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDj5Q-0007Nq-NL for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2013 22:14:53 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 1BDE0B5D; Thu, 7 Mar 2013 23:14:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost (gar31-2-82-226-185-134.fbx.proxad.net [82.226.185.134]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0590B81D; Thu, 7 Mar 2013 23:14:49 +0100 (CET) From: Maxime Ripard To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/6] serial: 8250_dw: add support for clocks property when using DeviceTree Date: Thu, 7 Mar 2013 23:14:15 +0100 Message-Id: <1362694460-1919-2-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362694460-1919-1-git-send-email-maxime.ripard@free-electrons.com> References: <1362694460-1919-1-git-send-email-maxime.ripard@free-electrons.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130307_171452_901792_5A7A81D4 X-CRM114-Status: GOOD ( 15.16 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.6 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: =?UTF-8?q?Emilio=20L=C3=B3pez?= , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, sunny@allwinnertech.com, shuge@allwinnertech.com, Jiri Slaby , kevin@allwinnertech.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Emilio López This commit implements support for using the "clocks" DT property, instead of having to use clock-frequency. Signed-off-by: Emilio López --- drivers/tty/serial/8250/8250_dw.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index db0e66f..8f03800 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "8250.h" @@ -55,8 +56,9 @@ struct dw8250_data { - int last_lcr; - int line; + int last_lcr; + int line; + struct clk *clk; }; static void dw8250_serial_out(struct uart_port *p, int offset, int value) @@ -116,6 +118,7 @@ static int dw8250_handle_irq(struct uart_port *p) static int dw8250_probe_of(struct uart_port *p) { struct device_node *np = p->dev->of_node; + struct dw8250_data *data = p->private_data; u32 val; if (!of_property_read_u32(np, "reg-io-width", &val)) { @@ -137,8 +140,15 @@ static int dw8250_probe_of(struct uart_port *p) p->regshift = val; if (of_property_read_u32(np, "clock-frequency", &val)) { - dev_err(p->dev, "no clock-frequency property set\n"); - return -EINVAL; + /* Get clk rate through clk driver if present */ + data->clk = clk_get(p->dev, NULL); + if (IS_ERR(data->clk)) { + dev_err(p->dev, "clk or clock-frequency not defined\n"); + return -EINVAL; + } + + clk_prepare_enable(data->clk); + val = clk_get_rate(data->clk); } p->uartclk = val; @@ -300,6 +310,12 @@ static int dw8250_probe(struct platform_device *pdev) dw8250_setup_port(&uart); + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + uart.port.private_data = data; + if (pdev->dev.of_node) { err = dw8250_probe_of(&uart.port); if (err) @@ -312,12 +328,6 @@ static int dw8250_probe(struct platform_device *pdev) return -ENODEV; } - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - uart.port.private_data = data; - data->line = serial8250_register_8250_port(&uart); if (data->line < 0) return data->line; @@ -333,6 +343,8 @@ static int dw8250_remove(struct platform_device *pdev) serial8250_unregister_port(data->line); + clk_disable_unprepare(data->clk); + return 0; }