MLK-11252-02 cpufreq: imx: add dc regulator in cpufreq driver
authorBai Ping <b51503@freescale.com>
Thu, 16 Jul 2015 11:08:28 +0000 (19:08 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:10 +0000 (14:49 -0500)
In some i.MX6 board (i.MX6UL EVK), it will have a additional
GPIO controlled DC-DC regulator. we need to change this regulator's
voltage According the maximum frequency that CPU can run at.

At present, we only need to set the voltage to minimum one, we need
to set the voltage to the maximum before suspend, resume back to the
minimum voltage after suspend.

Signed-off-by: Bai Ping <b51503@freescale.com>
(cherry picked from commit 31f0773ee7d6ba5715486a221857f2ceccb434b4)

drivers/cpufreq/imx6q-cpufreq.c

index 96e493a..09d8974 100644 (file)
 
 #define PU_SOC_VOLTAGE_NORMAL  1250000
 #define PU_SOC_VOLTAGE_HIGH    1275000
+#define DC_VOLTAGE_MIN         1300000
+#define DC_VOLTAGE_MAX         1400000
 #define FREQ_1P2_GHZ           1200000000
 #define FREQ_396_MHZ           396000
 
 static struct regulator *arm_reg;
 static struct regulator *pu_reg;
 static struct regulator *soc_reg;
+static struct regulator *dc_reg;
 
 static struct clk *arm_clk;
 static struct clk *pll1_sys_clk;
@@ -230,9 +233,15 @@ static int imx6_cpufreq_pm_notify(struct notifier_block *nb,
        case PM_SUSPEND_PREPARE:
                cpufreq_policy_min_pre_suspend = data->user_policy.min;
                data->user_policy.min = data->user_policy.max;
+
+               if (!IS_ERR(dc_reg))
+                       regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MAX, 0);
                break;
        case PM_POST_SUSPEND:
                data->user_policy.min = cpufreq_policy_min_pre_suspend;
+
+               if (!IS_ERR(dc_reg))
+                       regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MIN, 0);
                break;
        default:
                break;
@@ -304,6 +313,10 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
                goto put_node;
        }
 
+       dc_reg = devm_regulator_get_optional(cpu_dev, "dc");
+       if (!IS_ERR(dc_reg))
+               regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MIN, 0);
+
        /*
         * soc_reg sync  with arm_reg if arm shares the same regulator
         * with soc. Otherwise, regulator common framework will refuse to update