Lines Matching refs:opp_table
40 static bool _find_opp_dev(const struct device *dev, struct opp_table *opp_table) in _find_opp_dev() argument
44 guard(mutex)(&opp_table->lock); in _find_opp_dev()
46 list_for_each_entry(opp_dev, &opp_table->dev_list, node) in _find_opp_dev()
53 static struct opp_table *_find_opp_table_unlocked(struct device *dev) in _find_opp_table_unlocked()
55 struct opp_table *opp_table; in _find_opp_table_unlocked() local
57 list_for_each_entry(opp_table, &opp_tables, node) { in _find_opp_table_unlocked()
58 if (_find_opp_dev(dev, opp_table)) in _find_opp_table_unlocked()
59 return dev_pm_opp_get_opp_table_ref(opp_table); in _find_opp_table_unlocked()
76 struct opp_table *_find_opp_table(struct device *dev) in _find_opp_table()
94 static bool assert_single_clk(struct opp_table *opp_table, in assert_single_clk() argument
97 return !WARN_ON(opp_table->clk_count > 1); in assert_single_clk()
103 static bool assert_clk_index(struct opp_table *opp_table, in assert_clk_index() argument
106 return opp_table->clk_count > index; in assert_clk_index()
112 static bool assert_bandwidth_index(struct opp_table *opp_table, in assert_bandwidth_index() argument
115 return opp_table->path_count > index; in assert_bandwidth_index()
133 if (index >= opp->opp_table->path_count) in dev_pm_opp_get_bw()
183 sizeof(*supplies) * opp->opp_table->regulator_count); in dev_pm_opp_get_supplies()
206 for (i = 0; i < opp->opp_table->regulator_count; i++) in dev_pm_opp_get_power()
224 if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) { in dev_pm_opp_get_freq_indexed()
264 index >= opp->opp_table->required_opp_count) { in dev_pm_opp_get_required_pstate()
270 if (lazy_linking_pending(opp->opp_table)) in dev_pm_opp_get_required_pstate()
274 if (unlikely(!opp->opp_table->required_opp_tables[index]->is_genpd)) { in dev_pm_opp_get_required_pstate()
312 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_get_max_clock_latency()
314 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_clock_latency()
315 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_clock_latency()
318 return opp_table->clock_latency_ns_max; in dev_pm_opp_get_max_clock_latency()
330 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_get_max_volt_latency()
340 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_volt_latency()
341 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_volt_latency()
345 if (!opp_table->regulators) in dev_pm_opp_get_max_volt_latency()
348 count = opp_table->regulator_count; in dev_pm_opp_get_max_volt_latency()
354 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_get_max_volt_latency()
359 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_get_max_volt_latency()
376 reg = opp_table->regulators[i]; in dev_pm_opp_get_max_volt_latency()
412 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_get_suspend_opp_freq()
415 opp_table = _find_opp_table(dev); in dev_pm_opp_get_suspend_opp_freq()
416 if (IS_ERR(opp_table)) in dev_pm_opp_get_suspend_opp_freq()
419 if (opp_table->suspend_opp && opp_table->suspend_opp->available) in dev_pm_opp_get_suspend_opp_freq()
420 freq = dev_pm_opp_get_freq(opp_table->suspend_opp); in dev_pm_opp_get_suspend_opp_freq()
426 int _get_opp_count(struct opp_table *opp_table) in _get_opp_count() argument
431 guard(mutex)(&opp_table->lock); in _get_opp_count()
433 list_for_each_entry(opp, &opp_table->opp_list, node) { in _get_opp_count()
450 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_get_opp_count()
452 opp_table = _find_opp_table(dev); in dev_pm_opp_get_opp_count()
453 if (IS_ERR(opp_table)) { in dev_pm_opp_get_opp_count()
455 __func__, PTR_ERR(opp_table)); in dev_pm_opp_get_opp_count()
456 return PTR_ERR(opp_table); in dev_pm_opp_get_opp_count()
459 return _get_opp_count(opp_table); in dev_pm_opp_get_opp_count()
513 static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table, in _opp_table_find_key() argument
518 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _opp_table_find_key() argument
523 if (assert && !assert(opp_table, index)) in _opp_table_find_key()
526 guard(mutex)(&opp_table->lock); in _opp_table_find_key()
528 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in _opp_table_find_key()
549 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key() argument
551 struct opp_table *opp_table __free(put_opp_table); in _find_key()
553 opp_table = _find_opp_table(dev); in _find_key()
554 if (IS_ERR(opp_table)) { in _find_key()
556 PTR_ERR(opp_table)); in _find_key()
557 return ERR_CAST(opp_table); in _find_key()
560 return _opp_table_find_key(opp_table, key, index, available, read, in _find_key()
567 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_exact() argument
577 static struct dev_pm_opp *_opp_table_find_key_ceil(struct opp_table *opp_table, in _opp_table_find_key_ceil() argument
580 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _opp_table_find_key_ceil() argument
582 return _opp_table_find_key(opp_table, key, index, available, read, in _opp_table_find_key_ceil()
589 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_ceil() argument
598 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_floor() argument
664 static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, in _find_freq_ceil() argument
667 return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq, in _find_freq_ceil()
957 _opp_config_clk_single(struct device *dev, struct opp_table *opp_table, in _opp_config_clk_single() argument
974 ret = clk_set_rate(opp_table->clk, freq); in _opp_config_clk_single()
979 opp_table->current_rate_single_clk = freq; in _opp_config_clk_single()
990 struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, in dev_pm_opp_config_clks_simple() argument
996 for (i = opp_table->clk_count - 1; i >= 0; i--) { in dev_pm_opp_config_clks_simple()
997 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
1005 for (i = 0; i < opp_table->clk_count; i++) { in dev_pm_opp_config_clks_simple()
1006 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
1040 if (unlikely(!new_opp->opp_table->enabled)) { in _opp_config_regulator_single()
1049 static int _set_opp_bw(const struct opp_table *opp_table, in _set_opp_bw() argument
1055 if (!opp_table->paths) in _set_opp_bw()
1058 for (i = 0; i < opp_table->path_count; i++) { in _set_opp_bw()
1066 ret = icc_set_bw(opp_table->paths[i], avg, peak); in _set_opp_bw()
1099 static int _set_required_opps(struct device *dev, struct opp_table *opp_table, in _set_required_opps() argument
1102 struct device **devs = opp_table->required_devs; in _set_required_opps()
1110 if (lazy_linking_pending(opp_table)) in _set_required_opps()
1116 target = opp_table->required_opp_count; in _set_required_opps()
1119 index = opp_table->required_opp_count - 1; in _set_required_opps()
1139 static void _find_current_opp(struct device *dev, struct opp_table *opp_table) in _find_current_opp() argument
1144 if (!IS_ERR(opp_table->clk)) { in _find_current_opp()
1145 freq = clk_get_rate(opp_table->clk); in _find_current_opp()
1146 opp = _find_freq_ceil(opp_table, &freq); in _find_current_opp()
1155 guard(mutex)(&opp_table->lock); in _find_current_opp()
1156 opp = dev_pm_opp_get(list_first_entry(&opp_table->opp_list, in _find_current_opp()
1160 opp_table->current_opp = opp; in _find_current_opp()
1163 static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) in _disable_opp_table() argument
1167 if (!opp_table->enabled) in _disable_opp_table()
1175 if (!_get_opp_count(opp_table)) in _disable_opp_table()
1178 ret = _set_opp_bw(opp_table, NULL, dev); in _disable_opp_table()
1182 if (opp_table->regulators) in _disable_opp_table()
1183 regulator_disable(opp_table->regulators[0]); in _disable_opp_table()
1189 ret = _set_required_opps(dev, opp_table, NULL, false); in _disable_opp_table()
1192 opp_table->enabled = false; in _disable_opp_table()
1196 static int _set_opp(struct device *dev, struct opp_table *opp_table, in _set_opp() argument
1203 return _disable_opp_table(dev, opp_table); in _set_opp()
1206 if (unlikely(!opp_table->current_opp)) in _set_opp()
1207 _find_current_opp(dev, opp_table); in _set_opp()
1209 old_opp = opp_table->current_opp; in _set_opp()
1212 if (!forced && old_opp == opp && opp_table->enabled) { in _set_opp()
1222 scaling_down = _opp_compare_key(opp_table, old_opp, opp); in _set_opp()
1228 ret = _set_required_opps(dev, opp_table, opp, true); in _set_opp()
1238 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1244 if (opp_table->config_regulators) { in _set_opp()
1245 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1246 opp_table->regulators, in _set_opp()
1247 opp_table->regulator_count); in _set_opp()
1256 if (opp_table->config_clks) { in _set_opp()
1257 ret = opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_down); in _set_opp()
1264 if (opp_table->config_regulators) { in _set_opp()
1265 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1266 opp_table->regulators, in _set_opp()
1267 opp_table->regulator_count); in _set_opp()
1275 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1285 ret = _set_required_opps(dev, opp_table, opp, false); in _set_opp()
1292 opp_table->enabled = true; in _set_opp()
1296 opp_table->current_opp = dev_pm_opp_get(opp); in _set_opp()
1314 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_set_rate()
1319 opp_table = _find_opp_table(dev); in dev_pm_opp_set_rate()
1320 if (IS_ERR(opp_table)) { in dev_pm_opp_set_rate()
1322 return PTR_ERR(opp_table); in dev_pm_opp_set_rate()
1333 if (!_get_opp_count(opp_table)) { in dev_pm_opp_set_rate()
1334 return opp_table->config_clks(dev, opp_table, NULL, in dev_pm_opp_set_rate()
1338 freq = clk_round_rate(opp_table->clk, target_freq); in dev_pm_opp_set_rate()
1348 opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
1362 forced = opp_table->current_rate_single_clk != freq; in dev_pm_opp_set_rate()
1365 return _set_opp(dev, opp_table, opp, &freq, forced); in dev_pm_opp_set_rate()
1381 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_set_opp()
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 return _set_opp(dev, opp_table, opp, NULL, false); in dev_pm_opp_set_opp()
1395 struct opp_table *opp_table) in _remove_opp_dev() argument
1397 opp_debug_unregister(opp_dev, opp_table); in _remove_opp_dev()
1403 struct opp_table *opp_table) in _add_opp_dev() argument
1414 scoped_guard(mutex, &opp_table->lock) in _add_opp_dev()
1415 list_add(&opp_dev->node, &opp_table->dev_list); in _add_opp_dev()
1418 opp_debug_register(opp_dev, opp_table); in _add_opp_dev()
1423 static struct opp_table *_allocate_opp_table(struct device *dev, int index) in _allocate_opp_table()
1425 struct opp_table *opp_table; in _allocate_opp_table() local
1433 opp_table = kzalloc(sizeof(*opp_table), GFP_KERNEL); in _allocate_opp_table()
1434 if (!opp_table) in _allocate_opp_table()
1437 mutex_init(&opp_table->lock); in _allocate_opp_table()
1438 INIT_LIST_HEAD(&opp_table->dev_list); in _allocate_opp_table()
1439 INIT_LIST_HEAD(&opp_table->lazy); in _allocate_opp_table()
1441 opp_table->clk = ERR_PTR(-ENODEV); in _allocate_opp_table()
1444 opp_table->regulator_count = -1; in _allocate_opp_table()
1446 opp_dev = _add_opp_dev(dev, opp_table); in _allocate_opp_table()
1452 _of_init_opp_table(opp_table, dev, index); in _allocate_opp_table()
1455 ret = dev_pm_opp_of_find_icc_paths(dev, opp_table); in _allocate_opp_table()
1464 BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); in _allocate_opp_table()
1465 INIT_LIST_HEAD(&opp_table->opp_list); in _allocate_opp_table()
1466 kref_init(&opp_table->kref); in _allocate_opp_table()
1468 return opp_table; in _allocate_opp_table()
1471 _of_clear_opp_table(opp_table); in _allocate_opp_table()
1472 _remove_opp_dev(opp_dev, opp_table); in _allocate_opp_table()
1473 mutex_destroy(&opp_table->lock); in _allocate_opp_table()
1475 kfree(opp_table); in _allocate_opp_table()
1479 static struct opp_table *_update_opp_table_clk(struct device *dev, in _update_opp_table_clk()
1480 struct opp_table *opp_table, in _update_opp_table_clk() argument
1489 if (!getclk || IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || in _update_opp_table_clk()
1490 opp_table->clks) in _update_opp_table_clk()
1491 return opp_table; in _update_opp_table_clk()
1494 opp_table->clk = clk_get(dev, NULL); in _update_opp_table_clk()
1496 ret = PTR_ERR_OR_ZERO(opp_table->clk); in _update_opp_table_clk()
1498 opp_table->config_clks = _opp_config_clk_single; in _update_opp_table_clk()
1499 opp_table->clk_count = 1; in _update_opp_table_clk()
1500 return opp_table; in _update_opp_table_clk()
1516 opp_table->clk_count = 1; in _update_opp_table_clk()
1519 return opp_table; in _update_opp_table_clk()
1522 dev_pm_opp_put_opp_table(opp_table); in _update_opp_table_clk()
1543 struct opp_table *_add_opp_table_indexed(struct device *dev, int index, in _add_opp_table_indexed()
1546 struct opp_table *opp_table; in _add_opp_table_indexed() local
1551 opp_table = _find_opp_table_unlocked(dev); in _add_opp_table_indexed()
1552 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1566 opp_table = _managed_opp(dev, index); in _add_opp_table_indexed()
1571 if (opp_table) { in _add_opp_table_indexed()
1572 if (!_add_opp_dev(dev, opp_table)) { in _add_opp_table_indexed()
1573 dev_pm_opp_put_opp_table(opp_table); in _add_opp_table_indexed()
1574 opp_table = ERR_PTR(-ENOMEM); in _add_opp_table_indexed()
1579 opp_table = _allocate_opp_table(dev, index); in _add_opp_table_indexed()
1582 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1583 list_add(&opp_table->node, &opp_tables); in _add_opp_table_indexed()
1591 return _update_opp_table_clk(dev, opp_table, getclk); in _add_opp_table_indexed()
1594 static struct opp_table *_add_opp_table(struct device *dev, bool getclk) in _add_opp_table()
1599 struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) in dev_pm_opp_get_opp_table()
1607 struct opp_table *opp_table = container_of(kref, struct opp_table, kref); in _opp_table_kref_release() local
1612 list_del(&opp_table->node); in _opp_table_kref_release()
1615 if (opp_table->current_opp) in _opp_table_kref_release()
1616 dev_pm_opp_put(opp_table->current_opp); in _opp_table_kref_release()
1618 _of_clear_opp_table(opp_table); in _opp_table_kref_release()
1621 if (!IS_ERR(opp_table->clk)) in _opp_table_kref_release()
1622 clk_put(opp_table->clk); in _opp_table_kref_release()
1624 if (opp_table->paths) { in _opp_table_kref_release()
1625 for (i = 0; i < opp_table->path_count; i++) in _opp_table_kref_release()
1626 icc_put(opp_table->paths[i]); in _opp_table_kref_release()
1627 kfree(opp_table->paths); in _opp_table_kref_release()
1630 WARN_ON(!list_empty(&opp_table->opp_list)); in _opp_table_kref_release()
1632 list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) in _opp_table_kref_release()
1633 _remove_opp_dev(opp_dev, opp_table); in _opp_table_kref_release()
1635 mutex_destroy(&opp_table->lock); in _opp_table_kref_release()
1636 kfree(opp_table); in _opp_table_kref_release()
1639 struct opp_table *dev_pm_opp_get_opp_table_ref(struct opp_table *opp_table) in dev_pm_opp_get_opp_table_ref() argument
1641 kref_get(&opp_table->kref); in dev_pm_opp_get_opp_table_ref()
1642 return opp_table; in dev_pm_opp_get_opp_table_ref()
1646 void dev_pm_opp_put_opp_table(struct opp_table *opp_table) in dev_pm_opp_put_opp_table() argument
1648 kref_put_mutex(&opp_table->kref, _opp_table_kref_release, in dev_pm_opp_put_opp_table()
1661 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release() local
1664 mutex_unlock(&opp_table->lock); in _opp_kref_release()
1670 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp); in _opp_kref_release()
1671 _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()
1698 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_remove()
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, 0)) in dev_pm_opp_remove()
1708 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_remove()
1709 list_for_each_entry(iter, &opp_table->opp_list, node) { in dev_pm_opp_remove()
1721 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1729 static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table, in _opp_get_next() argument
1734 guard(mutex)(&opp_table->lock); in _opp_get_next()
1736 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_get_next()
1753 static void _opp_remove_all(struct opp_table *opp_table, bool dynamic) in _opp_remove_all() argument
1757 while ((opp = _opp_get_next(opp_table, dynamic))) { in _opp_remove_all()
1763 dev_pm_opp_put_opp_table(opp_table); in _opp_remove_all()
1767 bool _opp_remove_all_static(struct opp_table *opp_table) in _opp_remove_all_static() argument
1769 scoped_guard(mutex, &opp_table->lock) { in _opp_remove_all_static()
1770 if (!opp_table->parsed_static_opps) in _opp_remove_all_static()
1773 if (--opp_table->parsed_static_opps) in _opp_remove_all_static()
1777 _opp_remove_all(opp_table, false); in _opp_remove_all_static()
1789 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_remove_all_dynamic()
1791 opp_table = _find_opp_table(dev); in dev_pm_opp_remove_all_dynamic()
1792 if (IS_ERR(opp_table)) in dev_pm_opp_remove_all_dynamic()
1795 _opp_remove_all(opp_table, true); in dev_pm_opp_remove_all_dynamic()
1799 struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table) in _opp_allocate() argument
1805 supply_count = opp_table->regulator_count > 0 ? in _opp_allocate()
1806 opp_table->regulator_count : 1; in _opp_allocate()
1808 clk_size = sizeof(*opp->rates) * opp_table->clk_count; in _opp_allocate()
1809 icc_size = sizeof(*opp->bandwidth) * opp_table->path_count; in _opp_allocate()
1822 opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->rates + opp_table->clk_count); in _opp_allocate()
1832 struct opp_table *opp_table) in _opp_supported_by_regulators() argument
1837 if (!opp_table->regulators) in _opp_supported_by_regulators()
1840 for (i = 0; i < opp_table->regulator_count; i++) { in _opp_supported_by_regulators()
1841 reg = opp_table->regulators[i]; in _opp_supported_by_regulators()
1856 static int _opp_compare_rate(struct opp_table *opp_table, in _opp_compare_rate() argument
1861 for (i = 0; i < opp_table->clk_count; i++) { in _opp_compare_rate()
1870 static int _opp_compare_bw(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_bw() argument
1875 for (i = 0; i < opp_table->path_count; i++) { in _opp_compare_bw()
1890 int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_key() argument
1895 ret = _opp_compare_rate(opp_table, opp1, opp2); in _opp_compare_key()
1899 ret = _opp_compare_bw(opp_table, opp1, opp2); in _opp_compare_key()
1911 struct opp_table *opp_table, in _opp_is_duplicate() argument
1925 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_is_duplicate()
1926 opp_cmp = _opp_compare_key(opp_table, new_opp, opp); in _opp_is_duplicate()
1975 struct opp_table *opp_table) in _opp_add() argument
1980 scoped_guard(mutex, &opp_table->lock) { in _opp_add()
1981 head = &opp_table->opp_list; in _opp_add()
1983 ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); in _opp_add()
1990 new_opp->opp_table = opp_table; in _opp_add()
1993 opp_debug_create_one(new_opp, opp_table); in _opp_add()
1995 if (!_opp_supported_by_regulators(new_opp, opp_table)) { in _opp_add()
2002 if (lazy_linking_pending(opp_table)) in _opp_add()
2005 _required_opps_available(new_opp, opp_table->required_opp_count); in _opp_add()
2031 int _opp_add_v1(struct opp_table *opp_table, struct device *dev, in _opp_add_v1() argument
2038 if (!assert_single_clk(opp_table, 0)) in _opp_add_v1()
2041 new_opp = _opp_allocate(opp_table); in _opp_add_v1()
2049 tol = u_volt * opp_table->voltage_tolerance_v1 / 100; in _opp_add_v1()
2056 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_v1()
2068 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_v1()
2083 static int _opp_set_supported_hw(struct opp_table *opp_table, in _opp_set_supported_hw() argument
2087 if (opp_table->supported_hw) in _opp_set_supported_hw()
2090 opp_table->supported_hw = kmemdup_array(versions, count, in _opp_set_supported_hw()
2092 if (!opp_table->supported_hw) in _opp_set_supported_hw()
2095 opp_table->supported_hw_count = count; in _opp_set_supported_hw()
2100 static void _opp_put_supported_hw(struct opp_table *opp_table) in _opp_put_supported_hw() argument
2102 if (opp_table->supported_hw) { in _opp_put_supported_hw()
2103 kfree(opp_table->supported_hw); in _opp_put_supported_hw()
2104 opp_table->supported_hw = NULL; in _opp_put_supported_hw()
2105 opp_table->supported_hw_count = 0; in _opp_put_supported_hw()
2115 static int _opp_set_prop_name(struct opp_table *opp_table, const char *name) in _opp_set_prop_name() argument
2118 if (!opp_table->prop_name) { in _opp_set_prop_name()
2119 opp_table->prop_name = kstrdup(name, GFP_KERNEL); in _opp_set_prop_name()
2120 if (!opp_table->prop_name) in _opp_set_prop_name()
2127 static void _opp_put_prop_name(struct opp_table *opp_table) in _opp_put_prop_name() argument
2129 if (opp_table->prop_name) { in _opp_put_prop_name()
2130 kfree(opp_table->prop_name); in _opp_put_prop_name()
2131 opp_table->prop_name = NULL; in _opp_put_prop_name()
2142 static int _opp_set_regulators(struct opp_table *opp_table, struct device *dev, in _opp_set_regulators() argument
2157 if (opp_table->regulators) in _opp_set_regulators()
2160 opp_table->regulators = kmalloc_array(count, in _opp_set_regulators()
2161 sizeof(*opp_table->regulators), in _opp_set_regulators()
2163 if (!opp_table->regulators) in _opp_set_regulators()
2175 opp_table->regulators[i] = reg; in _opp_set_regulators()
2178 opp_table->regulator_count = count; in _opp_set_regulators()
2182 opp_table->config_regulators = _opp_config_regulator_single; in _opp_set_regulators()
2188 regulator_put(opp_table->regulators[--i]); in _opp_set_regulators()
2190 kfree(opp_table->regulators); in _opp_set_regulators()
2191 opp_table->regulators = NULL; in _opp_set_regulators()
2192 opp_table->regulator_count = -1; in _opp_set_regulators()
2197 static void _opp_put_regulators(struct opp_table *opp_table) in _opp_put_regulators() argument
2201 if (!opp_table->regulators) in _opp_put_regulators()
2204 if (opp_table->enabled) { in _opp_put_regulators()
2205 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2206 regulator_disable(opp_table->regulators[i]); in _opp_put_regulators()
2209 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2210 regulator_put(opp_table->regulators[i]); in _opp_put_regulators()
2212 kfree(opp_table->regulators); in _opp_put_regulators()
2213 opp_table->regulators = NULL; in _opp_put_regulators()
2214 opp_table->regulator_count = -1; in _opp_put_regulators()
2217 static void _put_clks(struct opp_table *opp_table, int count) in _put_clks() argument
2222 clk_put(opp_table->clks[i]); in _put_clks()
2224 kfree(opp_table->clks); in _put_clks()
2225 opp_table->clks = NULL; in _put_clks()
2237 static int _opp_set_clknames(struct opp_table *opp_table, struct device *dev, in _opp_set_clknames() argument
2261 if (opp_table->clks) in _opp_set_clknames()
2264 opp_table->clks = kmalloc_array(count, sizeof(*opp_table->clks), in _opp_set_clknames()
2266 if (!opp_table->clks) in _opp_set_clknames()
2279 opp_table->clks[i] = clk; in _opp_set_clknames()
2282 opp_table->clk_count = count; in _opp_set_clknames()
2283 opp_table->config_clks = config_clks; in _opp_set_clknames()
2287 if (!opp_table->config_clks) in _opp_set_clknames()
2288 opp_table->config_clks = _opp_config_clk_single; in _opp_set_clknames()
2302 opp_table->clk = opp_table->clks[0]; in _opp_set_clknames()
2308 _put_clks(opp_table, i); in _opp_set_clknames()
2312 static void _opp_put_clknames(struct opp_table *opp_table) in _opp_put_clknames() argument
2314 if (!opp_table->clks) in _opp_put_clknames()
2317 opp_table->config_clks = NULL; in _opp_put_clknames()
2318 opp_table->clk = ERR_PTR(-ENODEV); in _opp_put_clknames()
2320 _put_clks(opp_table, opp_table->clk_count); in _opp_put_clknames()
2328 static int _opp_set_config_regulators_helper(struct opp_table *opp_table, in _opp_set_config_regulators_helper() argument
2332 if (!opp_table->config_regulators) in _opp_set_config_regulators_helper()
2333 opp_table->config_regulators = config_regulators; in _opp_set_config_regulators_helper()
2338 static void _opp_put_config_regulators_helper(struct opp_table *opp_table) in _opp_put_config_regulators_helper() argument
2340 if (opp_table->config_regulators) in _opp_put_config_regulators_helper()
2341 opp_table->config_regulators = NULL; in _opp_put_config_regulators_helper()
2344 static int _opp_set_required_dev(struct opp_table *opp_table, in _opp_set_required_dev() argument
2349 struct opp_table *required_table, *pd_table; in _opp_set_required_dev()
2353 if (opp_table->is_genpd) { in _opp_set_required_dev()
2358 if (index >= opp_table->required_opp_count) { in _opp_set_required_dev()
2363 required_table = opp_table->required_opp_tables[index]; in _opp_set_required_dev()
2390 opp_table->required_opp_tables[index] = pd_table; in _opp_set_required_dev()
2396 opp_table->required_devs[index] = required_dev; in _opp_set_required_dev()
2400 static void _opp_put_required_dev(struct opp_table *opp_table, in _opp_put_required_dev() argument
2403 opp_table->required_devs[index] = NULL; in _opp_put_required_dev()
2409 _opp_put_required_dev(data->opp_table, in _opp_clear_config()
2412 _opp_put_regulators(data->opp_table); in _opp_clear_config()
2414 _opp_put_supported_hw(data->opp_table); in _opp_clear_config()
2416 _opp_put_config_regulators_helper(data->opp_table); in _opp_clear_config()
2418 _opp_put_prop_name(data->opp_table); in _opp_clear_config()
2420 _opp_put_clknames(data->opp_table); in _opp_clear_config()
2422 dev_pm_opp_put_opp_table(data->opp_table); in _opp_clear_config()
2445 struct opp_table *opp_table; in dev_pm_opp_set_config() local
2454 opp_table = _add_opp_table(dev, false); in dev_pm_opp_set_config()
2455 if (IS_ERR(opp_table)) { in dev_pm_opp_set_config()
2457 return PTR_ERR(opp_table); in dev_pm_opp_set_config()
2460 data->opp_table = opp_table; in dev_pm_opp_set_config()
2464 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_set_config()
2471 ret = _opp_set_clknames(opp_table, dev, config->clk_names, in dev_pm_opp_set_config()
2485 ret = _opp_set_prop_name(opp_table, config->prop_name); in dev_pm_opp_set_config()
2494 ret = _opp_set_config_regulators_helper(opp_table, dev, in dev_pm_opp_set_config()
2504 ret = _opp_set_supported_hw(opp_table, config->supported_hw, in dev_pm_opp_set_config()
2514 ret = _opp_set_regulators(opp_table, dev, in dev_pm_opp_set_config()
2523 ret = _opp_set_required_dev(opp_table, dev, in dev_pm_opp_set_config()
2619 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, in dev_pm_opp_xlate_required_opp()
2620 struct opp_table *dst_table, in dev_pm_opp_xlate_required_opp()
2671 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, in dev_pm_opp_xlate_performance_state()
2672 struct opp_table *dst_table, in dev_pm_opp_xlate_performance_state()
2740 struct opp_table *opp_table; in dev_pm_opp_add_dynamic() local
2743 opp_table = _add_opp_table(dev, true); in dev_pm_opp_add_dynamic()
2744 if (IS_ERR(opp_table)) in dev_pm_opp_add_dynamic()
2745 return PTR_ERR(opp_table); in dev_pm_opp_add_dynamic()
2748 opp_table->regulator_count = 1; in dev_pm_opp_add_dynamic()
2750 ret = _opp_add_v1(opp_table, dev, data, true); in dev_pm_opp_add_dynamic()
2752 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_add_dynamic()
2775 struct opp_table *opp_table __free(put_opp_table); in _opp_set_availability()
2778 opp_table = _find_opp_table(dev); in _opp_set_availability()
2779 if (IS_ERR(opp_table)) { in _opp_set_availability()
2781 PTR_ERR(opp_table)); in _opp_set_availability()
2782 return PTR_ERR(opp_table); in _opp_set_availability()
2785 if (!assert_single_clk(opp_table, 0)) in _opp_set_availability()
2788 scoped_guard(mutex, &opp_table->lock) { in _opp_set_availability()
2790 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in _opp_set_availability()
2809 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, in _opp_set_availability()
2812 blocking_notifier_call_chain(&opp_table->head, in _opp_set_availability()
2836 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_adjust_voltage()
2840 opp_table = _find_opp_table(dev); in dev_pm_opp_adjust_voltage()
2841 if (IS_ERR(opp_table)) { in dev_pm_opp_adjust_voltage()
2842 r = PTR_ERR(opp_table); in dev_pm_opp_adjust_voltage()
2847 if (!assert_single_clk(opp_table, 0)) in dev_pm_opp_adjust_voltage()
2850 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_adjust_voltage()
2852 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in dev_pm_opp_adjust_voltage()
2873 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, in dev_pm_opp_adjust_voltage()
2890 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_sync_regulators()
2895 opp_table = _find_opp_table(dev); in dev_pm_opp_sync_regulators()
2896 if (IS_ERR(opp_table)) in dev_pm_opp_sync_regulators()
2900 if (unlikely(!opp_table->regulators)) in dev_pm_opp_sync_regulators()
2904 if (!opp_table->enabled) in dev_pm_opp_sync_regulators()
2907 for (i = 0; i < opp_table->regulator_count; i++) { in dev_pm_opp_sync_regulators()
2908 reg = opp_table->regulators[i]; in dev_pm_opp_sync_regulators()
2966 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_register_notifier()
2968 opp_table = _find_opp_table(dev); in dev_pm_opp_register_notifier()
2969 if (IS_ERR(opp_table)) in dev_pm_opp_register_notifier()
2970 return PTR_ERR(opp_table); in dev_pm_opp_register_notifier()
2972 return blocking_notifier_chain_register(&opp_table->head, nb); in dev_pm_opp_register_notifier()
2986 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_unregister_notifier()
2988 opp_table = _find_opp_table(dev); in dev_pm_opp_unregister_notifier()
2989 if (IS_ERR(opp_table)) in dev_pm_opp_unregister_notifier()
2990 return PTR_ERR(opp_table); in dev_pm_opp_unregister_notifier()
2992 return blocking_notifier_chain_unregister(&opp_table->head, nb); in dev_pm_opp_unregister_notifier()
3005 struct opp_table *opp_table __free(put_opp_table); in dev_pm_opp_remove_table()
3008 opp_table = _find_opp_table(dev); in dev_pm_opp_remove_table()
3009 if (IS_ERR(opp_table)) { in dev_pm_opp_remove_table()
3010 int error = PTR_ERR(opp_table); in dev_pm_opp_remove_table()
3024 if (_opp_remove_all_static(opp_table)) in dev_pm_opp_remove_table()
3025 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_table()