Lines Matching full:opp
3 * Generic OPP OF helpers
22 #include "opp.h"
25 * Returns opp descriptor node for a device node, caller must
35 /* Returns opp descriptor node for a device, caller must do of_node_put() */
54 * Multiple devices can point to the same OPP table and in _managed_opp()
58 * OPP table contains a "opp-shared" property. 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
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()
86 return opp; in _find_opp_of_np()
158 * Populate all devices and opp tables which are part of "required-opps" list.
159 * Checking only the first OPP node should be enough.
169 /* Traversing the first OPP node is all we need */ in _opp_table_alloc_required_tables()
172 dev_err(dev, "Empty OPP table\n"); in _opp_table_alloc_required_tables()
202 * required OPP doesn't belong to a genpd. in _opp_table_alloc_required_tables()
205 dev_err(dev, "required-opp doesn't belong to genpd: %pOF\n", in _opp_table_alloc_required_tables()
241 /* Get OPP table node */ in _of_init_opp_table()
248 if (of_property_read_bool(opp_np, "opp-shared")) in _of_init_opp_table()
269 struct dev_pm_opp *opp) in _of_opp_free_required_opps() argument
271 struct dev_pm_opp **required_opps = opp->required_opps; in _of_opp_free_required_opps()
286 opp->required_opps = NULL; in _of_opp_free_required_opps()
291 struct dev_pm_opp *opp) in _of_opp_alloc_required_opps() argument
305 opp->required_opps = required_opps; in _of_opp_alloc_required_opps()
310 np = of_parse_required_opp(opp->np, i); in _of_opp_alloc_required_opps()
320 pr_err("%s: Unable to find required OPP node: %pOF (%d)\n", in _of_opp_alloc_required_opps()
321 __func__, opp->np, i); in _of_opp_alloc_required_opps()
330 _of_opp_free_required_opps(opp_table, opp); in _of_opp_alloc_required_opps()
351 /* Lets not fail in case we are parsing opp-v1 bindings */ in _bandwidth_supported()
355 /* Checking only first OPP is sufficient */ in _bandwidth_supported()
358 dev_err(dev, "OPP table empty\n"); in _bandwidth_supported()
363 prop = of_find_property(np, "opp-peak-kBps", NULL); in _bandwidth_supported()
444 * platform but there is an opp-supported-hw value set for in _opp_is_supported()
445 * an OPP then the OPP should not be enabled as there is in _opp_is_supported()
448 if (of_find_property(np, "opp-supported-hw", NULL)) in _opp_is_supported()
454 count = of_property_count_u32_elems(np, "opp-supported-hw"); in _opp_is_supported()
456 dev_err(dev, "%s: Invalid opp-supported-hw property (%d)\n", in _opp_is_supported()
468 ret = of_property_read_u32_index(np, "opp-supported-hw", in _opp_is_supported()
471 dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n", in _opp_is_supported()
490 static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, in opp_parse_supplies() argument
498 /* Search for "opp-microvolt-<name>" */ in opp_parse_supplies()
500 snprintf(name, sizeof(name), "opp-microvolt-%s", in opp_parse_supplies()
502 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
506 /* Search for "opp-microvolt" */ in opp_parse_supplies()
507 sprintf(name, "opp-microvolt"); in opp_parse_supplies()
508 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
521 dev_err(dev, "%s: opp-microvolt missing although OPP managing regulators\n", in opp_parse_supplies()
531 dev_err(dev, "%s: opp-microvolt wasn't expected\n", __func__); in opp_parse_supplies()
535 vcount = of_property_count_u32_elems(opp->np, name); in opp_parse_supplies()
553 ret = of_property_read_u32_array(opp->np, name, microvolt, vcount); in opp_parse_supplies()
560 /* Search for "opp-microamp-<name>" */ in opp_parse_supplies()
563 snprintf(name, sizeof(name), "opp-microamp-%s", in opp_parse_supplies()
565 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
569 /* Search for "opp-microamp" */ in opp_parse_supplies()
570 sprintf(name, "opp-microamp"); in opp_parse_supplies()
571 prop = of_find_property(opp->np, name, NULL); in opp_parse_supplies()
575 icount = of_property_count_u32_elems(opp->np, name); in opp_parse_supplies()
596 ret = of_property_read_u32_array(opp->np, name, microamp, in opp_parse_supplies()
607 opp->supplies[i].u_volt = microvolt[j++]; in opp_parse_supplies()
610 opp->supplies[i].u_volt_min = opp->supplies[i].u_volt; in opp_parse_supplies()
611 opp->supplies[i].u_volt_max = opp->supplies[i].u_volt; in opp_parse_supplies()
613 opp->supplies[i].u_volt_min = microvolt[j++]; in opp_parse_supplies()
614 opp->supplies[i].u_volt_max = microvolt[j++]; in opp_parse_supplies()
618 opp->supplies[i].u_amp = microamp[i]; in opp_parse_supplies()
630 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
632 * @dev: device pointer used to lookup OPP table.
645 const char *name = peak ? "opp-peak-kBps" : "opp-avg-kBps"; in _read_bw()
690 ret = of_property_read_u64(np, "opp-hz", &rate); in _read_opp_key()
704 * opp-peak-kBps = <path1_value path2_value>; in _read_opp_key()
705 * opp-avg-kBps = <path1_value path2_value>; in _read_opp_key()
717 if (!of_property_read_u32(np, "opp-level", &new_opp->level)) in _read_opp_key()
728 * @opp_table: OPP table
732 * This function adds an opp definition to the opp table and returns status. The
733 * opp can be controlled using dev_pm_opp_enable/disable functions and may be
737 * Valid OPP pointer:
740 * Duplicate OPPs (both freq and volt are same) and opp->available
741 * OR if the OPP is not supported by hardware.
744 * Duplicate OPPs (both freq and volt are same) and !opp->available
748 * Failed parsing the OPP node
765 dev_err(dev, "%s: opp key field not found\n", __func__); in _opp_add_static_v2()
769 /* Check if the OPP supports hardware's hierarchy of versions or not */ in _opp_add_static_v2()
771 dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate); in _opp_add_static_v2()
803 /* OPP to select on device suspend */ in _opp_add_static_v2()
804 if (of_property_read_bool(np, "opp-suspend")) { in _opp_add_static_v2()
806 /* Pick the OPP with higher rate as suspend OPP */ in _opp_add_static_v2()
841 /* Initializes OPP tables based on new bindings */
846 struct dev_pm_opp *opp; in _of_add_opp_table_v2() local
848 /* OPP table is already initialized for the device */ in _of_add_opp_table_v2()
859 /* We have opp-table node now, iterate over it and add OPPs */ in _of_add_opp_table_v2()
861 opp = _opp_add_static_v2(opp_table, dev, np); in _of_add_opp_table_v2()
862 if (IS_ERR(opp)) { in _of_add_opp_table_v2()
863 ret = PTR_ERR(opp); in _of_add_opp_table_v2()
864 dev_err(dev, "%s: Failed to add OPP, %d\n", __func__, in _of_add_opp_table_v2()
868 } else if (opp) { in _of_add_opp_table_v2()
873 /* There should be one of more OPP defined */ in _of_add_opp_table_v2()
879 list_for_each_entry(opp, &opp_table->opp_list, node) { in _of_add_opp_table_v2()
881 if (opp->pstate) { in _of_add_opp_table_v2()
895 /* Initializes OPP tables based on old-deprecated bindings */
923 * Each OPP is a set of tuples consisting of frequency and in _of_add_opp_table_v1()
928 dev_err(dev, "%s: Invalid OPP table\n", __func__); in _of_add_opp_table_v1()
940 dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", in _of_add_opp_table_v1()
956 * dev_pm_opp_of_add_table() - Initialize opp table from device tree
957 * @dev: device pointer used to lookup OPP table.
959 * Register the initial OPP table with the OPP library for given device.
963 * Duplicate OPPs (both freq and volt are same) and opp->available
965 * Duplicate OPPs (both freq and volt are same) and !opp->available
970 * -EINVAL when invalid entries are found in opp-v2 table
998 * dev_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree
999 * @dev: device pointer used to lookup OPP table.
1002 * Register the initial OPP table with the OPP library for given device only
1007 * Duplicate OPPs (both freq and volt are same) and opp->available
1009 * Duplicate OPPs (both freq and volt are same) and !opp->available
1014 * -EINVAL when invalid entries are found in opp-v2 table
1023 * If only one phandle is present, then the same OPP table in dev_pm_opp_of_add_table_indexed()
1047 * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
1048 * @cpumask: cpumask for which OPP table needs to be removed
1050 * This removes the OPP tables for CPUs present in the @cpumask.
1060 * dev_pm_opp_of_cpumask_add_table() - Adds OPP table for @cpumask
1061 * @cpumask: cpumask for which OPP table needs to be added.
1063 * This adds the OPP tables for CPUs present in the @cpumask.
1085 * OPP may get registered dynamically, don't print error in dev_pm_opp_of_cpumask_add_table()
1088 pr_debug("%s: couldn't find opp table for cpu:%d, %d\n", in dev_pm_opp_of_cpumask_add_table()
1106 * Works only for OPP v2 bindings.
1128 /* Get OPP descriptor node */ in dev_pm_opp_of_get_sharing_cpus()
1131 dev_dbg(cpu_dev, "%s: Couldn't find opp node.\n", __func__); in dev_pm_opp_of_get_sharing_cpus()
1138 if (!of_property_read_bool(np, "opp-shared")) in dev_pm_opp_of_get_sharing_cpus()
1153 /* Get OPP descriptor node */ in dev_pm_opp_of_get_sharing_cpus()
1157 pr_err("%pOF: Couldn't find opp node\n", cpu_np); in dev_pm_opp_of_get_sharing_cpus()
1162 /* CPUs are sharing opp node */ in dev_pm_opp_of_get_sharing_cpus()
1176 …* of_get_required_opp_performance_state() - Search for required OPP and return its performance sta…
1180 * Returns the performance state of the OPP pointed out by the "required-opps"
1188 struct dev_pm_opp *opp; in of_get_required_opp_performance_state() local
1199 pr_err("%s: Failed to find required OPP table %pOF: %ld\n", in of_get_required_opp_performance_state()
1204 opp = _find_opp_of_np(opp_table, required_np); in of_get_required_opp_performance_state()
1205 if (opp) { in of_get_required_opp_performance_state()
1206 pstate = opp->pstate; in of_get_required_opp_performance_state()
1207 dev_pm_opp_put(opp); in of_get_required_opp_performance_state()
1220 * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp
1221 * @opp: opp for which DT node has to be returned for
1223 * Return: DT node corresponding to the opp, else 0 on success.
1227 struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) in dev_pm_opp_get_of_node() argument
1229 if (IS_ERR_OR_NULL(opp)) { in dev_pm_opp_get_of_node()
1234 return of_node_get(opp->np); in dev_pm_opp_get_of_node()
1241 * of an existing OPP, or at the frequency of the first OPP above @kHz otherwise
1245 * respectively the voltage and frequency of the OPP.
1253 struct dev_pm_opp *opp; in _get_power() local
1270 opp = dev_pm_opp_find_freq_ceil(dev, &Hz); in _get_power()
1271 if (IS_ERR(opp)) in _get_power()
1274 mV = dev_pm_opp_get_voltage(opp) / 1000; in _get_power()
1275 dev_pm_opp_put(opp); in _get_power()