From patchwork Sat Jun 12 16:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1491297 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=sLVWfpeS; 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=mGdB5x2Z; 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=jEHCtVqh; 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 4G2Mvz6PzRz9sXb for ; Sun, 13 Jun 2021 02:03:59 +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=cqbnfAOUk+RemSmHVhVlsj0Fj7+UAkXhvVRpnNjT+jM=; b=sLVWfpeSQ2VOHJ GdEiXfhtJl1ehPBumiP4G89OlJOvgd8YbKfe5h+hLRnNmsr7nUlTMXY6lDUvrBPTNE96gVPgiZDq7 7P+iyt0XtY95U2qPHFps6CEHGJUqgOjWH/61J8umOSRww4G7eAGDNbBX1eS8v+G/boYNk48z9cXHu kIFpCfpaM4vy6w+P3m2G1WX8Lw4HmkVRyWCK+piuDTB3KOG+osm1C1gdIxpByNRXHclvNUpL5ZCBF CTDbMgnix5wSF89yLuHHoPSE/MyMwChuWmgsB0VSYsFtv4FmYziehwcXi9pX2ZWlYQR8bk1VXEWd9 Po2dyoq48oxXbkuZxhdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls66z-008mM8-QR; Sat, 12 Jun 2021 16:03:53 +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 1ls66v-008mKn-3b for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:03:51 +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=1623513828; x=1655049828; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3gepk7z2ROqXDjHsbN8V8lm14DdXZaBkLYb9cr6fdPo=; b=mGdB5x2ZYrpXXONJk9JT0FrKs14Fo7I8imjpLBNEPZpaFWGn8SKbo3ty /XGwAq5vYFClWhnyaGl8zwvrsPhb0kVARKg34IL2HuG/ybfzuzKcF4ehO BkuE1JwJIZVswzW01/y/bDjnD2u67FzgDXimQaZoWjGeYxkw6570bbxI7 iD2hfYOXLZYXKmfwrLaEztP+wRE4C9q71cg7TlI/OfDt3FwjG3k59+mAW cPRLy9uWdGuTU3PQPN2t6gtPFN1547f8navZIu41rgHPMV6gZ+wVPDLNl lQqH2BsM6oKlUqWa/2HQ7iiJHaa6bcaET/Sb9vSIsFyr8NefPonfne995 g==; IronPort-SDR: N3MiY1MV4YFgSQ31IZA6wpgJP2k3w5jVbvPyXQmRMut7SmB9NP8Hz6GhgdAWPNxSt2wqHXkytk SaYajdfePreDa5IJQMumS7mhWq3r8hPNXYt7wAAdtJZgpnPz69ca7HiL/zQwDwfj5CKyBi7mW0 qOfzD6PUYqr/PI5SKx5rnkh3lfZQ8PBpJZkymz1g568uvjMC37jnNt3yU+8hQxnjEICN21aN/L xy/8RdJGIAtWRTgl7DQHxmioxCX/dKxv+7c8nO5gezkQqaZEwfYnVRqzXOpOmmfpCsERGADeS7 LFU= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="170973839" Received: from mail-bn8nam08lp2045.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.45]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:03:46 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4jMCzabELEIBV5KMtT/nqWqgvGQp26qsUpwUGGFjIdsDtaMoSHOsoCzMbbV+SSeoKvNGidKK7VN8PWV8dvTmSpKNx0HutEhg9ce6MI9sVsIKRsMDgUJz6SrHeYLsyNSpIA2NalBTgeUgUFPVHauZF6oNDbvO7Jne6uBYRMyIJQeXAyTruVCV6IaxZTbki0PVsM+YRuA+E4yx8/pRo2B9SWVUiqIBWZh7cMws44pBr2rPxSdzo5CQlwqw9wkrR4NKyJ9akWujBIaqW98Llvt08pMhMZCRj6T9v22n1XVMRL6/LOaeRWQoMejj1E/1ae4ir5bzcKLexREUWEAm2gwwQ== 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=3HW8xcuhQn2XAaNCSpA59i5jsy5FaEJAY1+aJPidm0E=; b=L/4lZaRE1bxAbjNj7nUrnrPMCxMKxB25Mu5kT8eM1PHFj9IhXwbPgDIP1leow6nk1Vfa/TwpaH2aEINgWnrw863V1odMdFdRlNgnmBJDw7gsMt5daRlS9by4UgenLUaDjEL0BkOFRN9fl/D+HhauHZ8ezNFcUgCk7dTXt7ZrIar1ZL17hRXp3o+Cl+ePxRrEQAxBuQwTayU81Ym3JPSZGW3OLhAgmdWKFX6wTwIbdX/7wJXlCjow8K+LNnpyojIkTVevd1z85oQOw8B5JUPpseYeIVxpEu+rbnaT1Pk+1vJ2JqiR7pdAYd4kmlKRuVu5Ss2kj3NDLgMUkhQKL926uA== 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=3HW8xcuhQn2XAaNCSpA59i5jsy5FaEJAY1+aJPidm0E=; b=jEHCtVqhPU9WHy4INkgCEwVW9QfuYYXijS0RcHZaCjNymc46kcbwpaH414GYojIuUEVAb+jjid+d1FXU0fmXUb999wfvCHF7MGXIbeNsjK0jhCzyHv9g359xWKN8V0NsleZP3WRuO1nxzsu+OuWiV9YQC8Zxw6WCV+mNMXQ34YA= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16:03:45 +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.4219.025; Sat, 12 Jun 2021 16:03:45 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 1/6] lib: utils/timer: Add ACLINT MTIMER library Date: Sat, 12 Jun 2021 21:33:16 +0530 Message-Id: <20210612160321.330638-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a4bee44-edb8-4638-4677-08d92dbba843 X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: bRfDhjHm8Tb96j8YGNk8PyU5GKx7u9Vyf0MOk3mE/xmc0I7fyFX/oF7Deg1ND5PM3WIIpJegUL3EiBHtaZvmgGLzi7ijrJzaYG1XyumtJXkFGew/8HwG/437R3IHRUp0GJD1aq20yLRWcnz9XVcP/WfDj4di2Vy0Hzer0RRMo9f9oEay2i/nm5yyp+Wy9EPHt2ZccCyKys0LTTviNMXAKbR+pCDdCpQFmFOcRXxd0gXj5cw4FLI0qzfax2jSeV4j5EB+HfbmulMP6AfHMeqFAkb24H02/GmVpL4MCBldcd4FcivU/J2HHTaEI8eH/1GWfUBgVx44lZGKw+qucTdGSmTdNKl6jNBsGfddiwoauznTUdmD+C5RwhDaH1VcRSGuHDPMGSTpohKxJrqO7X+r1VADUqhXoqOq6+hlV5VpiRIUU3vOrhFPyODAof3KYmeGykKRDOCRd4q4TKLLmtizb+Ua8LFBFg6nn6RUymjVsWM+wZi6smXvo2zg/1MnM4kTvqlJTN36ivV7gcbzC1ooM/nDX8ewvVxEXtkBtL3VWsbv8hgHaccH3KFjDt5g2ZzEN/Rlwj8yNT6dx2L0mHTgBmmnzJvBgORJico/CYw7gRUgcIce+fB0blJ56cwa4V3RmC4SPaUzToL65BBdqUtGWQ== 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M24NxISK5B7EzodQwJVjAOZPCHkES2Fknc2YCfK4DkfPVQ5CfiK1dSuLKMOFNnWsrzx3480MI10p/xYx+HjTGg2dwNX/n9Iw9Dhc/89mdY/cNTIZ2y4TG5htzBS/lcD/UAP7WBUz0GVdVVHjhvX5Wo1VZgxDpNxVkbbubqb2vTo4bzwvUWvzmjeozVQS8vXTPdu/j+qwzGgeC3Xc65K5fXacddk34G50SEBmGP93CBvRxpnJXwkyjZw1184YlSsdYhyD0MxCcs2QViW6Uq56Fsr2Ip5BNZ9DQcyliNODT3/T7YKk9qvfUSiBgdxYzz8q/YyUtmf5cp0FahzihelbYkQGUVoXx1gvyxg7YAcl/VkdcbqrT3vMWKIjehMpDhLJ6qXPzMHo5mdfw/l0HoUGjO8JkFyItInknoR9mQYyvc+EgmTGI2QzI7c9APuctC00zkyiSrk2Lxw8x/mzUzp+29gZ6gbbKQqvCAoCRkZAu2oCXxe+gzsJH8e7Up2urxmpCBEFNQ9rLCc3mX/xRNUaEs2iBqU/zlnCz0IMtCvJY/7M1J7AIKGBzfeMrHsAlXWB2pDHOl+YU/v7+nb/77dsXhpg3EuzB3poCZO0xFXCpjr26pIuRUK1IbhsLVSkYoFjvnVDEyftvBjh3yYR+bqMpnQZpOxRQ50VuZJmjs+9ZOeu3gKDnyxcceZLblSk1LtFM2V87TKYr335hP6FiyUDp40jPGY65q9uKJhZSAlsQfVCy5JWTdCTKbDeLZyUxYG5cPKtOrrSnKjzneG0Jykq8KHSZz4+ubJ8bg/FmRplwi6QE85WbPz5/LQR9kKH13MhmD8+MYK1Q9+ENRBH82y7JT+YvRYXnAJwZRSrdVrpFDWbO48M91p9ppqWC9lx1Y94rxRZP0OJLvsYLiOdPDKxEhSCcRHnEA5C0cMxya/bhrxMfavSPDdlVFh7gXj/WzKljwXR9CThMrESaC8IScvcmTOZ49kicqOgQpVIXk74FZGoJh+xN2mxmvHOsMk1a63A5G/eRQN62FZGSG6Ulhr80bJ7m0zNZtyRGDFgavho2/trOktuCtJzbs9tUIGTNl9csUsKm5XtoDaSsq2aZ/WYP+w53+JTC7i973qnMZuPq8N8dGFxpRB5wFSJ+Ak32geWGZKdfx5cG+3BdbPRo/GIKb2tZ24nsbtMzaPQu1ir4D8pi1VHtnF6pxs+gWDR3pf4DqY4MiRmkWQVOmDmc0bQg4W+YEAGCMOMhzzK4xlpixOymMKLj81ohR2kJTjmuQ0+T+4TLTRbK0D5zjC5p5JIfoONwbRLHvGoabNziz6uHsMfxVm5Ed0SQ1XAoKWy8kcm X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a4bee44-edb8-4638-4677-08d92dbba843 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:03:45.6692 (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: uXXDLCVGBZfZyXP/6Vj+XYrwL5zrElxuVx2x93CXxtE6a3JUDfEWrMkZmzFDjRfYQhjebc1mX+4Bi5SFaA8YYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090350_126076_5B84E8E6 X-CRM114-Status: GOOD ( 20.80 ) 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 --- include/sbi_utils/timer/aclint_mtimer.h | 41 ++++++ lib/utils/timer/aclint_mtimer.c | 180 ++++++++++++++++++++++++ lib/utils/timer/objects.mk | 1 + 3 [...] 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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 | 180 ++++++++++++++++++++++++ lib/utils/timer/objects.mk | 1 + 3 files changed, 222 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..2c64ca8 --- /dev/null +++ b/lib/utils/timer/aclint_mtimer.c @@ -0,0 +1,180 @@ +/* + * 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) +{ + u32 mask = -1U; + + writel_relaxed(value & mask, (void *)(addr)); + writel_relaxed(value >> 32, (void *)(addr) + 0x04); +} + +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..f8e3931 100644 --- a/lib/utils/timer/objects.mk +++ b/lib/utils/timer/objects.mk @@ -9,3 +9,4 @@ libsbiutils-objs-y += timer/fdt_timer.o libsbiutils-objs-y += timer/fdt_timer_clint.o +libsbiutils-objs-y += timer/aclint_mtimer.o From patchwork Sat Jun 12 16:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1491295 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=O6FNZpTa; 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=XffmmXqE; 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=kRAVqpb1; 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 4G2Mw11q06z9sjJ for ; Sun, 13 Jun 2021 02:04:00 +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=b12QpdfFnkEMZ+mJYilTh423zS1SXe/Siz02M5GKJD0=; b=O6FNZpTamHP9Ou 8nCrZcMFa5zLXkgyXp5b6dh3F7r2ZbGycjxYmPxxtk5ie0yFQR7pZrteTgqfgLxadDHQaCEurnmQb S7L8oqczknuCqSVEG+dAtgIu6McqR1/9ZdTzjsoLYRDRFMbhkQU8zv5Zr05vCvuZ8AFtkIIsyT9zW 056yszIvdvRwz0d5TGXIVR5RDtv/EGn3VVBwvaTHDyxA5YxNbRzZzegaUd/qCouyZ5nDWxD9gYoqY Msqf3sUflB1cKj6BNoPLX09OG3HyCeo/t6ubkDi8Z6EgiNBWRcMpzs6nW0KkQS5EmOB0byFdEaVo+ jgcPoGS58EOeY7MJyg6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls671-008mMa-B4; Sat, 12 Jun 2021 16:03:55 +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 1ls66w-008mKw-AM for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:03:53 +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=1623513830; x=1655049830; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=fcRb41zDBHTufaTXkmbcxLanst78hOULZ5mrmf+w4wI=; b=XffmmXqEqp0SAw1Nzbz/l7E/dSuRtQ5dNhPW88GEke51kpH4jxZvJQQu vyGT/V7YAmFu04poZiKdL6I/VgKqRNyyUa7YY8cCuzreLDMOVsfe+kwFf wKU/dOGOcO6q3/QM25vknmKRGZSR8omvkcJqL8hgMTIST0EZ0p8PvnJ9X NlHmTj/V7ttd0E/lRCAE2m6KXwdl5gQvel3WvjadrU7cktk2Zdc8Bn5gQ FUyF2bUJc/+7XQl1B5Pq39SKGqTFFVQ+3vtq7RfJVT9YpSRldCeK7lC77 XXDfALYlML8pCxHqziuSkbtUFKjBeRfV7gJjd+aH2pTa4+nODW1RXv3m2 w==; IronPort-SDR: wvzHKSlkfWtpm+v8OIZ+Fc5fUe17CDoZjknNTcXwFhgC2HoevQVI8IkNwANInGcZVhUWhF5ehe zV9N3z+gK0MdLA9LPiRXYIboSAnirmqk5wklW0FRW4k43PbvZjs0FFa1OmNMO5QW/iiVMwLjjd U9ZWr8JTystc+xWTx1rP519qBb8HOc0FhW19CroNNiDtyEl10GAwiUf2ELKMKvE83Hcw+qHtgV WE9Eop484Cd/v92gP9BbGpxEHlw+wfVWRAkikANtdOsYPrLlulN5JWbTipjNKZCZ8Ym2LNLDdd vkU= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="170973844" Received: from mail-bn8nam08lp2046.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.46]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:03:49 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TXyEGI5Muz+UQuO2kITzJaaiEIfS48dNgoI1ey0cKO4RSq0h6bLGtuGXpTpzIjpxMxoePzgvl76tMtZ3u2QX0GuZsEmssj6NXG2oiruGScA6l6XQo8x1pz1ExFSjIfKehpdpQIBe6F3keKa0CULqG2gzH+q+yOJ0K4OhkA7HuTnIz8hhXPHBJ5Not0s637RElAbKGhVoQhVfc5ldAYQvA1I6uK55kxuXQ7negtNZOS1XqJRSvgepjwPQ66rPzeP/AoyvFOEcHcot20xCf6urCgN5QxFbf+lVIHme5i/hfxcG83RWwvlpv+0/Z5Qz2VcZP3Dck1k4aOPg1kcAl8gSpQ== 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=hLzRdWXm1MqKCfuXfJwyEHNR4Bzp1eG9Nq6o3h9YRlo=; b=SP4snGRVK74WRt0bsPbs/BTaEZwCh2pQd1ST2tqhyz4S8qzxzraBEWUUlQbuGGXEIB8t95Q+E2L1DfpetSuFS/kgj9k8hrPb/hfXGNZ2vRIB05AnHIoxVPb/UkSXhfd1nGNAS4dhQzhVMYsELsRzVY99TkqnVLAzAP815d8WtVf1FoL76MMW2I3XZKbD6AsMKMVhw8ApfG594Vax8L7XkuHh76CkdbE97jSsSMoejybKfRbxKxW8R9gITV1QGTgFs2uddId6ApuERjUdZLxQBU+72iee/a6tMJ3qyxcUzq2cMJQ8IIn/+Yq4HrQXTuklpKGkAtj/mFiiJf8i+aWOVg== 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=hLzRdWXm1MqKCfuXfJwyEHNR4Bzp1eG9Nq6o3h9YRlo=; b=kRAVqpb1YRJwdP8FwlDyn230N2PZBCsra8DCEnmr8jdFUhTXZ+m7ZZ3JUyo8gz2pC0MAPR5St408anzrMcZxhbMU322WL4S53IFdbWmROp7qyAO144w5ONe955Qjptj4/+3gNG3N1QYrn9F6KHNSGY1ebad27bg8tHVluxqvWjY= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16:03:48 +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.4219.025; Sat, 12 Jun 2021 16:03:48 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 2/6] lib: utils/ipi: Add ACLINT MSWI library Date: Sat, 12 Jun 2021 21:33:17 +0530 Message-Id: <20210612160321.330638-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d2002eb-c6c2-461e-2849-08d92dbba9e9 X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: AZzHQvJ5XTTc38ldes0NaxwlZKjZ/loYozTy7XZKsKZuxBB1ZnUx8wylFTjN1xWyEBmqrNczJL3nE6sCKDJXTxbfb/zP9ObyWHZem7btF8fKxVtifh7pzVqadrdzEqqVzi84rsro9YZxLTGeGVANspI0ugHsEYN7jtZpF4lm+vZZK/xhXcskaYyUgf0I85ucD6I54ia++GjY5iehpFTP1KMOTjm9jhi4N8tKZu5KhuNRVvAqXSmNshVjRjdEUkVsFCFikV79gyoBxY2au7RMQVLUZ3++NtqFFVibgEE5ViZhIFFf0a0LaJA4FQrVJK26nRceq87OTOcgjzI0BCXNlxzqU4vq1KLBsxw6zZ8jhOm4PT7yt/ezcLgcPQ1T/BZQ69e1/TEcbUdJ90/uYw8Eml97uDD/77JgV9V9M+uZ3iAwbwN3f2RQJrXOs8SZTBxRdEEUEDHPdujWHl6ybpAv0HXRem8qyrpcmO818I14yG9jizJC0pCee1420OHGZkakljVIlCnXoV4iM7u9re9ydlCNc31/7UpWFEqB0q3+K0W+y+3FRjsZNsmidCryyrcLcIj5O808L2CmHoPUbdfqtdTiTy5Ej+FicToMy1Gvoz6h2jF+2nMWcwQ2lGvfGG071Etwz89Br2uyYXqASLcUUX9Vka8H/I0X4hvqFkYp84g= 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AMUviitHGdxckSsi023FQ3Us33rcAxDeDnt9D8cElCMiOy09VZ6nyZJdWuGQoQYmrjD/JE2/1p36XOkLKGKNBGNFho55pm5LGsyNiwl4WTxCWKvKqQLzzTOnbc8uIDXYLQgXCzi0aQzN5ktGHZWD+Ocdqx78qVHn6laLpLoeNJ/fAWatKHV9RgFomHb1sqomMgao7MXLuqf1qDP27Opned5zALlvNegf6tSFLTiirfEmYMZMvZFoKHmGtWv+dy2wi1H+6MbfHvA90jPT5oQNi6h07TizRuv0EtPU64/4eddL4b3zfnHfSozDrJHOsPYkAeyKNJOZys0x2PFHrhgrKVqCPtO9GmaCNyzTuUDeDKhZo+Q29GmQkB0MsPh0AEwq7oobkSIirx5F1e2WO+Bal1XvdvNPa9izcUblVyJTeyqYL3WGG1uYPZs2+3NilFeqz2MqN8pKYVelVRB101c8F30ynPNCYRfPWQ8GlXGp4QmLPbDD1aoJ9zSoVU4DSpU6AaUZZEOkJNL2ZmeW0XDqlZX06jEP4edCgeKfDXD2us830pT7/q8oPwbzPkNO1ndnRL6AXB/10WGRW66SQR1XUGE+ZOXR0fQJEzcNCV6Lj5PqixGhLhNb0h3wIvyHsxfMW+OY0CZjolCMrfwlrOqAC0o4ShtsoRw7to1sM/FeAFUkDR1aC35o8bvw4rT74FdJy8qNW9z6SWZ/3YdfCMrySglnPt5BJONzfAgFsu10ABs05CcVSFjL59EBDTgXOuUsXanvF7RzG51r9YLbxx7ypDV/+fQwfJoxavyIJdWtCA34Wp5PlRc6wzgmiedIyEJqhI8GTnFNjOq8O5ZoHuCoKAdMUkCfcm78nkd0ossKV6ItAaDjQbfb2xBlOP74MO0zryERUfgDwKPiUoNyTtjcsbe5wndEzB5NczTtXBykMwSMElHWzmATzQ10AcAKRTtiBSKYp4S33ryeL5O3XJdg9YEbIwvwS463wLVAfJxR5ajZ+oqC6FImYZQs3gX2UzeTmfsKoyOXVE3cWe1gMHYYjsQzazRcYXT5yiPwUpLkg8c9cWRWhvi3xZZFmgMHXR+KS2VZtMWXJiilFIGEzmzR6pLF4ThxJYL1W9lNfSEdJefcYu396tZZye6ayuWYowawjDw70O9Mpn+x7ExWkKZab115WHsYbVRZAs/NsuwJvaIpf9XOSsMm+/FWRdI1AwLrZvtTkkwC2+CPehfhpXegUNZgVjOFBLbN5dZxb6VMfTh7GMKT2CNWQWRUPKiPbnCj5xCoobRfFp9XNjPwe630+8xp/49cdRdZybb5nW++bogyF48Y9TJvV7ElGj9FN1eB X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d2002eb-c6c2-461e-2849-08d92dbba9e9 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:03:48.4361 (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: SyqcRCb7hWDhR4kSe68ipFMP0FZgIJ+wY3wKvY3rxQ1LDVyyM+W0LosWuUSztJe8VN1cpdYi93zHT1tPuuttsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090350_455414_945ACE23 X-CRM114-Status: GOOD ( 18.96 ) 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 --- include/sbi_utils/ipi/aclint_mswi.h | 33 +++++++++ lib/utils/ipi/aclint_mswi.c | 100 ++++++++++++++++++++++++++++ lib/utils/ipi/objects.mk | 1 + 3 fi [...] 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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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..8360ae6 --- /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 CLINT 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 CLINT 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..cc77808 100644 --- a/lib/utils/ipi/objects.mk +++ b/lib/utils/ipi/objects.mk @@ -9,3 +9,4 @@ libsbiutils-objs-y += ipi/fdt_ipi.o libsbiutils-objs-y += ipi/fdt_ipi_clint.o +libsbiutils-objs-y += ipi/aclint_mswi.o From patchwork Sat Jun 12 16:03:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1491299 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=43wLrjuw; 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=FQcxlTB8; 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=mXdYs8Iq; 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 4G2Mw554vnz9sjB for ; Sun, 13 Jun 2021 02:04:05 +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=oiyLJonR4sPCZka9tdj1PySQsclvhbJN4jeKSALBuaw=; b=43wLrjuwA5cyWQ GtRdLJ+jbiUYPyGVR6jFtaYBxB0F6stLc1koOAG2i6n6M3nNPFvuXZsp2hBSMemnCxR68S6jkvXCR D0u3plsjI7YK6v/1GuqUMNwThIAMTCBauNwzSLZ7PhCBwVPQlu9VwPLJNJNmykS7dEoMD43FAV2Oq M/giapiQKK+1EVMYnMn4za0W9CX2Re6nHq+8KkMfPCUQmUCjzYauhTAHoLJcd94c7/n/4wUttSmql EA/TGa4x8193S05aYYDTERqhAWQlF5vlK6+BQhGtW0dsYgWeEgOs/cMcIHymRzaywPUfSiGocifhf rr5zYx9x1V62sbMjFxYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls676-008mOa-Aj; Sat, 12 Jun 2021 16:04:00 +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 1ls673-008mMc-6T for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:03:58 +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=1623513835; x=1655049835; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zzcKcB/kBrpcmyY506nBKQtYZdNN7kFC5DQuuBStLvg=; b=FQcxlTB8xZAp0w1wFJKFMewSkslGNMpVj+YHX0HIuZJmFf5k/010LO/s 1Eu5HwPNxbR3Za77vdq0iq8pd1X4cz1xH5gBDBOhKioWYhlObTH/nDdMA 8E41vQvjScsCWBYMIuhJSSgWDbAFJGa0aHj3vzKsKQgGoeKPYsqRU6frl GiQAh949qwZZLdhTgfqPOSeoTH6qvgQcjQxqFqKaMz36E58Lfw/2J2iFj yM9g9fE5tXKCn1Cdh9ermkLYsNDMqPW3Js/AHNohNtRb64HPRV4o3lba7 LLmh0wLkq+7Y5sdKVQmOyFINnaVpX9IfRnkZEbur56bmHq5lDHSckx+jl A==; IronPort-SDR: j56X4wKrFS7ie5t9KMlB4jZlg3xQ4mohlH7WKpSa7hegLlQ4NNEcSGJbq7KLF3S/4rrIzTQ+3L t87vcYLjiu3CqQwWjfRx3X4rnxhnCsO5WQ4FDbYQWKa7L/YxJgQUUIgq0LK7rvMbbGiQfYvc40 RHueXGRO86lWlEjGKGs1uzXixlucHXV0UbdRha9hbKdzGucKz21w5a9Xo9tytpBSa5rgyUXE1j ym4n4q0w4+AvZDiA59mc2YGS3jMsSj+Rh9a/mfXvxruZncWcKu0JOQMSfeTiu2HguDm/gskmI7 jTw= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="171704628" Received: from mail-bn8nam08lp2044.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.44]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:03:51 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=inDIDVyHaLxosTyT5q1zURy4R4ppfx4jmdcjsuoPEksUH2AhAF3j4DxKWR1UckLiNZo1mgsvyq0lVI/auCXH4oWemcgWWjbvE6vBovXu5X8IDncrxqv6JCQjQW3JBERwB5XmCQuXg4lL7noxOX3R5D3tP+7KAw1AAoLqS7y2l8SUvgByhO5dWOgo20LM3nfvQeEOAED/CueWR6XsyCdY1MORN7vVEHRduegQH25sXG7lkLvEwXzgMFu2Zp5Xg9AGG3AFqeJ06vZlb3bsq25m2XM2Va88DGPKzZ2KvtlPqhAGH+BlE7dieiPwm7c3mSl8Gtuek2F1QH5Vbm1E6SbArQ== 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=ObBimjn9WGSkGGAQ47SjY9Lv0HQp6lpUfV6VdEc4Oc8=; b=Y4ip8Ig5fNVhxGo+Hc1atCT1eCTo32/+r8MD61UdD6HaVqT4fjIpwoTxJo6ATlThJnYJhDQxxL+JyCHZEwOshyRoa2HqwALeohopI8xecATGqgCcgK5d8QEpGX0YxSJ5x6mN3QLHioBEeENp6GYHYmGBTnO6usmEs9IT4hSxUNMB/Sd1JNvZFVXxzIT799TtI+8gu6hN71NiK76lANL7kv12YS8lFyCkj6aldcnTXSWaqclZu94K/viiPUA6keCLK9pwOIQWR+PhDrbDmLqxIhqGmgQoI/VShbt6b2WDm4DGedZibQlzSXwEbikqfYsbFh3m5h4BPIo9B9uS2FY4GA== 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=ObBimjn9WGSkGGAQ47SjY9Lv0HQp6lpUfV6VdEc4Oc8=; b=mXdYs8IqHlFWno6aNsx86UMIN0xh6OGFrU5mC6ESLGgMaZsL0lQ8Ad4/TqyZ2u58u2othzmquL7B6TbTK4u9iUPoEz6BNvXsE2W0v4RDFaQPT4J5BxQakNvwdCc4GdlZa0pQOW+RQYPg2yP/0+6/TmEA42D7eQ/7ONuXgs9cc6k= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16: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.4219.025; Sat, 12 Jun 2021 16:03:51 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/6] lib: utils: Add FDT parsing API common for both ACLINT and CLINT Date: Sat, 12 Jun 2021 21:33:18 +0530 Message-Id: <20210612160321.330638-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aa4cca20-ceee-42cd-8b21-08d92dbbab7f X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: vOV/lwCLmuxBtfiM+85eYYhKw7bPsTLAx5vCoXyyerZ6RE1Z1MK5eahoBJzzmOd8mDqbQr8xEREn86qUYnevH46gby7HphKumSJ0KKcAr13EOAQlC+KySeWNNHk8BAkv1jjnndU4jY7owyoZ0QNqzlQl1mky727PGr2Wlor12p5096JUgX1KsRfr9/3OW7ZqoZzcGvUxfw4WUj5LjJKDanQSfE6CN7fBjXJClDdrCZhNt4DSZE/qPVV6uVejhK76eifwfkCmvvYgM7tSCmcl/s1oyRFR1W9SsiZBQr15jDFw2dXcoMyR+JnyS6eD79gMUu3bAaQaw56pTV10YWZUWV2S60IDOcBMI1dYOYZecEOMEupEmq6cZwG/xCbi9Px7moYnd6YWfqFwBXQezUxUspXSqTLGot0xveHsozCffRQUhSPF71127nKIqOtVEix/H7jF7N3kBYTqxx5vTqnCLjtoMfO5y5zEK8L5w0s9kCKm3Q3WkxW4G8BXPPsp97d8mHIW+SLB6eiPwC/sVBpwhSw9Rkhavxp16CF6rihJyX9jaBwR/Dhcy1RR2D14j1BS42EcLMV3b2OmvoubZJPvm5d91XuJ/GtuhMaHyoPris3r1XCZspZlP2b6cOIKEZqHX7repJixci25YkbegkR8PBcdBUp/JDHz/KwuuAtLzZ0= 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EH3hjfEdEbiVEvEnUV4VetKN/NMWeIWH3ybtltvJr1XOYDhlvPL2q17xjNr/SWEwYEUwDZOTQZYus04wBGdQz059/pZ6vWVZweM3Ehf5Jb02/U8IMlpVl3AdXpU0Jte2IrhggScRRsyZWNrTwr0oQvou0dCKDq2kfMB8oNmnRWzHh7MqDef4jeGHGKp4HoX3ht2vOx0qGJ/rKki6aSX46B5UwnmkLrSFiiSwUEoFSf0r0jysvmkdJ6fawjzKvs7iiekDCATwhe4TL0UHJ4BtrLv4vxNOYuSLbpnri+ymU3KKQgYDKQ1qyqF/ejkf2nBOfsqujijPe9hNJbuY8B5M6Ottr1XHyE87CUf3jnhPhWNOsT+HKbfKT/0P8KFWCW6sR5PIwp2O3TIbgGCwALB3VMAqlVv/FWJkiRZShG29MQP2+6CGEzx3QwXxaFOMhkr1MC9HRCLJUIceuVpRLBuydfei88MYnSBfR5pMn/SVsWa3iAaH8iN3bSDr/e9Ca6SGMiR7dVSRUossNDB5F+9HWz4beyGwJYPJWeh2rWmBRaA9NZ+sDTgCRE5KQu/al4sEvHq5zSbNYVc7fvfDy8KTEapOBuozfo2/xdrtRX86If4fzNPXIKLtQSjSez75pg/xf0qrJgCHQt+ST70cZ1W5wGOTZ3mdMf4/9brIRUzkDeRjIEvy2z/g1IDlRA9hVvthKq/lNIroTBCiNrkXideb4tgG5rlsMHJNLDyvNSGKMvJcEhLHz1YsDVDLBx+se3lQ/Iv4cGQXTYEPcFq/v+e6F06pl2LmdWtLV831n4UBdnvjrJzPhX/g9h3+kpEFb4pfev0gRxaZ+xzu4lD8MZG2OQWt3K9vc3AHJTwagx4C9tmAKKRwBxGt7aR3eXEi4iJsKFWTG+h/Le8Mi0cqLcX38/pfHfUzVjK0bXoQFNfgtITjgtm+iMxHQlg6CLfPw3zMf3u39qpcj/yMrkykDrUXFUc5MT7nLk72O2QiedVZdPuSgGoGCMAhqQgHDcADbcwitiIZU3b9P/NNdW9UWR1KF7PNq6uU0VRDgZ6JPyeTrxt7J8w5tnzThS7kuXbewp8R1WNbxxYe3lJbjSQ2IRuVQP+zqIF7eCZmrFa+pm8MOHxCp73O1TCuZkp0Awm/s1I/EAs5DthNIg6Wy9pxm6dDNZtxdfgIPUEH0Yf2/hxCdzV6OarqafLk04f/gGYgLmFJlXiBbODpDCs592cJ2n9XOZp5DDlarKWgF1moo/D6DE3ox6hjaf9Fr0ppKtmInY9MJab5jDeJK/2rv+55EfWfGFzbTl3grUlLpJBl/afC3dsEtcD5HQmp/0x5Mf5qidqf X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa4cca20-ceee-42cd-8b21-08d92dbbab7f X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:03:51.2945 (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: 48rr00XhO4aGPusf8f05EAILFPF/eRfGzJf/1kunkcqf05uCIajxHzjww1c+XGGbJaoFDrHSE7Q/U/BtbcC6ew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090357_286736_DA24A7BA X-CRM114-Status: GOOD ( 17.40 ) 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 is 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 --- include/sbi_utils/fdt/fdt_helper.h | 7 +++---- lib/utils/fdt/fdt_helper.c | 31 +++++++++++++++ lib/utils/ipi/fdt_ipi_clint.c | 5 ++++- [...] 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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 is 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..c97d3a9 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..9c84c3b 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 Sat Jun 12 16:03:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1491298 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=DE/FANmB; 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=ZVjS4SOR; 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=y9J+4FTk; 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 4G2Mw50tS1z9ssP for ; Sun, 13 Jun 2021 02:04:05 +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=3fhxU6+JIcpEsumkWYRjY/BjzZHRuu+91jNOYwAWvB0=; b=DE/FANmB/uH1Vv IQLzyEjbD/8yToKoJvCR5BJBKx/zM3EdzD9CgaSTKlqvl2iECVHecm2k1TD/HnOzyfqx9Upt1OnPM RYmGpXqF7aryVFQgqir4ZtfDBBTATPYkmV5AxWI2fmEjsIux7AUV2DllaAuzDc29/n3kIvTiyjdeN tqvFsU/iHmc4/BKSCMDdP0rW4lHvcYGJALtdcqgjiYK/tdpOmRrpv2PyR26YjkSSmlwvfBauYsIRN QfaPYv9LMj+/l94JsERFWVYeD1pP1hbAd37OHbLMgWKSWa2CBr6cogXMrcAOTh+LrQzlAd1TP1128 Su6ZK/XHmMChc2E3DeKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls675-008mOS-Pf; Sat, 12 Jun 2021 16:03:59 +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 1ls673-008mMv-6T for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:03:58 +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=1623513835; x=1655049835; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=K4weP+1/hcwApvJ87pB4EFIR9HhIyPT4jlEOyp1Uepw=; b=ZVjS4SORdvMvwpSSXRNfGYDqXFDVOL+y7NkyF1P9qx5fXXpsfVg92Ke1 o9ewtNi6H6y/v6/mB03bDIMtz3nCqIoy0NN8PaDKzbi0TE5gPFMPo1bQl dZBfqFB3OF1jp2EEgCaExH6nrbq8kzDFjLkpvtD6qnE8mzD7SP0HvdXi6 h1UGlWCY+Y+tFU91mftD7I9eFieqRWXWMhlvZl6LTIBr/isxmdWlzHrPP HLyj3ODSgTgcyFboGX1a3isIzvTjHZvFXgoPKcFqKrnvXZjf7BZA+BX5J Bg5tGyWmiO1O6Nmbo7itSPvw+sHMtZnPSPiPmVIbKunR2m0jK2SgZqKor w==; IronPort-SDR: 7VH02i8jEEkIqFKVmc3EIedLe4Vt6ti6Fa1qf8H/2we31u6VNM+/igXRp1Wl1sgwAd+2GH+JJD MBAG8Rx6AAPF+dNFgqkhi8c3I4H4xno4dPncpg6kXZX+quCJWOtfIiYCeVWND8/3mL7KDeG7ZU rCHKaYMA5EpiZwTAtFoCtrPPMZ1cbCkHKkKPlIvHHlBJ0lrs4SAwfdEhgKJ1/cnbitS60rZueM InKiM5izBMIle3gYX5v/4cIU556hnK3VcLUqbChLQfiS7a2IUEk5YL1EDqeu77N+esNJ49Yatm uac= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="171704631" Received: from mail-bn8nam08lp2044.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.44]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:03:53 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A7CNFugdMYHxsONpOrJ8f9DVPbVCMhYpwSoM2po1DFAahpdx1cM1R4xnHs+e7EurswZzinabj6uIdnaJxttcAouHTnomz3kRq2tCbTFG3NlBRv5v30S4pnthNBEhV01lxJUo6Tq3jVN82ZW/cGRYW/P4dGF8UDjGXXn58r8f9OrZCUFHSfjwcojIWdtTCZgGJRfy7PqbEZ/Ts3fVsYARuge6eH+z3hp/KL284Ou9ZxxFdZ65SXEuxNfHZ2+EzNdWCJIZeQ9mxVmUVkVzqQFL5kHS55AFkKIGyFHrpw88VjFMKfgnTI2h+cPuwZR/yIKHGwXTGMaC14dkGDwiXOmfIg== 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=J+ev+u+Ek5rAxJqYhx1LCtzTUiBI+7ZIchVVzNBw15E=; b=eybDGTGwHWdShXprtrx1V0TQ0prLo72PODVcZLuQz8LXJ1D6VDJsTvT4Vdypf9DFftWa4MRg2GtJci//ED6bqEeblXApmKcLaj1KOePsU+e9vSaekl7syc5GSiEHJnDfJyQhQC292IFu9iiwVhS+KJZEyd/LjtTxsaCL1QsEVBCpOmv54DLJ+/wmf2oHH7RnKzCInoK/XeX0ngsMEN6lQstrQCRPcr4n6feuy/3UK7JIgnJ97bNz6qh9r7s8D6flLhJUCLXDZObxKQzuVHMboTgnChd4mFuDxfQ75JaqLmepN8csd8OSdhyg4Rul0c9AuFRn9QsGAKFW6XDn2Yc9Ow== 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=J+ev+u+Ek5rAxJqYhx1LCtzTUiBI+7ZIchVVzNBw15E=; b=y9J+4FTkk4fGtB26vKN57hHbMIwouAMBaUlMLcE7irMHEnVZDEVK2AolmSNT2CpLYkzkPyXmkwvliVZJ7NxKOBBBjrAO4svGebyQiRIMZP15pxRtW+eG0XG4KYxYUoZtdfUAUHk11hfV7y2mpIV+BHEEPcNgIQICYNCdp7SxZ2g= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16:03:54 +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.4219.025; Sat, 12 Jun 2021 16:03:54 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 4/6] lib: utils/ipi: Add FDT based ACLINT MSWI IPI driver Date: Sat, 12 Jun 2021 21:33:19 +0530 Message-Id: <20210612160321.330638-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ff3dcd7-9576-4ab2-b89e-08d92dbbad44 X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: HatBaokP/iJh6mcQ59i/nm/OmAUntxeFFvOBI+dSHswdsiLx54W+a+QYQ4MxNyJuChEZ0j0k/vnhrqF5mXLo8bLclP92NJq9qQbxpD2fRUdmZWRU2UmnjNvLiVtcJFCYvwH8jW7psW4fLzjsgpox/JvVFI8abO0l9CFuc+dJmS1CfBKvC94fm97R5eTiZsXsgUmnLUhk6C5YQ9Jt5obX6dGhKn0yHOWDEPGa1i9l8a5qikT6nuR850pkwUwnq7A9CcM8xj+3nmRdHjDo0s9cn602S4vhnPjYo5VgAeFXZ1KVSV/beFmH9Ekw2aY0084QREaaLL7JwvhizBsQf2wBuYoEKQV0TdatiAVWy2Jr4ljaJ1Fl1iql53k61MrWjF9DbzhH0CfPrAVusvVijNXNcDc0Dr5siLv90wR6XU1wmuqh8Lj7hsdEkk9NnmDrOQCFXKzJ1irQ+tnL2VdVwVjXf8x5Bvv6vDtuzO/3z6ACWp1E0dW5zcmt82vyDRPq0s3NsshvHU9PLXKmLLLFY03LL81oGe4uC3YsMRCs09QEvhIVjWmdal3SMqXVGOu4O8ffXz5IGRFrV8DGD73gHcph4Q5e8eh5xlWnxKCEOg/N/58XgCi4ZsZhnBP0sZPRUnsrvmZSt5Zt6o3bX1k6igUO1LhPbsdztHFX7BRLBvW11Eg= 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2SAuf44a2nfl9rY92mqlh/RBsVgd5EQMozsv22n9QDMLL9hRSND9PLoj9Xcyyl4ZVLIU9zeEq49kgtAbnoHmkchRkuHisUD+Z9/ROTnDW5rVorXubqNNIlMMmTyS4VzhIO99Jv1lBw/t4TMiHOdPO0QJKzrU6h4f4JfKnPuUv0UYL6dE2m+ova8BX16D6RUtt8EXB0W9swVTqAr/o75ym4JZq0LjhAMNJHlJEAPgMSoAmwDQ1/Qvm3yxoOqLl7QZ36sX9Z7qdwOa41kLJE+NiGdc9uAJAJohx71GexE4/4FEGT6rf8jt35bcaFl/MbPzWQ8bnyYSVzs+7tltabzELWBqw9XutXOHD2Sx0eYFyS+7CGYI9JwQyrT7kRSXSyFWGfUV7YINAFG/Oon0NeL8LBcumQh7mD0g9pCD6Udoj6dqRQWAt/JnRr8yxzQ0xz/u0nO3ewFkrhXfRuh9z6CoZIAg199HBTqLxHwzbBhlwld9sHSO4Zb0KevTNu3pI2Piaaqfak9DYG/Cm4REHkErzv80s0ukY4X67JhHhJmVgFDsegDUT2VK9gch5qES26ytIOwUyLSOxwqgbEyObmL3FbA2YUnvgXlVuiFSf9OeTE2r27fGBatgGlnQHYzL54GaEvyZInljIJnjeqSE2SJjVWGWjdy8IGZfDdnU4LIE0eDbEHw/k/s7fmnw55+wx4C1s8qqGWrKvuU6I9O9KMu6hzn22GhoGNppeZyjm/S7S0pIv71OzkBhtmevIvhZTfQSUytRyf2M7jimrIwS2QkswZwQ7jZ8qKGfxhwbDYeMnjQt+FLMWle3LRcq2QGeflbX+EbLVv4XSccjQoynJeCpCetnIcuSz4MQnidiPglO5gKUfTTjw3aq7ZTw+OaFsozoJaK7aMPE2U/UMsDmW4bS/tv2Hk7W6z24u/x7v7aZ1CSPK03beoh5dnBjgT5uOjMIRQHS6rh6x6PQ07eloUvIjJqp+0WE4f5Peuh5HjP+HjolZKuhz4Acxjta0g5RWSwTdvlTyS6hPh5nI8+SJkGmFPbnrVGLD7yBXpaiYqhgSG9glk1eIqmIzIKLTmiD/qH5JMgqvc2I0BDMcTTsRMWYTxNivAUVU5jsTdAL0KTxFz+MKIsHc0GvO45xHDdtSkSpL0gerABTDTSJ6fGjmExKYiL/PdV36n4tQwdzHBgOVfhjsOeI4A2IRvkwUfVwgebXRz4XWIGY48iJiEyW7u+PFS6n9KAm/TUCSurQd+t1deCxw7iFY1YnZI3ce6cSKkAOwfOWf1OFgX0CC6d+rzq9DYW1It4UAg+8FHBdUzXsb+rwTelF+bMaRP+xUWWY6oX7 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ff3dcd7-9576-4ab2-b89e-08d92dbbad44 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:03:54.2346 (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: oQzYcwHH+1/M5Q0zVSpHpNh/En/NH+RPTOpaDfqk6w/vwLybVE/ArEc1pu6pyyXWt9PHqZjQGapOKwrwTd4gxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090357_278063_DCCE8857 X-CRM114-Status: GOOD ( 20.75 ) 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 --- lib/utils/ipi/fdt_ipi.c | 4 +-- lib/utils/ipi/fdt_ipi_clint.c | 51 lib/utils/ipi/fdt_ipi_mswi.c | 67 +++++++++++++++++++++ [...] 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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 c97d3a9..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..306a25b --- /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 cc77808..effbedd 100644 --- a/lib/utils/ipi/objects.mk +++ b/lib/utils/ipi/objects.mk @@ -8,5 +8,5 @@ # libsbiutils-objs-y += ipi/fdt_ipi.o -libsbiutils-objs-y += ipi/fdt_ipi_clint.o +libsbiutils-objs-y += ipi/fdt_ipi_mswi.o libsbiutils-objs-y += ipi/aclint_mswi.o From patchwork Sat Jun 12 16:03:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1491300 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=j25k7jCi; 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=axxsK9+4; 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=nUSCxkhd; 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 4G2Mw75jNPz9sXb for ; Sun, 13 Jun 2021 02:04:07 +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=FYF26RBch/2oCmig3+dsifSdRy53OQgWCLF0/mVTH4g=; b=j25k7jCiRaZ35P Zr8u8AuIwUkkvI/I5ldQRSbp7i+02Vewf1/uZU4vHJb4HMZFpChgEU7hebeYspmZxfeoeLxzOuUUq oLIS9ruxFC0jIlZoHQnO1NRwZBkILytIe24Vezb+MbsF/Xa7zPOHCFu4Y4jP5Kyf7AVnXwsK2l0km ztxjkmJwjnPTNcW0IbsoX6xlX7KGYX8SO6yPZWPupAyvrLoJNCXt66Es69XgO4UBvJX46ZL0CJb6K kBJGhQIsLaeiPHkVpWXyHWr6OXKoTrxrbH5c0gpMuiYyEFuvQKTsLh0bHVsrde3Wkv/VhMyseofny bsF3sbBcBcIlvtOpI1LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls677-008mPi-VI; Sat, 12 Jun 2021 16:04:01 +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 1ls675-008mO6-5L for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:04:00 +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=1623513838; x=1655049838; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=F//gP5QFEXn03NRJSHI8UxZuBTwjB1doRZ9Waj3RKMs=; b=axxsK9+4UVbSCoA6nhFfRWB3qYNYZwTLa0PXDB2GkvfMK9W5II1UTRS7 AME1f6N0VsTAo+05XblGQHcyaxU84Dnw13vIN5oh/vq8U2cFueNLDrPZV KqLqVJcuBPczKZCKtx41WScjdlllXZPg/eG0rLjgf/HSNYlXFFsF21G/4 hnfau3PAux/krEtjMNhJ3Ew3v1u/X7fN9oz0VbFMO/WGMLSl4Kt2R7FHA dfqeWtojQI/jqh6WZuIml0mqU/10J0CdxmCo3R9VoQfUvhmyg851fMY9/ n58IBwPn+GooXaP4JYuFtk9oSfosxy/4XRsFiuBVdfTyx5WkNrh1mzikq A==; IronPort-SDR: 7Pr2wvzQP4a5a4x0VXo22ns1WLV0KVaFfH1JDijQHfqZRwINe8/j7fffKbwvWT4qlGj3Zf98bw WBAH7MQ4nitjlvhAKZJnLn+3vX7yCGCno6qMFwogHxfVqKZNRKwkF+2agLOkQ0kIRXALfQ/heG bUAg6y3fcTckcx8bfFz0YaEmCxRxC44G1nsuaFUWB7OTMOiupzu8k4cuWn+EHghdyZDlsbs3u9 J2kGB5jJxRhNffUH27c3n9qGoVR8TglWL0uYt7RNr2G0CAXBSwHfkZyIgabw0uwNzGRK5+fczx 1oQ= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="170973852" Received: from mail-bn8nam08lp2048.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.48]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:03:57 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3nezffc+AskdVW5ZZbkL/lJLNZaiJVjDKo0Cy58GFZlBsRtb9zEJnXHtJFGzWFCg3RVQglBejlVVtFh4sC3OyFUwNm/L2QQHA5EtEY0F/w0tq5mUm+Jo0R+TLsyiNizkprDTb8b339OG5QZqrs7wQcFqEUad0bpVsOPiyBF1wTZ6FBmvqjb1XO2q76lJbShHA9L10O2twqOyWckRWYMOJVDI+y6cBkuCZ4v154qMIUriDY5EE2QfegmBOqnE7pBImA4API0u9oh/iQoPeqRpwiI/VnEUZf5LNXvBKUIX+SY2Ub9SHNmioIRtM39bZ/XiSvg2+bjHLxEO4uD3nHulg== 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=2hLLhyodIo6sPwEsDUCVOfLFTEGpgRkjH0AT1aMXtlM=; b=GI4qylpxR55Nt9++9JHAylryJfE1G/LBoO0yGZ1C5fBb5N7CBp8SWb81SdfQ00EUbS6w54+UmxVs5k9Cf38XmW1mxKOFLwURfR4lZPV2vA9gg4sjGWhn7jKfkfpYAiybrvZbd2RmaeW1WR2ZNW4orPQwm6AwuUGRcCzgXSkJlIjTplRyQ5x25ZbQIgi4ISMc+JDR00y4TQO0OT9eZWgcttWbxOiu33fCDVMqVn8g9vfcDkfCzDSYqHARH5rG7dQ1aVktWcnem5sH5uDDsJX1rRLVZuZnAk22cvy715sCnwJDmOyV6IHP9FrvgAP9VR/3t7sI/vFER4YLTYeMsPZlVQ== 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=2hLLhyodIo6sPwEsDUCVOfLFTEGpgRkjH0AT1aMXtlM=; b=nUSCxkhdVaCOCJkSJB2qjZ6e1iDztrD3KrrtMKlzCV63uT1BqCcbGkiTsbl8klv5iAyUxeu+k/tt3ZniAP61sfGwCm/FB47pUYzz9PIuG+65yjZ8UE/T+vAuTElLpOaUhjwJ9/dCCz3f9ItDX5B3riEhweXpvRbA76ASha4yMWM= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16:03:57 +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.4219.025; Sat, 12 Jun 2021 16:03:57 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 5/6] lib: utils/timer: Add FDT based ACLINT MTIMER driver Date: Sat, 12 Jun 2021 21:33:20 +0530 Message-Id: <20210612160321.330638-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c4d3efc-a87b-4ba5-7163-08d92dbbaf09 X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: gBi634/LCXEARIxJAlyz32LhHIsrqukNdBZwSmr8crzZsB+g8xwth/zGyLfbIgVqAjaTVbo0JuPbo/RBkUNUNYMm1PWd617Es4RhrpBx098N4yh1rQ/zq7mwu+DnuH5Fh5wqsH7pBQrBBR++MdQK98SEofGobEHIlFgqaAeE5aFtqLkGQFndm9mtDl7ToIQQWFO7u//xwASS/amkDWqqPXPPMya9b0Xk2Cx26xjheZIy9qLlcok+y3i0BVdNNwVoGzO1HgeULOiTDgnMu3AYKWfzPB3w56ZkOCCgEPeOX1bR0LPfKj/mKjPXAh22QCqYGM9bchh6NsgiOJtOBo6+t+Wj5263YDHefURPD6/BVEZumcq1HLXpSFCWuzxEHAHqjs26pVF1GCnT6hUfODfHX/4W5/b8yccvBplK4eFipBtsJ32hn4kg08vahjPycQWGsuHh16a2iE8gVeDix0LgVCONEkgE1yOS6unvKErngak/klfU4/zxGUIxQFXTYd7L9WJe0Bc3PjFNFR1DbXYD/OOmwpRIaPzfBFkSnK3Os66iasHQ9GDJrmiSPAitPXogaXYoO3IQ+iVLMU2rlbBlBLSg2R99ZrX0RjC16cogUKaCAp5lq3KGYPFhQuO2TJ6P6XN2If889C/BICxUvmRwy5FGXbs2kN13AuqOg0+Nn/A= 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bNyAbGKtfTz0xEdw3/d+ptJgpw2wK6Mxo5cZqcxWbmf9dEpv344jdmz1LdnWIbMv3HRTlIE5f0WZkBwZaHcs/RhB5b9yXgClIm3+d8EPp23k/wxN1jzvKudMBV8I2/OAh+u7ZDFxryxzV+XhzeOYRmFrjqkkPBCjqJFopYt1kqe/yRxaNVxneQNDV4sGIjjITMupG5A8NbNtAyXKrNdZQjLFU0/ntUpgUx/Ad2XSMXGYJslpon0qhs4WmtHLz4t0W7PPJEQKJ6+s4iD3ChRbrjJctJjwAZs5AW7O7hG7W52EvwEHYAPrjQ0CDpN5EYCmdZKw8s4yq8k7aFsHcEn8J8DEzpMCEUR9Q5Llzyf0Ykbkj5tr88mhxmDbwMq/kmN2MxgCZSVIDxyTV9wuA/mDxMZZGC3u/zWB8Oq/IrrtOmaPbQhGtDpkU53f4MJR/11OuPrq1T5o6XxunUmxHSgZyBq5cxqecwPp5MhRp9wr52LxnGA0lx4MC1a+SAjwf8s1fjS/seZ7VOGtBAh9AJ+xV1yW3+tFitC0c2YWFHA60MgCwt8ohXEzYjSxTvlcolf3QzDSBjn1MCy+2Mootwn17QqgrEV3RamNSYMsRVg2hfiL5X+l6yPoqHFmfLdqPGzskfkjjTi+fs86kJbCCaOUc2Jvv5gAucNdC0cTYM2ijvmkKgwYwbkfZexEZEwymwMsHCbc9/UWO/RWX12NWLnaRqrEXpV+fO89XlZ60n3KjP2hDf74GZitWnoRoci2J8EGdzUAceH0HV9U7dmdnGs5qzxY/zFdqm7ELI+aLVi9LSoPKBcwL3hrH5Lwwiswi+5u6f0r68jt4VSu9U8Ur2s1G/HfcuZrJgFlhhLkjWXVawrzzfuY/DAKxsPAAW6/P5Hd/n3qYQZPGLm3RkrDbQUG6uxnEWu/6QAtwEbl1gNLPJB/M5aEHZjofAA5CXEBQ8l15x3XqHtO+jc2sOyOxjsrOx/VVFrJun/Oa7BcsTGwvbJZPhtemy/HYu/htDxmu4VamOM9uzwLOKBSWrz9JA8PYSSvSsaPKJp3ftFnpITN7KefuRjscdxAe8AyUPEOmMrq09j0LV6K9bNDZPGdmT5BPMER+75ApSEr3TnqyRDWdUQ5HXyDH6ohZJWOZNUC8BLW/mW9OK2k2aN6O77l5xdE4wZHRTPoU2CcA/mBL2TW8wI8JvZ4D8qdBRAs9LbdWURHVA2OB80VLwrxHdxTZgie4fChPdYrNtxCm1uBQRCqczxsQsmeQFo1MgPCUbuhG+7whOS2zYG97rixDj6fP6WZcCKBaALqVy674/XutYTS6n+8j/C6c39082IhafSPkxA2 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c4d3efc-a87b-4ba5-7163-08d92dbbaf09 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:03:57.1976 (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: jQpc/Rw5kaPQ6RrEhFfoB96P3F8j1KqfagUou1fNY1Sdk5oOLj28IUwBwze1BUoCuLkrrvq6gfNzGU2NogQ2Wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090359_359660_11E844D6 X-CRM114-Status: GOOD ( 20.99 ) 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 --- lib/utils/timer/fdt_timer.c | 4 +- lib/utils/timer/fdt_timer_clint.c | 57 lib/utils/timer/fdt_timer_mtimer.c | 74 +++++++++++ [...] 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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 9c84c3b..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..6d9f789 --- /dev/null +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 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 f8e3931..228ccb1 100644 --- a/lib/utils/timer/objects.mk +++ b/lib/utils/timer/objects.mk @@ -8,5 +8,5 @@ # libsbiutils-objs-y += timer/fdt_timer.o -libsbiutils-objs-y += timer/fdt_timer_clint.o +libsbiutils-objs-y += timer/fdt_timer_mtimer.o libsbiutils-objs-y += timer/aclint_mtimer.o From patchwork Sat Jun 12 16:03: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: 1491301 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=wVYwwN9I; 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=EPpcSeA/; 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=zEn64Drf; 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 4G2MwD2GfXz9sXb for ; Sun, 13 Jun 2021 02:04: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=08BkWOMzd42UuxR2+VaQ5K2cKmgMFVpZAUk+13SswQk=; b=wVYwwN9IDbnLHG Xh3uQBq0AmhxqCOImD9ssj8MYI3bWepW0fj1gt7//gDXWJfJTJF0CcAuBuS5eQx7BjN7gBgVLU/jb vAw/YhUuO69Ct+Ls1VO7czZKyq4Rsk0hAOoepQYfLasmjlfwelUTAZ7kHAtimJCONic3bsws+wtzK hHcd+6tnySqpUTZv/zw6BHbj++/eg/xAEhEKAEvJBVIg4WOJaCQLY24O+IN5AHpGxMaVCnkjHE+9F CIRUYkiYAGoz5ZtTlIGgWutRtF9AQ7w0MGR4QjXhkZNX7drffeG19DdE+vuuFxRMQvKLeoXqEmTWl oE4dWvN++Kk3YFFHtFkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ls67C-008mS9-LK; Sat, 12 Jun 2021 16:04:06 +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 1ls678-008mO6-3O for opensbi@lists.infradead.org; Sat, 12 Jun 2021 16:04:04 +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=1623513841; x=1655049841; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zf8R3+r2FguyNZgnR0hmFPSmat509bWDapn6u4+FUX4=; b=EPpcSeA/C/CHbs/M27S6s7t/K465QjSylIPcmild5ztb0IsnsO+BdZdI +F9EGPqxQBYFbjo0x5lYYoFZ0uItkW6uhPOLA7buouY5vj5FNfXoUcU3J pwFyBBtLKHR/DcV+3E/iDsHveYqBoe6tTxw3OfhsBzB0qZn6RwVFJZHaD 0y37YmQH+86xM0CLakPDSK5Em9CJBwrpuZafp7symg3NvqUkfCyYRr1rr ZrWsjAkwMnfr0WlKAcDdXaJTRDXgIwMCVFaPsb5z3hlgpMmfiwKTLjFVq Xyy+3L3HVUrhZepD+a4NYE5Zd+qDtH7vr82htYYAtAejN/a31i2utqPQk g==; IronPort-SDR: pMVbF7kqT0H6Ft/64lA7p10JZPy5uyZrRjNN8jtvT1KoBGPt69+JzUdk5ciMjgebUlluEnmP4s EDC5m4O6Pe9r2iMMCnLXpJb9h/Kf24iL+RcVIWsDDNVMX5Z3h0aRz3ibX6Fb7N8ibsy8/pTRxf mvrnPmRRrX9nDtc0WcjI0l4rVo+bAq/xv4ETEgXjpv5dLD6h4ygVtlLrvj9xm+lzptdUxink2S VoTlNBw0n/ww8YuYSLRd4+OhuzkwXUPrlO09ymGKwStmaFb15nuAbfBbrH0HacdENjCX2oSaKN 3DU= X-IronPort-AV: E=Sophos;i="5.83,268,1616428800"; d="scan'208";a="170973856" Received: from mail-bn8nam08lp2045.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.45]) by ob1.hgst.iphmx.com with ESMTP; 13 Jun 2021 00:04:01 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/I/vea4TKEjRg8/gOLWQelK7QU+B0xHQOdoiyvvD7VwLNo6/t6ysYvft5AEjVaoEXtyMTjsjLBBW634l6COF/xLqviMF4idyzxsFFn7ARV4SEFNJBNEOYmsS4B7pT1V36VoG879pLvLTu8hhHO9gV1K2nFEu9C5adzNkvzIZa9lzbGlSsrpXLh/OEUBHb15SiGkgeyCzJEJrlSOckCypYeUS7VQnxnsbbKZHNaSr2VHn6z/gYOEa5D5Qtetpg/qJ9nd3XXRkw8qoAPfHsg5h6KP4LbYepKTJ6MEiiSBCdnAwlfPaNIa+sBkL8gvC3E4RPfQLfr7WlOksOuJSP8teg== 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=g9gmktWgRimpgsa2igGkX0Mgp/bDxWjloTNDoheTnJU=; b=K1cfWhbrBB5dr3vdAqGP9OEekBgW5nW6TArhzgoeKdhOVW/2fP1OcKL/XdoTT29NOlWgjkHXPLMQWiwIp5kt0FJf+Hqq2A5y6pI8HKC1Se0GNjNuZg7pKWucZEvGX2NMC8ImWMZWbqcziHP/u5HX4xqzag9waneTDmAMMn7OLmBRCdvhVmzpmt2u8kKEs5i8jyRCcSlDCAdulXNYctlT7bNLHFM1Pei9psAM7rwlJL8izsolguY37CR7aRlQz3/hvs8T1DfaLIKVqcHS59WiJr51SE39eci9xTZkILLFRLNaRkHba2ZJ4AYZw4rdZyVrCqvolsABiP9Je2wq63sHjA== 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=g9gmktWgRimpgsa2igGkX0Mgp/bDxWjloTNDoheTnJU=; b=zEn64DrfpWTNqw0GUa6qGrSa90vEe0erd3RMlqytW6V56lvpJbhiRi+71NAW4rXFjdpF5AHuWS6KStYmR5KqhWxDrNfSDiA/wAMKdR8TlQlXyHVcAJOaN7YP5CtYhy2E4tPaknxv0HYqFDU4Ryz4jQSRWyrTaoQXngAdYvdrzX8= 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 (10.242.165.134) by CO6PR04MB7795.namprd04.prod.outlook.com (10.242.164.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.23; Sat, 12 Jun 2021 16:04:00 +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.4219.025; Sat, 12 Jun 2021 16:04:00 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 6/6] platform: Replace CLINT library usage with ACLINT library Date: Sat, 12 Jun 2021 21:33:21 +0530 Message-Id: <20210612160321.330638-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612160321.330638-1-anup.patel@wdc.com> References: <20210612160321.330638-1-anup.patel@wdc.com> X-Originating-IP: [122.171.171.205] X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.171.205) by MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Sat, 12 Jun 2021 16:03:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3738adf9-e656-4bdc-eca0-08d92dbbb0ce X-MS-TrafficTypeDiagnostic: CO6PR04MB7795: 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: QZ0F/NkAONs8uf5S1yEzx8NpX9RBgVaoTJppwx+u0o/T3Sbt5SW9nDopZEERFTRkexyMMo6S5ZU6lewbinJ8HpnlcJQ6zz+af6IZFrK68ThpBr6Ow+qYuKGnJX4MPoluwmYIp6xoY+hKscUGOJOSh6RuQWmJlHQt2F/MB2R5i+A8lAwMN2tRj8LPPJ2WacAuJCJZ5cSx8prh1WlGmidS4lAtul634fgby28BoFCoAevGg3wuz3xGr6ks2OBhiWN37YnxCuCMk+rhd6QeXy1C6+tGZqrKJb+OZqv9TwFN4ciQKv0sSNabUafD9Hashttq5mG08s/NKbuWYm51FXslvYBHTWP7+Bv1H5Dw1ji6+FkVwritRE9EiiOXAuNL1WWfsIcTlTuEGbUpw6MKLzVJUORb0JDGqyqoXnYZKhMUlCiDqPyt2eEPu8ZTxy4nBZMVxJDHT/0ZTwLExKd8c5lGQ+ocOlckQA2KJ4uX9nNwqN9zpPs21BEf1JBshtcnnDPZR9Q3cmlvVnUlanZEJs8StTmbkjZuIjiyZRam48DMregKV6niDKfVmRNVTgfqdqTAyIwDO97IzR+rlRgWM8QmYNfhctjh0+zEeGkMXbBrVJQ/pmA+NsWrWhnDrHk8b1W+x2BoEy2SwYZDE/u7cLss+mVQ3W5eRBY5PlfGIz9Gw0fXYpO9vHu7BYgD7u6nTr1N 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)(346002)(136003)(396003)(366004)(376002)(956004)(6636002)(6666004)(8676002)(8886007)(26005)(44832011)(2616005)(52116002)(7696005)(110136005)(83380400001)(16526019)(478600001)(186003)(4326008)(38350700002)(8936002)(86362001)(30864003)(66946007)(316002)(36756003)(5660300002)(38100700002)(2906002)(1076003)(66476007)(54906003)(66556008)(55016002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r0w8UTQ87LaFUyTnTa5Zb9q/vNy/TztgStZQsXzs/9JtpRDxZpwuNAQ4XDHHIgiL6Q1h/2w4bXtBqINeadvKXezg8snURZQCinHn5yUkVs16V3S5wTwtfozSR/Ueo/eO//D7L1/q943wRdQkLZcxI/AT+MtoUn0dDimh+oYFE9z1N91sUl5vzsMtYNMYgiuMMUu7Nqm3gRinWjRDS4A2R3+9fgL7lB6gdMeSbSJ43eZ3XKAtFTJox4KW2n8nNy7OwxsFG/znXErHc7Y/KdAKoPak+u/neW8LQTTgEuhq53QQk9S/ibz9KvyvuxksFQ7IuDmJINgh7FCuQly3HrMkuhFNjsA+ljGO9vv3lvcEA3l8ePS+wIjORomlcUOMjQ/Fz8sq9I/7Wa7KERlLs1aeBOj+vFnNlhuckdK07pdc/rYZvA2+Rh1LESH9K9NOfSx9ykQqv6bPgbuB3M0KZB06O5+HgOdaqvKtuURS1ehJuroXZClrOh0s2eZ2X31GuuRMTL/qOlYUtZYZC1G9m6JqHoZhSexcW+ll1OiN/F8TdVcK/Bme55JQZWvjd/VgNvynvUuj75sVxni6pSMtjKfr2JKTAqS5hNWJFqnbjHT69aHEa0mERshIUq6S47pfko5H8/EMuCdMP72iHAyMqY2Wzo4odJ7dOMbskeRFNva0xMgkDUMiJtuJXpvgeTYk7qmU6pr53gDVe5fCA2pJd59uqf5uXLwrml1GaCnftK3M/u5beuyv8Imlk3kbug9BuMYKTXkqzlmj3ZNkkFEOEgYcpSyCscjC57lFsMQAMMce3SThtNidGWeHbWbpIKEmA8a6y07YGf/ZIBumJOwuHoDmnHQvWQDmwkIxjlUPq9oxY4sP3X+yj2smDoXUnXH1iggr0IhI3aJJiC0tJOC94uU+YUzpUTngcue3pk4kdccfWpWmwdsG/FmE9MI5tmPX0eIu/mOC5QHZCTyu/7Ylsx1Pl/YQzufRpyKqI7VKOkcCWf4bMfqtaYsxJrTJOmpbg4L1dw3otkk9Q9y6ykFj7i9l8hNZ2COIEPdGgXRuHb+Bcs6cUmaT73mYCQombjsZXVPz/iQHO57Yenql0T+5EdUZvzt90u7KYlVuYpdBPNrr8NBasJNqL9lHB+0Z2l3bj4RfK9Y9hBAMDwVMp3/mUfBRV7Kt0Ber1755KBV1FswpHKLGFcYTFAtVQsJ96JJQj1piK604fb4zoigIBAiiMVbVN+ptPvW0vgcKwqknA2Fqkatj7HhZ4XIbUUvqsevQYRoZnJfY2hM7IFLZKQN70hDNGCDeC2CA7+ZoKhu/HcvOwQ1MI5A06U8lt6+cj7PRdBbs X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3738adf9-e656-4bdc-eca0-08d92dbbb0ce X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2021 16:04:00.0878 (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: iGXGaw0TfjkIWFMc9LYoyCfzFejS6vhV0JLW0quTVrDIFufhDRDSD+/dOYbHdQ1PWZuLUn8w4AxGHreVcKBiJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7795 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_090402_335992_AC181ACA X-CRM114-Status: GOOD ( 16.99 ) 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.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 Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 | 26 ++- platform/fpga/openpiton/platform.c | 32 +++- platform/kendryte/k210/platform.c | 23 ++- platform/kendryte/k210/platform.h | 3 + platform/nuclei/ux600/platform.c | 27 ++- platform/template/platform.c | 30 +++- 9 files changed, 102 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..ec310a4 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,25 @@ #define ARIANE_PLIC_NUM_SOURCES 3 #define ARIANE_HART_COUNT 1 #define ARIANE_CLINT_ADDR 0x2000000 +#define ARIANE_ACLINT_MSWI_ADDR ARIANE_CLINT_ADDR +#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 +135,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 +151,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..89fce55 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,9 @@ #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 +#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 +40,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 +79,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 +163,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 +179,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..da21e56 100644 --- a/platform/kendryte/k210/platform.h +++ b/platform/kendryte/k210/platform.h @@ -22,6 +22,9 @@ #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 +#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..422c528 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,9 @@ #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 +#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 +65,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 +201,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 +214,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..9f1ac95 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -13,14 +13,18 @@ * 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 +#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 +34,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 +100,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 +117,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(); } /*