Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 2 | * arch/arm/mach-iop33x/irq.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Generic IOP331 IRQ handling functionality |
| 5 | * |
| 6 | * Author: Dave Jiang <dave.jiang@intel.com> |
| 7 | * Copyright (C) 2003 Intel Corp. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/init.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/list.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/mach/irq.h> |
| 18 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 19 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/mach-types.h> |
| 21 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 22 | static u32 iop33x_mask0; |
| 23 | static u32 iop33x_mask1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 25 | static void intctl0_write(u32 val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 27 | asm volatile("mcr p6, 0, %0, c0, c0, 0" : : "r" (val)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 30 | static void intctl1_write(u32 val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 32 | asm volatile("mcr p6, 0, %0, c1, c0, 0" : : "r" (val)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 35 | static void intstr0_write(u32 val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 37 | asm volatile("mcr p6, 0, %0, c2, c0, 0" : : "r" (val)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 40 | static void intstr1_write(u32 val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 42 | asm volatile("mcr p6, 0, %0, c3, c0, 0" : : "r" (val)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 45 | static void intbase_write(u32 val) |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 46 | { |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 47 | asm volatile("mcr p6, 0, %0, c12, c0, 0" : : "r" (val)); |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Dan Williams | d73d801 | 2007-05-15 01:03:36 +0100 | [diff] [blame] | 50 | static void intsize_write(u32 val) |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 51 | { |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 52 | asm volatile("mcr p6, 0, %0, c13, c0, 0" : : "r" (val)); |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 53 | } |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | static void |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 56 | iop33x_irq_mask1 (struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 58 | iop33x_mask0 &= ~(1 << d->irq); |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 59 | intctl0_write(iop33x_mask0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static void |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 63 | iop33x_irq_mask2 (struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 65 | iop33x_mask1 &= ~(1 << (d->irq - 32)); |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 66 | intctl1_write(iop33x_mask1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static void |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 70 | iop33x_irq_unmask1(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 72 | iop33x_mask0 |= 1 << d->irq; |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 73 | intctl0_write(iop33x_mask0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 77 | iop33x_irq_unmask2(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 79 | iop33x_mask1 |= (1 << (d->irq - 32)); |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 80 | intctl1_write(iop33x_mask1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 83 | struct irq_chip iop33x_irqchip1 = { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 84 | .name = "IOP33x-1", |
| 85 | .irq_ack = iop33x_irq_mask1, |
| 86 | .irq_mask = iop33x_irq_mask1, |
| 87 | .irq_unmask = iop33x_irq_unmask1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 90 | struct irq_chip iop33x_irqchip2 = { |
Lennert Buytenhek | a0ad2a7 | 2010-11-29 10:32:37 +0100 | [diff] [blame] | 91 | .name = "IOP33x-2", |
| 92 | .irq_ack = iop33x_irq_mask2, |
| 93 | .irq_mask = iop33x_irq_mask2, |
| 94 | .irq_unmask = iop33x_irq_unmask2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 97 | void __init iop33x_init_irq(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 99 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Dan Williams | 588ef76 | 2007-02-13 17:12:04 +0100 | [diff] [blame] | 101 | iop_init_cp6_handler(); |
| 102 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 103 | intctl0_write(0); |
| 104 | intctl1_write(0); |
| 105 | intstr0_write(0); |
| 106 | intstr1_write(0); |
Lennert Buytenhek | 7412b10 | 2006-09-18 23:24:10 +0100 | [diff] [blame] | 107 | intbase_write(0); |
| 108 | intsize_write(1); |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 109 | if (machine_is_iq80331()) |
Lennert Buytenhek | 7e9740b | 2006-09-18 23:17:36 +0100 | [diff] [blame] | 110 | *IOP3XX_PCIIRSR = 0x0f; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Lennert Buytenhek | c852ac8 | 2006-09-18 23:26:25 +0100 | [diff] [blame] | 112 | for (i = 0; i < NR_IRQS; i++) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 113 | irq_set_chip_and_handler(i, |
| 114 | (i < 32) ? &iop33x_irqchip1 : &iop33x_irqchip2, |
| 115 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | set_irq_flags(i, IRQF_VALID | IRQF_PROBE); |
| 117 | } |
| 118 | } |