| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ARC ARConnect (MultiCore IP) support (formerly known as MCIP) |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com) |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | #include <linux/smp.h> |
|---|
| .. | .. |
|---|
| 205 | 202 | __mcip_cmd_data(CMD_IDU_SET_DEST, cmn_irq, cpu_mask); |
|---|
| 206 | 203 | } |
|---|
| 207 | 204 | |
|---|
| 208 | | -static void idu_set_mode(unsigned int cmn_irq, unsigned int lvl, |
|---|
| 209 | | - unsigned int distr) |
|---|
| 205 | +static void idu_set_mode(unsigned int cmn_irq, bool set_lvl, unsigned int lvl, |
|---|
| 206 | + bool set_distr, unsigned int distr) |
|---|
| 210 | 207 | { |
|---|
| 211 | 208 | union { |
|---|
| 212 | 209 | unsigned int word; |
|---|
| .. | .. |
|---|
| 215 | 212 | }; |
|---|
| 216 | 213 | } data; |
|---|
| 217 | 214 | |
|---|
| 218 | | - data.distr = distr; |
|---|
| 219 | | - data.lvl = lvl; |
|---|
| 215 | + data.word = __mcip_cmd_read(CMD_IDU_READ_MODE, cmn_irq); |
|---|
| 216 | + if (set_distr) |
|---|
| 217 | + data.distr = distr; |
|---|
| 218 | + if (set_lvl) |
|---|
| 219 | + data.lvl = lvl; |
|---|
| 220 | 220 | __mcip_cmd_data(CMD_IDU_SET_MODE, cmn_irq, data.word); |
|---|
| 221 | 221 | } |
|---|
| 222 | 222 | |
|---|
| .. | .. |
|---|
| 243 | 243 | raw_spin_unlock_irqrestore(&mcip_lock, flags); |
|---|
| 244 | 244 | } |
|---|
| 245 | 245 | |
|---|
| 246 | +static void idu_irq_ack(struct irq_data *data) |
|---|
| 247 | +{ |
|---|
| 248 | + unsigned long flags; |
|---|
| 249 | + |
|---|
| 250 | + raw_spin_lock_irqsave(&mcip_lock, flags); |
|---|
| 251 | + __mcip_cmd(CMD_IDU_ACK_CIRQ, data->hwirq); |
|---|
| 252 | + raw_spin_unlock_irqrestore(&mcip_lock, flags); |
|---|
| 253 | +} |
|---|
| 254 | + |
|---|
| 255 | +static void idu_irq_mask_ack(struct irq_data *data) |
|---|
| 256 | +{ |
|---|
| 257 | + unsigned long flags; |
|---|
| 258 | + |
|---|
| 259 | + raw_spin_lock_irqsave(&mcip_lock, flags); |
|---|
| 260 | + __mcip_cmd_data(CMD_IDU_SET_MASK, data->hwirq, 1); |
|---|
| 261 | + __mcip_cmd(CMD_IDU_ACK_CIRQ, data->hwirq); |
|---|
| 262 | + raw_spin_unlock_irqrestore(&mcip_lock, flags); |
|---|
| 263 | +} |
|---|
| 264 | + |
|---|
| 246 | 265 | static int |
|---|
| 247 | 266 | idu_irq_set_affinity(struct irq_data *data, const struct cpumask *cpumask, |
|---|
| 248 | 267 | bool force) |
|---|
| .. | .. |
|---|
| 266 | 285 | else |
|---|
| 267 | 286 | distribution_mode = IDU_M_DISTRI_RR; |
|---|
| 268 | 287 | |
|---|
| 269 | | - idu_set_mode(data->hwirq, IDU_M_TRIG_LEVEL, distribution_mode); |
|---|
| 288 | + idu_set_mode(data->hwirq, false, 0, true, distribution_mode); |
|---|
| 270 | 289 | |
|---|
| 271 | 290 | raw_spin_unlock_irqrestore(&mcip_lock, flags); |
|---|
| 272 | 291 | |
|---|
| 273 | 292 | return IRQ_SET_MASK_OK; |
|---|
| 293 | +} |
|---|
| 294 | + |
|---|
| 295 | +static int idu_irq_set_type(struct irq_data *data, u32 type) |
|---|
| 296 | +{ |
|---|
| 297 | + unsigned long flags; |
|---|
| 298 | + |
|---|
| 299 | + /* |
|---|
| 300 | + * ARCv2 IDU HW does not support inverse polarity, so these are the |
|---|
| 301 | + * only interrupt types supported. |
|---|
| 302 | + */ |
|---|
| 303 | + if (type & ~(IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) |
|---|
| 304 | + return -EINVAL; |
|---|
| 305 | + |
|---|
| 306 | + raw_spin_lock_irqsave(&mcip_lock, flags); |
|---|
| 307 | + |
|---|
| 308 | + idu_set_mode(data->hwirq, true, |
|---|
| 309 | + type & IRQ_TYPE_EDGE_RISING ? IDU_M_TRIG_EDGE : |
|---|
| 310 | + IDU_M_TRIG_LEVEL, |
|---|
| 311 | + false, 0); |
|---|
| 312 | + |
|---|
| 313 | + raw_spin_unlock_irqrestore(&mcip_lock, flags); |
|---|
| 314 | + |
|---|
| 315 | + return 0; |
|---|
| 274 | 316 | } |
|---|
| 275 | 317 | |
|---|
| 276 | 318 | static void idu_irq_enable(struct irq_data *data) |
|---|
| .. | .. |
|---|
| 292 | 334 | .name = "MCIP IDU Intc", |
|---|
| 293 | 335 | .irq_mask = idu_irq_mask, |
|---|
| 294 | 336 | .irq_unmask = idu_irq_unmask, |
|---|
| 337 | + .irq_ack = idu_irq_ack, |
|---|
| 338 | + .irq_mask_ack = idu_irq_mask_ack, |
|---|
| 295 | 339 | .irq_enable = idu_irq_enable, |
|---|
| 340 | + .irq_set_type = idu_irq_set_type, |
|---|
| 296 | 341 | #ifdef CONFIG_SMP |
|---|
| 297 | 342 | .irq_set_affinity = idu_irq_set_affinity, |
|---|
| 298 | 343 | #endif |
|---|
| .. | .. |
|---|
| 320 | 365 | } |
|---|
| 321 | 366 | |
|---|
| 322 | 367 | static const struct irq_domain_ops idu_irq_ops = { |
|---|
| 323 | | - .xlate = irq_domain_xlate_onecell, |
|---|
| 368 | + .xlate = irq_domain_xlate_onetwocell, |
|---|
| 324 | 369 | .map = idu_irq_map, |
|---|
| 325 | 370 | }; |
|---|
| 326 | 371 | |
|---|