setup-sh7750.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * SH7750/SH7751 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2006 Jamie Lenehan
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/init.h>
  13. #include <linux/serial.h>
  14. #include <linux/io.h>
  15. #include <asm/sci.h>
  16. static struct resource rtc_resources[] = {
  17. [0] = {
  18. .start = 0xffc80000,
  19. .end = 0xffc80000 + 0x58 - 1,
  20. .flags = IORESOURCE_IO,
  21. },
  22. [1] = {
  23. /* Period IRQ */
  24. .start = 21,
  25. .flags = IORESOURCE_IRQ,
  26. },
  27. [2] = {
  28. /* Carry IRQ */
  29. .start = 22,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. [3] = {
  33. /* Alarm IRQ */
  34. .start = 20,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct platform_device rtc_device = {
  39. .name = "sh-rtc",
  40. .id = -1,
  41. .num_resources = ARRAY_SIZE(rtc_resources),
  42. .resource = rtc_resources,
  43. };
  44. static struct plat_sci_port sci_platform_data[] = {
  45. {
  46. #ifndef CONFIG_SH_RTS7751R2D
  47. .mapbase = 0xffe00000,
  48. .flags = UPF_BOOT_AUTOCONF,
  49. .type = PORT_SCI,
  50. .irqs = { 23, 24, 25, 0 },
  51. }, {
  52. #endif
  53. .mapbase = 0xffe80000,
  54. .flags = UPF_BOOT_AUTOCONF,
  55. .type = PORT_SCIF,
  56. .irqs = { 40, 41, 43, 42 },
  57. }, {
  58. .flags = 0,
  59. }
  60. };
  61. static struct platform_device sci_device = {
  62. .name = "sh-sci",
  63. .id = -1,
  64. .dev = {
  65. .platform_data = sci_platform_data,
  66. },
  67. };
  68. static struct platform_device *sh7750_devices[] __initdata = {
  69. &rtc_device,
  70. &sci_device,
  71. };
  72. static int __init sh7750_devices_setup(void)
  73. {
  74. return platform_add_devices(sh7750_devices,
  75. ARRAY_SIZE(sh7750_devices));
  76. }
  77. __initcall(sh7750_devices_setup);
  78. static struct ipr_data ipr_irq_table[] = {
  79. /* IRQ, IPR-idx, shift, priority */
  80. { 16, 0, 12, 2 }, /* TMU0 TUNI*/
  81. { 17, 0, 12, 2 }, /* TMU1 TUNI */
  82. { 18, 0, 4, 2 }, /* TMU2 TUNI */
  83. { 19, 0, 4, 2 }, /* TMU2 TIPCI */
  84. { 27, 1, 12, 2 }, /* WDT ITI */
  85. { 20, 0, 0, 2 }, /* RTC ATI (alarm) */
  86. { 21, 0, 0, 2 }, /* RTC PRI (period) */
  87. { 22, 0, 0, 2 }, /* RTC CUI (carry) */
  88. { 23, 1, 4, 3 }, /* SCI ERI */
  89. { 24, 1, 4, 3 }, /* SCI RXI */
  90. { 25, 1, 4, 3 }, /* SCI TXI */
  91. { 40, 2, 4, 3 }, /* SCIF ERI */
  92. { 41, 2, 4, 3 }, /* SCIF RXI */
  93. { 42, 2, 4, 3 }, /* SCIF BRI */
  94. { 43, 2, 4, 3 }, /* SCIF TXI */
  95. { 34, 2, 8, 7 }, /* DMAC DMTE0 */
  96. { 35, 2, 8, 7 }, /* DMAC DMTE1 */
  97. { 36, 2, 8, 7 }, /* DMAC DMTE2 */
  98. { 37, 2, 8, 7 }, /* DMAC DMTE3 */
  99. { 38, 2, 8, 7 }, /* DMAC DMAE */
  100. };
  101. static unsigned long ipr_offsets[] = {
  102. 0xffd00004UL, /* 0: IPRA */
  103. 0xffd00008UL, /* 1: IPRB */
  104. 0xffd0000cUL, /* 2: IPRC */
  105. 0xffd00010UL, /* 3: IPRD */
  106. };
  107. static struct ipr_desc ipr_irq_desc = {
  108. .ipr_offsets = ipr_offsets,
  109. .nr_offsets = ARRAY_SIZE(ipr_offsets),
  110. .ipr_data = ipr_irq_table,
  111. .nr_irqs = ARRAY_SIZE(ipr_irq_table),
  112. .chip = {
  113. .name = "IPR-sh7750",
  114. },
  115. };
  116. #ifdef CONFIG_CPU_SUBTYPE_SH7751
  117. static struct ipr_data ipr_irq_table_sh7751[] = {
  118. { 44, 2, 8, 7 }, /* DMAC DMTE4 */
  119. { 45, 2, 8, 7 }, /* DMAC DMTE5 */
  120. { 46, 2, 8, 7 }, /* DMAC DMTE6 */
  121. { 47, 2, 8, 7 }, /* DMAC DMTE7 */
  122. /* The following use INTC_INPRI00 for masking, which is a 32-bit
  123. register, not a 16-bit register like the IPRx registers, so it
  124. would need special support */
  125. /*{ 72, INTPRI00, 8, ? },*/ /* TMU3 TUNI */
  126. /*{ 76, INTPRI00, 12, ? },*/ /* TMU4 TUNI */
  127. };
  128. static struct ipr_desc ipr_irq_desc_sh7751 = {
  129. .ipr_offsets = ipr_offsets,
  130. .nr_offsets = ARRAY_SIZE(ipr_offsets),
  131. .ipr_data = ipr_irq_table_sh7751,
  132. .nr_irqs = ARRAY_SIZE(ipr_irq_table_sh7751),
  133. .chip = {
  134. .name = "IPR-sh7751",
  135. },
  136. };
  137. #endif
  138. void __init init_IRQ_ipr(void)
  139. {
  140. register_ipr_controller(&ipr_irq_desc);
  141. #ifdef CONFIG_CPU_SUBTYPE_SH7751
  142. register_ipr_controller(&ipr_irq_desc_sh7751);
  143. #endif
  144. }
  145. #define INTC_ICR 0xffd00000UL
  146. #define INTC_ICR_IRLM (1<<7)
  147. /* enable individual interrupt mode for external interupts */
  148. void ipr_irq_enable_irlm(void)
  149. {
  150. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  151. }