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