1 // SPDX-License-Identifier: GPL-2.0
3 * Special GIC quirks for the ARM RealView
4 * Copyright (C) 2015 Linus Walleij
7 #include <linux/regmap.h>
8 #include <linux/mfd/syscon.h>
9 #include <linux/bitops.h>
10 #include <linux/irqchip.h>
11 #include <linux/irqchip/arm-gic.h>
13 #define REALVIEW_SYS_LOCK_OFFSET 0x20
14 #define REALVIEW_SYS_PLD_CTRL1 0x74
15 #define REALVIEW_EB_REVB_SYS_PLD_CTRL1 0xD8
16 #define VERSATILE_LOCK_VAL 0xA05F
17 #define PLD_INTMODE_MASK BIT(22)|BIT(23)|BIT(24)
18 #define PLD_INTMODE_LEGACY 0x0
19 #define PLD_INTMODE_NEW_DCC BIT(22)
20 #define PLD_INTMODE_NEW_NO_DCC BIT(23)
21 #define PLD_INTMODE_FIQ_ENABLE BIT(24)
23 /* For some reason RealView EB Rev B moved this register */
24 static const struct of_device_id syscon_pldset_of_match[] = {
26 .compatible = "arm,realview-eb11mp-revb-syscon",
27 .data = (void *)REALVIEW_EB_REVB_SYS_PLD_CTRL1,
30 .compatible = "arm,realview-eb11mp-revc-syscon",
31 .data = (void *)REALVIEW_SYS_PLD_CTRL1,
34 .compatible = "arm,realview-eb-syscon",
35 .data = (void *)REALVIEW_SYS_PLD_CTRL1,
38 .compatible = "arm,realview-pb11mp-syscon",
39 .data = (void *)REALVIEW_SYS_PLD_CTRL1,
45 realview_gic_of_init(struct device_node *node, struct device_node *parent)
48 struct device_node *np;
49 const struct of_device_id *gic_id;
52 np = of_find_matching_node_and_match(NULL, syscon_pldset_of_match,
56 pld1_ctrl = (u32)gic_id->data;
58 /* The PB11MPCore GIC needs to be configured in the syscon */
59 map = syscon_node_to_regmap(np);
61 /* new irq mode with no DCC */
62 regmap_write(map, REALVIEW_SYS_LOCK_OFFSET,
64 regmap_update_bits(map, pld1_ctrl,
65 PLD_INTMODE_NEW_NO_DCC,
67 regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, 0x0000);
68 pr_info("RealView GIC: set up interrupt controller to NEW mode, no DCC\n");
70 pr_err("RealView GIC setup: could not find syscon\n");
73 return gic_of_init(node, parent);
75 IRQCHIP_DECLARE(armtc11mp_gic, "arm,tc11mp-gic", realview_gic_of_init);
76 IRQCHIP_DECLARE(armeb11mp_gic, "arm,eb11mp-gic", realview_gic_of_init);