struct kbase_device *kbdev = dev_get_drvdata(dev);
struct dev_pm_opp *opp;
unsigned long freq = 0;
+ unsigned long old_freq = kbdev->current_freq;
unsigned long voltage;
int err;
/*
* Only update if there is a change of frequency
*/
- if (kbdev->current_freq == freq) {
+ if (old_freq == freq) {
*target_freq = freq;
+#ifdef CONFIG_REGULATOR
+ if (kbdev->current_voltage == voltage)
+ return 0;
+ err = regulator_set_voltage(kbdev->regulator, voltage, voltage);
+ if (err) {
+ dev_err(dev, "Failed to set voltage (%d)\n", err);
+ return err;
+ }
+#else
return 0;
+#endif
}
#ifdef CONFIG_REGULATOR
- if (kbdev->regulator && kbdev->current_voltage != voltage
- && kbdev->current_freq < freq) {
+ if (kbdev->regulator && kbdev->current_voltage != voltage &&
+ old_freq < freq) {
err = regulator_set_voltage(kbdev->regulator, voltage, voltage);
if (err) {
dev_err(dev, "Failed to increase voltage (%d)\n", err);
freq, *target_freq);
return err;
}
+ *target_freq = freq;
+ kbdev->current_freq = freq;
#ifdef CONFIG_REGULATOR
- if (kbdev->regulator && kbdev->current_voltage != voltage
- && kbdev->current_freq > freq) {
+ if (kbdev->regulator && kbdev->current_voltage != voltage &&
+ old_freq > freq) {
err = regulator_set_voltage(kbdev->regulator, voltage, voltage);
if (err) {
dev_err(dev, "Failed to decrease voltage (%d)\n", err);
}
#endif
- *target_freq = freq;
kbdev->current_voltage = voltage;
- kbdev->current_freq = freq;
kbase_tlstream_aux_devfreq_target((u64)freq);
return -ENODEV;
kbdev->current_freq = clk_get_rate(kbdev->clock);
+#ifdef CONFIG_REGULATOR
+ if (kbdev->regulator)
+ kbdev->current_voltage =
+ regulator_get_voltage(kbdev->regulator);
+#endif
dp = &kbdev->devfreq_profile;