From patchwork Sat Aug 7 13:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1514679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=es6cS5hj; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=mAnGANOl; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=M1Uwk/1J; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GhjxV2qYKz9s24 for ; Sat, 7 Aug 2021 23:34:22 +1000 (AEST) 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=JlxXbQpiMdduc2oZ32zIl/m/83oFD6LxU3evwrfFaAM=; b=es6cS5hj0D+kx0 SmYEgu5MQJE9YmOXFXhA0wGj5cdUjql+0M7EB8ghUqhuejg7fkbG3t2LeP8+FoT9rpFd5XKZCwkrv zgVkRwuUkNznUjxMG0DXwyacgQz4hZjkB5wy2441I0tVe0oOa8VqTnSRkH1PfOeaaZ6vL/6JLIBH8 P+0HZjFuMBAGCPT1r31a1+QdY6u5Ky4kjdoo6SpQXC0Puj8832QI6Xqg0/8klMwlQItZ8aESW7Apg a35BKf8blAHwgsCT1HN461IUbp8ZC3payiTQbPjt5oxmCUg59ycy0hZYH9KZ3RBIT44CILnMpMpnD ocv+0LH1QtNDxyZ4k5+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mCMSu-00Epjk-Vp; Sat, 07 Aug 2021 13:34:16 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mCMSr-00Epgp-VM for opensbi@lists.infradead.org; Sat, 07 Aug 2021 13:34:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628343253; x=1659879253; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=oEdxqIcjRjRJjSrZbeWZK0vvIxHQ3rkY/fiO2vQXrLQ=; b=mAnGANOliGMke/AgUok+P8DOdNfq2sM3PRnDKkV86bbke+KrJq4WjD5m js8HaSwDywJW8cw4sUnNxb7W4YdMDkjzSZJHcMfRavgahYAHRk38GuILR KhHFB1w1kUfzVyqpwl+jOky9/uM8owxdSihaqCn1+cjP0ACvF3Q5BHhYF E9LeyekZce3jf8ybi/5+U1SJmxJbJVdW0xV5vClaq64qETBaQASmqQuYX XECmrz65O6gJMMsBYr0jzxS4kO6wdOgCMOV7VnlpiNf7ZR+VmELS4emZs CtzjX7y9m8kdFmzSgcNvs4eifGNYmAuukQo/r4OynY2r8lL278qijB8ES g==; X-IronPort-AV: E=Sophos;i="5.84,301,1620662400"; d="scan'208";a="175779556" Received: from mail-bn8nam08lp2043.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.43]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2021 21:34:02 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eDWf+EYeDwlNiLH5aZhy7X8YpnmPDBCLkihfEO/zlMD1y5t/A3+X7M/7bHGV9w4TnFqj68g8owJR1GlYTOpCmYWzHLt+Sw+R7B7Wm2owVARCbP19Fx56yv7v5IWtHVSd2z/+2djGswFyLBp8+2XfejYw3OSV99OU5n7RLu0nEdTCShUYBM1dy1AA1a8KAfQp6Zc1Q3vu3eo11hnlcPdXWGavjSnNsPNTZ0Uv3uXS6RwMX/lQSrzlcx586UyywTn/G7n6eMuUjEs6S6UWUL19iqAJC4J4hkcWI5ysdHFS6XOngc7dI/RIfHDBWK7Eqc8d+3NOU9XWrztzpuasUFpbeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eIGpiQCq/YkZIdk9lQUjutV3nb1vyofnAckn547O7ME=; b=DtSmb3snGmSazJwhJupKAtLqCj+jIDBsYJgEzcniixb6b9NrzsrejUU7JbbSCLd0aUWExRMfVWXD5b1cZG2Hn8/ABUTgK/EaG70mzhPttNT4CS2r1SP11aXkJLJ2VMkXaltXxH4og80YN27yIqPvEC1wX5Wgh4brw74pGDp09szo8H8TexMyHJQ8m5BMyzcxPr0kw0uIxrVNng66oORGAEW1Wwpf495+qVid7KVbGU6+ybWWiTwY2025RVdOBbR6Tc9wiTyhnqZErx7IxA2/L1c3VXdUkBKG9RC8LleTcn5NUylFN7VPZcRLUd3vVjF2y6rewz2d31GJrPUZ6CAX3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eIGpiQCq/YkZIdk9lQUjutV3nb1vyofnAckn547O7ME=; b=M1Uwk/1J/2Hk0glQChNdXEByE0u9VTeoJBpgdapozGuCvdJ5BOWWbV/4zvuoDICY2mJ3K04dAc2ISlX6SGFHcT8Dz3k4uk/Fc8vhciw+mO0Lt3MAmygheVNakXOI3scC6Kw+1qT3EUX3FncrDpMvgYu6ivlz0+L5NXRP72yrQjk= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7764.namprd04.prod.outlook.com (2603:10b6:303:138::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Sat, 7 Aug 2021 13:33:59 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::c9be:b1e1:60be:ef9d]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::c9be:b1e1:60be:ef9d%6]) with mapi id 15.20.4394.021; Sat, 7 Aug 2021 13:33:59 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 3/5] lib: utils/fdt: Extend fdt_parse_aclint_node() function Date: Sat, 7 Aug 2021 19:03:20 +0530 Message-Id: <20210807133322.545675-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210807133322.545675-1-anup.patel@wdc.com> References: <20210807133322.545675-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR0101CA0068.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::30) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.51.99) by MAXPR0101CA0068.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Sat, 7 Aug 2021 13:33:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 56f6c926-8e4f-4e11-4d02-08d959a80370 X-MS-TrafficTypeDiagnostic: CO6PR04MB7764: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Cg/4u2xNCTftEOX3FNvA8iXObi9+HHcxNKd2i9x8klsyIRWutCSGbVaVbX3BRxuekPCb50ZUewUokrWtm55P3Zwkipmkwo/7ri7DKjqhgf/sMpL6kOfF0vYss+ACXK3C3XWMBdL5rLnbl1+zsKUcjGWQIKJuHgs6HqZP8e1D8+ucr+HXLqrtnhHT65guiIylOLuB4+RWFzk0D/6PfqjiEgiJ9VuELq3t0wy548NkWGac3d5VKH/oJdLpBi5u++kvTgvBPTm++kTBjX7c57zEynzPGI6Aua9Sfs0ZJaTgvCO9a8aGyZSZGIQbU1Ydik1KhrE15rZuDFTD09pQSOHlriycI0TDbnqLLC8zX6VmB3Lnxvz4ri/1BBCs599vgAAMBGt3T8WhfJsAamtp3r3xkMFcjX0on2TWJgxCZzgQOqIH748yPKdr8a6CV7GFAEGGE1mrGAZnvDf+jXdb3PDufU1boKyyaNzqQV+X/qrc864sODvlo7nN1KOw4OUNVtnM2y+CdLHSa7ipkM/LzRkCrwku8/EaiOXFilIb4dHrLA9cv0L9thtcj8CT8YBQZsEB12u2IFjthmsDxgCaVE6T1Cm4kqZ+EVT6/gjuIKCtKSeLoiEbbTtmd3so6wW7cxdaDaHHbutHxS6evTrhkVkIGtGDNTV6tPwZqj7dDYfu7oK3RNld5k17aFbQh5ECDWtt9tuTRGV8V/Mr6WqbX/PYQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8886007)(54906003)(55016002)(2616005)(956004)(38100700002)(38350700002)(6666004)(36756003)(4326008)(86362001)(8676002)(6636002)(26005)(2906002)(44832011)(186003)(8936002)(1076003)(110136005)(316002)(7696005)(66476007)(52116002)(83380400001)(66946007)(508600001)(5660300002)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TR0UJind0ZqJcx578bGBgTg+OE+OJtP8yCyy+u3yV9WAlnqaozOLLY+bqaYjavX9vHknDKL/PFty78nmKP1iX4GpLx/nwxoCwnGZL8kHxdwCt0heYj2rn4JE85vdjdMN5PvEvdCzLgzjPviOxgesvuPrJZLaMGuTslajcjKLmKCKf9BinM8wuvuE+1XXY42rsq7v6o/hX0ZIH6QazXvMtSIPxvjDZMxopw/OSja9FtQCH1aspakeCEPVklvqpNQdvY9oB8IFEDlhMD9zrENveZhMuZCcU+ON4H6XyrnBDInAcgOWuuBw0+DC3bSQzlyH1jBk5B3tyk0vYQtxfxekdkFxe5l+FVyu/K34IvF4xYK7phgN4MGaYceDF0UZacAGmI0/FDyHXkYpTduxc80khz7p4dsVsLj36y71cO606ciB6VM2um14vdcKYIOqx1JiEnCzDYm4X3i8Z4ead4njczZgGPwF54JOU1NXfL8Nbi+NgFMt3cHUp8261y+706cXliyVRaJkdDkmpOs/DaBrBztsTL1tjSwq7CPGoZTwvBo8f330Blk9eC0DBd2e23M3VKvsU+edWWGNYQFGPyT8RPalf4FpITs7gSg2284C6l21RhnmrlcSPNkZx1YHMX1+FQaTbsy5UNaL2xzmJAlVLRoL2nEk3bg7nAEAkZAqSq48hVlGO8OKPfaKkEBhHbt67sRc62I30nAmuwEoMhKyrNtN6SRl4SDSGlyHybTCQrxVgFR+WyWboET2p+EvZ+l6r272MOpVXHHtG2WmbiNiPf9viJPutNYasVgTq9Y32tjsfL6ZFxva75SG7m5LZSYoUmA27Ojp6aQhOcP34Nm9lbLRrcSqKopXIhXIRAJSkUrasON1sWtmlVg0z6uZRG3Lg9LzxhIrxP5dqC1xDWQJ4KkRqFwN+yyjs8jduInWCfcNcjykd38P5PcXOEDQ0lVDGSpZQxOc7vbeJE/JsoUEXU+d3hBOFW31xXfXu6QAnFsK6C1pS6d8BrYAuYSNdIJYr5ygJj1Yzj7g/Iqc68pNRIvbmO5GqnE4yo/juz6EWuo3LIITjKkRgGmpdYpYyI9GnjWv778hkGVwNodZvIn8/Mv/IV5Fo2X8aWkVR/TfgO5npWqvFV53E3fV3HqGVGJl6zVKl5BMA7b6bVP8n1oel9R85BKicDoMnGUzrll21gB2YgysL54r6Z8YPbySScXDuJByq0S3CXwCNHbWeWef/RnshOHXPEbPoOmANDjd+F3Hg+SX4FiZJELsnXaIWbY6hPOAg90ME+ZAy6OeVdsD8OUztSHUHnH3wKRKrfeJk0YLJXxP10yK7ij9XK8rke9u X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56f6c926-8e4f-4e11-4d02-08d959a80370 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2021 13:33:59.8178 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UGctxd+I5MlnnV2NdjHfuTBj0AIiywi808XAvGMYJEXR0/YisO3S/Jwh1xGFF0rATskhBquCZ2fg/OIp0ma+9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7764 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210807_063414_106528_8915DB0F X-CRM114-Status: GOOD ( 18.12 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.42 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The fdt_parse_aclint_node() is used to parse DT node for SiFive CLINT, ACLINT MTIMER, and ACLINT MSWI devices. The ACLINT MTIMER has undergone following changes: 1) MTIMER DT node now requires separate addresses in for MTIME register and MTIMECMPx registers in the reg DT property. 2) MTIMER DT node might have no interrupts-extended DT property when the MTIMER device has no associated HARTs (i.e. the MTIMER device has no MTIMECMPx registers) This patch extends fdt_parse_aclint_node() to handle above mentioned changes in ACLINT MTIMER DT bindings. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi_utils/fdt/fdt_helper.h | 3 +- lib/utils/fdt/fdt_helper.c | 50 ++++++++++++++++++------------ lib/utils/ipi/fdt_ipi_mswi.c | 3 +- lib/utils/timer/fdt_timer_mtimer.c | 23 +++++++++----- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 1a93e1c..2246254 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -72,7 +72,8 @@ int fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic); int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat); int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, - unsigned long *out_addr, unsigned long *out_size, + unsigned long *out_addr1, unsigned long *out_size1, + unsigned long *out_addr2, unsigned long *out_size2, u32 *out_first_hartid, u32 *out_hart_count); int fdt_parse_compat_addr(void *fdt, uint64_t *addr, diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index b68544f..5628337 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -481,38 +481,50 @@ int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat) } int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, - unsigned long *out_addr, unsigned long *out_size, + unsigned long *out_addr1, unsigned long *out_size1, + unsigned long *out_addr2, unsigned long *out_size2, u32 *out_first_hartid, u32 *out_hart_count) { const fdt32_t *val; uint64_t reg_addr, reg_size; int i, rc, count, cpu_offset, cpu_intc_offset; - u32 phandle, hwirq, hartid, first_hartid, last_hartid; + u32 phandle, hwirq, hartid, first_hartid, last_hartid, hart_count; u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT; if (nodeoffset < 0 || !fdt || - !out_addr || !out_size || + !out_addr1 || !out_size1 || !out_first_hartid || !out_hart_count) return SBI_EINVAL; rc = fdt_get_node_addr_size(fdt, nodeoffset, 0, ®_addr, ®_size); - if (rc < 0 || !reg_addr || !reg_size) + if (rc < 0 || !reg_size) return SBI_ENODEV; - *out_addr = reg_addr; - *out_size = reg_size; + *out_addr1 = reg_addr; + *out_size1 = reg_size; + + rc = fdt_get_node_addr_size(fdt, nodeoffset, 1, + ®_addr, ®_size); + if (rc < 0 || !reg_size) + reg_addr = reg_size = 0; + if (out_addr2) + *out_addr2 = reg_addr; + if (out_size2) + *out_size2 = reg_size; + + *out_first_hartid = 0; + *out_hart_count = 0; val = fdt_getprop(fdt, nodeoffset, "interrupts-extended", &count); if (!val || count < sizeof(fdt32_t)) - return SBI_ENODEV; + return 0; count = count / sizeof(fdt32_t); first_hartid = -1U; - last_hartid = 0; - *out_hart_count = 0; - for (i = 0; i < count; i += 2) { - phandle = fdt32_to_cpu(val[i]); - hwirq = fdt32_to_cpu(val[i + 1]); + hart_count = last_hartid = 0; + for (i = 0; i < (count / 2); i++) { + phandle = fdt32_to_cpu(val[2 * i]); + hwirq = fdt32_to_cpu(val[(2 * i) + 1]); cpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle); if (cpu_intc_offset < 0) @@ -534,17 +546,15 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, first_hartid = hartid; if (hartid > last_hartid) last_hartid = hartid; - (*out_hart_count)++; + hart_count++; } } - if ((last_hartid < first_hartid) || first_hartid == -1U) - return SBI_ENODEV; - - *out_first_hartid = first_hartid; - count = last_hartid - first_hartid + 1; - if (*out_hart_count < count) - *out_hart_count = count; + if ((last_hartid >= first_hartid) && first_hartid != -1U) { + *out_first_hartid = first_hartid; + count = last_hartid - first_hartid + 1; + *out_hart_count = (hart_count < count) ? hart_count : count; + } return 0; } diff --git a/lib/utils/ipi/fdt_ipi_mswi.c b/lib/utils/ipi/fdt_ipi_mswi.c index f119f9c..1f0fda7 100644 --- a/lib/utils/ipi/fdt_ipi_mswi.c +++ b/lib/utils/ipi/fdt_ipi_mswi.c @@ -28,7 +28,8 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff, return SBI_ENOSPC; ms = &mswi[mswi_count]; - rc = fdt_parse_aclint_node(fdt, nodeoff, false, &ms->addr, &ms->size, + rc = fdt_parse_aclint_node(fdt, nodeoff, false, + &ms->addr, &ms->size, NULL, NULL, &ms->first_hartid, &ms->hart_count); if (rc) return rc; diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index 3f830ad..b08ed38 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -22,7 +22,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; - unsigned long offset, addr, size; + unsigned long offset, addr[2], size[2]; struct aclint_mtimer_data *mt, *mtmaster = NULL; if (MTIMER_MAX_NR <= mtimer_count) @@ -31,18 +31,19 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, if (0 < mtimer_count) mtmaster = &mtimer[0]; - rc = fdt_parse_aclint_node(fdt, nodeoff, true, &addr, &size, + rc = fdt_parse_aclint_node(fdt, nodeoff, true, + &addr[0], &size[0], &addr[1], &size[1], &mt->first_hartid, &mt->hart_count); if (rc) return rc; mt->has_64bit_mmio = true; - mt->mtimecmp_addr = addr + ACLINT_DEFAULT_MTIMECMP_OFFSET; - mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE; - mt->mtime_addr = addr + ACLINT_DEFAULT_MTIME_OFFSET; - mt->mtime_size = size - mt->mtimecmp_size; - - if (match->data) { + if (match->data) { /* SiFive CLINT */ + /* Set CLINT addresses */ + mt->mtimecmp_addr = addr[0] + ACLINT_DEFAULT_MTIMECMP_OFFSET; + mt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE; + mt->mtime_addr = addr[0] + ACLINT_DEFAULT_MTIME_OFFSET; + mt->mtime_size = size[0] - mt->mtimecmp_size; /* Adjust MTIMER address and size for CLINT device */ offset = *((unsigned long *)match->data); mt->mtime_addr += offset; @@ -51,6 +52,12 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, /* Parse additional CLINT properties */ if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) mt->has_64bit_mmio = false; + } else { /* RISC-V ACLINT MTIMER */ + /* Set ACLINT MTIMER addresses */ + mt->mtime_addr = addr[0]; + mt->mtime_size = size[0]; + mt->mtimecmp_addr = addr[1]; + mt->mtimecmp_size = size[1]; } rc = aclint_mtimer_cold_init(mt, mtmaster);