irq.c 2.7 KB

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