From patchwork Thu Apr 28 09:01:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kalle.jokiniemi@nokia.com X-Patchwork-Id: 738771 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 p3S91xxA018069 for ; Thu, 28 Apr 2011 09:01:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757923Ab1D1JBh (ORCPT ); Thu, 28 Apr 2011 05:01:37 -0400 Received: from smtp.nokia.com ([147.243.128.26]:49298 "EHLO mgw-da02.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757415Ab1D1JBf convert rfc822-to-8bit (ORCPT ); Thu, 28 Apr 2011 05:01:35 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-da02.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p3S90pLM028318; Thu, 28 Apr 2011 12:01:17 +0300 Received: from smtp.mgd.nokia.com ([65.54.30.7]) by vaebh105.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 28 Apr 2011 12:01:06 +0300 Received: from 008-AM1MMR1-001.mgdnok.nokia.com (65.54.30.56) by NOK-AM1MHUB-03.mgdnok.nokia.com (65.54.30.7) with Microsoft SMTP Server (TLS) id 8.2.255.0; Thu, 28 Apr 2011 11:01:05 +0200 Received: from 008-AM1MPN1-036.mgdnok.nokia.com ([169.254.6.209]) by 008-AM1MMR1-001.mgdnok.nokia.com ([65.54.30.56]) with mapi id 14.01.0289.008; Thu, 28 Apr 2011 11:01:04 +0200 From: To: , , , , , , , CC: , Subject: [RFC] Regulator state after regulator_get Thread-Topic: [RFC] Regulator state after regulator_get Thread-Index: AcwFgGFZ8c8Rl1ULSTCPpipjMzkFdg== Date: Thu, 28 Apr 2011 09:01:03 +0000 Message-ID: <9D0D31AA57AAF5499AFDC63D6472631B09C76A@008-AM1MPN1-036.mgdnok.nokia.com> Accept-Language: fi-FI, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.22.212.101] MIME-Version: 1.0 X-OriginalArrivalTime: 28 Apr 2011 09:01:06.0560 (UTC) FILETIME=[CF1D6800:01CC0582] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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]); Thu, 28 Apr 2011 09:02:00 +0000 (UTC) Hello regulator FW and OMAP3 ISP fellows, I'm currently optimizing power management for Nokia N900 MeeGo DE release, and found an issue with how regulators are handled at boot. The N900 uses VAUX2 regulator in OMAP3430 to power the CSIb IO complex that is used by the camera. While implementing regulator FW support to handle this regulator in the camera driver I noticed a problem with the regulator init sequence: If the device driver using the regulator does not enable and disable the regulator after regulator_get, the regulator is left in the state that it was after bootloader. In case of N900 this is a problem as the regulator is left on to leak current. Of course there is the option to let regulator FW disable all unused regulators, but this will break the N900 functionality, as the regulator handling is not in place for many drivers. I found couple of solutions to this: 1. reset all regulators that have users (regulator_get is called on them) with a regulator_enable/disable cycle within the regulator FW. 2. enable/disable the specific vdds_csib regulator in the omap3isp driver to reset this one specific regulator to disabled state. So, please share comments on which approach is more appropriate to take? Or maybe there is option 3? Here are example code for the two options (based on .37 kernel, will update on top of appropriate tree once right solution is agreed): Option1: If a consumer device of a regulator gets a regulator, but does not enable/disable it during probe, the regulator may be left active from boot, even though it is not needed. If it were needed it would be enabled by the consumer device. So reset the regulator on first regulator_get call to make sure that any regulator that has users is not left active needlessly. Signed-off-by: Kalle Jokiniemi --- drivers/regulator/core.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) -- Thanks, Kalle -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ba521f0..040d850 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1152,6 +1152,12 @@ found: module_put(rdev->owner); } + /* Reset regulator to make sure it is disabled, if not needed */ + if (!rdev->open_count) { + regulator_enable(regulator); + regulator_disable(regulator); + } + rdev->open_count++; if (exclusive) { rdev->exclusive = 1; -- Option2: Do a enable/disable cycle of the vdds_csib regulator to make sure it is disabled after init in case there are no other users for it. Otherwise regulator framework may leave it active in case it was activated by bootloader. Signed-off-by: Kalle Jokiniemi --- drivers/media/video/isp/ispccp2.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/isp/ispccp2.c b/drivers/media/video/isp/ispccp2.c index 2d6b014..e11957f 100644 --- a/drivers/media/video/isp/ispccp2.c +++ b/drivers/media/video/isp/ispccp2.c @@ -1201,6 +1201,11 @@ int isp_ccp2_init(struct isp_device *isp) } } + if (ccp2->vdds_csib) { + regulator_enable(ccp2->vdds); + regulator_disable(ccp2->vdds); + } + ret = isp_ccp2_init_entities(ccp2); if (ret < 0) goto out;