Lines Matching refs:opp_table

45 struct opp_table *_managed_opp(struct device *dev, int index)
47 struct opp_table *opp_table, *managed_table = NULL;
54 list_for_each_entry(opp_table, &opp_tables, node) {
55 if (opp_table->np == np) {
63 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED)
64 managed_table = dev_pm_opp_get_opp_table_ref(opp_table);
74 static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table,
79 guard(mutex)(&opp_table->lock);
81 list_for_each_entry(opp, &opp_table->opp_list, node) {
96 static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np)
99 struct opp_table *opp_table;
107 list_for_each_entry(opp_table, &opp_tables, node) {
108 if (opp_table_np == opp_table->np)
109 return dev_pm_opp_get_opp_table_ref(opp_table);
116 static void _opp_table_free_required_tables(struct opp_table *opp_table)
118 struct opp_table **required_opp_tables = opp_table->required_opp_tables;
124 for (i = 0; i < opp_table->required_opp_count; i++) {
133 opp_table->required_opp_count = 0;
134 opp_table->required_opp_tables = NULL;
137 list_del(&opp_table->lazy);
144 static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
148 struct opp_table **required_opp_tables;
164 size = sizeof(*required_opp_tables) + sizeof(*opp_table->required_devs);
169 opp_table->required_opp_tables = required_opp_tables;
170 opp_table->required_devs = (void *)(required_opp_tables + count);
171 opp_table->required_opp_count = count;
178 _opp_table_free_required_tables(opp_table);
195 list_add(&opp_table->lazy, &lazy_opp_tables);
199 void _of_init_opp_table(struct opp_table *opp_table, struct device *dev,
214 opp_table->clock_latency_ns_max = val;
216 &opp_table->voltage_tolerance_v1);
219 opp_table->is_genpd = true;
227 opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED;
229 opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE;
231 opp_table->np = opp_np;
233 _opp_table_alloc_required_tables(opp_table, dev, opp_np);
236 void _of_clear_opp_table(struct opp_table *opp_table)
238 _opp_table_free_required_tables(opp_table);
239 of_node_put(opp_table->np);
246 static void _of_opp_free_required_opps(struct opp_table *opp_table,
255 for (i = 0; i < opp_table->required_opp_count; i++) {
267 void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp)
269 _of_opp_free_required_opps(opp_table, opp);
274 struct opp_table *required_table, int index)
293 static int _of_opp_alloc_required_opps(struct opp_table *opp_table,
296 struct opp_table *required_table;
297 int i, ret, count = opp_table->required_opp_count;
307 required_table = opp_table->required_opp_tables[i];
321 _of_opp_free_required_opps(opp_table, opp);
327 static int lazy_link_required_opps(struct opp_table *opp_table,
328 struct opp_table *new_table, int index)
333 list_for_each_entry(opp, &opp_table->opp_list, node) {
343 static void lazy_link_required_opp_table(struct opp_table *new_table)
345 struct opp_table *opp_table, *temp, **required_opp_tables;
351 list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) {
356 opp_np = of_get_next_available_child(opp_table->np, NULL);
358 for (i = 0; i < opp_table->required_opp_count; i++) {
362 required_opp_tables = opp_table->required_opp_tables;
374 * opp_table.
384 ret = lazy_link_required_opps(opp_table, new_table, i);
394 list_del_init(&opp_table->lazy);
396 list_for_each_entry(opp, &opp_table->opp_list, node)
397 _required_opps_available(opp, opp_table->required_opp_count);
402 static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table)
408 if (!opp_table) {
417 opp_np = of_node_get(opp_table->np);
439 struct opp_table *opp_table)
445 ret = _bandwidth_supported(dev, opp_table);
480 if (opp_table) {
481 opp_table->paths = paths;
482 opp_table->path_count = num_paths;
496 static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table,
499 unsigned int levels = opp_table->supported_hw_count;
503 if (!opp_table->supported_hw) {
539 if (!(val & opp_table->supported_hw[j])) {
553 struct opp_table *opp_table,
562 if (opp_table->prop_name) {
564 opp_table->prop_name);
588 if (unlikely(opp_table->regulator_count == -1))
589 opp_table->regulator_count = 1;
591 if (count != opp_table->regulator_count &&
592 (!triplet || count != opp_table->regulator_count * 3)) {
594 __func__, prop_type, count, opp_table->regulator_count);
610 *triplet = count != opp_table->regulator_count;
616 struct opp_table *opp_table, bool *triplet)
620 microvolt = _parse_named_prop(opp, dev, opp_table, "microvolt", triplet);
632 if (list_empty(&opp_table->opp_list) &&
633 opp_table->regulator_count > 0) {
644 struct opp_table *opp_table)
650 microvolt = opp_parse_microvolt(opp, dev, opp_table, &triplet);
654 microamp = _parse_named_prop(opp, dev, opp_table, "microamp", NULL);
660 microwatt = _parse_named_prop(opp, dev, opp_table, "microwatt", NULL);
670 if (unlikely(opp_table->regulator_count == -1)) {
671 opp_table->regulator_count = 0;
675 for (i = 0, j = 0; i < opp_table->regulator_count; i++) {
717 static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_table,
729 if (opp_table->clk_count != count) {
731 __func__, count, opp_table->clk_count);
761 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_table,
774 if (opp_table->path_count != count) {
776 __func__, name, count, opp_table->path_count);
803 struct opp_table *opp_table, struct device_node *np)
808 ret = _read_rate(new_opp, opp_table, np);
819 ret = _read_bw(new_opp, opp_table, np, true);
822 ret = _read_bw(new_opp, opp_table, np, false);
840 * @opp_table: OPP table
862 static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
869 new_opp = _opp_allocate(opp_table);
873 ret = _read_opp_key(new_opp, opp_table, np);
880 if (!_opp_is_supported(dev, opp_table, np)) {
892 ret = _of_opp_alloc_required_opps(opp_table, new_opp);
899 ret = opp_parse_supplies(new_opp, dev, opp_table);
903 ret = _opp_add(dev, new_opp, opp_table);
913 if (opp_table->suspend_opp) {
915 if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) == 1) {
916 opp_table->suspend_opp->suspend = false;
918 opp_table->suspend_opp = new_opp;
922 opp_table->suspend_opp = new_opp;
926 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max)
927 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns;
939 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp);
943 _of_opp_free_required_opps(opp_table, new_opp);
953 static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
960 scoped_guard(mutex, &opp_table->lock) {
961 if (opp_table->parsed_static_opps) {
962 opp_table->parsed_static_opps++;
966 opp_table->parsed_static_opps = 1;
970 for_each_available_child_of_node(opp_table->np, np) {
971 opp = _opp_add_static_v2(opp_table, dev, np);
990 lazy_link_required_opp_table(opp_table);
995 _opp_remove_all_static(opp_table);
1001 static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
1007 scoped_guard(mutex, &opp_table->lock) {
1008 if (opp_table->parsed_static_opps) {
1009 opp_table->parsed_static_opps++;
1013 opp_table->parsed_static_opps = 1;
1046 ret = _opp_add_v1(opp_table, dev, &data, false);
1058 _opp_remove_all_static(opp_table);
1065 struct opp_table *opp_table;
1079 opp_table = _add_opp_table_indexed(dev, index, true);
1080 if (IS_ERR(opp_table))
1081 return PTR_ERR(opp_table);
1087 if (opp_table->np)
1088 ret = _of_add_opp_table_v2(dev, opp_table);
1090 ret = _of_add_opp_table_v1(dev, opp_table);
1093 dev_pm_opp_put_opp_table(opp_table);
1120 * The opp_table structure will be freed after the device is destroyed.
1332 struct opp_table *opp_table __free(put_opp_table) = NULL;
1340 opp_table = _find_table_of_opp_np(required_np);
1341 if (IS_ERR(opp_table)) {
1343 __func__, np, PTR_ERR(opp_table));
1344 return PTR_ERR(opp_table);
1348 if (unlikely(!opp_table->is_genpd)) {
1353 opp = _find_opp_of_np(opp_table, required_np);