blob: 3403bac94a31af62ffd3ea67589e3cb96d036d48 [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>
Shawn Guoee18a712014-05-19 22:23:43 +080019#include <linux/of.h>
20#include <linux/of_address.h>
Amit Kucheriaa329b482010-02-04 12:21:53 -080021
Shawn Guo50f2de62012-09-14 14:14:45 +080022#include "hardware.h"
Fabio Estevam22567792013-03-25 09:20:31 -030023#include "common.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080024
Jason Liuc52c9832011-08-26 13:35:23 +080025static int mx5_cpu_rev = -1;
Sascha Hauer54438562010-03-19 10:50:55 +010026
Dinh Nguyen9ab46502010-11-15 11:30:01 -060027#define IIM_SREV 0x24
Sascha Hauer54438562010-03-19 10:50:55 +010028
Shawn Guoee18a712014-05-19 22:23:43 +080029static u32 imx5_read_srev_reg(const char *compat)
30{
31 void __iomem *iim_base;
32 struct device_node *np;
33 u32 srev;
34
35 np = of_find_compatible_node(NULL, NULL, compat);
36 iim_base = of_iomap(np, 0);
37 WARN_ON(!iim_base);
38
39 srev = readl(iim_base + IIM_SREV) & 0xff;
40
41 iounmap(iim_base);
42
43 return srev;
44}
45
Dinh Nguyen9ab46502010-11-15 11:30:01 -060046static int get_mx51_srev(void)
Sascha Hauer54438562010-03-19 10:50:55 +010047{
Shawn Guoee18a712014-05-19 22:23:43 +080048 u32 rev = imx5_read_srev_reg("fsl,imx51-iim");
Sascha Hauer54438562010-03-19 10:50:55 +010049
Jason Liuc52c9832011-08-26 13:35:23 +080050 switch (rev) {
51 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060052 return IMX_CHIP_REVISION_2_0;
Jason Liuc52c9832011-08-26 13:35:23 +080053 case 0x10:
Dinh Nguyen9ab46502010-11-15 11:30:01 -060054 return IMX_CHIP_REVISION_3_0;
Jason Liuc52c9832011-08-26 13:35:23 +080055 default:
56 return IMX_CHIP_REVISION_UNKNOWN;
57 }
Sascha Hauer54438562010-03-19 10:50:55 +010058}
59
60/*
61 * Returns:
62 * the silicon revision of the cpu
63 * -EINVAL - not a mx51
64 */
65int mx51_revision(void)
66{
67 if (!cpu_is_mx51())
68 return -EINVAL;
69
Jason Liuc52c9832011-08-26 13:35:23 +080070 if (mx5_cpu_rev == -1)
71 mx5_cpu_rev = get_mx51_srev();
Sascha Hauer54438562010-03-19 10:50:55 +010072
Jason Liuc52c9832011-08-26 13:35:23 +080073 return mx5_cpu_rev;
Sascha Hauer54438562010-03-19 10:50:55 +010074}
75EXPORT_SYMBOL(mx51_revision);
76
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030077#ifdef CONFIG_NEON
78
79/*
80 * All versions of the silicon before Rev. 3 have broken NEON implementations.
81 * Dependent on link order - so the assumption is that vfp_init is called
82 * before us.
83 */
Shawn Guo8321b752012-04-26 11:42:34 +080084int __init mx51_neon_fixup(void)
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030085{
Fabio Estevamca066792011-11-21 16:26:52 -020086 if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
87 (elf_hwcap & HWCAP_NEON)) {
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030088 elf_hwcap &= ~HWCAP_NEON;
89 pr_info("Turning off NEON support, detected broken NEON implementation\n");
90 }
91 return 0;
92}
93
Amit Kucheria33d7c5c2010-09-01 22:49:13 +030094#endif
95
Dinh Nguyen9ab46502010-11-15 11:30:01 -060096static int get_mx53_srev(void)
97{
Shawn Guoee18a712014-05-19 22:23:43 +080098 u32 rev = imx5_read_srev_reg("fsl,imx53-iim");
Dinh Nguyen9ab46502010-11-15 11:30:01 -060099
Richard Zhao503e1632011-02-18 20:26:30 +0800100 switch (rev) {
101 case 0x0:
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600102 return IMX_CHIP_REVISION_1_0;
Richard Zhao503e1632011-02-18 20:26:30 +0800103 case 0x2:
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600104 return IMX_CHIP_REVISION_2_0;
Richard Zhao503e1632011-02-18 20:26:30 +0800105 case 0x3:
106 return IMX_CHIP_REVISION_2_1;
107 default:
108 return IMX_CHIP_REVISION_UNKNOWN;
109 }
Dinh Nguyen9ab46502010-11-15 11:30:01 -0600110}
111
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600112/*
113 * Returns:
114 * the silicon revision of the cpu
115 * -EINVAL - not a mx53
116 */
117int mx53_revision(void)
118{
119 if (!cpu_is_mx53())
120 return -EINVAL;
121
Jason Liuc52c9832011-08-26 13:35:23 +0800122 if (mx5_cpu_rev == -1)
123 mx5_cpu_rev = get_mx53_srev();
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600124
Jason Liuc52c9832011-08-26 13:35:23 +0800125 return mx5_cpu_rev;
Dinh Nguyenb66ff7a2010-11-15 11:30:00 -0600126}
127EXPORT_SYMBOL(mx53_revision);