* [PATCH v2 00/11] Clean up Tegra20 cpufreq driver
@ 2018-05-18 20:06 Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 01/11] cpufreq: tegra20: Change module description Dmitry Osipenko
` (10 more replies)
0 siblings, 11 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Hello,
Recently Peter Geis (who is working on Tegra30 cpufreq driver) asked me how
tegra20-cpufreq driver is getting loaded. After taking a look at the code
it became apparent that the drivers code has been rusted a tad and so this
series is intended to refresh the drivers code by disallowing module to be
loaded on non-Tegra20 machines, by cleaning whitespaces in the code, removing
dead EMC code and in the end by allowing tegra20-cpufreq to be built as a
loadable module.
Changelog:
v2:
- Added the new patch to the series: "Remove unnecessary parentheses",
please review.
- Addressed review comments to the v1 of the series:
1) Kept undeleted necessary headers in the "Clean up included headers"
patch as per Viresh's Kumar request.
2) Renamed tegra20_cpufreq_data to tegra20_cpufreq and moved cpufreq
driver structure to the tegra20_cpufreq as per Thierry's Reding
request.
- Dropped "ARM: tegra: Create platform device for tegra20-cpufreq driver"
patch from the series as Thierry already applied it and submitted
in the "ARM: tegra: Core changes for v4.18-rc1" pull request.
Dmitry Osipenko (11):
cpufreq: tegra20: Change module description
cpufreq: tegra20: Clean up whitespaces in the code
cpufreq: tegra20: Clean up included headers
cpufreq: tegra20: Remove EMC clock usage
cpufreq: tegra20: Release clocks properly
cpufreq: tegra20: Remove unneeded check in tegra_cpu_init
cpufreq: tegra20: Remove unnecessary parentheses
cpufreq: tegra20: Remove unneeded variable initialization
cpufreq: tegra20: Check if this is Tegra20 machine
cpufreq: tegra20: Allow cpufreq driver to be built as loadable module
cpufreq: tegra20: Wrap cpufreq into platform driver
drivers/cpufreq/Kconfig.arm | 2 +-
drivers/cpufreq/tegra20-cpufreq.c | 200 ++++++++++++++++--------------
2 files changed, 111 insertions(+), 91 deletions(-)
--
2.17.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 01/11] cpufreq: tegra20: Change module description
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 02/11] cpufreq: tegra20: Clean up whitespaces in the code Dmitry Osipenko
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Change module description to be in line with the other Tegra drivers, just
for consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 2bd62845e9d5..10793498355e 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -210,7 +210,7 @@ static void __exit tegra_cpufreq_exit(void)
MODULE_AUTHOR("Colin Cross <ccross@android.com>");
-MODULE_DESCRIPTION("cpufreq driver for Nvidia Tegra2");
+MODULE_DESCRIPTION("NVIDIA Tegra20 cpufreq driver");
MODULE_LICENSE("GPL");
module_init(tegra_cpufreq_init);
module_exit(tegra_cpufreq_exit);
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 02/11] cpufreq: tegra20: Clean up whitespaces in the code
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 01/11] cpufreq: tegra20: Change module description Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers Dmitry Osipenko
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Remove unneeded blank line and replace whitespaces with a tab in the code
for consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 10793498355e..dd8a76a64a8e 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -203,12 +203,11 @@ static int __init tegra_cpufreq_init(void)
static void __exit tegra_cpufreq_exit(void)
{
- cpufreq_unregister_driver(&tegra_cpufreq_driver);
+ cpufreq_unregister_driver(&tegra_cpufreq_driver);
clk_put(emc_clk);
clk_put(cpu_clk);
}
-
MODULE_AUTHOR("Colin Cross <ccross@android.com>");
MODULE_DESCRIPTION("NVIDIA Tegra20 cpufreq driver");
MODULE_LICENSE("GPL");
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 01/11] cpufreq: tegra20: Change module description Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 02/11] cpufreq: tegra20: Clean up whitespaces in the code Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-21 5:44 ` Viresh Kumar
2018-05-18 20:06 ` [PATCH v2 04/11] cpufreq: tegra20: Remove EMC clock usage Dmitry Osipenko
` (7 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Remove unused/unneeded headers and sort them in the alphabet order.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index dd8a76a64a8e..bec1a50a8138 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -16,16 +16,12 @@
*
*/
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/sched.h>
+#include <linux/clk.h>
#include <linux/cpufreq.h>
-#include <linux/delay.h>
-#include <linux/init.h>
#include <linux/err.h>
-#include <linux/clk.h>
-#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/types.h>
static struct cpufreq_frequency_table freq_table[] = {
{ .frequency = 216000 },
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 04/11] cpufreq: tegra20: Remove EMC clock usage
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (2 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 05/11] cpufreq: tegra20: Release clocks properly Dmitry Osipenko
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
The EMC driver has been gone 4 years ago, since the commit a7cbe92cef27
("ARM: tegra: remove tegra EMC scaling driver"). Remove the EMC clock
usage as it does nothing. We may consider re-implementing the EMC scaling
later, probably using PM Memory Bandwidth QoS API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index bec1a50a8138..4b09a8b410c4 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -40,7 +40,6 @@ static struct cpufreq_frequency_table freq_table[] = {
static struct clk *cpu_clk;
static struct clk *pll_x_clk;
static struct clk *pll_p_clk;
-static struct clk *emc_clk;
static bool pll_x_prepared;
static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
@@ -91,17 +90,6 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
int ret = 0;
- /*
- * Vote on memory bus frequency based on cpu frequency
- * This sets the minimum frequency, display or avp may request higher
- */
- if (rate >= 816000)
- clk_set_rate(emc_clk, 600000000); /* cpu 816 MHz, emc max */
- else if (rate >= 456000)
- clk_set_rate(emc_clk, 300000000); /* cpu 456 MHz, emc 150Mhz */
- else
- clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */
-
/*
* target freq == pll_p, don't need to take extra reference to pll_x_clk
* as it isn't used anymore.
@@ -137,14 +125,12 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu >= NUM_CPUS)
return -EINVAL;
- clk_prepare_enable(emc_clk);
clk_prepare_enable(cpu_clk);
/* FIXME: what's the actual transition time? */
ret = cpufreq_generic_init(policy, freq_table, 300 * 1000);
if (ret) {
clk_disable_unprepare(cpu_clk);
- clk_disable_unprepare(emc_clk);
return ret;
}
@@ -156,7 +142,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
static int tegra_cpu_exit(struct cpufreq_policy *policy)
{
clk_disable_unprepare(cpu_clk);
- clk_disable_unprepare(emc_clk);
return 0;
}
@@ -188,19 +173,12 @@ static int __init tegra_cpufreq_init(void)
if (IS_ERR(pll_p_clk))
return PTR_ERR(pll_p_clk);
- emc_clk = clk_get_sys("cpu", "emc");
- if (IS_ERR(emc_clk)) {
- clk_put(cpu_clk);
- return PTR_ERR(emc_clk);
- }
-
return cpufreq_register_driver(&tegra_cpufreq_driver);
}
static void __exit tegra_cpufreq_exit(void)
{
cpufreq_unregister_driver(&tegra_cpufreq_driver);
- clk_put(emc_clk);
clk_put(cpu_clk);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 05/11] cpufreq: tegra20: Release clocks properly
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (3 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 04/11] cpufreq: tegra20: Remove EMC clock usage Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 06/11] cpufreq: tegra20: Remove unneeded check in tegra_cpu_init Dmitry Osipenko
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Properly put requested clocks in the module init/exit code.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 4b09a8b410c4..ea186d3f0faf 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -161,24 +161,45 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
static int __init tegra_cpufreq_init(void)
{
+ int err;
+
cpu_clk = clk_get_sys(NULL, "cclk");
if (IS_ERR(cpu_clk))
return PTR_ERR(cpu_clk);
pll_x_clk = clk_get_sys(NULL, "pll_x");
- if (IS_ERR(pll_x_clk))
- return PTR_ERR(pll_x_clk);
+ if (IS_ERR(pll_x_clk)) {
+ err = PTR_ERR(pll_x_clk);
+ goto put_cpu;
+ }
pll_p_clk = clk_get_sys(NULL, "pll_p");
- if (IS_ERR(pll_p_clk))
- return PTR_ERR(pll_p_clk);
+ if (IS_ERR(pll_p_clk)) {
+ err = PTR_ERR(pll_p_clk);
+ goto put_pll_x;
+ }
+
+ err = cpufreq_register_driver(&tegra_cpufreq_driver);
+ if (err)
+ goto put_pll_p;
+
+ return 0;
+
+put_pll_p:
+ clk_put(pll_p_clk);
+put_pll_x:
+ clk_put(pll_x_clk);
+put_cpu:
+ clk_put(cpu_clk);
- return cpufreq_register_driver(&tegra_cpufreq_driver);
+ return err;
}
static void __exit tegra_cpufreq_exit(void)
{
cpufreq_unregister_driver(&tegra_cpufreq_driver);
+ clk_put(pll_p_clk);
+ clk_put(pll_x_clk);
clk_put(cpu_clk);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 06/11] cpufreq: tegra20: Remove unneeded check in tegra_cpu_init
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (4 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 05/11] cpufreq: tegra20: Release clocks properly Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses Dmitry Osipenko
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Remove checking of the CPU number for consistency as it won't ever fail
unless there is a severe bug in the cpufreq core.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index ea186d3f0faf..df25e350c8e6 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -35,8 +35,6 @@ static struct cpufreq_frequency_table freq_table[] = {
{ .frequency = CPUFREQ_TABLE_END },
};
-#define NUM_CPUS 2
-
static struct clk *cpu_clk;
static struct clk *pll_x_clk;
static struct clk *pll_p_clk;
@@ -122,9 +120,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
{
int ret;
- if (policy->cpu >= NUM_CPUS)
- return -EINVAL;
-
clk_prepare_enable(cpu_clk);
/* FIXME: what's the actual transition time? */
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (5 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 06/11] cpufreq: tegra20: Remove unneeded check in tegra_cpu_init Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 22:02 ` Thierry Reding
2018-05-21 5:44 ` Viresh Kumar
2018-05-18 20:06 ` [PATCH v2 08/11] cpufreq: tegra20: Remove unneeded variable initialization Dmitry Osipenko
` (3 subsequent siblings)
10 siblings, 2 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Remove unnecessary parentheses as suggested by the checkpatch script.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index df25e350c8e6..4b85a6733533 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -50,7 +50,7 @@ static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
* - we are already at it, i.e. policy->cur == ifreq
* - index corresponds to ifreq
*/
- if ((freq_table[index].frequency == ifreq) || (policy->cur == ifreq))
+ if (freq_table[index].frequency == ifreq || policy->cur == ifreq)
return 0;
return ifreq;
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 08/11] cpufreq: tegra20: Remove unneeded variable initialization
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (6 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 09/11] cpufreq: tegra20: Check if this is Tegra20 machine Dmitry Osipenko
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Remove unneeded variable initialization solely for consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 4b85a6733533..36075aee2ff2 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -86,7 +86,7 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
{
unsigned long rate = freq_table[index].frequency;
unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
- int ret = 0;
+ int ret;
/*
* target freq == pll_p, don't need to take extra reference to pll_x_clk
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 09/11] cpufreq: tegra20: Check if this is Tegra20 machine
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (7 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 08/11] cpufreq: tegra20: Remove unneeded variable initialization Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 10/11] cpufreq: tegra20: Allow cpufreq driver to be built as loadable module Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 11/11] cpufreq: tegra20: Wrap cpufreq into platform driver Dmitry Osipenko
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Don't even try to request the clocks during of module initialization on
non-Tegra20 machines (this is the case for a multi-platform kernel) for
consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/tegra20-cpufreq.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 36075aee2ff2..7b425ebe81e7 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -21,6 +21,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/types.h>
static struct cpufreq_frequency_table freq_table[] = {
@@ -158,6 +159,9 @@ static int __init tegra_cpufreq_init(void)
{
int err;
+ if (!of_machine_is_compatible("nvidia,tegra20"))
+ return -ENODEV;
+
cpu_clk = clk_get_sys(NULL, "cclk");
if (IS_ERR(cpu_clk))
return PTR_ERR(cpu_clk);
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 10/11] cpufreq: tegra20: Allow cpufreq driver to be built as loadable module
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (8 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 09/11] cpufreq: tegra20: Check if this is Tegra20 machine Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 11/11] cpufreq: tegra20: Wrap cpufreq into platform driver Dmitry Osipenko
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Nothing prevents Tegra20 CPUFreq module to be unloaded, hence allow it to
be built as a non-builtin kernel module.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/cpufreq/Kconfig.arm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 96b35b8b3606..a8a2e210c624 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -264,7 +264,7 @@ config ARM_TANGO_CPUFREQ
default y
config ARM_TEGRA20_CPUFREQ
- bool "Tegra20 CPUFreq support"
+ tristate "Tegra20 CPUFreq support"
depends on ARCH_TEGRA
default y
help
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 11/11] cpufreq: tegra20: Wrap cpufreq into platform driver
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
` (9 preceding siblings ...)
2018-05-18 20:06 ` [PATCH v2 10/11] cpufreq: tegra20: Allow cpufreq driver to be built as loadable module Dmitry Osipenko
@ 2018-05-18 20:06 ` Dmitry Osipenko
10 siblings, 0 replies; 15+ messages in thread
From: Dmitry Osipenko @ 2018-05-18 20:06 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter
Cc: linux-tegra, linux-pm, linux-kernel, Peter Geis
Currently tegra20-cpufreq kernel module isn't getting autoloaded because
there is no device associated with the module, this is one of two patches
that resolves the module autoloading. This patch adds a module alias that
will associate the tegra20-cpufreq kernel module with the platform device,
other patch will instantiate the actual platform device. And now it makes
sense to wrap cpufreq driver into a platform driver for consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/tegra20-cpufreq.c | 145 ++++++++++++++++++------------
1 file changed, 86 insertions(+), 59 deletions(-)
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 7b425ebe81e7..05f57dcd5215 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -21,7 +21,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
-#include <linux/of.h>
+#include <linux/platform_device.h>
#include <linux/types.h>
static struct cpufreq_frequency_table freq_table[] = {
@@ -36,15 +36,20 @@ static struct cpufreq_frequency_table freq_table[] = {
{ .frequency = CPUFREQ_TABLE_END },
};
-static struct clk *cpu_clk;
-static struct clk *pll_x_clk;
-static struct clk *pll_p_clk;
-static bool pll_x_prepared;
+struct tegra20_cpufreq {
+ struct device *dev;
+ struct cpufreq_driver driver;
+ struct clk *cpu_clk;
+ struct clk *pll_x_clk;
+ struct clk *pll_p_clk;
+ bool pll_x_prepared;
+};
static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
unsigned int index)
{
- unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
+ struct tegra20_cpufreq *cpufreq = cpufreq_get_driver_data();
+ unsigned int ifreq = clk_get_rate(cpufreq->pll_p_clk) / 1000;
/*
* Don't switch to intermediate freq if:
@@ -60,6 +65,7 @@ static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
static int tegra_target_intermediate(struct cpufreq_policy *policy,
unsigned int index)
{
+ struct tegra20_cpufreq *cpufreq = cpufreq_get_driver_data();
int ret;
/*
@@ -72,21 +78,22 @@ static int tegra_target_intermediate(struct cpufreq_policy *policy,
* Also, we wouldn't be using pll_x anymore and must not take extra
* reference to it, as it can be disabled now to save some power.
*/
- clk_prepare_enable(pll_x_clk);
+ clk_prepare_enable(cpufreq->pll_x_clk);
- ret = clk_set_parent(cpu_clk, pll_p_clk);
+ ret = clk_set_parent(cpufreq->cpu_clk, cpufreq->pll_p_clk);
if (ret)
- clk_disable_unprepare(pll_x_clk);
+ clk_disable_unprepare(cpufreq->pll_x_clk);
else
- pll_x_prepared = true;
+ cpufreq->pll_x_prepared = true;
return ret;
}
static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
{
+ struct tegra20_cpufreq *cpufreq = cpufreq_get_driver_data();
unsigned long rate = freq_table[index].frequency;
- unsigned int ifreq = clk_get_rate(pll_p_clk) / 1000;
+ unsigned int ifreq = clk_get_rate(cpufreq->pll_p_clk) / 1000;
int ret;
/*
@@ -94,14 +101,14 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
* as it isn't used anymore.
*/
if (rate == ifreq)
- return clk_set_parent(cpu_clk, pll_p_clk);
+ return clk_set_parent(cpufreq->cpu_clk, cpufreq->pll_p_clk);
- ret = clk_set_rate(pll_x_clk, rate * 1000);
+ ret = clk_set_rate(cpufreq->pll_x_clk, rate * 1000);
/* Restore to earlier frequency on error, i.e. pll_x */
if (ret)
- pr_err("Failed to change pll_x to %lu\n", rate);
+ dev_err(cpufreq->dev, "Failed to change pll_x to %lu\n", rate);
- ret = clk_set_parent(cpu_clk, pll_x_clk);
+ ret = clk_set_parent(cpufreq->cpu_clk, cpufreq->pll_x_clk);
/* This shouldn't fail while changing or restoring */
WARN_ON(ret);
@@ -109,9 +116,9 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
* Drop count to pll_x clock only if we switched to intermediate freq
* earlier while transitioning to a target frequency.
*/
- if (pll_x_prepared) {
- clk_disable_unprepare(pll_x_clk);
- pll_x_prepared = false;
+ if (cpufreq->pll_x_prepared) {
+ clk_disable_unprepare(cpufreq->pll_x_clk);
+ cpufreq->pll_x_prepared = false;
}
return ret;
@@ -119,91 +126,111 @@ static int tegra_target(struct cpufreq_policy *policy, unsigned int index)
static int tegra_cpu_init(struct cpufreq_policy *policy)
{
+ struct tegra20_cpufreq *cpufreq = cpufreq_get_driver_data();
int ret;
- clk_prepare_enable(cpu_clk);
+ clk_prepare_enable(cpufreq->cpu_clk);
/* FIXME: what's the actual transition time? */
ret = cpufreq_generic_init(policy, freq_table, 300 * 1000);
if (ret) {
- clk_disable_unprepare(cpu_clk);
+ clk_disable_unprepare(cpufreq->cpu_clk);
return ret;
}
- policy->clk = cpu_clk;
+ policy->clk = cpufreq->cpu_clk;
policy->suspend_freq = freq_table[0].frequency;
return 0;
}
static int tegra_cpu_exit(struct cpufreq_policy *policy)
{
- clk_disable_unprepare(cpu_clk);
+ struct tegra20_cpufreq *cpufreq = cpufreq_get_driver_data();
+
+ clk_disable_unprepare(cpufreq->cpu_clk);
return 0;
}
-static struct cpufreq_driver tegra_cpufreq_driver = {
- .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
- .verify = cpufreq_generic_frequency_table_verify,
- .get_intermediate = tegra_get_intermediate,
- .target_intermediate = tegra_target_intermediate,
- .target_index = tegra_target,
- .get = cpufreq_generic_get,
- .init = tegra_cpu_init,
- .exit = tegra_cpu_exit,
- .name = "tegra",
- .attr = cpufreq_generic_attr,
- .suspend = cpufreq_generic_suspend,
-};
-
-static int __init tegra_cpufreq_init(void)
+static int tegra20_cpufreq_probe(struct platform_device *pdev)
{
+ struct tegra20_cpufreq *cpufreq;
int err;
- if (!of_machine_is_compatible("nvidia,tegra20"))
- return -ENODEV;
+ cpufreq = devm_kzalloc(&pdev->dev, sizeof(*cpufreq), GFP_KERNEL);
+ if (!cpufreq)
+ return -ENOMEM;
- cpu_clk = clk_get_sys(NULL, "cclk");
- if (IS_ERR(cpu_clk))
- return PTR_ERR(cpu_clk);
+ cpufreq->cpu_clk = clk_get_sys(NULL, "cclk");
+ if (IS_ERR(cpufreq->cpu_clk))
+ return PTR_ERR(cpufreq->cpu_clk);
- pll_x_clk = clk_get_sys(NULL, "pll_x");
- if (IS_ERR(pll_x_clk)) {
- err = PTR_ERR(pll_x_clk);
+ cpufreq->pll_x_clk = clk_get_sys(NULL, "pll_x");
+ if (IS_ERR(cpufreq->pll_x_clk)) {
+ err = PTR_ERR(cpufreq->pll_x_clk);
goto put_cpu;
}
- pll_p_clk = clk_get_sys(NULL, "pll_p");
- if (IS_ERR(pll_p_clk)) {
- err = PTR_ERR(pll_p_clk);
+ cpufreq->pll_p_clk = clk_get_sys(NULL, "pll_p");
+ if (IS_ERR(cpufreq->pll_p_clk)) {
+ err = PTR_ERR(cpufreq->pll_p_clk);
goto put_pll_x;
}
- err = cpufreq_register_driver(&tegra_cpufreq_driver);
+ cpufreq->dev = &pdev->dev;
+ cpufreq->driver.get = cpufreq_generic_get;
+ cpufreq->driver.attr = cpufreq_generic_attr;
+ cpufreq->driver.init = tegra_cpu_init;
+ cpufreq->driver.exit = tegra_cpu_exit;
+ cpufreq->driver.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK;
+ cpufreq->driver.verify = cpufreq_generic_frequency_table_verify;
+ cpufreq->driver.suspend = cpufreq_generic_suspend;
+ cpufreq->driver.driver_data = cpufreq;
+ cpufreq->driver.target_index = tegra_target;
+ cpufreq->driver.get_intermediate = tegra_get_intermediate;
+ cpufreq->driver.target_intermediate = tegra_target_intermediate;
+ snprintf(cpufreq->driver.name, CPUFREQ_NAME_LEN, "tegra");
+
+ err = cpufreq_register_driver(&cpufreq->driver);
if (err)
goto put_pll_p;
+ platform_set_drvdata(pdev, cpufreq);
+
return 0;
put_pll_p:
- clk_put(pll_p_clk);
+ clk_put(cpufreq->pll_p_clk);
put_pll_x:
- clk_put(pll_x_clk);
+ clk_put(cpufreq->pll_x_clk);
put_cpu:
- clk_put(cpu_clk);
+ clk_put(cpufreq->cpu_clk);
return err;
}
-static void __exit tegra_cpufreq_exit(void)
+static int tegra20_cpufreq_remove(struct platform_device *pdev)
{
- cpufreq_unregister_driver(&tegra_cpufreq_driver);
- clk_put(pll_p_clk);
- clk_put(pll_x_clk);
- clk_put(cpu_clk);
+ struct tegra20_cpufreq *cpufreq = platform_get_drvdata(pdev);
+
+ cpufreq_unregister_driver(&cpufreq->driver);
+
+ clk_put(cpufreq->pll_p_clk);
+ clk_put(cpufreq->pll_x_clk);
+ clk_put(cpufreq->cpu_clk);
+
+ return 0;
}
+static struct platform_driver tegra20_cpufreq_driver = {
+ .probe = tegra20_cpufreq_probe,
+ .remove = tegra20_cpufreq_remove,
+ .driver = {
+ .name = "tegra20-cpufreq",
+ },
+};
+module_platform_driver(tegra20_cpufreq_driver);
+
+MODULE_ALIAS("platform:tegra20-cpufreq");
MODULE_AUTHOR("Colin Cross <ccross@android.com>");
MODULE_DESCRIPTION("NVIDIA Tegra20 cpufreq driver");
MODULE_LICENSE("GPL");
-module_init(tegra_cpufreq_init);
-module_exit(tegra_cpufreq_exit);
--
2.17.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses
2018-05-18 20:06 ` [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses Dmitry Osipenko
@ 2018-05-18 22:02 ` Thierry Reding
2018-05-21 5:44 ` Viresh Kumar
1 sibling, 0 replies; 15+ messages in thread
From: Thierry Reding @ 2018-05-18 22:02 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Viresh Kumar, Jonathan Hunter, linux-tegra,
linux-pm, linux-kernel, Peter Geis
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
On Fri, May 18, 2018 at 11:06:38PM +0300, Dmitry Osipenko wrote:
> Remove unnecessary parentheses as suggested by the checkpatch script.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> drivers/cpufreq/tegra20-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers
2018-05-18 20:06 ` [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers Dmitry Osipenko
@ 2018-05-21 5:44 ` Viresh Kumar
0 siblings, 0 replies; 15+ messages in thread
From: Viresh Kumar @ 2018-05-21 5:44 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, linux-tegra,
linux-pm, linux-kernel, Peter Geis
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unused/unneeded headers and sort them in the alphabet order.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> Acked-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/cpufreq/tegra20-cpufreq.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
> index dd8a76a64a8e..bec1a50a8138 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -16,16 +16,12 @@
> *
> */
>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/types.h>
> -#include <linux/sched.h>
> +#include <linux/clk.h>
> #include <linux/cpufreq.h>
> -#include <linux/delay.h>
> -#include <linux/init.h>
> #include <linux/err.h>
> -#include <linux/clk.h>
> -#include <linux/io.h>
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
>
> static struct cpufreq_frequency_table freq_table[] = {
> { .frequency = 216000 },
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses
2018-05-18 20:06 ` [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses Dmitry Osipenko
2018-05-18 22:02 ` Thierry Reding
@ 2018-05-21 5:44 ` Viresh Kumar
1 sibling, 0 replies; 15+ messages in thread
From: Viresh Kumar @ 2018-05-21 5:44 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, linux-tegra,
linux-pm, linux-kernel, Peter Geis
On 18-05-18, 23:06, Dmitry Osipenko wrote:
> Remove unnecessary parentheses as suggested by the checkpatch script.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> drivers/cpufreq/tegra20-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
> index df25e350c8e6..4b85a6733533 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -50,7 +50,7 @@ static unsigned int tegra_get_intermediate(struct cpufreq_policy *policy,
> * - we are already at it, i.e. policy->cur == ifreq
> * - index corresponds to ifreq
> */
> - if ((freq_table[index].frequency == ifreq) || (policy->cur == ifreq))
> + if (freq_table[index].frequency == ifreq || policy->cur == ifreq)
> return 0;
>
> return ifreq;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-05-21 5:44 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-18 20:06 [PATCH v2 00/11] Clean up Tegra20 cpufreq driver Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 01/11] cpufreq: tegra20: Change module description Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 02/11] cpufreq: tegra20: Clean up whitespaces in the code Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 03/11] cpufreq: tegra20: Clean up included headers Dmitry Osipenko
2018-05-21 5:44 ` Viresh Kumar
2018-05-18 20:06 ` [PATCH v2 04/11] cpufreq: tegra20: Remove EMC clock usage Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 05/11] cpufreq: tegra20: Release clocks properly Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 06/11] cpufreq: tegra20: Remove unneeded check in tegra_cpu_init Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 07/11] cpufreq: tegra20: Remove unnecessary parentheses Dmitry Osipenko
2018-05-18 22:02 ` Thierry Reding
2018-05-21 5:44 ` Viresh Kumar
2018-05-18 20:06 ` [PATCH v2 08/11] cpufreq: tegra20: Remove unneeded variable initialization Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 09/11] cpufreq: tegra20: Check if this is Tegra20 machine Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 10/11] cpufreq: tegra20: Allow cpufreq driver to be built as loadable module Dmitry Osipenko
2018-05-18 20:06 ` [PATCH v2 11/11] cpufreq: tegra20: Wrap cpufreq into platform driver Dmitry Osipenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).