setup_m32104ut.c 3.7 KB

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