setup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * linux/arch/m32r/platforms/m32104ut/setup.c
  3. *
  4. * Setup routines for M32104UT Board
  5. *
  6. * Copyright (c) 2002-2005 Hiroyuki Kondo, Hirokazu Takata,
  7. * Hitoshi Yamamoto, Mamoru Sakugawa,
  8. * Naoto Sugai, Hayato Fujiwara
  9. */
  10. #include <linux/irq.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <asm/system.h>
  15. #include <asm/m32r.h>
  16. #include <asm/io.h>
  17. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  18. icu_data_t icu_data[NR_IRQS];
  19. static void disable_m32104ut_irq(unsigned int irq)
  20. {
  21. unsigned long port, data;
  22. port = irq2port(irq);
  23. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  24. outl(data, port);
  25. }
  26. static void enable_m32104ut_irq(unsigned int irq)
  27. {
  28. unsigned long port, data;
  29. port = irq2port(irq);
  30. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  31. outl(data, port);
  32. }
  33. static void mask_and_ack_m32104ut(unsigned int irq)
  34. {
  35. disable_m32104ut_irq(irq);
  36. }
  37. static void end_m32104ut_irq(unsigned int irq)
  38. {
  39. enable_m32104ut_irq(irq);
  40. }
  41. static unsigned int startup_m32104ut_irq(unsigned int irq)
  42. {
  43. enable_m32104ut_irq(irq);
  44. return (0);
  45. }
  46. static void shutdown_m32104ut_irq(unsigned int irq)
  47. {
  48. unsigned long port;
  49. port = irq2port(irq);
  50. outl(M32R_ICUCR_ILEVEL7, port);
  51. }
  52. static struct irq_chip m32104ut_irq_type =
  53. {
  54. .typename = "M32104UT-IRQ",
  55. .startup = startup_m32104ut_irq,
  56. .shutdown = shutdown_m32104ut_irq,
  57. .enable = enable_m32104ut_irq,
  58. .disable = disable_m32104ut_irq,
  59. .ack = mask_and_ack_m32104ut,
  60. .end = end_m32104ut_irq
  61. };
  62. void __init init_IRQ(void)
  63. {
  64. static int once = 0;
  65. if (once)
  66. return;
  67. else
  68. once++;
  69. #if defined(CONFIG_SMC91X)
  70. /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/
  71. irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
  72. irq_desc[M32R_IRQ_INT0].chip = &m32104ut_irq_type;
  73. irq_desc[M32R_IRQ_INT0].action = 0;
  74. irq_desc[M32R_IRQ_INT0].depth = 1;
  75. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */
  76. disable_m32104ut_irq(M32R_IRQ_INT0);
  77. #endif /* CONFIG_SMC91X */
  78. /* MFT2 : system timer */
  79. irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
  80. irq_desc[M32R_IRQ_MFT2].chip = &m32104ut_irq_type;
  81. irq_desc[M32R_IRQ_MFT2].action = 0;
  82. irq_desc[M32R_IRQ_MFT2].depth = 1;
  83. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  84. disable_m32104ut_irq(M32R_IRQ_MFT2);
  85. #ifdef CONFIG_SERIAL_M32R_SIO
  86. /* SIO0_R : uart receive data */
  87. irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
  88. irq_desc[M32R_IRQ_SIO0_R].chip = &m32104ut_irq_type;
  89. irq_desc[M32R_IRQ_SIO0_R].action = 0;
  90. irq_desc[M32R_IRQ_SIO0_R].depth = 1;
  91. icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN;
  92. disable_m32104ut_irq(M32R_IRQ_SIO0_R);
  93. /* SIO0_S : uart send data */
  94. irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
  95. irq_desc[M32R_IRQ_SIO0_S].chip = &m32104ut_irq_type;
  96. irq_desc[M32R_IRQ_SIO0_S].action = 0;
  97. irq_desc[M32R_IRQ_SIO0_S].depth = 1;
  98. icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN;
  99. disable_m32104ut_irq(M32R_IRQ_SIO0_S);
  100. #endif /* CONFIG_SERIAL_M32R_SIO */
  101. }
  102. #if defined(CONFIG_SMC91X)
  103. #define LAN_IOSTART 0x300
  104. #define LAN_IOEND 0x320
  105. static struct resource smc91x_resources[] = {
  106. [0] = {
  107. .start = (LAN_IOSTART),
  108. .end = (LAN_IOEND),
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [1] = {
  112. .start = M32R_IRQ_INT0,
  113. .end = M32R_IRQ_INT0,
  114. .flags = IORESOURCE_IRQ,
  115. }
  116. };
  117. static struct platform_device smc91x_device = {
  118. .name = "smc91x",
  119. .id = 0,
  120. .num_resources = ARRAY_SIZE(smc91x_resources),
  121. .resource = smc91x_resources,
  122. };
  123. #endif
  124. static int __init platform_init(void)
  125. {
  126. #if defined(CONFIG_SMC91X)
  127. platform_device_register(&smc91x_device);
  128. #endif
  129. return 0;
  130. }
  131. arch_initcall(platform_init);