Blame view

drivers/irqchip/irq-xtensa-pic.c 2.72 KB
cbd1de2e8   Max Filippov   xtensa: move buil...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  /*
   * Xtensa built-in interrupt controller
   *
   * Copyright (C) 2002 - 2013 Tensilica, Inc.
   * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
   *
   * 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.
   *
   * Chris Zankel <chris@zankel.net>
   * Kevin Chea
   */
  
  #include <linux/interrupt.h>
  #include <linux/irqdomain.h>
  #include <linux/irq.h>
41a83e06e   Joel Porquet   irqchip: Prepare ...
18
  #include <linux/irqchip.h>
cbd1de2e8   Max Filippov   xtensa: move buil...
19
  #include <linux/of.h>
cbd1de2e8   Max Filippov   xtensa: move buil...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  unsigned int cached_irq_mask;
  
  /*
   * Device Tree IRQ specifier translation function which works with one or
   * two cell bindings. First cell value maps directly to the hwirq number.
   * Second cell if present specifies whether hwirq number is external (1) or
   * internal (0).
   */
  static int xtensa_pic_irq_domain_xlate(struct irq_domain *d,
  		struct device_node *ctrlr,
  		const u32 *intspec, unsigned int intsize,
  		unsigned long *out_hwirq, unsigned int *out_type)
  {
  	return xtensa_irq_domain_xlate(intspec, intsize,
  			intspec[0], intspec[0],
  			out_hwirq, out_type);
  }
  
  static const struct irq_domain_ops xtensa_irq_domain_ops = {
  	.xlate = xtensa_pic_irq_domain_xlate,
  	.map = xtensa_irq_map,
  };
  
  static void xtensa_irq_mask(struct irq_data *d)
  {
  	cached_irq_mask &= ~(1 << d->hwirq);
cad6fade6   Max Filippov   xtensa: clean up ...
46
  	xtensa_set_sr(cached_irq_mask, intenable);
cbd1de2e8   Max Filippov   xtensa: move buil...
47
48
49
50
51
  }
  
  static void xtensa_irq_unmask(struct irq_data *d)
  {
  	cached_irq_mask |= 1 << d->hwirq;
cad6fade6   Max Filippov   xtensa: clean up ...
52
  	xtensa_set_sr(cached_irq_mask, intenable);
cbd1de2e8   Max Filippov   xtensa: move buil...
53
54
55
56
  }
  
  static void xtensa_irq_enable(struct irq_data *d)
  {
cbd1de2e8   Max Filippov   xtensa: move buil...
57
58
59
60
61
62
  	xtensa_irq_unmask(d);
  }
  
  static void xtensa_irq_disable(struct irq_data *d)
  {
  	xtensa_irq_mask(d);
cbd1de2e8   Max Filippov   xtensa: move buil...
63
64
65
66
  }
  
  static void xtensa_irq_ack(struct irq_data *d)
  {
cad6fade6   Max Filippov   xtensa: clean up ...
67
  	xtensa_set_sr(1 << d->hwirq, intclear);
cbd1de2e8   Max Filippov   xtensa: move buil...
68
69
70
71
  }
  
  static int xtensa_irq_retrigger(struct irq_data *d)
  {
bb6652363   Max Filippov   drivers/irqchip: ...
72
73
74
75
76
  	unsigned int mask = 1u << d->hwirq;
  
  	if (WARN_ON(mask & ~XCHAL_INTTYPE_MASK_SOFTWARE))
  		return 0;
  	xtensa_set_sr(mask, intset);
cbd1de2e8   Max Filippov   xtensa: move buil...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  	return 1;
  }
  
  static struct irq_chip xtensa_irq_chip = {
  	.name		= "xtensa",
  	.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,
  };
  
  int __init xtensa_pic_init_legacy(struct device_node *interrupt_parent)
  {
  	struct irq_domain *root_domain =
e5c86679d   Max Filippov   xtensa: don't use...
93
  		irq_domain_add_legacy(NULL, NR_IRQS - 1, 1, 0,
cbd1de2e8   Max Filippov   xtensa: move buil...
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  				&xtensa_irq_domain_ops, &xtensa_irq_chip);
  	irq_set_default_host(root_domain);
  	return 0;
  }
  
  static int __init xtensa_pic_init(struct device_node *np,
  		struct device_node *interrupt_parent)
  {
  	struct irq_domain *root_domain =
  		irq_domain_add_linear(np, NR_IRQS, &xtensa_irq_domain_ops,
  				&xtensa_irq_chip);
  	irq_set_default_host(root_domain);
  	return 0;
  }
  IRQCHIP_DECLARE(xtensa_irq_chip, "cdns,xtensa-pic", xtensa_pic_init);