Merge remote-tracking branch 'agust/next' into merge
[pandora-kernel.git] / arch / arm / mach-omap2 / voltage.c
index c6352e3..1f8fdf7 100644 (file)
 
 #include <linux/delay.h>
 #include <linux/io.h>
-#include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/export.h>
 #include <linux/debugfs.h>
 #include <linux/slab.h>
+#include <linux/clk.h>
 
 #include <plat/common.h>
 
 
 static LIST_HEAD(voltdm_list);
 
-#define VOLTAGE_DIR_SIZE       16
-static struct dentry *voltage_dir;
-
-/* Init function pointers */
-static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
-                                       unsigned long target_volt);
-
-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;
-       struct clk *sys_ck;
-       u32 sys_clk_speed, timeout_val, waittime;
-       struct omap_vdd_info *vdd = voltdm->vdd;
-
-       /*
-        * XXX Clockfw should handle this, or this should be in a
-        * struct record
-        */
-       if (cpu_is_omap24xx() || cpu_is_omap34xx())
-               sys_ck_name = "sys_ck";
-       else if (cpu_is_omap44xx())
-               sys_ck_name = "sys_clkin_ck";
-       else
-               return -EINVAL;
-
-       /*
-        * Sys clk rate is require to calculate vp timeout value and
-        * smpswaittimemin and smpswaittimemax.
-        */
-       sys_ck = clk_get(NULL, sys_ck_name);
-       if (IS_ERR(sys_ck)) {
-               pr_warning("%s: Could not get the sys clk to calculate"
-                       "various vdd_%s params\n", __func__, voltdm->name);
-               return -EINVAL;
-       }
-       sys_clk_speed = clk_get_rate(sys_ck);
-       clk_put(sys_ck);
-       /* Divide to avoid overflow */
-       sys_clk_speed /= 1000;
-
-       /* Generic voltage parameters */
-       vdd->volt_scale = vp_forceupdate_scale_voltage;
-       vdd->vp_enabled = false;
-
-       vdd->vp_rt_data.vpconfig_erroroffset =
-               (vdd->pmic_info->vp_erroroffset <<
-                vdd->vp_data->vp_common->vpconfig_erroroffset_shift);
-
-       timeout_val = (sys_clk_speed * vdd->pmic_info->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;
-
-       waittime = ((vdd->pmic_info->step_size / vdd->pmic_info->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;
-
-       return 0;
-}
-
-/* Voltage debugfs support */
-static int vp_volt_debug_get(void *data, u64 *val)
-{
-       struct voltagedomain *voltdm = (struct voltagedomain *)data;
-       struct omap_vdd_info *vdd = voltdm->vdd;
-       u8 vsel;
-
-       if (!vdd) {
-               pr_warning("Wrong paramater passed\n");
-               return -EINVAL;
-       }
-
-       vsel = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->voltage);
-
-       if (!vdd->pmic_info->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);
-       return 0;
-}
-
-static int nom_volt_debug_get(void *data, u64 *val)
-{
-       struct voltagedomain *voltdm = (struct voltagedomain *)data;
-
-       if (!voltdm) {
-               pr_warning("Wrong paramater passed\n");
-               return -EINVAL;
-       }
-
-       *val = omap_voltage_get_nom_volt(voltdm);
-
-       return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(vp_volt_debug_fops, vp_volt_debug_get, NULL, "%llu\n");
-DEFINE_SIMPLE_ATTRIBUTE(nom_volt_debug_fops, nom_volt_debug_get, NULL,
-                                                               "%llu\n");
-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) {
-               pr_warning("%s: unable to find current voltage for vdd_%s\n",
-                       __func__, voltdm->name);
-               return;
-       }
-
-       if (!vdd->pmic_info || !vdd->pmic_info->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);
-
-       vpconfig = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       vpconfig &= ~(vdd->vp_data->vp_common->vpconfig_initvoltage_mask |
-                       vdd->vp_data->vp_common->vpconfig_initvdd);
-       vpconfig |= vsel << vdd->vp_data->vp_common->vpconfig_initvoltage_shift;
-
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /* Trigger initVDD value copy to voltage processor */
-       vdd->write_reg((vpconfig | vdd->vp_data->vp_common->vpconfig_initvdd),
-                      vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /* Clear initVDD copy trigger bit */
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-}
-
-/* Generic voltage init functions */
-static void __init vp_init(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd = voltdm->vdd;
-       u32 vp_val;
-
-       if (!vdd->read_reg || !vdd->write_reg) {
-               pr_err("%s: No read/write API for accessing vdd_%s regs\n",
-                       __func__, voltdm->name);
-               return;
-       }
-
-       vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
-               (vdd->vp_rt_data.vpconfig_errorgain <<
-               vdd->vp_data->vp_common->vpconfig_errorgain_shift) |
-               vdd->vp_data->vp_common->vpconfig_timeouten;
-       vdd->write_reg(vp_val, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin <<
-               vdd->vp_data->vp_common->vstepmin_smpswaittimemin_shift) |
-               (vdd->vp_rt_data.vstepmin_stepmin <<
-               vdd->vp_data->vp_common->vstepmin_stepmin_shift));
-       vdd->write_reg(vp_val, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vstepmin);
-
-       vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax <<
-               vdd->vp_data->vp_common->vstepmax_smpswaittimemax_shift) |
-               (vdd->vp_rt_data.vstepmax_stepmax <<
-               vdd->vp_data->vp_common->vstepmax_stepmax_shift));
-       vdd->write_reg(vp_val, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vstepmax);
-
-       vp_val = ((vdd->vp_rt_data.vlimitto_vddmax <<
-               vdd->vp_data->vp_common->vlimitto_vddmax_shift) |
-               (vdd->vp_rt_data.vlimitto_vddmin <<
-               vdd->vp_data->vp_common->vlimitto_vddmin_shift) |
-               (vdd->vp_rt_data.vlimitto_timeout <<
-               vdd->vp_data->vp_common->vlimitto_timeout_shift));
-       vdd->write_reg(vp_val, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vlimitto);
-}
-
-static void __init vdd_debugfs_init(struct voltagedomain *voltdm)
-{
-       char *name;
-       struct omap_vdd_info *vdd = voltdm->vdd;
-
-       name = kzalloc(VOLTAGE_DIR_SIZE, GFP_KERNEL);
-       if (!name) {
-               pr_warning("%s: Unable to allocate memory for debugfs"
-                       " directory name for vdd_%s",
-                       __func__, voltdm->name);
-               return;
-       }
-       strcpy(name, "vdd_");
-       strcat(name, voltdm->name);
-
-       vdd->debug_dir = debugfs_create_dir(name, voltage_dir);
-       kfree(name);
-       if (IS_ERR(vdd->debug_dir)) {
-               pr_warning("%s: Unable to create debugfs directory for"
-                       " vdd_%s\n", __func__, voltdm->name);
-               vdd->debug_dir = NULL;
-               return;
-       }
-
-       (void) debugfs_create_x16("vp_errorgain", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vpconfig_errorgain));
-       (void) debugfs_create_x16("vp_smpswaittimemin", S_IRUGO,
-                               vdd->debug_dir,
-                               &(vdd->vp_rt_data.vstepmin_smpswaittimemin));
-       (void) debugfs_create_x8("vp_stepmin", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vstepmin_stepmin));
-       (void) debugfs_create_x16("vp_smpswaittimemax", S_IRUGO,
-                               vdd->debug_dir,
-                               &(vdd->vp_rt_data.vstepmax_smpswaittimemax));
-       (void) debugfs_create_x8("vp_stepmax", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vstepmax_stepmax));
-       (void) debugfs_create_x8("vp_vddmax", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vlimitto_vddmax));
-       (void) debugfs_create_x8("vp_vddmin", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vlimitto_vddmin));
-       (void) debugfs_create_x16("vp_timeout", S_IRUGO, vdd->debug_dir,
-                               &(vdd->vp_rt_data.vlimitto_timeout));
-       (void) debugfs_create_file("curr_vp_volt", S_IRUGO, vdd->debug_dir,
-                               (void *) voltdm, &vp_volt_debug_fops);
-       (void) debugfs_create_file("curr_nominal_volt", S_IRUGO,
-                               vdd->debug_dir, (void *) voltdm,
-                               &nom_volt_debug_fops);
-}
-
-/* VP force update method of voltage scaling */
-static int vp_forceupdate_scale_voltage(struct voltagedomain *voltdm,
-               unsigned long target_volt)
-{
-       struct omap_vdd_info *vdd = voltdm->vdd;
-       u32 vpconfig;
-       u8 target_vsel, current_vsel;
-       int ret, timeout = 0;
-
-       ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, &current_vsel);
-       if (ret)
-               return ret;
-
-       /*
-        * Clear all pending TransactionDone interrupt/status. Typical latency
-        * is <3us
-        */
-       while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-               vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-                              vdd->prm_irqst_mod, vdd->prm_irqst_reg);
-               if (!(vdd->read_reg(vdd->prm_irqst_mod, vdd->prm_irqst_reg) &
-                     vdd->vp_data->prm_irqst_data->tranxdone_status))
-                       break;
-               udelay(1);
-       }
-       if (timeout >= VP_TRANXDONE_TIMEOUT) {
-               pr_warning("%s: vdd_%s TRANXDONE timeout exceeded."
-                       "Voltage change aborted", __func__, voltdm->name);
-               return -ETIMEDOUT;
-       }
-
-       /* Configure for VP-Force Update */
-       vpconfig = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       vpconfig &= ~(vdd->vp_data->vp_common->vpconfig_initvdd |
-                       vdd->vp_data->vp_common->vpconfig_forceupdate |
-                       vdd->vp_data->vp_common->vpconfig_initvoltage_mask);
-       vpconfig |= ((target_vsel <<
-                       vdd->vp_data->vp_common->vpconfig_initvoltage_shift));
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /* Trigger initVDD value copy to voltage processor */
-       vpconfig |= vdd->vp_data->vp_common->vpconfig_initvdd;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /* Force update of voltage */
-       vpconfig |= vdd->vp_data->vp_common->vpconfig_forceupdate;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /*
-        * Wait for TransactionDone. Typical latency is <200us.
-        * Depends on SMPSWAITTIMEMIN/MAX and voltage change
-        */
-       timeout = 0;
-       omap_test_timeout((vdd->read_reg(vdd->prm_irqst_mod,
-                                        vdd->prm_irqst_reg) &
-                          vdd->vp_data->prm_irqst_data->tranxdone_status),
-                         VP_TRANXDONE_TIMEOUT, timeout);
-       if (timeout >= VP_TRANXDONE_TIMEOUT)
-               pr_err("%s: vdd_%s TRANXDONE timeout exceeded."
-                       "TRANXDONE never got set after the voltage update\n",
-                       __func__, voltdm->name);
-
-       omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel);
-
-       /*
-        * Disable TransactionDone interrupt , clear all status, clear
-        * control registers
-        */
-       timeout = 0;
-       while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-               vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-                              vdd->prm_irqst_mod, vdd->prm_irqst_reg);
-               if (!(vdd->read_reg(vdd->prm_irqst_mod, vdd->prm_irqst_reg) &
-                     vdd->vp_data->prm_irqst_data->tranxdone_status))
-                       break;
-               udelay(1);
-       }
-
-       if (timeout >= VP_TRANXDONE_TIMEOUT)
-               pr_warning("%s: vdd_%s TRANXDONE timeout exceeded while trying"
-                       "to clear the TRANXDONE status\n",
-                       __func__, voltdm->name);
-
-       vpconfig = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       /* Clear initVDD copy trigger bit */
-       vpconfig &= ~vdd->vp_data->vp_common->vpconfig_initvdd;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       /* Clear force bit */
-       vpconfig &= ~vdd->vp_data->vp_common->vpconfig_forceupdate;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       return 0;
-}
-
-static int __init omap_vdd_data_configure(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd = voltdm->vdd;
-       int ret = -EINVAL;
-
-       if (!vdd->pmic_info) {
-               pr_err("%s: PMIC info requried to configure vdd_%s not"
-                       "populated.Hence cannot initialize vdd_%s\n",
-                       __func__, voltdm->name, voltdm->name);
-               goto ovdc_out;
-       }
-
-       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;
-       }
-
-ovdc_out:
-       return ret;
-}
-
 /* Public functions */
 /**
- * omap_voltage_get_nom_volt() - Gets the current non-auto-compensated voltage
- * @voltdm:    pointer to the VDD for which current voltage info is needed
+ * voltdm_get_voltage() - Gets the current non-auto-compensated voltage
+ * @voltdm:    pointer to the voltdm for which current voltage info is needed
  *
- * API to get the current non-auto-compensated voltage for a VDD.
- * Returns 0 in case of error else returns the current voltage for the VDD.
+ * API to get the current non-auto-compensated voltage for a voltage domain.
+ * Returns 0 in case of error else returns the current voltage.
  */
-unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm)
+unsigned long voltdm_get_voltage(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;
-}
-
-/**
- * omap_vp_get_curr_volt() - API to get the current vp voltage.
- * @voltdm:    pointer to the VDD.
- *
- * This API returns the current voltage for the specified voltage processor
- */
-unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd;
-       u8 curr_vsel;
-
-       if (!voltdm || IS_ERR(voltdm)) {
-               pr_warning("%s: VDD specified does not exist!\n", __func__);
-               return 0;
-       }
-
-       vdd = voltdm->vdd;
-       if (!vdd->read_reg) {
-               pr_err("%s: No read API for reading vdd_%s regs\n",
-                       __func__, voltdm->name);
-               return 0;
-       }
-
-       curr_vsel = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->voltage);
-
-       if (!vdd->pmic_info || !vdd->pmic_info->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);
-}
-
-/**
- * omap_vp_enable() - API to enable a particular VP
- * @voltdm:    pointer to the VDD whose VP is to be enabled.
- *
- * This API enables a particular voltage processor. Needed by the smartreflex
- * class drivers.
- */
-void omap_vp_enable(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd;
-       u32 vpconfig;
-
-       if (!voltdm || IS_ERR(voltdm)) {
-               pr_warning("%s: VDD specified does not exist!\n", __func__);
-               return;
-       }
-
-       vdd = voltdm->vdd;
-       if (!vdd->read_reg || !vdd->write_reg) {
-               pr_err("%s: No read/write API for accessing vdd_%s regs\n",
-                       __func__, voltdm->name);
-               return;
-       }
-
-       /* If VP is already enabled, do nothing. Return */
-       if (vdd->vp_enabled)
-               return;
-
-       vp_latch_vsel(voltdm);
-
-       /* Enable VP */
-       vpconfig = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       vpconfig |= vdd->vp_data->vp_common->vpconfig_vpenable;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       vdd->vp_enabled = true;
-}
-
-/**
- * omap_vp_disable() - API to disable a particular VP
- * @voltdm:    pointer to the VDD whose VP is to be disabled.
- *
- * This API disables a particular voltage processor. Needed by the smartreflex
- * class drivers.
- */
-void omap_vp_disable(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd;
-       u32 vpconfig;
-       int timeout;
-
-       if (!voltdm || IS_ERR(voltdm)) {
-               pr_warning("%s: VDD specified does not exist!\n", __func__);
-               return;
-       }
-
-       vdd = voltdm->vdd;
-       if (!vdd->read_reg || !vdd->write_reg) {
-               pr_err("%s: No read/write API for accessing vdd_%s regs\n",
-                       __func__, voltdm->name);
-               return;
-       }
-
-       /* If VP is already disabled, do nothing. Return */
-       if (!vdd->vp_enabled) {
-               pr_warning("%s: Trying to disable VP for vdd_%s when"
-                       "it is already disabled\n", __func__, voltdm->name);
-               return;
-       }
-
-       /* Disable VP */
-       vpconfig = vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-       vpconfig &= ~vdd->vp_data->vp_common->vpconfig_vpenable;
-       vdd->write_reg(vpconfig, vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vpconfig);
-
-       /*
-        * Wait for VP idle Typical latency is <2us. Maximum latency is ~100us
-        */
-       omap_test_timeout((vdd->read_reg(vdd->vp_data->vp_common->prm_mod, vdd->vp_data->vstatus)),
-                               VP_IDLE_TIMEOUT, timeout);
-
-       if (timeout >= VP_IDLE_TIMEOUT)
-               pr_warning("%s: vdd_%s idle timedout\n",
-                       __func__, voltdm->name);
-
-       vdd->vp_enabled = false;
-
-       return;
+       return voltdm->nominal_volt;
 }
 
 /**
- * omap_voltage_scale_vdd() - API to scale voltage of a particular
- *                             voltage domain.
- * @voltdm:    pointer to the VDD which is to be scaled.
- * @target_volt:       The target voltage of the voltage domain
+ * voltdm_scale() - API to scale voltage of a particular voltage domain.
+ * @voltdm: pointer to the voltage domain which is to be scaled.
+ * @target_volt: The target voltage of the voltage domain
  *
  * This API should be called by the kernel to do the voltage scaling
- * for a particular voltage domain during dvfs or any other situation.
+ * for a particular voltage domain during DVFS.
  */
