Vishwanath,<div><br></div><div>Thanks for suggestion.</div><div>Voltage change is not a must for frequency change, and it can be integrate in after regulator driver is ready for mx51.</div><div><br></div><div>Yong<br><br><div class="gmail_quote">
On Tue, Oct 19, 2010 at 5:18 PM, Vishwanath Sripathy <span dir="ltr">&lt;<a href="mailto:vishwanath.sripathy@linaro.org">vishwanath.sripathy@linaro.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="gmail_quote">Yong,</div><div class="im"><div class="gmail_quote"><br></div><div class="gmail_quote">&gt;On Mon, Oct 18, 2010 at 1:51 PM, &lt;<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>&gt; wrote:</div>

<div class="gmail_quote">&gt;From: Yong Shen &lt;<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>&gt;</div><div class="gmail_quote"><br></div><div class="gmail_quote">&gt;the operating points are tested on babbage 3.0</div>

</div><div class="gmail_quote">Commit log needs more description like</div><div class="gmail_quote">What are the supported operating points,</div><div class="gmail_quote">Is there any link between mpu OPP and other devices?</div>

<div class="gmail_quote">What are the platforms this patch is tested against</div><div class="gmail_quote">which codebase/tree this patch is based upon</div><div><div></div><div class="h5"><div class="gmail_quote">&gt;</div>
<div class="gmail_quote">&gt;Signed-off-by: Yong Shen &lt;<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>&gt;</div>
<div class="gmail_quote">&gt;---</div><div class="gmail_quote">&gt; arch/arm/Kconfig                       |    6 +</div><div class="gmail_quote">&gt; arch/arm/mach-mx5/Kconfig              |    1 +</div><div class="gmail_quote">

&gt; arch/arm/mach-mx5/Makefile             |    1 +</div><div class="gmail_quote">&gt; arch/arm/mach-mx5/board-mx51_babbage.c |   12 ++-</div><div class="gmail_quote">&gt; arch/arm/mach-mx5/clock-mx51.c         |   22 +++-</div>

<div class="gmail_quote">&gt; arch/arm/mach-mx5/cpu.c                |    2 +</div><div class="gmail_quote">&gt; arch/arm/mach-mx5/cpu_op-mx51.c        |   29 +++++</div><div class="gmail_quote">&gt; arch/arm/mach-mx5/cpu_op-mx51.h        |   14 +++</div>

<div class="gmail_quote">&gt; arch/arm/plat-mxc/Makefile             |    1 +</div><div class="gmail_quote">&gt; arch/arm/plat-mxc/cpufreq.c            |  202 ++++++++++++++++++++++++++++++++</div><div class="gmail_quote">

&gt; arch/arm/plat-mxc/include/mach/mxc.h   |   20 +++-</div><div class="gmail_quote">&gt; 11 files changed, 306 insertions(+), 4 deletions(-)</div><div class="gmail_quote">&gt; create mode 100644 arch/arm/mach-mx5/cpu_op-mx51.c</div>

<div class="gmail_quote">&gt; create mode 100644 arch/arm/mach-mx5/cpu_op-mx51.h</div><div class="gmail_quote">&gt; create mode 100644 arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">

&gt;diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig</div><div class="gmail_quote">&gt;index e4ea9cb..d9ad605 100644</div><div class="gmail_quote">&gt;--- a/arch/arm/Kconfig</div><div class="gmail_quote">&gt;+++ b/arch/arm/Kconfig</div>

<div class="gmail_quote">&gt;@@ -1692,6 +1692,12 @@ if ARCH_HAS_CPUFREQ</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt; source &quot;drivers/cpufreq/Kconfig&quot;</div><div class="gmail_quote">&gt;</div>

<div class="gmail_quote">&gt;+config CPU_FREQ_IMX</div><div class="gmail_quote">&gt;+       tristate &quot;CPUfreq driver for i.MX CPUs&quot;</div><div class="gmail_quote">&gt;+       depends on ARCH_MXC &amp;&amp; CPU_FREQ</div>

