From patchwork Mon Aug 29 18:15:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1110012 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7TIV6eu013033 for ; Mon, 29 Aug 2011 18:39:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754692Ab1H2SPQ (ORCPT ); Mon, 29 Aug 2011 14:15:16 -0400 Received: from na3sys009aog113.obsmtp.com ([74.125.149.209]:53491 "EHLO na3sys009aog113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754675Ab1H2SPQ (ORCPT ); Mon, 29 Aug 2011 14:15:16 -0400 Received: from mail-yi0-f51.google.com ([209.85.218.51]) (using TLSv1) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKTlvXM4hubSplB6NVq0Bmh3JJn73AwHqO@postini.com; Mon, 29 Aug 2011 11:15:15 PDT Received: by mail-yi0-f51.google.com with SMTP id 12so3818596yib.38 for ; Mon, 29 Aug 2011 11:15:15 -0700 (PDT) Received: by 10.142.158.16 with SMTP id g16mr2643939wfe.392.1314641694886; Mon, 29 Aug 2011 11:14:54 -0700 (PDT) Received: from localhost.localdomain (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id e3sm19639386pbi.7.2011.08.29.11.14.53 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Aug 2011 11:14:53 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/5] OMAP4: PM: TWL6030: fix voltage conversion formula Date: Mon, 29 Aug 2011 11:15:17 -0700 Message-Id: <1314641721-5172-2-git-send-email-khilman@ti.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1314641721-5172-1-git-send-email-khilman@ti.com> References: <1314641721-5172-1-git-send-email-khilman@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]); Mon, 29 Aug 2011 18:39:40 +0000 (UTC) From: Patrick Titiano omap_twl_vsel_to_uv() and omap_twl_uv_to_vsel() functions used to convert voltages to TWL6030 SMPS commands (a.k.a "vsel") implement incorrect conversion formula. It uses legacy OMAP3 formula, but OMAP4 Power IC has different offset and voltage step: - Voltage Step is now 12.66mV (instead of 12.5mV) - Offset is either 607.7mV or 709mV depending on TWL6030 chip revision (instead of 600mV) This leads to setting voltages potentially higher than expected, and so potentially some (limited) power overconsumption. For reference, see formula and tables in section 8.5.2.3 "Output Voltage Selection (Standard Mode / Extended Mode with or without offset)" in TWL6030 functional specifications document. [nm@ti.com: ported to voltdm_c] Signed-off-by: Nishanth Menon Signed-off-by: Patrick Titiano --- arch/arm/mach-omap2/omap_twl.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c index 6b247d1..a66bf6b 100644 --- a/arch/arm/mach-omap2/omap_twl.c +++ b/arch/arm/mach-omap2/omap_twl.c @@ -106,9 +106,9 @@ static unsigned long twl6030_vsel_to_uv(const u8 vsel) return 1350000; if (smps_offset & 0x8) - return ((((vsel - 1) * 125) + 7000)) * 100; + return ((((vsel - 1) * 1266) + 70900)) * 10; else - return ((((vsel - 1) * 125) + 6000)) * 100; + return ((((vsel - 1) * 1266) + 60770)) * 10; } static u8 twl6030_uv_to_vsel(unsigned long uv) @@ -138,9 +138,9 @@ static u8 twl6030_uv_to_vsel(unsigned long uv) return 0x3A; if (smps_offset & 0x8) - return DIV_ROUND_UP(uv - 700000, 12500) + 1; + return DIV_ROUND_UP(uv - 709000, 12660) + 1; else - return DIV_ROUND_UP(uv - 600000, 12500) + 1; + return DIV_ROUND_UP(uv - 607700, 12660) + 1; } static struct omap_voltdm_pmic omap3_mpu_pmic = { @@ -187,7 +187,7 @@ static struct omap_voltdm_pmic omap3_core_pmic = { static struct omap_voltdm_pmic omap4_mpu_pmic = { .slew_rate = 4000, - .step_size = 12500, + .step_size = 12660, .on_volt = 1350000, .onlp_volt = 1350000, .ret_volt = 837500, @@ -208,7 +208,7 @@ static struct omap_voltdm_pmic omap4_mpu_pmic = { static struct omap_voltdm_pmic omap4_iva_pmic = { .slew_rate = 4000, - .step_size = 12500, + .step_size = 12660, .on_volt = 1100000, .onlp_volt = 1100000, .ret_volt = 837500, @@ -229,7 +229,7 @@ static struct omap_voltdm_pmic omap4_iva_pmic = { static struct omap_voltdm_pmic omap4_core_pmic = { .slew_rate = 4000, - .step_size = 12500, + .step_size = 12660, .on_volt = 1100000, .onlp_volt = 1100000, .ret_volt = 837500,