Lines Matching full:gic
5 * Interrupt architecture for the GIC:
42 #include <linux/irqchip/arm-gic.h>
50 #include "irq-gic-common.h"
114 * The GIC mapping of CPU interfaces does not necessarily match
116 * by the GIC itself.
312 pr_warn("GIC: PPI%d is secure or misconfigured\n", gicirq - 16); in gic_set_type()
321 /* Only interrupts on the primary GIC can be forwarded to a vcpu. */ in gic_irq_set_vcpu_affinity()
340 struct gic_chip_data *gic = &gic_data[0]; in gic_handle_irq() local
341 void __iomem *cpu_base = gic_data_cpu_base(gic); in gic_handle_irq()
356 * is read after we've read the ACK register on the GIC. in gic_handle_irq()
364 * The GIC encodes the source CPU in GICC_IAR, in gic_handle_irq()
373 generic_handle_domain_irq(gic->domain, irqnr); in gic_handle_irq()
403 struct gic_chip_data *gic = irq_data_get_irq_chip_data(d); in gic_irq_print_chip() local
405 if (gic->domain->pm_dev) in gic_irq_print_chip()
406 seq_printf(p, gic->domain->pm_dev->of_node->name); in gic_irq_print_chip()
408 seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0])); in gic_irq_print_chip()
418 static u8 gic_get_cpumask(struct gic_chip_data *gic) in gic_get_cpumask() argument
420 void __iomem *base = gic_data_dist_base(gic); in gic_get_cpumask()
432 pr_crit("GIC CPU mask not found - kernel will fail to boot.\n"); in gic_get_cpumask()
443 static void gic_cpu_if_up(struct gic_chip_data *gic) in gic_cpu_if_up() argument
445 void __iomem *cpu_base = gic_data_cpu_base(gic); in gic_cpu_if_up()
450 if (gic == &gic_data[0] && static_branch_likely(&supports_deactivate_key)) in gic_cpu_if_up()
467 static void gic_dist_init(struct gic_chip_data *gic) in gic_dist_init() argument
471 unsigned int gic_irqs = gic->gic_irqs; in gic_dist_init()
472 void __iomem *base = gic_data_dist_base(gic); in gic_dist_init()
479 cpumask = gic_get_cpumask(gic); in gic_dist_init()
490 static int gic_cpu_init(struct gic_chip_data *gic) in gic_cpu_init() argument
492 void __iomem *dist_base = gic_data_dist_base(gic); in gic_cpu_init()
493 void __iomem *base = gic_data_cpu_base(gic); in gic_cpu_init()
498 * Setting up the CPU map is only relevant for the primary GIC in gic_cpu_init()
502 if (gic == &gic_data[0]) { in gic_cpu_init()
504 * Get what the GIC says our CPU mask is. in gic_cpu_init()
510 cpu_mask = gic_get_cpumask(gic); in gic_cpu_init()
525 gic_cpu_if_up(gic); in gic_cpu_init()
548 * Saves the GIC distributor registers during suspend or idle. Must be called
549 * with interrupts disabled but before powering down the GIC. After calling
550 * this function, no interrupts will be delivered by the GIC, and another
553 void gic_dist_save(struct gic_chip_data *gic) in gic_dist_save() argument
559 if (WARN_ON(!gic)) in gic_dist_save()
562 gic_irqs = gic->gic_irqs; in gic_dist_save()
563 dist_base = gic_data_dist_base(gic); in gic_dist_save()
569 gic->saved_spi_conf[i] = in gic_dist_save()
573 gic->saved_spi_target[i] = in gic_dist_save()
577 gic->saved_spi_enable[i] = in gic_dist_save()
581 gic->saved_spi_active[i] = in gic_dist_save()
586 * Restores the GIC distributor registers during resume or when coming out of
588 * that occurred while the GIC was suspended is still present, it will be
590 * the GIC and need to be handled by the platform-specific wakeup source.
592 void gic_dist_restore(struct gic_chip_data *gic) in gic_dist_restore() argument
598 if (WARN_ON(!gic)) in gic_dist_restore()
601 gic_irqs = gic->gic_irqs; in gic_dist_restore()
602 dist_base = gic_data_dist_base(gic); in gic_dist_restore()
610 writel_relaxed(gic->saved_spi_conf[i], in gic_dist_restore()
618 writel_relaxed(gic->saved_spi_target[i], in gic_dist_restore()
624 writel_relaxed(gic->saved_spi_enable[i], in gic_dist_restore()
631 writel_relaxed(gic->saved_spi_active[i], in gic_dist_restore()
638 void gic_cpu_save(struct gic_chip_data *gic) in gic_cpu_save() argument
645 if (WARN_ON(!gic)) in gic_cpu_save()
648 dist_base = gic_data_dist_base(gic); in gic_cpu_save()
649 cpu_base = gic_data_cpu_base(gic); in gic_cpu_save()
654 ptr = raw_cpu_ptr(gic->saved_ppi_enable); in gic_cpu_save()
658 ptr = raw_cpu_ptr(gic->saved_ppi_active); in gic_cpu_save()
662 ptr = raw_cpu_ptr(gic->saved_ppi_conf); in gic_cpu_save()
668 void gic_cpu_restore(struct gic_chip_data *gic) in gic_cpu_restore() argument
675 if (WARN_ON(!gic)) in gic_cpu_restore()
678 dist_base = gic_data_dist_base(gic); in gic_cpu_restore()
679 cpu_base = gic_data_cpu_base(gic); in gic_cpu_restore()
684 ptr = raw_cpu_ptr(gic->saved_ppi_enable); in gic_cpu_restore()
691 ptr = raw_cpu_ptr(gic->saved_ppi_active); in gic_cpu_restore()
698 ptr = raw_cpu_ptr(gic->saved_ppi_conf); in gic_cpu_restore()
707 gic_cpu_if_up(gic); in gic_cpu_restore()
740 static int gic_pm_init(struct gic_chip_data *gic) in gic_pm_init() argument
742 gic->saved_ppi_enable = __alloc_percpu(DIV_ROUND_UP(32, 32) * 4, in gic_pm_init()
744 if (WARN_ON(!gic->saved_ppi_enable)) in gic_pm_init()
747 gic->saved_ppi_active = __alloc_percpu(DIV_ROUND_UP(32, 32) * 4, in gic_pm_init()
749 if (WARN_ON(!gic->saved_ppi_active)) in gic_pm_init()
752 gic->saved_ppi_conf = __alloc_percpu(DIV_ROUND_UP(32, 16) * 4, in gic_pm_init()
754 if (WARN_ON(!gic->saved_ppi_conf)) in gic_pm_init()
757 if (gic == &gic_data[0]) in gic_pm_init()
763 free_percpu(gic->saved_ppi_active); in gic_pm_init()
765 free_percpu(gic->saved_ppi_enable); in gic_pm_init()
770 static int gic_pm_init(struct gic_chip_data *gic) in gic_pm_init() argument
800 struct gic_chip_data *gic = irq_data_get_irq_chip_data(d); in gic_set_affinity() local
803 if (unlikely(gic != &gic_data[0])) in gic_set_affinity()
868 "irqchip/arm/gic:starting", in gic_smp_init()
934 * @cpu: the logical CPU number to get the GIC ID for.
1047 pr_info("GIC physical location is %#lx\n", gic_dist_physaddr); in gic_init_physaddr()
1058 struct gic_chip_data *gic = d->host_data; in gic_irq_domain_map() local
1063 gic == &gic_data[0]) ? &gic_chip_mode1 : &gic_chip; in gic_irq_domain_map()
1166 static int gic_init_bases(struct gic_chip_data *gic, in gic_init_bases() argument
1171 if (IS_ENABLED(CONFIG_GIC_NON_BANKED) && gic->percpu_offset) { in gic_init_bases()
1172 /* Frankein-GIC without banked registers... */ in gic_init_bases()
1175 gic->dist_base.percpu_base = alloc_percpu(void __iomem *); in gic_init_bases()
1176 gic->cpu_base.percpu_base = alloc_percpu(void __iomem *); in gic_init_bases()
1177 if (WARN_ON(!gic->dist_base.percpu_base || in gic_init_bases()
1178 !gic->cpu_base.percpu_base)) { in gic_init_bases()
1186 unsigned long offset = gic->percpu_offset * core_id; in gic_init_bases()
1187 *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = in gic_init_bases()
1188 gic->raw_dist_base + offset; in gic_init_bases()
1189 *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = in gic_init_bases()
1190 gic->raw_cpu_base + offset; in gic_init_bases()
1195 /* Normal, sane GIC... */ in gic_init_bases()
1196 WARN(gic->percpu_offset, in gic_init_bases()
1198 gic->percpu_offset); in gic_init_bases()
1199 gic->dist_base.common_base = gic->raw_dist_base; in gic_init_bases()
1200 gic->cpu_base.common_base = gic->raw_cpu_base; in gic_init_bases()
1205 * The GIC only supports up to 1020 interrupt sources. in gic_init_bases()
1207 gic_irqs = readl_relaxed(gic_data_dist_base(gic) + GIC_DIST_CTR) & 0x1f; in gic_init_bases()
1211 gic->gic_irqs = gic_irqs; in gic_init_bases()
1213 gic->domain = irq_domain_create_linear(handle, gic_irqs, in gic_init_bases()
1215 gic); in gic_init_bases()
1216 if (WARN_ON(!gic->domain)) { in gic_init_bases()
1221 gic_dist_init(gic); in gic_init_bases()
1222 ret = gic_cpu_init(gic); in gic_init_bases()
1226 ret = gic_pm_init(gic); in gic_init_bases()
1233 if (IS_ENABLED(CONFIG_GIC_NON_BANKED) && gic->percpu_offset) { in gic_init_bases()
1234 free_percpu(gic->dist_base.percpu_base); in gic_init_bases()
1235 free_percpu(gic->cpu_base.percpu_base); in gic_init_bases()
1241 static int __init __gic_init_bases(struct gic_chip_data *gic, in __gic_init_bases() argument
1246 if (WARN_ON(!gic || gic->domain)) in __gic_init_bases()
1249 if (gic == &gic_data[0]) { in __gic_init_bases()
1253 * This is only necessary for the primary GIC. in __gic_init_bases()
1260 pr_info("GIC: Using split EOI/Deactivate mode\n"); in __gic_init_bases()
1263 ret = gic_init_bases(gic, handle); in __gic_init_bases()
1264 if (gic == &gic_data[0]) in __gic_init_bases()
1270 static void gic_teardown(struct gic_chip_data *gic) in gic_teardown() argument
1272 if (WARN_ON(!gic)) in gic_teardown()
1275 if (gic->raw_dist_base) in gic_teardown()
1276 iounmap(gic->raw_dist_base); in gic_teardown()
1277 if (gic->raw_cpu_base) in gic_teardown()
1278 iounmap(gic->raw_cpu_base); in gic_teardown()
1308 pr_warn("GIC: GICv2 detected, but range too small and irqchip.gicv2_force_probe not set\n"); in gic_check_eoimode()
1321 pr_warn("GIC: GICv2 at %pa, but range is too small (broken DT?), assuming 8kB\n", in gic_check_eoimode()
1338 pr_warn("GIC: Aliased GICv2 at %pa, trying to find the canonical range over 128kB\n", in gic_check_eoimode()
1361 pr_warn("GIC: Adjusting CPU interface base to %pa\n", in gic_check_eoimode()
1392 static int gic_of_setup(struct gic_chip_data *gic, struct device_node *node) in gic_of_setup() argument
1394 if (!gic || !node) in gic_of_setup()
1397 gic->raw_dist_base = of_iomap(node, 0); in gic_of_setup()
1398 if (WARN(!gic->raw_dist_base, "unable to map gic dist registers\n")) in gic_of_setup()
1401 gic->raw_cpu_base = of_iomap(node, 1); in gic_of_setup()
1402 if (WARN(!gic->raw_cpu_base, "unable to map gic cpu registers\n")) in gic_of_setup()
1405 if (of_property_read_u32(node, "cpu-offset", &gic->percpu_offset)) in gic_of_setup()
1406 gic->percpu_offset = 0; in gic_of_setup()
1408 gic_enable_of_quirks(node, gic_quirks, gic); in gic_of_setup()
1413 gic_teardown(gic); in gic_of_setup()
1418 int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq) in gic_of_init_child() argument
1422 if (!dev || !dev->of_node || !gic || !irq) in gic_of_init_child()
1425 *gic = devm_kzalloc(dev, sizeof(**gic), GFP_KERNEL); in gic_of_init_child()
1426 if (!*gic) in gic_of_init_child()
1429 ret = gic_of_setup(*gic, dev->of_node); in gic_of_init_child()
1433 ret = gic_init_bases(*gic, &dev->of_node->fwnode); in gic_of_init_child()
1435 gic_teardown(*gic); in gic_of_init_child()
1439 irq_domain_set_pm_device((*gic)->domain, dev); in gic_of_init_child()
1440 irq_set_chained_handler_and_data(irq, gic_handle_cascade_irq, *gic); in gic_of_init_child()
1472 struct gic_chip_data *gic; in gic_of_init() local
1481 gic = &gic_data[gic_cnt]; in gic_of_init()
1483 ret = gic_of_setup(gic, node); in gic_of_init()
1491 if (gic_cnt == 0 && !gic_check_eoimode(node, &gic->raw_cpu_base)) in gic_of_init()
1494 ret = __gic_init_bases(gic, &node->fwnode); in gic_of_init()
1496 gic_teardown(gic); in gic_of_init()
1516 IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);
1517 IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);
1518 IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);
1519 IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);
1520 IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);
1521 IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);
1641 struct gic_chip_data *gic = &gic_data[0]; in gic_v2_acpi_init() local
1652 gic->raw_cpu_base = ioremap(acpi_data.cpu_phys_base, ACPI_GIC_CPU_IF_MEM_SIZE); in gic_v2_acpi_init()
1653 if (!gic->raw_cpu_base) { in gic_v2_acpi_init()
1659 gic->raw_dist_base = ioremap(dist->base_address, in gic_v2_acpi_init()
1661 if (!gic->raw_dist_base) { in gic_v2_acpi_init()
1663 gic_teardown(gic); in gic_v2_acpi_init()
1676 * Initialize GIC instance zero (no multi-GIC support). in gic_v2_acpi_init()
1681 gic_teardown(gic); in gic_v2_acpi_init()
1685 ret = __gic_init_bases(gic, gsi_domain_handle); in gic_v2_acpi_init()
1687 pr_err("Failed to initialise GIC\n"); in gic_v2_acpi_init()
1689 gic_teardown(gic); in gic_v2_acpi_init()