* [PATCH 01/14] cpufreq: exynos4210: properly put of node
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 02/14] cpufreq: exynos4210: iounmap in error path Eduardo Valentin
` (9 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Call of_node_put when necessary during init.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4210-cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 843ec82..dba48f0 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -169,6 +169,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
info->set_freq = exynos4210_set_frequency;
cpufreq = info;
+ of_node_put(np);
return 0;
@@ -179,6 +180,8 @@ err_mout_mpll:
err_moutcore:
clk_put(cpu_clk);
+ of_node_put(np);
pr_debug("%s: failed initialization\n", __func__);
+
return -EINVAL;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/14] cpufreq: exynos4210: iounmap in error path
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
2015-02-02 20:58 ` [PATCH 01/14] cpufreq: exynos4210: properly put of node Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get Eduardo Valentin
` (8 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
When error occurs, allow systems to release iomapped area.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4210-cpufreq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index dba48f0..8a25dce 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -180,6 +180,7 @@ err_mout_mpll:
err_moutcore:
clk_put(cpu_clk);
+ iounmap(info->cmu_regs);
of_node_put(np);
pr_debug("%s: failed initialization\n", __func__);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
2015-02-02 20:58 ` [PATCH 01/14] cpufreq: exynos4210: properly put of node Eduardo Valentin
2015-02-02 20:58 ` [PATCH 02/14] cpufreq: exynos4210: iounmap in error path Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 04/14] cpufreq: exynos4x12: properly put of node Eduardo Valentin
` (7 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Switch to managed clk_get to properly release resources when
they are not needed.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4210-cpufreq.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 8a25dce..fc02a39 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -142,23 +142,23 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
return -EFAULT;
}
- cpu_clk = clk_get(NULL, "armclk");
+ cpu_clk = devm_clk_get(info->dev, "armclk");
if (IS_ERR(cpu_clk))
- return PTR_ERR(cpu_clk);
+ goto err;
- moutcore = clk_get(NULL, "moutcore");
+ moutcore = devm_clk_get(info->dev, "moutcore");
if (IS_ERR(moutcore))
- goto err_moutcore;
+ goto err;
- mout_mpll = clk_get(NULL, "mout_mpll");
+ mout_mpll = devm_clk_get(info->dev, "mout_mpll");
if (IS_ERR(mout_mpll))
- goto err_mout_mpll;
+ goto err;
rate = clk_get_rate(mout_mpll) / 1000;
- mout_apll = clk_get(NULL, "mout_apll");
+ mout_apll = devm_clk_get(info->dev, "mout_apll");
if (IS_ERR(mout_apll))
- goto err_mout_apll;
+ goto err;
info->mpll_freq_khz = rate;
/* 800Mhz */
@@ -173,13 +173,7 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
return 0;
-err_mout_apll:
- clk_put(mout_mpll);
-err_mout_mpll:
- clk_put(moutcore);
-err_moutcore:
- clk_put(cpu_clk);
-
+err:
iounmap(info->cmu_regs);
of_node_put(np);
pr_debug("%s: failed initialization\n", __func__);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/14] cpufreq: exynos4x12: properly put of node
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (2 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get Eduardo Valentin
` (6 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Call of_node_put when necessary during init.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4x12-cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 9e78a85..3d067f2 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -221,6 +221,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
info->set_freq = exynos4x12_set_frequency;
cpufreq = info;
+ of_node_put(np);
return 0;
@@ -231,6 +232,8 @@ err_mout_mpll:
err_moutcore:
clk_put(cpu_clk);
+ of_node_put(np);
pr_debug("%s: failed initialization\n", __func__);
+
return -EINVAL;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (3 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 04/14] cpufreq: exynos4x12: properly put of node Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 08/14] cpufreq: exynos5250: iounmap in error path Eduardo Valentin
` (5 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Switch to managed clk_get to properly release resources when
they are not needed.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4x12-cpufreq.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 3da36baf..7e0dd2a 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -189,23 +189,23 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
return -EFAULT;
}
- cpu_clk = clk_get(NULL, "armclk");
+ cpu_clk = devm_clk_get(info->dev, "armclk");
if (IS_ERR(cpu_clk))
- return PTR_ERR(cpu_clk);
+ goto err;
- moutcore = clk_get(NULL, "moutcore");
+ moutcore = devm_clk_get(info->dev, "moutcore");
if (IS_ERR(moutcore))
- goto err_moutcore;
+ goto err;
- mout_mpll = clk_get(NULL, "mout_mpll");
+ mout_mpll = devm_clk_get(info->dev, "mout_mpll");
if (IS_ERR(mout_mpll))
- goto err_mout_mpll;
+ goto err;
rate = clk_get_rate(mout_mpll) / 1000;
- mout_apll = clk_get(NULL, "mout_apll");
+ mout_apll = devm_clk_get(info->dev, "mout_apll");
if (IS_ERR(mout_apll))
- goto err_mout_apll;
+ goto err;
if (info->type == EXYNOS_SOC_4212)
apll_freq_4x12 = apll_freq_4212;
@@ -225,13 +225,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
return 0;
-err_mout_apll:
- clk_put(mout_mpll);
-err_mout_mpll:
- clk_put(moutcore);
-err_moutcore:
- clk_put(cpu_clk);
-
+err:
iounmap(info->cmu_regs);
of_node_put(np);
pr_debug("%s: failed initialization\n", __func__);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/14] cpufreq: exynos5250: iounmap in error path
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (4 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get Eduardo Valentin
` (4 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
When error occurs, allow systems to release iomapped area.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos5250-cpufreq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 50b0cdf..e61d149 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -206,6 +206,7 @@ err_mout_mpll:
err_moutcore:
clk_put(cpu_clk);
+ iounmap(info->cmu_regs);
of_node_put(np);
pr_err("%s: failed initialization\n", __func__);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (5 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 08/14] cpufreq: exynos5250: iounmap in error path Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback Eduardo Valentin
` (3 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Switch to managed clk_get to properly release resources when
they are not needed.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos5250-cpufreq.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index e61d149..d3ce829 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -168,23 +168,23 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
return -EFAULT;
}
- cpu_clk = clk_get(NULL, "armclk");
+ cpu_clk = devm_clk_get(info->dev, "armclk");
if (IS_ERR(cpu_clk))
- return PTR_ERR(cpu_clk);
+ goto err;
- moutcore = clk_get(NULL, "mout_cpu");
+ moutcore = devm_clk_get(info->dev, "mout_cpu");
if (IS_ERR(moutcore))
- goto err_moutcore;
+ goto err;
- mout_mpll = clk_get(NULL, "mout_mpll");
+ mout_mpll = devm_clk_get(info->dev, "mout_mpll");
if (IS_ERR(mout_mpll))
- goto err_mout_mpll;
+ goto err;
rate = clk_get_rate(mout_mpll) / 1000;
- mout_apll = clk_get(NULL, "mout_apll");
+ mout_apll = devm_clk_get(info->dev, "mout_apll");
if (IS_ERR(mout_apll))
- goto err_mout_apll;
+ goto err;
info->mpll_freq_khz = rate;
/* 800Mhz */
@@ -199,13 +199,7 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
return 0;
-err_mout_apll:
- clk_put(mout_mpll);
-err_mout_mpll:
- clk_put(moutcore);
-err_moutcore:
- clk_put(cpu_clk);
-
+err:
iounmap(info->cmu_regs);
of_node_put(np);
pr_err("%s: failed initialization\n", __func__);
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (6 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq Eduardo Valentin
` (2 subsequent siblings)
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
This change passes the exynos_dvfs_info to the .set_freq callback
to avoid using local static variables. Now, the core can use
same allocated data structure and child code can work on same
data structure.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos-cpufreq.c | 2 +-
drivers/cpufreq/exynos-cpufreq.h | 2 +-
drivers/cpufreq/exynos4210-cpufreq.c | 17 ++++++++++-------
drivers/cpufreq/exynos4x12-cpufreq.c | 19 +++++++++++--------
drivers/cpufreq/exynos5250-cpufreq.c | 19 +++++++++++--------
5 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 5e98c6b..a964602 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -108,7 +108,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
}
}
- exynos_info->set_freq(old_index, index);
+ exynos_info->set_freq(exynos_info, old_index, index);
/* When the new frequency is lower than current frequency */
if ((target_freq < old_freq) ||
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index 9f2062a..b59558e 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -48,7 +48,7 @@ struct exynos_dvfs_info {
struct clk *cpu_clk;
unsigned int *volt_table;
struct cpufreq_frequency_table *freq_table;
- void (*set_freq)(unsigned int, unsigned int);
+ void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
bool (*need_apll_change)(unsigned int, unsigned int);
void __iomem *cmu_regs;
};
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index fc02a39..00889a4 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -55,7 +55,8 @@ static struct apll_freq apll_freq_4210[] = {
APLL_FREQ(200, 0, 1, 3, 1, 3, 1, 0, 0, 3, 0, 0, 200, 6, 3),
};
-static void exynos4210_set_clkdiv(unsigned int div_index)
+static void exynos4210_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+ unsigned int div_index)
{
unsigned int tmp;
@@ -80,7 +81,8 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
} while (tmp & 0x11);
}
-static void exynos4210_set_apll(unsigned int index)
+static void exynos4210_set_apll(struct exynos_dvfs_info *cpufreq,
+ unsigned int index)
{
unsigned int tmp, freq = apll_freq_4210[index].freq;
@@ -104,15 +106,16 @@ static void exynos4210_set_apll(unsigned int index)
} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
}
-static void exynos4210_set_frequency(unsigned int old_index,
+static void exynos4210_set_frequency(struct exynos_dvfs_info *cpufreq,
+ unsigned int old_index,
unsigned int new_index)
{
if (old_index > new_index) {
- exynos4210_set_clkdiv(new_index);
- exynos4210_set_apll(new_index);
+ exynos4210_set_clkdiv(cpufreq, new_index);
+ exynos4210_set_apll(cpufreq, new_index);
} else if (old_index < new_index) {
- exynos4210_set_apll(new_index);
- exynos4210_set_clkdiv(new_index);
+ exynos4210_set_apll(cpufreq, new_index);
+ exynos4210_set_clkdiv(cpufreq, new_index);
}
}
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 7e0dd2a..d12087b 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -100,7 +100,8 @@ static struct apll_freq apll_freq_4412[] = {
APLL_FREQ(200, 0, 1, 3, 0, 1, 1, 1, 0, 3, 0, 0, 100, 3, 2),
};
-static void exynos4x12_set_clkdiv(unsigned int div_index)
+static void exynos4x12_set_clkdiv(struct exynos_dvfs_info *cpufreq,
+ unsigned int div_index)
{
unsigned int tmp;
@@ -125,7 +126,8 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
} while (tmp != 0x0);
}
-static void exynos4x12_set_apll(unsigned int index)
+static void exynos4x12_set_apll(struct exynos_dvfs_info *cpufreq,
+ unsigned int index)
{
unsigned int tmp, freq = apll_freq_4x12[index].freq;
@@ -151,15 +153,16 @@ static void exynos4x12_set_apll(unsigned int index)
} while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
}
-static void exynos4x12_set_frequency(unsigned int old_index,
- unsigned int new_index)
+static void exynos4x12_set_frequency(struct exynos_dvfs_info *cpufreq,
+ unsigned int old_index,
+ unsigned int new_index)
{
if (old_index > new_index) {
- exynos4x12_set_clkdiv(new_index);
- exynos4x12_set_apll(new_index);
+ exynos4x12_set_clkdiv(cpufreq, new_index);
+ exynos4x12_set_apll(cpufreq, new_index);
} else if (old_index < new_index) {
- exynos4x12_set_apll(new_index);
- exynos4x12_set_clkdiv(new_index);
+ exynos4x12_set_apll(cpufreq, new_index);
+ exynos4x12_set_clkdiv(cpufreq, new_index);
}
}
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index d3ce829..191a511 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -80,7 +80,8 @@ static struct apll_freq apll_freq_5250[] = {
APLL_FREQ(200, 0, 1, 7, 7, 1, 1, 1, 0, 0, 2, 0, 100, 3, 2),
};
-static void set_clkdiv(unsigned int div_index)
+static void set_clkdiv(struct exynos_dvfs_info *cpufreq,
+ unsigned int div_index)
{
unsigned int tmp;
@@ -103,7 +104,8 @@ static void set_clkdiv(unsigned int div_index)
cpu_relax();
}
-static void set_apll(unsigned int index)
+static void set_apll(struct exynos_dvfs_info *cpufreq,
+ unsigned int index)
{
unsigned int tmp;
unsigned int freq = apll_freq_5250[index].freq;
@@ -130,15 +132,16 @@ static void set_apll(unsigned int index)
} while (tmp != (0x1 << 16));
}
-static void exynos5250_set_frequency(unsigned int old_index,
- unsigned int new_index)
+static void exynos5250_set_frequency(struct exynos_dvfs_info *exynos_info,
+ unsigned int old_index,
+ unsigned int new_index)
{
if (old_index > new_index) {
- set_clkdiv(new_index);
- set_apll(new_index);
+ set_clkdiv(exynos_info, new_index);
+ set_apll(exynos_info, new_index);
} else if (old_index < new_index) {
- set_apll(new_index);
- set_clkdiv(new_index);
+ set_apll(exynos_info, new_index);
+ set_clkdiv(exynos_info, new_index);
}
}
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (7 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 13/14] cpufreq: exynos5250: " Eduardo Valentin
2015-02-02 20:58 ` [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation Eduardo Valentin
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos4210-cpufreq.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 00889a4..6757bda 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
static struct clk *moutcore;
static struct clk *mout_mpll;
static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
static unsigned int exynos4210_volt_table[] = {
1250000, 1150000, 1050000, 975000, 950000,
@@ -171,7 +170,6 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
info->freq_table = exynos4210_freq_table;
info->set_freq = exynos4210_set_frequency;
- cpufreq = info;
of_node_put(np);
return 0;
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 13/14] cpufreq: exynos5250: remove unused symbol cpufreq
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (8 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
2015-02-02 20:58 ` [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation Eduardo Valentin
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
Now that the set_freq call back receives the intended
data struct, the global cpufreq variable may be removed.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos5250-cpufreq.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 191a511..ee274c9 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -25,7 +25,6 @@ static struct clk *cpu_clk;
static struct clk *moutcore;
static struct clk *mout_mpll;
static struct clk *mout_apll;
-static struct exynos_dvfs_info *cpufreq;
static unsigned int exynos5250_volt_table[] = {
1300000, 1250000, 1225000, 1200000, 1150000,
@@ -197,7 +196,6 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
info->freq_table = exynos5250_freq_table;
info->set_freq = exynos5250_set_frequency;
- cpufreq = info;
of_node_put(np);
return 0;
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
` (9 preceding siblings ...)
2015-02-02 20:58 ` [PATCH 13/14] cpufreq: exynos5250: " Eduardo Valentin
@ 2015-02-02 20:58 ` Eduardo Valentin
10 siblings, 0 replies; 11+ messages in thread
From: Eduardo Valentin @ 2015-02-02 20:58 UTC (permalink / raw)
To: linux-arm-kernel
This change allows the proper resource release used by this driver.
The resources are now allocated using managed allocation by means
of the devm_* helper functions. Those resources that cannot be managed
are properly released during the device removal time.
The global variables have been removed as well. All static variables
were moved to driver data and properly assigned to cpufreq
driver data. In callbacks, now the data structure allocated
in probe time is fetched from cpufreq policy.
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: linux-pm at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/cpufreq/exynos-cpufreq.c | 99 +++++++++++++++++++++++++---------------
drivers/cpufreq/exynos-cpufreq.h | 5 ++
2 files changed, 67 insertions(+), 37 deletions(-)
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index a964602..f1a13e8 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -23,12 +23,8 @@
#include "exynos-cpufreq.h"
-static struct exynos_dvfs_info *exynos_info;
-static struct thermal_cooling_device *cdev;
-static struct regulator *arm_regulator;
-static unsigned int locking_frequency;
-
-static int exynos_cpufreq_get_index(unsigned int freq)
+static int exynos_cpufreq_get_index(struct exynos_dvfs_info *exynos_info,
+ unsigned int freq)
{
struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
struct cpufreq_frequency_table *pos;
@@ -43,7 +39,8 @@ static int exynos_cpufreq_get_index(unsigned int freq)
return pos - freq_table;
}
-static int exynos_cpufreq_scale(unsigned int target_freq)
+static int exynos_cpufreq_scale(struct exynos_dvfs_info *exynos_info,
+ unsigned int target_freq)
{
struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
unsigned int *volt_table = exynos_info->volt_table;
@@ -62,13 +59,13 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
* old_index with cpufreq_frequency_table_target(). Thus, ignore
* policy and get the index from the raw frequency table.
*/
- old_index = exynos_cpufreq_get_index(old_freq);
+ old_index = exynos_cpufreq_get_index(exynos_info, old_freq);
if (old_index < 0) {
ret = old_index;
goto out;
}
- index = exynos_cpufreq_get_index(target_freq);
+ index = exynos_cpufreq_get_index(exynos_info, target_freq);
if (index < 0) {
ret = index;
goto out;
@@ -90,7 +87,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
/* When the new frequency is higher than current frequency */
if ((target_freq > old_freq) && !safe_arm_volt) {
/* Firstly, voltage up to increase frequency */
- ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
+ ret = regulator_set_voltage(exynos_info->arm_regulator,
+ arm_volt, arm_volt);
if (ret) {
dev_err(dev, "failed to set cpu voltage to %d\n",
arm_volt);
@@ -99,8 +97,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
}
if (safe_arm_volt) {
- ret = regulator_set_voltage(arm_regulator, safe_arm_volt,
- safe_arm_volt);
+ ret = regulator_set_voltage(exynos_info->arm_regulator,
+ safe_arm_volt, safe_arm_volt);
if (ret) {
dev_err(dev, "failed to set cpu voltage to %d\n",
safe_arm_volt);
@@ -114,8 +112,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq)
if ((target_freq < old_freq) ||
((target_freq > old_freq) && safe_arm_volt)) {
/* down the voltage after frequency change */
- ret = regulator_set_voltage(arm_regulator, arm_volt,
- arm_volt);
+ ret = regulator_set_voltage(exynos_info->arm_regulator,
+ arm_volt, arm_volt);
if (ret) {
dev_err(dev, "failed to set cpu voltage to %d\n",
arm_volt);
@@ -131,22 +129,39 @@ out:
static int exynos_target(struct cpufreq_policy *policy, unsigned int index)
{
- return exynos_cpufreq_scale(exynos_info->freq_table[index].frequency);
+ struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
+ return exynos_cpufreq_scale(exynos_info,
+ exynos_info->freq_table[index].frequency);
}
static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
+ struct exynos_dvfs_info *exynos_info = policy->driver_data;
+
policy->clk = exynos_info->cpu_clk;
- policy->suspend_freq = locking_frequency;
+ policy->suspend_freq = exynos_info->locking_frequency;
return cpufreq_generic_init(policy, exynos_info->freq_table, 100000);
}
+static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+ struct exynos_dvfs_info *info = policy->driver_data;
+
+ if (info->cdev)
+ cpufreq_cooling_unregister(info->cdev);
+ dev_pm_opp_free_cpufreq_table(info->dev, &policy->freq_table);
+ iounmap(info->cmu_regs);
+
+ return 0;
+}
static struct cpufreq_driver exynos_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = exynos_target,
.get = cpufreq_generic_get,
.init = exynos_cpufreq_cpu_init,
+ .exit = exynos_cpufreq_cpu_exit,
.name = "exynos_cpufreq",
.attr = cpufreq_generic_attr,
#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
@@ -159,10 +174,12 @@ static struct cpufreq_driver exynos_driver = {
static int exynos_cpufreq_probe(struct platform_device *pdev)
{
+ struct exynos_dvfs_info *exynos_info;
struct device_node *cpus, *np;
int ret = -EINVAL;
- exynos_info = kzalloc(sizeof(*exynos_info), GFP_KERNEL);
+ exynos_info = devm_kzalloc(&pdev->dev, sizeof(*exynos_info),
+ GFP_KERNEL);
if (!exynos_info)
return -ENOMEM;
@@ -186,57 +203,64 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
}
if (ret)
- goto err_vdd_arm;
+ return -EINVAL;
if (exynos_info->set_freq == NULL) {
dev_err(&pdev->dev, "No set_freq function (ERR)\n");
- goto err_vdd_arm;
+ return -EINVAL;
}
- arm_regulator = regulator_get(NULL, "vdd_arm");
- if (IS_ERR(arm_regulator)) {
+ exynos_info->arm_regulator = devm_regulator_get(exynos_info->dev,
+ "vdd_arm");
+ if (IS_ERR(exynos_info->arm_regulator)) {
dev_err(&pdev->dev, "failed to get resource vdd_arm\n");
- goto err_vdd_arm;
+ return -EINVAL;
}
/* Done here as we want to capture boot frequency */
- locking_frequency = clk_get_rate(exynos_info->cpu_clk) / 1000;
+ exynos_info->locking_frequency = clk_get_rate(exynos_info->cpu_clk) /
+ 1000;
+
+ exynos_driver.driver_data = exynos_info;
ret = cpufreq_register_driver(&exynos_driver);
- if (ret)
- goto err_cpufreq_reg;
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register cpufreq driver\n");
+ return -EINVAL;
+ }
cpus = of_find_node_by_path("/cpus");
if (!cpus) {
pr_err("failed to find cpus node\n");
- return 0;
+ return -EINVAL;
}
np = of_get_next_child(cpus, NULL);
if (!np) {
pr_err("failed to find cpus child node\n");
- of_node_put(cpus);
- return 0;
+ goto of_exit;
}
if (of_find_property(np, "#cooling-cells", NULL)) {
- cdev = of_cpufreq_cooling_register(np,
+ exynos_info->cdev = of_cpufreq_cooling_register(np,
cpu_present_mask);
- if (IS_ERR(cdev))
+ if (IS_ERR(exynos_info->cdev))
pr_err("running cpufreq without cooling device: %ld\n",
- PTR_ERR(cdev));
+ PTR_ERR(exynos_info->cdev));
}
+
+of_exit:
of_node_put(np);
of_node_put(cpus);
return 0;
+}
-err_cpufreq_reg:
- dev_err(&pdev->dev, "failed to register cpufreq driver\n");
- regulator_put(arm_regulator);
-err_vdd_arm:
- kfree(exynos_info);
- return -EINVAL;
+static int exynos_cpufreq_remove(struct platform_device *pdev)
+{
+ cpufreq_unregister_driver(&exynos_driver);
+
+ return 0;
}
static struct platform_driver exynos_cpufreq_platdrv = {
@@ -244,5 +268,6 @@ static struct platform_driver exynos_cpufreq_platdrv = {
.name = "exynos-cpufreq",
},
.probe = exynos_cpufreq_probe,
+ .remove = exynos_cpufreq_remove,
};
module_platform_driver(exynos_cpufreq_platdrv);
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index b59558e..ac31d5d 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -9,6 +9,8 @@
* published by the Free Software Foundation.
*/
+#include <linux/thermal.h>
+
enum cpufreq_level_index {
L0, L1, L2, L3, L4,
L5, L6, L7, L8, L9,
@@ -51,6 +53,9 @@ struct exynos_dvfs_info {
void (*set_freq)(struct exynos_dvfs_info *, unsigned int, unsigned int);
bool (*need_apll_change)(unsigned int, unsigned int);
void __iomem *cmu_regs;
+ struct thermal_cooling_device *cdev;
+ struct regulator *arm_regulator;
+ unsigned int locking_frequency;
};
#ifdef CONFIG_ARM_EXYNOS4210_CPUFREQ
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-02-02 20:58 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1422910697-5920-1-git-send-email-edubezval@gmail.com>
2015-02-02 20:58 ` [PATCH 01/14] cpufreq: exynos4210: properly put of node Eduardo Valentin
2015-02-02 20:58 ` [PATCH 02/14] cpufreq: exynos4210: iounmap in error path Eduardo Valentin
2015-02-02 20:58 ` [PATCH 03/14] cpufreq: exynos4210: use devm_clk_get Eduardo Valentin
2015-02-02 20:58 ` [PATCH 04/14] cpufreq: exynos4x12: properly put of node Eduardo Valentin
2015-02-02 20:58 ` [PATCH 06/14] cpufreq: exynos4x12: use devm_clk_get Eduardo Valentin
2015-02-02 20:58 ` [PATCH 08/14] cpufreq: exynos5250: iounmap in error path Eduardo Valentin
2015-02-02 20:58 ` [PATCH 09/14] cpufreq: exynos5250: use devm_clk_get Eduardo Valentin
2015-02-02 20:58 ` [PATCH 10/14] cpufreq: exynox-cpufreq: pass exynos_dvfs_info to .set_freq callback Eduardo Valentin
2015-02-02 20:58 ` [PATCH 11/14] cpufreq: exynos4210: remove unused symbol cpufreq Eduardo Valentin
2015-02-02 20:58 ` [PATCH 13/14] cpufreq: exynos5250: " Eduardo Valentin
2015-02-02 20:58 ` [PATCH 14/14] cpufreq: exynos-cpufreq: release resources by using managed allocation Eduardo Valentin
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).