From ccd5ca7787df8f1bd267b90f03a09c31c160ffe2 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 21 Mar 2011 14:08:55 -0700 Subject: OMAP2+: voltage: split voltage controller (VC) code into dedicated layer As part of the voltage layer cleanup, split out VC specific code into a dedicated VC layer. This patch primarily just moves VC code from voltage.c into vc.c, and adds prototypes to vc.h. No functional changes. For readability, each function was given a local 'vc' pointer: struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; and a global replace of s/vdd->vc_data/vc/ was done. Also vc_init was renamed to vc_init_channel to reflect that this is per-VC channel initializtion. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 285 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 arch/arm/mach-omap2/vc.c (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c new file mode 100644 index 000000000000..098af2f3a63e --- /dev/null +++ b/arch/arm/mach-omap2/vc.c @@ -0,0 +1,285 @@ +/* + * OMAP Voltage Controller (VC) interface + * + * Copyright (C) 2011 Texas Instruments, Inc. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ +#include +#include +#include + +#include + +#include "voltage.h" +#include "vc.h" +#include "prm-regbits-34xx.h" +#include "prm-regbits-44xx.h" +#include "prm44xx.h" + +/* Voltage scale and accessory APIs */ +int omap_vc_pre_scale(struct voltagedomain *voltdm, + unsigned long target_volt, + u8 *target_vsel, u8 *current_vsel) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + struct omap_volt_data *volt_data; + const struct omap_vc_common_data *vc_common; + const struct omap_vp_common_data *vp_common; + u32 vc_cmdval, vp_errgain_val; + + vc_common = vc->vc_common; + vp_common = vdd->vp_data->vp_common; + + /* Check if sufficient pmic info is available for this vdd */ + if (!vdd->pmic_info) { + pr_err("%s: Insufficient pmic info to scale the vdd_%s\n", + __func__, voltdm->name); + return -EINVAL; + } + + if (!vdd->pmic_info->uv_to_vsel) { + pr_err("%s: PMIC function to convert voltage in uV to" + "vsel not registered. Hence unable to scale voltage" + "for vdd_%s\n", __func__, voltdm->name); + return -ENODATA; + } + + if (!vdd->read_reg || !vdd->write_reg) { + pr_err("%s: No read/write API for accessing vdd_%s regs\n", + __func__, voltdm->name); + 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 = vdd->pmic_info->uv_to_vsel(target_volt); + *current_vsel = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->voltage); + + /* Setting the ON voltage to the new target voltage */ + vc_cmdval = vdd->read_reg(vc->vc_common->prm_mod, vc->cmdval_reg); + vc_cmdval &= ~vc_common->cmd_on_mask; + vc_cmdval |= (*target_vsel << vc_common->cmd_on_shift); + vdd->write_reg(vc_cmdval, vc->vc_common->prm_mod, vc->cmdval_reg); + + /* Setting vp errorgain based on the voltage */ + if (volt_data) { + vp_errgain_val = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, + vdd->vp_data->vpconfig); + vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain; + vp_errgain_val &= ~vp_common->vpconfig_errorgain_mask; + vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain << + vp_common->vpconfig_errorgain_shift; + vdd->write_reg(vp_errgain_val, vdd->vp_data->vp_common->prm_mod, + vdd->vp_data->vpconfig); + } + + return 0; +} + +void omap_vc_post_scale(struct voltagedomain *voltdm, + unsigned long target_volt, + u8 target_vsel, u8 current_vsel) +{ + struct omap_vdd_info *vdd = voltdm->vdd; + u32 smps_steps = 0, smps_delay = 0; + + smps_steps = abs(target_vsel - current_vsel); + /* SMPS slew rate / step size. 2us added as buffer. */ + smps_delay = ((smps_steps * vdd->pmic_info->step_size) / + vdd->pmic_info->slew_rate) + 2; + udelay(smps_delay); + + vdd->curr_volt = target_volt; +} + +/* vc_bypass_scale_voltage - VC bypass method of voltage scaling */ +int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, + unsigned long target_volt) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + u32 loop_cnt = 0, retries_cnt = 0; + u32 vc_valid, vc_bypass_val_reg, vc_bypass_value; + u8 target_vsel, current_vsel; + int ret; + + ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, ¤t_vsel); + if (ret) + return ret; + + vc_valid = vc->vc_common->valid; + vc_bypass_val_reg = vc->vc_common->bypass_val_reg; + vc_bypass_value = (target_vsel << vc->vc_common->data_shift) | + (vdd->pmic_info->pmic_reg << + vc->vc_common->regaddr_shift) | + (vdd->pmic_info->i2c_slave_addr << + vc->vc_common->slaveaddr_shift); + + vdd->write_reg(vc_bypass_value, vc->vc_common->prm_mod, vc_bypass_val_reg); + vdd->write_reg(vc_bypass_value | vc_valid, vc->vc_common->prm_mod, + vc_bypass_val_reg); + + vc_bypass_value = vdd->read_reg(vc->vc_common->prm_mod, vc_bypass_val_reg); + /* + * Loop till the bypass command is acknowledged from the SMPS. + * NOTE: This is legacy code. The loop count and retry count needs + * to be revisited. + */ + while (!(vc_bypass_value & vc_valid)) { + loop_cnt++; + + if (retries_cnt > 10) { + pr_warning("%s: Retry count exceeded\n", __func__); + return -ETIMEDOUT; + } + + if (loop_cnt > 50) { + retries_cnt++; + loop_cnt = 0; + udelay(10); + } + vc_bypass_value = vdd->read_reg(vc->vc_common->prm_mod, + vc_bypass_val_reg); + } + + omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel); + return 0; +} + +static void __init omap3_vfsm_init(struct voltagedomain *voltdm) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + + /* + * Voltage Manager FSM parameters init + * XXX This data should be passed in from the board file + */ + vdd->write_reg(OMAP3_CLKSETUP, vc->vc_common->prm_mod, OMAP3_PRM_CLKSETUP_OFFSET); + vdd->write_reg(OMAP3_VOLTOFFSET, vc->vc_common->prm_mod, + OMAP3_PRM_VOLTOFFSET_OFFSET); + vdd->write_reg(OMAP3_VOLTSETUP2, vc->vc_common->prm_mod, + OMAP3_PRM_VOLTSETUP2_OFFSET); +} + +static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + static bool is_initialized; + u8 on_vsel, onlp_vsel, ret_vsel, off_vsel; + u32 vc_val; + + if (is_initialized) + return; + + /* Set up the on, inactive, retention and off voltage */ + on_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->on_volt); + onlp_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->onlp_volt); + ret_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->ret_volt); + off_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->off_volt); + vc_val = ((on_vsel << vc->vc_common->cmd_on_shift) | + (onlp_vsel << vc->vc_common->cmd_onlp_shift) | + (ret_vsel << vc->vc_common->cmd_ret_shift) | + (off_vsel << vc->vc_common->cmd_off_shift)); + vdd->write_reg(vc_val, vc->vc_common->prm_mod, vc->cmdval_reg); + + /* + * Generic VC parameters init + * XXX This data should be abstracted out + */ + vdd->write_reg(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, vc->vc_common->prm_mod, + OMAP3_PRM_VC_CH_CONF_OFFSET); + vdd->write_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, vc->vc_common->prm_mod, + OMAP3_PRM_VC_I2C_CFG_OFFSET); + + omap3_vfsm_init(voltdm); + + is_initialized = true; +} + + +/* OMAP4 specific voltage init functions */ +static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + static bool is_initialized; + u32 vc_val; + + if (is_initialized) + return; + + /* TODO: Configure setup times and CMD_VAL values*/ + + /* + * Generic VC parameters init + * XXX This data should be abstracted out + */ + vc_val = (OMAP4430_RAV_VDD_MPU_L_MASK | OMAP4430_CMD_VDD_MPU_L_MASK | + OMAP4430_RAV_VDD_IVA_L_MASK | OMAP4430_CMD_VDD_IVA_L_MASK | + OMAP4430_RAV_VDD_CORE_L_MASK | OMAP4430_CMD_VDD_CORE_L_MASK); + vdd->write_reg(vc_val, vc->vc_common->prm_mod, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); + + /* XXX These are magic numbers and do not belong! */ + vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT); + vdd->write_reg(vc_val, vc->vc_common->prm_mod, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); + + is_initialized = true; +} + +void __init omap_vc_init_channel(struct voltagedomain *voltdm) +{ + struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vdd_info *vdd = voltdm->vdd; + u32 vc_val; + + if (!vdd->pmic_info || !vdd->pmic_info->uv_to_vsel) { + pr_err("%s: PMIC info requried to configure vc for" + "vdd_%s not populated.Hence cannot initialize vc\n", + __func__, voltdm->name); + return; + } + + if (!vdd->read_reg || !vdd->write_reg) { + pr_err("%s: No read/write API for accessing vdd_%s regs\n", + __func__, voltdm->name); + return; + } + + /* Set up the SMPS_SA(i2c slave address in VC */ + vc_val = vdd->read_reg(vc->vc_common->prm_mod, + vc->vc_common->smps_sa_reg); + vc_val &= ~vc->smps_sa_mask; + vc_val |= vdd->pmic_info->i2c_slave_addr << vc->smps_sa_shift; + vdd->write_reg(vc_val, vc->vc_common->prm_mod, + vc->vc_common->smps_sa_reg); + + /* Setup the VOLRA(pmic reg addr) in VC */ + vc_val = vdd->read_reg(vc->vc_common->prm_mod, + vc->vc_common->smps_volra_reg); + vc_val &= ~vc->smps_volra_mask; + vc_val |= vdd->pmic_info->pmic_reg << vc->smps_volra_shift; + vdd->write_reg(vc_val, vc->vc_common->prm_mod, + vc->vc_common->smps_volra_reg); + + /* Configure the setup times */ + vc_val = vdd->read_reg(vc->vc_common->prm_mod, vdd->vfsm->voltsetup_reg); + vc_val &= ~vdd->vfsm->voltsetup_mask; + vc_val |= vdd->pmic_info->volt_setup_time << + vdd->vfsm->voltsetup_shift; + vdd->write_reg(vc_val, vc->vc_common->prm_mod, vdd->vfsm->voltsetup_reg); + + if (cpu_is_omap34xx()) + omap3_vc_init_channel(voltdm); + else if (cpu_is_omap44xx()) + omap4_vc_init_channel(voltdm); +} + -- cgit v1.2.3 From d84adcf46b9c235d1f4975b72a8c2763dbfb0081 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 22 Mar 2011 16:14:57 -0700 Subject: OMAP2+: voltage: move VC into struct voltagedomain, misc. renames Move the VC instance struct from omap_vdd_info into struct voltagedomain. While moving, perform some misc. renames for readability. No functional changes. Summary of renames: - rename omap_vc_instance to omap_vc_channel, since there is only one instance of the VC IP and this actually represents channels using TRM terminology. - rename 'vc_common' field of VC channel which led to: s/vc->vc_common/vc->common/ - remove redundant '_data' suffix - OMAP3: vc1 --> vc_mpu, vc2 --> vc_core - omap_vc_bypass_scale_voltage() -> omap_vc_bypass_scale() Signed-off-by: Kevin Hilman merge --- arch/arm/mach-omap2/vc.c | 90 +++++++++++++-------------- arch/arm/mach-omap2/vc.h | 26 ++++---- arch/arm/mach-omap2/vc3xxx_data.c | 10 +-- arch/arm/mach-omap2/vc44xx_data.c | 14 ++--- arch/arm/mach-omap2/voltage.c | 6 +- arch/arm/mach-omap2/voltage.h | 6 +- arch/arm/mach-omap2/voltagedomains3xxx_data.c | 4 +- arch/arm/mach-omap2/voltagedomains44xx_data.c | 6 +- 8 files changed, 81 insertions(+), 81 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 098af2f3a63e..b62363d9d2b7 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -24,14 +24,12 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, unsigned long target_volt, u8 *target_vsel, u8 *current_vsel) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; struct omap_volt_data *volt_data; - const struct omap_vc_common_data *vc_common; const struct omap_vp_common_data *vp_common; u32 vc_cmdval, vp_errgain_val; - vc_common = vc->vc_common; vp_common = vdd->vp_data->vp_common; /* Check if sufficient pmic info is available for this vdd */ @@ -63,10 +61,10 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, *current_vsel = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->voltage); /* Setting the ON voltage to the new target voltage */ - vc_cmdval = vdd->read_reg(vc->vc_common->prm_mod, vc->cmdval_reg); - vc_cmdval &= ~vc_common->cmd_on_mask; - vc_cmdval |= (*target_vsel << vc_common->cmd_on_shift); - vdd->write_reg(vc_cmdval, vc->vc_common->prm_mod, vc->cmdval_reg); + vc_cmdval = vdd->read_reg(vc->common->prm_mod, vc->cmdval_reg); + vc_cmdval &= ~vc->common->cmd_on_mask; + vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift); + vdd->write_reg(vc_cmdval, vc->common->prm_mod, vc->cmdval_reg); /* Setting vp errorgain based on the voltage */ if (volt_data) { @@ -99,11 +97,11 @@ void omap_vc_post_scale(struct voltagedomain *voltdm, vdd->curr_volt = target_volt; } -/* vc_bypass_scale_voltage - VC bypass method of voltage scaling */ -int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, - unsigned long target_volt) +/* vc_bypass_scale - VC bypass method of voltage scaling */ +int omap_vc_bypass_scale(struct voltagedomain *voltdm, + unsigned long target_volt) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; u32 loop_cnt = 0, retries_cnt = 0; u32 vc_valid, vc_bypass_val_reg, vc_bypass_value; @@ -114,19 +112,19 @@ int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, if (ret) return ret; - vc_valid = vc->vc_common->valid; - vc_bypass_val_reg = vc->vc_common->bypass_val_reg; - vc_bypass_value = (target_vsel << vc->vc_common->data_shift) | + vc_valid = vc->common->valid; + vc_bypass_val_reg = vc->common->bypass_val_reg; + vc_bypass_value = (target_vsel << vc->common->data_shift) | (vdd->pmic_info->pmic_reg << - vc->vc_common->regaddr_shift) | + vc->common->regaddr_shift) | (vdd->pmic_info->i2c_slave_addr << - vc->vc_common->slaveaddr_shift); + vc->common->slaveaddr_shift); - vdd->write_reg(vc_bypass_value, vc->vc_common->prm_mod, vc_bypass_val_reg); - vdd->write_reg(vc_bypass_value | vc_valid, vc->vc_common->prm_mod, + vdd->write_reg(vc_bypass_value, vc->common->prm_mod, vc_bypass_val_reg); + vdd->write_reg(vc_bypass_value | vc_valid, vc->common->prm_mod, vc_bypass_val_reg); - vc_bypass_value = vdd->read_reg(vc->vc_common->prm_mod, vc_bypass_val_reg); + vc_bypass_value = vdd->read_reg(vc->common->prm_mod, vc_bypass_val_reg); /* * Loop till the bypass command is acknowledged from the SMPS. * NOTE: This is legacy code. The loop count and retry count needs @@ -145,7 +143,7 @@ int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, loop_cnt = 0; udelay(10); } - vc_bypass_value = vdd->read_reg(vc->vc_common->prm_mod, + vc_bypass_value = vdd->read_reg(vc->common->prm_mod, vc_bypass_val_reg); } @@ -155,23 +153,23 @@ int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, static void __init omap3_vfsm_init(struct voltagedomain *voltdm) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; /* * Voltage Manager FSM parameters init * XXX This data should be passed in from the board file */ - vdd->write_reg(OMAP3_CLKSETUP, vc->vc_common->prm_mod, OMAP3_PRM_CLKSETUP_OFFSET); - vdd->write_reg(OMAP3_VOLTOFFSET, vc->vc_common->prm_mod, + vdd->write_reg(OMAP3_CLKSETUP, vc->common->prm_mod, OMAP3_PRM_CLKSETUP_OFFSET); + vdd->write_reg(OMAP3_VOLTOFFSET, vc->common->prm_mod, OMAP3_PRM_VOLTOFFSET_OFFSET); - vdd->write_reg(OMAP3_VOLTSETUP2, vc->vc_common->prm_mod, + vdd->write_reg(OMAP3_VOLTSETUP2, vc->common->prm_mod, OMAP3_PRM_VOLTSETUP2_OFFSET); } static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; static bool is_initialized; u8 on_vsel, onlp_vsel, ret_vsel, off_vsel; @@ -185,19 +183,19 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) onlp_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->onlp_volt); ret_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->ret_volt); off_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->off_volt); - vc_val = ((on_vsel << vc->vc_common->cmd_on_shift) | - (onlp_vsel << vc->vc_common->cmd_onlp_shift) | - (ret_vsel << vc->vc_common->cmd_ret_shift) | - (off_vsel << vc->vc_common->cmd_off_shift)); - vdd->write_reg(vc_val, vc->vc_common->prm_mod, vc->cmdval_reg); + vc_val = ((on_vsel << vc->common->cmd_on_shift) | + (onlp_vsel << vc->common->cmd_onlp_shift) | + (ret_vsel << vc->common->cmd_ret_shift) | + (off_vsel << vc->common->cmd_off_shift)); + vdd->write_reg(vc_val, vc->common->prm_mod, vc->cmdval_reg); /* * Generic VC parameters init * XXX This data should be abstracted out */ - vdd->write_reg(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, vc->vc_common->prm_mod, + vdd->write_reg(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, vc->common->prm_mod, OMAP3_PRM_VC_CH_CONF_OFFSET); - vdd->write_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, vc->vc_common->prm_mod, + vdd->write_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, vc->common->prm_mod, OMAP3_PRM_VC_I2C_CFG_OFFSET); omap3_vfsm_init(voltdm); @@ -209,7 +207,7 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) /* OMAP4 specific voltage init functions */ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; static bool is_initialized; u32 vc_val; @@ -226,18 +224,18 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) vc_val = (OMAP4430_RAV_VDD_MPU_L_MASK | OMAP4430_CMD_VDD_MPU_L_MASK | OMAP4430_RAV_VDD_IVA_L_MASK | OMAP4430_CMD_VDD_IVA_L_MASK | OMAP4430_RAV_VDD_CORE_L_MASK | OMAP4430_CMD_VDD_CORE_L_MASK); - vdd->write_reg(vc_val, vc->vc_common->prm_mod, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); + vdd->write_reg(vc_val, vc->common->prm_mod, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); /* XXX These are magic numbers and do not belong! */ vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT); - vdd->write_reg(vc_val, vc->vc_common->prm_mod, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); + vdd->write_reg(vc_val, vc->common->prm_mod, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); is_initialized = true; } void __init omap_vc_init_channel(struct voltagedomain *voltdm) { - struct omap_vc_instance_data *vc = voltdm->vdd->vc_data; + struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; u32 vc_val; @@ -255,27 +253,27 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) } /* Set up the SMPS_SA(i2c slave address in VC */ - vc_val = vdd->read_reg(vc->vc_common->prm_mod, - vc->vc_common->smps_sa_reg); + vc_val = vdd->read_reg(vc->common->prm_mod, + vc->common->smps_sa_reg); vc_val &= ~vc->smps_sa_mask; vc_val |= vdd->pmic_info->i2c_slave_addr << vc->smps_sa_shift; - vdd->write_reg(vc_val, vc->vc_common->prm_mod, - vc->vc_common->smps_sa_reg); + vdd->write_reg(vc_val, vc->common->prm_mod, + vc->common->smps_sa_reg); /* Setup the VOLRA(pmic reg addr) in VC */ - vc_val = vdd->read_reg(vc->vc_common->prm_mod, - vc->vc_common->smps_volra_reg); + vc_val = vdd->read_reg(vc->common->prm_mod, + vc->common->smps_volra_reg); vc_val &= ~vc->smps_volra_mask; vc_val |= vdd->pmic_info->pmic_reg << vc->smps_volra_shift; - vdd->write_reg(vc_val, vc->vc_common->prm_mod, - vc->vc_common->smps_volra_reg); + vdd->write_reg(vc_val, vc->common->prm_mod, + vc->common->smps_volra_reg); /* Configure the setup times */ - vc_val = vdd->read_reg(vc->vc_common->prm_mod, vdd->vfsm->voltsetup_reg); + vc_val = vdd->read_reg(vc->common->prm_mod, vdd->vfsm->voltsetup_reg); vc_val &= ~vdd->vfsm->voltsetup_mask; vc_val |= vdd->pmic_info->volt_setup_time << vdd->vfsm->voltsetup_shift; - vdd->write_reg(vc_val, vc->vc_common->prm_mod, vdd->vfsm->voltsetup_reg); + vdd->write_reg(vc_val, vc->common->prm_mod, vdd->vfsm->voltsetup_reg); if (cpu_is_omap34xx()) omap3_vc_init_channel(voltdm); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index d0bf34831c0b..51d36a80b131 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -22,7 +22,7 @@ struct voltagedomain; /** - * struct omap_vc_common_data - per-VC register/bitfield data + * struct omap_vc_common - per-VC register/bitfield data * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register * @prm_mod: PRM module id used for PRM register access @@ -40,7 +40,7 @@ struct voltagedomain; * XXX One of cmd_on_mask and cmd_on_shift are not needed * XXX VALID should probably be a shift, not a mask */ -struct omap_vc_common_data { +struct omap_vc_common { u32 cmd_on_mask; u32 valid; s16 prm_mod; @@ -57,8 +57,8 @@ struct omap_vc_common_data { }; /** - * struct omap_vc_instance_data - VC per-instance data - * @vc_common: pointer to VC common data for this platform + * struct omap_vc_channel - VC per-instance data + * @common: pointer to VC common data for this platform * @smps_sa_mask: SA* bitmask in the PRM_VC_SMPS_SA register * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register * @smps_sa_shift: SA* field shift in the PRM_VC_SMPS_SA register @@ -67,8 +67,8 @@ struct omap_vc_common_data { * XXX It is not necessary to have both a *_mask and a *_shift - * remove one */ -struct omap_vc_instance_data { - const struct omap_vc_common_data *vc_common; +struct omap_vc_channel { + const struct omap_vc_common *common; u32 smps_sa_mask; u32 smps_volra_mask; u8 cmdval_reg; @@ -76,12 +76,12 @@ struct omap_vc_instance_data { u8 smps_volra_shift; }; -extern struct omap_vc_instance_data omap3_vc1_data; -extern struct omap_vc_instance_data omap3_vc2_data; +extern struct omap_vc_channel omap3_vc_mpu; +extern struct omap_vc_channel omap3_vc_core; -extern struct omap_vc_instance_data omap4_vc_mpu_data; -extern struct omap_vc_instance_data omap4_vc_iva_data; -extern struct omap_vc_instance_data omap4_vc_core_data; +extern struct omap_vc_channel omap4_vc_mpu; +extern struct omap_vc_channel omap4_vc_iva; +extern struct omap_vc_channel omap4_vc_core; void omap_vc_init_channel(struct voltagedomain *voltdm); int omap_vc_pre_scale(struct voltagedomain *voltdm, @@ -90,8 +90,8 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, void omap_vc_post_scale(struct voltagedomain *voltdm, unsigned long target_volt, u8 target_vsel, u8 current_vsel); -int omap_vc_bypass_scale_voltage(struct voltagedomain *voltdm, - unsigned long target_volt); +int omap_vc_bypass_scale(struct voltagedomain *voltdm, + unsigned long target_volt); #endif diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 55caccb2908d..1a17ed459cc3 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -29,7 +29,7 @@ * VC data common to 34xx/36xx chips * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ -static struct omap_vc_common_data omap3_vc_common = { +static struct omap_vc_common omap3_vc_common = { .prm_mod = OMAP3430_GR_MOD, .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, @@ -45,8 +45,8 @@ static struct omap_vc_common_data omap3_vc_common = { .cmd_off_shift = OMAP3430_VC_CMD_OFF_SHIFT, }; -struct omap_vc_instance_data omap3_vc1_data = { - .vc_common = &omap3_vc_common, +struct omap_vc_channel omap3_vc_mpu = { + .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA0_SHIFT, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, @@ -54,8 +54,8 @@ struct omap_vc_instance_data omap3_vc1_data = { .smps_volra_mask = OMAP3430_VOLRA0_MASK, }; -struct omap_vc_instance_data omap3_vc2_data = { - .vc_common = &omap3_vc_common, +struct omap_vc_channel omap3_vc_core = { + .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index b62678e12a3c..56f3f4a37879 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -30,7 +30,7 @@ * VC data common to 44xx chips * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ -static const struct omap_vc_common_data omap4_vc_common = { +static const struct omap_vc_common omap4_vc_common = { .prm_mod = OMAP4430_PRM_DEVICE_INST, .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, @@ -47,8 +47,8 @@ static const struct omap_vc_common_data omap4_vc_common = { }; /* VC instance data for each controllable voltage line */ -struct omap_vc_instance_data omap4_vc_mpu_data = { - .vc_common = &omap4_vc_common, +struct omap_vc_channel omap4_vc_mpu = { + .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, .smps_sa_shift = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, @@ -56,8 +56,8 @@ struct omap_vc_instance_data omap4_vc_mpu_data = { .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, }; -struct omap_vc_instance_data omap4_vc_iva_data = { - .vc_common = &omap4_vc_common, +struct omap_vc_channel omap4_vc_iva = { + .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, .smps_sa_shift = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, @@ -65,8 +65,8 @@ struct omap_vc_instance_data omap4_vc_iva_data = { .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, }; -struct omap_vc_instance_data omap4_vc_core_data = { - .vc_common = &omap4_vc_common, +struct omap_vc_channel omap4_vc_core = { + .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, .smps_sa_shift = OMAP4430_SA_VDD_CORE_L_0_6_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 6ba6e493c757..c6352e3230b7 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -769,7 +769,7 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm, vdd->volt_scale = vp_forceupdate_scale_voltage; return; case VOLTSCALE_VCBYPASS: - vdd->volt_scale = omap_vc_bypass_scale_voltage; + vdd->volt_scale = omap_vc_bypass_scale; return; default: pr_warning("%s: Trying to change the method of voltage scaling" @@ -802,10 +802,12 @@ int __init omap_voltage_late_init(void) if (!voltdm->scalable) continue; + if (voltdm->vc) + omap_vc_init_channel(voltdm); + if (voltdm->vdd) { if (omap_vdd_data_configure(voltdm)) continue; - omap_vc_init_channel(voltdm); vp_init(voltdm); vdd_debugfs_init(voltdm); } diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 5063ab33af7b..488576497c88 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -58,6 +58,7 @@ struct omap_vfsm_instance_data { * @scalable: Whether or not this voltage domain is scalable * @node: list_head linking all voltage domains * @pwrdm_list: list_head linking all powerdomains in this voltagedomain + * @vc: pointer to VC channel associated with this voltagedomain * @vdd: to be removed */ struct voltagedomain { @@ -65,6 +66,8 @@ struct voltagedomain { bool scalable; struct list_head node; struct list_head pwrdm_list; + struct omap_vc_channel *vc; + struct omap_vdd_info *vdd; }; @@ -124,8 +127,6 @@ struct omap_volt_pmic_info { * @vp_data : the register values, shifts, masks for various * vp registers * @vp_rt_data : VP data derived at runtime, not predefined - * @vc_data : structure containing various various vc registers, - * shifts, masks etc. * @vfsm : voltage manager FSM data * @debug_dir : debug directory for this voltage domain. * @curr_volt : current voltage for this vdd. @@ -138,7 +139,6 @@ struct omap_vdd_info { struct omap_volt_pmic_info *pmic_info; struct omap_vp_instance_data *vp_data; struct omap_vp_runtime_data vp_rt_data; - struct omap_vc_instance_data *vc_data; const struct omap_vfsm_instance_data *vfsm; struct dentry *debug_dir; u32 curr_volt; diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c index d7e1052d2cdb..7cb27ec64890 100644 --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c @@ -41,7 +41,6 @@ static struct omap_vdd_info omap3_vdd1_info = { .prm_irqst_mod = OCP_MOD, .prm_irqst_reg = OMAP3_PRM_IRQSTATUS_MPU_OFFSET, .vp_data = &omap3_vp1_data, - .vc_data = &omap3_vc1_data, .vfsm = &omap3_vdd1_vfsm_data, }; @@ -55,19 +54,20 @@ static struct omap_vdd_info omap3_vdd2_info = { .prm_irqst_mod = OCP_MOD, .prm_irqst_reg = OMAP3_PRM_IRQSTATUS_MPU_OFFSET, .vp_data = &omap3_vp2_data, - .vc_data = &omap3_vc2_data, .vfsm = &omap3_vdd2_vfsm_data, }; static struct voltagedomain omap3_voltdm_mpu = { .name = "mpu_iva", .scalable = true, + .vc = &omap3_vc_mpu, .vdd = &omap3_vdd1_info, }; static struct voltagedomain omap3_voltdm_core = { .name = "core", .scalable = true, + .vc = &omap3_vc_core, .vdd = &omap3_vdd2_info, }; diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c index 9a17b5ebf665..a05d90ab6869 100644 --- a/arch/arm/mach-omap2/voltagedomains44xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c @@ -40,7 +40,6 @@ static struct omap_vdd_info omap4_vdd_mpu_info = { .prm_irqst_mod = OMAP4430_PRM_OCP_SOCKET_INST, .prm_irqst_reg = OMAP4_PRM_IRQSTATUS_MPU_2_OFFSET, .vp_data = &omap4_vp_mpu_data, - .vc_data = &omap4_vc_mpu_data, .vfsm = &omap4_vdd_mpu_vfsm_data, }; @@ -52,7 +51,6 @@ static struct omap_vdd_info omap4_vdd_iva_info = { .prm_irqst_mod = OMAP4430_PRM_OCP_SOCKET_INST, .prm_irqst_reg = OMAP4_PRM_IRQSTATUS_MPU_OFFSET, .vp_data = &omap4_vp_iva_data, - .vc_data = &omap4_vc_iva_data, .vfsm = &omap4_vdd_iva_vfsm_data, }; @@ -64,25 +62,27 @@ static struct omap_vdd_info omap4_vdd_core_info = { .prm_irqst_mod = OMAP4430_PRM_OCP_SOCKET_INST, .prm_irqst_reg = OMAP4_PRM_IRQSTATUS_MPU_OFFSET, .vp_data = &omap4_vp_core_data, - .vc_data = &omap4_vc_core_data, .vfsm = &omap4_vdd_core_vfsm_data, }; static struct voltagedomain omap4_voltdm_mpu = { .name = "mpu", .scalable = true, + .vc = &omap4_vc_mpu, .vdd = &omap4_vdd_mpu_info, }; static struct voltagedomain omap4_voltdm_iva = { .name = "iva", .scalable = true, + .vc = &omap4_vc_iva, .vdd = &omap4_vdd_iva_info, }; static struct voltagedomain omap4_voltdm_core = { .name = "core", .scalable = true, + .vc = &omap4_vc_core, .vdd = &omap4_vdd_core_info, }; -- cgit v1.2.3 From e74e44054f8297d60fbd2ed1d412d84055afee8c Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 22 Mar 2011 14:12:37 -0700 Subject: OMAP2+: VC: support PMICs with separate voltage and command registers The VC layer can support PMICs with separate voltage and command registers by putting the different registers in the PRM_VC_SMPS_VOL_RA and PRCM_VC_SMPS_CMD_RA registers respectively. The PMIC data must supply at least a voltage register address (volt_reg_addr). The command register address (cmd_reg_addr) is optional. If the PMIC data does not supply a separate command register address, the VC will use the voltage register address for both. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/omap_twl.c | 10 +++++----- arch/arm/mach-omap2/vc.c | 4 ++-- arch/arm/mach-omap2/voltage.h | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c index 760487bcfca6..3249fe3c3c1d 100644 --- a/arch/arm/mach-omap2/omap_twl.c +++ b/arch/arm/mach-omap2/omap_twl.c @@ -158,7 +158,7 @@ static struct omap_volt_pmic_info omap3_mpu_volt_info = { .vp_vddmax = OMAP3430_VP1_VLIMITTO_VDDMAX, .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR, - .pmic_reg = OMAP3_VDD_MPU_SR_CONTROL_REG, + .volt_reg_addr = OMAP3_VDD_MPU_SR_CONTROL_REG, .vsel_to_uv = twl4030_vsel_to_uv, .uv_to_vsel = twl4030_uv_to_vsel, }; @@ -178,7 +178,7 @@ static struct omap_volt_pmic_info omap3_core_volt_info = { .vp_vddmax = OMAP3430_VP2_VLIMITTO_VDDMAX, .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR, - .pmic_reg = OMAP3_VDD_CORE_SR_CONTROL_REG, + .volt_reg_addr = OMAP3_VDD_CORE_SR_CONTROL_REG, .vsel_to_uv = twl4030_vsel_to_uv, .uv_to_vsel = twl4030_uv_to_vsel, }; @@ -198,7 +198,7 @@ static struct omap_volt_pmic_info omap4_mpu_volt_info = { .vp_vddmax = OMAP4_VP_MPU_VLIMITTO_VDDMAX, .vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR, - .pmic_reg = OMAP4_VDD_MPU_SR_VOLT_REG, + .volt_reg_addr = OMAP4_VDD_MPU_SR_VOLT_REG, .vsel_to_uv = twl6030_vsel_to_uv, .uv_to_vsel = twl6030_uv_to_vsel, }; @@ -218,7 +218,7 @@ static struct omap_volt_pmic_info omap4_iva_volt_info = { .vp_vddmax = OMAP4_VP_IVA_VLIMITTO_VDDMAX, .vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR, - .pmic_reg = OMAP4_VDD_IVA_SR_VOLT_REG, + .volt_reg_addr = OMAP4_VDD_IVA_SR_VOLT_REG, .vsel_to_uv = twl6030_vsel_to_uv, .uv_to_vsel = twl6030_uv_to_vsel, }; @@ -238,7 +238,7 @@ static struct omap_volt_pmic_info omap4_core_volt_info = { .vp_vddmax = OMAP4_VP_CORE_VLIMITTO_VDDMAX, .vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR, - .pmic_reg = OMAP4_VDD_CORE_SR_VOLT_REG, + .volt_reg_addr = OMAP4_VDD_CORE_SR_VOLT_REG, .vsel_to_uv = twl6030_vsel_to_uv, .uv_to_vsel = twl6030_uv_to_vsel, }; diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index b62363d9d2b7..1bdbe7c15612 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -115,7 +115,7 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, vc_valid = vc->common->valid; vc_bypass_val_reg = vc->common->bypass_val_reg; vc_bypass_value = (target_vsel << vc->common->data_shift) | - (vdd->pmic_info->pmic_reg << + (vdd->pmic_info->volt_reg_addr << vc->common->regaddr_shift) | (vdd->pmic_info->i2c_slave_addr << vc->common->slaveaddr_shift); @@ -264,7 +264,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc_val = vdd->read_reg(vc->common->prm_mod, vc->common->smps_volra_reg); vc_val &= ~vc->smps_volra_mask; - vc_val |= vdd->pmic_info->pmic_reg << vc->smps_volra_shift; + vc_val |= vdd->pmic_info->volt_reg_addr << vc->smps_volra_shift; vdd->write_reg(vc_val, vc->common->prm_mod, vc->common->smps_volra_reg); diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index ea6bb98c63f8..5ca30fca114d 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -96,6 +96,8 @@ struct omap_volt_data { * @step_size: PMIC voltage step size (in uv) * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. + * @volt_reg_addr: voltage configuration register address + * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address */ struct omap_volt_pmic_info { int slew_rate; @@ -112,7 +114,8 @@ struct omap_volt_pmic_info { u8 vp_vddmax; u8 vp_timeout_us; u8 i2c_slave_addr; - u8 pmic_reg; + u8 volt_reg_addr; + u8 cmd_reg_addr; unsigned long (*vsel_to_uv) (const u8 vsel); u8 (*uv_to_vsel) (unsigned long uV); }; -- cgit v1.2.3 From 4bcc475ebd06a04e1531254c27c6cf508ef8ebf9 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 28 Mar 2011 10:40:15 -0700 Subject: OMAP3+: voltage: convert to PRM register access functions Convert VC/VP register access to use PRM VC/VP accessor functions. In the process, move the read/write function pointers from vdd_info into struct voltagedomain. No functional changes. Additional cleanup: - remove prm_mod field from VC/VP data structures, the PRM register access functions know which PRM module to use. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 69 +++++++++++---------------- arch/arm/mach-omap2/vc.h | 2 - arch/arm/mach-omap2/vc3xxx_data.c | 1 - arch/arm/mach-omap2/vc44xx_data.c | 1 - arch/arm/mach-omap2/voltage.c | 31 +----------- arch/arm/mach-omap2/voltage.h | 10 +++- arch/arm/mach-omap2/voltagedomains3xxx_data.c | 6 +++ arch/arm/mach-omap2/voltagedomains44xx_data.c | 9 ++++ arch/arm/mach-omap2/vp.c | 57 +++++++++++----------- arch/arm/mach-omap2/vp.h | 2 - arch/arm/mach-omap2/vp3xxx_data.c | 1 - arch/arm/mach-omap2/vp44xx_data.c | 1 - 12 files changed, 79 insertions(+), 111 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 1bdbe7c15612..f1c73cbe3cb4 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -46,7 +46,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, return -ENODATA; } - if (!vdd->read_reg || !vdd->write_reg) { + if (!voltdm->read || !voltdm->write) { pr_err("%s: No read/write API for accessing vdd_%s regs\n", __func__, voltdm->name); return -EINVAL; @@ -58,24 +58,22 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, volt_data = NULL; *target_vsel = vdd->pmic_info->uv_to_vsel(target_volt); - *current_vsel = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->voltage); + *current_vsel = voltdm->read(vdd->vp_data->voltage); /* Setting the ON voltage to the new target voltage */ - vc_cmdval = vdd->read_reg(vc->common->prm_mod, vc->cmdval_reg); + vc_cmdval = voltdm->read(vc->cmdval_reg); vc_cmdval &= ~vc->common->cmd_on_mask; vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift); - vdd->write_reg(vc_cmdval, vc->common->prm_mod, vc->cmdval_reg); + voltdm->write(vc_cmdval, vc->cmdval_reg); /* Setting vp errorgain based on the voltage */ if (volt_data) { - vp_errgain_val = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, - vdd->vp_data->vpconfig); + vp_errgain_val = voltdm->read(vdd->vp_data->vpconfig); vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain; vp_errgain_val &= ~vp_common->vpconfig_errorgain_mask; vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain << vp_common->vpconfig_errorgain_shift; - vdd->write_reg(vp_errgain_val, vdd->vp_data->vp_common->prm_mod, - vdd->vp_data->vpconfig); + voltdm->write(vp_errgain_val, vdd->vp_data->vpconfig); } return 0; @@ -120,11 +118,10 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, (vdd->pmic_info->i2c_slave_addr << vc->common->slaveaddr_shift); - vdd->write_reg(vc_bypass_value, vc->common->prm_mod, vc_bypass_val_reg); - vdd->write_reg(vc_bypass_value | vc_valid, vc->common->prm_mod, - vc_bypass_val_reg); + voltdm->write(vc_bypass_value, vc_bypass_val_reg); + voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg); - vc_bypass_value = vdd->read_reg(vc->common->prm_mod, vc_bypass_val_reg); + vc_bypass_value = voltdm->read(vc_bypass_val_reg); /* * Loop till the bypass command is acknowledged from the SMPS. * NOTE: This is legacy code. The loop count and retry count needs @@ -143,8 +140,7 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, loop_cnt = 0; udelay(10); } - vc_bypass_value = vdd->read_reg(vc->common->prm_mod, - vc_bypass_val_reg); + vc_bypass_value = voltdm->read(vc_bypass_val_reg); } omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel); @@ -153,18 +149,13 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, static void __init omap3_vfsm_init(struct voltagedomain *voltdm) { - struct omap_vc_channel *vc = voltdm->vc; - struct omap_vdd_info *vdd = voltdm->vdd; - /* * Voltage Manager FSM parameters init * XXX This data should be passed in from the board file */ - vdd->write_reg(OMAP3_CLKSETUP, vc->common->prm_mod, OMAP3_PRM_CLKSETUP_OFFSET); - vdd->write_reg(OMAP3_VOLTOFFSET, vc->common->prm_mod, - OMAP3_PRM_VOLTOFFSET_OFFSET); - vdd->write_reg(OMAP3_VOLTSETUP2, vc->common->prm_mod, - OMAP3_PRM_VOLTSETUP2_OFFSET); + voltdm->write(OMAP3_CLKSETUP, OMAP3_PRM_CLKSETUP_OFFSET); + voltdm->write(OMAP3_VOLTOFFSET, OMAP3_PRM_VOLTOFFSET_OFFSET); + voltdm->write(OMAP3_VOLTSETUP2, OMAP3_PRM_VOLTSETUP2_OFFSET); } static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) @@ -187,16 +178,16 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) (onlp_vsel << vc->common->cmd_onlp_shift) | (ret_vsel << vc->common->cmd_ret_shift) | (off_vsel << vc->common->cmd_off_shift)); - vdd->write_reg(vc_val, vc->common->prm_mod, vc->cmdval_reg); + voltdm->write(vc_val, vc->cmdval_reg); /* * Generic VC parameters init * XXX This data should be abstracted out */ - vdd->write_reg(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, vc->common->prm_mod, - OMAP3_PRM_VC_CH_CONF_OFFSET); - vdd->write_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, vc->common->prm_mod, - OMAP3_PRM_VC_I2C_CFG_OFFSET); + voltdm->write(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, + OMAP3_PRM_VC_CH_CONF_OFFSET); + voltdm->write(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, + OMAP3_PRM_VC_I2C_CFG_OFFSET); omap3_vfsm_init(voltdm); @@ -207,8 +198,6 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) /* OMAP4 specific voltage init functions */ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) { - struct omap_vc_channel *vc = voltdm->vc; - struct omap_vdd_info *vdd = voltdm->vdd; static bool is_initialized; u32 vc_val; @@ -224,11 +213,11 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) vc_val = (OMAP4430_RAV_VDD_MPU_L_MASK | OMAP4430_CMD_VDD_MPU_L_MASK | OMAP4430_RAV_VDD_IVA_L_MASK | OMAP4430_CMD_VDD_IVA_L_MASK | OMAP4430_RAV_VDD_CORE_L_MASK | OMAP4430_CMD_VDD_CORE_L_MASK); - vdd->write_reg(vc_val, vc->common->prm_mod, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); + voltdm->write(vc_val, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); /* XXX These are magic numbers and do not belong! */ vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT); - vdd->write_reg(vc_val, vc->common->prm_mod, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); + voltdm->write(vc_val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); is_initialized = true; } @@ -246,34 +235,30 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) return; } - if (!vdd->read_reg || !vdd->write_reg) { + if (!voltdm->read || !voltdm->write) { pr_err("%s: No read/write API for accessing vdd_%s regs\n", __func__, voltdm->name); return; } /* Set up the SMPS_SA(i2c slave address in VC */ - vc_val = vdd->read_reg(vc->common->prm_mod, - vc->common->smps_sa_reg); + vc_val = voltdm->read(vc->common->smps_sa_reg); vc_val &= ~vc->smps_sa_mask; vc_val |= vdd->pmic_info->i2c_slave_addr << vc->smps_sa_shift; - vdd->write_reg(vc_val, vc->common->prm_mod, - vc->common->smps_sa_reg); + voltdm->write(vc_val, vc->common->smps_sa_reg); /* Setup the VOLRA(pmic reg addr) in VC */ - vc_val = vdd->read_reg(vc->common->prm_mod, - vc->common->smps_volra_reg); + vc_val = voltdm->read(vc->common->smps_volra_reg); vc_val &= ~vc->smps_volra_mask; vc_val |= vdd->pmic_info->volt_reg_addr << vc->smps_volra_shift; - vdd->write_reg(vc_val, vc->common->prm_mod, - vc->common->smps_volra_reg); + voltdm->write(vc_val, vc->common->smps_volra_reg); /* Configure the setup times */ - vc_val = vdd->read_reg(vc->common->prm_mod, vdd->vfsm->voltsetup_reg); + vc_val = voltdm->read(vdd->vfsm->voltsetup_reg); vc_val &= ~vdd->vfsm->voltsetup_mask; vc_val |= vdd->pmic_info->volt_setup_time << vdd->vfsm->voltsetup_shift; - vdd->write_reg(vc_val, vc->common->prm_mod, vdd->vfsm->voltsetup_reg); + voltdm->write(vc_val, vdd->vfsm->voltsetup_reg); if (cpu_is_omap34xx()) omap3_vc_init_channel(voltdm); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 51d36a80b131..d0050f0ee6d5 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -25,7 +25,6 @@ struct voltagedomain; * struct omap_vc_common - per-VC register/bitfield data * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register - * @prm_mod: PRM module id used for PRM register access * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start * @bypass_val_reg: Offset of PRM_VC_BYPASS_VAL reg from PRM start @@ -43,7 +42,6 @@ struct voltagedomain; struct omap_vc_common { u32 cmd_on_mask; u32 valid; - s16 prm_mod; u8 smps_sa_reg; u8 smps_volra_reg; u8 bypass_val_reg; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 1a17ed459cc3..6b6720301345 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -30,7 +30,6 @@ * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ static struct omap_vc_common omap3_vc_common = { - .prm_mod = OMAP3430_GR_MOD, .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, .bypass_val_reg = OMAP3_PRM_VC_BYPASS_VAL_OFFSET, diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 56f3f4a37879..e3125a370fa7 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -31,7 +31,6 @@ * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ static const struct omap_vc_common omap4_vc_common = { - .prm_mod = OMAP4430_PRM_DEVICE_INST, .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, .bypass_val_reg = OMAP4_PRM_VC_VAL_BYPASS_OFFSET, diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 9b9f01973d12..9f9f01465f6a 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -46,27 +46,6 @@ static LIST_HEAD(voltdm_list); #define VOLTAGE_DIR_SIZE 16 static struct dentry *voltage_dir; -static u32 omap3_voltage_read_reg(u16 mod, u8 offset) -{ - return omap2_prm_read_mod_reg(mod, offset); -} - -static void omap3_voltage_write_reg(u32 val, u16 mod, u8 offset) -{ - omap2_prm_write_mod_reg(val, mod, offset); -} - -static u32 omap4_voltage_read_reg(u16 mod, u8 offset) -{ - return omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, - mod, offset); -} - -static void omap4_voltage_write_reg(u32 val, u16 mod, u8 offset) -{ - omap4_prminst_write_inst_reg(val, OMAP4430_PRM_PARTITION, mod, offset); -} - static int __init _config_common_vdd_data(struct voltagedomain *voltdm) { char *sys_ck_name; @@ -183,15 +162,7 @@ static int __init omap_vdd_data_configure(struct voltagedomain *voltdm) if (IS_ERR_VALUE(_config_common_vdd_data(voltdm))) goto ovdc_out; - if (cpu_is_omap34xx()) { - vdd->read_reg = omap3_voltage_read_reg; - vdd->write_reg = omap3_voltage_write_reg; - ret = 0; - } else if (cpu_is_omap44xx()) { - vdd->read_reg = omap4_voltage_read_reg; - vdd->write_reg = omap4_voltage_write_reg; - ret = 0; - } + ret = 0; ovdc_out: return ret; diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 04e06266dbd7..6a19cf39118b 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -59,6 +59,9 @@ struct omap_vfsm_instance_data { * @node: list_head linking all voltage domains * @pwrdm_list: list_head linking all powerdomains in this voltagedomain * @vc: pointer to VC channel associated with this voltagedomain + * @read: read a VC/VP register + * @write: write a VC/VP register + * @read: read-modify-write a VC/VP register * @vdd: to be removed */ struct voltagedomain { @@ -68,6 +71,11 @@ struct voltagedomain { struct list_head pwrdm_list; struct omap_vc_channel *vc; + /* VC/VP register access functions: SoC specific */ + u32 (*read) (u8 offset); + void (*write) (u32 val, u8 offset); + u32 (*rmw)(u32 mask, u32 bits, u8 offset); + struct omap_vdd_info *vdd; }; @@ -146,8 +154,6 @@ struct omap_vdd_info { u32 curr_volt; bool vp_enabled; - u32 (*read_reg) (u16 mod, u8 offset); - void (*write_reg) (u32 val, u16 mod, u8 offset); 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 ad8f05b6a889..1d667490bc95 100644 --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c @@ -56,6 +56,9 @@ static struct omap_vdd_info omap3_vdd2_info = { static struct voltagedomain omap3_voltdm_mpu = { .name = "mpu_iva", .scalable = true, + .read = omap3_prm_vcvp_read, + .write = omap3_prm_vcvp_write, + .rmw = omap3_prm_vcvp_rmw, .vc = &omap3_vc_mpu, .vdd = &omap3_vdd1_info, }; @@ -63,6 +66,9 @@ static struct voltagedomain omap3_voltdm_mpu = { static struct voltagedomain omap3_voltdm_core = { .name = "core", .scalable = true, + .read = omap3_prm_vcvp_read, + .write = omap3_prm_vcvp_write, + .rmw = omap3_prm_vcvp_rmw, .vc = &omap3_vc_core, .vdd = &omap3_vdd2_info, }; diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c index 43e1d3817244..e435795d61b7 100644 --- a/arch/arm/mach-omap2/voltagedomains44xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c @@ -62,6 +62,9 @@ static struct omap_vdd_info omap4_vdd_core_info = { static struct voltagedomain omap4_voltdm_mpu = { .name = "mpu", .scalable = true, + .read = omap4_prm_vcvp_read, + .write = omap4_prm_vcvp_write, + .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_mpu, .vdd = &omap4_vdd_mpu_info, }; @@ -69,6 +72,9 @@ static struct voltagedomain omap4_voltdm_mpu = { static struct voltagedomain omap4_voltdm_iva = { .name = "iva", .scalable = true, + .read = omap4_prm_vcvp_read, + .write = omap4_prm_vcvp_write, + .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_iva, .vdd = &omap4_vdd_iva_info, }; @@ -76,6 +82,9 @@ static struct voltagedomain omap4_voltdm_iva = { static struct voltagedomain omap4_voltdm_core = { .name = "core", .scalable = true, + .read = omap4_prm_vcvp_read, + .write = omap4_prm_vcvp_write, + .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_core, .vdd = &omap4_vdd_core_info, }; diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c index 113c839f6e23..88ac742a38cf 100644 --- a/arch/arm/mach-omap2/vp.c +++ b/arch/arm/mach-omap2/vp.c @@ -35,19 +35,19 @@ static void vp_latch_vsel(struct voltagedomain *voltdm) vsel = vdd->pmic_info->uv_to_vsel(uvdc); - vpconfig = vdd->read_reg(vp->vp_common->prm_mod, vp->vpconfig); + 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; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* Trigger initVDD value copy to voltage processor */ - vdd->write_reg((vpconfig | vp->vp_common->vpconfig_initvdd), - vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write((vpconfig | vp->vp_common->vpconfig_initvdd), + vp->vpconfig); /* Clear initVDD copy trigger bit */ - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); } /* Generic voltage init functions */ @@ -57,7 +57,7 @@ void __init omap_vp_init(struct voltagedomain *voltdm) struct omap_vdd_info *vdd = voltdm->vdd; u32 vp_val; - if (!vdd->read_reg || !vdd->write_reg) { + if (!voltdm->read || !voltdm->write) { pr_err("%s: No read/write API for accessing vdd_%s regs\n", __func__, voltdm->name); return; @@ -67,19 +67,19 @@ void __init omap_vp_init(struct voltagedomain *voltdm) (vdd->vp_rt_data.vpconfig_errorgain << vp->vp_common->vpconfig_errorgain_shift) | vp->vp_common->vpconfig_timeouten; - vdd->write_reg(vp_val, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vp_val, vp->vpconfig); vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin << vp->vp_common->vstepmin_smpswaittimemin_shift) | (vdd->vp_rt_data.vstepmin_stepmin << vp->vp_common->vstepmin_stepmin_shift)); - vdd->write_reg(vp_val, vp->vp_common->prm_mod, vp->vstepmin); + voltdm->write(vp_val, vp->vstepmin); vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax << vp->vp_common->vstepmax_smpswaittimemax_shift) | (vdd->vp_rt_data.vstepmax_stepmax << vp->vp_common->vstepmax_stepmax_shift)); - vdd->write_reg(vp_val, vp->vp_common->prm_mod, vp->vstepmax); + voltdm->write(vp_val, vp->vstepmax); vp_val = ((vdd->vp_rt_data.vlimitto_vddmax << vp->vp_common->vlimitto_vddmax_shift) | @@ -87,7 +87,7 @@ void __init omap_vp_init(struct voltagedomain *voltdm) vp->vp_common->vlimitto_vddmin_shift) | (vdd->vp_rt_data.vlimitto_timeout << vp->vp_common->vlimitto_timeout_shift)); - vdd->write_reg(vp_val, vp->vp_common->prm_mod, vp->vlimitto); + voltdm->write(vp_val, vp->vlimitto); vp_debugfs_init(voltdm); } @@ -97,7 +97,6 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, unsigned long target_volt) { struct omap_vp_instance_data *vp = voltdm->vdd->vp_data; - struct omap_vdd_info *vdd = voltdm->vdd; u32 vpconfig; u8 target_vsel, current_vsel; int ret, timeout = 0; @@ -123,21 +122,21 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, } /* Configure for VP-Force Update */ - vpconfig = vdd->read_reg(vp->vp_common->prm_mod, vp->vpconfig); + vpconfig = voltdm->read(vp->vpconfig); vpconfig &= ~(vp->vp_common->vpconfig_initvdd | vp->vp_common->vpconfig_forceupdate | vp->vp_common->vpconfig_initvoltage_mask); vpconfig |= ((target_vsel << vp->vp_common->vpconfig_initvoltage_shift)); - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* Trigger initVDD value copy to voltage processor */ vpconfig |= vp->vp_common->vpconfig_initvdd; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* Force update of voltage */ vpconfig |= vp->vp_common->vpconfig_forceupdate; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* * Wait for TransactionDone. Typical latency is <200us. @@ -170,13 +169,13 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, "to clear the TRANXDONE status\n", __func__, voltdm->name); - vpconfig = vdd->read_reg(vp->vp_common->prm_mod, vp->vpconfig); + vpconfig = voltdm->read(vp->vpconfig); /* Clear initVDD copy trigger bit */ vpconfig &= ~vp->vp_common->vpconfig_initvdd; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* Clear force bit */ vpconfig &= ~vp->vp_common->vpconfig_forceupdate; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); return 0; } @@ -199,13 +198,13 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm) } vdd = voltdm->vdd; - if (!vdd->read_reg) { + if (!voltdm->read) { pr_err("%s: No read API for reading vdd_%s regs\n", __func__, voltdm->name); return 0; } - curr_vsel = vdd->read_reg(vp->vp_common->prm_mod, vp->voltage); + curr_vsel = voltdm->read(vp->voltage); if (!vdd->pmic_info || !vdd->pmic_info->vsel_to_uv) { pr_warning("%s: PMIC function to convert vsel to voltage" @@ -236,7 +235,7 @@ void omap_vp_enable(struct voltagedomain *voltdm) vdd = voltdm->vdd; vp = voltdm->vdd->vp_data; - if (!vdd->read_reg || !vdd->write_reg) { + if (!voltdm->read || !voltdm->write) { pr_err("%s: No read/write API for accessing vdd_%s regs\n", __func__, voltdm->name); return; @@ -249,9 +248,9 @@ void omap_vp_enable(struct voltagedomain *voltdm) vp_latch_vsel(voltdm); /* Enable VP */ - vpconfig = vdd->read_reg(vp->vp_common->prm_mod, vp->vpconfig); + vpconfig = voltdm->read(vp->vpconfig); vpconfig |= vp->vp_common->vpconfig_vpenable; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); vdd->vp_enabled = true; } @@ -276,7 +275,7 @@ void omap_vp_disable(struct voltagedomain *voltdm) vdd = voltdm->vdd; vp = voltdm->vdd->vp_data; - if (!vdd->read_reg || !vdd->write_reg) { + if (!voltdm->read || !voltdm->write) { pr_err("%s: No read/write API for accessing vdd_%s regs\n", __func__, voltdm->name); return; @@ -290,15 +289,15 @@ void omap_vp_disable(struct voltagedomain *voltdm) } /* Disable VP */ - vpconfig = vdd->read_reg(vp->vp_common->prm_mod, vp->vpconfig); + vpconfig = voltdm->read(vp->vpconfig); vpconfig &= ~vp->vp_common->vpconfig_vpenable; - vdd->write_reg(vpconfig, vp->vp_common->prm_mod, vp->vpconfig); + voltdm->write(vpconfig, vp->vpconfig); /* * Wait for VP idle Typical latency is <2us. Maximum latency is ~100us */ - omap_test_timeout((vdd->read_reg(vp->vp_common->prm_mod, vp->vstatus)), - VP_IDLE_TIMEOUT, timeout); + omap_test_timeout((voltdm->read(vp->vstatus)), + VP_IDLE_TIMEOUT, timeout); if (timeout >= VP_IDLE_TIMEOUT) pr_warning("%s: vdd_%s idle timedout\n", @@ -322,7 +321,7 @@ static int vp_volt_debug_get(void *data, u64 *val) return -EINVAL; } - vsel = vdd->read_reg(vp->vp_common->prm_mod, vp->voltage); + vsel = voltdm->read(vp->voltage); if (!vdd->pmic_info->vsel_to_uv) { pr_warning("PMIC function to convert vsel to voltage" diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h index 1ccf7419a36c..382fef13dbc4 100644 --- a/arch/arm/mach-omap2/vp.h +++ b/arch/arm/mach-omap2/vp.h @@ -62,7 +62,6 @@ struct omap_vp_ops { * @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 - * @prm_mod: PRM module id used for PRM register access * * XXX It it not necessary to have both a mask and a shift for the same * bitfield - remove one @@ -75,7 +74,6 @@ struct omap_vp_common_data { u32 vpconfig_initvdd; u32 vpconfig_forceupdate; u32 vpconfig_vpenable; - s16 prm_mod; u8 vpconfig_erroroffset_shift; u8 vpconfig_errorgain_shift; u8 vpconfig_initvoltage_shift; diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c index 0372c1ab5672..b01d33325d52 100644 --- a/arch/arm/mach-omap2/vp3xxx_data.c +++ b/arch/arm/mach-omap2/vp3xxx_data.c @@ -37,7 +37,6 @@ 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_data omap3_vp_common = { - .prm_mod = OMAP3430_GR_MOD, .vpconfig_erroroffset_shift = OMAP3430_ERROROFFSET_SHIFT, .vpconfig_errorgain_mask = OMAP3430_ERRORGAIN_MASK, .vpconfig_errorgain_shift = OMAP3430_ERRORGAIN_SHIFT, diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c index 738ba04f5cf1..9704c7ba9e99 100644 --- a/arch/arm/mach-omap2/vp44xx_data.c +++ b/arch/arm/mach-omap2/vp44xx_data.c @@ -37,7 +37,6 @@ 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_data omap4_vp_common = { - .prm_mod = OMAP4430_PRM_DEVICE_INST, .vpconfig_erroroffset_shift = OMAP4430_ERROROFFSET_SHIFT, .vpconfig_errorgain_mask = OMAP4430_ERRORGAIN_MASK, .vpconfig_errorgain_shift = OMAP4430_ERRORGAIN_SHIFT, -- cgit v1.2.3 From ba112a4e86ba8f0f9546bd953374cde064b507ca Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 29 Mar 2011 14:02:36 -0700 Subject: OMAP3+: VC: cleanup i2c slave address configuration - Add an i2c_slave_address field to the omap_vc_channel - use VC/VP read/modify/write helper instead of open-coding - remove smps_sa_shift, use __ffs(mask) for shift value - I2C addresses 10-bit, change size to u16 Special thanks to Shweta Gulati for suggesting the use of __ffs(x) instead of ffs(x) - 1. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 12 +++++++----- arch/arm/mach-omap2/vc.h | 9 ++++++--- arch/arm/mach-omap2/vc3xxx_data.c | 2 -- arch/arm/mach-omap2/vc44xx_data.c | 3 --- arch/arm/mach-omap2/voltage.h | 3 ++- 5 files changed, 15 insertions(+), 14 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index f1c73cbe3cb4..d5e792f20f16 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -241,11 +241,13 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) return; } - /* Set up the SMPS_SA(i2c slave address in VC */ - vc_val = voltdm->read(vc->common->smps_sa_reg); - vc_val &= ~vc->smps_sa_mask; - vc_val |= vdd->pmic_info->i2c_slave_addr << vc->smps_sa_shift; - voltdm->write(vc_val, vc->common->smps_sa_reg); + /* get PMIC/board specific settings */ + vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; + + /* Configure the i2c slave address for this VC */ + voltdm->rmw(vc->smps_sa_mask, + vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), + vc->common->smps_sa_reg); /* Setup the VOLRA(pmic reg addr) in VC */ vc_val = voltdm->read(vc->common->smps_volra_reg); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index d0050f0ee6d5..69ca900aff0b 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -56,21 +56,24 @@ struct omap_vc_common { /** * struct omap_vc_channel - VC per-instance data + * @i2c_slave_addr: I2C slave address of PMIC for this VC channel * @common: pointer to VC common data for this platform - * @smps_sa_mask: SA* bitmask in the PRM_VC_SMPS_SA register + * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register - * @smps_sa_shift: SA* field shift in the PRM_VC_SMPS_SA register * @smps_volra_shift: VOLRA* field shift in the PRM_VC_VOL_RA register * * XXX It is not necessary to have both a *_mask and a *_shift - * remove one */ struct omap_vc_channel { + /* channel state */ + u16 i2c_slave_addr; + + /* register access data */ const struct omap_vc_common *common; u32 smps_sa_mask; u32 smps_volra_mask; u8 cmdval_reg; - u8 smps_sa_shift; u8 smps_volra_shift; }; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 6b6720301345..86be50c263ac 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -47,7 +47,6 @@ static struct omap_vc_common omap3_vc_common = { struct omap_vc_channel omap3_vc_mpu = { .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, - .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA0_SHIFT, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, .smps_volra_shift = OMAP3430_VOLRA0_SHIFT, .smps_volra_mask = OMAP3430_VOLRA0_MASK, @@ -56,7 +55,6 @@ struct omap_vc_channel omap3_vc_mpu = { struct omap_vc_channel omap3_vc_core = { .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, - .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, .smps_volra_shift = OMAP3430_VOLRA1_SHIFT, .smps_volra_mask = OMAP3430_VOLRA1_MASK, diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index e3125a370fa7..af922b440e96 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -49,7 +49,6 @@ static const struct omap_vc_common omap4_vc_common = { struct omap_vc_channel omap4_vc_mpu = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, - .smps_sa_shift = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, .smps_volra_shift = OMAP4430_VOLRA_VDD_MPU_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, @@ -58,7 +57,6 @@ struct omap_vc_channel omap4_vc_mpu = { struct omap_vc_channel omap4_vc_iva = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, - .smps_sa_shift = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, .smps_volra_shift = OMAP4430_VOLRA_VDD_IVA_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, @@ -67,7 +65,6 @@ struct omap_vc_channel omap4_vc_iva = { struct omap_vc_channel omap4_vc_core = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, - .smps_sa_shift = OMAP4430_SA_VDD_CORE_L_0_6_SHIFT, .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, .smps_volra_shift = OMAP4430_VOLRA_VDD_CORE_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 6a19cf39118b..590384978279 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -102,6 +102,7 @@ struct omap_volt_data { * struct omap_volt_pmic_info - PMIC specific data required by voltage driver. * @slew_rate: PMIC slew rate (in uv/us) * @step_size: PMIC voltage step size (in uv) + * @i2c_slave_addr: I2C slave address of PMIC * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. * @volt_reg_addr: voltage configuration register address @@ -115,13 +116,13 @@ struct omap_volt_pmic_info { u32 ret_volt; u32 off_volt; u16 volt_setup_time; + u16 i2c_slave_addr; u8 vp_erroroffset; u8 vp_vstepmin; u8 vp_vstepmax; u8 vp_vddmin; u8 vp_vddmax; u8 vp_timeout_us; - u8 i2c_slave_addr; u8 volt_reg_addr; u8 cmd_reg_addr; unsigned long (*vsel_to_uv) (const u8 vsel); -- cgit v1.2.3 From e4e021c5491537783f5f65a6defa92e6098a3658 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Thu, 9 Jun 2011 11:01:55 -0700 Subject: OMAP3+: VC: cleanup PMIC register address configuration - support both voltage register address and command register address for each VC channel - add fields for voltage register address (volra) and command register address (cmdra) to struct omap_vc_channel - use VC/VP register access read/modify/write helper - remove volra_shift field (use __ffs(mask) for shift value) - I2C addresses 10-bit, change size to u16 Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 17 ++++++++++++----- arch/arm/mach-omap2/vc.h | 14 +++++++++----- arch/arm/mach-omap2/vc3xxx_data.c | 5 +++-- arch/arm/mach-omap2/vc44xx_data.c | 7 ++++--- arch/arm/mach-omap2/voltage.h | 8 ++++---- 5 files changed, 32 insertions(+), 19 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index d5e792f20f16..22db6e6764d7 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -243,17 +243,24 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) /* get PMIC/board specific settings */ vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; + vc->volt_reg_addr = vdd->pmic_info->volt_reg_addr; + vc->cmd_reg_addr = vdd->pmic_info->cmd_reg_addr; /* Configure the i2c slave address for this VC */ voltdm->rmw(vc->smps_sa_mask, vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), vc->common->smps_sa_reg); - /* Setup the VOLRA(pmic reg addr) in VC */ - vc_val = voltdm->read(vc->common->smps_volra_reg); - vc_val &= ~vc->smps_volra_mask; - vc_val |= vdd->pmic_info->volt_reg_addr << vc->smps_volra_shift; - voltdm->write(vc_val, vc->common->smps_volra_reg); + /* + * Configure the PMIC register addresses. + */ + voltdm->rmw(vc->smps_volra_mask, + vc->volt_reg_addr << __ffs(vc->smps_volra_mask), + vc->common->smps_volra_reg); + if (vc->cmd_reg_addr) + voltdm->rmw(vc->smps_cmdra_mask, + vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), + vc->common->smps_cmdra_reg); /* Configure the setup times */ vc_val = voltdm->read(vdd->vfsm->voltsetup_reg); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 69ca900aff0b..43a0c5c2b07a 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -27,6 +27,7 @@ struct voltagedomain; * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start + * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start * @bypass_val_reg: Offset of PRM_VC_BYPASS_VAL reg from PRM start * @data_shift: DATA field shift in PRM_VC_BYPASS_VAL register * @slaveaddr_shift: SLAVEADDR field shift in PRM_VC_BYPASS_VAL register @@ -44,6 +45,7 @@ struct omap_vc_common { u32 valid; u8 smps_sa_reg; u8 smps_volra_reg; + u8 smps_cmdra_reg; u8 bypass_val_reg; u8 data_shift; u8 slaveaddr_shift; @@ -57,24 +59,26 @@ struct omap_vc_common { /** * struct omap_vc_channel - VC per-instance data * @i2c_slave_addr: I2C slave address of PMIC for this VC channel + * @volt_reg_addr: voltage configuration register address + * @cmd_reg_addr: command configuration register address * @common: pointer to VC common data for this platform * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register - * @smps_volra_shift: VOLRA* field shift in the PRM_VC_VOL_RA register - * - * XXX It is not necessary to have both a *_mask and a *_shift - - * remove one + * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register + * @cmdval_reg: register for on/ret/off voltage level values for this channel */ struct omap_vc_channel { /* channel state */ u16 i2c_slave_addr; + u16 volt_reg_addr; + u16 cmd_reg_addr; /* register access data */ const struct omap_vc_common *common; u32 smps_sa_mask; u32 smps_volra_mask; + u32 smps_cmdra_mask; u8 cmdval_reg; - u8 smps_volra_shift; }; extern struct omap_vc_channel omap3_vc_mpu; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 86be50c263ac..df8bd5ead7e4 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -32,6 +32,7 @@ static struct omap_vc_common omap3_vc_common = { .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, + .smps_cmdra_reg = OMAP3_PRM_VC_SMPS_CMD_RA_OFFSET, .bypass_val_reg = OMAP3_PRM_VC_BYPASS_VAL_OFFSET, .data_shift = OMAP3430_DATA_SHIFT, .slaveaddr_shift = OMAP3430_SLAVEADDR_SHIFT, @@ -48,14 +49,14 @@ struct omap_vc_channel omap3_vc_mpu = { .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, - .smps_volra_shift = OMAP3430_VOLRA0_SHIFT, .smps_volra_mask = OMAP3430_VOLRA0_MASK, + .smps_cmdra_mask = OMAP3430_CMDRA0_MASK, }; struct omap_vc_channel omap3_vc_core = { .common = &omap3_vc_common, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, - .smps_volra_shift = OMAP3430_VOLRA1_SHIFT, .smps_volra_mask = OMAP3430_VOLRA1_MASK, + .smps_cmdra_mask = OMAP3430_CMDRA1_MASK, }; diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index af922b440e96..5d104ff662b3 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -33,6 +33,7 @@ static const struct omap_vc_common omap4_vc_common = { .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, + .smps_cmdra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_CMD_OFFSET, .bypass_val_reg = OMAP4_PRM_VC_VAL_BYPASS_OFFSET, .data_shift = OMAP4430_DATA_SHIFT, .slaveaddr_shift = OMAP4430_SLAVEADDR_SHIFT, @@ -50,23 +51,23 @@ struct omap_vc_channel omap4_vc_mpu = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, - .smps_volra_shift = OMAP4430_VOLRA_VDD_MPU_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, + .smps_cmdra_mask = OMAP4430_CMDRA_VDD_MPU_L_MASK, }; struct omap_vc_channel omap4_vc_iva = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, - .smps_volra_shift = OMAP4430_VOLRA_VDD_IVA_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, + .smps_cmdra_mask = OMAP4430_CMDRA_VDD_IVA_L_MASK, }; struct omap_vc_channel omap4_vc_core = { .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, - .smps_volra_shift = OMAP4430_VOLRA_VDD_CORE_L_SHIFT, .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, + .smps_cmdra_mask = OMAP4430_CMDRA_VDD_CORE_L_MASK, }; diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 590384978279..3f49807a36e8 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -103,10 +103,10 @@ struct omap_volt_data { * @slew_rate: PMIC slew rate (in uv/us) * @step_size: PMIC voltage step size (in uv) * @i2c_slave_addr: I2C slave address of PMIC - * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. - * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. * @volt_reg_addr: voltage configuration register address * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address + * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. + * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. */ struct omap_volt_pmic_info { int slew_rate; @@ -117,14 +117,14 @@ struct omap_volt_pmic_info { u32 off_volt; u16 volt_setup_time; u16 i2c_slave_addr; + u16 volt_reg_addr; + u16 cmd_reg_addr; u8 vp_erroroffset; u8 vp_vstepmin; u8 vp_vstepmax; u8 vp_vddmin; u8 vp_vddmax; u8 vp_timeout_us; - u8 volt_reg_addr; - u8 cmd_reg_addr; unsigned long (*vsel_to_uv) (const u8 vsel); u8 (*uv_to_vsel) (unsigned long uV); }; -- cgit v1.2.3 From 78614e0f8f32dca52beebaadfb53c2a3acf1604a Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 29 Mar 2011 14:24:47 -0700 Subject: OMAP3+: VC bypass: use fields from VC struct instead of PMIC info The PMIC configurable variables should be isolated to VC initialization. The rest of the VC functions (like VC bypass) should use the i2c slave address and voltage register address fields from struct omap_vc_channel. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 22db6e6764d7..8f0105a7bb4b 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -100,7 +100,6 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, unsigned long target_volt) { struct omap_vc_channel *vc = voltdm->vc; - struct omap_vdd_info *vdd = voltdm->vdd; u32 loop_cnt = 0, retries_cnt = 0; u32 vc_valid, vc_bypass_val_reg, vc_bypass_value; u8 target_vsel, current_vsel; @@ -113,10 +112,8 @@ int omap_vc_bypass_scale(struct voltagedomain *voltdm, vc_valid = vc->common->valid; vc_bypass_val_reg = vc->common->bypass_val_reg; vc_bypass_value = (target_vsel << vc->common->data_shift) | - (vdd->pmic_info->volt_reg_addr << - vc->common->regaddr_shift) | - (vdd->pmic_info->i2c_slave_addr << - vc->common->slaveaddr_shift); + (vc->volt_reg_addr << vc->common->regaddr_shift) | + (vc->i2c_slave_addr << vc->common->slaveaddr_shift); voltdm->write(vc_bypass_value, vc_bypass_val_reg); voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg); -- cgit v1.2.3 From 5892bb1fc6430d086f5c2a4216f9ed00070e31ad Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 29 Mar 2011 14:36:04 -0700 Subject: OMAP3+: VC: cleanup voltage setup time configuration - add setup_time field to struct omap_vc_channel (init'd from PMIC data) - use VC/VP register access helper for read/modify/write - move VFSM structure from omap_vdd_info into struct voltagedomain - remove redunant _data suffix from VFSM structures and variables - remove voltsetup_shift, use ffs() on the mask value to find the shift Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 10 ++++------ arch/arm/mach-omap2/vc.h | 2 ++ arch/arm/mach-omap2/voltage.h | 11 +++-------- arch/arm/mach-omap2/voltagedomains3xxx_data.c | 10 ++++------ arch/arm/mach-omap2/voltagedomains44xx_data.c | 12 ++++++------ 5 files changed, 19 insertions(+), 26 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 8f0105a7bb4b..f78e62abe720 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -223,7 +223,6 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) { struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; - u32 vc_val; if (!vdd->pmic_info || !vdd->pmic_info->uv_to_vsel) { pr_err("%s: PMIC info requried to configure vc for" @@ -242,6 +241,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; vc->volt_reg_addr = vdd->pmic_info->volt_reg_addr; vc->cmd_reg_addr = vdd->pmic_info->cmd_reg_addr; + vc->setup_time = vdd->pmic_info->volt_setup_time; /* Configure the i2c slave address for this VC */ voltdm->rmw(vc->smps_sa_mask, @@ -260,11 +260,9 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc->common->smps_cmdra_reg); /* Configure the setup times */ - vc_val = voltdm->read(vdd->vfsm->voltsetup_reg); - vc_val &= ~vdd->vfsm->voltsetup_mask; - vc_val |= vdd->pmic_info->volt_setup_time << - vdd->vfsm->voltsetup_shift; - voltdm->write(vc_val, vdd->vfsm->voltsetup_reg); + voltdm->rmw(voltdm->vfsm->voltsetup_mask, + vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask), + voltdm->vfsm->voltsetup_reg); if (cpu_is_omap34xx()) omap3_vc_init_channel(voltdm); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 43a0c5c2b07a..6e8806b59823 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -61,6 +61,7 @@ struct omap_vc_common { * @i2c_slave_addr: I2C slave address of PMIC for this VC channel * @volt_reg_addr: voltage configuration register address * @cmd_reg_addr: command configuration register address + * @setup_time: setup time (in sys_clk cycles) of regulator for this channel * @common: pointer to VC common data for this platform * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register @@ -72,6 +73,7 @@ struct omap_vc_channel { u16 i2c_slave_addr; u16 volt_reg_addr; u16 cmd_reg_addr; + u16 setup_time; /* register access data */ const struct omap_vc_common *common; diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 3f49807a36e8..99df2d13e42e 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -36,20 +36,16 @@ struct powerdomain; struct omap_vdd_info; /** - * struct omap_vfsm_instance_data - per-voltage manager FSM register/bitfield + * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield * data * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base - * @voltsetup_shift: SETUP_TIME* field shift in the PRM_VOLTSETUP* register * * XXX What about VOLTOFFSET/VOLTCTRL? - * XXX It is not necessary to have both a _mask and a _shift for the same - * bitfield - remove one! */ -struct omap_vfsm_instance_data { +struct omap_vfsm_instance { u32 voltsetup_mask; u8 voltsetup_reg; - u8 voltsetup_shift; }; /** @@ -70,6 +66,7 @@ struct voltagedomain { struct list_head node; struct list_head pwrdm_list; struct omap_vc_channel *vc; + const struct omap_vfsm_instance *vfsm; /* VC/VP register access functions: SoC specific */ u32 (*read) (u8 offset); @@ -139,7 +136,6 @@ struct omap_volt_pmic_info { * @vp_data : the register values, shifts, masks for various * vp registers * @vp_rt_data : VP data derived at runtime, not predefined - * @vfsm : voltage manager FSM data * @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 @@ -150,7 +146,6 @@ struct omap_vdd_info { struct omap_volt_pmic_info *pmic_info; struct omap_vp_instance_data *vp_data; struct omap_vp_runtime_data vp_rt_data; - const struct omap_vfsm_instance_data *vfsm; struct dentry *debug_dir; u32 curr_volt; bool vp_enabled; diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c index 1d667490bc95..ce5a7971addf 100644 --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c @@ -31,26 +31,22 @@ * VDD data */ -static const struct omap_vfsm_instance_data omap3_vdd1_vfsm_data = { +static const struct omap_vfsm_instance omap3_vdd1_vfsm = { .voltsetup_reg = OMAP3_PRM_VOLTSETUP1_OFFSET, - .voltsetup_shift = OMAP3430_SETUP_TIME1_SHIFT, .voltsetup_mask = OMAP3430_SETUP_TIME1_MASK, }; static struct omap_vdd_info omap3_vdd1_info = { .vp_data = &omap3_vp1_data, - .vfsm = &omap3_vdd1_vfsm_data, }; -static const struct omap_vfsm_instance_data omap3_vdd2_vfsm_data = { +static const struct omap_vfsm_instance omap3_vdd2_vfsm = { .voltsetup_reg = OMAP3_PRM_VOLTSETUP1_OFFSET, - .voltsetup_shift = OMAP3430_SETUP_TIME2_SHIFT, .voltsetup_mask = OMAP3430_SETUP_TIME2_MASK, }; static struct omap_vdd_info omap3_vdd2_info = { .vp_data = &omap3_vp2_data, - .vfsm = &omap3_vdd2_vfsm_data, }; static struct voltagedomain omap3_voltdm_mpu = { @@ -60,6 +56,7 @@ static struct voltagedomain omap3_voltdm_mpu = { .write = omap3_prm_vcvp_write, .rmw = omap3_prm_vcvp_rmw, .vc = &omap3_vc_mpu, + .vfsm = &omap3_vdd1_vfsm, .vdd = &omap3_vdd1_info, }; @@ -70,6 +67,7 @@ static struct voltagedomain omap3_voltdm_core = { .write = omap3_prm_vcvp_write, .rmw = omap3_prm_vcvp_rmw, .vc = &omap3_vc_core, + .vfsm = &omap3_vdd2_vfsm, .vdd = &omap3_vdd2_info, }; diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c index e435795d61b7..dd4bd222739a 100644 --- a/arch/arm/mach-omap2/voltagedomains44xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c @@ -32,31 +32,28 @@ #include "vc.h" #include "vp.h" -static const struct omap_vfsm_instance_data omap4_vdd_mpu_vfsm_data = { +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, - .vfsm = &omap4_vdd_mpu_vfsm_data, }; -static const struct omap_vfsm_instance_data omap4_vdd_iva_vfsm_data = { +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, - .vfsm = &omap4_vdd_iva_vfsm_data, }; -static const struct omap_vfsm_instance_data omap4_vdd_core_vfsm_data = { +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, - .vfsm = &omap4_vdd_core_vfsm_data, }; static struct voltagedomain omap4_voltdm_mpu = { @@ -66,6 +63,7 @@ static struct voltagedomain omap4_voltdm_mpu = { .write = omap4_prm_vcvp_write, .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_mpu, + .vfsm = &omap4_vdd_mpu_vfsm, .vdd = &omap4_vdd_mpu_info, }; @@ -76,6 +74,7 @@ static struct voltagedomain omap4_voltdm_iva = { .write = omap4_prm_vcvp_write, .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_iva, + .vfsm = &omap4_vdd_iva_vfsm, .vdd = &omap4_vdd_iva_info, }; @@ -86,6 +85,7 @@ static struct voltagedomain omap4_voltdm_core = { .write = omap4_prm_vcvp_write, .rmw = omap4_prm_vcvp_rmw, .vc = &omap4_vc_core, + .vfsm = &omap4_vdd_core_vfsm, .vdd = &omap4_vdd_core_info, }; -- cgit v1.2.3 From 08d1c9a3e2dc7a285db7c689c42963d0f5271c1f Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 29 Mar 2011 15:14:38 -0700 Subject: OMAP3+: VC: move on/onlp/ret/off command configuration into common init Configuring the on/onlp/ret/off command values is common to OMAP3 & 4. Move from OMAP3-only init into common VC init. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index f78e62abe720..72c9cb64a42b 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -157,26 +157,11 @@ static void __init omap3_vfsm_init(struct voltagedomain *voltdm) static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) { - struct omap_vc_channel *vc = voltdm->vc; - struct omap_vdd_info *vdd = voltdm->vdd; static bool is_initialized; - u8 on_vsel, onlp_vsel, ret_vsel, off_vsel; - u32 vc_val; if (is_initialized) return; - /* Set up the on, inactive, retention and off voltage */ - on_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->on_volt); - onlp_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->onlp_volt); - ret_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->ret_volt); - off_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->off_volt); - vc_val = ((on_vsel << vc->common->cmd_on_shift) | - (onlp_vsel << vc->common->cmd_onlp_shift) | - (ret_vsel << vc->common->cmd_ret_shift) | - (off_vsel << vc->common->cmd_off_shift)); - voltdm->write(vc_val, vc->cmdval_reg); - /* * Generic VC parameters init * XXX This data should be abstracted out @@ -201,8 +186,6 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) if (is_initialized) return; - /* TODO: Configure setup times and CMD_VAL values*/ - /* * Generic VC parameters init * XXX This data should be abstracted out @@ -223,6 +206,8 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) { struct omap_vc_channel *vc = voltdm->vc; struct omap_vdd_info *vdd = voltdm->vdd; + u8 on_vsel, onlp_vsel, ret_vsel, off_vsel; + u32 val; if (!vdd->pmic_info || !vdd->pmic_info->uv_to_vsel) { pr_err("%s: PMIC info requried to configure vc for" @@ -259,6 +244,17 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), vc->common->smps_cmdra_reg); + /* Set up the on, inactive, retention and off voltage */ + on_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->on_volt); + onlp_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->onlp_volt); + ret_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->ret_volt); + off_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->off_volt); + val = ((on_vsel << vc->common->cmd_on_shift) | + (onlp_vsel << vc->common->cmd_onlp_shift) | + (ret_vsel << vc->common->cmd_ret_shift) | + (off_vsel << vc->common->cmd_off_shift)); + voltdm->write(val, vc->cmdval_reg); + /* Configure the setup times */ voltdm->rmw(voltdm->vfsm->voltsetup_mask, vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask), -- cgit v1.2.3 From 24d3194a2c9bc4d2315117915d4d22c395c07fd5 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 29 Mar 2011 15:57:16 -0700 Subject: OMAP3+: VC: abstract out channel configuration VC channel configuration is programmed based on settings coming from the PMIC configuration. Currently, the VC channel to PMIC mapping is a simple one-to-one mapping. Whenever a VC channel parameter is configured (i2c slave addres, PMIC register address, on/ret/off command), the corresponding bits are enabled in the VC channel configuration register. If necessary, the programmability of channel configuration settings could be extended to board/PMIC files, however, because this patch changes the channel configuration to be programmed based on existing values from the PMIC settings, it may not be required. Also note that starting with OMAP4, where there are more than 2 channels, one channel is identified as the "default" channel. When any of the bits in the channel config for the other channels are zero, it means to use the default channel. The OMAP4 TRM (at least through NDA version Q) is wrong in describing which is the default channel. The default channel on OMAP4 is MPU, not CORE as decribed in the TRM. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 70 ++++++++++++++++++++++++++++++++------- arch/arm/mach-omap2/vc.h | 8 +++++ arch/arm/mach-omap2/vc3xxx_data.c | 3 ++ arch/arm/mach-omap2/vc44xx_data.c | 5 +++ 4 files changed, 74 insertions(+), 12 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 72c9cb64a42b..1791f79112bf 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -19,6 +19,52 @@ #include "prm-regbits-44xx.h" #include "prm44xx.h" +/* + * Channel configuration bits, common for OMAP3 & 4 + * OMAP3 register: PRM_VC_CH_CONF + * OMAP4 register: PRM_VC_CFG_CHANNEL + */ +#define CFG_CHANNEL_SA BIT(0) +#define CFG_CHANNEL_RAV BIT(1) +#define CFG_CHANNEL_RAC BIT(2) +#define CFG_CHANNEL_RACEN BIT(3) +#define CFG_CHANNEL_CMD BIT(4) +#define CFG_CHANNEL_MASK 0x3f + +/** + * omap_vc_config_channel - configure VC channel to PMIC mappings + * @voltdm: pointer to voltagdomain defining the desired VC channel + * + * Configures the VC channel to PMIC mappings for the following + * PMIC settings + * - i2c slave address (SA) + * - voltage configuration address (RAV) + * - command configuration address (RAC) and enable bit (RACEN) + * - command values for ON, ONLP, RET and OFF (CMD) + * + * This function currently only allows flexible configuration of the + * non-default channel. Starting with OMAP4, there are more than 2 + * channels, with one defined as the default (on OMAP4, it's MPU.) + * Only the non-default channel can be configured. + */ +static int omap_vc_config_channel(struct voltagedomain *voltdm) +{ + struct omap_vc_channel *vc = voltdm->vc; + + /* + * For default channel, the only configurable bit is RACEN. + * All others must stay at zero (see function comment above.) + */ + if (vc->flags & OMAP_VC_CHANNEL_DEFAULT) + vc->cfg_channel &= CFG_CHANNEL_RACEN; + + voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift, + vc->cfg_channel << vc->cfg_channel_sa_shift, + vc->common->cfg_channel_reg); + + return 0; +} + /* Voltage scale and accessory APIs */ int omap_vc_pre_scale(struct voltagedomain *voltdm, unsigned long target_volt, @@ -166,8 +212,6 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) * Generic VC parameters init * XXX This data should be abstracted out */ - voltdm->write(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, - OMAP3_PRM_VC_CH_CONF_OFFSET); voltdm->write(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, OMAP3_PRM_VC_I2C_CFG_OFFSET); @@ -186,15 +230,6 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) if (is_initialized) return; - /* - * Generic VC parameters init - * XXX This data should be abstracted out - */ - vc_val = (OMAP4430_RAV_VDD_MPU_L_MASK | OMAP4430_CMD_VDD_MPU_L_MASK | - OMAP4430_RAV_VDD_IVA_L_MASK | OMAP4430_CMD_VDD_IVA_L_MASK | - OMAP4430_RAV_VDD_CORE_L_MASK | OMAP4430_CMD_VDD_CORE_L_MASK); - voltdm->write(vc_val, OMAP4_PRM_VC_CFG_CHANNEL_OFFSET); - /* XXX These are magic numbers and do not belong! */ vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT); voltdm->write(vc_val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); @@ -222,6 +257,8 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) return; } + vc->cfg_channel = 0; + /* get PMIC/board specific settings */ vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; vc->volt_reg_addr = vdd->pmic_info->volt_reg_addr; @@ -232,6 +269,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) voltdm->rmw(vc->smps_sa_mask, vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), vc->common->smps_sa_reg); + vc->cfg_channel |= CFG_CHANNEL_SA; /* * Configure the PMIC register addresses. @@ -239,10 +277,14 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) voltdm->rmw(vc->smps_volra_mask, vc->volt_reg_addr << __ffs(vc->smps_volra_mask), vc->common->smps_volra_reg); - if (vc->cmd_reg_addr) + vc->cfg_channel |= CFG_CHANNEL_RAV; + + if (vc->cmd_reg_addr) { voltdm->rmw(vc->smps_cmdra_mask, vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), vc->common->smps_cmdra_reg); + vc->cfg_channel |= CFG_CHANNEL_RAC | CFG_CHANNEL_RACEN; + } /* Set up the on, inactive, retention and off voltage */ on_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->on_volt); @@ -254,6 +296,10 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) (ret_vsel << vc->common->cmd_ret_shift) | (off_vsel << vc->common->cmd_off_shift)); voltdm->write(val, vc->cmdval_reg); + vc->cfg_channel |= CFG_CHANNEL_CMD; + + /* Channel configuration */ + omap_vc_config_channel(voltdm); /* Configure the setup times */ voltdm->rmw(voltdm->vfsm->voltsetup_mask, diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 6e8806b59823..4e1913748d2a 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -54,8 +54,12 @@ struct omap_vc_common { u8 cmd_onlp_shift; u8 cmd_ret_shift; u8 cmd_off_shift; + u8 cfg_channel_reg; }; +/* omap_vc_channel.flags values */ +#define OMAP_VC_CHANNEL_DEFAULT BIT(0) + /** * struct omap_vc_channel - VC per-instance data * @i2c_slave_addr: I2C slave address of PMIC for this VC channel @@ -67,6 +71,7 @@ struct omap_vc_common { * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register * @cmdval_reg: register for on/ret/off voltage level values for this channel + * @flags: VC channel-specific flags (optional) */ struct omap_vc_channel { /* channel state */ @@ -74,6 +79,7 @@ struct omap_vc_channel { u16 volt_reg_addr; u16 cmd_reg_addr; u16 setup_time; + u8 cfg_channel; /* register access data */ const struct omap_vc_common *common; @@ -81,6 +87,8 @@ struct omap_vc_channel { u32 smps_volra_mask; u32 smps_cmdra_mask; u8 cmdval_reg; + u8 cfg_channel_sa_shift; + u8 flags; }; extern struct omap_vc_channel omap3_vc_mpu; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index df8bd5ead7e4..f4449eb59841 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -43,6 +43,7 @@ static struct omap_vc_common omap3_vc_common = { .cmd_onlp_shift = OMAP3430_VC_CMD_ONLP_SHIFT, .cmd_ret_shift = OMAP3430_VC_CMD_RET_SHIFT, .cmd_off_shift = OMAP3430_VC_CMD_OFF_SHIFT, + .cfg_channel_reg = OMAP3_PRM_VC_CH_CONF_OFFSET, }; struct omap_vc_channel omap3_vc_mpu = { @@ -51,6 +52,7 @@ struct omap_vc_channel omap3_vc_mpu = { .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, .smps_volra_mask = OMAP3430_VOLRA0_MASK, .smps_cmdra_mask = OMAP3430_CMDRA0_MASK, + .cfg_channel_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA0_SHIFT, }; struct omap_vc_channel omap3_vc_core = { @@ -59,4 +61,5 @@ struct omap_vc_channel omap3_vc_core = { .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, .smps_volra_mask = OMAP3430_VOLRA1_MASK, .smps_cmdra_mask = OMAP3430_CMDRA1_MASK, + .cfg_channel_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT, }; diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 5d104ff662b3..1610bdedee6b 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -44,15 +44,18 @@ static const struct omap_vc_common omap4_vc_common = { .cmd_onlp_shift = OMAP4430_ONLP_SHIFT, .cmd_ret_shift = OMAP4430_RET_SHIFT, .cmd_off_shift = OMAP4430_OFF_SHIFT, + .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, }; /* VC instance data for each controllable voltage line */ struct omap_vc_channel omap4_vc_mpu = { + .flags = OMAP_VC_CHANNEL_DEFAULT, .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, .smps_cmdra_mask = OMAP4430_CMDRA_VDD_MPU_L_MASK, + .cfg_channel_sa_shift = OMAP4430_SA_VDD_MPU_L_SHIFT, }; struct omap_vc_channel omap4_vc_iva = { @@ -61,6 +64,7 @@ struct omap_vc_channel omap4_vc_iva = { .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, .smps_cmdra_mask = OMAP4430_CMDRA_VDD_IVA_L_MASK, + .cfg_channel_sa_shift = OMAP4430_SA_VDD_IVA_L_SHIFT, }; struct omap_vc_channel omap4_vc_core = { @@ -69,5 +73,6 @@ struct omap_vc_channel omap4_vc_core = { .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, .smps_cmdra_mask = OMAP4430_CMDRA_VDD_CORE_L_MASK, + .cfg_channel_sa_shift = OMAP4430_SA_VDD_CORE_L_SHIFT, }; -- cgit v1.2.3 From ce8ebe0dfb1f8713337cebf82499d3dced288328 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Wed, 30 Mar 2011 11:01:10 -0700 Subject: OMAP3+: voltage domain: move PMIC struct from vdd_info into struct voltagedomain Move structure containing PMIC configurable settings into struct voltagedomain. In the process, rename from omap_volt_pmic_info to omap_voltdm_pmic (_info suffix is not helpful.) No functional changes. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/omap_twl.c | 28 ++++++++++++++-------------- arch/arm/mach-omap2/vc.c | 29 ++++++++++++++--------------- arch/arm/mach-omap2/vc.h | 4 ++++ arch/arm/mach-omap2/voltage.c | 29 ++++++++++++----------------- arch/arm/mach-omap2/voltage.h | 12 +++++------- arch/arm/mach-omap2/vp.c | 13 ++++++------- 6 files changed, 55 insertions(+), 60 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c index 3249fe3c3c1d..e467d4565a2d 100644 --- a/arch/arm/mach-omap2/omap_twl.c +++ b/arch/arm/mach-omap2/omap_twl.c @@ -143,7 +143,7 @@ static u8 twl6030_uv_to_vsel(unsigned long uv) return DIV_ROUND_UP(uv - 600000, 12500) + 1; } -static struct omap_volt_pmic_info omap3_mpu_volt_info = { +static struct omap_voltdm_pmic omap3_mpu_pmic = { .slew_rate = 4000, .step_size = 12500, .on_volt = 1200000, @@ -163,7 +163,7 @@ static struct omap_volt_pmic_info omap3_mpu_volt_info = { .uv_to_vsel = twl4030_uv_to_vsel, }; -static struct omap_volt_pmic_info omap3_core_volt_info = { +static struct omap_voltdm_pmic omap3_core_pmic = { .slew_rate = 4000, .step_size = 12500, .on_volt = 1200000, @@ -183,7 +183,7 @@ static struct omap_volt_pmic_info omap3_core_volt_info = { .uv_to_vsel = twl4030_uv_to_vsel, }; -static struct omap_volt_pmic_info omap4_mpu_volt_info = { +static struct omap_voltdm_pmic omap4_mpu_pmic = { .slew_rate = 4000, .step_size = 12500, .on_volt = 1350000, @@ -203,7 +203,7 @@ static struct omap_volt_pmic_info omap4_mpu_volt_info = { .uv_to_vsel = twl6030_uv_to_vsel, }; -static struct omap_volt_pmic_info omap4_iva_volt_info = { +static struct omap_voltdm_pmic omap4_iva_pmic = { .slew_rate = 4000, .step_size = 12500, .on_volt = 1100000, @@ -223,7 +223,7 @@ static struct omap_volt_pmic_info omap4_iva_volt_info = { .uv_to_vsel = twl6030_uv_to_vsel, }; -static struct omap_volt_pmic_info omap4_core_volt_info = { +static struct omap_voltdm_pmic omap4_core_pmic = { .slew_rate = 4000, .step_size = 12500, .on_volt = 1100000, @@ -251,13 +251,13 @@ int __init omap4_twl_init(void) return -ENODEV; voltdm = voltdm_lookup("mpu"); - omap_voltage_register_pmic(voltdm, &omap4_mpu_volt_info); + omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic); voltdm = voltdm_lookup("iva"); - omap_voltage_register_pmic(voltdm, &omap4_iva_volt_info); + omap_voltage_register_pmic(voltdm, &omap4_iva_pmic); voltdm = voltdm_lookup("core"); - omap_voltage_register_pmic(voltdm, &omap4_core_volt_info); + omap_voltage_register_pmic(voltdm, &omap4_core_pmic); return 0; } @@ -270,10 +270,10 @@ int __init omap3_twl_init(void) return -ENODEV; if (cpu_is_omap3630()) { - omap3_mpu_volt_info.vp_vddmin = OMAP3630_VP1_VLIMITTO_VDDMIN; - omap3_mpu_volt_info.vp_vddmax = OMAP3630_VP1_VLIMITTO_VDDMAX; - omap3_core_volt_info.vp_vddmin = OMAP3630_VP2_VLIMITTO_VDDMIN; - omap3_core_volt_info.vp_vddmax = OMAP3630_VP2_VLIMITTO_VDDMAX; + omap3_mpu_pmic.vp_vddmin = OMAP3630_VP1_VLIMITTO_VDDMIN; + omap3_mpu_pmic.vp_vddmax = OMAP3630_VP1_VLIMITTO_VDDMAX; + omap3_core_pmic.vp_vddmin = OMAP3630_VP2_VLIMITTO_VDDMIN; + omap3_core_pmic.vp_vddmax = OMAP3630_VP2_VLIMITTO_VDDMAX; } /* @@ -289,10 +289,10 @@ int __init omap3_twl_init(void) omap3_twl_set_sr_bit(true); voltdm = voltdm_lookup("mpu_iva"); - omap_voltage_register_pmic(voltdm, &omap3_mpu_volt_info); + omap_voltage_register_pmic(voltdm, &omap3_mpu_pmic); voltdm = voltdm_lookup("core"); - omap_voltage_register_pmic(voltdm, &omap3_core_volt_info); + omap_voltage_register_pmic(voltdm, &omap3_core_pmic); return 0; } diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 1791f79112bf..4ac761440d62 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -79,13 +79,13 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, vp_common = vdd->vp_data->vp_common; /* Check if sufficient pmic info is available for this vdd */ - if (!vdd->pmic_info) { + if (!voltdm->pmic) { pr_err("%s: Insufficient pmic info to scale the vdd_%s\n", __func__, voltdm->name); return -EINVAL; } - if (!vdd->pmic_info->uv_to_vsel) { + if (!voltdm->pmic->uv_to_vsel) { pr_err("%s: PMIC function to convert voltage in uV to" "vsel not registered. Hence unable to scale voltage" "for vdd_%s\n", __func__, voltdm->name); @@ -103,7 +103,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, if (IS_ERR(volt_data)) volt_data = NULL; - *target_vsel = vdd->pmic_info->uv_to_vsel(target_volt); + *target_vsel = voltdm->pmic->uv_to_vsel(target_volt); *current_vsel = voltdm->read(vdd->vp_data->voltage); /* Setting the ON voltage to the new target voltage */ @@ -134,8 +134,8 @@ void omap_vc_post_scale(struct voltagedomain *voltdm, smps_steps = abs(target_vsel - current_vsel); /* SMPS slew rate / step size. 2us added as buffer. */ - smps_delay = ((smps_steps * vdd->pmic_info->step_size) / - vdd->pmic_info->slew_rate) + 2; + smps_delay = ((smps_steps * voltdm->pmic->step_size) / + voltdm->pmic->slew_rate) + 2; udelay(smps_delay); vdd->curr_volt = target_volt; @@ -240,11 +240,10 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) void __init omap_vc_init_channel(struct voltagedomain *voltdm) { struct omap_vc_channel *vc = voltdm->vc; - struct omap_vdd_info *vdd = voltdm->vdd; u8 on_vsel, onlp_vsel, ret_vsel, off_vsel; u32 val; - if (!vdd->pmic_info || !vdd->pmic_info->uv_to_vsel) { + if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) { pr_err("%s: PMIC info requried to configure vc for" "vdd_%s not populated.Hence cannot initialize vc\n", __func__, voltdm->name); @@ -260,10 +259,10 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc->cfg_channel = 0; /* get PMIC/board specific settings */ - vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; - vc->volt_reg_addr = vdd->pmic_info->volt_reg_addr; - vc->cmd_reg_addr = vdd->pmic_info->cmd_reg_addr; - vc->setup_time = vdd->pmic_info->volt_setup_time; + vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr; + vc->volt_reg_addr = voltdm->pmic->volt_reg_addr; + vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr; + vc->setup_time = voltdm->pmic->volt_setup_time; /* Configure the i2c slave address for this VC */ voltdm->rmw(vc->smps_sa_mask, @@ -287,10 +286,10 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) } /* Set up the on, inactive, retention and off voltage */ - on_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->on_volt); - onlp_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->onlp_volt); - ret_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->ret_volt); - off_vsel = vdd->pmic_info->uv_to_vsel(vdd->pmic_info->off_volt); + on_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->on_volt); + onlp_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->onlp_volt); + ret_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->ret_volt); + off_vsel = voltdm->pmic->uv_to_vsel(voltdm->pmic->off_volt); val = ((on_vsel << vc->common->cmd_on_shift) | (onlp_vsel << vc->common->cmd_onlp_shift) | (ret_vsel << vc->common->cmd_ret_shift) | diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 4e1913748d2a..fd385285a3bf 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -36,6 +36,7 @@ struct voltagedomain; * @cmd_onlp_shift: ONLP field shift in PRM_VC_CMD_VAL_* register * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register + * @cfg_channel_reg: VC channel configuration register * * XXX One of cmd_on_mask and cmd_on_shift are not needed * XXX VALID should probably be a shift, not a mask @@ -66,11 +67,14 @@ struct omap_vc_common { * @volt_reg_addr: voltage configuration register address * @cmd_reg_addr: command configuration register address * @setup_time: setup time (in sys_clk cycles) of regulator for this channel + * @cfg_channel: current value of VC channel configuration register + * * @common: pointer to VC common data for this platform * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register * @cmdval_reg: register for on/ret/off voltage level values for this channel + * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register * @flags: VC channel-specific flags (optional) */ struct omap_vc_channel { diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 9f9f01465f6a..94f7fc41c27c 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -84,20 +84,20 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm) vdd->vp_enabled = false; vdd->vp_rt_data.vpconfig_erroroffset = - (vdd->pmic_info->vp_erroroffset << + (voltdm->pmic->vp_erroroffset << vdd->vp_data->vp_common->vpconfig_erroroffset_shift); - timeout_val = (sys_clk_speed * vdd->pmic_info->vp_timeout_us) / 1000; + timeout_val = (sys_clk_speed * voltdm->pmic->vp_timeout_us) / 1000; vdd->vp_rt_data.vlimitto_timeout = timeout_val; - vdd->vp_rt_data.vlimitto_vddmin = vdd->pmic_info->vp_vddmin; - vdd->vp_rt_data.vlimitto_vddmax = vdd->pmic_info->vp_vddmax; + vdd->vp_rt_data.vlimitto_vddmin = voltdm->pmic->vp_vddmin; + vdd->vp_rt_data.vlimitto_vddmax = voltdm->pmic->vp_vddmax; - waittime = ((vdd->pmic_info->step_size / vdd->pmic_info->slew_rate) * + waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) * sys_clk_speed) / 1000; vdd->vp_rt_data.vstepmin_smpswaittimemin = waittime; vdd->vp_rt_data.vstepmax_smpswaittimemax = waittime; - vdd->vp_rt_data.vstepmin_stepmin = vdd->pmic_info->vp_vstepmin; - vdd->vp_rt_data.vstepmax_stepmax = vdd->pmic_info->vp_vstepmax; + vdd->vp_rt_data.vstepmin_stepmin = voltdm->pmic->vp_vstepmin; + vdd->vp_rt_data.vstepmax_stepmax = voltdm->pmic->vp_vstepmax; return 0; } @@ -149,10 +149,9 @@ static void __init vdd_debugfs_init(struct voltagedomain *voltdm) static int __init omap_vdd_data_configure(struct voltagedomain *voltdm) { - struct omap_vdd_info *vdd = voltdm->vdd; int ret = -EINVAL; - if (!vdd->pmic_info) { + if (!voltdm->pmic) { pr_err("%s: PMIC info requried to configure vdd_%s not" "populated.Hence cannot initialize vdd_%s\n", __func__, voltdm->name, voltdm->name); @@ -324,24 +323,20 @@ struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, * omap_voltage_register_pmic() - API to register PMIC specific data * @voltdm: pointer to the VDD for which the PMIC specific data is * to be registered - * @pmic_info: the structure containing pmic info + * @pmic: the structure containing pmic info * * This API is to be called by the SOC/PMIC file to specify the - * pmic specific info as present in omap_volt_pmic_info structure. + * pmic specific info as present in omap_voltdm_pmic structure. */ int omap_voltage_register_pmic(struct voltagedomain *voltdm, - struct omap_volt_pmic_info *pmic_info) + struct omap_voltdm_pmic *pmic) { - 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; - - vdd->pmic_info = pmic_info; + voltdm->pmic = pmic; return 0; } diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 99df2d13e42e..43ee7bf57969 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -67,6 +67,7 @@ struct voltagedomain { struct list_head pwrdm_list; struct omap_vc_channel *vc; const struct omap_vfsm_instance *vfsm; + struct omap_voltdm_pmic *pmic; /* VC/VP register access functions: SoC specific */ u32 (*read) (u8 offset); @@ -96,7 +97,7 @@ struct omap_volt_data { }; /** - * struct omap_volt_pmic_info - PMIC specific data required by voltage driver. + * struct omap_voltdm_pmic - PMIC specific data required by voltage driver. * @slew_rate: PMIC slew rate (in uv/us) * @step_size: PMIC voltage step size (in uv) * @i2c_slave_addr: I2C slave address of PMIC @@ -105,7 +106,7 @@ struct omap_volt_data { * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. */ -struct omap_volt_pmic_info { +struct omap_voltdm_pmic { int slew_rate; int step_size; u32 on_volt; @@ -131,8 +132,6 @@ struct omap_volt_pmic_info { * * @volt_data : voltage table having the distinct voltages supported * by the domain and other associated per voltage data. - * @pmic_info : pmic specific parameters which should be populted by - * the pmic drivers. * @vp_data : the register values, shifts, masks for various * vp registers * @vp_rt_data : VP data derived at runtime, not predefined @@ -143,7 +142,6 @@ struct omap_volt_pmic_info { */ struct omap_vdd_info { struct omap_volt_data *volt_data; - struct omap_volt_pmic_info *pmic_info; struct omap_vp_instance_data *vp_data; struct omap_vp_runtime_data vp_rt_data; struct dentry *debug_dir; @@ -165,13 +163,13 @@ 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_volt_pmic_info *pmic_info); + struct omap_voltdm_pmic *pmic); void omap_change_voltscale_method(struct voltagedomain *voltdm, int voltscale_method); int omap_voltage_late_init(void); #else static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm, - struct omap_volt_pmic_info *pmic_info) + struct omap_voltdm_pmic *pmic) { return -EINVAL; } diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c index 88ac742a38cf..a3afcbe741e3 100644 --- a/arch/arm/mach-omap2/vp.c +++ b/arch/arm/mach-omap2/vp.c @@ -18,7 +18,6 @@ static void vp_latch_vsel(struct voltagedomain *voltdm) u32 vpconfig; unsigned long uvdc; char vsel; - struct omap_vdd_info *vdd = voltdm->vdd; uvdc = omap_voltage_get_nom_volt(voltdm); if (!uvdc) { @@ -27,13 +26,13 @@ static void vp_latch_vsel(struct voltagedomain *voltdm) return; } - if (!vdd->pmic_info || !vdd->pmic_info->uv_to_vsel) { + 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 = vdd->pmic_info->uv_to_vsel(uvdc); + vsel = voltdm->pmic->uv_to_vsel(uvdc); vpconfig = voltdm->read(vp->vpconfig); vpconfig &= ~(vp->vp_common->vpconfig_initvoltage_mask | @@ -206,13 +205,13 @@ unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm) curr_vsel = voltdm->read(vp->voltage); - if (!vdd->pmic_info || !vdd->pmic_info->vsel_to_uv) { + 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 vdd->pmic_info->vsel_to_uv(curr_vsel); + return voltdm->pmic->vsel_to_uv(curr_vsel); } /** @@ -323,13 +322,13 @@ static int vp_volt_debug_get(void *data, u64 *val) vsel = voltdm->read(vp->voltage); - if (!vdd->pmic_info->vsel_to_uv) { + if (!voltdm->pmic->vsel_to_uv) { pr_warning("PMIC function to convert vsel to voltage" "in uV not registerd\n"); return -EINVAL; } - *val = vdd->pmic_info->vsel_to_uv(vsel); + *val = voltdm->pmic->vsel_to_uv(vsel); return 0; } -- cgit v1.2.3 From f5395480f5088a86cc8594d29b5c2f07f6995c3d Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Wed, 30 Mar 2011 16:36:30 -0700 Subject: OMAP3+: VC: make I2C config programmable with PMIC-specific settings Remove hard-coded I2C configuration in favor of settings that can be configured from PMIC-specific values. Currently only high-speed mode and the master-code value are supported, since they were the only fields currently used, but extending this is now trivial. Thanks to Nishanth Menon for reporting/fixing a sparse problem and making omap_vc_i2c_init() static, as well as finding and fixing a problem with the shift/mask of mcode. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/omap_twl.c | 4 +++ arch/arm/mach-omap2/vc.c | 51 +++++++++++++++++++++++++++++++++------ arch/arm/mach-omap2/vc.h | 8 ++++++ arch/arm/mach-omap2/vc3xxx_data.c | 3 +++ arch/arm/mach-omap2/vc44xx_data.c | 3 +++ arch/arm/mach-omap2/voltage.h | 4 +++ 6 files changed, 66 insertions(+), 7 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c index e467d4565a2d..6b247d183299 100644 --- a/arch/arm/mach-omap2/omap_twl.c +++ b/arch/arm/mach-omap2/omap_twl.c @@ -159,6 +159,7 @@ static struct omap_voltdm_pmic omap3_mpu_pmic = { .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR, .volt_reg_addr = OMAP3_VDD_MPU_SR_CONTROL_REG, + .i2c_high_speed = true, .vsel_to_uv = twl4030_vsel_to_uv, .uv_to_vsel = twl4030_uv_to_vsel, }; @@ -179,6 +180,7 @@ static struct omap_voltdm_pmic omap3_core_pmic = { .vp_timeout_us = OMAP3_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR, .volt_reg_addr = OMAP3_VDD_CORE_SR_CONTROL_REG, + .i2c_high_speed = true, .vsel_to_uv = twl4030_vsel_to_uv, .uv_to_vsel = twl4030_uv_to_vsel, }; @@ -199,6 +201,7 @@ static struct omap_voltdm_pmic omap4_mpu_pmic = { .vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR, .volt_reg_addr = OMAP4_VDD_MPU_SR_VOLT_REG, + .i2c_high_speed = true, .vsel_to_uv = twl6030_vsel_to_uv, .uv_to_vsel = twl6030_uv_to_vsel, }; @@ -219,6 +222,7 @@ static struct omap_voltdm_pmic omap4_iva_pmic = { .vp_timeout_us = OMAP4_VP_VLIMITTO_TIMEOUT_US, .i2c_slave_addr = OMAP4_SRI2C_SLAVE_ADDR, .volt_reg_addr = OMAP4_VDD_IVA_SR_VOLT_REG, + .i2c_high_speed = true, .vsel_to_uv = twl6030_vsel_to_uv, .uv_to_vsel = twl6030_uv_to_vsel, }; diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 4ac761440d62..5d545632388d 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -208,13 +208,6 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) if (is_initialized) return; - /* - * Generic VC parameters init - * XXX This data should be abstracted out - */ - voltdm->write(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, - OMAP3_PRM_VC_I2C_CFG_OFFSET); - omap3_vfsm_init(voltdm); is_initialized = true; @@ -237,6 +230,48 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) is_initialized = true; } +/** + * omap_vc_i2c_init - initialize I2C interface to PMIC + * @voltdm: voltage domain containing VC data + * + * Use PMIC supplied seetings for I2C high-speed mode and + * master code (if set) and program the VC I2C configuration + * register. + * + * The VC I2C configuration is common to all VC channels, + * so this function only configures I2C for the first VC + * channel registers. All other VC channels will use the + * same configuration. + */ +static void __init omap_vc_i2c_init(struct voltagedomain *voltdm) +{ + struct omap_vc_channel *vc = voltdm->vc; + static bool initialized; + static bool i2c_high_speed; + u8 mcode; + + if (initialized) { + if (voltdm->pmic->i2c_high_speed != i2c_high_speed) + pr_warn("%s: I2C config for all channels must match.", + __func__); + return; + } + + i2c_high_speed = voltdm->pmic->i2c_high_speed; + if (i2c_high_speed) + voltdm->rmw(vc->common->i2c_cfg_hsen_mask, + vc->common->i2c_cfg_hsen_mask, + vc->common->i2c_cfg_reg); + + mcode = voltdm->pmic->i2c_mcode; + if (mcode) + voltdm->rmw(vc->common->i2c_mcode_mask, + mcode << __ffs(vc->common->i2c_mcode_mask), + vc->common->i2c_cfg_reg); + + initialized = true; +} + void __init omap_vc_init_channel(struct voltagedomain *voltdm) { struct omap_vc_channel *vc = voltdm->vc; @@ -305,6 +340,8 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask), voltdm->vfsm->voltsetup_reg); + omap_vc_i2c_init(voltdm); + if (cpu_is_omap34xx()) omap3_vc_init_channel(voltdm); else if (cpu_is_omap44xx()) diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index fd385285a3bf..c86301330b75 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -37,6 +37,9 @@ struct voltagedomain; * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register * @cfg_channel_reg: VC channel configuration register + * @i2c_cfg_reg: I2C configuration register offset + * @i2c_cfg_hsen_mask: high-speed mode bit field mask in I2C config register + * @i2c_mcode_mask: MCODE field mask for I2C config register * * XXX One of cmd_on_mask and cmd_on_shift are not needed * XXX VALID should probably be a shift, not a mask @@ -56,6 +59,9 @@ struct omap_vc_common { u8 cmd_ret_shift; u8 cmd_off_shift; u8 cfg_channel_reg; + u8 i2c_cfg_reg; + u8 i2c_cfg_hsen_mask; + u8 i2c_mcode_mask; }; /* omap_vc_channel.flags values */ @@ -68,6 +74,7 @@ struct omap_vc_common { * @cmd_reg_addr: command configuration register address * @setup_time: setup time (in sys_clk cycles) of regulator for this channel * @cfg_channel: current value of VC channel configuration register + * @i2c_high_speed: whether or not to use I2C high-speed mode * * @common: pointer to VC common data for this platform * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register @@ -84,6 +91,7 @@ struct omap_vc_channel { u16 cmd_reg_addr; u16 setup_time; u8 cfg_channel; + bool i2c_high_speed; /* register access data */ const struct omap_vc_common *common; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index f4449eb59841..95d7701300cb 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -44,6 +44,9 @@ static struct omap_vc_common omap3_vc_common = { .cmd_ret_shift = OMAP3430_VC_CMD_RET_SHIFT, .cmd_off_shift = OMAP3430_VC_CMD_OFF_SHIFT, .cfg_channel_reg = OMAP3_PRM_VC_CH_CONF_OFFSET, + .i2c_cfg_hsen_mask = OMAP3430_HSEN_MASK, + .i2c_cfg_reg = OMAP3_PRM_VC_I2C_CFG_OFFSET, + .i2c_mcode_mask = OMAP3430_MCODE_MASK, }; struct omap_vc_channel omap3_vc_mpu = { diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 1610bdedee6b..148be18397f8 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -45,6 +45,9 @@ static const struct omap_vc_common omap4_vc_common = { .cmd_ret_shift = OMAP4430_RET_SHIFT, .cmd_off_shift = OMAP4430_OFF_SHIFT, .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, + .i2c_cfg_reg = OMAP4_PRM_VC_CFG_I2C_MODE_OFFSET, + .i2c_cfg_hsen_mask = OMAP4430_HSMODEEN_MASK, + .i2c_mcode_mask = OMAP4430_HSMCODE_MASK, }; /* VC instance data for each controllable voltage line */ diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 43ee7bf57969..a36d2cfa5ca7 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -103,6 +103,8 @@ struct omap_volt_data { * @i2c_slave_addr: I2C slave address of PMIC * @volt_reg_addr: voltage configuration register address * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address + * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC + * @i2c_mcode: master code value for I2C high-speed preamble transmission * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. */ @@ -123,6 +125,8 @@ struct omap_voltdm_pmic { u8 vp_vddmin; u8 vp_vddmax; u8 vp_timeout_us; + bool i2c_high_speed; + u8 i2c_mcode; unsigned long (*vsel_to_uv) (const u8 vsel); u8 (*uv_to_vsel) (unsigned long uV); }; -- cgit v1.2.3 From 8abc0b58fdb89124d8278f110f523b27c666d36c Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Thu, 2 Jun 2011 17:28:13 -0700 Subject: OMAP3+: PM: VC: handle mutant channel config for OMAP4 MPU channel On OMAP3+, all VC channels have the the same bitfield ordering for all VC channels, except the OMAP4 MPU channel. This appears to be a freak accident as all other VC channel (including OMAP5) have the standard configuration. Handle the mutant case by adding a per-channel flag to signal the deformity and handle it during VC init. Special thanks to Nishanth Menon for finding this problem and for proposing the initial solution. Cc: Nishanth Menon Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 64 +++++++++++++++++++++++++++++++-------- arch/arm/mach-omap2/vc.h | 1 + arch/arm/mach-omap2/vc44xx_data.c | 2 +- 3 files changed, 53 insertions(+), 14 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 5d545632388d..f53d1f5acce1 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -19,17 +19,51 @@ #include "prm-regbits-44xx.h" #include "prm44xx.h" -/* - * Channel configuration bits, common for OMAP3 & 4 +/** + * struct omap_vc_channel_cfg - describe the cfg_channel bitfield + * @sa: bit for slave address + * @rav: bit for voltage configuration register + * @rac: bit for command configuration register + * @racen: enable bit for RAC + * @cmd: bit for command value set selection + * + * Channel configuration bits, common for OMAP3+ * OMAP3 register: PRM_VC_CH_CONF * OMAP4 register: PRM_VC_CFG_CHANNEL + * OMAP5 register: PRM_VC_SMPS__CONFIG */ -#define CFG_CHANNEL_SA BIT(0) -#define CFG_CHANNEL_RAV BIT(1) -#define CFG_CHANNEL_RAC BIT(2) -#define CFG_CHANNEL_RACEN BIT(3) -#define CFG_CHANNEL_CMD BIT(4) -#define CFG_CHANNEL_MASK 0x3f +struct omap_vc_channel_cfg { + u8 sa; + u8 rav; + u8 rac; + u8 racen; + u8 cmd; +}; + +static struct omap_vc_channel_cfg vc_default_channel_cfg = { + .sa = BIT(0), + .rav = BIT(1), + .rac = BIT(2), + .racen = BIT(3), + .cmd = BIT(4), +}; + +/* + * On OMAP3+, all VC channels have the above default bitfield + * configuration, except the OMAP4 MPU channel. This appears + * to be a freak accident as every other VC channel has the + * default configuration, thus creating a mutant channel config. + */ +static struct omap_vc_channel_cfg vc_mutant_channel_cfg = { + .sa = BIT(0), + .rav = BIT(2), + .rac = BIT(3), + .racen = BIT(4), + .cmd = BIT(1), +}; + +static struct omap_vc_channel_cfg *vc_cfg_bits; +#define CFG_CHANNEL_MASK 0x1f /** * omap_vc_config_channel - configure VC channel to PMIC mappings @@ -56,7 +90,7 @@ static int omap_vc_config_channel(struct voltagedomain *voltdm) * All others must stay at zero (see function comment above.) */ if (vc->flags & OMAP_VC_CHANNEL_DEFAULT) - vc->cfg_channel &= CFG_CHANNEL_RACEN; + vc->cfg_channel &= vc_cfg_bits->racen; voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift, vc->cfg_channel << vc->cfg_channel_sa_shift, @@ -292,6 +326,10 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) } vc->cfg_channel = 0; + if (vc->flags & OMAP_VC_CHANNEL_CFG_MUTANT) + vc_cfg_bits = &vc_mutant_channel_cfg; + else + vc_cfg_bits = &vc_default_channel_cfg; /* get PMIC/board specific settings */ vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr; @@ -303,7 +341,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) voltdm->rmw(vc->smps_sa_mask, vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), vc->common->smps_sa_reg); - vc->cfg_channel |= CFG_CHANNEL_SA; + vc->cfg_channel |= vc_cfg_bits->sa; /* * Configure the PMIC register addresses. @@ -311,13 +349,13 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) voltdm->rmw(vc->smps_volra_mask, vc->volt_reg_addr << __ffs(vc->smps_volra_mask), vc->common->smps_volra_reg); - vc->cfg_channel |= CFG_CHANNEL_RAV; + vc->cfg_channel |= vc_cfg_bits->rav; if (vc->cmd_reg_addr) { voltdm->rmw(vc->smps_cmdra_mask, vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), vc->common->smps_cmdra_reg); - vc->cfg_channel |= CFG_CHANNEL_RAC | CFG_CHANNEL_RACEN; + vc->cfg_channel |= vc_cfg_bits->rac | vc_cfg_bits->racen; } /* Set up the on, inactive, retention and off voltage */ @@ -330,7 +368,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) (ret_vsel << vc->common->cmd_ret_shift) | (off_vsel << vc->common->cmd_off_shift)); voltdm->write(val, vc->cmdval_reg); - vc->cfg_channel |= CFG_CHANNEL_CMD; + vc->cfg_channel |= vc_cfg_bits->cmd; /* Channel configuration */ omap_vc_config_channel(voltdm); diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index c86301330b75..7ed70e07becf 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -66,6 +66,7 @@ struct omap_vc_common { /* omap_vc_channel.flags values */ #define OMAP_VC_CHANNEL_DEFAULT BIT(0) +#define OMAP_VC_CHANNEL_CFG_MUTANT BIT(1) /** * struct omap_vc_channel - VC per-instance data diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 148be18397f8..0a4fc37877cc 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -52,7 +52,7 @@ static const struct omap_vc_common omap4_vc_common = { /* VC instance data for each controllable voltage line */ struct omap_vc_channel omap4_vc_mpu = { - .flags = OMAP_VC_CHANNEL_DEFAULT, + .flags = OMAP_VC_CHANNEL_DEFAULT | OMAP_VC_CHANNEL_CFG_MUTANT, .common = &omap4_vc_common, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, -- cgit v1.2.3 From d7b0de2b46803062148345ae6a976c1e44a457b6 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 18 Jul 2011 15:31:00 -0700 Subject: OMAP3+: VC: use last nominal voltage setting to get current_vsel Instead of reading current vsel value from the VP's voltage register, just use current nominal voltage translated into vsel via the PMIC. Doing this allows VC bypass scaling to work even without a VP configured. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index f53d1f5acce1..21ffde86ad83 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -138,7 +138,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, volt_data = NULL; *target_vsel = voltdm->pmic->uv_to_vsel(target_volt); - *current_vsel = voltdm->read(vdd->vp_data->voltage); + *current_vsel = voltdm->pmic->uv_to_vsel(vdd->curr_volt); /* Setting the ON voltage to the new target voltage */ vc_cmdval = voltdm->read(vc->cmdval_reg); -- cgit v1.2.3 From b7ea803e55769768d1eff3b32e4f99837fa6ddb5 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 4 Apr 2011 15:25:07 -0700 Subject: OMAP3+: VP: cleanup: move VP instance into voltdm, misc. renames - 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 --- arch/arm/mach-omap2/vc.c | 11 ++-- arch/arm/mach-omap2/voltage.c | 4 +- arch/arm/mach-omap2/voltage.h | 7 +-- 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, 84 insertions(+), 99 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 21ffde86ad83..e872a0369afb 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -107,11 +107,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", @@ -148,12 +145,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 94f7fc41c27c..c22b53c42193 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 a36d2cfa5ca7..1ea735431ee0 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -55,6 +55,7 @@ struct omap_vfsm_instance { * @node: list_head linking all voltage domains * @pwrdm_list: list_head linking all powerdomains in this voltagedomain * @vc: pointer to VC channel associated with this voltagedomain + * @vp: pointer to VP associated with this voltagedomain * @read: read a VC/VP register * @write: write a VC/VP register * @read: read-modify-write a VC/VP register @@ -67,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 */ @@ -136,21 +138,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 ce5a7971addf..35117fcd55cf 100644 --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c @@ -36,18 +36,14 @@ 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, .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", @@ -57,6 +53,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, }; @@ -68,6 +65,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 dd4bd222739a..3e7cb4e0a63a 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 a3afcbe741e3..53d6018fa678 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 382fef13dbc4..b50ca91fef24 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,19 +89,20 @@ 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 * @id: Unique identifier for VP instance. + * @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; @@ -109,6 +110,7 @@ struct omap_vp_instance_data { u8 vstatus; u8 voltage; u8 id; + bool enabled; }; /** @@ -140,12 +142,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 b01d33325d52..79c3df94f500 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 9704c7ba9e99..8f75cd9e7e66 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, -- cgit v1.2.3 From 0ec3041e91cf365a76c81b224e85d3c2574fec23 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 4 Apr 2011 16:02:28 -0700 Subject: OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask) 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 --- 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(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index e872a0369afb..7b87ea16ce43 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -149,7 +149,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 eaa5f93021ae..5b16fd1fe373 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 c9a315f9d3d8..297d094263aa 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 b50ca91fef24..1cfde5a55f9b 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; @@ -128,7 +123,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 79c3df94f500..d429c447eef0 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 8f75cd9e7e66..0daf2a47dc28 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, -- cgit v1.2.3 From 76ea7424f80350884b4d70ae54cfa51f7f9b2a48 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 5 Apr 2011 15:15:31 -0700 Subject: OMAP3+: VP: create VP helper function for updating error gain 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 --- 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(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 7b87ea16ce43..f8bdd5183e2f 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -105,9 +105,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) { @@ -129,11 +127,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); @@ -143,15 +136,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 ea61a47bd199..f68a6db27111 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 1cfde5a55f9b..bb4c78e0c26f 100644 --- a/arch/arm/mach-omap2/vp.h +++ b/arch/arm/mach-omap2/vp.h @@ -149,5 +149,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 -- cgit v1.2.3 From 7590f608aacba64c42edd5a8d9560264b049f403 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 5 Apr 2011 16:55:22 -0700 Subject: OMAP3+: voltage: move/rename curr_volt from vdd_info into struct voltagedomain Track current nominal voltage as part of struct voltagedomain instead of omap_vdd_info, which will soon be removed. Also renames field from curr_volt to nominal_volt. No functional changes. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 5 ++--- arch/arm/mach-omap2/voltage.c | 6 +----- arch/arm/mach-omap2/voltage.h | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index f8bdd5183e2f..d9e69944f0c9 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -128,7 +128,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm, } *target_vsel = voltdm->pmic->uv_to_vsel(target_volt); - *current_vsel = voltdm->pmic->uv_to_vsel(vdd->curr_volt); + *current_vsel = voltdm->pmic->uv_to_vsel(voltdm->nominal_volt); /* Setting the ON voltage to the new target voltage */ vc_cmdval = voltdm->read(vc->cmdval_reg); @@ -145,7 +145,6 @@ void omap_vc_post_scale(struct voltagedomain *voltdm, unsigned long target_volt, u8 target_vsel, u8 current_vsel) { - struct omap_vdd_info *vdd = voltdm->vdd; u32 smps_steps = 0, smps_delay = 0; smps_steps = abs(target_vsel - current_vsel); @@ -154,7 +153,7 @@ void omap_vc_post_scale(struct voltagedomain *voltdm, voltdm->pmic->slew_rate) + 2; udelay(smps_delay); - vdd->curr_volt = target_volt; + voltdm->nominal_volt = target_volt; } /* vc_bypass_scale - VC bypass method of voltage scaling */ diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 4afb36883b25..1b39e68db355 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -81,16 +81,12 @@ ovdc_out: */ unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm) { - struct omap_vdd_info *vdd; - if (!voltdm || IS_ERR(voltdm)) { pr_warning("%s: VDD specified does not exist!\n", __func__); return 0; } - vdd = voltdm->vdd; - - return vdd->curr_volt; + return voltdm->nominal_volt; } /** diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 7f8b00aff394..0bd71a2910ab 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h @@ -62,6 +62,7 @@ struct omap_vfsm_instance { * @sys_clk: system clock name/frequency, used for various timing calculations * @vdd: to be removed * @scale: function used to scale the voltage of the voltagedomain + * @nominal_volt: current nominal voltage for this voltage domain */ struct voltagedomain { char *name; @@ -85,6 +86,7 @@ struct voltagedomain { int (*scale) (struct voltagedomain *voltdm, unsigned long target_volt); + u32 nominal_volt; struct omap_vdd_info *vdd; }; @@ -148,11 +150,9 @@ 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. */ struct omap_vdd_info { struct omap_volt_data *volt_data; - u32 curr_volt; }; void omap_voltage_get_volttable(struct voltagedomain *voltdm, -- cgit v1.2.3 From 6a62b78d9aa6661cae1a7d30b574daf435a14c47 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Mon, 18 Jul 2011 16:24:17 -0700 Subject: OMAP3+: voltage: update nominal voltage in voltdm_scale() not VC post-scale Currently, the nominal voltage is updated in the VC post-scale function which is common to both scaling methods. However, this has readabiliy problems as this update is not where it might be expected. Instead, move the updated into voltdm_scale() upon a successful return of voltdm->scale() Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 2 -- arch/arm/mach-omap2/voltage.c | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index d9e69944f0c9..6e586767a904 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -152,8 +152,6 @@ void omap_vc_post_scale(struct voltagedomain *voltdm, smps_delay = ((smps_steps * voltdm->pmic->step_size) / voltdm->pmic->slew_rate) + 2; udelay(smps_delay); - - voltdm->nominal_volt = target_volt; } /* vc_bypass_scale - VC bypass method of voltage scaling */ diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 441c2d98008c..64070ac1e761 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -85,7 +85,11 @@ int voltdm_scale(struct voltagedomain *voltdm, return -ENODATA; } - return voltdm->scale(voltdm, target_volt); + ret = voltdm->scale(voltdm, target_volt); + if (!ret) + voltdm->nominal_volt = target_volt; + + return ret; } /** -- cgit v1.2.3 From 5876c940c0dee298e38fbf47ce67c9e220b0572c Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Wed, 20 Jul 2011 16:35:46 -0700 Subject: OMAP2+: VC: more registers are per-channel starting with OMAP5 Starting with OMAP5, the following registers are per-channel and not common to a all VC channels: - SMPS I2C slave address - SMPS voltage register address offset - SMPS cmd/value register address offset - VC channel configuration register Move these from the channel-common struct into the per-channel struct to support OMAP5. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/vc.c | 8 ++++---- arch/arm/mach-omap2/vc.h | 16 ++++++++-------- arch/arm/mach-omap2/vc3xxx_data.c | 12 ++++++++---- arch/arm/mach-omap2/vc44xx_data.c | 16 ++++++++++++---- 4 files changed, 32 insertions(+), 20 deletions(-) (limited to 'arch/arm/mach-omap2/vc.c') diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 6e586767a904..031d116fbf10 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -94,7 +94,7 @@ static int omap_vc_config_channel(struct voltagedomain *voltdm) voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift, vc->cfg_channel << vc->cfg_channel_sa_shift, - vc->common->cfg_channel_reg); + vc->cfg_channel_reg); return 0; } @@ -319,7 +319,7 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) /* Configure the i2c slave address for this VC */ voltdm->rmw(vc->smps_sa_mask, vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), - vc->common->smps_sa_reg); + vc->smps_sa_reg); vc->cfg_channel |= vc_cfg_bits->sa; /* @@ -327,13 +327,13 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) */ voltdm->rmw(vc->smps_volra_mask, vc->volt_reg_addr << __ffs(vc->smps_volra_mask), - vc->common->smps_volra_reg); + vc->smps_volra_reg); vc->cfg_channel |= vc_cfg_bits->rav; if (vc->cmd_reg_addr) { voltdm->rmw(vc->smps_cmdra_mask, vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), - vc->common->smps_cmdra_reg); + vc->smps_cmdra_reg); vc->cfg_channel |= vc_cfg_bits->rac | vc_cfg_bits->racen; } diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index 7ed70e07becf..478bf6b432c4 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h @@ -25,9 +25,6 @@ struct voltagedomain; * struct omap_vc_common - per-VC register/bitfield data * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register - * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start - * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start - * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start * @bypass_val_reg: Offset of PRM_VC_BYPASS_VAL reg from PRM start * @data_shift: DATA field shift in PRM_VC_BYPASS_VAL register * @slaveaddr_shift: SLAVEADDR field shift in PRM_VC_BYPASS_VAL register @@ -36,7 +33,6 @@ struct voltagedomain; * @cmd_onlp_shift: ONLP field shift in PRM_VC_CMD_VAL_* register * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register - * @cfg_channel_reg: VC channel configuration register * @i2c_cfg_reg: I2C configuration register offset * @i2c_cfg_hsen_mask: high-speed mode bit field mask in I2C config register * @i2c_mcode_mask: MCODE field mask for I2C config register @@ -47,9 +43,6 @@ struct voltagedomain; struct omap_vc_common { u32 cmd_on_mask; u32 valid; - u8 smps_sa_reg; - u8 smps_volra_reg; - u8 smps_cmdra_reg; u8 bypass_val_reg; u8 data_shift; u8 slaveaddr_shift; @@ -58,7 +51,6 @@ struct omap_vc_common { u8 cmd_onlp_shift; u8 cmd_ret_shift; u8 cmd_off_shift; - u8 cfg_channel_reg; u8 i2c_cfg_reg; u8 i2c_cfg_hsen_mask; u8 i2c_mcode_mask; @@ -82,6 +74,10 @@ struct omap_vc_common { * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register * @cmdval_reg: register for on/ret/off voltage level values for this channel + * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start + * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start + * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start + * @cfg_channel_reg: VC channel configuration register * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register * @flags: VC channel-specific flags (optional) */ @@ -100,6 +96,10 @@ struct omap_vc_channel { u32 smps_volra_mask; u32 smps_cmdra_mask; u8 cmdval_reg; + u8 smps_sa_reg; + u8 smps_volra_reg; + u8 smps_cmdra_reg; + u8 cfg_channel_reg; u8 cfg_channel_sa_shift; u8 flags; }; diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 95d7701300cb..cfe348e1af0e 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -30,9 +30,6 @@ * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ static struct omap_vc_common omap3_vc_common = { - .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, - .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, - .smps_cmdra_reg = OMAP3_PRM_VC_SMPS_CMD_RA_OFFSET, .bypass_val_reg = OMAP3_PRM_VC_BYPASS_VAL_OFFSET, .data_shift = OMAP3430_DATA_SHIFT, .slaveaddr_shift = OMAP3430_SLAVEADDR_SHIFT, @@ -43,7 +40,6 @@ static struct omap_vc_common omap3_vc_common = { .cmd_onlp_shift = OMAP3430_VC_CMD_ONLP_SHIFT, .cmd_ret_shift = OMAP3430_VC_CMD_RET_SHIFT, .cmd_off_shift = OMAP3430_VC_CMD_OFF_SHIFT, - .cfg_channel_reg = OMAP3_PRM_VC_CH_CONF_OFFSET, .i2c_cfg_hsen_mask = OMAP3430_HSEN_MASK, .i2c_cfg_reg = OMAP3_PRM_VC_I2C_CFG_OFFSET, .i2c_mcode_mask = OMAP3430_MCODE_MASK, @@ -51,6 +47,10 @@ static struct omap_vc_common omap3_vc_common = { struct omap_vc_channel omap3_vc_mpu = { .common = &omap3_vc_common, + .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, + .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, + .smps_cmdra_reg = OMAP3_PRM_VC_SMPS_CMD_RA_OFFSET, + .cfg_channel_reg = OMAP3_PRM_VC_CH_CONF_OFFSET, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, .smps_volra_mask = OMAP3430_VOLRA0_MASK, @@ -60,6 +60,10 @@ struct omap_vc_channel omap3_vc_mpu = { struct omap_vc_channel omap3_vc_core = { .common = &omap3_vc_common, + .smps_sa_reg = OMAP3_PRM_VC_SMPS_SA_OFFSET, + .smps_volra_reg = OMAP3_PRM_VC_SMPS_VOL_RA_OFFSET, + .smps_cmdra_reg = OMAP3_PRM_VC_SMPS_CMD_RA_OFFSET, + .cfg_channel_reg = OMAP3_PRM_VC_CH_CONF_OFFSET, .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, .smps_volra_mask = OMAP3430_VOLRA1_MASK, diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 0a4fc37877cc..2740a968145e 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -31,9 +31,6 @@ * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. */ static const struct omap_vc_common omap4_vc_common = { - .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, - .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, - .smps_cmdra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_CMD_OFFSET, .bypass_val_reg = OMAP4_PRM_VC_VAL_BYPASS_OFFSET, .data_shift = OMAP4430_DATA_SHIFT, .slaveaddr_shift = OMAP4430_SLAVEADDR_SHIFT, @@ -44,7 +41,6 @@ static const struct omap_vc_common omap4_vc_common = { .cmd_onlp_shift = OMAP4430_ONLP_SHIFT, .cmd_ret_shift = OMAP4430_RET_SHIFT, .cmd_off_shift = OMAP4430_OFF_SHIFT, - .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, .i2c_cfg_reg = OMAP4_PRM_VC_CFG_I2C_MODE_OFFSET, .i2c_cfg_hsen_mask = OMAP4430_HSMODEEN_MASK, .i2c_mcode_mask = OMAP4430_HSMCODE_MASK, @@ -54,6 +50,10 @@ static const struct omap_vc_common omap4_vc_common = { struct omap_vc_channel omap4_vc_mpu = { .flags = OMAP_VC_CHANNEL_DEFAULT | OMAP_VC_CHANNEL_CFG_MUTANT, .common = &omap4_vc_common, + .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, + .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, + .smps_cmdra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_CMD_OFFSET, + .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, @@ -63,6 +63,10 @@ struct omap_vc_channel omap4_vc_mpu = { struct omap_vc_channel omap4_vc_iva = { .common = &omap4_vc_common, + .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, + .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, + .smps_cmdra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_CMD_OFFSET, + .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, @@ -72,6 +76,10 @@ struct omap_vc_channel omap4_vc_iva = { struct omap_vc_channel omap4_vc_core = { .common = &omap4_vc_common, + .smps_sa_reg = OMAP4_PRM_VC_SMPS_SA_OFFSET, + .smps_volra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_VOL_OFFSET, + .smps_cmdra_reg = OMAP4_PRM_VC_VAL_SMPS_RA_CMD_OFFSET, + .cfg_channel_reg = OMAP4_PRM_VC_CFG_CHANNEL_OFFSET, .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, -- cgit v1.2.3