blob: 3b4c307430522572692cfbc84b6e2f093d8c1ee4 [file] [log] [blame]
Amit Kucheriaa329b482010-02-04 12:21:53 -08001/*
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -06002 * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
Amit Kucheriaa329b482010-02-04 12:21:53 -08003 *
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:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 *
11 * This file contains the CPU initialization code.
12 */
13
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
Sascha Hauer54438562010-03-19 10:50:55 +010017#include <linux/module.h>
Amit Kucheriaa329b482010-02-04 12:21:53 -080018#include <mach/hardware.h>
19#include <asm/io.h>
20
Sascha Hauer54438562010-03-19 10:50:55 +010021static int cpu_silicon_rev = -1;
22
Dinh Nguyen9ab46502010-11-15 11:30:01 -060023#define IIM_SREV 0x24
Sascha Hauer54438562010-03-19 10:50:55 +010024
Dinh Nguyen9ab46502010-11-15 11:30:01 -060025static int get_mx51_srev(void)
Sascha Hauer54438562010-03-19 10:50:55 +010026{
Dinh Nguyen9ab46502010-11-15 11:30:01 -060027 void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR);
28 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
Sascha Hauer54438562010-03-19 10:50:55 +010029
Dinh Nguyen9ab46502010-11-15 11:30:01 -060030 if (rev == 0x0)
31 return IMX_CHIP_REVISION_2_0;
32 else if (rev == 0x10)
33 return IMX_CHIP_REVISION_3_0;
34 return 0;
Sascha Hauer54438562010-03-19 10:50:55 +010035}
36
37/*
38 * Returns:
39 * the silicon revision of the cpu
40 * -EINVAL - not a mx51
41 */
42int mx51_revision(void)
43{
44 if (!cpu_is_mx51())
45 return -EINVAL;
46
47 if (cpu_silicon_rev == -1)
Dinh Nguyen9ab46502010-11-15 11:30:01 -060048 cpu_silicon_rev = get_mx51_srev();
Sascha Hauer54438562010-03-19 10:50:55 +010049
50 return cpu_silicon_rev;
51}
52EXPORT_SYMBOL(mx51_revision);
53
Fabio Estevam76422db2011-03-17 23:32:11 -030054void mx51_display_revision(void)
55{
56 int rev;
57 char *srev;
58 rev = mx51_revision();
59
60 switch (rev) {
61 case IMX_CHIP_REVISION_2_0:
62 srev = IMX_CHIP_REVISION_2_0_STRING;
63 break;
64 case IMX_CHIP_REVISION_3_0:
65 srev = IMX_CHIP_REVISION_3_0_STRING;
66 break;
67 default:
68 srev = IMX_CHIP_REVISION_UNKNOWN_STRING;
69 }
70 printk(KERN_INFO "CPU identified as i.MX51, silicon rev %s\n", srev);
71}
72EXPORT_SYMBOL(mx51_display_revision);
73
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030074#ifdef CONFIG_NEON
75
76/*
77 * All versions of the silicon before Rev. 3 have broken NEON implementations.
78 * Dependent on link order - so the assumption is that vfp_init is called
79 * before us.
80 */
81static int __init mx51_neon_fixup(void)
82{
Sascha Hauer92fcdc92010-11-04 23:08:17 +010083 if (!cpu_is_mx51())
84 return 0;
85
Dinh Nguyen9ab46502010-11-15 11:30:01 -060086 if (mx51_revision() < IMX_CHIP_REVISION_3_0 && (elf_hwcap & HWCAP_NEON)) {
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030087 elf_hwcap &= ~HWCAP_NEON;
88 pr_info("Turning off NEON support, detected broken NEON implementation\n");
89 }
90 return 0;
91}
92
93late_initcall(mx51_neon_fixup);
94#endif
95
Dinh Nguyen9ab46502010-11-15 11:30:01 -060096static int get_mx53_srev(void)
97{
98 void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
99 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
100
Richard Zhao503e1632011-02-18 20:26:30 +0800101 switch (rev) {
102 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600103 return IMX_CHIP_REVISION_1_0;
Richard Zhao503e1632011-02-18 20:26:30 +0800104 case 0x2:
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600105 return IMX_CHIP_REVISION_2_0;
Richard Zhao503e1632011-02-18 20:26:30 +0800106 case 0x3:
107 return IMX_CHIP_REVISION_2_1;
108 default:
109 return IMX_CHIP_REVISION_UNKNOWN;
110 }
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600111}
112
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600113/*
114 * Returns:
115 * the silicon revision of the cpu
116 * -EINVAL - not a mx53
117 */
118int mx53_revision(void)
119{
120 if (!cpu_is_mx53())
121 return -EINVAL;
122
123 if (cpu_silicon_rev == -1)
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600124 cpu_silicon_rev = get_mx53_srev();
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600125
126 return cpu_silicon_rev;
127}
128EXPORT_SYMBOL(mx53_revision);
129
Amit Kucheriaa329b482010-02-04 12:21:53 -0800130static int __init post_cpu_init(void)
131{
132 unsigned int reg;
133 void __iomem *base;
134
Dinh Nguyenc0abefd2010-11-15 11:29:59 -0600135 if (cpu_is_mx51() || cpu_is_mx53()) {
136 if (cpu_is_mx51())
137 base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
138 else
139 base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR);
Amit Kucheriaa329b482010-02-04 12:21:53 -0800140
Dinh Nguyenc0abefd2010-11-15 11:29:59 -0600141 __raw_writel(0x0, base + 0x40);
142 __raw_writel(0x0, base + 0x44);
143 __raw_writel(0x0, base + 0x48);
144 __raw_writel(0x0, base + 0x4C);
145 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
146 __raw_writel(reg, base + 0x50);
Amit Kucheriaa329b482010-02-04 12:21:53 -0800147
Dinh Nguyenc0abefd2010-11-15 11:29:59 -0600148 if (cpu_is_mx51())
149 base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
150 else
151 base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR);
152
153 __raw_writel(0x0, base + 0x40);
154 __raw_writel(0x0, base + 0x44);
155 __raw_writel(0x0, base + 0x48);
156 __raw_writel(0x0, base + 0x4C);
157 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
158 __raw_writel(reg, base + 0x50);
159 }
Amit Kucheriaa329b482010-02-04 12:21:53 -0800160
161 return 0;
162}
163
164postcore_initcall(post_cpu_init);