MLK-11252-02 cpufreq: imx: add dc regulator in cpufreq driver

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)
This commit is contained in:
Leonard Crestez 2018-02-26 16:29:32 +02:00 committed by Jason Liu
parent 39652a1aca
commit c6d5e42baa

View file

@ -20,12 +20,15 @@
#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;
@ -225,6 +228,19 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
static int imx6_cpufreq_pm_notify(struct notifier_block *nb,
unsigned long event, void *dummy)
{
switch (event) {
case PM_SUSPEND_PREPARE:
if (!IS_ERR(dc_reg))
regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MAX, 0);
break;
case PM_POST_SUSPEND:
if (!IS_ERR(dc_reg))
regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MIN, 0);
break;
default:
break;
}
return NOTIFY_OK;
}
@ -297,6 +313,10 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
goto put_reg;
}
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