From patchwork Thu Jun 16 08:30:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MyungJoo Ham X-Patchwork-Id: 886342 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5G8Uo34024623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 16 Jun 2011 08:31:11 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QX7yG-0007XS-OT; Thu, 16 Jun 2011 08:30:37 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QX7yG-0003UH-Bn; Thu, 16 Jun 2011 08:30:36 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QX7xs-0003Qg-R6 for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2011 08:30:14 +0000 Received: from epcpsbgm2.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LMV0052OJM5PTQ0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2011 17:30:05 +0900 (KST) X-AuditID: cbfee61b-b7c62ae0000056ed-61-4df9bf0d84ea Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (MMPCPMTA) with SMTP id 45.00.22253.D0FB9FD4; Thu, 16 Jun 2011 17:30:05 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LMV00DAMJM50A@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2011 17:30:05 +0900 (KST) Received: from localhost.localdomain ([165.213.219.116]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.4675); Thu, 16 Jun 2011 17:29:52 +0900 Date: Thu, 16 Jun 2011 17:30:02 +0900 From: MyungJoo Ham Subject: [PATCH 1/2] Samsung SoC ADC: use regulator (VDD for ADC). To: linux-arm-kernel@lists.infradead.org Message-id: <1308213003-6526-1-git-send-email-myungjoo.ham@samsung.com> X-Mailer: git-send-email 1.7.4.1 X-OriginalArrivalTime: 16 Jun 2011 08:29:52.0085 (UTC) FILETIME=[9014F850:01CC2BFF] X-Brightmail-Tracker: AAAAAA== X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110616_043013_155841_37CC76F9 X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [203.254.224.25 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain Cc: Kukjin Kim , Russell King , linux-kernel@vger.kernel.org, dg77.kim@samsung.com, kyungmin.park@samsung.com, myungjoo.ham@gmail.com, Ben Dooks X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 16 Jun 2011 08:31:12 +0000 (UTC) This patch allows the Samsung ADC driver to enable VDD regulator at probe and resume and to disable at exit and suspend. In a platform where ADC's VDD regulator is not "always-on", this control is required although this patch does not provide fine-grained power control (turning on the regulator only when being accessed). However, if VDD regulator ("vdd" for the adc device) is not provided, the regulator control will not be activated because there are platforms that do not provide regulator for ADC device. Signed-off-by: MyungJoo Ham Signed-off-by: Kyungmin Park --- arch/arm/plat-samsung/adc.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c index e8f2be2..a8499d8 100644 --- a/arch/arm/plat-samsung/adc.c +++ b/arch/arm/plat-samsung/adc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,8 @@ struct s3c_adc_client { unsigned *samples_left); }; +#define S3C_ADC_REGULATOR_NAME "vdd" + struct adc_device { struct platform_device *pdev; struct platform_device *owner; @@ -71,6 +74,7 @@ struct adc_device { unsigned int prescale; int irq; + struct regulator *vdd; }; static struct adc_device *adc_dev; @@ -338,6 +342,12 @@ static int s3c_adc_probe(struct platform_device *pdev) adc->pdev = pdev; adc->prescale = S3C2410_ADCCON_PRSCVL(49); + adc->vdd = regulator_get(dev, S3C_ADC_REGULATOR_NAME); + if (IS_ERR_OR_NULL(adc->vdd)) { + dev_dbg(dev, "operating without regulator %s.\n", S3C_ADC_REGULATOR_NAME); + adc->vdd = NULL; /* Do not control regulator */ + } + adc->irq = platform_get_irq(pdev, 1); if (adc->irq <= 0) { dev_err(dev, "failed to get adc irq\n"); @@ -372,6 +382,8 @@ static int s3c_adc_probe(struct platform_device *pdev) goto err_clk; } + if (adc->vdd) + regulator_enable(adc->vdd); clk_enable(adc->clk); tmp = adc->prescale | S3C2410_ADCCON_PRSCEN; @@ -406,6 +418,8 @@ static int __devexit s3c_adc_remove(struct platform_device *pdev) iounmap(adc->regs); free_irq(adc->irq, adc); clk_disable(adc->clk); + if (adc->vdd) + regulator_disable(adc->vdd); clk_put(adc->clk); kfree(adc); @@ -428,6 +442,8 @@ static int s3c_adc_suspend(struct platform_device *pdev, pm_message_t state) disable_irq(adc->irq); spin_unlock_irqrestore(&adc->lock, flags); clk_disable(adc->clk); + if (adc->vdd) + regulator_disable(adc->vdd); return 0; } @@ -436,6 +452,8 @@ static int s3c_adc_resume(struct platform_device *pdev) { struct adc_device *adc = platform_get_drvdata(pdev); + if (adc->vdd) + regulator_enable(adc->vdd); clk_enable(adc->clk); enable_irq(adc->irq); @@ -485,4 +503,4 @@ static int __init adc_init(void) return ret; } -arch_initcall(adc_init); +module_init(adc_init);