aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorKevin Hilman <khilman@ti.com>2011-07-15 20:05:48 -0400
committerKevin Hilman <khilman@ti.com>2011-09-15 15:09:08 -0400
commitb666b4767d3e6a23634b4d485c8511bd42d50023 (patch)
tree1ec312c224261b9380b968a10168e0ca1e95194c /arch
parentcc6962dbab223ae51b47c8057d39d89ac6af0d35 (diff)
OMAP3+: VP: combine setting init voltage into common function
combine VPCONFIG init voltage setup into common function and use from both vp_enable and from vp_forceupdate_scale(). NOTE: this patch changes the sequence of when the initVDD bit is cleared. The bit is now cleared immediately after it was written. Since only the rising edge of this bit has any affect according to the TRM, the exact timing of clearing of this bit should not have any effect. Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/vp.c58
1 files changed, 19 insertions, 39 deletions
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 24020ea2b7e4..66bd700a2b98 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -9,31 +9,18 @@
9#include "prm-regbits-44xx.h" 9#include "prm-regbits-44xx.h"
10#include "prm44xx.h" 10#include "prm44xx.h"
11 11
12static void vp_latch_vsel(struct voltagedomain *voltdm) 12static u32 _vp_set_init_voltage(struct voltagedomain *voltdm, u32 volt)
13{ 13{
14 struct omap_vp_instance *vp = voltdm->vp; 14 struct omap_vp_instance *vp = voltdm->vp;
15 u32 vpconfig; 15 u32 vpconfig;
16 unsigned long uvdc;
17 char vsel; 16 char vsel;
18 17
19 uvdc = omap_voltage_get_nom_volt(voltdm); 18 vsel = voltdm->pmic->uv_to_vsel(volt);
20 if (!uvdc) {
21 pr_warning("%s: unable to find current voltage for vdd_%s\n",
22 __func__, voltdm->name);
23 return;
24 }
25
26 if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) {
27 pr_warning("%s: PMIC function to convert voltage in uV to"
28 " vsel not registered\n", __func__);
29 return;
30 }
31
32 vsel = voltdm->pmic->uv_to_vsel(uvdc);
33 19
34 vpconfig = voltdm->read(vp->vpconfig); 20 vpconfig = voltdm->read(vp->vpconfig);
35 vpconfig &= ~(vp->common->vpconfig_initvoltage_mask | 21 vpconfig &= ~(vp->common->vpconfig_initvoltage_mask |
36 vp->common->vpconfig_initvdd); 22 vp->common->vpconfig_forceupdate |
23 vp->common->vpconfig_initvdd);
37 vpconfig |= vsel << __ffs(vp->common->vpconfig_initvoltage_mask); 24 vpconfig |= vsel << __ffs(vp->common->vpconfig_initvoltage_mask);
38 voltdm->write(vpconfig, vp->vpconfig); 25 voltdm->write(vpconfig, vp->vpconfig);
39 26
@@ -43,6 +30,8 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
43 30
44 /* Clear initVDD copy trigger bit */ 31 /* Clear initVDD copy trigger bit */
45 voltdm->write(vpconfig, vp->vpconfig); 32 voltdm->write(vpconfig, vp->vpconfig);
33
34 return vpconfig;
46} 35}
47 36
48/* Generic voltage init functions */ 37/* Generic voltage init functions */
@@ -149,22 +138,11 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
149 return -ETIMEDOUT; 138 return -ETIMEDOUT;
150 } 139 }
151 140
152 /* Configure for VP-Force Update */ 141 vpconfig = _vp_set_init_voltage(voltdm, target_volt);
153 vpconfig = voltdm->read(vp->vpconfig);
154 vpconfig &= ~(vp->common->vpconfig_initvdd |
155 vp->common->vpconfig_forceupdate |
156 vp->common->vpconfig_initvoltage_mask);
157 vpconfig |= ((target_vsel <<
158 __ffs(vp->common->vpconfig_initvoltage_mask)));
159 voltdm->write(vpconfig, vp->vpconfig);
160
161 /* Trigger initVDD value copy to voltage processor */
162 vpconfig |= vp->common->vpconfig_initvdd;
163 voltdm->write(vpconfig, vp->vpconfig);
164 142
165 /* Force update of voltage */ 143 /* Force update of voltage */
166 vpconfig |= vp->common->vpconfig_forceupdate; 144 voltdm->write(vpconfig | vp->common->vpconfig_forceupdate,
167 voltdm->write(vpconfig, vp->vpconfig); 145 voltdm->vp->vpconfig);
168 146
169 /* 147 /*
170 * Wait for TransactionDone. Typical latency is <200us. 148 * Wait for TransactionDone. Typical latency is <200us.
@@ -197,12 +175,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
197 "to clear the TRANXDONE status\n", 175 "to clear the TRANXDONE status\n",
198 __func__, voltdm->name); 176 __func__, voltdm->name);
199 177
200 vpconfig = voltdm->read(vp->vpconfig);
201 /* Clear initVDD copy trigger bit */
202 vpconfig &= ~vp->common->vpconfig_initvdd;
203 voltdm->write(vpconfig, vp->vpconfig);
204 /* Clear force bit */ 178 /* Clear force bit */
205 vpconfig &= ~vp->common->vpconfig_forceupdate;
206 voltdm->write(vpconfig, vp->vpconfig); 179 voltdm->write(vpconfig, vp->vpconfig);
207 180
208 return 0; 181 return 0;
@@ -218,7 +191,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
218void omap_vp_enable(struct voltagedomain *voltdm) 191void omap_vp_enable(struct voltagedomain *voltdm)
219{ 192{
220 struct omap_vp_instance *vp; 193 struct omap_vp_instance *vp;
221 u32 vpconfig; 194 u32 vpconfig, volt;
222 195
223 if (!voltdm || IS_ERR(voltdm)) { 196 if (!voltdm || IS_ERR(voltdm)) {
224 pr_warning("%s: VDD specified does not exist!\n", __func__); 197 pr_warning("%s: VDD specified does not exist!\n", __func__);
@@ -236,12 +209,19 @@ void omap_vp_enable(struct voltagedomain *voltdm)
236 if (vp->enabled) 209 if (vp->enabled)
237 return; 210 return;
238 211
239 vp_latch_vsel(voltdm); 212 volt = voltdm_get_voltage(voltdm);
213 if (!volt) {
214 pr_warning("%s: unable to find current voltage for %s\n",
215 __func__, voltdm->name);
216 return;
217 }
218
219 vpconfig = _vp_set_init_voltage(voltdm, volt);
240 220
241 /* Enable VP */ 221 /* Enable VP */
242 vpconfig = voltdm->read(vp->vpconfig);
243 vpconfig |= vp->common->vpconfig_vpenable; 222 vpconfig |= vp->common->vpconfig_vpenable;
244 voltdm->write(vpconfig, vp->vpconfig); 223 voltdm->write(vpconfig, vp->vpconfig);
224
245 vp->enabled = true; 225 vp->enabled = true;
246} 226}
247 227