setup-emev2.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Emma Mobile EV2 processor support
  3. *
  4. * Copyright (C) 2012 Magnus Damm
  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; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/irq.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/platform_data/gpio-em.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/delay.h>
  27. #include <linux/input.h>
  28. #include <linux/io.h>
  29. #include <linux/irqchip/arm-gic.h>
  30. #include <mach/hardware.h>
  31. #include <mach/common.h>
  32. #include <mach/emev2.h>
  33. #include <mach/irqs.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/time.h>
  38. static struct map_desc emev2_io_desc[] __initdata = {
  39. #ifdef CONFIG_SMP
  40. /* 128K entity map for 0xe0100000 (SMU) */
  41. {
  42. .virtual = 0xe0100000,
  43. .pfn = __phys_to_pfn(0xe0100000),
  44. .length = SZ_128K,
  45. .type = MT_DEVICE
  46. },
  47. /* 2M mapping for SCU + L2 controller */
  48. {
  49. .virtual = 0xf0000000,
  50. .pfn = __phys_to_pfn(0x1e000000),
  51. .length = SZ_2M,
  52. .type = MT_DEVICE
  53. },
  54. #endif
  55. };
  56. void __init emev2_map_io(void)
  57. {
  58. iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
  59. }
  60. /* UART */
  61. static struct resource uart0_resources[] = {
  62. DEFINE_RES_MEM(0xe1020000, 0x38),
  63. DEFINE_RES_IRQ(40),
  64. };
  65. static struct resource uart1_resources[] = {
  66. DEFINE_RES_MEM(0xe1030000, 0x38),
  67. DEFINE_RES_IRQ(41),
  68. };
  69. static struct resource uart2_resources[] = {
  70. DEFINE_RES_MEM(0xe1040000, 0x38),
  71. DEFINE_RES_IRQ(42),
  72. };
  73. static struct resource uart3_resources[] = {
  74. DEFINE_RES_MEM(0xe1050000, 0x38),
  75. DEFINE_RES_IRQ(43),
  76. };
  77. #define emev2_register_uart(idx) \
  78. platform_device_register_simple("serial8250-em", idx, \
  79. uart##idx##_resources, \
  80. ARRAY_SIZE(uart##idx##_resources))
  81. /* STI */
  82. static struct resource sti_resources[] = {
  83. DEFINE_RES_MEM(0xe0180000, 0x54),
  84. DEFINE_RES_IRQ(157),
  85. };
  86. #define emev2_register_sti() \
  87. platform_device_register_simple("em_sti", 0, \
  88. sti_resources, \
  89. ARRAY_SIZE(sti_resources))
  90. /* GIO */
  91. static struct gpio_em_config gio0_config = {
  92. .gpio_base = 0,
  93. .irq_base = EMEV2_GPIO_IRQ(0),
  94. .number_of_pins = 32,
  95. };
  96. static struct resource gio0_resources[] = {
  97. DEFINE_RES_MEM(0xe0050000, 0x2c),
  98. DEFINE_RES_MEM(0xe0050040, 0x20),
  99. DEFINE_RES_IRQ(99),
  100. DEFINE_RES_IRQ(100),
  101. };
  102. static struct gpio_em_config gio1_config = {
  103. .gpio_base = 32,
  104. .irq_base = EMEV2_GPIO_IRQ(32),
  105. .number_of_pins = 32,
  106. };
  107. static struct resource gio1_resources[] = {
  108. DEFINE_RES_MEM(0xe0050080, 0x2c),
  109. DEFINE_RES_MEM(0xe00500c0, 0x20),
  110. DEFINE_RES_IRQ(101),
  111. DEFINE_RES_IRQ(102),
  112. };
  113. static struct gpio_em_config gio2_config = {
  114. .gpio_base = 64,
  115. .irq_base = EMEV2_GPIO_IRQ(64),
  116. .number_of_pins = 32,
  117. };
  118. static struct resource gio2_resources[] = {
  119. DEFINE_RES_MEM(0xe0050100, 0x2c),
  120. DEFINE_RES_MEM(0xe0050140, 0x20),
  121. DEFINE_RES_IRQ(103),
  122. DEFINE_RES_IRQ(104),
  123. };
  124. static struct gpio_em_config gio3_config = {
  125. .gpio_base = 96,
  126. .irq_base = EMEV2_GPIO_IRQ(96),
  127. .number_of_pins = 32,
  128. };
  129. static struct resource gio3_resources[] = {
  130. DEFINE_RES_MEM(0xe0050180, 0x2c),
  131. DEFINE_RES_MEM(0xe00501c0, 0x20),
  132. DEFINE_RES_IRQ(105),
  133. DEFINE_RES_IRQ(106),
  134. };
  135. static struct gpio_em_config gio4_config = {
  136. .gpio_base = 128,
  137. .irq_base = EMEV2_GPIO_IRQ(128),
  138. .number_of_pins = 31,
  139. };
  140. static struct resource gio4_resources[] = {
  141. DEFINE_RES_MEM(0xe0050200, 0x2c),
  142. DEFINE_RES_MEM(0xe0050240, 0x20),
  143. DEFINE_RES_IRQ(107),
  144. DEFINE_RES_IRQ(108),
  145. };
  146. #define emev2_register_gio(idx) \
  147. platform_device_register_resndata(&platform_bus, "em_gio", \
  148. idx, gio##idx##_resources, \
  149. ARRAY_SIZE(gio##idx##_resources), \
  150. &gio##idx##_config, \
  151. sizeof(struct gpio_em_config))
  152. static struct resource pmu_resources[] = {
  153. DEFINE_RES_IRQ(152),
  154. DEFINE_RES_IRQ(153),
  155. };
  156. #define emev2_register_pmu() \
  157. platform_device_register_simple("arm-pmu", -1, \
  158. pmu_resources, \
  159. ARRAY_SIZE(pmu_resources))
  160. void __init emev2_add_standard_devices(void)
  161. {
  162. emev2_clock_init();
  163. emev2_register_uart(0);
  164. emev2_register_uart(1);
  165. emev2_register_uart(2);
  166. emev2_register_uart(3);
  167. emev2_register_sti();
  168. emev2_register_gio(0);
  169. emev2_register_gio(1);
  170. emev2_register_gio(2);
  171. emev2_register_gio(3);
  172. emev2_register_gio(4);
  173. emev2_register_pmu();
  174. }
  175. void __init emev2_init_delay(void)
  176. {
  177. shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
  178. }
  179. void __init emev2_init_irq(void)
  180. {
  181. void __iomem *gic_dist_base;
  182. void __iomem *gic_cpu_base;
  183. /* Static mappings, never released */
  184. gic_dist_base = ioremap(0xe0028000, PAGE_SIZE);
  185. gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE);
  186. BUG_ON(!gic_dist_base || !gic_cpu_base);
  187. /* Use GIC to handle interrupts */
  188. gic_init(0, 29, gic_dist_base, gic_cpu_base);
  189. }
  190. #ifdef CONFIG_USE_OF
  191. static const char *emev2_boards_compat_dt[] __initdata = {
  192. "renesas,emev2",
  193. NULL,
  194. };
  195. DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
  196. .smp = smp_ops(emev2_smp_ops),
  197. .init_early = emev2_init_delay,
  198. .nr_irqs = NR_IRQS_LEGACY,
  199. .dt_compat = emev2_boards_compat_dt,
  200. MACHINE_END
  201. #endif /* CONFIG_USE_OF */