1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
5 * This file contains the CPU initialization code.
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
14 #include <linux/of_address.h>
19 static int mx5_cpu_rev
= -1;
23 static u32
imx5_read_srev_reg(const char *compat
)
25 void __iomem
*iim_base
;
26 struct device_node
*np
;
29 np
= of_find_compatible_node(NULL
, NULL
, compat
);
30 iim_base
= of_iomap(np
, 0);
33 srev
= readl(iim_base
+ IIM_SREV
) & 0xff;
40 static int get_mx51_srev(void)
42 u32 rev
= imx5_read_srev_reg("fsl,imx51-iim");
46 return IMX_CHIP_REVISION_2_0
;
48 return IMX_CHIP_REVISION_3_0
;
50 return IMX_CHIP_REVISION_UNKNOWN
;
56 * the silicon revision of the cpu
58 int mx51_revision(void)
60 if (mx5_cpu_rev
== -1)
61 mx5_cpu_rev
= get_mx51_srev();
65 EXPORT_SYMBOL(mx51_revision
);
70 * All versions of the silicon before Rev. 3 have broken NEON implementations.
71 * Dependent on link order - so the assumption is that vfp_init is called
74 int __init
mx51_neon_fixup(void)
76 if (mx51_revision() < IMX_CHIP_REVISION_3_0
&&
77 (elf_hwcap
& HWCAP_NEON
)) {
78 elf_hwcap
&= ~HWCAP_NEON
;
79 pr_info("Turning off NEON support, detected broken NEON implementation\n");
86 static int get_mx53_srev(void)
88 u32 rev
= imx5_read_srev_reg("fsl,imx53-iim");
92 return IMX_CHIP_REVISION_1_0
;
94 return IMX_CHIP_REVISION_2_0
;
96 return IMX_CHIP_REVISION_2_1
;
98 return IMX_CHIP_REVISION_UNKNOWN
;
104 * the silicon revision of the cpu
106 int mx53_revision(void)
108 if (mx5_cpu_rev
== -1)
109 mx5_cpu_rev
= get_mx53_srev();
113 EXPORT_SYMBOL(mx53_revision
);
116 #define DBGEN BIT(16)
119 * This enables the DBGEN bit in ARM_GPC register, which is
120 * required for accessing some performance counter features.
121 * Technically it is only required while perf is used, but to
122 * keep the source code simple we just enable it all the time
123 * when the kernel configuration allows using the feature.
125 void __init
imx5_pmu_init(void)
127 void __iomem
*tigerp_base
;
128 struct device_node
*np
;
131 if (!IS_ENABLED(CONFIG_ARM_PMU
))
134 np
= of_find_compatible_node(NULL
, NULL
, "arm,cortex-a8-pmu");
138 if (!of_property_read_bool(np
, "secure-reg-access"))
143 np
= of_find_compatible_node(NULL
, NULL
, "fsl,imx51-tigerp");
147 tigerp_base
= of_iomap(np
, 0);
151 gpc
= readl_relaxed(tigerp_base
+ ARM_GPC
);
153 writel_relaxed(gpc
, tigerp_base
+ ARM_GPC
);
154 iounmap(tigerp_base
);