irq.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * linux/arch/sh/boards/systemh/irq.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. *
  6. * Hitachi SystemH Support.
  7. *
  8. * Modified for 7751 SystemH by
  9. * Jonathan Short.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/irq.h>
  13. #include <linux/hdreg.h>
  14. #include <linux/ide.h>
  15. #include <asm/io.h>
  16. #include <asm/mach/7751systemh.h>
  17. #include <asm/smc37c93x.h>
  18. /* address of external interrupt mask register
  19. * address must be set prior to use these (maybe in init_XXX_irq())
  20. * XXX : is it better to use .config than specifying it in code? */
  21. static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
  22. static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
  23. /* forward declaration */
  24. static unsigned int startup_systemh_irq(unsigned int irq);
  25. static void shutdown_systemh_irq(unsigned int irq);
  26. static void enable_systemh_irq(unsigned int irq);
  27. static void disable_systemh_irq(unsigned int irq);
  28. static void mask_and_ack_systemh(unsigned int);
  29. static void end_systemh_irq(unsigned int irq);
  30. /* hw_interrupt_type */
  31. static struct hw_interrupt_type systemh_irq_type = {
  32. .typename = " SystemH Register",
  33. .startup = startup_systemh_irq,
  34. .shutdown = shutdown_systemh_irq,
  35. .enable = enable_systemh_irq,
  36. .disable = disable_systemh_irq,
  37. .ack = mask_and_ack_systemh,
  38. .end = end_systemh_irq
  39. };
  40. static unsigned int startup_systemh_irq(unsigned int irq)
  41. {
  42. enable_systemh_irq(irq);
  43. return 0; /* never anything pending */
  44. }
  45. static void shutdown_systemh_irq(unsigned int irq)
  46. {
  47. disable_systemh_irq(irq);
  48. }
  49. static void disable_systemh_irq(unsigned int irq)
  50. {
  51. if (systemh_irq_mask_register) {
  52. unsigned long flags;
  53. unsigned long val, mask = 0x01 << 1;
  54. /* Clear the "irq"th bit in the mask and set it in the request */
  55. local_irq_save(flags);
  56. val = ctrl_inl((unsigned long)systemh_irq_mask_register);
  57. val &= ~mask;
  58. ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
  59. val = ctrl_inl((unsigned long)systemh_irq_request_register);
  60. val |= mask;
  61. ctrl_outl(val, (unsigned long)systemh_irq_request_register);
  62. local_irq_restore(flags);
  63. }
  64. }
  65. static void enable_systemh_irq(unsigned int irq)
  66. {
  67. if (systemh_irq_mask_register) {
  68. unsigned long flags;
  69. unsigned long val, mask = 0x01 << 1;
  70. /* Set "irq"th bit in the mask register */
  71. local_irq_save(flags);
  72. val = ctrl_inl((unsigned long)systemh_irq_mask_register);
  73. val |= mask;
  74. ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
  75. local_irq_restore(flags);
  76. }
  77. }
  78. static void mask_and_ack_systemh(unsigned int irq)
  79. {
  80. disable_systemh_irq(irq);
  81. }
  82. static void end_systemh_irq(unsigned int irq)
  83. {
  84. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  85. enable_systemh_irq(irq);
  86. }
  87. void make_systemh_irq(unsigned int irq)
  88. {
  89. disable_irq_nosync(irq);
  90. irq_desc[irq].chip = &systemh_irq_type;
  91. disable_systemh_irq(irq);
  92. }