drm/amdgpu: Sprinkle drm_modeset_lock_all to appease locking checks
[deliverable/linux.git] / drivers / irqchip / irq-renesas-h8300h.c
1 /*
2 * H8/300H interrupt controller driver
3 *
4 * Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp>
5 */
6
7 #include <linux/init.h>
8 #include <linux/irq.h>
9 #include <linux/irqchip.h>
10 #include <linux/of_address.h>
11 #include <linux/of_irq.h>
12 #include <asm/io.h>
13
14 #include "irqchip.h"
15
16 static const char ipr_bit[] = {
17 7, 6, 5, 5,
18 4, 4, 4, 4, 3, 3, 3, 3,
19 2, 2, 2, 2, 1, 1, 1, 1,
20 0, 0, 0, 0, 15, 15, 15, 15,
21 14, 14, 14, 14, 13, 13, 13, 13,
22 -1, -1, -1, -1, 11, 11, 11, 11,
23 10, 10, 10, 10, 9, 9, 9, 9,
24 };
25
26 static void *intc_baseaddr;
27
28 #define IPR ((unsigned long)intc_baseaddr + 6)
29
30 static void h8300h_disable_irq(struct irq_data *data)
31 {
32 int bit;
33 int irq = data->irq - 12;
34
35 bit = ipr_bit[irq];
36 if (bit >= 0) {
37 if (bit < 8)
38 ctrl_bclr(bit & 7, IPR);
39 else
40 ctrl_bclr(bit & 7, (IPR+1));
41 }
42 }
43
44 static void h8300h_enable_irq(struct irq_data *data)
45 {
46 int bit;
47 int irq = data->irq - 12;
48
49 bit = ipr_bit[irq];
50 if (bit >= 0) {
51 if (bit < 8)
52 ctrl_bset(bit & 7, IPR);
53 else
54 ctrl_bset(bit & 7, (IPR+1));
55 }
56 }
57
58 struct irq_chip h8300h_irq_chip = {
59 .name = "H8/300H-INTC",
60 .irq_enable = h8300h_enable_irq,
61 .irq_disable = h8300h_disable_irq,
62 };
63
64 static int irq_map(struct irq_domain *h, unsigned int virq,
65 irq_hw_number_t hw_irq_num)
66 {
67 irq_set_chip_and_handler(virq, &h8300h_irq_chip, handle_simple_irq);
68
69 return 0;
70 }
71
72 static struct irq_domain_ops irq_ops = {
73 .map = irq_map,
74 .xlate = irq_domain_xlate_onecell,
75 };
76
77 static int __init h8300h_intc_of_init(struct device_node *intc,
78 struct device_node *parent)
79 {
80 struct irq_domain *domain;
81
82 intc_baseaddr = of_iomap(intc, 0);
83 BUG_ON(!intc_baseaddr);
84
85 /* All interrupt priority low */
86 ctrl_outb(0x00, IPR + 0);
87 ctrl_outb(0x00, IPR + 1);
88
89 domain = irq_domain_add_linear(intc, NR_IRQS, &irq_ops, NULL);
90 BUG_ON(!domain);
91 irq_set_default_host(domain);
92 return 0;
93 }
94
95 IRQCHIP_DECLARE(h8300h_intc, "renesas,h8300h-intc", h8300h_intc_of_init);
This page took 0.040231 seconds and 5 git commands to generate.