cpu-imx31.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * MX31 CPU type detection
  3. *
  4. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/io.h>
  13. #include "common.h"
  14. #include "hardware.h"
  15. #include "iim.h"
  16. static int mx31_cpu_rev = -1;
  17. static struct {
  18. u8 srev;
  19. const char *name;
  20. unsigned int rev;
  21. } mx31_cpu_type[] = {
  22. { .srev = 0x00, .name = "i.MX31(L)", .rev = IMX_CHIP_REVISION_1_0 },
  23. { .srev = 0x10, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_1 },
  24. { .srev = 0x11, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_1 },
  25. { .srev = 0x12, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_1 },
  26. { .srev = 0x13, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_1 },
  27. { .srev = 0x14, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_2 },
  28. { .srev = 0x15, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_2 },
  29. { .srev = 0x28, .name = "i.MX31", .rev = IMX_CHIP_REVISION_2_0 },
  30. { .srev = 0x29, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_2_0 },
  31. };
  32. static int mx31_read_cpu_rev(void)
  33. {
  34. u32 i, srev;
  35. /* read SREV register from IIM module */
  36. srev = imx_readl(MX31_IO_ADDRESS(MX31_IIM_BASE_ADDR + MXC_IIMSREV));
  37. srev &= 0xff;
  38. for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
  39. if (srev == mx31_cpu_type[i].srev) {
  40. imx_print_silicon_rev(mx31_cpu_type[i].name,
  41. mx31_cpu_type[i].rev);
  42. return mx31_cpu_type[i].rev;
  43. }
  44. imx_print_silicon_rev("i.MX31", IMX_CHIP_REVISION_UNKNOWN);
  45. return IMX_CHIP_REVISION_UNKNOWN;
  46. }
  47. int mx31_revision(void)
  48. {
  49. if (mx31_cpu_rev == -1)
  50. mx31_cpu_rev = mx31_read_cpu_rev();
  51. return mx31_cpu_rev;
  52. }
  53. EXPORT_SYMBOL(mx31_revision);