Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
7c139d3f
Commit
7c139d3f
authored
Feb 08, 2019
by
Viresh Kumar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'opp/power' into cpufreq/qcom-hw
parents
55538fbc
a4f342b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
6 deletions
+110
-6
drivers/opp/core.c
drivers/opp/core.c
+5
-6
drivers/opp/of.c
drivers/opp/of.c
+99
-0
include/linux/pm_opp.h
include/linux/pm_opp.h
+6
-0
No files found.
drivers/opp/core.c
View file @
7c139d3f
...
...
@@ -533,9 +533,8 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg,
return
ret
;
}
static
inline
int
_generic_set_opp_clk_only
(
struct
device
*
dev
,
struct
clk
*
clk
,
unsigned
long
old_freq
,
unsigned
long
freq
)
static
inline
int
_generic_set_opp_clk_only
(
struct
device
*
dev
,
struct
clk
*
clk
,
unsigned
long
freq
)
{
int
ret
;
...
...
@@ -572,7 +571,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
}
/* Change frequency */
ret
=
_generic_set_opp_clk_only
(
dev
,
opp_table
->
clk
,
old_freq
,
freq
);
ret
=
_generic_set_opp_clk_only
(
dev
,
opp_table
->
clk
,
freq
);
if
(
ret
)
goto
restore_voltage
;
...
...
@@ -586,7 +585,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
return
0
;
restore_freq:
if
(
_generic_set_opp_clk_only
(
dev
,
opp_table
->
clk
,
freq
,
old_freq
))
if
(
_generic_set_opp_clk_only
(
dev
,
opp_table
->
clk
,
old_freq
))
dev_err
(
dev
,
"%s: failed to restore old-freq (%lu Hz)
\n
"
,
__func__
,
old_freq
);
restore_voltage:
...
...
@@ -759,7 +758,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
opp
->
supplies
);
}
else
{
/* Only frequency scaling */
ret
=
_generic_set_opp_clk_only
(
dev
,
clk
,
old_freq
,
freq
);
ret
=
_generic_set_opp_clk_only
(
dev
,
clk
,
freq
);
}
/* Scaling down? Configure required OPPs after frequency */
...
...
drivers/opp/of.c
View file @
7c139d3f
...
...
@@ -20,6 +20,7 @@
#include <linux/pm_domain.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/energy_model.h>
#include "opp.h"
...
...
@@ -1047,3 +1048,101 @@ struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp)
return
of_node_get
(
opp
->
np
);
}
EXPORT_SYMBOL_GPL
(
dev_pm_opp_get_of_node
);
/*
* Callback function provided to the Energy Model framework upon registration.
* This computes the power estimated by @CPU at @kHz if it is the frequency
* of an existing OPP, or at the frequency of the first OPP above @kHz otherwise
* (see dev_pm_opp_find_freq_ceil()). This function updates @kHz to the ceiled
* frequency and @mW to the associated power. The power is estimated as
* P = C * V^2 * f with C being the CPU's capacitance and V and f respectively
* the voltage and frequency of the OPP.
*
* Returns -ENODEV if the CPU device cannot be found, -EINVAL if the power
* calculation failed because of missing parameters, 0 otherwise.
*/
static
int
__maybe_unused
_get_cpu_power
(
unsigned
long
*
mW
,
unsigned
long
*
kHz
,
int
cpu
)
{
struct
device
*
cpu_dev
;
struct
dev_pm_opp
*
opp
;
struct
device_node
*
np
;
unsigned
long
mV
,
Hz
;
u32
cap
;
u64
tmp
;
int
ret
;
cpu_dev
=
get_cpu_device
(
cpu
);
if
(
!
cpu_dev
)
return
-
ENODEV
;
np
=
of_node_get
(
cpu_dev
->
of_node
);
if
(
!
np
)
return
-
EINVAL
;
ret
=
of_property_read_u32
(
np
,
"dynamic-power-coefficient"
,
&
cap
);
of_node_put
(
np
);
if
(
ret
)
return
-
EINVAL
;
Hz
=
*
kHz
*
1000
;
opp
=
dev_pm_opp_find_freq_ceil
(
cpu_dev
,
&
Hz
);
if
(
IS_ERR
(
opp
))
return
-
EINVAL
;
mV
=
dev_pm_opp_get_voltage
(
opp
)
/
1000
;
dev_pm_opp_put
(
opp
);
if
(
!
mV
)
return
-
EINVAL
;
tmp
=
(
u64
)
cap
*
mV
*
mV
*
(
Hz
/
1000000
);
do_div
(
tmp
,
1000000000
);
*
mW
=
(
unsigned
long
)
tmp
;
*
kHz
=
Hz
/
1000
;
return
0
;
}
/**
* dev_pm_opp_of_register_em() - Attempt to register an Energy Model
* @cpus : CPUs for which an Energy Model has to be registered
*
* This checks whether the "dynamic-power-coefficient" devicetree property has
* been specified, and tries to register an Energy Model with it if it has.
*/
void
dev_pm_opp_of_register_em
(
struct
cpumask
*
cpus
)
{
struct
em_data_callback
em_cb
=
EM_DATA_CB
(
_get_cpu_power
);
int
ret
,
nr_opp
,
cpu
=
cpumask_first
(
cpus
);
struct
device
*
cpu_dev
;
struct
device_node
*
np
;
u32
cap
;
cpu_dev
=
get_cpu_device
(
cpu
);
if
(
!
cpu_dev
)
return
;
nr_opp
=
dev_pm_opp_get_opp_count
(
cpu_dev
);
if
(
nr_opp
<=
0
)
return
;
np
=
of_node_get
(
cpu_dev
->
of_node
);
if
(
!
np
)
return
;
/*
* Register an EM only if the 'dynamic-power-coefficient' property is
* set in devicetree. It is assumed the voltage values are known if that
* property is set since it is useless otherwise. If voltages are not
* known, just let the EM registration fail with an error to alert the
* user about the inconsistent configuration.
*/
ret
=
of_property_read_u32
(
np
,
"dynamic-power-coefficient"
,
&
cap
);
of_node_put
(
np
);
if
(
ret
||
!
cap
)
return
;
em_register_perf_domain
(
cpus
,
nr_opp
,
&
em_cb
);
}
EXPORT_SYMBOL_GPL
(
dev_pm_opp_of_register_em
);
include/linux/pm_opp.h
View file @
7c139d3f
...
...
@@ -327,6 +327,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma
struct
device_node
*
dev_pm_opp_of_get_opp_desc_node
(
struct
device
*
dev
);
struct
device_node
*
dev_pm_opp_get_of_node
(
struct
dev_pm_opp
*
opp
);
int
of_get_required_opp_performance_state
(
struct
device_node
*
np
,
int
index
);
void
dev_pm_opp_of_register_em
(
struct
cpumask
*
cpus
);
#else
static
inline
int
dev_pm_opp_of_add_table
(
struct
device
*
dev
)
{
...
...
@@ -365,6 +366,11 @@ static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp)
{
return
NULL
;
}
static
inline
void
dev_pm_opp_of_register_em
(
struct
cpumask
*
cpus
)
{
}
static
inline
int
of_get_required_opp_performance_state
(
struct
device_node
*
np
,
int
index
)
{
return
-
ENOTSUPP
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment