setup.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/m32r.h>
  15. #include <asm/io.h>
  16. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  17. icu_data_t icu_data[NR_IRQS];
  18. static void disable_m32104ut_irq(unsigned int irq)
  19. {
  20. unsigned long port, data;
  21. port = irq2port(irq);
  22. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  23. outl(data, port);
  24. }
  25. static void enable_m32104ut_irq(unsigned int irq)
  26. {
  27. unsigned long port, data;
  28. port = irq2port(irq);
  29. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  30. outl(data, port);
  31. }
  32. static void mask_m32104ut_irq(struct irq_data *data)
  33. {
  34. disable_m32104ut_irq(data->irq);
  35. }
  36. static void unmask_m32104ut_irq(struct irq_data *data)
  37. {
  38. enable_m32104ut_irq(data->irq);
  39. }
  40. static void shutdown_m32104ut_irq(struct irq_data *data)
  41. {
  42. unsigned int irq = data->irq;
  43. unsigned long port = irq2port(irq);
  44. outl(M32R_ICUCR_ILEVEL7, port);
  45. }
  46. static struct irq_chip m32104ut_irq_type =
  47. {
  48. .name = "M32104UT-IRQ",
  49. .irq_shutdown = shutdown_m32104ut_irq,
  50. .irq_unmask = unmask_m32104ut_irq,
  51. .irq_mask = mask_m32104ut_irq,
  52. };
  53. void __init init_IRQ(void)
  54. {
  55. static int once = 0;
  56. if (once)
  57. return;
  58. else
  59. once++;
  60. #if defined(CONFIG_SMC91X)
  61. /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/
  62. irq_set_chip_and_handler(M32R_IRQ_INT0, &m32104ut_irq_type,
  63. handle_level_irq);
  64. /* "H" level sense */
  65. cu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11;
  66. disable_m32104ut_irq(M32R_IRQ_INT0);
  67. #endif /* CONFIG_SMC91X */
  68. /* MFT2 : system timer */
  69. irq_set_chip_and_handler(M32R_IRQ_MFT2, &m32104ut_irq_type,
  70. handle_level_irq);
  71. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  72. disable_m32104ut_irq(M32R_IRQ_MFT2);
  73. #ifdef CONFIG_SERIAL_M32R_SIO
  74. /* SIO0_R : uart receive data */
  75. irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &m32104ut_irq_type,
  76. handle_level_irq);
  77. icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN;
  78. disable_m32104ut_irq(M32R_IRQ_SIO0_R);
  79. /* SIO0_S : uart send data */
  80. irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &m32104ut_irq_type,
  81. handle_level_irq);
  82. icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN;
  83. disable_m32104ut_irq(M32R_IRQ_SIO0_S);
  84. #endif /* CONFIG_SERIAL_M32R_SIO */
  85. }
  86. #if defined(CONFIG_SMC91X)
  87. #define LAN_IOSTART 0x300
  88. #define LAN_IOEND 0x320
  89. static struct resource smc91x_resources[] = {
  90. [0] = {
  91. .start = (LAN_IOSTART),
  92. .end = (LAN_IOEND),
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = M32R_IRQ_INT0,
  97. .end = M32R_IRQ_INT0,
  98. .flags = IORESOURCE_IRQ,
  99. }
  100. };
  101. static struct platform_device smc91x_device = {
  102. .name = "smc91x",
  103. .id = 0,
  104. .num_resources = ARRAY_SIZE(smc91x_resources),
  105. .resource = smc91x_resources,
  106. };
  107. #endif
  108. static int __init platform_init(void)
  109. {
  110. #if defined(CONFIG_SMC91X)
  111. platform_device_register(&smc91x_device);
  112. #endif
  113. return 0;
  114. }
  115. arch_initcall(platform_init);