From patchwork Wed Feb 17 15:24:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 79967 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 o1HFOHmO005699 for ; Wed, 17 Feb 2010 15:24:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757404Ab0BQPY3 (ORCPT ); Wed, 17 Feb 2010 10:24:29 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:33922 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754154Ab0BQPY2 (ORCPT ); Wed, 17 Feb 2010 10:24:28 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o1HFOKSi020074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 17 Feb 2010 09:24:23 -0600 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 o1HFOGIG020532; Wed, 17 Feb 2010 20:54:17 +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 o1HFOGVU004444; Wed, 17 Feb 2010 20:54:16 +0530 Received: (from x0016154@localhost) by linfarm476.india.ti.com (8.12.11/8.12.11/Submit) id o1HFOFfo004441; Wed, 17 Feb 2010 20:54:15 +0530 From: Rajendra Nayak To: linux-omap@vger.kernel.org Cc: Rajendra Nayak , Liam Girdwood , Samuel Ortiz , Mark Brown Subject: [PATCH 1/2] twl6030: regulator: Fix vsel calculations in set/get voltage apis Date: Wed, 17 Feb 2010 20:54:14 +0530 Message-Id: <1266420255-4307-1-git-send-email-rnayak@ti.com> X-Mailer: git-send-email 1.5.5 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, 17 Feb 2010 15:24:30 +0000 (UTC) diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 7e67485..e7871d6 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c @@ -367,11 +367,17 @@ twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) /* REVISIT for VAUX2, first match may not be best/lowest */ /* use the first in-range value */ - if (min_uV <= uV && uV <= max_uV) + if (min_uV <= uV && uV <= max_uV) { + if (twl_class_is_6030()) + /* + * Use the below formula to calculate vsel + * mV = 1000mv + 100mv * (vsel - 1) + */ + vsel = (LDO_MV(mV) - 1000)/100 + 1; return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel); + } } - return -EDOM; } @@ -384,8 +390,17 @@ static int twlldo_get_voltage(struct regulator_dev *rdev) if (vsel < 0) return vsel; - vsel &= info->table_len - 1; - return LDO_MV(info->table[vsel]) * 1000; + if (twl_class_is_4030()) { + vsel &= info->table_len - 1; + return LDO_MV(info->table[vsel]) * 1000; + } else if (twl_class_is_6030()) { + /* + * Use the below formula to calculate vsel + * mV = 1000mv + 100mv * (vsel - 1) + */ + return (1000 + (100 * (vsel - 1))) * 1000; + } + return -EDOM; } static struct regulator_ops twlldo_ops = {