blob: d88760014ff96ab46277d3ef97e4f592105b5dbb [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>
Fabio Estevamca066792011-11-21 16:26:52 -020018#include <linux/io.h>
Amit Kucheriaa329b482010-02-04 12:21:53 -080019
Shawn Guo50f2de62012-09-14 14:14:45 +080020#include "hardware.h"
21
Jason Liuc52c9832011-08-26 13:35:23 +080022static int mx5_cpu_rev = -1;
Sascha Hauer54438562010-03-19 10:50:55 +010023
Dinh Nguyen9ab46502010-11-15 11:30:01 -060024#define IIM_SREV 0x24
Dinh Nguyen16f246e2011-03-21 16:30:35 -050025#define MX50_HW_ADADIG_DIGPROG 0xB0
Sascha Hauer54438562010-03-19 10:50:55 +010026
Dinh Nguyen9ab46502010-11-15 11:30:01 -060027static int get_mx51_srev(void)
Sascha Hauer54438562010-03-19 10:50:55 +010028{
Dinh Nguyen9ab46502010-11-15 11:30:01 -060029 void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR);
30 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
Sascha Hauer54438562010-03-19 10:50:55 +010031
Jason Liuc52c9832011-08-26 13:35:23 +080032 switch (rev) {
33 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060034 return IMX_CHIP_REVISION_2_0;
Jason Liuc52c9832011-08-26 13:35:23 +080035 case 0x10:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060036 return IMX_CHIP_REVISION_3_0;
Jason Liuc52c9832011-08-26 13:35:23 +080037 default:
38 return IMX_CHIP_REVISION_UNKNOWN;
39 }
Sascha Hauer54438562010-03-19 10:50:55 +010040}
41
42/*
43 * Returns:
44 * the silicon revision of the cpu
45 * -EINVAL - not a mx51
46 */
47int mx51_revision(void)
48{
49 if (!cpu_is_mx51())
50 return -EINVAL;
51
Jason Liuc52c9832011-08-26 13:35:23 +080052 if (mx5_cpu_rev == -1)
53 mx5_cpu_rev = get_mx51_srev();
Sascha Hauer54438562010-03-19 10:50:55 +010054
Jason Liuc52c9832011-08-26 13:35:23 +080055 return mx5_cpu_rev;
Sascha Hauer54438562010-03-19 10:50:55 +010056}
57EXPORT_SYMBOL(mx51_revision);
58
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030059#ifdef CONFIG_NEON
60
61/*
62 * All versions of the silicon before Rev. 3 have broken NEON implementations.
63 * Dependent on link order - so the assumption is that vfp_init is called
64 * before us.
65 */
Shawn Guo8321b752012-04-26 11:42:34 +080066int __init mx51_neon_fixup(void)
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030067{
Fabio Estevamca066792011-11-21 16:26:52 -020068 if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
69 (elf_hwcap & HWCAP_NEON)) {
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030070 elf_hwcap &= ~HWCAP_NEON;
71 pr_info("Turning off NEON support, detected broken NEON implementation\n");
72 }
73 return 0;
74}
75
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030076#endif
77
Dinh Nguyen9ab46502010-11-15 11:30:01 -060078static int get_mx53_srev(void)
79{
80 void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
81 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
82
Richard Zhao503e1632011-02-18 20:26:30 +080083 switch (rev) {
84 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060085 return IMX_CHIP_REVISION_1_0;
Richard Zhao503e1632011-02-18 20:26:30 +080086 case 0x2:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060087 return IMX_CHIP_REVISION_2_0;
Richard Zhao503e1632011-02-18 20:26:30 +080088 case 0x3:
89 return IMX_CHIP_REVISION_2_1;
90 default:
91 return IMX_CHIP_REVISION_UNKNOWN;
92 }
Dinh Nguyen9ab46502010-11-15 11:30:01 -060093}
94
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -060095/*
96 * Returns:
97 * the silicon revision of the cpu
98 * -EINVAL - not a mx53
99 */
100int mx53_revision(void)
101{
102 if (!cpu_is_mx53())
103 return -EINVAL;
104
Jason Liuc52c9832011-08-26 13:35:23 +0800105 if (mx5_cpu_rev == -1)
106 mx5_cpu_rev = get_mx53_srev();
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600107
Jason Liuc52c9832011-08-26 13:35:23 +0800108 return mx5_cpu_rev;
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600109}
110EXPORT_SYMBOL(mx53_revision);
111
Dinh Nguyen16f246e2011-03-21 16:30:35 -0500112static int get_mx50_srev(void)
113{
114 void __iomem *anatop = ioremap(MX50_ANATOP_BASE_ADDR, SZ_8K);
115 u32 rev;
116
117 if (!anatop) {
Jason Liuc52c9832011-08-26 13:35:23 +0800118 mx5_cpu_rev = -EINVAL;
Dinh Nguyen16f246e2011-03-21 16:30:35 -0500119 return 0;
120 }
121
122 rev = readl(anatop + MX50_HW_ADADIG_DIGPROG);
123 rev &= 0xff;
124
125 iounmap(anatop);
126 if (rev == 0x0)
127 return IMX_CHIP_REVISION_1_0;
128 else if (rev == 0x1)
129 return IMX_CHIP_REVISION_1_1;
130 return 0;
131}
132
133/*
134 * Returns:
135 * the silicon revision of the cpu
136 * -EINVAL - not a mx50
137 */
138int mx50_revision(void)
139{
140 if (!cpu_is_mx50())
141 return -EINVAL;
142
Jason Liuc52c9832011-08-26 13:35:23 +0800143 if (mx5_cpu_rev == -1)
144 mx5_cpu_rev = get_mx50_srev();
Dinh Nguyen16f246e2011-03-21 16:30:35 -0500145
Jason Liuc52c9832011-08-26 13:35:23 +0800146 return mx5_cpu_rev;
Dinh Nguyen16f246e2011-03-21 16:30:35 -0500147}
148EXPORT_SYMBOL(mx50_revision);