Lines Matching full:opp

3  * Generic OPP Interface
22 #include "opp.h"
25 * The root of the list of all opp-tables. All opp_table structures branch off
31 /* OPP tables with uninitialized required OPPs */
34 /* Lock to allow exclusive modification to the device and opp lists */
71 * @dev: device pointer used to lookup OPP table
73 * Search OPP table for one containing matching device.
97 * dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp
98 * @opp: opp for which voltage has to be returned for
100 * Return: voltage in micro volt corresponding to the opp, else
105 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) in dev_pm_opp_get_voltage() argument
107 if (IS_ERR_OR_NULL(opp)) { in dev_pm_opp_get_voltage()
112 return opp->supplies[0].u_volt; in dev_pm_opp_get_voltage()
117 * dev_pm_opp_get_freq() - Gets the frequency corresponding to an available opp
118 * @opp: opp for which frequency has to be returned for
120 * Return: frequency in hertz corresponding to the opp, else
123 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) in dev_pm_opp_get_freq() argument
125 if (IS_ERR_OR_NULL(opp)) { in dev_pm_opp_get_freq()
130 return opp->rate; in dev_pm_opp_get_freq()
135 * dev_pm_opp_get_level() - Gets the level corresponding to an available opp
136 * @opp: opp for which level value has to be returned for
138 * Return: level read from device tree corresponding to the opp, else
141 unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) in dev_pm_opp_get_level() argument
143 if (IS_ERR_OR_NULL(opp) || !opp->available) { in dev_pm_opp_get_level()
148 return opp->level; in dev_pm_opp_get_level()
154 * corresponding to an available opp
155 * @opp: opp for which performance state has to be returned for
156 * @index: index of the required opp
159 * required opp, else return 0.
161 unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, in dev_pm_opp_get_required_pstate() argument
164 if (IS_ERR_OR_NULL(opp) || !opp->available || in dev_pm_opp_get_required_pstate()
165 index >= opp->opp_table->required_opp_count) { in dev_pm_opp_get_required_pstate()
171 if (lazy_linking_pending(opp->opp_table)) in dev_pm_opp_get_required_pstate()
174 return opp->required_opps[index]->pstate; in dev_pm_opp_get_required_pstate()
179 * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
180 * @opp: opp for which turbo mode is being verified
186 * Return: true if opp is turbo opp, else false.
188 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) in dev_pm_opp_is_turbo() argument
190 if (IS_ERR_OR_NULL(opp) || !opp->available) { in dev_pm_opp_is_turbo()
195 return opp->turbo; in dev_pm_opp_is_turbo()
231 struct dev_pm_opp *opp; in dev_pm_opp_get_max_volt_latency() local
260 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_get_max_volt_latency()
261 if (!opp->available) in dev_pm_opp_get_max_volt_latency()
264 if (opp->supplies[i].u_volt_min < uV[i].min) in dev_pm_opp_get_max_volt_latency()
265 uV[i].min = opp->supplies[i].u_volt_min; in dev_pm_opp_get_max_volt_latency()
266 if (opp->supplies[i].u_volt_max > uV[i].max) in dev_pm_opp_get_max_volt_latency()
267 uV[i].max = opp->supplies[i].u_volt_max; in dev_pm_opp_get_max_volt_latency()
298 * switch from one OPP to other.
308 * dev_pm_opp_get_suspend_opp_freq() - Get frequency of suspend opp in Hz
311 * Return: This function returns the frequency of the OPP marked as suspend_opp
334 struct dev_pm_opp *opp; in _get_opp_count() local
339 list_for_each_entry(opp, &opp_table->opp_list, node) { in _get_opp_count()
340 if (opp->available) in _get_opp_count()
350 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp table
364 dev_dbg(dev, "%s: OPP table not found (%d)\n", in dev_pm_opp_get_opp_count()
380 * @available: true/false - match for available opp
382 * Return: Searches for exact match in the opp table and returns pointer to the
383 * matching opp if found, else returns ERR_PTR in case of error and should
390 * match is for exact matching frequency and is available in the stored OPP
393 * This provides a mechanism to enable an opp which is not available currently
396 * The callers are required to call dev_pm_opp_put() for the returned OPP after
404 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in dev_pm_opp_find_freq_exact() local
410 dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r); in dev_pm_opp_find_freq_exact()
419 opp = temp_opp; in dev_pm_opp_find_freq_exact()
421 /* Increment the reference count of OPP */ in dev_pm_opp_find_freq_exact()
422 dev_pm_opp_get(opp); in dev_pm_opp_find_freq_exact()
430 return opp; in dev_pm_opp_find_freq_exact()
439 * Return: Searches for exact match in the opp table and returns pointer to the
440 * matching opp if found, else returns ERR_PTR in case of error and should
446 * The callers are required to call dev_pm_opp_put() for the returned OPP after
453 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in dev_pm_opp_find_level_exact() local
459 dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r); in dev_pm_opp_find_level_exact()
467 opp = temp_opp; in dev_pm_opp_find_level_exact()
469 /* Increment the reference count of OPP */ in dev_pm_opp_find_level_exact()
470 dev_pm_opp_get(opp); in dev_pm_opp_find_level_exact()
478 return opp; in dev_pm_opp_find_level_exact()
487 * Return: Searches for rounded up match in the opp table and returns pointer
488 * to the matching opp if found, else returns ERR_PTR in case of error and
494 * The callers are required to call dev_pm_opp_put() for the returned OPP after
501 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in dev_pm_opp_find_level_ceil() local
507 dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r); in dev_pm_opp_find_level_ceil()
515 opp = temp_opp; in dev_pm_opp_find_level_ceil()
516 *level = opp->level; in dev_pm_opp_find_level_ceil()
518 /* Increment the reference count of OPP */ in dev_pm_opp_find_level_ceil()
519 dev_pm_opp_get(opp); in dev_pm_opp_find_level_ceil()
527 return opp; in dev_pm_opp_find_level_ceil()
534 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in _find_freq_ceil() local
540 opp = temp_opp; in _find_freq_ceil()
541 *freq = opp->rate; in _find_freq_ceil()
543 /* Increment the reference count of OPP */ in _find_freq_ceil()
544 dev_pm_opp_get(opp); in _find_freq_ceil()
551 return opp; in _find_freq_ceil()
559 * Search for the matching ceil *available* OPP from a starting freq
562 * Return: matching *opp and refreshes *freq accordingly, else returns
569 * The callers are required to call dev_pm_opp_put() for the returned OPP after
576 struct dev_pm_opp *opp; in dev_pm_opp_find_freq_ceil() local
587 opp = _find_freq_ceil(opp_table, freq); in dev_pm_opp_find_freq_ceil()
591 return opp; in dev_pm_opp_find_freq_ceil()
600 * Search for the matching floor *available* OPP from a starting freq
603 * Return: matching *opp and refreshes *freq accordingly, else returns
610 * The callers are required to call dev_pm_opp_put() for the returned OPP after
617 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in dev_pm_opp_find_freq_floor() local
636 opp = temp_opp; in dev_pm_opp_find_freq_floor()
640 /* Increment the reference count of OPP */ in dev_pm_opp_find_freq_floor()
641 if (!IS_ERR(opp)) in dev_pm_opp_find_freq_floor()
642 dev_pm_opp_get(opp); in dev_pm_opp_find_freq_floor()
646 if (!IS_ERR(opp)) in dev_pm_opp_find_freq_floor()
647 *freq = opp->rate; in dev_pm_opp_find_freq_floor()
649 return opp; in dev_pm_opp_find_freq_floor()
654 * dev_pm_opp_find_freq_ceil_by_volt() - Find OPP with highest frequency for
659 * Search for OPP with highest (ceil) frequency and has voltage <= u_volt.
661 * Return: matching *opp, else returns ERR_PTR in case of error which should be
667 * The callers are required to call dev_pm_opp_put() for the returned OPP after
674 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); in dev_pm_opp_find_freq_ceil_by_volt() local
692 opp = temp_opp; in dev_pm_opp_find_freq_ceil_by_volt()
696 /* Increment the reference count of OPP */ in dev_pm_opp_find_freq_ceil_by_volt()
697 if (!IS_ERR(opp)) in dev_pm_opp_find_freq_ceil_by_volt()
698 dev_pm_opp_get(opp); in dev_pm_opp_find_freq_ceil_by_volt()
703 return opp; in dev_pm_opp_find_freq_ceil_by_volt()
752 struct dev_pm_opp *opp, in _generic_set_opp_regulator() argument
768 ret = _set_opp_voltage(dev, reg, opp->supplies); in _generic_set_opp_regulator()
780 ret = _set_opp_voltage(dev, reg, opp->supplies); in _generic_set_opp_regulator()
809 struct dev_pm_opp *opp, struct device *dev) in _set_opp_bw() argument
818 if (!opp) { in _set_opp_bw()
822 avg = opp->bandwidth[i].avg; in _set_opp_bw()
823 peak = opp->bandwidth[i].peak; in _set_opp_bw()
828 opp ? "set" : "remove", i, ret); in _set_opp_bw()
837 struct device *dev, struct dev_pm_opp *opp, in _set_opp_custom() argument
851 memcpy(data->new_opp.supplies, opp->supplies, size); in _set_opp_custom()
867 struct dev_pm_opp *opp, int i) in _set_required_opp() argument
869 unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0; in _set_required_opp()
887 struct dev_pm_opp *opp, bool up) in _set_required_opps() argument
902 * don't know much about other use cases. Error out if the required OPP in _set_required_opps()
912 return _set_required_opp(dev, dev, opp, 0); in _set_required_opps()
925 ret = _set_required_opp(dev, genpd_virt_devs[i], opp, i); in _set_required_opps()
931 ret = _set_required_opp(dev, genpd_virt_devs[i], opp, i); in _set_required_opps()
944 struct dev_pm_opp *opp = ERR_PTR(-ENODEV); in _find_current_opp() local
949 opp = _find_freq_ceil(opp_table, &freq); in _find_current_opp()
953 * Unable to find the current OPP ? Pick the first from the list since in _find_current_opp()
957 if (IS_ERR(opp)) { in _find_current_opp()
959 opp = list_first_entry(&opp_table->opp_list, struct dev_pm_opp, node); in _find_current_opp()
960 dev_pm_opp_get(opp); in _find_current_opp()
964 opp_table->current_opp = opp; in _find_current_opp()
976 * have OPP table for the device, while others don't and in _disable_opp_table()
996 struct dev_pm_opp *opp, unsigned long freq) in _set_opp() argument
1001 if (unlikely(!opp)) in _set_opp()
1004 /* Find the currently set OPP if we don't know already */ in _set_opp()
1011 if (old_opp == opp && opp_table->current_rate == freq && in _set_opp()
1017 dev_dbg(dev, "%s: switching OPP: Freq %lu -> %lu Hz, Level %u -> %u, Bw %u -> %u\n", in _set_opp()
1019 opp->level, old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, in _set_opp()
1020 opp->bandwidth ? opp->bandwidth[0].peak : 0); in _set_opp()
1022 scaling_down = _opp_compare_key(old_opp, opp); in _set_opp()
1028 ret = _set_required_opps(dev, opp_table, opp, true); in _set_opp()
1034 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1042 ret = _set_opp_custom(opp_table, dev, opp, freq); in _set_opp()
1044 ret = _generic_set_opp_regulator(opp_table, dev, opp, freq, in _set_opp()
1056 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1062 ret = _set_required_opps(dev, opp_table, opp, false); in _set_opp()
1073 dev_pm_opp_get(opp); in _set_opp()
1074 opp_table->current_opp = opp; in _set_opp()
1081 * dev_pm_opp_set_rate() - Configure new OPP based on frequency
1085 * This configures the power-supplies to the levels specified by the OPP
1088 * provided by the opp, should have already rounded to the target OPP's
1095 struct dev_pm_opp *opp = NULL; in dev_pm_opp_set_rate() local
1100 dev_err(dev, "%s: device's opp table doesn't exist\n", __func__); in dev_pm_opp_set_rate()
1106 * For IO devices which require an OPP on some platforms/SoCs in dev_pm_opp_set_rate()
1108 * we look for empty OPP tables with just a clock handle and in dev_pm_opp_set_rate()
1123 * frequencies than the OPP table, don't update the frequency we in dev_pm_opp_set_rate()
1127 opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
1128 if (IS_ERR(opp)) { in dev_pm_opp_set_rate()
1129 ret = PTR_ERR(opp); in dev_pm_opp_set_rate()
1130 dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n", in dev_pm_opp_set_rate()
1136 ret = _set_opp(dev, opp_table, opp, freq); in dev_pm_opp_set_rate()
1139 dev_pm_opp_put(opp); in dev_pm_opp_set_rate()
1147 * dev_pm_opp_set_opp() - Configure device for OPP
1149 * @opp: OPP to set to
1151 * This configures the device based on the properties of the OPP passed to this
1156 int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) in dev_pm_opp_set_opp() argument
1163 dev_err(dev, "%s: device opp doesn't exist\n", __func__); in dev_pm_opp_set_opp()
1167 ret = _set_opp(dev, opp_table, opp, opp ? opp->rate : 0); in dev_pm_opp_set_opp()
1174 /* OPP-dev Helpers */
1192 /* Initialize opp-dev */ in _add_opp_dev()
1212 * Allocate a new OPP table. In the infrequent case where a new in _allocate_opp_table()
1295 * We need to make sure that the OPP table for a device doesn't get added twice,
1303 * indirect users of OPP core.
1307 * of adding an OPP table and others should wait for it to finish.
1322 * The opp_tables list or an OPP table's dev_list is getting updated by in _add_opp_table_indexed()
1400 * The OPP table is getting removed, drop the performance state in _opp_table_kref_release()
1421 void _opp_free(struct dev_pm_opp *opp) in _opp_free() argument
1423 kfree(opp); in _opp_free()
1428 struct dev_pm_opp *opp = container_of(kref, struct dev_pm_opp, kref); in _opp_kref_release() local
1429 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release()
1431 list_del(&opp->node); in _opp_kref_release()
1438 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp); in _opp_kref_release()
1439 _of_opp_free_required_opps(opp_table, opp); in _opp_kref_release()
1440 opp_debug_remove_one(opp); in _opp_kref_release()
1441 kfree(opp); in _opp_kref_release()
1444 void dev_pm_opp_get(struct dev_pm_opp *opp) in dev_pm_opp_get() argument
1446 kref_get(&opp->kref); in dev_pm_opp_get()
1449 void dev_pm_opp_put(struct dev_pm_opp *opp) in dev_pm_opp_put() argument
1451 kref_put_mutex(&opp->kref, _opp_kref_release, &opp->opp_table->lock); in dev_pm_opp_put()
1456 * dev_pm_opp_remove() - Remove an OPP from OPP table
1458 * @freq: OPP to remove with matching 'freq'
1460 * This function removes an opp from the opp table.
1464 struct dev_pm_opp *opp; in dev_pm_opp_remove() local
1474 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_remove()
1475 if (opp->rate == freq) { in dev_pm_opp_remove()
1484 dev_pm_opp_put(opp); in dev_pm_opp_remove()
1489 dev_warn(dev, "%s: Couldn't find OPP with freq: %lu\n", in dev_pm_opp_remove()
1501 struct dev_pm_opp *opp = NULL, *temp; in _opp_get_next() local
1506 * Refcount must be dropped only once for each OPP by OPP core, in _opp_get_next()
1510 opp = temp; in _opp_get_next()
1516 return opp; in _opp_get_next()
1526 struct dev_pm_opp *opp; in _opp_remove_all() local
1528 while ((opp = _opp_get_next(opp_table, dynamic))) { in _opp_remove_all()
1529 opp->removed = true; in _opp_remove_all()
1530 dev_pm_opp_put(opp); in _opp_remove_all()
1562 * This function removes all dynamically created OPPs from the opp table.
1581 struct dev_pm_opp *opp; in _opp_allocate() local
1586 supply_size = sizeof(*opp->supplies) * supply_count; in _opp_allocate()
1587 icc_size = sizeof(*opp->bandwidth) * table->path_count; in _opp_allocate()
1589 /* allocate new OPP node and supplies structures */ in _opp_allocate()
1590 opp = kzalloc(sizeof(*opp) + supply_size + icc_size, GFP_KERNEL); in _opp_allocate()
1592 if (!opp) in _opp_allocate()
1595 /* Put the supplies at the end of the OPP structure as an empty array */ in _opp_allocate()
1596 opp->supplies = (struct dev_pm_opp_supply *)(opp + 1); in _opp_allocate()
1598 opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->supplies + supply_count); in _opp_allocate()
1599 INIT_LIST_HEAD(&opp->node); in _opp_allocate()
1601 return opp; in _opp_allocate()
1604 static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, in _opp_supported_by_regulators() argument
1617 opp->supplies[i].u_volt_min, in _opp_supported_by_regulators()
1618 opp->supplies[i].u_volt_max)) { in _opp_supported_by_regulators()
1619 pr_warn("%s: OPP minuV: %lu maxuV: %lu, not supported by regulator\n", in _opp_supported_by_regulators()
1620 __func__, opp->supplies[i].u_volt_min, in _opp_supported_by_regulators()
1621 opp->supplies[i].u_volt_max); in _opp_supported_by_regulators()
1645 struct dev_pm_opp *opp; in _opp_is_duplicate() local
1649 * Insert new OPP in order of increasing frequency and discard if in _opp_is_duplicate()
1656 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_is_duplicate()
1657 opp_cmp = _opp_compare_key(new_opp, opp); in _opp_is_duplicate()
1659 *head = &opp->node; in _opp_is_duplicate()
1668 __func__, opp->rate, opp->supplies[0].u_volt, in _opp_is_duplicate()
1669 opp->available, new_opp->rate, in _opp_is_duplicate()
1673 return opp->available && in _opp_is_duplicate()
1674 new_opp->supplies[0].u_volt == opp->supplies[0].u_volt ? -EBUSY : -EEXIST; in _opp_is_duplicate()
1680 void _required_opps_available(struct dev_pm_opp *opp, int count) in _required_opps_available() argument
1685 if (opp->required_opps[i]->available) in _required_opps_available()
1688 opp->available = false; in _required_opps_available()
1689 pr_warn("%s: OPP not supported by required OPP %pOF (%lu)\n", in _required_opps_available()
1690 __func__, opp->required_opps[i]->np, opp->rate); in _required_opps_available()
1698 * -EBUSY: For OPP with same freq/volt and is available. The callers of
1701 * kernel try to initialize the OPP table.
1702 * -EEXIST: For OPP with same freq but different volt or is unavailable. This
1730 dev_warn(dev, "%s: OPP not supported by regulators (%lu)\n", in _opp_add()
1744 * _opp_add_v1() - Allocate a OPP based on v1 bindings.
1745 * @opp_table: OPP table
1747 * @freq: Frequency in Hz for this OPP
1748 * @u_volt: Voltage in uVolts for this OPP
1751 * This function adds an opp definition to the opp table and returns status.
1752 * The opp is made available by default and it can be controlled using
1760 * Duplicate OPPs (both freq and volt are same) and opp->available
1762 * Duplicate OPPs (both freq and volt are same) and !opp->available
1776 /* populate the opp table */ in _opp_add_v1()
1813 * specify the hierarchy of versions it supports. OPP layer will then enable
1814 * OPPs, which are available for those versions, based on its 'opp-supported-hw'
1829 /* Another CPU that shares the OPP table has set the property ? */ in dev_pm_opp_set_supported_hw()
1848 * @opp_table: OPP table returned by dev_pm_opp_set_supported_hw().
1903 * which the extension will apply are opp-microvolt and opp-microamp. OPP core
1917 /* Another CPU that shares the OPP table has set the property ? */ in dev_pm_opp_set_prop_name()
1933 * @opp_table: OPP table returned by dev_pm_opp_set_prop_name().
1957 * In order to support OPP switching, OPP layer needs to know the name of the
1982 /* Another CPU that shares the OPP table has set the regulators ? */ in dev_pm_opp_set_regulators()
2041 * @opp_table: OPP table returned from dev_pm_opp_set_regulators().
2115 * In order to support OPP switching, OPP layer needs to get pointer to the
2118 * available, the OPP core needs to know the exact name of the clk to use.
2165 * @opp_table: OPP table returned from dev_pm_opp_set_clkname().
2207 * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper
2209 * @set_opp: Custom set OPP helper.
2212 * regulators per device), instead of the generic OPP set rate helper.
2235 /* Another CPU that shares the OPP table has set the helper ? */ in dev_pm_opp_register_set_opp_helper()
2261 * @opp_table: OPP table returned from dev_pm_opp_register_set_opp_helper().
2287 * devm_pm_opp_register_set_opp_helper() - Register custom set OPP helper
2289 * @set_opp: Custom set OPP helper.
2337 * and are required by the OPP core to set the performance state of the genpd.
2345 * Otherwise the original device structure will be used instead by the OPP core.
2366 * If the genpd's OPP table isn't already initialized, parsing of the in dev_pm_opp_attach_genpd()
2367 * required-opps fail for dev. We should retry this after genpd's OPP in dev_pm_opp_attach_genpd()
2385 dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n", in dev_pm_opp_attach_genpd()
2422 * @opp_table: OPP table returned by dev_pm_opp_attach_genpd().
2425 * OPP table.
2475 * dev_pm_opp_xlate_required_opp() - Find required OPP for @src_table OPP.
2476 * @src_table: OPP table which has @dst_table as one of its required OPP table.
2477 * @dst_table: Required OPP table of the @src_table.
2478 * @src_opp: OPP from the @src_table.
2480 * This function returns the OPP (present in @dst_table) pointed out by the
2483 * The callers are required to call dev_pm_opp_put() for the returned OPP after
2492 struct dev_pm_opp *opp, *dest_opp = ERR_PTR(-ENODEV); in dev_pm_opp_xlate_required_opp() local
2507 list_for_each_entry(opp, &src_table->opp_list, node) { in dev_pm_opp_xlate_required_opp()
2508 if (opp == src_opp) { in dev_pm_opp_xlate_required_opp()
2509 dest_opp = opp->required_opps[i]; in dev_pm_opp_xlate_required_opp()
2521 pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, in dev_pm_opp_xlate_required_opp()
2530 * dev_pm_opp_xlate_performance_state() - Find required OPP's pstate for src_table.
2531 * @src_table: OPP table which has dst_table as one of its required OPP table.
2532 * @dst_table: Required OPP table of the src_table.
2535 * This Returns pstate of the OPP (present in @dst_table) pointed out by the
2536 * "required-opps" property of the OPP (present in @src_table) which has
2546 struct dev_pm_opp *opp; in dev_pm_opp_xlate_performance_state() local
2570 pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", in dev_pm_opp_xlate_performance_state()
2577 list_for_each_entry(opp, &src_table->opp_list, node) { in dev_pm_opp_xlate_performance_state()
2578 if (opp->pstate == pstate) { in dev_pm_opp_xlate_performance_state()
2579 dest_pstate = opp->required_opps[i]->pstate; in dev_pm_opp_xlate_performance_state()
2584 pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, src_table, in dev_pm_opp_xlate_performance_state()
2594 * dev_pm_opp_add() - Add an OPP table from a table definitions
2596 * @freq: Frequency in Hz for this OPP
2597 * @u_volt: Voltage in uVolts for this OPP
2599 * This function adds an opp definition to the opp table and returns status.
2600 * The opp is made available by default and it can be controlled using
2605 * Duplicate OPPs (both freq and volt are same) and opp->available
2607 * Duplicate OPPs (both freq and volt are same) and !opp->available
2631 * _opp_set_availability() - helper to set the availability of an opp
2633 * @freq: OPP frequency to modify availability
2634 * @availability_req: availability status requested for this opp
2636 * Set the availability of an OPP, opp_{enable,disable} share a common logic
2647 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); in _opp_set_availability() local
2654 dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); in _opp_set_availability()
2663 opp = tmp_opp; in _opp_set_availability()
2668 if (IS_ERR(opp)) { in _opp_set_availability()
2669 r = PTR_ERR(opp); in _opp_set_availability()
2674 if (opp->available == availability_req) in _opp_set_availability()
2677 opp->available = availability_req; in _opp_set_availability()
2679 dev_pm_opp_get(opp); in _opp_set_availability()
2682 /* Notify the change of the OPP availability */ in _opp_set_availability()
2685 opp); in _opp_set_availability()
2688 OPP_EVENT_DISABLE, opp); in _opp_set_availability()
2690 dev_pm_opp_put(opp); in _opp_set_availability()
2701 * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP
2703 * @freq: OPP frequency to adjust voltage of
2704 * @u_volt: new OPP target voltage
2705 * @u_volt_min: new OPP min voltage
2706 * @u_volt_max: new OPP max voltage
2718 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); in dev_pm_opp_adjust_voltage() local
2725 dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); in dev_pm_opp_adjust_voltage()
2734 opp = tmp_opp; in dev_pm_opp_adjust_voltage()
2739 if (IS_ERR(opp)) { in dev_pm_opp_adjust_voltage()
2740 r = PTR_ERR(opp); in dev_pm_opp_adjust_voltage()
2745 if (opp->supplies->u_volt == u_volt) in dev_pm_opp_adjust_voltage()
2748 opp->supplies->u_volt = u_volt; in dev_pm_opp_adjust_voltage()
2749 opp->supplies->u_volt_min = u_volt_min; in dev_pm_opp_adjust_voltage()
2750 opp->supplies->u_volt_max = u_volt_max; in dev_pm_opp_adjust_voltage()
2752 dev_pm_opp_get(opp); in dev_pm_opp_adjust_voltage()
2755 /* Notify the voltage change of the OPP */ in dev_pm_opp_adjust_voltage()
2757 opp); in dev_pm_opp_adjust_voltage()
2759 dev_pm_opp_put(opp); in dev_pm_opp_adjust_voltage()
2771 * dev_pm_opp_enable() - Enable a specific OPP
2773 * @freq: OPP frequency to enable
2775 * Enables a provided opp. If the operation is valid, this returns 0, else the
2776 * corresponding error value. It is meant to be used for users an OPP available
2790 * dev_pm_opp_disable() - Disable a specific OPP
2792 * @freq: OPP frequency to disable
2794 * Disables a provided opp. If the operation is valid, this returns
2796 * control by users to make this OPP not available until the circumstances are
2810 * dev_pm_opp_register_notifier() - Register OPP notifier for the device
2834 * dev_pm_opp_unregister_notifier() - Unregister OPP notifier for the device
2860 * @dev: device pointer used to lookup OPP table.
2883 * Drop the extra reference only if the OPP table was successfully added in dev_pm_opp_remove_table()
2898 * Sync voltage state of the OPP table regulators.
2908 /* Device may not have OPP table */ in dev_pm_opp_sync_regulators()