-int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
-               unsigned long target_volt)
+int voltdm_scale(struct voltagedomain *voltdm,
+                unsigned long target_volt)
 {
-       struct omap_vdd_info *vdd;
+       int ret;
 
        if (!voltdm || IS_ERR(voltdm)) {
                pr_warning("%s: VDD specified does not exist!\n", __func__);
                return -EINVAL;
        }
 
-       vdd = voltdm->vdd;
-
-       if (!vdd->volt_scale) {
+       if (!voltdm->scale) {
                pr_err("%s: No voltage scale API registered for vdd_%s\n",
                        __func__, voltdm->name);
                return -ENODATA;
        }
 
-       return vdd->volt_scale(voltdm, target_volt);
+       ret = voltdm->scale(voltdm, target_volt);
+       if (!ret)
+               voltdm->nominal_volt = target_volt;
+
+       return ret;
 }
 
 /**
- * omap_voltage_reset() - Resets the voltage of a particular voltage domain
- *                     to that of the current OPP.
- * @voltdm:    pointer to the VDD whose voltage is to be reset.
+ * voltdm_reset() - Resets the voltage of a particular voltage domain
+ *                 to that of the current OPP.
+ * @voltdm: pointer to the voltage domain whose voltage is to be reset.
  *
  * This API finds out the correct voltage the voltage domain is supposed
  * to be at and resets the voltage to that level. Should be used especially
  * while disabling any voltage compensation modules.
  */
-void omap_voltage_reset(struct voltagedomain *voltdm)
+void voltdm_reset(struct voltagedomain *voltdm)
 {
-       unsigned long target_uvdc;
+       unsigned long target_volt;
 
        if (!voltdm || IS_ERR(voltdm)) {
                pr_warning("%s: VDD specified does not exist!\n", __func__);
                return;
        }
 
-       target_uvdc = omap_voltage_get_nom_volt(voltdm);
-       if (!target_uvdc) {
+       target_volt = voltdm_get_voltage(voltdm);
+       if (!target_volt) {
                pr_err("%s: unable to find current voltage for vdd_%s\n",
                        __func__, voltdm->name);
                return;
        }
 
-       omap_voltage_scale_vdd(voltdm, target_uvdc);
+       voltdm_scale(voltdm, target_volt);
 }
 
 /**
@@ -632,18 +134,14 @@ void omap_voltage_reset(struct voltagedomain *voltdm)
  *
  */
 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
-               struct omap_volt_data **volt_data)
+                               struct omap_volt_data **volt_data)
 {
-       struct omap_vdd_info *vdd;
-
        if (!voltdm || IS_ERR(voltdm)) {
                pr_warning("%s: VDD specified does not exist!\n", __func__);
                return;
        }
 
-       vdd = voltdm->vdd;
-
-       *volt_data = vdd->volt_data;
+       *volt_data = voltdm->volt_data;
 }
 
 /**
@@ -662,9 +160,8 @@ void omap_voltage_get_volttable(struct voltagedomain *voltdm,
  * domain or if there is no matching entry.
  */
 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
