From patchwork Fri Jan 20 15:56:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 9528871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 433BA601B7 for ; Fri, 20 Jan 2017 15:57:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AC7D286AB for ; Fri, 20 Jan 2017 15:57:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F587286AE; Fri, 20 Jan 2017 15:57:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE5F4286AB for ; Fri, 20 Jan 2017 15:57:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cUbZV-0006ww-IF; Fri, 20 Jan 2017 15:57:49 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cUbYo-0005jP-PE for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2017 15:57:11 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 9548120C13; Fri, 20 Jan 2017 16:56:50 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 73F3120BA8; Fri, 20 Jan 2017 16:56:50 +0100 (CET) From: Maxime Ripard To: Alexandre Belloni , Alessandro Zummo , Chen-Yu Tsai Subject: [PATCH 4/6] rtc: sun6i: Force the mux to the external oscillator Date: Fri, 20 Jan 2017 16:56:41 +0100 Message-Id: <409c56f0ed1c4b0026ad60cb1218c99fe1686408.1484927680.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170120_075707_030442_385A6C0C X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Maxime Ripard , Rob Herring , rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The internal oscillator is way too inaccurate to do something useful with it. Switch to the external oscillator if it is available. Signed-off-by: Maxime Ripard --- drivers/rtc/rtc-sun6i.c | 12 ++++++++++++ 1 file changed, 12 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index edd5627da10f..1695fae24cd5 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -493,6 +493,7 @@ static const struct rtc_class_ops sun6i_rtc_ops = { static int sun6i_rtc_probe(struct platform_device *pdev) { struct sun6i_rtc_dev *chip = sun6i_rtc; + struct clk *parent; int ret; if (!chip) @@ -540,6 +541,17 @@ static int sun6i_rtc_probe(struct platform_device *pdev) /* disable alarm wakeup */ writel(0, chip->base + SUN6I_ALARM_CONFIG); + parent = clk_get(&pdev->dev, NULL); + if (!IS_ERR(parent)) { + ret = clk_set_parent(chip->losc, parent); + clk_put(parent); + + if (ret) { + dev_err(&pdev->dev, + "Failed to reparent the RTC to the external oscillator\n"); + return ret; + } + } clk_prepare_enable(chip->losc); chip->rtc = rtc_device_register("rtc-sun6i", &pdev->dev,