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