setup-emev2.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. /* 2M mapping for SCU + L2 controller */
  41. {
  42. .virtual = 0xf0000000,
  43. .pfn = __phys_to_pfn(0x1e000000),
  44. .length = SZ_2M,
  45. .type = MT_DEVICE
  46. },
  47. #endif
  48. };
  49. void __init emev2_map_io(void)
  50. {
  51. iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
  52. }
  53. /* UART */
  54. static struct resource uart0_resources[] = {
  55. DEFINE_RES_MEM(0xe1020000, 0x38),
  56. DEFINE_RES_IRQ(40),
  57. };
  58. static struct resource uart1_resources[] = {
  59. DEFINE_RES_MEM(0xe1030000, 0x38),
  60. DEFINE_RES_IRQ(41),
  61. };
  62. static struct resource uart2_resources[] = {
  63. DEFINE_RES_MEM(0xe1040000, 0x38),
  64. DEFINE_RES_IRQ(42),
  65. };
  66. static struct resource uart3_resources[] = {
  67. DEFINE_RES_MEM(0xe1050000, 0x38),
  68. DEFINE_RES_IRQ(43),
  69. };
  70. #define emev2_register_uart(idx) \
  71. platform_device_register_simple("serial8250-em", idx, \
  72. uart##idx##_resources, \
  73. ARRAY_SIZE(uart##idx##_resources))
  74. /* STI */
  75. static struct resource sti_resources[] = {
  76. DEFINE_RES_MEM(0xe0180000, 0x54),
  77. DEFINE_RES_IRQ(157),
  78. };
  79. #define emev2_register_sti() \
  80. platform_device_register_simple("em_sti", 0, \
  81. sti_resources, \
  82. ARRAY_SIZE(sti_resources))
  83. /* GIO */
  84. static struct gpio_em_config gio0_config = {
  85. .gpio_base = 0,
  86. .irq_base = EMEV2_GPIO_IRQ(0),
  87. .number_of_pins = 32,
  88. };
  89. static struct resource gio0_resources[] = {
  90. DEFINE_RES_MEM(0xe0050000, 0x2c),
  91. DEFINE_RES_MEM(0xe0050040, 0x20),
  92. DEFINE_RES_IRQ(99),
  93. DEFINE_RES_IRQ(100),
  94. };
  95. static struct gpio_em_config gio1_config = {
  96. .gpio_base = 32,
  97. .irq_base = EMEV2_GPIO_IRQ(32),
  98. .number_of_pins = 32,
  99. };
  100. static struct resource gio1_resources[] = {
  101. DEFINE_RES_MEM(0xe0050080, 0x2c),
  102. DEFINE_RES_MEM(0xe00500c0, 0x20),
  103. DEFINE_RES_IRQ(101),
  104. DEFINE_RES_IRQ(102),
  105. };
  106. static struct gpio_em_config gio2_config = {
  107. .gpio_base = 64,
  108. .irq_base = EMEV2_GPIO_IRQ(64),
  109. .number_of_pins = 32,
  110. };
  111. static struct resource gio2_resources[] = {
  112. DEFINE_RES_MEM(0xe0050100, 0x2c),
  113. DEFINE_RES_MEM(0xe0050140, 0x20),
  114. DEFINE_RES_IRQ(103),
  115. DEFINE_RES_IRQ(104),
  116. };
  117. static struct gpio_em_config gio3_config = {
  118. .gpio_base = 96,
  119. .irq_base = EMEV2_GPIO_IRQ(96),
  120. .number_of_pins = 32,
  121. };
  122. static struct resource gio3_resources[] = {
  123. DEFINE_RES_MEM(0xe0050180, 0x2c),
  124. DEFINE_RES_MEM(0xe00501c0, 0x20),
  125. DEFINE_RES_IRQ(105),
  126. DEFINE_RES_IRQ(106),
  127. };
  128. static struct gpio_em_config gio4_config = {
  129. .gpio_base = 128,
  130. .irq_base = EMEV2_GPIO_IRQ(128),
  131. .number_of_pins = 31,
  132. };
  133. static struct resource gio4_resources[] = {
  134. DEFINE_RES_MEM(0xe0050200, 0x2c),
  135. DEFINE_RES_MEM(0xe0050240, 0x20),
  136. DEFINE_RES_IRQ(107),
  137. DEFINE_RES_IRQ(108),
  138. };
  139. #define emev2_register_gio(idx) \
  140. platform_device_register_resndata(&platform_bus, "em_gio", \
  141. idx, gio##idx##_resources, \
  142. ARRAY_SIZE(gio##idx##_resources), \
  143. &gio##idx##_config, \
  144. sizeof(struct gpio_em_config))
  145. static struct resource pmu_resources[] = {
  146. DEFINE_RES_IRQ(152),
  147. DEFINE_RES_IRQ(153),
  148. };
  149. #define emev2_register_pmu() \
  150. platform_device_register_simple("arm-pmu", -1, \
  151. pmu_resources, \
  152. ARRAY_SIZE(pmu_resources))
  153. void __init emev2_add_standard_devices(void)
  154. {
  155. if (!IS_ENABLED(CONFIG_COMMON_CLK))
  156. emev2_clock_init();
  157. emev2_register_uart(0);
  158. emev2_register_uart(1);
  159. emev2_register_uart(2);
  160. emev2_register_uart(3);
  161. emev2_register_sti();
  162. emev2_register_gio(0);
  163. emev2_register_gio(1);
  164. emev2_register_gio(2);
  165. emev2_register_gio(3);
  166. emev2_register_gio(4);
  167. emev2_register_pmu();
  168. }
  169. void __init emev2_init_delay(void)
  170. {
  171. shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
  172. }
  173. #ifdef CONFIG_USE_OF
  174. static const char *emev2_boards_compat_dt[] __initdata = {
  175. "renesas,emev2",
  176. NULL,
  177. };
  178. DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
  179. .smp = smp_ops(emev2_smp_ops),
  180. .map_io = emev2_map_io,
  181. .init_early = emev2_init_delay,
  182. .dt_compat = emev2_boards_compat_dt,
  183. MACHINE_END
  184. #endif /* CONFIG_USE_OF */