From patchwork Wed Jun 23 06:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495955 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=zVA4M6L2; 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=jo6AeC8O; 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=sJAh+cF0; 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 4G8t3h2LYMz9sCD for ; Wed, 23 Jun 2021 16:03:12 +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=QNexm9ZKXhRZRpcxNHp9ypGuzyRDCzd0WC8otCoYE2Q=; b=zVA4M6L2jFmedi HId9Odbvfo8ePCroJLLllOrh9jIzVm6wopMgTjih5VyJyAJJHdw/bCHhIIAuUbfjzZsDO26dKYDgq AhILDCOMNXvNowVt1KjJdrgwGi1u/ioggzNldrOmrUFGwT3tgLu6f+U+0/cizauEkR1Jo3lq2460H MqtwWFOQD5DHgCgkznz+3cK9L2oW98OicY4mE/rxg54iS3zTUa13TgfICnGe7tdhZpe6py5FR9mng nBEcMfOreeKaGXFmKV/KYji+GGtWMPVjH6vMQa9Tcna17BL7jTYZ5mRJK/bPsRed6FsuLtZRvQfGe VwMA1nMEFYLZonEAvg9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvyd-009Tvy-9r; Wed, 23 Jun 2021 06:03:07 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvya-009Tup-3W for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:06 +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=1624428183; x=1655964183; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=gViMD2Qzm77wIBTzVZiRP720oT39A3y/sqrQdK9okik=; b=jo6AeC8OuNe1/+TpJ0jACDiJLo4dEUAsbMSygcwKrwxx05n5xgY4eewV MgyGQ/uTbeaDegWxJaSEN8y+oPByVZtMJ+EIn3uLJc1ExJjxHcFGZ+yh8 UFw5z47vB28feDcgkw+L5zWpDfabCYXYfPcQMbvMQdZpgxLCS7xE7Y/CC OZdurW1cShwDhD5nRgS+hjWMr8i48VFnP6KeEV3y3wY41FIf2oonN1sXn GuHHFAf3Pm332fWM5HGEmciMD+lbMUnyr0gcE+ysPm2bMsx65YMuWEpVH sPuyCzatFkCqMFi0stFG2vB77474PnC5aU5LCzbduUNH14srlrerIEOcE g==; IronPort-SDR: LPp8g4zSRjEMqaGoJayRaPuS3BGBUkc7ZQUneNnv0w6KGevf0KvELEdndn+navuXEA7jimDORn IKaurBBuKWvDgtw0ZfdPAkpzRVveS+qyhRewWi8uF57WW3i5aVRbxuXDpQEyTvBkaDSGKPR0T/ I9NG2D+vRsrig5rf4IsvarVTXEgW11SlcSlojGM15regu1mqTCyFUrdzl0gZHaW1y4PdzLXL5T sBsFsSU0KdBjc5hLwftI4pMSy66BBLc5axWNp8gw5tQ2r28nh6SHNNfbeOw3+gQ+wv021QJ0yc J3U= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="172661851" Received: from mail-mw2nam10lp2103.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.103]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:01 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l8Z/cV76h81HFebXFSWYuMc+lggRksgavjQBoFU7BwXEa4O9nIId6x+DSOGC1nzPfgcHnXQhDIbC3QUIEblIiMnJbqlmlnqNuwqVTjRlwz2zjeL6fXRGMZ5IMnML+ZBE6fcJvUAlD4WZ/5JmENYqZsWw3E48QdtLrW/lUu9l6YFHGI9dGXA00hsDUf4WyvmfcVdn+HhWXST13MLyQJesiB1OLaAdN7lDr3avLRH74qP7LZhLX7l/UjS5dovOWj+eB+J7jzqvCjUSQt/JtqkE4XuKZBQqdakqP/NH8lNnOxkPswnFcYH+ynhuJW6cqtBKEUhyJrncSSOcGQBMxAnqiw== 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=ILJRO/taWDNAwj4zKCaBi/SEUHIh0m4eazVsbeTM2VI=; b=YmmniD7xKyh0ER7jGTkpXAlxjbplDJy9Zr0l0u91bVPe9p9YQvoy/cmEjD+5e7JfJdkPJKNt3zC1YBPaaaPqZEdvijmKkKD5ezEPVksKuTQdwHA2TJvPv9js4g4PoYdFNAP41PQXtupCsLuLFzYS2BKyZjREbjRuw0OCTHvJFaQilmrSA5E64/NMZ17P1t91ksq8YFKMm+X/ZYWIRTSIh7dL0UdtyHVYXLVSgwORnjkeSQZPziE4Va1gwys68LXE22b6x9is3QEvU90Yc6fXZmIo5HQoPF2KdsNY9YvPGuANUAVanjFJ2nm+NZRFWg8I66Kn2+XirbIceM+thqE6qA== 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=ILJRO/taWDNAwj4zKCaBi/SEUHIh0m4eazVsbeTM2VI=; b=sJAh+cF02kh4/Fiz9UjBlMW+3C4cwB14V+cJflyMHVj9wa/XQBAHYipob2lp4Vw5MCPRGS+7N3MaubIkRXKfP6PTjnRd3c5SvWjiQza2qDDykxAdp6yKU2Wh9Aoim/FrhKjO45RZcw7CPPaqSgG2lCYW71c8C5J6J7OY1a3xKP0= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:02:59 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:02:59 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 1/6] lib: utils/timer: Add ACLINT MTIMER library Date: Wed, 23 Jun 2021 11:32:21 +0530 Message-Id: <20210623060226.442030-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:02:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b83d65ca-153e-4f15-8132-08d9360c8c87 X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X3w9TbO0F+VmWlz/dlGBfItiIvFaMnBZltRWf9FyhKKh64FhJhOzqxAVwiI0ytSdhp0GkKqfANdsOkHXkJLXirLVXcETV3wJgE5VebKf71o0dD8wovSxzPsyKRnze9khISY+eqTlgXo99PV0UYfxQymv0EuooOA9FpSeB4K506TkC49ZgZzSI+njVu9epYcxi74Om8d45OVkVNy4kzPtw1+Q6SpHqdAN361y+xmLuEbUJaSZUFP+sZDIRMg6mFXx3I1o4IsjCeWooIf95VMEkRw6xkWdHoJNxylEa2w5FoQIANi2lyHfWyZnbqej74h2rOcnQ5BzEA+KvVPN+dnq6PAx3LHmzWrzJZZJNFvBgxdlp3umuxH3ZHz8DGhtTP3WLDSaGLfy3DdHbYj9mCirC+F9aDTcIqkl2+kLVkVSyfglO+rT8lZzpfJCZrrH1EqXRKBMk8GZZrGRxEA/HVuMPasyk5oy5Yxlz0N17u9mrWohmLKut7Rp+xS4TG5+xbi7rXIKFQIAolTsZUnmodfRT910BXo54IGU20Bkd3DP3ijw05McIYl4Jtu0cFbKxpHqM8RRHALJ/yLeD9RE/Zd7zZhysN66idW9LtAD9gY/FdNUsR0KqNP8VJzbvf53DoX31n2F497z8sq3bID2Gq60uot88XfO06ycQHRNyXUbCF6CJ76UGioJCOC5NWJXEUYEt+qObRNyLDXGJ6ySh5hXFIwjQvxBVUKHaEp/RGQaF5E= 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)(396003)(136003)(346002)(376002)(366004)(39860400002)(66946007)(66476007)(16526019)(66556008)(186003)(83380400001)(6666004)(8886007)(86362001)(54906003)(52116002)(316002)(110136005)(26005)(8676002)(8936002)(7696005)(478600001)(2906002)(4326008)(36756003)(956004)(2616005)(55016002)(44832011)(1076003)(38100700002)(6636002)(5660300002)(38350700002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N7ncbsbeyunoHUpKBD4GCKavi2BrzxYUSCoQ71YUEnr291jL+I0B2q+7PKx6EKykdfEHh7lKomirxkmuTLx7AE8L2xEQpMQSMc0uEujKjyBTw8PCVPtqbtClN3GwvM/92QTxvsr71L/KN1R3+eP1vYghFqD1TAUfqQEWAHWcEr7y+eLaEeFwWIFIhU3l5eKtdiUjaPGWchHrILlcTQtmwCHpZeeuhYURFJH6XNJgRVfOc2Sgva+63b941SzCigUb8suR4Duldbd9neL4XC0AwvgwSdurnSqVGP8gs6tR2YITsfX7+bXLZlE4O94orCiZY8IUNApUZXNJctBuxTF1J202Eiq1oMOc713EWiVC7lLEiYBeiB6Lv7TUQZAOlrYxYf83p9llUeH2h8nLRFKpICQ0gctZvfNgxjIomr/6VHAhjt5mnPx58K/utKmtqZtDg2phNkpPUwuSSzFydgaWlqVAbW/i1xud0ADmvKBk5Xzq2jsxpRQugBDNjibhiS8BBrDXepw6k1jr0j4+d2NZTN6rUijWiz+5iHmVPmaRam4tzxGKoY5Lghkp0v1mByQ49yoxMOHjok+Bbi+YpETRri+bEyPAaTxet8ki10lqNqcemSMo8v92SKWPBqQCbf9lYDo3IFn72FXt3gnM+shY9xv1EZs8NqivoZg5He52mh1OzO081rHrhFWJKtEoqJpohjN4A5w2aIT9wn9aGhgzNQbIVQPniAxGSAuBq854hCwWNACVYClaKlUS/dV0drtqEHdyWmBDhRi/BjQOqrC2nZctJbgQYoK0Ame12FVHstAqW81h82TD3OfoYAsu0weJQj8N+OQ7roZggSebvK1CIpvZamYXmiWT8PywZL/QhwO2Lbpni3IwA/qWH8Gr88l8kxXjxpzgM43amRv0HZqhG/ZfO5O03Z6mgWqMZqD0ZI6CtkTvU9Qq5BKEIxSlijtnL/iErqj9axLB6egHqxwp/IHJWbo1J0CYwi9eSczGxrw45GcKjIi+Sv9b4Cyiklhe6msB7EkliFGAHoCYro+hmMrMopndhGZiFJE0yPoYQjPmX5FXEss+YrGbNxgefsGnSumpi8gyZ2VMIcqpV/XauWucQwNM6HlgMVFvfhRl46swbz7ofUnsoPvY4i2FEcUd6vRh2qg1FlGIkaZtO17wfPt3jx033wK7kKVK2UpiE0jatBPsRxju8XExAMf5M5OS67htE3OKzVAwjXPAJEsD48+W7C/Xs2z+S28A68Q5Yf6HEGbU4YJ5l9vhmpkZjK3mPQjjK9cvm1HpPGWkxa0v+o04OWiEx8wsfo24bXd0PCzDpmJ9xu3pA1D/ixrvuu75 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b83d65ca-153e-4f15-8132-08d9360c8c87 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:02:59.2446 (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: 0BW2LzKcugu8bpU7I4ewtluaZivcCOJqgd4RmDwNiCArPbrWR+rlIdZ+tLxdyrNJdY/mOSYOUvq83+LRh1eWfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230304_214400_17D7ED85 X-CRM114-Status: GOOD ( 20.64 ) 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: We add common ACLINT MTIMER library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/timer/aclint_mtimer.h | 41 ++++++ lib/utils/timer/ [...] 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.153.144 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 We add common ACLINT MTIMER library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/timer/aclint_mtimer.h | 41 ++++++ lib/utils/timer/aclint_mtimer.c | 179 ++++++++++++++++++++++++ lib/utils/timer/objects.mk | 1 + 3 files changed, 221 insertions(+) create mode 100644 include/sbi_utils/timer/aclint_mtimer.h create mode 100644 lib/utils/timer/aclint_mtimer.c diff --git a/include/sbi_utils/timer/aclint_mtimer.h b/include/sbi_utils/timer/aclint_mtimer.h new file mode 100644 index 0000000..510bfa9 --- /dev/null +++ b/include/sbi_utils/timer/aclint_mtimer.h @@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __TIMER_ACLINT_MTIMER_H__ +#define __TIMER_ACLINT_MTIMER_H__ + +#include + +#define ACLINT_MTIMER_ALIGN 0x1000 +#define ACLINT_MTIMER_SIZE 0x8000 +#define ACLINT_MTIMER_MAX_HARTS 4095 + +#define CLINT_MTIMER_OFFSET 0x4000 + +struct aclint_mtimer_data { + /* Public details */ + unsigned long addr; + unsigned long size; + u32 first_hartid; + u32 hart_count; + bool has_64bit_mmio; + /* Private details (initialized and used by ACLINT MTIMER library) */ + struct aclint_mtimer_data *time_delta_reference; + unsigned long time_delta_computed; + u64 time_delta; + u64 (*time_rd)(volatile u64 *addr); + void (*time_wr)(u64 value, volatile u64 *addr); +}; + +int aclint_mtimer_warm_init(void); + +int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, + struct aclint_mtimer_data *reference); + +#endif diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c new file mode 100644 index 0000000..f50a0b5 --- /dev/null +++ b/lib/utils/timer/aclint_mtimer.c @@ -0,0 +1,179 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MTIMER_CMP_OFF 0x0000 +#define MTIMER_VAL_OFF 0x7ff8 + +static struct aclint_mtimer_data *mtimer_hartid2data[SBI_HARTMASK_MAX_BITS]; + +#if __riscv_xlen != 32 +static u64 mtimer_time_rd64(volatile u64 *addr) +{ + return readq_relaxed(addr); +} + +static void mtimer_time_wr64(u64 value, volatile u64 *addr) +{ + writeq_relaxed(value, addr); +} +#endif + +static u64 mtimer_time_rd32(volatile u64 *addr) +{ + u32 lo, hi; + + do { + hi = readl_relaxed((u32 *)addr + 1); + lo = readl_relaxed((u32 *)addr); + } while (hi != readl_relaxed((u32 *)addr + 1)); + + return ((u64)hi << 32) | (u64)lo; +} + +static void mtimer_time_wr32(u64 value, volatile u64 *addr) +{ + writel_relaxed(-1U, (void *)(addr)); + writel_relaxed((u32)(value >> 32), (void *)(addr) + 0x04); + writel_relaxed((u32)value, (void *)(addr)); +} + +static u64 mtimer_value(void) +{ + struct aclint_mtimer_data *mt = mtimer_hartid2data[current_hartid()]; + u64 *time_val = ((void *)mt->addr) + MTIMER_VAL_OFF; + + /* Read MTIMER Time Value */ + return mt->time_rd(time_val) + mt->time_delta; +} + +static void mtimer_event_stop(void) +{ + u32 target_hart = current_hartid(); + struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; + u64 *time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + + /* Clear MTIMER Time Compare */ + mt->time_wr(-1ULL, &time_cmp[target_hart - mt->first_hartid]); +} + +static void mtimer_event_start(u64 next_event) +{ + u32 target_hart = current_hartid(); + struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; + u64 *time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + + /* Program MTIMER Time Compare */ + mt->time_wr(next_event - mt->time_delta, + &time_cmp[target_hart - mt->first_hartid]); +} + +static struct sbi_timer_device mtimer = { + .name = "aclint-mtimer", + .timer_value = mtimer_value, + .timer_event_start = mtimer_event_start, + .timer_event_stop = mtimer_event_stop +}; + +int aclint_mtimer_warm_init(void) +{ + u64 v1, v2, mv; + u32 target_hart = current_hartid(); + struct aclint_mtimer_data *reference; + u64 *mt_time_val, *mt_time_cmp, *ref_time_val; + struct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart]; + + if (!mt) + return SBI_ENODEV; + + /* + * Compute delta if reference available + * + * We deliberately compute time_delta in warm init so that time_delta + * is computed on a HART which is going to use given MTIMER. We use + * atomic flag timer_delta_computed to ensure that only one HART does + * time_delta computation. + */ + if (mt->time_delta_reference) { + reference = mt->time_delta_reference; + mt_time_val = (void *)mt->addr + MTIMER_VAL_OFF; + ref_time_val = (void *)reference->addr + MTIMER_VAL_OFF; + if (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) { + v1 = mt->time_rd(mt_time_val); + mv = reference->time_rd(ref_time_val); + v2 = mt->time_rd(mt_time_val); + mt->time_delta = mv - ((v1 / 2) + (v2 / 2)); + } + } + + /* Clear Time Compare */ + mt_time_cmp = (void *)mt->addr + MTIMER_CMP_OFF; + mt->time_wr(-1ULL, &mt_time_cmp[target_hart - mt->first_hartid]); + + return 0; +} + +int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, + struct aclint_mtimer_data *reference) +{ + u32 i; + int rc; + unsigned long pos, region_size; + struct sbi_domain_memregion reg; + + /* Sanity checks */ + if (!mt || (mt->addr & (ACLINT_MTIMER_ALIGN - 1)) || + (mt->size < ACLINT_MTIMER_SIZE) || + (mt->first_hartid >= SBI_HARTMASK_MAX_BITS) || + (mt->hart_count > ACLINT_MTIMER_MAX_HARTS)) + return SBI_EINVAL; + + /* Initialize private data */ + mt->time_delta_reference = reference; + mt->time_delta_computed = 0; + mt->time_delta = 0; + mt->time_rd = mtimer_time_rd32; + mt->time_wr = mtimer_time_wr32; + + /* Override read/write accessors for 64bit MMIO */ +#if __riscv_xlen != 32 + if (mt->has_64bit_mmio) { + mt->time_rd = mtimer_time_rd64; + mt->time_wr = mtimer_time_wr64; + } +#endif + + /* Update MTIMER hartid table */ + for (i = 0; i < mt->hart_count; i++) + mtimer_hartid2data[mt->first_hartid + i] = mt; + + /* Add MTIMER regions to the root domain */ + for (pos = 0; pos < mt->size; pos += ACLINT_MTIMER_ALIGN) { + region_size = ((mt->size - pos) < ACLINT_MTIMER_ALIGN) ? + (mt->size - pos) : ACLINT_MTIMER_ALIGN; + sbi_domain_memregion_init(mt->addr + pos, region_size, + SBI_DOMAIN_MEMREGION_MMIO, ®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + } + + sbi_timer_set_device(&mtimer); + + return 0; +} diff --git a/lib/utils/timer/objects.mk b/lib/utils/timer/objects.mk index 1b84e92..1d8b1e5 100644 --- a/lib/utils/timer/objects.mk +++ b/lib/utils/timer/objects.mk @@ -7,5 +7,6 @@ # Anup Patel # +libsbiutils-objs-y += timer/aclint_mtimer.o libsbiutils-objs-y += timer/fdt_timer.o libsbiutils-objs-y += timer/fdt_timer_clint.o From patchwork Wed Jun 23 06:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495956 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=Bd30igOQ; 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=osGWOJWP; 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=zCmhPDLx; 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 4G8t3k6V8Rz9sVm for ; Wed, 23 Jun 2021 16:03:14 +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=0lRswacsyXOs90aU2TVc8cZh3clTRfgy1fnc2pI+5PQ=; b=Bd30igOQvvP2r3 co2KMCVvfyP7nmBeWMc2wBDSOa2M5ifLBkNZ5shDRQif1mq1QXMgbrj3Ry35TQhJNIKS6xay+TpYl uXrhZq37wCTfeV2BqblUIfVwFsVuJNCrxv7g9XLn+Kf7Ex1jcLLgrePFrKt2YBHB8MGZ+1jHpwKOg 8Z+/63Eyrl08g0Z/JWSblqF/VkP52SGZwJy9cDo+6boLZOsx0cM7hV20o5Ul83O4me1q+Afc8ylvG tlHdMVEa7OtMihgy2lpqZEXX9+lhM1bJ0yzEWnQiRykpCE5H+iZVzp+f5J0X5PT1nzCSTOo8+LEe9 7fjrPjdwPbHlJyIx+Nbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvyg-009TxN-6N; Wed, 23 Jun 2021 06:03:10 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvye-009Tup-6J for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:09 +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=1624428187; x=1655964187; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=4abkZPStpS9z6U2ehwpxC6S8BqRHZsjsn4h1iv5EWyQ=; b=osGWOJWP0TANcZ6v/XRm3Aqqjia0UuzuTbonq0Z/fG0Io8+c7QKbCtu9 ITlwJvI6C0Fk8vgUh+LK+yfPo1Nwe8dVclD/aWu4RAQhNzS5lG61tu0Ra JYkicjWYy3/senbq5giYepdltDwN2ElW0vkrjmuawgFw4fd6rxq7nE1i7 O0pXGiPDYwygCmBM3ARfBWebHNp4xzck1EwR88tGxuJtaUUOKcXR3Kv/p AoIXqH4SBIlqtVyoFpnqyoZVqYn6kkeK181wpXGNDsmU/EE9KwGkZK5mO qiycU8d1zKEijd9BX3acbIG10pPJX54Tmlqj/+r8kvMIlsbC2ztoLQYAn A==; IronPort-SDR: vAuGue4yZMMyWEyA5fTJ7QENecWIdC3ThL0ZY7vVn9Xj1zd9Em/ouwns3VzR9Bba6Ji+ZnfoG2 IHHUl7JtS7w1oB9CEbQ9KgHUvGwNBym9v+O109SXM4bkDijxL+Rhjl0hQzfJU54DzQweCorTBJ 65T29JC2Q9+GSpqwNvObN/A+jSz62xlB45tvg6Sr8jyXSZ2oA5zPLbxWvomecyCTk0QpjYdF2g GKIIarYCNa2MjR2LZvNzGPGHRFv062oEAQad7KekOggkLYc6huSqNPOZ0mADez2Mthl2xRPvA4 /qc= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="172661862" Received: from mail-mw2nam10lp2102.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.102]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:07 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaNLqmDns6tGywnJbIOIIlDnQ0C2iDKf7Kmd0BEXFE/ScIofh/oL/Opvoh57vd/5u64Zl2aZb8dtvuP6hP1XR/7jU5W/tDWayx5tAbSm8ZTtGThl+AKfHePFSXoi1P28dWgn+BF8mnd+iC8lr+KthTXlmtUt5PYzkekXybE0TQpd/OCX0qBxCpImy7rT+q84F/YyTfQVfLcSthUn4VJF9evvzz6ylKyV6zXwIngQd9WGB39Xe/ye6qF+WjuhBAySMT1vQr/orfOQLbLc4ol4Z/b95LmdYx1SWrTB/c3xLayvFX/kS7HwmheQlVAuvje9iF4e43qKIIt4KJ+d/ExGsw== 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=Bl2SQzbf8qL/5pXHCZyhZUcp0Ud3FnZ3eth5QMuWUF8=; b=NXd9+z0SvZcamCKoF07cItrDm4m6XsXd6396KNvE3P1dmm1KwEHNJLyLZS0+McWOAIaSYcDOlofUg/yHxBed7FUsz/GLzNbm/kTiS7DtgydYkBhu2Rdft5QazBHpOKq5JESP4QDrkz1QZLYIymq6XmQdRCZILDDLnQ3WZMmvxBscC0TlxBaA/5f8YT1ZidaimMZls2u3Hv3o2NfLLAF92wSI7M9RBfwTl6jHRPJGGz/qGKKLc6187s5XqMTmyfYlKMYsycL2ixAy7DLsTkD0kbGUGJyEP/BBEcvoVrTvXIT+k8ZLVoEh+siJYa8W2ijQkxQuThdeCi32T4mS5tzlqw== 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=Bl2SQzbf8qL/5pXHCZyhZUcp0Ud3FnZ3eth5QMuWUF8=; b=zCmhPDLxWhKJ9eq3A9GZB+aumaYHw49mDP97RgIEu7LZ9Qqx+rmFjhq1BkLAWqtyYT8fnD+z2nGUNKcoiwRiPewOpuFv/zFBwWbgAE7y5mGKjVh2lmxmZkqlVRNjbW8D2zD0+dPewJql8sHDmJGjUOU9u16WH+CsBZFvbJlojac= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:03:07 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:03:06 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 2/6] lib: utils/ipi: Add ACLINT MSWI library Date: Wed, 23 Jun 2021 11:32:22 +0530 Message-Id: <20210623060226.442030-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:03:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bad171b6-68ed-4e02-630e-08d9360c9000 X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jpFTBKGHA4jzGC2juu1lqeb9m05YCsELPK1pjtYoH/HvUxkjyFJfP2BfDdfKCVLlusP4Yb5XdMHmd0qs9nEcM6iNndpwf8C7QXlHr+xyhuJj8AySleuW5gqhWYR8lg6a4C7QtfCMNg+AlSGVXdRYkhUU1gCdRAsnFUotxgyqA8YMDhuFceqniJWIhYX70wBwBoi+qlew/xDH/uD4w5AgzjZIITK0aGmF9VI4FwTI+gc0jyWUV2otyvcix3Yvbm+E6bUYIyIyMNDOXAsAV12fRJlKlJiU8UVjBOGXDvYwciKXFsp1wN6g0ehdg2DYC1Djha3/VhriNftGhuEuNmdXiUUdpmKni17jdkO8aAHDggtIHDgmZV71n609HdgACuAbrNqAQ2XDh2GEmIo+2GOWkwsEwlGiGfaT/xksduD/vj6k0GESWMD17ZaZLkqStSpyynf3polVaQz+6flvoOZjhcDETAhBwQfbJlTdsUrzn7nvilSBKvuRQWlXCsQwdy+2h2yGhaDnRvhhxYdPG5ROeZDoc6T8euUmm15x7vlzm/FsiAne0AKP5TvjcQuKUKuuW18/ANrsMShrHm+86s985Ip/QUKcnmDNzUUNcyqMf8LHrc1ZLJWmSLTpGhNHDyziDe7x1VMVQE7rtdNqpQyfMmNRbv5/CMgR9ZGHuki/w498Zct5P8GBr96tL/LYthJ6k1hs7aKfFyA+8PMJwAmnQuG89iC47si44YAz14Ol+XU= 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)(396003)(136003)(346002)(376002)(366004)(39860400002)(66946007)(66476007)(16526019)(66556008)(186003)(83380400001)(6666004)(8886007)(86362001)(54906003)(52116002)(316002)(110136005)(26005)(8676002)(8936002)(7696005)(478600001)(2906002)(4326008)(36756003)(956004)(2616005)(55016002)(44832011)(1076003)(38100700002)(6636002)(5660300002)(38350700002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ii6y+JncAHOn92p69Vq5thKllfPLMdMMFksQx/Vo6CsIZD87UA06OK89RyXvrcjjduIrzBvcUmhmpE3IIocxSzIyhRhrI2Sc0JZ6UnmX6usgI31WICH4ZlaKwInoYAQrosuvYp/sRgfkRZ0l3t1NF1n7Ifnhb0jeMb2dF5WTjKy9E7oiLSUQ9nv3y6G/tP5g0h5//Bxm3C0HernjHjOpkq4FkduzuSxtcguqLtipXFEW2ARz5TAdV021uMsXsc5CfEDtTetByt/1pQJtcuIyDSSxGnDzFYKU/y0AR0nZoq+3nHFvZVFHNTLNkL7ASoYEHgfNtO4Qvd9Das1jhK6yLOfwnasXUONOmqoikiKy6zE19y6wav7q6b7+KbJD9UZUtq49cPyxw+Ronq/1M8f+uijwYPidoxNiK2WI7m4BqXmUMffbKxqK4Qhgk9gh7a7AHbtm0golwzgyzrwGgxzXPbuot4a8KRHMPeTn3gHZsY7R8kgxSvz99W8mOpamEomwGH4QU+3W03dF4mvl5Ch0Z+6y6JDkmh2lVWPVmpSCenEYLgEy7uGKf+5OToC6HK4PPqfu6DuJOuEDZBa1ynlPlOpWctxDLhFCTrmw7XNw8OHTxMk1CzXDTB9ohIOJd+d51apiRv/xttcdEC9Wol0cmp2duhZ2EA4KIcZHU2C9wVc+lezt07TxXffSyk3l1UfQgGkh5Tkvwbz3LNMqAn7P2DBUNJsnd4juREyKNNe6kPYhS0EHDW7kGBUitI7xHJlV3v/pYUgLyi27HnF7wmbvT3QIvRKt/1DR8Dp77CAGVaA/B5lmCYrnDQaTzB5fpE60N7sKOKbF0KpSWxlLsrOsxJnoj+s5YlHKqxwm14NBBp9QXCktOjDYU83d0B5EsZeBEJzlNoe0aPHgp6y0vWQEG8D/eQAdwO78JnwBj73Ie7UBFrWJzU+UifdSZFRi1ZyluWMlp1NEPQvi5KrLRw4+fz+z0dwEUn/gh+0OSL4OvdDlQD5t7YJO7D0TUgv5ds+i+oQ/tL0nLvwxQFDncZafmDfM+1OClwxNjIZip6UMIT08HiNZNTXUBqLDOZOouTdSsqzg2G+icv3PIaDNb15SznIRWZvaxW6G02r1fr1ZnW0sIaRQ+Kr4t+vOTuPSGu28PrvZRCfkzUVE9C0Hk7iPi+2GKfzDQ+flUZLtXW6mFVU3b5Tmb6PbNnb9bqmaz0WV/h6tsLApRLD/E/ql4fGKUkwul5B+h2Fpm2t8iqmMt1v2wLfBCtHZhDz7tQ9q2KimP0Ltx5NFEIQ4q4+BK4CY5nWJiYSddSBCa55T82iDYBqwU4yaia7NrAdddN+7qu5z X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: bad171b6-68ed-4e02-630e-08d9360c9000 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:03:05.7749 (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: 0vJgitstdPPwzplOyzcVX1IGPcFD2NqccKdQ1CmQy+wXDHTJaWmaDxGL6dgas1c92+EtBtambBceFag217RrJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230308_278215_1C0BDB0D X-CRM114-Status: GOOD ( 19.04 ) 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: We add common ACLINT MSWI library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/ipi/aclint_mswi.h | 33 +++++++++ lib/utils/ipi/acl [...] 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.153.144 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 We add common ACLINT MSWI library similar to the CLINT library so that OpenSBI platforms can use it. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/ipi/aclint_mswi.h | 33 +++++++++ lib/utils/ipi/aclint_mswi.c | 100 ++++++++++++++++++++++++++++ lib/utils/ipi/objects.mk | 1 + 3 files changed, 134 insertions(+) create mode 100644 include/sbi_utils/ipi/aclint_mswi.h create mode 100644 lib/utils/ipi/aclint_mswi.c diff --git a/include/sbi_utils/ipi/aclint_mswi.h b/include/sbi_utils/ipi/aclint_mswi.h new file mode 100644 index 0000000..e373a8c --- /dev/null +++ b/include/sbi_utils/ipi/aclint_mswi.h @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __IPI_ACLINT_MSWI_H__ +#define __IPI_ACLINT_MSWI_H__ + +#include + +#define ACLINT_MSWI_ALIGN 0x1000 +#define ACLINT_MSWI_SIZE 0x4000 +#define ACLINT_MSWI_MAX_HARTS 4095 + +#define CLINT_MSWI_OFFSET 0x0000 + +struct aclint_mswi_data { + /* Public details */ + unsigned long addr; + unsigned long size; + u32 first_hartid; + u32 hart_count; +}; + +int aclint_mswi_warm_init(void); + +int aclint_mswi_cold_init(struct aclint_mswi_data *mswi); + +#endif diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c new file mode 100644 index 0000000..a3de2f5 --- /dev/null +++ b/lib/utils/ipi/aclint_mswi.c @@ -0,0 +1,100 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct aclint_mswi_data *mswi_hartid2data[SBI_HARTMASK_MAX_BITS]; + +static void mswi_ipi_send(u32 target_hart) +{ + u32 *msip; + struct aclint_mswi_data *mswi; + + if (SBI_HARTMASK_MAX_BITS <= target_hart) + return; + mswi = mswi_hartid2data[target_hart]; + if (!mswi) + return; + + /* Set ACLINT IPI */ + msip = (void *)mswi->addr; + writel(1, &msip[target_hart - mswi->first_hartid]); +} + +static void mswi_ipi_clear(u32 target_hart) +{ + u32 *msip; + struct aclint_mswi_data *mswi; + + if (SBI_HARTMASK_MAX_BITS <= target_hart) + return; + mswi = mswi_hartid2data[target_hart]; + if (!mswi) + return; + + /* Clear ACLINT IPI */ + msip = (void *)mswi->addr; + writel(0, &msip[target_hart - mswi->first_hartid]); +} + +static struct sbi_ipi_device aclint_mswi = { + .name = "aclint-mswi", + .ipi_send = mswi_ipi_send, + .ipi_clear = mswi_ipi_clear +}; + +int aclint_mswi_warm_init(void) +{ + /* Clear IPI for current HART */ + mswi_ipi_clear(current_hartid()); + + return 0; +} + +int aclint_mswi_cold_init(struct aclint_mswi_data *mswi) +{ + u32 i; + int rc; + unsigned long pos, region_size; + struct sbi_domain_memregion reg; + + /* Sanity checks */ + if (!mswi || (mswi->addr & (ACLINT_MSWI_ALIGN - 1)) || + (mswi->size < ACLINT_MSWI_SIZE) || + (mswi->first_hartid >= SBI_HARTMASK_MAX_BITS) || + (mswi->hart_count > ACLINT_MSWI_MAX_HARTS)) + return SBI_EINVAL; + + /* Update MSWI hartid table */ + for (i = 0; i < mswi->hart_count; i++) + mswi_hartid2data[mswi->first_hartid + i] = mswi; + + /* Add MSWI regions to the root domain */ + for (pos = 0; pos < mswi->size; pos += ACLINT_MSWI_ALIGN) { + region_size = ((mswi->size - pos) < ACLINT_MSWI_ALIGN) ? + (mswi->size - pos) : ACLINT_MSWI_ALIGN; + sbi_domain_memregion_init(mswi->addr + pos, region_size, + SBI_DOMAIN_MEMREGION_MMIO, ®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + } + + sbi_ipi_set_device(&aclint_mswi); + + return 0; +} diff --git a/lib/utils/ipi/objects.mk b/lib/utils/ipi/objects.mk index 0071957..7e37816 100644 --- a/lib/utils/ipi/objects.mk +++ b/lib/utils/ipi/objects.mk @@ -7,5 +7,6 @@ # Anup Patel # +libsbiutils-objs-y += ipi/aclint_mswi.o libsbiutils-objs-y += ipi/fdt_ipi.o libsbiutils-objs-y += ipi/fdt_ipi_clint.o From patchwork Wed Jun 23 06:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495957 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=4UAtWTKe; 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=iGLvEAnZ; 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=V5FXTnxa; 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 4G8t3y6gYLz9sCD for ; Wed, 23 Jun 2021 16:03:26 +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=WgER211DpuzQSR/FzuJ0dVHRNJ5M51OWk1XoJUpDuOM=; b=4UAtWTKeWy5Ims Ii3APnKpPkqCTue1v5XHTe8rhnfITQWZ2Iy3tOh/CSIHMTjNrGYjm4ewFF9sI1/lpt7eN1lRubTEi GNTUU9GTxID+H3uxXsBdqrb5lMAA78DKcM0v2U6mKnU4USJ7s1OSQ/Hz2JGuXBy2Ku7dRPtkDutQg W487U1hSTmS9yYkRuljv4WwPXJ/QnKjUu5XqvQG5QeL6hFxGZRlQrK8zlWnx7PLERM03lU1Fh1VfA SaJmbhJRfKoMUM9TElrPLaxDnKZtgwndltnrWadvvgKvG2iL/s118EJJM3Uf73PPOIbAEgH+xkzpF bxxkFN3iRagwXEX0Bh+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvyr-009U2r-Sa; Wed, 23 Jun 2021 06:03:21 +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 1lvvyo-009U1F-7X for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:19 +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=1624428198; x=1655964198; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zqFAGf0dLRfojjV6ONUv1SSrS4xd87NDfpvslk/g3Bw=; b=iGLvEAnZhBl5GZTUsh6b6eFxcooKw5bkaW48kDiwYSh1nNGUV2UrySXR HNsTxPI0RmXmmhljnIkiVbeUeXJeCHoP+FYX0epHsx0rrLB7Ij+/8BHGU afuSi60dLGdovuVsmbuDtiO4MBPPKSFtvNQwyHokYMEdUeL/yrqX55HfJ 4MXnXI6gE9kuEm69V6dap/nIkFFUZ2Ri4ga7q+sfshJDJwVVyd9jJpAtq UJc1A8mQCCXcRS0yfsd6dTASDyiuWh9giVYivyVCIzN6uHnn8SP1aw5rt xCq/gCHGqCzPVDLL5VMCC7ovbgxrzvbaHNQ2C7CTm/Hq8qHvflmZAoLFN Q==; IronPort-SDR: E0hZPyVGKWXEAoDeKsl7LpiA7lshfboE0tJkmRVjtfIpf82cKZNDfDZkq9J9/l/3Y9qTLX0vSX gjZvNnllk55SZGLnSwyzgynGY79T9tAoRhBoRWSS2AQsBxdqiV/+5rwL7a7DjGZQ3pe+EybIGk glIJRt9ssU10HiQMYMM6ANS7A1ZB10OeUJapgleByzBTGY5omluqUqp3e0R9L7XCjKCh6uLPZy UX5F5QXu1kNjKrdflwh5Zjopbwi1/MnxYZIZMi+a/KmYZTdN3ClkrLYVGS9+t3MgwCFFQfSstr S8A= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="171913210" Received: from mail-mw2nam10lp2105.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.105]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:15 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hk9t7RPh3LVGEehre9MRTmAOaxoBA3CJ5JEo41phyvJYW7eMLSmsQ0Wtgf7rq0vg8DnLZMk9BfhKPNFLBhz/xou71nnMwNYAaGz4DUmR3cHt8UR7pCt4WHsK2I3Lw+MVFtf2NNPzQtK7zR4RgmwX8EkUJzv5HkRf6c9f/9mZs5uCPQPAZ3ND0nR/LwInVHRkyHbe5Czvjc9XZqaV2uPyrnPuH0hVODzouXGyMOTAvFrLBaaWtBL2CFfbfUi+sslJK5zJ8I75JCfWca1uoiCVlIudTZ5JbpIGG0urza+5lk2GXniDi11i+/D8bkWBJyOE+V3A8SyaqyVq6FeCt8Rq9w== 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=FlclpNXITpifuxp9VRGOTr0eU6eu0ssSMlJ37JTcmas=; b=mQzGv+oXti8I+EkypKkQ9WVYsM8cVOrOhSMnbPkMAGtgk3biTKMZyiP8TeOIzjspN32JgnwgVoE0ZgC7lCa6KhZat1LVNWQjesEOlAN2Hrv6vDdfKDiNO/IeqI0u8Xjx/WCnnk75s5oxZOLTfuBxcXK9jFAempqBXvIZTYO+xRK3dsuYYPU1goBvHK+NoCOSRUJ0+9BSiXVeQm/xSgke2O6nv4yquOVLPO6RL2KKZaNNVNsvaihPRF9McKDrmdUoUQWK7o7UvATfdJk4Vsl4FreHi294C2eqyiH9ex1qTkQ/EUZ0VGpeOAAcndkGogfxCImIJqCrf0cpkeNPLbZClg== 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=FlclpNXITpifuxp9VRGOTr0eU6eu0ssSMlJ37JTcmas=; b=V5FXTnxa571Zmp6YK/pV3f8UxPZNjpmxP1pbDrKhrl3ZYHFqjHJNji2xSRDnwriSuIsl/6wfl5yucuL8qmQppyR84CAns+peM3eoULXk4aAQOKs6xHu6HCGetHqYdTeb5DuleoCONFInLpVSBfiDgxnuW6G6N2eJRAXWOeSHH+w= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:03:14 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:03:14 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 3/6] lib: utils: Add FDT parsing API common for both ACLINT and CLINT Date: Wed, 23 Jun 2021 11:32:23 +0530 Message-Id: <20210623060226.442030-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:03:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93ae7192-be89-4d40-b774-08d9360c94a9 X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sm+qIUcqhyaaOGwP4sJLJIiBhhT7tbRsrSST1Wl21dTfSAg2LjD5a7890fX2Y+003TyoaSTCXmL+NDJmq/xbmROD5rofN8atIeJWxvPE/YPKHkdZniz/4yuWeq0LrDDDds2fihtgGW1OwdQIMHQOTQnS35Feld4THvtKAYdbg9Rk4tNzTr8Co3AK5Y9Gt1/VHKYhwz9OBXgn0jNp6dx8KUndWSJs/stfDc3ZxVm3wg3o2Lb1NefcXmo33wiMjKSGocXkfyo1NHK3dH/I8q5eSrJyh783ubiCk/U5k7GmnYdFlFiFmsQSv+RQGsB+paYJq16PtUtLkrJgBRc6PNWYmjvZvEDBXEcIdo1t5RmaZfgpweZUjJnkkFdW9kQifzJxhCAQOq3c/uxMv7zccyVCijDyjTGq77mrqJ3J2UDMi8qeY4PrIFMpcss77AoOpdqYczxwWIa2syCZnOQ23gPW2pNLi0ybLuTJSeMtDkJxKTBXg8NLTh5hqa28GvrTrzuZh6p+rkXHUMeAWZ7FXjk+7VIez67M6r2WIEWszsIVszSATRe2iYDgxKMRRbZ9A+Hv8V5/Xf0Oyz9C2Pux5hzSnpp8rxg3EznaA5m6UIpJJcqZMyIXuiZ5bmlx9UX9IP//LNXgm3l64TBv3Mw83uAyVwfnGtZin6CmKeOZ3tKGPZlV8K/Lqj/sTIljAhHNxgE5Xg15KTOnzi7XQANY/lqK79dEZ+/Qg3elxEAv8TCx7HM= 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)(396003)(136003)(346002)(376002)(366004)(39860400002)(66946007)(66476007)(16526019)(66556008)(186003)(83380400001)(6666004)(8886007)(86362001)(54906003)(52116002)(316002)(110136005)(26005)(8676002)(8936002)(7696005)(478600001)(2906002)(4326008)(36756003)(956004)(2616005)(55016002)(44832011)(1076003)(38100700002)(6636002)(5660300002)(38350700002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lOWhffWDWj9Nc0JdLNUnAo7mvme/9LZyKqoAp4BGGoBXk38k5hKRnXLqCAzCKAT+Sm5KxDa8iK1nYP6kGIkvKLYefyt7LVMVPLqjFDiaU3lEDbazDxSJpUgsg7cwLsgEkyS7Xvs5Hae/sBF+jmNjhO/n/MYV89FKboogm1BPT1tS3SMmyZEjOBWtc3ShwFm9ld+43UYgeS/LLEt1Yh1Ysbeal0o8dyhYSHHai7rO7ecf2lDVSP5FrTyf+UNCWpHIQV8EsVOE9wqXblrraOcaukKieSFLDLBee2g5EpctAkgcLFYy0Mv7Bt2RitmALXEA+FPGmwMYwwCymcpHZMDLnW0/aYMaIZMWoxmgCHpjIJSqm9HFNvrxV/s4FUFYr76uaHogNojFXWB+dxvKaRejsqHYlTWoAvRmbsZNf6aGlqOinZFsjg4D3V3Or/3+9xjOSx1kfBd2hiA07hmbihc3Io5SI7X1B7zhQJxm6/RvnN5aHWJJX0YjnJ/0brc7xVE3zZUneM4PKXdL4tE9iUVMT/mQ7GZn2CktI5NQ/HZ87g0gq7Z9MZw61m8eU69LK3WGfffYU8Wtf2fNkB44TMkUCHnHq2cEK8M+DYkQD9txSPDqD+lO3Rt8YqIOPH9n+pcFcrI85A6ekj5M78Ka1lyGOqsJ3/F95xdVUeU7uOghmZD3WY6PBIyV3H+su3WhqMqIohP8uxgb2WrFm+ZSITCqhdimqJTtjTHcO0vSnBuMqNURNlYiHmMEqtKbhMDfMPmRx5RN6TxSBVKaUDpR+pkGybSaSTgtoFrvnVOyYkYx44Qrtv7KjRl5EmiR9OpS/h9+VOTTL81D6js2eYd43YEmQsykmEomuxyDyq/yFj7vqJgy6cigVxPk5iYKp3Apff/QKhMkikcu/Rx12SSx8735+hdmizK8he+zSxcDgxqemoMi/Bll4SI4DFAI3906euTfh1FBM2AwWxjx/BK8KTvZFs5pE42/je4NSDW/dUVOvmIECd9XVCkRzCAA4C6Pk3NPICuexaQ/p/Y84MHpFcM0HcQdkcgseZJIj0fxE+Mxp2+U3ht3aQ8iWY4waAWn+naKPTqlrgonT6mnV6gvzHJyZv4P1gJDj8eUOW3HnHJ4Je0f6uYA8oRJ6j1BwdhHSjG84vvctcPW/b2Ex1xflca7YTYUzp5zDzIWJRP9ulY3OVoxfdWiDrtd+nL58NjZasw0no+PJjt+DTnuFx87nV5lexPvuoXVrRTYM02eDfj3X7zWNLBJTBRuYzm+rt+yH583di+bBBvALDJ7D3XBHANHzMKQWd5gHTFnSm5Efb5HksFrtjTtPlwGqUKCWxNLlUZ/ X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93ae7192-be89-4d40-b774-08d9360c94a9 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:03:12.6188 (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: UBL37qR4CZtFEaIwxe6F6BpBcOw2kjHLpFW26xZ64jGHLClFvfO2Hht63dx0oWa5TUuPt+anH47lZpy9VI8Nlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230318_432537_818C7A78 X-CRM114-Status: GOOD ( 17.19 ) 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: We add fdt_parse_aclint_node() which can parse both ACLINT and CLINT DT nodes. This means fdt_parse_clint_node() is not required anymore so we remove it as well. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/fdt/fdt_helper.h | 7 +++---- lib/utils/fdt/fdt_hel [...] 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 We add fdt_parse_aclint_node() which can parse both ACLINT and CLINT DT nodes. This means fdt_parse_clint_node() is not required anymore so we remove it as well. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/fdt/fdt_helper.h | 7 +++---- lib/utils/fdt/fdt_helper.c | 31 +++++++++++++++--------------- lib/utils/ipi/fdt_ipi_clint.c | 5 ++++- lib/utils/timer/fdt_timer_clint.c | 9 ++++++++- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index c89f2e6..871f9b9 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -60,10 +60,9 @@ 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); -struct clint_data; - -int fdt_parse_clint_node(void *fdt, int nodeoffset, bool for_timer, - struct clint_data *clint); +int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, + unsigned long *out_addr, unsigned long *out_size, + u32 *out_first_hartid, u32 *out_hart_count); int fdt_parse_compat_addr(void *fdt, unsigned long *addr, const char *compatible); diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 9143e44..de77196 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -14,7 +14,6 @@ #include #include #include -#include #define DEFAULT_UART_FREQ 0 #define DEFAULT_UART_BAUD 115200 @@ -421,8 +420,9 @@ int fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat) return fdt_parse_plic_node(fdt, nodeoffset, plic); } -int fdt_parse_clint_node(void *fdt, int nodeoffset, bool for_timer, - struct clint_data *clint) +int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer, + unsigned long *out_addr, unsigned long *out_size, + u32 *out_first_hartid, u32 *out_hart_count) { const fdt32_t *val; unsigned long reg_addr, reg_size; @@ -430,22 +430,25 @@ int fdt_parse_clint_node(void *fdt, int nodeoffset, bool for_timer, u32 phandle, hwirq, hartid, first_hartid, last_hartid; u32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT; - if (nodeoffset < 0 || !clint || !fdt) - return SBI_ENODEV; + if (nodeoffset < 0 || !fdt || + !out_addr || !out_size || + !out_first_hartid || !out_hart_count) + return SBI_EINVAL; rc = fdt_get_node_addr_size(fdt, nodeoffset, ®_addr, ®_size); if (rc < 0 || !reg_addr || !reg_size) return SBI_ENODEV; - clint->addr = reg_addr; + *out_addr = reg_addr; + *out_size = reg_size; val = fdt_getprop(fdt, nodeoffset, "interrupts-extended", &count); if (!val || count < sizeof(fdt32_t)) - return SBI_EINVAL; + return SBI_ENODEV; count = count / sizeof(fdt32_t); first_hartid = -1U; last_hartid = 0; - clint->hart_count = 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]); @@ -470,21 +473,17 @@ int fdt_parse_clint_node(void *fdt, int nodeoffset, bool for_timer, first_hartid = hartid; if (hartid > last_hartid) last_hartid = hartid; - clint->hart_count++; + (*out_hart_count)++; } } if ((last_hartid < first_hartid) || first_hartid == -1U) return SBI_ENODEV; - clint->first_hartid = first_hartid; + *out_first_hartid = first_hartid; count = last_hartid - first_hartid + 1; - if (clint->hart_count < count) - clint->hart_count = count; - - clint->has_64bit_mmio = TRUE; - if (fdt_getprop(fdt, nodeoffset, "clint,has-no-64bit-mmio", &count)) - clint->has_64bit_mmio = FALSE; + if (*out_hart_count < count) + *out_hart_count = count; return 0; } diff --git a/lib/utils/ipi/fdt_ipi_clint.c b/lib/utils/ipi/fdt_ipi_clint.c index 529f978..ce0ca8e 100644 --- a/lib/utils/ipi/fdt_ipi_clint.c +++ b/lib/utils/ipi/fdt_ipi_clint.c @@ -21,15 +21,18 @@ static int ipi_clint_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; + unsigned long cisize; struct clint_data *ci; if (CLINT_IPI_MAX_NR <= clint_ipi_count) return SBI_ENOSPC; ci = &clint_ipi[clint_ipi_count++]; - rc = fdt_parse_clint_node(fdt, nodeoff, FALSE, ci); + rc = fdt_parse_aclint_node(fdt, nodeoff, false, &ci->addr, &cisize, + &ci->first_hartid, &ci->hart_count); if (rc) return rc; + ci->has_64bit_mmio = false; return clint_cold_ipi_init(ci); } diff --git a/lib/utils/timer/fdt_timer_clint.c b/lib/utils/timer/fdt_timer_clint.c index 0352e53..63d6586 100644 --- a/lib/utils/timer/fdt_timer_clint.c +++ b/lib/utils/timer/fdt_timer_clint.c @@ -7,6 +7,7 @@ * Anup Patel */ +#include #include #include #include @@ -21,6 +22,7 @@ static int timer_clint_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) { int rc; + unsigned long ctsize; struct clint_data *ct, *ctmaster = NULL; if (CLINT_TIMER_MAX_NR <= clint_timer_count) @@ -29,10 +31,15 @@ static int timer_clint_cold_init(void *fdt, int nodeoff, if (1 < clint_timer_count) ctmaster = &clint_timer[0]; - rc = fdt_parse_clint_node(fdt, nodeoff, TRUE, ct); + rc = fdt_parse_aclint_node(fdt, nodeoff, true, &ct->addr, &ctsize, + &ct->first_hartid, &ct->hart_count); if (rc) return rc; + ct->has_64bit_mmio = true; + if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) + ct->has_64bit_mmio = false; + return clint_cold_timer_init(ct, ctmaster); } From patchwork Wed Jun 23 06:02:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495958 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=f8IXLjOj; 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=ZFmymuQT; 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=EQ8zQ6v/; 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 4G8t3z0JnDz9sPf for ; Wed, 23 Jun 2021 16:03:27 +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=V3gZcWstPce08QqSP7dEAjjawi1PKIBFx6fuTTNaX3M=; b=f8IXLjOjEpT63m ptcXUzP/K2hwLkrLsgFgXq2mpNNR6Qnv0232joZsbczchkPz6MnK5Ly7hGbt00Fh24SC7wxp44Xcc jdvZRQzeu+LgL9bxRL4NjR4fwpuRqpOfagXCESHsk31rC8ddEzKnLW+AUe//7Vk8/sdS5IJWr54ii BgYroFMfQbOLlp1xecqeKt6X+Bv5KFaydI3+BBtBk7AKVLN75FCuxhE3zP7/NqBdDBHbieOk4XEDc 6eIqP28KJHPVZsUbPEbZJUlIYEmOYiz/GPnhu8x5NehB8QrmE/qclG2AJMKir46bmBWBO0/6oFvCY 7WamzZFbbR99mj6mz6FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvys-009U33-Bj; Wed, 23 Jun 2021 06:03:22 +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 1lvvyp-009U22-Qu for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:21 +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=1624428199; x=1655964199; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=wmkWuEGMULO6DxxgfqX1RyH7JzKuK/FtL741ABxiJoI=; b=ZFmymuQTG6xxGJf8nFRVQot19FXwcPgvhgm1mUaVHo1ww+yDhwFTE5Ub DfbQZ3Xx/442ODCxJt+kOyYCYo2ruWEbFtXrA2yVU9utSt7yQykFXOSjJ nrWCeDBJ6oGHjy1fbhBKUvcQARzzTegTtvfmEJ1btuTFL3ZU6fDDORCM0 Y2KcdpMFw6Zg/DPAOWTvZq9UentDw9k7Teu5vmBxrISIxnctYTfMJJnrS vnLlHfPD7r72/61mcP4TUd6OEUVw9mRvSEuonWoNLhxKVuIFnqyHI1SUU P6TRhXtSesu0X87+Dx3wt4AMNq+1styiqHiuT1QbKOqx2mEzkJzpeybWc g==; IronPort-SDR: IvXzQk0digs5bfsl6kcvhtghxrCjCqvmmit5BKm7/LrQyRVuFrqnHCydPdiTFPGxplvB+pozQD KNoWDXPbeNjtKMJzFP5jw++u+n8Q00axoZOlohJPHTQ5eoEyOxKN6ieJZDdRfnDv3GeTmIPDga b3GFJ/HNyMby0soTRxYmoMPBU8D//hQXAuiXUGwqygLs3UOz4OQL3zaGujnFyewadATMZPoLmf 9Arv2AE9of8UgTuKhRSkc1nyLwXKXBzPUnknPX4pMs7TH50jJiRkS/KgXzdfoaLv7lartGRr7A Nrg= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="171913215" Received: from mail-mw2nam10lp2104.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.104]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:19 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApSZjP4w4nXIMO4qbaoZSSbc7x35F1K8DAbDHgv7J1n7tZFiqu/c75LK8bKniyUdWlWJUZmrI/3rAAQMe96gS3l/hI3bynxG4mH6kep+khW8nX4eKnsM4esr1IxqwpBBGSsxM+8OuzylLWOd/IC9hBlYUe0Ywo1Y9X4NPCS7iIYzA2K/wr+Dghm5e/kMUgs9xyZUmyM2Ty6H+Q19f1UIoAYNzS9CWlzhPw99se27sLteramooxHJI5sSDE6LGRfSw+ZetDLJ81PNCpjkf+x389kAnj6ietOvEHjQQBnu5zYQPJjKxl8ApN1vz+IyHq4dPzv9ZeLD1owTFLkzHpnpdQ== 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=F/Z0PIDJymtkfLDFL6yKgi4EWRj6HZQZZvSa9X+RYE0=; b=BtnNPnjMby2BbCx1ewDJZ0osxTt5m+F2ir7py9OLHL5iXg/sOYZICQ+ds/vQngLgcGUiADAX2/2yY8TdYgg5R97mkutXX3USjcBIePJ1YeAWIq3q2WbHnewEHCkJqYxPb9MMdwEX5DrCvqEklaXfaYTiGDRSqp0mKOcwUsKHc2Jt/rsNVXnbXpnQnpQgT+8kHF9HV1+vBmIvgQ5yLFQhy2FVxoiDdu1LYEm38Wy+iXJFcyTbmwO3tLIv+Gpblq0L7Nj8/TcxlUmIUI7/Piz7Hn6BBd5r5KDWiy08rrUTCBEi3Ayb3dAQzs6uzTTuoFXwcBjAirlRY09nzch8dE7q+g== 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=F/Z0PIDJymtkfLDFL6yKgi4EWRj6HZQZZvSa9X+RYE0=; b=EQ8zQ6v/S4M57Z/VVajkTc5p+abxoCQjf5JKJcU4Vhhl9bya9W3RSBEKddzTf6wGzoRh7K30nVFXJFp0AtYDT/MozJV4LqlgkmUl7iY7yw0hN+Wqx7qfcJ/UlUoyw4GbLILqaxpFCxKNYLRIJDqz/L/6zjRqWBngmWEyVNFEZyg= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:03:18 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:03:17 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 4/6] lib: utils/ipi: Add FDT based ACLINT MSWI IPI driver Date: Wed, 23 Jun 2021 11:32:24 +0530 Message-Id: <20210623060226.442030-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:03:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37e440b2-de9b-4c1a-4b24-08d9360c9816 X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eIVlaoInpsT92zZGHP+yJLS1oV8WCvZ64gY/x4Yh+8AYBZe7AcoUrdUD7qCxdKczZ0IhzirsInRm7INOAv1b61dxC+RdxdjaJAlpnRH3DH/cIr4ViqxiMc+J8H80ZBHSEFdLEz2JTAGy7/Tca/zFHFT5hlt3QrT7NMLQipbvv5IYZklrA0t6amVdYPnqspxmk4YJoAaTRsHmdOYkpuPtVZ5owykTE0TPYPSo16A8+nWeykRnNs15OqGga2s6UzYzC2FFE3ZZ4wMr1nPWk9JykNcRFhZZ2HfvgCRNO3w7IfmSjCU5v0dtPSXiTnbiNstxIHQJ/sb2ycHPJ71TBon73p52RWFDQ7NlAPzFI6XhPGPvr7jUYB2tApQ5F65YYfvklQVfRBNY0QfEJIxXF1X2ynsXzDsfH87hbm22dDIewABDLo6SPaZsNR0SLNuGyNl1mhWnnV4ROin+dgppQARixVym+wkOifgc22mp3R9iPo1qH7pbJ2tmoPFho0zsmC6GSuQOjTueK9neJIrK3yQQ383UkRrt/EI6FsE4fWACCi3oOzaOBTNBq145farXUoITMNBZNnGBVPPd8tJGuNqhz4erJ/Pu5IRVCKuc2BL1HstwuQdRzN+cRdA1kgaVsZIC3E5MfRQp0bUtErjPcQULvejAv/7mFScZZYBGOuUUQN4RBcVDGZOXJFfoJ36i+mg/HqL92LNNdH8JJI4FEmlyZZlh3puOYKDsObs7aA/wB3g= 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)(39860400002)(366004)(346002)(136003)(396003)(376002)(2616005)(956004)(55016002)(4326008)(478600001)(2906002)(36756003)(38350700002)(5660300002)(1076003)(44832011)(6636002)(38100700002)(186003)(83380400001)(6666004)(66476007)(16526019)(66946007)(66556008)(26005)(8676002)(8936002)(7696005)(86362001)(8886007)(54906003)(110136005)(52116002)(316002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CS67vjV9u/biiXyzG7YyWwfIlFQlvbypAiLYsf8aaLA+hZE2ZZddNFeVwCY+20v1sgI2eX+3D6fVQmRbGNgq3nXtE3AG1i/tJuScQeIyKXrNtGan77gcnTBTGI7Ofr6ACwEWSyLaqo+xSJ5W55ezCwwBsDEcH4DAmvN5GEDbjl8qpiZtW5BKTj53h+r/TWV7A7sn4LXfJ4rXEOqvJ+R61ZjPZGwjBZ5AsSNcEPIaPeedyCF0knzoYLgBNFTP8P4avEamXCJG7Kkvm45mKAmkCxZJkAZ0kEx0Kj4CCbXgiAOgd48g6fQvAkM2zgJVi5s0CTtUUY0ArmjXzSiPT1Qode8a3PsSmin5TVUHeIrNfRC68UCOuYUBXq4KjHxN+gYwaqar9ZUUI2YP4wXc6vSoUhx3ynqV0mTEQPbAeC/MagJfvTaXZMDsZxn0rkGnVfII05gvZdWjGPoWAKyekKQlPi9G03hOMTi0krxaNHJu4fuzlDGxi3ifuxZd6pjUhkUKRSNnYuAaVR6xyQk1CjyMTQGnCMw4tuQDheXXMCdYhkvVBzq1xMrCkyl/Fixop8Y2ZmKe6XuUNCzCds1diS4Y6X6M4yru21dblStVRyQ21utmNtHy1LmF8UXOQEpAc/DaW4ug8/ibnsA5W0BBOGB9lhcgE+THtAw/Dzy4W2KidcY1Me/bKMl+FpoPw6x3X1X+EqOM9tUr5++2F598w3ntLLeXg7UmLljyX/pVfU83dW/NYmmVqkhoojF/t3D2m7jOLgq7JgX/8QFvpSDPoNohFw1hOExEQ0LnDHnefE7+DDCjIakRl6u/TAwLqdhJ572qUoLP6nEd610ryKroF/2so3NZyjfp59rFKWPa2XpvcgkYDhvCjR04No47HQSa86enq7zzKSgaZO8RbzLoKd4oReLBx0TAQq7EvEF/UAn9iEcwh9BP6mB8v2xy51m0JdrPvP1nkz3QhSDZxFzqK2PIQoAHgnRpg5cjD7B6NEgPMiGEcL712igK7DGS3Sa5d6CwVsdUkJIRnDMAn2/3kpmzsFKObkpMAaf2BRrDLA5ZF9DOcK0HjqaNupV04NZgfok0sM9GilDY00DnoF3mhSOpxz/GRETeTMFCV2WXozBIf98Qp9UN6LxAIx0CnXu5BrzBrdKh8Z45lB3Y81/58Av1+vvVuGXy42sXggsuVuwFJkUEk5xgSI428FFiowU8HFvzu2AGtBLlFzc6Cgcmza0zRyq1kRm8D/u6hlB80j3ca0krV96VAhmYuhxzjK49YhBsY5A9hR5yEqafM/4q2U1z74X4UwhrtWMrISqXZoJj5bW8OoeKAaNn2z6EhIwnjMiO X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37e440b2-de9b-4c1a-4b24-08d9360c9816 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:03:17.7522 (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: Omo/n2iBrcneGxTdMJzKatig3xwFh0P5KurkolYKPzGJgRsYRfJpkwQ0jpOnYVrZwcA01GOQ20Ls4USr7B9Njg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230320_016319_E18411CF X-CRM114-Status: GOOD ( 20.65 ) 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: We add a new FDT based ACLINT MSWI IPI driver which works for both CLINT device and standalone ACLINT MSWI device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/ipi/fdt_ipi.c | 4 +-- lib/utils/ipi/fdt_ipi_clint.c | 51 - [...] 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 We add a new FDT based ACLINT MSWI IPI driver which works for both CLINT device and standalone ACLINT MSWI device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/ipi/fdt_ipi.c | 4 +-- lib/utils/ipi/fdt_ipi_clint.c | 51 -------------------------- lib/utils/ipi/fdt_ipi_mswi.c | 67 +++++++++++++++++++++++++++++++++++ lib/utils/ipi/objects.mk | 2 +- 4 files changed, 70 insertions(+), 54 deletions(-) delete mode 100644 lib/utils/ipi/fdt_ipi_clint.c create mode 100644 lib/utils/ipi/fdt_ipi_mswi.c diff --git a/lib/utils/ipi/fdt_ipi.c b/lib/utils/ipi/fdt_ipi.c index 3932f50..ed56e49 100644 --- a/lib/utils/ipi/fdt_ipi.c +++ b/lib/utils/ipi/fdt_ipi.c @@ -12,10 +12,10 @@ #include #include -extern struct fdt_ipi fdt_ipi_clint; +extern struct fdt_ipi fdt_ipi_mswi; static struct fdt_ipi *ipi_drivers[] = { - &fdt_ipi_clint + &fdt_ipi_mswi }; static struct fdt_ipi dummy = { diff --git a/lib/utils/ipi/fdt_ipi_clint.c b/lib/utils/ipi/fdt_ipi_clint.c deleted file mode 100644 index ce0ca8e..0000000 --- a/lib/utils/ipi/fdt_ipi_clint.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2020 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#include -#include -#include -#include - -#define CLINT_IPI_MAX_NR 16 - -static unsigned long clint_ipi_count = 0; -static struct clint_data clint_ipi[CLINT_IPI_MAX_NR]; - -static int ipi_clint_cold_init(void *fdt, int nodeoff, - const struct fdt_match *match) -{ - int rc; - unsigned long cisize; - struct clint_data *ci; - - if (CLINT_IPI_MAX_NR <= clint_ipi_count) - return SBI_ENOSPC; - ci = &clint_ipi[clint_ipi_count++]; - - rc = fdt_parse_aclint_node(fdt, nodeoff, false, &ci->addr, &cisize, - &ci->first_hartid, &ci->hart_count); - if (rc) - return rc; - ci->has_64bit_mmio = false; - - return clint_cold_ipi_init(ci); -} - -static const struct fdt_match ipi_clint_match[] = { - { .compatible = "riscv,clint0" }, - { .compatible = "sifive,clint0" }, - { }, -}; - -struct fdt_ipi fdt_ipi_clint = { - .match_table = ipi_clint_match, - .cold_init = ipi_clint_cold_init, - .warm_init = clint_warm_ipi_init, - .exit = NULL, -}; diff --git a/lib/utils/ipi/fdt_ipi_mswi.c b/lib/utils/ipi/fdt_ipi_mswi.c new file mode 100644 index 0000000..f119f9c --- /dev/null +++ b/lib/utils/ipi/fdt_ipi_mswi.c @@ -0,0 +1,67 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include + +#define MSWI_MAX_NR 16 + +static unsigned long mswi_count = 0; +static struct aclint_mswi_data mswi[MSWI_MAX_NR]; + +static int ipi_mswi_cold_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + int rc; + unsigned long offset; + struct aclint_mswi_data *ms; + + if (MSWI_MAX_NR <= mswi_count) + return SBI_ENOSPC; + ms = &mswi[mswi_count]; + + rc = fdt_parse_aclint_node(fdt, nodeoff, false, &ms->addr, &ms->size, + &ms->first_hartid, &ms->hart_count); + if (rc) + return rc; + + if (match->data) { + /* Adjust MSWI address and size for CLINT device */ + offset = *((unsigned long *)match->data); + ms->addr += offset; + if ((ms->size - offset) < ACLINT_MSWI_SIZE) + return SBI_EINVAL; + ms->size = ACLINT_MSWI_SIZE; + } + + rc = aclint_mswi_cold_init(ms); + if (rc) + return rc; + + mswi_count++; + return 0; +} + +static unsigned long clint_offset = CLINT_MSWI_OFFSET; + +static const struct fdt_match ipi_mswi_match[] = { + { .compatible = "riscv,clint0", .data = &clint_offset }, + { .compatible = "sifive,clint0", .data = &clint_offset }, + { .compatible = "riscv,aclint-mswi" }, + { }, +}; + +struct fdt_ipi fdt_ipi_mswi = { + .match_table = ipi_mswi_match, + .cold_init = ipi_mswi_cold_init, + .warm_init = aclint_mswi_warm_init, + .exit = NULL, +}; diff --git a/lib/utils/ipi/objects.mk b/lib/utils/ipi/objects.mk index 7e37816..129eea8 100644 --- a/lib/utils/ipi/objects.mk +++ b/lib/utils/ipi/objects.mk @@ -9,4 +9,4 @@ libsbiutils-objs-y += ipi/aclint_mswi.o libsbiutils-objs-y += ipi/fdt_ipi.o -libsbiutils-objs-y += ipi/fdt_ipi_clint.o +libsbiutils-objs-y += ipi/fdt_ipi_mswi.o From patchwork Wed Jun 23 06:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495959 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=TjCdy8E/; 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=hKiYeP6L; 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=Ia4o5qEL; 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 4G8t4Q3Gxlz9sVm for ; Wed, 23 Jun 2021 16:03:50 +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=XZcEvIzOi1Y/zm/+1wy//PPWg0zebS5fqDa27GDSHbc=; b=TjCdy8E/zcTeNi yznEIlzxAEF/9R4A/HMUss8hVS1w/KEapr3HCEuds7olDtDdYrtHfp+8jwpFSfnVRC0ppX8b687eq BCHbdWP3ROfBlBkKVi/aDD8JK3fxro2YVsLEdb/mFZD9r1f7yRIZc+AECr5FzQNsXFf8I6nK7jJO4 D52R3Q8RgKdIrb/j/9jV/t6Qze2tMsx6GLtmPH5UkASAk+ONMEOOSPw3fY1wahOQn5PC7oGL/xphQ WpMHyG8JdvCRy9W0hxaRLy3Ak/Dj84ROvDXPPxFsZZgHllciNA+t3mn/y0Aq27U6V7nTnIi4rdwrk UfvABilh4Y7Z3qZyvfJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvzF-009UAq-JZ; Wed, 23 Jun 2021 06:03:45 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvzC-009UA3-HK for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:44 +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=1624428221; x=1655964221; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ZTilRSEOwhKp4j2Qmc8d3fQ/2yVcsECSzGfHJWY5nY4=; b=hKiYeP6LwBJD3lviOMPWq51AlXkRnbkEME3hMdIFZeXVmRSSo8PSRnZF mc3StChpY4Cozr5ESeDamILHqMLmrkTS9cYV7SNo3htBJWcjReO4JBg+y 4IHpeErGqBtUhl6+9YQAhipczkwXXO8IjpLvipqZoFnbsRKiOoe03WJ9A T/8cLSqHWcRBG4X8YOJWhNb6TposEoYS5Bvd4+UcAYbSywbXFLPLp0d5g bhkdlrPlHIctz9zX+m3sCbOBw9RVV0q6X9H5V1bHjRQTxFZ8bWXNip7ta S67U0u2AeGiAO2GIlSXFc6Oce6XoloclNSeCbDAMjHvpk80ILgNCOkxQ7 A==; IronPort-SDR: uM98YStKNE4GASO/Hkd+jZmDqSkR4Oqb2TgzNDbSGP5r8+dlyiQYwZ5lWbqTpYNZD6NnprLiPu wlFzT7Inu0IS/uU3lizqoDErWlQ5VoJKahMlffIIdRFzcOLmFpUoxiRHGHN1HIjp4rG2bkMod7 QvlbrBX2yRdz6At8gZ3lOrB+rNNv94LAwvi1KJl3myOBb7yb10+yLcOe/kGuUmEKygiLtznijS OLm6VnbdE5B98SYVjH6WQ8xXF4+Ml7PSr0e1U/txLIiFSTwdk3rJnD8lbQmY7+AAxze32Jk+TO Poo= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="172661909" Received: from mail-mw2nam10lp2109.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.109]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:41 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3UCJZi/RerVXQgdCSmpt9pVUItTgN6G/CjzCNuL0JOqlzC5ZzDrCjDSpXQ1OGLZM72QFdZ+JIws85DZ5AA2g3QJLMzeaVSSD6Vn8ShEzFDfmGyU1Am/kAbyBx6JOPv6XttZxHcxvPZEJCTfr2ITcg9Yqj7Z7H+bJJhePSsfhALK/nJv0u/uimSyk3mKwJy+U9NgQV6OTMs3oFToYAXmWVkg7fdqYoig43SwkGJMI9J3I4uHsPZvCuyItovtHEA05JaKpO0M/0GDdU3ppSCRfTChcF4MXraLSuVLSnLN1I3/cWVYzdvf+zx8LiHga7UcHsKPK4rpzFb8slAuZScKmw== 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=5uadWBdj7SPdymlBpa1q6+RnomUCNaIx4qKO5WK31Mw=; b=XonpQqziNZhHgHYap3A/q+NFMcWdeRRdggNo6sz+MBVf455PzPDrffDlavVIbS/lhYpMzXXDoSjCGdLduTrD9OmBv8KThPEAfLuhKWXqn4A0yrvLxLzl9q4TwSnrv27TU/+ID/RBDlz3P9qab45XMc04hRotyHqqxn7w8eYQ1VnoSAk79mPMkUCtJt4nynuOMRXnpNJ6WgNv00seVgogivSFgVlkVZItN2oLuJsbfEtQEhguwVrM12BLm8pPYKLV6mcJ984aZIlk6/MNGSTqitVZYPtq1qRGCOVvnoTpuptor8ZeA+4GCA4Ff2Xa2xnWz/HINoghR7A1UDuTUPJeSw== 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=5uadWBdj7SPdymlBpa1q6+RnomUCNaIx4qKO5WK31Mw=; b=Ia4o5qELh+9fH1/qphvlcBr9505TMlSuuqpyw8rrCoML0A+DN8M/5NgDZaFZgwfR+LMbwllSwF2XmLZxEZJsf4mJRS8uWhKZpNmGQ5SVFjmov6kLbPDL9TJbUxwB2oenrMPv43zQyaemKpZTGcQrBNputil0BBGhRYxyA5uvVfU= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:03:41 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:03:41 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 5/6] lib: utils/timer: Add FDT based ACLINT MTIMER driver Date: Wed, 23 Jun 2021 11:32:25 +0530 Message-Id: <20210623060226.442030-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:03:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1eed1341-448e-4f11-e7af-08d9360ca623 X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E0DgRu6jvITvDaFZwcObo6quVUYuzfp6YzasSNY1JKYt2v9Kp8IhULj5LH0UgvztYjZE7hBVrnYrJIwVmPn22yf3Lan4eSmBn5nI5TetNP0B5Kq8FZIYKQVHNkwMn2XgFQm201c4MeyODzufqbkzxryiwx7GJM+LUoGwxhLf3bFkUkv0RDulsxptxMXdN1cRv4CNXTUMPlafWhu/gSvLdrHqouivx5OPg2j4uqnRioOeDbctEocfeto8t33FTarHM30R6ISSbWQ5zG0j7LUjwD4Fgf4cMjJ/GiCuRcwO8mqBTnJu5cC5nHb2cyWzvTqlez9eWhcOzZ8Jp5d8qNcY5QusJffuOEBwx3cCAJY3QgzGSBrmYkFdwfT9U9/MJ+TpCQW/aylXATgRFUvwzGmtlAsCkI2I0HqF0W4qTL8GWdJcM7HHFoDcdk8KW5R3v6aN3kbiUNFtl9DC5CIBKTCmeWADNXqRUikP/nXIIsM3xlZKACdtjNsjcZGfR8ipIqU9Gf4VKw05gGuhZI+zdA6ZLbF3BOvrChqOuyhhN2ePvhxQU1+xW03NwRiarmm3k4qiygA5UYg402NK7o56ewXiqfvlh3d0kPkT3ue/9EbgEHeie1EBUxUvabZvH5Q9hXdIM9bpFUT6DJ26vnQ1A99Dvmj7vpAx2TvDKZ8Wtb0noeDiZyUa5SziBWewmPjEdWA92cbiCYVGb+iaKvSV6J7AO5OV88mqBIMzi6y08BJ0aZs= 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)(39860400002)(366004)(346002)(136003)(396003)(376002)(2616005)(956004)(55016002)(4326008)(478600001)(2906002)(36756003)(38350700002)(5660300002)(1076003)(44832011)(6636002)(38100700002)(186003)(83380400001)(6666004)(66476007)(16526019)(66946007)(66556008)(26005)(8676002)(8936002)(7696005)(86362001)(8886007)(54906003)(110136005)(52116002)(316002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5AhGJGxqfSdzAiNWOX49CKaYJOL24VJq1N347V0Mjn3V8YGYQqPPC4ZtZRhvVzrkrvM56U2ZGvljPaGYUlF9PCctpY2JY3ZscL9aVeFGLeNeUZKiLrPdoJIzB5ae0+FIuCj/siDE9jhsOUhgciVyPS62HadX9RVrDIwPKSnbQiRkG3lmPZ/5FkEvLa5CW2mCWa4kaNsDahpTiPJNgvYHzI+GR1bK5lM4dmlgWpqa5BudQ9IEYVDKZbgu3TQ6XWKP4HeL55uXanEgEFjhez6AZq5TItzmMDDoeKO1IfiahdX6sjjHe8TbUoEzc2zERlwDVXCfbM9cwbRnM4ntxJaZtqrm3fivrYyyLBXgG45WjovYeHIlDNj6dDi+ryN+DP15vdZDvMByddofcSybfo3N+tA0xMmKJv7n9QyIMJQyP3CWcZVs43u2A6ieTJvwhfg43Gstu1NLG1ZZJu5kCXhQCKQsy35ANXsDH3HyCOtzEVgg83c3+vbjb3E6guUBKfffaN4IyFchy0hCSGfllS1klZVS8vvCQUblN3w9PBvWGwdbpUHwQHJdaFBlT5QOcWhF/f5ZKuAuwVq98Xikhpy0N8A5hD7yLWQhyDpCLMT8byP14eCUmIuVaTam4T8I+DT2qZq3oY//l/67m6oVCwHW3vIYKfIsJ+gEI6HdNnuUD5firl5kZolxgW8sDnx4G29md41plwqN5Zjfi8WlJi2I1NsPx2h2SRNiHT0sMXBpWNft8XgUa5HR1g+hGHwW6Wjw1+FraHb4jrN1X1ZuatuG/33BlYR+/sM7IR559n6/aWqhvB0M8MamrC8tchuSTUsU0ZRruUiOKLQffrH9OCLizbNdmJfPINifl2LVmHnFvno4ZhgQ44/6sFPT14TnGQZvk1ffnJfEfXMy6V2O6TfTp+7zipMqa37h72ZyOdzpPkQxkd0+Tovs7s5nZ4dmZahqJ50hV0g+6fZ6/0ajgM5uytEt0oDznOooW7jAX9s60gjKl2wu2AgsChSZlF374FdoivlD1sfMmQkdE7ngn1Xy2gxQRb/tUa2tL+lLBWmd+R3FcyDDBxANcf8VbpIpGVR0cldjVRYG5Dq2AsEdKvwwlHZUdr5MJIQ66l0DOCNkka2FmJjMBhVcxrRQ4RP5LDhwzszo0csY3z9l6wYU+z4F17X6vvw3abRdqZ2ApCgE8yBHlO0TJG85f2+oRrRxYIxrQcNyVLCY0/7X8KI3wr9H4DZIjCLMW807h/Jmq0fhLf/TO9Nt5GiwE56oj+JMkK8O/giqaEQFIkUaSl0cp3k2eU59xGIrq5F9wcS6XQtQ7CgiSJa7L3woPryhh0WPIo+D X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1eed1341-448e-4f11-e7af-08d9360ca623 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:03:41.4191 (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: KB1YlxxMX6cmtCWbs2vRIFF+BqGvmosa47HtEHVdRMz8Tbh0APvLM/0M9xtEApnBzdewkTSDU1q0sd47qSy6kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230342_655379_801688C2 X-CRM114-Status: GOOD ( 20.89 ) 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: We add a new FDT based ACLINT MTIMER driver which works for both CLINT device and standalone ACLINT MTIMER device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/timer/fdt_timer.c | 4 +- lib/utils/timer/fdt_timer_clint.c [...] 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.153.144 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 We add a new FDT based ACLINT MTIMER driver which works for both CLINT device and standalone ACLINT MTIMER device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/timer/fdt_timer.c | 4 +- lib/utils/timer/fdt_timer_clint.c | 57 ----------------------- lib/utils/timer/fdt_timer_mtimer.c | 74 ++++++++++++++++++++++++++++++ lib/utils/timer/objects.mk | 2 +- 4 files changed, 77 insertions(+), 60 deletions(-) delete mode 100644 lib/utils/timer/fdt_timer_clint.c create mode 100644 lib/utils/timer/fdt_timer_mtimer.c diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index 1fad42c..148c05e 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -12,10 +12,10 @@ #include #include -extern struct fdt_timer fdt_timer_clint; +extern struct fdt_timer fdt_timer_mtimer; static struct fdt_timer *timer_drivers[] = { - &fdt_timer_clint + &fdt_timer_mtimer }; static struct fdt_timer dummy = { diff --git a/lib/utils/timer/fdt_timer_clint.c b/lib/utils/timer/fdt_timer_clint.c deleted file mode 100644 index 63d6586..0000000 --- a/lib/utils/timer/fdt_timer_clint.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2020 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#include -#include -#include -#include -#include - -#define CLINT_TIMER_MAX_NR 16 - -static unsigned long clint_timer_count = 0; -static struct clint_data clint_timer[CLINT_TIMER_MAX_NR]; - -static int timer_clint_cold_init(void *fdt, int nodeoff, - const struct fdt_match *match) -{ - int rc; - unsigned long ctsize; - struct clint_data *ct, *ctmaster = NULL; - - if (CLINT_TIMER_MAX_NR <= clint_timer_count) - return SBI_ENOSPC; - ct = &clint_timer[clint_timer_count++]; - if (1 < clint_timer_count) - ctmaster = &clint_timer[0]; - - rc = fdt_parse_aclint_node(fdt, nodeoff, true, &ct->addr, &ctsize, - &ct->first_hartid, &ct->hart_count); - if (rc) - return rc; - - ct->has_64bit_mmio = true; - if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) - ct->has_64bit_mmio = false; - - return clint_cold_timer_init(ct, ctmaster); -} - -static const struct fdt_match timer_clint_match[] = { - { .compatible = "riscv,clint0" }, - { .compatible = "sifive,clint0" }, - { }, -}; - -struct fdt_timer fdt_timer_clint = { - .match_table = timer_clint_match, - .cold_init = timer_clint_cold_init, - .warm_init = clint_warm_timer_init, - .exit = NULL, -}; diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c new file mode 100644 index 0000000..4907428 --- /dev/null +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include + +#define MTIMER_MAX_NR 16 + +static unsigned long mtimer_count = 0; +static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR]; + +static int timer_mtimer_cold_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + int rc; + unsigned long offset; + struct aclint_mtimer_data *mt, *mtmaster = NULL; + + if (MTIMER_MAX_NR <= mtimer_count) + return SBI_ENOSPC; + mt = &mtimer[mtimer_count]; + if (0 < mtimer_count) + mtmaster = &mtimer[0]; + + rc = fdt_parse_aclint_node(fdt, nodeoff, true, &mt->addr, &mt->size, + &mt->first_hartid, &mt->hart_count); + if (rc) + return rc; + mt->has_64bit_mmio = true; + + if (match->data) { + /* Adjust MTIMER address and size for CLINT device */ + offset = *((unsigned long *)match->data); + mt->addr += offset; + if ((mt->size - offset) < ACLINT_MTIMER_SIZE) + return SBI_EINVAL; + mt->size -= offset; + /* Parse additional CLINT properties */ + if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) + mt->has_64bit_mmio = false; + } + + rc = aclint_mtimer_cold_init(mt, mtmaster); + if (rc) + return rc; + + mtimer_count++; + return 0; +} + +static unsigned long clint_offset = CLINT_MTIMER_OFFSET; + +static const struct fdt_match timer_mtimer_match[] = { + { .compatible = "riscv,clint0", .data = &clint_offset }, + { .compatible = "sifive,clint0", .data = &clint_offset }, + { .compatible = "riscv,aclint-mtimer" }, + { }, +}; + +struct fdt_timer fdt_timer_mtimer = { + .match_table = timer_mtimer_match, + .cold_init = timer_mtimer_cold_init, + .warm_init = aclint_mtimer_warm_init, + .exit = NULL, +}; diff --git a/lib/utils/timer/objects.mk b/lib/utils/timer/objects.mk index 1d8b1e5..12cffcf 100644 --- a/lib/utils/timer/objects.mk +++ b/lib/utils/timer/objects.mk @@ -9,4 +9,4 @@ libsbiutils-objs-y += timer/aclint_mtimer.o libsbiutils-objs-y += timer/fdt_timer.o -libsbiutils-objs-y += timer/fdt_timer_clint.o +libsbiutils-objs-y += timer/fdt_timer_mtimer.o From patchwork Wed Jun 23 06:02:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1495960 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=fGeEm2Wt; 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=ZgYwRC4R; 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=CRnOZkHP; 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 4G8t4d51Xcz9sVm for ; Wed, 23 Jun 2021 16:04:01 +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=kEwtOEGtIf04tf/B/ewFNXKkFK3qGslhAGgQfNe+M9M=; b=fGeEm2Wt+1IbKF JN06+/RXXJbjhNYZP25OI68rfQ3dCnsjeX/mx1qsmookpSE4K9lHJYdGhLCqg/uLq59J53sFTDZrP QqV9Er57hxX4l/sy1+QONxj22HrGH0jLKC5yJZ23WwzTkRZCF8xzBAA5jY2lh58xjxaWutpaiAsFt XUDq94z5wFyEsqQ2XIOtUHuZnqCQyqOUeOD/WK5ffF15TssDdgKN1Dy0RRLK0FzQxMM7tptbh8kAK zRd8T7nuDgZL7vnKZohJvZMZo/9uxZ+Q8TzRMfsBLMmom4HrpPi+3kSeWILPXlb6a7k68LJE88eYv yZNlVDI6IG+JcDTC1/fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvzQ-009UE6-I4; Wed, 23 Jun 2021 06:03:56 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvvzM-009UD5-JK for opensbi@lists.infradead.org; Wed, 23 Jun 2021 06:03:55 +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=1624428232; x=1655964232; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qzgYrp4/0EPCYX55c+VMFEaI+KLVcqs+6J2J/AUhOhE=; b=ZgYwRC4RgH0gpwxVUViUxMc5nAY6GXm3hwM5FgEck1i/QoT8AWQRWbXq BmAzNK1PiikxRuRcX3ow84CBAmkAyX5OxXzi5ObilS3qqZqf1dBTHvXQV hn12Z8pfnuyYbdDtu8Shw3u3HWvagTiJBloypvFe/o+oxLURbjPS8xuvp KzQXcUFoIKZZ0Z+fJ07Hngw/OVoKR83awBKR4kxqbUG8GdcwqHgWX/L5+ 6uUj2F/34r9gJmP+SVcUeg9RQfkYfERNbVhtJlW+lflMrlNRzX3a5x199 S73mjFMsF1yjP39LPsQY54Gj5ViZ/Edh7v1O7EAigDOqZlhb5Z4+Jke2Z g==; IronPort-SDR: pyuSGpRp44KKjtu+RipWC5FJ7mJtCdSkq0UFMQ1i/gjZc5jNKW7CQfxwdKqVQ0f9Z75/oAd0wj 8gdRuR5ZTzMio7pPd4QDwAUhYNRcDOJnlOmmfw6JAVBTLb8FWfDU8Wcoik4TCG6NvCdwIGg4nm 8GdM07jVAUNGnJdd56fPlCXl9roGDKdlc3dsPI6h98UbItSqwt0HNwM4Uz7PY8BkrGNP6IPbKz MikiR3Q0tRarNvoh5s+x+M1ULEv5Sy84BFIdHgnbULvLfDEafc+Zvqy5CcsFnlTnww4tVxpSnX Klc= X-IronPort-AV: E=Sophos;i="5.83,293,1616428800"; d="scan'208";a="172661920" Received: from mail-mw2nam10lp2101.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.101]) by ob1.hgst.iphmx.com with ESMTP; 23 Jun 2021 14:03:51 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLAyT5urVBVjI7qvwmRYcVFJmCHHNwmJCo+3V6sf1OkeWyJpL7Ffe0OGAPzSmr3gFY6nezfIgdOpLu/x2i7zYSZoohxK/1c4LlErpoGCQVdD0cFSDIO0cZaRWDeBpW9B39hhnsjPg5D+4StI1Tfm437gIpNznKvsRUaXHZlitRLZTz6HZawYlWcTY2UjEOAA6eDOpP1FGdIyMbGEpo0ZBxLLAbpK6payxLbanBYTTRjNG4JI3JuYw/TqCVLBr5Qp5n2F2eg3uDRYfa8bK06iNauC5LEJtRoqOnRVjEjSemH4rBHmwCNzuMTpI5qSxej4Tb4pKK2eVjhfLJ6hQlv4Kw== 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=MD4wUqqr+lb+QExNc0OQuJnRpKf6GGpDEFDYi8GhFPA=; b=WECxQw0heSbEmuSrsC0eiTHJ4GeFbattxmOU1zmd4txGvOdvA9N0FRy0xB5ALPC2/XRKJd8X0z16/C0fmeGIHB0HXApbXcQ3x4VonB8JEKeDeH/6uD1XKWKW5NSKUTuYA4Kog+zmPh5b4ic8FSnvWk2exInSF505u41KM+Uv1Piw/03SvaQXHJwDgNguv3Ko6iTEOS9cflshFLKfBHSffpGpaGspS6g33DLvbGFNa9s0pUzRVaJHqRc9YNk05k0HgYWG3uHq0Wgv9ODCXubG93HubWpx9qrSZXHBGNZIcXJ5W1pa6Ngrz81O7YNYeRXLQYAWRez5Y0/ytSdJTi3hNQ== 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=MD4wUqqr+lb+QExNc0OQuJnRpKf6GGpDEFDYi8GhFPA=; b=CRnOZkHPaI35s2G4mImAeBCQi6mVsBVlgi4wLlOYevYODTY3To87goCGPaSBDLT5YYl8pYeH51cWd40PKPUFYm3qDQ6HDsX4ZkRVuyWqW5uLGSB15iZK+GohFwenBEnbWu2XulBW1VWAigf7kIDA6Lb8PulS28x1NKCJ8uNRvdo= 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 CO6PR04MB7810.namprd04.prod.outlook.com (2603:10b6:5:358::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 06:03:51 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 06:03:51 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v2 6/6] platform: Replace CLINT library usage with ACLINT library Date: Wed, 23 Jun 2021 11:32:26 +0530 Message-Id: <20210623060226.442030-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210623060226.442030-1-anup.patel@wdc.com> References: <20210623060226.442030-1-anup.patel@wdc.com> X-Originating-IP: [122.167.39.73] X-ClientProxiedBy: MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) 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.167.39.73) by MA1PR0101CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 23 Jun 2021 06:03:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a3aaa56-cbd0-449a-2871-08d9360ca95b X-MS-TrafficTypeDiagnostic: CO6PR04MB7810: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +V16YlEs3pAR4cu2XkVjAS2K7GvzQokhdEGmiLkQlTEqtXubAegVTlepcMla42AhbjRZBHqaNSZvre28hHhz4g7jZntKwK7FdZMZm4/IDpKzuF+Fn7FeapecNNJ/6P51/0dmM6lZsNYgQVSsFt1v0JNAkbeW4sOplS9K62YS8L3T2EnShBzfcqOXq0HzMRo3EJsvXMvX5XxjRChB0ZGuC+2S84VQb/24Yr//Rx01vBfh57wblDfY+XsgS+MC9LH220hpOoGjGNecDNITmX3SSvgwz949baHXd7rb2CtLyEOd3NO7+fdLJ49BFWnyoYCdYMinHg6T6lGBotfk7/pc5qNAfGQ06jv2xfotXThmRuYR+SiTRiRYfU4+cJYibNMxAW9ycRgdGL8g718zYWUIUKHsiVycoH9u0dLtpnav5KXXvpu+jzLM5TF0GG7xZRjadCLxusToP2PpKvuqPUeFF99+KUbatU90LLIkgCVsGG2RTKVKVVeyY6/I9Je9IkJhLkL8mA1YL172vzvUfdfzgv9iH8PmPabO8Z5RLG54NB7GPaJ8mESMBn/ZAwBDwKJ4ULgIz0U7oQtLunkLQRUegN9OSrIBDA5DTvZXACXUACnoFx88SHCf8e/7wdDANOCJSZSXOTWUjDKd1PdHYUlA412x6vbg4lYZUXSY23rg9zL/LmOOjd8gF7mS2LMxaF4VWrfeKEP4gWKBPYqExEfJXCATSyay4AH1g5Saeg5uVS72YgvUgBhlFYfTNB5zpHh+ 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)(39860400002)(366004)(346002)(136003)(396003)(376002)(2616005)(956004)(55016002)(4326008)(478600001)(2906002)(36756003)(38350700002)(5660300002)(1076003)(44832011)(6636002)(38100700002)(186003)(83380400001)(6666004)(66476007)(30864003)(16526019)(66946007)(66556008)(26005)(8676002)(8936002)(7696005)(86362001)(8886007)(54906003)(110136005)(52116002)(316002)(525324003)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M7DO2gHliGGcEk7qLeS01zne5jeehc8yqap0YdHp994/dL7znHUe2ccdxWePrSMIk3wjfrv8ppUAnFEoI96Ij4vdZKbz3xEMQSU23yVlDa53F5VLEsbMITseHsmAWUst5U/rRI2ap/UPq5dhW76han18pGsHijKrgOkRCEScs2Fm/Q54NbFhkavUJ43oZVwiHjRESlNaVruMfnTznu9IUPsmN7Yw4PODiwK+lUzKYJ/p2yzarep5RkaYalYugrcWMjXQT+x3bR9sbkTwxhJboXJfrqk3QDBKc0ZWHiDgoI3QmWrN7gQIJvz8Nt0pV1tSsH0OhRl0XDkIuSfOvC5QPurfvN1osvuZZGTGeTvRQREG3dGcnUgjQuDP18+wO6uZ9egRlDL+q9hRPhhwvIuMidGybrJ4RFGtPLKhpDh0TJzm0rrioo9zkMATBL1wokRAYQKZix7EvtWy9AW7kJY5UXHojPGRaIuABX5PYYiUAx9EkgzwrYkZQ7wUCRumQztb4d9kMS22iQtADE1NFsjlWhaA8/dD4U9yjAarBhz/ozJFHo2WIw7JpYZnmaHGj58519pJd8HmqT/mhM9kEzBmvKENlyZfclTYFUE9Nd/TLkZP8pUDeA7XN+p52CVhaIaJpYQU5P33AvMXveRPKhlXEhGcu4n0i81/IZ5/64FZOyUs+f0kE4Ze7SGFnjhm20h9IrgjHK+DhA680Z7e2yzwUqz1lbuYUcSfjzhGSrrwb+jVfn9N9R7Av9t6sV7Wrsloo7vhcGlruHnjj9fdtHJ7sW5pInJOR1aSGAZEbVxrMOvCKR18YFv3bUOJZ4KBZVYu74vDtEI3s1yTyTXoPKKzueIvcO2HFbdC5ijd7JdaUFPBO9JJOUrsK9ZHskNex0HdO3/vjxiqW6Zmgebr/QYIpU3evLnVyv5kipV6go/1ybzN4Jba+jjMWWj9kITFtQdbfp6PTNVQk8SyTaKricJDUA88S/m2Q4XNnvipgUb7dZXH7oaJCJuDyxFIrkkE+pkhoDTnnniaPktnCkwhmHJufjhLqyx8NbV+1nN8eAAJLE89VOTdreDKXuCh1ZBmC2HNkqtK9BM1gJuXlZaEJLKEmRbF9VKZ6uaTBA+xdHLoVoqQDPRjCcYgd8+Js0vpUIwYc3rFNdjy5+OBJRONwFp/J7yicfP5fwhK0gd3159lJa8vD4/CQGYSv9V5UaLAzQEJqdJDSOyEJOmK/sQoRAh4MtxKa2B0KGrYwsULV6c/bJ3P/QYEaTrJq/FhEc+KUHZpRkgBa5DyZjktOcAsNHLxivIhRq7uu4KgHPhN8WfSBQa0wGopba3cC+b1JR/XwMq3 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a3aaa56-cbd0-449a-2871-08d9360ca95b X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2021 06:03:51.1384 (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: gAV2Tu7llxd8hIzBzEo8909edNXojE+KTAczAUXYPUjGkBgoxaVF3q8CpVKmB/7DkfGwPqUpKbY4FBH9PXIHbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7810 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_230352_689347_889728AE X-CRM114-Status: GOOD ( 16.61 ) 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 ACLINT devices are backward compatible with SiFive CLINT so we replace all CLINT library usage in various platforms with ACLINT library. As a result of this replacement, the CLINT library is not u [...] 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.153.144 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 ACLINT devices are backward compatible with SiFive CLINT so we replace all CLINT library usage in various platforms with ACLINT library. As a result of this replacement, the CLINT library is not used by any part of OpenSBI hence we remove it. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- include/sbi_utils/sys/clint.h | 41 ----- lib/utils/sys/clint.c | 256 ----------------------------- lib/utils/sys/objects.mk | 1 - platform/fpga/ariane/platform.c | 27 ++- platform/fpga/openpiton/platform.c | 33 +++- platform/kendryte/k210/platform.c | 23 ++- platform/kendryte/k210/platform.h | 4 + platform/nuclei/ux600/platform.c | 28 +++- platform/template/platform.c | 31 +++- 9 files changed, 107 insertions(+), 337 deletions(-) delete mode 100644 include/sbi_utils/sys/clint.h delete mode 100644 lib/utils/sys/clint.c diff --git a/include/sbi_utils/sys/clint.h b/include/sbi_utils/sys/clint.h deleted file mode 100644 index 1e2b40b..0000000 --- a/include/sbi_utils/sys/clint.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2019 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#ifndef __SYS_CLINT_H__ -#define __SYS_CLINT_H__ - -#include - -struct clint_data { - /* Public details */ - unsigned long addr; - u32 first_hartid; - u32 hart_count; - bool has_64bit_mmio; - /* Private details (initialized and used by CLINT library)*/ - u32 *ipi; - struct clint_data *time_delta_reference; - unsigned long time_delta_computed; - u64 time_delta; - u64 *time_val; - u64 *time_cmp; - u64 (*time_rd)(volatile u64 *addr); - void (*time_wr)(u64 value, volatile u64 *addr); -}; - -int clint_warm_ipi_init(void); - -int clint_cold_ipi_init(struct clint_data *clint); - -int clint_warm_timer_init(void); - -int clint_cold_timer_init(struct clint_data *clint, - struct clint_data *reference); - -#endif diff --git a/lib/utils/sys/clint.c b/lib/utils/sys/clint.c deleted file mode 100644 index e8c2bd9..0000000 --- a/lib/utils/sys/clint.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2019 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CLINT_IPI_OFF 0 -#define CLINT_IPI_SIZE 0x4000 - -#define CLINT_TIME_CMP_OFF 0x4000 -#define CLINT_TIME_CMP_SIZE 0x4000 - -#define CLINT_TIME_VAL_OFF 0xbff8 -#define CLINT_TIME_VAL_SIZE 0x4000 - -static struct clint_data *clint_ipi_hartid2data[SBI_HARTMASK_MAX_BITS]; - -static void clint_ipi_send(u32 target_hart) -{ - struct clint_data *clint; - - if (SBI_HARTMASK_MAX_BITS <= target_hart) - return; - clint = clint_ipi_hartid2data[target_hart]; - if (!clint) - return; - - /* Set CLINT IPI */ - writel(1, &clint->ipi[target_hart - clint->first_hartid]); -} - -static void clint_ipi_clear(u32 target_hart) -{ - struct clint_data *clint; - - if (SBI_HARTMASK_MAX_BITS <= target_hart) - return; - clint = clint_ipi_hartid2data[target_hart]; - if (!clint) - return; - - /* Clear CLINT IPI */ - writel(0, &clint->ipi[target_hart - clint->first_hartid]); -} - -static struct sbi_ipi_device clint_ipi = { - .name = "clint", - .ipi_send = clint_ipi_send, - .ipi_clear = clint_ipi_clear -}; - -int clint_warm_ipi_init(void) -{ - /* Clear CLINT IPI for current HART */ - clint_ipi_clear(current_hartid()); - - return 0; -} - -int clint_cold_ipi_init(struct clint_data *clint) -{ - u32 i; - int rc; - struct sbi_domain_memregion reg; - - if (!clint) - return SBI_EINVAL; - - /* Initialize private data */ - clint->ipi = (void *)clint->addr; - - /* Update IPI hartid table */ - for (i = 0; i < clint->hart_count; i++) - clint_ipi_hartid2data[clint->first_hartid + i] = clint; - - /* Add CLINT ipi region to the root domain */ - sbi_domain_memregion_init(clint->addr + CLINT_IPI_OFF, - CLINT_IPI_SIZE, - SBI_DOMAIN_MEMREGION_MMIO, ®); - rc = sbi_domain_root_add_memregion(®); - if (rc) - return rc; - - sbi_ipi_set_device(&clint_ipi); - - return 0; -} - -static struct clint_data *clint_timer_hartid2data[SBI_HARTMASK_MAX_BITS]; - -#if __riscv_xlen != 32 -static u64 clint_time_rd64(volatile u64 *addr) -{ - return readq_relaxed(addr); -} - -static void clint_time_wr64(u64 value, volatile u64 *addr) -{ - writeq_relaxed(value, addr); -} -#endif - -static u64 clint_time_rd32(volatile u64 *addr) -{ - u32 lo, hi; - - do { - hi = readl_relaxed((u32 *)addr + 1); - lo = readl_relaxed((u32 *)addr); - } while (hi != readl_relaxed((u32 *)addr + 1)); - - return ((u64)hi << 32) | (u64)lo; -} - -static void clint_time_wr32(u64 value, volatile u64 *addr) -{ - u32 mask = -1U; - - writel_relaxed(value & mask, (void *)(addr)); - writel_relaxed(value >> 32, (void *)(addr) + 0x04); -} - -static u64 clint_timer_value(void) -{ - struct clint_data *clint = clint_timer_hartid2data[current_hartid()]; - - /* Read CLINT Time Value */ - return clint->time_rd(clint->time_val) + clint->time_delta; -} - -static void clint_timer_event_stop(void) -{ - u32 target_hart = current_hartid(); - struct clint_data *clint = clint_timer_hartid2data[target_hart]; - - /* Clear CLINT Time Compare */ - clint->time_wr(-1ULL, - &clint->time_cmp[target_hart - clint->first_hartid]); -} - -static void clint_timer_event_start(u64 next_event) -{ - u32 target_hart = current_hartid(); - struct clint_data *clint = clint_timer_hartid2data[target_hart]; - - /* Program CLINT Time Compare */ - clint->time_wr(next_event - clint->time_delta, - &clint->time_cmp[target_hart - clint->first_hartid]); -} - -static struct sbi_timer_device clint_timer = { - .name = "clint", - .timer_value = clint_timer_value, - .timer_event_start = clint_timer_event_start, - .timer_event_stop = clint_timer_event_stop -}; - -int clint_warm_timer_init(void) -{ - u64 v1, v2, mv; - u32 target_hart = current_hartid(); - struct clint_data *reference; - struct clint_data *clint = clint_timer_hartid2data[target_hart]; - - if (!clint) - return SBI_ENODEV; - - /* - * Compute delta if reference available - * - * We deliberately compute time_delta in warm init so that time_delta - * is computed on a HART which is going to use given CLINT. We use - * atomic flag timer_delta_computed to ensure that only one HART does - * time_delta computation. - */ - if (clint->time_delta_reference) { - reference = clint->time_delta_reference; - if (!atomic_raw_xchg_ulong(&clint->time_delta_computed, 1)) { - v1 = clint->time_rd(clint->time_val); - mv = reference->time_rd(reference->time_val); - v2 = clint->time_rd(clint->time_val); - clint->time_delta = mv - ((v1 / 2) + (v2 / 2)); - } - } - - /* Clear CLINT Time Compare */ - clint->time_wr(-1ULL, - &clint->time_cmp[target_hart - clint->first_hartid]); - - return 0; -} - -int clint_cold_timer_init(struct clint_data *clint, - struct clint_data *reference) -{ - u32 i; - int rc; - struct sbi_domain_memregion reg; - - if (!clint) - return SBI_EINVAL; - - /* Initialize private data */ - clint->time_delta_reference = reference; - clint->time_delta_computed = 0; - clint->time_delta = 0; - clint->time_val = (u64 *)((void *)clint->addr + CLINT_TIME_VAL_OFF); - clint->time_cmp = (u64 *)((void *)clint->addr + CLINT_TIME_CMP_OFF); - clint->time_rd = clint_time_rd32; - clint->time_wr = clint_time_wr32; - - /* Override read/write accessors for 64bit MMIO */ -#if __riscv_xlen != 32 - if (clint->has_64bit_mmio) { - clint->time_rd = clint_time_rd64; - clint->time_wr = clint_time_wr64; - } -#endif - - /* Update timer hartid table */ - for (i = 0; i < clint->hart_count; i++) - clint_timer_hartid2data[clint->first_hartid + i] = clint; - - /* Add CLINT mtime region to the root domain */ - sbi_domain_memregion_init(clint->addr + CLINT_TIME_VAL_OFF, - CLINT_TIME_VAL_SIZE, - SBI_DOMAIN_MEMREGION_MMIO, ®); - rc = sbi_domain_root_add_memregion(®); - if (rc) - return rc; - - /* Add CLINT timecmp region to the root domain */ - sbi_domain_memregion_init(clint->addr + CLINT_TIME_CMP_OFF, - CLINT_TIME_CMP_SIZE, - SBI_DOMAIN_MEMREGION_MMIO, ®); - rc = sbi_domain_root_add_memregion(®); - if (rc) - return rc; - - sbi_timer_set_device(&clint_timer); - - return 0; -} diff --git a/lib/utils/sys/objects.mk b/lib/utils/sys/objects.mk index 7878ca8..06be322 100644 --- a/lib/utils/sys/objects.mk +++ b/lib/utils/sys/objects.mk @@ -7,6 +7,5 @@ # Anup Patel # -libsbiutils-objs-y += sys/clint.o libsbiutils-objs-y += sys/htif.o libsbiutils-objs-y += sys/sifive_test.o diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 42e43fa..0b47aa0 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -12,9 +12,10 @@ #include #include #include +#include #include #include -#include +#include #define ARIANE_UART_ADDR 0x10000000 #define ARIANE_UART_FREQ 50000000 @@ -25,14 +26,26 @@ #define ARIANE_PLIC_NUM_SOURCES 3 #define ARIANE_HART_COUNT 1 #define ARIANE_CLINT_ADDR 0x2000000 +#define ARIANE_ACLINT_MSWI_ADDR (ARIANE_CLINT_ADDR + \ + CLINT_MSWI_OFFSET) +#define ARIANE_ACLINT_MTIMER_ADDR (ARIANE_CLINT_ADDR + \ + CLINT_MTIMER_OFFSET) static struct plic_data plic = { .addr = ARIANE_PLIC_ADDR, .num_src = ARIANE_PLIC_NUM_SOURCES, }; -static struct clint_data clint = { - .addr = ARIANE_CLINT_ADDR, +static struct aclint_mswi_data mswi = { + .addr = ARIANE_ACLINT_MSWI_ADDR, + .size = ACLINT_MSWI_SIZE, + .first_hartid = 0, + .hart_count = ARIANE_HART_COUNT, +}; + +static struct aclint_mtimer_data mtimer = { + .addr = ARIANE_ACLINT_MTIMER_ADDR, + .size = ACLINT_MTIMER_SIZE, .first_hartid = 0, .hart_count = ARIANE_HART_COUNT, .has_64bit_mmio = TRUE, @@ -123,12 +136,12 @@ static int ariane_ipi_init(bool cold_boot) int ret; if (cold_boot) { - ret = clint_cold_ipi_init(&clint); + ret = aclint_mswi_cold_init(&mswi); if (ret) return ret; } - return clint_warm_ipi_init(); + return aclint_mswi_warm_init(); } /* @@ -139,12 +152,12 @@ static int ariane_timer_init(bool cold_boot) int ret; if (cold_boot) { - ret = clint_cold_timer_init(&clint, NULL); + ret = aclint_mtimer_cold_init(&mtimer, NULL); if (ret) return ret; } - return clint_warm_timer_init(); + return aclint_mtimer_warm_init(); } /* diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 894bfdc..57ec21b 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -12,9 +12,10 @@ #include #include #include +#include #include #include -#include +#include #define OPENPITON_DEFAULT_UART_ADDR 0xfff0c2c000 #define OPENPITON_DEFAULT_UART_FREQ 60000000 @@ -25,6 +26,10 @@ #define OPENPITON_DEFAULT_PLIC_NUM_SOURCES 2 #define OPENPITON_DEFAULT_HART_COUNT 3 #define OPENPITON_DEFAULT_CLINT_ADDR 0xfff1020000 +#define OPENPITON_DEFAULT_ACLINT_MSWI_ADDR \ + (OPENPITON_DEFAULT_CLINT_ADDR + CLINT_MSWI_OFFSET) +#define OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR \ + (OPENPITON_DEFAULT_CLINT_ADDR + CLINT_MTIMER_OFFSET) static struct platform_uart_data uart = { OPENPITON_DEFAULT_UART_ADDR, @@ -36,8 +41,16 @@ static struct plic_data plic = { .num_src = OPENPITON_DEFAULT_PLIC_NUM_SOURCES, }; -static struct clint_data clint = { - .addr = OPENPITON_DEFAULT_CLINT_ADDR, +static struct aclint_mswi_data mswi = { + .addr = OPENPITON_DEFAULT_ACLINT_MSWI_ADDR, + .size = ACLINT_MSWI_SIZE, + .first_hartid = 0, + .hart_count = OPENPITON_DEFAULT_HART_COUNT, +}; + +static struct aclint_mtimer_data mtimer = { + .addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR, + .size = ACLINT_MTIMER_SIZE, .first_hartid = 0, .hart_count = OPENPITON_DEFAULT_HART_COUNT, .has_64bit_mmio = TRUE, @@ -67,8 +80,10 @@ static int openpiton_early_init(bool cold_boot) plic = plic_data; rc = fdt_parse_compat_addr(fdt, &clint_addr, "riscv,clint0"); - if (!rc) - clint.addr = clint_addr; + if (!rc) { + mswi.addr = clint_addr; + mtimer.addr = clint_addr + CLINT_MTIMER_OFFSET; + } return 0; } @@ -149,12 +164,12 @@ static int openpiton_ipi_init(bool cold_boot) int ret; if (cold_boot) { - ret = clint_cold_ipi_init(&clint); + ret = aclint_mswi_cold_init(&mswi); if (ret) return ret; } - return clint_warm_ipi_init(); + return aclint_mswi_warm_init(); } /* @@ -165,12 +180,12 @@ static int openpiton_timer_init(bool cold_boot) int ret; if (cold_boot) { - ret = clint_cold_timer_init(&clint, NULL); + ret = aclint_mtimer_cold_init(&mtimer, NULL); if (ret) return ret; } - return clint_warm_timer_init(); + return aclint_mtimer_warm_init(); } /* diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 66a0392..55c4b1e 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -14,9 +14,10 @@ #include #include #include +#include #include #include -#include +#include #include "platform.h" extern const char dt_k210_start[]; @@ -33,8 +34,16 @@ static struct plic_data plic = { .num_src = K210_PLIC_NUM_SOURCES, }; -static struct clint_data clint = { - .addr = K210_CLINT_BASE_ADDR, +static struct aclint_mswi_data mswi = { + .addr = K210_ACLINT_MSWI_ADDR, + .size = ACLINT_MSWI_SIZE, + .first_hartid = 0, + .hart_count = K210_HART_COUNT, +}; + +static struct aclint_mtimer_data mtimer = { + .addr = K210_ACLINT_MTIMER_ADDR, + .size = ACLINT_MTIMER_SIZE, .first_hartid = 0, .hart_count = K210_HART_COUNT, .has_64bit_mmio = TRUE, @@ -139,12 +148,12 @@ static int k210_ipi_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_ipi_init(&clint); + rc = aclint_mswi_cold_init(&mswi); if (rc) return rc; } - return clint_warm_ipi_init(); + return aclint_mswi_warm_init(); } static int k210_timer_init(bool cold_boot) @@ -152,12 +161,12 @@ static int k210_timer_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_timer_init(&clint, NULL); + rc = aclint_mtimer_cold_init(&mtimer, NULL); if (rc) return rc; } - return clint_warm_timer_init(); + return aclint_mtimer_warm_init(); } const struct sbi_platform_operations platform_ops = { diff --git a/platform/kendryte/k210/platform.h b/platform/kendryte/k210/platform.h index e425faf..0a32530 100644 --- a/platform/kendryte/k210/platform.h +++ b/platform/kendryte/k210/platform.h @@ -22,6 +22,10 @@ #define K210_SYSCTL_BASE_ADDR 0x50440000ULL #define K210_UART_BASE_ADDR 0x38000000ULL #define K210_CLINT_BASE_ADDR 0x02000000ULL +#define K210_ACLINT_MSWI_ADDR \ + (K210_CLINT_BASE_ADDR + CLINT_MSWI_OFFSET) +#define K210_ACLINT_MTIMER_ADDR \ + (K210_CLINT_BASE_ADDR + CLINT_MTIMER_OFFSET) #define K210_PLIC_BASE_ADDR 0x0C000000ULL /* Registers */ diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 5414316..22ca4c9 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -17,9 +17,10 @@ #include #include #include +#include #include #include -#include +#include /* clang-format off */ @@ -32,6 +33,10 @@ #define UX600_NUCLEI_TIMER_MSFTRST_KEY 0x80000A5F /* The clint compatiable timer offset is 0x1000 against nuclei timer */ #define UX600_CLINT_TIMER_ADDR (UX600_NUCLEI_TIMER_ADDR + 0x1000) +#define UX600_ACLINT_MSWI_ADDR (UX600_CLINT_TIMER_ADDR + \ + CLINT_MSWI_OFFSET) +#define UX600_ACLINT_MTIMER_ADDR (UX600_CLINT_TIMER_ADDR + \ + CLINT_MTIMER_OFFSET) #define UX600_PLIC_ADDR 0x8000000 #define UX600_PLIC_NUM_SOURCES 0x35 @@ -61,12 +66,21 @@ static struct plic_data plic = { .num_src = UX600_PLIC_NUM_SOURCES, }; -static struct clint_data clint = { - .addr = UX600_CLINT_TIMER_ADDR, +static struct aclint_mswi_data mswi = { + .addr = UX600_ACLINT_MSWI_ADDR, + .size = ACLINT_MSWI_SIZE, + .first_hartid = 0, + .hart_count = UX600_HART_COUNT, +}; + +static struct aclint_mtimer_data mtimer = { + .addr = UX600_ACLINT_MTIMER_ADDR, + .size = ACLINT_MTIMER_SIZE, .first_hartid = 0, .hart_count = UX600_HART_COUNT, .has_64bit_mmio = TRUE, }; + static u32 measure_cpu_freq(u32 n) { u32 start_mtime, delta_mtime; @@ -188,12 +202,12 @@ static int ux600_ipi_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_ipi_init(&clint); + rc = aclint_mswi_cold_init(&mswi); if (rc) return rc; } - return clint_warm_ipi_init(); + return aclint_mswi_warm_init(); } static int ux600_timer_init(bool cold_boot) @@ -201,12 +215,12 @@ static int ux600_timer_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_timer_init(&clint, NULL); + rc = aclint_mtimer_cold_init(&mtimer, NULL); if (rc) return rc; } - return clint_warm_timer_init(); + return aclint_mtimer_warm_init(); } const struct sbi_platform_operations platform_ops = { diff --git a/platform/template/platform.c b/platform/template/platform.c index d407fd5..3f09d98 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -13,14 +13,19 @@ * Include these files as needed. * See config.mk PLATFORM_xxx configuration parameters. */ +#include #include #include -#include +#include #define PLATFORM_PLIC_ADDR 0xc000000 #define PLATFORM_PLIC_NUM_SOURCES 128 #define PLATFORM_HART_COUNT 4 #define PLATFORM_CLINT_ADDR 0x2000000 +#define PLATFORM_ACLINT_MSWI_ADDR (PLATFORM_CLINT_ADDR + \ + CLINT_MSWI_OFFSET) +#define PLATFORM_ACLINT_MTIMER_ADDR (PLATFORM_CLINT_ADDR + \ + CLINT_MTIMER_OFFSET) #define PLATFORM_UART_ADDR 0x09000000 #define PLATFORM_UART_INPUT_FREQ 10000000 #define PLATFORM_UART_BAUDRATE 115200 @@ -30,8 +35,16 @@ static struct plic_data plic = { .num_src = PLATFORM_PLIC_NUM_SOURCES, }; -static struct clint_data clint = { - .addr = PLATFORM_CLINT_ADDR, +static struct aclint_mswi_data mswi = { + .addr = PLATFORM_ACLINT_MSWI_ADDR, + .size = ACLINT_MSWI_SIZE, + .first_hartid = 0, + .hart_count = PLATFORM_HART_COUNT, +}; + +static struct aclint_mtimer_data mtimer = { + .addr = PLATFORM_ACLINT_MTIMER_ADDR, + .size = ACLINT_MTIMER_SIZE, .first_hartid = 0, .hart_count = PLATFORM_HART_COUNT, .has_64bit_mmio = TRUE, @@ -88,14 +101,14 @@ static int platform_ipi_init(bool cold_boot) { int ret; - /* Example if the generic CLINT driver is used */ + /* Example if the generic ACLINT driver is used */ if (cold_boot) { - ret = clint_cold_ipi_init(&clint); + ret = aclint_mswi_cold_init(&mswi); if (ret) return ret; } - return clint_warm_ipi_init(); + return aclint_mswi_warm_init(); } /* @@ -105,14 +118,14 @@ static int platform_timer_init(bool cold_boot) { int ret; - /* Example if the generic CLINT driver is used */ + /* Example if the generic ACLINT driver is used */ if (cold_boot) { - ret = clint_cold_timer_init(&clint, NULL); + ret = aclint_mtimer_cold_init(&mtimer, NULL); if (ret) return ret; } - return clint_warm_timer_init(); + return aclint_mtimer_warm_init(); } /*