setup-mxg.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Renesas MX-G (R8A03022BG) Setup
  3. *
  4. * Copyright (C) 2008, 2009 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/serial_sci.h>
  14. #include <linux/sh_timer.h>
  15. enum {
  16. UNUSED = 0,
  17. /* interrupt sources */
  18. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  19. IRQ8, IRQ9, IRQ10, IRQ11, IRQ12, IRQ13, IRQ14, IRQ15,
  20. PINT0, PINT1, PINT2, PINT3, PINT4, PINT5, PINT6, PINT7,
  21. SINT8, SINT7, SINT6, SINT5, SINT4, SINT3, SINT2, SINT1,
  22. SCIF0, SCIF1,
  23. MTU2_GROUP1, MTU2_GROUP2, MTU2_GROUP3, MTU2_GROUP4, MTU2_GROUP5,
  24. MTU2_TGI3B, MTU2_TGI3C,
  25. /* interrupt groups */
  26. PINT,
  27. };
  28. static struct intc_vect vectors[] __initdata = {
  29. INTC_IRQ(IRQ0, 64), INTC_IRQ(IRQ1, 65),
  30. INTC_IRQ(IRQ2, 66), INTC_IRQ(IRQ3, 67),
  31. INTC_IRQ(IRQ4, 68), INTC_IRQ(IRQ5, 69),
  32. INTC_IRQ(IRQ6, 70), INTC_IRQ(IRQ7, 71),
  33. INTC_IRQ(IRQ8, 72), INTC_IRQ(IRQ9, 73),
  34. INTC_IRQ(IRQ10, 74), INTC_IRQ(IRQ11, 75),
  35. INTC_IRQ(IRQ12, 76), INTC_IRQ(IRQ13, 77),
  36. INTC_IRQ(IRQ14, 78), INTC_IRQ(IRQ15, 79),
  37. INTC_IRQ(PINT0, 80), INTC_IRQ(PINT1, 81),
  38. INTC_IRQ(PINT2, 82), INTC_IRQ(PINT3, 83),
  39. INTC_IRQ(PINT4, 84), INTC_IRQ(PINT5, 85),
  40. INTC_IRQ(PINT6, 86), INTC_IRQ(PINT7, 87),
  41. INTC_IRQ(SINT8, 94), INTC_IRQ(SINT7, 95),
  42. INTC_IRQ(SINT6, 96), INTC_IRQ(SINT5, 97),
  43. INTC_IRQ(SINT4, 98), INTC_IRQ(SINT3, 99),
  44. INTC_IRQ(SINT2, 100), INTC_IRQ(SINT1, 101),
  45. INTC_IRQ(SCIF0, 220), INTC_IRQ(SCIF0, 221),
  46. INTC_IRQ(SCIF0, 222), INTC_IRQ(SCIF0, 223),
  47. INTC_IRQ(SCIF1, 224), INTC_IRQ(SCIF1, 225),
  48. INTC_IRQ(SCIF1, 226), INTC_IRQ(SCIF1, 227),
  49. INTC_IRQ(MTU2_GROUP1, 228), INTC_IRQ(MTU2_GROUP1, 229),
  50. INTC_IRQ(MTU2_GROUP1, 230), INTC_IRQ(MTU2_GROUP1, 231),
  51. INTC_IRQ(MTU2_GROUP1, 232), INTC_IRQ(MTU2_GROUP1, 233),
  52. INTC_IRQ(MTU2_GROUP2, 234), INTC_IRQ(MTU2_GROUP2, 235),
  53. INTC_IRQ(MTU2_GROUP2, 236), INTC_IRQ(MTU2_GROUP2, 237),
  54. INTC_IRQ(MTU2_GROUP2, 238), INTC_IRQ(MTU2_GROUP2, 239),
  55. INTC_IRQ(MTU2_GROUP3, 240), INTC_IRQ(MTU2_GROUP3, 241),
  56. INTC_IRQ(MTU2_GROUP3, 242), INTC_IRQ(MTU2_GROUP3, 243),
  57. INTC_IRQ(MTU2_TGI3B, 244),
  58. INTC_IRQ(MTU2_TGI3C, 245),
  59. INTC_IRQ(MTU2_GROUP4, 246), INTC_IRQ(MTU2_GROUP4, 247),
  60. INTC_IRQ(MTU2_GROUP4, 248), INTC_IRQ(MTU2_GROUP4, 249),
  61. INTC_IRQ(MTU2_GROUP4, 250), INTC_IRQ(MTU2_GROUP4, 251),
  62. INTC_IRQ(MTU2_GROUP5, 252), INTC_IRQ(MTU2_GROUP5, 253),
  63. INTC_IRQ(MTU2_GROUP5, 254), INTC_IRQ(MTU2_GROUP5, 255),
  64. };
  65. static struct intc_group groups[] __initdata = {
  66. INTC_GROUP(PINT, PINT0, PINT1, PINT2, PINT3,
  67. PINT4, PINT5, PINT6, PINT7),
  68. };
  69. static struct intc_prio_reg prio_registers[] __initdata = {
  70. { 0xfffd9418, 0, 16, 4, /* IPR01 */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  71. { 0xfffd941a, 0, 16, 4, /* IPR02 */ { IRQ4, IRQ5, IRQ6, IRQ7 } },
  72. { 0xfffd941c, 0, 16, 4, /* IPR03 */ { IRQ8, IRQ9, IRQ10, IRQ11 } },
  73. { 0xfffd941e, 0, 16, 4, /* IPR04 */ { IRQ12, IRQ13, IRQ14, IRQ15 } },
  74. { 0xfffd9420, 0, 16, 4, /* IPR05 */ { PINT, 0, 0, 0 } },
  75. { 0xfffd9800, 0, 16, 4, /* IPR06 */ { } },
  76. { 0xfffd9802, 0, 16, 4, /* IPR07 */ { } },
  77. { 0xfffd9804, 0, 16, 4, /* IPR08 */ { } },
  78. { 0xfffd9806, 0, 16, 4, /* IPR09 */ { } },
  79. { 0xfffd9808, 0, 16, 4, /* IPR10 */ { } },
  80. { 0xfffd980a, 0, 16, 4, /* IPR11 */ { } },
  81. { 0xfffd980c, 0, 16, 4, /* IPR12 */ { } },
  82. { 0xfffd980e, 0, 16, 4, /* IPR13 */ { } },
  83. { 0xfffd9810, 0, 16, 4, /* IPR14 */ { 0, 0, 0, SCIF0 } },
  84. { 0xfffd9812, 0, 16, 4, /* IPR15 */
  85. { SCIF1, MTU2_GROUP1, MTU2_GROUP2, MTU2_GROUP3 } },
  86. { 0xfffd9814, 0, 16, 4, /* IPR16 */
  87. { MTU2_TGI3B, MTU2_TGI3C, MTU2_GROUP4, MTU2_GROUP5 } },
  88. };
  89. static struct intc_mask_reg mask_registers[] __initdata = {
  90. { 0xfffd9408, 0, 16, /* PINTER */
  91. { 0, 0, 0, 0, 0, 0, 0, 0,
  92. PINT7, PINT6, PINT5, PINT4, PINT3, PINT2, PINT1, PINT0 } },
  93. };
  94. static DECLARE_INTC_DESC(intc_desc, "mxg", vectors, groups,
  95. mask_registers, prio_registers, NULL);
  96. static struct resource mtu2_resources[] = {
  97. DEFINE_RES_MEM(0xff801000, 0x400),
  98. DEFINE_RES_IRQ_NAMED(228, "tgi0a"),
  99. DEFINE_RES_IRQ_NAMED(234, "tgi1a"),
  100. DEFINE_RES_IRQ_NAMED(240, "tgi2a"),
  101. };
  102. static struct platform_device mtu2_device = {
  103. .name = "sh-mtu2",
  104. .id = -1,
  105. .resource = mtu2_resources,
  106. .num_resources = ARRAY_SIZE(mtu2_resources),
  107. };
  108. static struct plat_sci_port scif0_platform_data = {
  109. .flags = UPF_BOOT_AUTOCONF,
  110. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  111. .type = PORT_SCIF,
  112. };
  113. static struct resource scif0_resources[] = {
  114. DEFINE_RES_MEM(0xff804000, 0x100),
  115. DEFINE_RES_IRQ(220),
  116. };
  117. static struct platform_device scif0_device = {
  118. .name = "sh-sci",
  119. .id = 0,
  120. .resource = scif0_resources,
  121. .num_resources = ARRAY_SIZE(scif0_resources),
  122. .dev = {
  123. .platform_data = &scif0_platform_data,
  124. },
  125. };
  126. static struct platform_device *mxg_devices[] __initdata = {
  127. &scif0_device,
  128. &mtu2_device,
  129. };
  130. static int __init mxg_devices_setup(void)
  131. {
  132. return platform_add_devices(mxg_devices,
  133. ARRAY_SIZE(mxg_devices));
  134. }
  135. arch_initcall(mxg_devices_setup);
  136. void __init plat_irq_setup(void)
  137. {
  138. register_intc_controller(&intc_desc);
  139. }
  140. static struct platform_device *mxg_early_devices[] __initdata = {
  141. &scif0_device,
  142. &mtu2_device,
  143. };
  144. void __init plat_early_device_setup(void)
  145. {
  146. early_platform_add_devices(mxg_early_devices,
  147. ARRAY_SIZE(mxg_early_devices));
  148. }