-               unsigned long volt)
+                                                unsigned long volt)
 {
-       struct omap_vdd_info *vdd;
        int i;
 
        if (!voltdm || IS_ERR(voltdm)) {
@@ -672,17 +169,15 @@ struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
                return ERR_PTR(-EINVAL);
        }
 
-       vdd = voltdm->vdd;
-
-       if (!vdd->volt_data) {
+       if (!voltdm->volt_data) {
                pr_warning("%s: voltage table does not exist for vdd_%s\n",
                        __func__, voltdm->name);
                return ERR_PTR(-ENODATA);
        }
 
-       for (i = 0; vdd->volt_data[i].volt_nominal != 0; i++) {
-               if (vdd->volt_data[i].volt_nominal == volt)
-                       return &vdd->volt_data[i];
+       for (i = 0; voltdm->volt_data[i].volt_nominal != 0; i++) {
+               if (voltdm->volt_data[i].volt_nominal == volt)
+                       return &voltdm->volt_data[i];
        }
 
        pr_notice("%s: Unable to match the current voltage with the voltage"
@@ -695,53 +190,24 @@ 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;
 }
 
-/**
- * omap_voltage_get_dbgdir() - API to get pointer to the debugfs directory
- *                             corresponding to a voltage domain.
- *
- * @voltdm:    pointer to the VDD whose debug directory is required.
- *
- * This API returns pointer to the debugfs directory corresponding
- * to the voltage domain. Should be used by drivers requiring to
- * add any debug entry for a particular voltage domain. Returns NULL
- * in case of error.
- */
-struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm)
-{
-       struct omap_vdd_info *vdd;
-
-       if (!voltdm || IS_ERR(voltdm)) {
-               pr_warning("%s: VDD specified does not exist!\n", __func__);
-               return NULL;
-       }
-
-       vdd = voltdm->vdd;
-
-       return vdd->debug_dir;
-}
-
 /**
  * omap_change_voltscale_method() - API to change the voltage scaling method.
  * @voltdm:    pointer to the VDD whose voltage scaling method
@@ -753,23 +219,19 @@ struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm)
  * defined in voltage.h
  */
 void omap_change_voltscale_method(struct voltagedomain *voltdm,
-               int voltscale_method)
+                                 int voltscale_method)
 {
-       struct omap_vdd_info *vdd;
-
        if (!voltdm || IS_ERR(voltdm)) {
                pr_warning("%s: VDD specified does not exist!\n", __func__);
                return;
        }
 
-       vdd = voltdm->vdd;
-
        switch (voltscale_method) {
        case VOLTSCALE_VPFORCEUPDATE:
-               vdd->volt_scale = vp_forceupdate_scale_voltage;
+               voltdm->scale = omap_vp_forceupdate_scale;
                return;
        case VOLTSCALE_VCBYPASS:
-               vdd->volt_scale = omap_vc_bypass_scale;
+               voltdm->scale = omap_vc_bypass_scale;
                return;
        default:
                pr_warning("%s: Trying to change the method of voltage scaling"
@@ -794,22 +256,29 @@ int __init omap_voltage_late_init(void)
                return -EINVAL;
        }
 
-       voltage_dir = debugfs_create_dir("voltage", NULL);
-       if (IS_ERR(voltage_dir))
-               pr_err("%s: Unable to create voltage debugfs main dir\n",
-                       __func__);
        list_for_each_entry(voltdm, &voltdm_list, node) {
+               struct clk *sys_ck;
+
                if (!voltdm->scalable)
                        continue;
 
-               if (voltdm->vc)
+               sys_ck = clk_get(NULL, voltdm->sys_clk.name);
+               if (IS_ERR(sys_ck)) {
+                       pr_warning("%s: Could not get sys clk.\n", __func__);
+                       return -EINVAL;
+               }
+               voltdm->sys_clk.rate = clk_get_rate(sys_ck);
+               WARN_ON(!voltdm->sys_clk.rate);
+               clk_put(sys_ck);
+
+               if (voltdm->vc) {
+                       voltdm->scale = omap_vc_bypass_scale;
                        omap_vc_init_channel(voltdm);
+               }
 
-               if (voltdm->vdd) {
-                       if (omap_vdd_data_configure(voltdm))
-                               continue;
-                       vp_init(voltdm);
-                       vdd_debugfs_init(voltdm);
+               if (voltdm->vp) {
+                       voltdm->scale = omap_vp_forceupdate_scale;
+                       omap_vp_init(voltdm);
                }
        }