diff options
author | Yong Shen <yong.shen@linaro.org> | 2010-10-21 09:18:59 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-10-22 02:24:14 -0400 |
commit | 64f102b67f77f5054d27e58dbb26ec7ebef20e62 (patch) | |
tree | 0075f0e564fbda189c5372106b9a7287b4d536bb /arch/arm/mach-mx5 | |
parent | 71e2889d9d8f2149f38bbeedfa6d9aefa0875ca6 (diff) |
cpufreq for freescale mx51
Currently, only two operating points: 160Mhz and 800Mhz.
the operating points are tested on babbage 3.0
Signed-off-by: Yong Shen <yong.shen@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx5')
-rw-r--r-- | arch/arm/mach-mx5/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-mx5/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx51_babbage.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-mx5/clock-mx51.c | 22 | ||||
-rw-r--r-- | arch/arm/mach-mx5/cpu_op-mx51.c | 29 | ||||
-rw-r--r-- | arch/arm/mach-mx5/cpu_op-mx51.h | 14 |
6 files changed, 70 insertions, 3 deletions
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig index fe96cd25de83..3ec910a7a182 100644 --- a/arch/arm/mach-mx5/Kconfig +++ b/arch/arm/mach-mx5/Kconfig | |||
@@ -6,6 +6,7 @@ config ARCH_MX51 | |||
6 | select MXC_TZIC | 6 | select MXC_TZIC |
7 | select ARCH_MXC_IOMUX_V3 | 7 | select ARCH_MXC_IOMUX_V3 |
8 | select ARCH_MXC_AUDMUX_V2 | 8 | select ARCH_MXC_AUDMUX_V2 |
9 | select ARCH_HAS_CPUFREQ | ||
9 | 10 | ||
10 | comment "MX5 platforms:" | 11 | comment "MX5 platforms:" |
11 | 12 | ||
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 1769c161a60d..462f177eddfe 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile | |||
@@ -5,6 +5,7 @@ | |||
5 | # Object file lists. | 5 | # Object file lists. |
6 | obj-y := cpu.o mm.o clock-mx51.o devices.o | 6 | obj-y := cpu.o mm.o clock-mx51.o devices.o |
7 | 7 | ||
8 | obj-$(CONFIG_CPU_FREQ_IMX) += cpu_op-mx51.o | ||
8 | obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o | 9 | obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o |
9 | obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o | 10 | obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o |
10 | obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o | 11 | obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o |
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c index 39304b4f0069..cbf07ff34d2b 100644 --- a/arch/arm/mach-mx5/board-mx51_babbage.c +++ b/arch/arm/mach-mx5/board-mx51_babbage.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. | 2 | * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. |
3 | * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com> | 3 | * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com> |
4 | * | 4 | * |
5 | * The code contained herein is licensed under the GNU General Public | 5 | * The code contained herein is licensed under the GNU General Public |
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | #include "devices-imx51.h" | 33 | #include "devices-imx51.h" |
34 | #include "devices.h" | 34 | #include "devices.h" |
35 | #include "cpu_op-mx51.h" | ||
35 | 36 | ||
36 | #define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */ | 37 | #define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */ |
37 | #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */ | 38 | #define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */ |
@@ -298,6 +299,9 @@ static void __init mxc_board_init(void) | |||
298 | { | 299 | { |
299 | struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP; | 300 | struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP; |
300 | 301 | ||
302 | #if defined(CONFIG_CPU_FREQ_IMX) | ||
303 | get_cpu_op = mx51_get_cpu_op; | ||
304 | #endif | ||
301 | mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, | 305 | mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, |
302 | ARRAY_SIZE(mx51babbage_pads)); | 306 | ARRAY_SIZE(mx51babbage_pads)); |
303 | mxc_init_imx_uart(); | 307 | mxc_init_imx_uart(); |
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c index f2aae92cf0e2..8ac36d882927 100644 --- a/arch/arm/mach-mx5/clock-mx51.c +++ b/arch/arm/mach-mx5/clock-mx51.c | |||
@@ -362,7 +362,7 @@ static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent) | |||
362 | return 0; | 362 | return 0; |
363 | } | 363 | } |
364 | 364 | ||
365 | static unsigned long clk_arm_get_rate(struct clk *clk) | 365 | static unsigned long clk_cpu_get_rate(struct clk *clk) |
366 | { | 366 | { |
367 | u32 cacrr, div; | 367 | u32 cacrr, div; |
368 | unsigned long parent_rate; | 368 | unsigned long parent_rate; |
@@ -374,6 +374,22 @@ static unsigned long clk_arm_get_rate(struct clk *clk) | |||
374 | return parent_rate / div; | 374 | return parent_rate / div; |
375 | } | 375 | } |
376 | 376 | ||
377 | static int clk_cpu_set_rate(struct clk *clk, unsigned long rate) | ||
378 | { | ||
379 | u32 reg, cpu_podf; | ||
380 | unsigned long parent_rate; | ||
381 | |||
382 | parent_rate = clk_get_rate(clk->parent); | ||
383 | cpu_podf = parent_rate / rate - 1; | ||
384 | /* use post divider to change freq */ | ||
385 | reg = __raw_readl(MXC_CCM_CACRR); | ||
386 | reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK; | ||
387 | reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET; | ||
388 | __raw_writel(reg, MXC_CCM_CACRR); | ||
389 | |||
390 | return 0; | ||
391 | } | ||
392 | |||
377 | static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent) | 393 | static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent) |
378 | { | 394 | { |
379 | u32 reg, mux; | 395 | u32 reg, mux; |
@@ -736,7 +752,8 @@ static struct clk periph_apm_clk = { | |||
736 | 752 | ||
737 | static struct clk cpu_clk = { | 753 | static struct clk cpu_clk = { |
738 | .parent = &pll1_sw_clk, | 754 | .parent = &pll1_sw_clk, |
739 | .get_rate = clk_arm_get_rate, | 755 | .get_rate = clk_cpu_get_rate, |
756 | .set_rate = clk_cpu_set_rate, | ||
740 | }; | 757 | }; |
741 | 758 | ||
742 | static struct clk ahb_clk = { | 759 | static struct clk ahb_clk = { |
@@ -1064,6 +1081,7 @@ static struct clk_lookup lookups[] = { | |||
1064 | _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) | 1081 | _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) |
1065 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) | 1082 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) |
1066 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) | 1083 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) |
1084 | _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) | ||
1067 | }; | 1085 | }; |
1068 | 1086 | ||
1069 | static void clk_tree_init(void) | 1087 | static void clk_tree_init(void) |
diff --git a/arch/arm/mach-mx5/cpu_op-mx51.c b/arch/arm/mach-mx5/cpu_op-mx51.c new file mode 100644 index 000000000000..9d34c3d4c024 --- /dev/null +++ b/arch/arm/mach-mx5/cpu_op-mx51.c | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | #include <linux/types.h> | ||
15 | #include <mach/hardware.h> | ||
16 | #include <linux/kernel.h> | ||
17 | |||
18 | static struct cpu_op mx51_cpu_op[] = { | ||
19 | { | ||
20 | .cpu_rate = 160000000,}, | ||
21 | { | ||
22 | .cpu_rate = 800000000,}, | ||
23 | }; | ||
24 | |||
25 | struct cpu_op *mx51_get_cpu_op(int *op) | ||
26 | { | ||
27 | *op = ARRAY_SIZE(mx51_cpu_op); | ||
28 | return mx51_cpu_op; | ||
29 | } | ||
diff --git a/arch/arm/mach-mx5/cpu_op-mx51.h b/arch/arm/mach-mx5/cpu_op-mx51.h new file mode 100644 index 000000000000..97477fecb469 --- /dev/null +++ b/arch/arm/mach-mx5/cpu_op-mx51.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | extern struct cpu_op *mx51_get_cpu_op(int *op); | ||