From: Jean Pihet <jean.pihet@newoldbits.com>
To: Kevin Hilman <khilman@ti.com>
Cc: linux-omap@vger.kernel.org, Paul Walmsely <paul@pwsan.com>,
Benoit Cousson <b-cousson@ti.com>
Subject: Re: [PATCH/RFC 14/19] OMAP2+: voltage: split voltage controller (VC) code into dedicated layer
Date: Fri, 25 Mar 2011 10:26:12 +0100 [thread overview]
Message-ID: <AANLkTinDbAbhSNMNgTGGWyOGxOUJb4CF24bjHKNDe4nW@mail.gmail.com> (raw)
In-Reply-To: <1300924833-26745-15-git-send-email-khilman@ti.com>
On Thu, Mar 24, 2011 at 1:00 AM, Kevin Hilman <khilman@ti.com> wrote:
> 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, cach function was given a local 'vc' pointer:
s/cach/each
>
> struct omap_vc_instance_data *vc = voltdm->vdd->vc_data;
>
> and a global replace of s/vdd->vc_data/vc/ was done.
>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
> arch/arm/mach-omap2/Makefile | 2 +-
> arch/arm/mach-omap2/vc.c | 276 +++++++++++++++++++++++++++++++++++++++++
> arch/arm/mach-omap2/vc.h | 12 ++
> arch/arm/mach-omap2/voltage.c | 262 +--------------------------------------
> 4 files changed, 292 insertions(+), 260 deletions(-)
> create mode 100644 arch/arm/mach-omap2/vc.c
>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index ce2105c..a0d8f61 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -90,7 +90,7 @@ obj-$(CONFIG_ARCH_OMAP4) += prcm.o cm2xxx_3xxx.o cminst44xx.o \
>
> # OMAP voltage domains
> ifeq ($(CONFIG_PM),y)
> -voltagedomain-common := voltage.o
> +voltagedomain-common := voltage.o vc.o
> obj-$(CONFIG_ARCH_OMAP2) += $(voltagedomain-common) \
> voltagedomains2xxx_data.o
> obj-$(CONFIG_ARCH_OMAP3) += $(voltagedomain-common) \
> diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
> new file mode 100644
> index 0000000..4e65fdc
> --- /dev/null
> +++ b/arch/arm/mach-omap2/vc.c
> @@ -0,0 +1,276 @@
> +#include <linux/kernel.h>
> +#include <linux/delay.h>
> +#include <linux/init.h>
> +
> +#include <plat/cpu.h>
> +
> +#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 suffiecient pmic info is available for this vdd */
Typo
> + 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(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(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(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(voltdm);
> + else if (cpu_is_omap44xx())
> + omap4_vc_init(voltdm);
> +}
> +
> diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h
> index f7338af..b823e5b 100644
> --- a/arch/arm/mach-omap2/vc.h
> +++ b/arch/arm/mach-omap2/vc.h
> @@ -19,6 +19,8 @@
>
> #include <linux/kernel.h>
>
> +struct voltagedomain;
> +
> /**
> * struct omap_vc_common_data - per-VC register/bitfield data
> * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register
> @@ -81,5 +83,15 @@ 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;
>
> +void omap_vc_init(struct voltagedomain *voltdm);
> +int omap_vc_pre_scale(struct voltagedomain *voltdm,
> + unsigned long target_volt,
> + u8 *target_vsel, u8 *current_vsel);
> +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);
> +
> #endif
>
> diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
> index b1b5e38..8a47dd1 100644
> --- a/arch/arm/mach-omap2/voltage.c
> +++ b/arch/arm/mach-omap2/voltage.c
> @@ -293,136 +293,6 @@ static void __init vdd_debugfs_init(struct voltagedomain *voltdm)
> &nom_volt_debug_fops);
> }
>
> -/* Voltage scale and accessory APIs */
> -static int _pre_volt_scale(struct voltagedomain *voltdm,
> - unsigned long target_volt, u8 *target_vsel, u8 *current_vsel)
> -{
> - 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 = vdd->vc_data->vc_common;
> - vp_common = vdd->vp_data->vp_common;
> -
> - /* Check if suffiecient 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(vdd->vc_data->vc_common->prm_mod, vdd->vc_data->cmdval_reg);
> - vc_cmdval &= ~vc_common->cmd_on_mask;
> - vc_cmdval |= (*target_vsel << vc_common->cmd_on_shift);
> - vdd->write_reg(vc_cmdval, vdd->vc_data->vc_common->prm_mod, vdd->vc_data->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;
> -}
> -
> -static void _post_volt_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 */
> -static int vc_bypass_scale_voltage(struct voltagedomain *voltdm,
> - unsigned long target_volt)
> -{
> - 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 = _pre_volt_scale(voltdm, target_volt, &target_vsel, ¤t_vsel);
> - if (ret)
> - return ret;
> -
> - vc_valid = vdd->vc_data->vc_common->valid;
> - vc_bypass_val_reg = vdd->vc_data->vc_common->bypass_val_reg;
> - vc_bypass_value = (target_vsel << vdd->vc_data->vc_common->data_shift) |
> - (vdd->pmic_info->pmic_reg <<
> - vdd->vc_data->vc_common->regaddr_shift) |
> - (vdd->pmic_info->i2c_slave_addr <<
> - vdd->vc_data->vc_common->slaveaddr_shift);
> -
> - vdd->write_reg(vc_bypass_value, vdd->vc_data->vc_common->prm_mod, vc_bypass_val_reg);
> - vdd->write_reg(vc_bypass_value | vc_valid, vdd->vc_data->vc_common->prm_mod,
> - vc_bypass_val_reg);
> -
> - vc_bypass_value = vdd->read_reg(vdd->vc_data->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(vdd->vc_data->vc_common->prm_mod,
> - vc_bypass_val_reg);
> - }
> -
> - _post_volt_scale(voltdm, target_volt, target_vsel, current_vsel);
> - return 0;
> -}
> -
> /* VP force update method of voltage scaling */
> static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
> unsigned long target_volt)
> @@ -432,7 +302,7 @@ static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
> u8 target_vsel, current_vsel;
> int ret, timeout = 0;
>
> - ret = _pre_volt_scale(voltdm, target_volt, &target_vsel, ¤t_vsel);
> + ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, ¤t_vsel);
> if (ret)
> return ret;
>
> @@ -485,7 +355,7 @@ static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
> "TRANXDONE never got set after the voltage update\n",
> __func__, voltdm->name);
>
> - _post_volt_scale(voltdm, target_volt, target_vsel, current_vsel);
> + omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel);
>
> /*
> * Disable TransactionDone interrupt , clear all status, clear
> @@ -517,132 +387,6 @@ static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
> return 0;
> }
>
> -static void __init omap3_vfsm_init(struct voltagedomain *voltdm)
> -{
> - 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, vdd->vc_data->vc_common->prm_mod, OMAP3_PRM_CLKSETUP_OFFSET);
> - vdd->write_reg(OMAP3_VOLTOFFSET, vdd->vc_data->vc_common->prm_mod,
> - OMAP3_PRM_VOLTOFFSET_OFFSET);
> - vdd->write_reg(OMAP3_VOLTSETUP2, vdd->vc_data->vc_common->prm_mod,
> - OMAP3_PRM_VOLTSETUP2_OFFSET);
> -}
> -
> -static void __init omap3_vc_init(struct voltagedomain *voltdm)
> -{
> - 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 << vdd->vc_data->vc_common->cmd_on_shift) |
> - (onlp_vsel << vdd->vc_data->vc_common->cmd_onlp_shift) |
> - (ret_vsel << vdd->vc_data->vc_common->cmd_ret_shift) |
> - (off_vsel << vdd->vc_data->vc_common->cmd_off_shift));
> - vdd->write_reg(vc_val, vdd->vc_data->vc_common->prm_mod, vdd->vc_data->cmdval_reg);
> -
> - /*
> - * Generic VC parameters init
> - * XXX This data should be abstracted out
> - */
> - vdd->write_reg(OMAP3430_CMD1_MASK | OMAP3430_RAV1_MASK, vdd->vc_data->vc_common->prm_mod,
> - OMAP3_PRM_VC_CH_CONF_OFFSET);
> - vdd->write_reg(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, vdd->vc_data->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(struct voltagedomain *voltdm)
> -{
> - 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, vdd->vc_data->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, vdd->vc_data->vc_common->prm_mod, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET);
> -
> - is_initialized = true;
> -}
> -
> -static void __init omap_vc_init(struct voltagedomain *voltdm)
> -{
> - 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(vdd->vc_data->vc_common->prm_mod,
> - vdd->vc_data->vc_common->smps_sa_reg);
> - vc_val &= ~vdd->vc_data->smps_sa_mask;
> - vc_val |= vdd->pmic_info->i2c_slave_addr << vdd->vc_data->smps_sa_shift;
> - vdd->write_reg(vc_val, vdd->vc_data->vc_common->prm_mod,
> - vdd->vc_data->vc_common->smps_sa_reg);
> -
> - /* Setup the VOLRA(pmic reg addr) in VC */
> - vc_val = vdd->read_reg(vdd->vc_data->vc_common->prm_mod,
> - vdd->vc_data->vc_common->smps_volra_reg);
> - vc_val &= ~vdd->vc_data->smps_volra_mask;
> - vc_val |= vdd->pmic_info->pmic_reg << vdd->vc_data->smps_volra_shift;
> - vdd->write_reg(vc_val, vdd->vc_data->vc_common->prm_mod,
> - vdd->vc_data->vc_common->smps_volra_reg);
> -
> - /* Configure the setup times */
> - vc_val = vdd->read_reg(vdd->vc_data->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, vdd->vc_data->vc_common->prm_mod, vdd->vfsm->voltsetup_reg);
> -
> - if (cpu_is_omap34xx())
> - omap3_vc_init(voltdm);
> - else if (cpu_is_omap44xx())
> - omap4_vc_init(voltdm);
> -}
> -
> static int __init omap_vdd_data_configure(struct voltagedomain *voltdm)
> {
> struct omap_vdd_info *vdd = voltdm->vdd;
> @@ -1025,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 = vc_bypass_scale_voltage;
> + vdd->volt_scale = omap_vc_bypass_scale_voltage;
> return;
> default:
> pr_warning("%s: Trying to change the method of voltage scaling"
> --
> 1.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-03-25 9:26 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 0:00 [PATCH/RFC 00/19] OMAP: voltage layer cleanup and restructure Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 01/19] OMAP2+: hwmod: remove unused voltagedomain pointer Kevin Hilman
2011-03-25 8:58 ` Jean Pihet
2011-03-25 14:24 ` Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 02/19] OMAP2+: voltage: move PRCM mod offets into VC/VP structures Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 03/19] OMAP2+: voltage: move prm_irqst_reg from VP into voltage domain Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 04/19] OMAP2+: voltage: start towards a new voltagedomain layer Kevin Hilman
2011-03-25 8:59 ` Jean Pihet
2011-03-25 15:48 ` Kevin Hilman
2011-03-25 16:41 ` Jean Pihet
2011-03-24 0:00 ` [PATCH/RFC 05/19] OMAP3: voltage: rename "mpu" voltagedomain to "mpu_iva" Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 06/19] OMAP3: voltagedomain data: add wakeup domain Kevin Hilman
2011-03-25 9:00 ` Jean Pihet
2011-03-24 0:00 ` [PATCH/RFC 07/19] OMAP3: voltage: add scalable flag to voltagedomain Kevin Hilman
2011-03-24 5:23 ` Vishwanath Sripathy
2011-03-24 14:12 ` Kevin Hilman
2011-03-24 14:54 ` Cousson, Benoit
2011-03-24 17:31 ` Vishwanath Sripathy
2011-03-24 0:00 ` [PATCH/RFC 08/19] OMAP2+: powerdomain: add voltagedomain to struct powerdomain Kevin Hilman
2011-03-25 9:05 ` Jean Pihet
2011-03-25 15:49 ` Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 09/19] OMAP2: add voltage domains and connect to powerdomains Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 10/19] OMAP3: powerdomain data: add voltage domains Kevin Hilman
2011-03-25 9:09 ` Jean Pihet
2011-03-25 15:51 ` Kevin Hilman
2011-03-25 16:43 ` Jean Pihet
2011-03-24 0:00 ` [PATCH/RFC 11/19] OMAP4: " Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 12/19] OMAP2+: powerdomain: add voltage domain lookup during register Kevin Hilman
2011-03-25 9:18 ` Jean Pihet
2011-03-25 15:52 ` Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 13/19] OMAP2+: voltage: keep track of powerdomains in each voltagedomain Kevin Hilman
2011-03-25 9:22 ` Jean Pihet
2011-03-25 15:56 ` Kevin Hilman
2011-03-25 16:52 ` Jean Pihet
2011-03-24 0:00 ` [PATCH/RFC 14/19] OMAP2+: voltage: split voltage controller (VC) code into dedicated layer Kevin Hilman
2011-03-25 9:26 ` Jean Pihet [this message]
2011-03-24 0:00 ` [PATCH/RFC 15/19] OMAP2+: voltage: move VC into struct voltagedomain, misc. renames Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 16/19] OMAP2+: voltage: split out voltage processor (VP) code into new layer Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 17/19] OMAP2+: voltage: VC: begin spliting out SoC specifics; start with i2c slave addr Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 18/19] OMAP2+: VC: support PMICs with separate voltage and command registers Kevin Hilman
2011-03-24 0:00 ` [PATCH/RFC 19/19] OMAP2+: VC: add SoC-specific op for PMIC register addresses Kevin Hilman
2011-03-25 0:02 ` [PATCH/RFC 00/19] OMAP: voltage layer cleanup and restructure Kevin Hilman
2011-03-25 0:09 ` [PATCH] OMAP2+: VC: begin spliting out SoC specifics; start with i2c slave addr Kevin Hilman
2011-03-25 0:09 ` [PATCH] OMAP2+: VC: add SoC-specific op for PMIC register addresses Kevin Hilman
2011-03-25 9:31 ` Vishwanath Sripathy
2011-03-25 14:22 ` Kevin Hilman
2011-03-25 14:37 ` [PATCH/RFC 00/19] OMAP: voltage layer cleanup and restructure Cousson, Benoit
2011-03-25 23:02 ` Paul Walmsley
2011-03-26 0:20 ` Kevin Hilman
2011-03-25 8:58 ` Jean Pihet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTinDbAbhSNMNgTGGWyOGxOUJb4CF24bjHKNDe4nW@mail.gmail.com \
--to=jean.pihet@newoldbits.com \
--cc=b-cousson@ti.com \
--cc=khilman@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=paul@pwsan.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).