Lines Matching +full:opp +full:- +full:table

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Generic OPP OF helpers
5 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
22 #include "opp.h"
25 * Returns opp descriptor node for a device node, caller must
31 /* "operating-points-v2" can be an array for power domain providers */ in _opp_of_get_opp_desc_node()
32 return of_parse_phandle(np, "operating-points-v2", index); in _opp_of_get_opp_desc_node()
35 /* Returns opp descriptor node for a device, caller must do of_node_put() */
38 return _opp_of_get_opp_desc_node(dev->of_node, 0); in dev_pm_opp_of_get_opp_desc_node()
47 np = _opp_of_get_opp_desc_node(dev->of_node, index); in _managed_opp()
52 if (opp_table->np == np) { in _managed_opp()
54 * Multiple devices can point to the same OPP table and in _managed_opp()
55 * so will have same node-pointer, np. in _managed_opp()
58 * OPP table contains a "opp-shared" property. in _managed_opp()
60 if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) { in _managed_opp()
74 /* The caller must call dev_pm_opp_put() after the OPP is used */
78 struct dev_pm_opp *opp; in _find_opp_of_np() local
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()
83 if (opp->np == opp_np) { in _find_opp_of_np()
84 dev_pm_opp_get(opp); in _find_opp_of_np()
85 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
86 return opp; in _find_opp_of_np()
90 mutex_unlock(&opp_table->lock); in _find_opp_of_np()
98 return of_parse_phandle(np, "required-opps", index); in of_parse_required_opp()
101 /* The caller must call dev_pm_opp_put_opp_table() after the table is used */
116 if (opp_table_np == opp_table->np) { in _find_table_of_opp_np()
125 return ERR_PTR(-ENODEV); in _find_table_of_opp_np()
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()
152 * Populate all devices and opp tables which are part of "required-opps" list.
153 * Checking only the first OPP node should be enough.
164 /* Traversing the first OPP node is all we need */ in _opp_table_alloc_required_tables()
167 dev_warn(dev, "Empty OPP table\n"); in _opp_table_alloc_required_tables()
172 count = of_count_phandle_with_args(np, "required-opps", NULL); 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()
218 np = of_node_get(dev->of_node); in _of_init_opp_table()
222 if (!of_property_read_u32(np, "clock-latency", &val)) in _of_init_opp_table()
223 opp_table->clock_latency_ns_max = val; in _of_init_opp_table()
224 of_property_read_u32(np, "voltage-tolerance", in _of_init_opp_table()
225 &opp_table->voltage_tolerance_v1); in _of_init_opp_table()
227 if (of_find_property(np, "#power-domain-cells", NULL)) in _of_init_opp_table()
228 opp_table->is_genpd = true; in _of_init_opp_table()
230 /* Get OPP table node */ in _of_init_opp_table()
237 if (of_property_read_bool(opp_np, "opp-shared")) 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()
258 struct dev_pm_opp *opp) in _of_opp_free_required_opps() argument
260 struct dev_pm_opp **required_opps = opp->required_opps; in _of_opp_free_required_opps()
266 for (i = 0; i < opp_table->required_opp_count; i++) { in _of_opp_free_required_opps()
274 opp->required_opps = NULL; in _of_opp_free_required_opps()
278 /* Populate all required OPPs which are part of "required-opps" list */
280 struct dev_pm_opp *opp) in _of_opp_alloc_required_opps() argument
285 int i, ret, count = opp_table->required_opp_count; in _of_opp_alloc_required_opps()
292 return -ENOMEM; in _of_opp_alloc_required_opps()
294 opp->required_opps = required_opps; in _of_opp_alloc_required_opps()
297 required_table = opp_table->required_opp_tables[i]; in _of_opp_alloc_required_opps()
299 /* Required table not added yet, we will link later */ in _of_opp_alloc_required_opps()
303 np = of_parse_required_opp(opp->np, i); in _of_opp_alloc_required_opps()
305 ret = -ENODEV; in _of_opp_alloc_required_opps()
313 pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", in _of_opp_alloc_required_opps()
314 __func__, opp->np, i); in _of_opp_alloc_required_opps()
315 ret = -ENODEV; in _of_opp_alloc_required_opps()
323 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
328 /* Link required OPPs for an individual OPP */
333 struct dev_pm_opp *opp; in lazy_link_required_opps() local
335 list_for_each_entry(opp, &opp_table->opp_list, node) { in lazy_link_required_opps()
336 required_np = of_parse_required_opp(opp->np, index); in lazy_link_required_opps()
338 return -ENODEV; in lazy_link_required_opps()
340 opp->required_opps[index] = _find_opp_of_np(new_table, required_np); in lazy_link_required_opps()
343 if (!opp->required_opps[index]) { in lazy_link_required_opps()
344 pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", in lazy_link_required_opps()
345 __func__, opp->np, index); in lazy_link_required_opps()
346 return -ENODEV; in lazy_link_required_opps()
353 /* Link required OPPs for all OPPs of the newly added OPP table */
358 struct dev_pm_opp *opp; in lazy_link_required_opp_table() local
367 opp_np = of_get_next_available_child(opp_table->np, NULL); in lazy_link_required_opp_table()
369 for (i = 0; i < opp_table->required_opp_count; i++) { in lazy_link_required_opp_table()
370 required_opp_tables = opp_table->required_opp_tables; in lazy_link_required_opp_table()
372 /* Required opp-table is already parsed */ in lazy_link_required_opp_table()
384 * Newly added table isn't the required opp-table for in lazy_link_required_opp_table()
387 if (required_table_np != new_table->np) { in lazy_link_required_opp_table()
406 /* All required opp-tables found, remove from lazy list */ in lazy_link_required_opp_table()
408 list_del_init(&opp_table->lazy); in lazy_link_required_opp_table()
410 list_for_each_entry(opp, &opp_table->opp_list, node) in lazy_link_required_opp_table()
411 _required_opps_available(opp, opp_table->required_opp_count); in lazy_link_required_opp_table()
424 np = of_node_get(dev->of_node); in _bandwidth_supported()
426 return -ENODEV; in _bandwidth_supported()
431 opp_np = of_node_get(opp_table->np); in _bandwidth_supported()
434 /* Lets not fail in case we are parsing opp-v1 bindings */ in _bandwidth_supported()
438 /* Checking only first OPP is sufficient */ in _bandwidth_supported()
441 dev_err(dev, "OPP table empty\n"); in _bandwidth_supported()
442 return -EINVAL; in _bandwidth_supported()
446 prop = of_find_property(np, "opp-peak-kBps", NULL); in _bandwidth_supported()
449 if (!prop || !prop->length) in _bandwidth_supported()
463 if (ret == -EINVAL) in dev_pm_opp_of_find_icc_paths()
464 return 0; /* Empty OPP table is a valid corner-case, let's not fail */ in dev_pm_opp_of_find_icc_paths()
470 np = of_node_get(dev->of_node); in dev_pm_opp_of_find_icc_paths()
475 "#interconnect-cells"); in dev_pm_opp_of_find_icc_paths()
480 /* two phandles when #interconnect-cells = <1> */ in dev_pm_opp_of_find_icc_paths()
483 return -EINVAL; in dev_pm_opp_of_find_icc_paths()
489 return -ENOMEM; in dev_pm_opp_of_find_icc_paths()
495 if (ret != -EPROBE_DEFER) { in dev_pm_opp_of_find_icc_paths()
504 opp_table->paths = paths; in dev_pm_opp_of_find_icc_paths()
505 opp_table->path_count = num_paths; in dev_pm_opp_of_find_icc_paths()
510 while (i--) in dev_pm_opp_of_find_icc_paths()
522 unsigned int levels = opp_table->supported_hw_count; in _opp_is_supported()
526 if (!opp_table->supported_hw) { in _opp_is_supported()
529 * platform but there is an opp-supported-hw value set for in _opp_is_supported()
530 * an OPP then the OPP should not be enabled as there is in _opp_is_supported()
533 if (of_find_property(np, "opp-supported-hw", NULL)) in _opp_is_supported()
539 count = of_property_count_u32_elems(np, "opp-supported-hw"); in _opp_is_supported()
541 dev_err(dev, "%s: Invalid opp-supported-hw property (%d)\n", in _opp_is_supported()
553 ret = of_property_read_u32_index(np, "opp-supported-hw", in _opp_is_supported()
556 dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n", in _opp_is_supported()
562 if (!(val & opp_table->supported_hw[j])) { in _opp_is_supported()
575 static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, in opp_parse_supplies() argument
579 int supplies = opp_table->regulator_count, vcount, icount, ret, i, j; in opp_parse_supplies()
583 /* Search for "opp-microvolt-<name>" */ in opp_parse_supplies()
584 if (opp_table->prop_name) { in opp_parse_supplies()
585 snprintf(name, sizeof(name), "opp-microvolt-%s", in opp_parse_supplies()
586 opp_table->prop_name); in opp_parse_supplies()
587 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
591 /* Search for "opp-microvolt" */ in opp_parse_supplies()
592 sprintf(name, "opp-microvolt"); in opp_parse_supplies()
593 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
597 if (unlikely(supplies == -1)) { in opp_parse_supplies()
599 opp_table->regulator_count = 0; in opp_parse_supplies()
606 dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n", in opp_parse_supplies()
608 return -EINVAL; in opp_parse_supplies()
612 if (unlikely(supplies == -1)) { in opp_parse_supplies()
614 supplies = opp_table->regulator_count = 1; in opp_parse_supplies()
616 dev_err(dev, "%s: opp-microvolt wasn't expected\n", __func__); in opp_parse_supplies()
617 return -EINVAL; in opp_parse_supplies()
620 vcount = of_property_count_u32_elems(opp->np, name); in opp_parse_supplies()
631 return -EINVAL; in opp_parse_supplies()
636 return -ENOMEM; in opp_parse_supplies()
638 ret = of_property_read_u32_array(opp->np, name, microvolt, vcount); in opp_parse_supplies()
641 ret = -EINVAL; in opp_parse_supplies()
645 /* Search for "opp-microamp-<name>" */ in opp_parse_supplies()
647 if (opp_table->prop_name) { in opp_parse_supplies()
648 snprintf(name, sizeof(name), "opp-microamp-%s", in opp_parse_supplies()
649 opp_table->prop_name); in opp_parse_supplies()
650 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
654 /* Search for "opp-microamp" */ in opp_parse_supplies()
655 sprintf(name, "opp-microamp"); in opp_parse_supplies()
656 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
660 icount = of_property_count_u32_elems(opp->np, name); in opp_parse_supplies()
671 ret = -EINVAL; in opp_parse_supplies()
677 ret = -EINVAL; in opp_parse_supplies()
681 ret = of_property_read_u32_array(opp->np, name, microamp, in opp_parse_supplies()
686 ret = -EINVAL; in opp_parse_supplies()
692 opp->supplies[i].u_volt = microvolt[j++]; in opp_parse_supplies()
695 opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; in opp_parse_supplies()
696 opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; in opp_parse_supplies()
698 opp->supplies[i].u_volt_min = microvolt[j++]; in opp_parse_supplies()
699 opp->supplies[i].u_volt_max = microvolt[j++]; in opp_parse_supplies()
703 opp->supplies[i].u_amp = microamp[i]; in opp_parse_supplies()
715 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
717 * @dev: device pointer used to lookup OPP table.
727 static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *table, in _read_bw() argument
730 const char *name = peak ? "opp-peak-kBps" : "opp-avg-kBps"; in _read_bw()
737 return -ENODEV; in _read_bw()
739 count = prop->length / sizeof(u32); in _read_bw()
740 if (table->path_count != count) { in _read_bw()
742 __func__, name, count, table->path_count); in _read_bw()
743 return -EINVAL; in _read_bw()
748 return -ENOMEM; in _read_bw()
758 new_opp->bandwidth[i].peak = kBps_to_icc(bw[i]); in _read_bw()
760 new_opp->bandwidth[i].avg = kBps_to_icc(bw[i]); in _read_bw()
768 static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *table, in _read_opp_key() argument
775 ret = of_property_read_u64(np, "opp-hz", &rate); in _read_opp_key()
782 new_opp->rate = (unsigned long)rate; in _read_opp_key()
789 * opp-peak-kBps = <path1_value path2_value>; in _read_opp_key()
790 * opp-avg-kBps = <path1_value path2_value>; in _read_opp_key()
792 ret = _read_bw(new_opp, table, np, true); in _read_opp_key()
795 ret = _read_bw(new_opp, table, np, false); in _read_opp_key()
799 if (ret && ret != -ENODEV) in _read_opp_key()
802 if (!of_property_read_u32(np, "opp-level", &new_opp->level)) in _read_opp_key()
812 * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings)
813 * @opp_table: OPP table
817 * This function adds an opp definition to the opp table and returns status. The
818 * opp can be controlled using dev_pm_opp_enable/disable functions and may be
822 * Valid OPP pointer:
825 * Duplicate OPPs (both freq and volt are same) and opp->available
826 * OR if the OPP is not supported by hardware.
827 * ERR_PTR(-EEXIST):
829 * Duplicate OPPs (both freq and volt are same) and !opp->available
830 * ERR_PTR(-ENOMEM):
832 * ERR_PTR(-EINVAL):
833 * Failed parsing the OPP node
845 return ERR_PTR(-ENOMEM); in _opp_add_static_v2()
849 dev_err(dev, "%s: opp key field not found\n", __func__); in _opp_add_static_v2()
853 /* Check if the OPP supports hardware's hierarchy of versions or not */ in _opp_add_static_v2()
855 dev_dbg(dev, "OPP not supported by hardware: %lu\n", in _opp_add_static_v2()
856 new_opp->rate); in _opp_add_static_v2()
860 new_opp->turbo = of_property_read_bool(np, "turbo-mode"); in _opp_add_static_v2()
862 new_opp->np = np; in _opp_add_static_v2()
863 new_opp->dynamic = false; in _opp_add_static_v2()
864 new_opp->available = true; in _opp_add_static_v2()
870 if (!of_property_read_u32(np, "clock-latency-ns", &val)) in _opp_add_static_v2()
871 new_opp->clock_latency_ns = val; in _opp_add_static_v2()
877 if (opp_table->is_genpd) in _opp_add_static_v2()
878 new_opp->pstate = pm_genpd_opp_to_performance_state(dev, new_opp); in _opp_add_static_v2()
883 if (ret == -EBUSY) in _opp_add_static_v2()
888 /* OPP to select on device suspend */ in _opp_add_static_v2()
889 if (of_property_read_bool(np, "opp-suspend")) { in _opp_add_static_v2()
890 if (opp_table->suspend_opp) { in _opp_add_static_v2()
891 /* Pick the OPP with higher rate as suspend OPP */ in _opp_add_static_v2()
892 if (new_opp->rate > opp_table->suspend_opp->rate) { in _opp_add_static_v2()
893 opp_table->suspend_opp->suspend = false; in _opp_add_static_v2()
894 new_opp->suspend = true; in _opp_add_static_v2()
895 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
898 new_opp->suspend = true; in _opp_add_static_v2()
899 opp_table->suspend_opp = new_opp; in _opp_add_static_v2()
903 if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) in _opp_add_static_v2()
904 opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; in _opp_add_static_v2()
907 __func__, new_opp->turbo, new_opp->rate, in _opp_add_static_v2()
908 new_opp->supplies[0].u_volt, new_opp->supplies[0].u_volt_min, in _opp_add_static_v2()
909 new_opp->supplies[0].u_volt_max, new_opp->clock_latency_ns, in _opp_add_static_v2()
910 new_opp->level); in _opp_add_static_v2()
916 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp); in _opp_add_static_v2()
927 /* Initializes OPP tables based on new bindings */
932 struct dev_pm_opp *opp; in _of_add_opp_table_v2() local
934 /* OPP table is already initialized for the device */ in _of_add_opp_table_v2()
935 mutex_lock(&opp_table->lock); in _of_add_opp_table_v2()
936 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v2()
937 opp_table->parsed_static_opps++; in _of_add_opp_table_v2()
938 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
942 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v2()
943 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v2()
945 /* We have opp-table node now, iterate over it and add OPPs */ in _of_add_opp_table_v2()
946 for_each_available_child_of_node(opp_table->np, np) { in _of_add_opp_table_v2()
947 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
948 if (IS_ERR(opp)) { in _of_add_opp_table_v2()
949 ret = PTR_ERR(opp); in _of_add_opp_table_v2()
950 dev_err(dev, "%s: Failed to add OPP, %d\n", __func__, in _of_add_opp_table_v2()
954 } else if (opp) { in _of_add_opp_table_v2()
962 ret = -ENOENT; in _of_add_opp_table_v2()
966 list_for_each_entry(opp, &opp_table->opp_list, node) { in _of_add_opp_table_v2()
967 /* Any non-zero performance state would enable the feature */ in _of_add_opp_table_v2()
968 if (opp->pstate) { in _of_add_opp_table_v2()
969 opp_table->genpd_performance_state = true; in _of_add_opp_table_v2()
984 /* Initializes OPP tables based on old-deprecated bindings */
991 mutex_lock(&opp_table->lock); in _of_add_opp_table_v1()
992 if (opp_table->parsed_static_opps) { in _of_add_opp_table_v1()
993 opp_table->parsed_static_opps++; in _of_add_opp_table_v1()
994 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
998 opp_table->parsed_static_opps = 1; in _of_add_opp_table_v1()
999 mutex_unlock(&opp_table->lock); in _of_add_opp_table_v1()
1001 prop = of_find_property(dev->of_node, "operating-points", NULL); in _of_add_opp_table_v1()
1003 ret = -ENODEV; in _of_add_opp_table_v1()
1006 if (!prop->value) { in _of_add_opp_table_v1()
1007 ret = -ENODATA; in _of_add_opp_table_v1()
1012 * Each OPP is a set of tuples consisting of frequency and in _of_add_opp_table_v1()
1013 * voltage like <freq-kHz vol-uV>. in _of_add_opp_table_v1()
1015 nr = prop->length / sizeof(u32); in _of_add_opp_table_v1()
1017 dev_err(dev, "%s: Invalid OPP table\n", __func__); in _of_add_opp_table_v1()
1018 ret = -EINVAL; in _of_add_opp_table_v1()
1022 val = prop->value; in _of_add_opp_table_v1()
1029 dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", in _of_add_opp_table_v1()
1033 nr -= 2; in _of_add_opp_table_v1()
1051 * If only one phandle is present, then the same OPP table in _of_add_table_indexed()
1054 count = of_count_phandle_with_args(dev->of_node, in _of_add_table_indexed()
1055 "operating-points-v2", NULL); in _of_add_table_indexed()
1068 if (opp_table->np) in _of_add_table_indexed()
1085 * devm_pm_opp_of_add_table() - Initialize opp table from device tree
1086 * @dev: device pointer used to lookup OPP table.
1088 * Register the initial OPP table with the OPP library for given device.
1094 * Duplicate OPPs (both freq and volt are same) and opp->available
1095 * -EEXIST Freq are same and volt are different OR
1096 * Duplicate OPPs (both freq and volt are same) and !opp->available
1097 * -ENOMEM Memory allocation failure
1098 * -ENODEV when 'operating-points' property is not found or is invalid data
1100 * -ENODATA when empty 'operating-points' property is found
1101 * -EINVAL when invalid entries are found in opp-v2 table
1116 * dev_pm_opp_of_add_table() - Initialize opp table from device tree
1117 * @dev: device pointer used to lookup OPP table.
1119 * Register the initial OPP table with the OPP library for given device.
1123 * Duplicate OPPs (both freq and volt are same) and opp->available
1124 * -EEXIST Freq are same and volt are different OR
1125 * Duplicate OPPs (both freq and volt are same) and !opp->available
1126 * -ENOMEM Memory allocation failure
1127 * -ENODEV when 'operating-points' property is not found or is invalid data
1129 * -ENODATA when empty 'operating-points' property is found
1130 * -EINVAL when invalid entries are found in opp-v2 table
1139 * dev_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree
1140 * @dev: device pointer used to lookup OPP table.
1143 * Register the initial OPP table with the OPP library for given device only
1144 * using the "operating-points-v2" property.
1155 * dev_pm_opp_of_add_table_noclk() - Initialize indexed opp table from device
1157 * @dev: device pointer used to lookup OPP table.
1160 * Register the initial OPP table with the OPP library for given device only
1161 * using the "operating-points-v2" property. Do not try to get the clk for the
1175 * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
1176 * @cpumask: cpumask for which OPP table needs to be removed
1178 * This removes the OPP tables for CPUs present in the @cpumask.
1183 _dev_pm_opp_cpumask_remove_table(cpumask, -1); in dev_pm_opp_of_cpumask_remove_table()
1188 * dev_pm_opp_of_cpumask_add_table() - Adds OPP table for @cpumask
1189 * @cpumask: cpumask for which OPP table needs to be added.
1191 * This adds the OPP tables for CPUs present in the @cpumask.
1199 return -ENODEV; in dev_pm_opp_of_cpumask_add_table()
1206 ret = -ENODEV; in dev_pm_opp_of_cpumask_add_table()
1213 * OPP may get registered dynamically, don't print error in dev_pm_opp_of_cpumask_add_table()
1216 pr_debug("%s: couldn't find opp table for cpu:%d, %d\n", in dev_pm_opp_of_cpumask_add_table()
1234 * Works only for OPP v2 bindings.
1236 * Returns -ENOENT if operating-points-v2 bindings aren't supported.
1239 * dev_pm_opp_of_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with
1240 * @cpu_dev using operating-points-v2
1248 * Returns -ENOENT if operating-points-v2 isn't present for @cpu_dev.
1256 /* Get OPP descriptor node */ in dev_pm_opp_of_get_sharing_cpus()
1259 dev_dbg(cpu_dev, "%s: Couldn't find opp node.\n", __func__); in dev_pm_opp_of_get_sharing_cpus()
1260 return -ENOENT; in dev_pm_opp_of_get_sharing_cpus()
1263 cpumask_set_cpu(cpu_dev->id, cpumask); in dev_pm_opp_of_get_sharing_cpus()
1266 if (!of_property_read_bool(np, "opp-shared")) in dev_pm_opp_of_get_sharing_cpus()
1270 if (cpu == cpu_dev->id) in dev_pm_opp_of_get_sharing_cpus()
1277 ret = -ENOENT; in dev_pm_opp_of_get_sharing_cpus()
1281 /* Get OPP descriptor node */ in dev_pm_opp_of_get_sharing_cpus()
1285 pr_err("%pOF: Couldn't find opp node\n", cpu_np); in dev_pm_opp_of_get_sharing_cpus()
1286 ret = -ENOENT; in dev_pm_opp_of_get_sharing_cpus()
1290 /* CPUs are sharing opp node */ in dev_pm_opp_of_get_sharing_cpus()
1304 …* of_get_required_opp_performance_state() - Search for required OPP and return its performance sta…
1305 * @np: Node that contains the "required-opps" property.
1308 * Returns the performance state of the OPP pointed out by the "required-opps"
1316 struct dev_pm_opp *opp; in of_get_required_opp_performance_state() local
1319 int pstate = -EINVAL; in of_get_required_opp_performance_state()
1323 return -ENODEV; in of_get_required_opp_performance_state()
1327 pr_err("%s: Failed to find required OPP table %pOF: %ld\n", in of_get_required_opp_performance_state()
1332 opp = _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()
1333 if (opp) { in of_get_required_opp_performance_state()
1334 pstate = opp->pstate; in of_get_required_opp_performance_state()
1335 dev_pm_opp_put(opp); in of_get_required_opp_performance_state()
1348 * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp
1349 * @opp: opp for which DT node has to be returned for
1351 * Return: DT node corresponding to the opp, else 0 on success.
1355 struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) in dev_pm_opp_get_of_node() argument
1357 if (IS_ERR_OR_NULL(opp)) { in dev_pm_opp_get_of_node()
1362 return of_node_get(opp->np); in dev_pm_opp_get_of_node()
1369 * of an existing OPP, or at the frequency of the first OPP above @kHz otherwise
1373 * respectively the voltage and frequency of the OPP.
1375 * Returns -EINVAL if the power calculation failed because of missing
1381 struct dev_pm_opp *opp; in _get_power() local
1388 np = of_node_get(dev->of_node); in _get_power()
1390 return -EINVAL; in _get_power()
1392 ret = of_property_read_u32(np, "dynamic-power-coefficient", &cap); in _get_power()
1395 return -EINVAL; in _get_power()
1398 opp = dev_pm_opp_find_freq_ceil(dev, &Hz); in _get_power()
1399 if (IS_ERR(opp)) in _get_power()
1400 return -EINVAL; in _get_power()
1402 mV = dev_pm_opp_get_voltage(opp) / 1000; in _get_power()
1403 dev_pm_opp_put(opp); in _get_power()
1405 return -EINVAL; in _get_power()
1417 * dev_pm_opp_of_register_em() - Attempt to register an Energy Model
1422 * This checks whether the "dynamic-power-coefficient" devicetree property has
1435 ret = -EINVAL; in dev_pm_opp_of_register_em()
1441 ret = -EINVAL; in dev_pm_opp_of_register_em()
1445 np = of_node_get(dev->of_node); in dev_pm_opp_of_register_em()
1447 ret = -EINVAL; in dev_pm_opp_of_register_em()
1452 * Register an EM only if the 'dynamic-power-coefficient' property is in dev_pm_opp_of_register_em()
1458 ret = of_property_read_u32(np, "dynamic-power-coefficient", &cap); in dev_pm_opp_of_register_em()
1461 dev_dbg(dev, "Couldn't find proper 'dynamic-power-coefficient' in DT\n"); in dev_pm_opp_of_register_em()
1462 ret = -EINVAL; in dev_pm_opp_of_register_em()