setup-sh7750.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. .mapbase = 0xffe00000,
  47. .flags = UPF_BOOT_AUTOCONF,
  48. .type = PORT_SCI,
  49. .irqs = { 23, 24, 25, 0 },
  50. }, {
  51. .mapbase = 0xffe80000,
  52. .flags = UPF_BOOT_AUTOCONF,
  53. .type = PORT_SCIF,
  54. .irqs = { 40, 41, 43, 42 },
  55. }, {
  56. .flags = 0,
  57. }
  58. };
  59. static struct platform_device sci_device = {
  60. .name = "sh-sci",
  61. .id = -1,
  62. .dev = {
  63. .platform_data = sci_platform_data,
  64. },
  65. };
  66. static struct platform_device *sh7750_devices[] __initdata = {
  67. &rtc_device,
  68. &sci_device,
  69. };
  70. static int __init sh7750_devices_setup(void)
  71. {
  72. return platform_add_devices(sh7750_devices,
  73. ARRAY_SIZE(sh7750_devices));
  74. }
  75. __initcall(sh7750_devices_setup);
  76. static struct ipr_data sh7750_ipr_map[] = {
  77. /* IRQ, IPR-idx, shift, priority */
  78. { 16, 0, 12, 2 }, /* TMU0 TUNI*/
  79. { 17, 0, 12, 2 }, /* TMU1 TUNI */
  80. { 18, 0, 4, 2 }, /* TMU2 TUNI */
  81. { 19, 0, 4, 2 }, /* TMU2 TIPCI */
  82. { 27, 1, 12, 2 }, /* WDT ITI */
  83. { 20, 0, 0, 2 }, /* RTC ATI (alarm) */
  84. { 21, 0, 0, 2 }, /* RTC PRI (period) */
  85. { 22, 0, 0, 2 }, /* RTC CUI (carry) */
  86. { 23, 1, 4, 3 }, /* SCI ERI */
  87. { 24, 1, 4, 3 }, /* SCI RXI */
  88. { 25, 1, 4, 3 }, /* SCI TXI */
  89. { 40, 2, 4, 3 }, /* SCIF ERI */
  90. { 41, 2, 4, 3 }, /* SCIF RXI */
  91. { 42, 2, 4, 3 }, /* SCIF BRI */
  92. { 43, 2, 4, 3 }, /* SCIF TXI */
  93. { 34, 2, 8, 7 }, /* DMAC DMTE0 */
  94. { 35, 2, 8, 7 }, /* DMAC DMTE1 */
  95. { 36, 2, 8, 7 }, /* DMAC DMTE2 */
  96. { 37, 2, 8, 7 }, /* DMAC DMTE3 */
  97. { 28, 2, 8, 7 }, /* DMAC DMAE */
  98. };
  99. static struct ipr_data sh7751_ipr_map[] = {
  100. { 44, 2, 8, 7 }, /* DMAC DMTE4 */
  101. { 45, 2, 8, 7 }, /* DMAC DMTE5 */
  102. { 46, 2, 8, 7 }, /* DMAC DMTE6 */
  103. { 47, 2, 8, 7 }, /* DMAC DMTE7 */
  104. /* The following use INTC_INPRI00 for masking, which is a 32-bit
  105. register, not a 16-bit register like the IPRx registers, so it
  106. would need special support */
  107. /*{ 72, INTPRI00, 8, ? },*/ /* TMU3 TUNI */
  108. /*{ 76, INTPRI00, 12, ? },*/ /* TMU4 TUNI */
  109. };
  110. static unsigned long ipr_offsets[] = {
  111. 0xffd00004UL, /* 0: IPRA */
  112. 0xffd00008UL, /* 1: IPRB */
  113. 0xffd0000cUL, /* 2: IPRC */
  114. 0xffd00010UL, /* 3: IPRD */
  115. };
  116. /* given the IPR index return the address of the IPR register */
  117. unsigned int map_ipridx_to_addr(int idx)
  118. {
  119. if (idx >= ARRAY_SIZE(ipr_offsets))
  120. return 0;
  121. return ipr_offsets[idx];
  122. }
  123. #define INTC_ICR 0xffd00000UL
  124. #define INTC_ICR_IRLM (1<<7)
  125. /* enable individual interrupt mode for external interupts */
  126. void ipr_irq_enable_irlm(void)
  127. {
  128. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  129. }
  130. void __init init_IRQ_ipr()
  131. {
  132. make_ipr_irq(sh7750_ipr_map, ARRAY_SIZE(sh7750_ipr_map));
  133. #ifdef CONFIG_CPU_SUBTYPE_SH7751
  134. make_ipr_irq(sh7751_ipr_map, ARRAY_SIZE(sh7751_ipr_map));
  135. #endif
  136. }