cpu-imx5.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 <linux/io.h>
  18. #include <linux/of.h>
  19. #include <linux/of_address.h>
  20. #include "hardware.h"
  21. #include "common.h"
  22. static int mx5_cpu_rev = -1;
  23. #define IIM_SREV 0x24
  24. static u32 imx5_read_srev_reg(const char *compat)
  25. {
  26. void __iomem *iim_base;
  27. struct device_node *np;
  28. u32 srev;
  29. np = of_find_compatible_node(NULL, NULL, compat);
  30. iim_base = of_iomap(np, 0);
  31. WARN_ON(!iim_base);
  32. srev = readl(iim_base + IIM_SREV) & 0xff;
  33. iounmap(iim_base);
  34. return srev;
  35. }
  36. static int get_mx51_srev(void)
  37. {
  38. u32 rev = imx5_read_srev_reg("fsl,imx51-iim");
  39. switch (rev) {
  40. case 0x0:
  41. return IMX_CHIP_REVISION_2_0;
  42. case 0x10:
  43. return IMX_CHIP_REVISION_3_0;
  44. default:
  45. return IMX_CHIP_REVISION_UNKNOWN;
  46. }
  47. }
  48. /*
  49. * Returns:
  50. * the silicon revision of the cpu
  51. * -EINVAL - not a mx51
  52. */
  53. int mx51_revision(void)
  54. {
  55. if (!cpu_is_mx51())
  56. return -EINVAL;
  57. if (mx5_cpu_rev == -1)
  58. mx5_cpu_rev = get_mx51_srev();
  59. return mx5_cpu_rev;
  60. }
  61. EXPORT_SYMBOL(mx51_revision);
  62. #ifdef CONFIG_NEON
  63. /*
  64. * All versions of the silicon before Rev. 3 have broken NEON implementations.
  65. * Dependent on link order - so the assumption is that vfp_init is called
  66. * before us.
  67. */
  68. int __init mx51_neon_fixup(void)
  69. {
  70. if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
  71. (elf_hwcap & HWCAP_NEON)) {
  72. elf_hwcap &= ~HWCAP_NEON;
  73. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  74. }
  75. return 0;
  76. }
  77. #endif
  78. static int get_mx53_srev(void)
  79. {
  80. u32 rev = imx5_read_srev_reg("fsl,imx53-iim");
  81. switch (rev) {
  82. case 0x0:
  83. return IMX_CHIP_REVISION_1_0;
  84. case 0x2:
  85. return IMX_CHIP_REVISION_2_0;
  86. case 0x3:
  87. return IMX_CHIP_REVISION_2_1;
  88. default:
  89. return IMX_CHIP_REVISION_UNKNOWN;
  90. }
  91. }
  92. /*
  93. * Returns:
  94. * the silicon revision of the cpu
  95. * -EINVAL - not a mx53
  96. */
  97. int mx53_revision(void)
  98. {
  99. if (!cpu_is_mx53())
  100. return -EINVAL;
  101. if (mx5_cpu_rev == -1)
  102. mx5_cpu_rev = get_mx53_srev();
  103. return mx5_cpu_rev;
  104. }
  105. EXPORT_SYMBOL(mx53_revision);