irq.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Interrupt handling H8/300H depend.
  3. * Yoshinori Sato <ysato@users.sourceforge.jp>
  4. *
  5. */
  6. #include <linux/init.h>
  7. #include <linux/errno.h>
  8. #include <asm/ptrace.h>
  9. #include <asm/traps.h>
  10. #include <asm/irq.h>
  11. #include <asm/io.h>
  12. #include <asm/gpio.h>
  13. #include <asm/regs306x.h>
  14. const int __initdata h8300_saved_vectors[] = {
  15. #if defined(CONFIG_GDB_DEBUG)
  16. TRAP3_VEC, /* TRAPA #3 is GDB breakpoint */
  17. #endif
  18. -1,
  19. };
  20. const h8300_vector __initdata h8300_trap_table[] = {
  21. 0, 0, 0, 0, 0, 0, 0, 0,
  22. system_call,
  23. 0,
  24. 0,
  25. trace_break,
  26. };
  27. int h8300_enable_irq_pin(unsigned int irq)
  28. {
  29. int bitmask;
  30. if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
  31. return 0;
  32. /* initialize IRQ pin */
  33. bitmask = 1 << (irq - EXT_IRQ0);
  34. switch(irq) {
  35. case EXT_IRQ0:
  36. case EXT_IRQ1:
  37. case EXT_IRQ2:
  38. case EXT_IRQ3:
  39. if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0)
  40. return -EBUSY;
  41. H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT);
  42. break;
  43. case EXT_IRQ4:
  44. case EXT_IRQ5:
  45. if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0)
  46. return -EBUSY;
  47. H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT);
  48. break;
  49. }
  50. return 0;
  51. }
  52. void h8300_disable_irq_pin(unsigned int irq)
  53. {
  54. int bitmask;
  55. if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
  56. return;
  57. /* disable interrupt & release IRQ pin */
  58. bitmask = 1 << (irq - EXT_IRQ0);
  59. switch(irq) {
  60. case EXT_IRQ0:
  61. case EXT_IRQ1:
  62. case EXT_IRQ2:
  63. case EXT_IRQ3:
  64. *(volatile unsigned char *)IER &= ~bitmask;
  65. H8300_GPIO_FREE(H8300_GPIO_P8, bitmask);
  66. break ;
  67. case EXT_IRQ4:
  68. case EXT_IRQ5:
  69. *(volatile unsigned char *)IER &= ~bitmask;
  70. H8300_GPIO_FREE(H8300_GPIO_P9, bitmask);
  71. break;
  72. }
  73. }