~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/rb532/irq.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/rb532/irq.c (Architecture sparc64) and /arch/mips/rb532/irq.c (Architecture mips)


  1 /*                                                  1 /*
  2  *  This program is free software; you can red      2  *  This program is free software; you can redistribute  it and/or modify it
  3  *  under  the terms of  the GNU General  Publ      3  *  under  the terms of  the GNU General  Public License as published by the
  4  *  Free Software Foundation;  either version       4  *  Free Software Foundation;  either version 2 of the  License, or (at your
  5  *  option) any later version.                      5  *  option) any later version.
  6  *                                                  6  *
  7  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' A      7  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
  8  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED       8  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
  9  *  MERCHANTABILITY AND FITNESS FOR A PARTICUL      9  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 10  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABL     10  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
 11  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQU     11  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 12  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITU     12  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
 13  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTER     13  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 14  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTR     14  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
 15  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISIN     15  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 16  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSS     16  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 17  *                                                 17  *
 18  *  You should have received a copy of the  GN     18  *  You should have received a copy of the  GNU General Public License along
 19  *  with this program; if not, write  to the F     19  *  with this program; if not, write  to the Free Software Foundation, Inc.,
 20  *  675 Mass Ave, Cambridge, MA 02139, USA.        20  *  675 Mass Ave, Cambridge, MA 02139, USA.
 21  *                                                 21  *
 22  * Copyright 2002 MontaVista Software Inc.         22  * Copyright 2002 MontaVista Software Inc.
 23  * Author: MontaVista Software, Inc.               23  * Author: MontaVista Software, Inc.
 24  *              stevel@mvista.com or source@mv     24  *              stevel@mvista.com or source@mvista.com
 25  */                                                25  */
 26                                                    26 
 27 #include <linux/bitops.h>                          27 #include <linux/bitops.h>
 28 #include <linux/errno.h>                           28 #include <linux/errno.h>
 29 #include <linux/init.h>                            29 #include <linux/init.h>
 30 #include <linux/io.h>                              30 #include <linux/io.h>
 31 #include <linux/kernel_stat.h>                     31 #include <linux/kernel_stat.h>
 32 #include <linux/signal.h>                          32 #include <linux/signal.h>
 33 #include <linux/sched.h>                           33 #include <linux/sched.h>
 34 #include <linux/types.h>                           34 #include <linux/types.h>
 35 #include <linux/interrupt.h>                       35 #include <linux/interrupt.h>
 36 #include <linux/ioport.h>                          36 #include <linux/ioport.h>
 37 #include <linux/timex.h>                           37 #include <linux/timex.h>
 38 #include <linux/random.h>                          38 #include <linux/random.h>
 39 #include <linux/delay.h>                           39 #include <linux/delay.h>
 40                                                    40 
 41 #include <asm/bootinfo.h>                          41 #include <asm/bootinfo.h>
 42 #include <asm/time.h>                              42 #include <asm/time.h>
 43 #include <asm/mipsregs.h>                          43 #include <asm/mipsregs.h>
 44                                                    44 
 45 #include <asm/mach-rc32434/irq.h>                  45 #include <asm/mach-rc32434/irq.h>
 46 #include <asm/mach-rc32434/gpio.h>                 46 #include <asm/mach-rc32434/gpio.h>
 47                                                    47 
 48 struct intr_group {                                48 struct intr_group {
 49         u32 mask;       /* mask of valid bits      49         u32 mask;       /* mask of valid bits in pending/mask registers */
 50         volatile u32 *base_addr;                   50         volatile u32 *base_addr;
 51 };                                                 51 };
 52                                                    52 
 53 #define RC32434_NR_IRQS  (GROUP4_IRQ_BASE + 32     53 #define RC32434_NR_IRQS  (GROUP4_IRQ_BASE + 32)
 54                                                    54 
 55 #if (NR_IRQS < RC32434_NR_IRQS)                    55 #if (NR_IRQS < RC32434_NR_IRQS)
 56 #error Too little irqs defined. Did you overri     56 #error Too little irqs defined. Did you override <asm/irq.h> ?
 57 #endif                                             57 #endif
 58                                                    58 
 59 static const struct intr_group intr_group[NUM_     59 static const struct intr_group intr_group[NUM_INTR_GROUPS] = {
 60         {                                          60         {
 61                 .mask   = 0x0000efff,              61                 .mask   = 0x0000efff,
 62                 .base_addr = (u32 *) KSEG1ADDR     62                 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 0 * IC_GROUP_OFFSET)},
 63         {                                          63         {
 64                 .mask   = 0x00001fff,              64                 .mask   = 0x00001fff,
 65                 .base_addr = (u32 *) KSEG1ADDR     65                 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 1 * IC_GROUP_OFFSET)},
 66         {                                          66         {
 67                 .mask   = 0x00000007,              67                 .mask   = 0x00000007,
 68                 .base_addr = (u32 *) KSEG1ADDR     68                 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 2 * IC_GROUP_OFFSET)},
 69         {                                          69         {
 70                 .mask   = 0x0003ffff,              70                 .mask   = 0x0003ffff,
 71                 .base_addr = (u32 *) KSEG1ADDR     71                 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 3 * IC_GROUP_OFFSET)},
 72         {                                          72         {
 73                 .mask   = 0xffffffff,              73                 .mask   = 0xffffffff,
 74                 .base_addr = (u32 *) KSEG1ADDR     74                 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 4 * IC_GROUP_OFFSET)}
 75 };                                                 75 };
 76                                                    76 
 77 #define READ_PEND(base) (*(base))                  77 #define READ_PEND(base) (*(base))
 78 #define READ_MASK(base) (*(base + 2))              78 #define READ_MASK(base) (*(base + 2))
 79 #define WRITE_MASK(base, val) (*(base + 2) = (     79 #define WRITE_MASK(base, val) (*(base + 2) = (val))
 80                                                    80 
 81 static inline int irq_to_group(unsigned int ir     81 static inline int irq_to_group(unsigned int irq_nr)
 82 {                                                  82 {
 83         return (irq_nr - GROUP0_IRQ_BASE) >> 5     83         return (irq_nr - GROUP0_IRQ_BASE) >> 5;
 84 }                                                  84 }
 85                                                    85 
 86 static inline int group_to_ip(unsigned int gro     86 static inline int group_to_ip(unsigned int group)
 87 {                                                  87 {
 88         return group + 2;                          88         return group + 2;
 89 }                                                  89 }
 90                                                    90 
 91 static inline void enable_local_irq(unsigned i     91 static inline void enable_local_irq(unsigned int ip)
 92 {                                                  92 {
 93         int ipnum = 0x100 << ip;                   93         int ipnum = 0x100 << ip;
 94                                                    94 
 95         set_c0_status(ipnum);                      95         set_c0_status(ipnum);
 96 }                                                  96 }
 97                                                    97 
 98 static inline void disable_local_irq(unsigned      98 static inline void disable_local_irq(unsigned int ip)
 99 {                                                  99 {
100         int ipnum = 0x100 << ip;                  100         int ipnum = 0x100 << ip;
101                                                   101 
102         clear_c0_status(ipnum);                   102         clear_c0_status(ipnum);
103 }                                                 103 }
104                                                   104 
105 static inline void ack_local_irq(unsigned int     105 static inline void ack_local_irq(unsigned int ip)
106 {                                                 106 {
107         int ipnum = 0x100 << ip;                  107         int ipnum = 0x100 << ip;
108                                                   108 
109         clear_c0_cause(ipnum);                    109         clear_c0_cause(ipnum);
110 }                                                 110 }
111                                                   111 
112 static void rb532_enable_irq(struct irq_data *    112 static void rb532_enable_irq(struct irq_data *d)
113 {                                                 113 {
114         unsigned int group, intr_bit, irq_nr =    114         unsigned int group, intr_bit, irq_nr = d->irq;
115         int ip = irq_nr - GROUP0_IRQ_BASE;        115         int ip = irq_nr - GROUP0_IRQ_BASE;
116         volatile unsigned int *addr;              116         volatile unsigned int *addr;
117                                                   117 
118         if (ip < 0)                               118         if (ip < 0)
119                 enable_local_irq(irq_nr);         119                 enable_local_irq(irq_nr);
120         else {                                    120         else {
121                 group = ip >> 5;                  121                 group = ip >> 5;
122                                                   122 
123                 ip &= (1 << 5) - 1;               123                 ip &= (1 << 5) - 1;
124                 intr_bit = 1 << ip;               124                 intr_bit = 1 << ip;
125                                                   125 
126                 enable_local_irq(group_to_ip(g    126                 enable_local_irq(group_to_ip(group));
127                                                   127 
128                 addr = intr_group[group].base_    128                 addr = intr_group[group].base_addr;
129                 WRITE_MASK(addr, READ_MASK(add    129                 WRITE_MASK(addr, READ_MASK(addr) & ~intr_bit);
130         }                                         130         }
131 }                                                 131 }
132                                                   132 
133 static void rb532_disable_irq(struct irq_data     133 static void rb532_disable_irq(struct irq_data *d)
134 {                                                 134 {
135         unsigned int group, intr_bit, mask, ir    135         unsigned int group, intr_bit, mask, irq_nr = d->irq;
136         int ip = irq_nr - GROUP0_IRQ_BASE;        136         int ip = irq_nr - GROUP0_IRQ_BASE;
137         volatile unsigned int *addr;              137         volatile unsigned int *addr;
138                                                   138 
139         if (ip < 0) {                             139         if (ip < 0) {
140                 disable_local_irq(irq_nr);        140                 disable_local_irq(irq_nr);
141         } else {                                  141         } else {
142                 group = ip >> 5;                  142                 group = ip >> 5;
143                                                   143 
144                 ip &= (1 << 5) - 1;               144                 ip &= (1 << 5) - 1;
145                 intr_bit = 1 << ip;               145                 intr_bit = 1 << ip;
146                 addr = intr_group[group].base_    146                 addr = intr_group[group].base_addr;
147                 mask = READ_MASK(addr);           147                 mask = READ_MASK(addr);
148                 mask |= intr_bit;                 148                 mask |= intr_bit;
149                 WRITE_MASK(addr, mask);           149                 WRITE_MASK(addr, mask);
150                                                   150 
151                 /* There is a maximum of 14 GP    151                 /* There is a maximum of 14 GPIO interrupts */
152                 if (group == GPIO_MAPPED_IRQ_G    152                 if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= (GROUP4_IRQ_BASE + 13))
153                         rb532_gpio_set_istat(0    153                         rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
154                                                   154 
155                 /*                                155                 /*
156                  * if there are no more interr    156                  * if there are no more interrupts enabled in this
157                  * group, disable correspondin    157                  * group, disable corresponding IP
158                  */                               158                  */
159                 if (mask == intr_group[group].    159                 if (mask == intr_group[group].mask)
160                         disable_local_irq(grou    160                         disable_local_irq(group_to_ip(group));
161         }                                         161         }
162 }                                                 162 }
163                                                   163 
164 static void rb532_mask_and_ack_irq(struct irq_    164 static void rb532_mask_and_ack_irq(struct irq_data *d)
165 {                                                 165 {
166         rb532_disable_irq(d);                     166         rb532_disable_irq(d);
167         ack_local_irq(group_to_ip(irq_to_group    167         ack_local_irq(group_to_ip(irq_to_group(d->irq)));
168 }                                                 168 }
169                                                   169 
170 static int rb532_set_type(struct irq_data *d,     170 static int rb532_set_type(struct irq_data *d,  unsigned type)
171 {                                                 171 {
172         int gpio = d->irq - GPIO_MAPPED_IRQ_BA    172         int gpio = d->irq - GPIO_MAPPED_IRQ_BASE;
173         int group = irq_to_group(d->irq);         173         int group = irq_to_group(d->irq);
174                                                   174 
175         if (group != GPIO_MAPPED_IRQ_GROUP ||     175         if (group != GPIO_MAPPED_IRQ_GROUP || d->irq > (GROUP4_IRQ_BASE + 13))
176                 return (type == IRQ_TYPE_LEVEL    176                 return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
177                                                   177 
178         switch (type) {                           178         switch (type) {
179         case IRQ_TYPE_LEVEL_HIGH:                 179         case IRQ_TYPE_LEVEL_HIGH:
180                 rb532_gpio_set_ilevel(1, gpio)    180                 rb532_gpio_set_ilevel(1, gpio);
181                 break;                            181                 break;
182         case IRQ_TYPE_LEVEL_LOW:                  182         case IRQ_TYPE_LEVEL_LOW:
183                 rb532_gpio_set_ilevel(0, gpio)    183                 rb532_gpio_set_ilevel(0, gpio);
184                 break;                            184                 break;
185         default:                                  185         default:
186                 return -EINVAL;                   186                 return -EINVAL;
187         }                                         187         }
188                                                   188 
189         return 0;                                 189         return 0;
190 }                                                 190 }
191                                                   191 
192 static struct irq_chip rc32434_irq_type = {       192 static struct irq_chip rc32434_irq_type = {
193         .name           = "RB532",                193         .name           = "RB532",
194         .irq_ack        = rb532_disable_irq,      194         .irq_ack        = rb532_disable_irq,
195         .irq_mask       = rb532_disable_irq,      195         .irq_mask       = rb532_disable_irq,
196         .irq_mask_ack   = rb532_mask_and_ack_i    196         .irq_mask_ack   = rb532_mask_and_ack_irq,
197         .irq_unmask     = rb532_enable_irq,       197         .irq_unmask     = rb532_enable_irq,
198         .irq_set_type   = rb532_set_type,         198         .irq_set_type   = rb532_set_type,
199 };                                                199 };
200                                                   200 
201 void __init arch_init_irq(void)                   201 void __init arch_init_irq(void)
202 {                                                 202 {
203         int i;                                    203         int i;
204                                                   204 
205         pr_info("Initializing IRQ's: %d out of    205         pr_info("Initializing IRQ's: %d out of %d\n", RC32434_NR_IRQS, NR_IRQS);
206                                                   206 
207         for (i = 0; i < RC32434_NR_IRQS; i++)     207         for (i = 0; i < RC32434_NR_IRQS; i++)
208                 irq_set_chip_and_handler(i, &r    208                 irq_set_chip_and_handler(i, &rc32434_irq_type,
209                                          handl    209                                          handle_level_irq);
210 }                                                 210 }
211                                                   211 
212 /* Main Interrupt dispatcher */                   212 /* Main Interrupt dispatcher */
213 asmlinkage void plat_irq_dispatch(void)           213 asmlinkage void plat_irq_dispatch(void)
214 {                                                 214 {
215         unsigned int ip, pend, group;             215         unsigned int ip, pend, group;
216         volatile unsigned int *addr;              216         volatile unsigned int *addr;
217         unsigned int cp0_cause = read_c0_cause    217         unsigned int cp0_cause = read_c0_cause() & read_c0_status();
218                                                   218 
219         if (cp0_cause & CAUSEF_IP7) {             219         if (cp0_cause & CAUSEF_IP7) {
220                 do_IRQ(7);                        220                 do_IRQ(7);
221         } else {                                  221         } else {
222                 ip = (cp0_cause & 0x7c00);        222                 ip = (cp0_cause & 0x7c00);
223                 if (ip) {                         223                 if (ip) {
224                         group = 21 + (fls(ip)     224                         group = 21 + (fls(ip) - 32);
225                                                   225 
226                         addr = intr_group[grou    226                         addr = intr_group[group].base_addr;
227                                                   227 
228                         pend = READ_PEND(addr)    228                         pend = READ_PEND(addr);
229                         pend &= ~READ_MASK(add    229                         pend &= ~READ_MASK(addr);       /* only unmasked interrupts */
230                         pend = 39 + (fls(pend)    230                         pend = 39 + (fls(pend) - 32);
231                         do_IRQ((group << 5) +     231                         do_IRQ((group << 5) + pend);
232                 }                                 232                 }
233         }                                         233         }
234 }                                                 234 }
235                                                   235 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php