irq.c 2.6 KB

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