Lines Matching refs: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
55 list_for_each_entry(opp_table, &opp_tables, node) { in _managed_opp()
56 if (opp_table->np == np) { in _managed_opp()
64 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) in _managed_opp()
65 managed_table = dev_pm_opp_get_opp_table_ref(opp_table); in _managed_opp()
75 static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table, in _find_opp_of_np() argument
80 guard(mutex)(&opp_table->lock); in _find_opp_of_np()
82 list_for_each_entry(opp, &opp_table->opp_list, node) { in _find_opp_of_np()
97 static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) in _find_table_of_opp_np()
99 struct opp_table *opp_table; in _find_table_of_opp_np() local
109 list_for_each_entry(opp_table, &opp_tables, node) { in _find_table_of_opp_np()
110 if (opp_table_np == opp_table->np) in _find_table_of_opp_np()
111 return dev_pm_opp_get_opp_table_ref(opp_table); in _find_table_of_opp_np()
118 static void _opp_table_free_required_tables(struct opp_table *opp_table) in _opp_table_free_required_tables() argument
120 struct opp_table **required_opp_tables = opp_table->required_opp_tables; in _opp_table_free_required_tables()
126 for (i = 0; i < opp_table->required_opp_count; i++) { in _opp_table_free_required_tables()
135 opp_table->required_opp_count = 0; in _opp_table_free_required_tables()
136 opp_table->required_opp_tables = NULL; in _opp_table_free_required_tables()
139 list_del(&opp_table->lazy); in _opp_table_free_required_tables()
146 static void _opp_table_alloc_required_tables(struct opp_table *opp_table, in _opp_table_alloc_required_tables() argument
150 struct opp_table **required_opp_tables; in _opp_table_alloc_required_tables()
167 size = sizeof(*required_opp_tables) + sizeof(*opp_table->required_devs); in _opp_table_alloc_required_tables()
172 opp_table->required_opp_tables = required_opp_tables; in _opp_table_alloc_required_tables()
173 opp_table->required_devs = (void *)(required_opp_tables + count); in _opp_table_alloc_required_tables()
174 opp_table->required_opp_count = count; in _opp_table_alloc_required_tables()
181 _opp_table_free_required_tables(opp_table); in _opp_table_alloc_required_tables()
198 list_add(&opp_table->lazy, &lazy_opp_tables); in _opp_table_alloc_required_tables()
202 void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, in _of_init_opp_table() argument
218 opp_table->clock_latency_ns_max = val; in _of_init_opp_table()
220 &opp_table->voltage_tolerance_v1); in _of_init_opp_table()
223 opp_table->is_genpd = true; in _of_init_opp_table()
231 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; in _of_init_opp_table()
233 opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE; in _of_init_opp_table()
235 opp_table->np = opp_np; in _of_init_opp_table()
237 _opp_table_alloc_required_tables(opp_table, dev, opp_np); in _of_init_opp_table()
240 void _of_clear_opp_table(struct opp_table *opp_table) in _of_clear_opp_table() argument
242 _opp_table_free_required_tables(opp_table); in _of_clear_opp_table()
243 of_node_put(opp_table->np); in _of_clear_opp_table()
250 static void _of_opp_free_required_opps(struct opp_table *opp_table, in _of_opp_free_required_opps() argument
259 for (i = 0; i < opp_table->required_opp_count; i++) { in _of_opp_free_required_opps()
271 void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) in _of_clear_opp() argument
273 _of_opp_free_required_opps(opp_table, opp); in _of_clear_opp()
278 struct opp_table *required_table, int index) in _link_required_opps()
297 static int _of_opp_alloc_required_opps(struct opp_table *opp_table, in _of_opp_alloc_required_opps() argument
300 struct opp_table *required_table; in _of_opp_alloc_required_opps()
301 int i, ret, count = opp_table->required_opp_count; in _of_opp_alloc_required_opps()
311 required_table = opp_table->required_opp_tables[i]; in _of_opp_alloc_required_opps()
325 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
331 static int lazy_link_required_opps(struct opp_table *opp_table, in lazy_link_required_opps() argument
332 struct opp_table *new_table, int index) in lazy_link_required_opps()
337 list_for_each_entry(opp, &opp_table->opp_list, node) { in lazy_link_required_opps()
347 static void lazy_link_required_opp_table(struct opp_table *new_table) in lazy_link_required_opp_table()
349 struct opp_table *opp_table, *temp, **required_opp_tables; in lazy_link_required_opp_table() local
355 list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) { in lazy_link_required_opp_table()
360 of_get_next_available_child(opp_table->np, NULL); in lazy_link_required_opp_table()
362 for (i = 0; i < opp_table->required_opp_count; i++) { in lazy_link_required_opp_table()
363 required_opp_tables = opp_table->required_opp_tables; in lazy_link_required_opp_table()
387 ret = lazy_link_required_opps(opp_table, new_table, i); in lazy_link_required_opp_table()
397 list_del_init(&opp_table->lazy); in lazy_link_required_opp_table()
399 list_for_each_entry(opp, &opp_table->opp_list, node) in lazy_link_required_opp_table()
400 _required_opps_available(opp, opp_table->required_opp_count); in lazy_link_required_opp_table()
405 static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) in _bandwidth_supported() argument
410 if (!opp_table) { in _bandwidth_supported()
419 opp_np = of_node_get(opp_table->np); in _bandwidth_supported()
443 struct opp_table *opp_table) in dev_pm_opp_of_find_icc_paths() argument
449 ret = _bandwidth_supported(dev, opp_table); in dev_pm_opp_of_find_icc_paths()
484 if (opp_table) { in dev_pm_opp_of_find_icc_paths()
485 opp_table->paths = paths; in dev_pm_opp_of_find_icc_paths()
486 opp_table->path_count = num_paths; in dev_pm_opp_of_find_icc_paths()
500 static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, in _opp_is_supported() argument
503 unsigned int levels = opp_table->supported_hw_count; in _opp_is_supported()
507 if (!opp_table->supported_hw) { in _opp_is_supported()
543 if (!(val & opp_table->supported_hw[j])) { in _opp_is_supported()
557 struct opp_table *opp_table, in _parse_named_prop() argument
566 if (opp_table->prop_name) { in _parse_named_prop()
568 opp_table->prop_name); in _parse_named_prop()
592 if (unlikely(opp_table->regulator_count == -1)) in _parse_named_prop()
593 opp_table->regulator_count = 1; in _parse_named_prop()
595 if (count != opp_table->regulator_count && in _parse_named_prop()
596 (!triplet || count != opp_table->regulator_count * 3)) { in _parse_named_prop()
598 __func__, prop_type, count, opp_table->regulator_count); in _parse_named_prop()
614 *triplet = count != opp_table->regulator_count; in _parse_named_prop()
620 struct opp_table *opp_table, bool *triplet) in opp_parse_microvolt() argument
624 microvolt = _parse_named_prop(opp, dev, opp_table, "microvolt", triplet); in opp_parse_microvolt()
636 if (list_empty(&opp_table->opp_list) && in opp_parse_microvolt()
637 opp_table->regulator_count > 0) { in opp_parse_microvolt()
648 struct opp_table *opp_table) in opp_parse_supplies() argument
654 microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet); in opp_parse_supplies()
658 microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL); in opp_parse_supplies()
664 microwatt = _parse_named_prop(opp, dev, opp_table, "microwatt", NULL); in opp_parse_supplies()
674 if (unlikely(opp_table->regulator_count == -1)) { in opp_parse_supplies()
675 opp_table->regulator_count = 0; in opp_parse_supplies()
679 for (i = 0, j = 0; i < opp_table->regulator_count; i++) { in opp_parse_supplies()
721 static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_rate() argument
733 if (opp_table->clk_count != count) { in _read_rate()
735 __func__, count, opp_table->clk_count); in _read_rate()
765 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_bw() argument
778 if (opp_table->path_count != count) { in _read_bw()
780 __func__, name, count, opp_table->path_count); in _read_bw()
807 struct opp_table *opp_table, struct device_node *np) in _read_opp_key() argument
812 ret = _read_rate(new_opp, opp_table, np); in _read_opp_key()
823 ret = _read_bw(new_opp, opp_table, np, true); in _read_opp_key()
826 ret = _read_bw(new_opp, opp_table, np, false); in _read_opp_key()
866 static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, in _opp_add_static_v2() argument
873 new_opp = _opp_allocate(opp_table); in _opp_add_static_v2()
877 ret = _read_opp_key(new_opp, opp_table, np); in _opp_add_static_v2()
884 if (!_opp_is_supported(dev, opp_table, np)) { in _opp_add_static_v2()
896 ret = _of_opp_alloc_required_opps(opp_table, new_opp); in _opp_add_static_v2()
903 ret = opp_parse_supplies(new_opp, dev, opp_table); in _opp_add_static_v2()
907 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_static_v2()
917 if (opp_table->suspend_opp) { in _opp_add_static_v2()
919 if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) == 1) { in _opp_add_static_v2()
920 opp_table->suspend_opp->suspend = false; in _opp_add_static_v2()
922 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
926 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
930 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) in _opp_add_static_v2()
931 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; in _opp_add_static_v2()
943 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_static_v2()
947 _of_opp_free_required_opps(opp_table, new_opp); in _opp_add_static_v2()
957 static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v2() argument
963 scoped_guard(mutex, &opp_table->lock) { in _of_add_opp_table_v2()
964 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v2()
965 opp_table->parsed_static_opps++; in _of_add_opp_table_v2()
969 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v2()
973 for_each_available_child_of_node_scoped(opp_table->np, np) { in _of_add_opp_table_v2()
974 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
992 lazy_link_required_opp_table(opp_table); in _of_add_opp_table_v2()
997 _opp_remove_all_static(opp_table); in _of_add_opp_table_v2()
1003 static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v1() argument
1009 scoped_guard(mutex, &opp_table->lock) { in _of_add_opp_table_v1()
1010 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v1()
1011 opp_table->parsed_static_opps++; in _of_add_opp_table_v1()
1015 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v1()
1048 ret = _opp_add_v1(opp_table, dev, &data, false); in _of_add_opp_table_v1()
1060 _opp_remove_all_static(opp_table); in _of_add_opp_table_v1()
1067 struct opp_table *opp_table; in _of_add_table_indexed() local
1081 opp_table = _add_opp_table_indexed(dev, index, true); in _of_add_table_indexed()
1082 if (IS_ERR(opp_table)) in _of_add_table_indexed()
1083 return PTR_ERR(opp_table); in _of_add_table_indexed()
1089 if (opp_table->np) in _of_add_table_indexed()
1090 ret = _of_add_opp_table_v2(dev, opp_table); in _of_add_table_indexed()
1092 ret = _of_add_opp_table_v1(dev, opp_table); in _of_add_table_indexed()
1095 dev_pm_opp_put_opp_table(opp_table); in _of_add_table_indexed()
1343 struct opp_table *opp_table __free(put_opp_table) = in of_get_required_opp_performance_state()
1346 if (IS_ERR(opp_table)) { in of_get_required_opp_performance_state()
1348 __func__, np, PTR_ERR(opp_table)); in of_get_required_opp_performance_state()
1349 return PTR_ERR(opp_table); in of_get_required_opp_performance_state()
1353 if (unlikely(!opp_table->is_genpd)) { in of_get_required_opp_performance_state()
1359 _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()