Skip to content

Commit f011df6

Browse files
lokeshvutlaMarc Zyngier
authored andcommitted
irqchip/ti-sci-inta: Add msi domain support
Add a msi domain that is child to the INTA domain. Clients uses the INTA MSI bus layer to allocate irqs in this MSI domain. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 49b3231 commit f011df6

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

drivers/irqchip/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ config TI_SCI_INTA_IRQCHIP
433433
bool
434434
depends on TI_SCI_PROTOCOL
435435
select IRQ_DOMAIN_HIERARCHY
436+
select TI_SCI_INTA_MSI_DOMAIN
436437
help
437438
This enables the irqchip driver support for K3 Interrupt aggregator
438439
over TI System Control Interface available on some new TI's SoCs.

drivers/irqchip/irq-ti-sci-inta.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/of_irq.h>
1919
#include <linux/of_platform.h>
2020
#include <linux/irqchip/chained_irq.h>
21+
#include <linux/soc/ti/ti_sci_inta_msi.h>
2122
#include <linux/soc/ti/ti_sci_protocol.h>
2223
#include <asm-generic/msi.h>
2324

@@ -28,6 +29,9 @@
2829
#define HWIRQ_TO_DEVID(hwirq) (((hwirq) >> (TI_SCI_DEV_ID_SHIFT)) & \
2930
(TI_SCI_DEV_ID_MASK))
3031
#define HWIRQ_TO_IRQID(hwirq) ((hwirq) & (TI_SCI_IRQ_ID_MASK))
32+
#define TO_HWIRQ(dev, index) ((((dev) & TI_SCI_DEV_ID_MASK) << \
33+
TI_SCI_DEV_ID_SHIFT) | \
34+
((index) & TI_SCI_IRQ_ID_MASK))
3135

3236
#define MAX_EVENTS_PER_VINT 64
3337
#define VINT_ENABLE_SET_OFFSET 0x0
@@ -484,9 +488,34 @@ static const struct irq_domain_ops ti_sci_inta_irq_domain_ops = {
484488
.alloc = ti_sci_inta_irq_domain_alloc,
485489
};
486490

491+
static struct irq_chip ti_sci_inta_msi_irq_chip = {
492+
.name = "MSI-INTA",
493+
.flags = IRQCHIP_SUPPORTS_LEVEL_MSI,
494+
};
495+
496+
static void ti_sci_inta_msi_set_desc(msi_alloc_info_t *arg,
497+
struct msi_desc *desc)
498+
{
499+
struct platform_device *pdev = to_platform_device(desc->dev);
500+
501+
arg->desc = desc;
502+
arg->hwirq = TO_HWIRQ(pdev->id, desc->inta.dev_index);
503+
}
504+
505+
static struct msi_domain_ops ti_sci_inta_msi_ops = {
506+
.set_desc = ti_sci_inta_msi_set_desc,
507+
};
508+
509+
static struct msi_domain_info ti_sci_inta_msi_domain_info = {
510+
.flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
511+
MSI_FLAG_LEVEL_CAPABLE),
512+
.ops = &ti_sci_inta_msi_ops,
513+
.chip = &ti_sci_inta_msi_irq_chip,
514+
};
515+
487516
static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
488517
{
489-
struct irq_domain *parent_domain, *domain;
518+
struct irq_domain *parent_domain, *domain, *msi_domain;
490519
struct device_node *parent_node, *node;
491520
struct ti_sci_inta_irq_domain *inta;
492521
struct device *dev = &pdev->dev;
@@ -551,6 +580,15 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
551580
return -ENOMEM;
552581
}
553582

583+
msi_domain = ti_sci_inta_msi_create_irq_domain(of_node_to_fwnode(node),
584+
&ti_sci_inta_msi_domain_info,
585+
domain);
586+
if (!msi_domain) {
587+
irq_domain_remove(domain);
588+
dev_err(dev, "Failed to allocate msi domain\n");
589+
return -ENOMEM;
590+
}
591+
554592
INIT_LIST_HEAD(&inta->vint_list);
555593
mutex_init(&inta->vint_mutex);
556594

0 commit comments

Comments
 (0)