cpu.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 <asm/io.h>
  19. static int cpu_silicon_rev = -1;
  20. #define IIM_SREV 0x24
  21. static int get_mx51_srev(void)
  22. {
  23. void __iomem *iim_base = MX51_IO_ADDRESS(MX51_IIM_BASE_ADDR);
  24. u32 rev = readl(iim_base + IIM_SREV) & 0xff;
  25. if (rev == 0x0)
  26. return IMX_CHIP_REVISION_2_0;
  27. else if (rev == 0x10)
  28. return IMX_CHIP_REVISION_3_0;
  29. return 0;
  30. }
  31. /*
  32. * Returns:
  33. * the silicon revision of the cpu
  34. * -EINVAL - not a mx51
  35. */
  36. int mx51_revision(void)
  37. {
  38. if (!cpu_is_mx51())
  39. return -EINVAL;
  40. if (cpu_silicon_rev == -1)
  41. cpu_silicon_rev = get_mx51_srev();
  42. return cpu_silicon_rev;
  43. }
  44. EXPORT_SYMBOL(mx51_revision);
  45. #ifdef CONFIG_NEON
  46. /*
  47. * All versions of the silicon before Rev. 3 have broken NEON implementations.
  48. * Dependent on link order - so the assumption is that vfp_init is called
  49. * before us.
  50. */
  51. static int __init mx51_neon_fixup(void)
  52. {
  53. if (!cpu_is_mx51())
  54. return 0;
  55. if (mx51_revision() < IMX_CHIP_REVISION_3_0 && (elf_hwcap & HWCAP_NEON)) {
  56. elf_hwcap &= ~HWCAP_NEON;
  57. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  58. }
  59. return 0;
  60. }
  61. late_initcall(mx51_neon_fixup);
  62. #endif
  63. static int get_mx53_srev(void)
  64. {
  65. void __iomem *iim_base = MX51_IO_ADDRESS(MX53_IIM_BASE_ADDR);
  66. u32 rev = readl(iim_base + IIM_SREV) & 0xff;
  67. switch (rev) {
  68. case 0x0:
  69. return IMX_CHIP_REVISION_1_0;
  70. case 0x2:
  71. return IMX_CHIP_REVISION_2_0;
  72. case 0x3:
  73. return IMX_CHIP_REVISION_2_1;
  74. default:
  75. return IMX_CHIP_REVISION_UNKNOWN;
  76. }
  77. }
  78. /*
  79. * Returns:
  80. * the silicon revision of the cpu
  81. * -EINVAL - not a mx53
  82. */
  83. int mx53_revision(void)
  84. {
  85. if (!cpu_is_mx53())
  86. return -EINVAL;
  87. if (cpu_silicon_rev == -1)
  88. cpu_silicon_rev = get_mx53_srev();
  89. return cpu_silicon_rev;
  90. }
  91. EXPORT_SYMBOL(mx53_revision);
  92. static int __init post_cpu_init(void)
  93. {
  94. unsigned int reg;
  95. void __iomem *base;
  96. if (cpu_is_mx51() || cpu_is_mx53()) {
  97. if (cpu_is_mx51())
  98. base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
  99. else
  100. base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR);
  101. __raw_writel(0x0, base + 0x40);
  102. __raw_writel(0x0, base + 0x44);
  103. __raw_writel(0x0, base + 0x48);
  104. __raw_writel(0x0, base + 0x4C);
  105. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  106. __raw_writel(reg, base + 0x50);
  107. if (cpu_is_mx51())
  108. base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
  109. else
  110. base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR);
  111. __raw_writel(0x0, base + 0x40);
  112. __raw_writel(0x0, base + 0x44);
  113. __raw_writel(0x0, base + 0x48);
  114. __raw_writel(0x0, base + 0x4C);
  115. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  116. __raw_writel(reg, base + 0x50);
  117. }
  118. return 0;
  119. }
  120. postcore_initcall(post_cpu_init);