irq.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * linux/arch/sh/boards/renesas/hs7751rvoip/irq.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. *
  6. * Renesas Technology Sales HS7751RVoIP Support.
  7. *
  8. * Modified for HS7751RVoIP by
  9. * Atom Create Engineering Co., Ltd. 2002.
  10. * Lineo uSolutions, Inc. 2003.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/init.h>
  14. #include <linux/irq.h>
  15. #include <asm/io.h>
  16. #include <asm/irq.h>
  17. #include <asm/hs7751rvoip/hs7751rvoip.h>
  18. static int mask_pos[] = {8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7};
  19. static void enable_hs7751rvoip_irq(unsigned int irq);
  20. static void disable_hs7751rvoip_irq(unsigned int irq);
  21. /* shutdown is same as "disable" */
  22. #define shutdown_hs7751rvoip_irq disable_hs7751rvoip_irq
  23. static void ack_hs7751rvoip_irq(unsigned int irq);
  24. static void end_hs7751rvoip_irq(unsigned int irq);
  25. static unsigned int startup_hs7751rvoip_irq(unsigned int irq)
  26. {
  27. enable_hs7751rvoip_irq(irq);
  28. return 0; /* never anything pending */
  29. }
  30. static void disable_hs7751rvoip_irq(unsigned int irq)
  31. {
  32. unsigned long flags;
  33. unsigned short val;
  34. unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
  35. /* Set the priority in IPR to 0 */
  36. local_irq_save(flags);
  37. val = ctrl_inw(IRLCNTR3);
  38. val &= mask;
  39. ctrl_outw(val, IRLCNTR3);
  40. local_irq_restore(flags);
  41. }
  42. static void enable_hs7751rvoip_irq(unsigned int irq)
  43. {
  44. unsigned long flags;
  45. unsigned short val;
  46. unsigned short value = (0x0001 << mask_pos[irq]);
  47. /* Set priority in IPR back to original value */
  48. local_irq_save(flags);
  49. val = ctrl_inw(IRLCNTR3);
  50. val |= value;
  51. ctrl_outw(val, IRLCNTR3);
  52. local_irq_restore(flags);
  53. }
  54. static void ack_hs7751rvoip_irq(unsigned int irq)
  55. {
  56. disable_hs7751rvoip_irq(irq);
  57. }
  58. static void end_hs7751rvoip_irq(unsigned int irq)
  59. {
  60. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  61. enable_hs7751rvoip_irq(irq);
  62. }
  63. static struct hw_interrupt_type hs7751rvoip_irq_type = {
  64. "HS7751RVoIP IRQ",
  65. startup_hs7751rvoip_irq,
  66. shutdown_hs7751rvoip_irq,
  67. enable_hs7751rvoip_irq,
  68. disable_hs7751rvoip_irq,
  69. ack_hs7751rvoip_irq,
  70. end_hs7751rvoip_irq,
  71. };
  72. static void make_hs7751rvoip_irq(unsigned int irq)
  73. {
  74. disable_irq_nosync(irq);
  75. irq_desc[irq].handler = &hs7751rvoip_irq_type;
  76. disable_hs7751rvoip_irq(irq);
  77. }
  78. /*
  79. * Initialize IRQ setting
  80. */
  81. void __init init_hs7751rvoip_IRQ(void)
  82. {
  83. int i;
  84. /* IRL0=ON HOOK1
  85. * IRL1=OFF HOOK1
  86. * IRL2=ON HOOK2
  87. * IRL3=OFF HOOK2
  88. * IRL4=Ringing Detection
  89. * IRL5=CODEC
  90. * IRL6=Ethernet
  91. * IRL7=Ethernet Hub
  92. * IRL8=USB Communication
  93. * IRL9=USB Connection
  94. * IRL10=USB DMA
  95. * IRL11=CF Card
  96. * IRL12=PCMCIA
  97. * IRL13=PCI Slot
  98. */
  99. ctrl_outw(0x9876, IRLCNTR1);
  100. ctrl_outw(0xdcba, IRLCNTR2);
  101. ctrl_outw(0x0050, IRLCNTR4);
  102. ctrl_outw(0x4321, IRLCNTR5);
  103. for (i=0; i<14; i++)
  104. make_hs7751rvoip_irq(i);
  105. }