irq.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * linux/arch/sh/boards/se/770x/irq.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. * Copyright (C) 2006 Nobuhiro Iwamatsu
  6. *
  7. * Hitachi SolutionEngine Support.
  8. *
  9. */
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/irq.h>
  13. #include <asm/irq.h>
  14. #include <asm/io.h>
  15. #include <asm/se.h>
  16. /*
  17. * If the problem of make_ipr_irq is solved,
  18. * this code will become unnecessary. :-)
  19. */
  20. static void se770x_disable_ipr_irq(unsigned int irq)
  21. {
  22. struct ipr_data *p = get_irq_chip_data(irq);
  23. ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
  24. }
  25. static void se770x_enable_ipr_irq(unsigned int irq)
  26. {
  27. struct ipr_data *p = get_irq_chip_data(irq);
  28. ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
  29. }
  30. static struct irq_chip se770x_irq_chip = {
  31. .name = "MS770xSE-FPGA",
  32. .mask = se770x_disable_ipr_irq,
  33. .unmask = se770x_enable_ipr_irq,
  34. .mask_ack = se770x_disable_ipr_irq,
  35. };
  36. void make_se770x_irq(struct ipr_data *table, unsigned int nr_irqs)
  37. {
  38. int i;
  39. for (i = 0; i < nr_irqs; i++) {
  40. unsigned int irq = table[i].irq;
  41. disable_irq_nosync(irq);
  42. set_irq_chip_and_handler_name(irq, &se770x_irq_chip,
  43. handle_level_irq, "level");
  44. set_irq_chip_data(irq, &table[i]);
  45. se770x_enable_ipr_irq(irq);
  46. }
  47. }
  48. static struct ipr_data se770x_ipr_map[] = {
  49. /*
  50. * Super I/O (Just mimic PC):
  51. * 1: keyboard
  52. * 3: serial 0
  53. * 4: serial 1
  54. * 5: printer
  55. * 6: floppy
  56. * 8: rtc
  57. * 12: mouse
  58. * 14: ide0
  59. */
  60. #if defined(CONFIG_CPU_SUBTYPE_SH7705)
  61. /* This is default value */
  62. { 13, 0, 8, 0x0f-13 ,BCR_ILCRA},
  63. { 5 , 0, 4, 0x0f- 5 ,BCR_ILCRA},
  64. { 10, 0, 0, 0x0f-10, BCR_ILCRB},
  65. { 7 , 0, 4, 0x0f- 7, BCR_ILCRC},
  66. { 3 , 0, 0, 0x0f- 3, BCR_ILCRC},
  67. { 1 , 0, 12, 0x0f- 1, BCR_ILCRD},
  68. { 12, 0, 4, 0x0f-12, BCR_ILCRD}, /* LAN */
  69. { 2 , 0, 8, 0x0f- 2, BCR_ILCRE}, /* PCIRQ2 */
  70. { 6 , 0, 4, 0x0f- 6, BCR_ILCRE}, /* PCIRQ1 */
  71. { 14, 0, 0, 0x0f-14, BCR_ILCRE}, /* PCIRQ0 */
  72. { 0 , 0, 12, 0x0f , BCR_ILCRF},
  73. { 4 , 0, 4, 0x0f- 4, BCR_ILCRF},
  74. { 8 , 0, 12, 0x0f- 8, BCR_ILCRG},
  75. { 9 , 0, 8, 0x0f- 9, BCR_ILCRG},
  76. { 11, 0, 4, 0x0f-11, BCR_ILCRG},
  77. #else
  78. { 14, 0, 8, 0x0f-14 ,BCR_ILCRA},
  79. { 12, 0, 4, 0x0f-12 ,BCR_ILCRA},
  80. { 8, 0, 4, 0x0f- 8 ,BCR_ILCRB},
  81. { 6, 0, 12, 0x0f- 6 ,BCR_ILCRC},
  82. { 5, 0, 8, 0x0f- 5 ,BCR_ILCRC},
  83. { 4, 0, 4, 0x0f- 4 ,BCR_ILCRC},
  84. { 3, 0, 0, 0x0f- 3 ,BCR_ILCRC},
  85. { 1, 0, 12, 0x0f- 1 ,BCR_ILCRD},
  86. #if defined(CONFIG_STNIC)
  87. /* ST NIC */
  88. { 10, 0, 4, 0x0f-10 ,BCR_ILCRD}, /* LAN */
  89. #endif
  90. /* MRSHPC IRQs setting */
  91. { 0, 0, 12, 0x0f- 0 ,BCR_ILCRE}, /* PCIRQ3 */
  92. { 11, 0, 8, 0x0f-11 ,BCR_ILCRE}, /* PCIRQ2 */
  93. { 9, 0, 4, 0x0f- 9 ,BCR_ILCRE}, /* PCIRQ1 */
  94. { 7, 0, 0, 0x0f- 7 ,BCR_ILCRE}, /* PCIRQ0 */
  95. /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
  96. /* NOTE: #2 and #13 are not used on PC */
  97. { 13, 0, 4, 0x0f-13 ,BCR_ILCRG}, /* SLOTIRQ2 */
  98. { 2, 0, 0, 0x0f- 2 ,BCR_ILCRG}, /* SLOTIRQ1 */
  99. #endif
  100. };
  101. /*
  102. * Initialize IRQ setting
  103. */
  104. void __init init_se_IRQ(void)
  105. {
  106. /* Disable all interrupts */
  107. ctrl_outw(0, BCR_ILCRA);
  108. ctrl_outw(0, BCR_ILCRB);
  109. ctrl_outw(0, BCR_ILCRC);
  110. ctrl_outw(0, BCR_ILCRD);
  111. ctrl_outw(0, BCR_ILCRE);
  112. ctrl_outw(0, BCR_ILCRF);
  113. ctrl_outw(0, BCR_ILCRG);
  114. make_se770x_irq(se770x_ipr_map, ARRAY_SIZE(se770x_ipr_map));
  115. }