Blame view

arch/xtensa/kernel/irq.c 3.17 KB
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
1
2
3
4
5
6
  /*
   * linux/arch/xtensa/kernel/irq.c
   *
   * Xtensa built-in interrupt controller and some generic functions copied
   * from i386.
   *
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
7
   * Copyright (C) 2002 - 2006 Tensilica, Inc.
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
   * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
   *
   *
   * Chris Zankel <chris@zankel.net>
   * Kevin Chea
   *
   */
  
  #include <linux/module.h>
  #include <linux/seq_file.h>
  #include <linux/interrupt.h>
  #include <linux/irq.h>
  #include <linux/kernel_stat.h>
  
  #include <asm/uaccess.h>
  #include <asm/platform.h>
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
24
25
26
27
28
  static unsigned int cached_irq_mask;
  
  atomic_t irq_err_count;
  
  /*
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
29
30
31
32
   * do_IRQ handles all normal device IRQ's (the special
   * SMP cross-CPU interrupts have their own specific
   * handlers).
   */
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
33
  asmlinkage void do_IRQ(int irq, struct pt_regs *regs)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
34
  {
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
35
  	struct pt_regs *old_regs = set_irq_regs(regs);
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
36
37
38
39
  
  	if (irq >= NR_IRQS) {
  		printk(KERN_EMERG "%s: cannot handle IRQ %d
  ",
1b532c6ce   Harvey Harrison   xtensa: replace r...
40
  				__func__, irq);
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
41
  	}
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  	irq_enter();
  
  #ifdef CONFIG_DEBUG_STACKOVERFLOW
  	/* Debugging check for stack overflow: is there less than 1KB free? */
  	{
  		unsigned long sp;
  
  		__asm__ __volatile__ ("mov %0, a1
  " : "=a" (sp));
  		sp &= THREAD_SIZE - 1;
  
  		if (unlikely(sp < (sizeof(thread_info) + 1024)))
  			printk("Stack overflow in do_IRQ: %ld
  ",
  			       sp - sizeof(struct thread_info));
  	}
  #endif
495e0c794   Thomas Gleixner   xtensa: Convert m...
59
  	generic_handle_irq(irq);
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
60
61
  
  	irq_exit();
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
62
  	set_irq_regs(old_regs);
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
63
  }
47a5d9dcb   Thomas Gleixner   xtensa: Use gener...
64
  int arch_show_interrupts(struct seq_file *p, int prec)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
65
  {
47a5d9dcb   Thomas Gleixner   xtensa: Use gener...
66
67
68
  	seq_printf(p, "%*s: ", prec, "ERR");
  	seq_printf(p, "%10u
  ", atomic_read(&irq_err_count));
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
69
70
  	return 0;
  }
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
71

2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
72
  static void xtensa_irq_mask(struct irq_data *d)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
73
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
74
  	cached_irq_mask &= ~(1 << d->irq);
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
75
76
  	set_sr (cached_irq_mask, INTENABLE);
  }
2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
77
  static void xtensa_irq_unmask(struct irq_data *d)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
78
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
79
  	cached_irq_mask |= 1 << d->irq;
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
80
81
  	set_sr (cached_irq_mask, INTENABLE);
  }
2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
82
  static void xtensa_irq_enable(struct irq_data *d)
4c0d21414   Johannes Weiner   xtensa: variant i...
83
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
84
85
  	variant_irq_enable(d->irq);
  	xtensa_irq_unmask(d->irq);
4c0d21414   Johannes Weiner   xtensa: variant i...
86
  }
2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
87
  static void xtensa_irq_disable(struct irq_data *d)
4c0d21414   Johannes Weiner   xtensa: variant i...
88
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
89
90
  	xtensa_irq_mask(d->irq);
  	variant_irq_disable(d->irq);
4c0d21414   Johannes Weiner   xtensa: variant i...
91
  }
2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
92
  static void xtensa_irq_ack(struct irq_data *d)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
93
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
94
  	set_sr(1 << d->irq, INTCLEAR);
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
95
  }
2ea4db65b   Thomas Gleixner   xtensa: Fixup irq...
96
  static int xtensa_irq_retrigger(struct irq_data *d)
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
97
  {
495e0c794   Thomas Gleixner   xtensa: Convert m...
98
  	set_sr (1 << d->irq, INTSET);
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
99
  	return 1;
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
100
  }
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
101

fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
102
103
  static struct irq_chip xtensa_irq_chip = {
  	.name		= "xtensa",
495e0c794   Thomas Gleixner   xtensa: Convert m...
104
105
106
107
108
109
  	.irq_enable	= xtensa_irq_enable,
  	.irq_disable	= xtensa_irq_disable,
  	.irq_mask	= xtensa_irq_mask,
  	.irq_unmask	= xtensa_irq_unmask,
  	.irq_ack	= xtensa_irq_ack,
  	.irq_retrigger	= xtensa_irq_retrigger,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
110
  };
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
111
112
113
  
  void __init init_IRQ(void)
  {
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
114
  	int index;
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
115

fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
116
117
  	for (index = 0; index < XTENSA_NR_IRQS; index++) {
  		int mask = 1 << index;
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
118

fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
119
  		if (mask & XCHAL_INTTYPE_MASK_SOFTWARE)
610e1756e   Thomas Gleixner   xtensa: Convert g...
120
  			irq_set_chip_and_handler(index, &xtensa_irq_chip,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
121
  						 handle_simple_irq);
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
122

fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
123
  		else if (mask & XCHAL_INTTYPE_MASK_EXTERN_EDGE)
610e1756e   Thomas Gleixner   xtensa: Convert g...
124
  			irq_set_chip_and_handler(index, &xtensa_irq_chip,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
125
126
127
  						 handle_edge_irq);
  
  		else if (mask & XCHAL_INTTYPE_MASK_EXTERN_LEVEL)
610e1756e   Thomas Gleixner   xtensa: Convert g...
128
  			irq_set_chip_and_handler(index, &xtensa_irq_chip,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
129
130
131
  						 handle_level_irq);
  
  		else if (mask & XCHAL_INTTYPE_MASK_TIMER)
610e1756e   Thomas Gleixner   xtensa: Convert g...
132
  			irq_set_chip_and_handler(index, &xtensa_irq_chip,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
133
134
135
136
  						 handle_edge_irq);
  
  		else	/* XCHAL_INTTYPE_MASK_WRITE_ERROR */
  			/* XCHAL_INTTYPE_MASK_NMI */
610e1756e   Thomas Gleixner   xtensa: Convert g...
137
  			irq_set_chip_and_handler(index, &xtensa_irq_chip,
fd43fe19b   Chris Zankel   [PATCH] xtensa: f...
138
139
140
141
  						 handle_level_irq);
  	}
  
  	cached_irq_mask = 0;
1beee2103   Daniel Glöckner   xtensa: allow var...
142
143
  
  	variant_init_irq();
5a0015d62   Chris Zankel   [PATCH] xtensa: A...
144
  }