Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* irq-mb93493.c: MB93493 companion chip interrupt handler |
| 2 | * |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 3 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/ptrace.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/signal.h> |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/ioport.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/irq.h> |
| 20 | |
| 21 | #include <asm/io.h> |
| 22 | #include <asm/system.h> |
| 23 | #include <asm/bitops.h> |
| 24 | #include <asm/delay.h> |
| 25 | #include <asm/irq.h> |
| 26 | #include <asm/irc-regs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <asm/mb93493-irqs.h> |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 28 | #include <asm/mb93493-regs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 30 | #define IRQ_ROUTE_ONE(X) (X##_ROUTE << (X - IRQ_BASE_MB93493)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 32 | #define IRQ_ROUTING \ |
| 33 | (IRQ_ROUTE_ONE(IRQ_MB93493_VDC) | \ |
| 34 | IRQ_ROUTE_ONE(IRQ_MB93493_VCC) | \ |
| 35 | IRQ_ROUTE_ONE(IRQ_MB93493_AUDIO_OUT) | \ |
| 36 | IRQ_ROUTE_ONE(IRQ_MB93493_I2C_0) | \ |
| 37 | IRQ_ROUTE_ONE(IRQ_MB93493_I2C_1) | \ |
| 38 | IRQ_ROUTE_ONE(IRQ_MB93493_USB) | \ |
| 39 | IRQ_ROUTE_ONE(IRQ_MB93493_LOCAL_BUS) | \ |
| 40 | IRQ_ROUTE_ONE(IRQ_MB93493_PCMCIA) | \ |
| 41 | IRQ_ROUTE_ONE(IRQ_MB93493_GPIO) | \ |
| 42 | IRQ_ROUTE_ONE(IRQ_MB93493_AUDIO_IN)) |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | /* |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 45 | * daughter board PIC operations |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | */ |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 47 | static void frv_mb93493_enable(unsigned int irq) |
| 48 | { |
| 49 | uint32_t iqsr; |
| 50 | volatile void *piqsr; |
| 51 | |
| 52 | if (IRQ_ROUTING & (1 << (irq - IRQ_BASE_MB93493))) |
| 53 | piqsr = __addr_MB93493_IQSR(1); |
| 54 | else |
| 55 | piqsr = __addr_MB93493_IQSR(0); |
| 56 | |
| 57 | iqsr = readl(piqsr); |
| 58 | iqsr |= 1 << (irq - IRQ_BASE_MB93493 + 16); |
| 59 | writel(iqsr, piqsr); |
| 60 | } |
| 61 | |
| 62 | static void frv_mb93493_disable(unsigned int irq) |
| 63 | { |
| 64 | uint32_t iqsr; |
| 65 | volatile void *piqsr; |
| 66 | |
| 67 | if (IRQ_ROUTING & (1 << (irq - IRQ_BASE_MB93493))) |
| 68 | piqsr = __addr_MB93493_IQSR(1); |
| 69 | else |
| 70 | piqsr = __addr_MB93493_IQSR(0); |
| 71 | |
| 72 | iqsr = readl(piqsr); |
| 73 | iqsr &= ~(1 << (irq - IRQ_BASE_MB93493 + 16)); |
| 74 | writel(iqsr, piqsr); |
| 75 | } |
| 76 | |
| 77 | static void frv_mb93493_ack(unsigned int irq) |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | static void frv_mb93493_end(unsigned int irq) |
| 82 | { |
| 83 | } |
| 84 | |
| 85 | static struct irq_chip frv_mb93493_pic = { |
| 86 | .name = "mb93093", |
| 87 | .enable = frv_mb93493_enable, |
| 88 | .disable = frv_mb93493_disable, |
| 89 | .ack = frv_mb93493_ack, |
| 90 | .mask = frv_mb93493_disable, |
| 91 | .unmask = frv_mb93493_enable, |
| 92 | .end = frv_mb93493_end, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 95 | /* |
| 96 | * MB93493 PIC interrupt handler |
| 97 | */ |
| 98 | static irqreturn_t mb93493_interrupt(int irq, void *_piqsr, struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | { |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 100 | volatile void *piqsr = _piqsr; |
| 101 | irqreturn_t iret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | uint32_t iqsr; |
| 103 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 104 | iqsr = readl(piqsr); |
| 105 | iqsr = iqsr & (iqsr >> 16) & 0xffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 107 | /* poll all the triggered IRQs */ |
| 108 | while (iqsr) { |
| 109 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 111 | asm("scan %1,gr0,%0" : "=r"(irq) : "r"(iqsr)); |
| 112 | irq = 31 - irq; |
| 113 | iqsr &= ~(1 << irq); |
| 114 | |
| 115 | if (__do_IRQ(IRQ_BASE_MB93493 + irq, regs)) |
| 116 | iret |= IRQ_HANDLED; |
| 117 | } |
| 118 | |
| 119 | return iret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 122 | /* |
| 123 | * define an interrupt action for each MB93493 PIC output |
| 124 | * - use dev_id to indicate the MB93493 PIC input to output mappings |
| 125 | */ |
| 126 | static struct irqaction mb93493_irq[2] = { |
| 127 | [0] = { |
| 128 | .handler = mb93493_interrupt, |
| 129 | .flags = IRQF_DISABLED | IRQF_SHARED, |
| 130 | .mask = CPU_MASK_NONE, |
| 131 | .name = "mb93493.0", |
| 132 | .dev_id = (void *) __addr_MB93493_IQSR(0), |
| 133 | }, |
| 134 | [1] = { |
| 135 | .handler = mb93493_interrupt, |
| 136 | .flags = IRQF_DISABLED | IRQF_SHARED, |
| 137 | .mask = CPU_MASK_NONE, |
| 138 | .name = "mb93493.1", |
| 139 | .dev_id = (void *) __addr_MB93493_IQSR(1), |
| 140 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 143 | /* |
| 144 | * initialise the motherboard MB93493's PIC |
| 145 | */ |
| 146 | void __init mb93493_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 148 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 150 | for (irq = IRQ_BASE_MB93493 + 0; irq <= IRQ_BASE_MB93493 + 10; irq++) |
| 151 | set_irq_chip_and_handler(irq, &frv_mb93493_pic, handle_edge_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame^] | 153 | /* the MB93493 drives external IRQ inputs on the CPU PIC */ |
| 154 | setup_irq(IRQ_CPU_MB93493_0, &mb93493_irq[0]); |
| 155 | setup_irq(IRQ_CPU_MB93493_1, &mb93493_irq[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } |