1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/sh/boards/se/7206/irq.c
5 * Copyright (C) 2005,2006 Yoshinori Sato
7 * Hitachi SolutionEngine Support.
10 #include <linux/init.h>
11 #include <linux/irq.h>
13 #include <linux/interrupt.h>
14 #include <mach-se/mach/se7206.h>
16 #define INTSTS0 0x31800000
17 #define INTSTS1 0x31800002
18 #define INTMSK0 0x31800004
19 #define INTMSK1 0x31800006
20 #define INTSEL 0x31800008
26 #define INTC_IPR01 0xfffe0818
27 #define INTC_ICR1 0xfffe0802
29 static void disable_se7206_irq(struct irq_data
*data
)
31 unsigned int irq
= data
->irq
;
33 unsigned short mask
= 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ
- irq
)));
34 unsigned short msk0
,msk1
;
36 /* Set the priority in IPR to 0 */
37 val
= __raw_readw(INTC_IPR01
);
39 __raw_writew(val
, INTC_IPR01
);
41 msk0
= __raw_readw(INTMSK0
);
42 msk1
= __raw_readw(INTMSK1
);
56 __raw_writew(msk0
, INTMSK0
);
57 __raw_writew(msk1
, INTMSK1
);
60 static void enable_se7206_irq(struct irq_data
*data
)
62 unsigned int irq
= data
->irq
;
64 unsigned short value
= (0x0001 << 4 * (3 - (IRQ0_IRQ
- irq
)));
65 unsigned short msk0
,msk1
;
67 /* Set priority in IPR back to original value */
68 val
= __raw_readw(INTC_IPR01
);
70 __raw_writew(val
, INTC_IPR01
);
73 msk0
= __raw_readw(INTMSK0
);
74 msk1
= __raw_readw(INTMSK1
);
88 __raw_writew(msk0
, INTMSK0
);
89 __raw_writew(msk1
, INTMSK1
);
92 static void eoi_se7206_irq(struct irq_data
*data
)
94 unsigned short sts0
,sts1
;
95 unsigned int irq
= data
->irq
;
97 if (!irqd_irq_disabled(data
) && !irqd_irq_inprogress(data
))
98 enable_se7206_irq(data
);
100 sts0
= __raw_readw(INTSTS0
);
101 sts1
= __raw_readw(INTSTS1
);
115 __raw_writew(sts0
, INTSTS0
);
116 __raw_writew(sts1
, INTSTS1
);
119 static struct irq_chip se7206_irq_chip __read_mostly
= {
120 .name
= "SE7206-FPGA",
121 .irq_mask
= disable_se7206_irq
,
122 .irq_unmask
= enable_se7206_irq
,
123 .irq_eoi
= eoi_se7206_irq
,
126 static void make_se7206_irq(unsigned int irq
)
128 disable_irq_nosync(irq
);
129 irq_set_chip_and_handler_name(irq
, &se7206_irq_chip
,
130 handle_level_irq
, "level");
131 disable_se7206_irq(irq_get_irq_data(irq
));
135 * Initialize IRQ setting
137 void __init
init_se7206_IRQ(void)
139 make_se7206_irq(IRQ0_IRQ
); /* SMC91C111 */
140 make_se7206_irq(IRQ1_IRQ
); /* ATA */
141 make_se7206_irq(IRQ3_IRQ
); /* SLOT / PCM */
143 __raw_writew(__raw_readw(INTC_ICR1
) | 0x000b, INTC_ICR1
); /* ICR1 */
145 /* FPGA System register setup*/
146 __raw_writew(0x0000,INTSTS0
); /* Clear INTSTS0 */
147 __raw_writew(0x0000,INTSTS1
); /* Clear INTSTS1 */
149 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
150 __raw_writew(0x0001,INTSEL
);