From patchwork Fri Nov 7 13:04:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 5252331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 829E39F3ED for ; Fri, 7 Nov 2014 13:07:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B405920138 for ; Fri, 7 Nov 2014 13:07:27 +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 D4E6A20121 for ; Fri, 7 Nov 2014 13:07:26 +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 1XmjEX-0006Jw-Bt; Fri, 07 Nov 2014 13:05:45 +0000 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmjEB-00052p-TJ for linux-arm-kernel@lists.infradead.org; Fri, 07 Nov 2014 13:05:24 +0000 Received: by mail-pd0-f181.google.com with SMTP id y10so3282902pdj.40 for ; Fri, 07 Nov 2014 05:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=zTCaLyh4eHnZdUrOo0c4FJWJoet6g6aiprQbxe6RKqQ=; b=TbD6vQ9pwL4OOoh662AFt3wI4XcFdik+Yn/rShQu+WJlPXFpDsSsRL81KVtqDJBmxT YQE7ij8x6hDf2JN1JBW2v9EQWm3Ug09Co/Agw8EGhbYhwcwF3h77Q0UIpO6yLCPA+GOl K15NiFpEcvlsXYVie+0rn36Eyt4RBpgs/obU5SCwv+rkR/pHG5s5NkI5hhjpObd+xyeJ antfNdWFe/seXfBlBX3sksfQHqghKYC4TE9OhThWOoqF6yiwzrO1Ife2XJE1dlpVdHno zTNBzqjLqq5tuSPZjiiBHJMFL7qpeHP6iDnZYBR3fUNRf1L4NVeoBSESWmP4DJxBffkY ATsQ== X-Received: by 10.70.40.197 with SMTP id z5mr11844823pdk.120.1415365502799; Fri, 07 Nov 2014 05:05:02 -0800 (PST) Received: from pallav-Inspiron-660s.toradex.int ([115.115.225.206]) by mx.google.com with ESMTPSA id ra4sm8797493pab.33.2014.11.07.05.04.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 05:05:02 -0800 (PST) From: Sanchayan Maity To: rtc-linux@googlegroups.com Subject: [[PATCHv2] 3/3] drivers/rtc/rtc-snvs: Add clock support Date: Fri, 7 Nov 2014 18:34:28 +0530 Message-Id: <30e496ce2d6521e608df3b68b73b3e05caa1daef.1415364391.git.maitysanchayan@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141107_050523_972850_055722C4 X-CRM114-Status: GOOD ( 15.18 ) X-Spam-Score: -0.8 (/) Cc: linux@arm.linux.org.uk, linux-kernel@vger.kernel.org, stefan@agner.ch, Sanchayan Maity , kernel@pengutronix.de, shawn.guo@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This patch adds clock enable and disable support for the SNVS peripheral, which is required for using the RTC within the SNVS block. Signed-off-by: Sanchayan Maity Acked-by: Stefan Agner --- drivers/rtc/rtc-snvs.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index fa384fe..d4a6512 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -17,6 +17,7 @@ #include #include #include +#include /* These register offsets are relative to LP (Low Power) range */ #define SNVS_LPCR 0x04 @@ -39,6 +40,7 @@ struct snvs_rtc_data { void __iomem *ioaddr; int irq; spinlock_t lock; + struct clk *clk; }; static u32 rtc_read_lp_counter(void __iomem *ioaddr) @@ -260,6 +262,18 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (data->irq < 0) return data->irq; + data->clk = devm_clk_get(&pdev->dev, "snvs-rtc"); + if (IS_ERR(data->clk)) { + data->clk = NULL; + } else { + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(&pdev->dev, + "Could not prepare or enable the snvs clock\n"); + return ret; + } + } + platform_set_drvdata(pdev, data); spin_lock_init(&data->lock); @@ -280,7 +294,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to request irq %d: %d\n", data->irq, ret); - return ret; + goto error_rtc_device_register; } data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, @@ -288,10 +302,16 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (IS_ERR(data->rtc)) { ret = PTR_ERR(data->rtc); dev_err(&pdev->dev, "failed to register rtc: %d\n", ret); - return ret; + goto error_rtc_device_register; } return 0; + +error_rtc_device_register: + if (data->clk) + clk_disable_unprepare(data->clk); + + return ret; } #ifdef CONFIG_PM_SLEEP @@ -302,16 +322,26 @@ static int snvs_rtc_suspend(struct device *dev) if (device_may_wakeup(dev)) enable_irq_wake(data->irq); + if (data->clk) + clk_disable_unprepare(data->clk); + return 0; } static int snvs_rtc_resume(struct device *dev) { struct snvs_rtc_data *data = dev_get_drvdata(dev); + int ret; if (device_may_wakeup(dev)) disable_irq_wake(data->irq); + if (data->clk) { + ret = clk_prepare_enable(data->clk); + if (ret) + return ret; + } + return 0; } #endif