Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 1 | /* |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 2 | * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 3 | * |
| 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 Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 17 | #include <linux/module.h> |
Fabio Estevam | ca06679 | 2011-11-21 16:26:52 -0200 | [diff] [blame] | 18 | #include <linux/io.h> |
Shawn Guo | ee18a71 | 2014-05-19 22:23:43 +0800 | [diff] [blame] | 19 | #include <linux/of.h> |
| 20 | #include <linux/of_address.h> |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 21 | |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 22 | #include "hardware.h" |
Fabio Estevam | 2256779 | 2013-03-25 09:20:31 -0300 | [diff] [blame] | 23 | #include "common.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 24 | |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 25 | static int mx5_cpu_rev = -1; |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 26 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 27 | #define IIM_SREV 0x24 |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 28 | |
Shawn Guo | ee18a71 | 2014-05-19 22:23:43 +0800 | [diff] [blame] | 29 | static 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 Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 46 | static int get_mx51_srev(void) |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 47 | { |
Shawn Guo | ee18a71 | 2014-05-19 22:23:43 +0800 | [diff] [blame] | 48 | u32 rev = imx5_read_srev_reg("fsl,imx51-iim"); |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 49 | |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 50 | switch (rev) { |
| 51 | case 0x0: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 52 | return IMX_CHIP_REVISION_2_0; |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 53 | case 0x10: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 54 | return IMX_CHIP_REVISION_3_0; |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 55 | default: |
| 56 | return IMX_CHIP_REVISION_UNKNOWN; |
| 57 | } |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /* |
| 61 | * Returns: |
| 62 | * the silicon revision of the cpu |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 63 | */ |
| 64 | int mx51_revision(void) |
| 65 | { |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 66 | if (mx5_cpu_rev == -1) |
| 67 | mx5_cpu_rev = get_mx51_srev(); |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 68 | |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 69 | return mx5_cpu_rev; |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 70 | } |
| 71 | EXPORT_SYMBOL(mx51_revision); |
| 72 | |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 73 | #ifdef CONFIG_NEON |
| 74 | |
| 75 | /* |
| 76 | * All versions of the silicon before Rev. 3 have broken NEON implementations. |
| 77 | * Dependent on link order - so the assumption is that vfp_init is called |
| 78 | * before us. |
| 79 | */ |
Shawn Guo | 8321b75 | 2012-04-26 11:42:34 +0800 | [diff] [blame] | 80 | int __init mx51_neon_fixup(void) |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 81 | { |
Fabio Estevam | ca06679 | 2011-11-21 16:26:52 -0200 | [diff] [blame] | 82 | if (mx51_revision() < IMX_CHIP_REVISION_3_0 && |
| 83 | (elf_hwcap & HWCAP_NEON)) { |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 84 | elf_hwcap &= ~HWCAP_NEON; |
| 85 | pr_info("Turning off NEON support, detected broken NEON implementation\n"); |
| 86 | } |
| 87 | return 0; |
| 88 | } |
| 89 | |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 90 | #endif |
| 91 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 92 | static int get_mx53_srev(void) |
| 93 | { |
Shawn Guo | ee18a71 | 2014-05-19 22:23:43 +0800 | [diff] [blame] | 94 | u32 rev = imx5_read_srev_reg("fsl,imx53-iim"); |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 95 | |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 96 | switch (rev) { |
| 97 | case 0x0: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 98 | return IMX_CHIP_REVISION_1_0; |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 99 | case 0x2: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 100 | return IMX_CHIP_REVISION_2_0; |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 101 | case 0x3: |
| 102 | return IMX_CHIP_REVISION_2_1; |
| 103 | default: |
| 104 | return IMX_CHIP_REVISION_UNKNOWN; |
| 105 | } |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 106 | } |
| 107 | |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 108 | /* |
| 109 | * Returns: |
| 110 | * the silicon revision of the cpu |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 111 | */ |
| 112 | int mx53_revision(void) |
| 113 | { |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 114 | if (mx5_cpu_rev == -1) |
| 115 | mx5_cpu_rev = get_mx53_srev(); |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 116 | |
Jason Liu | c52c983 | 2011-08-26 13:35:23 +0800 | [diff] [blame] | 117 | return mx5_cpu_rev; |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 118 | } |
| 119 | EXPORT_SYMBOL(mx53_revision); |