Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Telechips, Inc. |
| 3 | * Copyright (C) 2009-2010 Hans J. Koch <hjk@linutronix.de> |
| 4 | * |
| 5 | * Licensed under the terms of the GNU GPL version 2. |
| 6 | */ |
| 7 | |
| 8 | #include <linux/init.h> |
| 9 | #include <linux/interrupt.h> |
| 10 | #include <linux/io.h> |
| 11 | |
| 12 | #include <asm/irq.h> |
| 13 | #include <asm/mach/irq.h> |
| 14 | |
| 15 | #include <mach/tcc8k-regs.h> |
| 16 | #include <mach/irqs.h> |
| 17 | |
| 18 | #include "common.h" |
| 19 | |
| 20 | /* Disable IRQ */ |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 21 | static void tcc8000_mask_ack_irq0(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 22 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 23 | PIC0_IEN &= ~(1 << d->irq); |
| 24 | PIC0_CREQ |= (1 << d->irq); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 25 | } |
| 26 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 27 | static void tcc8000_mask_ack_irq1(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 28 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 29 | PIC1_IEN &= ~(1 << (d->irq - 32)); |
| 30 | PIC1_CREQ |= (1 << (d->irq - 32)); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 31 | } |
| 32 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 33 | static void tcc8000_mask_irq0(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 34 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 35 | PIC0_IEN &= ~(1 << d->irq); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 36 | } |
| 37 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 38 | static void tcc8000_mask_irq1(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 39 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 40 | PIC1_IEN &= ~(1 << (d->irq - 32)); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 41 | } |
| 42 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 43 | static void tcc8000_ack_irq0(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 44 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 45 | PIC0_CREQ |= (1 << d->irq); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 48 | static void tcc8000_ack_irq1(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 49 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 50 | PIC1_CREQ |= (1 << (d->irq - 32)); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /* Enable IRQ */ |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 54 | static void tcc8000_unmask_irq0(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 55 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 56 | PIC0_IEN |= (1 << d->irq); |
| 57 | PIC0_INTOEN |= (1 << d->irq); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 60 | static void tcc8000_unmask_irq1(struct irq_data *d) |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 61 | { |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 62 | PIC1_IEN |= (1 << (d->irq - 32)); |
| 63 | PIC1_INTOEN |= (1 << (d->irq - 32)); |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | static struct irq_chip tcc8000_irq_chip0 = { |
| 67 | .name = "tcc_irq0", |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 68 | .irq_mask = tcc8000_mask_irq0, |
| 69 | .irq_ack = tcc8000_ack_irq0, |
| 70 | .irq_mask_ack = tcc8000_mask_ack_irq0, |
| 71 | .irq_unmask = tcc8000_unmask_irq0, |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | static struct irq_chip tcc8000_irq_chip1 = { |
| 75 | .name = "tcc_irq1", |
Lennert Buytenhek | 76fbec8 | 2010-11-29 11:14:16 +0100 | [diff] [blame] | 76 | .irq_mask = tcc8000_mask_irq1, |
| 77 | .irq_ack = tcc8000_ack_irq1, |
| 78 | .irq_mask_ack = tcc8000_mask_ack_irq1, |
| 79 | .irq_unmask = tcc8000_unmask_irq1, |
Hans J. Koch | e9268ef | 2010-09-17 18:16:29 +0200 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | void __init tcc8k_init_irq(void) |
| 83 | { |
| 84 | int irqno; |
| 85 | |
| 86 | /* Mask and clear all interrupts */ |
| 87 | PIC0_IEN = 0x00000000; |
| 88 | PIC0_CREQ = 0xffffffff; |
| 89 | PIC1_IEN = 0x00000000; |
| 90 | PIC1_CREQ = 0xffffffff; |
| 91 | |
| 92 | PIC0_MEN0 = 0x00000003; |
| 93 | PIC1_MEN1 = 0x00000003; |
| 94 | PIC1_MEN = 0x00000003; |
| 95 | |
| 96 | /* let all IRQs be level triggered */ |
| 97 | PIC0_TMODE = 0xffffffff; |
| 98 | PIC1_TMODE = 0xffffffff; |
| 99 | /* all IRQs are IRQs (not FIQs) */ |
| 100 | PIC0_IRQSEL = 0xffffffff; |
| 101 | PIC1_IRQSEL = 0xffffffff; |
| 102 | |
| 103 | for (irqno = 0; irqno < NR_IRQS; irqno++) { |
| 104 | if (irqno < 32) |
| 105 | set_irq_chip(irqno, &tcc8000_irq_chip0); |
| 106 | else |
| 107 | set_irq_chip(irqno, &tcc8000_irq_chip1); |
| 108 | set_irq_handler(irqno, handle_level_irq); |
| 109 | set_irq_flags(irqno, IRQF_VALID); |
| 110 | } |
| 111 | } |