cpu.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright 2008-2009 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 SI_REV 0x48
  21. static void query_silicon_parameter(void)
  22. {
  23. void __iomem *rom = ioremap(MX51_IROM_BASE_ADDR, MX51_IROM_SIZE);
  24. u32 rev;
  25. if (!rom) {
  26. cpu_silicon_rev = -EINVAL;
  27. return;
  28. }
  29. rev = readl(rom + SI_REV);
  30. switch (rev) {
  31. case 0x1:
  32. cpu_silicon_rev = MX51_CHIP_REV_1_0;
  33. break;
  34. case 0x2:
  35. cpu_silicon_rev = MX51_CHIP_REV_1_1;
  36. break;
  37. case 0x10:
  38. cpu_silicon_rev = MX51_CHIP_REV_2_0;
  39. break;
  40. case 0x20:
  41. cpu_silicon_rev = MX51_CHIP_REV_3_0;
  42. break;
  43. default:
  44. cpu_silicon_rev = 0;
  45. }
  46. iounmap(rom);
  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 (cpu_silicon_rev == -1)
  58. query_silicon_parameter();
  59. return cpu_silicon_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. static int __init mx51_neon_fixup(void)
  69. {
  70. if (mx51_revision() < MX51_CHIP_REV_3_0 && (elf_hwcap & HWCAP_NEON)) {
  71. elf_hwcap &= ~HWCAP_NEON;
  72. pr_info("Turning off NEON support, detected broken NEON implementation\n");
  73. }
  74. return 0;
  75. }
  76. late_initcall(mx51_neon_fixup);
  77. #endif
  78. static int __init post_cpu_init(void)
  79. {
  80. unsigned int reg;
  81. void __iomem *base;
  82. if (!cpu_is_mx51())
  83. return 0;
  84. base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
  85. __raw_writel(0x0, base + 0x40);
  86. __raw_writel(0x0, base + 0x44);
  87. __raw_writel(0x0, base + 0x48);
  88. __raw_writel(0x0, base + 0x4C);
  89. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  90. __raw_writel(reg, base + 0x50);
  91. base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
  92. __raw_writel(0x0, base + 0x40);
  93. __raw_writel(0x0, base + 0x44);
  94. __raw_writel(0x0, base + 0x48);
  95. __raw_writel(0x0, base + 0x4C);
  96. reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
  97. __raw_writel(reg, base + 0x50);
  98. return 0;
  99. }
  100. postcore_initcall(post_cpu_init);