Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/loongson-pch-lpc: Add OF init code

The OF-based MIPS Loongson-3 systems can also have a PCH LPC interrupt
controller.

Add OF-based initialization code for this driver.

Co-developed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Link: https://patch.msgid.link/20260321092032.3502701-6-zhengxingda@iscas.ac.cn

authored by

Icenowy Zheng and committed by
Thomas Gleixner
ed3772aa 29c10a0a

+35
+35
drivers/irqchip/irq-loongson-pch-lpc.c
··· 13 13 #include <linux/irqchip/chained_irq.h> 14 14 #include <linux/irqdomain.h> 15 15 #include <linux/kernel.h> 16 + #include <linux/of_address.h> 17 + #include <linux/of_irq.h> 16 18 #include <linux/syscore_ops.h> 17 19 18 20 #include "irq-loongson.h" ··· 226 224 return -ENOMEM; 227 225 } 228 226 227 + #ifdef CONFIG_ACPI 229 228 int __init pch_lpc_acpi_init(struct irq_domain *parent, struct acpi_madt_lpc_pic *acpi_pchlpc) 230 229 { 231 230 struct fwnode_handle *irq_handle; ··· 259 256 260 257 return 0; 261 258 } 259 + #endif /* CONFIG_ACPI */ 260 + 261 + #ifdef CONFIG_OF 262 + static int __init pch_lpc_of_init(struct device_node *node, struct device_node *parent) 263 + { 264 + struct fwnode_handle *irq_handle; 265 + struct resource res; 266 + int parent_irq, ret; 267 + 268 + if (of_address_to_resource(node, 0, &res)) 269 + return -EINVAL; 270 + 271 + parent_irq = irq_of_parse_and_map(node, 0); 272 + if (!parent_irq) { 273 + pr_err("Failed to get the parent IRQ for LPC IRQs\n"); 274 + return -EINVAL; 275 + } 276 + 277 + irq_handle = of_fwnode_handle(node); 278 + 279 + ret = pch_lpc_init(res.start, resource_size(&res), irq_handle, 280 + parent_irq); 281 + if (ret) { 282 + irq_dispose_mapping(parent_irq); 283 + return ret; 284 + } 285 + 286 + return 0; 287 + } 288 + 289 + IRQCHIP_DECLARE(pch_lpc, "loongson,ls7a-lpc", pch_lpc_of_init); 290 + #endif /* CONFIG_OF */