* [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup
@ 2011-08-29 17:58 Kevin Hilman
2011-08-29 17:58 ` [PATCH 01/12] OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames Kevin Hilman
` (12 more replies)
0 siblings, 13 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
This series focuses on cleanup and better abstraction in the voltage
processor (VP) layer.
Available in the pm-wip/voltdm_c branch of my linux-omap-pm tree
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
Applies on v3.1-rc3 + the part A & B series.
Kevin
Kevin Hilman (11):
OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames
OMAP3+: voltage: remove unneeded debugfs interface
OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask)
OMAP3+: VP: move SoC-specific sys clock rate retreival late init
OMAP3+: VP: move timing calculation/config into VP init
OMAP3+: VP: create VP helper function for updating error gain
OMAP3+: VP: remove omap_vp_runtime_data
OMAP3+: VP: move voltage scale function pointer into struct
voltagedomain
OMAP3+: VP: update_errorgain(): return error if VP
OMAP3+: VP: remove unused omap_vp_get_curr_volt()
OMAP3+: VP: combine setting init voltage into common function
Todd Poynor (1):
OMAP: VP: Explicitly mask VPVOLTAGE field
arch/arm/mach-omap2/smartreflex.c | 29 ++-
arch/arm/mach-omap2/vc.c | 22 +--
arch/arm/mach-omap2/voltage.c | 161 ++------------
arch/arm/mach-omap2/voltage.h | 24 +--
arch/arm/mach-omap2/voltagedomains3xxx_data.c | 18 +-
arch/arm/mach-omap2/voltagedomains44xx_data.c | 23 ++-
arch/arm/mach-omap2/vp.c | 292 +++++++++----------------
arch/arm/mach-omap2/vp.h | 91 +++-----
arch/arm/mach-omap2/vp3xxx_data.c | 16 +-
arch/arm/mach-omap2/vp44xx_data.c | 19 +-
10 files changed, 226 insertions(+), 469 deletions(-)
--
1.7.6
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/12] OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 02/12] OMAP3+: voltage: remove unneeded debugfs interface Kevin Hilman
` (11 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
- move VP instance struct from vdd_info into struct voltage domain
- remove _data suffix from structure name
- rename vp_ prefix from vp_common field: accesses are now vp->common
- move vp_enabled bool from vdd_info into VP instance
- remove remaining references to omap_vdd_info
No functional changes.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vc.c | 11 +--
arch/arm/mach-omap2/voltage.c | 4 +-
arch/arm/mach-omap2/voltage.h | 6 +--
arch/arm/mach-omap2/voltagedomains3xxx_data.c | 10 +--
arch/arm/mach-omap2/voltagedomains44xx_data.c | 15 ++---
arch/arm/mach-omap2/vp.c | 88 ++++++++++++-------------
arch/arm/mach-omap2/vp.h | 24 ++++---
arch/arm/mach-omap2/vp3xxx_data.c | 10 ++--
arch/arm/mach-omap2/vp44xx_data.c | 14 ++--
9 files changed, 83 insertions(+), 99 deletions(-)
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 31362cd..d0f87cc 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -98,11 +98,8 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
struct omap_vc_channel *vc = voltdm->vc;
struct omap_vdd_info *vdd = voltdm->vdd;
struct omap_volt_data *volt_data;
- const struct omap_vp_common_data *vp_common;
u32 vc_cmdval, vp_errgain_val;
- vp_common = vdd->vp_data->vp_common;
-
/* Check if sufficient pmic info is available for this vdd */
if (!voltdm->pmic) {
pr_err("%s: Insufficient pmic info to scale the vdd_%s\n",
@@ -139,12 +136,12 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
/* Setting vp errorgain based on the voltage */
if (volt_data) {
- vp_errgain_val = voltdm->read(vdd->vp_data->vpconfig);
+ vp_errgain_val = voltdm->read(voltdm->vp->vpconfig);
vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain;
- vp_errgain_val &= ~vp_common->vpconfig_errorgain_mask;
+ vp_errgain_val &= voltdm->vp->common->vpconfig_errorgain_mask;
vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain <<
- vp_common->vpconfig_errorgain_shift;
- voltdm->write(vp_errgain_val, vdd->vp_data->vpconfig);
+ voltdm->vp->common->vpconfig_errorgain_shift;
+ voltdm->write(vp_errgain_val, voltdm->vp->vpconfig);
}
return 0;
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 94f7fc4..c22b53c 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -81,11 +81,11 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
/* Generic voltage parameters */
vdd->volt_scale = omap_vp_forceupdate_scale;
- vdd->vp_enabled = false;
+ voltdm->vp->enabled = false;
vdd->vp_rt_data.vpconfig_erroroffset =
(voltdm->pmic->vp_erroroffset <<
- vdd->vp_data->vp_common->vpconfig_erroroffset_shift);
+ voltdm->vp->common->vpconfig_erroroffset_shift);
timeout_val = (sys_clk_speed * voltdm->pmic->vp_timeout_us) / 1000;
vdd->vp_rt_data.vlimitto_timeout = timeout_val;
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index a0ae5c6..65f94c7 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -68,6 +68,7 @@ struct voltagedomain {
struct list_head pwrdm_list;
struct omap_vc_channel *vc;
const struct omap_vfsm_instance *vfsm;
+ struct omap_vp_instance *vp;
struct omap_voltdm_pmic *pmic;
/* VC/VP register access functions: SoC specific */
@@ -134,21 +135,16 @@ struct omap_voltdm_pmic {
*
* @volt_data : voltage table having the distinct voltages supported
* by the domain and other associated per voltage data.
- * @vp_data : the register values, shifts, masks for various
- * vp registers
* @vp_rt_data : VP data derived at runtime, not predefined
* @debug_dir : debug directory for this voltage domain.
* @curr_volt : current voltage for this vdd.
- * @vp_enabled : flag to keep track of whether vp is enabled or not
* @volt_scale : API to scale the voltage of the vdd.
*/
struct omap_vdd_info {
struct omap_volt_data *volt_data;
- struct omap_vp_instance_data *vp_data;
struct omap_vp_runtime_data vp_rt_data;
struct dentry *debug_dir;
u32 curr_volt;
- bool vp_enabled;
int (*volt_scale) (struct voltagedomain *voltdm,
unsigned long target_volt);
diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index 4ea9a7b..4db2c6c 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -37,9 +37,7 @@ static const struct omap_vfsm_instance omap3_vdd1_vfsm = {
.voltsetup_mask = OMAP3430_SETUP_TIME1_MASK,
};
-static struct omap_vdd_info omap3_vdd1_info = {
- .vp_data = &omap3_vp1_data,
-};
+static struct omap_vdd_info omap3_vdd1_info;
static const struct omap_vfsm_instance omap3_vdd2_vfsm = {
.voltsetup_reg = OMAP3_PRM_VOLTSETUP1_OFFSET,
@@ -47,9 +45,7 @@ static const struct omap_vfsm_instance omap3_vdd2_vfsm = {
.voltsetup_mask = OMAP3430_SETUP_TIME2_MASK,
};
-static struct omap_vdd_info omap3_vdd2_info = {
- .vp_data = &omap3_vp2_data,
-};
+static struct omap_vdd_info omap3_vdd2_info;
static struct voltagedomain omap3_voltdm_mpu = {
.name = "mpu_iva",
@@ -59,6 +55,7 @@ static struct voltagedomain omap3_voltdm_mpu = {
.rmw = omap3_prm_vcvp_rmw,
.vc = &omap3_vc_mpu,
.vfsm = &omap3_vdd1_vfsm,
+ .vp = &omap3_vp_mpu,
.vdd = &omap3_vdd1_info,
};
@@ -70,6 +67,7 @@ static struct voltagedomain omap3_voltdm_core = {
.rmw = omap3_prm_vcvp_rmw,
.vc = &omap3_vc_core,
.vfsm = &omap3_vdd2_vfsm,
+ .vp = &omap3_vp_core,
.vdd = &omap3_vdd2_info,
};
diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
index dd4bd22..3e7cb4e 100644
--- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
@@ -36,25 +36,19 @@ static const struct omap_vfsm_instance omap4_vdd_mpu_vfsm = {
.voltsetup_reg = OMAP4_PRM_VOLTSETUP_MPU_RET_SLEEP_OFFSET,
};
-static struct omap_vdd_info omap4_vdd_mpu_info = {
- .vp_data = &omap4_vp_mpu_data,
-};
+static struct omap_vdd_info omap4_vdd_mpu_info;
static const struct omap_vfsm_instance omap4_vdd_iva_vfsm = {
.voltsetup_reg = OMAP4_PRM_VOLTSETUP_IVA_RET_SLEEP_OFFSET,
};
-static struct omap_vdd_info omap4_vdd_iva_info = {
- .vp_data = &omap4_vp_iva_data,
-};
+static struct omap_vdd_info omap4_vdd_iva_info;
static const struct omap_vfsm_instance omap4_vdd_core_vfsm = {
.voltsetup_reg = OMAP4_PRM_VOLTSETUP_CORE_RET_SLEEP_OFFSET,
};
-static struct omap_vdd_info omap4_vdd_core_info = {
- .vp_data = &omap4_vp_core_data,
-};
+static struct omap_vdd_info omap4_vdd_core_info;
static struct voltagedomain omap4_voltdm_mpu = {
.name = "mpu",
@@ -64,6 +58,7 @@ static struct voltagedomain omap4_voltdm_mpu = {
.rmw = omap4_prm_vcvp_rmw,
.vc = &omap4_vc_mpu,
.vfsm = &omap4_vdd_mpu_vfsm,
+ .vp = &omap4_vp_mpu,
.vdd = &omap4_vdd_mpu_info,
};
@@ -75,6 +70,7 @@ static struct voltagedomain omap4_voltdm_iva = {
.rmw = omap4_prm_vcvp_rmw,
.vc = &omap4_vc_iva,
.vfsm = &omap4_vdd_iva_vfsm,
+ .vp = &omap4_vp_iva,
.vdd = &omap4_vdd_iva_info,
};
@@ -86,6 +82,7 @@ static struct voltagedomain omap4_voltdm_core = {
.rmw = omap4_prm_vcvp_rmw,
.vc = &omap4_vc_core,
.vfsm = &omap4_vdd_core_vfsm,
+ .vp = &omap4_vp_core,
.vdd = &omap4_vdd_core_info,
};
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index a3afcbe..53d6018 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -14,7 +14,7 @@ static void __init vp_debugfs_init(struct voltagedomain *voltdm);
static void vp_latch_vsel(struct voltagedomain *voltdm)
{
- struct omap_vp_instance_data *vp = voltdm->vdd->vp_data;
+ struct omap_vp_instance *vp = voltdm->vp;
u32 vpconfig;
unsigned long uvdc;
char vsel;
@@ -35,14 +35,14 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
vsel = voltdm->pmic->uv_to_vsel(uvdc);
vpconfig = voltdm->read(vp->vpconfig);
- vpconfig &= ~(vp->vp_common->vpconfig_initvoltage_mask |
- vp->vp_common->vpconfig_initvdd);
- vpconfig |= vsel << vp->vp_common->vpconfig_initvoltage_shift;
+ vpconfig &= ~(vp->common->vpconfig_initvoltage_mask |
+ vp->common->vpconfig_initvdd);
+ vpconfig |= vsel << vp->common->vpconfig_initvoltage_shift;
voltdm->write(vpconfig, vp->vpconfig);
/* Trigger initVDD value copy to voltage processor */
- voltdm->write((vpconfig | vp->vp_common->vpconfig_initvdd),
+ voltdm->write((vpconfig | vp->common->vpconfig_initvdd),
vp->vpconfig);
/* Clear initVDD copy trigger bit */
@@ -52,7 +52,7 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
/* Generic voltage init functions */
void __init omap_vp_init(struct voltagedomain *voltdm)
{
- struct omap_vp_instance_data *vp = voltdm->vdd->vp_data;
+ struct omap_vp_instance *vp = voltdm->vp;
struct omap_vdd_info *vdd = voltdm->vdd;
u32 vp_val;
@@ -64,28 +64,28 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
(vdd->vp_rt_data.vpconfig_errorgain <<
- vp->vp_common->vpconfig_errorgain_shift) |
- vp->vp_common->vpconfig_timeouten;
+ vp->common->vpconfig_errorgain_shift) |
+ vp->common->vpconfig_timeouten;
voltdm->write(vp_val, vp->vpconfig);
vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin <<
- vp->vp_common->vstepmin_smpswaittimemin_shift) |
+ vp->common->vstepmin_smpswaittimemin_shift) |
(vdd->vp_rt_data.vstepmin_stepmin <<
- vp->vp_common->vstepmin_stepmin_shift));
+ vp->common->vstepmin_stepmin_shift));
voltdm->write(vp_val, vp->vstepmin);
vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax <<
- vp->vp_common->vstepmax_smpswaittimemax_shift) |
+ vp->common->vstepmax_smpswaittimemax_shift) |
(vdd->vp_rt_data.vstepmax_stepmax <<
- vp->vp_common->vstepmax_stepmax_shift));
+ vp->common->vstepmax_stepmax_shift));
voltdm->write(vp_val, vp->vstepmax);
vp_val = ((vdd->vp_rt_data.vlimitto_vddmax <<
- vp->vp_common->vlimitto_vddmax_shift) |
+ vp->common->vlimitto_vddmax_shift) |
(vdd->vp_rt_data.vlimitto_vddmin <<
- vp->vp_common->vlimitto_vddmin_shift) |
+ vp->common->vlimitto_vddmin_shift) |
(vdd->vp_rt_data.vlimitto_timeout <<
- vp->vp_common->vlimitto_timeout_shift));
+ vp->common->vlimitto_timeout_shift));
voltdm->write(vp_val, vp->vlimitto);
vp_debugfs_init(voltdm);
@@ -95,7 +95,7 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
unsigned long target_volt)
{
- struct omap_vp_instance_data *vp = voltdm->vdd->vp_data;
+ struct omap_vp_instance *vp = voltdm->vp;
u32 vpconfig;
u8 target_vsel, current_vsel;
int ret, timeout = 0;
@@ -109,8 +109,8 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
* is <3us
*/
while (timeout++ < VP_TRANXDONE_TIMEOUT) {
- vp->vp_common->ops->clear_txdone(vp->id);
- if (!vp->vp_common->ops->check_txdone(vp->id))
+ vp->common->ops->clear_txdone(vp->id);
+ if (!vp->common->ops->check_txdone(vp->id))
break;
udelay(1);
}
@@ -122,19 +122,19 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
/* Configure for VP-Force Update */
vpconfig = voltdm->read(vp->vpconfig);
- vpconfig &= ~(vp->vp_common->vpconfig_initvdd |
- vp->vp_common->vpconfig_forceupdate |
- vp->vp_common->vpconfig_initvoltage_mask);
+ vpconfig &= ~(vp->common->vpconfig_initvdd |
+ vp->common->vpconfig_forceupdate |
+ vp->common->vpconfig_initvoltage_mask);
vpconfig |= ((target_vsel <<
- vp->vp_common->vpconfig_initvoltage_shift));
+ vp->common->vpconfig_initvoltage_shift));
voltdm->write(vpconfig, vp->vpconfig);
/* Trigger initVDD value copy to voltage processor */
- vpconfig |= vp->vp_common->vpconfig_initvdd;
+ vpconfig |= vp->common->vpconfig_initvdd;
voltdm->write(vpconfig, vp->vpconfig);
/* Force update of voltage */
- vpconfig |= vp->vp_common->vpconfig_forceupdate;
+ vpconfig |= vp->common->vpconfig_forceupdate;
voltdm->write(vpconfig, vp->vpconfig);
/*
@@ -142,7 +142,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
* Depends on SMPSWAITTIMEMIN/MAX and voltage change
*/
timeout = 0;
- omap_test_timeout(vp->vp_common->ops->check_txdone(vp->id),
+ omap_test_timeout(vp->common->ops->check_txdone(vp->id),
VP_TRANXDONE_TIMEOUT, timeout);
if (timeout >= VP_TRANXDONE_TIMEOUT)
pr_err("%s: vdd_%s TRANXDONE timeout exceeded."
@@ -157,8 +157,8 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
*/
timeout = 0;
while (timeout++ < VP_TRANXDONE_TIMEOUT) {
- vp->vp_common->ops->clear_txdone(vp->id);
- if (!vp->vp_common->ops->check_txdone(vp->id))
+ vp->common->ops->clear_txdone(vp->id);
+ if (!vp->common->ops->check_txdone(vp->id))
break;
udelay(1);
}
@@ -170,10 +170,10 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
vpconfig = voltdm->read(vp->vpconfig);
/* Clear initVDD copy trigger bit */
- vpconfig &= ~vp->vp_common->vpconfig_initvdd;
+ vpconfig &= ~vp->common->vpconfig_initvdd;
voltdm->write(vpconfig, vp->vpconfig);
/* Clear force bit */
- vpconfig &= ~vp->vp_common->vpconfig_forceupdate;
+ vpconfig &= ~vp->common->vpconfig_forceupdate;
voltdm->write(vpconfig, vp->vpconfig);
return 0;
@@ -187,8 +187,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
*/
unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
{
- struct omap_vp_instance_data *vp = voltdm->vdd->vp_data;
- struct omap_vdd_info *vdd;
+ struct omap_vp_instance *vp = voltdm->vp;
u8 curr_vsel;
if (!voltdm || IS_ERR(voltdm)) {
@@ -196,7 +195,6 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
return 0;
}
- vdd = voltdm->vdd;
if (!voltdm->read) {
pr_err("%s: No read API for reading vdd_%s regs\n",
__func__, voltdm->name);
@@ -223,8 +221,7 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
*/
void omap_vp_enable(struct voltagedomain *voltdm)
{
- struct omap_vp_instance_data *vp;
- struct omap_vdd_info *vdd;
+ struct omap_vp_instance *vp;
u32 vpconfig;
if (!voltdm || IS_ERR(voltdm)) {
@@ -232,8 +229,7 @@ void omap_vp_enable(struct voltagedomain *voltdm)
return;
}
- vdd = voltdm->vdd;
- vp = voltdm->vdd->vp_data;
+ vp = voltdm->vp;
if (!voltdm->read || !voltdm->write) {
pr_err("%s: No read/write API for accessing vdd_%s regs\n",
__func__, voltdm->name);
@@ -241,16 +237,16 @@ void omap_vp_enable(struct voltagedomain *voltdm)
}
/* If VP is already enabled, do nothing. Return */
- if (vdd->vp_enabled)
+ if (vp->enabled)
return;
vp_latch_vsel(voltdm);
/* Enable VP */
vpconfig = voltdm->read(vp->vpconfig);
- vpconfig |= vp->vp_common->vpconfig_vpenable;
+ vpconfig |= vp->common->vpconfig_vpenable;
voltdm->write(vpconfig, vp->vpconfig);
- vdd->vp_enabled = true;
+ vp->enabled = true;
}
/**
@@ -262,8 +258,7 @@ void omap_vp_enable(struct voltagedomain *voltdm)
*/
void omap_vp_disable(struct voltagedomain *voltdm)
{
- struct omap_vp_instance_data *vp;
- struct omap_vdd_info *vdd;
+ struct omap_vp_instance *vp;
u32 vpconfig;
int timeout;
@@ -272,8 +267,7 @@ void omap_vp_disable(struct voltagedomain *voltdm)
return;
}
- vdd = voltdm->vdd;
- vp = voltdm->vdd->vp_data;
+ vp = voltdm->vp;
if (!voltdm->read || !voltdm->write) {
pr_err("%s: No read/write API for accessing vdd_%s regs\n",
__func__, voltdm->name);
@@ -281,7 +275,7 @@ void omap_vp_disable(struct voltagedomain *voltdm)
}
/* If VP is already disabled, do nothing. Return */
- if (!vdd->vp_enabled) {
+ if (!vp->enabled) {
pr_warning("%s: Trying to disable VP for vdd_%s when"
"it is already disabled\n", __func__, voltdm->name);
return;
@@ -289,7 +283,7 @@ void omap_vp_disable(struct voltagedomain *voltdm)
/* Disable VP */
vpconfig = voltdm->read(vp->vpconfig);
- vpconfig &= ~vp->vp_common->vpconfig_vpenable;
+ vpconfig &= ~vp->common->vpconfig_vpenable;
voltdm->write(vpconfig, vp->vpconfig);
/*
@@ -302,7 +296,7 @@ void omap_vp_disable(struct voltagedomain *voltdm)
pr_warning("%s: vdd_%s idle timedout\n",
__func__, voltdm->name);
- vdd->vp_enabled = false;
+ vp->enabled = false;
return;
}
@@ -311,7 +305,7 @@ void omap_vp_disable(struct voltagedomain *voltdm)
static int vp_volt_debug_get(void *data, u64 *val)
{
struct voltagedomain *voltdm = (struct voltagedomain *)data;
- struct omap_vp_instance_data *vp = voltdm->vdd->vp_data;
+ struct omap_vp_instance *vp = voltdm->vp;
struct omap_vdd_info *vdd = voltdm->vdd;
u8 vsel;
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 79aa8d3..1d63960 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -45,7 +45,7 @@ struct omap_vp_ops {
};
/**
- * struct omap_vp_common_data - register data common to all VDDs
+ * struct omap_vp_common - register data common to all VDDs
* @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
@@ -67,7 +67,7 @@ struct omap_vp_ops {
* bitfield - remove one
* XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix!
*/
-struct omap_vp_common_data {
+struct omap_vp_common {
u32 vpconfig_errorgain_mask;
u32 vpconfig_initvoltage_mask;
u32 vpconfig_timeouten;
@@ -89,18 +89,19 @@ struct omap_vp_common_data {
};
/**
- * struct omap_vp_instance_data - VP register offsets (per-VDD)
- * @vp_common: pointer to struct omap_vp_common_data * for this SoC
+ * struct omap_vp_instance - VP register offsets (per-VDD)
+ * @common: pointer to struct omap_vp_common * for this SoC
* @vpconfig: PRM_VP*_CONFIG reg offset from PRM start
* @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start
* @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start
* @vstatus: PRM_VP*_VSTATUS reg offset from PRM start
* @voltage: PRM_VP*_VOLTAGE reg offset from PRM start
+ * @enabled: flag to keep track of whether vp is enabled or not
*
* XXX vp_common is probably not needed since it is per-SoC
*/
-struct omap_vp_instance_data {
- const struct omap_vp_common_data *vp_common;
+struct omap_vp_instance {
+ const struct omap_vp_common *common;
u8 vpconfig;
u8 vstepmin;
u8 vstepmax;
@@ -108,6 +109,7 @@ struct omap_vp_instance_data {
u8 vstatus;
u8 voltage;
u8 id;
+ bool enabled;
};
/**
@@ -139,12 +141,12 @@ struct omap_vp_runtime_data {
u8 vlimitto_vddmax;
};
-extern struct omap_vp_instance_data omap3_vp1_data;
-extern struct omap_vp_instance_data omap3_vp2_data;
+extern struct omap_vp_instance omap3_vp_mpu;
+extern struct omap_vp_instance omap3_vp_core;
-extern struct omap_vp_instance_data omap4_vp_mpu_data;
-extern struct omap_vp_instance_data omap4_vp_iva_data;
-extern struct omap_vp_instance_data omap4_vp_core_data;
+extern struct omap_vp_instance omap4_vp_mpu;
+extern struct omap_vp_instance omap4_vp_iva;
+extern struct omap_vp_instance omap4_vp_core;
void omap_vp_init(struct voltagedomain *voltdm);
void omap_vp_enable(struct voltagedomain *voltdm);
diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
index b01d333..79c3df9 100644
--- a/arch/arm/mach-omap2/vp3xxx_data.c
+++ b/arch/arm/mach-omap2/vp3xxx_data.c
@@ -36,7 +36,7 @@ static const struct omap_vp_ops omap3_vp_ops = {
* VP data common to 34xx/36xx chips
* XXX This stuff presumably belongs in the vp3xxx.c or vp.c file.
*/
-static const struct omap_vp_common_data omap3_vp_common = {
+static const struct omap_vp_common omap3_vp_common = {
.vpconfig_erroroffset_shift = OMAP3430_ERROROFFSET_SHIFT,
.vpconfig_errorgain_mask = OMAP3430_ERRORGAIN_MASK,
.vpconfig_errorgain_shift = OMAP3430_ERRORGAIN_SHIFT,
@@ -56,9 +56,9 @@ static const struct omap_vp_common_data omap3_vp_common = {
.ops = &omap3_vp_ops,
};
-struct omap_vp_instance_data omap3_vp1_data = {
+struct omap_vp_instance omap3_vp_mpu = {
.id = OMAP3_VP_VDD_MPU_ID,
- .vp_common = &omap3_vp_common,
+ .common = &omap3_vp_common,
.vpconfig = OMAP3_PRM_VP1_CONFIG_OFFSET,
.vstepmin = OMAP3_PRM_VP1_VSTEPMIN_OFFSET,
.vstepmax = OMAP3_PRM_VP1_VSTEPMAX_OFFSET,
@@ -67,9 +67,9 @@ struct omap_vp_instance_data omap3_vp1_data = {
.voltage = OMAP3_PRM_VP1_VOLTAGE_OFFSET,
};
-struct omap_vp_instance_data omap3_vp2_data = {
+struct omap_vp_instance omap3_vp_core = {
.id = OMAP3_VP_VDD_CORE_ID,
- .vp_common = &omap3_vp_common,
+ .common = &omap3_vp_common,
.vpconfig = OMAP3_PRM_VP2_CONFIG_OFFSET,
.vstepmin = OMAP3_PRM_VP2_VSTEPMIN_OFFSET,
.vstepmax = OMAP3_PRM_VP2_VSTEPMAX_OFFSET,
diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
index 9704c7b..8f75cd9 100644
--- a/arch/arm/mach-omap2/vp44xx_data.c
+++ b/arch/arm/mach-omap2/vp44xx_data.c
@@ -36,7 +36,7 @@ static const struct omap_vp_ops omap4_vp_ops = {
* VP data common to 44xx chips
* XXX This stuff presumably belongs in the vp44xx.c or vp.c file.
*/
-static const struct omap_vp_common_data omap4_vp_common = {
+static const struct omap_vp_common omap4_vp_common = {
.vpconfig_erroroffset_shift = OMAP4430_ERROROFFSET_SHIFT,
.vpconfig_errorgain_mask = OMAP4430_ERRORGAIN_MASK,
.vpconfig_errorgain_shift = OMAP4430_ERRORGAIN_SHIFT,
@@ -56,9 +56,9 @@ static const struct omap_vp_common_data omap4_vp_common = {
.ops = &omap4_vp_ops,
};
-struct omap_vp_instance_data omap4_vp_mpu_data = {
+struct omap_vp_instance omap4_vp_mpu = {
.id = OMAP4_VP_VDD_MPU_ID,
- .vp_common = &omap4_vp_common,
+ .common = &omap4_vp_common,
.vpconfig = OMAP4_PRM_VP_MPU_CONFIG_OFFSET,
.vstepmin = OMAP4_PRM_VP_MPU_VSTEPMIN_OFFSET,
.vstepmax = OMAP4_PRM_VP_MPU_VSTEPMAX_OFFSET,
@@ -67,9 +67,9 @@ struct omap_vp_instance_data omap4_vp_mpu_data = {
.voltage = OMAP4_PRM_VP_MPU_VOLTAGE_OFFSET,
};
-struct omap_vp_instance_data omap4_vp_iva_data = {
+struct omap_vp_instance omap4_vp_iva = {
.id = OMAP4_VP_VDD_IVA_ID,
- .vp_common = &omap4_vp_common,
+ .common = &omap4_vp_common,
.vpconfig = OMAP4_PRM_VP_IVA_CONFIG_OFFSET,
.vstepmin = OMAP4_PRM_VP_IVA_VSTEPMIN_OFFSET,
.vstepmax = OMAP4_PRM_VP_IVA_VSTEPMAX_OFFSET,
@@ -78,9 +78,9 @@ struct omap_vp_instance_data omap4_vp_iva_data = {
.voltage = OMAP4_PRM_VP_IVA_VOLTAGE_OFFSET,
};
-struct omap_vp_instance_data omap4_vp_core_data = {
+struct omap_vp_instance omap4_vp_core = {
.id = OMAP4_VP_VDD_CORE_ID,
- .vp_common = &omap4_vp_common,
+ .common = &omap4_vp_common,
.vpconfig = OMAP4_PRM_VP_CORE_CONFIG_OFFSET,
.vstepmin = OMAP4_PRM_VP_CORE_VSTEPMIN_OFFSET,
.vstepmax = OMAP4_PRM_VP_CORE_VSTEPMAX_OFFSET,
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/12] OMAP3+: voltage: remove unneeded debugfs interface
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
2011-08-29 17:58 ` [PATCH 01/12] OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 03/12] OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask) Kevin Hilman
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Remove read-only debugfs interface to VP values. Most of the values
are init-time only and never change. Current voltage value should be
retreived from the (eventual) regulator framework interface to the
voltage domain.
Fixes to original version provided by Nishanth Menon <nm@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/smartreflex.c | 29 +++++++++-----
arch/arm/mach-omap2/voltage.c | 78 -------------------------------------
arch/arm/mach-omap2/voltage.h | 3 -
arch/arm/mach-omap2/vp.c | 63 -----------------------------
4 files changed, 19 insertions(+), 154 deletions(-)
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 34c01a7..bb606c9 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -62,6 +62,7 @@ static LIST_HEAD(sr_list);
static struct omap_sr_class_data *sr_class;
static struct omap_sr_pmic_data *sr_pmic_data;
+static struct dentry *sr_dbg_dir;
static inline void sr_write_reg(struct omap_sr *sr, unsigned offset, u32 value)
{
@@ -826,9 +827,10 @@ static int __init omap_sr_probe(struct platform_device *pdev)
struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
struct omap_sr_data *pdata = pdev->dev.platform_data;
struct resource *mem, *irq;
- struct dentry *vdd_dbg_dir, *nvalue_dir;
+ struct dentry *nvalue_dir;
struct omap_volt_data *volt_data;
int i, ret = 0;
+ char *name;
if (!sr_info) {
dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
@@ -899,18 +901,25 @@ static int __init omap_sr_probe(struct platform_device *pdev)
}
dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
+ if (!sr_dbg_dir) {
+ sr_dbg_dir = debugfs_create_dir("smartreflex", NULL);
+ if (!sr_dbg_dir) {
+ ret = PTR_ERR(sr_dbg_dir);
+ pr_err("%s:sr debugfs dir creation failed(%d)\n",
+ __func__, ret);
+ goto err_iounmap;
+ }
+ }
- /*
- * If the voltage domain debugfs directory is not created, do
- * not try to create rest of the debugfs entries.
- */
- vdd_dbg_dir = omap_voltage_get_dbgdir(sr_info->voltdm);
- if (!vdd_dbg_dir) {
- ret = -EINVAL;
+ name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
+ if (!name) {
+ dev_err(&pdev->dev, "%s: Unable to alloc debugfs name\n",
+ __func__);
+ ret = -ENOMEM;
goto err_iounmap;
}
-
- sr_info->dbg_dir = debugfs_create_dir("smartreflex", vdd_dbg_dir);
+ sr_info->dbg_dir = debugfs_create_dir(name, sr_dbg_dir);
+ kfree(name);
if (IS_ERR(sr_info->dbg_dir)) {
dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
__func__);
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index c22b53c..eaa5f93 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -43,9 +43,6 @@
static LIST_HEAD(voltdm_list);
-#define VOLTAGE_DIR_SIZE 16
-static struct dentry *voltage_dir;
-
static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
{
char *sys_ck_name;
@@ -102,51 +99,6 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
return 0;
}
-static int nom_volt_debug_get(void *data, u64 *val)
-{
- struct voltagedomain *voltdm = (struct voltagedomain *)data;
-
- if (!voltdm) {
- pr_warning("Wrong paramater passed\n");
- return -EINVAL;
- }
-
- *val = omap_voltage_get_nom_volt(voltdm);
-
- return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(nom_volt_debug_fops, nom_volt_debug_get, NULL,
- "%llu\n");
-static void __init vdd_debugfs_init(struct voltagedomain *voltdm)
-{
- char *name;
- struct omap_vdd_info *vdd = voltdm->vdd;
-
- name = kzalloc(VOLTAGE_DIR_SIZE, GFP_KERNEL);
- if (!name) {
- pr_warning("%s: Unable to allocate memory for debugfs"
- " directory name for vdd_%s",
- __func__, voltdm->name);
- return;
- }
- strcpy(name, "vdd_");
- strcat(name, voltdm->name);
-
- vdd->debug_dir = debugfs_create_dir(name, voltage_dir);
- kfree(name);
- if (IS_ERR(vdd->debug_dir)) {
- pr_warning("%s: Unable to create debugfs directory for"
- " vdd_%s\n", __func__, voltdm->name);
- vdd->debug_dir = NULL;
- return;
- }
-
- (void) debugfs_create_file("curr_nominal_volt", S_IRUGO,
- vdd->debug_dir, (void *) voltdm,
- &nom_volt_debug_fops);
-}
-
static int __init omap_vdd_data_configure(struct voltagedomain *voltdm)
{
int ret = -EINVAL;
@@ -342,31 +294,6 @@ int omap_voltage_register_pmic(struct voltagedomain *voltdm,
}
/**
- * omap_voltage_get_dbgdir() - API to get pointer to the debugfs directory
- * corresponding to a voltage domain.
- *
- * @voltdm: pointer to the VDD whose debug directory is required.
- *
- * This API returns pointer to the debugfs directory corresponding
- * to the voltage domain. Should be used by drivers requiring to
- * add any debug entry for a particular voltage domain. Returns NULL
- * in case of error.
- */
-struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm)
-{
- struct omap_vdd_info *vdd;
-
- if (!voltdm || IS_ERR(voltdm)) {
- pr_warning("%s: VDD specified does not exist!\n", __func__);
- return NULL;
- }
-
- vdd = voltdm->vdd;
-
- return vdd->debug_dir;
-}
-
-/**
* omap_change_voltscale_method() - API to change the voltage scaling method.
* @voltdm: pointer to the VDD whose voltage scaling method
* has to be changed.
@@ -418,10 +345,6 @@ int __init omap_voltage_late_init(void)
return -EINVAL;
}
- voltage_dir = debugfs_create_dir("voltage", NULL);
- if (IS_ERR(voltage_dir))
- pr_err("%s: Unable to create voltage debugfs main dir\n",
- __func__);
list_for_each_entry(voltdm, &voltdm_list, node) {
if (!voltdm->scalable)
continue;
@@ -434,7 +357,6 @@ int __init omap_voltage_late_init(void)
if (voltdm->vdd) {
if (omap_vdd_data_configure(voltdm))
continue;
- vdd_debugfs_init(voltdm);
omap_vp_init(voltdm);
}
}
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 65f94c7..5261703 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -136,14 +136,12 @@ struct omap_voltdm_pmic {
* @volt_data : voltage table having the distinct voltages supported
* by the domain and other associated per voltage data.
* @vp_rt_data : VP data derived at runtime, not predefined
- * @debug_dir : debug directory for this voltage domain.
* @curr_volt : current voltage for this vdd.
* @volt_scale : API to scale the voltage of the vdd.
*/
struct omap_vdd_info {
struct omap_volt_data *volt_data;
struct omap_vp_runtime_data vp_rt_data;
- struct dentry *debug_dir;
u32 curr_volt;
int (*volt_scale) (struct voltagedomain *voltdm,
@@ -158,7 +156,6 @@ void omap_voltage_get_volttable(struct voltagedomain *voltdm,
struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
unsigned long volt);
unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
-struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
#ifdef CONFIG_PM
int omap_voltage_register_pmic(struct voltagedomain *voltdm,
struct omap_voltdm_pmic *pmic);
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 53d6018..c9a315f 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -1,6 +1,5 @@
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/debugfs.h>
#include <plat/common.h>
@@ -10,8 +9,6 @@
#include "prm-regbits-44xx.h"
#include "prm44xx.h"
-static void __init vp_debugfs_init(struct voltagedomain *voltdm);
-
static void vp_latch_vsel(struct voltagedomain *voltdm)
{
struct omap_vp_instance *vp = voltdm->vp;
@@ -87,8 +84,6 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
(vdd->vp_rt_data.vlimitto_timeout <<
vp->common->vlimitto_timeout_shift));
voltdm->write(vp_val, vp->vlimitto);
-
- vp_debugfs_init(voltdm);
}
/* VP force update method of voltage scaling */
@@ -300,61 +295,3 @@ void omap_vp_disable(struct voltagedomain *voltdm)
return;
}
-
-/* Voltage debugfs support */
-static int vp_volt_debug_get(void *data, u64 *val)
-{
- struct voltagedomain *voltdm = (struct voltagedomain *)data;
- struct omap_vp_instance *vp = voltdm->vp;
- struct omap_vdd_info *vdd = voltdm->vdd;
- u8 vsel;
-
- if (!vdd) {
- pr_warning("Wrong paramater passed\n");
- return -EINVAL;
- }
-
- vsel = voltdm->read(vp->voltage);
-
- if (!voltdm->pmic->vsel_to_uv) {
- pr_warning("PMIC function to convert vsel to voltage"
- "in uV not registerd\n");
- return -EINVAL;
- }
-
- *val = voltdm->pmic->vsel_to_uv(vsel);
- return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(vp_volt_debug_fops, vp_volt_debug_get, NULL, "%llu\n");
-
-static void __init vp_debugfs_init(struct voltagedomain *voltdm)
-{
- struct omap_vdd_info *vdd = voltdm->vdd;
- struct dentry *debug_dir;
-
- debug_dir = debugfs_create_dir("vp", vdd->debug_dir);
- if (IS_ERR(debug_dir))
- pr_err("%s: Unable to create VP debugfs dir dir\n", __func__);
-
- (void) debugfs_create_x16("errorgain", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vpconfig_errorgain));
- (void) debugfs_create_x16("smpswaittimemin", S_IRUGO,
- debug_dir,
- &(vdd->vp_rt_data.vstepmin_smpswaittimemin));
- (void) debugfs_create_x8("stepmin", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vstepmin_stepmin));
- (void) debugfs_create_x16("smpswaittimemax", S_IRUGO,
- debug_dir,
- &(vdd->vp_rt_data.vstepmax_smpswaittimemax));
- (void) debugfs_create_x8("stepmax", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vstepmax_stepmax));
- (void) debugfs_create_x8("vddmax", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vlimitto_vddmax));
- (void) debugfs_create_x8("vddmin", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vlimitto_vddmin));
- (void) debugfs_create_x16("timeout", S_IRUGO, debug_dir,
- &(vdd->vp_rt_data.vlimitto_timeout));
- (void) debugfs_create_file("curr_volt", S_IRUGO, debug_dir,
- (void *) voltdm, &vp_volt_debug_fops);
-}
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/12] OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask)
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
2011-08-29 17:58 ` [PATCH 01/12] OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames Kevin Hilman
2011-08-29 17:58 ` [PATCH 02/12] OMAP3+: voltage: remove unneeded debugfs interface Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 04/12] OMAP3+: VP: move SoC-specific sys clock rate retreival late init Kevin Hilman
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
In struct omap_vp_common, the shift value can be derived from the mask
value by using __ffs(), so remove the shift value for the various
VPCONFIG bitfields, and use __ffs() in the code for the shift value.
While here, rename field names in kerneldoc comment to match actual
field names in structure. Also, cleanup indendentaion for other VP
register accesses in omap_vp_init().
No functional changes.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vc.c | 2 +-
arch/arm/mach-omap2/voltage.c | 2 +-
arch/arm/mach-omap2/vp.c | 29 ++++++++++++++---------------
arch/arm/mach-omap2/vp.h | 34 ++++++++++++++--------------------
arch/arm/mach-omap2/vp3xxx_data.c | 4 +---
arch/arm/mach-omap2/vp44xx_data.c | 4 +---
6 files changed, 32 insertions(+), 43 deletions(-)
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index d0f87cc..d615a0d 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -140,7 +140,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain;
vp_errgain_val &= voltdm->vp->common->vpconfig_errorgain_mask;
vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain <<
- voltdm->vp->common->vpconfig_errorgain_shift;
+ __ffs(voltdm->vp->common->vpconfig_errorgain_mask);
voltdm->write(vp_errgain_val, voltdm->vp->vpconfig);
}
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index eaa5f93..5b16fd1 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -82,7 +82,7 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
vdd->vp_rt_data.vpconfig_erroroffset =
(voltdm->pmic->vp_erroroffset <<
- voltdm->vp->common->vpconfig_erroroffset_shift);
+ __ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
timeout_val = (sys_clk_speed * voltdm->pmic->vp_timeout_us) / 1000;
vdd->vp_rt_data.vlimitto_timeout = timeout_val;
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index c9a315f..297d094 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -34,8 +34,7 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
vpconfig = voltdm->read(vp->vpconfig);
vpconfig &= ~(vp->common->vpconfig_initvoltage_mask |
vp->common->vpconfig_initvdd);
- vpconfig |= vsel << vp->common->vpconfig_initvoltage_shift;
-
+ vpconfig |= vsel << __ffs(vp->common->vpconfig_initvoltage_mask);
voltdm->write(vpconfig, vp->vpconfig);
/* Trigger initVDD value copy to voltage processor */
@@ -61,28 +60,28 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
(vdd->vp_rt_data.vpconfig_errorgain <<
- vp->common->vpconfig_errorgain_shift) |
+ __ffs(vp->common->vpconfig_errorgain_mask)) |
vp->common->vpconfig_timeouten;
voltdm->write(vp_val, vp->vpconfig);
vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin <<
- vp->common->vstepmin_smpswaittimemin_shift) |
- (vdd->vp_rt_data.vstepmin_stepmin <<
- vp->common->vstepmin_stepmin_shift));
+ vp->common->vstepmin_smpswaittimemin_shift) |
+ (vdd->vp_rt_data.vstepmin_stepmin <<
+ vp->common->vstepmin_stepmin_shift));
voltdm->write(vp_val, vp->vstepmin);
vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax <<
- vp->common->vstepmax_smpswaittimemax_shift) |
- (vdd->vp_rt_data.vstepmax_stepmax <<
- vp->common->vstepmax_stepmax_shift));
+ vp->common->vstepmax_smpswaittimemax_shift) |
+ (vdd->vp_rt_data.vstepmax_stepmax <<
+ vp->common->vstepmax_stepmax_shift));
voltdm->write(vp_val, vp->vstepmax);
vp_val = ((vdd->vp_rt_data.vlimitto_vddmax <<
- vp->common->vlimitto_vddmax_shift) |
- (vdd->vp_rt_data.vlimitto_vddmin <<
- vp->common->vlimitto_vddmin_shift) |
- (vdd->vp_rt_data.vlimitto_timeout <<
- vp->common->vlimitto_timeout_shift));
+ vp->common->vlimitto_vddmax_shift) |
+ (vdd->vp_rt_data.vlimitto_vddmin <<
+ vp->common->vlimitto_vddmin_shift) |
+ (vdd->vp_rt_data.vlimitto_timeout <<
+ vp->common->vlimitto_timeout_shift));
voltdm->write(vp_val, vp->vlimitto);
}
@@ -121,7 +120,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
vp->common->vpconfig_forceupdate |
vp->common->vpconfig_initvoltage_mask);
vpconfig |= ((target_vsel <<
- vp->common->vpconfig_initvoltage_shift));
+ __ffs(vp->common->vpconfig_initvoltage_mask)));
voltdm->write(vpconfig, vp->vpconfig);
/* Trigger initVDD value copy to voltage processor */
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 1d63960..2afe11d 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -46,37 +46,32 @@ struct omap_vp_ops {
/**
* struct omap_vp_common - register data common to all VDDs
+ * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
* @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
* @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
* @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
- * @vpconfig_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
- * @vpconfig_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
- * @vpconfig_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
- * @vpconfig_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
- * @vpconfig_vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
- * @vpconfig_vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
- * @vpconfig_vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
- *
- * XXX It it not necessary to have both a mask and a shift for the same
- * bitfield - remove one
- * XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix!
+ * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
+ * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
+ * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
+ * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
+ * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
+ * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
+ * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
*/
struct omap_vp_common {
+ u32 vpconfig_erroroffset_mask;
u32 vpconfig_errorgain_mask;
u32 vpconfig_initvoltage_mask;
- u32 vpconfig_timeouten;
- u32 vpconfig_initvdd;
- u32 vpconfig_forceupdate;
- u32 vpconfig_vpenable;
- u8 vpconfig_erroroffset_shift;
- u8 vpconfig_errorgain_shift;
- u8 vpconfig_initvoltage_shift;
+ u8 vpconfig_timeouten;
+ u8 vpconfig_initvdd;
+ u8 vpconfig_forceupdate;
+ u8 vpconfig_vpenable;
u8 vstepmin_stepmin_shift;
u8 vstepmin_smpswaittimemin_shift;
u8 vstepmax_stepmax_shift;
@@ -127,7 +122,6 @@ struct omap_vp_instance {
* XXX Is this structure really needed? Why not just program the
* device directly? They are in PRM space, therefore in the WKUP
* powerdomain, so register contents should not be lost in off-mode.
- * XXX Some of these fields are incorrectly named, e.g., vstep*
*/
struct omap_vp_runtime_data {
u32 vpconfig_erroroffset;
diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
index 79c3df9..d429c44 100644
--- a/arch/arm/mach-omap2/vp3xxx_data.c
+++ b/arch/arm/mach-omap2/vp3xxx_data.c
@@ -37,10 +37,8 @@ static const struct omap_vp_ops omap3_vp_ops = {
* XXX This stuff presumably belongs in the vp3xxx.c or vp.c file.
*/
static const struct omap_vp_common omap3_vp_common = {
- .vpconfig_erroroffset_shift = OMAP3430_ERROROFFSET_SHIFT,
+ .vpconfig_erroroffset_mask = OMAP3430_ERROROFFSET_MASK,
.vpconfig_errorgain_mask = OMAP3430_ERRORGAIN_MASK,
- .vpconfig_errorgain_shift = OMAP3430_ERRORGAIN_SHIFT,
- .vpconfig_initvoltage_shift = OMAP3430_INITVOLTAGE_SHIFT,
.vpconfig_initvoltage_mask = OMAP3430_INITVOLTAGE_MASK,
.vpconfig_timeouten = OMAP3430_TIMEOUTEN_MASK,
.vpconfig_initvdd = OMAP3430_INITVDD_MASK,
diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
index 8f75cd9..0daf2a4 100644
--- a/arch/arm/mach-omap2/vp44xx_data.c
+++ b/arch/arm/mach-omap2/vp44xx_data.c
@@ -37,10 +37,8 @@ static const struct omap_vp_ops omap4_vp_ops = {
* XXX This stuff presumably belongs in the vp44xx.c or vp.c file.
*/
static const struct omap_vp_common omap4_vp_common = {
- .vpconfig_erroroffset_shift = OMAP4430_ERROROFFSET_SHIFT,
+ .vpconfig_erroroffset_mask = OMAP4430_ERROROFFSET_MASK,
.vpconfig_errorgain_mask = OMAP4430_ERRORGAIN_MASK,
- .vpconfig_errorgain_shift = OMAP4430_ERRORGAIN_SHIFT,
- .vpconfig_initvoltage_shift = OMAP4430_INITVOLTAGE_SHIFT,
.vpconfig_initvoltage_mask = OMAP4430_INITVOLTAGE_MASK,
.vpconfig_timeouten = OMAP4430_TIMEOUTEN_MASK,
.vpconfig_initvdd = OMAP4430_INITVDD_MASK,
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/12] OMAP3+: VP: move SoC-specific sys clock rate retreival late init
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (2 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 03/12] OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask) Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 05/12] OMAP3+: VP: move timing calculation/config into VP init Kevin Hilman
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Add sys clock name and rate to struct voltage domain. SoC specific
voltagedomain init code initializes sys clock name. After clock
framework is initialized, voltage late init will then use use the
sys_clk rate to calculate the various timing that depend on that rate.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/voltage.c | 47 +++++++++----------------
arch/arm/mach-omap2/voltage.h | 5 +++
arch/arm/mach-omap2/voltagedomains3xxx_data.c | 8 ++++
arch/arm/mach-omap2/voltagedomains44xx_data.c | 8 ++++
4 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 5b16fd1..533ea38 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -21,10 +21,10 @@
#include <linux/delay.h>
#include <linux/io.h>
-#include <linux/clk.h>
#include <linux/err.h>
#include <linux/debugfs.h>
#include <linux/slab.h>
+#include <linux/clk.h>
#include <plat/common.h>
@@ -45,36 +45,12 @@ static LIST_HEAD(voltdm_list);
static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
{
- char *sys_ck_name;
- struct clk *sys_ck;
- u32 sys_clk_speed, timeout_val, waittime;
struct omap_vdd_info *vdd = voltdm->vdd;
+ u32 sys_clk_rate, timeout_val, waittime;
- /*
- * XXX Clockfw should handle this, or this should be in a
- * struct record
- */
- if (cpu_is_omap24xx() || cpu_is_omap34xx())
- sys_ck_name = "sys_ck";
- else if (cpu_is_omap44xx())
- sys_ck_name = "sys_clkin_ck";
- else
- return -EINVAL;
-
- /*
- * Sys clk rate is require to calculate vp timeout value and
- * smpswaittimemin and smpswaittimemax.
- */
- sys_ck = clk_get(NULL, sys_ck_name);
- if (IS_ERR(sys_ck)) {
- pr_warning("%s: Could not get the sys clk to calculate"
- "various vdd_%s params\n", __func__, voltdm->name);
- return -EINVAL;
- }
- sys_clk_speed = clk_get_rate(sys_ck);
- clk_put(sys_ck);
/* Divide to avoid overflow */
- sys_clk_speed /= 1000;
+ sys_clk_rate = voltdm->sys_clk.rate / 1000;
+ WARN_ON(!sys_clk_rate);
/* Generic voltage parameters */
vdd->volt_scale = omap_vp_forceupdate_scale;
@@ -84,13 +60,13 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
(voltdm->pmic->vp_erroroffset <<
__ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
- timeout_val = (sys_clk_speed * voltdm->pmic->vp_timeout_us) / 1000;
+ timeout_val = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
vdd->vp_rt_data.vlimitto_timeout = timeout_val;
vdd->vp_rt_data.vlimitto_vddmin = voltdm->pmic->vp_vddmin;
vdd->vp_rt_data.vlimitto_vddmax = voltdm->pmic->vp_vddmax;
waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
- sys_clk_speed) / 1000;
+ sys_clk_rate) / 1000;
vdd->vp_rt_data.vstepmin_smpswaittimemin = waittime;
vdd->vp_rt_data.vstepmax_smpswaittimemax = waittime;
vdd->vp_rt_data.vstepmin_stepmin = voltdm->pmic->vp_vstepmin;
@@ -346,9 +322,20 @@ int __init omap_voltage_late_init(void)
}
list_for_each_entry(voltdm, &voltdm_list, node) {
+ struct clk *sys_ck;
+
if (!voltdm->scalable)
continue;
+ sys_ck = clk_get(NULL, voltdm->sys_clk.name);
+ if (IS_ERR(sys_ck)) {
+ pr_warning("%s: Could not get sys clk.\n", __func__);
+ return -EINVAL;
+ }
+ voltdm->sys_clk.rate = clk_get_rate(sys_ck);
+ WARN_ON(!voltdm->sys_clk.rate);
+ clk_put(sys_ck);
+
if (voltdm->vc) {
voltdm->vdd->volt_scale = omap_vc_bypass_scale;
omap_vc_init_channel(voltdm);
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 5261703..d73c956 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -76,6 +76,11 @@ struct voltagedomain {
void (*write) (u32 val, u8 offset);
u32 (*rmw)(u32 mask, u32 bits, u8 offset);
+ union {
+ const char *name;
+ u32 rate;
+ } sys_clk;
+
struct omap_vdd_info *vdd;
};
diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index 4db2c6c..e7a0be1 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -82,8 +82,13 @@ static struct voltagedomain *voltagedomains_omap3[] __initdata = {
NULL,
};
+static const char *sys_clk_name __initdata = "sys_ck";
+
void __init omap3xxx_voltagedomains_init(void)
{
+ struct voltagedomain *voltdm;
+ int i;
+
/*
* XXX Will depend on the process, validation, and binning
* for the currently-running IC
@@ -96,5 +101,8 @@ void __init omap3xxx_voltagedomains_init(void)
omap3_vdd2_info.volt_data = omap34xx_vddcore_volt_data;
}
+ for (i = 0; voltdm = voltagedomains_omap3[i], voltdm; i++)
+ voltdm->sys_clk.name = sys_clk_name;
+
voltdm_init(voltagedomains_omap3);
};
diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
index 3e7cb4e..9c20fbb 100644
--- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
@@ -98,8 +98,13 @@ static struct voltagedomain *voltagedomains_omap4[] __initdata = {
NULL,
};
+static const char *sys_clk_name __initdata = "sys_clkin_ck";
+
void __init omap44xx_voltagedomains_init(void)
{
+ struct voltagedomain *voltdm;
+ int i;
+
/*
* XXX Will depend on the process, validation, and binning
* for the currently-running IC
@@ -108,5 +113,8 @@ void __init omap44xx_voltagedomains_init(void)
omap4_vdd_iva_info.volt_data = omap44xx_vdd_iva_volt_data;
omap4_vdd_core_info.volt_data = omap44xx_vdd_core_volt_data;
+ for (i = 0; voltdm = voltagedomains_omap4[i], voltdm; i++)
+ voltdm->sys_clk.name = sys_clk_name;
+
voltdm_init(voltagedomains_omap4);
};
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/12] OMAP3+: VP: move timing calculation/config into VP init
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (3 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 04/12] OMAP3+: VP: move SoC-specific sys clock rate retreival late init Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 06/12] OMAP3+: VP: create VP helper function for updating error gain Kevin Hilman
` (7 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Move VP timing calcluation (based on sys clock) and register programming
into VP init.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/voltage.c | 22 ----------------------
arch/arm/mach-omap2/vp.c | 23 ++++++++++++++++++++++-
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 533ea38..4a15668 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -46,31 +46,9 @@ static LIST_HEAD(voltdm_list);
static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
{
struct omap_vdd_info *vdd = voltdm->vdd;
- u32 sys_clk_rate, timeout_val, waittime;
-
- /* Divide to avoid overflow */
- sys_clk_rate = voltdm->sys_clk.rate / 1000;
- WARN_ON(!sys_clk_rate);
/* Generic voltage parameters */
vdd->volt_scale = omap_vp_forceupdate_scale;
- voltdm->vp->enabled = false;
-
- vdd->vp_rt_data.vpconfig_erroroffset =
- (voltdm->pmic->vp_erroroffset <<
- __ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
-
- timeout_val = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
- vdd->vp_rt_data.vlimitto_timeout = timeout_val;
- vdd->vp_rt_data.vlimitto_vddmin = voltdm->pmic->vp_vddmin;
- vdd->vp_rt_data.vlimitto_vddmax = voltdm->pmic->vp_vddmax;
-
- waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
- sys_clk_rate) / 1000;
- vdd->vp_rt_data.vstepmin_smpswaittimemin = waittime;
- vdd->vp_rt_data.vstepmax_smpswaittimemax = waittime;
- vdd->vp_rt_data.vstepmin_stepmin = voltdm->pmic->vp_vstepmin;
- vdd->vp_rt_data.vstepmax_stepmax = voltdm->pmic->vp_vstepmax;
return 0;
}
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 297d094..ea61a47 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -50,7 +50,7 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
{
struct omap_vp_instance *vp = voltdm->vp;
struct omap_vdd_info *vdd = voltdm->vdd;
- u32 vp_val;
+ u32 vp_val, sys_clk_rate, timeout_val, waittime;
if (!voltdm->read || !voltdm->write) {
pr_err("%s: No read/write API for accessing vdd_%s regs\n",
@@ -58,6 +58,27 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
return;
}
+ vp->enabled = false;
+
+ /* Divide to avoid overflow */
+ sys_clk_rate = voltdm->sys_clk.rate / 1000;
+
+ vdd->vp_rt_data.vpconfig_erroroffset =
+ (voltdm->pmic->vp_erroroffset <<
+ __ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
+
+ timeout_val = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
+ vdd->vp_rt_data.vlimitto_timeout = timeout_val;
+ vdd->vp_rt_data.vlimitto_vddmin = voltdm->pmic->vp_vddmin;
+ vdd->vp_rt_data.vlimitto_vddmax = voltdm->pmic->vp_vddmax;
+
+ waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
+ sys_clk_rate) / 1000;
+ vdd->vp_rt_data.vstepmin_smpswaittimemin = waittime;
+ vdd->vp_rt_data.vstepmax_smpswaittimemax = waittime;
+ vdd->vp_rt_data.vstepmin_stepmin = voltdm->pmic->vp_vstepmin;
+ vdd->vp_rt_data.vstepmax_stepmax = voltdm->pmic->vp_vstepmax;
+
vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
(vdd->vp_rt_data.vpconfig_errorgain <<
__ffs(vp->common->vpconfig_errorgain_mask)) |
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/12] OMAP3+: VP: create VP helper function for updating error gain
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (4 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 05/12] OMAP3+: VP: move timing calculation/config into VP init Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 07/12] OMAP3+: VP: remove omap_vp_runtime_data Kevin Hilman
` (6 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Create new helper function in VP layer for updating VP error gain.
Currently used during pre-scale for VP force update and VC bypass.
TODO: determine if this can be removed from the pre-scale path and
moved to VP enable path.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vc.c | 19 ++-----------------
arch/arm/mach-omap2/vp.c | 19 +++++++++++++++++++
arch/arm/mach-omap2/vp.h | 2 ++
3 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index d615a0d..38ba13b 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -96,9 +96,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
u8 *target_vsel, u8 *current_vsel)
{
struct omap_vc_channel *vc = voltdm->vc;
- struct omap_vdd_info *vdd = voltdm->vdd;
- struct omap_volt_data *volt_data;
- u32 vc_cmdval, vp_errgain_val;
+ u32 vc_cmdval;
/* Check if sufficient pmic info is available for this vdd */
if (!voltdm->pmic) {
@@ -120,11 +118,6 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
return -EINVAL;
}
- /* Get volt_data corresponding to target_volt */
- volt_data = omap_voltage_get_voltdata(voltdm, target_volt);
- if (IS_ERR(volt_data))
- volt_data = NULL;
-
*target_vsel = voltdm->pmic->uv_to_vsel(target_volt);
*current_vsel = voltdm->pmic->uv_to_vsel(vdd->curr_volt);
@@ -134,15 +127,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
voltdm->write(vc_cmdval, vc->cmdval_reg);
- /* Setting vp errorgain based on the voltage */
- if (volt_data) {
- vp_errgain_val = voltdm->read(voltdm->vp->vpconfig);
- vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain;
- vp_errgain_val &= voltdm->vp->common->vpconfig_errorgain_mask;
- vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain <<
- __ffs(voltdm->vp->common->vpconfig_errorgain_mask);
- voltdm->write(vp_errgain_val, voltdm->vp->vpconfig);
- }
+ omap_vp_update_errorgain(voltdm, target_volt);
return 0;
}
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index ea61a47..f68a6db 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -106,6 +106,25 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
voltdm->write(vp_val, vp->vlimitto);
}
+int omap_vp_update_errorgain(struct voltagedomain *voltdm,
+ unsigned long target_volt)
+{
+ struct omap_volt_data *volt_data;
+
+ /* Get volt_data corresponding to target_volt */
+ volt_data = omap_voltage_get_voltdata(voltdm, target_volt);
+ if (IS_ERR(volt_data))
+ return -EINVAL;
+
+ /* Setting vp errorgain based on the voltage */
+ voltdm->rmw(voltdm->vp->common->vpconfig_errorgain_mask,
+ volt_data->vp_errgain <<
+ __ffs(voltdm->vp->common->vpconfig_errorgain_mask),
+ voltdm->vp->vpconfig);
+
+ return 0;
+}
+
/* VP force update method of voltage scaling */
int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
unsigned long target_volt)
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 2afe11d..71ac738 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -148,5 +148,7 @@ void omap_vp_disable(struct voltagedomain *voltdm);
unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
unsigned long target_volt);
+int omap_vp_update_errorgain(struct voltagedomain *voltdm,
+ unsigned long target_volt);
#endif
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/12] OMAP3+: VP: remove omap_vp_runtime_data
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (5 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 06/12] OMAP3+: VP: create VP helper function for updating error gain Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 08/12] OMAP3+: VP: move voltage scale function pointer into struct voltagedomain Kevin Hilman
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Remove the "runtime" VP data in favor of direct programming of VP registers.
The VP is in the PRM, which is in the wakeup powerdomain, so there is no
need to keep the state dynamically.
Fixes to original version from Nishanth Menon <nm@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/voltage.h | 2 -
arch/arm/mach-omap2/vp.c | 70 ++++++++++++++++++-----------------------
arch/arm/mach-omap2/vp.h | 28 ----------------
3 files changed, 31 insertions(+), 69 deletions(-)
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index d73c956..5235eec 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -140,13 +140,11 @@ struct omap_voltdm_pmic {
*
* @volt_data : voltage table having the distinct voltages supported
* by the domain and other associated per voltage data.
- * @vp_rt_data : VP data derived at runtime, not predefined
* @curr_volt : current voltage for this vdd.
* @volt_scale : API to scale the voltage of the vdd.
*/
struct omap_vdd_info {
struct omap_volt_data *volt_data;
- struct omap_vp_runtime_data vp_rt_data;
u32 curr_volt;
int (*volt_scale) (struct voltagedomain *voltdm,
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index f68a6db..e7d38f6 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -49,8 +49,8 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
void __init omap_vp_init(struct voltagedomain *voltdm)
{
struct omap_vp_instance *vp = voltdm->vp;
- struct omap_vdd_info *vdd = voltdm->vdd;
- u32 vp_val, sys_clk_rate, timeout_val, waittime;
+ u32 val, sys_clk_rate, timeout, waittime;
+ u32 vddmin, vddmax, vstepmin, vstepmax;
if (!voltdm->read || !voltdm->write) {
pr_err("%s: No read/write API for accessing vdd_%s regs\n",
@@ -63,47 +63,39 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
/* Divide to avoid overflow */
sys_clk_rate = voltdm->sys_clk.rate / 1000;
- vdd->vp_rt_data.vpconfig_erroroffset =
- (voltdm->pmic->vp_erroroffset <<
- __ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
-
- timeout_val = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
- vdd->vp_rt_data.vlimitto_timeout = timeout_val;
- vdd->vp_rt_data.vlimitto_vddmin = voltdm->pmic->vp_vddmin;
- vdd->vp_rt_data.vlimitto_vddmax = voltdm->pmic->vp_vddmax;
+ timeout = (sys_clk_rate * voltdm->pmic->vp_timeout_us) / 1000;
+ vddmin = voltdm->pmic->vp_vddmin;
+ vddmax = voltdm->pmic->vp_vddmax;
waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
sys_clk_rate) / 1000;
- vdd->vp_rt_data.vstepmin_smpswaittimemin = waittime;
- vdd->vp_rt_data.vstepmax_smpswaittimemax = waittime;
- vdd->vp_rt_data.vstepmin_stepmin = voltdm->pmic->vp_vstepmin;
- vdd->vp_rt_data.vstepmax_stepmax = voltdm->pmic->vp_vstepmax;
-
- vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
- (vdd->vp_rt_data.vpconfig_errorgain <<
- __ffs(vp->common->vpconfig_errorgain_mask)) |
+ vstepmin = voltdm->pmic->vp_vstepmin;
+ vstepmax = voltdm->pmic->vp_vstepmax;
+
+ /*
+ * VP_CONFIG: error gain is not set here, it will be updated
+ * on each scale, based on OPP.
+ */
+ val = (voltdm->pmic->vp_erroroffset <<
+ __ffs(voltdm->vp->common->vpconfig_erroroffset_mask)) |
vp->common->vpconfig_timeouten;
- voltdm->write(vp_val, vp->vpconfig);
-
- vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin <<
- vp->common->vstepmin_smpswaittimemin_shift) |
- (vdd->vp_rt_data.vstepmin_stepmin <<
- vp->common->vstepmin_stepmin_shift));
- voltdm->write(vp_val, vp->vstepmin);
-
- vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax <<
- vp->common->vstepmax_smpswaittimemax_shift) |
- (vdd->vp_rt_data.vstepmax_stepmax <<
- vp->common->vstepmax_stepmax_shift));
- voltdm->write(vp_val, vp->vstepmax);
-
- vp_val = ((vdd->vp_rt_data.vlimitto_vddmax <<
- vp->common->vlimitto_vddmax_shift) |
- (vdd->vp_rt_data.vlimitto_vddmin <<
- vp->common->vlimitto_vddmin_shift) |
- (vdd->vp_rt_data.vlimitto_timeout <<
- vp->common->vlimitto_timeout_shift));
- voltdm->write(vp_val, vp->vlimitto);
+ voltdm->write(val, vp->vpconfig);
+
+ /* VSTEPMIN */
+ val = (waittime << vp->common->vstepmin_smpswaittimemin_shift) |
+ (vstepmin << vp->common->vstepmin_stepmin_shift);
+ voltdm->write(val, vp->vstepmin);
+
+ /* VSTEPMAX */
+ val = (vstepmax << vp->common->vstepmax_stepmax_shift) |
+ (waittime << vp->common->vstepmax_smpswaittimemax_shift);
+ voltdm->write(val, vp->vstepmax);
+
+ /* VLIMITTO */
+ val = (vddmax << vp->common->vlimitto_vddmax_shift) |
+ (vddmin << vp->common->vlimitto_vddmin_shift) |
+ (timeout << vp->common->vlimitto_timeout_shift);
+ voltdm->write(val, vp->vlimitto);
}
int omap_vp_update_errorgain(struct voltagedomain *voltdm,
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 71ac738..0d63267 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -107,34 +107,6 @@ struct omap_vp_instance {
bool enabled;
};
-/**
- * struct omap_vp_runtime_data - VP data populated at runtime by code
- * @vpconfig_erroroffset: value of ERROROFFSET bitfield in PRM_VP*_CONFIG
- * @vpconfig_errorgain: value of ERRORGAIN bitfield in PRM_VP*_CONFIG
- * @vstepmin_smpswaittimemin: value of SMPSWAITTIMEMIN bitfield in PRM_VP*_VSTEPMIN
- * @vstepmax_smpswaittimemax: value of SMPSWAITTIMEMAX bitfield in PRM_VP*_VSTEPMAX
- * @vlimitto_timeout: value of TIMEOUT bitfield in PRM_VP*_VLIMITTO
- * @vstepmin_stepmin: value of VSTEPMIN bitfield in PRM_VP*_VSTEPMIN
- * @vstepmax_stepmax: value of VSTEPMAX bitfield in PRM_VP*_VSTEPMAX
- * @vlimitto_vddmin: value of VDDMIN bitfield in PRM_VP*_VLIMITTO
- * @vlimitto_vddmax: value of VDDMAX bitfield in PRM_VP*_VLIMITTO
- *
- * XXX Is this structure really needed? Why not just program the
- * device directly? They are in PRM space, therefore in the WKUP
- * powerdomain, so register contents should not be lost in off-mode.
- */
-struct omap_vp_runtime_data {
- u32 vpconfig_erroroffset;
- u16 vpconfig_errorgain;
- u16 vstepmin_smpswaittimemin;
- u16 vstepmax_smpswaittimemax;
- u16 vlimitto_timeout;
- u8 vstepmin_stepmin;
- u8 vstepmax_stepmax;
- u8 vlimitto_vddmin;
- u8 vlimitto_vddmax;
-};
-
extern struct omap_vp_instance omap3_vp_mpu;
extern struct omap_vp_instance omap3_vp_core;
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/12] OMAP3+: VP: move voltage scale function pointer into struct voltagedomain
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (6 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 07/12] OMAP3+: VP: remove omap_vp_runtime_data Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field Kevin Hilman
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Function pointer used for actual voltage scaling (e.g. VP force update
or VC bypass) is moved from omap_vdd_info into struct voltagedomain,
resulting in renames s/vdd->volt_scale/voltdm->scale/
No functional changes.
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/voltage.c | 24 +++++++-----------------
arch/arm/mach-omap2/voltage.h | 8 ++++----
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index 4a15668..32f0873 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -45,10 +45,8 @@ static LIST_HEAD(voltdm_list);
static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
{
- struct omap_vdd_info *vdd = voltdm->vdd;
-
/* Generic voltage parameters */
- vdd->volt_scale = omap_vp_forceupdate_scale;
+ voltdm->scale = omap_vp_forceupdate_scale;
return 0;
}
@@ -107,22 +105,18 @@ unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm)
int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
unsigned long target_volt)
{
- struct omap_vdd_info *vdd;
-
if (!voltdm || IS_ERR(voltdm)) {
pr_warning("%s: VDD specified does not exist!\n", __func__);
return -EINVAL;
}
- vdd = voltdm->vdd;
-
- if (!vdd->volt_scale) {
+ if (!voltdm->scale) {
pr_err("%s: No voltage scale API registered for vdd_%s\n",
__func__, voltdm->name);
return -ENODATA;
}
- return vdd->volt_scale(voltdm, target_volt);
+ return voltdm->scale(voltdm, target_volt);
}
/**
@@ -258,23 +252,19 @@ int omap_voltage_register_pmic(struct voltagedomain *voltdm,
* defined in voltage.h
*/
void omap_change_voltscale_method(struct voltagedomain *voltdm,
- int voltscale_method)
+ int voltscale_method)
{
- struct omap_vdd_info *vdd;
-
if (!voltdm || IS_ERR(voltdm)) {
pr_warning("%s: VDD specified does not exist!\n", __func__);
return;
}
- vdd = voltdm->vdd;
-
switch (voltscale_method) {
case VOLTSCALE_VPFORCEUPDATE:
- vdd->volt_scale = omap_vp_forceupdate_scale;
+ voltdm->scale = omap_vp_forceupdate_scale;
return;
case VOLTSCALE_VCBYPASS:
- vdd->volt_scale = omap_vc_bypass_scale;
+ voltdm->scale = omap_vc_bypass_scale;
return;
default:
pr_warning("%s: Trying to change the method of voltage scaling"
@@ -315,7 +305,7 @@ int __init omap_voltage_late_init(void)
clk_put(sys_ck);
if (voltdm->vc) {
- voltdm->vdd->volt_scale = omap_vc_bypass_scale;
+ voltdm->scale = omap_vc_bypass_scale;
omap_vc_init_channel(voltdm);
}
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 5235eec..d2a0c24 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -60,6 +60,7 @@ struct omap_vfsm_instance {
* @pwrdm_node: list_head linking all powerdomains in this voltagedomain
* @vdd: to be removed
* @pwrdms: powerdomains in this voltagedomain
+ * @scale: function used to scale the voltage of the voltagedomain
*/
struct voltagedomain {
char *name;
@@ -81,6 +82,9 @@ struct voltagedomain {
u32 rate;
} sys_clk;
+ int (*scale) (struct voltagedomain *voltdm,
+ unsigned long target_volt);
+
struct omap_vdd_info *vdd;
};
@@ -141,14 +145,10 @@ struct omap_voltdm_pmic {
* @volt_data : voltage table having the distinct voltages supported
* by the domain and other associated per voltage data.
* @curr_volt : current voltage for this vdd.
- * @volt_scale : API to scale the voltage of the vdd.
*/
struct omap_vdd_info {
struct omap_volt_data *volt_data;
u32 curr_volt;
-
- int (*volt_scale) (struct voltagedomain *voltdm,
- unsigned long target_volt);
};
int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (7 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 08/12] OMAP3+: VP: move voltage scale function pointer into struct voltagedomain Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-09-07 12:31 ` Jean Pihet
2011-08-29 17:58 ` [PATCH 10/12] OMAP3+: VP: update_errorgain(): return error if VP Kevin Hilman
` (3 subsequent siblings)
12 siblings, 1 reply; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
From: Todd Poynor <toddpoynor@google.com>
Reading the VPVOLTAGE field of PRM_VP_*_VOLTAGE registers currently
relies on a u32 -> u8 conversion to mask off the FORCEUPDATEWAIT field
in the upper bits. Make this explicit using the mask symbol
already defined, added as a new field in struct omap_vp_common.
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vp.c | 3 ++-
arch/arm/mach-omap2/vp.h | 2 ++
arch/arm/mach-omap2/vp3xxx_data.c | 2 ++
arch/arm/mach-omap2/vp44xx_data.c | 1 +
4 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index e7d38f6..3807620 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -227,7 +227,8 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
return 0;
}
- curr_vsel = voltdm->read(vp->voltage);
+ curr_vsel = (voltdm->read(vp->voltage) & vp->common->vpvoltage_mask)
+ >> __ffs(vp->common->vpvoltage_mask);
if (!voltdm->pmic || !voltdm->pmic->vsel_to_uv) {
pr_warning("%s: PMIC function to convert vsel to voltage"
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index 0d63267..f78752b 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -63,6 +63,7 @@ struct omap_vp_ops {
* @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
* @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
* @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
+ * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg
*/
struct omap_vp_common {
u32 vpconfig_erroroffset_mask;
@@ -79,6 +80,7 @@ struct omap_vp_common {
u8 vlimitto_vddmin_shift;
u8 vlimitto_vddmax_shift;
u8 vlimitto_timeout_shift;
+ u8 vpvoltage_mask;
const struct omap_vp_ops *ops;
};
diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
index d429c44..260c554 100644
--- a/arch/arm/mach-omap2/vp3xxx_data.c
+++ b/arch/arm/mach-omap2/vp3xxx_data.c
@@ -51,6 +51,8 @@ static const struct omap_vp_common omap3_vp_common = {
.vlimitto_vddmin_shift = OMAP3430_VDDMIN_SHIFT,
.vlimitto_vddmax_shift = OMAP3430_VDDMAX_SHIFT,
.vlimitto_timeout_shift = OMAP3430_TIMEOUT_SHIFT,
+ .vpvoltage_mask = OMAP3430_VPVOLTAGE_MASK,
+
.ops = &omap3_vp_ops,
};
diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
index 0daf2a4..b4e7704 100644
--- a/arch/arm/mach-omap2/vp44xx_data.c
+++ b/arch/arm/mach-omap2/vp44xx_data.c
@@ -51,6 +51,7 @@ static const struct omap_vp_common omap4_vp_common = {
.vlimitto_vddmin_shift = OMAP4430_VDDMIN_SHIFT,
.vlimitto_vddmax_shift = OMAP4430_VDDMAX_SHIFT,
.vlimitto_timeout_shift = OMAP4430_TIMEOUT_SHIFT,
+ .vpvoltage_mask = OMAP4430_VPVOLTAGE_MASK,
.ops = &omap4_vp_ops,
};
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/12] OMAP3+: VP: update_errorgain(): return error if VP
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (8 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 11/12] OMAP3+: VP: remove unused omap_vp_get_curr_volt() Kevin Hilman
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Add check for valid VP in omap_vp_update_errorgain()
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vp.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 3807620..29698ac 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -103,6 +103,9 @@ int omap_vp_update_errorgain(struct voltagedomain *voltdm,
{
struct omap_volt_data *volt_data;
+ if (!voltdm->vp)
+ return -EINVAL;
+
/* Get volt_data corresponding to target_volt */
volt_data = omap_voltage_get_voltdata(voltdm, target_volt);
if (IS_ERR(volt_data))
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/12] OMAP3+: VP: remove unused omap_vp_get_curr_volt()
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (9 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 10/12] OMAP3+: VP: update_errorgain(): return error if VP Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-08-29 17:58 ` [PATCH 12/12] OMAP3+: VP: combine setting init voltage into common function Kevin Hilman
2011-09-07 19:11 ` [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Jean Pihet
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Kevin Hilman <khilman@ti.com>
---
arch/arm/mach-omap2/vp.c | 34 ----------------------------------
arch/arm/mach-omap2/vp.h | 1 -
2 files changed, 0 insertions(+), 35 deletions(-)
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 29698ac..24020ea 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -209,40 +209,6 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
}
/**
- * omap_vp_get_curr_volt() - API to get the current vp voltage.
- * @voltdm: pointer to the VDD.
- *
- * This API returns the current voltage for the specified voltage processor
- */
-unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
-{
- struct omap_vp_instance *vp = voltdm->vp;
- u8 curr_vsel;
-
- if (!voltdm || IS_ERR(voltdm)) {
- pr_warning("%s: VDD specified does not exist!\n", __func__);
- return 0;
- }
-
- if (!voltdm->read) {
- pr_err("%s: No read API for reading vdd_%s regs\n",
- __func__, voltdm->name);
- return 0;
- }
-
- curr_vsel = (voltdm->read(vp->voltage) & vp->common->vpvoltage_mask)
- >> __ffs(vp->common->vpvoltage_mask);
-
- if (!voltdm->pmic || !voltdm->pmic->vsel_to_uv) {
- pr_warning("%s: PMIC function to convert vsel to voltage"
- "in uV not registerd\n", __func__);
- return 0;
- }
-
- return voltdm->pmic->vsel_to_uv(curr_vsel);
-}
-
-/**
* omap_vp_enable() - API to enable a particular VP
* @voltdm: pointer to the VDD whose VP is to be enabled.
*
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
index f78752b..d9bc4f1 100644
--- a/arch/arm/mach-omap2/vp.h
+++ b/arch/arm/mach-omap2/vp.h
@@ -119,7 +119,6 @@ extern struct omap_vp_instance omap4_vp_core;
void omap_vp_init(struct voltagedomain *voltdm);
void omap_vp_enable(struct voltagedomain *voltdm);
void omap_vp_disable(struct voltagedomain *voltdm);
-unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
unsigned long target_volt);
int omap_vp_update_errorgain(struct voltagedomain *voltdm,
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/12] OMAP3+: VP: combine setting init voltage into common function
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (10 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 11/12] OMAP3+: VP: remove unused omap_vp_get_curr_volt() Kevin Hilman
@ 2011-08-29 17:58 ` Kevin Hilman
2011-09-07 19:11 ` [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Jean Pihet
12 siblings, 0 replies; 15+ messages in thread
From: Kevin Hilman @ 2011-08-29 17:58 UTC (permalink / raw)
To: linux-arm-kernel
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>
---
arch/arm/mach-omap2/vp.c | 58 +++++++++++++++-------------------------------
1 files changed, 19 insertions(+), 39 deletions(-)
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 24020ea..66bd700 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -9,31 +9,18 @@
#include "prm-regbits-44xx.h"
#include "prm44xx.h"
-static void vp_latch_vsel(struct voltagedomain *voltdm)
+static u32 _vp_set_init_voltage(struct voltagedomain *voltdm, u32 volt)
{
struct omap_vp_instance *vp = voltdm->vp;
u32 vpconfig;
- unsigned long uvdc;
char vsel;
- uvdc = omap_voltage_get_nom_volt(voltdm);
- if (!uvdc) {
- pr_warning("%s: unable to find current voltage for vdd_%s\n",
- __func__, voltdm->name);
- return;
- }
-
- if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) {
- pr_warning("%s: PMIC function to convert voltage in uV to"
- " vsel not registered\n", __func__);
- return;
- }
-
- vsel = voltdm->pmic->uv_to_vsel(uvdc);
+ vsel = voltdm->pmic->uv_to_vsel(volt);
vpconfig = voltdm->read(vp->vpconfig);
vpconfig &= ~(vp->common->vpconfig_initvoltage_mask |
- vp->common->vpconfig_initvdd);
+ vp->common->vpconfig_forceupdate |
+ vp->common->vpconfig_initvdd);
vpconfig |= vsel << __ffs(vp->common->vpconfig_initvoltage_mask);
voltdm->write(vpconfig, vp->vpconfig);
@@ -43,6 +30,8 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
/* Clear initVDD copy trigger bit */
voltdm->write(vpconfig, vp->vpconfig);
+
+ return vpconfig;
}
/* Generic voltage init functions */
@@ -149,22 +138,11 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
return -ETIMEDOUT;
}
- /* Configure for VP-Force Update */
- vpconfig = voltdm->read(vp->vpconfig);
- vpconfig &= ~(vp->common->vpconfig_initvdd |
- vp->common->vpconfig_forceupdate |
- vp->common->vpconfig_initvoltage_mask);
- vpconfig |= ((target_vsel <<
- __ffs(vp->common->vpconfig_initvoltage_mask)));
- voltdm->write(vpconfig, vp->vpconfig);
-
- /* Trigger initVDD value copy to voltage processor */
- vpconfig |= vp->common->vpconfig_initvdd;
- voltdm->write(vpconfig, vp->vpconfig);
+ vpconfig = _vp_set_init_voltage(voltdm, target_volt);
/* Force update of voltage */
- vpconfig |= vp->common->vpconfig_forceupdate;
- voltdm->write(vpconfig, vp->vpconfig);
+ voltdm->write(vpconfig | vp->common->vpconfig_forceupdate,
+ voltdm->vp->vpconfig);
/*
* Wait for TransactionDone. Typical latency is <200us.
@@ -197,12 +175,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
"to clear the TRANXDONE status\n",
__func__, voltdm->name);
- vpconfig = voltdm->read(vp->vpconfig);
- /* Clear initVDD copy trigger bit */
- vpconfig &= ~vp->common->vpconfig_initvdd;
- voltdm->write(vpconfig, vp->vpconfig);
/* Clear force bit */
- vpconfig &= ~vp->common->vpconfig_forceupdate;
voltdm->write(vpconfig, vp->vpconfig);
return 0;
@@ -218,7 +191,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
void omap_vp_enable(struct voltagedomain *voltdm)
{
struct omap_vp_instance *vp;
- u32 vpconfig;
+ u32 vpconfig, volt;
if (!voltdm || IS_ERR(voltdm)) {
pr_warning("%s: VDD specified does not exist!\n", __func__);
@@ -236,12 +209,19 @@ void omap_vp_enable(struct voltagedomain *voltdm)
if (vp->enabled)
return;
- vp_latch_vsel(voltdm);
+ volt = voltdm_get_voltage(voltdm);
+ if (!volt) {
+ pr_warning("%s: unable to find current voltage for %s\n",
+ __func__, voltdm->name);
+ return;
+ }
+
+ vpconfig = _vp_set_init_voltage(voltdm, volt);
/* Enable VP */
- vpconfig = voltdm->read(vp->vpconfig);
vpconfig |= vp->common->vpconfig_vpenable;
voltdm->write(vpconfig, vp->vpconfig);
+
vp->enabled = true;
}
--
1.7.6
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field
2011-08-29 17:58 ` [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field Kevin Hilman
@ 2011-09-07 12:31 ` Jean Pihet
0 siblings, 0 replies; 15+ messages in thread
From: Jean Pihet @ 2011-09-07 12:31 UTC (permalink / raw)
To: linux-arm-kernel
Kevin,
On Mon, Aug 29, 2011 at 7:58 PM, Kevin Hilman <khilman@ti.com> wrote:
> From: Todd Poynor <toddpoynor@google.com>
>
> Reading the VPVOLTAGE field of PRM_VP_*_VOLTAGE registers currently
> relies on a u32 -> u8 conversion to mask off the FORCEUPDATEWAIT field
> in the upper bits. ?Make this explicit using the mask symbol
> already defined, added as a new field in struct omap_vp_common.
>
> Signed-off-by: Todd Poynor <toddpoynor@google.com>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
> ?arch/arm/mach-omap2/vp.c ? ? ? ? ?| ? ?3 ++-
> ?arch/arm/mach-omap2/vp.h ? ? ? ? ?| ? ?2 ++
> ?arch/arm/mach-omap2/vp3xxx_data.c | ? ?2 ++
> ?arch/arm/mach-omap2/vp44xx_data.c | ? ?1 +
> ?4 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
> index e7d38f6..3807620 100644
> --- a/arch/arm/mach-omap2/vp.c
> +++ b/arch/arm/mach-omap2/vp.c
> @@ -227,7 +227,8 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
> ? ? ? ? ? ? ? ?return 0;
> ? ? ? ?}
>
> - ? ? ? curr_vsel = voltdm->read(vp->voltage);
> + ? ? ? curr_vsel = (voltdm->read(vp->voltage) & vp->common->vpvoltage_mask)
> + ? ? ? ? ? ? ? >> __ffs(vp->common->vpvoltage_mask);
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
` (11 preceding siblings ...)
2011-08-29 17:58 ` [PATCH 12/12] OMAP3+: VP: combine setting init voltage into common function Kevin Hilman
@ 2011-09-07 19:11 ` Jean Pihet
12 siblings, 0 replies; 15+ messages in thread
From: Jean Pihet @ 2011-09-07 19:11 UTC (permalink / raw)
To: linux-arm-kernel
Kevin,
On Mon, Aug 29, 2011 at 7:58 PM, Kevin Hilman <khilman@ti.com> wrote:
> This series focuses on cleanup and better abstraction in the voltage
> processor (VP) layer.
>
> Available in the pm-wip/voltdm_c branch of my linux-omap-pm tree
> git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git
>
> Applies on v3.1-rc3 + the part A & B series.
>
> Kevin
>
Some comments have been sent on this patch set, otherwise OK after review.
FWIW:
Acked-by: Jean Pihet <j-pihet@ti.com>
Regards,
Jean
>
> Kevin Hilman (11):
> ?OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames
> ?OMAP3+: voltage: remove unneeded debugfs interface
> ?OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask)
> ?OMAP3+: VP: move SoC-specific sys clock rate retreival late init
> ?OMAP3+: VP: move timing calculation/config into VP init
> ?OMAP3+: VP: create VP helper function for updating error gain
> ?OMAP3+: VP: remove omap_vp_runtime_data
> ?OMAP3+: VP: move voltage scale function pointer into struct
> ? ?voltagedomain
> ?OMAP3+: VP: update_errorgain(): return error if VP
> ?OMAP3+: VP: remove unused omap_vp_get_curr_volt()
> ?OMAP3+: VP: combine setting init voltage into common function
>
> Todd Poynor (1):
> ?OMAP: VP: Explicitly mask VPVOLTAGE field
>
> ?arch/arm/mach-omap2/smartreflex.c ? ? ? ? ? ? | ? 29 ++-
> ?arch/arm/mach-omap2/vc.c ? ? ? ? ? ? ? ? ? ? ?| ? 22 +--
> ?arch/arm/mach-omap2/voltage.c ? ? ? ? ? ? ? ? | ?161 ++------------
> ?arch/arm/mach-omap2/voltage.h ? ? ? ? ? ? ? ? | ? 24 +--
> ?arch/arm/mach-omap2/voltagedomains3xxx_data.c | ? 18 +-
> ?arch/arm/mach-omap2/voltagedomains44xx_data.c | ? 23 ++-
> ?arch/arm/mach-omap2/vp.c ? ? ? ? ? ? ? ? ? ? ?| ?292 +++++++++----------------
> ?arch/arm/mach-omap2/vp.h ? ? ? ? ? ? ? ? ? ? ?| ? 91 +++-----
> ?arch/arm/mach-omap2/vp3xxx_data.c ? ? ? ? ? ? | ? 16 +-
> ?arch/arm/mach-omap2/vp44xx_data.c ? ? ? ? ? ? | ? 19 +-
> ?10 files changed, 226 insertions(+), 469 deletions(-)
>
> --
> 1.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2011-09-07 19:11 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-29 17:58 [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Kevin Hilman
2011-08-29 17:58 ` [PATCH 01/12] OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames Kevin Hilman
2011-08-29 17:58 ` [PATCH 02/12] OMAP3+: voltage: remove unneeded debugfs interface Kevin Hilman
2011-08-29 17:58 ` [PATCH 03/12] OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask) Kevin Hilman
2011-08-29 17:58 ` [PATCH 04/12] OMAP3+: VP: move SoC-specific sys clock rate retreival late init Kevin Hilman
2011-08-29 17:58 ` [PATCH 05/12] OMAP3+: VP: move timing calculation/config into VP init Kevin Hilman
2011-08-29 17:58 ` [PATCH 06/12] OMAP3+: VP: create VP helper function for updating error gain Kevin Hilman
2011-08-29 17:58 ` [PATCH 07/12] OMAP3+: VP: remove omap_vp_runtime_data Kevin Hilman
2011-08-29 17:58 ` [PATCH 08/12] OMAP3+: VP: move voltage scale function pointer into struct voltagedomain Kevin Hilman
2011-08-29 17:58 ` [PATCH 09/12] OMAP: VP: Explicitly mask VPVOLTAGE field Kevin Hilman
2011-09-07 12:31 ` Jean Pihet
2011-08-29 17:58 ` [PATCH 10/12] OMAP3+: VP: update_errorgain(): return error if VP Kevin Hilman
2011-08-29 17:58 ` [PATCH 11/12] OMAP3+: VP: remove unused omap_vp_get_curr_volt() Kevin Hilman
2011-08-29 17:58 ` [PATCH 12/12] OMAP3+: VP: combine setting init voltage into common function Kevin Hilman
2011-09-07 19:11 ` [PATCH 00/12] OMAP: voltage cleanup part C: VP cleanup Jean Pihet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).