OSDN Git Service

cleanup
authorYoshinori Sato <ysato@sa76r4.localdomain>
Wed, 23 Apr 2014 06:55:29 +0000 (15:55 +0900)
committerYoshinori Sato <ysato@sa76r4.localdomain>
Wed, 23 Apr 2014 06:55:29 +0000 (15:55 +0900)
arch/h8300/include/asm/irq.h
arch/h8300/kernel/irq_s.c [new file with mode: 0644]

index 13d7c60..66776a6 100644 (file)
@@ -1,42 +1,18 @@
 #ifndef _H8300_IRQ_H_
 #define _H8300_IRQ_H_
 
-#include <asm/ptrace.h>
+#include <linux/irqchip.h>
 
 #if defined(CONFIG_CPU_H8300H)
 #define NR_IRQS 64
+#define IRQ_CHIP &h8300h_irq_chip
 #define EXT_IRQ0 12
-#define EXT_IRQ1 13
-#define EXT_IRQ2 14
-#define EXT_IRQ3 15
-#define EXT_IRQ4 16
-#define EXT_IRQ5 17
-#define EXT_IRQ6 18
-#define EXT_IRQ7 19
-#define EXT_IRQS 5
-#define IER_REGS *(volatile unsigned char *)IER
-#endif
-#if defined(CONFIG_CPU_H8S)
+#define EXT_IRQS 6
+#elif defined(CONFIG_CPU_H8S)
 #define NR_IRQS 128
+#define IRQ_CHIP &h8s_irq_chip
 #define EXT_IRQ0 16
-#define EXT_IRQ1 17
-#define EXT_IRQ2 18
-#define EXT_IRQ3 19
-#define EXT_IRQ4 20
-#define EXT_IRQ5 21
-#define EXT_IRQ6 22
-#define EXT_IRQ7 23
-#define EXT_IRQ8 24
-#define EXT_IRQ9 25
-#define EXT_IRQ10 26
-#define EXT_IRQ11 27
-#define EXT_IRQ12 28
-#define EXT_IRQ13 29
-#define EXT_IRQ14 30
-#define EXT_IRQ15 31
-#define EXT_IRQS 15
-
-#define IER_REGS *(volatile unsigned short *)IER
+#define EXT_IRQS 16
 #endif
 
 static __inline__ int irq_canonicalize(int irq)
@@ -44,6 +20,7 @@ static __inline__ int irq_canonicalize(int irq)
        return irq;
 }
 
-typedef void (*h8300_vector)(void);
-
+void h8300_init_ipr(void);
+extern struct irq_chip h8300h_irq_chip;
+extern struct irq_chip h8s_irq_chip;
 #endif /* _H8300_IRQ_H_ */
diff --git a/arch/h8300/kernel/irq_s.c b/arch/h8300/kernel/irq_s.c
new file mode 100644 (file)
index 0000000..1212fb1
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * linux/arch/h8300/kernel/irq_s.c
+ *
+ * Copyright 2014 Yoshinori Sato <ysato@users.sourceforge.jp>
+ */
+
+#include <asm/io.h>
+#define IPRA 0xfffe00
+
+const static unsigned char ipr_table[] = {
+       0x03, 0x02, 0x01, 0x00, 0x13, 0x12, 0x11, 0x10, /* 16 - 23 */
+       0x23, 0x22, 0x21, 0x20, 0x33, 0x32, 0x31, 0x30, /* 24 - 31 */
+       0x43, 0x42, 0x41, 0x40, 0x53, 0x53, 0x52, 0x52, /* 32 - 39 */
+       0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, /* 40 - 47 */
+       0x50, 0x50, 0x50, 0x50, 0x63, 0x63, 0x63, 0x63, /* 48 - 55 */
+       0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, /* 56 - 63 */
+       0x61, 0x61, 0x61, 0x61, 0x60, 0x60, 0x60, 0x60, /* 64 - 71 */
+       0x73, 0x73, 0x73, 0x73, 0x72, 0x72, 0x72, 0x72, /* 72 - 79 */
+       0x71, 0x71, 0x71, 0x71, 0x70, 0x83, 0x82, 0x81, /* 80 - 87 */
+       0x80, 0x80, 0x80, 0x80, 0x93, 0x93, 0x93, 0x93, /* 88 - 95 */
+       0x92, 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, /* 96 - 103 */
+       0x90, 0x90, 0x90, 0x90, 0xa3, 0xa3, 0xa3, 0xa3, /* 104 - 111 */
+       0xa2, 0xa2, 0xa2, 0xa2, 0xa1, 0xa1, 0xa1, 0xa1, /* 112 - 119 */
+       0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, /* 120 - 127 */
+};
+
+static void h8s_disable_irq(struct irq_data *data)
+{
+       int pos;
+       unsigned int addr;
+       unsigned short pri;
+       int irq = data->irq;
+       addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3);
+       pos = (ipr_table[irq - 16] & 0x0f) * 4;
+       pri = ~(0x000f << pos);
+       pri &= ctrl_inw(addr);
+       ctrl_outw(pri, addr);
+}
+
+static void h8s_enable_irq(struct irq_data *data)
+{
+       int pos;
+       unsigned int addr;
+       unsigned short pri;
+       int irq = data->irq;
+       addr = IPRA + ((ipr_table[irq - 16] & 0xf0) >> 3);
+       pos = (ipr_table[irq - 16] & 0x0f) * 4;
+       pri = ~(0x000f << pos);
+       pri &= ctrl_inw(addr);
+       pri |= 1 << pos;
+       ctrl_outw(pri, addr);
+}
+
+struct irq_chip h8s_irq_chip = {
+       .name           = "H8S-INTC",
+       .irq_enable     = h8s_enable_irq,
+       .irq_disable    = h8s_disable_irq,
+};
+
+void __init h8300_init_ipr(void)
+{
+       int n;
+       /* IPRA to IPRK */
+       for (n = 0; n <= 'k' - 'a'; n++)
+               ctrl_outw(0x1111, IPRA + (n * 2));
+}