Lines Matching full:opp_table

42 struct opp_table *_managed_opp(struct device *dev, int index)  in _managed_opp()
44 struct opp_table *opp_table, *managed_table = NULL; in _managed_opp() local
51 list_for_each_entry(opp_table, &opp_tables, node) { in _managed_opp()
52 if (opp_table->np == np) { in _managed_opp()
60 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) { in _managed_opp()
61 _get_opp_table_kref(opp_table); in _managed_opp()
62 managed_table = 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 mutex_lock(&opp_table->lock); in _find_opp_of_np()
82 list_for_each_entry(opp, &opp_table->opp_list, node) { in _find_opp_of_np()
85 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
90 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
102 static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) in _find_table_of_opp_np()
104 struct opp_table *opp_table; in _find_table_of_opp_np() local
115 list_for_each_entry(opp_table, &opp_tables, node) { in _find_table_of_opp_np()
116 if (opp_table_np == opp_table->np) { in _find_table_of_opp_np()
117 _get_opp_table_kref(opp_table); in _find_table_of_opp_np()
119 return opp_table; in _find_table_of_opp_np()
129 static void _opp_table_free_required_tables(struct opp_table *opp_table) in _opp_table_free_required_tables() argument
131 struct opp_table **required_opp_tables = opp_table->required_opp_tables; in _opp_table_free_required_tables()
137 for (i = 0; i < opp_table->required_opp_count; i++) { in _opp_table_free_required_tables()
146 opp_table->required_opp_count = 0; in _opp_table_free_required_tables()
147 opp_table->required_opp_tables = NULL; in _opp_table_free_required_tables()
148 list_del(&opp_table->lazy); in _opp_table_free_required_tables()
155 static void _opp_table_alloc_required_tables(struct opp_table *opp_table, in _opp_table_alloc_required_tables() argument
159 struct opp_table **required_opp_tables; in _opp_table_alloc_required_tables()
181 opp_table->required_opp_tables = required_opp_tables; in _opp_table_alloc_required_tables()
182 opp_table->required_opp_count = count; in _opp_table_alloc_required_tables()
198 list_add(&opp_table->lazy, &lazy_opp_tables); in _opp_table_alloc_required_tables()
203 _opp_table_free_required_tables(opp_table); in _opp_table_alloc_required_tables()
208 void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, in _of_init_opp_table() argument
223 opp_table->clock_latency_ns_max = val; in _of_init_opp_table()
225 &opp_table->voltage_tolerance_v1); in _of_init_opp_table()
228 opp_table->is_genpd = true; in _of_init_opp_table()
238 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; in _of_init_opp_table()
240 opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE; in _of_init_opp_table()
242 opp_table->np = opp_np; in _of_init_opp_table()
244 _opp_table_alloc_required_tables(opp_table, dev, opp_np); in _of_init_opp_table()
247 void _of_clear_opp_table(struct opp_table *opp_table) in _of_clear_opp_table() argument
249 _opp_table_free_required_tables(opp_table); in _of_clear_opp_table()
250 of_node_put(opp_table->np); in _of_clear_opp_table()
257 static void _of_opp_free_required_opps(struct opp_table *opp_table, in _of_opp_free_required_opps() argument
266 for (i = 0; i < opp_table->required_opp_count; i++) { in _of_opp_free_required_opps()
278 void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) in _of_clear_opp() argument
280 _of_opp_free_required_opps(opp_table, opp); in _of_clear_opp()
285 static int _of_opp_alloc_required_opps(struct opp_table *opp_table, in _of_opp_alloc_required_opps() argument
289 struct opp_table *required_table; in _of_opp_alloc_required_opps()
291 int i, ret, count = opp_table->required_opp_count; in _of_opp_alloc_required_opps()
303 required_table = opp_table->required_opp_tables[i]; in _of_opp_alloc_required_opps()
329 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
335 static int lazy_link_required_opps(struct opp_table *opp_table, in lazy_link_required_opps() argument
336 struct opp_table *new_table, int index) in lazy_link_required_opps()
341 list_for_each_entry(opp, &opp_table->opp_list, node) { in lazy_link_required_opps()
360 static void lazy_link_required_opp_table(struct opp_table *new_table) in lazy_link_required_opp_table()
362 struct opp_table *opp_table, *temp, **required_opp_tables; in lazy_link_required_opp_table() local
369 list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) { in lazy_link_required_opp_table()
373 opp_np = of_get_next_available_child(opp_table->np, NULL); in lazy_link_required_opp_table()
375 for (i = 0; i < opp_table->required_opp_count; i++) { in lazy_link_required_opp_table()
376 required_opp_tables = opp_table->required_opp_tables; in lazy_link_required_opp_table()
391 * opp_table. in lazy_link_required_opp_table()
402 ret = lazy_link_required_opps(opp_table, new_table, i); in lazy_link_required_opp_table()
414 list_del_init(&opp_table->lazy); in lazy_link_required_opp_table()
416 list_for_each_entry(opp, &opp_table->opp_list, node) in lazy_link_required_opp_table()
417 _required_opps_available(opp, opp_table->required_opp_count); in lazy_link_required_opp_table()
424 static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) in _bandwidth_supported() argument
429 if (!opp_table) { in _bandwidth_supported()
437 opp_np = of_node_get(opp_table->np); in _bandwidth_supported()
462 struct opp_table *opp_table) in dev_pm_opp_of_find_icc_paths() argument
468 ret = _bandwidth_supported(dev, opp_table); in dev_pm_opp_of_find_icc_paths()
509 if (opp_table) { in dev_pm_opp_of_find_icc_paths()
510 opp_table->paths = paths; in dev_pm_opp_of_find_icc_paths()
511 opp_table->path_count = num_paths; in dev_pm_opp_of_find_icc_paths()
525 static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, in _opp_is_supported() argument
528 unsigned int levels = opp_table->supported_hw_count; in _opp_is_supported()
532 if (!opp_table->supported_hw) { in _opp_is_supported()
568 if (!(val & opp_table->supported_hw[j])) { in _opp_is_supported()
582 struct opp_table *opp_table) in opp_parse_supplies() argument
585 int supplies = opp_table->regulator_count; in opp_parse_supplies()
591 if (opp_table->prop_name) { in opp_parse_supplies()
593 opp_table->prop_name); in opp_parse_supplies()
606 opp_table->regulator_count = 0; in opp_parse_supplies()
621 supplies = opp_table->regulator_count = 1; in opp_parse_supplies()
654 if (opp_table->prop_name) { in opp_parse_supplies()
656 opp_table->prop_name); in opp_parse_supplies()
776 static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_rate() argument
788 if (opp_table->clk_count != count) { in _read_rate()
790 __func__, count, opp_table->clk_count); in _read_rate()
820 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_bw() argument
833 if (opp_table->path_count != count) { in _read_bw()
835 __func__, name, count, opp_table->path_count); in _read_bw()
862 struct opp_table *opp_table, struct device_node *np) in _read_opp_key() argument
867 ret = _read_rate(new_opp, opp_table, np); in _read_opp_key()
878 ret = _read_bw(new_opp, opp_table, np, true); in _read_opp_key()
881 ret = _read_bw(new_opp, opp_table, np, false); in _read_opp_key()
899 * @opp_table: OPP table
921 static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, in _opp_add_static_v2() argument
928 new_opp = _opp_allocate(opp_table); in _opp_add_static_v2()
932 ret = _read_opp_key(new_opp, opp_table, np); in _opp_add_static_v2()
939 if (!_opp_is_supported(dev, opp_table, np)) { in _opp_add_static_v2()
951 ret = _of_opp_alloc_required_opps(opp_table, new_opp); in _opp_add_static_v2()
958 ret = opp_parse_supplies(new_opp, dev, opp_table); in _opp_add_static_v2()
962 if (opp_table->is_genpd) in _opp_add_static_v2()
965 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_static_v2()
975 if (opp_table->suspend_opp) { in _opp_add_static_v2()
977 if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) == 1) { in _opp_add_static_v2()
978 opp_table->suspend_opp->suspend = false; in _opp_add_static_v2()
980 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
984 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
988 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) in _opp_add_static_v2()
989 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; in _opp_add_static_v2()
1001 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_static_v2()
1005 _of_opp_free_required_opps(opp_table, new_opp); in _opp_add_static_v2()
1013 static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v2() argument
1020 mutex_lock(&opp_table->lock); in _of_add_opp_table_v2()
1021 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v2()
1022 opp_table->parsed_static_opps++; in _of_add_opp_table_v2()
1023 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1027 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v2()
1028 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1031 for_each_available_child_of_node(opp_table->np, np) { in _of_add_opp_table_v2()
1032 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
1051 list_for_each_entry(opp, &opp_table->opp_list, node) { in _of_add_opp_table_v2()
1054 opp_table->genpd_performance_state = true; in _of_add_opp_table_v2()
1059 lazy_link_required_opp_table(opp_table); in _of_add_opp_table_v2()
1064 _opp_remove_all_static(opp_table); in _of_add_opp_table_v2()
1070 static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v1() argument
1076 mutex_lock(&opp_table->lock); in _of_add_opp_table_v1()
1077 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v1()
1078 opp_table->parsed_static_opps++; in _of_add_opp_table_v1()
1079 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1083 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v1()
1084 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1112 ret = _opp_add_v1(opp_table, dev, freq, volt, false); in _of_add_opp_table_v1()
1124 _opp_remove_all_static(opp_table); in _of_add_opp_table_v1()
1131 struct opp_table *opp_table; in _of_add_table_indexed() local
1145 opp_table = _add_opp_table_indexed(dev, index, true); in _of_add_table_indexed()
1146 if (IS_ERR(opp_table)) in _of_add_table_indexed()
1147 return PTR_ERR(opp_table); in _of_add_table_indexed()
1153 if (opp_table->np) in _of_add_table_indexed()
1154 ret = _of_add_opp_table_v2(dev, opp_table); in _of_add_table_indexed()
1156 ret = _of_add_opp_table_v1(dev, opp_table); in _of_add_table_indexed()
1159 dev_pm_opp_put_opp_table(opp_table); in _of_add_table_indexed()
1186 * The opp_table structure will be freed after the device is destroyed.
1403 struct opp_table *opp_table; in of_get_required_opp_performance_state() local
1410 opp_table = _find_table_of_opp_np(required_np); in of_get_required_opp_performance_state()
1411 if (IS_ERR(opp_table)) { in of_get_required_opp_performance_state()
1413 __func__, np, PTR_ERR(opp_table)); in of_get_required_opp_performance_state()
1417 opp = _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()
1423 dev_pm_opp_put_opp_table(opp_table); in of_get_required_opp_performance_state()