Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Armada 370 and Armada XP SoC IRQ handling |
| 3 | * |
| 4 | * Copyright (C) 2012 Marvell |
| 5 | * |
| 6 | * Lior Amsalem <alior@marvell.com> |
| 7 | * Gregory CLEMENT <gregory.clement@free-electrons.com> |
| 8 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| 9 | * Ben Dooks <ben.dooks@codethink.co.uk> |
| 10 | * |
| 11 | * This file is licensed under the terms of the GNU General Public |
| 12 | * License version 2. This program is licensed "as is" without any |
| 13 | * warranty of any kind, whether express or implied. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/interrupt.h> |
Joel Porquet | 41a83e06 | 2015-07-07 17:11:46 -0400 | [diff] [blame] | 21 | #include <linux/irqchip.h> |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 22 | #include <linux/irqchip/chained_irq.h> |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 23 | #include <linux/cpu.h> |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 24 | #include <linux/io.h> |
| 25 | #include <linux/of_address.h> |
| 26 | #include <linux/of_irq.h> |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 27 | #include <linux/of_pci.h> |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 28 | #include <linux/irqdomain.h> |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 29 | #include <linux/slab.h> |
Thomas Petazzoni | 0f077eb | 2014-11-21 17:00:00 +0100 | [diff] [blame] | 30 | #include <linux/syscore_ops.h> |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 31 | #include <linux/msi.h> |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/exception.h> |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 34 | #include <asm/smp_plat.h> |
Thomas Petazzoni | 9339d43 | 2013-04-09 23:26:15 +0200 | [diff] [blame] | 35 | #include <asm/mach/irq.h> |
| 36 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 37 | /* Interrupt Controller Registers Map */ |
| 38 | #define ARMADA_370_XP_INT_SET_MASK_OFFS (0x48) |
| 39 | #define ARMADA_370_XP_INT_CLEAR_MASK_OFFS (0x4C) |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 40 | #define ARMADA_370_XP_INT_FABRIC_MASK_OFFS (0x54) |
| 41 | #define ARMADA_370_XP_INT_CAUSE_PERF(cpu) (1 << cpu) |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 42 | |
Ben Dooks | f3e16cc | 2012-06-04 18:50:12 +0200 | [diff] [blame] | 43 | #define ARMADA_370_XP_INT_CONTROL (0x00) |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 44 | #define ARMADA_370_XP_INT_SET_ENABLE_OFFS (0x30) |
| 45 | #define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34) |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 46 | #define ARMADA_370_XP_INT_SOURCE_CTL(irq) (0x100 + irq*4) |
Thomas Gleixner | 8cc3cfc | 2014-03-04 20:43:41 +0000 | [diff] [blame] | 47 | #define ARMADA_370_XP_INT_SOURCE_CPU_MASK 0xF |
Grzegorz Jaszczyk | 758e836 | 2014-09-25 13:17:19 +0200 | [diff] [blame] | 48 | #define ARMADA_370_XP_INT_IRQ_FIQ_MASK(cpuid) ((BIT(0) | BIT(8)) << cpuid) |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 49 | |
| 50 | #define ARMADA_370_XP_CPU_INTACK_OFFS (0x44) |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 51 | #define ARMADA_375_PPI_CAUSE (0x10) |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 52 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 53 | #define ARMADA_370_XP_SW_TRIG_INT_OFFS (0x4) |
| 54 | #define ARMADA_370_XP_IN_DRBEL_MSK_OFFS (0xc) |
| 55 | #define ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS (0x8) |
| 56 | |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 57 | #define ARMADA_370_XP_MAX_PER_CPU_IRQS (28) |
| 58 | |
Gregory CLEMENT | 7f23f62 | 2013-03-20 16:09:35 +0100 | [diff] [blame] | 59 | #define ARMADA_370_XP_TIMER0_PER_CPU_IRQ (5) |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 60 | #define ARMADA_370_XP_FABRIC_IRQ (3) |
Gregory CLEMENT | 7f23f62 | 2013-03-20 16:09:35 +0100 | [diff] [blame] | 61 | |
Thomas Petazzoni | 5ec6901 | 2013-04-09 23:26:17 +0200 | [diff] [blame] | 62 | #define IPI_DOORBELL_START (0) |
| 63 | #define IPI_DOORBELL_END (8) |
| 64 | #define IPI_DOORBELL_MASK 0xFF |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 65 | #define PCI_MSI_DOORBELL_START (16) |
| 66 | #define PCI_MSI_DOORBELL_NR (16) |
| 67 | #define PCI_MSI_DOORBELL_END (32) |
| 68 | #define PCI_MSI_DOORBELL_MASK 0xFFFF0000 |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 69 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 70 | static void __iomem *per_cpu_int_base; |
| 71 | static void __iomem *main_int_base; |
| 72 | static struct irq_domain *armada_370_xp_mpic_domain; |
Thomas Petazzoni | 0f077eb | 2014-11-21 17:00:00 +0100 | [diff] [blame] | 73 | static u32 doorbell_mask_reg; |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 74 | static int parent_irq; |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 75 | #ifdef CONFIG_PCI_MSI |
| 76 | static struct irq_domain *armada_370_xp_msi_domain; |
| 77 | static DECLARE_BITMAP(msi_used, PCI_MSI_DOORBELL_NR); |
| 78 | static DEFINE_MUTEX(msi_used_lock); |
| 79 | static phys_addr_t msi_doorbell_addr; |
| 80 | #endif |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 81 | |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 82 | static inline bool is_percpu_irq(irq_hw_number_t irq) |
| 83 | { |
| 84 | switch (irq) { |
| 85 | case ARMADA_370_XP_TIMER0_PER_CPU_IRQ: |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 86 | case ARMADA_370_XP_FABRIC_IRQ: |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 87 | return true; |
| 88 | default: |
| 89 | return false; |
| 90 | } |
| 91 | } |
| 92 | |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 93 | /* |
| 94 | * In SMP mode: |
| 95 | * For shared global interrupts, mask/unmask global enable bit |
Marek Belisko | 097ef18 | 2013-03-15 23:34:04 +0100 | [diff] [blame] | 96 | * For CPU interrupts, mask/unmask the calling CPU's bit |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 97 | */ |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 98 | static void armada_370_xp_irq_mask(struct irq_data *d) |
| 99 | { |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 100 | irq_hw_number_t hwirq = irqd_to_hwirq(d); |
| 101 | |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 102 | if (!is_percpu_irq(hwirq)) |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 103 | writel(hwirq, main_int_base + |
| 104 | ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS); |
| 105 | else |
| 106 | writel(hwirq, per_cpu_int_base + |
| 107 | ARMADA_370_XP_INT_SET_MASK_OFFS); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | static void armada_370_xp_irq_unmask(struct irq_data *d) |
| 111 | { |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 112 | irq_hw_number_t hwirq = irqd_to_hwirq(d); |
| 113 | |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 114 | if (!is_percpu_irq(hwirq)) |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 115 | writel(hwirq, main_int_base + |
| 116 | ARMADA_370_XP_INT_SET_ENABLE_OFFS); |
| 117 | else |
| 118 | writel(hwirq, per_cpu_int_base + |
| 119 | ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 120 | } |
| 121 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 122 | #ifdef CONFIG_PCI_MSI |
| 123 | |
| 124 | static int armada_370_xp_alloc_msi(void) |
| 125 | { |
| 126 | int hwirq; |
| 127 | |
| 128 | mutex_lock(&msi_used_lock); |
| 129 | hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR); |
| 130 | if (hwirq >= PCI_MSI_DOORBELL_NR) |
| 131 | hwirq = -ENOSPC; |
| 132 | else |
| 133 | set_bit(hwirq, msi_used); |
| 134 | mutex_unlock(&msi_used_lock); |
| 135 | |
| 136 | return hwirq; |
| 137 | } |
| 138 | |
| 139 | static void armada_370_xp_free_msi(int hwirq) |
| 140 | { |
| 141 | mutex_lock(&msi_used_lock); |
| 142 | if (!test_bit(hwirq, msi_used)) |
| 143 | pr_err("trying to free unused MSI#%d\n", hwirq); |
| 144 | else |
| 145 | clear_bit(hwirq, msi_used); |
| 146 | mutex_unlock(&msi_used_lock); |
| 147 | } |
| 148 | |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 149 | static int armada_370_xp_setup_msi_irq(struct msi_controller *chip, |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 150 | struct pci_dev *pdev, |
| 151 | struct msi_desc *desc) |
| 152 | { |
| 153 | struct msi_msg msg; |
Thomas Petazzoni | da343fc | 2014-04-18 14:19:47 +0200 | [diff] [blame] | 154 | int virq, hwirq; |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 155 | |
Alexander Gordeev | 3930115 | 2014-09-07 20:57:54 +0200 | [diff] [blame] | 156 | /* We support MSI, but not MSI-X */ |
| 157 | if (desc->msi_attrib.is_msix) |
| 158 | return -EINVAL; |
| 159 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 160 | hwirq = armada_370_xp_alloc_msi(); |
| 161 | if (hwirq < 0) |
| 162 | return hwirq; |
| 163 | |
| 164 | virq = irq_create_mapping(armada_370_xp_msi_domain, hwirq); |
| 165 | if (!virq) { |
| 166 | armada_370_xp_free_msi(hwirq); |
| 167 | return -EINVAL; |
| 168 | } |
| 169 | |
| 170 | irq_set_msi_desc(virq, desc); |
| 171 | |
| 172 | msg.address_lo = msi_doorbell_addr; |
| 173 | msg.address_hi = 0; |
| 174 | msg.data = 0xf00 | (hwirq + 16); |
| 175 | |
Jiang Liu | 83a1891 | 2014-11-09 23:10:34 +0800 | [diff] [blame] | 176 | pci_write_msi_msg(virq, &msg); |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 177 | return 0; |
| 178 | } |
| 179 | |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 180 | static void armada_370_xp_teardown_msi_irq(struct msi_controller *chip, |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 181 | unsigned int irq) |
| 182 | { |
| 183 | struct irq_data *d = irq_get_irq_data(irq); |
Neil Greatorex | ff3c664 | 2014-04-18 14:19:49 +0200 | [diff] [blame] | 184 | unsigned long hwirq = d->hwirq; |
| 185 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 186 | irq_dispose_mapping(irq); |
Neil Greatorex | ff3c664 | 2014-04-18 14:19:49 +0200 | [diff] [blame] | 187 | armada_370_xp_free_msi(hwirq); |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | static struct irq_chip armada_370_xp_msi_irq_chip = { |
| 191 | .name = "armada_370_xp_msi_irq", |
Thomas Gleixner | 280510f | 2014-11-23 12:23:20 +0100 | [diff] [blame] | 192 | .irq_enable = pci_msi_unmask_irq, |
| 193 | .irq_disable = pci_msi_mask_irq, |
| 194 | .irq_mask = pci_msi_mask_irq, |
| 195 | .irq_unmask = pci_msi_unmask_irq, |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | static int armada_370_xp_msi_map(struct irq_domain *domain, unsigned int virq, |
| 199 | irq_hw_number_t hw) |
| 200 | { |
| 201 | irq_set_chip_and_handler(virq, &armada_370_xp_msi_irq_chip, |
| 202 | handle_simple_irq); |
| 203 | set_irq_flags(virq, IRQF_VALID); |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static const struct irq_domain_ops armada_370_xp_msi_irq_ops = { |
| 209 | .map = armada_370_xp_msi_map, |
| 210 | }; |
| 211 | |
| 212 | static int armada_370_xp_msi_init(struct device_node *node, |
| 213 | phys_addr_t main_int_phys_base) |
| 214 | { |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 215 | struct msi_controller *msi_chip; |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 216 | u32 reg; |
| 217 | int ret; |
| 218 | |
| 219 | msi_doorbell_addr = main_int_phys_base + |
| 220 | ARMADA_370_XP_SW_TRIG_INT_OFFS; |
| 221 | |
| 222 | msi_chip = kzalloc(sizeof(*msi_chip), GFP_KERNEL); |
| 223 | if (!msi_chip) |
| 224 | return -ENOMEM; |
| 225 | |
| 226 | msi_chip->setup_irq = armada_370_xp_setup_msi_irq; |
| 227 | msi_chip->teardown_irq = armada_370_xp_teardown_msi_irq; |
| 228 | msi_chip->of_node = node; |
| 229 | |
| 230 | armada_370_xp_msi_domain = |
| 231 | irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR, |
| 232 | &armada_370_xp_msi_irq_ops, |
| 233 | NULL); |
| 234 | if (!armada_370_xp_msi_domain) { |
| 235 | kfree(msi_chip); |
| 236 | return -ENOMEM; |
| 237 | } |
| 238 | |
| 239 | ret = of_pci_msi_chip_add(msi_chip); |
| 240 | if (ret < 0) { |
| 241 | irq_domain_remove(armada_370_xp_msi_domain); |
| 242 | kfree(msi_chip); |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | reg = readl(per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS) |
| 247 | | PCI_MSI_DOORBELL_MASK; |
| 248 | |
| 249 | writel(reg, per_cpu_int_base + |
| 250 | ARMADA_370_XP_IN_DRBEL_MSK_OFFS); |
| 251 | |
| 252 | /* Unmask IPI interrupt */ |
| 253 | writel(1, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | #else |
| 258 | static inline int armada_370_xp_msi_init(struct device_node *node, |
| 259 | phys_addr_t main_int_phys_base) |
| 260 | { |
| 261 | return 0; |
| 262 | } |
| 263 | #endif |
| 264 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 265 | #ifdef CONFIG_SMP |
Arnaud Ebalard | 19e61d4 | 2014-01-20 22:52:05 +0100 | [diff] [blame] | 266 | static DEFINE_RAW_SPINLOCK(irq_controller_lock); |
| 267 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 268 | static int armada_xp_set_affinity(struct irq_data *d, |
| 269 | const struct cpumask *mask_val, bool force) |
| 270 | { |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 271 | irq_hw_number_t hwirq = irqd_to_hwirq(d); |
Thomas Gleixner | 8cc3cfc | 2014-03-04 20:43:41 +0000 | [diff] [blame] | 272 | unsigned long reg, mask; |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 273 | int cpu; |
| 274 | |
Thomas Gleixner | 8cc3cfc | 2014-03-04 20:43:41 +0000 | [diff] [blame] | 275 | /* Select a single core from the affinity mask which is online */ |
| 276 | cpu = cpumask_any_and(mask_val, cpu_online_mask); |
| 277 | mask = 1UL << cpu_logical_map(cpu); |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 278 | |
| 279 | raw_spin_lock(&irq_controller_lock); |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 280 | reg = readl(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq)); |
Thomas Gleixner | 8cc3cfc | 2014-03-04 20:43:41 +0000 | [diff] [blame] | 281 | reg = (reg & (~ARMADA_370_XP_INT_SOURCE_CPU_MASK)) | mask; |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 282 | writel(reg, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq)); |
Gregory CLEMENT | 3202bf0 | 2012-12-05 21:43:23 +0100 | [diff] [blame] | 283 | raw_spin_unlock(&irq_controller_lock); |
| 284 | |
Thomas Petazzoni | 1dacf19 | 2014-10-24 13:59:16 +0200 | [diff] [blame] | 285 | return IRQ_SET_MASK_OK; |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 286 | } |
| 287 | #endif |
| 288 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 289 | static struct irq_chip armada_370_xp_irq_chip = { |
| 290 | .name = "armada_370_xp_irq", |
| 291 | .irq_mask = armada_370_xp_irq_mask, |
| 292 | .irq_mask_ack = armada_370_xp_irq_mask, |
| 293 | .irq_unmask = armada_370_xp_irq_unmask, |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 294 | #ifdef CONFIG_SMP |
| 295 | .irq_set_affinity = armada_xp_set_affinity, |
| 296 | #endif |
Gregory CLEMENT | 0d8e1d8 | 2015-03-30 16:04:37 +0200 | [diff] [blame] | 297 | .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND, |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | static int armada_370_xp_mpic_irq_map(struct irq_domain *h, |
| 301 | unsigned int virq, irq_hw_number_t hw) |
| 302 | { |
| 303 | armada_370_xp_irq_mask(irq_get_irq_data(virq)); |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 304 | if (!is_percpu_irq(hw)) |
Gregory CLEMENT | 600468d | 2013-04-05 14:32:52 +0200 | [diff] [blame] | 305 | writel(hw, per_cpu_int_base + |
| 306 | ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 307 | else |
| 308 | writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 309 | irq_set_status_flags(virq, IRQ_LEVEL); |
Gregory CLEMENT | 3a6f08a | 2013-01-25 18:32:41 +0100 | [diff] [blame] | 310 | |
Ezequiel Garcia | 2c299de | 2015-03-03 11:43:15 +0100 | [diff] [blame] | 311 | if (is_percpu_irq(hw)) { |
Gregory CLEMENT | 3a6f08a | 2013-01-25 18:32:41 +0100 | [diff] [blame] | 312 | irq_set_percpu_devid(virq); |
| 313 | irq_set_chip_and_handler(virq, &armada_370_xp_irq_chip, |
| 314 | handle_percpu_devid_irq); |
| 315 | |
| 316 | } else { |
| 317 | irq_set_chip_and_handler(virq, &armada_370_xp_irq_chip, |
| 318 | handle_level_irq); |
| 319 | } |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 320 | set_irq_flags(virq, IRQF_VALID | IRQF_PROBE); |
| 321 | |
| 322 | return 0; |
| 323 | } |
| 324 | |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 325 | static void armada_xp_mpic_smp_cpu_init(void) |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 326 | { |
Thomas Petazzoni | b73842b | 2014-05-30 22:18:18 +0200 | [diff] [blame] | 327 | u32 control; |
| 328 | int nr_irqs, i; |
| 329 | |
| 330 | control = readl(main_int_base + ARMADA_370_XP_INT_CONTROL); |
| 331 | nr_irqs = (control >> 2) & 0x3ff; |
| 332 | |
| 333 | for (i = 0; i < nr_irqs; i++) |
| 334 | writel(i, per_cpu_int_base + ARMADA_370_XP_INT_SET_MASK_OFFS); |
| 335 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 336 | /* Clear pending IPIs */ |
| 337 | writel(0, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); |
| 338 | |
| 339 | /* Enable first 8 IPIs */ |
Thomas Petazzoni | 5ec6901 | 2013-04-09 23:26:17 +0200 | [diff] [blame] | 340 | writel(IPI_DOORBELL_MASK, per_cpu_int_base + |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 341 | ARMADA_370_XP_IN_DRBEL_MSK_OFFS); |
| 342 | |
| 343 | /* Unmask IPI interrupt */ |
| 344 | writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 345 | } |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 346 | |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 347 | static void armada_xp_mpic_perf_init(void) |
| 348 | { |
| 349 | unsigned long cpuid = cpu_logical_map(smp_processor_id()); |
| 350 | |
| 351 | /* Enable Performance Counter Overflow interrupts */ |
| 352 | writel(ARMADA_370_XP_INT_CAUSE_PERF(cpuid), |
| 353 | per_cpu_int_base + ARMADA_370_XP_INT_FABRIC_MASK_OFFS); |
| 354 | } |
| 355 | |
Ezequiel Garcia | 933a24b | 2015-03-03 11:43:14 +0100 | [diff] [blame] | 356 | #ifdef CONFIG_SMP |
| 357 | static void armada_mpic_send_doorbell(const struct cpumask *mask, |
| 358 | unsigned int irq) |
| 359 | { |
| 360 | int cpu; |
| 361 | unsigned long map = 0; |
| 362 | |
| 363 | /* Convert our logical CPU mask into a physical one. */ |
| 364 | for_each_cpu(cpu, mask) |
| 365 | map |= 1 << cpu_logical_map(cpu); |
| 366 | |
| 367 | /* |
| 368 | * Ensure that stores to Normal memory are visible to the |
| 369 | * other CPUs before issuing the IPI. |
| 370 | */ |
| 371 | dsb(); |
| 372 | |
| 373 | /* submit softirq */ |
| 374 | writel((map << 8) | irq, main_int_base + |
| 375 | ARMADA_370_XP_SW_TRIG_INT_OFFS); |
| 376 | } |
| 377 | |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 378 | static int armada_xp_mpic_secondary_init(struct notifier_block *nfb, |
| 379 | unsigned long action, void *hcpu) |
| 380 | { |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 381 | if (action == CPU_STARTING || action == CPU_STARTING_FROZEN) { |
| 382 | armada_xp_mpic_perf_init(); |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 383 | armada_xp_mpic_smp_cpu_init(); |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 384 | } |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 385 | |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 386 | return NOTIFY_OK; |
| 387 | } |
| 388 | |
| 389 | static struct notifier_block armada_370_xp_mpic_cpu_notifier = { |
| 390 | .notifier_call = armada_xp_mpic_secondary_init, |
| 391 | .priority = 100, |
| 392 | }; |
| 393 | |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 394 | static int mpic_cascaded_secondary_init(struct notifier_block *nfb, |
| 395 | unsigned long action, void *hcpu) |
| 396 | { |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 397 | if (action == CPU_STARTING || action == CPU_STARTING_FROZEN) { |
| 398 | armada_xp_mpic_perf_init(); |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 399 | enable_percpu_irq(parent_irq, IRQ_TYPE_NONE); |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 400 | } |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 401 | |
| 402 | return NOTIFY_OK; |
| 403 | } |
| 404 | |
| 405 | static struct notifier_block mpic_cascaded_cpu_notifier = { |
| 406 | .notifier_call = mpic_cascaded_secondary_init, |
| 407 | .priority = 100, |
| 408 | }; |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 409 | #endif /* CONFIG_SMP */ |
| 410 | |
Krzysztof Kozlowski | 9600973 | 2015-04-27 21:54:24 +0900 | [diff] [blame] | 411 | static const struct irq_domain_ops armada_370_xp_mpic_irq_ops = { |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 412 | .map = armada_370_xp_mpic_irq_map, |
| 413 | .xlate = irq_domain_xlate_onecell, |
| 414 | }; |
| 415 | |
Ezequiel Garcia | 9b8cf77 | 2014-02-10 17:00:01 -0300 | [diff] [blame] | 416 | #ifdef CONFIG_PCI_MSI |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 417 | static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained) |
Ezequiel Garcia | 9b8cf77 | 2014-02-10 17:00:01 -0300 | [diff] [blame] | 418 | { |
| 419 | u32 msimask, msinr; |
| 420 | |
| 421 | msimask = readl_relaxed(per_cpu_int_base + |
| 422 | ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS) |
| 423 | & PCI_MSI_DOORBELL_MASK; |
| 424 | |
| 425 | writel(~msimask, per_cpu_int_base + |
| 426 | ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); |
| 427 | |
| 428 | for (msinr = PCI_MSI_DOORBELL_START; |
| 429 | msinr < PCI_MSI_DOORBELL_END; msinr++) { |
| 430 | int irq; |
| 431 | |
| 432 | if (!(msimask & BIT(msinr))) |
| 433 | continue; |
| 434 | |
Marc Zyngier | e89c6a0 | 2014-08-26 11:03:21 +0100 | [diff] [blame] | 435 | if (is_chained) { |
| 436 | irq = irq_find_mapping(armada_370_xp_msi_domain, |
| 437 | msinr - 16); |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 438 | generic_handle_irq(irq); |
Marc Zyngier | e89c6a0 | 2014-08-26 11:03:21 +0100 | [diff] [blame] | 439 | } else { |
| 440 | irq = msinr - 16; |
| 441 | handle_domain_irq(armada_370_xp_msi_domain, |
| 442 | irq, regs); |
| 443 | } |
Ezequiel Garcia | 9b8cf77 | 2014-02-10 17:00:01 -0300 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | #else |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 447 | static void armada_370_xp_handle_msi_irq(struct pt_regs *r, bool b) {} |
Ezequiel Garcia | 9b8cf77 | 2014-02-10 17:00:01 -0300 | [diff] [blame] | 448 | #endif |
| 449 | |
Thomas Gleixner | bd0b9ac | 2015-09-14 10:42:37 +0200 | [diff] [blame^] | 450 | static void armada_370_xp_mpic_handle_cascade_irq(struct irq_desc *desc) |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 451 | { |
Jiang Liu | 5b29264 | 2015-06-04 12:13:20 +0800 | [diff] [blame] | 452 | struct irq_chip *chip = irq_desc_get_chip(desc); |
Grzegorz Jaszczyk | 758e836 | 2014-09-25 13:17:19 +0200 | [diff] [blame] | 453 | unsigned long irqmap, irqn, irqsrc, cpuid; |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 454 | unsigned int cascade_irq; |
| 455 | |
| 456 | chained_irq_enter(chip, desc); |
| 457 | |
| 458 | irqmap = readl_relaxed(per_cpu_int_base + ARMADA_375_PPI_CAUSE); |
Grzegorz Jaszczyk | 758e836 | 2014-09-25 13:17:19 +0200 | [diff] [blame] | 459 | cpuid = cpu_logical_map(smp_processor_id()); |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 460 | |
| 461 | for_each_set_bit(irqn, &irqmap, BITS_PER_LONG) { |
Grzegorz Jaszczyk | 758e836 | 2014-09-25 13:17:19 +0200 | [diff] [blame] | 462 | irqsrc = readl_relaxed(main_int_base + |
| 463 | ARMADA_370_XP_INT_SOURCE_CTL(irqn)); |
| 464 | |
| 465 | /* Check if the interrupt is not masked on current CPU. |
| 466 | * Test IRQ (0-1) and FIQ (8-9) mask bits. |
| 467 | */ |
| 468 | if (!(irqsrc & ARMADA_370_XP_INT_IRQ_FIQ_MASK(cpuid))) |
| 469 | continue; |
| 470 | |
| 471 | if (irqn == 1) { |
| 472 | armada_370_xp_handle_msi_irq(NULL, true); |
| 473 | continue; |
| 474 | } |
| 475 | |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 476 | cascade_irq = irq_find_mapping(armada_370_xp_mpic_domain, irqn); |
| 477 | generic_handle_irq(cascade_irq); |
| 478 | } |
| 479 | |
| 480 | chained_irq_exit(chip, desc); |
| 481 | } |
| 482 | |
Stephen Boyd | 8783dd3 | 2014-03-04 16:40:30 -0800 | [diff] [blame] | 483 | static void __exception_irq_entry |
Thomas Petazzoni | 9339d43 | 2013-04-09 23:26:15 +0200 | [diff] [blame] | 484 | armada_370_xp_handle_irq(struct pt_regs *regs) |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 485 | { |
| 486 | u32 irqstat, irqnr; |
| 487 | |
| 488 | do { |
| 489 | irqstat = readl_relaxed(per_cpu_int_base + |
| 490 | ARMADA_370_XP_CPU_INTACK_OFFS); |
| 491 | irqnr = irqstat & 0x3FF; |
| 492 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 493 | if (irqnr > 1022) |
| 494 | break; |
| 495 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 496 | if (irqnr > 1) { |
Marc Zyngier | e89c6a0 | 2014-08-26 11:03:21 +0100 | [diff] [blame] | 497 | handle_domain_irq(armada_370_xp_mpic_domain, |
| 498 | irqnr, regs); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 499 | continue; |
| 500 | } |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 501 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 502 | /* MSI handling */ |
Ezequiel Garcia | 9b8cf77 | 2014-02-10 17:00:01 -0300 | [diff] [blame] | 503 | if (irqnr == 1) |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 504 | armada_370_xp_handle_msi_irq(regs, false); |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 505 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 506 | #ifdef CONFIG_SMP |
| 507 | /* IPI Handling */ |
| 508 | if (irqnr == 0) { |
| 509 | u32 ipimask, ipinr; |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 510 | |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 511 | ipimask = readl_relaxed(per_cpu_int_base + |
| 512 | ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS) |
Thomas Petazzoni | 5ec6901 | 2013-04-09 23:26:17 +0200 | [diff] [blame] | 513 | & IPI_DOORBELL_MASK; |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 514 | |
Lior Amsalem | a6f089e | 2013-11-25 17:26:44 +0100 | [diff] [blame] | 515 | writel(~ipimask, per_cpu_int_base + |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 516 | ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); |
| 517 | |
| 518 | /* Handle all pending doorbells */ |
Thomas Petazzoni | 5ec6901 | 2013-04-09 23:26:17 +0200 | [diff] [blame] | 519 | for (ipinr = IPI_DOORBELL_START; |
| 520 | ipinr < IPI_DOORBELL_END; ipinr++) { |
Gregory CLEMENT | 344e873 | 2012-08-02 11:19:12 +0300 | [diff] [blame] | 521 | if (ipimask & (0x1 << ipinr)) |
| 522 | handle_IPI(ipinr, regs); |
| 523 | } |
| 524 | continue; |
| 525 | } |
| 526 | #endif |
| 527 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 528 | } while (1); |
| 529 | } |
| 530 | |
Thomas Petazzoni | 0f077eb | 2014-11-21 17:00:00 +0100 | [diff] [blame] | 531 | static int armada_370_xp_mpic_suspend(void) |
| 532 | { |
| 533 | doorbell_mask_reg = readl(per_cpu_int_base + |
| 534 | ARMADA_370_XP_IN_DRBEL_MSK_OFFS); |
| 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | static void armada_370_xp_mpic_resume(void) |
| 539 | { |
| 540 | int nirqs; |
| 541 | irq_hw_number_t irq; |
| 542 | |
| 543 | /* Re-enable interrupts */ |
| 544 | nirqs = (readl(main_int_base + ARMADA_370_XP_INT_CONTROL) >> 2) & 0x3ff; |
| 545 | for (irq = 0; irq < nirqs; irq++) { |
| 546 | struct irq_data *data; |
| 547 | int virq; |
| 548 | |
| 549 | virq = irq_linear_revmap(armada_370_xp_mpic_domain, irq); |
| 550 | if (virq == 0) |
| 551 | continue; |
| 552 | |
| 553 | if (irq != ARMADA_370_XP_TIMER0_PER_CPU_IRQ) |
| 554 | writel(irq, per_cpu_int_base + |
| 555 | ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 556 | else |
| 557 | writel(irq, main_int_base + |
| 558 | ARMADA_370_XP_INT_SET_ENABLE_OFFS); |
| 559 | |
| 560 | data = irq_get_irq_data(virq); |
| 561 | if (!irqd_irq_disabled(data)) |
| 562 | armada_370_xp_irq_unmask(data); |
| 563 | } |
| 564 | |
| 565 | /* Reconfigure doorbells for IPIs and MSIs */ |
| 566 | writel(doorbell_mask_reg, |
| 567 | per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS); |
| 568 | if (doorbell_mask_reg & IPI_DOORBELL_MASK) |
| 569 | writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 570 | if (doorbell_mask_reg & PCI_MSI_DOORBELL_MASK) |
| 571 | writel(1, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); |
| 572 | } |
| 573 | |
| 574 | struct syscore_ops armada_370_xp_mpic_syscore_ops = { |
| 575 | .suspend = armada_370_xp_mpic_suspend, |
| 576 | .resume = armada_370_xp_mpic_resume, |
| 577 | }; |
| 578 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 579 | static int __init armada_370_xp_mpic_of_init(struct device_node *node, |
| 580 | struct device_node *parent) |
| 581 | { |
Thomas Petazzoni | 627dfcc | 2013-08-09 22:27:10 +0200 | [diff] [blame] | 582 | struct resource main_int_res, per_cpu_int_res; |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 583 | int nr_irqs, i; |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 584 | u32 control; |
| 585 | |
Thomas Petazzoni | 627dfcc | 2013-08-09 22:27:10 +0200 | [diff] [blame] | 586 | BUG_ON(of_address_to_resource(node, 0, &main_int_res)); |
| 587 | BUG_ON(of_address_to_resource(node, 1, &per_cpu_int_res)); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 588 | |
Thomas Petazzoni | 627dfcc | 2013-08-09 22:27:10 +0200 | [diff] [blame] | 589 | BUG_ON(!request_mem_region(main_int_res.start, |
| 590 | resource_size(&main_int_res), |
| 591 | node->full_name)); |
| 592 | BUG_ON(!request_mem_region(per_cpu_int_res.start, |
| 593 | resource_size(&per_cpu_int_res), |
| 594 | node->full_name)); |
| 595 | |
| 596 | main_int_base = ioremap(main_int_res.start, |
| 597 | resource_size(&main_int_res)); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 598 | BUG_ON(!main_int_base); |
Thomas Petazzoni | 627dfcc | 2013-08-09 22:27:10 +0200 | [diff] [blame] | 599 | |
| 600 | per_cpu_int_base = ioremap(per_cpu_int_res.start, |
| 601 | resource_size(&per_cpu_int_res)); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 602 | BUG_ON(!per_cpu_int_base); |
Gregory CLEMENT | d792b1e | 2012-09-26 18:02:48 +0200 | [diff] [blame] | 603 | |
| 604 | control = readl(main_int_base + ARMADA_370_XP_INT_CONTROL); |
Thomas Petazzoni | b73842b | 2014-05-30 22:18:18 +0200 | [diff] [blame] | 605 | nr_irqs = (control >> 2) & 0x3ff; |
| 606 | |
| 607 | for (i = 0; i < nr_irqs; i++) |
| 608 | writel(i, main_int_base + ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS); |
Gregory CLEMENT | d792b1e | 2012-09-26 18:02:48 +0200 | [diff] [blame] | 609 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 610 | armada_370_xp_mpic_domain = |
Thomas Petazzoni | b73842b | 2014-05-30 22:18:18 +0200 | [diff] [blame] | 611 | irq_domain_add_linear(node, nr_irqs, |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 612 | &armada_370_xp_mpic_irq_ops, NULL); |
| 613 | |
Thomas Petazzoni | 627dfcc | 2013-08-09 22:27:10 +0200 | [diff] [blame] | 614 | BUG_ON(!armada_370_xp_mpic_domain); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 615 | |
Ezequiel Garcia | 933a24b | 2015-03-03 11:43:14 +0100 | [diff] [blame] | 616 | /* Setup for the boot CPU */ |
Maxime Ripard | 28da06d | 2015-03-03 11:43:16 +0100 | [diff] [blame] | 617 | armada_xp_mpic_perf_init(); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 618 | armada_xp_mpic_smp_cpu_init(); |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 619 | |
Thomas Petazzoni | 31f614e | 2013-08-09 22:27:11 +0200 | [diff] [blame] | 620 | armada_370_xp_msi_init(node, main_int_res.start); |
| 621 | |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 622 | parent_irq = irq_of_parse_and_map(node, 0); |
| 623 | if (parent_irq <= 0) { |
| 624 | irq_set_default_host(armada_370_xp_mpic_domain); |
| 625 | set_handle_irq(armada_370_xp_handle_irq); |
Thomas Petazzoni | ef37d33 | 2014-04-14 15:54:01 +0200 | [diff] [blame] | 626 | #ifdef CONFIG_SMP |
| 627 | set_smp_cross_call(armada_mpic_send_doorbell); |
Thomas Petazzoni | d7df84b | 2014-04-14 15:54:02 +0200 | [diff] [blame] | 628 | register_cpu_notifier(&armada_370_xp_mpic_cpu_notifier); |
Thomas Petazzoni | ef37d33 | 2014-04-14 15:54:01 +0200 | [diff] [blame] | 629 | #endif |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 630 | } else { |
Maxime Ripard | 5724be8 | 2015-03-03 11:27:23 +0100 | [diff] [blame] | 631 | #ifdef CONFIG_SMP |
| 632 | register_cpu_notifier(&mpic_cascaded_cpu_notifier); |
| 633 | #endif |
Ezequiel Garcia | bc69b8a | 2014-02-10 17:00:02 -0300 | [diff] [blame] | 634 | irq_set_chained_handler(parent_irq, |
| 635 | armada_370_xp_mpic_handle_cascade_irq); |
| 636 | } |
Thomas Petazzoni | b313ada | 2013-04-09 23:26:16 +0200 | [diff] [blame] | 637 | |
Thomas Petazzoni | 0f077eb | 2014-11-21 17:00:00 +0100 | [diff] [blame] | 638 | register_syscore_ops(&armada_370_xp_mpic_syscore_ops); |
| 639 | |
Thomas Petazzoni | 9ae6f74 | 2012-06-13 19:01:28 +0200 | [diff] [blame] | 640 | return 0; |
| 641 | } |
| 642 | |
Thomas Petazzoni | 9339d43 | 2013-04-09 23:26:15 +0200 | [diff] [blame] | 643 | IRQCHIP_DECLARE(armada_370_xp_mpic, "marvell,mpic", armada_370_xp_mpic_of_init); |