Blame view

arch/arm/mach-bcmring/irq.c 3.56 KB
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  /*
   *
   *  Copyright (C) 1999 ARM Limited
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
  #include <linux/init.h>
  #include <linux/stddef.h>
  #include <linux/list.h>
  #include <linux/timer.h>
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
23
24
25
26
27
28
29
30
  #include <linux/io.h>
  
  #include <mach/hardware.h>
  #include <asm/irq.h>
  
  #include <asm/mach/irq.h>
  #include <mach/csp/intcHw_reg.h>
  #include <mach/csp/mm_io.h>
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
31
  static void bcmring_mask_irq0(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
32
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
33
  	writel(1 << (d->irq - IRQ_INTC0_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
34
35
  	       MM_IO_BASE_INTC0 + INTCHW_INTENCLEAR);
  }
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
36
  static void bcmring_unmask_irq0(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
37
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
38
  	writel(1 << (d->irq - IRQ_INTC0_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
39
40
  	       MM_IO_BASE_INTC0 + INTCHW_INTENABLE);
  }
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
41
  static void bcmring_mask_irq1(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
42
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
43
  	writel(1 << (d->irq - IRQ_INTC1_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
44
45
  	       MM_IO_BASE_INTC1 + INTCHW_INTENCLEAR);
  }
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
46
  static void bcmring_unmask_irq1(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
47
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
48
  	writel(1 << (d->irq - IRQ_INTC1_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
49
50
  	       MM_IO_BASE_INTC1 + INTCHW_INTENABLE);
  }
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
51
  static void bcmring_mask_irq2(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
52
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
53
  	writel(1 << (d->irq - IRQ_SINTC_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
54
55
  	       MM_IO_BASE_SINTC + INTCHW_INTENCLEAR);
  }
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
56
  static void bcmring_unmask_irq2(struct irq_data *d)
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
57
  {
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
58
  	writel(1 << (d->irq - IRQ_SINTC_START),
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
59
60
61
62
  	       MM_IO_BASE_SINTC + INTCHW_INTENABLE);
  }
  
  static struct irq_chip bcmring_irq0_chip = {
d1ea13c6e   Thomas Gleixner   genirq: Cleanup i...
63
  	.name = "ARM-INTC0",
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
64
65
66
  	.irq_ack = bcmring_mask_irq0,
  	.irq_mask = bcmring_mask_irq0,	/* mask a specific interrupt, blocking its delivery. */
  	.irq_unmask = bcmring_unmask_irq0,	/* unmaks an interrupt */
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
67
68
69
  };
  
  static struct irq_chip bcmring_irq1_chip = {
d1ea13c6e   Thomas Gleixner   genirq: Cleanup i...
70
  	.name = "ARM-INTC1",
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
71
72
73
  	.irq_ack = bcmring_mask_irq1,
  	.irq_mask = bcmring_mask_irq1,
  	.irq_unmask = bcmring_unmask_irq1,
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
74
75
76
  };
  
  static struct irq_chip bcmring_irq2_chip = {
d1ea13c6e   Thomas Gleixner   genirq: Cleanup i...
77
  	.name = "ARM-SINTC",
cf1d4d509   Lennert Buytenhek   ARM: bcmring: irq...
78
79
80
  	.irq_ack = bcmring_mask_irq2,
  	.irq_mask = bcmring_mask_irq2,
  	.irq_unmask = bcmring_unmask_irq2,
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
81
82
83
84
85
86
87
88
  };
  
  static void vic_init(void __iomem *base, struct irq_chip *chip,
  		     unsigned int irq_start, unsigned int vic_sources)
  {
  	unsigned int i;
  	for (i = 0; i < 32; i++) {
  		unsigned int irq = irq_start + i;
6845664a6   Thomas Gleixner   arm: Cleanup the ...
89
90
  		irq_set_chip(irq, chip);
  		irq_set_chip_data(irq, base);
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
91
92
  
  		if (vic_sources & (1 << i)) {
6845664a6   Thomas Gleixner   arm: Cleanup the ...
93
  			irq_set_handler(irq, handle_level_irq);
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  			set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  		}
  	}
  	writel(0, base + INTCHW_INTSELECT);
  	writel(0, base + INTCHW_INTENABLE);
  	writel(~0, base + INTCHW_INTENCLEAR);
  	writel(0, base + INTCHW_IRQSTATUS);
  	writel(~0, base + INTCHW_SOFTINTCLEAR);
  }
  
  void __init bcmring_init_irq(void)
  {
  	vic_init((void __iomem *)MM_IO_BASE_INTC0, &bcmring_irq0_chip,
  		 IRQ_INTC0_START, IRQ_INTC0_VALID_MASK);
  	vic_init((void __iomem *)MM_IO_BASE_INTC1, &bcmring_irq1_chip,
  		 IRQ_INTC1_START, IRQ_INTC1_VALID_MASK);
  	vic_init((void __iomem *)MM_IO_BASE_SINTC, &bcmring_irq2_chip,
  		 IRQ_SINTC_START, IRQ_SINTC_VALID_MASK);
  
  	/* special cases */
  	if (INTCHW_INTC1_GPIO0 & IRQ_INTC1_VALID_MASK) {
6845664a6   Thomas Gleixner   arm: Cleanup the ...
115
  		irq_set_handler(IRQ_GPIO0, handle_simple_irq);
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
116
117
  	}
  	if (INTCHW_INTC1_GPIO1 & IRQ_INTC1_VALID_MASK) {
6845664a6   Thomas Gleixner   arm: Cleanup the ...
118
  		irq_set_handler(IRQ_GPIO1, handle_simple_irq);
b7462d654   Leo Chen   ARM: 5645/1: bcmr...
119
120
  	}
  }