OSDN Git Service

90021d82beaafa09919b25db5b913570e1d23392
[uclinux-h8/linux.git] / arch / h8300 / kernel / irq_h.c
1 /*
2  * linux/arch/h8300/kernel/irq_h.c
3  *
4  * Copyright 2014 Yoshinori Sato <ysato@users.sourceforge.jp>
5  */
6
7 #include <linux/init.h>
8 #include <linux/irq.h>
9 #include <asm/io.h>
10
11 static const char ipr_bit[] = {
12          7,  6,  5,  5,
13          4,  4,  4,  4,  3,  3,  3,  3,
14          2,  2,  2,  2,  1,  1,  1,  1,
15          0,  0,  0,  0, 15, 15, 15, 15,
16         14, 14, 14, 14, 13, 13, 13, 13,
17         -1, -1, -1, -1, 11, 11, 11, 11,
18         10, 10, 10, 10,  9,  9,  9,  9,
19 };
20
21 #define IPR 0xffee18
22
23 static void h8300h_disable_irq(struct irq_data *data)
24 {
25         int bit;
26         int irq = data->irq - 12;
27
28         bit = ipr_bit[irq];
29         if (bit >= 0) {
30                 if (bit < 8)
31                         ctrl_bclr(bit & 7, IPR);
32                 else
33                         ctrl_bclr(bit & 7, (IPR+1));
34         }
35 }
36
37 static void h8300h_enable_irq(struct irq_data *data)
38 {
39         int bit;
40         int irq = data->irq - 12;
41
42         bit = ipr_bit[irq];
43         if (bit >= 0) {
44                 if (bit < 8)
45                         ctrl_bset(bit & 7, IPR);
46                 else
47                         ctrl_bset(bit & 7, (IPR+1));
48         }
49 }
50
51 struct irq_chip h8300h_irq_chip = {
52         .name           = "H8/300H-INTC",
53         .irq_enable     = h8300h_enable_irq,
54         .irq_disable    = h8300h_disable_irq,
55 };
56
57 void __init h8300_init_ipr(void)
58 {
59         /* All interrupt priority high */
60         ctrl_outb(0xff, IPR + 0);
61         ctrl_outb(0xee, IPR + 1);
62 }