cpu-imx25.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * MX25 CPU type detection
  3. *
  4. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  5. * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/io.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #include "iim.h"
  17. #include "hardware.h"
  18. static int mx25_cpu_rev = -1;
  19. static int mx25_read_cpu_rev(void)
  20. {
  21. u32 rev;
  22. void __iomem *iim_base;
  23. struct device_node *np;
  24. np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim");
  25. iim_base = of_iomap(np, 0);
  26. BUG_ON(!iim_base);
  27. rev = readl(iim_base + MXC_IIMSREV);
  28. iounmap(iim_base);
  29. switch (rev) {
  30. case 0x00:
  31. return IMX_CHIP_REVISION_1_0;
  32. case 0x01:
  33. return IMX_CHIP_REVISION_1_1;
  34. default:
  35. return IMX_CHIP_REVISION_UNKNOWN;
  36. }
  37. }
  38. int mx25_revision(void)
  39. {
  40. if (mx25_cpu_rev == -1)
  41. mx25_cpu_rev = mx25_read_cpu_rev();
  42. return mx25_cpu_rev;
  43. }
  44. EXPORT_SYMBOL(mx25_revision);