<div class="gmail_quote">&gt;+       help</div><div class="gmail_quote">&gt;+         This enables the CPUfreq driver for i.MX CPUs.</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt; config CPU_FREQ_SA1100</div>

<div class="gmail_quote">&gt;       bool</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">&gt;index 0848db5..7a621b4 100644</div>

<div class="gmail_quote">&gt;--- a/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">&gt;@@ -5,6 +5,7 @@ config ARCH_MX51</div><div class="gmail_quote">

&gt;       default y</div><div class="gmail_quote">&gt;       select MXC_TZIC</div><div class="gmail_quote">&gt;       select ARCH_MXC_IOMUX_V3</div><div class="gmail_quote">&gt;+       select ARCH_HAS_CPUFREQ</div><div class="gmail_quote">

&gt;</div><div class="gmail_quote">&gt; comment &quot;MX5 platforms:&quot;</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">

&gt;index 86c66e7..2fadac5 100644</div><div class="gmail_quote">&gt;--- a/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">&gt;@@ -5,6 +5,7 @@</div>

<div class="gmail_quote">&gt; # Object file lists.</div><div class="gmail_quote">&gt; obj-y   := cpu.o mm.o clock-mx51.o devices.o</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;+obj-$(CONFIG_CPU_FREQ_IMX)    += cpu_op-mx51.o</div>

<div class="gmail_quote">&gt; obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o</div><div class="gmail_quote">&gt; obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o</div><div class="gmail_quote">&gt; obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o</div>

<div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c</div><div class="gmail_quote">&gt;index 6e384d9..74c796f 100644</div><div class="gmail_quote">&gt;--- a/arch/arm/mach-mx5/board-mx51_babbage.c</div>

<div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/board-mx51_babbage.c</div><div class="gmail_quote">&gt;@@ -1,5 +1,5 @@</div><div class="gmail_quote">&gt; /*</div><div class="gmail_quote">&gt;- * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.</div>

<div class="gmail_quote">&gt;+ * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">&gt; * Copyright (C) 2009-2010 Amit Kucheria &lt;<a href="mailto:amit.kucheria@canonical.com" target="_blank">amit.kucheria@canonical.com</a>&gt;</div>

<div class="gmail_quote">&gt; *</div><div class="gmail_quote">&gt; * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">&gt;@@ -32,6 +32,7 @@</div><div class="gmail_quote">&gt; #include &lt;asm/mach/time.h&gt;</div>

<div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt; #include &quot;devices.h&quot;</div><div class="gmail_quote">&gt;+#include &quot;cpu_op-mx51.h&quot;</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">

&gt; #define BABBAGE_USB_HUB_RESET  (0*32 + 7)      /* GPIO_1_7 */</div><div class="gmail_quote">&gt; #define BABBAGE_USBH1_STP      (0*32 + 27)     /* GPIO_1_27 */</div><div class="gmail_quote">&gt;@@ -279,8 +280,17 @@ static struct sys_timer mxc_timer = {</div>

<div class="gmail_quote">&gt;       .init   = mx51_babbage_timer_init,</div><div class="gmail_quote">&gt; };</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;+static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags,</div>

<div class="gmail_quote">&gt;+                                  char **cmdline, struct meminfo *mi)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+#if defined(CONFIG_CPU_FREQ_IMX)</div><div class="gmail_quote">

&gt;+       get_cpu_op = mx51_get_cpu_op;</div><div class="gmail_quote">&gt;+#endif</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt; MACHINE_START(MX51_BABBAGE, &quot;Freescale MX51 Babbage Board&quot;)</div>

<div class="gmail_quote">&gt;       /* Maintainer: Amit Kucheria &lt;<a href="mailto:amit.kucheria@canonical.com" target="_blank">amit.kucheria@canonical.com</a>&gt; */</div><div class="gmail_quote">&gt;+       .fixup = fixup_mxc_board,</div>

