From patchwork Wed Oct 27 16:16:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 286142 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 o9RGGkJh013145 for ; Wed, 27 Oct 2010 16:16:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757735Ab0J0QQp (ORCPT ); Wed, 27 Oct 2010 12:16:45 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:56152 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757603Ab0J0QQo (ORCPT ); Wed, 27 Oct 2010 12:16:44 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9RGGdHr029801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Oct 2010 11:16:42 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9RGGbqW009849; Wed, 27 Oct 2010 21:46:37 +0530 (IST) From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: paul@pwsan.com, khilman@deeprootsystems.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PATCH v3 1/6] OMAP4: Add the new voltage to vsel calculation formula Date: Wed, 27 Oct 2010 21:46:31 +0530 Message-Id: <1288196196-15469-2-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1288196196-15469-1-git-send-email-thara@ti.com> References: <1288196196-15469-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 (demeter1.kernel.org [140.211.167.41]); Wed, 27 Oct 2010 16:16:47 +0000 (UTC) diff --git a/arch/arm/plat-omap/opp_twl_tps.c b/arch/arm/plat-omap/opp_twl_tps.c index 4448fc5..358b67b 100644 --- a/arch/arm/plat-omap/opp_twl_tps.c +++ b/arch/arm/plat-omap/opp_twl_tps.c @@ -15,9 +15,16 @@ #include +#include + #include #include +static bool is_offset_valid; +static u8 smps_offset; + +#define REG_SMPS_OFFSET 0xE0 + /** * omap_twl_vsel_to_vdc - convert TWL/TPS VSEL value to microvolts DC * @vsel: TWL/TPS VSEL value to convert @@ -27,6 +34,38 @@ */ unsigned long omap_twl_vsel_to_uv(const u8 vsel) { + if (twl_class_is_6030()) { + /* + * In TWL6030 depending on the value of SMPS_OFFSET + * efuse register the voltage range supported in + * standard mode can be either between 0.6V - 1.3V or + * 0.7V - 1.4V. In TWL6030 ES1.0 SMPS_OFFSET efuse + * is programmed to all 0's where as starting from + * TWL6030 ES1.1 the efuse is programmed to 1 + */ + if (!is_offset_valid) { + twl_i2c_read_u8(TWL6030_MODULE_ID0, &smps_offset, 0xE0); + is_offset_valid = true; + } + + if (smps_offset & 0x8) { + return ((((vsel - 1) * 125) + 7000)) * 100; + } else { + /* + * In case of the supported voltage range being + * between 0.6V - 1.3V, there is not specific + * formula for voltage to vsel conversion above + * 1.3V. There are special hardcoded values for + * voltages above 1.3V. Currently we are hardcodig + * only for 1.35 V which is used for 1GH OPP for + * OMAP4430. + */ + if (vsel == 0x3A) + return 1350000; + return ((((vsel - 1) * 125) + 6000)) * 100; + } + } + return (((vsel * 125) + 6000)) * 100; } @@ -40,6 +79,38 @@ unsigned long omap_twl_vsel_to_uv(const u8 vsel) u8 omap_twl_uv_to_vsel(unsigned long uv) { /* Round up to higher voltage */ + if (twl_class_is_6030()) { + /* + * In TWL6030 depending on the value of SMPS_OFFSET + * efuse register the voltage range supported in + * standard mode can be either between 0.6V - 1.3V or + * 0.7V - 1.4V. In TWL6030 ES1.0 SMPS_OFFSET efuse + * is programmed to all 0's where as starting from + * TWL6030 ES1.1 the efuse is programmed to 1 + */ + if (!is_offset_valid) { + twl_i2c_read_u8(TWL6030_MODULE_ID0, &smps_offset, 0xE0); + is_offset_valid = true; + } + + if (smps_offset & 0x8) { + return DIV_ROUND_UP(uv - 700000, 12500) + 1; + } else { + /* + * In case of the supported voltage range being + * between 0.6V - 1.3V, there is not specific + * formula for voltage to vsel conversion above + * 1.3V. There are special hardcoded values for + * voltages above 1.3V. Currently we are hardcodig + * only for 1.35 V which is used for 1GH OPP for + * OMAP4430. + */ + if (uv == 1350000) + return 0x3A; + return DIV_ROUND_UP(uv - 600000, 12500) + 1; + } + } + return DIV_ROUND_UP(uv - 600000, 12500); }