Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Special GIC quirks for the ARM RealView
0004  * Copyright (C) 2015 Linus Walleij
0005  */
0006 #include <linux/of.h>
0007 #include <linux/regmap.h>
0008 #include <linux/mfd/syscon.h>
0009 #include <linux/bitops.h>
0010 #include <linux/irqchip.h>
0011 #include <linux/irqchip/arm-gic.h>
0012 
0013 #define REALVIEW_SYS_LOCK_OFFSET    0x20
0014 #define REALVIEW_SYS_PLD_CTRL1      0x74
0015 #define REALVIEW_EB_REVB_SYS_PLD_CTRL1  0xD8
0016 #define VERSATILE_LOCK_VAL      0xA05F
0017 #define PLD_INTMODE_MASK        BIT(22)|BIT(23)|BIT(24)
0018 #define PLD_INTMODE_LEGACY      0x0
0019 #define PLD_INTMODE_NEW_DCC     BIT(22)
0020 #define PLD_INTMODE_NEW_NO_DCC      BIT(23)
0021 #define PLD_INTMODE_FIQ_ENABLE      BIT(24)
0022 
0023 /* For some reason RealView EB Rev B moved this register */
0024 static const struct of_device_id syscon_pldset_of_match[] = {
0025     {
0026         .compatible = "arm,realview-eb11mp-revb-syscon",
0027         .data = (void *)REALVIEW_EB_REVB_SYS_PLD_CTRL1,
0028     },
0029     {
0030         .compatible = "arm,realview-eb11mp-revc-syscon",
0031         .data = (void *)REALVIEW_SYS_PLD_CTRL1,
0032     },
0033     {
0034         .compatible = "arm,realview-eb-syscon",
0035         .data = (void *)REALVIEW_SYS_PLD_CTRL1,
0036     },
0037     {
0038         .compatible = "arm,realview-pb11mp-syscon",
0039         .data = (void *)REALVIEW_SYS_PLD_CTRL1,
0040     },
0041     {},
0042 };
0043 
0044 static int __init
0045 realview_gic_of_init(struct device_node *node, struct device_node *parent)
0046 {
0047     struct regmap *map;
0048     struct device_node *np;
0049     const struct of_device_id *gic_id;
0050     u32 pld1_ctrl;
0051 
0052     np = of_find_matching_node_and_match(NULL, syscon_pldset_of_match,
0053                          &gic_id);
0054     if (!np)
0055         return -ENODEV;
0056     pld1_ctrl = (u32)gic_id->data;
0057 
0058     /* The PB11MPCore GIC needs to be configured in the syscon */
0059     map = syscon_node_to_regmap(np);
0060     of_node_put(np);
0061     if (!IS_ERR(map)) {
0062         /* new irq mode with no DCC */
0063         regmap_write(map, REALVIEW_SYS_LOCK_OFFSET,
0064                  VERSATILE_LOCK_VAL);
0065         regmap_update_bits(map, pld1_ctrl,
0066                    PLD_INTMODE_NEW_NO_DCC,
0067                    PLD_INTMODE_MASK);
0068         regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, 0x0000);
0069         pr_info("RealView GIC: set up interrupt controller to NEW mode, no DCC\n");
0070     } else {
0071         pr_err("RealView GIC setup: could not find syscon\n");
0072         return -ENODEV;
0073     }
0074     return gic_of_init(node, parent);
0075 }
0076 IRQCHIP_DECLARE(armtc11mp_gic, "arm,tc11mp-gic", realview_gic_of_init);
0077 IRQCHIP_DECLARE(armeb11mp_gic, "arm,eb11mp-gic", realview_gic_of_init);