cpu.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. if (rev == 0x0)
  68. return IMX_CHIP_REVISION_1_0;
  69. else if (rev == 0x10)
  70. return IMX_CHIP_REVISION_2_0;
  71. return 0;
  72. }
  73. /*
  74. * Returns:
  75. * the silicon revision of the cpu
  76. * -EINVAL - not a mx53
  77. */
  78. int mx53_revision(void)
  79. {
  80. if (!cpu_is_mx53())
  81. return -EINVAL;
  82. if (cpu_silicon_rev == -1)
  83. cpu_silicon_rev = get_mx53_srev();
  84. return cpu_silicon_rev;
  85. }
  86. EXPORT_SYMBOL(mx53_revision);
  87. static int __init post_cpu_init(void)
  88. {
  89. unsigned int reg;
  90. void __iomem *base;
  91. if (cpu_is_mx51() || cpu_is_mx53()) {
  92. if (cpu_is_mx51())
  93. base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
  94. else
  95. base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR);
  96. __raw_writel(0x0, base + 0x40);
  97. __raw_writel(0x0, base + 0x44);
  98. __raw_writel(0x0, base + 0x48);
  99. __raw_writel(0x0, base + 0x4C);
  100. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  101. __raw_writel(reg, base + 0x50);
  102. if (cpu_is_mx51())
  103. base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
  104. else
  105. base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR);
  106. __raw_writel(0x0, base + 0x40);
  107. __raw_writel(0x0, base + 0x44);
  108. __raw_writel(0x0, base + 0x48);
  109. __raw_writel(0x0, base + 0x4C);
  110. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  111. __raw_writel(reg, base + 0x50);
  112. }
  113. return 0;
  114. }
  115. postcore_initcall(post_cpu_init);