From patchwork Wed Mar 31 06:30:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 89893 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2V6UnCD007365 for ; Wed, 31 Mar 2010 06:30:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932767Ab0CaGaf (ORCPT ); Wed, 31 Mar 2010 02:30:35 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:53811 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932761Ab0CaGac (ORCPT ); Wed, 31 Mar 2010 02:30:32 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o2V6UN5q003346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 31 Mar 2010 01:30:26 -0500 Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o2V6UFjb014128; Wed, 31 Mar 2010 12:00:16 +0530 (IST) Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by linfarm476.india.ti.com (8.12.11/8.12.11) with ESMTP id o2V6UF56028073; Wed, 31 Mar 2010 12:00:15 +0530 Received: (from a0393109@localhost) by linfarm476.india.ti.com (8.12.11/8.12.11/Submit) id o2V6UFwg028071; Wed, 31 Mar 2010 12:00:15 +0530 From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: khilman@deeprootsystems.com, paul@pwsan.com, nm@ti.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PATCHv2 1/3] OMAP3: PM: Fix crash when enabling SmartReflex on non-supported OMAPs. Date: Wed, 31 Mar 2010 12:00:12 +0530 Message-Id: <1270017014-27704-2-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.5.5 In-Reply-To: <1270017014-27704-1-git-send-email-thara@ti.com> References: <1270017014-27704-1-git-send-email-thara@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.3 (demeter.kernel.org [140.211.167.41]); Wed, 31 Mar 2010 06:30:52 +0000 (UTC) diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index 1d7d2e6..3f4b47b 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c @@ -115,9 +115,14 @@ static int sr_clk_enable(struct omap_sr *sr) { struct omap_smartreflex_data *pdata = sr->pdev->dev.platform_data; + if (!sr->is_sr_reset) + return 0; + if (pdata->device_enable) pdata->device_enable(sr->pdev); + sr->is_sr_reset = 0; + return 0; } @@ -125,6 +130,9 @@ static void sr_clk_disable(struct omap_sr *sr) { struct omap_smartreflex_data *pdata = sr->pdev->dev.platform_data; + if (sr->is_sr_reset) + return; + if (pdata->device_idle) pdata->device_idle(sr->pdev); @@ -308,7 +316,6 @@ static void sr_configure(struct omap_sr *sr) ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST | ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST)); } - sr->is_sr_reset = 0; } static void sr_start_vddautocomp(int srid) @@ -329,8 +336,7 @@ static void sr_start_vddautocomp(int srid) sr->is_autocomp_active = 1; if (!sr_class->enable(srid)) { sr->is_autocomp_active = 0; - if (sr->is_sr_reset == 1) - sr_clk_disable(sr); + sr_clk_disable(sr); } } @@ -350,8 +356,10 @@ static void sr_stop_vddautocomp(int srid) } if (sr->is_autocomp_active == 1) { - sr_class->disable(srid); - sr_clk_disable(sr); + if (!sr->is_sr_reset) { + sr_class->disable(srid); + sr_clk_disable(sr); + } sr->is_autocomp_active = 0; } } @@ -431,6 +439,11 @@ int sr_enable(int srid, unsigned long volt) /* Enable the clocks and configure SR */ sr_clk_enable(sr); + + /* Check if SR is already enabled. If yes do nothing */ + if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) + return true; + sr_configure(sr); sr_write_reg(sr, NVALUERECIPROCAL, nvalue_reciprocal); @@ -518,10 +531,8 @@ void omap_smartreflex_enable(int srid) } if (sr->is_autocomp_active == 1) { - if (sr->is_sr_reset == 1) { - if (!sr_class->enable(srid)) - sr_clk_disable(sr); - } + if (!sr_class->enable(srid)) + sr_clk_disable(sr); } } @@ -550,7 +561,7 @@ void omap_smartreflex_disable(int srid) } if (sr->is_autocomp_active == 1) { - if (sr->is_sr_reset == 0) { + if (!sr->is_sr_reset) { sr_class->disable(srid); /* Disable SR clk */ sr_clk_disable(sr);