Lines Matching full:opp_table
26 * The root of the list of all opp-tables. All opp_table structures branch off
27 * from here, with each opp_table containing the list of opps it supports in
40 static bool _find_opp_dev(const struct device *dev, struct opp_table *opp_table) in _find_opp_dev() argument
45 mutex_lock(&opp_table->lock); in _find_opp_dev()
46 list_for_each_entry(opp_dev, &opp_table->dev_list, node) in _find_opp_dev()
52 mutex_unlock(&opp_table->lock); in _find_opp_dev()
56 static struct opp_table *_find_opp_table_unlocked(struct device *dev) in _find_opp_table_unlocked()
58 struct opp_table *opp_table; in _find_opp_table_unlocked() local
60 list_for_each_entry(opp_table, &opp_tables, node) { in _find_opp_table_unlocked()
61 if (_find_opp_dev(dev, opp_table)) { in _find_opp_table_unlocked()
62 _get_opp_table_kref(opp_table); in _find_opp_table_unlocked()
63 return opp_table; in _find_opp_table_unlocked()
71 * _find_opp_table() - find opp_table struct using device pointer
76 * Return: pointer to 'struct opp_table' if found, otherwise -ENODEV or
81 struct opp_table *_find_opp_table(struct device *dev) in _find_opp_table()
83 struct opp_table *opp_table; in _find_opp_table() local
91 opp_table = _find_opp_table_unlocked(dev); in _find_opp_table()
94 return opp_table; in _find_opp_table()
104 static bool assert_single_clk(struct opp_table *opp_table) in assert_single_clk() argument
106 return !WARN_ON(opp_table->clk_count > 1); in assert_single_clk()
149 sizeof(*supplies) * opp->opp_table->regulator_count); in dev_pm_opp_get_supplies()
172 for (i = 0; i < opp->opp_table->regulator_count; i++) in dev_pm_opp_get_power()
190 if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) { in dev_pm_opp_get_freq_indexed()
230 index >= opp->opp_table->required_opp_count) { in dev_pm_opp_get_required_pstate()
236 if (lazy_linking_pending(opp->opp_table)) in dev_pm_opp_get_required_pstate()
240 if (unlikely(!opp->opp_table->required_opp_tables[index]->is_genpd)) { in dev_pm_opp_get_required_pstate()
278 struct opp_table *opp_table; in dev_pm_opp_get_max_clock_latency() local
281 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_clock_latency()
282 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_clock_latency()
285 clock_latency_ns = opp_table->clock_latency_ns_max; in dev_pm_opp_get_max_clock_latency()
287 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_max_clock_latency()
301 struct opp_table *opp_table; in dev_pm_opp_get_max_volt_latency() local
311 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_volt_latency()
312 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_volt_latency()
316 if (!opp_table->regulators) in dev_pm_opp_get_max_volt_latency()
319 count = opp_table->regulator_count; in dev_pm_opp_get_max_volt_latency()
325 mutex_lock(&opp_table->lock); in dev_pm_opp_get_max_volt_latency()
331 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_get_max_volt_latency()
342 mutex_unlock(&opp_table->lock); in dev_pm_opp_get_max_volt_latency()
345 * The caller needs to ensure that opp_table (and hence the regulator) in dev_pm_opp_get_max_volt_latency()
349 reg = opp_table->regulators[i]; in dev_pm_opp_get_max_volt_latency()
357 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_max_volt_latency()
387 struct opp_table *opp_table; in dev_pm_opp_get_suspend_opp_freq() local
390 opp_table = _find_opp_table(dev); in dev_pm_opp_get_suspend_opp_freq()
391 if (IS_ERR(opp_table)) in dev_pm_opp_get_suspend_opp_freq()
394 if (opp_table->suspend_opp && opp_table->suspend_opp->available) in dev_pm_opp_get_suspend_opp_freq()
395 freq = dev_pm_opp_get_freq(opp_table->suspend_opp); in dev_pm_opp_get_suspend_opp_freq()
397 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_suspend_opp_freq()
403 int _get_opp_count(struct opp_table *opp_table) in _get_opp_count() argument
408 mutex_lock(&opp_table->lock); in _get_opp_count()
410 list_for_each_entry(opp, &opp_table->opp_list, node) { in _get_opp_count()
415 mutex_unlock(&opp_table->lock); in _get_opp_count()
429 struct opp_table *opp_table; in dev_pm_opp_get_opp_count() local
432 opp_table = _find_opp_table(dev); in dev_pm_opp_get_opp_count()
433 if (IS_ERR(opp_table)) { in dev_pm_opp_get_opp_count()
434 count = PTR_ERR(opp_table); in dev_pm_opp_get_opp_count()
440 count = _get_opp_count(opp_table); in dev_pm_opp_get_opp_count()
441 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_opp_count()
497 static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table, in _opp_table_find_key() argument
502 bool (*assert)(struct opp_table *opp_table)) in _opp_table_find_key() argument
507 if (assert && !assert(opp_table)) in _opp_table_find_key()
510 mutex_lock(&opp_table->lock); in _opp_table_find_key()
512 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in _opp_table_find_key()
525 mutex_unlock(&opp_table->lock); in _opp_table_find_key()
535 bool (*assert)(struct opp_table *opp_table)) in _find_key() argument
537 struct opp_table *opp_table; in _find_key() local
540 opp_table = _find_opp_table(dev); in _find_key()
541 if (IS_ERR(opp_table)) { in _find_key()
543 PTR_ERR(opp_table)); in _find_key()
544 return ERR_CAST(opp_table); in _find_key()
547 opp = _opp_table_find_key(opp_table, key, index, available, read, in _find_key()
550 dev_pm_opp_put_opp_table(opp_table); in _find_key()
558 bool (*assert)(struct opp_table *opp_table)) in _find_key_exact() argument
568 static struct dev_pm_opp *_opp_table_find_key_ceil(struct opp_table *opp_table, in _opp_table_find_key_ceil() argument
571 bool (*assert)(struct opp_table *opp_table)) in _opp_table_find_key_ceil() argument
573 return _opp_table_find_key(opp_table, key, index, available, read, in _opp_table_find_key_ceil()
580 bool (*assert)(struct opp_table *opp_table)) in _find_key_ceil() argument
589 bool (*assert)(struct opp_table *opp_table)) in _find_key_floor() argument
654 static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, in _find_freq_ceil() argument
657 return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq, in _find_freq_ceil()
944 _opp_config_clk_single(struct device *dev, struct opp_table *opp_table, in _opp_config_clk_single() argument
961 ret = clk_set_rate(opp_table->clk, freq); in _opp_config_clk_single()
966 opp_table->current_rate_single_clk = freq; in _opp_config_clk_single()
977 struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, in dev_pm_opp_config_clks_simple() argument
983 for (i = opp_table->clk_count - 1; i >= 0; i--) { in dev_pm_opp_config_clks_simple()
984 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
992 for (i = 0; i < opp_table->clk_count; i++) { in dev_pm_opp_config_clks_simple()
993 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
1027 if (unlikely(!new_opp->opp_table->enabled)) { in _opp_config_regulator_single()
1036 static int _set_opp_bw(const struct opp_table *opp_table, in _set_opp_bw() argument
1042 if (!opp_table->paths) in _set_opp_bw()
1045 for (i = 0; i < opp_table->path_count; i++) { in _set_opp_bw()
1053 ret = icc_set_bw(opp_table->paths[i], avg, peak); in _set_opp_bw()
1086 static int _set_required_opps(struct device *dev, struct opp_table *opp_table, in _set_required_opps() argument
1089 struct device **devs = opp_table->required_devs; in _set_required_opps()
1097 if (lazy_linking_pending(opp_table)) in _set_required_opps()
1103 target = opp_table->required_opp_count; in _set_required_opps()
1106 index = opp_table->required_opp_count - 1; in _set_required_opps()
1126 static void _find_current_opp(struct device *dev, struct opp_table *opp_table) in _find_current_opp() argument
1131 if (!IS_ERR(opp_table->clk)) { in _find_current_opp()
1132 freq = clk_get_rate(opp_table->clk); in _find_current_opp()
1133 opp = _find_freq_ceil(opp_table, &freq); in _find_current_opp()
1142 mutex_lock(&opp_table->lock); in _find_current_opp()
1143 opp = list_first_entry(&opp_table->opp_list, struct dev_pm_opp, node); in _find_current_opp()
1145 mutex_unlock(&opp_table->lock); in _find_current_opp()
1148 opp_table->current_opp = opp; in _find_current_opp()
1151 static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) in _disable_opp_table() argument
1155 if (!opp_table->enabled) in _disable_opp_table()
1163 if (!_get_opp_count(opp_table)) in _disable_opp_table()
1166 ret = _set_opp_bw(opp_table, NULL, dev); in _disable_opp_table()
1170 if (opp_table->regulators) in _disable_opp_table()
1171 regulator_disable(opp_table->regulators[0]); in _disable_opp_table()
1177 ret = _set_required_opps(dev, opp_table, NULL, false); in _disable_opp_table()
1180 opp_table->enabled = false; in _disable_opp_table()
1184 static int _set_opp(struct device *dev, struct opp_table *opp_table, in _set_opp() argument
1191 return _disable_opp_table(dev, opp_table); in _set_opp()
1194 if (unlikely(!opp_table->current_opp)) in _set_opp()
1195 _find_current_opp(dev, opp_table); in _set_opp()
1197 old_opp = opp_table->current_opp; in _set_opp()
1200 if (!forced && old_opp == opp && opp_table->enabled) { in _set_opp()
1210 scaling_down = _opp_compare_key(opp_table, old_opp, opp); in _set_opp()
1216 ret = _set_required_opps(dev, opp_table, opp, true); in _set_opp()
1226 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1232 if (opp_table->config_regulators) { in _set_opp()
1233 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1234 opp_table->regulators, in _set_opp()
1235 opp_table->regulator_count); in _set_opp()
1244 if (opp_table->config_clks) { in _set_opp()
1245 ret = opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_down); in _set_opp()
1252 if (opp_table->config_regulators) { in _set_opp()
1253 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1254 opp_table->regulators, in _set_opp()
1255 opp_table->regulator_count); in _set_opp()
1263 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1273 ret = _set_required_opps(dev, opp_table, opp, false); in _set_opp()
1280 opp_table->enabled = true; in _set_opp()
1285 opp_table->current_opp = opp; in _set_opp()
1303 struct opp_table *opp_table; in dev_pm_opp_set_rate() local
1309 opp_table = _find_opp_table(dev); in dev_pm_opp_set_rate()
1310 if (IS_ERR(opp_table)) { in dev_pm_opp_set_rate()
1312 return PTR_ERR(opp_table); in dev_pm_opp_set_rate()
1323 if (!_get_opp_count(opp_table)) { in dev_pm_opp_set_rate()
1324 ret = opp_table->config_clks(dev, opp_table, NULL, in dev_pm_opp_set_rate()
1329 freq = clk_round_rate(opp_table->clk, target_freq); in dev_pm_opp_set_rate()
1339 opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
1354 forced = opp_table->current_rate_single_clk != freq; in dev_pm_opp_set_rate()
1357 ret = _set_opp(dev, opp_table, opp, &freq, forced); in dev_pm_opp_set_rate()
1363 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_rate()
1380 struct opp_table *opp_table; in dev_pm_opp_set_opp() local
1383 opp_table = _find_opp_table(dev); in dev_pm_opp_set_opp()
1384 if (IS_ERR(opp_table)) { in dev_pm_opp_set_opp()
1386 return PTR_ERR(opp_table); in dev_pm_opp_set_opp()
1389 ret = _set_opp(dev, opp_table, opp, NULL, false); in dev_pm_opp_set_opp()
1390 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_opp()
1398 struct opp_table *opp_table) in _remove_opp_dev() argument
1400 opp_debug_unregister(opp_dev, opp_table); in _remove_opp_dev()
1406 struct opp_table *opp_table) in _add_opp_dev() argument
1417 mutex_lock(&opp_table->lock); in _add_opp_dev()
1418 list_add(&opp_dev->node, &opp_table->dev_list); in _add_opp_dev()
1419 mutex_unlock(&opp_table->lock); in _add_opp_dev()
1421 /* Create debugfs entries for the opp_table */ in _add_opp_dev()
1422 opp_debug_register(opp_dev, opp_table); in _add_opp_dev()
1427 static struct opp_table *_allocate_opp_table(struct device *dev, int index) in _allocate_opp_table()
1429 struct opp_table *opp_table; in _allocate_opp_table() local
1437 opp_table = kzalloc(sizeof(*opp_table), GFP_KERNEL); in _allocate_opp_table()
1438 if (!opp_table) in _allocate_opp_table()
1441 mutex_init(&opp_table->lock); in _allocate_opp_table()
1442 INIT_LIST_HEAD(&opp_table->dev_list); in _allocate_opp_table()
1443 INIT_LIST_HEAD(&opp_table->lazy); in _allocate_opp_table()
1445 opp_table->clk = ERR_PTR(-ENODEV); in _allocate_opp_table()
1448 opp_table->regulator_count = -1; in _allocate_opp_table()
1450 opp_dev = _add_opp_dev(dev, opp_table); in _allocate_opp_table()
1456 _of_init_opp_table(opp_table, dev, index); in _allocate_opp_table()
1459 ret = dev_pm_opp_of_find_icc_paths(dev, opp_table); in _allocate_opp_table()
1468 BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); in _allocate_opp_table()
1469 INIT_LIST_HEAD(&opp_table->opp_list); in _allocate_opp_table()
1470 kref_init(&opp_table->kref); in _allocate_opp_table()
1472 return opp_table; in _allocate_opp_table()
1475 _of_clear_opp_table(opp_table); in _allocate_opp_table()
1476 _remove_opp_dev(opp_dev, opp_table); in _allocate_opp_table()
1477 mutex_destroy(&opp_table->lock); in _allocate_opp_table()
1479 kfree(opp_table); in _allocate_opp_table()
1483 void _get_opp_table_kref(struct opp_table *opp_table) in _get_opp_table_kref() argument
1485 kref_get(&opp_table->kref); in _get_opp_table_kref()
1488 static struct opp_table *_update_opp_table_clk(struct device *dev, in _update_opp_table_clk()
1489 struct opp_table *opp_table, in _update_opp_table_clk() argument
1498 if (!getclk || IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || in _update_opp_table_clk()
1499 opp_table->clks) in _update_opp_table_clk()
1500 return opp_table; in _update_opp_table_clk()
1503 opp_table->clk = clk_get(dev, NULL); in _update_opp_table_clk()
1505 ret = PTR_ERR_OR_ZERO(opp_table->clk); in _update_opp_table_clk()
1507 opp_table->config_clks = _opp_config_clk_single; in _update_opp_table_clk()
1508 opp_table->clk_count = 1; in _update_opp_table_clk()
1509 return opp_table; in _update_opp_table_clk()
1525 opp_table->clk_count = 1; in _update_opp_table_clk()
1528 return opp_table; in _update_opp_table_clk()
1531 dev_pm_opp_put_opp_table(opp_table); in _update_opp_table_clk()
1552 struct opp_table *_add_opp_table_indexed(struct device *dev, int index, in _add_opp_table_indexed()
1555 struct opp_table *opp_table; in _add_opp_table_indexed() local
1560 opp_table = _find_opp_table_unlocked(dev); in _add_opp_table_indexed()
1561 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1575 opp_table = _managed_opp(dev, index); in _add_opp_table_indexed()
1580 if (opp_table) { in _add_opp_table_indexed()
1581 if (!_add_opp_dev(dev, opp_table)) { in _add_opp_table_indexed()
1582 dev_pm_opp_put_opp_table(opp_table); in _add_opp_table_indexed()
1583 opp_table = ERR_PTR(-ENOMEM); in _add_opp_table_indexed()
1588 opp_table = _allocate_opp_table(dev, index); in _add_opp_table_indexed()
1591 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1592 list_add(&opp_table->node, &opp_tables); in _add_opp_table_indexed()
1600 return _update_opp_table_clk(dev, opp_table, getclk); in _add_opp_table_indexed()
1603 static struct opp_table *_add_opp_table(struct device *dev, bool getclk) in _add_opp_table()
1608 struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) in dev_pm_opp_get_opp_table()
1616 struct opp_table *opp_table = container_of(kref, struct opp_table, kref); in _opp_table_kref_release() local
1621 list_del(&opp_table->node); in _opp_table_kref_release()
1624 if (opp_table->current_opp) in _opp_table_kref_release()
1625 dev_pm_opp_put(opp_table->current_opp); in _opp_table_kref_release()
1627 _of_clear_opp_table(opp_table); in _opp_table_kref_release()
1630 if (!IS_ERR(opp_table->clk)) in _opp_table_kref_release()
1631 clk_put(opp_table->clk); in _opp_table_kref_release()
1633 if (opp_table->paths) { in _opp_table_kref_release()
1634 for (i = 0; i < opp_table->path_count; i++) in _opp_table_kref_release()
1635 icc_put(opp_table->paths[i]); in _opp_table_kref_release()
1636 kfree(opp_table->paths); in _opp_table_kref_release()
1639 WARN_ON(!list_empty(&opp_table->opp_list)); in _opp_table_kref_release()
1641 list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) in _opp_table_kref_release()
1642 _remove_opp_dev(opp_dev, opp_table); in _opp_table_kref_release()
1644 mutex_destroy(&opp_table->lock); in _opp_table_kref_release()
1645 kfree(opp_table); in _opp_table_kref_release()
1648 void dev_pm_opp_put_opp_table(struct opp_table *opp_table) in dev_pm_opp_put_opp_table() argument
1650 kref_put_mutex(&opp_table->kref, _opp_table_kref_release, in dev_pm_opp_put_opp_table()
1663 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release() local
1666 mutex_unlock(&opp_table->lock); in _opp_kref_release()
1672 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp); in _opp_kref_release()
1673 _of_clear_opp(opp_table, opp); in _opp_kref_release()
1685 kref_put_mutex(&opp->kref, _opp_kref_release, &opp->opp_table->lock); in dev_pm_opp_put()
1699 struct opp_table *opp_table; in dev_pm_opp_remove() local
1701 opp_table = _find_opp_table(dev); in dev_pm_opp_remove()
1702 if (IS_ERR(opp_table)) in dev_pm_opp_remove()
1705 if (!assert_single_clk(opp_table)) in dev_pm_opp_remove()
1708 mutex_lock(&opp_table->lock); in dev_pm_opp_remove()
1710 list_for_each_entry(iter, &opp_table->opp_list, node) { in dev_pm_opp_remove()
1717 mutex_unlock(&opp_table->lock); in dev_pm_opp_remove()
1723 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1731 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1735 static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table, in _opp_get_next() argument
1740 mutex_lock(&opp_table->lock); in _opp_get_next()
1741 list_for_each_entry(temp, &opp_table->opp_list, node) { in _opp_get_next()
1752 mutex_unlock(&opp_table->lock); in _opp_get_next()
1759 * called without the opp_table->lock held.
1761 static void _opp_remove_all(struct opp_table *opp_table, bool dynamic) in _opp_remove_all() argument
1765 while ((opp = _opp_get_next(opp_table, dynamic))) { in _opp_remove_all()
1771 dev_pm_opp_put_opp_table(opp_table); in _opp_remove_all()
1775 bool _opp_remove_all_static(struct opp_table *opp_table) in _opp_remove_all_static() argument
1777 mutex_lock(&opp_table->lock); in _opp_remove_all_static()
1779 if (!opp_table->parsed_static_opps) { in _opp_remove_all_static()
1780 mutex_unlock(&opp_table->lock); in _opp_remove_all_static()
1784 if (--opp_table->parsed_static_opps) { in _opp_remove_all_static()
1785 mutex_unlock(&opp_table->lock); in _opp_remove_all_static()
1789 mutex_unlock(&opp_table->lock); in _opp_remove_all_static()
1791 _opp_remove_all(opp_table, false); in _opp_remove_all_static()
1803 struct opp_table *opp_table; in dev_pm_opp_remove_all_dynamic() local
1805 opp_table = _find_opp_table(dev); in dev_pm_opp_remove_all_dynamic()
1806 if (IS_ERR(opp_table)) in dev_pm_opp_remove_all_dynamic()
1809 _opp_remove_all(opp_table, true); in dev_pm_opp_remove_all_dynamic()
1812 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_all_dynamic()
1816 struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table) in _opp_allocate() argument
1822 supply_count = opp_table->regulator_count > 0 ? in _opp_allocate()
1823 opp_table->regulator_count : 1; in _opp_allocate()
1825 clk_size = sizeof(*opp->rates) * opp_table->clk_count; in _opp_allocate()
1826 icc_size = sizeof(*opp->bandwidth) * opp_table->path_count; in _opp_allocate()
1839 opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->rates + opp_table->clk_count); in _opp_allocate()
1849 struct opp_table *opp_table) in _opp_supported_by_regulators() argument
1854 if (!opp_table->regulators) in _opp_supported_by_regulators()
1857 for (i = 0; i < opp_table->regulator_count; i++) { in _opp_supported_by_regulators()
1858 reg = opp_table->regulators[i]; in _opp_supported_by_regulators()
1873 static int _opp_compare_rate(struct opp_table *opp_table, in _opp_compare_rate() argument
1878 for (i = 0; i < opp_table->clk_count; i++) { in _opp_compare_rate()
1887 static int _opp_compare_bw(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_bw() argument
1892 for (i = 0; i < opp_table->path_count; i++) { in _opp_compare_bw()
1907 int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_key() argument
1912 ret = _opp_compare_rate(opp_table, opp1, opp2); in _opp_compare_key()
1916 ret = _opp_compare_bw(opp_table, opp1, opp2); in _opp_compare_key()
1928 struct opp_table *opp_table, in _opp_is_duplicate() argument
1938 * Need to use &opp_table->opp_list in the condition part of the 'for' in _opp_is_duplicate()
1942 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_is_duplicate()
1943 opp_cmp = _opp_compare_key(opp_table, new_opp, opp); in _opp_is_duplicate()
1992 struct opp_table *opp_table) in _opp_add() argument
1997 mutex_lock(&opp_table->lock); in _opp_add()
1998 head = &opp_table->opp_list; in _opp_add()
2000 ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); in _opp_add()
2002 mutex_unlock(&opp_table->lock); in _opp_add()
2007 mutex_unlock(&opp_table->lock); in _opp_add()
2009 new_opp->opp_table = opp_table; in _opp_add()
2012 opp_debug_create_one(new_opp, opp_table); in _opp_add()
2014 if (!_opp_supported_by_regulators(new_opp, opp_table)) { in _opp_add()
2021 if (lazy_linking_pending(opp_table)) in _opp_add()
2024 _required_opps_available(new_opp, opp_table->required_opp_count); in _opp_add()
2031 * @opp_table: OPP table
2050 int _opp_add_v1(struct opp_table *opp_table, struct device *dev, in _opp_add_v1() argument
2057 if (!assert_single_clk(opp_table)) in _opp_add_v1()
2060 new_opp = _opp_allocate(opp_table); in _opp_add_v1()
2068 tol = u_volt * opp_table->voltage_tolerance_v1 / 100; in _opp_add_v1()
2075 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_v1()
2087 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_v1()
2102 static int _opp_set_supported_hw(struct opp_table *opp_table, in _opp_set_supported_hw() argument
2106 if (opp_table->supported_hw) in _opp_set_supported_hw()
2109 opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions), in _opp_set_supported_hw()
2111 if (!opp_table->supported_hw) in _opp_set_supported_hw()
2114 opp_table->supported_hw_count = count; in _opp_set_supported_hw()
2119 static void _opp_put_supported_hw(struct opp_table *opp_table) in _opp_put_supported_hw() argument
2121 if (opp_table->supported_hw) { in _opp_put_supported_hw()
2122 kfree(opp_table->supported_hw); in _opp_put_supported_hw()
2123 opp_table->supported_hw = NULL; in _opp_put_supported_hw()
2124 opp_table->supported_hw_count = 0; in _opp_put_supported_hw()
2134 static int _opp_set_prop_name(struct opp_table *opp_table, const char *name) in _opp_set_prop_name() argument
2137 if (!opp_table->prop_name) { in _opp_set_prop_name()
2138 opp_table->prop_name = kstrdup(name, GFP_KERNEL); in _opp_set_prop_name()
2139 if (!opp_table->prop_name) in _opp_set_prop_name()
2146 static void _opp_put_prop_name(struct opp_table *opp_table) in _opp_put_prop_name() argument
2148 if (opp_table->prop_name) { in _opp_put_prop_name()
2149 kfree(opp_table->prop_name); in _opp_put_prop_name()
2150 opp_table->prop_name = NULL; in _opp_put_prop_name()
2161 static int _opp_set_regulators(struct opp_table *opp_table, struct device *dev, in _opp_set_regulators() argument
2176 if (opp_table->regulators) in _opp_set_regulators()
2179 opp_table->regulators = kmalloc_array(count, in _opp_set_regulators()
2180 sizeof(*opp_table->regulators), in _opp_set_regulators()
2182 if (!opp_table->regulators) in _opp_set_regulators()
2194 opp_table->regulators[i] = reg; in _opp_set_regulators()
2197 opp_table->regulator_count = count; in _opp_set_regulators()
2201 opp_table->config_regulators = _opp_config_regulator_single; in _opp_set_regulators()
2207 regulator_put(opp_table->regulators[--i]); in _opp_set_regulators()
2209 kfree(opp_table->regulators); in _opp_set_regulators()
2210 opp_table->regulators = NULL; in _opp_set_regulators()
2211 opp_table->regulator_count = -1; in _opp_set_regulators()
2216 static void _opp_put_regulators(struct opp_table *opp_table) in _opp_put_regulators() argument
2220 if (!opp_table->regulators) in _opp_put_regulators()
2223 if (opp_table->enabled) { in _opp_put_regulators()
2224 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2225 regulator_disable(opp_table->regulators[i]); in _opp_put_regulators()
2228 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2229 regulator_put(opp_table->regulators[i]); in _opp_put_regulators()
2231 kfree(opp_table->regulators); in _opp_put_regulators()
2232 opp_table->regulators = NULL; in _opp_put_regulators()
2233 opp_table->regulator_count = -1; in _opp_put_regulators()
2236 static void _put_clks(struct opp_table *opp_table, int count) in _put_clks() argument
2241 clk_put(opp_table->clks[i]); in _put_clks()
2243 kfree(opp_table->clks); in _put_clks()
2244 opp_table->clks = NULL; in _put_clks()
2256 static int _opp_set_clknames(struct opp_table *opp_table, struct device *dev, in _opp_set_clknames() argument
2280 if (opp_table->clks) in _opp_set_clknames()
2283 opp_table->clks = kmalloc_array(count, sizeof(*opp_table->clks), in _opp_set_clknames()
2285 if (!opp_table->clks) in _opp_set_clknames()
2298 opp_table->clks[i] = clk; in _opp_set_clknames()
2301 opp_table->clk_count = count; in _opp_set_clknames()
2302 opp_table->config_clks = config_clks; in _opp_set_clknames()
2306 if (!opp_table->config_clks) in _opp_set_clknames()
2307 opp_table->config_clks = _opp_config_clk_single; in _opp_set_clknames()
2321 opp_table->clk = opp_table->clks[0]; in _opp_set_clknames()
2327 _put_clks(opp_table, i); in _opp_set_clknames()
2331 static void _opp_put_clknames(struct opp_table *opp_table) in _opp_put_clknames() argument
2333 if (!opp_table->clks) in _opp_put_clknames()
2336 opp_table->config_clks = NULL; in _opp_put_clknames()
2337 opp_table->clk = ERR_PTR(-ENODEV); in _opp_put_clknames()
2339 _put_clks(opp_table, opp_table->clk_count); in _opp_put_clknames()
2347 static int _opp_set_config_regulators_helper(struct opp_table *opp_table, in _opp_set_config_regulators_helper() argument
2351 if (!opp_table->config_regulators) in _opp_set_config_regulators_helper()
2352 opp_table->config_regulators = config_regulators; in _opp_set_config_regulators_helper()
2357 static void _opp_put_config_regulators_helper(struct opp_table *opp_table) in _opp_put_config_regulators_helper() argument
2359 if (opp_table->config_regulators) in _opp_put_config_regulators_helper()
2360 opp_table->config_regulators = NULL; in _opp_put_config_regulators_helper()
2363 static void _opp_detach_genpd(struct opp_table *opp_table) in _opp_detach_genpd() argument
2367 for (index = 0; index < opp_table->required_opp_count; index++) { in _opp_detach_genpd()
2368 if (!opp_table->required_devs[index]) in _opp_detach_genpd()
2371 dev_pm_domain_detach(opp_table->required_devs[index], false); in _opp_detach_genpd()
2372 opp_table->required_devs[index] = NULL; in _opp_detach_genpd()
2393 static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, in _opp_attach_genpd() argument
2397 struct opp_table *genpd_table; in _opp_attach_genpd()
2401 if (!opp_table->required_devs) { in _opp_attach_genpd()
2407 if (opp_table->is_genpd) { in _opp_attach_genpd()
2413 if (opp_table->required_devs[0]) in _opp_attach_genpd()
2417 if (index >= opp_table->required_opp_count) { in _opp_attach_genpd()
2419 *name, opp_table->required_opp_count, index); in _opp_attach_genpd()
2438 * they all create separate instances of 'struct opp_table' from in _opp_attach_genpd()
2452 if (genpd_table != opp_table->required_opp_tables[index]) { in _opp_attach_genpd()
2453 dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); in _opp_attach_genpd()
2454 opp_table->required_opp_tables[index] = genpd_table; in _opp_attach_genpd()
2460 opp_table->required_devs[index] = virt_dev; in _opp_attach_genpd()
2466 *virt_devs = opp_table->required_devs; in _opp_attach_genpd()
2471 _opp_detach_genpd(opp_table); in _opp_attach_genpd()
2476 static int _opp_set_required_devs(struct opp_table *opp_table, in _opp_set_required_devs() argument
2482 if (!opp_table->required_devs) { in _opp_set_required_devs()
2488 if (opp_table->required_devs[0]) in _opp_set_required_devs()
2491 for (i = 0; i < opp_table->required_opp_count; i++) { in _opp_set_required_devs()
2493 if (required_devs[i] && opp_table->is_genpd && in _opp_set_required_devs()
2494 opp_table->required_opp_tables[i]->is_genpd) { in _opp_set_required_devs()
2499 opp_table->required_devs[i] = required_devs[i]; in _opp_set_required_devs()
2505 static void _opp_put_required_devs(struct opp_table *opp_table) in _opp_put_required_devs() argument
2509 for (i = 0; i < opp_table->required_opp_count; i++) in _opp_put_required_devs()
2510 opp_table->required_devs[i] = NULL; in _opp_put_required_devs()
2516 _opp_put_required_devs(data->opp_table); in _opp_clear_config()
2518 _opp_detach_genpd(data->opp_table); in _opp_clear_config()
2521 _opp_put_regulators(data->opp_table); in _opp_clear_config()
2523 _opp_put_supported_hw(data->opp_table); in _opp_clear_config()
2525 _opp_put_config_regulators_helper(data->opp_table); in _opp_clear_config()
2527 _opp_put_prop_name(data->opp_table); in _opp_clear_config()
2529 _opp_put_clknames(data->opp_table); in _opp_clear_config()
2531 dev_pm_opp_put_opp_table(data->opp_table); in _opp_clear_config()
2554 struct opp_table *opp_table; in dev_pm_opp_set_config() local
2563 opp_table = _add_opp_table(dev, false); in dev_pm_opp_set_config()
2564 if (IS_ERR(opp_table)) { in dev_pm_opp_set_config()
2566 return PTR_ERR(opp_table); in dev_pm_opp_set_config()
2569 data->opp_table = opp_table; in dev_pm_opp_set_config()
2573 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_set_config()
2580 ret = _opp_set_clknames(opp_table, dev, config->clk_names, in dev_pm_opp_set_config()
2594 ret = _opp_set_prop_name(opp_table, config->prop_name); in dev_pm_opp_set_config()
2603 ret = _opp_set_config_regulators_helper(opp_table, dev, in dev_pm_opp_set_config()
2613 ret = _opp_set_supported_hw(opp_table, config->supported_hw, in dev_pm_opp_set_config()
2623 ret = _opp_set_regulators(opp_table, dev, in dev_pm_opp_set_config()
2638 ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, in dev_pm_opp_set_config()
2645 ret = _opp_set_required_devs(opp_table, dev, in dev_pm_opp_set_config()
2739 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, in dev_pm_opp_xlate_required_opp()
2740 struct opp_table *dst_table, in dev_pm_opp_xlate_required_opp()
2793 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, in dev_pm_opp_xlate_performance_state()
2794 struct opp_table *dst_table, in dev_pm_opp_xlate_performance_state()
2868 struct opp_table *opp_table; in dev_pm_opp_add_dynamic() local
2871 opp_table = _add_opp_table(dev, true); in dev_pm_opp_add_dynamic()
2872 if (IS_ERR(opp_table)) in dev_pm_opp_add_dynamic()
2873 return PTR_ERR(opp_table); in dev_pm_opp_add_dynamic()
2876 opp_table->regulator_count = 1; in dev_pm_opp_add_dynamic()
2878 ret = _opp_add_v1(opp_table, dev, data, true); in dev_pm_opp_add_dynamic()
2880 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_add_dynamic()
2902 struct opp_table *opp_table; in _opp_set_availability() local
2906 /* Find the opp_table */ in _opp_set_availability()
2907 opp_table = _find_opp_table(dev); in _opp_set_availability()
2908 if (IS_ERR(opp_table)) { in _opp_set_availability()
2909 r = PTR_ERR(opp_table); in _opp_set_availability()
2914 if (!assert_single_clk(opp_table)) { in _opp_set_availability()
2919 mutex_lock(&opp_table->lock); in _opp_set_availability()
2922 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in _opp_set_availability()
2941 mutex_unlock(&opp_table->lock); in _opp_set_availability()
2945 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, in _opp_set_availability()
2948 blocking_notifier_call_chain(&opp_table->head, in _opp_set_availability()
2955 mutex_unlock(&opp_table->lock); in _opp_set_availability()
2957 dev_pm_opp_put_opp_table(opp_table); in _opp_set_availability()
2978 struct opp_table *opp_table; in dev_pm_opp_adjust_voltage() local
2982 /* Find the opp_table */ in dev_pm_opp_adjust_voltage()
2983 opp_table = _find_opp_table(dev); in dev_pm_opp_adjust_voltage()
2984 if (IS_ERR(opp_table)) { in dev_pm_opp_adjust_voltage()
2985 r = PTR_ERR(opp_table); in dev_pm_opp_adjust_voltage()
2990 if (!assert_single_clk(opp_table)) { in dev_pm_opp_adjust_voltage()
2995 mutex_lock(&opp_table->lock); in dev_pm_opp_adjust_voltage()
2998 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in dev_pm_opp_adjust_voltage()
3019 mutex_unlock(&opp_table->lock); in dev_pm_opp_adjust_voltage()
3022 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, in dev_pm_opp_adjust_voltage()
3029 mutex_unlock(&opp_table->lock); in dev_pm_opp_adjust_voltage()
3031 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_adjust_voltage()
3046 struct opp_table *opp_table; in dev_pm_opp_sync_regulators() local
3051 opp_table = _find_opp_table(dev); in dev_pm_opp_sync_regulators()
3052 if (IS_ERR(opp_table)) in dev_pm_opp_sync_regulators()
3056 if (unlikely(!opp_table->regulators)) in dev_pm_opp_sync_regulators()
3060 if (!opp_table->enabled) in dev_pm_opp_sync_regulators()
3063 for (i = 0; i < opp_table->regulator_count; i++) { in dev_pm_opp_sync_regulators()
3064 reg = opp_table->regulators[i]; in dev_pm_opp_sync_regulators()
3071 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_sync_regulators()
3125 struct opp_table *opp_table; in dev_pm_opp_register_notifier() local
3128 opp_table = _find_opp_table(dev); in dev_pm_opp_register_notifier()
3129 if (IS_ERR(opp_table)) in dev_pm_opp_register_notifier()
3130 return PTR_ERR(opp_table); in dev_pm_opp_register_notifier()
3132 ret = blocking_notifier_chain_register(&opp_table->head, nb); in dev_pm_opp_register_notifier()
3134 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_register_notifier()
3150 struct opp_table *opp_table; in dev_pm_opp_unregister_notifier() local
3153 opp_table = _find_opp_table(dev); in dev_pm_opp_unregister_notifier()
3154 if (IS_ERR(opp_table)) in dev_pm_opp_unregister_notifier()
3155 return PTR_ERR(opp_table); in dev_pm_opp_unregister_notifier()
3157 ret = blocking_notifier_chain_unregister(&opp_table->head, nb); in dev_pm_opp_unregister_notifier()
3159 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_unregister_notifier()
3174 struct opp_table *opp_table; in dev_pm_opp_remove_table() local
3177 opp_table = _find_opp_table(dev); in dev_pm_opp_remove_table()
3178 if (IS_ERR(opp_table)) { in dev_pm_opp_remove_table()
3179 int error = PTR_ERR(opp_table); in dev_pm_opp_remove_table()
3182 WARN(1, "%s: opp_table: %d\n", in dev_pm_opp_remove_table()
3193 if (_opp_remove_all_static(opp_table)) in dev_pm_opp_remove_table()
3194 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_table()
3197 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_table()