cpu-imx25.c 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * MX25 CPU type detection
  4. *
  5. * Copyright (c) 2009 Daniel Mack <[email protected]>
  6. * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved
  7. */
  8. #include <linux/module.h>
  9. #include <linux/io.h>
  10. #include <linux/of.h>
  11. #include <linux/of_address.h>
  12. #include "iim.h"
  13. #include "hardware.h"
  14. static int mx25_cpu_rev = -1;
  15. static int mx25_read_cpu_rev(void)
  16. {
  17. u32 rev;
  18. void __iomem *iim_base;
  19. struct device_node *np;
  20. np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim");
  21. iim_base = of_iomap(np, 0);
  22. of_node_put(np);
  23. BUG_ON(!iim_base);
  24. rev = readl(iim_base + MXC_IIMSREV);
  25. iounmap(iim_base);
  26. switch (rev) {
  27. case 0x00:
  28. return IMX_CHIP_REVISION_1_0;
  29. case 0x01:
  30. return IMX_CHIP_REVISION_1_1;
  31. case 0x02:
  32. return IMX_CHIP_REVISION_1_2;
  33. default:
  34. return IMX_CHIP_REVISION_UNKNOWN;
  35. }
  36. }
  37. int mx25_revision(void)
  38. {
  39. if (mx25_cpu_rev == -1)
  40. mx25_cpu_rev = mx25_read_cpu_rev();
  41. return mx25_cpu_rev;
  42. }
  43. EXPORT_SYMBOL(mx25_revision);