setup-sh4-202.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * SH4-202 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2009 Magnus Damm
  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/serial_sci.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/sh_intc.h>
  17. #include <linux/io.h>
  18. static struct plat_sci_port scif0_platform_data = {
  19. .scscr = SCSCR_REIE,
  20. .type = PORT_SCIF,
  21. };
  22. static struct resource scif0_resources[] = {
  23. DEFINE_RES_MEM(0xffe80000, 0x100),
  24. DEFINE_RES_IRQ(evt2irq(0x700)),
  25. DEFINE_RES_IRQ(evt2irq(0x720)),
  26. DEFINE_RES_IRQ(evt2irq(0x760)),
  27. DEFINE_RES_IRQ(evt2irq(0x740)),
  28. };
  29. static struct platform_device scif0_device = {
  30. .name = "sh-sci",
  31. .id = 0,
  32. .resource = scif0_resources,
  33. .num_resources = ARRAY_SIZE(scif0_resources),
  34. .dev = {
  35. .platform_data = &scif0_platform_data,
  36. },
  37. };
  38. static struct sh_timer_config tmu0_platform_data = {
  39. .channels_mask = 7,
  40. };
  41. static struct resource tmu0_resources[] = {
  42. DEFINE_RES_MEM(0xffd80000, 0x30),
  43. DEFINE_RES_IRQ(evt2irq(0x400)),
  44. DEFINE_RES_IRQ(evt2irq(0x420)),
  45. DEFINE_RES_IRQ(evt2irq(0x440)),
  46. };
  47. static struct platform_device tmu0_device = {
  48. .name = "sh-tmu",
  49. .id = 0,
  50. .dev = {
  51. .platform_data = &tmu0_platform_data,
  52. },
  53. .resource = tmu0_resources,
  54. .num_resources = ARRAY_SIZE(tmu0_resources),
  55. };
  56. static struct platform_device *sh4202_devices[] __initdata = {
  57. &scif0_device,
  58. &tmu0_device,
  59. };
  60. static int __init sh4202_devices_setup(void)
  61. {
  62. return platform_add_devices(sh4202_devices,
  63. ARRAY_SIZE(sh4202_devices));
  64. }
  65. arch_initcall(sh4202_devices_setup);
  66. static struct platform_device *sh4202_early_devices[] __initdata = {
  67. &scif0_device,
  68. &tmu0_device,
  69. };
  70. void __init plat_early_device_setup(void)
  71. {
  72. early_platform_add_devices(sh4202_early_devices,
  73. ARRAY_SIZE(sh4202_early_devices));
  74. }
  75. enum {
  76. UNUSED = 0,
  77. /* interrupt sources */
  78. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  79. HUDI, TMU0, TMU1, TMU2, RTC, SCIF, WDT,
  80. };
  81. static struct intc_vect vectors[] __initdata = {
  82. INTC_VECT(HUDI, 0x600),
  83. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  84. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  85. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  86. INTC_VECT(RTC, 0x4c0),
  87. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  88. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  89. INTC_VECT(WDT, 0x560),
  90. };
  91. static struct intc_prio_reg prio_registers[] __initdata = {
  92. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  93. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, 0, 0, 0 } },
  94. { 0xffd0000c, 0, 16, 4, /* IPRC */ { 0, 0, SCIF, HUDI } },
  95. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  96. };
  97. static DECLARE_INTC_DESC(intc_desc, "sh4-202", vectors, NULL,
  98. NULL, prio_registers, NULL);
  99. static struct intc_vect vectors_irlm[] __initdata = {
  100. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  101. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  102. };
  103. static DECLARE_INTC_DESC(intc_desc_irlm, "sh4-202_irlm", vectors_irlm, NULL,
  104. NULL, prio_registers, NULL);
  105. void __init plat_irq_setup(void)
  106. {
  107. register_intc_controller(&intc_desc);
  108. }
  109. #define INTC_ICR 0xffd00000UL
  110. #define INTC_ICR_IRLM (1<<7)
  111. void __init plat_irq_setup_pins(int mode)
  112. {
  113. switch (mode) {
  114. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  115. __raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  116. register_intc_controller(&intc_desc_irlm);
  117. break;
  118. default:
  119. BUG();
  120. }
  121. }