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
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()
187 opp_table->required_opp_tables = required_opp_tables; in _opp_table_alloc_required_tables()
188 opp_table->required_opp_count = count; in _opp_table_alloc_required_tables()
209 list_add(&opp_table->lazy, &lazy_opp_tables); in _opp_table_alloc_required_tables()
213 _update_set_required_opps(opp_table); in _opp_table_alloc_required_tables()
218 _opp_table_free_required_tables(opp_table); in _opp_table_alloc_required_tables()
223 void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, in _of_init_opp_table() argument
238 opp_table->clock_latency_ns_max = val; in _of_init_opp_table()
240 &opp_table->voltage_tolerance_v1); in _of_init_opp_table()
243 opp_table->is_genpd = true; in _of_init_opp_table()
253 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; in _of_init_opp_table()
255 opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE; in _of_init_opp_table()
257 opp_table->np = opp_np; in _of_init_opp_table()
259 _opp_table_alloc_required_tables(opp_table, dev, opp_np); in _of_init_opp_table()
262 void _of_clear_opp_table(struct opp_table *opp_table) in _of_clear_opp_table() argument
264 _opp_table_free_required_tables(opp_table); in _of_clear_opp_table()
265 of_node_put(opp_table->np); in _of_clear_opp_table()
272 static void _of_opp_free_required_opps(struct opp_table *opp_table, in _of_opp_free_required_opps() argument
281 for (i = 0; i < opp_table->required_opp_count; i++) { in _of_opp_free_required_opps()
293 void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) in _of_clear_opp() argument
295 _of_opp_free_required_opps(opp_table, opp); in _of_clear_opp()
300 static int _of_opp_alloc_required_opps(struct opp_table *opp_table, in _of_opp_alloc_required_opps() argument
304 struct opp_table *required_table; in _of_opp_alloc_required_opps()
306 int i, ret, count = opp_table->required_opp_count; in _of_opp_alloc_required_opps()
318 required_table = opp_table->required_opp_tables[i]; in _of_opp_alloc_required_opps()
344 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
350 static int lazy_link_required_opps(struct opp_table *opp_table, in lazy_link_required_opps() argument
351 struct opp_table *new_table, int index) in lazy_link_required_opps()
356 list_for_each_entry(opp, &opp_table->opp_list, node) { in lazy_link_required_opps()
375 static void lazy_link_required_opp_table(struct opp_table *new_table) in lazy_link_required_opp_table()
377 struct opp_table *opp_table, *temp, **required_opp_tables; in lazy_link_required_opp_table() local
384 list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) { in lazy_link_required_opp_table()
388 opp_np = of_get_next_available_child(opp_table->np, NULL); in lazy_link_required_opp_table()
390 for (i = 0; i < opp_table->required_opp_count; i++) { in lazy_link_required_opp_table()
391 required_opp_tables = opp_table->required_opp_tables; in lazy_link_required_opp_table()
417 ret = lazy_link_required_opps(opp_table, new_table, i); in lazy_link_required_opp_table()
429 _update_set_required_opps(opp_table); in lazy_link_required_opp_table()
430 list_del_init(&opp_table->lazy); in lazy_link_required_opp_table()
432 list_for_each_entry(opp, &opp_table->opp_list, node) in lazy_link_required_opp_table()
433 _required_opps_available(opp, opp_table->required_opp_count); in lazy_link_required_opp_table()
440 static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) in _bandwidth_supported() argument
445 if (!opp_table) { in _bandwidth_supported()
453 opp_np = of_node_get(opp_table->np); in _bandwidth_supported()
478 struct opp_table *opp_table) in dev_pm_opp_of_find_icc_paths() argument
484 ret = _bandwidth_supported(dev, opp_table); in dev_pm_opp_of_find_icc_paths()
521 if (opp_table) { in dev_pm_opp_of_find_icc_paths()
522 opp_table->paths = paths; in dev_pm_opp_of_find_icc_paths()
523 opp_table->path_count = num_paths; in dev_pm_opp_of_find_icc_paths()
537 static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, in _opp_is_supported() argument
540 unsigned int levels = opp_table->supported_hw_count; in _opp_is_supported()
544 if (!opp_table->supported_hw) { in _opp_is_supported()
580 if (!(val & opp_table->supported_hw[j])) { in _opp_is_supported()
594 struct opp_table *opp_table, in _parse_named_prop() argument
603 if (opp_table->prop_name) { in _parse_named_prop()
605 opp_table->prop_name); in _parse_named_prop()
629 if (unlikely(opp_table->regulator_count == -1)) in _parse_named_prop()
630 opp_table->regulator_count = 1; in _parse_named_prop()
632 if (count != opp_table->regulator_count && in _parse_named_prop()
633 (!triplet || count != opp_table->regulator_count * 3)) { in _parse_named_prop()
635 __func__, prop_type, count, opp_table->regulator_count); in _parse_named_prop()
651 *triplet = count != opp_table->regulator_count; in _parse_named_prop()
657 struct opp_table *opp_table, bool *triplet) in opp_parse_microvolt() argument
661 microvolt = _parse_named_prop(opp, dev, opp_table, "microvolt", triplet); in opp_parse_microvolt()
673 if (list_empty(&opp_table->opp_list) && in opp_parse_microvolt()
674 opp_table->regulator_count > 0) { in opp_parse_microvolt()
685 struct opp_table *opp_table) in opp_parse_supplies() argument
691 microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet); in opp_parse_supplies()
695 microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL); in opp_parse_supplies()
701 microwatt = _parse_named_prop(opp, dev, opp_table, "microwatt", NULL); in opp_parse_supplies()
711 if (unlikely(opp_table->regulator_count == -1)) { in opp_parse_supplies()
712 opp_table->regulator_count = 0; in opp_parse_supplies()
716 for (i = 0, j = 0; i < opp_table->regulator_count; i++) { in opp_parse_supplies()
758 static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_rate() argument
770 if (opp_table->clk_count != count) { in _read_rate()
772 __func__, count, opp_table->clk_count); in _read_rate()
802 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_table, in _read_bw() argument
815 if (opp_table->path_count != count) { in _read_bw()
817 __func__, name, count, opp_table->path_count); in _read_bw()
844 struct opp_table *opp_table, struct device_node *np) in _read_opp_key() argument
849 ret = _read_rate(new_opp, opp_table, np); in _read_opp_key()
860 ret = _read_bw(new_opp, opp_table, np, true); in _read_opp_key()
863 ret = _read_bw(new_opp, opp_table, np, false); in _read_opp_key()
903 static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, in _opp_add_static_v2() argument
910 new_opp = _opp_allocate(opp_table); in _opp_add_static_v2()
914 ret = _read_opp_key(new_opp, opp_table, np); in _opp_add_static_v2()
921 if (!_opp_is_supported(dev, opp_table, np)) { in _opp_add_static_v2()
933 ret = _of_opp_alloc_required_opps(opp_table, new_opp); in _opp_add_static_v2()
940 ret = opp_parse_supplies(new_opp, dev, opp_table); in _opp_add_static_v2()
944 ret = _opp_add(dev, new_opp, opp_table); in _opp_add_static_v2()
954 if (opp_table->suspend_opp) { in _opp_add_static_v2()
956 if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) == 1) { in _opp_add_static_v2()
957 opp_table->suspend_opp->suspend = false; in _opp_add_static_v2()
959 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
963 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
967 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) in _opp_add_static_v2()
968 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; in _opp_add_static_v2()
980 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_static_v2()
984 _of_opp_free_required_opps(opp_table, new_opp); in _opp_add_static_v2()
992 static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v2() argument
999 mutex_lock(&opp_table->lock); in _of_add_opp_table_v2()
1000 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v2()
1001 opp_table->parsed_static_opps++; in _of_add_opp_table_v2()
1002 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1006 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v2()
1007 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
1010 for_each_available_child_of_node(opp_table->np, np) { in _of_add_opp_table_v2()
1011 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
1030 lazy_link_required_opp_table(opp_table); in _of_add_opp_table_v2()
1035 _opp_remove_all_static(opp_table); in _of_add_opp_table_v2()
1041 static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) in _of_add_opp_table_v1() argument
1047 mutex_lock(&opp_table->lock); in _of_add_opp_table_v1()
1048 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v1()
1049 opp_table->parsed_static_opps++; in _of_add_opp_table_v1()
1050 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1054 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v1()
1055 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1083 ret = _opp_add_v1(opp_table, dev, freq, volt, false); in _of_add_opp_table_v1()
1095 _opp_remove_all_static(opp_table); in _of_add_opp_table_v1()
1102 struct opp_table *opp_table; in _of_add_table_indexed() local
1116 opp_table = _add_opp_table_indexed(dev, index, true); in _of_add_table_indexed()
1117 if (IS_ERR(opp_table)) in _of_add_table_indexed()
1118 return PTR_ERR(opp_table); in _of_add_table_indexed()
1124 if (opp_table->np) in _of_add_table_indexed()
1125 ret = _of_add_opp_table_v2(dev, opp_table); in _of_add_table_indexed()
1127 ret = _of_add_opp_table_v1(dev, opp_table); in _of_add_table_indexed()
1130 dev_pm_opp_put_opp_table(opp_table); in _of_add_table_indexed()
1374 struct opp_table *opp_table; in of_get_required_opp_performance_state() local
1381 opp_table = _find_table_of_opp_np(required_np); in of_get_required_opp_performance_state()
1382 if (IS_ERR(opp_table)) { in of_get_required_opp_performance_state()
1384 __func__, np, PTR_ERR(opp_table)); in of_get_required_opp_performance_state()
1389 if (unlikely(!opp_table->is_genpd)) { in of_get_required_opp_performance_state()
1394 opp = _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()
1400 dev_pm_opp_put_opp_table(opp_table); in of_get_required_opp_performance_state()