irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * linux/arch/sh/boards/renesas/r7780rp/irq.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. *
  6. * Renesas Solutions Highlander R7780RP-1 Support.
  7. *
  8. * Modified for R7780RP-1 by
  9. * Atom Create Engineering Co., Ltd. 2002.
  10. */
  11. #include <linux/config.h>
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <asm/io.h>
  15. #include <asm/irq.h>
  16. #include <asm/r7780rp/r7780rp.h>
  17. #ifdef CONFIG_SH_R7780MP
  18. static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
  19. #else
  20. static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
  21. #endif
  22. static void enable_r7780rp_irq(unsigned int irq);
  23. static void disable_r7780rp_irq(unsigned int irq);
  24. /* shutdown is same as "disable" */
  25. #define shutdown_r7780rp_irq disable_r7780rp_irq
  26. static void ack_r7780rp_irq(unsigned int irq);
  27. static void end_r7780rp_irq(unsigned int irq);
  28. static unsigned int startup_r7780rp_irq(unsigned int irq)
  29. {
  30. enable_r7780rp_irq(irq);
  31. return 0; /* never anything pending */
  32. }
  33. static void disable_r7780rp_irq(unsigned int irq)
  34. {
  35. unsigned short val;
  36. unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
  37. /* Set the priority in IPR to 0 */
  38. val = ctrl_inw(IRLCNTR1);
  39. val &= mask;
  40. ctrl_outw(val, IRLCNTR1);
  41. }
  42. static void enable_r7780rp_irq(unsigned int irq)
  43. {
  44. unsigned short val;
  45. unsigned short value = (0x0001 << mask_pos[irq]);
  46. /* Set priority in IPR back to original value */
  47. val = ctrl_inw(IRLCNTR1);
  48. val |= value;
  49. ctrl_outw(val, IRLCNTR1);
  50. }
  51. static void ack_r7780rp_irq(unsigned int irq)
  52. {
  53. disable_r7780rp_irq(irq);
  54. }
  55. static void end_r7780rp_irq(unsigned int irq)
  56. {
  57. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  58. enable_r7780rp_irq(irq);
  59. }
  60. static struct hw_interrupt_type r7780rp_irq_type = {
  61. .typename = "R7780RP-IRQ",
  62. .startup = startup_r7780rp_irq,
  63. .shutdown = shutdown_r7780rp_irq,
  64. .enable = enable_r7780rp_irq,
  65. .disable = disable_r7780rp_irq,
  66. .ack = ack_r7780rp_irq,
  67. .end = end_r7780rp_irq,
  68. };
  69. static void make_r7780rp_irq(unsigned int irq)
  70. {
  71. disable_irq_nosync(irq);
  72. irq_desc[irq].handler = &r7780rp_irq_type;
  73. disable_r7780rp_irq(irq);
  74. }
  75. /*
  76. * Initialize IRQ setting
  77. */
  78. void __init init_r7780rp_IRQ(void)
  79. {
  80. int i;
  81. /* IRL0=PCI Slot #A
  82. * IRL1=PCI Slot #B
  83. * IRL2=PCI Slot #C
  84. * IRL3=PCI Slot #D
  85. * IRL4=CF Card
  86. * IRL5=CF Card Insert
  87. * IRL6=M66596
  88. * IRL7=SD Card
  89. * IRL8=Touch Panel
  90. * IRL9=SCI
  91. * IRL10=Serial
  92. * IRL11=Extention #A
  93. * IRL11=Extention #B
  94. * IRL12=Debug LAN
  95. * IRL13=Push Switch
  96. * IRL14=ZiggBee IO
  97. */
  98. for (i=0; i<15; i++)
  99. make_r7780rp_irq(i);
  100. }