setup-sh4-202.c 3.4 KB

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