MALI: rockchip: Ensure that set voltage when update devfreq for the first time

Sometimes the regulator is shared between several devices, if target rate
and target voltage are equal to initial rate and iniital voltage , the
min_uV and max_uV of regulator will be always equal to zero, other devices
may set a low voltage.

Change-Id: Ibf82f335ce0739776286e3733be5415f84bf035b
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
This commit is contained in:
Finley Xiao
2018-05-07 16:17:29 +08:00
committed by Tao Huang
parent 211ccb244c
commit 5d88f40f5a
5 changed files with 20 additions and 12 deletions

View File

@@ -349,11 +349,6 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
kbdev->current_freq = clk_get_rate(kbdev->clock);
kbdev->current_nominal_freq = kbdev->current_freq;
#ifdef CONFIG_REGULATOR
if (kbdev->regulator)
kbdev->current_voltage =
regulator_get_voltage(kbdev->regulator);
#endif
dp = &kbdev->devfreq_profile;

View File

@@ -329,11 +329,6 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
kbdev->current_freq = clk_get_rate(kbdev->clock);
kbdev->current_nominal_freq = kbdev->current_freq;
#ifdef CONFIG_REGULATOR
if (kbdev->regulator)
kbdev->current_voltage =
regulator_get_voltage(kbdev->regulator);
#endif
dp = &kbdev->devfreq_profile;

View File

@@ -237,8 +237,6 @@ int mali_devfreq_init(struct mali_device *mdev)
return -ENODEV;
mdev->current_freq = clk_get_rate(mdev->clock);
if (mdev->regulator)
mdev->current_voltage = regulator_get_voltage(mdev->regulator);
dp = &mdev->devfreq_profile;

View File

@@ -108,6 +108,16 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags)
*/
if (kbdev->current_nominal_freq == nominal_freq) {
*target_freq = nominal_freq;
#ifdef CONFIG_REGULATOR
if (kbdev->current_voltage == voltage)
return 0;
err = regulator_set_voltage(kbdev->regulator, voltage, INT_MAX);
if (err) {
dev_err(dev, "Failed to set voltage (%d)\n", err);
return err;
}
kbdev->current_voltage = voltage;
#endif
return 0;
}

View File

@@ -73,6 +73,16 @@ kbase_devfreq_target(struct device *dev, unsigned long *target_freq, u32 flags)
*/
if (kbdev->current_freq == freq) {
*target_freq = freq;
#ifdef CONFIG_REGULATOR
if (kbdev->current_voltage == voltage)
return 0;
err = regulator_set_voltage(kbdev->regulator, voltage, INT_MAX);
if (err) {
dev_err(dev, "Failed to set voltage (%d)\n", err);
return err;
}
kbdev->current_voltage = voltage;
#endif
return 0;
}