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> |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 18 | #include <mach/hardware.h> |
| 19 | #include <asm/io.h> |
| 20 | |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 21 | static int cpu_silicon_rev = -1; |
| 22 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 23 | #define IIM_SREV 0x24 |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 24 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 25 | static int get_mx51_srev(void) |
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 | void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR); |
| 28 | u32 rev = readl(iim_base + IIM_SREV) & 0xff; |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 29 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 30 | if (rev == 0x0) |
| 31 | return IMX_CHIP_REVISION_2_0; |
| 32 | else if (rev == 0x10) |
| 33 | return IMX_CHIP_REVISION_3_0; |
| 34 | return 0; |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /* |
| 38 | * Returns: |
| 39 | * the silicon revision of the cpu |
| 40 | * -EINVAL - not a mx51 |
| 41 | */ |
| 42 | int mx51_revision(void) |
| 43 | { |
| 44 | if (!cpu_is_mx51()) |
| 45 | return -EINVAL; |
| 46 | |
| 47 | if (cpu_silicon_rev == -1) |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 48 | cpu_silicon_rev = get_mx51_srev(); |
Sascha Hauer | 5443856 | 2010-03-19 10:50:55 +0100 | [diff] [blame] | 49 | |
| 50 | return cpu_silicon_rev; |
| 51 | } |
| 52 | EXPORT_SYMBOL(mx51_revision); |
| 53 | |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 54 | #ifdef CONFIG_NEON |
| 55 | |
| 56 | /* |
| 57 | * All versions of the silicon before Rev. 3 have broken NEON implementations. |
| 58 | * Dependent on link order - so the assumption is that vfp_init is called |
| 59 | * before us. |
| 60 | */ |
| 61 | static int __init mx51_neon_fixup(void) |
| 62 | { |
Sascha Hauer | 92fcdc9 | 2010-11-04 23:08:17 +0100 | [diff] [blame] | 63 | if (!cpu_is_mx51()) |
| 64 | return 0; |
| 65 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 66 | if (mx51_revision() < IMX_CHIP_REVISION_3_0 && (elf_hwcap & HWCAP_NEON)) { |
Amit Kucheria | 33d7c5c | 2010-09-01 22:49:13 +0300 | [diff] [blame] | 67 | elf_hwcap &= ~HWCAP_NEON; |
| 68 | pr_info("Turning off NEON support, detected broken NEON implementation\n"); |
| 69 | } |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | late_initcall(mx51_neon_fixup); |
| 74 | #endif |
| 75 | |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 76 | static int get_mx53_srev(void) |
| 77 | { |
| 78 | void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR); |
| 79 | u32 rev = readl(iim_base + IIM_SREV) & 0xff; |
| 80 | |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 81 | switch (rev) { |
| 82 | case 0x0: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 83 | return IMX_CHIP_REVISION_1_0; |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 84 | case 0x2: |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 85 | return IMX_CHIP_REVISION_2_0; |
Richard Zhao | 503e163 | 2011-02-18 20:26:30 +0800 | [diff] [blame] | 86 | case 0x3: |
| 87 | return IMX_CHIP_REVISION_2_1; |
| 88 | default: |
| 89 | return IMX_CHIP_REVISION_UNKNOWN; |
| 90 | } |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 91 | } |
| 92 | |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 93 | /* |
| 94 | * Returns: |
| 95 | * the silicon revision of the cpu |
| 96 | * -EINVAL - not a mx53 |
| 97 | */ |
| 98 | int mx53_revision(void) |
| 99 | { |
| 100 | if (!cpu_is_mx53()) |
| 101 | return -EINVAL; |
| 102 | |
| 103 | if (cpu_silicon_rev == -1) |
Dinh Nguyen | 9ab4650 | 2010-11-15 11:30:01 -0600 | [diff] [blame] | 104 | cpu_silicon_rev = get_mx53_srev(); |
Dinh Nguyen | b66ff7a | 2010-11-15 11:30:00 -0600 | [diff] [blame] | 105 | |
| 106 | return cpu_silicon_rev; |
| 107 | } |
| 108 | EXPORT_SYMBOL(mx53_revision); |
| 109 | |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 110 | static int __init post_cpu_init(void) |
| 111 | { |
| 112 | unsigned int reg; |
| 113 | void __iomem *base; |
| 114 | |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 115 | if (cpu_is_mx51() || cpu_is_mx53()) { |
| 116 | if (cpu_is_mx51()) |
| 117 | base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR); |
| 118 | else |
| 119 | base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR); |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 120 | |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 121 | __raw_writel(0x0, base + 0x40); |
| 122 | __raw_writel(0x0, base + 0x44); |
| 123 | __raw_writel(0x0, base + 0x48); |
| 124 | __raw_writel(0x0, base + 0x4C); |
| 125 | reg = __raw_readl(base + 0x50) & 0x00FFFFFF; |
| 126 | __raw_writel(reg, base + 0x50); |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 127 | |
Dinh Nguyen | c0abefd | 2010-11-15 11:29:59 -0600 | [diff] [blame] | 128 | if (cpu_is_mx51()) |
| 129 | base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR); |
| 130 | else |
| 131 | base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR); |
| 132 | |
| 133 | __raw_writel(0x0, base + 0x40); |
| 134 | __raw_writel(0x0, base + 0x44); |
| 135 | __raw_writel(0x0, base + 0x48); |
| 136 | __raw_writel(0x0, base + 0x4C); |
| 137 | reg = __raw_readl(base + 0x50) & 0x00FFFFFF; |
| 138 | __raw_writel(reg, base + 0x50); |
| 139 | } |
Amit Kucheria | a329b48 | 2010-02-04 12:21:53 -0800 | [diff] [blame] | 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | postcore_initcall(post_cpu_init); |