From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E3BDC27C50 for ; Sat, 1 Jun 2024 15:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d2OHXGMxKSkWdBZl3ien1FwkrKzRHmWgXBOgnxFnFsc=; b=QgW0I0eBJWAIZa OvhLJOerzB4us/LNRA31Uk8QNVf9y2nx5e6PTrfFhu46cBeEfxslq0T2uyMSMPrKgMmnIY+uhmtUS uEqub87depNbgvKbSTvdZ6K/1fNdLW16Qww/IDwDHdph5pQ1SUrGHZZLtqcu07e0S+cARpBzkhlY3 Q9KAZWB2CA/POAezTIHHUkI1ogdXlg6DgkVZJbPLhrm98scEe7+pN0Y1Pty9STJbC8xvLp1IDeStu 68dxsiQYK0s03+ga7nVQNkVs3K/i/3vKLkVSc2XxLaafeAvcxdwSbfvgkDe/rQocY0UizgYNwskFl VJcj96KvZRWOFB3j8fWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDQJf-0000000CqH8-1HvC; Sat, 01 Jun 2024 15:06:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDQJ5-0000000CplY-181f for linux-arm-kernel@bombadil.infradead.org; Sat, 01 Jun 2024 15:06:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; b=mVVDarv4ELvc69zM+Go8cSulbE phXsJD8sLnfvFnyXyPcwznISRWt1SMzvG2tmY6Ee9hCvv0gGfw1XRzUqdizQjOPBPVay7TIqMbajf jDfVBZ/PsfyG/hw/gWaR+Hrvg9ChncV86qpYAJnolnTwsGvAHS4XC4iPJi7QxLbWo1/KX70xTa8CO C0slc1LSqyfzYlIKpFj6g/vkPiRyrQ20lI21spBq0F69S4TIUJwWoSMHOaf9fOWoVK1j8tvo0rGZG DqNmCuC5FblHvAi89qHrII31+ifbZnAWWMiHbZ9Qj8RZ0OFMlyzuY/a5FA4Mx63fDy1S1vs7Ayv1g 7UHJsbsA==; Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDQJ1-0000000F3Zf-2ffa for linux-arm-kernel@lists.infradead.org; Sat, 01 Jun 2024 15:06:05 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-702555eb23bso537631b3a.1 for ; Sat, 01 Jun 2024 08:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1717254360; x=1717859160; darn=lists.infradead.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=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; b=Lo0AWaW8/Z2YIqyfoX1wGiC49tEtVeWB3KB9DtU/cEOQ9SA/T7iFdAwJW6luBO0VvA TG4e/cvkpHX3BVi9e/y2jr9DNQ1vSlKZQd7lG82MZ6AFikqb7TP6Z2w5FyGWsLQJANfG t3Oy/3/OKldIS1rBadbdaXUMT8Rb1+kqcb9BvneWVesVTpQRYi9XvaBTpgfwJZq/jyUI pwuSvib3UMuTvSo0hOTNLNCrZ0unouz4PgLcWNMGbB+KCJHSbaPcSYdWe340uUHBfmII 3ZBi730FPkj/ZT4Ps4SRpjaRXthz0fMJwPTz03PJMcbV9gytGNmPnHR3osr2oqjKvDDw EWaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717254360; x=1717859160; 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=3PWsEZjmDFCls294wVt5rkIwO83PA99zSOvcBamPy6U=; b=TEqKaTCrQiy6pfenvPMnISfS1fpY6puRn154W8il1cL7nMaXJbFV2p+JOHlaKrrweE jYs+wkxC7nrgPRPdHY41x3mGRzVWDEbZJmmg1yey3gJk0aziujyJxzMOI6oT/+yEzOoY 304sM2pggu1YGQv10KDAT1C+pY32Bt/uEDD5Z/SbTF/2exIcYflz1mDS2hQZvz+BrGij 8cuyHLzgVlA+kwByXtSh4yErgUNmy0AdJeoRFpZZstQeO9Vz30mgsxr+uZAp79kIxrs4 tFlPdsXiU3+ETt6DeNWhvPNFn5kLLF2sUgpkH7b9Y/4lCQcIu1KOuZQzfbNkOOukTbJc Delg== X-Gm-Message-State: AOJu0YzV+O21Or38htsuBRNvZA7jyeRxFjtDK2olahjNk+Cb9XzCdC7A 66CWplPwMXfIBE4BLiweoN7olmQPtLLS1togqxD72L+Dv9q77Wo/g1aQ5Wrr0LK2FzqjnzyPj+C 4Zq8= X-Google-Smtp-Source: AGHT+IFCMwJXYdknheI4VS/aPP1tbqbAGPqO3DadWwdo/Evl6cETwOaxePiXpISSwiqztkqdIn5wYA== X-Received: by 2002:a05:6a20:a115:b0:1b1:e7de:4d36 with SMTP id adf61e73a8af0-1b26f0f1b28mr5381872637.2.1717254360532; Sat, 01 Jun 2024 08:06:00 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.187.237]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6c35a4ba741sm2559410a12.85.2024.06.01.08.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 08:06:00 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Robert Moore , Conor Dooley , Andrew Jones , Andy Shevchenko , Marc Zyngier , Atish Kumar Patra , Haibo1 Xu , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Sunil V L Subject: [PATCH v6 14/17] irqchip/riscv-imsic-state: Create separate function for DT Date: Sat, 1 Jun 2024 20:34:08 +0530 Message-Id: <20240601150411.1929783-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240601150411.1929783-1-sunilvl@ventanamicro.com> References: <20240601150411.1929783-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240601_160604_083692_2B0CF885 X-CRM114-Status: GOOD ( 16.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While populating IMSIC global structure, many fields are initialized using DT properties. Make the code which uses DT properties as separate function so that it is easier to add ACPI support later. No functionality added/changed. Suggested-by: Thomas Gleixner Signed-off-by: Sunil V L --- drivers/irqchip/irq-riscv-imsic-state.c | 97 ++++++++++++++----------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5479f872e62b..f9e70832863a 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -510,6 +510,60 @@ static int __init imsic_matrix_init(void) return 0; } +static int __init imsic_populate_global_dt(struct fwnode_handle *fwnode, + struct imsic_global_config *global, + u32 *nr_parent_irqs) +{ + int rc; + + /* Find number of guest index bits in MSI address */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", + &global->guest_index_bits); + if (rc) + global->guest_index_bits = 0; + + /* Find number of HART index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", + &global->hart_index_bits); + if (rc) { + /* Assume default value */ + global->hart_index_bits = __fls(*nr_parent_irqs); + if (BIT(global->hart_index_bits) < *nr_parent_irqs) + global->hart_index_bits++; + } + + /* Find number of group index bits */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", + &global->group_index_bits); + if (rc) + global->group_index_bits = 0; + + /* + * Find first bit position of group index. + * If not specified assumed the default APLIC-IMSIC configuration. + */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", + &global->group_index_shift); + if (rc) + global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; + + /* Find number of interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", + &global->nr_ids); + if (rc) { + pr_err("%pfwP: number of interrupt identities not found\n", fwnode); + return rc; + } + + /* Find number of guest interrupt identities */ + rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", + &global->nr_guest_ids); + if (rc) + global->nr_guest_ids = global->nr_ids; + + return 0; +} + static int __init imsic_get_parent_hartid(struct fwnode_handle *fwnode, u32 index, unsigned long *hartid) { @@ -578,50 +632,9 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - /* Find number of guest index bits in MSI address */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,guest-index-bits", - &global->guest_index_bits); + rc = imsic_populate_global_dt(fwnode, global, nr_parent_irqs); if (rc) - global->guest_index_bits = 0; - - /* Find number of HART index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,hart-index-bits", - &global->hart_index_bits); - if (rc) { - /* Assume default value */ - global->hart_index_bits = __fls(*nr_parent_irqs); - if (BIT(global->hart_index_bits) < *nr_parent_irqs) - global->hart_index_bits++; - } - - /* Find number of group index bits */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-bits", - &global->group_index_bits); - if (rc) - global->group_index_bits = 0; - - /* - * Find first bit position of group index. - * If not specified assumed the default APLIC-IMSIC configuration. - */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,group-index-shift", - &global->group_index_shift); - if (rc) - global->group_index_shift = IMSIC_MMIO_PAGE_SHIFT * 2; - - /* Find number of interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-ids", - &global->nr_ids); - if (rc) { - pr_err("%pfwP: number of interrupt identities not found\n", fwnode); return rc; - } - - /* Find number of guest interrupt identities */ - rc = of_property_read_u32(to_of_node(fwnode), "riscv,num-guest-ids", - &global->nr_guest_ids); - if (rc) - global->nr_guest_ids = global->nr_ids; /* Sanity check guest index bits */ i = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT; -- 2.40.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel