cpu-db8500.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (C) 2008-2009 ST-Ericsson
  3. *
  4. * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
  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 version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/types.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/amba/bus.h>
  15. #include <linux/irq.h>
  16. #include <linux/gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/io.h>
  19. #include <asm/mach/map.h>
  20. #include <mach/hardware.h>
  21. #include <mach/setup.h>
  22. #include <mach/devices.h>
  23. static struct platform_device *platform_devs[] __initdata = {
  24. &u8500_gpio_devs[0],
  25. &u8500_gpio_devs[1],
  26. &u8500_gpio_devs[2],
  27. &u8500_gpio_devs[3],
  28. &u8500_gpio_devs[4],
  29. &u8500_gpio_devs[5],
  30. &u8500_gpio_devs[6],
  31. &u8500_gpio_devs[7],
  32. &u8500_gpio_devs[8],
  33. &u8500_dma40_device,
  34. };
  35. /* minimum static i/o mapping required to boot U8500 platforms */
  36. static struct map_desc u8500_io_desc[] __initdata = {
  37. __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
  38. __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE, SZ_4K),
  39. __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
  40. __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
  41. __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
  42. __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
  43. __MEM_DEV_DESC(U8500_BOOT_ROM_BASE, SZ_1M),
  44. };
  45. static struct map_desc u8500ed_io_desc[] __initdata = {
  46. __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
  47. __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
  48. };
  49. static struct map_desc u8500v1_io_desc[] __initdata = {
  50. __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
  51. };
  52. /*
  53. * Functions to differentiate between later ASICs
  54. * We look into the end of the ROM to locate the hardcoded ASIC ID.
  55. * This is only needed to differentiate between minor revisions and
  56. * process variants of an ASIC, the major revisions are encoded in
  57. * the cpuid.
  58. */
  59. #define U8500_ASIC_ID_LOC_ED_V1 (U8500_BOOT_ROM_BASE + 0x1FFF4)
  60. #define U8500_ASIC_ID_LOC_V2 (U8500_BOOT_ROM_BASE + 0x1DBF4)
  61. #define U8500_ASIC_REV_ED 0x01
  62. #define U8500_ASIC_REV_V10 0xA0
  63. #define U8500_ASIC_REV_V11 0xA1
  64. #define U8500_ASIC_REV_V20 0xB0
  65. /**
  66. * struct db8500_asic_id - fields of the ASIC ID
  67. * @process: the manufacturing process, 0x40 is 40 nm
  68. * 0x00 is "standard"
  69. * @partnumber: hithereto 0x8500 for DB8500
  70. * @revision: version code in the series
  71. * This field definion is not formally defined but makes
  72. * sense.
  73. */
  74. struct db8500_asic_id {
  75. u8 process;
  76. u16 partnumber;
  77. u8 revision;
  78. };
  79. /* This isn't going to change at runtime */
  80. static struct db8500_asic_id db8500_id;
  81. static void __init get_db8500_asic_id(void)
  82. {
  83. u32 asicid;
  84. if (cpu_is_u8500v1() || cpu_is_u8500ed())
  85. asicid = readl(__io_address(U8500_ASIC_ID_LOC_ED_V1));
  86. else if (cpu_is_u8500v2())
  87. asicid = readl(__io_address(U8500_ASIC_ID_LOC_V2));
  88. else
  89. BUG();
  90. db8500_id.process = (asicid >> 24);
  91. db8500_id.partnumber = (asicid >> 16) & 0xFFFFU;
  92. db8500_id.revision = asicid & 0xFFU;
  93. }
  94. bool cpu_is_u8500v10(void)
  95. {
  96. return (db8500_id.revision == U8500_ASIC_REV_V10);
  97. }
  98. bool cpu_is_u8500v11(void)
  99. {
  100. return (db8500_id.revision == U8500_ASIC_REV_V11);
  101. }
  102. bool cpu_is_u8500v20(void)
  103. {
  104. return (db8500_id.revision == U8500_ASIC_REV_V20);
  105. }
  106. void __init u8500_map_io(void)
  107. {
  108. ux500_map_io();
  109. iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
  110. if (cpu_is_u8500ed())
  111. iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
  112. else
  113. iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
  114. /* Read out the ASIC ID as early as we can */
  115. get_db8500_asic_id();
  116. }
  117. /*
  118. * This function is called from the board init
  119. */
  120. void __init u8500_init_devices(void)
  121. {
  122. /* Display some ASIC boilerplate */
  123. pr_info("DB8500: process: %02x, revision ID: 0x%02x\n",
  124. db8500_id.process, db8500_id.revision);
  125. if (cpu_is_u8500ed())
  126. pr_info("DB8500: Early Drop (ED)\n");
  127. else if (cpu_is_u8500v10())
  128. pr_info("DB8500: version 1.0\n");
  129. else if (cpu_is_u8500v11())
  130. pr_info("DB8500: version 1.1\n");
  131. else if (cpu_is_u8500v20())
  132. pr_info("DB8500: version 2.0\n");
  133. else
  134. pr_warning("ASIC: UNKNOWN SILICON VERSION!\n");
  135. ux500_init_devices();
  136. if (cpu_is_u8500ed())
  137. dma40_u8500ed_fixup();
  138. /* Register the platform devices */
  139. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  140. return ;
  141. }