Lines Matching refs:opp
22 #include "opp.h"
25 * The root of the list of all opp-tables. All opp_table structures branch off
30 /* Lock to allow exclusive modification to the device and opp lists */
93 * dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp
94 * @opp: opp for which voltage has to be returned for
96 * Return: voltage in micro volt corresponding to the opp, else
101 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
103 if (IS_ERR_OR_NULL(opp)) {
108 return opp->supplies[0].u_volt;
113 * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp
114 * @opp: opp for which frequency has to be returned for
116 * Return: frequency in hertz corresponding to the opp, else
119 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
121 if (IS_ERR_OR_NULL(opp)) {
126 return opp->rate;
131 * dev_pm_opp_get_level() - Gets the level corresponding to an available opp
132 * @opp: opp for which level value has to be returned for
134 * Return: level read from device tree corresponding to the opp, else
137 unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
139 if (IS_ERR_OR_NULL(opp) || !opp->available) {
144 return opp->level;
149 * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
150 * @opp: opp for which turbo mode is being verified
156 * Return: true if opp is turbo opp, else false.
158 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
160 if (IS_ERR_OR_NULL(opp) || !opp->available) {
165 return opp->turbo;
201 struct dev_pm_opp *opp;
230 list_for_each_entry(opp, &opp_table->opp_list, node) {
231 if (!opp->available)
234 if (opp->supplies[i].u_volt_min < uV[i].min)
235 uV[i].min = opp->supplies[i].u_volt_min;
236 if (opp->supplies[i].u_volt_max > uV[i].max)
237 uV[i].max = opp->supplies[i].u_volt_max;
278 * dev_pm_opp_get_suspend_opp_freq() - Get frequency of suspend opp in Hz
304 struct dev_pm_opp *opp;
309 list_for_each_entry(opp, &opp_table->opp_list, node) {
310 if (opp->available)
320 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp table
350 * @available: true/false - match for available opp
352 * Return: Searches for exact match in the opp table and returns pointer to the
353 * matching opp if found, else returns ERR_PTR in case of error and should
363 * This provides a mechanism to enable an opp which is not available currently
374 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
389 opp = temp_opp;
392 dev_pm_opp_get(opp);
400 return opp;
409 * Return: Searches for exact match in the opp table and returns pointer to the
410 * matching opp if found, else returns ERR_PTR in case of error and should
423 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
437 opp = temp_opp;
440 dev_pm_opp_get(opp);
448 return opp;
455 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
461 opp = temp_opp;
462 *freq = opp->rate;
465 dev_pm_opp_get(opp);
472 return opp;
483 * Return: matching *opp and refreshes *freq accordingly, else returns
497 struct dev_pm_opp *opp;
508 opp = _find_freq_ceil(opp_table, freq);
512 return opp;
524 * Return: matching *opp and refreshes *freq accordingly, else returns
538 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
557 opp = temp_opp;
562 if (!IS_ERR(opp))
563 dev_pm_opp_get(opp);
567 if (!IS_ERR(opp))
568 *freq = opp->rate;
570 return opp;
582 * Return: matching *opp, else returns ERR_PTR in case of error which should be
595 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
613 opp = temp_opp;
618 if (!IS_ERR(opp))
619 dev_pm_opp_get(opp);
624 return opp;
727 struct dev_pm_opp *opp, struct device *dev, bool remove)
740 avg = opp->bandwidth[i].avg;
741 peak = opp->bandwidth[i].peak;
783 struct dev_pm_opp *opp, int i)
785 unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
803 struct dev_pm_opp *opp, bool up)
814 return _set_required_opp(dev, dev, opp, 0);
827 ret = _set_required_opp(dev, genpd_virt_devs[i], opp, i);
833 ret = _set_required_opp(dev, genpd_virt_devs[i], opp, i);
845 * dev_pm_opp_set_bw() - sets bandwidth levels corresponding to an opp
847 * @opp: opp based on which the bandwidth levels are to be configured
854 int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp)
861 dev_err(dev, "%s: device opp table doesn't exist\n", __func__);
865 if (opp)
866 ret = _set_opp_bw(opp_table, opp, dev, false);
911 * provided by the opp, should have already rounded to the target OPP's
918 struct dev_pm_opp *old_opp, *opp;
924 dev_err(dev, "%s: device opp doesn't exist\n", __func__);
975 opp = _find_freq_ceil(opp_table, &temp_freq);
976 if (IS_ERR(opp)) {
977 ret = PTR_ERR(opp);
988 ret = _set_required_opps(dev, opp_table, opp, true);
996 opp->supplies);
1000 opp->supplies);
1008 ret = _set_required_opps(dev, opp_table, opp, false);
1014 ret = _set_opp_bw(opp_table, opp, dev, false);
1020 dev_pm_opp_put(opp);
1048 /* Initialize opp-dev */
1230 void _opp_free(struct dev_pm_opp *opp)
1232 kfree(opp);
1235 static void _opp_kref_release(struct dev_pm_opp *opp,
1242 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp);
1243 _of_opp_free_required_opps(opp_table, opp);
1244 opp_debug_remove_one(opp);
1245 list_del(&opp->node);
1246 kfree(opp);
1251 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref);
1252 struct opp_table *opp_table = opp->opp_table;
1254 _opp_kref_release(opp, opp_table);
1259 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref);
1260 struct opp_table *opp_table = opp->opp_table;
1262 _opp_kref_release(opp, opp_table);
1266 void dev_pm_opp_get(struct dev_pm_opp *opp)
1268 kref_get(&opp->kref);
1271 void dev_pm_opp_put(struct dev_pm_opp *opp)
1273 kref_put_mutex(&opp->kref, _opp_kref_release_locked,
1274 &opp->opp_table->lock);
1278 static void dev_pm_opp_put_unlocked(struct dev_pm_opp *opp)
1280 kref_put(&opp->kref, _opp_kref_release_unlocked);
1288 * This function removes an opp from the opp table.
1292 struct dev_pm_opp *opp;
1302 list_for_each_entry(opp, &opp_table->opp_list, node) {
1303 if (opp->rate == freq) {
1312 dev_pm_opp_put(opp);
1328 struct dev_pm_opp *opp, *tmp;
1341 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
1342 if (!opp->dynamic)
1343 dev_pm_opp_put_unlocked(opp);
1356 * This function removes all dynamically created OPPs from the opp table.
1361 struct dev_pm_opp *opp, *temp;
1369 list_for_each_entry_safe(opp, temp, &opp_table->opp_list, node) {
1370 if (opp->dynamic) {
1371 dev_pm_opp_put_unlocked(opp);
1388 struct dev_pm_opp *opp;
1393 supply_size = sizeof(*opp->supplies) * supply_count;
1394 icc_size = sizeof(*opp->bandwidth) * table->path_count;
1397 opp = kzalloc(sizeof(*opp) + supply_size + icc_size, GFP_KERNEL);
1399 if (!opp)
1403 opp->supplies = (struct dev_pm_opp_supply *)(opp + 1);
1405 opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->supplies + supply_count);
1406 INIT_LIST_HEAD(&opp->node);
1408 return opp;
1411 static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
1424 opp->supplies[i].u_volt_min,
1425 opp->supplies[i].u_volt_max)) {
1427 __func__, opp->supplies[i].u_volt_min,
1428 opp->supplies[i].u_volt_max);
1452 struct dev_pm_opp *opp;
1463 list_for_each_entry(opp, &opp_table->opp_list, node) {
1464 opp_cmp = _opp_compare_key(new_opp, opp);
1466 *head = &opp->node;
1475 __func__, opp->rate, opp->supplies[0].u_volt,
1476 opp->available, new_opp->rate,
1480 return opp->available &&
1481 new_opp->supplies[0].u_volt == opp->supplies[0].u_volt ? -EBUSY : -EEXIST;
1539 * This function adds an opp definition to the opp table and returns status.
1540 * The opp is made available by default and it can be controlled using
1548 * Duplicate OPPs (both freq and volt are same) and opp->available
1550 * Duplicate OPPs (both freq and volt are same) and !opp->available
1564 /* populate the opp table */
1602 * OPPs, which are available for those versions, based on its 'opp-supported-hw'
1662 * which the extension will apply are opp-microvolt and opp-microamp. OPP core
2049 dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n",
2122 struct dev_pm_opp *opp;
2149 list_for_each_entry(opp, &src_table->opp_list, node) {
2150 if (opp->pstate == pstate) {
2151 dest_pstate = opp->required_opps[i]->pstate;
2171 * This function adds an opp definition to the opp table and returns status.
2172 * The opp is made available by default and it can be controlled using
2177 * Duplicate OPPs (both freq and volt are same) and opp->available
2179 * Duplicate OPPs (both freq and volt are same) and !opp->available
2203 * _opp_set_availability() - helper to set the availability of an opp
2206 * @availability_req: availability status requested for this opp
2219 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
2235 opp = tmp_opp;
2240 if (IS_ERR(opp)) {
2241 r = PTR_ERR(opp);
2246 if (opp->available == availability_req)
2249 opp->available = availability_req;
2251 dev_pm_opp_get(opp);
2257 opp);
2260 OPP_EVENT_DISABLE, opp);
2262 dev_pm_opp_put(opp);
2290 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
2306 opp = tmp_opp;
2311 if (IS_ERR(opp)) {
2312 r = PTR_ERR(opp);
2317 if (opp->supplies->u_volt == u_volt)
2320 opp->supplies->u_volt = u_volt;
2321 opp->supplies->u_volt_min = u_volt_min;
2322 opp->supplies->u_volt_max = u_volt_max;
2324 dev_pm_opp_get(opp);
2329 opp);
2331 dev_pm_opp_put(opp);
2347 * Enables a provided opp. If the operation is valid, this returns 0, else the
2366 * Disables a provided opp. If the operation is valid, this returns