Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Broadcom BCM7120 style Level 2 interrupt controller driver |
| 3 | * |
| 4 | * Copyright (C) 2014 Broadcom Corporation |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/slab.h> |
| 15 | #include <linux/module.h> |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 16 | #include <linux/kernel.h> |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/of.h> |
| 19 | #include <linux/of_irq.h> |
| 20 | #include <linux/of_address.h> |
| 21 | #include <linux/of_platform.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/io.h> |
| 25 | #include <linux/irqdomain.h> |
| 26 | #include <linux/reboot.h> |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 27 | #include <linux/bitops.h> |
Joel Porquet | 41a83e0 | 2015-07-07 17:11:46 -0400 | [diff] [blame] | 28 | #include <linux/irqchip.h> |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 29 | #include <linux/irqchip/chained_irq.h> |
| 30 | |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 31 | /* Register offset in the L2 interrupt controller */ |
| 32 | #define IRQEN 0x00 |
| 33 | #define IRQSTAT 0x04 |
| 34 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 35 | #define MAX_WORDS 4 |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 36 | #define MAX_MAPPINGS (MAX_WORDS * 2) |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 37 | #define IRQS_PER_WORD 32 |
| 38 | |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 39 | struct bcm7120_l1_intc_data { |
| 40 | struct bcm7120_l2_intc_data *b; |
| 41 | u32 irq_map_mask[MAX_WORDS]; |
| 42 | }; |
| 43 | |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 44 | struct bcm7120_l2_intc_data { |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 45 | unsigned int n_words; |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 46 | void __iomem *map_base[MAX_MAPPINGS]; |
| 47 | void __iomem *pair_base[MAX_WORDS]; |
| 48 | int en_offset[MAX_WORDS]; |
| 49 | int stat_offset[MAX_WORDS]; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 50 | struct irq_domain *domain; |
| 51 | bool can_wake; |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 52 | u32 irq_fwd_mask[MAX_WORDS]; |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 53 | struct bcm7120_l1_intc_data *l1_data; |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 54 | int num_parent_irqs; |
| 55 | const __be32 *map_mask_prop; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame] | 58 | static void bcm7120_l2_intc_irq_handle(struct irq_desc *desc) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 59 | { |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 60 | struct bcm7120_l1_intc_data *data = irq_desc_get_handler_data(desc); |
| 61 | struct bcm7120_l2_intc_data *b = data->b; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 62 | struct irq_chip *chip = irq_desc_get_chip(desc); |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 63 | unsigned int idx; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 64 | |
| 65 | chained_irq_enter(chip, desc); |
| 66 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 67 | for (idx = 0; idx < b->n_words; idx++) { |
| 68 | int base = idx * IRQS_PER_WORD; |
| 69 | struct irq_chip_generic *gc = |
| 70 | irq_get_domain_generic_chip(b->domain, base); |
| 71 | unsigned long pending; |
| 72 | int hwirq; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 73 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 74 | irq_gc_lock(gc); |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 75 | pending = irq_reg_readl(gc, b->stat_offset[idx]) & |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 76 | gc->mask_cache & |
| 77 | data->irq_map_mask[idx]; |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 78 | irq_gc_unlock(gc); |
| 79 | |
| 80 | for_each_set_bit(hwirq, &pending, IRQS_PER_WORD) { |
| 81 | generic_handle_irq(irq_find_mapping(b->domain, |
| 82 | base + hwirq)); |
| 83 | } |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 86 | chained_irq_exit(chip, desc); |
| 87 | } |
| 88 | |
Brian Norris | fd53776 | 2015-07-22 16:21:40 -0700 | [diff] [blame] | 89 | static void bcm7120_l2_intc_suspend(struct irq_chip_generic *gc) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 90 | { |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 91 | struct bcm7120_l2_intc_data *b = gc->private; |
Brian Norris | fd53776 | 2015-07-22 16:21:40 -0700 | [diff] [blame] | 92 | struct irq_chip_type *ct = gc->chip_types; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 93 | |
| 94 | irq_gc_lock(gc); |
Kevin Cernekee | c17261f | 2014-11-06 22:44:28 -0800 | [diff] [blame] | 95 | if (b->can_wake) |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 96 | irq_reg_writel(gc, gc->mask_cache | gc->wake_active, |
| 97 | ct->regs.mask); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 98 | irq_gc_unlock(gc); |
| 99 | } |
| 100 | |
Brian Norris | fd53776 | 2015-07-22 16:21:40 -0700 | [diff] [blame] | 101 | static void bcm7120_l2_intc_resume(struct irq_chip_generic *gc) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 102 | { |
Brian Norris | fd53776 | 2015-07-22 16:21:40 -0700 | [diff] [blame] | 103 | struct irq_chip_type *ct = gc->chip_types; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 104 | |
| 105 | /* Restore the saved mask */ |
| 106 | irq_gc_lock(gc); |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 107 | irq_reg_writel(gc, gc->mask_cache, ct->regs.mask); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 108 | irq_gc_unlock(gc); |
| 109 | } |
| 110 | |
| 111 | static int bcm7120_l2_intc_init_one(struct device_node *dn, |
| 112 | struct bcm7120_l2_intc_data *data, |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 113 | int irq, u32 *valid_mask) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 114 | { |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 115 | struct bcm7120_l1_intc_data *l1_data = &data->l1_data[irq]; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 116 | int parent_irq; |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 117 | unsigned int idx; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 118 | |
| 119 | parent_irq = irq_of_parse_and_map(dn, irq); |
Dmitry Torokhov | 714710e | 2014-11-14 14:16:14 -0800 | [diff] [blame] | 120 | if (!parent_irq) { |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 121 | pr_err("failed to map interrupt %d\n", irq); |
Dmitry Torokhov | 714710e | 2014-11-14 14:16:14 -0800 | [diff] [blame] | 122 | return -EINVAL; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 125 | /* For multiple parent IRQs with multiple words, this looks like: |
| 126 | * <irq0_w0 irq0_w1 irq1_w0 irq1_w1 ...> |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 127 | * |
| 128 | * We need to associate a given parent interrupt with its corresponding |
| 129 | * map_mask in order to mask the status register with it because we |
| 130 | * have the same handler being called for multiple parent interrupts. |
| 131 | * |
| 132 | * This is typically something needed on BCM7xxx (STB chips). |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 133 | */ |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 134 | for (idx = 0; idx < data->n_words; idx++) { |
| 135 | if (data->map_mask_prop) { |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 136 | l1_data->irq_map_mask[idx] |= |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 137 | be32_to_cpup(data->map_mask_prop + |
| 138 | irq * data->n_words + idx); |
| 139 | } else { |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 140 | l1_data->irq_map_mask[idx] = 0xffffffff; |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 141 | } |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 142 | valid_mask[idx] |= l1_data->irq_map_mask[idx]; |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 143 | } |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 144 | |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 145 | l1_data->b = data; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 146 | |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 147 | irq_set_chained_handler_and_data(parent_irq, |
| 148 | bcm7120_l2_intc_irq_handle, l1_data); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 152 | static int __init bcm7120_l2_intc_iomap_7120(struct device_node *dn, |
| 153 | struct bcm7120_l2_intc_data *data) |
| 154 | { |
| 155 | int ret; |
| 156 | |
| 157 | data->map_base[0] = of_iomap(dn, 0); |
| 158 | if (!data->map_base[0]) { |
| 159 | pr_err("unable to map registers\n"); |
| 160 | return -ENOMEM; |
| 161 | } |
| 162 | |
| 163 | data->pair_base[0] = data->map_base[0]; |
| 164 | data->en_offset[0] = IRQEN; |
| 165 | data->stat_offset[0] = IRQSTAT; |
| 166 | data->n_words = 1; |
| 167 | |
| 168 | ret = of_property_read_u32_array(dn, "brcm,int-fwd-mask", |
| 169 | data->irq_fwd_mask, data->n_words); |
| 170 | if (ret != 0 && ret != -EINVAL) { |
| 171 | /* property exists but has the wrong number of words */ |
| 172 | pr_err("invalid brcm,int-fwd-mask property\n"); |
| 173 | return -EINVAL; |
| 174 | } |
| 175 | |
| 176 | data->map_mask_prop = of_get_property(dn, "brcm,int-map-mask", &ret); |
| 177 | if (!data->map_mask_prop || |
| 178 | (ret != (sizeof(__be32) * data->num_parent_irqs * data->n_words))) { |
| 179 | pr_err("invalid brcm,int-map-mask property\n"); |
| 180 | return -EINVAL; |
| 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 186 | static int __init bcm7120_l2_intc_iomap_3380(struct device_node *dn, |
| 187 | struct bcm7120_l2_intc_data *data) |
| 188 | { |
| 189 | unsigned int gc_idx; |
| 190 | |
| 191 | for (gc_idx = 0; gc_idx < MAX_WORDS; gc_idx++) { |
| 192 | unsigned int map_idx = gc_idx * 2; |
| 193 | void __iomem *en = of_iomap(dn, map_idx + 0); |
| 194 | void __iomem *stat = of_iomap(dn, map_idx + 1); |
| 195 | void __iomem *base = min(en, stat); |
| 196 | |
| 197 | data->map_base[map_idx + 0] = en; |
| 198 | data->map_base[map_idx + 1] = stat; |
| 199 | |
| 200 | if (!base) |
| 201 | break; |
| 202 | |
| 203 | data->pair_base[gc_idx] = base; |
| 204 | data->en_offset[gc_idx] = en - base; |
| 205 | data->stat_offset[gc_idx] = stat - base; |
| 206 | } |
| 207 | |
| 208 | if (!gc_idx) { |
| 209 | pr_err("unable to map registers\n"); |
| 210 | return -EINVAL; |
| 211 | } |
| 212 | |
| 213 | data->n_words = gc_idx; |
| 214 | return 0; |
| 215 | } |
| 216 | |
Ben Dooks | dde7e6d1a | 2016-06-08 18:59:58 +0100 | [diff] [blame] | 217 | static int __init bcm7120_l2_intc_probe(struct device_node *dn, |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 218 | struct device_node *parent, |
| 219 | int (*iomap_regs_fn)(struct device_node *, |
| 220 | struct bcm7120_l2_intc_data *), |
| 221 | const char *intc_name) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 222 | { |
| 223 | unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; |
| 224 | struct bcm7120_l2_intc_data *data; |
| 225 | struct irq_chip_generic *gc; |
| 226 | struct irq_chip_type *ct; |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 227 | int ret = 0; |
Kevin Cernekee | c17261f | 2014-11-06 22:44:28 -0800 | [diff] [blame] | 228 | unsigned int idx, irq, flags; |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 229 | u32 valid_mask[MAX_WORDS] = { }; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 230 | |
| 231 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 232 | if (!data) |
| 233 | return -ENOMEM; |
| 234 | |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 235 | data->num_parent_irqs = of_irq_count(dn); |
| 236 | if (data->num_parent_irqs <= 0) { |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 237 | pr_err("invalid number of parent interrupts\n"); |
| 238 | ret = -ENOMEM; |
| 239 | goto out_unmap; |
| 240 | } |
| 241 | |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 242 | data->l1_data = kcalloc(data->num_parent_irqs, sizeof(*data->l1_data), |
| 243 | GFP_KERNEL); |
| 244 | if (!data->l1_data) { |
| 245 | ret = -ENOMEM; |
| 246 | goto out_free_l1_data; |
| 247 | } |
| 248 | |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 249 | ret = iomap_regs_fn(dn, data); |
| 250 | if (ret < 0) |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 251 | goto out_free_l1_data; |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 252 | |
| 253 | for (idx = 0; idx < data->n_words; idx++) { |
| 254 | __raw_writel(data->irq_fwd_mask[idx], |
| 255 | data->pair_base[idx] + |
| 256 | data->en_offset[idx]); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 259 | for (irq = 0; irq < data->num_parent_irqs; irq++) { |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 260 | ret = bcm7120_l2_intc_init_one(dn, data, irq, valid_mask); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 261 | if (ret) |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 262 | goto out_free_l1_data; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 265 | data->domain = irq_domain_add_linear(dn, IRQS_PER_WORD * data->n_words, |
| 266 | &irq_generic_chip_ops, NULL); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 267 | if (!data->domain) { |
| 268 | ret = -ENOMEM; |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 269 | goto out_free_l1_data; |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Kevin Cernekee | c17261f | 2014-11-06 22:44:28 -0800 | [diff] [blame] | 272 | /* MIPS chips strapped for BE will automagically configure the |
| 273 | * peripheral registers for CPU-native byte order. |
| 274 | */ |
| 275 | flags = IRQ_GC_INIT_MASK_CACHE; |
| 276 | if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) |
| 277 | flags |= IRQ_GC_BE_IO; |
| 278 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 279 | ret = irq_alloc_domain_generic_chips(data->domain, IRQS_PER_WORD, 1, |
Kevin Cernekee | c17261f | 2014-11-06 22:44:28 -0800 | [diff] [blame] | 280 | dn->full_name, handle_level_irq, clr, 0, flags); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 281 | if (ret) { |
| 282 | pr_err("failed to allocate generic irq chip\n"); |
| 283 | goto out_free_domain; |
| 284 | } |
| 285 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 286 | if (of_property_read_bool(dn, "brcm,irq-can-wake")) |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 287 | data->can_wake = true; |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 288 | |
| 289 | for (idx = 0; idx < data->n_words; idx++) { |
| 290 | irq = idx * IRQS_PER_WORD; |
| 291 | gc = irq_get_domain_generic_chip(data->domain, irq); |
| 292 | |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 293 | gc->unused = 0xffffffff & ~valid_mask[idx]; |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 294 | gc->private = data; |
| 295 | ct = gc->chip_types; |
| 296 | |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 297 | gc->reg_base = data->pair_base[idx]; |
| 298 | ct->regs.mask = data->en_offset[idx]; |
| 299 | |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 300 | ct->chip.irq_mask = irq_gc_mask_clr_bit; |
| 301 | ct->chip.irq_unmask = irq_gc_mask_set_bit; |
| 302 | ct->chip.irq_ack = irq_gc_noop; |
Brian Norris | fd53776 | 2015-07-22 16:21:40 -0700 | [diff] [blame] | 303 | gc->suspend = bcm7120_l2_intc_suspend; |
| 304 | gc->resume = bcm7120_l2_intc_resume; |
| 305 | |
| 306 | /* |
| 307 | * Initialize mask-cache, in case we need it for |
| 308 | * saving/restoring fwd mask even w/o any child interrupts |
| 309 | * installed |
| 310 | */ |
| 311 | gc->mask_cache = irq_reg_readl(gc, ct->regs.mask); |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 312 | |
| 313 | if (data->can_wake) { |
| 314 | /* This IRQ chip can wake the system, set all |
| 315 | * relevant child interupts in wake_enabled mask |
| 316 | */ |
| 317 | gc->wake_enabled = 0xffffffff; |
| 318 | gc->wake_enabled &= ~gc->unused; |
| 319 | ct->chip.irq_set_wake = irq_gc_set_wake; |
| 320 | } |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 323 | pr_info("registered %s intc (mem: 0x%p, parent IRQ(s): %d)\n", |
| 324 | intc_name, data->map_base[0], data->num_parent_irqs); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 325 | |
| 326 | return 0; |
| 327 | |
| 328 | out_free_domain: |
| 329 | irq_domain_remove(data->domain); |
Florian Fainelli | 0aef399 | 2015-07-23 15:52:21 -0700 | [diff] [blame] | 330 | out_free_l1_data: |
| 331 | kfree(data->l1_data); |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 332 | out_unmap: |
Kevin Cernekee | 5b5468c | 2014-12-25 09:49:03 -0800 | [diff] [blame] | 333 | for (idx = 0; idx < MAX_MAPPINGS; idx++) { |
| 334 | if (data->map_base[idx]) |
| 335 | iounmap(data->map_base[idx]); |
Kevin Cernekee | c76acf4 | 2014-11-06 22:44:26 -0800 | [diff] [blame] | 336 | } |
Florian Fainelli | a5042de2 | 2014-09-09 17:44:21 -0700 | [diff] [blame] | 337 | kfree(data); |
| 338 | return ret; |
| 339 | } |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 340 | |
Ben Dooks | dde7e6d1a | 2016-06-08 18:59:58 +0100 | [diff] [blame] | 341 | static int __init bcm7120_l2_intc_probe_7120(struct device_node *dn, |
| 342 | struct device_node *parent) |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 343 | { |
| 344 | return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_7120, |
| 345 | "BCM7120 L2"); |
| 346 | } |
| 347 | |
Ben Dooks | dde7e6d1a | 2016-06-08 18:59:58 +0100 | [diff] [blame] | 348 | static int __init bcm7120_l2_intc_probe_3380(struct device_node *dn, |
| 349 | struct device_node *parent) |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 350 | { |
| 351 | return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_3380, |
| 352 | "BCM3380 L2"); |
| 353 | } |
| 354 | |
Kevin Cernekee | a4fcbb8 | 2014-11-06 22:44:27 -0800 | [diff] [blame] | 355 | IRQCHIP_DECLARE(bcm7120_l2_intc, "brcm,bcm7120-l2-intc", |
Kevin Cernekee | ca40f1b | 2014-12-25 09:49:04 -0800 | [diff] [blame] | 356 | bcm7120_l2_intc_probe_7120); |
Kevin Cernekee | 7b7230e | 2014-12-25 09:49:05 -0800 | [diff] [blame] | 357 | |
| 358 | IRQCHIP_DECLARE(bcm3380_l2_intc, "brcm,bcm3380-l2-intc", |
| 359 | bcm7120_l2_intc_probe_3380); |