Blame view
arch/mips/kernel/irq-gt641xx.c
3.34 KB
d5ab1a691 [MIPS] Add GT641x... |
1 2 3 |
/* * GT641xx IRQ routines. * |
ada8e9514 Update Yoichi Yua... |
4 |
* Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> |
d5ab1a691 [MIPS] Add GT641x... |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <linux/hardirq.h> #include <linux/init.h> #include <linux/irq.h> #include <linux/spinlock.h> #include <linux/types.h> #include <asm/gt64120.h> #define GT641XX_IRQ_TO_BIT(irq) (1U << (irq - GT641XX_IRQ_BASE)) |
f2c194a00 MIPS: GT641xx: Co... |
29 |
static DEFINE_RAW_SPINLOCK(gt641xx_irq_lock); |
d5ab1a691 [MIPS] Add GT641x... |
30 |
|
aa400ae5e MIPS: GT641xx: Co... |
31 |
static void ack_gt641xx_irq(struct irq_data *d) |
d5ab1a691 [MIPS] Add GT641x... |
32 33 34 |
{ unsigned long flags; u32 cause; |
f2c194a00 MIPS: GT641xx: Co... |
35 |
raw_spin_lock_irqsave(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
36 |
cause = GT_READ(GT_INTRCAUSE_OFS); |
aa400ae5e MIPS: GT641xx: Co... |
37 |
cause &= ~GT641XX_IRQ_TO_BIT(d->irq); |
d5ab1a691 [MIPS] Add GT641x... |
38 |
GT_WRITE(GT_INTRCAUSE_OFS, cause); |
f2c194a00 MIPS: GT641xx: Co... |
39 |
raw_spin_unlock_irqrestore(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
40 |
} |
aa400ae5e MIPS: GT641xx: Co... |
41 |
static void mask_gt641xx_irq(struct irq_data *d) |
d5ab1a691 [MIPS] Add GT641x... |
42 43 44 |
{ unsigned long flags; u32 mask; |
f2c194a00 MIPS: GT641xx: Co... |
45 |
raw_spin_lock_irqsave(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
46 |
mask = GT_READ(GT_INTRMASK_OFS); |
aa400ae5e MIPS: GT641xx: Co... |
47 |
mask &= ~GT641XX_IRQ_TO_BIT(d->irq); |
d5ab1a691 [MIPS] Add GT641x... |
48 |
GT_WRITE(GT_INTRMASK_OFS, mask); |
f2c194a00 MIPS: GT641xx: Co... |
49 |
raw_spin_unlock_irqrestore(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
50 |
} |
aa400ae5e MIPS: GT641xx: Co... |
51 |
static void mask_ack_gt641xx_irq(struct irq_data *d) |
d5ab1a691 [MIPS] Add GT641x... |
52 53 54 |
{ unsigned long flags; u32 cause, mask; |
f2c194a00 MIPS: GT641xx: Co... |
55 |
raw_spin_lock_irqsave(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
56 |
mask = GT_READ(GT_INTRMASK_OFS); |
aa400ae5e MIPS: GT641xx: Co... |
57 |
mask &= ~GT641XX_IRQ_TO_BIT(d->irq); |
d5ab1a691 [MIPS] Add GT641x... |
58 59 60 |
GT_WRITE(GT_INTRMASK_OFS, mask); cause = GT_READ(GT_INTRCAUSE_OFS); |
aa400ae5e MIPS: GT641xx: Co... |
61 |
cause &= ~GT641XX_IRQ_TO_BIT(d->irq); |
d5ab1a691 [MIPS] Add GT641x... |
62 |
GT_WRITE(GT_INTRCAUSE_OFS, cause); |
f2c194a00 MIPS: GT641xx: Co... |
63 |
raw_spin_unlock_irqrestore(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
64 |
} |
aa400ae5e MIPS: GT641xx: Co... |
65 |
static void unmask_gt641xx_irq(struct irq_data *d) |
d5ab1a691 [MIPS] Add GT641x... |
66 67 68 |
{ unsigned long flags; u32 mask; |
f2c194a00 MIPS: GT641xx: Co... |
69 |
raw_spin_lock_irqsave(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
70 |
mask = GT_READ(GT_INTRMASK_OFS); |
aa400ae5e MIPS: GT641xx: Co... |
71 |
mask |= GT641XX_IRQ_TO_BIT(d->irq); |
d5ab1a691 [MIPS] Add GT641x... |
72 |
GT_WRITE(GT_INTRMASK_OFS, mask); |
f2c194a00 MIPS: GT641xx: Co... |
73 |
raw_spin_unlock_irqrestore(>641xx_irq_lock, flags); |
d5ab1a691 [MIPS] Add GT641x... |
74 75 76 77 |
} static struct irq_chip gt641xx_irq_chip = { .name = "GT641xx", |
aa400ae5e MIPS: GT641xx: Co... |
78 79 80 81 |
.irq_ack = ack_gt641xx_irq, .irq_mask = mask_gt641xx_irq, .irq_mask_ack = mask_ack_gt641xx_irq, .irq_unmask = unmask_gt641xx_irq, |
d5ab1a691 [MIPS] Add GT641x... |
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
}; void gt641xx_irq_dispatch(void) { u32 cause, mask; int i; cause = GT_READ(GT_INTRCAUSE_OFS); mask = GT_READ(GT_INTRMASK_OFS); cause &= mask; /* * bit0 : logical or of all the interrupt bits. * bit30: logical or of bits[29:26,20:1]. * bit31: logical or of bits[25:1]. */ for (i = 1; i < 30; i++) { if (cause & (1U << i)) { do_IRQ(GT641XX_IRQ_BASE + i); return; } } atomic_inc(&irq_err_count); } void __init gt641xx_irq_init(void) { int i; GT_WRITE(GT_INTRMASK_OFS, 0); GT_WRITE(GT_INTRCAUSE_OFS, 0); /* * bit0 : logical or of all the interrupt bits. * bit30: logical or of bits[29:26,20:1]. * bit31: logical or of bits[25:1]. */ for (i = 1; i < 30; i++) |
e4ec7989b MIPS: Convert the... |
121 122 |
irq_set_chip_and_handler(GT641XX_IRQ_BASE + i, >641xx_irq_chip, handle_level_irq); |
d5ab1a691 [MIPS] Add GT641x... |
123 |
} |