From patchwork Sat Mar 5 15:29:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 612431 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p25FVjUV025035 for ; Sat, 5 Mar 2011 15:31:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753099Ab1CEPbo (ORCPT ); Sat, 5 Mar 2011 10:31:44 -0500 Received: from na3sys009aog116.obsmtp.com ([74.125.149.240]:42240 "EHLO na3sys009aog116.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750821Ab1CEPbn (ORCPT ); Sat, 5 Mar 2011 10:31:43 -0500 Received: from source ([209.85.218.52]) (using TLSv1) by na3sys009aob116.postini.com ([74.125.148.12]) with SMTP ID DSNKTXJXXx/ht4+FC2dlFNkDXyCi23ILqm7w@postini.com; Sat, 05 Mar 2011 07:31:43 PST Received: by yih10 with SMTP id 10so2458230yih.25 for ; Sat, 05 Mar 2011 07:31:42 -0800 (PST) Received: by 10.150.160.5 with SMTP id i5mr2143902ybe.320.1299339102372; Sat, 05 Mar 2011 07:31:42 -0800 (PST) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id w1sm404542ybl.9.2011.03.05.07.31.37 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Mar 2011 07:31:41 -0800 (PST) From: Nishanth Menon To: linux-omap Cc: linux-arm , Kevin Hilman , Tony , Paul , Jarkko Nikula , Nishanth Menon Subject: [PATCH V3 13/19] OMAP3+: SR: Reuse sr_[start|stop]_vddautocomp functions Date: Sat, 5 Mar 2011 20:59:16 +0530 Message-Id: <1299338962-5602-14-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1299338962-5602-1-git-send-email-nm@ti.com> References: <1299338962-5602-1-git-send-email-nm@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 05 Mar 2011 15:31:45 +0000 (UTC) diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index 592e9a0..d839fa6 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c @@ -211,8 +211,12 @@ static void sr_set_regfields(struct omap_sr *sr) } } -static void sr_start_vddautocomp(struct omap_sr *sr) +static void sr_start_vddautocomp(struct omap_sr *sr, bool class_start) { + int r; + if (sr->autocomp_active) + return; + if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) { dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not registered\n", @@ -220,19 +224,24 @@ static void sr_start_vddautocomp(struct omap_sr *sr) return; } - if (sr_class->start && + if (class_start && sr_class->start && sr_class->start(sr->voltdm, sr_class->class_priv_data)) { dev_err(&sr->pdev->dev, "%s: SRClass initialization failed\n", __func__); return; } - if (!sr_class->enable(sr->voltdm)) + r = sr_class->enable(sr->voltdm); + if (!r && class_start) sr->autocomp_active = true; } -static void sr_stop_vddautocomp(struct omap_sr *sr) +static void sr_stop_vddautocomp(struct omap_sr *sr, bool class_stop, + int is_volt_reset) { + if (!sr->autocomp_active) + return; + if (!sr_class || !(sr_class->disable)) { dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not registered\n", @@ -240,15 +249,13 @@ static void sr_stop_vddautocomp(struct omap_sr *sr) return; } - if (sr->autocomp_active) { - sr_class->disable(sr->voltdm, 1); + sr_class->disable(sr->voltdm, is_volt_reset); + if (class_stop) { if (sr_class->stop && - sr_class->stop(sr->voltdm, - sr_class->class_priv_data)) { + sr_class->stop(sr->voltdm, sr_class->class_priv_data)) dev_err(&sr->pdev->dev, "%s: SR[%d]Class deinitialization failed\n", __func__, sr->srid); - } sr->autocomp_active = false; } } @@ -285,7 +292,7 @@ static int sr_late_init(struct omap_sr *sr_info) } if (pdata && pdata->enable_on_init) - sr_start_vddautocomp(sr_info); + sr_start_vddautocomp(sr_info, true); return ret; @@ -693,16 +700,7 @@ void omap_sr_enable(struct voltagedomain *voltdm) return; } - if (!sr->autocomp_active) - return; - - if (!sr_class || !(sr_class->enable) || !(sr_class->configure)) { - dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not" - "registered\n", __func__); - return; - } - - sr_class->enable(voltdm); + sr_start_vddautocomp(sr, false); } /** @@ -726,16 +724,7 @@ void omap_sr_disable(struct voltagedomain *voltdm) return; } - if (!sr->autocomp_active) - return; - - if (!sr_class || !(sr_class->disable)) { - dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not" - "registered\n", __func__); - return; - } - - sr_class->disable(voltdm, 0); + sr_stop_vddautocomp(sr, false, 0); } /** @@ -759,16 +748,7 @@ void omap_sr_disable_reset_volt(struct voltagedomain *voltdm) return; } - if (!sr->autocomp_active) - return; - - if (!sr_class || !(sr_class->disable)) { - dev_warn(&sr->pdev->dev, "%s: smartreflex class driver not" - "registered\n", __func__); - return; - } - - sr_class->disable(voltdm, 1); + sr_stop_vddautocomp(sr, false, 1); } /** @@ -823,9 +803,9 @@ static int omap_sr_autocomp_store(void *data, u64 val) /* control enable/disable only if there is a delta in value */ if (sr_info->autocomp_active != val) { if (!val) - sr_stop_vddautocomp(sr_info); + sr_stop_vddautocomp(sr_info, true, 1); else - sr_start_vddautocomp(sr_info); + sr_start_vddautocomp(sr_info, true); } return 0; @@ -987,7 +967,7 @@ static int __devexit omap_sr_remove(struct platform_device *pdev) } if (sr_info->autocomp_active) - sr_stop_vddautocomp(sr_info); + sr_stop_vddautocomp(sr_info, true, 1); list_del(&sr_info->node); iounmap(sr_info->base);