Lines Matching full:opp_table

45 struct opp_table *_managed_opp(struct device *dev, int index)  in _managed_opp()
47 struct opp_table *opp_table, *managed_table = NULL; in _managed_opp() local
54 list_for_each_entry(opp_table, &opp_tables, node) { in _managed_opp()
55 if (opp_table->np == np) { in _managed_opp()
63 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) { in _managed_opp()
64 _get_opp_table_kref(opp_table); in _managed_opp()
65 managed_table = opp_table; in _managed_opp()
78 static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table, in _find_opp_of_np() argument
83 mutex_lock(&opp_table->lock); in _find_opp_of_np()
85 list_for_each_entry(opp, &opp_table->opp_list, node) { in _find_opp_of_np()
88 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
93 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
105 static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) in _find_table_of_opp_np()
107 struct opp_table *opp_table; in _find_table_of_opp_np() local
118 list_for_each_entry(opp_table, &opp_tables, node) { in _find_table_of_opp_np()
119 if (opp_table_np == opp_table->np) { in _find_table_of_opp_np()
120 _get_opp_table_kref(opp_table); in _find_table_of_opp_np()
122 return opp_table; in _find_table_of_opp_np()
132 static void _opp_table_free_required_tables(struct opp_table *opp_table) in _opp_table_free_required_tables() argument
134 struct opp_table **required_opp_tables = opp_table->required_opp_tables; in _opp_table_free_required_tables()
140 for (i = 0; i < opp_table->required_opp_count; i++) { in _opp_table_free_required_tables()
149 opp_table->required_opp_count = 0; in _opp_table_free_required_tables()
150 opp_table->required_opp_tables = NULL; in _opp_table_free_required_tables()
153 list_del(&opp_table->lazy); in _opp_table_free_required_tables()
161 static void _opp_table_alloc_required_tables(struct opp_table *opp_table, in _opp_table_alloc_required_tables() argument
165 struct opp_table **required_opp_tables; in _opp_table_alloc_required_tables()
182 size = sizeof(*required_opp_tables) + sizeof(*opp_table->required_devs); in _opp_table_alloc_required_tables()
187 opp_table->required_opp_tables = required_opp_tables; in _opp_table_alloc_required_tables()
188 opp_table->required_devs = (void *)(required_opp_tables + count); in _opp_table_alloc_required_tables()
189 opp_table->required_opp_count = count; in _opp_table_alloc_required_tables()
210 list_add(&opp_table->lazy, &lazy_opp_tables); in _opp_table_alloc_required_tables()
217 _opp_table_free_required_tables(opp_table); in _opp_table_alloc_required_tables()
222 void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, in _of_init_opp_table() argument
237 opp_table->clock_latency_ns_max = val; in _of_init_opp_table()
239 &opp_table->voltage_tolerance_v1); in _of_init_opp_table()
242 opp_table->is_genpd = true; in _of_init_opp_table()
252 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; in _of_init_opp_table()
254 opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE; in _of_init_opp_table()
256 opp_table->np = opp_np; in _of_init_opp_table()
258 _opp_table_alloc_required_tables(opp_table, dev, opp_np); in _of_init_opp_table()
261 void _of_clear_opp_table(struct opp_table *opp_table) in _of_clear_opp_table() argument
263 _opp_table_free_required_tables(opp_table); in _of_clear_opp_table()
264 of_node_put(opp_table->np); in _of_clear_opp_table()
271 static void _of_opp_free_required_opps(struct opp_table *opp_table, in _of_opp_free_required_opps() argument
280 for (i = 0; i < opp_table->required_opp_count; i++) { in _of_opp_free_required_opps()
292 void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) in _of_clear_opp() argument
294 _of_opp_free_required_opps(opp_table, opp); in _of_clear_opp()
298 static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_table, in _link_required_opps() argument
299 struct opp_table *required_table, int index) in _link_required_opps()
340 if (required_table->is_genpd && opp_table->required_opp_count == 1 && in _link_required_opps()
341 !opp_table->required_devs[0]) { in _link_required_opps()
343 if (!opp_table->is_genpd) { in _link_required_opps()
353 static int _of_opp_alloc_required_opps(struct opp_table *opp_table, in _of_opp_alloc_required_opps() argument
356 struct opp_table *required_table; in _of_opp_alloc_required_opps()
357 int i, ret, count = opp_table->required_opp_count; in _of_opp_alloc_required_opps()
367 required_table = opp_table->required_opp_tables[i]; in _of_opp_alloc_required_opps()
373 ret = _link_required_opps(opp, opp_table, required_table, i); in _of_opp_alloc_required_opps()
381 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
387 static int lazy_link_required_opps(struct opp_table *opp_table, in lazy_link_required_opps() argument
388 struct opp_table *new_table, int index) in lazy_link_required_opps()
393 list_for_each_entry(opp, &opp_table->opp_list, node) { in lazy_link_required_opps()
394 ret = _link_required_opps(opp, opp_table, new_table, index); in lazy_link_required_opps()
403 static void lazy_link_required_opp_table(struct opp_table *new_table) in lazy_link_required_opp_table()
405 struct opp_table *opp_table, *temp, **required_opp_tables; in lazy_link_required_opp_table() local
412 list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) { in lazy_link_required_opp_table()
416 opp_np = of_get_next_available_child(opp_table->np, NULL); in lazy_link_required_opp_table()
418 for (i = 0; i < opp_table->required_opp_count; i++) { in lazy_link_required_opp_table()
419 required_opp_tables = opp_table->required_opp_tables; in lazy_link_required_opp_table()
434 * opp_table. in lazy_link_required_opp_table()
445 ret = lazy_link_required_opps(opp_table, new_table, i); in lazy_link_required_opp_table()
457 list_del_init(&opp_table->lazy); in lazy_link_required_opp_table()
459 list_for_each_entry(opp, &opp_table->opp_list, node) in lazy_link_required_opp_table()
460 _required_opps_available(opp, opp_table->required_opp_count); in lazy_link_required_opp_table()
467 static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) in _bandwidth_supported() argument
472 if (!opp_table) { in _bandwidth_supported()
480 opp_np = of_node_get(opp_table->np); in _bandwidth_supported()
505 struct opp_table *opp_table) in dev_pm_opp_of_find_icc_paths() argument
511 ret = _bandwidth_supported(dev, opp_table); in dev_pm_opp_of_find_icc_paths()
548 if (opp_table) { in dev_pm_opp_of_find_icc_paths()
549 opp_table->paths = paths; in dev_pm_opp_of_find_icc_paths()
550 opp_table->path_count = num_paths; in dev_pm_opp_of_find_icc_paths()
564 static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, in _opp_is_supported() argument
567 unsigned int levels = opp_table->supported_hw_count; in _opp_is_supported()
571 if (!opp_table->supported_hw) { in _opp_is_supported()
607 if (!(val & opp_table->supported_hw[j])) { in _opp_is_supported()
621 struct opp_table *opp_table, in _parse_named_prop() argument
630 if (opp_table->prop_name) { in _parse_named_prop()
632 opp_table->prop_name); in _parse_named_prop()
656 if (unlikely(opp_table->regulator_count == -1)) in _parse_named_prop()
657 opp_table->regulator_count = 1; in _parse_named_prop()
659 if (count != opp_table->regulator_count && in _parse_named_prop()
660 (!triplet || count != opp_table->regulator_count * 3)) { in _parse_named_prop()
662 __func__, prop_type, count, opp_table->regulator_count); in _parse_named_prop()
678 *triplet = count != opp_table->regulator_count; in _parse_named_prop()
684 struct opp_table *opp_table, bool *triplet) in opp_parse_microvolt() argument
688 microvolt = _parse_named_prop(opp, dev, opp_table, "microvolt", triplet); in opp_parse_microvolt()
700 if (list_empty(&opp_table->opp_list) && in opp_parse_microvolt()
701 opp_table->regulator_count > 0) { in opp_parse_microvolt()
712 struct opp_table *opp_table) in opp_parse_supplies() argument
718 microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet); in opp_parse_supplies()
722 microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL); in opp_parse_supplies()
728 microwatt = _parse_named_prop(opp, dev, opp_table, "microwatt", NULL); in opp_parse_supplies()
738 if (unlikely(opp_table->regulator_count == -1)) { in opp_parse_supplies()
739 opp_table->regulator_count = 0; in opp_parse_supplies()
743 for (i = 0, j = 0; i < opp_table->regulator_count; i++) { in opp_parse_supplies()
785 static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_rate() argument
797 if (opp_table->clk_count != count) { in _read_rate()
799 __func__, count, opp_table->clk_count); in _read_rate()
829 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_bw() argument
842 if (opp_table->path_count != count) { in _read_bw()
844 __func__, name, count, opp_table->path_count); in _read_bw()
871 struct opp_table *opp_table, struct device_node *np) in _read_opp_key() argument
876 ret = _read_rate(new_opp, opp_table, np); in _read_opp_key()
887 ret = _read_bw(new_opp, opp_table, np, true); in _read_opp_key()
890 ret = _read_bw(new_opp, opp_table, np, false); in _read_opp_key()
908 * @opp_table: OPP table
930 static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, in _opp_add_static_v2() argument
937 new_opp = _opp_allocate(opp_table); in _opp_add_static_v2()
941 ret = _read_opp_key(new_opp, opp_table, np); in _opp_add_static_v2()
948 if (!_opp_is_supported(dev, opp_table, np)) { in _opp_add_static_v2()
960 ret = _of_opp_alloc_required_opps(opp_table, new_opp); in _opp_add_static_v2()
967 ret = opp_parse_supplies(new_opp, dev, opp_table); in _opp_add_static_v2()
971 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_static_v2()
981 if (opp_table->suspend_opp) { in _opp_add_static_v2()
983 if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) == 1) { in _opp_add_static_v2()
984 opp_table->suspend_opp->suspend = false; in _opp_add_static_v2()
986 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
990 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
994 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) in _opp_add_static_v2()
995 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; in _opp_add_static_v2()
1007 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_static_v2()
1011 _of_opp_free_required_opps(opp_table, new_opp); in _opp_add_static_v2()
1019 static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v2() argument
1026 mutex_lock(&opp_table->lock); in _of_add_opp_table_v2()
1027 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v2()
1028 opp_table->parsed_static_opps++; in _of_add_opp_table_v2()
1029 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1033 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v2()
1034 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1037 for_each_available_child_of_node(opp_table->np, np) { in _of_add_opp_table_v2()
1038 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
1057 lazy_link_required_opp_table(opp_table); in _of_add_opp_table_v2()
1062 _opp_remove_all_static(opp_table); in _of_add_opp_table_v2()
1068 static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v1() argument
1074 mutex_lock(&opp_table->lock); in _of_add_opp_table_v1()
1075 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v1()
1076 opp_table->parsed_static_opps++; in _of_add_opp_table_v1()
1077 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1081 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v1()
1082 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1114 ret = _opp_add_v1(opp_table, dev, &data, false); in _of_add_opp_table_v1()
1126 _opp_remove_all_static(opp_table); in _of_add_opp_table_v1()
1133 struct opp_table *opp_table; in _of_add_table_indexed() local
1147 opp_table = _add_opp_table_indexed(dev, index, true); in _of_add_table_indexed()
1148 if (IS_ERR(opp_table)) in _of_add_table_indexed()
1149 return PTR_ERR(opp_table); in _of_add_table_indexed()
1155 if (opp_table->np) in _of_add_table_indexed()
1156 ret = _of_add_opp_table_v2(dev, opp_table); in _of_add_table_indexed()
1158 ret = _of_add_opp_table_v1(dev, opp_table); in _of_add_table_indexed()
1161 dev_pm_opp_put_opp_table(opp_table); in _of_add_table_indexed()
1188 * The opp_table structure will be freed after the device is destroyed.
1405 struct opp_table *opp_table; in of_get_required_opp_performance_state() local
1412 opp_table = _find_table_of_opp_np(required_np); in of_get_required_opp_performance_state()
1413 if (IS_ERR(opp_table)) { in of_get_required_opp_performance_state()
1415 __func__, np, PTR_ERR(opp_table)); in of_get_required_opp_performance_state()
1420 if (unlikely(!opp_table->is_genpd)) { in of_get_required_opp_performance_state()
1425 opp = _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()
1437 dev_pm_opp_put_opp_table(opp_table); in of_get_required_opp_performance_state()