Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Special GIC quirks for the ARM RealView |
| 4 | * Copyright (C) 2015 Linus Walleij |
| 5 | */ |
| 6 | #include <linux/of.h> |
| 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> |
| 12 | |
| 13 | #define REALVIEW_SYS_LOCK_OFFSET 0x20 |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 14 | #define REALVIEW_SYS_PLD_CTRL1 0x74 |
| 15 | #define REALVIEW_EB_REVB_SYS_PLD_CTRL1 0xD8 |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 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) |
| 22 | |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 23 | /* For some reason RealView EB Rev B moved this register */ |
| 24 | static const struct of_device_id syscon_pldset_of_match[] = { |
| 25 | { |
| 26 | .compatible = "arm,realview-eb11mp-revb-syscon", |
| 27 | .data = (void *)REALVIEW_EB_REVB_SYS_PLD_CTRL1, |
| 28 | }, |
| 29 | { |
| 30 | .compatible = "arm,realview-eb11mp-revc-syscon", |
| 31 | .data = (void *)REALVIEW_SYS_PLD_CTRL1, |
| 32 | }, |
| 33 | { |
| 34 | .compatible = "arm,realview-eb-syscon", |
| 35 | .data = (void *)REALVIEW_SYS_PLD_CTRL1, |
| 36 | }, |
| 37 | { |
| 38 | .compatible = "arm,realview-pb11mp-syscon", |
| 39 | .data = (void *)REALVIEW_SYS_PLD_CTRL1, |
| 40 | }, |
| 41 | {}, |
| 42 | }; |
| 43 | |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 44 | static int __init |
| 45 | realview_gic_of_init(struct device_node *node, struct device_node *parent) |
| 46 | { |
Julia Lawall | 512f9e79 | 2017-07-15 22:07:40 +0200 | [diff] [blame] | 47 | struct regmap *map; |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 48 | struct device_node *np; |
| 49 | const struct of_device_id *gic_id; |
| 50 | u32 pld1_ctrl; |
| 51 | |
| 52 | np = of_find_matching_node_and_match(NULL, syscon_pldset_of_match, |
| 53 | &gic_id); |
| 54 | if (!np) |
| 55 | return -ENODEV; |
| 56 | pld1_ctrl = (u32)gic_id->data; |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 57 | |
| 58 | /* The PB11MPCore GIC needs to be configured in the syscon */ |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 59 | map = syscon_node_to_regmap(np); |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 60 | if (!IS_ERR(map)) { |
| 61 | /* new irq mode with no DCC */ |
| 62 | regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, |
| 63 | VERSATILE_LOCK_VAL); |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 64 | regmap_update_bits(map, pld1_ctrl, |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 65 | PLD_INTMODE_NEW_NO_DCC, |
| 66 | PLD_INTMODE_MASK); |
| 67 | regmap_write(map, REALVIEW_SYS_LOCK_OFFSET, 0x0000); |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 68 | pr_info("RealView GIC: set up interrupt controller to NEW mode, no DCC\n"); |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 69 | } else { |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 70 | pr_err("RealView GIC setup: could not find syscon\n"); |
| 71 | return -ENODEV; |
Linus Walleij | 8673c1d | 2015-10-24 00:15:52 +0200 | [diff] [blame] | 72 | } |
| 73 | return gic_of_init(node, parent); |
| 74 | } |
| 75 | IRQCHIP_DECLARE(armtc11mp_gic, "arm,tc11mp-gic", realview_gic_of_init); |
Linus Walleij | 82b0a43 | 2016-02-22 15:01:01 +0100 | [diff] [blame] | 76 | IRQCHIP_DECLARE(armeb11mp_gic, "arm,eb11mp-gic", realview_gic_of_init); |