From patchwork Thu Aug 3 17:59:07 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: 130795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1338346vqx; Thu, 3 Aug 2023 11:44:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlGBRY4hUvcnQ20EMc50bqMUAjKq9+8Ji/O6eofDNGQU5/ttpyPHr+G0n+ip0vR13td3Y4pF X-Received: by 2002:adf:e889:0:b0:317:660f:6f5e with SMTP id d9-20020adfe889000000b00317660f6f5emr7027475wrm.42.1691088240525; Thu, 03 Aug 2023 11:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691088240; cv=none; d=google.com; s=arc-20160816; b=wuUYHEa4GPxZfUJwHsYHjiIyL4rf+3ZV3KP8mqhdzs8pgSFrpNrosrqvvyUX1/AOkl vxFv+jNChJo7ChxpNkYu2V17Tuu4pxol0Ez9isWZgeSVMHc8kJjo9KOz6zd08Uru9pwE Kc+zTR2JATi5yutHemtK3owfBVnSZSP8VQSHPAdMiMYjIQWClqa2dTQIfmWU+dYzVjRs ErWoTEJ+aOOQcQPpJG84LR3hjS96dERKKUEu+0VAW38Lef0vkGLhy4F7qx23TAYHlSqt nNvUm12c5/3/AmaLA/W56PJTRoIDGexNOp5p5TgJ4cabHYpxAY9dlDsCNhnat58zgsKx PDWA== 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=Vqi3iZnSO0pCz4r86HvzjXAIoq/LUkNm+cOCoheLdcU=; fh=dzn7FZXuyjRD/SsADoLVmv8ajN6bypv0shpvYBNDmUc=; b=xwmWTufJnBJviwTPY22C0RFYTEhrMdvGvzvG8Jbmx8aevV8jbXBJjLdCBRQaeMJfdj UMoLIq8rauF6XnWFIRP4IBLu5h+YPZKnUACxj/tPidPiSnsHg1NKUA8Rvd9XbDkfsL1B iTdXAhunBmz9pWVElRSI5YH7wjwmjcALRUCkZk4/ZqVW67RIGahDAPnnQ58xF2fVKajx p6n+bkd7EqKWkInoMrhfSodfGbPy7kI4bud9lDtbsZdTJdgvg44oXD2DqogcocnpamCE DZHQ8NfFZ4obwGj95wR6+zXAezXCeTIUNFOdqGYb1AqDD9tjIbNPWWqwv+CStuFi7u1h qX9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=RGBk6rx5; 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 q19-20020aa7cc13000000b00522d912cd61si213824edt.175.2023.08.03.11.43.36; Thu, 03 Aug 2023 11:44:00 -0700 (PDT) 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=RGBk6rx5; 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 S231553AbjHCSCm (ORCPT + 99 others); Thu, 3 Aug 2023 14:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbjHCSCD (ORCPT ); Thu, 3 Aug 2023 14:02:03 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F4944BC for ; Thu, 3 Aug 2023 11:01:15 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686bea20652so1129518b3a.1 for ; Thu, 03 Aug 2023 11:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1691085663; x=1691690463; 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=Vqi3iZnSO0pCz4r86HvzjXAIoq/LUkNm+cOCoheLdcU=; b=RGBk6rx5Hg20bOXt+KLaRA26VcrOyNOoG/eZ7AxmlMnjFLn1DtSewmy8B6izdUW0E9 GsvBNf8e3jLCLs9h3DTaOaEA4Km0R9H4SNrQ9+L743IjhhgsHfGIylndzoIQZ265aQGL n3u5HhJfofcxpdy320nz2rQ2QoD01GiNeIZKOW51Fa3p9Z3xFqseEFfup54Xbr4HF94E 1EWqxSsfqSg9VtpcDRRRk5I1Neux3XeF5LvtGw6Xi2P1PAQzmkcPwAZHb9qGJ5o3kBoC gZ6YooLlmoRGD/mmS9270tnx8asDRFY2Qh6PHJuGg7a6wwcl70gJWrfxbZ1zW3Bv9Blq Sc+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691085663; x=1691690463; 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=Vqi3iZnSO0pCz4r86HvzjXAIoq/LUkNm+cOCoheLdcU=; b=SjuMPeQ+RI7lN0CTxc2wv8KLYndl94cyPvDHHfZAUKlckCsulj3vnk/wRmTtMwDKLo XybtnjM4H6av+Tz3+B3NXnzXCtBm51OwszrcdQtmr2hmDUrecDS1FfkpTFNZ9VEcljrA Bdipdz59MqcEhktjKDF/jrAwOXGW2FgyDgZ/aP0+NXhnNxj2ry8bF6s09a+KtXoM4GXm M7prH9Wt603c+KSnoLFIauOtvMBC0HrMG2LN72rNxTwbt5Jk863k6rbyqT8Nq7jK7Eym uSl0sS+wW3u70jSRxWF033zCFgIQoxaIAVWD4LjNrH/+3RHZdFiNxgzfbIznr9UNSzV8 MDlw== X-Gm-Message-State: ABy/qLYRYXVCEpFmdQ1HHSLFHpC2qXc47HVdVbKi5oftCOCr2VOajXtK 4VXr14D8wuTCkNZ2v0Y4Ch277w== X-Received: by 2002:a05:6a00:2351:b0:687:5c3f:d834 with SMTP id j17-20020a056a00235100b006875c3fd834mr8861510pfj.11.1691085663545; Thu, 03 Aug 2023 11:01:03 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.190.143]) by smtp.gmail.com with ESMTPSA id s8-20020aa78d48000000b0065a1b05193asm134952pfe.185.2023.08.03.11.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 11:01:03 -0700 (PDT) From: Sunil V L To: linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" , Len Brown , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , Daniel Lezcano , Thomas Gleixner , Anup Patel , Marc Zyngier , Bjorn Helgaas , Robert Moore , Haibo Xu , Andrew Jones , Conor Dooley , Atish Kumar Patra , Sunil V L Subject: [RFC PATCH v1 12/21] irqchip/riscv-intc: Use swnode framework to create fwnode Date: Thu, 3 Aug 2023 23:29:07 +0530 Message-Id: <20230803175916.3174453-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230803175916.3174453-1-sunilvl@ventanamicro.com> References: <20230803175916.3174453-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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1773234542974460685 X-GMAIL-MSGID: 1773234542974460685 By using swnode framework, all data from ACPI tables can be populated as properties of the swnode. This simplifies the driver code and removes the need for ACPI vs DT checks. Use this framework for RISC-V INTC driver. Signed-off-by: Sunil V L --- Documentation/riscv/acpi.rst | 21 +++++++++++++++ arch/riscv/include/asm/acpi.h | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irqchip.c | 46 ++++++++++++++++++++++++++++++++ drivers/irqchip/irq-riscv-intc.c | 12 ++++----- 5 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 drivers/acpi/riscv/irqchip.c diff --git a/Documentation/riscv/acpi.rst b/Documentation/riscv/acpi.rst index 9870a282815b..e2406546bc16 100644 --- a/Documentation/riscv/acpi.rst +++ b/Documentation/riscv/acpi.rst @@ -8,3 +8,24 @@ The ISA string parsing rules for ACPI are defined by `Version ASCIIDOC Conversion, 12/2022 of the RISC-V specifications, as defined by tag "riscv-isa-release-1239329-2023-05-23" (commit 1239329 ) `_ + +Interrupt Controller Drivers +======= + +ACPI drivers for RISC-V interrupt controllers use software node framework to +create the fwnode for the interrupt controllers. Below properties are +additionally required for some firmware nodes apart from the properties +defined by the device tree bindings for these interrupt controllers. The +properties are created using the data in MADT table. + +1) RISC-V Interrupt Controller (INTC) +----------- +``hartid`` - Hart ID of the hart this interrupt controller belongs to. + +``riscv,imsic-addr`` - Physical base address of the Incoming MSI Controller +(IMSIC) MMIO region of this hart. + +``riscv,imsic-size`` - Size in bytes of the IMSIC MMIO region of this hart. + +``riscv,ext-intc-id`` - The unique ID of the external interrupts connected +to this hart. diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 0c4e8b35103e..0ac2df2dd194 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -68,6 +68,7 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } int acpi_get_cbo_block_size(struct acpi_table_header *table, unsigned int cpu, u32 *cbom_size, u32 *cboz_size, u32 *cbop_size); +struct fwnode_handle *acpi_rintc_create_irqchip_fwnode(struct acpi_madt_rintc *rintc); #else static inline void acpi_init_rintc_map(void) { } static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile index 8b3b126e0b94..8b664190d172 100644 --- a/drivers/acpi/riscv/Makefile +++ b/drivers/acpi/riscv/Makefile @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o +obj-y += rhct.o irqchip.o diff --git a/drivers/acpi/riscv/irqchip.c b/drivers/acpi/riscv/irqchip.c new file mode 100644 index 000000000000..36f066a2cad5 --- /dev/null +++ b/drivers/acpi/riscv/irqchip.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023, Ventana Micro Systems Inc + * Author: Sunil V L + * + */ + +#include +#include +#include +#include +#include + +struct riscv_irqchip_list { + struct fwnode_handle *fwnode; + struct list_head list; +}; + +LIST_HEAD(rintc_list); + +struct fwnode_handle *acpi_rintc_create_irqchip_fwnode(struct acpi_madt_rintc *rintc) +{ + struct property_entry props[6] = {}; + struct fwnode_handle *fwnode; + struct riscv_irqchip_list *rintc_element; + + props[0] = PROPERTY_ENTRY_U64("hartid", rintc->hart_id); + props[1] = PROPERTY_ENTRY_U32("riscv,ext-intc-id", rintc->ext_intc_id); + props[2] = PROPERTY_ENTRY_U64("riscv,imsic-addr", rintc->imsic_addr); + props[3] = PROPERTY_ENTRY_U32("riscv,imsic-size", rintc->imsic_size); + props[4] = PROPERTY_ENTRY_U32("#interrupt-cells", 1); + + fwnode = fwnode_create_software_node_early(props, NULL); + if (fwnode) { + rintc_element = kzalloc(sizeof(*rintc_element), GFP_KERNEL); + if (!rintc_element) { + fwnode_remove_software_node(fwnode); + return NULL; + } + + rintc_element->fwnode = fwnode; + list_add_tail(&rintc_element->list, &rintc_list); + } + + return fwnode; +} diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 1a0fc87152c5..1ef9cada1ed3 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -203,6 +203,12 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, rintc = (struct acpi_madt_rintc *)header; + fn = acpi_rintc_create_irqchip_fwnode(rintc); + if (!fn) { + pr_err("unable to create INTC FW node\n"); + return -ENOMEM; + } + /* * The ACPI MADT will have one INTC for each CPU (or HART) * so riscv_intc_acpi_init() function will be called once @@ -212,12 +218,6 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header, 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; - } - return riscv_intc_init_common(fn); }