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()
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()
339 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_get_max_volt_latency()
342 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_volt_latency()
346 if (!opp_table->regulators) in dev_pm_opp_get_max_volt_latency()
349 count = opp_table->regulator_count; in dev_pm_opp_get_max_volt_latency()
355 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_get_max_volt_latency()
360 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_get_max_volt_latency()
377 reg = opp_table->regulators[i]; in dev_pm_opp_get_max_volt_latency()
415 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_get_suspend_opp_freq()
418 if (IS_ERR(opp_table)) in dev_pm_opp_get_suspend_opp_freq()
421 if (opp_table->suspend_opp && opp_table->suspend_opp->available) in dev_pm_opp_get_suspend_opp_freq()
422 freq = dev_pm_opp_get_freq(opp_table->suspend_opp); in dev_pm_opp_get_suspend_opp_freq()
428 int _get_opp_count(struct opp_table *opp_table) in _get_opp_count() argument
433 guard(mutex)(&opp_table->lock); in _get_opp_count()
435 list_for_each_entry(opp, &opp_table->opp_list, node) { in _get_opp_count()
452 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_get_opp_count()
455 if (IS_ERR(opp_table)) { in dev_pm_opp_get_opp_count()
457 __func__, PTR_ERR(opp_table)); in dev_pm_opp_get_opp_count()
458 return PTR_ERR(opp_table); in dev_pm_opp_get_opp_count()
461 return _get_opp_count(opp_table); in dev_pm_opp_get_opp_count()
541 static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table, in _opp_table_find_key() argument
546 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _opp_table_find_key() argument
551 if (assert && !assert(opp_table, index)) in _opp_table_find_key()
554 guard(mutex)(&opp_table->lock); in _opp_table_find_key()
556 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in _opp_table_find_key()
572 static struct dev_pm_opp *_opp_table_find_opp_key(struct opp_table *opp_table, in _opp_table_find_opp_key() argument
578 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _opp_table_find_opp_key() argument
584 if (!assert(opp_table, 0)) in _opp_table_find_opp_key()
587 guard(mutex)(&opp_table->lock); in _opp_table_find_opp_key()
589 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in _opp_table_find_opp_key()
608 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key() argument
610 struct opp_table *opp_table __free(put_opp_table) = in _find_key()
613 if (IS_ERR(opp_table)) { in _find_key()
615 PTR_ERR(opp_table)); in _find_key()
616 return ERR_CAST(opp_table); in _find_key()
619 return _opp_table_find_key(opp_table, key, index, available, read, in _find_key()
626 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_exact() argument
636 static struct dev_pm_opp *_opp_table_find_key_ceil(struct opp_table *opp_table, in _opp_table_find_key_ceil() argument
639 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _opp_table_find_key_ceil() argument
641 return _opp_table_find_key(opp_table, key, index, available, read, in _opp_table_find_key_ceil()
648 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_ceil() argument
657 bool (*assert)(struct opp_table *opp_table, unsigned int index)) in _find_key_floor() argument
722 struct opp_table *opp_table __free(put_opp_table) = _find_opp_table(dev); in dev_pm_opp_find_key_exact()
724 if (IS_ERR(opp_table)) { in dev_pm_opp_find_key_exact()
726 PTR_ERR(opp_table)); in dev_pm_opp_find_key_exact()
727 return ERR_CAST(opp_table); in dev_pm_opp_find_key_exact()
730 return _opp_table_find_opp_key(opp_table, key, available, in dev_pm_opp_find_key_exact()
765 static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, in _find_freq_ceil() argument
768 return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq, in _find_freq_ceil()
1058 _opp_config_clk_single(struct device *dev, struct opp_table *opp_table, in _opp_config_clk_single() argument
1075 ret = clk_set_rate(opp_table->clk, freq); in _opp_config_clk_single()
1080 opp_table->current_rate_single_clk = freq; in _opp_config_clk_single()
1091 struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, in dev_pm_opp_config_clks_simple() argument
1097 for (i = opp_table->clk_count - 1; i >= 0; i--) { in dev_pm_opp_config_clks_simple()
1098 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
1106 for (i = 0; i < opp_table->clk_count; i++) { in dev_pm_opp_config_clks_simple()
1107 ret = clk_set_rate(opp_table->clks[i], opp->rates[i]); in dev_pm_opp_config_clks_simple()
1141 if (unlikely(!new_opp->opp_table->enabled)) { in _opp_config_regulator_single()
1150 static int _set_opp_bw(const struct opp_table *opp_table, in _set_opp_bw() argument
1156 if (!opp_table->paths) in _set_opp_bw()
1159 for (i = 0; i < opp_table->path_count; i++) { in _set_opp_bw()
1167 ret = icc_set_bw(opp_table->paths[i], avg, peak); in _set_opp_bw()
1200 static int _set_required_opps(struct device *dev, struct opp_table *opp_table, in _set_required_opps() argument
1203 struct device **devs = opp_table->required_devs; in _set_required_opps()
1211 if (lazy_linking_pending(opp_table)) in _set_required_opps()
1217 target = opp_table->required_opp_count; in _set_required_opps()
1220 index = opp_table->required_opp_count - 1; in _set_required_opps()
1240 static void _find_current_opp(struct device *dev, struct opp_table *opp_table) in _find_current_opp() argument
1245 if (!IS_ERR(opp_table->clk)) { in _find_current_opp()
1246 freq = clk_get_rate(opp_table->clk); in _find_current_opp()
1247 opp = _find_freq_ceil(opp_table, &freq); in _find_current_opp()
1256 guard(mutex)(&opp_table->lock); in _find_current_opp()
1257 opp = dev_pm_opp_get(list_first_entry(&opp_table->opp_list, in _find_current_opp()
1261 opp_table->current_opp = opp; in _find_current_opp()
1264 static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) in _disable_opp_table() argument
1268 if (!opp_table->enabled) in _disable_opp_table()
1276 if (!_get_opp_count(opp_table)) in _disable_opp_table()
1279 ret = _set_opp_bw(opp_table, NULL, dev); in _disable_opp_table()
1283 if (opp_table->regulators) in _disable_opp_table()
1284 regulator_disable(opp_table->regulators[0]); in _disable_opp_table()
1290 ret = _set_required_opps(dev, opp_table, NULL, false); in _disable_opp_table()
1293 opp_table->enabled = false; in _disable_opp_table()
1297 static int _set_opp(struct device *dev, struct opp_table *opp_table, in _set_opp() argument
1304 return _disable_opp_table(dev, opp_table); in _set_opp()
1307 if (unlikely(!opp_table->current_opp)) in _set_opp()
1308 _find_current_opp(dev, opp_table); in _set_opp()
1310 old_opp = opp_table->current_opp; in _set_opp()
1313 if (!forced && old_opp == opp && opp_table->enabled) { in _set_opp()
1323 scaling_down = _opp_compare_key(opp_table, old_opp, opp); in _set_opp()
1329 ret = _set_required_opps(dev, opp_table, opp, true); in _set_opp()
1339 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1345 if (opp_table->config_regulators) { in _set_opp()
1346 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1347 opp_table->regulators, in _set_opp()
1348 opp_table->regulator_count); in _set_opp()
1357 if (opp_table->config_clks) { in _set_opp()
1358 ret = opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_down); in _set_opp()
1365 if (opp_table->config_regulators) { in _set_opp()
1366 ret = opp_table->config_regulators(dev, old_opp, opp, in _set_opp()
1367 opp_table->regulators, in _set_opp()
1368 opp_table->regulator_count); in _set_opp()
1376 ret = _set_opp_bw(opp_table, opp, dev); in _set_opp()
1386 ret = _set_required_opps(dev, opp_table, opp, false); in _set_opp()
1393 opp_table->enabled = true; in _set_opp()
1397 opp_table->current_opp = dev_pm_opp_get(opp); in _set_opp()
1419 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_set_rate()
1422 if (IS_ERR(opp_table)) { in dev_pm_opp_set_rate()
1424 return PTR_ERR(opp_table); in dev_pm_opp_set_rate()
1435 if (!_get_opp_count(opp_table)) { in dev_pm_opp_set_rate()
1436 return opp_table->config_clks(dev, opp_table, NULL, in dev_pm_opp_set_rate()
1440 freq = clk_round_rate(opp_table->clk, target_freq); in dev_pm_opp_set_rate()
1450 opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
1464 forced = opp_table->current_rate_single_clk != freq; in dev_pm_opp_set_rate()
1467 return _set_opp(dev, opp_table, opp, &freq, forced); in dev_pm_opp_set_rate()
1483 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_set_opp()
1486 if (IS_ERR(opp_table)) { in dev_pm_opp_set_opp()
1488 return PTR_ERR(opp_table); in dev_pm_opp_set_opp()
1491 return _set_opp(dev, opp_table, opp, NULL, false); in dev_pm_opp_set_opp()
1497 struct opp_table *opp_table) in _remove_opp_dev() argument
1499 opp_debug_unregister(opp_dev, opp_table); in _remove_opp_dev()
1505 struct opp_table *opp_table) in _add_opp_dev() argument
1516 scoped_guard(mutex, &opp_table->lock) in _add_opp_dev()
1517 list_add(&opp_dev->node, &opp_table->dev_list); in _add_opp_dev()
1520 opp_debug_register(opp_dev, opp_table); in _add_opp_dev()
1525 static struct opp_table *_allocate_opp_table(struct device *dev, int index) in _allocate_opp_table()
1527 struct opp_table *opp_table; in _allocate_opp_table() local
1535 opp_table = kzalloc_obj(*opp_table); in _allocate_opp_table()
1536 if (!opp_table) in _allocate_opp_table()
1539 mutex_init(&opp_table->lock); in _allocate_opp_table()
1540 INIT_LIST_HEAD(&opp_table->dev_list); in _allocate_opp_table()
1541 INIT_LIST_HEAD(&opp_table->lazy); in _allocate_opp_table()
1543 opp_table->clk = ERR_PTR(-ENODEV); in _allocate_opp_table()
1546 opp_table->regulator_count = -1; in _allocate_opp_table()
1548 opp_dev = _add_opp_dev(dev, opp_table); in _allocate_opp_table()
1554 _of_init_opp_table(opp_table, dev, index); in _allocate_opp_table()
1557 ret = dev_pm_opp_of_find_icc_paths(dev, opp_table); in _allocate_opp_table()
1566 BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); in _allocate_opp_table()
1567 INIT_LIST_HEAD(&opp_table->opp_list); in _allocate_opp_table()
1568 kref_init(&opp_table->kref); in _allocate_opp_table()
1570 return opp_table; in _allocate_opp_table()
1573 _of_clear_opp_table(opp_table); in _allocate_opp_table()
1574 _remove_opp_dev(opp_dev, opp_table); in _allocate_opp_table()
1575 mutex_destroy(&opp_table->lock); in _allocate_opp_table()
1577 kfree(opp_table); in _allocate_opp_table()
1581 static struct opp_table *_update_opp_table_clk(struct device *dev, in _update_opp_table_clk()
1582 struct opp_table *opp_table, in _update_opp_table_clk() argument
1591 if (!getclk || IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || in _update_opp_table_clk()
1592 opp_table->clks) in _update_opp_table_clk()
1593 return opp_table; in _update_opp_table_clk()
1596 opp_table->clk = clk_get(dev, NULL); in _update_opp_table_clk()
1598 ret = PTR_ERR_OR_ZERO(opp_table->clk); in _update_opp_table_clk()
1600 opp_table->config_clks = _opp_config_clk_single; in _update_opp_table_clk()
1601 opp_table->clk_count = 1; in _update_opp_table_clk()
1602 return opp_table; in _update_opp_table_clk()
1618 opp_table->clk_count = 1; in _update_opp_table_clk()
1621 return opp_table; in _update_opp_table_clk()
1624 dev_pm_opp_put_opp_table(opp_table); in _update_opp_table_clk()
1645 struct opp_table *_add_opp_table_indexed(struct device *dev, int index, in _add_opp_table_indexed()
1648 struct opp_table *opp_table; in _add_opp_table_indexed() local
1653 opp_table = _find_opp_table_unlocked(dev); in _add_opp_table_indexed()
1654 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1668 opp_table = _managed_opp(dev, index); in _add_opp_table_indexed()
1673 if (opp_table) { in _add_opp_table_indexed()
1674 if (!_add_opp_dev(dev, opp_table)) { in _add_opp_table_indexed()
1675 dev_pm_opp_put_opp_table(opp_table); in _add_opp_table_indexed()
1676 opp_table = ERR_PTR(-ENOMEM); in _add_opp_table_indexed()
1681 opp_table = _allocate_opp_table(dev, index); in _add_opp_table_indexed()
1684 if (!IS_ERR(opp_table)) in _add_opp_table_indexed()
1685 list_add(&opp_table->node, &opp_tables); in _add_opp_table_indexed()
1693 return _update_opp_table_clk(dev, opp_table, getclk); in _add_opp_table_indexed()
1696 static struct opp_table *_add_opp_table(struct device *dev, bool getclk) in _add_opp_table()
1701 struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) in dev_pm_opp_get_opp_table()
1709 struct opp_table *opp_table = container_of(kref, struct opp_table, kref); in _opp_table_kref_release() local
1714 list_del(&opp_table->node); in _opp_table_kref_release()
1717 if (opp_table->current_opp) in _opp_table_kref_release()
1718 dev_pm_opp_put(opp_table->current_opp); in _opp_table_kref_release()
1720 _of_clear_opp_table(opp_table); in _opp_table_kref_release()
1723 if (!IS_ERR(opp_table->clk)) in _opp_table_kref_release()
1724 clk_put(opp_table->clk); in _opp_table_kref_release()
1726 if (opp_table->paths) { in _opp_table_kref_release()
1727 for (i = 0; i < opp_table->path_count; i++) in _opp_table_kref_release()
1728 icc_put(opp_table->paths[i]); in _opp_table_kref_release()
1729 kfree(opp_table->paths); in _opp_table_kref_release()
1732 WARN_ON(!list_empty(&opp_table->opp_list)); in _opp_table_kref_release()
1734 list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) in _opp_table_kref_release()
1735 _remove_opp_dev(opp_dev, opp_table); in _opp_table_kref_release()
1737 mutex_destroy(&opp_table->lock); in _opp_table_kref_release()
1738 kfree(opp_table); in _opp_table_kref_release()
1741 struct opp_table *dev_pm_opp_get_opp_table_ref(struct opp_table *opp_table) in dev_pm_opp_get_opp_table_ref() argument
1743 kref_get(&opp_table->kref); in dev_pm_opp_get_opp_table_ref()
1744 return opp_table; in dev_pm_opp_get_opp_table_ref()
1748 void dev_pm_opp_put_opp_table(struct opp_table *opp_table) in dev_pm_opp_put_opp_table() argument
1750 kref_put_mutex(&opp_table->kref, _opp_table_kref_release, in dev_pm_opp_put_opp_table()
1763 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release() local
1766 mutex_unlock(&opp_table->lock); in _opp_kref_release()
1772 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp); in _opp_kref_release()
1773 _of_clear_opp(opp_table, opp); in _opp_kref_release()
1787 kref_put_mutex(&opp->kref, _opp_kref_release, &opp->opp_table->lock); in dev_pm_opp_put()
1802 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_remove()
1805 if (IS_ERR(opp_table)) in dev_pm_opp_remove()
1808 if (!assert_single_clk(opp_table, 0)) in dev_pm_opp_remove()
1811 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_remove()
1812 list_for_each_entry(iter, &opp_table->opp_list, node) { in dev_pm_opp_remove()
1824 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1832 static struct dev_pm_opp *_opp_get_next(struct opp_table *opp_table, in _opp_get_next() argument
1837 guard(mutex)(&opp_table->lock); in _opp_get_next()
1839 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_get_next()
1856 static void _opp_remove_all(struct opp_table *opp_table, bool dynamic) in _opp_remove_all() argument
1860 while ((opp = _opp_get_next(opp_table, dynamic))) { in _opp_remove_all()
1866 dev_pm_opp_put_opp_table(opp_table); in _opp_remove_all()
1870 bool _opp_remove_all_static(struct opp_table *opp_table) in _opp_remove_all_static() argument
1872 scoped_guard(mutex, &opp_table->lock) { in _opp_remove_all_static()
1873 if (!opp_table->parsed_static_opps) in _opp_remove_all_static()
1876 if (--opp_table->parsed_static_opps) in _opp_remove_all_static()
1880 _opp_remove_all(opp_table, false); in _opp_remove_all_static()
1892 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_remove_all_dynamic()
1895 if (IS_ERR(opp_table)) in dev_pm_opp_remove_all_dynamic()
1898 _opp_remove_all(opp_table, true); in dev_pm_opp_remove_all_dynamic()
1902 struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table) in _opp_allocate() argument
1908 supply_count = opp_table->regulator_count > 0 ? in _opp_allocate()
1909 opp_table->regulator_count : 1; in _opp_allocate()
1911 clk_size = sizeof(*opp->rates) * opp_table->clk_count; in _opp_allocate()
1912 icc_size = sizeof(*opp->bandwidth) * opp_table->path_count; in _opp_allocate()
1925 opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->rates + opp_table->clk_count); in _opp_allocate()
1935 struct opp_table *opp_table) in _opp_supported_by_regulators() argument
1940 if (!opp_table->regulators) in _opp_supported_by_regulators()
1943 for (i = 0; i < opp_table->regulator_count; i++) { in _opp_supported_by_regulators()
1944 reg = opp_table->regulators[i]; in _opp_supported_by_regulators()
1959 static int _opp_compare_rate(struct opp_table *opp_table, in _opp_compare_rate() argument
1964 for (i = 0; i < opp_table->clk_count; i++) { in _opp_compare_rate()
1973 static int _opp_compare_bw(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_bw() argument
1978 for (i = 0; i < opp_table->path_count; i++) { in _opp_compare_bw()
1993 int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1, in _opp_compare_key() argument
1998 ret = _opp_compare_rate(opp_table, opp1, opp2); in _opp_compare_key()
2002 ret = _opp_compare_bw(opp_table, opp1, opp2); in _opp_compare_key()
2014 struct opp_table *opp_table, in _opp_is_duplicate() argument
2028 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_is_duplicate()
2029 opp_cmp = _opp_compare_key(opp_table, new_opp, opp); in _opp_is_duplicate()
2078 struct opp_table *opp_table) in _opp_add() argument
2083 scoped_guard(mutex, &opp_table->lock) { in _opp_add()
2084 head = &opp_table->opp_list; in _opp_add()
2086 ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); in _opp_add()
2093 new_opp->opp_table = opp_table; in _opp_add()
2096 opp_debug_create_one(new_opp, opp_table); in _opp_add()
2098 if (!_opp_supported_by_regulators(new_opp, opp_table)) { in _opp_add()
2105 if (lazy_linking_pending(opp_table)) in _opp_add()
2108 _required_opps_available(new_opp, opp_table->required_opp_count); in _opp_add()
2134 int _opp_add_v1(struct opp_table *opp_table, struct device *dev, in _opp_add_v1() argument
2141 if (!assert_single_clk(opp_table, 0)) in _opp_add_v1()
2144 new_opp = _opp_allocate(opp_table); in _opp_add_v1()
2152 tol = u_volt * opp_table->voltage_tolerance_v1 / 100; in _opp_add_v1()
2159 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_v1()
2171 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_v1()
2186 static int _opp_set_supported_hw(struct opp_table *opp_table, in _opp_set_supported_hw() argument
2190 if (opp_table->supported_hw) in _opp_set_supported_hw()
2193 opp_table->supported_hw = kmemdup_array(versions, count, in _opp_set_supported_hw()
2195 if (!opp_table->supported_hw) in _opp_set_supported_hw()
2198 opp_table->supported_hw_count = count; in _opp_set_supported_hw()
2203 static void _opp_put_supported_hw(struct opp_table *opp_table) in _opp_put_supported_hw() argument
2205 if (opp_table->supported_hw) { in _opp_put_supported_hw()
2206 kfree(opp_table->supported_hw); in _opp_put_supported_hw()
2207 opp_table->supported_hw = NULL; in _opp_put_supported_hw()
2208 opp_table->supported_hw_count = 0; in _opp_put_supported_hw()
2218 static int _opp_set_prop_name(struct opp_table *opp_table, const char *name) in _opp_set_prop_name() argument
2221 if (!opp_table->prop_name) { in _opp_set_prop_name()
2222 opp_table->prop_name = kstrdup(name, GFP_KERNEL); in _opp_set_prop_name()
2223 if (!opp_table->prop_name) in _opp_set_prop_name()
2230 static void _opp_put_prop_name(struct opp_table *opp_table) in _opp_put_prop_name() argument
2232 if (opp_table->prop_name) { in _opp_put_prop_name()
2233 kfree(opp_table->prop_name); in _opp_put_prop_name()
2234 opp_table->prop_name = NULL; in _opp_put_prop_name()
2245 static int _opp_set_regulators(struct opp_table *opp_table, struct device *dev, in _opp_set_regulators() argument
2260 if (opp_table->regulators) in _opp_set_regulators()
2263 opp_table->regulators = kmalloc_objs(*opp_table->regulators, count); in _opp_set_regulators()
2264 if (!opp_table->regulators) in _opp_set_regulators()
2276 opp_table->regulators[i] = reg; in _opp_set_regulators()
2279 opp_table->regulator_count = count; in _opp_set_regulators()
2283 opp_table->config_regulators = _opp_config_regulator_single; in _opp_set_regulators()
2289 regulator_put(opp_table->regulators[--i]); in _opp_set_regulators()
2291 kfree(opp_table->regulators); in _opp_set_regulators()
2292 opp_table->regulators = NULL; in _opp_set_regulators()
2293 opp_table->regulator_count = -1; in _opp_set_regulators()
2298 static void _opp_put_regulators(struct opp_table *opp_table) in _opp_put_regulators() argument
2302 if (!opp_table->regulators) in _opp_put_regulators()
2305 if (opp_table->enabled) { in _opp_put_regulators()
2306 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2307 regulator_disable(opp_table->regulators[i]); in _opp_put_regulators()
2310 for (i = opp_table->regulator_count - 1; i >= 0; i--) in _opp_put_regulators()
2311 regulator_put(opp_table->regulators[i]); in _opp_put_regulators()
2313 kfree(opp_table->regulators); in _opp_put_regulators()
2314 opp_table->regulators = NULL; in _opp_put_regulators()
2315 opp_table->regulator_count = -1; in _opp_put_regulators()
2318 static void _put_clks(struct opp_table *opp_table, int count) in _put_clks() argument
2323 clk_put(opp_table->clks[i]); in _put_clks()
2325 kfree(opp_table->clks); in _put_clks()
2326 opp_table->clks = NULL; in _put_clks()
2338 static int _opp_set_clknames(struct opp_table *opp_table, struct device *dev, in _opp_set_clknames() argument
2362 if (opp_table->clks) in _opp_set_clknames()
2365 opp_table->clks = kmalloc_objs(*opp_table->clks, count); in _opp_set_clknames()
2366 if (!opp_table->clks) in _opp_set_clknames()
2379 opp_table->clks[i] = clk; in _opp_set_clknames()
2382 opp_table->clk_count = count; in _opp_set_clknames()
2383 opp_table->config_clks = config_clks; in _opp_set_clknames()
2387 if (!opp_table->config_clks) in _opp_set_clknames()
2388 opp_table->config_clks = _opp_config_clk_single; in _opp_set_clknames()
2402 opp_table->clk = opp_table->clks[0]; in _opp_set_clknames()
2408 _put_clks(opp_table, i); in _opp_set_clknames()
2412 static void _opp_put_clknames(struct opp_table *opp_table) in _opp_put_clknames() argument
2414 if (!opp_table->clks) in _opp_put_clknames()
2417 opp_table->config_clks = NULL; in _opp_put_clknames()
2418 opp_table->clk = ERR_PTR(-ENODEV); in _opp_put_clknames()
2420 _put_clks(opp_table, opp_table->clk_count); in _opp_put_clknames()
2428 static int _opp_set_config_regulators_helper(struct opp_table *opp_table, in _opp_set_config_regulators_helper() argument
2432 if (!opp_table->config_regulators) in _opp_set_config_regulators_helper()
2433 opp_table->config_regulators = config_regulators; in _opp_set_config_regulators_helper()
2438 static void _opp_put_config_regulators_helper(struct opp_table *opp_table) in _opp_put_config_regulators_helper() argument
2440 if (opp_table->config_regulators) in _opp_put_config_regulators_helper()
2441 opp_table->config_regulators = NULL; in _opp_put_config_regulators_helper()
2444 static int _opp_set_required_dev(struct opp_table *opp_table, in _opp_set_required_dev() argument
2449 struct opp_table *required_table, *pd_table; in _opp_set_required_dev()
2453 if (opp_table->is_genpd) { in _opp_set_required_dev()
2458 if (index >= opp_table->required_opp_count) { in _opp_set_required_dev()
2463 required_table = opp_table->required_opp_tables[index]; in _opp_set_required_dev()
2490 opp_table->required_opp_tables[index] = pd_table; in _opp_set_required_dev()
2496 opp_table->required_devs[index] = required_dev; in _opp_set_required_dev()
2500 static void _opp_put_required_dev(struct opp_table *opp_table, in _opp_put_required_dev() argument
2503 opp_table->required_devs[index] = NULL; in _opp_put_required_dev()
2509 _opp_put_required_dev(data->opp_table, in _opp_clear_config()
2512 _opp_put_regulators(data->opp_table); in _opp_clear_config()
2514 _opp_put_supported_hw(data->opp_table); in _opp_clear_config()
2516 _opp_put_config_regulators_helper(data->opp_table); in _opp_clear_config()
2518 _opp_put_prop_name(data->opp_table); in _opp_clear_config()
2520 _opp_put_clknames(data->opp_table); in _opp_clear_config()
2522 dev_pm_opp_put_opp_table(data->opp_table); in _opp_clear_config()
2545 struct opp_table *opp_table; in dev_pm_opp_set_config() local
2554 opp_table = _add_opp_table(dev, false); in dev_pm_opp_set_config()
2555 if (IS_ERR(opp_table)) { in dev_pm_opp_set_config()
2557 return PTR_ERR(opp_table); in dev_pm_opp_set_config()
2560 data->opp_table = opp_table; in dev_pm_opp_set_config()
2564 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_set_config()
2571 ret = _opp_set_clknames(opp_table, dev, config->clk_names, in dev_pm_opp_set_config()
2585 ret = _opp_set_prop_name(opp_table, config->prop_name); in dev_pm_opp_set_config()
2594 ret = _opp_set_config_regulators_helper(opp_table, dev, in dev_pm_opp_set_config()
2604 ret = _opp_set_supported_hw(opp_table, config->supported_hw, in dev_pm_opp_set_config()
2614 ret = _opp_set_regulators(opp_table, dev, in dev_pm_opp_set_config()
2623 ret = _opp_set_required_dev(opp_table, dev, in dev_pm_opp_set_config()
2719 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, in dev_pm_opp_xlate_required_opp()
2720 struct opp_table *dst_table, in dev_pm_opp_xlate_required_opp()
2771 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, in dev_pm_opp_xlate_performance_state()
2772 struct opp_table *dst_table, in dev_pm_opp_xlate_performance_state()
2840 struct opp_table *opp_table; in dev_pm_opp_add_dynamic() local
2843 opp_table = _add_opp_table(dev, true); in dev_pm_opp_add_dynamic()
2844 if (IS_ERR(opp_table)) in dev_pm_opp_add_dynamic()
2845 return PTR_ERR(opp_table); in dev_pm_opp_add_dynamic()
2848 opp_table->regulator_count = 1; in dev_pm_opp_add_dynamic()
2850 ret = _opp_add_v1(opp_table, dev, data, true); in dev_pm_opp_add_dynamic()
2852 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_add_dynamic()
2877 struct opp_table *opp_table __free(put_opp_table) = in _opp_set_availability()
2880 if (IS_ERR(opp_table)) { in _opp_set_availability()
2882 PTR_ERR(opp_table)); in _opp_set_availability()
2883 return PTR_ERR(opp_table); in _opp_set_availability()
2886 if (!assert_single_clk(opp_table, 0)) in _opp_set_availability()
2889 scoped_guard(mutex, &opp_table->lock) { in _opp_set_availability()
2891 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in _opp_set_availability()
2910 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, in _opp_set_availability()
2913 blocking_notifier_call_chain(&opp_table->head, in _opp_set_availability()
2940 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_adjust_voltage()
2943 if (IS_ERR(opp_table)) { in dev_pm_opp_adjust_voltage()
2944 r = PTR_ERR(opp_table); in dev_pm_opp_adjust_voltage()
2949 if (!assert_single_clk(opp_table, 0)) in dev_pm_opp_adjust_voltage()
2952 scoped_guard(mutex, &opp_table->lock) { in dev_pm_opp_adjust_voltage()
2954 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in dev_pm_opp_adjust_voltage()
2975 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, in dev_pm_opp_adjust_voltage()
2996 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_sync_regulators()
2999 if (IS_ERR(opp_table)) in dev_pm_opp_sync_regulators()
3003 if (unlikely(!opp_table->regulators)) in dev_pm_opp_sync_regulators()
3007 if (!opp_table->enabled) in dev_pm_opp_sync_regulators()
3010 for (i = 0; i < opp_table->regulator_count; i++) { in dev_pm_opp_sync_regulators()
3011 reg = opp_table->regulators[i]; in dev_pm_opp_sync_regulators()
3069 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_register_notifier()
3072 if (IS_ERR(opp_table)) in dev_pm_opp_register_notifier()
3073 return PTR_ERR(opp_table); in dev_pm_opp_register_notifier()
3075 return blocking_notifier_chain_register(&opp_table->head, nb); in dev_pm_opp_register_notifier()
3089 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_unregister_notifier()
3092 if (IS_ERR(opp_table)) in dev_pm_opp_unregister_notifier()
3093 return PTR_ERR(opp_table); in dev_pm_opp_unregister_notifier()
3095 return blocking_notifier_chain_unregister(&opp_table->head, nb); in dev_pm_opp_unregister_notifier()
3109 struct opp_table *opp_table __free(put_opp_table) = in dev_pm_opp_remove_table()
3112 if (IS_ERR(opp_table)) { in dev_pm_opp_remove_table()
3113 int error = PTR_ERR(opp_table); in dev_pm_opp_remove_table()
3127 if (_opp_remove_all_static(opp_table)) in dev_pm_opp_remove_table()
3128 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_table()