cpu-imx5.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. int __init mx51_neon_fixup(void)
  56. {
  57. if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
  58. (elf_hwcap & HWCAP_NEON)) {
  59. elf_hwcap &= ~HWCAP_NEON;
  60. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  61. }
  62. return 0;
  63. }
  64. #endif
  65. static int get_mx53_srev(void)
  66. {
  67. void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
  68. u32 rev = readl(iim_base + IIM_SREV) & 0xff;
  69. switch (rev) {
  70. case 0x0:
  71. return IMX_CHIP_REVISION_1_0;
  72. case 0x2:
  73. return IMX_CHIP_REVISION_2_0;
  74. case 0x3:
  75. return IMX_CHIP_REVISION_2_1;
  76. default:
  77. return IMX_CHIP_REVISION_UNKNOWN;
  78. }
  79. }
  80. /*
  81. * Returns:
  82. * the silicon revision of the cpu
  83. * -EINVAL - not a mx53
  84. */
  85. int mx53_revision(void)
  86. {
  87. if (!cpu_is_mx53())
  88. return -EINVAL;
  89. if (mx5_cpu_rev == -1)
  90. mx5_cpu_rev = get_mx53_srev();
  91. return mx5_cpu_rev;
  92. }
  93. EXPORT_SYMBOL(mx53_revision);
  94. static int get_mx50_srev(void)
  95. {
  96. void __iomem *anatop = ioremap(MX50_ANATOP_BASE_ADDR, SZ_8K);
  97. u32 rev;
  98. if (!anatop) {
  99. mx5_cpu_rev = -EINVAL;
  100. return 0;
  101. }
  102. rev = readl(anatop + MX50_HW_ADADIG_DIGPROG);
  103. rev &= 0xff;
  104. iounmap(anatop);
  105. if (rev == 0x0)
  106. return IMX_CHIP_REVISION_1_0;
  107. else if (rev == 0x1)
  108. return IMX_CHIP_REVISION_1_1;
  109. return 0;
  110. }
  111. /*
  112. * Returns:
  113. * the silicon revision of the cpu
  114. * -EINVAL - not a mx50
  115. */
  116. int mx50_revision(void)
  117. {
  118. if (!cpu_is_mx50())
  119. return -EINVAL;
  120. if (mx5_cpu_rev == -1)
  121. mx5_cpu_rev = get_mx50_srev();
  122. return mx5_cpu_rev;
  123. }
  124. EXPORT_SYMBOL(mx50_revision);