WorkStruct: make allyesconfig
[deliverable/linux.git] / arch / mips / emma2rh / common / irq_emma2rh.c
1 /*
2 * arch/mips/emma2rh/common/irq_emma2rh.c
3 * This file defines the irq handler for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq_5477.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26 /*
27 * EMMA2RH defines 64 IRQs.
28 *
29 * This file exports one function:
30 * emma2rh_irq_init(u32 irq_base);
31 */
32
33 #include <linux/interrupt.h>
34 #include <linux/types.h>
35 #include <linux/ptrace.h>
36
37 #include <asm/debug.h>
38
39 #include <asm/emma2rh/emma2rh.h>
40
41 /* number of total irqs supported by EMMA2RH */
42 #define NUM_EMMA2RH_IRQ 96
43
44 static int emma2rh_irq_base = -1;
45
46 void ll_emma2rh_irq_enable(int);
47 void ll_emma2rh_irq_disable(int);
48
49 static void emma2rh_irq_enable(unsigned int irq)
50 {
51 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
52 }
53
54 static void emma2rh_irq_disable(unsigned int irq)
55 {
56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
57 }
58
59 static unsigned int emma2rh_irq_startup(unsigned int irq)
60 {
61 emma2rh_irq_enable(irq);
62 return 0;
63 }
64
65 #define emma2rh_irq_shutdown emma2rh_irq_disable
66
67 static void emma2rh_irq_ack(unsigned int irq)
68 {
69 /* disable interrupt - some handler will re-enable the irq
70 * and if the interrupt is leveled, we will have infinite loop
71 */
72 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
73 }
74
75 static void emma2rh_irq_end(unsigned int irq)
76 {
77 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
78 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
79 }
80
81 struct irq_chip emma2rh_irq_controller = {
82 .typename = "emma2rh_irq",
83 .startup = emma2rh_irq_startup,
84 .shutdown = emma2rh_irq_shutdown,
85 .enable = emma2rh_irq_enable,
86 .disable = emma2rh_irq_disable,
87 .ack = emma2rh_irq_ack,
88 .end = emma2rh_irq_end,
89 .set_affinity = NULL /* no affinity stuff for UP */
90 };
91
92 void emma2rh_irq_init(u32 irq_base)
93 {
94 u32 i;
95
96 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++) {
97 irq_desc[i].status = IRQ_DISABLED;
98 irq_desc[i].action = NULL;
99 irq_desc[i].depth = 1;
100 irq_desc[i].chip = &emma2rh_irq_controller;
101 }
102
103 emma2rh_irq_base = irq_base;
104 }
105
106 void ll_emma2rh_irq_enable(int emma2rh_irq)
107 {
108 u32 reg_value;
109 u32 reg_bitmask;
110 u32 reg_index;
111
112 reg_index = EMMA2RH_BHIF_INT_EN_0
113 + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
114 * (emma2rh_irq / 32);
115 reg_value = emma2rh_in32(reg_index);
116 reg_bitmask = 0x1 << (emma2rh_irq % 32);
117 db_assert((reg_value & reg_bitmask) == 0);
118 emma2rh_out32(reg_index, reg_value | reg_bitmask);
119 }
120
121 void ll_emma2rh_irq_disable(int emma2rh_irq)
122 {
123 u32 reg_value;
124 u32 reg_bitmask;
125 u32 reg_index;
126
127 reg_index = EMMA2RH_BHIF_INT_EN_0
128 + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
129 * (emma2rh_irq / 32);
130 reg_value = emma2rh_in32(reg_index);
131 reg_bitmask = 0x1 << (emma2rh_irq % 32);
132 db_assert((reg_value & reg_bitmask) != 0);
133 emma2rh_out32(reg_index, reg_value & ~reg_bitmask);
134 }
This page took 0.035344 seconds and 5 git commands to generate.