blob: d7ce72252a4e6b34d5416e387c3bf1b02f7c6c2b [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
Sascha Hauer54438562010-03-19 10:50:55 +010025
Dinh Nguyen9ab46502010-11-15 11:30:01 -060026static int get_mx51_srev(void)
Sascha Hauer54438562010-03-19 10:50:55 +010027{
Dinh Nguyen9ab46502010-11-15 11:30:01 -060028 void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR);
29 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
Sascha Hauer54438562010-03-19 10:50:55 +010030
Jason Liuc52c9832011-08-26 13:35:23 +080031 switch (rev) {
32 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060033 return IMX_CHIP_REVISION_2_0;
Jason Liuc52c9832011-08-26 13:35:23 +080034 case 0x10:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060035 return IMX_CHIP_REVISION_3_0;
Jason Liuc52c9832011-08-26 13:35:23 +080036 default:
37 return IMX_CHIP_REVISION_UNKNOWN;
38 }
Sascha Hauer54438562010-03-19 10:50:55 +010039}
40
41/*
42 * Returns:
43 * the silicon revision of the cpu
44 * -EINVAL - not a mx51
45 */
46int mx51_revision(void)
47{
48 if (!cpu_is_mx51())
49 return -EINVAL;
50
Jason Liuc52c9832011-08-26 13:35:23 +080051 if (mx5_cpu_rev == -1)
52 mx5_cpu_rev = get_mx51_srev();
Sascha Hauer54438562010-03-19 10:50:55 +010053
Jason Liuc52c9832011-08-26 13:35:23 +080054 return mx5_cpu_rev;
Sascha Hauer54438562010-03-19 10:50:55 +010055}
56EXPORT_SYMBOL(mx51_revision);
57
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030058#ifdef CONFIG_NEON
59
60/*
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
63 * before us.
64 */
Shawn Guo8321b752012-04-26 11:42:34 +080065int __init mx51_neon_fixup(void)
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030066{
Fabio Estevamca066792011-11-21 16:26:52 -020067 if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
68 (elf_hwcap & HWCAP_NEON)) {
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030069 elf_hwcap &= ~HWCAP_NEON;
70 pr_info("Turning off NEON support, detected broken NEON implementation\n");
71 }
72 return 0;
73}
74
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030075#endif
76
Dinh Nguyen9ab46502010-11-15 11:30:01 -060077static int get_mx53_srev(void)
78{
79 void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
80 u32 rev = readl(iim_base + IIM_SREV) & 0xff;
81
Richard Zhao503e1632011-02-18 20:26:30 +080082 switch (rev) {
83 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060084 return IMX_CHIP_REVISION_1_0;
Richard Zhao503e1632011-02-18 20:26:30 +080085 case 0x2:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060086 return IMX_CHIP_REVISION_2_0;
Richard Zhao503e1632011-02-18 20:26:30 +080087 case 0x3:
88 return IMX_CHIP_REVISION_2_1;
89 default:
90 return IMX_CHIP_REVISION_UNKNOWN;
91 }
Dinh Nguyen9ab46502010-11-15 11:30:01 -060092}
93
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -060094/*
95 * Returns:
96 * the silicon revision of the cpu
97 * -EINVAL - not a mx53
98 */
99int mx53_revision(void)
100{
101 if (!cpu_is_mx53())
102 return -EINVAL;
103
Jason Liuc52c9832011-08-26 13:35:23 +0800104 if (mx5_cpu_rev == -1)
105 mx5_cpu_rev = get_mx53_srev();
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600106
Jason Liuc52c9832011-08-26 13:35:23 +0800107 return mx5_cpu_rev;
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600108}
109EXPORT_SYMBOL(mx53_revision);