From patchwork Wed Jul 25 06:12:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Afzal X-Patchwork-Id: 173109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-gg0-f184.google.com (mail-gg0-f184.google.com [209.85.161.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7F4482C008E for ; Wed, 25 Jul 2012 16:12:45 +1000 (EST) Received: by ggmo6 with SMTP id o6sf339916ggm.11 for ; Tue, 24 Jul 2012 23:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=cHWeUCalxje3IbJBN9Go0TiVJS2g6NQSjeoxROXuEt8=; b=FA0+LBomSUYmtTx46rFPhK0Qzb8yGQDwQgZQEyvb9K4aU1+d0Bln4Z+894vzeienwH 6p6DquWgP4xE3vBm7KBp5Vpk1KsHulO6sxtBBUdOizlNOli2rH+ijqjdCM+K4rgFWg9p ygFPfu+GtodFiVLcJWDG/+OPSzj5WhQaxglBM= Received: by 10.182.112.42 with SMTP id in10mr1014740obb.13.1343196762892; Tue, 24 Jul 2012 23:12:42 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.231.49.81 with SMTP id u17ls195240ibf.6.gmail; Tue, 24 Jul 2012 23:12:42 -0700 (PDT) Received: by 10.42.180.198 with SMTP id bv6mr10585802icb.3.1343196762456; Tue, 24 Jul 2012 23:12:42 -0700 (PDT) Received: by 10.42.180.198 with SMTP id bv6mr10585801icb.3.1343196762438; Tue, 24 Jul 2012 23:12:42 -0700 (PDT) Received: from comal.ext.ti.com (comal.ext.ti.com. [198.47.26.152]) by gmr-mx.google.com with ESMTPS id v3si204805igw.1.2012.07.24.23.12.42 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 23:12:42 -0700 (PDT) Received-SPF: neutral (google.com: 198.47.26.152 is neither permitted nor denied by best guess record for domain of ubnuser@udx0156546) client-ip=198.47.26.152; Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6P6CbFC012811; Wed, 25 Jul 2012 01:12:38 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6P6CXBW005996; Wed, 25 Jul 2012 11:42:33 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Wed, 25 Jul 2012 11:42:33 +0530 Received: from udx0156546 (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6P6CW9O019504; Wed, 25 Jul 2012 11:42:32 +0530 Received: from ubnuser by udx0156546 with local (Exim 4.72) (envelope-from ) id 1Stupk-0003f0-NT; Wed, 25 Jul 2012 11:42:32 +0530 From: Afzal Mohammed To: , , , , , , , , , , , , , CC: Vaibhav Hiremath , Afzal Mohammed Subject: [rtc-linux] [PATCH v2 5/6] rtc: omap: Add runtime pm support Date: Wed, 25 Jul 2012 11:42:32 +0530 Message-ID: <61fe13f88db5c6b0830816322aadb456cb6e0c3e.1343191280.git.afzal@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: MIME-Version: 1.0 X-Original-Sender: afzal@ti.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 198.47.26.152 is neither permitted nor denied by best guess record for domain of ubnuser@udx0156546) smtp.mail=ubnuser@udx0156546 Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Vaibhav Hiremath OMAP1 RTC driver is used in multiple devices like, OMAPL138 and AM33XX. Driver currently doesn't handle any clocks, which may be right for OMAP1 architecture but in case of AM33XX, the clock/module needs to be enabled in order to access the registers. So covert this driver to runtime pm, which internally handles rest. Afzal: handle error path Signed-off-by: Vaibhav Hiremath Signed-off-by: Afzal Mohammed --- drivers/rtc/rtc-omap.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index dc1a4da..3ee3401 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -363,6 +364,10 @@ static int __init omap_rtc_probe(struct platform_device *pdev) goto fail; } + /* Enable the clock/module so that we can access the registers */ + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + id_entry = platform_get_device_id(pdev); if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) { rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG); @@ -447,6 +452,8 @@ fail1: fail0: if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) rtc_writel(0, OMAP_RTC_KICK0_REG); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); iounmap(rtc_base); fail: release_mem_region(mem->start, resource_size(mem)); @@ -473,6 +480,11 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) rtc_device_unregister(rtc); if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) rtc_writel(0, OMAP_RTC_KICK0_REG); + + /* Disable the clock/module */ + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + iounmap(rtc_base); release_mem_region(mem->start, resource_size(mem)); return 0; @@ -495,11 +507,17 @@ static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state) else rtc_write(0, OMAP_RTC_INTERRUPTS_REG); + /* Disable the clock/module */ + pm_runtime_put_sync(&pdev->dev); + return 0; } static int omap_rtc_resume(struct platform_device *pdev) { + /* Enable the clock/module so that we can access the registers */ + pm_runtime_get_sync(&pdev->dev); + if (device_may_wakeup(&pdev->dev)) disable_irq_wake(omap_rtc_alarm); else