From patchwork Fri Mar 3 13:36:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 63927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp412653wrd; Fri, 3 Mar 2023 05:39:46 -0800 (PST) X-Google-Smtp-Source: AK7set+OJKIQZP+DuIX3yu+Og1L0HoBSv08xdNgoAb+nNmpAWMxGL7Nj6ghKgxyBTb3yySD0kwyy X-Received: by 2002:aa7:990e:0:b0:5a8:4de2:e94e with SMTP id z14-20020aa7990e000000b005a84de2e94emr1905307pff.33.1677850785738; Fri, 03 Mar 2023 05:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677850785; cv=none; d=google.com; s=arc-20160816; b=EobjdJntWZ+1R0w8BVfohWNcRj4XShqSltFBpK9oNrDFSx32GgAfPr0zqHIptAH9AH l7L6Je15f68NznQpVF0MeWtQToHGd6khEQpOtfngk+qF/nJLc+GITkgnxdiqe9p4fHmZ mEAyZNFcb6W8t4Z6V6ZTGpOV1rn1Gm/+fkVtlUw6dAkXCA4n7Kvtlsy2Vjtr4EnMjOXy 754JLN8TxFZztHXX6pvM0haD+SYzfX8icPBypUiZZk2CYlNH6eHUzUA5wv1zPB5/wVUS fGE6J6Ti7DDwVZkyPwhP4UUFviiKQGSL6w6SuJ0683WSDow9/vLgyTQAJKxSNsGVUDxW dRYQ== 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 :dkim-signature; bh=0NTsYtUJNb7uS+HqQnID6st7LmlddjRj2NkYh86FZo0=; b=OZvRwFsM+Htpa9t8XELi26Zx6GctEOHpNG/JYUeH/n2MjtjimybvKtC8pniy3zDDTa tK17LD4GO2z925QhqjPTh4cOtueqwduWzC7z6tncJvYcbBrABiio5r0ubVQxBh/d2w0t qbDpctcKVixjB2BsrQ1Tx8lOSU0fOIzecmAp6EFULWrH84z79wkCsmthR4s94aKftu26 tQoCJ+LQmD8zQVdmYJzpC6Cv/kjJdTNQxB8+qNTTgLbCQ3FrLfrQXhPp/ZOZQyc04pae ZXi0buOCDgxvSX9HR9Ul2GxjLHb6Yv5dWOdeHBc+5qvbkpA5FQQI7+YovIcmvhBCNrBu /MKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=M25owZtp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020aa79a4a000000b006105436e080si2171742pfj.285.2023.03.03.05.39.32; Fri, 03 Mar 2023 05:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=M25owZtp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjCCNjO (ORCPT + 99 others); Fri, 3 Mar 2023 08:39:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbjCCNih (ORCPT ); Fri, 3 Mar 2023 08:38:37 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658F14D612 for ; Fri, 3 Mar 2023 05:38:04 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id m20-20020a17090ab79400b00239d8e182efso6125482pjr.5 for ; Fri, 03 Mar 2023 05:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1677850683; 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=0NTsYtUJNb7uS+HqQnID6st7LmlddjRj2NkYh86FZo0=; b=M25owZtphUqGcASQ2wyvBhUCpahd7MWa9/fmZwAfVRWgbrRzkft6axRYT28uRgX7nr CWw1nNLCuKzppnBZB0ssVkSqMGx4zhsAEg17by5BoUk1z0z2g419FysJb7yNcxXyW66M AubtTnC5e+7NhVdzDHizPlpKnPfaUNjI7AbbQn+CBY18I+AOSeGgBkkySrdZhzhRi5rc +l28bOnsnBX91qr7YXP4w1oPMSzBGdCs2Ik6H7DDUqFIYYLaaWkh/tp+61GMufHDMHVC AkpbptY08TtFh9wTVgXoIu1F+X4ASt7lZSBcUtRfRn+zqpq9oyYPtCbJY5sxeTZo8V9Z FCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677850683; 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=0NTsYtUJNb7uS+HqQnID6st7LmlddjRj2NkYh86FZo0=; b=SRMBKa3aAtf5YO7Hf78s1XH6339qCs1ZiSaEcmoI/PjMCp7O/e/NbEXT5sSydrn7Rf vs9mRiU+6halNlqWLA3G0KFumQcvJKYiezk6ITk4YyRxGZiJ0F5EtU2sbDpeODQ55pp8 AZGQ8I8802e2AFaQn0Fd6BMylDB/UKcrTj+FcM7UEi0vfjAgqVRWsEzqIEz7L2WcWWyW luQ/vmvenf8pLAUrEH6c56ZwHkrlGM0kpW+0PU3jMaoSxGsUhrMYh7uNSgXwghr1nczy amTaUHNsomdJXLmMdSx1ZL7f9bPtDhLWpkKziez+lNfbukWg23xFEYtOOi7N2Xvg/hqE QirA== X-Gm-Message-State: AO0yUKVNyWonokPFGK9H7fkfeULj0jjpxPROHBtAWwgH8wO1mzPpJHfq Ts4XcQdqQX6S4WRadDy7SUORPg== X-Received: by 2002:a17:903:247:b0:19e:8076:9bd2 with SMTP id j7-20020a170903024700b0019e80769bd2mr2490767plh.17.1677850682759; Fri, 03 Mar 2023 05:38:02 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id m9-20020a170902768900b0019ac5d3ee9dsm1533125pll.157.2023.03.03.05.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 05:38:02 -0800 (PST) From: Sunil V L To: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Jonathan Corbet , Anup Patel , Andrew Jones , Atish Patra , 'Conor Dooley ' , Sunil V L , "Rafael J . Wysocki" Subject: [PATCH V3 14/20] irqchip/riscv-intc: Add ACPI support Date: Fri, 3 Mar 2023 19:06:41 +0530 Message-Id: <20230303133647.845095-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303133647.845095-1-sunilvl@ventanamicro.com> References: <20230303133647.845095-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759354065556973960?= X-GMAIL-MSGID: =?utf-8?q?1759354065556973960?= Add support for initializing the RISC-V INTC driver on ACPI platforms. Signed-off-by: Sunil V L Acked-by: Rafael J. Wysocki Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley --- drivers/irqchip/irq-riscv-intc.c | 77 +++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index f229e3e66387..f522510dc1f3 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) "riscv-intc: " fmt +#include #include #include #include @@ -112,6 +113,30 @@ static struct fwnode_handle *riscv_intc_hwnode(void) return intc_domain->fwnode; } +static int __init riscv_intc_init_common(struct fwnode_handle *fn) +{ + int rc; + + intc_domain = irq_domain_create_linear(fn, BITS_PER_LONG, + &riscv_intc_domain_ops, NULL); + if (!intc_domain) { + pr_err("unable to add IRQ domain\n"); + return -ENXIO; + } + + rc = set_handle_irq(&riscv_intc_irq); + if (rc) { + pr_err("failed to set irq handler\n"); + return rc; + } + + riscv_set_intc_hwnode_fn(riscv_intc_hwnode); + + pr_info("%d local interrupts mapped\n", BITS_PER_LONG); + + return 0; +} + static int __init riscv_intc_init(struct device_node *node, struct device_node *parent) { @@ -133,24 +158,52 @@ static int __init riscv_intc_init(struct device_node *node, if (riscv_hartid_to_cpuid(hartid) != smp_processor_id()) return 0; - intc_domain = irq_domain_add_linear(node, BITS_PER_LONG, - &riscv_intc_domain_ops, NULL); - if (!intc_domain) { - pr_err("unable to add IRQ domain\n"); - return -ENXIO; - } - - rc = set_handle_irq(&riscv_intc_irq); + rc = riscv_intc_init_common(of_node_to_fwnode(node)); if (rc) { - pr_err("failed to set irq handler\n"); + pr_err("failed to initialize INTC\n"); return rc; } - riscv_set_intc_hwnode_fn(riscv_intc_hwnode); + return 0; +} - pr_info("%d local interrupts mapped\n", BITS_PER_LONG); +IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); + +#ifdef CONFIG_ACPI + +static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, + const unsigned long end) +{ + int rc; + struct fwnode_handle *fn; + struct acpi_madt_rintc *rintc; + + rintc = (struct acpi_madt_rintc *)header; + + /* + * The ACPI MADT will have one INTC for each CPU (or HART) + * so riscv_intc_acpi_init() function will be called once + * for each INTC. We only do INTC initialization + * for the INTC belonging to the boot CPU (or boot HART). + */ + if (riscv_hartid_to_cpuid(rintc->hart_id) != smp_processor_id()) + return 0; + + fn = irq_domain_alloc_named_fwnode("RISCV-INTC"); + if (!fn) { + pr_err("unable to allocate INTC FW node\n"); + return -ENOMEM; + } + + rc = riscv_intc_init_common(fn); + if (rc) { + pr_err("failed to initialize INTC\n"); + return rc; + } return 0; } -IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init); +IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, + ACPI_MADT_RINTC_VERSION_V1, riscv_intc_acpi_init); +#endif