aboutsummaryrefslogtreecommitdiff
path: root/arch/h8300/platform/h8s/ints_h8s.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/h8300/platform/h8s/ints_h8s.c
downloadlinux-stericsson-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.gz
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/h8300/platform/h8s/ints_h8s.c')
-rw-r--r--arch/h8300/platform/h8s/ints_h8s.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/arch/h8300/platform/h8s/ints_h8s.c b/arch/h8300/platform/h8s/ints_h8s.c
new file mode 100644
index 000000000000..f53de493e3e8
--- /dev/null
+++ b/arch/h8300/platform/h8s/ints_h8s.c
@@ -0,0 +1,105 @@
+/*
+ * linux/arch/h8300/platform/h8s/ints_h8s.c
+ * Interrupt handling CPU variants
+ *
+ * Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+
+#include <asm/ptrace.h>
+#include <asm/traps.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <asm/regs267x.h>
+
+/* saved vector list */
+const int __initdata h8300_saved_vectors[]={
+#if defined(CONFIG_GDB_DEBUG)
+ TRACE_VEC,
+ TRAP3_VEC,
+#endif
+ -1
+};
+
+/* trap entry table */
+const unsigned long __initdata h8300_trap_table[NR_TRAPS]={
+ 0,0,0,0,0,
+ (unsigned long)trace_break, /* TRACE */
+ 0,0,
+ (unsigned long)system_call, /* TRAPA #0 */
+ 0,0,0,0,0,0,0
+};
+
+/* IRQ pin assignment */
+struct irq_pins {
+ unsigned char port_no;
+ unsigned char bit_no;
+} __attribute__((aligned(1),packed));
+/* ISTR = 0 */
+const static struct irq_pins irq_assign_table0[16]={
+ {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1},
+ {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3},
+ {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5},
+ {H8300_GPIO_P5,H8300_GPIO_B6},{H8300_GPIO_P5,H8300_GPIO_B7},
+ {H8300_GPIO_P6,H8300_GPIO_B0},{H8300_GPIO_P6,H8300_GPIO_B1},
+ {H8300_GPIO_P6,H8300_GPIO_B2},{H8300_GPIO_P6,H8300_GPIO_B3},
+ {H8300_GPIO_P6,H8300_GPIO_B4},{H8300_GPIO_P6,H8300_GPIO_B5},
+ {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2},
+};
+/* ISTR = 1 */
+const static struct irq_pins irq_assign_table1[16]={
+ {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1},
+ {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3},
+ {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5},
+ {H8300_GPIO_PH,H8300_GPIO_B2},{H8300_GPIO_PH,H8300_GPIO_B3},
+ {H8300_GPIO_P2,H8300_GPIO_B0},{H8300_GPIO_P2,H8300_GPIO_B1},
+ {H8300_GPIO_P2,H8300_GPIO_B2},{H8300_GPIO_P2,H8300_GPIO_B3},
+ {H8300_GPIO_P2,H8300_GPIO_B4},{H8300_GPIO_P2,H8300_GPIO_B5},
+ {H8300_GPIO_P2,H8300_GPIO_B6},{H8300_GPIO_P2,H8300_GPIO_B7},
+};
+
+/* IRQ to GPIO pinno transrate */
+#define IRQ_GPIO_MAP(irqbit,irq,port,bit) \
+do { \
+ if (*(volatile unsigned short *)ITSR & irqbit) { \
+ port = irq_assign_table1[irq - EXT_IRQ0].port_no; \
+ bit = irq_assign_table1[irq - EXT_IRQ0].bit_no; \
+ } else { \
+ port = irq_assign_table0[irq - EXT_IRQ0].port_no; \
+ bit = irq_assign_table0[irq - EXT_IRQ0].bit_no; \
+ } \
+} while(0)
+
+int h8300_enable_irq_pin(unsigned int irq)
+{
+ if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) {
+ unsigned short ptn = 1 << (irq - EXT_IRQ0);
+ unsigned int port_no,bit_no;
+ IRQ_GPIO_MAP(ptn, irq, port_no, bit_no);
+ if (H8300_GPIO_RESERVE(port_no, bit_no) == 0)
+ return -EBUSY; /* pin already use */
+ H8300_GPIO_DDR(port_no, bit_no, H8300_GPIO_INPUT);
+ *(volatile unsigned short *)ISR &= ~ptn; /* ISR clear */
+ }
+
+ return 0;
+}
+
+void h8300_disable_irq_pin(unsigned int irq)
+{
+ if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) {
+ /* disable interrupt & release IRQ pin */
+ unsigned short ptn = 1 << (irq - EXT_IRQ0);
+ unsigned short port_no,bit_no;
+ *(volatile unsigned short *)ISR &= ~ptn;
+ *(volatile unsigned short *)IER &= ~ptn;
+ IRQ_GPIO_MAP(ptn, irq, port_no, bit_no);
+ H8300_GPIO_FREE(port_no, bit_no);
+ }
+}