From patchwork Thu Apr 23 08:51:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 6261001 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 098559F313 for ; Thu, 23 Apr 2015 08:53:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A12B20380 for ; Thu, 23 Apr 2015 08:53:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 443C820328 for ; Thu, 23 Apr 2015 08:53:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlCtJ-0001wC-E6; Thu, 23 Apr 2015 08:53:49 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlCrV-0000hf-PZ for linux-mediatek@bombadil.infradead.org; Thu, 23 Apr 2015 08:51:57 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlCrU-0003kg-3x for linux-mediatek@lists.infradead.org; Thu, 23 Apr 2015 08:51:56 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YlCqs-0004jy-Di; Thu, 23 Apr 2015 10:51:18 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YlCqr-00060h-Eb; Thu, 23 Apr 2015 10:51:17 +0200 From: Sascha Hauer To: linux-kernel@vger.kernel.org Subject: [PATCH 4/4] tty: serial: 8250_mtk: Add support for bus clock Date: Thu, 23 Apr 2015 10:51:06 +0200 Message-Id: <1429779066-21406-5-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429779066-21406-1-git-send-email-s.hauer@pengutronix.de> References: <1429779066-21406-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mediatek@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150423_045156_373055_D72FD720 X-CRM114-Status: GOOD ( 17.08 ) X-Spam-Score: -1.9 (-) Cc: gregkh@linuxfoundation.org, Sascha Hauer , linux-mediatek@lists.infradead.org, linux-serial@vger.kernel.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, Alan Cox X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The mtk 8250 needs two clocks, one for providing the baudrate and one that needs to be enabled for register accesses. The latter has not been supported, this patch adds support for it. It is optional for now since not all SoCs provide a bus clock. Signed-off-by: Sascha Hauer --- Documentation/devicetree/bindings/serial/mtk-uart.txt | 9 +++++++-- drivers/tty/serial/8250/8250_mtk.c | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/mtk-uart.txt b/Documentation/devicetree/bindings/serial/mtk-uart.txt index 4415226..369b5c3 100644 --- a/Documentation/devicetree/bindings/serial/mtk-uart.txt +++ b/Documentation/devicetree/bindings/serial/mtk-uart.txt @@ -14,7 +14,11 @@ Required properties: - interrupts: A single interrupt specifier. -- clocks: Clock driving the hardware. +- clocks : Must contain an entry for each entry in clock-names. + See ../clocks/clock-bindings.txt for details. +- clock-names: + - "baud": The clock the baudrate is derived from + - "bus": The bus clock for register accesses (optional) Example: @@ -22,5 +26,6 @@ Example: compatible = "mediatek,mt6589-uart", "mediatek,mt6577-uart"; reg = <0x11006000 0x400>; interrupts = ; - clocks = <&uart_clk>; + clocks = <&uart_clk>, <&bus_clk>; + clock-names = "baud", "bus"; }; diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index 2f28bd0..20c27f0 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -34,6 +34,7 @@ struct mtk8250_data { int line; struct clk *uart_clk; + struct clk *bus_clk; }; static void @@ -120,6 +121,7 @@ static int mtk8250_runtime_suspend(struct device *dev) struct mtk8250_data *data = dev_get_drvdata(dev); clk_disable_unprepare(data->uart_clk); + clk_disable_unprepare(data->bus_clk); return 0; } @@ -135,6 +137,12 @@ static int mtk8250_runtime_resume(struct device *dev) return err; } + err = clk_prepare_enable(data->bus_clk); + if (err) { + dev_warn(dev, "Can't enable bus clock\n"); + return err; + } + return 0; } @@ -153,7 +161,7 @@ mtk8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p, struct mtk8250_data *data) { - data->uart_clk = devm_clk_get(&pdev->dev, NULL); + data->uart_clk = devm_clk_get(&pdev->dev, "baud"); if (IS_ERR(data->uart_clk)) { dev_warn(&pdev->dev, "Can't get uart clock\n"); return PTR_ERR(data->uart_clk); @@ -161,6 +169,10 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p, p->uartclk = clk_get_rate(data->uart_clk); + data->bus_clk = devm_clk_get(&pdev->dev, "bus"); + if (IS_ERR(data->bus_clk)) + data->bus_clk = NULL; + return 0; }