id.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/init.h>
  9. #include <linux/io.h>
  10. #include <asm/cputype.h>
  11. #include <asm/tlbflush.h>
  12. #include <asm/cacheflush.h>
  13. #include <asm/mach/map.h>
  14. #include <mach/hardware.h>
  15. #include <mach/setup.h>
  16. #include "id.h"
  17. struct dbx500_asic_id dbx500_id;
  18. static unsigned int ux500_read_asicid(phys_addr_t addr)
  19. {
  20. phys_addr_t base = addr & ~0xfff;
  21. struct map_desc desc = {
  22. .virtual = UX500_VIRT_ROM,
  23. .pfn = __phys_to_pfn(base),
  24. .length = SZ_16K,
  25. .type = MT_DEVICE,
  26. };
  27. iotable_init(&desc, 1);
  28. /* As in devicemaps_init() */
  29. local_flush_tlb_all();
  30. flush_cache_all();
  31. return readl(IOMEM(UX500_VIRT_ROM + (addr & 0xfff)));
  32. }
  33. static void ux500_print_soc_info(unsigned int asicid)
  34. {
  35. unsigned int rev = dbx500_revision();
  36. pr_info("DB%4x ", dbx500_partnumber());
  37. if (rev == 0x01)
  38. pr_cont("Early Drop");
  39. else if (rev >= 0xA0)
  40. pr_cont("v%d.%d" , (rev >> 4) - 0xA + 1, rev & 0xf);
  41. else
  42. pr_cont("Unknown");
  43. pr_cont(" [%#010x]\n", asicid);
  44. }
  45. static unsigned int partnumber(unsigned int asicid)
  46. {
  47. return (asicid >> 8) & 0xffff;
  48. }
  49. /*
  50. * SOC MIDR ASICID ADDRESS ASICID VALUE
  51. * DB8500ed 0x410fc090 0x9001FFF4 0x00850001
  52. * DB8500v1 0x411fc091 0x9001FFF4 0x008500A0
  53. * DB8500v1.1 0x411fc091 0x9001FFF4 0x008500A1
  54. * DB8500v2 0x412fc091 0x9001DBF4 0x008500B0
  55. * DB8520v2.2 0x412fc091 0x9001DBF4 0x008500B2
  56. * DB5500v1 0x412fc091 0x9001FFF4 0x005500A0
  57. * DB9540 0x413fc090 0xFFFFDBF4 0x009540xx
  58. */
  59. void __init ux500_map_io(void)
  60. {
  61. unsigned int cpuid = read_cpuid_id();
  62. unsigned int asicid = 0;
  63. phys_addr_t addr = 0;
  64. switch (cpuid) {
  65. case 0x410fc090: /* DB8500ed */
  66. case 0x411fc091: /* DB8500v1 */
  67. addr = 0x9001FFF4;
  68. break;
  69. case 0x412fc091: /* DB8520 / DB8500v2 / DB5500v1 */
  70. asicid = ux500_read_asicid(0x9001DBF4);
  71. if (partnumber(asicid) == 0x8500 ||
  72. partnumber(asicid) == 0x8520)
  73. /* DB8500v2 */
  74. break;
  75. /* DB5500v1 */
  76. addr = 0x9001FFF4;
  77. break;
  78. case 0x413fc090: /* DB9540 */
  79. addr = 0xFFFFDBF4;
  80. break;
  81. }
  82. if (addr)
  83. asicid = ux500_read_asicid(addr);
  84. if (!asicid) {
  85. pr_err("Unable to identify SoC\n");
  86. ux500_unknown_soc();
  87. }
  88. dbx500_id.process = asicid >> 24;
  89. dbx500_id.partnumber = partnumber(asicid);
  90. dbx500_id.revision = asicid & 0xff;
  91. ux500_print_soc_info(asicid);
  92. }