Lines Matching +full:int +full:- +full:fwd +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-only
39 unsigned int n_words;
79 static inline unsigned int reg_status(struct bcm7038_l1_chip *intc, in reg_status()
80 unsigned int word) in reg_status()
82 return (0 * intc->n_words + word) * sizeof(u32); in reg_status()
85 static inline unsigned int reg_mask_status(struct bcm7038_l1_chip *intc, in reg_mask_status()
86 unsigned int word) in reg_mask_status()
88 return (1 * intc->n_words + word) * sizeof(u32); in reg_mask_status()
91 static inline unsigned int reg_mask_set(struct bcm7038_l1_chip *intc, in reg_mask_set()
92 unsigned int word) in reg_mask_set()
94 return (2 * intc->n_words + word) * sizeof(u32); in reg_mask_set()
97 static inline unsigned int reg_mask_clr(struct bcm7038_l1_chip *intc, in reg_mask_clr()
98 unsigned int word) in reg_mask_clr()
100 return (3 * intc->n_words + word) * sizeof(u32); in reg_mask_clr()
124 unsigned int idx; in bcm7038_l1_irq_handle()
127 cpu = intc->cpus[cpu_logical_map(smp_processor_id())]; in bcm7038_l1_irq_handle()
129 cpu = intc->cpus[0]; in bcm7038_l1_irq_handle()
134 for (idx = 0; idx < intc->n_words; idx++) { in bcm7038_l1_irq_handle()
135 int base = idx * IRQS_PER_WORD; in bcm7038_l1_irq_handle()
137 int hwirq; in bcm7038_l1_irq_handle()
139 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_irq_handle()
140 pending = l1_readl(cpu->map_base + reg_status(intc, idx)) & in bcm7038_l1_irq_handle()
141 ~cpu->mask_cache[idx]; in bcm7038_l1_irq_handle()
142 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_irq_handle()
145 generic_handle_domain_irq(intc->domain, base + hwirq); in bcm7038_l1_irq_handle()
151 static void __bcm7038_l1_unmask(struct irq_data *d, unsigned int cpu_idx) in __bcm7038_l1_unmask()
154 u32 word = d->hwirq / IRQS_PER_WORD; in __bcm7038_l1_unmask()
155 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in __bcm7038_l1_unmask() local
157 intc->cpus[cpu_idx]->mask_cache[word] &= ~mask; in __bcm7038_l1_unmask()
158 l1_writel(mask, intc->cpus[cpu_idx]->map_base + in __bcm7038_l1_unmask()
162 static void __bcm7038_l1_mask(struct irq_data *d, unsigned int cpu_idx) in __bcm7038_l1_mask()
165 u32 word = d->hwirq / IRQS_PER_WORD; in __bcm7038_l1_mask()
166 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in __bcm7038_l1_mask() local
168 intc->cpus[cpu_idx]->mask_cache[word] |= mask; in __bcm7038_l1_mask()
169 l1_writel(mask, intc->cpus[cpu_idx]->map_base + in __bcm7038_l1_mask()
178 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_unmask()
179 __bcm7038_l1_unmask(d, intc->affinity[d->hwirq]); in bcm7038_l1_unmask()
180 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_unmask()
188 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_mask()
189 __bcm7038_l1_mask(d, intc->affinity[d->hwirq]); in bcm7038_l1_mask()
190 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_mask()
194 static int bcm7038_l1_set_affinity(struct irq_data *d, in bcm7038_l1_set_affinity()
200 irq_hw_number_t hw = d->hwirq; in bcm7038_l1_set_affinity()
202 u32 mask = BIT(hw % IRQS_PER_WORD); in bcm7038_l1_set_affinity() local
203 unsigned int first_cpu = cpumask_any_and(dest, cpu_online_mask); in bcm7038_l1_set_affinity()
206 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_set_affinity()
208 was_disabled = !!(intc->cpus[intc->affinity[hw]]->mask_cache[word] & in bcm7038_l1_set_affinity()
209 mask); in bcm7038_l1_set_affinity()
210 __bcm7038_l1_mask(d, intc->affinity[hw]); in bcm7038_l1_set_affinity()
211 intc->affinity[hw] = first_cpu; in bcm7038_l1_set_affinity()
215 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_set_affinity()
222 static int __init bcm7038_l1_init_one(struct device_node *dn, in bcm7038_l1_init_one()
223 unsigned int idx, in bcm7038_l1_init_one()
229 unsigned int i, n_words, parent_irq; in bcm7038_l1_init_one()
230 int ret; in bcm7038_l1_init_one()
233 return -EINVAL; in bcm7038_l1_init_one()
238 return -EINVAL; in bcm7038_l1_init_one()
239 else if (!intc->n_words) in bcm7038_l1_init_one()
240 intc->n_words = n_words; in bcm7038_l1_init_one()
241 else if (intc->n_words != n_words) in bcm7038_l1_init_one()
242 return -EINVAL; in bcm7038_l1_init_one()
244 ret = of_property_read_u32_array(dn , "brcm,int-fwd-mask", in bcm7038_l1_init_one()
245 intc->irq_fwd_mask, n_words); in bcm7038_l1_init_one()
246 if (ret != 0 && ret != -EINVAL) { in bcm7038_l1_init_one()
248 pr_err("invalid brcm,int-fwd-mask property\n"); in bcm7038_l1_init_one()
249 return -EINVAL; in bcm7038_l1_init_one()
252 cpu = intc->cpus[idx] = kzalloc(sizeof(*cpu) + n_words * sizeof(u32), in bcm7038_l1_init_one()
255 return -ENOMEM; in bcm7038_l1_init_one()
257 cpu->map_base = ioremap(res.start, sz); in bcm7038_l1_init_one()
258 if (!cpu->map_base) in bcm7038_l1_init_one()
259 return -ENOMEM; in bcm7038_l1_init_one()
262 l1_writel(~intc->irq_fwd_mask[i], in bcm7038_l1_init_one()
263 cpu->map_base + reg_mask_set(intc, i)); in bcm7038_l1_init_one()
264 l1_writel(intc->irq_fwd_mask[i], in bcm7038_l1_init_one()
265 cpu->map_base + reg_mask_clr(intc, i)); in bcm7038_l1_init_one()
266 cpu->mask_cache[i] = ~intc->irq_fwd_mask[i]; in bcm7038_l1_init_one()
272 return -EINVAL; in bcm7038_l1_init_one()
275 if (of_property_read_bool(dn, "brcm,irq-can-wake")) in bcm7038_l1_init_one()
295 static int bcm7038_l1_suspend(void) in bcm7038_l1_suspend()
298 int boot_cpu, word; in bcm7038_l1_suspend()
309 for (word = 0; word < intc->n_words; word++) { in bcm7038_l1_suspend()
310 val = intc->wake_mask[word] | intc->irq_fwd_mask[word]; in bcm7038_l1_suspend()
312 intc->cpus[boot_cpu]->map_base + reg_mask_set(intc, word)); in bcm7038_l1_suspend()
314 intc->cpus[boot_cpu]->map_base + reg_mask_clr(intc, word)); in bcm7038_l1_suspend()
324 int boot_cpu, word; in bcm7038_l1_resume()
333 for (word = 0; word < intc->n_words; word++) { in bcm7038_l1_resume()
334 l1_writel(intc->cpus[boot_cpu]->mask_cache[word], in bcm7038_l1_resume()
335 intc->cpus[boot_cpu]->map_base + reg_mask_set(intc, word)); in bcm7038_l1_resume()
336 l1_writel(~intc->cpus[boot_cpu]->mask_cache[word], in bcm7038_l1_resume()
337 intc->cpus[boot_cpu]->map_base + reg_mask_clr(intc, word)); in bcm7038_l1_resume()
347 static int bcm7038_l1_set_wake(struct irq_data *d, unsigned int on) in bcm7038_l1_set_wake()
351 u32 word = d->hwirq / IRQS_PER_WORD; in bcm7038_l1_set_wake()
352 u32 mask = BIT(d->hwirq % IRQS_PER_WORD); in bcm7038_l1_set_wake() local
354 raw_spin_lock_irqsave(&intc->lock, flags); in bcm7038_l1_set_wake()
356 intc->wake_mask[word] |= mask; in bcm7038_l1_set_wake()
358 intc->wake_mask[word] &= ~mask; in bcm7038_l1_set_wake()
359 raw_spin_unlock_irqrestore(&intc->lock, flags); in bcm7038_l1_set_wake()
366 .name = "bcm7038-l1",
377 static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq, in bcm7038_l1_map()
380 struct bcm7038_l1_chip *intc = d->host_data; in bcm7038_l1_map()
381 u32 mask = BIT(hw_irq % IRQS_PER_WORD); in bcm7038_l1_map() local
384 if (intc->irq_fwd_mask[word] & mask) in bcm7038_l1_map()
385 return -EPERM; in bcm7038_l1_map()
388 irq_set_chip_data(virq, d->host_data); in bcm7038_l1_map()
398 static int __init bcm7038_l1_of_init(struct device_node *dn, in bcm7038_l1_of_init()
402 int idx, ret; in bcm7038_l1_of_init()
406 return -ENOMEM; in bcm7038_l1_of_init()
408 raw_spin_lock_init(&intc->lock); in bcm7038_l1_of_init()
419 intc->domain = irq_domain_add_linear(dn, IRQS_PER_WORD * intc->n_words, in bcm7038_l1_of_init()
422 if (!intc->domain) { in bcm7038_l1_of_init()
423 ret = -ENOMEM; in bcm7038_l1_of_init()
430 list_add_tail(&intc->list, &bcm7038_l1_intcs_list); in bcm7038_l1_of_init()
438 dn, IRQS_PER_WORD * intc->n_words); in bcm7038_l1_of_init()
444 struct bcm7038_l1_cpu *cpu = intc->cpus[idx]; in bcm7038_l1_of_init()
447 if (cpu->map_base) in bcm7038_l1_of_init()
448 iounmap(cpu->map_base); in bcm7038_l1_of_init()
458 IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
460 MODULE_DESCRIPTION("Broadcom STB 7038-style L1/L2 interrupt controller");