setup-emev2.c 5.1 KB

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