irq.c 2.5 KB

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