Lines Matching refs:opp_table
34 struct opp_table *opp_table) in _find_opp_dev() argument
38 list_for_each_entry(opp_dev, &opp_table->dev_list, node) in _find_opp_dev()
45 static struct opp_table *_find_opp_table_unlocked(struct device *dev) in _find_opp_table_unlocked()
47 struct opp_table *opp_table; in _find_opp_table_unlocked() local
50 list_for_each_entry(opp_table, &opp_tables, node) { in _find_opp_table_unlocked()
51 mutex_lock(&opp_table->lock); in _find_opp_table_unlocked()
52 found = !!_find_opp_dev(dev, opp_table); in _find_opp_table_unlocked()
53 mutex_unlock(&opp_table->lock); in _find_opp_table_unlocked()
56 _get_opp_table_kref(opp_table); in _find_opp_table_unlocked()
58 return opp_table; in _find_opp_table_unlocked()
76 struct opp_table *_find_opp_table(struct device *dev) in _find_opp_table()
78 struct opp_table *opp_table; in _find_opp_table() local
86 opp_table = _find_opp_table_unlocked(dev); in _find_opp_table()
89 return opp_table; in _find_opp_table()
177 struct opp_table *opp_table; in dev_pm_opp_get_max_clock_latency() local
180 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_clock_latency()
181 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_clock_latency()
184 clock_latency_ns = opp_table->clock_latency_ns_max; in dev_pm_opp_get_max_clock_latency()
186 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_max_clock_latency()
200 struct opp_table *opp_table; in dev_pm_opp_get_max_volt_latency() local
210 opp_table = _find_opp_table(dev); in dev_pm_opp_get_max_volt_latency()
211 if (IS_ERR(opp_table)) in dev_pm_opp_get_max_volt_latency()
215 if (!opp_table->regulators) in dev_pm_opp_get_max_volt_latency()
218 count = opp_table->regulator_count; in dev_pm_opp_get_max_volt_latency()
224 mutex_lock(&opp_table->lock); in dev_pm_opp_get_max_volt_latency()
230 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_get_max_volt_latency()
241 mutex_unlock(&opp_table->lock); in dev_pm_opp_get_max_volt_latency()
248 reg = opp_table->regulators[i]; in dev_pm_opp_get_max_volt_latency()
256 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_max_volt_latency()
286 struct opp_table *opp_table; in dev_pm_opp_get_suspend_opp_freq() local
289 opp_table = _find_opp_table(dev); in dev_pm_opp_get_suspend_opp_freq()
290 if (IS_ERR(opp_table)) in dev_pm_opp_get_suspend_opp_freq()
293 if (opp_table->suspend_opp && opp_table->suspend_opp->available) in dev_pm_opp_get_suspend_opp_freq()
294 freq = dev_pm_opp_get_freq(opp_table->suspend_opp); in dev_pm_opp_get_suspend_opp_freq()
296 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_suspend_opp_freq()
302 int _get_opp_count(struct opp_table *opp_table) in _get_opp_count() argument
307 mutex_lock(&opp_table->lock); in _get_opp_count()
309 list_for_each_entry(opp, &opp_table->opp_list, node) { in _get_opp_count()
314 mutex_unlock(&opp_table->lock); in _get_opp_count()
328 struct opp_table *opp_table; in dev_pm_opp_get_opp_count() local
331 opp_table = _find_opp_table(dev); in dev_pm_opp_get_opp_count()
332 if (IS_ERR(opp_table)) { in dev_pm_opp_get_opp_count()
333 count = PTR_ERR(opp_table); in dev_pm_opp_get_opp_count()
339 count = _get_opp_count(opp_table); in dev_pm_opp_get_opp_count()
340 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_get_opp_count()
373 struct opp_table *opp_table; in dev_pm_opp_find_freq_exact() local
376 opp_table = _find_opp_table(dev); in dev_pm_opp_find_freq_exact()
377 if (IS_ERR(opp_table)) { in dev_pm_opp_find_freq_exact()
378 int r = PTR_ERR(opp_table); in dev_pm_opp_find_freq_exact()
384 mutex_lock(&opp_table->lock); in dev_pm_opp_find_freq_exact()
386 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in dev_pm_opp_find_freq_exact()
397 mutex_unlock(&opp_table->lock); in dev_pm_opp_find_freq_exact()
398 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_find_freq_exact()
422 struct opp_table *opp_table; in dev_pm_opp_find_level_exact() local
425 opp_table = _find_opp_table(dev); in dev_pm_opp_find_level_exact()
426 if (IS_ERR(opp_table)) { in dev_pm_opp_find_level_exact()
427 int r = PTR_ERR(opp_table); in dev_pm_opp_find_level_exact()
433 mutex_lock(&opp_table->lock); in dev_pm_opp_find_level_exact()
435 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in dev_pm_opp_find_level_exact()
445 mutex_unlock(&opp_table->lock); in dev_pm_opp_find_level_exact()
446 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_find_level_exact()
452 static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, in _find_freq_ceil() argument
457 mutex_lock(&opp_table->lock); in _find_freq_ceil()
459 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in _find_freq_ceil()
470 mutex_unlock(&opp_table->lock); in _find_freq_ceil()
496 struct opp_table *opp_table; in dev_pm_opp_find_freq_ceil() local
504 opp_table = _find_opp_table(dev); in dev_pm_opp_find_freq_ceil()
505 if (IS_ERR(opp_table)) in dev_pm_opp_find_freq_ceil()
506 return ERR_CAST(opp_table); in dev_pm_opp_find_freq_ceil()
508 opp = _find_freq_ceil(opp_table, freq); in dev_pm_opp_find_freq_ceil()
510 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_find_freq_ceil()
537 struct opp_table *opp_table; in dev_pm_opp_find_freq_floor() local
545 opp_table = _find_opp_table(dev); in dev_pm_opp_find_freq_floor()
546 if (IS_ERR(opp_table)) in dev_pm_opp_find_freq_floor()
547 return ERR_CAST(opp_table); in dev_pm_opp_find_freq_floor()
549 mutex_lock(&opp_table->lock); in dev_pm_opp_find_freq_floor()
551 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in dev_pm_opp_find_freq_floor()
564 mutex_unlock(&opp_table->lock); in dev_pm_opp_find_freq_floor()
565 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_find_freq_floor()
594 struct opp_table *opp_table; in dev_pm_opp_find_freq_ceil_by_volt() local
603 opp_table = _find_opp_table(dev); in dev_pm_opp_find_freq_ceil_by_volt()
604 if (IS_ERR(opp_table)) in dev_pm_opp_find_freq_ceil_by_volt()
605 return ERR_CAST(opp_table); in dev_pm_opp_find_freq_ceil_by_volt()
607 mutex_lock(&opp_table->lock); in dev_pm_opp_find_freq_ceil_by_volt()
609 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { in dev_pm_opp_find_freq_ceil_by_volt()
621 mutex_unlock(&opp_table->lock); in dev_pm_opp_find_freq_ceil_by_volt()
622 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_find_freq_ceil_by_volt()
667 static int _generic_set_opp_regulator(const struct opp_table *opp_table, in _generic_set_opp_regulator() argument
674 struct regulator *reg = opp_table->regulators[0]; in _generic_set_opp_regulator()
678 if (WARN_ON(opp_table->regulator_count > 1)) { in _generic_set_opp_regulator()
691 ret = _generic_set_opp_clk_only(dev, opp_table->clk, freq); in _generic_set_opp_regulator()
705 if (_generic_set_opp_clk_only(dev, opp_table->clk, old_freq)) in _generic_set_opp_regulator()
716 static int _set_opp_custom(const struct opp_table *opp_table, in _set_opp_custom() argument
725 data = opp_table->set_opp_data; in _set_opp_custom()
726 data->regulators = opp_table->regulators; in _set_opp_custom()
727 data->regulator_count = opp_table->regulator_count; in _set_opp_custom()
728 data->clk = opp_table->clk; in _set_opp_custom()
732 size = sizeof(*old_supply) * opp_table->regulator_count; in _set_opp_custom()
741 return opp_table->set_opp(data); in _set_opp_custom()
746 struct opp_table *opp_table, in _set_required_opps() argument
749 struct opp_table **required_opp_tables = opp_table->required_opp_tables; in _set_required_opps()
750 struct device **genpd_virt_devs = opp_table->genpd_virt_devs; in _set_required_opps()
774 mutex_lock(&opp_table->genpd_virt_dev_lock); in _set_required_opps()
776 for (i = 0; i < opp_table->required_opp_count; i++) { in _set_required_opps()
789 mutex_unlock(&opp_table->genpd_virt_dev_lock); in _set_required_opps()
807 struct opp_table *opp_table; in dev_pm_opp_set_rate() local
813 opp_table = _find_opp_table(dev); in dev_pm_opp_set_rate()
814 if (IS_ERR(opp_table)) { in dev_pm_opp_set_rate()
816 return PTR_ERR(opp_table); in dev_pm_opp_set_rate()
820 if (opp_table->required_opp_tables) { in dev_pm_opp_set_rate()
821 ret = _set_required_opps(dev, opp_table, NULL); in dev_pm_opp_set_rate()
830 clk = opp_table->clk; in dev_pm_opp_set_rate()
853 old_opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
860 opp = _find_freq_ceil(opp_table, &temp_freq); in dev_pm_opp_set_rate()
873 ret = _set_required_opps(dev, opp_table, opp); in dev_pm_opp_set_rate()
878 if (opp_table->set_opp) { in dev_pm_opp_set_rate()
879 ret = _set_opp_custom(opp_table, dev, old_freq, freq, in dev_pm_opp_set_rate()
882 } else if (opp_table->regulators) { in dev_pm_opp_set_rate()
883 ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq, in dev_pm_opp_set_rate()
893 ret = _set_required_opps(dev, opp_table, opp); in dev_pm_opp_set_rate()
904 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_rate()
911 struct opp_table *opp_table) in _remove_opp_dev() argument
913 opp_debug_unregister(opp_dev, opp_table); in _remove_opp_dev()
919 struct opp_table *opp_table) in _add_opp_dev_unlocked() argument
930 list_add(&opp_dev->node, &opp_table->dev_list); in _add_opp_dev_unlocked()
933 opp_debug_register(opp_dev, opp_table); in _add_opp_dev_unlocked()
939 struct opp_table *opp_table) in _add_opp_dev() argument
943 mutex_lock(&opp_table->lock); in _add_opp_dev()
944 opp_dev = _add_opp_dev_unlocked(dev, opp_table); in _add_opp_dev()
945 mutex_unlock(&opp_table->lock); in _add_opp_dev()
950 static struct opp_table *_allocate_opp_table(struct device *dev, int index) in _allocate_opp_table()
952 struct opp_table *opp_table; in _allocate_opp_table() local
960 opp_table = kzalloc(sizeof(*opp_table), GFP_KERNEL); in _allocate_opp_table()
961 if (!opp_table) in _allocate_opp_table()
964 mutex_init(&opp_table->lock); in _allocate_opp_table()
965 mutex_init(&opp_table->genpd_virt_dev_lock); in _allocate_opp_table()
966 INIT_LIST_HEAD(&opp_table->dev_list); in _allocate_opp_table()
969 opp_table->regulator_count = -1; in _allocate_opp_table()
971 opp_dev = _add_opp_dev(dev, opp_table); in _allocate_opp_table()
973 kfree(opp_table); in _allocate_opp_table()
977 _of_init_opp_table(opp_table, dev, index); in _allocate_opp_table()
980 opp_table->clk = clk_get(dev, NULL); in _allocate_opp_table()
981 if (IS_ERR(opp_table->clk)) { in _allocate_opp_table()
982 ret = PTR_ERR(opp_table->clk); in _allocate_opp_table()
988 BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); in _allocate_opp_table()
989 INIT_LIST_HEAD(&opp_table->opp_list); in _allocate_opp_table()
990 kref_init(&opp_table->kref); in _allocate_opp_table()
991 kref_init(&opp_table->list_kref); in _allocate_opp_table()
994 list_add(&opp_table->node, &opp_tables); in _allocate_opp_table()
995 return opp_table; in _allocate_opp_table()
998 void _get_opp_table_kref(struct opp_table *opp_table) in _get_opp_table_kref() argument
1000 kref_get(&opp_table->kref); in _get_opp_table_kref()
1003 static struct opp_table *_opp_get_opp_table(struct device *dev, int index) in _opp_get_opp_table()
1005 struct opp_table *opp_table; in _opp_get_opp_table() local
1010 opp_table = _find_opp_table_unlocked(dev); in _opp_get_opp_table()
1011 if (!IS_ERR(opp_table)) in _opp_get_opp_table()
1014 opp_table = _managed_opp(dev, index); in _opp_get_opp_table()
1015 if (opp_table) { in _opp_get_opp_table()
1016 if (!_add_opp_dev_unlocked(dev, opp_table)) { in _opp_get_opp_table()
1017 dev_pm_opp_put_opp_table(opp_table); in _opp_get_opp_table()
1018 opp_table = NULL; in _opp_get_opp_table()
1023 opp_table = _allocate_opp_table(dev, index); in _opp_get_opp_table()
1028 return opp_table; in _opp_get_opp_table()
1031 struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) in dev_pm_opp_get_opp_table()
1037 struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, in dev_pm_opp_get_opp_table_indexed()
1045 struct opp_table *opp_table = container_of(kref, struct opp_table, kref); in _opp_table_kref_release() local
1048 _of_clear_opp_table(opp_table); in _opp_table_kref_release()
1051 if (!IS_ERR(opp_table->clk)) in _opp_table_kref_release()
1052 clk_put(opp_table->clk); in _opp_table_kref_release()
1054 WARN_ON(!list_empty(&opp_table->opp_list)); in _opp_table_kref_release()
1056 list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) { in _opp_table_kref_release()
1061 if (opp_table->genpd_performance_state) in _opp_table_kref_release()
1064 _remove_opp_dev(opp_dev, opp_table); in _opp_table_kref_release()
1067 mutex_destroy(&opp_table->genpd_virt_dev_lock); in _opp_table_kref_release()
1068 mutex_destroy(&opp_table->lock); in _opp_table_kref_release()
1069 list_del(&opp_table->node); in _opp_table_kref_release()
1070 kfree(opp_table); in _opp_table_kref_release()
1075 void _opp_remove_all_static(struct opp_table *opp_table) in _opp_remove_all_static() argument
1079 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { in _opp_remove_all_static()
1084 opp_table->parsed_static_opps = false; in _opp_remove_all_static()
1089 struct opp_table *opp_table = container_of(kref, struct opp_table, in _opp_table_list_kref_release() local
1092 _opp_remove_all_static(opp_table); in _opp_table_list_kref_release()
1096 void _put_opp_list_kref(struct opp_table *opp_table) in _put_opp_list_kref() argument
1098 kref_put_mutex(&opp_table->list_kref, _opp_table_list_kref_release, in _put_opp_list_kref()
1102 void dev_pm_opp_put_opp_table(struct opp_table *opp_table) in dev_pm_opp_put_opp_table() argument
1104 kref_put_mutex(&opp_table->kref, _opp_table_kref_release, in dev_pm_opp_put_opp_table()
1115 struct opp_table *opp_table) in _opp_kref_release() argument
1121 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_REMOVE, opp); in _opp_kref_release()
1122 _of_opp_free_required_opps(opp_table, opp); in _opp_kref_release()
1131 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release_unlocked() local
1133 _opp_kref_release(opp, opp_table); in _opp_kref_release_unlocked()
1139 struct opp_table *opp_table = opp->opp_table; in _opp_kref_release_locked() local
1141 _opp_kref_release(opp, opp_table); in _opp_kref_release_locked()
1142 mutex_unlock(&opp_table->lock); in _opp_kref_release_locked()
1153 &opp->opp_table->lock); in dev_pm_opp_put()
1172 struct opp_table *opp_table; in dev_pm_opp_remove() local
1175 opp_table = _find_opp_table(dev); in dev_pm_opp_remove()
1176 if (IS_ERR(opp_table)) in dev_pm_opp_remove()
1179 mutex_lock(&opp_table->lock); in dev_pm_opp_remove()
1181 list_for_each_entry(opp, &opp_table->opp_list, node) { in dev_pm_opp_remove()
1188 mutex_unlock(&opp_table->lock); in dev_pm_opp_remove()
1194 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1201 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove()
1213 struct opp_table *opp_table; in dev_pm_opp_remove_all_dynamic() local
1217 opp_table = _find_opp_table(dev); in dev_pm_opp_remove_all_dynamic()
1218 if (IS_ERR(opp_table)) in dev_pm_opp_remove_all_dynamic()
1221 mutex_lock(&opp_table->lock); in dev_pm_opp_remove_all_dynamic()
1222 list_for_each_entry_safe(opp, temp, &opp_table->opp_list, node) { in dev_pm_opp_remove_all_dynamic()
1228 mutex_unlock(&opp_table->lock); in dev_pm_opp_remove_all_dynamic()
1232 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_all_dynamic()
1235 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_remove_all_dynamic()
1239 struct dev_pm_opp *_opp_allocate(struct opp_table *table) in _opp_allocate()
1261 struct opp_table *opp_table) in _opp_supported_by_regulators() argument
1266 if (!opp_table->regulators) in _opp_supported_by_regulators()
1269 for (i = 0; i < opp_table->regulator_count; i++) { in _opp_supported_by_regulators()
1270 reg = opp_table->regulators[i]; in _opp_supported_by_regulators()
1286 struct opp_table *opp_table, in _opp_is_duplicate() argument
1299 list_for_each_entry(opp, &opp_table->opp_list, node) { in _opp_is_duplicate()
1333 struct opp_table *opp_table, bool rate_not_available) in _opp_add() argument
1338 mutex_lock(&opp_table->lock); in _opp_add()
1339 head = &opp_table->opp_list; in _opp_add()
1342 ret = _opp_is_duplicate(dev, new_opp, opp_table, &head); in _opp_add()
1344 mutex_unlock(&opp_table->lock); in _opp_add()
1350 mutex_unlock(&opp_table->lock); in _opp_add()
1352 new_opp->opp_table = opp_table; in _opp_add()
1355 opp_debug_create_one(new_opp, opp_table); in _opp_add()
1357 if (!_opp_supported_by_regulators(new_opp, opp_table)) { in _opp_add()
1388 int _opp_add_v1(struct opp_table *opp_table, struct device *dev, in _opp_add_v1() argument
1395 new_opp = _opp_allocate(opp_table); in _opp_add_v1()
1401 tol = u_volt * opp_table->voltage_tolerance_v1 / 100; in _opp_add_v1()
1408 ret = _opp_add(dev, new_opp, opp_table, false); in _opp_add_v1()
1420 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_v1()
1440 struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, in dev_pm_opp_set_supported_hw()
1443 struct opp_table *opp_table; in dev_pm_opp_set_supported_hw() local
1445 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_set_supported_hw()
1446 if (!opp_table) in dev_pm_opp_set_supported_hw()
1450 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_set_supported_hw()
1453 if (opp_table->supported_hw) in dev_pm_opp_set_supported_hw()
1454 return opp_table; in dev_pm_opp_set_supported_hw()
1456 opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions), in dev_pm_opp_set_supported_hw()
1458 if (!opp_table->supported_hw) { in dev_pm_opp_set_supported_hw()
1459 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_supported_hw()
1463 opp_table->supported_hw_count = count; in dev_pm_opp_set_supported_hw()
1465 return opp_table; in dev_pm_opp_set_supported_hw()
1477 void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) in dev_pm_opp_put_supported_hw() argument
1480 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_put_supported_hw()
1482 kfree(opp_table->supported_hw); in dev_pm_opp_put_supported_hw()
1483 opp_table->supported_hw = NULL; in dev_pm_opp_put_supported_hw()
1484 opp_table->supported_hw_count = 0; in dev_pm_opp_put_supported_hw()
1486 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_put_supported_hw()
1500 struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name) in dev_pm_opp_set_prop_name()
1502 struct opp_table *opp_table; in dev_pm_opp_set_prop_name() local
1504 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_set_prop_name()
1505 if (!opp_table) in dev_pm_opp_set_prop_name()
1509 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_set_prop_name()
1512 if (opp_table->prop_name) in dev_pm_opp_set_prop_name()
1513 return opp_table; in dev_pm_opp_set_prop_name()
1515 opp_table->prop_name = kstrdup(name, GFP_KERNEL); in dev_pm_opp_set_prop_name()
1516 if (!opp_table->prop_name) { in dev_pm_opp_set_prop_name()
1517 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_prop_name()
1521 return opp_table; in dev_pm_opp_set_prop_name()
1533 void dev_pm_opp_put_prop_name(struct opp_table *opp_table) in dev_pm_opp_put_prop_name() argument
1536 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_put_prop_name()
1538 kfree(opp_table->prop_name); in dev_pm_opp_put_prop_name()
1539 opp_table->prop_name = NULL; in dev_pm_opp_put_prop_name()
1541 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_put_prop_name()
1545 static int _allocate_set_opp_data(struct opp_table *opp_table) in _allocate_set_opp_data() argument
1548 int len, count = opp_table->regulator_count; in _allocate_set_opp_data()
1550 if (WARN_ON(!opp_table->regulators)) in _allocate_set_opp_data()
1566 opp_table->set_opp_data = data; in _allocate_set_opp_data()
1571 static void _free_set_opp_data(struct opp_table *opp_table) in _free_set_opp_data() argument
1573 kfree(opp_table->set_opp_data); in _free_set_opp_data()
1574 opp_table->set_opp_data = NULL; in _free_set_opp_data()
1589 struct opp_table *dev_pm_opp_set_regulators(struct device *dev, in dev_pm_opp_set_regulators()
1593 struct opp_table *opp_table; in dev_pm_opp_set_regulators() local
1597 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_set_regulators()
1598 if (!opp_table) in dev_pm_opp_set_regulators()
1602 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_set_regulators()
1608 if (opp_table->regulators) in dev_pm_opp_set_regulators()
1609 return opp_table; in dev_pm_opp_set_regulators()
1611 opp_table->regulators = kmalloc_array(count, in dev_pm_opp_set_regulators()
1612 sizeof(*opp_table->regulators), in dev_pm_opp_set_regulators()
1614 if (!opp_table->regulators) { in dev_pm_opp_set_regulators()
1629 opp_table->regulators[i] = reg; in dev_pm_opp_set_regulators()
1632 opp_table->regulator_count = count; in dev_pm_opp_set_regulators()
1635 ret = _allocate_set_opp_data(opp_table); in dev_pm_opp_set_regulators()
1639 return opp_table; in dev_pm_opp_set_regulators()
1643 regulator_put(opp_table->regulators[--i]); in dev_pm_opp_set_regulators()
1645 kfree(opp_table->regulators); in dev_pm_opp_set_regulators()
1646 opp_table->regulators = NULL; in dev_pm_opp_set_regulators()
1647 opp_table->regulator_count = -1; in dev_pm_opp_set_regulators()
1649 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_regulators()
1659 void dev_pm_opp_put_regulators(struct opp_table *opp_table) in dev_pm_opp_put_regulators() argument
1663 if (!opp_table->regulators) in dev_pm_opp_put_regulators()
1667 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_put_regulators()
1669 for (i = opp_table->regulator_count - 1; i >= 0; i--) in dev_pm_opp_put_regulators()
1670 regulator_put(opp_table->regulators[i]); in dev_pm_opp_put_regulators()
1672 _free_set_opp_data(opp_table); in dev_pm_opp_put_regulators()
1674 kfree(opp_table->regulators); in dev_pm_opp_put_regulators()
1675 opp_table->regulators = NULL; in dev_pm_opp_put_regulators()
1676 opp_table->regulator_count = -1; in dev_pm_opp_put_regulators()
1679 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_put_regulators()
1695 struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char *name) in dev_pm_opp_set_clkname()
1697 struct opp_table *opp_table; in dev_pm_opp_set_clkname() local
1700 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_set_clkname()
1701 if (!opp_table) in dev_pm_opp_set_clkname()
1705 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_set_clkname()
1711 if (!IS_ERR(opp_table->clk)) in dev_pm_opp_set_clkname()
1712 clk_put(opp_table->clk); in dev_pm_opp_set_clkname()
1715 opp_table->clk = clk_get(dev, name); in dev_pm_opp_set_clkname()
1716 if (IS_ERR(opp_table->clk)) { in dev_pm_opp_set_clkname()
1717 ret = PTR_ERR(opp_table->clk); in dev_pm_opp_set_clkname()
1725 return opp_table; in dev_pm_opp_set_clkname()
1728 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_set_clkname()
1738 void dev_pm_opp_put_clkname(struct opp_table *opp_table) in dev_pm_opp_put_clkname() argument
1741 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_put_clkname()
1743 clk_put(opp_table->clk); in dev_pm_opp_put_clkname()
1744 opp_table->clk = ERR_PTR(-EINVAL); in dev_pm_opp_put_clkname()
1746 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_put_clkname()
1760 struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, in dev_pm_opp_register_set_opp_helper()
1763 struct opp_table *opp_table; in dev_pm_opp_register_set_opp_helper() local
1768 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_register_set_opp_helper()
1769 if (!opp_table) in dev_pm_opp_register_set_opp_helper()
1773 if (WARN_ON(!list_empty(&opp_table->opp_list))) { in dev_pm_opp_register_set_opp_helper()
1774 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_register_set_opp_helper()
1779 if (!opp_table->set_opp) in dev_pm_opp_register_set_opp_helper()
1780 opp_table->set_opp = set_opp; in dev_pm_opp_register_set_opp_helper()
1782 return opp_table; in dev_pm_opp_register_set_opp_helper()
1793 void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table) in dev_pm_opp_unregister_set_opp_helper() argument
1796 WARN_ON(!list_empty(&opp_table->opp_list)); in dev_pm_opp_unregister_set_opp_helper()
1798 opp_table->set_opp = NULL; in dev_pm_opp_unregister_set_opp_helper()
1799 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_unregister_set_opp_helper()
1803 static void _opp_detach_genpd(struct opp_table *opp_table) in _opp_detach_genpd() argument
1807 for (index = 0; index < opp_table->required_opp_count; index++) { in _opp_detach_genpd()
1808 if (!opp_table->genpd_virt_devs[index]) in _opp_detach_genpd()
1811 dev_pm_domain_detach(opp_table->genpd_virt_devs[index], false); in _opp_detach_genpd()
1812 opp_table->genpd_virt_devs[index] = NULL; in _opp_detach_genpd()
1815 kfree(opp_table->genpd_virt_devs); in _opp_detach_genpd()
1816 opp_table->genpd_virt_devs = NULL; in _opp_detach_genpd()
1841 struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, in dev_pm_opp_attach_genpd()
1844 struct opp_table *opp_table; in dev_pm_opp_attach_genpd() local
1849 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_attach_genpd()
1850 if (!opp_table) in dev_pm_opp_attach_genpd()
1858 if (!opp_table->required_opp_count) { in dev_pm_opp_attach_genpd()
1863 mutex_lock(&opp_table->genpd_virt_dev_lock); in dev_pm_opp_attach_genpd()
1865 opp_table->genpd_virt_devs = kcalloc(opp_table->required_opp_count, in dev_pm_opp_attach_genpd()
1866 sizeof(*opp_table->genpd_virt_devs), in dev_pm_opp_attach_genpd()
1868 if (!opp_table->genpd_virt_devs) in dev_pm_opp_attach_genpd()
1872 if (index >= opp_table->required_opp_count) { in dev_pm_opp_attach_genpd()
1874 *name, opp_table->required_opp_count, index); in dev_pm_opp_attach_genpd()
1878 if (opp_table->genpd_virt_devs[index]) { in dev_pm_opp_attach_genpd()
1891 opp_table->genpd_virt_devs[index] = virt_dev; in dev_pm_opp_attach_genpd()
1897 *virt_devs = opp_table->genpd_virt_devs; in dev_pm_opp_attach_genpd()
1898 mutex_unlock(&opp_table->genpd_virt_dev_lock); in dev_pm_opp_attach_genpd()
1900 return opp_table; in dev_pm_opp_attach_genpd()
1903 _opp_detach_genpd(opp_table); in dev_pm_opp_attach_genpd()
1905 mutex_unlock(&opp_table->genpd_virt_dev_lock); in dev_pm_opp_attach_genpd()
1908 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_attach_genpd()
1921 void dev_pm_opp_detach_genpd(struct opp_table *opp_table) in dev_pm_opp_detach_genpd() argument
1927 mutex_lock(&opp_table->genpd_virt_dev_lock); in dev_pm_opp_detach_genpd()
1928 _opp_detach_genpd(opp_table); in dev_pm_opp_detach_genpd()
1929 mutex_unlock(&opp_table->genpd_virt_dev_lock); in dev_pm_opp_detach_genpd()
1931 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_detach_genpd()
1948 int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, in dev_pm_opp_xlate_performance_state()
1949 struct opp_table *dst_table, in dev_pm_opp_xlate_performance_state()
2017 struct opp_table *opp_table; in dev_pm_opp_add() local
2020 opp_table = dev_pm_opp_get_opp_table(dev); in dev_pm_opp_add()
2021 if (!opp_table) in dev_pm_opp_add()
2025 opp_table->regulator_count = 1; in dev_pm_opp_add()
2027 ret = _opp_add_v1(opp_table, dev, freq, u_volt, true); in dev_pm_opp_add()
2029 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_add()
2051 struct opp_table *opp_table; in _opp_set_availability() local
2056 opp_table = _find_opp_table(dev); in _opp_set_availability()
2057 if (IS_ERR(opp_table)) { in _opp_set_availability()
2058 r = PTR_ERR(opp_table); in _opp_set_availability()
2063 mutex_lock(&opp_table->lock); in _opp_set_availability()
2066 list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { in _opp_set_availability()
2085 mutex_unlock(&opp_table->lock); in _opp_set_availability()
2089 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, in _opp_set_availability()
2092 blocking_notifier_call_chain(&opp_table->head, in _opp_set_availability()
2099 mutex_unlock(&opp_table->lock); in _opp_set_availability()
2101 dev_pm_opp_put_opp_table(opp_table); in _opp_set_availability()
2153 struct opp_table *opp_table; in dev_pm_opp_register_notifier() local
2156 opp_table = _find_opp_table(dev); in dev_pm_opp_register_notifier()
2157 if (IS_ERR(opp_table)) in dev_pm_opp_register_notifier()
2158 return PTR_ERR(opp_table); in dev_pm_opp_register_notifier()
2160 ret = blocking_notifier_chain_register(&opp_table->head, nb); in dev_pm_opp_register_notifier()
2162 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_register_notifier()
2178 struct opp_table *opp_table; in dev_pm_opp_unregister_notifier() local
2181 opp_table = _find_opp_table(dev); in dev_pm_opp_unregister_notifier()
2182 if (IS_ERR(opp_table)) in dev_pm_opp_unregister_notifier()
2183 return PTR_ERR(opp_table); in dev_pm_opp_unregister_notifier()
2185 ret = blocking_notifier_chain_unregister(&opp_table->head, nb); in dev_pm_opp_unregister_notifier()
2187 dev_pm_opp_put_opp_table(opp_table); in dev_pm_opp_unregister_notifier()
2195 struct opp_table *opp_table; in _dev_pm_opp_find_and_remove_table() local
2198 opp_table = _find_opp_table(dev); in _dev_pm_opp_find_and_remove_table()
2199 if (IS_ERR(opp_table)) { in _dev_pm_opp_find_and_remove_table()
2200 int error = PTR_ERR(opp_table); in _dev_pm_opp_find_and_remove_table()
2210 _put_opp_list_kref(opp_table); in _dev_pm_opp_find_and_remove_table()
2213 dev_pm_opp_put_opp_table(opp_table); in _dev_pm_opp_find_and_remove_table()
2216 dev_pm_opp_put_opp_table(opp_table); in _dev_pm_opp_find_and_remove_table()