setup_m32104ut.c 3.8 KB

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