Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 1 | /* |
| 2 | * BRIEF MODULE DESCRIPTION |
| 3 | * Au1xxx irq map table |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the |
| 7 | * Free Software Foundation; either version 2 of the License, or (at your |
| 8 | * option) any later version. |
| 9 | * |
| 10 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 11 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 13 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 14 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 15 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 16 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 17 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 18 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 19 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | */ |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 25 | |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 29 | #include <asm/mach-au1x00/au1000.h> |
| 30 | |
| 31 | #ifdef CONFIG_MIPS_PB1200 |
| 32 | #include <asm/mach-pb1x00/pb1200.h> |
| 33 | #endif |
| 34 | |
| 35 | #ifdef CONFIG_MIPS_DB1200 |
| 36 | #include <asm/mach-db1x00/db1200.h> |
| 37 | #define PB1200_INT_BEGIN DB1200_INT_BEGIN |
| 38 | #define PB1200_INT_END DB1200_INT_END |
| 39 | #endif |
| 40 | |
Ralf Baechle | 0e6799e | 2007-10-15 01:07:39 +0100 | [diff] [blame] | 41 | struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 42 | /* This is external interrupt cascade */ |
| 43 | { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
Herbert Valerio Riedel | a643d2b | 2006-05-07 15:48:25 +0200 | [diff] [blame] | 46 | int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 47 | |
| 48 | /* |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 49 | * Support for External interrupts on the Pb1200 Development platform. |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 50 | */ |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 51 | static volatile int pb1200_cascade_en; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 52 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 53 | irqreturn_t pb1200_cascade_handler(int irq, void *dev_id) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 54 | { |
| 55 | unsigned short bisr = bcsr->int_status; |
| 56 | int extirq_nr = 0; |
| 57 | |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 58 | /* Clear all the edge interrupts. This has no effect on level. */ |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 59 | bcsr->int_status = bisr; |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 60 | for ( ; bisr; bisr &= bisr - 1) { |
Sergei Shtylyov | 4b36673 | 2007-12-05 19:08:24 +0300 | [diff] [blame] | 61 | extirq_nr = PB1200_INT_BEGIN + __ffs(bisr); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 62 | /* Ack and dispatch IRQ */ |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 63 | do_IRQ(extirq_nr); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 64 | } |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 65 | |
Pete Popov | 26a940e | 2005-09-15 08:03:12 +0000 | [diff] [blame] | 66 | return IRQ_RETVAL(1); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | inline void pb1200_enable_irq(unsigned int irq_nr) |
| 70 | { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 71 | bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN); |
| 72 | bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | inline void pb1200_disable_irq(unsigned int irq_nr) |
| 76 | { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 77 | bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN); |
| 78 | bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 81 | static unsigned int pb1200_setup_cascade(void) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 82 | { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 83 | return request_irq(AU1000_GPIO_7, &pb1200_cascade_handler, |
| 84 | 0, "Pb1200 Cascade", &pb1200_cascade_handler); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 87 | static unsigned int pb1200_startup_irq(unsigned int irq) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 88 | { |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 89 | if (++pb1200_cascade_en == 1) { |
| 90 | int res; |
| 91 | |
| 92 | res = pb1200_setup_cascade(); |
| 93 | if (res) |
| 94 | return res; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 95 | } |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 96 | |
| 97 | pb1200_enable_irq(irq); |
| 98 | |
| 99 | return 0; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 102 | static void pb1200_shutdown_irq(unsigned int irq) |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 103 | { |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 104 | pb1200_disable_irq(irq); |
| 105 | if (--pb1200_cascade_en == 0) |
| 106 | free_irq(AU1000_GPIO_7, &pb1200_cascade_handler); |
| 107 | } |
| 108 | |
| 109 | static struct irq_chip external_irq_type = { |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 110 | #ifdef CONFIG_MIPS_PB1200 |
Atsushi Nemoto | 19487f1 | 2007-02-04 00:57:25 +0900 | [diff] [blame] | 111 | .name = "Pb1200 Ext", |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 112 | #endif |
| 113 | #ifdef CONFIG_MIPS_DB1200 |
Atsushi Nemoto | 19487f1 | 2007-02-04 00:57:25 +0900 | [diff] [blame] | 114 | .name = "Db1200 Ext", |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 115 | #endif |
Atsushi Nemoto | 19487f1 | 2007-02-04 00:57:25 +0900 | [diff] [blame] | 116 | .startup = pb1200_startup_irq, |
| 117 | .shutdown = pb1200_shutdown_irq, |
| 118 | .ack = pb1200_disable_irq, |
| 119 | .mask = pb1200_disable_irq, |
| 120 | .mask_ack = pb1200_disable_irq, |
| 121 | .unmask = pb1200_enable_irq, |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | void _board_init_irq(void) |
| 125 | { |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 126 | unsigned int irq; |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 127 | |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 128 | #ifdef CONFIG_MIPS_PB1200 |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 129 | /* We have a problem with CPLD rev 3. */ |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 130 | if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) { |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 131 | printk(KERN_ERR "WARNING!!!\n"); |
| 132 | printk(KERN_ERR "WARNING!!!\n"); |
| 133 | printk(KERN_ERR "WARNING!!!\n"); |
| 134 | printk(KERN_ERR "WARNING!!!\n"); |
| 135 | printk(KERN_ERR "WARNING!!!\n"); |
| 136 | printk(KERN_ERR "WARNING!!!\n"); |
| 137 | printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n"); |
| 138 | printk(KERN_ERR "updated to latest revision. This software will\n"); |
| 139 | printk(KERN_ERR "not work on anything less than CPLD rev 4.\n"); |
| 140 | printk(KERN_ERR "WARNING!!!\n"); |
| 141 | printk(KERN_ERR "WARNING!!!\n"); |
| 142 | printk(KERN_ERR "WARNING!!!\n"); |
| 143 | printk(KERN_ERR "WARNING!!!\n"); |
| 144 | printk(KERN_ERR "WARNING!!!\n"); |
| 145 | printk(KERN_ERR "WARNING!!!\n"); |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 146 | panic("Game over. Your score is 0."); |
| 147 | } |
| 148 | #endif |
| 149 | |
| 150 | for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++) { |
| 151 | set_irq_chip_and_handler(irq, &external_irq_type, |
Atsushi Nemoto | 19487f1 | 2007-02-04 00:57:25 +0900 | [diff] [blame] | 152 | handle_level_irq); |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 153 | pb1200_disable_irq(irq); |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 156 | /* |
| 157 | * GPIO_7 can not be hooked here, so it is hooked upon first |
Sergei Shtylyov | c3d1d5c | 2008-04-30 23:29:04 +0400 | [diff] [blame] | 158 | * request of any source attached to the cascade. |
Ralf Baechle | db0c19e | 2007-11-01 12:59:18 +0000 | [diff] [blame] | 159 | */ |
Pete Popov | e3ad1c2 | 2005-03-01 06:33:16 +0000 | [diff] [blame] | 160 | } |