/** * partition_enable_opps() - disable all opps above a given state * @dfc: Pointer to devfreq we are operating on * @cdev_state: cooling device state we're setting * * Go through the OPPs of the device, enabling all OPPs until * @cdev_state and disabling those frequencies above it. */ static int partition_enable_opps(struct devfreq_cooling_device *dfc, unsigned long cdev_state) { int i; struct device *dev = dfc->devfreq->dev.parent; for (i = 0; i < dfc->freq_table_size; i++) { struct dev_pm_opp *opp; int ret = 0; unsigned int freq = dfc->freq_table[i]; bool want_enable = i >= cdev_state ? true : false; opp = dev_pm_opp_find_freq_exact(dev, freq, !want_enable); if (PTR_ERR(opp) == -ERANGE) continue; else if (IS_ERR(opp)) return PTR_ERR(opp); dev_pm_opp_put(opp); if (want_enable) ret = dev_pm_opp_enable(dev, freq); else ret = dev_pm_opp_disable(dev, freq); if (ret) return ret; } return 0; }
static int __init beagle_opp_init(void) { int r = 0; if (!machine_is_omap3_beagle()) return 0; /* Initialize the omap3 opp table if not already created. */ r = omap3_opp_init(); if (r < 0 && (r != -EEXIST)) { pr_err("%s: opp default init failed\n", __func__); return r; } /* Custom OPP enabled for all xM versions */ if (cpu_is_omap3630()) { struct device *mpu_dev, *iva_dev; mpu_dev = get_cpu_device(0); iva_dev = omap_device_get_by_hwmod_name("iva"); if (!mpu_dev || IS_ERR(iva_dev)) { pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n", __func__, mpu_dev, iva_dev); return -ENODEV; } /* Enable MPU 1GHz and lower opps */ r = dev_pm_opp_enable(mpu_dev, 800000000); /* TODO: MPU 1GHz needs SR and ABB */ /* Enable IVA 800MHz and lower opps */ r |= dev_pm_opp_enable(iva_dev, 660000000); /* TODO: DSP 800MHz needs SR and ABB */ if (r) { pr_err("%s: failed to enable higher opp %d\n", __func__, r); /* * Cleanup - disable the higher freqs - we dont care * about the results */ dev_pm_opp_disable(mpu_dev, 800000000); dev_pm_opp_disable(iva_dev, 660000000); } } return 0; }