Merge remote-tracking branch 'agust/next' into merge
[pandora-kernel.git] / arch / arm / mach-omap2 / voltage.c
index 4afb368..1f8fdf7 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/err.h>
+#include <linux/export.h>
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
 
 static LIST_HEAD(voltdm_list);
 
-static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
-{
-       /* Generic voltage parameters */
-       voltdm->scale = omap_vp_forceupdate_scale;
-
-       return 0;
-}
-
-static int __init omap_vdd_data_configure(struct voltagedomain *voltdm)
-{
-       int ret = -EINVAL;
-
-       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);
-               goto ovdc_out;
-       }
-
-       if (IS_ERR_VALUE(_config_common_vdd_data(voltdm)))
-               goto ovdc_out;
-
-       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;
+       return voltdm->nominal_volt;
 }
 
 /**
@@ -104,6 +73,8 @@ unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm)
 int voltdm_scale(struct voltagedomain *voltdm,
                 unsigned long target_volt)
 {
+       int ret;
+
        if (!voltdm || IS_ERR(voltdm)) {
                pr_warning("%s: VDD specified does not exist!\n", __func__);
                return -EINVAL;
@@ -115,7 +86,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;
 }
 
 /**
@@ -136,7 +111,7 @@ void voltdm_reset(struct voltagedomain *voltdm)
                return;
        }
 
-       target_volt = omap_voltage_get_nom_volt(voltdm);
+       target_volt = voltdm_get_voltage(voltdm);
        if (!target_volt) {
                pr_err("%s: unable to find current voltage for vdd_%s\n",
                        __func__, voltdm->name);
@@ -159,18 +134,14 @@ void voltdm_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;
 }
 
 /**
@@ -189,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)) {
@@ -199,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"
@@ -308,9 +276,8 @@ int __init omap_voltage_late_init(void)
                        omap_vc_init_channel(voltdm);
                }
 
-               if (voltdm->vdd) {
-                       if (omap_vdd_data_configure(voltdm))
-                               continue;
+               if (voltdm->vp) {
+                       voltdm->scale = omap_vp_forceupdate_scale;
                        omap_vp_init(voltdm);
                }
        }