]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/arm/mach-mx6/cpu.c
ENGR00139280: MX6: Add CPUFREQ support
[karo-tx-linux.git] / arch / arm / mach-mx6 / cpu.c
1 /*
2  * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include <linux/types.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/clk.h>
23 #include <linux/module.h>
24 #include <linux/iram_alloc.h>
25 #include <mach/hardware.h>
26 #include <asm/io.h>
27
28 #include "crm_regs.h"
29
30 struct cpu_op *(*get_cpu_op)(int *op);
31
32 int mx6_set_cpu_voltage(u32 cpu_volt)
33 {
34         u32 reg, val;
35
36         val = (cpu_volt - 725000) / 25000;
37
38         reg = __raw_readl(ANADIG_REG_CORE);
39         reg &= ~(ANADIG_REG_TARGET_MASK << ANADIG_REG0_CORE_TARGET_OFFSET);
40         reg |= ((val + 1) << ANADIG_REG0_CORE_TARGET_OFFSET);
41
42         __raw_writel(reg, ANADIG_REG_CORE);
43
44         return 0;
45 }
46
47 static int __init post_cpu_init(void)
48 {
49         unsigned int reg;
50         void __iomem *base;
51
52         iram_init(MX6Q_IRAM_BASE_ADDR, MX6Q_IRAM_SIZE);
53
54         base = ioremap(AIPS1_ON_BASE_ADDR, PAGE_SIZE);
55         __raw_writel(0x0, base + 0x40);
56         __raw_writel(0x0, base + 0x44);
57         __raw_writel(0x0, base + 0x48);
58         __raw_writel(0x0, base + 0x4C);
59         reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
60         __raw_writel(reg, base + 0x50);
61         iounmap(base);
62
63         base = ioremap(AIPS2_ON_BASE_ADDR, PAGE_SIZE);
64         __raw_writel(0x0, base + 0x40);
65         __raw_writel(0x0, base + 0x44);
66         __raw_writel(0x0, base + 0x48);
67         __raw_writel(0x0, base + 0x4C);
68         reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
69         __raw_writel(reg, base + 0x50);
70         iounmap(base);
71
72         return 0;
73 }
74
75 postcore_initcall(post_cpu_init);