cpu-imx5.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. */
  52. int mx51_revision(void)
  53. {
  54. if (mx5_cpu_rev == -1)
  55. mx5_cpu_rev = get_mx51_srev();
  56. return mx5_cpu_rev;
  57. }
  58. EXPORT_SYMBOL(mx51_revision);
  59. #ifdef CONFIG_NEON
  60. /*
  61. * All versions of the silicon before Rev. 3 have broken NEON implementations.
  62. * Dependent on link order - so the assumption is that vfp_init is called
  63. * before us.
  64. */
  65. int __init mx51_neon_fixup(void)
  66. {
  67. if (mx51_revision() < IMX_CHIP_REVISION_3_0 &&
  68. (elf_hwcap & HWCAP_NEON)) {
  69. elf_hwcap &= ~HWCAP_NEON;
  70. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  71. }
  72. return 0;
  73. }
  74. #endif
  75. static int get_mx53_srev(void)
  76. {
  77. u32 rev = imx5_read_srev_reg("fsl,imx53-iim");
  78. switch (rev) {
  79. case 0x0:
  80. return IMX_CHIP_REVISION_1_0;
  81. case 0x2:
  82. return IMX_CHIP_REVISION_2_0;
  83. case 0x3:
  84. return IMX_CHIP_REVISION_2_1;
  85. default:
  86. return IMX_CHIP_REVISION_UNKNOWN;
  87. }
  88. }
  89. /*
  90. * Returns:
  91. * the silicon revision of the cpu
  92. */
  93. int mx53_revision(void)
  94. {
  95. if (mx5_cpu_rev == -1)
  96. mx5_cpu_rev = get_mx53_srev();
  97. return mx5_cpu_rev;
  98. }
  99. EXPORT_SYMBOL(mx53_revision);