From patchwork Fri Sep 26 13:14:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 4982271 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 778359F2BB for ; Fri, 26 Sep 2014 13:17:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A0482020F for ; Fri, 26 Sep 2014 13:17:02 +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 9CA0C201E4 for ; Fri, 26 Sep 2014 13:16:57 +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 1XXVMh-0000qj-Ih; Fri, 26 Sep 2014 13:15:15 +0000 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXVMJ-0007nR-52 for linux-arm-kernel@lists.infradead.org; Fri, 26 Sep 2014 13:14:51 +0000 Received: by mail-pd0-f171.google.com with SMTP id y13so12667810pdi.16 for ; Fri, 26 Sep 2014 06:14:33 -0700 (PDT) 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=mgC1Kk9rGDB5Onl1HCo1e5t4vqm69QN4LQfmyY8Bkc8=; b=yRB8TqSpFlOqobLz7udd/geHvcHFe9KWfeW4f14eFj6Sat3ek5hXrhKPdFkt7EOIHu /eqJkPvggAneS8+TXtTI9UYk0kEzSzKwRSqCpzPSGLjlv5NaO1VRj9gt/kTiflFOwx7W FiQvlco/hpyZwwqbyzDC3HdJwTewszgrpDCE4qsf6E8U6ZG6DZvzq+USjWsTtUP6xwaT eyczEG+2UgLKHGnLzGv3E6TlrkGnji7RMBd3NUDLvR8MOGZJIvT2lifpToymN8PtTlwG R72dZuTutorQlPNnlIsBG0S8CBp2wfNoe2xvaAVMPPxhEN56xqJRyn6g9bc4Hshv1mys DJtQ== X-Received: by 10.68.103.68 with SMTP id fu4mr31507090pbb.32.1411737273397; Fri, 26 Sep 2014 06:14:33 -0700 (PDT) Received: from pallav-Inspiron-660s.toradex.int ([115.115.225.206]) by mx.google.com with ESMTPSA id pp8sm4990168pac.34.2014.09.26.06.14.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 06:14:32 -0700 (PDT) From: Sanchayan Maity To: kernel@pengutronix.de, a.zummo@towertech.it Subject: [PATCH 3/3] drivers/rtc/rtc-snvs: Add clock support Date: Fri, 26 Sep 2014 18:44:01 +0530 Message-Id: <8a1904a59f7b171a7cf1e71b9e80f0cf7b1061c0.1411736171.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-20140926_061451_235936_6B75291D X-CRM114-Status: GOOD ( 16.02 ) X-Spam-Score: -0.8 (/) Cc: linux@arm.linux.org.uk, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, stefan@agner.ch, Sanchayan Maity , linux-arm-kernel@lists.infradead.org, b35083@freescale.com, shawn.guo@freescale.com 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.5 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 by the SNVS RTC. Signed-off-by: Sanchayan Maity --- drivers/rtc/rtc-snvs.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index fa384fe..f3e8f05 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,8 +262,31 @@ static int snvs_rtc_probe(struct platform_device *pdev) if (data->irq < 0) return data->irq; + ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler, + IRQF_SHARED, "rtc alarm", &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "failed to request irq %d: %d\n", + data->irq, ret); + return ret; + } + + data->clk = devm_clk_get(&pdev->dev, "snvs"); + if (IS_ERR(data->clk)) { + dev_err(&pdev->dev, "failed getting clock, err = %ld\n", + PTR_ERR(data->clk)); + ret = PTR_ERR(data->clk); + return ret; + } + platform_set_drvdata(pdev, data); + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(&pdev->dev, + "Could not prepare or enable the snvs clock\n"); + return ret; + } + spin_lock_init(&data->lock); /* Initialize glitch detect */ @@ -275,23 +300,20 @@ static int snvs_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, true); - ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler, - IRQF_SHARED, "rtc alarm", &pdev->dev); - if (ret) { - dev_err(&pdev->dev, "failed to request irq %d: %d\n", - data->irq, ret); - return ret; - } - data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &snvs_rtc_ops, THIS_MODULE); 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: + clk_disable_unprepare(data->clk); + + return ret; } #ifdef CONFIG_PM_SLEEP @@ -302,16 +324,24 @@ static int snvs_rtc_suspend(struct device *dev) if (device_may_wakeup(dev)) enable_irq_wake(data->irq); + clk_disable_unprepare(data->clk); + return 0; } static int snvs_rtc_resume(struct device *dev) { + int ret; + struct snvs_rtc_data *data = dev_get_drvdata(dev); if (device_may_wakeup(dev)) disable_irq_wake(data->irq); + ret = clk_prepare_enable(data->clk); + if (ret) + return ret; + return 0; } #endif