mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	PM / OPP: Get performance state using genpd helper
The genpd core provides an API now to retrieve the performance state from DT, use that instead of the ->get_pstate() callback. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
		
							parent
							
								
									6e41766a6a
								
							
						
					
					
						commit
						3ba98324e8
					
				
					 2 changed files with 19 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -1056,9 +1056,6 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp,
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (opp_table->get_pstate)
 | 
			
		||||
		new_opp->pstate = opp_table->get_pstate(dev, new_opp->rate);
 | 
			
		||||
 | 
			
		||||
	list_add(&new_opp->node, head);
 | 
			
		||||
	mutex_unlock(&opp_table->lock);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,7 @@
 | 
			
		|||
#include <linux/errno.h>
 | 
			
		||||
#include <linux/device.h>
 | 
			
		||||
#include <linux/of_device.h>
 | 
			
		||||
#include <linux/pm_domain.h>
 | 
			
		||||
#include <linux/slab.h>
 | 
			
		||||
#include <linux/export.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -329,6 +330,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev,
 | 
			
		|||
	if (!of_property_read_u32(np, "clock-latency-ns", &val))
 | 
			
		||||
		new_opp->clock_latency_ns = val;
 | 
			
		||||
 | 
			
		||||
	new_opp->pstate = of_genpd_opp_to_performance_state(dev, np);
 | 
			
		||||
 | 
			
		||||
	ret = opp_parse_supplies(new_opp, dev, opp_table);
 | 
			
		||||
	if (ret)
 | 
			
		||||
		goto free_opp;
 | 
			
		||||
| 
						 | 
				
			
			@ -379,7 +382,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
 | 
			
		|||
{
 | 
			
		||||
	struct device_node *np;
 | 
			
		||||
	struct opp_table *opp_table;
 | 
			
		||||
	int ret = 0, count = 0;
 | 
			
		||||
	int ret = 0, count = 0, pstate_count = 0;
 | 
			
		||||
	struct dev_pm_opp *opp;
 | 
			
		||||
 | 
			
		||||
	opp_table = _managed_opp(opp_np);
 | 
			
		||||
	if (opp_table) {
 | 
			
		||||
| 
						 | 
				
			
			@ -413,6 +417,20 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
 | 
			
		|||
		goto put_opp_table;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	list_for_each_entry(opp, &opp_table->opp_list, node)
 | 
			
		||||
		pstate_count += !!opp->pstate;
 | 
			
		||||
 | 
			
		||||
	/* Either all or none of the nodes shall have performance state set */
 | 
			
		||||
	if (pstate_count && pstate_count != count) {
 | 
			
		||||
		dev_err(dev, "Not all nodes have performance state set (%d: %d)\n",
 | 
			
		||||
			count, pstate_count);
 | 
			
		||||
		ret = -ENOENT;
 | 
			
		||||
		goto put_opp_table;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (pstate_count)
 | 
			
		||||
		opp_table->genpd_performance_state = true;
 | 
			
		||||
 | 
			
		||||
	opp_table->np = opp_np;
 | 
			
		||||
	if (of_property_read_bool(opp_np, "opp-shared"))
 | 
			
		||||
		opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue