Skip to content

Commit e8bba72

Browse files
lvjianmin-loongsonMarc Zyngier
authored andcommitted
irqchip / ACPI: Introduce ACPI_IRQ_MODEL_LPIC for LoongArch
For LoongArch, ACPI_IRQ_MODEL_LPIC is introduced, and then the callback acpi_get_gsi_domain_id and acpi_gsi_to_irq_fallback are implemented. The acpi_get_gsi_domain_id callback returns related fwnode handle of irqdomain for different GSI range. The acpi_gsi_to_irq_fallback will create new mapping for gsi when the mapping of it is not found. Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/1658314292-35346-14-git-send-email-lvjianmin@loongson.cn
1 parent b2d3e33 commit e8bba72

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

drivers/acpi/bus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ static int __init acpi_bus_init_irq(void)
11451145
case ACPI_IRQ_MODEL_PLATFORM:
11461146
message = "platform specific model";
11471147
break;
1148+
case ACPI_IRQ_MODEL_LPIC:
1149+
message = "LPIC";
1150+
break;
11481151
default:
11491152
pr_info("Unknown interrupt routing model\n");
11501153
return -ENODEV;

drivers/irqchip/irq-loongarch-cpu.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,41 @@
1616
static struct irq_domain *irq_domain;
1717
struct fwnode_handle *cpuintc_handle;
1818

19+
static u32 lpic_gsi_to_irq(u32 gsi)
20+
{
21+
/* Only pch irqdomain transferring is required for LoongArch. */
22+
if (gsi >= GSI_MIN_PCH_IRQ && gsi <= GSI_MAX_PCH_IRQ)
23+
return acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH);
24+
25+
return 0;
26+
}
27+
28+
static struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi)
29+
{
30+
int id;
31+
struct fwnode_handle *domain_handle = NULL;
32+
33+
switch (gsi) {
34+
case GSI_MIN_CPU_IRQ ... GSI_MAX_CPU_IRQ:
35+
if (liointc_handle)
36+
domain_handle = liointc_handle;
37+
break;
38+
39+
case GSI_MIN_LPC_IRQ ... GSI_MAX_LPC_IRQ:
40+
if (pch_lpc_handle)
41+
domain_handle = pch_lpc_handle;
42+
break;
43+
44+
case GSI_MIN_PCH_IRQ ... GSI_MAX_PCH_IRQ:
45+
id = find_pch_pic(gsi);
46+
if (id >= 0 && pch_pic_handle[id])
47+
domain_handle = pch_pic_handle[id];
48+
break;
49+
}
50+
51+
return domain_handle;
52+
}
53+
1954
static void mask_loongarch_irq(struct irq_data *d)
2055
{
2156
clear_csr_ecfg(ECFGF(d->hwirq));
@@ -102,6 +137,8 @@ static int __init cpuintc_acpi_init(union acpi_subtable_headers *header,
102137
panic("Failed to add irqdomain for LoongArch CPU");
103138

104139
set_handle_irq(&handle_cpu_irq);
140+
acpi_set_irq_model(ACPI_IRQ_MODEL_LPIC, lpic_get_gsi_domain_id);
141+
acpi_set_gsi_to_irq_fallback(lpic_gsi_to_irq);
105142
acpi_cascade_irqdomain_init();
106143

107144
return 0;

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ enum acpi_irq_model_id {
105105
ACPI_IRQ_MODEL_IOSAPIC,
106106
ACPI_IRQ_MODEL_PLATFORM,
107107
ACPI_IRQ_MODEL_GIC,
108+
ACPI_IRQ_MODEL_LPIC,
108109
ACPI_IRQ_MODEL_COUNT
109110
};
110111

0 commit comments

Comments
 (0)