Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4305428pxv; Mon, 5 Jul 2021 20:13:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz13MA81zpNKsGFAKCvRputzcUTyUI6aHvyC4HH1CKIkJtA7535Gmyuw60quWiUsaZE9MSy X-Received: by 2002:a17:907:9805:: with SMTP id ji5mr4699501ejc.388.1625541229594; Mon, 05 Jul 2021 20:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625541229; cv=none; d=google.com; s=arc-20160816; b=J9P9GdmQTWL8pU5XFFiyCcRVFIMP8gf/OAC8gE5VVRr9GIy4Vu3fSSAao0x7uauEa2 EvAlHXfPvX7OMXi2hVfJMCjhpBBhy6iLCfVsGjrpB+aELYVZfhwu5R+QJTqLs5W0F9Bk FyyDd5FG76alAU6DGzObsffywot3tikR5hioSjwv+w/xGS85t2otzSR7ju1aLLuPybzm LuOBkBpvTqX6bImiGnLDbwJSXxt8qq1j++Rra13ioUUA+bwk/Reya73bRvQrvR/iZioU DTvgkR0Qte6Nc2TDfu3m4ZdH1Cjfi34Lp1MRMg9I+KX/tyOkh9OhSrbMjjnLCPN0PJ/x TTNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Takdy+SiJfizh70MhEWs/RgOrHSUh9M7FEwl93fyZfI=; b=V7NbIKE5bI6KSdl2sBKklkAai6Lfq+EH9NAJ6LKtc22iRGmKmotnBmmW+wBt9jrssu HiaifA9RNcRdQ7yBH1sqz+Y7mVUH53bBL+T+Vgy+6L5M9pNJL9pcDZaFJ4mHEsqN+Wg8 wQ2gJrHb0FEJPk01/cQsEyTuNlrulpnjfVzqgQhGuDJemCnsS+h1OS2g/Q04+hKuOLUk mU9Tz+Ivt19aFUy4CxlGiGqcD9xKVEMx6hTed+XjarqPEWeoomlS/IqvLi6B2RReHKUP fAgrAZvMX0/1UDpgUi2QXQECLLpBRCKtGHVpghRKVjvAo3WdhmDTfOdbsHxEDVSWfpMH 98Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa36si11633027ejc.345.2021.07.05.20.13.26; Mon, 05 Jul 2021 20:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbhGFDMr (ORCPT + 99 others); Mon, 5 Jul 2021 23:12:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbhGFDMq (ORCPT ); Mon, 5 Jul 2021 23:12:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5877E6197F; Tue, 6 Jul 2021 03:10:06 +0000 (UTC) From: Huacai Chen To: Thomas Gleixner , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Xuefeng Li , Huacai Chen , Jiaxun Yang , Huacai Chen Subject: [PATCH 4/9] irqchip/loongson-pch-msi: Add ACPI init support Date: Tue, 6 Jul 2021 11:08:59 +0800 Message-Id: <20210706030904.1411775-5-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210706030904.1411775-1-chenhuacai@loongson.cn> References: <20210706030904.1411775-1-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We are preparing to add new Loongson (based on LoongArch, not MIPS) support. LoongArch use ACPI other than DT as its boot protocol, so add ACPI init support. Signed-off-by: Huacai Chen --- drivers/irqchip/irq-loongson-pch-msi.c | 69 ++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c index 32562b7e681b..adfa30046f0a 100644 --- a/drivers/irqchip/irq-loongson-pch-msi.c +++ b/drivers/irqchip/irq-loongson-pch-msi.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2020, Jiaxun Yang + * Jianmin Lv + * Huacai Chen * Loongson PCH MSI support */ @@ -21,6 +23,7 @@ struct pch_msi_data { u32 irq_first; /* The vector number that MSIs starts */ u32 num_irqs; /* The number of vectors for MSIs */ unsigned long *msi_map; + struct fwnode_handle *domain_handle; }; static void pch_msi_mask_msi_irq(struct irq_data *d) @@ -159,7 +162,12 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, { struct irq_domain *middle_domain, *msi_domain; - middle_domain = irq_domain_create_linear(of_node_to_fwnode(node), + if (node) + priv->domain_handle = of_node_to_fwnode(node); + else + priv->domain_handle = irq_domain_alloc_fwnode((phys_addr_t *)priv); + + middle_domain = irq_domain_create_linear(priv->domain_handle, priv->num_irqs, &pch_msi_middle_domain_ops, priv); @@ -171,7 +179,7 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, middle_domain->parent = parent; irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); - msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(node), + msi_domain = pci_msi_create_irq_domain(priv->domain_handle, &pch_msi_domain_info, middle_domain); if (!msi_domain) { @@ -183,8 +191,9 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, return 0; } -static int pch_msi_init(struct device_node *node, - struct device_node *parent) +#ifdef CONFIG_OF + +int pch_msi_of_init(struct device_node *node, struct device_node *parent) { struct pch_msi_data *priv; struct irq_domain *parent_domain; @@ -247,4 +256,54 @@ static int pch_msi_init(struct device_node *node, return ret; } -IRQCHIP_DECLARE(pch_msi, "loongson,pch-msi-1.0", pch_msi_init); +IRQCHIP_DECLARE(pch_msi, "loongson,pch-msi-1.0", pch_msi_of_init); + +#endif + +#ifdef CONFIG_ACPI + +struct fwnode_handle *pch_msi_acpi_init(struct fwnode_handle *parent, + struct acpi_madt_msi_pic *acpi_pchmsi) +{ + int ret; + struct pch_msi_data *priv; + struct irq_domain *parent_domain; + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return NULL; + + mutex_init(&priv->msi_map_lock); + + priv->doorbell = acpi_pchmsi->msg_address; + priv->irq_first = acpi_pchmsi->start; + priv->num_irqs = acpi_pchmsi->count; + + parent_domain = irq_find_matching_fwnode(parent, DOMAIN_BUS_ANY); + if (!parent_domain) { + pr_err("Failed to find the parent domain\n"); + return NULL; + } + + priv->msi_map = bitmap_zalloc(priv->num_irqs, GFP_KERNEL); + if (!priv->msi_map) + goto err_priv; + + pr_debug("Registering %d MSIs, starting at %d\n", + priv->num_irqs, priv->irq_first); + + ret = pch_msi_init_domains(priv, NULL, parent_domain); + if (ret) + goto err_map; + + return priv->domain_handle; + +err_map: + kfree(priv->msi_map); +err_priv: + kfree(priv); + + return NULL; +} + +#endif -- 2.27.0