From patchwork Thu Jun 25 23:56:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sawsd wang X-Patchwork-Id: 32479 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5Q04KET029517 for ; Fri, 26 Jun 2009 00:04:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbZFZAEP (ORCPT ); Thu, 25 Jun 2009 20:04:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752699AbZFZAEP (ORCPT ); Thu, 25 Jun 2009 20:04:15 -0400 Received: from mail-yx0-f186.google.com ([209.85.210.186]:34404 "EHLO mail-yx0-f186.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752683AbZFZAEO (ORCPT ); Thu, 25 Jun 2009 20:04:14 -0400 Received: by yxe16 with SMTP id 16so533293yxe.33 for ; Thu, 25 Jun 2009 17:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=pnDVeRCVT0xu+RnCwsdOojsoWs9nochcufW/pMb2Ya0=; b=G4cCPHqc5ti90wWqzyFvx4hZ4ua02BG85nWFHI5PZqDp/2YU+tsCvu8RZlAhrZBZ/M mbqIEEBN9P8TGpDExeuYrcRDljTHJLYiZu8QTvEotti7n0YQh0NwQMesATpiTtVY4EDh rg0E9K3GgqSEsmmf7pUqj94tmT5vW9WpvO3UI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=OFfYaRa2MCAUxU+B1EjR9lWBlZFQ1fIe10xoYQKxhZURhVFjmG+MRALGZkuVsdj8d7 i1U6uOL08fKuCFxtVO3AcH5A4CIqd73vdtAYc7CWQbf17uq9tkRuwhx0oqEuoeh3cAln XN3FXgOVRwFYXU22+anJpZg75cBZYjOlY3Rug= MIME-Version: 1.0 Received: by 10.231.14.3 with SMTP id e3mr1078219iba.13.1245974160141; Thu, 25 Jun 2009 16:56:00 -0700 (PDT) Date: Fri, 26 Jun 2009 07:56:00 +0800 Message-ID: <1950ceae0906251656k40d9514btd178f3c8ba36d055@mail.gmail.com> Subject: [PATCH 2/2] OMAP3: Implement separate function to send bypass command through VC From: sawsd wang To: linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From 803cbdcd8df3d6f931089979c2dbad8942512cb4 Mon Sep 17 00:00:00 2001 From: Chunqiu Wang Date: Wed, 24 Jun 2009 07:57:17 +0800 Subject: [PATCH] OMAP3: Implement separate function to send bypass command through VC Some system may need use OMAP VC to configure their Power IC, so make the common code to send bypass command using SR VC Signed-off-by: Chunqiu Wang --- arch/arm/mach-omap2/pm.h | 1 + arch/arm/mach-omap2/pm34xx.c | 36 ++++++++++++++++++++++ arch/arm/mach-omap2/smartreflex.c | 59 +++--------------------------------- 3 files changed, 42 insertions(+), 54 deletions(-) @@ -815,31 +789,8 @@ int sr_voltagescale_vcbypass(u32 target_opp, u32 current_opp, reg_addr = R_VDD2_SR_CONTROL; } - vc_bypass_value = (target_vsel << OMAP3430_DATA_SHIFT) | - (reg_addr << OMAP3430_REGADDR_SHIFT) | - (R_SRI2C_SLAVE_ADDR << OMAP3430_SLAVEADDR_SHIFT); - - prm_write_mod_reg(vc_bypass_value, OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - - vc_bypass_value = prm_set_mod_reg_bits(OMAP3430_VALID, OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - - while ((vc_bypass_value & OMAP3430_VALID) != 0x0) { - loop_cnt++; - if (retries_cnt > 10) { - pr_info("Loop count exceeded in check SR I2C" - "write\n"); - return 1; - } - if (loop_cnt > 50) { - retries_cnt++; - loop_cnt = 0; - udelay(10); - } - vc_bypass_value = prm_read_mod_reg(OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - } + if (omap3_vc_bypass_cmd(R_SRI2C_SLAVE_ADDR, reg_addr, target_vsel)) + return 1; /* * T2 SMPS slew rate (min) 4mV/uS, step size 12.5mV, diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index ddc9453..fa118cd 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h @@ -44,6 +44,7 @@ extern int set_pwrdm_state(struct powerdomain *pwrdm, u32 state); extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm); extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state); extern void omap3_set_prm_setup_vc(struct prm_setup_vc *setup_vc); +extern int omap3_vc_bypass_cmd(u8 slave_addr, u8 reg_addr, u8 cmd); #ifdef CONFIG_CPU_IDLE int omap3_idle_init(void); diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 7a4a525..85b0944 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -1135,6 +1136,41 @@ err2: return ret; } +/* Program Power IC via OMAP3 voltage controller bypass interface */ +int omap3_vc_bypass_cmd(u8 slave_addr, u8 reg_addr, u8 cmd) +{ + u32 vc_bypass_value; + u32 loop_cnt = 0, retries_cnt = 0; + + vc_bypass_value = (cmd << OMAP3430_DATA_SHIFT) | + (reg_addr << OMAP3430_REGADDR_SHIFT) | + (slave_addr << OMAP3430_SLAVEADDR_SHIFT); + + prm_write_mod_reg(vc_bypass_value, OMAP3430_GR_MOD, + OMAP3_PRM_VC_BYPASS_VAL_OFFSET); + + vc_bypass_value = prm_set_mod_reg_bits(OMAP3430_VALID, OMAP3430_GR_MOD, + OMAP3_PRM_VC_BYPASS_VAL_OFFSET); + + while ((vc_bypass_value & OMAP3430_VALID) != 0x0) { + loop_cnt++; + if (retries_cnt > 10) { + printk(KERN_ERR"Loop count exceeded in check SR I2C" + "write\n"); + return 1; + } + if (loop_cnt > 50) { + retries_cnt++; + loop_cnt = 0; + udelay(10); + } + vc_bypass_value = prm_read_mod_reg(OMAP3430_GR_MOD, + OMAP3_PRM_VC_BYPASS_VAL_OFFSET); + } + + return 0; +} + static void __init configure_vc(void) { diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index bacf602..2158b5c 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c @@ -35,6 +35,7 @@ #include "prm.h" #include "smartreflex.h" #include "prm-regbits-34xx.h" +#include "pm.h" struct omap_sr { int srid; @@ -449,8 +450,6 @@ static int sr_reset_voltage(int srid) { u32 target_opp_no, vsel = 0; u32 reg_addr = 0; - u32 loop_cnt = 0, retries_cnt = 0; - u32 vc_bypass_value; u32 t2_smps_steps = 0; u32 t2_smps_delay = 0; u32 prm_vp1_voltage, prm_vp2_voltage; @@ -479,31 +478,8 @@ static int sr_reset_voltage(int srid) t2_smps_steps = abs(vsel - prm_vp2_voltage); } - vc_bypass_value = (vsel << OMAP3430_DATA_SHIFT) | - (reg_addr << OMAP3430_REGADDR_SHIFT) | - (R_SRI2C_SLAVE_ADDR << OMAP3430_SLAVEADDR_SHIFT); - - prm_write_mod_reg(vc_bypass_value, OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - - vc_bypass_value = prm_set_mod_reg_bits(OMAP3430_VALID, OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - - while ((vc_bypass_value & OMAP3430_VALID) != 0x0) { - loop_cnt++; - if (retries_cnt > 10) { - pr_info("Loop count exceeded in check SR I2C" - "write\n"); - return 1; - } - if (loop_cnt > 50) { - retries_cnt++; - loop_cnt = 0; - udelay(10); - } - vc_bypass_value = prm_read_mod_reg(OMAP3430_GR_MOD, - OMAP3_PRM_VC_BYPASS_VAL_OFFSET); - } + if (omap3_vc_bypass_cmd(R_SRI2C_SLAVE_ADDR, reg_addr, vsel)) + return 1; /* * T2 SMPS slew rate (min) 4mV/uS, step size 12.5mV, @@ -780,9 +756,7 @@ int sr_voltagescale_vcbypass(u32 target_opp, u32 current_opp, { int sr_status = 0; u32 vdd, target_opp_no, current_opp_no; - u32 vc_bypass_value; u32 reg_addr = 0; - u32 loop_cnt = 0, retries_cnt = 0; u32 t2_smps_steps = 0; u32 t2_smps_delay = 0;