<div class="gmail_quote">&gt;       .phys_io = MX51_AIPS1_BASE_ADDR,</div><div class="gmail_quote">&gt;       .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) &gt;&gt; 18) &amp; 0xfffc,</div><div class="gmail_quote">&gt;       .boot_params = PHYS_OFFSET + 0x100,</div>

<div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c</div><div class="gmail_quote">&gt;index 6af69de..f89d8a0 100644</div><div class="gmail_quote">&gt;--- a/arch/arm/mach-mx5/clock-mx51.c</div>

<div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/clock-mx51.c</div><div class="gmail_quote">&gt;@@ -330,7 +330,7 @@ static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)</div><div class="gmail_quote">

&gt;       return 0;</div><div class="gmail_quote">&gt; }</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;-static unsigned long clk_arm_get_rate(struct clk *clk)</div><div class="gmail_quote">&gt;+static unsigned long clk_cpu_get_rate(struct clk *clk)</div>

<div class="gmail_quote">&gt; {</div><div class="gmail_quote">&gt;       u32 cacrr, div;</div><div class="gmail_quote">&gt;       unsigned long parent_rate;</div><div class="gmail_quote">&gt;@@ -342,6 +342,22 @@ static unsigned long clk_arm_get_rate(struct clk *clk)</div>

<div class="gmail_quote">&gt;       return parent_rate / div;</div><div class="gmail_quote">&gt; }</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;+static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)</div>

<div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       u32 reg, cpu_podf;</div><div class="gmail_quote">&gt;+       unsigned long parent_rate;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+       parent_rate = clk_get_rate(clk-&gt;parent);</div><div class="gmail_quote">&gt;+       cpu_podf = parent_rate / rate - 1;</div><div class="gmail_quote">&gt;+       /* use post divider to change freq */</div><div class="gmail_quote">

&gt;+       reg = __raw_readl(MXC_CCM_CACRR);</div><div class="gmail_quote">&gt;+       reg &amp;= ~MXC_CCM_CACRR_ARM_PODF_MASK;</div><div class="gmail_quote">&gt;+       reg |= cpu_podf &lt;&lt; MXC_CCM_CACRR_ARM_PODF_OFFSET;</div>

<div class="gmail_quote">&gt;+       __raw_writel(reg, MXC_CCM_CACRR);</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       return 0;</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">

&gt;+</div><div class="gmail_quote">&gt; static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)</div><div class="gmail_quote">&gt; {</div><div class="gmail_quote">&gt;       u32 reg, mux;</div><div class="gmail_quote">

&gt;@@ -693,7 +709,8 @@ static struct clk periph_apm_clk = {</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt; static struct clk cpu_clk = {</div><div class="gmail_quote">&gt;       .parent = &amp;pll1_sw_clk,</div>

<div class="gmail_quote">&gt;-       .get_rate = clk_arm_get_rate,</div><div class="gmail_quote">&gt;+       .get_rate = clk_cpu_get_rate,</div><div class="gmail_quote">&gt;+       .set_rate = clk_cpu_set_rate,</div><div class="gmail_quote">

&gt; };</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt; static struct clk ahb_clk = {</div><div class="gmail_quote">&gt;@@ -837,6 +854,7 @@ static struct clk_lookup lookups[] = {</div><div class="gmail_quote">

&gt;       _REGISTER_CLOCK(&quot;fsl-usb2-udc&quot;, &quot;usb&quot;, usboh3_clk)</div><div class="gmail_quote">&gt;       _REGISTER_CLOCK(&quot;fsl-usb2-udc&quot;, &quot;usb_ahb&quot;, ahb_clk)</div><div class="gmail_quote">

&gt;       _REGISTER_CLOCK(&quot;imx-keypad.0&quot;, NULL, kpp_clk)</div><div class="gmail_quote">&gt;+       _REGISTER_CLOCK(NULL, &quot;cpu_clk&quot;, cpu_clk)</div><div class="gmail_quote">&gt; };</div><div class="gmail_quote">

&gt;</div><div class="gmail_quote">&gt; static void clk_tree_init(void)</div><div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/cpu.c b/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">&gt;index 2d37785..f3fe51a 100644</div>

<div class="gmail_quote">&gt;--- a/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">&gt;@@ -22,6 +22,8 @@ static int cpu_silicon_rev = -1;</div><div class="gmail_quote">

&gt;</div><div class="gmail_quote">&gt; #define SI_REV 0x48</div><div class="gmail_quote">&gt;</div><div class="gmail_quote">&gt;+struct cpu_op *(*get_cpu_op)(int *op);</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt; static void query_silicon_parameter(void)</div><div class="gmail_quote">&gt; {</div><div class="gmail_quote">&gt;       void __iomem *rom = ioremap(MX51_IROM_BASE_ADDR, MX51_IROM_SIZE);</div><div class="gmail_quote">

&gt;diff --git a/arch/arm/mach-mx5/cpu_op-mx51.c b/arch/arm/mach-mx5/cpu_op-mx51.c</div><div class="gmail_quote">&gt;new file mode 100644</div><div class="gmail_quote">&gt;index 0000000..9d34c3d</div><div class="gmail_quote">

&gt;--- /dev/null</div><div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/cpu_op-mx51.c</div><div class="gmail_quote">&gt;@@ -0,0 +1,29 @@</div><div class="gmail_quote">&gt;+/*</div><div class="gmail_quote">&gt;+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>

<div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+/*</div><div class="gmail_quote">&gt;+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">

&gt;+ * License. You may obtain a copy of the GNU General Public License</div><div class="gmail_quote">&gt;+ * Version 2 or later at the following locations:</div><div class="gmail_quote">&gt;+ *</div><div class="gmail_quote">

&gt;+ * <a href="http://www.opensource.org/licenses/gpl-license.html" target="_blank">http://www.opensource.org/licenses/gpl-license.html</a></div><div class="gmail_quote">&gt;+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div>

<div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+#include &lt;linux/types.h&gt;</div><div class="gmail_quote">&gt;+#include &lt;mach/hardware.h&gt;</div><div class="gmail_quote">

&gt;+#include &lt;linux/kernel.h&gt;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static struct cpu_op mx51_cpu_op[] = {</div><div class="gmail_quote">&gt;+       {</div><div class="gmail_quote">

&gt;+       .cpu_rate = 160000000,},</div><div class="gmail_quote">&gt;+       {</div><div class="gmail_quote">&gt;+       .cpu_rate = 800000000,},</div><div class="gmail_quote">&gt;+};</div><div class="gmail_quote">&gt;+</div>

<div class="gmail_quote">&gt;+struct cpu_op *mx51_get_cpu_op(int *op)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       *op = ARRAY_SIZE(mx51_cpu_op);</div><div class="gmail_quote">&gt;+       return mx51_cpu_op;</div>

<div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;diff --git a/arch/arm/mach-mx5/cpu_op-mx51.h b/arch/arm/mach-mx5/cpu_op-mx51.h</div><div class="gmail_quote">&gt;new file mode 100644</div><div class="gmail_quote">

&gt;index 0000000..97477fe</div><div class="gmail_quote">&gt;--- /dev/null</div><div class="gmail_quote">&gt;+++ b/arch/arm/mach-mx5/cpu_op-mx51.h</div><div class="gmail_quote">&gt;@@ -0,0 +1,14 @@</div><div class="gmail_quote">

&gt;+/*</div><div class="gmail_quote">&gt;+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+/*</div><div class="gmail_quote">&gt;+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">&gt;+ * License. You may obtain a copy of the GNU General Public License</div>

<div class="gmail_quote">&gt;+ * Version 2 or later at the following locations:</div><div class="gmail_quote">&gt;+ *</div><div class="gmail_quote">&gt;+ * <a href="http://www.opensource.org/licenses/gpl-license.html" target="_blank">http://www.opensource.org/licenses/gpl-license.html</a></div>

<div class="gmail_quote">&gt;+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div><div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+extern struct cpu_op *mx51_get_cpu_op(int *op);</div><div class="gmail_quote">&gt;diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">&gt;index 78d405e..a833d38 100644</div>

<div class="gmail_quote">&gt;--- a/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">&gt;+++ b/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">&gt;@@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o</div><div class="gmail_quote">

&gt; obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o</div><div class="gmail_quote">&gt; obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o</div><div class="gmail_quote">&gt; obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o</div>

<div class="gmail_quote">&gt;+obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o</div><div class="gmail_quote">&gt; ifdef CONFIG_SND_IMX_SOC</div><div class="gmail_quote">&gt; obj-y += ssi-fiq.o</div><div class="gmail_quote">&gt; obj-y += ssi-fiq-ksym.o</div>

<div class="gmail_quote">&gt;diff --git a/arch/arm/plat-mxc/cpufreq.c b/arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">&gt;new file mode 100644</div><div class="gmail_quote">&gt;index 0000000..9cabeb9</div><div class="gmail_quote">

&gt;--- /dev/null</div><div class="gmail_quote">&gt;+++ b/arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">&gt;@@ -0,0 +1,202 @@</div><div class="gmail_quote">&gt;+/*</div><div class="gmail_quote">&gt;+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>

<div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+/*</div><div class="gmail_quote">&gt;+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">

&gt;+ * License. You may obtain a copy of the GNU General Public License</div><div class="gmail_quote">&gt;+ * Version 2 or later at the following locations:</div><div class="gmail_quote">&gt;+ *</div><div class="gmail_quote">

&gt;+ * <a href="http://www.opensource.org/licenses/gpl-license.html" target="_blank">http://www.opensource.org/licenses/gpl-license.html</a></div><div class="gmail_quote">&gt;+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div>

<div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+/*</div><div class="gmail_quote">&gt;+ * A driver for the Freescale Semiconductor i.MXC CPUfreq module.</div><div class="gmail_quote">

&gt;+ * The CPUFREQ driver is for controling CPU frequency. It allows you to change</div><div class="gmail_quote">&gt;+ * the CPU clock speed on the fly.</div><div class="gmail_quote">&gt;+ */</div><div class="gmail_quote">

&gt;+</div><div class="gmail_quote">&gt;+#include &lt;linux/cpufreq.h&gt;</div><div class="gmail_quote">&gt;+#include &lt;linux/clk.h&gt;</div><div class="gmail_quote">&gt;+#include &lt;linux/err.h&gt;</div><div class="gmail_quote">

&gt;+#include &lt;linux/slab.h&gt;</div><div class="gmail_quote">&gt;+#include &lt;mach/hardware.h&gt;</div><div class="gmail_quote">&gt;+#include &lt;mach/clock.h&gt;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+#define CLK32_FREQ     32768</div><div class="gmail_quote">&gt;+#define NANOSECOND     (1000 * 1000 * 1000)</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int cpu_freq_khz_min;</div><div class="gmail_quote">

&gt;+static int cpu_freq_khz_max;</div><div class="gmail_quote">&gt;+static int arm_normal_clk;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static struct clk *cpu_clk;</div><div class="gmail_quote">

&gt;+static struct cpufreq_frequency_table *imx_freq_table;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int cpu_op_nr;</div><div class="gmail_quote">&gt;+static struct cpu_op *cpu_op_tbl;</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int set_cpu_freq(int freq)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       int ret = 0;</div><div class="gmail_quote">

&gt;+       int org_cpu_rate;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       org_cpu_rate = clk_get_rate(cpu_clk);</div><div class="gmail_quote">&gt;+       if (org_cpu_rate == freq)</div><div class="gmail_quote">

&gt;+               return ret;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       ret = clk_set_rate(cpu_clk, freq);</div><div class="gmail_quote">&gt;+       if (ret != 0) {</div><div class="gmail_quote">

&gt;+               printk(KERN_DEBUG &quot;cannot set CPU clock rate\n&quot;);</div><div class="gmail_quote">&gt;+               return ret;</div><div class="gmail_quote">&gt;+       }</div><div class="gmail_quote">&gt;+</div>

<div class="gmail_quote">&gt;+       return ret;</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int mxc_verify_speed(struct cpufreq_policy *policy)</div>

<div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       if (policy-&gt;cpu != 0)</div><div class="gmail_quote">&gt;+               return -EINVAL;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+       return cpufreq_frequency_table_verify(policy, imx_freq_table);</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static unsigned int mxc_get_speed(unsigned int cpu)</div>

<div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       if (cpu)</div><div class="gmail_quote">&gt;+               return 0;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       return clk_get_rate(cpu_clk) / 1000;</div>

<div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int mxc_set_target(struct cpufreq_policy *policy,</div><div class="gmail_quote">&gt;+                         unsigned int target_freq, unsigned int relation)</div>

<div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       struct cpufreq_freqs freqs;</div><div class="gmail_quote">&gt;+       int freq_Hz;</div><div class="gmail_quote">&gt;+       int ret = 0;</div><div class="gmail_quote">

&gt;+       unsigned int index;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       cpufreq_frequency_table_target(policy, imx_freq_table,</div><div class="gmail_quote">&gt;+                       target_freq, relation, &amp;index);</div>

<div class="gmail_quote">&gt;+       freq_Hz = imx_freq_table[index].frequency * 1000;</div><div class="gmail_quote"><br></div></div></div><div class="gmail_quote">Is it not needed to scale voltage also along with frequency?</div>
<div class="gmail_quote">
<br></div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       freqs.old = clk_get_rate(cpu_clk) / 1000;</div><div><div></div><div class="h5"><div class="gmail_quote">&gt;+       freqs.new = freq_Hz / 1000;</div>
<div class="gmail_quote">
&gt;+       freqs.cpu = 0;</div><div class="gmail_quote">&gt;+       freqs.flags = 0;</div><div class="gmail_quote">&gt;+       cpufreq_notify_transition(&amp;freqs, CPUFREQ_PRECHANGE);</div><div class="gmail_quote">&gt;+</div>

<div class="gmail_quote">&gt;+       if (freqs.old != freqs.new)</div><div class="gmail_quote">&gt;+               ret = set_cpu_freq(freq_Hz);</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       cpufreq_notify_transition(&amp;freqs, CPUFREQ_POSTCHANGE);</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       return ret;</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static int __init mxc_cpufreq_init(struct cpufreq_policy *policy)</div>

<div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       int ret;</div><div class="gmail_quote">&gt;+       int i;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       printk(KERN_INFO &quot;i.MXC CPU frequency driver\n&quot;);</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       if (policy-&gt;cpu != 0)</div><div class="gmail_quote">&gt;+               return -EINVAL;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+       cpu_clk = clk_get(NULL, &quot;cpu_clk&quot;);</div><div class="gmail_quote">&gt;+       if (IS_ERR(cpu_clk)) {</div><div class="gmail_quote">&gt;+               printk(KERN_ERR &quot;%s: failed to get cpu clock\n&quot;, __func__);</div>

<div class="gmail_quote">&gt;+               return PTR_ERR(cpu_clk);</div><div class="gmail_quote">&gt;+       }</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       cpu_op_tbl = get_cpu_op(&amp;cpu_op_nr);</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       cpu_freq_khz_min = cpu_op_tbl[0].cpu_rate / 1000;</div><div class="gmail_quote">&gt;+       cpu_freq_khz_max = cpu_op_tbl[0].cpu_rate / 1000;</div>
<div class="gmail_quote">
&gt;+</div><div class="gmail_quote">&gt;+       imx_freq_table = kmalloc(</div><div class="gmail_quote">&gt;+               sizeof(struct cpufreq_frequency_table) * (cpu_op_nr + 1),</div><div class="gmail_quote">&gt;+                       GFP_KERNEL);</div>

<div class="gmail_quote">&gt;+       if (!imx_freq_table) {</div><div class="gmail_quote">&gt;+               clk_put(cpu_clk);</div><div class="gmail_quote">&gt;+               return -ENOMEM;</div><div class="gmail_quote">

&gt;+       }</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       for (i = 0; i &lt; cpu_op_nr; i++) {</div><div class="gmail_quote">&gt;+               imx_freq_table[i].index = i;</div><div class="gmail_quote">

&gt;+               imx_freq_table[i].frequency =</div><div class="gmail_quote">&gt;+                   cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+               if ((cpu_op_tbl[i].cpu_rate / 1000) &lt; cpu_freq_khz_min)</div>

<div class="gmail_quote">&gt;+                       cpu_freq_khz_min = cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+               if ((cpu_op_tbl[i].cpu_rate / 1000) &gt; cpu_freq_khz_max)</div>

<div class="gmail_quote">&gt;+                       cpu_freq_khz_max = cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">&gt;+       }</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       imx_freq_table[i].index = i;</div>

<div class="gmail_quote">&gt;+       imx_freq_table[i].frequency = CPUFREQ_TABLE_END;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       policy-&gt;cur = clk_get_rate(cpu_clk) / 1000;</div><div class="gmail_quote">

&gt;+       policy-&gt;governor = CPUFREQ_DEFAULT_GOVERNOR;</div><div class="gmail_quote">&gt;+       policy-&gt;min = policy-&gt;cpuinfo.min_freq = cpu_freq_khz_min;</div><div class="gmail_quote">&gt;+       policy-&gt;max = policy-&gt;cpuinfo.max_freq = cpu_freq_khz_max;</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       arm_normal_clk = cpu_freq_khz_max * 1000;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       /* Manual states, that PLL stabilizes in two CLK32 periods */</div>

<div class="gmail_quote">&gt;+       policy-&gt;cpuinfo.transition_latency = 2 / CLK32_FREQ * NANOSECOND;</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       ret = cpufreq_frequency_table_cpuinfo(policy, imx_freq_table);</div>

<div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+       if (ret &lt; 0) {</div><div class="gmail_quote">&gt;+               clk_put(cpu_clk);</div><div class="gmail_quote">&gt;+               printk(KERN_ERR &quot;%s: failed to register i.MXC CPUfreq\n&quot;,</div>

<div class="gmail_quote">&gt;+                      __func__);</div><div class="gmail_quote">&gt;+               return ret;</div><div class="gmail_quote">&gt;+       }</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+       cpufreq_frequency_table_get_attr(imx_freq_table, policy-&gt;cpu);</div><div class="gmail_quote">&gt;+       return 0;</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt;+static int mxc_cpufreq_exit(struct cpufreq_policy *policy)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       cpufreq_frequency_table_put_attr(policy-&gt;cpu);</div><div class="gmail_quote">

&gt;+</div><div class="gmail_quote">&gt;+       set_cpu_freq(arm_normal_clk);</div><div class="gmail_quote">&gt;+       clk_put(cpu_clk);</div><div class="gmail_quote">&gt;+       kfree(imx_freq_table);</div><div class="gmail_quote">

&gt;+       return 0;</div><div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static struct cpufreq_driver mxc_driver = {</div><div class="gmail_quote">&gt;+       .flags = CPUFREQ_STICKY,</div>

<div class="gmail_quote">&gt;+       .verify = mxc_verify_speed,</div><div class="gmail_quote">&gt;+       .target = mxc_set_target,</div><div class="gmail_quote">&gt;+       .get = mxc_get_speed,</div><div class="gmail_quote">

&gt;+       .init = mxc_cpufreq_init,</div><div class="gmail_quote">&gt;+       .exit = mxc_cpufreq_exit,</div><div class="gmail_quote">&gt;+       .name = &quot;imx&quot;,</div><div class="gmail_quote">&gt;+};</div><div class="gmail_quote">

&gt;+</div><div class="gmail_quote">&gt;+static int __devinit mxc_cpufreq_driver_init(void)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       return cpufreq_register_driver(&amp;mxc_driver);</div>

<div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+static void mxc_cpufreq_driver_exit(void)</div><div class="gmail_quote">&gt;+{</div><div class="gmail_quote">&gt;+       cpufreq_unregister_driver(&amp;mxc_driver);</div>

<div class="gmail_quote">&gt;+}</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+module_init(mxc_cpufreq_driver_init);</div><div class="gmail_quote">&gt;+module_exit(mxc_cpufreq_driver_exit);</div><div class="gmail_quote">

&gt;+</div><div class="gmail_quote">&gt;+MODULE_AUTHOR(&quot;Freescale Semiconductor Inc. Yong Shen &lt;<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>&gt;&quot;);</div><div class="gmail_quote">
&gt;+MODULE_DESCRIPTION(&quot;CPUfreq driver for i.MX&quot;);</div>
<div class="gmail_quote">&gt;+MODULE_LICENSE(&quot;GPL&quot;);</div><div class="gmail_quote">&gt;diff --git a/arch/arm/plat-mxc/include/mach/mxc.h b/arch/arm/plat-mxc/include/mach/mxc.h</div><div class="gmail_quote">&gt;index a790bf2..888dddc 100644</div>

<div class="gmail_quote">&gt;--- a/arch/arm/plat-mxc/include/mach/mxc.h</div><div class="gmail_quote">&gt;+++ b/arch/arm/plat-mxc/include/mach/mxc.h</div><div class="gmail_quote">&gt;@@ -1,5 +1,5 @@</div><div class="gmail_quote">

&gt; /*</div><div class="gmail_quote">&gt;- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">&gt;+ * Copyright 2004-2007, 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>

<div class="gmail_quote">&gt; * Copyright (C) 2008 Juergen Beisert (<a href="mailto:kernel@pengutronix.de" target="_blank">kernel@pengutronix.de</a>)</div><div class="gmail_quote">&gt; *</div><div class="gmail_quote">&gt; * This program is free software; you can redistribute it and/or</div>

<div class="gmail_quote">&gt;@@ -133,6 +133,24 @@ extern unsigned int __mxc_cpu_type;</div><div class="gmail_quote">&gt; # define cpu_is_mxc91231()     (0)</div><div class="gmail_quote">&gt; #endif</div><div class="gmail_quote">

&gt;</div><div class="gmail_quote">&gt;+#ifndef __ASSEMBLY__</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+struct cpu_op {</div><div class="gmail_quote">&gt;+       u32 pll_reg;</div><div class="gmail_quote">

&gt;+       u32 pll_rate;</div><div class="gmail_quote">&gt;+       u32 cpu_rate;</div><div class="gmail_quote">&gt;+       u32 pdr0_reg;</div><div class="gmail_quote">&gt;+       u32 pdf;</div><div class="gmail_quote">&gt;+       u32 mfi;</div>

<div class="gmail_quote">&gt;+       u32 mfd;</div><div class="gmail_quote">&gt;+       u32 mfn;</div><div class="gmail_quote">&gt;+       u32 cpu_voltage;</div><div class="gmail_quote">&gt;+       u32 cpu_podf;</div><div class="gmail_quote">

&gt;+};</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">&gt;+extern struct cpu_op *(*get_cpu_op)(int *op);</div><div class="gmail_quote">&gt;+#endif</div><div class="gmail_quote">&gt;+</div><div class="gmail_quote">

&gt; #if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2)</div><div class="gmail_quote">&gt; /* These are deprecated, use mx[23][157]_setup_weimcs instead. */</div><div class="gmail_quote">&gt; #define CSCR_U(n) (IO_ADDRESS(WEIM_BASE_ADDR + n * 0x10))</div>

<div class="gmail_quote">&gt;--</div><div class="gmail_quote">&gt;1.6.3.3</div><div class="gmail_quote">&gt;</div></div></div></div>
</blockquote></div><br></div>