cpu-imx5.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  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. #include <linux/types.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <mach/hardware.h>
  18. #include <linux/io.h>
  19. static int mx5_cpu_rev = -1;
  20. #define IIM_SREV 0x24
  21. #define MX50_HW_ADADIG_DIGPROG 0xB0
  22. static int get_mx51_srev(void)
  23. {
  24. void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR);
  25. u32 rev = readl(iim_base + IIM_SREV) & 0xff;
  26. switch (rev) {
  27. case 0x0:
  28. return IMX_CHIP_REVISION_2_0;
  29. case 0x10:
  30. return IMX_CHIP_REVISION_3_0;
  31. default:
  32. return IMX_CHIP_REVISION_UNKNOWN;
  33. }
  34. }
  35. /*
  36. * Returns:
  37. * the silicon revision of the cpu
  38. * -EINVAL - not a mx51
  39. */
  40. int mx51_revision(void)
  41. {
  42. if (!cpu_is_mx51())
  43. return -EINVAL;
  44. if (mx5_cpu_rev == -1)
  45. mx5_cpu_rev = get_mx51_srev();
  46. return mx5_cpu_rev;
  47. }
  48. EXPORT_SYMBOL(mx51_revision);
  49. #ifdef CONFIG_NEON
  50. /*
  51. * All versions of the silicon before Rev. 3 have broken NEON implementations.
  52. * Dependent on link order - so the assumption is that vfp_init is called
  53. * before us.
  54. */
  55. static int __init mx51_neon_fixup(void)
  56. {
  57. if (!cpu_is_mx51())
  58. return 0;
  59. if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
  60. (elf_hwcap & HWCAP_NEON)) {
  61. elf_hwcap &= ~HWCAP_NEON;
  62. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  63. }
  64. return 0;
  65. }
  66. late_initcall(mx51_neon_fixup);
  67. #endif
  68. static int get_mx53_srev(void)
  69. {
  70. void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
  71. u32 rev = readl(iim_base + IIM_SREV) & 0xff;
  72. switch (rev) {
  73. case 0x0:
  74. return IMX_CHIP_REVISION_1_0;
  75. case 0x2:
  76. return IMX_CHIP_REVISION_2_0;
  77. case 0x3:
  78. return IMX_CHIP_REVISION_2_1;
  79. default:
  80. return IMX_CHIP_REVISION_UNKNOWN;
  81. }
  82. }
  83. /*
  84. * Returns:
  85. * the silicon revision of the cpu
  86. * -EINVAL - not a mx53
  87. */
  88. int mx53_revision(void)
  89. {
  90. if (!cpu_is_mx53())
  91. return -EINVAL;
  92. if (mx5_cpu_rev == -1)
  93. mx5_cpu_rev = get_mx53_srev();
  94. return mx5_cpu_rev;
  95. }
  96. EXPORT_SYMBOL(mx53_revision);
  97. static int get_mx50_srev(void)
  98. {
  99. void __iomem *anatop = ioremap(MX50_ANATOP_BASE_ADDR, SZ_8K);
  100. u32 rev;
  101. if (!anatop) {
  102. mx5_cpu_rev = -EINVAL;
  103. return 0;
  104. }
  105. rev = readl(anatop + MX50_HW_ADADIG_DIGPROG);
  106. rev &= 0xff;
  107. iounmap(anatop);
  108. if (rev == 0x0)
  109. return IMX_CHIP_REVISION_1_0;
  110. else if (rev == 0x1)
  111. return IMX_CHIP_REVISION_1_1;
  112. return 0;
  113. }
  114. /*
  115. * Returns:
  116. * the silicon revision of the cpu
  117. * -EINVAL - not a mx50
  118. */
  119. int mx50_revision(void)
  120. {
  121. if (!cpu_is_mx50())
  122. return -EINVAL;
  123. if (mx5_cpu_rev == -1)
  124. mx5_cpu_rev = get_mx50_srev();
  125. return mx5_cpu_rev;
  126. }
  127. EXPORT_SYMBOL(mx50_revision);