Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 2 | * Set up the interrupt priorities |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 3 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 4 | * Copyright 2004-2009 Analog Devices Inc. |
| 5 | * 2003 Bas Vermeulen <bas@buyways.nl> |
| 6 | * 2002 Arcturus Networks Inc. MaTed <mated@sympatico.ca> |
| 7 | * 2000-2001 Lineo, Inc. D. Jefff Dionne <jeff@lineo.ca> |
| 8 | * 1999 D. Jeff Dionne <jeff@uclinux.org> |
| 9 | * 1996 Roman Zippel |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 10 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 11 | * Licensed under the GPL-2 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/kernel_stat.h> |
| 16 | #include <linux/seq_file.h> |
| 17 | #include <linux/irq.h> |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 18 | #ifdef CONFIG_IPIPE |
| 19 | #include <linux/ipipe.h> |
| 20 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 21 | #ifdef CONFIG_KGDB |
| 22 | #include <linux/kgdb.h> |
| 23 | #endif |
| 24 | #include <asm/traps.h> |
| 25 | #include <asm/blackfin.h> |
| 26 | #include <asm/gpio.h> |
| 27 | #include <asm/irq_handler.h> |
Mike Frysinger | 761ec44 | 2009-10-15 17:12:05 +0000 | [diff] [blame] | 28 | #include <asm/dpmc.h> |
Mike Frysinger | 7eb87fd | 2009-11-03 09:29:50 +0000 | [diff] [blame] | 29 | #include <asm/bfin5xx_spi.h> |
| 30 | #include <asm/bfin_sport.h> |
Michael Hennerich | 15435a2 | 2009-12-16 08:39:58 +0000 | [diff] [blame] | 31 | #include <asm/bfin_can.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 32 | |
Mike Frysinger | 7beb743 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 33 | #define SIC_SYSIRQ(irq) (irq - (IRQ_CORETMR + 1)) |
| 34 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 35 | #ifdef BF537_FAMILY |
| 36 | # define BF537_GENERIC_ERROR_INT_DEMUX |
Mike Frysinger | 7eb87fd | 2009-11-03 09:29:50 +0000 | [diff] [blame] | 37 | # define SPI_ERR_MASK (BIT_STAT_TXCOL | BIT_STAT_RBSY | BIT_STAT_MODF | BIT_STAT_TXE) /* SPI_STAT */ |
| 38 | # define SPORT_ERR_MASK (ROVF | RUVF | TOVF | TUVF) /* SPORT_STAT */ |
| 39 | # define PPI_ERR_MASK (0xFFFF & ~FLD) /* PPI_STATUS */ |
| 40 | # define EMAC_ERR_MASK (PHYINT | MMCINT | RXFSINT | TXFSINT | WAKEDET | RXDMAERR | TXDMAERR | STMDONE) /* EMAC_SYSTAT */ |
| 41 | # define UART_ERR_MASK (0x6) /* UART_IIR */ |
| 42 | # define CAN_ERR_MASK (EWTIF | EWRIF | EPIF | BOIF | WUIF | UIAIF | AAIF | RMLIF | UCEIF | EXTIF | ADIF) /* CAN_GIF */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 43 | #else |
| 44 | # undef BF537_GENERIC_ERROR_INT_DEMUX |
| 45 | #endif |
| 46 | |
| 47 | /* |
| 48 | * NOTES: |
| 49 | * - we have separated the physical Hardware interrupt from the |
| 50 | * levels that the LINUX kernel sees (see the description in irq.h) |
| 51 | * - |
| 52 | */ |
| 53 | |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 54 | #ifndef CONFIG_SMP |
Mike Frysinger | a99bbcc | 2007-10-22 00:19:31 +0800 | [diff] [blame] | 55 | /* Initialize this to an actual value to force it into the .data |
| 56 | * section so that we know it is properly initialized at entry into |
| 57 | * the kernel but before bss is initialized to zero (which is where |
| 58 | * it would live otherwise). The 0x1f magic represents the IRQs we |
| 59 | * cannot actually mask out in hardware. |
| 60 | */ |
Mike Frysinger | 4005978 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 61 | unsigned long bfin_irq_flags = 0x1f; |
| 62 | EXPORT_SYMBOL(bfin_irq_flags); |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 63 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 64 | |
| 65 | /* The number of spurious interrupts */ |
| 66 | atomic_t num_spurious; |
| 67 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 68 | #ifdef CONFIG_PM |
| 69 | unsigned long bfin_sic_iwr[3]; /* Up to 3 SIC_IWRx registers */ |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 70 | unsigned vr_wakeup; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 71 | #endif |
| 72 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 73 | struct ivgx { |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 74 | /* irq number for request_irq, available in mach-bf5xx/irq.h */ |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 75 | unsigned int irqno; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 76 | /* corresponding bit in the SIC_ISR register */ |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 77 | unsigned int isrflag; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 78 | } ivg_table[NR_PERI_INTS]; |
| 79 | |
| 80 | struct ivg_slice { |
| 81 | /* position of first irq in ivg_table for given ivg */ |
| 82 | struct ivgx *ifirst; |
| 83 | struct ivgx *istop; |
| 84 | } ivg7_13[IVG13 - IVG7 + 1]; |
| 85 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Search SIC_IAR and fill tables with the irqvalues |
| 89 | * and their positions in the SIC_ISR register. |
| 90 | */ |
| 91 | static void __init search_IAR(void) |
| 92 | { |
| 93 | unsigned ivg, irq_pos = 0; |
| 94 | for (ivg = 0; ivg <= IVG13 - IVG7; ivg++) { |
Mike Frysinger | 80fcdb9 | 2010-04-22 21:15:00 +0000 | [diff] [blame] | 95 | int irqN; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 96 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 97 | ivg7_13[ivg].istop = ivg7_13[ivg].ifirst = &ivg_table[irq_pos]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 98 | |
Mike Frysinger | 80fcdb9 | 2010-04-22 21:15:00 +0000 | [diff] [blame] | 99 | for (irqN = 0; irqN < NR_PERI_INTS; irqN += 4) { |
| 100 | int irqn; |
| 101 | u32 iar = bfin_read32((unsigned long *)SIC_IAR0 + |
| 102 | #if defined(CONFIG_BF51x) || defined(CONFIG_BF52x) || \ |
| 103 | defined(CONFIG_BF538) || defined(CONFIG_BF539) |
| 104 | ((irqN % 32) >> 3) + ((irqN / 32) * ((SIC_IAR4 - SIC_IAR0) / 4)) |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 105 | #else |
Mike Frysinger | 80fcdb9 | 2010-04-22 21:15:00 +0000 | [diff] [blame] | 106 | (irqN >> 3) |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 107 | #endif |
Mike Frysinger | 80fcdb9 | 2010-04-22 21:15:00 +0000 | [diff] [blame] | 108 | ); |
| 109 | |
| 110 | for (irqn = irqN; irqn < irqN + 4; ++irqn) { |
| 111 | int iar_shift = (irqn & 7) * 4; |
| 112 | if (ivg == (0xf & (iar >> iar_shift))) { |
| 113 | ivg_table[irq_pos].irqno = IVG7 + irqn; |
| 114 | ivg_table[irq_pos].isrflag = 1 << (irqn % 32); |
| 115 | ivg7_13[ivg].istop++; |
| 116 | irq_pos++; |
| 117 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /* |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 124 | * This is for core internal IRQs |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 125 | */ |
| 126 | |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 127 | static void bfin_ack_noop(struct irq_data *d) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 128 | { |
| 129 | /* Dummy function. */ |
| 130 | } |
| 131 | |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 132 | static void bfin_core_mask_irq(struct irq_data *d) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 133 | { |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 134 | bfin_irq_flags &= ~(1 << d->irq); |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 135 | if (!hard_irqs_disabled()) |
| 136 | hard_local_irq_enable(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 139 | static void bfin_core_unmask_irq(struct irq_data *d) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 140 | { |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 141 | bfin_irq_flags |= 1 << d->irq; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 142 | /* |
| 143 | * If interrupts are enabled, IMASK must contain the same value |
Mike Frysinger | 4005978 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 144 | * as bfin_irq_flags. Make sure that invariant holds. If interrupts |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 145 | * are currently disabled we need not do anything; one of the |
| 146 | * callers will take care of setting IMASK to the proper value |
| 147 | * when reenabling interrupts. |
Mike Frysinger | 4005978 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 148 | * local_irq_enable just does "STI bfin_irq_flags", so it's exactly |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 149 | * what we need. |
| 150 | */ |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 151 | if (!hard_irqs_disabled()) |
| 152 | hard_local_irq_enable(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 153 | return; |
| 154 | } |
| 155 | |
| 156 | static void bfin_internal_mask_irq(unsigned int irq) |
| 157 | { |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 158 | unsigned long flags; |
| 159 | |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 160 | #ifdef CONFIG_BF53x |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 161 | flags = hard_local_irq_save(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 162 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() & |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 163 | ~(1 << SIC_SYSIRQ(irq))); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 164 | #else |
| 165 | unsigned mask_bank, mask_bit; |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 166 | flags = hard_local_irq_save(); |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 167 | mask_bank = SIC_SYSIRQ(irq) / 32; |
| 168 | mask_bit = SIC_SYSIRQ(irq) % 32; |
Bryan Wu | c04d66b | 2007-07-12 17:26:31 +0800 | [diff] [blame] | 169 | bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) & |
| 170 | ~(1 << mask_bit)); |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 171 | #ifdef CONFIG_SMP |
| 172 | bfin_write_SICB_IMASK(mask_bank, bfin_read_SICB_IMASK(mask_bank) & |
| 173 | ~(1 << mask_bit)); |
| 174 | #endif |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 175 | #endif |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 176 | hard_local_irq_restore(flags); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 179 | static void bfin_internal_mask_irq_chip(struct irq_data *d) |
| 180 | { |
| 181 | bfin_internal_mask_irq(d->irq); |
| 182 | } |
| 183 | |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 184 | #ifdef CONFIG_SMP |
| 185 | static void bfin_internal_unmask_irq_affinity(unsigned int irq, |
| 186 | const struct cpumask *affinity) |
| 187 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 188 | static void bfin_internal_unmask_irq(unsigned int irq) |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 189 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 190 | { |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 191 | unsigned long flags; |
| 192 | |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 193 | #ifdef CONFIG_BF53x |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 194 | flags = hard_local_irq_save(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 195 | bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 196 | (1 << SIC_SYSIRQ(irq))); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 197 | #else |
| 198 | unsigned mask_bank, mask_bit; |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 199 | flags = hard_local_irq_save(); |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 200 | mask_bank = SIC_SYSIRQ(irq) / 32; |
| 201 | mask_bit = SIC_SYSIRQ(irq) % 32; |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 202 | #ifdef CONFIG_SMP |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 203 | if (cpumask_test_cpu(0, affinity)) |
| 204 | #endif |
| 205 | bfin_write_SIC_IMASK(mask_bank, |
| 206 | bfin_read_SIC_IMASK(mask_bank) | |
| 207 | (1 << mask_bit)); |
| 208 | #ifdef CONFIG_SMP |
| 209 | if (cpumask_test_cpu(1, affinity)) |
| 210 | bfin_write_SICB_IMASK(mask_bank, |
| 211 | bfin_read_SICB_IMASK(mask_bank) | |
| 212 | (1 << mask_bit)); |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 213 | #endif |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 214 | #endif |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 215 | hard_local_irq_restore(flags); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 218 | #ifdef CONFIG_SMP |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 219 | static void bfin_internal_unmask_irq_chip(struct irq_data *d) |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 220 | { |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 221 | bfin_internal_unmask_irq_affinity(d->irq, d->affinity); |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 224 | static int bfin_internal_set_affinity(struct irq_data *d, |
| 225 | const struct cpumask *mask, bool force) |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 226 | { |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 227 | bfin_internal_mask_irq(d->irq); |
| 228 | bfin_internal_unmask_irq_affinity(d->irq, mask); |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 229 | |
| 230 | return 0; |
| 231 | } |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 232 | #else |
| 233 | static void bfin_internal_unmask_irq_chip(struct irq_data *d) |
| 234 | { |
| 235 | bfin_internal_unmask_irq(d->irq); |
| 236 | } |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 237 | #endif |
| 238 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 239 | #ifdef CONFIG_PM |
| 240 | int bfin_internal_set_wake(unsigned int irq, unsigned int state) |
| 241 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 242 | u32 bank, bit, wakeup = 0; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 243 | unsigned long flags; |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 244 | bank = SIC_SYSIRQ(irq) / 32; |
| 245 | bit = SIC_SYSIRQ(irq) % 32; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 246 | |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 247 | switch (irq) { |
| 248 | #ifdef IRQ_RTC |
| 249 | case IRQ_RTC: |
| 250 | wakeup |= WAKE; |
| 251 | break; |
| 252 | #endif |
| 253 | #ifdef IRQ_CAN0_RX |
| 254 | case IRQ_CAN0_RX: |
| 255 | wakeup |= CANWE; |
| 256 | break; |
| 257 | #endif |
| 258 | #ifdef IRQ_CAN1_RX |
| 259 | case IRQ_CAN1_RX: |
| 260 | wakeup |= CANWE; |
| 261 | break; |
| 262 | #endif |
| 263 | #ifdef IRQ_USB_INT0 |
| 264 | case IRQ_USB_INT0: |
| 265 | wakeup |= USBWE; |
| 266 | break; |
| 267 | #endif |
Michael Hennerich | d310fb4 | 2008-08-28 17:32:01 +0800 | [diff] [blame] | 268 | #ifdef CONFIG_BF54x |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 269 | case IRQ_CNT: |
| 270 | wakeup |= ROTWE; |
| 271 | break; |
| 272 | #endif |
| 273 | default: |
| 274 | break; |
| 275 | } |
| 276 | |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 277 | flags = hard_local_irq_save(); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 278 | |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 279 | if (state) { |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 280 | bfin_sic_iwr[bank] |= (1 << bit); |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 281 | vr_wakeup |= wakeup; |
| 282 | |
| 283 | } else { |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 284 | bfin_sic_iwr[bank] &= ~(1 << bit); |
Michael Hennerich | 4a88d0c | 2008-08-05 17:38:41 +0800 | [diff] [blame] | 285 | vr_wakeup &= ~wakeup; |
| 286 | } |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 287 | |
David Howells | 3b139cd | 2010-10-07 14:08:52 +0100 | [diff] [blame] | 288 | hard_local_irq_restore(flags); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 289 | |
| 290 | return 0; |
| 291 | } |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 292 | |
| 293 | static int bfin_internal_set_wake_chip(struct irq_data *d, unsigned int state) |
| 294 | { |
| 295 | return bfin_internal_set_wake(d->irq, state); |
| 296 | } |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 297 | #endif |
| 298 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 299 | static struct irq_chip bfin_core_irqchip = { |
Graf Yang | 763e63c | 2008-10-08 17:08:15 +0800 | [diff] [blame] | 300 | .name = "CORE", |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 301 | .irq_ack = bfin_ack_noop, |
| 302 | .irq_mask = bfin_core_mask_irq, |
| 303 | .irq_unmask = bfin_core_unmask_irq, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | static struct irq_chip bfin_internal_irqchip = { |
Graf Yang | 763e63c | 2008-10-08 17:08:15 +0800 | [diff] [blame] | 307 | .name = "INTN", |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 308 | .irq_ack = bfin_ack_noop, |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 309 | .irq_mask = bfin_internal_mask_irq_chip, |
| 310 | .irq_unmask = bfin_internal_unmask_irq_chip, |
| 311 | .irq_mask_ack = bfin_internal_mask_irq_chip, |
| 312 | .irq_disable = bfin_internal_mask_irq_chip, |
| 313 | .irq_enable = bfin_internal_unmask_irq_chip, |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 314 | #ifdef CONFIG_SMP |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 315 | .irq_set_affinity = bfin_internal_set_affinity, |
Sonic Zhang | 0325f25 | 2009-12-28 07:29:57 +0000 | [diff] [blame] | 316 | #endif |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 317 | #ifdef CONFIG_PM |
Thomas Gleixner | ff43a67 | 2011-02-06 18:23:29 +0000 | [diff] [blame] | 318 | .irq_set_wake = bfin_internal_set_wake_chip, |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 319 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 322 | static void bfin_handle_irq(unsigned irq) |
| 323 | { |
| 324 | #ifdef CONFIG_IPIPE |
| 325 | struct pt_regs regs; /* Contents not used. */ |
| 326 | ipipe_trace_irq_entry(irq); |
| 327 | __ipipe_handle_irq(irq, ®s); |
| 328 | ipipe_trace_irq_exit(irq); |
| 329 | #else /* !CONFIG_IPIPE */ |
Thomas Gleixner | b10bbbb | 2011-02-06 18:23:25 +0000 | [diff] [blame] | 330 | generic_handle_irq(irq); |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 331 | #endif /* !CONFIG_IPIPE */ |
| 332 | } |
| 333 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 334 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 335 | static int error_int_mask; |
| 336 | |
Thomas Gleixner | dabf64b | 2011-02-06 18:23:31 +0000 | [diff] [blame] | 337 | static void bfin_generic_error_mask_irq(struct irq_data *d) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 338 | { |
Thomas Gleixner | dabf64b | 2011-02-06 18:23:31 +0000 | [diff] [blame] | 339 | error_int_mask &= ~(1L << (d->irq - IRQ_PPI_ERROR)); |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 340 | if (!error_int_mask) |
| 341 | bfin_internal_mask_irq(IRQ_GENERIC_ERROR); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 342 | } |
| 343 | |
Thomas Gleixner | dabf64b | 2011-02-06 18:23:31 +0000 | [diff] [blame] | 344 | static void bfin_generic_error_unmask_irq(struct irq_data *d) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 345 | { |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 346 | bfin_internal_unmask_irq(IRQ_GENERIC_ERROR); |
Thomas Gleixner | dabf64b | 2011-02-06 18:23:31 +0000 | [diff] [blame] | 347 | error_int_mask |= 1L << (d->irq - IRQ_PPI_ERROR); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | static struct irq_chip bfin_generic_error_irqchip = { |
Graf Yang | 763e63c | 2008-10-08 17:08:15 +0800 | [diff] [blame] | 351 | .name = "ERROR", |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 352 | .irq_ack = bfin_ack_noop, |
Thomas Gleixner | dabf64b | 2011-02-06 18:23:31 +0000 | [diff] [blame] | 353 | .irq_mask_ack = bfin_generic_error_mask_irq, |
| 354 | .irq_mask = bfin_generic_error_mask_irq, |
| 355 | .irq_unmask = bfin_generic_error_unmask_irq, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | static void bfin_demux_error_irq(unsigned int int_err_irq, |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 359 | struct irq_desc *inta_desc) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 360 | { |
| 361 | int irq = 0; |
| 362 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 363 | #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) |
| 364 | if (bfin_read_EMAC_SYSTAT() & EMAC_ERR_MASK) |
| 365 | irq = IRQ_MAC_ERROR; |
| 366 | else |
| 367 | #endif |
| 368 | if (bfin_read_SPORT0_STAT() & SPORT_ERR_MASK) |
| 369 | irq = IRQ_SPORT0_ERROR; |
| 370 | else if (bfin_read_SPORT1_STAT() & SPORT_ERR_MASK) |
| 371 | irq = IRQ_SPORT1_ERROR; |
| 372 | else if (bfin_read_PPI_STATUS() & PPI_ERR_MASK) |
| 373 | irq = IRQ_PPI_ERROR; |
| 374 | else if (bfin_read_CAN_GIF() & CAN_ERR_MASK) |
| 375 | irq = IRQ_CAN_ERROR; |
| 376 | else if (bfin_read_SPI_STAT() & SPI_ERR_MASK) |
| 377 | irq = IRQ_SPI_ERROR; |
Mike Frysinger | 7eb87fd | 2009-11-03 09:29:50 +0000 | [diff] [blame] | 378 | else if ((bfin_read_UART0_IIR() & UART_ERR_MASK) == UART_ERR_MASK) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 379 | irq = IRQ_UART0_ERROR; |
Mike Frysinger | 7eb87fd | 2009-11-03 09:29:50 +0000 | [diff] [blame] | 380 | else if ((bfin_read_UART1_IIR() & UART_ERR_MASK) == UART_ERR_MASK) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 381 | irq = IRQ_UART1_ERROR; |
| 382 | |
| 383 | if (irq) { |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 384 | if (error_int_mask & (1L << (irq - IRQ_PPI_ERROR))) |
| 385 | bfin_handle_irq(irq); |
| 386 | else { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 387 | |
| 388 | switch (irq) { |
| 389 | case IRQ_PPI_ERROR: |
| 390 | bfin_write_PPI_STATUS(PPI_ERR_MASK); |
| 391 | break; |
| 392 | #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) |
| 393 | case IRQ_MAC_ERROR: |
| 394 | bfin_write_EMAC_SYSTAT(EMAC_ERR_MASK); |
| 395 | break; |
| 396 | #endif |
| 397 | case IRQ_SPORT0_ERROR: |
| 398 | bfin_write_SPORT0_STAT(SPORT_ERR_MASK); |
| 399 | break; |
| 400 | |
| 401 | case IRQ_SPORT1_ERROR: |
| 402 | bfin_write_SPORT1_STAT(SPORT_ERR_MASK); |
| 403 | break; |
| 404 | |
| 405 | case IRQ_CAN_ERROR: |
| 406 | bfin_write_CAN_GIS(CAN_ERR_MASK); |
| 407 | break; |
| 408 | |
| 409 | case IRQ_SPI_ERROR: |
| 410 | bfin_write_SPI_STAT(SPI_ERR_MASK); |
| 411 | break; |
| 412 | |
| 413 | default: |
| 414 | break; |
| 415 | } |
| 416 | |
| 417 | pr_debug("IRQ %d:" |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 418 | " MASKED PERIPHERAL ERROR INTERRUPT ASSERTED\n", |
| 419 | irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 420 | } |
| 421 | } else |
| 422 | printk(KERN_ERR |
| 423 | "%s : %s : LINE %d :\nIRQ ?: PERIPHERAL ERROR" |
| 424 | " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n", |
Harvey Harrison | b85d858 | 2008-04-23 09:39:01 +0800 | [diff] [blame] | 425 | __func__, __FILE__, __LINE__); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 426 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 427 | } |
| 428 | #endif /* BF537_GENERIC_ERROR_INT_DEMUX */ |
| 429 | |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 430 | #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) |
| 431 | static int mac_stat_int_mask; |
| 432 | |
| 433 | static void bfin_mac_status_ack_irq(unsigned int irq) |
| 434 | { |
| 435 | switch (irq) { |
| 436 | case IRQ_MAC_MMCINT: |
| 437 | bfin_write_EMAC_MMC_TIRQS( |
| 438 | bfin_read_EMAC_MMC_TIRQE() & |
| 439 | bfin_read_EMAC_MMC_TIRQS()); |
| 440 | bfin_write_EMAC_MMC_RIRQS( |
| 441 | bfin_read_EMAC_MMC_RIRQE() & |
| 442 | bfin_read_EMAC_MMC_RIRQS()); |
| 443 | break; |
| 444 | case IRQ_MAC_RXFSINT: |
| 445 | bfin_write_EMAC_RX_STKY( |
| 446 | bfin_read_EMAC_RX_IRQE() & |
| 447 | bfin_read_EMAC_RX_STKY()); |
| 448 | break; |
| 449 | case IRQ_MAC_TXFSINT: |
| 450 | bfin_write_EMAC_TX_STKY( |
| 451 | bfin_read_EMAC_TX_IRQE() & |
| 452 | bfin_read_EMAC_TX_STKY()); |
| 453 | break; |
| 454 | case IRQ_MAC_WAKEDET: |
| 455 | bfin_write_EMAC_WKUP_CTL( |
| 456 | bfin_read_EMAC_WKUP_CTL() | MPKS | RWKS); |
| 457 | break; |
| 458 | default: |
| 459 | /* These bits are W1C */ |
| 460 | bfin_write_EMAC_SYSTAT(1L << (irq - IRQ_MAC_PHYINT)); |
| 461 | break; |
| 462 | } |
| 463 | } |
| 464 | |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 465 | static void bfin_mac_status_mask_irq(struct irq_data *d) |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 466 | { |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 467 | unsigned int irq = d->irq; |
| 468 | |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 469 | mac_stat_int_mask &= ~(1L << (irq - IRQ_MAC_PHYINT)); |
| 470 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 471 | switch (irq) { |
| 472 | case IRQ_MAC_PHYINT: |
| 473 | bfin_write_EMAC_SYSCTL(bfin_read_EMAC_SYSCTL() & ~PHYIE); |
| 474 | break; |
| 475 | default: |
| 476 | break; |
| 477 | } |
| 478 | #else |
| 479 | if (!mac_stat_int_mask) |
| 480 | bfin_internal_mask_irq(IRQ_MAC_ERROR); |
| 481 | #endif |
| 482 | bfin_mac_status_ack_irq(irq); |
| 483 | } |
| 484 | |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 485 | static void bfin_mac_status_unmask_irq(struct irq_data *d) |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 486 | { |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 487 | unsigned int irq = d->irq; |
| 488 | |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 489 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 490 | switch (irq) { |
| 491 | case IRQ_MAC_PHYINT: |
| 492 | bfin_write_EMAC_SYSCTL(bfin_read_EMAC_SYSCTL() | PHYIE); |
| 493 | break; |
| 494 | default: |
| 495 | break; |
| 496 | } |
| 497 | #else |
| 498 | if (!mac_stat_int_mask) |
| 499 | bfin_internal_unmask_irq(IRQ_MAC_ERROR); |
| 500 | #endif |
| 501 | mac_stat_int_mask |= 1L << (irq - IRQ_MAC_PHYINT); |
| 502 | } |
| 503 | |
| 504 | #ifdef CONFIG_PM |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 505 | int bfin_mac_status_set_wake(struct irq_data *d, unsigned int state) |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 506 | { |
| 507 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
| 508 | return bfin_internal_set_wake(IRQ_GENERIC_ERROR, state); |
| 509 | #else |
| 510 | return bfin_internal_set_wake(IRQ_MAC_ERROR, state); |
| 511 | #endif |
| 512 | } |
| 513 | #endif |
| 514 | |
| 515 | static struct irq_chip bfin_mac_status_irqchip = { |
| 516 | .name = "MACST", |
Thomas Gleixner | 4f19ea4 | 2011-02-06 18:23:27 +0000 | [diff] [blame] | 517 | .irq_ack = bfin_ack_noop, |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 518 | .irq_mask_ack = bfin_mac_status_mask_irq, |
| 519 | .irq_mask = bfin_mac_status_mask_irq, |
| 520 | .irq_unmask = bfin_mac_status_unmask_irq, |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 521 | #ifdef CONFIG_PM |
Thomas Gleixner | 172d2d1 | 2011-02-06 18:23:34 +0000 | [diff] [blame^] | 522 | .irq_set_wake = bfin_mac_status_set_wake, |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 523 | #endif |
| 524 | }; |
| 525 | |
| 526 | static void bfin_demux_mac_status_irq(unsigned int int_err_irq, |
| 527 | struct irq_desc *inta_desc) |
| 528 | { |
| 529 | int i, irq = 0; |
| 530 | u32 status = bfin_read_EMAC_SYSTAT(); |
| 531 | |
Michael Hennerich | bedeea6 | 2010-08-20 11:59:27 +0000 | [diff] [blame] | 532 | for (i = 0; i <= (IRQ_MAC_STMDONE - IRQ_MAC_PHYINT); i++) |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 533 | if (status & (1L << i)) { |
| 534 | irq = IRQ_MAC_PHYINT + i; |
| 535 | break; |
| 536 | } |
| 537 | |
| 538 | if (irq) { |
| 539 | if (mac_stat_int_mask & (1L << (irq - IRQ_MAC_PHYINT))) { |
| 540 | bfin_handle_irq(irq); |
| 541 | } else { |
| 542 | bfin_mac_status_ack_irq(irq); |
| 543 | pr_debug("IRQ %d:" |
| 544 | " MASKED MAC ERROR INTERRUPT ASSERTED\n", |
| 545 | irq); |
| 546 | } |
| 547 | } else |
| 548 | printk(KERN_ERR |
| 549 | "%s : %s : LINE %d :\nIRQ ?: MAC ERROR" |
Michael Hennerich | bedeea6 | 2010-08-20 11:59:27 +0000 | [diff] [blame] | 550 | " INTERRUPT ASSERTED BUT NO SOURCE FOUND" |
| 551 | "(EMAC_SYSTAT=0x%X)\n", |
| 552 | __func__, __FILE__, __LINE__, status); |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 553 | } |
| 554 | #endif |
| 555 | |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 556 | static inline void bfin_set_irq_handler(unsigned irq, irq_flow_handler_t handle) |
| 557 | { |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 558 | #ifdef CONFIG_IPIPE |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 559 | _set_irq_handler(irq, handle_level_irq); |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 560 | #else |
Thomas Gleixner | b10bbbb | 2011-02-06 18:23:25 +0000 | [diff] [blame] | 561 | __set_irq_handler_unlocked(irq, handle); |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 562 | #endif |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 563 | } |
| 564 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 565 | static DECLARE_BITMAP(gpio_enabled, MAX_BLACKFIN_GPIOS); |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 566 | extern void bfin_gpio_irq_prepare(unsigned gpio); |
Michael Hennerich | 6fce6a8 | 2007-12-24 16:56:12 +0800 | [diff] [blame] | 567 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 568 | #if !defined(CONFIG_BF54x) |
| 569 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 570 | static void bfin_gpio_ack_irq(unsigned int irq) |
| 571 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 572 | /* AFAIK ack_irq in case mask_ack is provided |
| 573 | * get's only called for edge sense irqs |
| 574 | */ |
| 575 | set_gpio_data(irq_to_gpio(irq), 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | static void bfin_gpio_mask_ack_irq(unsigned int irq) |
| 579 | { |
Thomas Gleixner | b10bbbb | 2011-02-06 18:23:25 +0000 | [diff] [blame] | 580 | struct irq_desc *desc = irq_to_desc(irq); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 581 | u32 gpionr = irq_to_gpio(irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 582 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 583 | if (desc->handle_irq == handle_edge_irq) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 584 | set_gpio_data(gpionr, 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 585 | |
| 586 | set_gpio_maska(gpionr, 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | static void bfin_gpio_mask_irq(unsigned int irq) |
| 590 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 591 | set_gpio_maska(irq_to_gpio(irq), 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | static void bfin_gpio_unmask_irq(unsigned int irq) |
| 595 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 596 | set_gpio_maska(irq_to_gpio(irq), 1); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | static unsigned int bfin_gpio_irq_startup(unsigned int irq) |
| 600 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 601 | u32 gpionr = irq_to_gpio(irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 602 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 603 | if (__test_and_set_bit(gpionr, gpio_enabled)) |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 604 | bfin_gpio_irq_prepare(gpionr); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 605 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 606 | bfin_gpio_unmask_irq(irq); |
| 607 | |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 608 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | static void bfin_gpio_irq_shutdown(unsigned int irq) |
| 612 | { |
Graf Yang | 30af6d4 | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 613 | u32 gpionr = irq_to_gpio(irq); |
| 614 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 615 | bfin_gpio_mask_irq(irq); |
Graf Yang | 30af6d4 | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 616 | __clear_bit(gpionr, gpio_enabled); |
Graf Yang | 9570ff4 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 617 | bfin_gpio_irq_free(gpionr); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | static int bfin_gpio_irq_type(unsigned int irq, unsigned int type) |
| 621 | { |
Graf Yang | 8eb3e3b | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 622 | int ret; |
| 623 | char buf[16]; |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 624 | u32 gpionr = irq_to_gpio(irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 625 | |
| 626 | if (type == IRQ_TYPE_PROBE) { |
| 627 | /* only probe unenabled GPIO interrupt lines */ |
Mike Frysinger | c369534 | 2009-06-13 10:32:29 -0400 | [diff] [blame] | 628 | if (test_bit(gpionr, gpio_enabled)) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 629 | return 0; |
| 630 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
| 631 | } |
| 632 | |
| 633 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 634 | IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 635 | |
Graf Yang | 9570ff4 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 636 | snprintf(buf, 16, "gpio-irq%d", irq); |
| 637 | ret = bfin_gpio_irq_request(gpionr, buf); |
| 638 | if (ret) |
| 639 | return ret; |
| 640 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 641 | if (__test_and_set_bit(gpionr, gpio_enabled)) |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 642 | bfin_gpio_irq_prepare(gpionr); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 643 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 644 | } else { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 645 | __clear_bit(gpionr, gpio_enabled); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 646 | return 0; |
| 647 | } |
| 648 | |
Michael Hennerich | f1bceb4 | 2008-02-02 16:17:52 +0800 | [diff] [blame] | 649 | set_gpio_inen(gpionr, 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 650 | set_gpio_dir(gpionr, 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 651 | |
| 652 | if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 653 | == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 654 | set_gpio_both(gpionr, 1); |
| 655 | else |
| 656 | set_gpio_both(gpionr, 0); |
| 657 | |
| 658 | if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW))) |
| 659 | set_gpio_polar(gpionr, 1); /* low or falling edge denoted by one */ |
| 660 | else |
| 661 | set_gpio_polar(gpionr, 0); /* high or rising edge denoted by zero */ |
| 662 | |
Michael Hennerich | f1bceb4 | 2008-02-02 16:17:52 +0800 | [diff] [blame] | 663 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { |
| 664 | set_gpio_edge(gpionr, 1); |
| 665 | set_gpio_inen(gpionr, 1); |
Michael Hennerich | f1bceb4 | 2008-02-02 16:17:52 +0800 | [diff] [blame] | 666 | set_gpio_data(gpionr, 0); |
| 667 | |
| 668 | } else { |
| 669 | set_gpio_edge(gpionr, 0); |
Michael Hennerich | f1bceb4 | 2008-02-02 16:17:52 +0800 | [diff] [blame] | 670 | set_gpio_inen(gpionr, 1); |
| 671 | } |
| 672 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 673 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 674 | bfin_set_irq_handler(irq, handle_edge_irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 675 | else |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 676 | bfin_set_irq_handler(irq, handle_level_irq); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 677 | |
| 678 | return 0; |
| 679 | } |
| 680 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 681 | #ifdef CONFIG_PM |
| 682 | int bfin_gpio_set_wake(unsigned int irq, unsigned int state) |
| 683 | { |
Michael Hennerich | bb84dbf | 2010-03-10 14:26:06 +0000 | [diff] [blame] | 684 | return gpio_pm_wakeup_ctrl(irq_to_gpio(irq), state); |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 685 | } |
| 686 | #endif |
| 687 | |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 688 | static void bfin_demux_gpio_irq(unsigned int inta_irq, |
| 689 | struct irq_desc *desc) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 690 | { |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 691 | unsigned int i, gpio, mask, irq, search = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 692 | |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 693 | switch (inta_irq) { |
| 694 | #if defined(CONFIG_BF53x) |
| 695 | case IRQ_PROG_INTA: |
| 696 | irq = IRQ_PF0; |
| 697 | search = 1; |
| 698 | break; |
| 699 | # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) |
| 700 | case IRQ_MAC_RX: |
| 701 | irq = IRQ_PH0; |
| 702 | break; |
| 703 | # endif |
Michael Hennerich | dc26aec | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 704 | #elif defined(CONFIG_BF538) || defined(CONFIG_BF539) |
| 705 | case IRQ_PORTF_INTA: |
| 706 | irq = IRQ_PF0; |
| 707 | break; |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 708 | #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x) |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 709 | case IRQ_PORTF_INTA: |
| 710 | irq = IRQ_PF0; |
| 711 | break; |
| 712 | case IRQ_PORTG_INTA: |
| 713 | irq = IRQ_PG0; |
| 714 | break; |
| 715 | case IRQ_PORTH_INTA: |
| 716 | irq = IRQ_PH0; |
| 717 | break; |
| 718 | #elif defined(CONFIG_BF561) |
| 719 | case IRQ_PROG0_INTA: |
| 720 | irq = IRQ_PF0; |
| 721 | break; |
| 722 | case IRQ_PROG1_INTA: |
| 723 | irq = IRQ_PF16; |
| 724 | break; |
| 725 | case IRQ_PROG2_INTA: |
| 726 | irq = IRQ_PF32; |
| 727 | break; |
| 728 | #endif |
| 729 | default: |
| 730 | BUG(); |
| 731 | return; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 732 | } |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 733 | |
| 734 | if (search) { |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 735 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 736 | irq += i; |
| 737 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 738 | mask = get_gpiop_data(i) & get_gpiop_maska(i); |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 739 | |
| 740 | while (mask) { |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 741 | if (mask & 1) |
| 742 | bfin_handle_irq(irq); |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 743 | irq++; |
| 744 | mask >>= 1; |
| 745 | } |
| 746 | } |
| 747 | } else { |
| 748 | gpio = irq_to_gpio(irq); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 749 | mask = get_gpiop_data(gpio) & get_gpiop_maska(gpio); |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 750 | |
| 751 | do { |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 752 | if (mask & 1) |
| 753 | bfin_handle_irq(irq); |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 754 | irq++; |
| 755 | mask >>= 1; |
| 756 | } while (mask); |
| 757 | } |
| 758 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 761 | #else /* CONFIG_BF54x */ |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 762 | |
| 763 | #define NR_PINT_SYS_IRQS 4 |
| 764 | #define NR_PINT_BITS 32 |
| 765 | #define NR_PINTS 160 |
| 766 | #define IRQ_NOT_AVAIL 0xFF |
| 767 | |
| 768 | #define PINT_2_BANK(x) ((x) >> 5) |
| 769 | #define PINT_2_BIT(x) ((x) & 0x1F) |
| 770 | #define PINT_BIT(x) (1 << (PINT_2_BIT(x))) |
| 771 | |
| 772 | static unsigned char irq2pint_lut[NR_PINTS]; |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 773 | static unsigned char pint2irq_lut[NR_PINT_SYS_IRQS * NR_PINT_BITS]; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 774 | |
| 775 | struct pin_int_t { |
| 776 | unsigned int mask_set; |
| 777 | unsigned int mask_clear; |
| 778 | unsigned int request; |
| 779 | unsigned int assign; |
| 780 | unsigned int edge_set; |
| 781 | unsigned int edge_clear; |
| 782 | unsigned int invert_set; |
| 783 | unsigned int invert_clear; |
| 784 | unsigned int pinstate; |
| 785 | unsigned int latch; |
| 786 | }; |
| 787 | |
| 788 | static struct pin_int_t *pint[NR_PINT_SYS_IRQS] = { |
| 789 | (struct pin_int_t *)PINT0_MASK_SET, |
| 790 | (struct pin_int_t *)PINT1_MASK_SET, |
| 791 | (struct pin_int_t *)PINT2_MASK_SET, |
| 792 | (struct pin_int_t *)PINT3_MASK_SET, |
| 793 | }; |
| 794 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 795 | inline unsigned int get_irq_base(u32 bank, u8 bmap) |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 796 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 797 | unsigned int irq_base; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 798 | |
| 799 | if (bank < 2) { /*PA-PB */ |
| 800 | irq_base = IRQ_PA0 + bmap * 16; |
| 801 | } else { /*PC-PJ */ |
| 802 | irq_base = IRQ_PC0 + bmap * 16; |
| 803 | } |
| 804 | |
| 805 | return irq_base; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */ |
| 809 | void init_pint_lut(void) |
| 810 | { |
| 811 | u16 bank, bit, irq_base, bit_pos; |
| 812 | u32 pint_assign; |
| 813 | u8 bmap; |
| 814 | |
| 815 | memset(irq2pint_lut, IRQ_NOT_AVAIL, sizeof(irq2pint_lut)); |
| 816 | |
| 817 | for (bank = 0; bank < NR_PINT_SYS_IRQS; bank++) { |
| 818 | |
| 819 | pint_assign = pint[bank]->assign; |
| 820 | |
| 821 | for (bit = 0; bit < NR_PINT_BITS; bit++) { |
| 822 | |
| 823 | bmap = (pint_assign >> ((bit / 8) * 8)) & 0xFF; |
| 824 | |
| 825 | irq_base = get_irq_base(bank, bmap); |
| 826 | |
| 827 | irq_base += (bit % 8) + ((bit / 8) & 1 ? 8 : 0); |
| 828 | bit_pos = bit + bank * NR_PINT_BITS; |
| 829 | |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 830 | pint2irq_lut[bit_pos] = irq_base - SYS_IRQS; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 831 | irq2pint_lut[irq_base - SYS_IRQS] = bit_pos; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 832 | } |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 833 | } |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 834 | } |
| 835 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 836 | static void bfin_gpio_ack_irq(unsigned int irq) |
| 837 | { |
Thomas Gleixner | b10bbbb | 2011-02-06 18:23:25 +0000 | [diff] [blame] | 838 | struct irq_desc *desc = irq_to_desc(irq); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 839 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 840 | u32 pintbit = PINT_BIT(pint_val); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 841 | u32 bank = PINT_2_BANK(pint_val); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 842 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 843 | if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) { |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 844 | if (pint[bank]->invert_set & pintbit) |
| 845 | pint[bank]->invert_clear = pintbit; |
| 846 | else |
| 847 | pint[bank]->invert_set = pintbit; |
| 848 | } |
| 849 | pint[bank]->request = pintbit; |
| 850 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | static void bfin_gpio_mask_ack_irq(unsigned int irq) |
| 854 | { |
Thomas Gleixner | b10bbbb | 2011-02-06 18:23:25 +0000 | [diff] [blame] | 855 | struct irq_desc *desc = irq_to_desc(irq); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 856 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 857 | u32 pintbit = PINT_BIT(pint_val); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 858 | u32 bank = PINT_2_BANK(pint_val); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 859 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 860 | if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) { |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 861 | if (pint[bank]->invert_set & pintbit) |
| 862 | pint[bank]->invert_clear = pintbit; |
| 863 | else |
| 864 | pint[bank]->invert_set = pintbit; |
| 865 | } |
| 866 | |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 867 | pint[bank]->request = pintbit; |
| 868 | pint[bank]->mask_clear = pintbit; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | static void bfin_gpio_mask_irq(unsigned int irq) |
| 872 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 873 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 874 | |
| 875 | pint[PINT_2_BANK(pint_val)]->mask_clear = PINT_BIT(pint_val); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | static void bfin_gpio_unmask_irq(unsigned int irq) |
| 879 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 880 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 881 | u32 pintbit = PINT_BIT(pint_val); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 882 | u32 bank = PINT_2_BANK(pint_val); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 883 | |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 884 | pint[bank]->mask_set = pintbit; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | static unsigned int bfin_gpio_irq_startup(unsigned int irq) |
| 888 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 889 | u32 gpionr = irq_to_gpio(irq); |
| 890 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 891 | |
Michael Hennerich | 50e163c | 2007-07-24 16:17:28 +0800 | [diff] [blame] | 892 | if (pint_val == IRQ_NOT_AVAIL) { |
| 893 | printk(KERN_ERR |
| 894 | "GPIO IRQ %d :Not in PINT Assign table " |
| 895 | "Reconfigure Interrupt to Port Assignemt\n", irq); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 896 | return -ENODEV; |
Michael Hennerich | 50e163c | 2007-07-24 16:17:28 +0800 | [diff] [blame] | 897 | } |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 898 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 899 | if (__test_and_set_bit(gpionr, gpio_enabled)) |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 900 | bfin_gpio_irq_prepare(gpionr); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 901 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 902 | bfin_gpio_unmask_irq(irq); |
| 903 | |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 904 | return 0; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | static void bfin_gpio_irq_shutdown(unsigned int irq) |
| 908 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 909 | u32 gpionr = irq_to_gpio(irq); |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 910 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 911 | bfin_gpio_mask_irq(irq); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 912 | __clear_bit(gpionr, gpio_enabled); |
Graf Yang | 9570ff4 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 913 | bfin_gpio_irq_free(gpionr); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | static int bfin_gpio_irq_type(unsigned int irq, unsigned int type) |
| 917 | { |
Graf Yang | 8eb3e3b | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 918 | int ret; |
| 919 | char buf[16]; |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 920 | u32 gpionr = irq_to_gpio(irq); |
| 921 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 922 | u32 pintbit = PINT_BIT(pint_val); |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 923 | u32 bank = PINT_2_BANK(pint_val); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 924 | |
| 925 | if (pint_val == IRQ_NOT_AVAIL) |
| 926 | return -ENODEV; |
| 927 | |
| 928 | if (type == IRQ_TYPE_PROBE) { |
| 929 | /* only probe unenabled GPIO interrupt lines */ |
Mike Frysinger | c369534 | 2009-06-13 10:32:29 -0400 | [diff] [blame] | 930 | if (test_bit(gpionr, gpio_enabled)) |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 931 | return 0; |
| 932 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
| 933 | } |
| 934 | |
| 935 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING | |
| 936 | IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { |
Graf Yang | 9570ff4 | 2009-01-07 23:14:38 +0800 | [diff] [blame] | 937 | |
| 938 | snprintf(buf, 16, "gpio-irq%d", irq); |
| 939 | ret = bfin_gpio_irq_request(gpionr, buf); |
| 940 | if (ret) |
| 941 | return ret; |
| 942 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 943 | if (__test_and_set_bit(gpionr, gpio_enabled)) |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 944 | bfin_gpio_irq_prepare(gpionr); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 945 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 946 | } else { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 947 | __clear_bit(gpionr, gpio_enabled); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 948 | return 0; |
| 949 | } |
| 950 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 951 | if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW))) |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 952 | pint[bank]->invert_set = pintbit; /* low or falling edge denoted by one */ |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 953 | else |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 954 | pint[bank]->invert_clear = pintbit; /* high or rising edge denoted by zero */ |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 955 | |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 956 | if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) |
| 957 | == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 958 | if (gpio_get_value(gpionr)) |
| 959 | pint[bank]->invert_set = pintbit; |
| 960 | else |
| 961 | pint[bank]->invert_clear = pintbit; |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { |
| 965 | pint[bank]->edge_set = pintbit; |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 966 | bfin_set_irq_handler(irq, handle_edge_irq); |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 967 | } else { |
| 968 | pint[bank]->edge_clear = pintbit; |
Graf Yang | bfd1511 | 2008-10-08 18:02:44 +0800 | [diff] [blame] | 969 | bfin_set_irq_handler(irq, handle_level_irq); |
Michael Hennerich | 8baf560 | 2007-12-24 18:51:34 +0800 | [diff] [blame] | 970 | } |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 971 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 972 | return 0; |
| 973 | } |
| 974 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 975 | #ifdef CONFIG_PM |
| 976 | u32 pint_saved_masks[NR_PINT_SYS_IRQS]; |
| 977 | u32 pint_wakeup_masks[NR_PINT_SYS_IRQS]; |
| 978 | |
| 979 | int bfin_gpio_set_wake(unsigned int irq, unsigned int state) |
| 980 | { |
| 981 | u32 pint_irq; |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 982 | u32 pint_val = irq2pint_lut[irq - SYS_IRQS]; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 983 | u32 bank = PINT_2_BANK(pint_val); |
| 984 | u32 pintbit = PINT_BIT(pint_val); |
| 985 | |
| 986 | switch (bank) { |
| 987 | case 0: |
| 988 | pint_irq = IRQ_PINT0; |
| 989 | break; |
| 990 | case 2: |
| 991 | pint_irq = IRQ_PINT2; |
| 992 | break; |
| 993 | case 3: |
| 994 | pint_irq = IRQ_PINT3; |
| 995 | break; |
| 996 | case 1: |
| 997 | pint_irq = IRQ_PINT1; |
| 998 | break; |
| 999 | default: |
| 1000 | return -EINVAL; |
| 1001 | } |
| 1002 | |
| 1003 | bfin_internal_set_wake(pint_irq, state); |
| 1004 | |
| 1005 | if (state) |
| 1006 | pint_wakeup_masks[bank] |= pintbit; |
| 1007 | else |
| 1008 | pint_wakeup_masks[bank] &= ~pintbit; |
| 1009 | |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
| 1013 | u32 bfin_pm_setup(void) |
| 1014 | { |
| 1015 | u32 val, i; |
| 1016 | |
| 1017 | for (i = 0; i < NR_PINT_SYS_IRQS; i++) { |
| 1018 | val = pint[i]->mask_clear; |
| 1019 | pint_saved_masks[i] = val; |
| 1020 | if (val ^ pint_wakeup_masks[i]) { |
| 1021 | pint[i]->mask_clear = val; |
| 1022 | pint[i]->mask_set = pint_wakeup_masks[i]; |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
| 1029 | void bfin_pm_restore(void) |
| 1030 | { |
| 1031 | u32 i, val; |
| 1032 | |
| 1033 | for (i = 0; i < NR_PINT_SYS_IRQS; i++) { |
| 1034 | val = pint_saved_masks[i]; |
| 1035 | if (val ^ pint_wakeup_masks[i]) { |
| 1036 | pint[i]->mask_clear = pint[i]->mask_clear; |
| 1037 | pint[i]->mask_set = val; |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | #endif |
| 1042 | |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 1043 | static void bfin_demux_gpio_irq(unsigned int inta_irq, |
| 1044 | struct irq_desc *desc) |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1045 | { |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1046 | u32 bank, pint_val; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1047 | u32 request, irq; |
| 1048 | |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 1049 | switch (inta_irq) { |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1050 | case IRQ_PINT0: |
| 1051 | bank = 0; |
| 1052 | break; |
| 1053 | case IRQ_PINT2: |
| 1054 | bank = 2; |
| 1055 | break; |
| 1056 | case IRQ_PINT3: |
| 1057 | bank = 3; |
| 1058 | break; |
| 1059 | case IRQ_PINT1: |
| 1060 | bank = 1; |
| 1061 | break; |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 1062 | default: |
| 1063 | return; |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | pint_val = bank * NR_PINT_BITS; |
| 1067 | |
| 1068 | request = pint[bank]->request; |
| 1069 | |
| 1070 | while (request) { |
| 1071 | if (request & 1) { |
Michael Hennerich | e3f2300 | 2007-07-12 16:39:29 +0800 | [diff] [blame] | 1072 | irq = pint2irq_lut[pint_val] + SYS_IRQS; |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1073 | bfin_handle_irq(irq); |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1074 | } |
| 1075 | pint_val++; |
| 1076 | request >>= 1; |
| 1077 | } |
| 1078 | |
| 1079 | } |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1080 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1081 | |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1082 | static struct irq_chip bfin_gpio_irqchip = { |
| 1083 | .name = "GPIO", |
| 1084 | .ack = bfin_gpio_ack_irq, |
| 1085 | .mask = bfin_gpio_mask_irq, |
| 1086 | .mask_ack = bfin_gpio_mask_ack_irq, |
| 1087 | .unmask = bfin_gpio_unmask_irq, |
| 1088 | .disable = bfin_gpio_mask_irq, |
| 1089 | .enable = bfin_gpio_unmask_irq, |
| 1090 | .set_type = bfin_gpio_irq_type, |
| 1091 | .startup = bfin_gpio_irq_startup, |
| 1092 | .shutdown = bfin_gpio_irq_shutdown, |
| 1093 | #ifdef CONFIG_PM |
| 1094 | .set_wake = bfin_gpio_set_wake, |
| 1095 | #endif |
| 1096 | }; |
| 1097 | |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1098 | void __cpuinit init_exception_vectors(void) |
Bernd Schmidt | 8be80ed | 2007-07-25 14:44:49 +0800 | [diff] [blame] | 1099 | { |
Mike Frysinger | f0b5d12 | 2007-08-05 17:03:59 +0800 | [diff] [blame] | 1100 | /* cannot program in software: |
| 1101 | * evt0 - emulation (jtag) |
| 1102 | * evt1 - reset |
| 1103 | */ |
| 1104 | bfin_write_EVT2(evt_nmi); |
Bernd Schmidt | 8be80ed | 2007-07-25 14:44:49 +0800 | [diff] [blame] | 1105 | bfin_write_EVT3(trap); |
| 1106 | bfin_write_EVT5(evt_ivhw); |
| 1107 | bfin_write_EVT6(evt_timer); |
| 1108 | bfin_write_EVT7(evt_evt7); |
| 1109 | bfin_write_EVT8(evt_evt8); |
| 1110 | bfin_write_EVT9(evt_evt9); |
| 1111 | bfin_write_EVT10(evt_evt10); |
| 1112 | bfin_write_EVT11(evt_evt11); |
| 1113 | bfin_write_EVT12(evt_evt12); |
| 1114 | bfin_write_EVT13(evt_evt13); |
Philippe Gerum | 9703a73 | 2009-06-22 18:23:48 +0200 | [diff] [blame] | 1115 | bfin_write_EVT14(evt_evt14); |
Bernd Schmidt | 8be80ed | 2007-07-25 14:44:49 +0800 | [diff] [blame] | 1116 | bfin_write_EVT15(evt_system_call); |
| 1117 | CSYNC(); |
| 1118 | } |
| 1119 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1120 | /* |
| 1121 | * This function should be called during kernel startup to initialize |
| 1122 | * the BFin IRQ handling routines. |
| 1123 | */ |
Michael Hennerich | 8d02237 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1124 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1125 | int __init init_arch_irq(void) |
| 1126 | { |
| 1127 | int irq; |
| 1128 | unsigned long ilat = 0; |
| 1129 | /* Disable all the peripheral intrs - page 4-29 HW Ref manual */ |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 1130 | #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) \ |
| 1131 | || defined(BF538_FAMILY) || defined(CONFIG_BF51x) |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1132 | bfin_write_SIC_IMASK0(SIC_UNMASK_ALL); |
| 1133 | bfin_write_SIC_IMASK1(SIC_UNMASK_ALL); |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1134 | # ifdef CONFIG_BF54x |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 1135 | bfin_write_SIC_IMASK2(SIC_UNMASK_ALL); |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1136 | # endif |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1137 | # ifdef CONFIG_SMP |
| 1138 | bfin_write_SICB_IMASK0(SIC_UNMASK_ALL); |
| 1139 | bfin_write_SICB_IMASK1(SIC_UNMASK_ALL); |
| 1140 | # endif |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1141 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1142 | bfin_write_SIC_IMASK(SIC_UNMASK_ALL); |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1143 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1144 | |
| 1145 | local_irq_disable(); |
| 1146 | |
Mike Frysinger | d70536e | 2008-08-25 17:37:35 +0800 | [diff] [blame] | 1147 | #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) |
Mike Frysinger | 95a86b5 | 2008-08-14 15:05:01 +0800 | [diff] [blame] | 1148 | /* Clear EMAC Interrupt Status bits so we can demux it later */ |
| 1149 | bfin_write_EMAC_SYSTAT(-1); |
| 1150 | #endif |
| 1151 | |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1152 | #ifdef CONFIG_BF54x |
| 1153 | # ifdef CONFIG_PINTx_REASSIGN |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1154 | pint[0]->assign = CONFIG_PINT0_ASSIGN; |
| 1155 | pint[1]->assign = CONFIG_PINT1_ASSIGN; |
| 1156 | pint[2]->assign = CONFIG_PINT2_ASSIGN; |
| 1157 | pint[3]->assign = CONFIG_PINT3_ASSIGN; |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1158 | # endif |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1159 | /* Whenever PINTx_ASSIGN is altered init_pint_lut() must be executed! */ |
| 1160 | init_pint_lut(); |
| 1161 | #endif |
| 1162 | |
| 1163 | for (irq = 0; irq <= SYS_IRQS; irq++) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1164 | if (irq <= IRQ_CORETMR) |
| 1165 | set_irq_chip(irq, &bfin_core_irqchip); |
| 1166 | else |
| 1167 | set_irq_chip(irq, &bfin_internal_irqchip); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1168 | |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1169 | switch (irq) { |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 1170 | #if defined(CONFIG_BF53x) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1171 | case IRQ_PROG_INTA: |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1172 | # if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1173 | case IRQ_MAC_RX: |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1174 | # endif |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 1175 | #elif defined(CONFIG_BF54x) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1176 | case IRQ_PINT0: |
| 1177 | case IRQ_PINT1: |
| 1178 | case IRQ_PINT2: |
| 1179 | case IRQ_PINT3: |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 1180 | #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1181 | case IRQ_PORTF_INTA: |
| 1182 | case IRQ_PORTG_INTA: |
| 1183 | case IRQ_PORTH_INTA: |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 1184 | #elif defined(CONFIG_BF561) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1185 | case IRQ_PROG0_INTA: |
| 1186 | case IRQ_PROG1_INTA: |
| 1187 | case IRQ_PROG2_INTA: |
Michael Hennerich | dc26aec | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1188 | #elif defined(CONFIG_BF538) || defined(CONFIG_BF539) |
| 1189 | case IRQ_PORTF_INTA: |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 1190 | #endif |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1191 | set_irq_chained_handler(irq, |
| 1192 | bfin_demux_gpio_irq); |
| 1193 | break; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1194 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1195 | case IRQ_GENERIC_ERROR: |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1196 | set_irq_chained_handler(irq, bfin_demux_error_irq); |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1197 | break; |
| 1198 | #endif |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 1199 | #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) |
| 1200 | case IRQ_MAC_ERROR: |
| 1201 | set_irq_chained_handler(irq, bfin_demux_mac_status_irq); |
| 1202 | break; |
| 1203 | #endif |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1204 | #ifdef CONFIG_SMP |
| 1205 | case IRQ_SUPPLE_0: |
| 1206 | case IRQ_SUPPLE_1: |
| 1207 | set_irq_handler(irq, handle_percpu_irq); |
| 1208 | break; |
| 1209 | #endif |
Graf Yang | 17941314 | 2009-08-18 04:29:33 +0000 | [diff] [blame] | 1210 | |
Yi Li | cb19171 | 2009-12-30 07:12:50 +0000 | [diff] [blame] | 1211 | #ifdef CONFIG_TICKSOURCE_CORETMR |
| 1212 | case IRQ_CORETMR: |
| 1213 | # ifdef CONFIG_SMP |
| 1214 | set_irq_handler(irq, handle_percpu_irq); |
| 1215 | break; |
| 1216 | # else |
| 1217 | set_irq_handler(irq, handle_simple_irq); |
| 1218 | break; |
| 1219 | # endif |
| 1220 | #endif |
| 1221 | |
| 1222 | #ifdef CONFIG_TICKSOURCE_GPTMR0 |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1223 | case IRQ_TIMER0: |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1224 | set_irq_handler(irq, handle_simple_irq); |
| 1225 | break; |
Graf Yang | 17941314 | 2009-08-18 04:29:33 +0000 | [diff] [blame] | 1226 | #endif |
Yi Li | cb19171 | 2009-12-30 07:12:50 +0000 | [diff] [blame] | 1227 | |
| 1228 | #ifdef CONFIG_IPIPE |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1229 | default: |
| 1230 | set_irq_handler(irq, handle_level_irq); |
| 1231 | break; |
| 1232 | #else /* !CONFIG_IPIPE */ |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1233 | default: |
| 1234 | set_irq_handler(irq, handle_simple_irq); |
| 1235 | break; |
Graf Yang | 17941314 | 2009-08-18 04:29:33 +0000 | [diff] [blame] | 1236 | #endif /* !CONFIG_IPIPE */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1237 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1238 | } |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1239 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1240 | #ifdef BF537_GENERIC_ERROR_INT_DEMUX |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1241 | for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++) |
| 1242 | set_irq_chip_and_handler(irq, &bfin_generic_error_irqchip, |
| 1243 | handle_level_irq); |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 1244 | #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) |
| 1245 | set_irq_chained_handler(IRQ_MAC_ERROR, bfin_demux_mac_status_irq); |
| 1246 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1247 | #endif |
| 1248 | |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 1249 | #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) |
| 1250 | for (irq = IRQ_MAC_PHYINT; irq <= IRQ_MAC_STMDONE; irq++) |
| 1251 | set_irq_chip_and_handler(irq, &bfin_mac_status_irqchip, |
| 1252 | handle_level_irq); |
| 1253 | #endif |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1254 | /* if configured as edge, then will be changed to do_edge_IRQ */ |
Michael Hennerich | aec59c9 | 2010-02-19 15:09:10 +0000 | [diff] [blame] | 1255 | for (irq = GPIO_IRQ_BASE; |
| 1256 | irq < (GPIO_IRQ_BASE + MAX_BLACKFIN_GPIOS); irq++) |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1257 | set_irq_chip_and_handler(irq, &bfin_gpio_irqchip, |
| 1258 | handle_level_irq); |
Michael Hennerich | 2c4f829 | 2008-02-09 04:11:14 +0800 | [diff] [blame] | 1259 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1260 | bfin_write_IMASK(0); |
| 1261 | CSYNC(); |
| 1262 | ilat = bfin_read_ILAT(); |
| 1263 | CSYNC(); |
| 1264 | bfin_write_ILAT(ilat); |
| 1265 | CSYNC(); |
| 1266 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1267 | printk(KERN_INFO "Configuring Blackfin Priority Driven Interrupts\n"); |
Mike Frysinger | 4005978 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1268 | /* IMASK=xxx is equivalent to STI xx or bfin_irq_flags=xx, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1269 | * local_irq_enable() |
| 1270 | */ |
| 1271 | program_IAR(); |
| 1272 | /* Therefore it's better to setup IARs before interrupts enabled */ |
| 1273 | search_IAR(); |
| 1274 | |
| 1275 | /* Enable interrupts IVG7-15 */ |
Mike Frysinger | 4005978 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1276 | bfin_irq_flags |= IMASK_IVG15 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1277 | IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1278 | IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1279 | |
Michael Hennerich | 349ebbcc | 2009-04-15 08:48:08 +0000 | [diff] [blame] | 1280 | /* This implicitly covers ANOMALY_05000171 |
| 1281 | * Boot-ROM code modifies SICA_IWRx wakeup registers |
| 1282 | */ |
Mike Frysinger | be1d854 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1283 | #ifdef SIC_IWR0 |
Michael Hennerich | 56f5f59 | 2008-08-06 17:55:32 +0800 | [diff] [blame] | 1284 | bfin_write_SIC_IWR0(IWR_DISABLE_ALL); |
Mike Frysinger | be1d854 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1285 | # ifdef SIC_IWR1 |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 1286 | /* BF52x/BF51x system reset does not properly reset SIC_IWR1 which |
Michael Hennerich | 55546ac | 2008-08-13 17:41:13 +0800 | [diff] [blame] | 1287 | * will screw up the bootrom as it relies on MDMA0/1 waking it |
| 1288 | * up from IDLE instructions. See this report for more info: |
| 1289 | * http://blackfin.uclinux.org/gf/tracker/4323 |
| 1290 | */ |
Mike Frysinger | b7e1129 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1291 | if (ANOMALY_05000435) |
| 1292 | bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11)); |
| 1293 | else |
| 1294 | bfin_write_SIC_IWR1(IWR_DISABLE_ALL); |
Mike Frysinger | be1d854 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1295 | # endif |
| 1296 | # ifdef SIC_IWR2 |
Michael Hennerich | 56f5f59 | 2008-08-06 17:55:32 +0800 | [diff] [blame] | 1297 | bfin_write_SIC_IWR2(IWR_DISABLE_ALL); |
Michael Hennerich | fe9ec9b | 2008-02-25 12:04:57 +0800 | [diff] [blame] | 1298 | # endif |
| 1299 | #else |
Michael Hennerich | 56f5f59 | 2008-08-06 17:55:32 +0800 | [diff] [blame] | 1300 | bfin_write_SIC_IWR(IWR_DISABLE_ALL); |
Michael Hennerich | fe9ec9b | 2008-02-25 12:04:57 +0800 | [diff] [blame] | 1301 | #endif |
| 1302 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1303 | return 0; |
| 1304 | } |
| 1305 | |
| 1306 | #ifdef CONFIG_DO_IRQ_L1 |
Mike Frysinger | a055b2b | 2007-11-15 21:12:32 +0800 | [diff] [blame] | 1307 | __attribute__((l1_text)) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1308 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1309 | void do_irq(int vec, struct pt_regs *fp) |
| 1310 | { |
| 1311 | if (vec == EVT_IVTMR_P) { |
| 1312 | vec = IRQ_CORETMR; |
| 1313 | } else { |
| 1314 | struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst; |
| 1315 | struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop; |
Mike Frysinger | 39c9996 | 2010-10-19 18:44:23 +0000 | [diff] [blame] | 1316 | #if defined(SIC_ISR0) |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1317 | unsigned long sic_status[3]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1318 | |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1319 | if (smp_processor_id()) { |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1320 | # ifdef SICB_ISR0 |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1321 | /* This will be optimized out in UP mode. */ |
| 1322 | sic_status[0] = bfin_read_SICB_ISR0() & bfin_read_SICB_IMASK0(); |
| 1323 | sic_status[1] = bfin_read_SICB_ISR1() & bfin_read_SICB_IMASK1(); |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1324 | # endif |
Graf Yang | 6b3087c | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1325 | } else { |
| 1326 | sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0(); |
| 1327 | sic_status[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1(); |
| 1328 | } |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1329 | # ifdef SIC_ISR2 |
Michael Hennerich | 4fb4524 | 2007-10-21 16:53:53 +0800 | [diff] [blame] | 1330 | sic_status[2] = bfin_read_SIC_ISR2() & bfin_read_SIC_IMASK2(); |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1331 | # endif |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 1332 | for (;; ivg++) { |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1333 | if (ivg >= ivg_stop) { |
| 1334 | atomic_inc(&num_spurious); |
| 1335 | return; |
| 1336 | } |
Michael Hennerich | 34e0fc8 | 2007-07-12 16:17:18 +0800 | [diff] [blame] | 1337 | if (sic_status[(ivg->irqno - IVG7) / 32] & ivg->isrflag) |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1338 | break; |
| 1339 | } |
| 1340 | #else |
| 1341 | unsigned long sic_status; |
Michael Hennerich | 464abc5 | 2008-02-25 13:50:20 +0800 | [diff] [blame] | 1342 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1343 | sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR(); |
| 1344 | |
| 1345 | for (;; ivg++) { |
| 1346 | if (ivg >= ivg_stop) { |
| 1347 | atomic_inc(&num_spurious); |
| 1348 | return; |
| 1349 | } else if (sic_status & ivg->isrflag) |
| 1350 | break; |
| 1351 | } |
Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1352 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1353 | vec = ivg->irqno; |
| 1354 | } |
| 1355 | asm_do_IRQ(vec, fp); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1356 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1357 | |
| 1358 | #ifdef CONFIG_IPIPE |
| 1359 | |
| 1360 | int __ipipe_get_irq_priority(unsigned irq) |
| 1361 | { |
| 1362 | int ient, prio; |
| 1363 | |
| 1364 | if (irq <= IRQ_CORETMR) |
| 1365 | return irq; |
| 1366 | |
| 1367 | for (ient = 0; ient < NR_PERI_INTS; ient++) { |
| 1368 | struct ivgx *ivg = ivg_table + ient; |
| 1369 | if (ivg->irqno == irq) { |
| 1370 | for (prio = 0; prio <= IVG13-IVG7; prio++) { |
| 1371 | if (ivg7_13[prio].ifirst <= ivg && |
| 1372 | ivg7_13[prio].istop > ivg) |
| 1373 | return IVG7 + prio; |
| 1374 | } |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | return IVG15; |
| 1379 | } |
| 1380 | |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1381 | /* Hw interrupts are disabled on entry (check SAVE_CONTEXT). */ |
| 1382 | #ifdef CONFIG_DO_IRQ_L1 |
| 1383 | __attribute__((l1_text)) |
| 1384 | #endif |
| 1385 | asmlinkage int __ipipe_grab_irq(int vec, struct pt_regs *regs) |
| 1386 | { |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1387 | struct ipipe_percpu_domain_data *p = ipipe_root_cpudom_ptr(); |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1388 | struct ipipe_domain *this_domain = __ipipe_current_domain; |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1389 | struct ivgx *ivg_stop = ivg7_13[vec-IVG7].istop; |
| 1390 | struct ivgx *ivg = ivg7_13[vec-IVG7].ifirst; |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1391 | int irq, s; |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1392 | |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1393 | if (likely(vec == EVT_IVTMR_P)) |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1394 | irq = IRQ_CORETMR; |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1395 | else { |
Mike Frysinger | 39c9996 | 2010-10-19 18:44:23 +0000 | [diff] [blame] | 1396 | #if defined(SIC_ISR0) |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1397 | unsigned long sic_status[3]; |
| 1398 | |
| 1399 | sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0(); |
| 1400 | sic_status[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1(); |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1401 | # ifdef SIC_ISR2 |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1402 | sic_status[2] = bfin_read_SIC_ISR2() & bfin_read_SIC_IMASK2(); |
Mike Frysinger | 780172b | 2009-06-01 19:43:02 -0400 | [diff] [blame] | 1403 | # endif |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1404 | for (;; ivg++) { |
| 1405 | if (ivg >= ivg_stop) { |
| 1406 | atomic_inc(&num_spurious); |
| 1407 | return 0; |
| 1408 | } |
| 1409 | if (sic_status[(ivg->irqno - IVG7) / 32] & ivg->isrflag) |
| 1410 | break; |
| 1411 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1412 | #else |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1413 | unsigned long sic_status; |
| 1414 | |
| 1415 | sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR(); |
| 1416 | |
| 1417 | for (;; ivg++) { |
| 1418 | if (ivg >= ivg_stop) { |
| 1419 | atomic_inc(&num_spurious); |
| 1420 | return 0; |
| 1421 | } else if (sic_status & ivg->isrflag) |
| 1422 | break; |
| 1423 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1424 | #endif |
Graf Yang | 1fa9be7 | 2009-05-15 11:01:59 +0000 | [diff] [blame] | 1425 | irq = ivg->irqno; |
| 1426 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1427 | |
| 1428 | if (irq == IRQ_SYSTMR) { |
Philippe Gerum | a40494a | 2009-06-16 05:25:42 +0200 | [diff] [blame] | 1429 | #if !defined(CONFIG_GENERIC_CLOCKEVENTS) || defined(CONFIG_TICKSOURCE_GPTMR0) |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1430 | bfin_write_TIMER_STATUS(1); /* Latch TIMIL0 */ |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1431 | #endif |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1432 | /* This is basically what we need from the register frame. */ |
| 1433 | __raw_get_cpu_var(__ipipe_tick_regs).ipend = regs->ipend; |
| 1434 | __raw_get_cpu_var(__ipipe_tick_regs).pc = regs->pc; |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1435 | if (this_domain != ipipe_root_domain) |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1436 | __raw_get_cpu_var(__ipipe_tick_regs).ipend &= ~0x10; |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1437 | else |
| 1438 | __raw_get_cpu_var(__ipipe_tick_regs).ipend |= 0x10; |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1439 | } |
| 1440 | |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1441 | if (this_domain == ipipe_root_domain) { |
| 1442 | s = __test_and_set_bit(IPIPE_SYNCDEFER_FLAG, &p->status); |
| 1443 | barrier(); |
| 1444 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1445 | |
| 1446 | ipipe_trace_irq_entry(irq); |
| 1447 | __ipipe_handle_irq(irq, regs); |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1448 | ipipe_trace_irq_exit(irq); |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1449 | |
Philippe Gerum | 9bd50df | 2009-03-04 16:52:38 +0800 | [diff] [blame] | 1450 | if (this_domain == ipipe_root_domain) { |
| 1451 | set_thread_flag(TIF_IRQ_SYNC); |
| 1452 | if (!s) { |
| 1453 | __clear_bit(IPIPE_SYNCDEFER_FLAG, &p->status); |
| 1454 | return !test_bit(IPIPE_STALL_FLAG, &p->status); |
| 1455 | } |
| 1456 | } |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1457 | |
Graf Yang | 1fa9be7 | 2009-05-15 11:01:59 +0000 | [diff] [blame] | 1458 | return 0; |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | #endif /* CONFIG_IPIPE */ |