cpu-db8500.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. #include "devices-db8500.h"
  24. static struct platform_device *platform_devs[] __initdata = {
  25. &u8500_dma40_device,
  26. };
  27. /* minimum static i/o mapping required to boot U8500 platforms */
  28. static struct map_desc u8500_io_desc[] __initdata = {
  29. __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
  30. __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
  31. __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
  32. __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
  33. __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
  34. __MEM_DEV_DESC(U8500_BOOT_ROM_BASE, SZ_1M),
  35. };
  36. static struct map_desc u8500_ed_io_desc[] __initdata = {
  37. __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
  38. __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
  39. };
  40. static struct map_desc u8500_v1_io_desc[] __initdata = {
  41. __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
  42. __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE_V1, SZ_4K),
  43. };
  44. static struct map_desc u8500_v2_io_desc[] __initdata = {
  45. __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE, SZ_4K),
  46. };
  47. /*
  48. * Functions to differentiate between later ASICs
  49. * We look into the end of the ROM to locate the hardcoded ASIC ID.
  50. * This is only needed to differentiate between minor revisions and
  51. * process variants of an ASIC, the major revisions are encoded in
  52. * the cpuid.
  53. */
  54. #define U8500_ASIC_ID_LOC_ED_V1 (U8500_BOOT_ROM_BASE + 0x1FFF4)
  55. #define U8500_ASIC_ID_LOC_V2 (U8500_BOOT_ROM_BASE + 0x1DBF4)
  56. #define U8500_ASIC_REV_ED 0x01
  57. #define U8500_ASIC_REV_V10 0xA0
  58. #define U8500_ASIC_REV_V11 0xA1
  59. #define U8500_ASIC_REV_V20 0xB0
  60. /**
  61. * struct db8500_asic_id - fields of the ASIC ID
  62. * @process: the manufacturing process, 0x40 is 40 nm
  63. * 0x00 is "standard"
  64. * @partnumber: hithereto 0x8500 for DB8500
  65. * @revision: version code in the series
  66. * This field definion is not formally defined but makes
  67. * sense.
  68. */
  69. struct db8500_asic_id {
  70. u8 process;
  71. u16 partnumber;
  72. u8 revision;
  73. };
  74. /* This isn't going to change at runtime */
  75. static struct db8500_asic_id db8500_id;
  76. static void __init get_db8500_asic_id(void)
  77. {
  78. u32 asicid;
  79. if (cpu_is_u8500v1() || cpu_is_u8500ed())
  80. asicid = readl(__io_address(U8500_ASIC_ID_LOC_ED_V1));
  81. else if (cpu_is_u8500v2())
  82. asicid = readl(__io_address(U8500_ASIC_ID_LOC_V2));
  83. else
  84. BUG();
  85. db8500_id.process = (asicid >> 24);
  86. db8500_id.partnumber = (asicid >> 16) & 0xFFFFU;
  87. db8500_id.revision = asicid & 0xFFU;
  88. }
  89. bool cpu_is_u8500v10(void)
  90. {
  91. return (db8500_id.revision == U8500_ASIC_REV_V10);
  92. }
  93. bool cpu_is_u8500v11(void)
  94. {
  95. return (db8500_id.revision == U8500_ASIC_REV_V11);
  96. }
  97. bool cpu_is_u8500v20(void)
  98. {
  99. return (db8500_id.revision == U8500_ASIC_REV_V20);
  100. }
  101. void __init u8500_map_io(void)
  102. {
  103. ux500_map_io();
  104. iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
  105. if (cpu_is_u8500ed())
  106. iotable_init(u8500_ed_io_desc, ARRAY_SIZE(u8500_ed_io_desc));
  107. else if (cpu_is_u8500v1())
  108. iotable_init(u8500_v1_io_desc, ARRAY_SIZE(u8500_v1_io_desc));
  109. else if (cpu_is_u8500v2())
  110. iotable_init(u8500_v2_io_desc, ARRAY_SIZE(u8500_v2_io_desc));
  111. /* Read out the ASIC ID as early as we can */
  112. get_db8500_asic_id();
  113. }
  114. static resource_size_t __initdata db8500_gpio_base[] = {
  115. U8500_GPIOBANK0_BASE,
  116. U8500_GPIOBANK1_BASE,
  117. U8500_GPIOBANK2_BASE,
  118. U8500_GPIOBANK3_BASE,
  119. U8500_GPIOBANK4_BASE,
  120. U8500_GPIOBANK5_BASE,
  121. U8500_GPIOBANK6_BASE,
  122. U8500_GPIOBANK7_BASE,
  123. U8500_GPIOBANK8_BASE,
  124. };
  125. static void __init db8500_add_gpios(void)
  126. {
  127. struct nmk_gpio_platform_data pdata = {
  128. /* No custom data yet */
  129. };
  130. dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base),
  131. IRQ_DB8500_GPIO0, &pdata);
  132. }
  133. /*
  134. * This function is called from the board init
  135. */
  136. void __init u8500_init_devices(void)
  137. {
  138. /* Display some ASIC boilerplate */
  139. pr_info("DB8500: process: %02x, revision ID: 0x%02x\n",
  140. db8500_id.process, db8500_id.revision);
  141. if (cpu_is_u8500ed())
  142. pr_info("DB8500: Early Drop (ED)\n");
  143. else if (cpu_is_u8500v10())
  144. pr_info("DB8500: version 1.0\n");
  145. else if (cpu_is_u8500v11())
  146. pr_info("DB8500: version 1.1\n");
  147. else if (cpu_is_u8500v20())
  148. pr_info("DB8500: version 2.0\n");
  149. else
  150. pr_warning("ASIC: UNKNOWN SILICON VERSION!\n");
  151. if (cpu_is_u8500ed())
  152. dma40_u8500ed_fixup();
  153. db8500_add_rtc();
  154. db8500_add_gpios();
  155. platform_device_register_simple("cpufreq-u8500", -1, NULL, 0);
  156. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  157. return ;
  158. }