2 * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
11 * This file contains the CPU initialization code.
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <mach/hardware.h>
21 static int mx5_cpu_rev
= -1;
24 #define MX50_HW_ADADIG_DIGPROG 0xB0
26 static int get_mx51_srev(void)
28 void __iomem
*iim_base
= MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR
);
29 u32 rev
= readl(iim_base
+ IIM_SREV
) & 0xff;
33 return IMX_CHIP_REVISION_2_0
;
35 return IMX_CHIP_REVISION_3_0
;
37 return IMX_CHIP_REVISION_UNKNOWN
;
43 * the silicon revision of the cpu
44 * -EINVAL - not a mx51
46 int mx51_revision(void)
51 if (mx5_cpu_rev
== -1)
52 mx5_cpu_rev
= get_mx51_srev();
56 EXPORT_SYMBOL(mx51_revision
);
61 * All versions of the silicon before Rev. 3 have broken NEON implementations.
62 * Dependent on link order - so the assumption is that vfp_init is called
65 static int __init
mx51_neon_fixup(void)
70 if (mx51_revision() < IMX_CHIP_REVISION_3_0
&& (elf_hwcap
& HWCAP_NEON
)) {
71 elf_hwcap
&= ~HWCAP_NEON
;
72 pr_info("Turning off NEON support, detected broken NEON implementation\n");
77 late_initcall(mx51_neon_fixup
);
80 static int get_mx53_srev(void)
82 void __iomem
*iim_base
= MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR
);
83 u32 rev
= readl(iim_base
+ IIM_SREV
) & 0xff;
87 return IMX_CHIP_REVISION_1_0
;
89 return IMX_CHIP_REVISION_2_0
;
91 return IMX_CHIP_REVISION_2_1
;
93 return IMX_CHIP_REVISION_UNKNOWN
;
99 * the silicon revision of the cpu
100 * -EINVAL - not a mx53
102 int mx53_revision(void)
107 if (mx5_cpu_rev
== -1)
108 mx5_cpu_rev
= get_mx53_srev();
112 EXPORT_SYMBOL(mx53_revision
);
114 static int get_mx50_srev(void)
116 void __iomem
*anatop
= ioremap(MX50_ANATOP_BASE_ADDR
, SZ_8K
);
120 mx5_cpu_rev
= -EINVAL
;
124 rev
= readl(anatop
+ MX50_HW_ADADIG_DIGPROG
);
129 return IMX_CHIP_REVISION_1_0
;
131 return IMX_CHIP_REVISION_1_1
;
137 * the silicon revision of the cpu
138 * -EINVAL - not a mx50
140 int mx50_revision(void)
145 if (mx5_cpu_rev
== -1)
146 mx5_cpu_rev
= get_mx50_srev();
150 EXPORT_SYMBOL(mx50_revision
);
152 static int __init
post_cpu_init(void)
157 if (cpu_is_mx51() || cpu_is_mx53()) {
159 base
= MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR
);
161 base
= MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR
);
163 __raw_writel(0x0, base
+ 0x40);
164 __raw_writel(0x0, base
+ 0x44);
165 __raw_writel(0x0, base
+ 0x48);
166 __raw_writel(0x0, base
+ 0x4C);
167 reg
= __raw_readl(base
+ 0x50) & 0x00FFFFFF;
168 __raw_writel(reg
, base
+ 0x50);
171 base
= MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR
);
173 base
= MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR
);
175 __raw_writel(0x0, base
+ 0x40);
176 __raw_writel(0x0, base
+ 0x44);
177 __raw_writel(0x0, base
+ 0x48);
178 __raw_writel(0x0, base
+ 0x4C);
179 reg
= __raw_readl(base
+ 0x50) & 0x00FFFFFF;
180 __raw_writel(reg
, base
+ 0x50);
186 postcore_initcall(post_cpu_init
);