irq.c 2.6 KB

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