This patch adds the mx35 to the supported cpu-families of the
"CPUfreq driver for i.MX CPUs".
Signed-off-by: Christoph Fritz <[email protected]>
Signed-off-by: Christian Hemp <[email protected]>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/Makefile | 2 +-
arch/arm/mach-imx/clock-imx35.c | 67 +++++++++++++++++++++++++++++++++-----
arch/arm/mach-imx/cpu_op-mx35.c | 27 +++++++++++++++
arch/arm/mach-imx/cpu_op-mx35.h | 7 ++++
5 files changed, 94 insertions(+), 10 deletions(-)
create mode 100644 arch/arm/mach-imx/cpu_op-mx35.c
create mode 100644 arch/arm/mach-imx/cpu_op-mx35.h
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 7f43a1f..e88db4d 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -73,6 +73,7 @@ config SOC_IMX35
select HAVE_EPIT
select MXC_AVIC
select SMP_ON_UP if SMP
+ select ARCH_HAS_CPUFREQ
config SOC_IMX5
select CPU_V7
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index ff1e438..dbdd757 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o
obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o
obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
-obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o
+obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o cpu_op-mx35.o
obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
diff --git a/arch/arm/mach-imx/clock-imx35.c b/arch/arm/mach-imx/clock-imx35.c
index e56c1a8..704cf24 100644
--- a/arch/arm/mach-imx/clock-imx35.c
+++ b/arch/arm/mach-imx/clock-imx35.c
@@ -27,6 +27,7 @@
#include <mach/hardware.h>
#include <mach/common.h>
+#include "cpu_op-mx35.h"
#include "crmregs-imx3.h"
#ifdef HAVE_SET_RATE_SUPPORT
@@ -112,24 +113,32 @@ struct arm_ahb_div {
};
static struct arm_ahb_div clk_consumer[] = {
- { .arm = 1, .ahb = 4, .sel = 0},
- { .arm = 1, .ahb = 3, .sel = 1},
- { .arm = 2, .ahb = 2, .sel = 0},
+ { .arm = 1, .ahb = 4, .sel = 0}, /* ARM: 532 MHz, AHB: 133 Mhz */
+ { .arm = 1, .ahb = 3, .sel = 1}, /* ARM: 399 MHz, AHB: 133 Mhz */
+ { .arm = 2, .ahb = 2, .sel = 0}, /* ARM: 266 MHz, AHB: 133 Mhz */
{ .arm = 0, .ahb = 0, .sel = 0},
{ .arm = 0, .ahb = 0, .sel = 0},
{ .arm = 0, .ahb = 0, .sel = 0},
- { .arm = 4, .ahb = 1, .sel = 0},
- { .arm = 1, .ahb = 5, .sel = 0},
- { .arm = 1, .ahb = 8, .sel = 0},
- { .arm = 1, .ahb = 6, .sel = 1},
- { .arm = 2, .ahb = 4, .sel = 0},
+ { .arm = 4, .ahb = 1, .sel = 0}, /* ARM: 133 MHz, AHB: 133 Mhz */
+ { .arm = 1, .ahb = 5, .sel = 0}, /* ARM: 665 MHz, AHB: 133 Mhz */
+ { .arm = 1, .ahb = 8, .sel = 0}, /* ARM: 532 MHz, AHB: 66.5 Mhz */
+ { .arm = 1, .ahb = 6, .sel = 1}, /* ARM: 399 MHz, AHB: 66.5 Mhz */
+ { .arm = 2, .ahb = 4, .sel = 0}, /* ARM: 266 MHz, AHB: 66.5 Mhz */
{ .arm = 0, .ahb = 0, .sel = 0},
{ .arm = 0, .ahb = 0, .sel = 0},
{ .arm = 0, .ahb = 0, .sel = 0},
- { .arm = 4, .ahb = 2, .sel = 0},
+ { .arm = 4, .ahb = 2, .sel = 0}, /* ARM: 133 MHz, AHB: 66.5 Mhz */
{ .arm = 0, .ahb = 0, .sel = 0},
};
+enum mx35_cpu_freqs {
+ mx35_cpu_freq_532_mhz,
+ mx35_cpu_freq_399_mhz,
+ mx35_cpu_freq_266_mhz,
+ mx35_cpu_freq_133_mhz = 6,
+ mx35_cpu_freq_665_mhz,
+};
+
static unsigned long get_rate_arm(void)
{
unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
@@ -143,6 +152,40 @@ static unsigned long get_rate_arm(void)
return fref / aad->arm;
}
+#if defined(CONFIG_CPU_FREQ_IMX)
+static unsigned long clk_cpu_get_rate(struct clk *clk)
+{
+ return get_rate_arm();
+}
+
+static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)
+{
+ int i;
+ struct cpu_op *cpu_op_tbl;
+ int cpu_op_nr;
+ unsigned long pdr0;
+ const int mx35_cpu_freq[] = {
+ mx35_cpu_freq_133_mhz, mx35_cpu_freq_266_mhz,
+ mx35_cpu_freq_399_mhz, mx35_cpu_freq_532_mhz };
+
+ if (!get_cpu_op)
+ return -EINVAL;
+
+ cpu_op_tbl = get_cpu_op(&cpu_op_nr);
+
+ for (i = 0; i < cpu_op_nr; i++) {
+ if (cpu_op_tbl[i].cpu_rate == rate)
+ break;
+ }
+ pdr0 = __raw_readl(MXC_CCM_PDR0);
+ pdr0 &= ~(0xF << 16);
+ pdr0 |= mx35_cpu_freq[i] << 16;
+ __raw_writel(pdr0, MXC_CCM_PDR0);
+
+ return 0;
+}
+#endif
+
static unsigned long get_rate_ahb(struct clk *clk)
{
unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
@@ -392,6 +435,9 @@ DEFINE_CLOCK(iim_clk, 0, MX35_CCM_CGR3, 2, NULL, NULL);
DEFINE_CLOCK(gpu2d_clk, 0, MX35_CCM_CGR3, 4, NULL, NULL);
DEFINE_CLOCK(usbahb_clk, 0, 0, 0, get_rate_ahb, NULL);
+#if defined(CONFIG_CPU_FREQ_IMX)
+DEFINE_CLOCK(cpu_clk, 0, 0, 0, clk_cpu_get_rate, clk_cpu_set_rate);
+#endif
static int clk_dummy_enable(struct clk *clk)
{
@@ -487,6 +533,9 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(NULL, "iim", iim_clk)
_REGISTER_CLOCK(NULL, "gpu2d", gpu2d_clk)
_REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
+#if defined(CONFIG_CPU_FREQ_IMX)
+ _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)
+#endif
};
int __init mx35_clocks_init()
diff --git a/arch/arm/mach-imx/cpu_op-mx35.c b/arch/arm/mach-imx/cpu_op-mx35.c
new file mode 100644
index 0000000..7618f86
--- /dev/null
+++ b/arch/arm/mach-imx/cpu_op-mx35.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 PHYTEC Messtechnik GmbH
+ *
+ * Licensed under the GPLv2 or (at your option) any later version.
+ */
+
+#include <linux/bug.h>
+#include <linux/types.h>
+#include <mach/hardware.h>
+#include <linux/kernel.h>
+
+static struct cpu_op mx35_cpu_op[] = {
+ {
+ .cpu_rate = 133000000,},
+ {
+ .cpu_rate = 266000000,},
+ {
+ .cpu_rate = 399000000,},
+ {
+ .cpu_rate = 532000000,},
+};
+
+struct cpu_op *mx35_get_cpu_op(int *op)
+{
+ *op = ARRAY_SIZE(mx35_cpu_op);
+ return mx35_cpu_op;
+}
diff --git a/arch/arm/mach-imx/cpu_op-mx35.h b/arch/arm/mach-imx/cpu_op-mx35.h
new file mode 100644
index 0000000..6ea9385
--- /dev/null
+++ b/arch/arm/mach-imx/cpu_op-mx35.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2012 PHYTEC Messtechnik GmbH
+ *
+ * Licensed under the GPLv2 or (at your option) any later version.
+ */
+
+extern struct cpu_op *mx35_get_cpu_op(int *op);
--
1.7.2.5
On Mon, May 07, 2012 at 04:14:37PM +0200, Christoph Fritz wrote:
> This patch adds the mx35 to the supported cpu-families of the
> "CPUfreq driver for i.MX CPUs".
I'm afraid this has to wait another cycle since you are patching a file
that is scheduled to be replaced with common clock framework support.
This patch contains several #ifdefs which I think can all be removed.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Sascha,
On Wed, May 09, 2012 at 09:22:39AM +0200, Sascha Hauer wrote:
> On Mon, May 07, 2012 at 04:14:37PM +0200, Christoph Fritz wrote:
> > This patch adds the mx35 to the supported cpu-families of the
> > "CPUfreq driver for i.MX CPUs".
>
> I'm afraid this has to wait another cycle since you are patching a file
> that is scheduled to be replaced with common clock framework support.
Has this "scheduled replacement" somewhere (e.g. calendar) been
marked? So that I can check in the future before editing "scheduled
files".
Thanks,
-- Christoph
On Wed, May 09, 2012 at 09:56:18AM +0200, Christoph Fritz wrote:
> Hi Sascha,
>
> On Wed, May 09, 2012 at 09:22:39AM +0200, Sascha Hauer wrote:
> > On Mon, May 07, 2012 at 04:14:37PM +0200, Christoph Fritz wrote:
> > > This patch adds the mx35 to the supported cpu-families of the
> > > "CPUfreq driver for i.MX CPUs".
> >
> > I'm afraid this has to wait another cycle since you are patching a file
> > that is scheduled to be replaced with common clock framework support.
>
> Has this "scheduled replacement" somewhere (e.g. calendar) been
> marked? So that I can check in the future before editing "scheduled
> files".
The clock framework conversion has been a hot topic for quite a while
now, but there hasn't been an official note about it outside the list.
I can understand that the occasional linux arm kernel reader is not
aware of it, but we currently have nothing in place to anounce such
things. (Other than feature-removal.txt which seems not very suitable
since no feature is removed, only updated)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On Wed, 2012-05-09 at 10:13 +0200, Sascha Hauer wrote:
> On Wed, May 09, 2012 at 09:56:18AM +0200, Christoph Fritz wrote:
> > Hi Sascha,
> >
> > On Wed, May 09, 2012 at 09:22:39AM +0200, Sascha Hauer wrote:
> > > On Mon, May 07, 2012 at 04:14:37PM +0200, Christoph Fritz wrote:
> > > > This patch adds the mx35 to the supported cpu-families of the
> > > > "CPUfreq driver for i.MX CPUs".
> > >
> > > I'm afraid this has to wait another cycle since you are patching a file
> > > that is scheduled to be replaced with common clock framework support.
> >
> > Has this "scheduled replacement" somewhere (e.g. calendar) been
> > marked? So that I can check in the future before editing "scheduled
> > files".
>
> The clock framework conversion has been a hot topic for quite a while
> now, but there hasn't been an official note about it outside the list.
> I can understand that the occasional linux arm kernel reader is not
> aware of it, but we currently have nothing in place to anounce such
> things. (Other than feature-removal.txt which seems not very suitable
> since no feature is removed, only updated)
Is there already a version I can rebase the patch?
On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
find the new clock framework or even a work-in-progress version.
Thanks,
-- Christoph
On Thu, May 17, 2012 at 07:49:20PM +0200, Christoph Fritz wrote:
> On Wed, 2012-05-09 at 10:13 +0200, Sascha Hauer wrote:
> > On Wed, May 09, 2012 at 09:56:18AM +0200, Christoph Fritz wrote:
> > > Hi Sascha,
> > >
> > > On Wed, May 09, 2012 at 09:22:39AM +0200, Sascha Hauer wrote:
> > > > On Mon, May 07, 2012 at 04:14:37PM +0200, Christoph Fritz wrote:
> > > > > This patch adds the mx35 to the supported cpu-families of the
> > > > > "CPUfreq driver for i.MX CPUs".
> > > >
> > > > I'm afraid this has to wait another cycle since you are patching a file
> > > > that is scheduled to be replaced with common clock framework support.
> > >
> > > Has this "scheduled replacement" somewhere (e.g. calendar) been
> > > marked? So that I can check in the future before editing "scheduled
> > > files".
> >
> > The clock framework conversion has been a hot topic for quite a while
> > now, but there hasn't been an official note about it outside the list.
> > I can understand that the occasional linux arm kernel reader is not
> > aware of it, but we currently have nothing in place to anounce such
> > things. (Other than feature-removal.txt which seems not very suitable
> > since no feature is removed, only updated)
>
> Is there already a version I can rebase the patch?
>
> On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
> find the new clock framework or even a work-in-progress version.
They are in linux-next now.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On Thu, 2012-05-17 at 20:20 +0200, Sascha Hauer wrote:
> On Thu, May 17, 2012 at 07:49:20PM +0200, Christoph Fritz wrote:
> > Is there already a version I can rebase the patch?
> >
> > On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
> > find the new clock framework or even a work-in-progress version.
>
> They are in linux-next now.
Great, I'll rebase over this weekend.
Thanks,
Christoph
On Thu, May 17, 2012 at 08:40:58PM +0200, Christoph Fritz wrote:
> On Thu, 2012-05-17 at 20:20 +0200, Sascha Hauer wrote:
> > On Thu, May 17, 2012 at 07:49:20PM +0200, Christoph Fritz wrote:
>
> > > Is there already a version I can rebase the patch?
> > >
> > > On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
> > > find the new clock framework or even a work-in-progress version.
> >
> > They are in linux-next now.
There changed a lot of stuff: Where should I register the function to
set/get the cpu frequency?
To get an idea of how it should be done, I looked at imx51: Is there
cpufreq-support still implemented/working? I can see the
arch/arm/mach-imx/cpu_op-mx51.c but not its correlating
clk_cpu_set_rate function in arch/arm/mach-imx/clk-imx51-imx53.c.
Thanks,
-- Christoph
On Fri, 2012-05-18 at 00:42 +0200, Christoph Fritz wrote:
> On Thu, May 17, 2012 at 08:40:58PM +0200, Christoph Fritz wrote:
> > On Thu, 2012-05-17 at 20:20 +0200, Sascha Hauer wrote:
> > > On Thu, May 17, 2012 at 07:49:20PM +0200, Christoph Fritz wrote:
> >
> > > > Is there already a version I can rebase the patch?
> > > >
> > > > On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
> > > > find the new clock framework or even a work-in-progress version.
> > >
> > > They are in linux-next now.
>
> There changed a lot of stuff: Where should I register the function to
> set/get the cpu frequency?
>
> To get an idea of how it should be done, I looked at imx51: Is there
> cpufreq-support still implemented/working? I can see the
> arch/arm/mach-imx/cpu_op-mx51.c but not its correlating
> clk_cpu_set_rate function in arch/arm/mach-imx/clk-imx51-imx53.c.
*ping*
Thanks,
-- Christoph
On Fri, May 18, 2012 at 12:42:05AM +0200, Christoph Fritz wrote:
> On Thu, May 17, 2012 at 08:40:58PM +0200, Christoph Fritz wrote:
> > On Thu, 2012-05-17 at 20:20 +0200, Sascha Hauer wrote:
> > > On Thu, May 17, 2012 at 07:49:20PM +0200, Christoph Fritz wrote:
> >
> > > > Is there already a version I can rebase the patch?
> > > >
> > > > On your repo at git://git.pengutronix.de/git/imx/linux-2.6.git I can't
> > > > find the new clock framework or even a work-in-progress version.
> > >
> > > They are in linux-next now.
>
> There changed a lot of stuff: Where should I register the function to
> set/get the cpu frequency?
>
> To get an idea of how it should be done, I looked at imx51: Is there
> cpufreq-support still implemented/working? I can see the
> arch/arm/mach-imx/cpu_op-mx51.c but not its correlating
> clk_cpu_set_rate function in arch/arm/mach-imx/clk-imx51-imx53.c.
>From what I see there must be a clkdev registered for the cpu clock.
Seems this got lost during conversion to the generic clock framework.
in arch/arm/plat-mxc/cpufreq.c:
cpu_clk = clk_get(NULL, "cpu_clk");
should be:
cpu_clk = clk_get(NULL, "cpu");
I don't know if that's enough though.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |