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"><<a href="mailto:vishwanath.sripathy@linaro.org">vishwanath.sripathy@linaro.org</a>></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">>On Mon, Oct 18, 2010 at 1:51 PM, <<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>> wrote:</div>
<div class="gmail_quote">>From: Yong Shen <<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>></div><div class="gmail_quote"><br></div><div class="gmail_quote">>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">></div>
<div class="gmail_quote">>Signed-off-by: Yong Shen <<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>></div>
<div class="gmail_quote">>---</div><div class="gmail_quote">> arch/arm/Kconfig | 6 +</div><div class="gmail_quote">> arch/arm/mach-mx5/Kconfig | 1 +</div><div class="gmail_quote">
> arch/arm/mach-mx5/Makefile | 1 +</div><div class="gmail_quote">> arch/arm/mach-mx5/board-mx51_babbage.c | 12 ++-</div><div class="gmail_quote">> arch/arm/mach-mx5/clock-mx51.c | 22 +++-</div>
<div class="gmail_quote">> arch/arm/mach-mx5/cpu.c | 2 +</div><div class="gmail_quote">> arch/arm/mach-mx5/cpu_op-mx51.c | 29 +++++</div><div class="gmail_quote">> arch/arm/mach-mx5/cpu_op-mx51.h | 14 +++</div>
<div class="gmail_quote">> arch/arm/plat-mxc/Makefile | 1 +</div><div class="gmail_quote">> arch/arm/plat-mxc/cpufreq.c | 202 ++++++++++++++++++++++++++++++++</div><div class="gmail_quote">
> arch/arm/plat-mxc/include/mach/mxc.h | 20 +++-</div><div class="gmail_quote">> 11 files changed, 306 insertions(+), 4 deletions(-)</div><div class="gmail_quote">> create mode 100644 arch/arm/mach-mx5/cpu_op-mx51.c</div>
<div class="gmail_quote">> create mode 100644 arch/arm/mach-mx5/cpu_op-mx51.h</div><div class="gmail_quote">> create mode 100644 arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">></div><div class="gmail_quote">
>diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig</div><div class="gmail_quote">>index e4ea9cb..d9ad605 100644</div><div class="gmail_quote">>--- a/arch/arm/Kconfig</div><div class="gmail_quote">>+++ b/arch/arm/Kconfig</div>
<div class="gmail_quote">>@@ -1692,6 +1692,12 @@ if ARCH_HAS_CPUFREQ</div><div class="gmail_quote">></div><div class="gmail_quote">> source "drivers/cpufreq/Kconfig"</div><div class="gmail_quote">></div>
<div class="gmail_quote">>+config CPU_FREQ_IMX</div><div class="gmail_quote">>+ tristate "CPUfreq driver for i.MX CPUs"</div><div class="gmail_quote">>+ depends on ARCH_MXC && CPU_FREQ</div>
<div class="gmail_quote">>+ help</div><div class="gmail_quote">>+ This enables the CPUfreq driver for i.MX CPUs.</div><div class="gmail_quote">>+</div><div class="gmail_quote">> config CPU_FREQ_SA1100</div>
<div class="gmail_quote">> bool</div><div class="gmail_quote">></div><div class="gmail_quote">>diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">>index 0848db5..7a621b4 100644</div>
<div class="gmail_quote">>--- a/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">>+++ b/arch/arm/mach-mx5/Kconfig</div><div class="gmail_quote">>@@ -5,6 +5,7 @@ config ARCH_MX51</div><div class="gmail_quote">
> default y</div><div class="gmail_quote">> select MXC_TZIC</div><div class="gmail_quote">> select ARCH_MXC_IOMUX_V3</div><div class="gmail_quote">>+ select ARCH_HAS_CPUFREQ</div><div class="gmail_quote">
></div><div class="gmail_quote">> comment "MX5 platforms:"</div><div class="gmail_quote">></div><div class="gmail_quote">>diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">
>index 86c66e7..2fadac5 100644</div><div class="gmail_quote">>--- a/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">>+++ b/arch/arm/mach-mx5/Makefile</div><div class="gmail_quote">>@@ -5,6 +5,7 @@</div>
<div class="gmail_quote">> # Object file lists.</div><div class="gmail_quote">> obj-y := cpu.o mm.o clock-mx51.o devices.o</div><div class="gmail_quote">></div><div class="gmail_quote">>+obj-$(CONFIG_CPU_FREQ_IMX) += cpu_op-mx51.o</div>
<div class="gmail_quote">> obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o</div><div class="gmail_quote">> obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o</div><div class="gmail_quote">> obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o</div>
<div class="gmail_quote">>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">>index 6e384d9..74c796f 100644</div><div class="gmail_quote">>--- a/arch/arm/mach-mx5/board-mx51_babbage.c</div>
<div class="gmail_quote">>+++ b/arch/arm/mach-mx5/board-mx51_babbage.c</div><div class="gmail_quote">>@@ -1,5 +1,5 @@</div><div class="gmail_quote">> /*</div><div class="gmail_quote">>- * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.</div>
<div class="gmail_quote">>+ * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">> * Copyright (C) 2009-2010 Amit Kucheria <<a href="mailto:amit.kucheria@canonical.com" target="_blank">amit.kucheria@canonical.com</a>></div>
<div class="gmail_quote">> *</div><div class="gmail_quote">> * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">>@@ -32,6 +32,7 @@</div><div class="gmail_quote">> #include <asm/mach/time.h></div>
<div class="gmail_quote">></div><div class="gmail_quote">> #include "devices.h"</div><div class="gmail_quote">>+#include "cpu_op-mx51.h"</div><div class="gmail_quote">></div><div class="gmail_quote">
> #define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */</div><div class="gmail_quote">> #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */</div><div class="gmail_quote">>@@ -279,8 +280,17 @@ static struct sys_timer mxc_timer = {</div>
<div class="gmail_quote">> .init = mx51_babbage_timer_init,</div><div class="gmail_quote">> };</div><div class="gmail_quote">></div><div class="gmail_quote">>+static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags,</div>
<div class="gmail_quote">>+ char **cmdline, struct meminfo *mi)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+#if defined(CONFIG_CPU_FREQ_IMX)</div><div class="gmail_quote">
>+ get_cpu_op = mx51_get_cpu_op;</div><div class="gmail_quote">>+#endif</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">> MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board")</div>
<div class="gmail_quote">> /* Maintainer: Amit Kucheria <<a href="mailto:amit.kucheria@canonical.com" target="_blank">amit.kucheria@canonical.com</a>> */</div><div class="gmail_quote">>+ .fixup = fixup_mxc_board,</div>
<div class="gmail_quote">> .phys_io = MX51_AIPS1_BASE_ADDR,</div><div class="gmail_quote">> .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,</div><div class="gmail_quote">> .boot_params = PHYS_OFFSET + 0x100,</div>
<div class="gmail_quote">>diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c</div><div class="gmail_quote">>index 6af69de..f89d8a0 100644</div><div class="gmail_quote">>--- a/arch/arm/mach-mx5/clock-mx51.c</div>
<div class="gmail_quote">>+++ b/arch/arm/mach-mx5/clock-mx51.c</div><div class="gmail_quote">>@@ -330,7 +330,7 @@ static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)</div><div class="gmail_quote">
> return 0;</div><div class="gmail_quote">> }</div><div class="gmail_quote">></div><div class="gmail_quote">>-static unsigned long clk_arm_get_rate(struct clk *clk)</div><div class="gmail_quote">>+static unsigned long clk_cpu_get_rate(struct clk *clk)</div>
<div class="gmail_quote">> {</div><div class="gmail_quote">> u32 cacrr, div;</div><div class="gmail_quote">> unsigned long parent_rate;</div><div class="gmail_quote">>@@ -342,6 +342,22 @@ static unsigned long clk_arm_get_rate(struct clk *clk)</div>
<div class="gmail_quote">> return parent_rate / div;</div><div class="gmail_quote">> }</div><div class="gmail_quote">></div><div class="gmail_quote">>+static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)</div>
<div class="gmail_quote">>+{</div><div class="gmail_quote">>+ u32 reg, cpu_podf;</div><div class="gmail_quote">>+ unsigned long parent_rate;</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+ parent_rate = clk_get_rate(clk->parent);</div><div class="gmail_quote">>+ cpu_podf = parent_rate / rate - 1;</div><div class="gmail_quote">>+ /* use post divider to change freq */</div><div class="gmail_quote">
>+ reg = __raw_readl(MXC_CCM_CACRR);</div><div class="gmail_quote">>+ reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK;</div><div class="gmail_quote">>+ reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET;</div>
<div class="gmail_quote">>+ __raw_writel(reg, MXC_CCM_CACRR);</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ return 0;</div><div class="gmail_quote">>+}</div><div class="gmail_quote">
>+</div><div class="gmail_quote">> static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)</div><div class="gmail_quote">> {</div><div class="gmail_quote">> u32 reg, mux;</div><div class="gmail_quote">
>@@ -693,7 +709,8 @@ static struct clk periph_apm_clk = {</div><div class="gmail_quote">></div><div class="gmail_quote">> static struct clk cpu_clk = {</div><div class="gmail_quote">> .parent = &pll1_sw_clk,</div>
<div class="gmail_quote">>- .get_rate = clk_arm_get_rate,</div><div class="gmail_quote">>+ .get_rate = clk_cpu_get_rate,</div><div class="gmail_quote">>+ .set_rate = clk_cpu_set_rate,</div><div class="gmail_quote">
> };</div><div class="gmail_quote">></div><div class="gmail_quote">> static struct clk ahb_clk = {</div><div class="gmail_quote">>@@ -837,6 +854,7 @@ static struct clk_lookup lookups[] = {</div><div class="gmail_quote">
> _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)</div><div class="gmail_quote">> _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)</div><div class="gmail_quote">
> _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk)</div><div class="gmail_quote">>+ _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)</div><div class="gmail_quote">> };</div><div class="gmail_quote">
></div><div class="gmail_quote">> static void clk_tree_init(void)</div><div class="gmail_quote">>diff --git a/arch/arm/mach-mx5/cpu.c b/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">>index 2d37785..f3fe51a 100644</div>
<div class="gmail_quote">>--- a/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">>+++ b/arch/arm/mach-mx5/cpu.c</div><div class="gmail_quote">>@@ -22,6 +22,8 @@ static int cpu_silicon_rev = -1;</div><div class="gmail_quote">
></div><div class="gmail_quote">> #define SI_REV 0x48</div><div class="gmail_quote">></div><div class="gmail_quote">>+struct cpu_op *(*get_cpu_op)(int *op);</div><div class="gmail_quote">>+</div><div class="gmail_quote">
> static void query_silicon_parameter(void)</div><div class="gmail_quote">> {</div><div class="gmail_quote">> void __iomem *rom = ioremap(MX51_IROM_BASE_ADDR, MX51_IROM_SIZE);</div><div class="gmail_quote">
>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">>new file mode 100644</div><div class="gmail_quote">>index 0000000..9d34c3d</div><div class="gmail_quote">
>--- /dev/null</div><div class="gmail_quote">>+++ b/arch/arm/mach-mx5/cpu_op-mx51.c</div><div class="gmail_quote">>@@ -0,0 +1,29 @@</div><div class="gmail_quote">>+/*</div><div class="gmail_quote">>+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>
<div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+/*</div><div class="gmail_quote">>+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">
>+ * License. You may obtain a copy of the GNU General Public License</div><div class="gmail_quote">>+ * Version 2 or later at the following locations:</div><div class="gmail_quote">>+ *</div><div class="gmail_quote">
>+ * <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">>+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div>
<div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+#include <linux/types.h></div><div class="gmail_quote">>+#include <mach/hardware.h></div><div class="gmail_quote">
>+#include <linux/kernel.h></div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static struct cpu_op mx51_cpu_op[] = {</div><div class="gmail_quote">>+ {</div><div class="gmail_quote">
>+ .cpu_rate = 160000000,},</div><div class="gmail_quote">>+ {</div><div class="gmail_quote">>+ .cpu_rate = 800000000,},</div><div class="gmail_quote">>+};</div><div class="gmail_quote">>+</div>
<div class="gmail_quote">>+struct cpu_op *mx51_get_cpu_op(int *op)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+ *op = ARRAY_SIZE(mx51_cpu_op);</div><div class="gmail_quote">>+ return mx51_cpu_op;</div>
<div class="gmail_quote">>+}</div><div class="gmail_quote">>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">>new file mode 100644</div><div class="gmail_quote">
>index 0000000..97477fe</div><div class="gmail_quote">>--- /dev/null</div><div class="gmail_quote">>+++ b/arch/arm/mach-mx5/cpu_op-mx51.h</div><div class="gmail_quote">>@@ -0,0 +1,14 @@</div><div class="gmail_quote">
>+/*</div><div class="gmail_quote">>+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+/*</div><div class="gmail_quote">>+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">>+ * License. You may obtain a copy of the GNU General Public License</div>
<div class="gmail_quote">>+ * Version 2 or later at the following locations:</div><div class="gmail_quote">>+ *</div><div class="gmail_quote">>+ * <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">>+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div><div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+extern struct cpu_op *mx51_get_cpu_op(int *op);</div><div class="gmail_quote">>diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">>index 78d405e..a833d38 100644</div>
<div class="gmail_quote">>--- a/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">>+++ b/arch/arm/plat-mxc/Makefile</div><div class="gmail_quote">>@@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o</div><div class="gmail_quote">
> obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o</div><div class="gmail_quote">> obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o</div><div class="gmail_quote">> obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o</div>
<div class="gmail_quote">>+obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o</div><div class="gmail_quote">> ifdef CONFIG_SND_IMX_SOC</div><div class="gmail_quote">> obj-y += ssi-fiq.o</div><div class="gmail_quote">> obj-y += ssi-fiq-ksym.o</div>
<div class="gmail_quote">>diff --git a/arch/arm/plat-mxc/cpufreq.c b/arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">>new file mode 100644</div><div class="gmail_quote">>index 0000000..9cabeb9</div><div class="gmail_quote">
>--- /dev/null</div><div class="gmail_quote">>+++ b/arch/arm/plat-mxc/cpufreq.c</div><div class="gmail_quote">>@@ -0,0 +1,202 @@</div><div class="gmail_quote">>+/*</div><div class="gmail_quote">>+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>
<div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+/*</div><div class="gmail_quote">>+ * The code contained herein is licensed under the GNU General Public</div><div class="gmail_quote">
>+ * License. You may obtain a copy of the GNU General Public License</div><div class="gmail_quote">>+ * Version 2 or later at the following locations:</div><div class="gmail_quote">>+ *</div><div class="gmail_quote">
>+ * <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">>+ * <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a></div>
<div class="gmail_quote">>+ */</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+/*</div><div class="gmail_quote">>+ * A driver for the Freescale Semiconductor i.MXC CPUfreq module.</div><div class="gmail_quote">
>+ * The CPUFREQ driver is for controling CPU frequency. It allows you to change</div><div class="gmail_quote">>+ * the CPU clock speed on the fly.</div><div class="gmail_quote">>+ */</div><div class="gmail_quote">
>+</div><div class="gmail_quote">>+#include <linux/cpufreq.h></div><div class="gmail_quote">>+#include <linux/clk.h></div><div class="gmail_quote">>+#include <linux/err.h></div><div class="gmail_quote">
>+#include <linux/slab.h></div><div class="gmail_quote">>+#include <mach/hardware.h></div><div class="gmail_quote">>+#include <mach/clock.h></div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+#define CLK32_FREQ 32768</div><div class="gmail_quote">>+#define NANOSECOND (1000 * 1000 * 1000)</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static int cpu_freq_khz_min;</div><div class="gmail_quote">
>+static int cpu_freq_khz_max;</div><div class="gmail_quote">>+static int arm_normal_clk;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static struct clk *cpu_clk;</div><div class="gmail_quote">
>+static struct cpufreq_frequency_table *imx_freq_table;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static int cpu_op_nr;</div><div class="gmail_quote">>+static struct cpu_op *cpu_op_tbl;</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+static int set_cpu_freq(int freq)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+ int ret = 0;</div><div class="gmail_quote">
>+ int org_cpu_rate;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ org_cpu_rate = clk_get_rate(cpu_clk);</div><div class="gmail_quote">>+ if (org_cpu_rate == freq)</div><div class="gmail_quote">
>+ return ret;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ ret = clk_set_rate(cpu_clk, freq);</div><div class="gmail_quote">>+ if (ret != 0) {</div><div class="gmail_quote">
>+ printk(KERN_DEBUG "cannot set CPU clock rate\n");</div><div class="gmail_quote">>+ return ret;</div><div class="gmail_quote">>+ }</div><div class="gmail_quote">>+</div>
<div class="gmail_quote">>+ return ret;</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static int mxc_verify_speed(struct cpufreq_policy *policy)</div>
<div class="gmail_quote">>+{</div><div class="gmail_quote">>+ if (policy->cpu != 0)</div><div class="gmail_quote">>+ return -EINVAL;</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+ return cpufreq_frequency_table_verify(policy, imx_freq_table);</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static unsigned int mxc_get_speed(unsigned int cpu)</div>
<div class="gmail_quote">>+{</div><div class="gmail_quote">>+ if (cpu)</div><div class="gmail_quote">>+ return 0;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ return clk_get_rate(cpu_clk) / 1000;</div>
<div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static int mxc_set_target(struct cpufreq_policy *policy,</div><div class="gmail_quote">>+ unsigned int target_freq, unsigned int relation)</div>
<div class="gmail_quote">>+{</div><div class="gmail_quote">>+ struct cpufreq_freqs freqs;</div><div class="gmail_quote">>+ int freq_Hz;</div><div class="gmail_quote">>+ int ret = 0;</div><div class="gmail_quote">
>+ unsigned int index;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ cpufreq_frequency_table_target(policy, imx_freq_table,</div><div class="gmail_quote">>+ target_freq, relation, &index);</div>
<div class="gmail_quote">>+ 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">>+</div><div class="gmail_quote">>+ freqs.old = clk_get_rate(cpu_clk) / 1000;</div><div><div></div><div class="h5"><div class="gmail_quote">>+ freqs.new = freq_Hz / 1000;</div>
<div class="gmail_quote">
>+ freqs.cpu = 0;</div><div class="gmail_quote">>+ freqs.flags = 0;</div><div class="gmail_quote">>+ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);</div><div class="gmail_quote">>+</div>
<div class="gmail_quote">>+ if (freqs.old != freqs.new)</div><div class="gmail_quote">>+ ret = set_cpu_freq(freq_Hz);</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+ return ret;</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static int __init mxc_cpufreq_init(struct cpufreq_policy *policy)</div>
<div class="gmail_quote">>+{</div><div class="gmail_quote">>+ int ret;</div><div class="gmail_quote">>+ int i;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ printk(KERN_INFO "i.MXC CPU frequency driver\n");</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+ if (policy->cpu != 0)</div><div class="gmail_quote">>+ return -EINVAL;</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+ cpu_clk = clk_get(NULL, "cpu_clk");</div><div class="gmail_quote">>+ if (IS_ERR(cpu_clk)) {</div><div class="gmail_quote">>+ printk(KERN_ERR "%s: failed to get cpu clock\n", __func__);</div>
<div class="gmail_quote">>+ return PTR_ERR(cpu_clk);</div><div class="gmail_quote">>+ }</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ cpu_op_tbl = get_cpu_op(&cpu_op_nr);</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+ cpu_freq_khz_min = cpu_op_tbl[0].cpu_rate / 1000;</div><div class="gmail_quote">>+ cpu_freq_khz_max = cpu_op_tbl[0].cpu_rate / 1000;</div>
<div class="gmail_quote">
>+</div><div class="gmail_quote">>+ imx_freq_table = kmalloc(</div><div class="gmail_quote">>+ sizeof(struct cpufreq_frequency_table) * (cpu_op_nr + 1),</div><div class="gmail_quote">>+ GFP_KERNEL);</div>
<div class="gmail_quote">>+ if (!imx_freq_table) {</div><div class="gmail_quote">>+ clk_put(cpu_clk);</div><div class="gmail_quote">>+ return -ENOMEM;</div><div class="gmail_quote">
>+ }</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ for (i = 0; i < cpu_op_nr; i++) {</div><div class="gmail_quote">>+ imx_freq_table[i].index = i;</div><div class="gmail_quote">
>+ imx_freq_table[i].frequency =</div><div class="gmail_quote">>+ cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ if ((cpu_op_tbl[i].cpu_rate / 1000) < cpu_freq_khz_min)</div>
<div class="gmail_quote">>+ cpu_freq_khz_min = cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ if ((cpu_op_tbl[i].cpu_rate / 1000) > cpu_freq_khz_max)</div>
<div class="gmail_quote">>+ cpu_freq_khz_max = cpu_op_tbl[i].cpu_rate / 1000;</div><div class="gmail_quote">>+ }</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ imx_freq_table[i].index = i;</div>
<div class="gmail_quote">>+ imx_freq_table[i].frequency = CPUFREQ_TABLE_END;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ policy->cur = clk_get_rate(cpu_clk) / 1000;</div><div class="gmail_quote">
>+ policy->governor = CPUFREQ_DEFAULT_GOVERNOR;</div><div class="gmail_quote">>+ policy->min = policy->cpuinfo.min_freq = cpu_freq_khz_min;</div><div class="gmail_quote">>+ policy->max = policy->cpuinfo.max_freq = cpu_freq_khz_max;</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+ arm_normal_clk = cpu_freq_khz_max * 1000;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ /* Manual states, that PLL stabilizes in two CLK32 periods */</div>
<div class="gmail_quote">>+ policy->cpuinfo.transition_latency = 2 / CLK32_FREQ * NANOSECOND;</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+ ret = cpufreq_frequency_table_cpuinfo(policy, imx_freq_table);</div>
<div class="gmail_quote">>+</div><div class="gmail_quote">>+ if (ret < 0) {</div><div class="gmail_quote">>+ clk_put(cpu_clk);</div><div class="gmail_quote">>+ printk(KERN_ERR "%s: failed to register i.MXC CPUfreq\n",</div>
<div class="gmail_quote">>+ __func__);</div><div class="gmail_quote">>+ return ret;</div><div class="gmail_quote">>+ }</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+ cpufreq_frequency_table_get_attr(imx_freq_table, policy->cpu);</div><div class="gmail_quote">>+ return 0;</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">
>+static int mxc_cpufreq_exit(struct cpufreq_policy *policy)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+ cpufreq_frequency_table_put_attr(policy->cpu);</div><div class="gmail_quote">
>+</div><div class="gmail_quote">>+ set_cpu_freq(arm_normal_clk);</div><div class="gmail_quote">>+ clk_put(cpu_clk);</div><div class="gmail_quote">>+ kfree(imx_freq_table);</div><div class="gmail_quote">
>+ return 0;</div><div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static struct cpufreq_driver mxc_driver = {</div><div class="gmail_quote">>+ .flags = CPUFREQ_STICKY,</div>
<div class="gmail_quote">>+ .verify = mxc_verify_speed,</div><div class="gmail_quote">>+ .target = mxc_set_target,</div><div class="gmail_quote">>+ .get = mxc_get_speed,</div><div class="gmail_quote">
>+ .init = mxc_cpufreq_init,</div><div class="gmail_quote">>+ .exit = mxc_cpufreq_exit,</div><div class="gmail_quote">>+ .name = "imx",</div><div class="gmail_quote">>+};</div><div class="gmail_quote">
>+</div><div class="gmail_quote">>+static int __devinit mxc_cpufreq_driver_init(void)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+ return cpufreq_register_driver(&mxc_driver);</div>
<div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+static void mxc_cpufreq_driver_exit(void)</div><div class="gmail_quote">>+{</div><div class="gmail_quote">>+ cpufreq_unregister_driver(&mxc_driver);</div>
<div class="gmail_quote">>+}</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+module_init(mxc_cpufreq_driver_init);</div><div class="gmail_quote">>+module_exit(mxc_cpufreq_driver_exit);</div><div class="gmail_quote">
>+</div><div class="gmail_quote">>+MODULE_AUTHOR("Freescale Semiconductor Inc. Yong Shen <<a href="mailto:yong.shen@linaro.org" target="_blank">yong.shen@linaro.org</a>>");</div><div class="gmail_quote">
>+MODULE_DESCRIPTION("CPUfreq driver for i.MX");</div>
<div class="gmail_quote">>+MODULE_LICENSE("GPL");</div><div class="gmail_quote">>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">>index a790bf2..888dddc 100644</div>
<div class="gmail_quote">>--- a/arch/arm/plat-mxc/include/mach/mxc.h</div><div class="gmail_quote">>+++ b/arch/arm/plat-mxc/include/mach/mxc.h</div><div class="gmail_quote">>@@ -1,5 +1,5 @@</div><div class="gmail_quote">
> /*</div><div class="gmail_quote">>- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.</div><div class="gmail_quote">>+ * Copyright 2004-2007, 2010 Freescale Semiconductor, Inc. All Rights Reserved.</div>
<div class="gmail_quote">> * Copyright (C) 2008 Juergen Beisert (<a href="mailto:kernel@pengutronix.de" target="_blank">kernel@pengutronix.de</a>)</div><div class="gmail_quote">> *</div><div class="gmail_quote">> * This program is free software; you can redistribute it and/or</div>
<div class="gmail_quote">>@@ -133,6 +133,24 @@ extern unsigned int __mxc_cpu_type;</div><div class="gmail_quote">> # define cpu_is_mxc91231() (0)</div><div class="gmail_quote">> #endif</div><div class="gmail_quote">
></div><div class="gmail_quote">>+#ifndef __ASSEMBLY__</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+struct cpu_op {</div><div class="gmail_quote">>+ u32 pll_reg;</div><div class="gmail_quote">
>+ u32 pll_rate;</div><div class="gmail_quote">>+ u32 cpu_rate;</div><div class="gmail_quote">>+ u32 pdr0_reg;</div><div class="gmail_quote">>+ u32 pdf;</div><div class="gmail_quote">>+ u32 mfi;</div>
<div class="gmail_quote">>+ u32 mfd;</div><div class="gmail_quote">>+ u32 mfn;</div><div class="gmail_quote">>+ u32 cpu_voltage;</div><div class="gmail_quote">>+ u32 cpu_podf;</div><div class="gmail_quote">
>+};</div><div class="gmail_quote">>+</div><div class="gmail_quote">>+extern struct cpu_op *(*get_cpu_op)(int *op);</div><div class="gmail_quote">>+#endif</div><div class="gmail_quote">>+</div><div class="gmail_quote">
> #if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2)</div><div class="gmail_quote">> /* These are deprecated, use mx[23][157]_setup_weimcs instead. */</div><div class="gmail_quote">> #define CSCR_U(n) (IO_ADDRESS(WEIM_BASE_ADDR + n * 0x10))</div>
<div class="gmail_quote">>--</div><div class="gmail_quote">>1.6.3.3</div><div class="gmail_quote">></div></div></div></div>
</blockquote></div><br></div>