Blame view

arch/mips/jazz/irq.c 4.22 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
  /*
   * This file is subject to the terms and conditions of the GNU General Public
   * License.  See the file "COPYING" in the main directory of this archive
   * for more details.
   *
   * Copyright (C) 1992 Linus Torvalds
89742e537   Ralf Baechle   [MIPS] Jazz: Reti...
7
   * Copyright (C) 1994 - 2001, 2003, 07 Ralf Baechle
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
   */
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
9
  #include <linux/clockchips.h>
334955ef9   Ralf Baechle   i8253: Create lin...
10
  #include <linux/i8253.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
12
13
  #include <linux/init.h>
  #include <linux/interrupt.h>
  #include <linux/kernel.h>
631330f58   Ralf Baechle   MIPS: Build fix -...
14
  #include <linux/smp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
  #include <linux/spinlock.h>
ca4d3e674   David Howells   MIPS: Add missing...
16
  #include <linux/irq.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17

ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
18
  #include <asm/irq_cpu.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
  #include <asm/i8259.h>
  #include <asm/io.h>
  #include <asm/jazz.h>
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
22
  #include <asm/pgtable.h>
3d18c9836   Ralf Baechle   MIPS: Fix Jazz 64...
23
  #include <asm/tlbmisc.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24

4a41abe59   Ralf Baechle   MIPS: Jazz: Conve...
25
  static DEFINE_RAW_SPINLOCK(r4030_lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26

db00bed4b   Thomas Gleixner   MIPS: JAZZ: Conve...
27
  static void enable_r4030_irq(struct irq_data *d)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
  {
db00bed4b   Thomas Gleixner   MIPS: JAZZ: Conve...
29
  	unsigned int mask = 1 << (d->irq - JAZZ_IRQ_START);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
  	unsigned long flags;
4a41abe59   Ralf Baechle   MIPS: Jazz: Conve...
31
  	raw_spin_lock_irqsave(&r4030_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
33
  	mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  	r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
4a41abe59   Ralf Baechle   MIPS: Jazz: Conve...
34
  	raw_spin_unlock_irqrestore(&r4030_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
  }
db00bed4b   Thomas Gleixner   MIPS: JAZZ: Conve...
36
  void disable_r4030_irq(struct irq_data *d)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  {
db00bed4b   Thomas Gleixner   MIPS: JAZZ: Conve...
38
  	unsigned int mask = ~(1 << (d->irq - JAZZ_IRQ_START));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
  	unsigned long flags;
4a41abe59   Ralf Baechle   MIPS: Jazz: Conve...
40
  	raw_spin_lock_irqsave(&r4030_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
42
  	mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
  	r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
4a41abe59   Ralf Baechle   MIPS: Jazz: Conve...
43
  	raw_spin_unlock_irqrestore(&r4030_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
  }
94dee171d   Ralf Baechle   [MIPS] Eleminate ...
45
  static struct irq_chip r4030_irq_type = {
70d21cdee   Atsushi Nemoto   [MIPS] use name i...
46
  	.name = "R4030",
db00bed4b   Thomas Gleixner   MIPS: JAZZ: Conve...
47
48
  	.irq_mask = disable_r4030_irq,
  	.irq_unmask = enable_r4030_irq,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
51
52
53
  };
  
  void __init init_r4030_ints(void)
  {
  	int i;
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
54
  	for (i = JAZZ_IRQ_START; i <= JAZZ_IRQ_END; i++)
e4ec7989b   Thomas Gleixner   MIPS: Convert the...
55
  		irq_set_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
58
59
60
61
62
63
64
65
66
67
68
  
  	r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
  	r4030_read_reg16(JAZZ_IO_IRQ_SOURCE);		/* clear pending IRQs */
  	r4030_read_reg32(JAZZ_R4030_INVAL_ADDR);	/* clear error bits */
  }
  
  /*
   * On systems with i8259-style interrupt controllers we assume for
   * driver compatibility reasons interrupts 0 - 15 to be the i8259
   * interrupts even if the hardware uses a different interrupt numbering.
   */
  void __init arch_init_irq(void)
  {
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
69
70
71
72
73
74
75
76
77
78
79
  	/*
  	 * this is a hack to get back the still needed wired mapping
  	 * killed by init_mm()
  	 */
  
  	/* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */
  	add_wired_entry(0x02000017, 0x03c00017, 0xe0000000, PM_64K);
  	/* Map 0xe2000000 -> 0x0:900005C0, 0xe3010000 -> 0x0:910005C0 */
  	add_wired_entry(0x02400017, 0x02440017, 0xe2000000, PM_16M);
  	/* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */
  	add_wired_entry(0x01800017, 0x01000017, 0xe4000000, PM_4M);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
  	init_i8259_irqs();			/* Integrated i8259  */
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
81
  	mips_cpu_irq_init();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
  	init_r4030_ints();
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
83
  	change_c0_status(ST0_IM, IE_IRQ2 | IE_IRQ1);
e4ac58afd   Ralf Baechle   [MIPS] Rewrite al...
84
  }
937a80157   Ralf Baechle   [MIPS] Complete f...
85
  asmlinkage void plat_irq_dispatch(void)
e4ac58afd   Ralf Baechle   [MIPS] Rewrite al...
86
  {
119537c09   Thiemo Seufer   [MIPS] Misc fixes...
87
  	unsigned int pending = read_c0_cause() & read_c0_status();
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
88
  	unsigned int irq;
e4ac58afd   Ralf Baechle   [MIPS] Rewrite al...
89

ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
90
  	if (pending & IE_IRQ4) {
e4ac58afd   Ralf Baechle   [MIPS] Rewrite al...
91
  		r4030_read_reg32(JAZZ_TIMER_REGISTER);
937a80157   Ralf Baechle   [MIPS] Complete f...
92
  		do_IRQ(JAZZ_TIMER_IRQ);
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
93
94
95
96
  	} else if (pending & IE_IRQ2) {
  		irq = *(volatile u8 *)JAZZ_EISA_IRQ_ACK;
  		do_IRQ(irq);
  	} else if (pending & IE_IRQ1) {
ea202c632   Thomas Bogendoerfer   [MIPS] JAZZ fixes
97
98
99
100
101
  		irq = *(volatile u8 *)JAZZ_IO_IRQ_SOURCE >> 2;
  		if (likely(irq > 0))
  			do_IRQ(irq + JAZZ_IRQ_START - 1);
  		else
  			panic("Unimplemented loc_no_irq handler");
e4ac58afd   Ralf Baechle   [MIPS] Rewrite al...
102
103
  	}
  }
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
104
105
106
107
108
109
110
111
112
113
  
  static void r4030_set_mode(enum clock_event_mode mode,
                             struct clock_event_device *evt)
  {
  	/* Nothing to do ...  */
  }
  
  struct clock_event_device r4030_clockevent = {
  	.name		= "r4030",
  	.features	= CLOCK_EVT_FEAT_PERIODIC,
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
114
  	.rating		= 300,
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
115
  	.irq		= JAZZ_TIMER_IRQ,
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
116
117
118
119
120
  	.set_mode	= r4030_set_mode,
  };
  
  static irqreturn_t r4030_timer_interrupt(int irq, void *dev_id)
  {
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
121
  	struct clock_event_device *cd = dev_id;
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
122

3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
123
  	cd->event_handler(cd);
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
124
125
126
127
128
  	return IRQ_HANDLED;
  }
  
  static struct irqaction r4030_timer_irqaction = {
  	.handler	= r4030_timer_interrupt,
8b5690f88   Yong Zhang   MIPS: irq: Remove...
129
  	.flags		= IRQF_TIMER,
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
130
  	.name		= "R4030 timer",
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
131
  };
89742e537   Ralf Baechle   [MIPS] Jazz: Reti...
132
  void __init plat_time_init(void)
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
133
  {
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
134
135
136
  	struct clock_event_device *cd = &r4030_clockevent;
  	struct irqaction *action = &r4030_timer_irqaction;
  	unsigned int cpu = smp_processor_id();
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
137
138
  
  	BUG_ON(HZ != 100);
320ab2b0b   Rusty Russell   cpumask: convert ...
139
  	cd->cpumask             = cpumask_of(cpu);
3be51f70e   Thomas Bogendoerfer   [MIPS] Jazz: disa...
140
141
142
  	clockevents_register_device(cd);
  	action->dev_id = cd;
  	setup_irq(JAZZ_TIMER_IRQ, action);
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
143
144
145
146
147
148
149
  	/*
  	 * Set clock to 100Hz.
  	 *
  	 * The R4030 timer receives an input clock of 1kHz which is divieded by
  	 * a programmable 4-bit divider.  This makes it fairly inflexible.
  	 */
  	r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9);
89742e537   Ralf Baechle   [MIPS] Jazz: Reti...
150
  	setup_pit_timer();
584d98be3   Ralf Baechle   [MIPS] Jazz clock...
151
  }