From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77EB32DFF29 for ; Wed, 18 Jun 2025 12:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249039; cv=none; b=CSGi8IyHILTmJKCbDIZ/rV0fkYKOzE5Pe+EJT5UZAwdnT6z+fkjd1mQt9B1gdo2n7mpQXAIMuUuLP8xRa3SY8OjcfB3dBwn51JvH0hacxgRY6aHPp9EUSyfB11oNvY+iDTVOVPQmNYnalgxvj7BcYHdzabjC1XaN6A0Hrj4T7OE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750249039; c=relaxed/simple; bh=MnWssIe2gPHfcipP/eIFfuXpaV0J/C/5d3IRgfnAQHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KdMWpi/RmyxaqLxRq6P1sgxPuCs8z4G5ogrWmfCgPTBfG9Yuwwk9uw9iqVphC+1PYQxhTiKksVT2EZPxe9rH7K7aHIaol1aCQsIMmi0c6dmlElN4ZHE5bCFn8P5Ge1gjhZ0VGyZh1MgVNu1P2ln40hBjgXELKYe75o2XGNLpAm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=IT9Jo25x; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="IT9Jo25x" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-739b3fe7ce8so5175014b3a.0 for ; Wed, 18 Jun 2025 05:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1750249037; x=1750853837; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F4qfR8q3szE7n/ZgMiX3NXp6iFpiigvvy3GXc1Xt1a0=; b=IT9Jo25xCdbOPiCQnMOb/NCrHUZL141F24OYef1o/vRfqJQqaa1utLlidO5nCzL/v/ W7NdcdBAxmAouYVw3vls1qbI3e5xG0OH3eI3K+C4XPtPAA8wgkO3EDvDtaq9Bj+U8nNY aINZL4IEq6nDGHvJ8RpJitcy6QSeO0hGlgritiolGw/xh1ETXn208kT9LPl9fuRj49ST guvCwFhsbJdZF4jrsNeLInAQECy1obulVm46esbNgVpIhyqJeIlZuPYW+v2HkVKjc/Xx JaTbWp0L4MmNq3W8asZ3uUBEsL7Iof0zpS/8f9I99XaifQN2Is+8B+O024AAui1udMqm OfvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750249037; x=1750853837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F4qfR8q3szE7n/ZgMiX3NXp6iFpiigvvy3GXc1Xt1a0=; b=VhSXNwSPVXbLVD2m5v6PrNos9gijXMXSDPr4dUqvWowl1bABMcyAQJs5Bv9HBNnqbt HBMaDvc9MYUd5X4U0KS/xe5ju48j3hhjyZT3Mctr7WlaMNRMRXgvKq7uTWcq77otShsj GzIaCwNYBLDarNoya8/s7W8qbHE8hskFWGRBDHIRpaYkMLzfUcyT8x/MsrWmrJt63y1/ vRqrC7BweI8qRQeWpk2qOgWYPIouCZwW8qDAuiyo1f3+C8txDPvAJgODzrN1rXpDuuR1 qoRuEG1Yl4eEVrVUI5SgjTgg5PE9qWC6ZVk0Kh5xUzXCt7365N8MnG2m9ZAg2NKHehHq xj8g== X-Forwarded-Encrypted: i=1; AJvYcCUtbHLY7l3zG58srsoJFCvdSOmCP5cqYckVlsp9GczTSfdHTSYiDrSMSDwjFiRs0hvRJk+AmGUJzBWA@vger.kernel.org X-Gm-Message-State: AOJu0YwBA1pQGKF7Vc3lrGEQf2+uHENe2kurwQk5tXVZ1FbwIyF+1AIi N32hMvJ5uP32UhCrs0IAVkA4yhe6fZG/5HywMYmPYf6FrFrD/s24Q+/LzVZu4+e+LEY= X-Gm-Gg: ASbGncuXVxhdgTh8fZ7do2eBTca5/dU3WR4sAWEkp4PYQRMG6gpqQRxXWMKbhEXoVe3 W7QFpvM8pWnmjaTyQBnfl7Zse8/53A0ZNQ0XJjsy3qbMH6H4tIJACS6FdrD/VT04XVxbqzClX0N 9cxNhFWOGrf2ws2XCVlPUCX+Z2SEzU1k3OeggZ6P9VoiM50OQd3AhXh/UarVHYpSFESrpPjFkpv rpjTmzIaJso/KxlB5kzDdbWMcxmNQwTVCpS8Vw0Duv6qqiG7akWHk7kpZJZdzi5kKJy3SV2NFNF tbaOTZP98rTjU/4JmbCyP2VIQwwP2/e4y288zxxuulV0lDFppLBH/4/HWT2J/QskMg/BC0yomd1 Ry5znbs+MN4yV9iUiudLcNBXTjh84 X-Google-Smtp-Source: AGHT+IGZxm5K+fImPTj80yc/09wm99fEy6jDG9RVHP9Gj1V5pfPQ80BXgbZFOxeJiG+mqaum26We2w== X-Received: by 2002:a05:6a00:14c2:b0:748:2e1a:84e3 with SMTP id d2e1a72fcca58-7489ce0c6bbmr28455044b3a.8.1750249036547; Wed, 18 Jun 2025 05:17:16 -0700 (PDT) Received: from localhost.localdomain ([122.171.23.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-748900d7e0asm11201177b3a.174.2025.06.18.05.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jun 2025 05:17:16 -0700 (PDT) From: Anup Patel To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jassi Brar , Thomas Gleixner , "Rafael J . Wysocki" , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Palmer Dabbelt , Paul Walmsley , Len Brown , Sunil V L , Rahul Pathak , Leyfoon Tan , Atish Patra , Andrew Jones , Samuel Holland , Anup Patel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v6 21/23] irqchip/riscv-rpmi-sysmsi: Add ACPI support Date: Wed, 18 Jun 2025 17:43:56 +0530 Message-ID: <20250618121358.503781-22-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250618121358.503781-1-apatel@ventanamicro.com> References: <20250618121358.503781-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sunil V L Add ACPI support for the RISC-V RPMI system MSI based irqchip driver. Reviewed-by: Thomas Gleixner Signed-off-by: Sunil V L Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 2 +- drivers/irqchip/irq-riscv-rpmi-sysmsi.c | 47 +++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 96bf6aa55681..dfa8cc0e23dd 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -619,7 +619,7 @@ config RISCV_IMSIC config RISCV_RPMI_SYSMSI bool - depends on MAILBOX + depends on RISCV && MAILBOX select IRQ_DOMAIN_HIERARCHY select GENERIC_MSI_IRQ default RISCV diff --git a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c index c42fceab71fa..6b64a93d3c87 100644 --- a/drivers/irqchip/irq-riscv-rpmi-sysmsi.c +++ b/drivers/irqchip/irq-riscv-rpmi-sysmsi.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2025 Ventana Micro Systems Inc. */ +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -209,6 +211,8 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rpmi_sysmsi_priv *priv; + struct fwnode_handle *fwnode; + u32 id; int rc; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -239,6 +243,22 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) } priv->nr_irqs = rc; + fwnode = dev_fwnode(dev); + if (is_acpi_node(fwnode)) { + u32 nr_irqs; + + rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id, + &nr_irqs, NULL); + if (rc) { + dev_err(dev, "failed to find GSI mapping\n"); + return rc; + } + + /* Update with actual GSI range */ + if (nr_irqs != priv->nr_irqs) + riscv_acpi_update_gsi_range(priv->gsi_base, priv->nr_irqs); + } + /* Set the device MSI domain if not available */ if (!dev_get_msi_domain(dev)) { /* @@ -248,8 +268,15 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) * then we need to set it explicitly before using any platform * MSI functions. */ - if (dev_of_node(dev)) + if (is_of_node(fwnode)) { of_msi_configure(dev, dev_of_node(dev)); + } else if (is_acpi_device_node(fwnode)) { + struct irq_domain *msi_domain; + + msi_domain = irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + dev_set_msi_domain(dev, msi_domain); + } if (!dev_get_msi_domain(dev)) { mbox_free_channel(priv->chan); @@ -264,6 +291,13 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) return dev_err_probe(dev, -ENOMEM, "failed to create MSI irq domain\n"); } +#ifdef CONFIG_ACPI + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev) + acpi_dev_clear_dependencies(adev); +#endif + dev_info(dev, "%u system MSIs registered\n", priv->nr_irqs); return 0; } @@ -273,10 +307,17 @@ static const struct of_device_id rpmi_sysmsi_match[] = { {} }; +static const struct acpi_device_id acpi_rpmi_sysmsi_match[] = { + { "RSCV0006" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, acpi_rpmi_sysmsi_match); + static struct platform_driver rpmi_sysmsi_driver = { .driver = { - .name = "rpmi-sysmsi", - .of_match_table = rpmi_sysmsi_match, + .name = "rpmi-sysmsi", + .of_match_table = rpmi_sysmsi_match, + .acpi_match_table = acpi_rpmi_sysmsi_match, }, .probe = rpmi_sysmsi_probe, }; -- 2.43.0