From patchwork Thu Jun 24 04:30: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: 1496372 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=nlbeMTZV; 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=WoCFwaGL; 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=p2u2bYnv; 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 4G9Ryz4ysgz9sWX for ; Thu, 24 Jun 2021 14:31: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=XZcEvIzOi1Y/zm/+1wy//PPWg0zebS5fqDa27GDSHbc=; b=nlbeMTZVuOFtnR ypAPms9VLHeW0bfst4PQVQwCzXKvaEAALIh7t5SywD6Ed901H0SPhKmD/x5IueUKOmjPm3ZN3TtnM l/b121zncHN7G7s6YeD3JwMawnRvqMGIx/gk/9yqTSYTolVp4bJsBYtl9NYOt1GTDxYzx/YzO4oaf yViXi0jlC3Vf7QqnCcJ45Hrf0AmwUQ36Kf46zs1d7UlttUoYNUNTH81DtZ7vRlIROq2CJ4RYo65UY u5Xvznw6OYnBXsawPN4/ovl0T8gfemQnmOXoRkWbOeKewNq4TrLOYMToNU7nlM0JWaXuVJVNOrqAw AJalpGTqTKxs6ibEyMlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwH14-00Cglg-Rl; Thu, 24 Jun 2021 04:31:02 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwH12-00Cgj5-AU for opensbi@lists.infradead.org; Thu, 24 Jun 2021 04:31:02 +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=1624509061; x=1656045061; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ZTilRSEOwhKp4j2Qmc8d3fQ/2yVcsECSzGfHJWY5nY4=; b=WoCFwaGLVSsAyZlZ52ZjNVl/Sq1Ue4ObtB/YUuWlItPd65noxC08NSap 1Hta8k6reuTJs2W7lBACGesjSLFCJzb7GNEs3Eq0VKOBfRSmWVi3vHmGR KDu1Uu4GBokcAzs5V4XLMoAAmDsMMWT8lFgy3oCljXm4KtTTUOBEwR2FT nm9hjbeeMKpEwW+md0rQNYwOClx5ygbDBDDLU3+q1z/E71AXYrikXSZ+b 2mAyhy83Wq87Zp/pAEcIgqTVfdtwaQ2VefQ+NiRLr8+f3QDGc2y4vY86S jVdt0Ab6rfJ0cqzU7v+bwf+d6pIzS1INqasVrjKtJhE/F11Li/aZXlvM9 g==; IronPort-SDR: +HIMJM4n9KEaMazpXQ1XKQ+5tu7ybfmOBArkBJvjjoah5jEEZqjB7QKwV84ZiL7Xd19ZaG3o4T F5MaCPphPXzpGq0jrYjsqMX44vSHQGM0KfGQSkKuLvLcRlGFZCVnJbD3Q+dxUKzEEUQGSCNR8w qzSMbyLXdIks/C+5QqCQYqDlMoMzLSbKC9U3GQvH4vQ10/jYtqzshaCya9Ol532xrmstq+pPDX ad5pQAtceOwtyAG4S7o+yh7mA2SX54u63FURbQ5Pkxr0UwtK+tw3FobZRrTHGuCJnD7uErmbHs 5nY= X-IronPort-AV: E=Sophos;i="5.83,295,1616428800"; d="scan'208";a="173330058" Received: from mail-bn8nam12lp2172.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.172]) by ob1.hgst.iphmx.com with ESMTP; 24 Jun 2021 12:30:59 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GpHWPvhiDSFJgFMFYKPGQEazV7stus+BCGgUZhD0+4VXbViBIkZhEWuTPNu1Qy7kNswP/9OCfDwt1lLjUuEdh2vBX3foTBTtVQQ7OZEpZlBMckFIrvgvRrwr44/OcfFSJmC7QSJCokYEmPdk59QQls3od7rT8mV1iVOoCUGNP/ky6iWTiuegOWZqcTKKB/FphI6sCnjTFS2RoKAxsn7vq0f+BHj/PgkD5GHIZ/044yCjx8jj/eu9BIX/g6XqOzJ0uUwm9lTfT7c/IacYwYNjB6eGeRkftOjt0rt29ipXf9G+Uyjm2AZGjDwvQKgOQF1kICOkEidaY/6k21m2eQVw2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5uadWBdj7SPdymlBpa1q6+RnomUCNaIx4qKO5WK31Mw=; b=GDZ9XL3fQe6hheV6C3hotPMh3Ehl33ratEZ99yCuatlEw/D1Uug31mGG1p6a1amZFgIdPzhQkSvXnyVjXgCqse4NYkk0Xma+gJg66mG5vUtL5yAl58y75++8btDQSCVOrbceMsexnC1cVh2Hej/IAKTyDB4c0Mjsnz8eBAcxQ1DWQ/RWQUrLVc5gi/dh76gHc1ccEOQNStOvX553PRLfRT5yuN+3up5FJsh2V+k/zIs6EOcrg9hEvBo+MQ9KkjlfDUX+S4jR9aAHDCRK4Xdb4RLLZwpcHY9Ug+OHihyd1nXwq05nX4pNwzMzRTRCzt8ADgKi9thm1frQVSEB8QfW5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5uadWBdj7SPdymlBpa1q6+RnomUCNaIx4qKO5WK31Mw=; b=p2u2bYnvcIekWbPSY3FJ5Nc4liHlmhiubL4DY5p9mHikisCRBclG9MOwlxhrKLgbvp4w3pf8hwVUqCQUwDPf/MGeVUEVfAjdhdvovL8W2WXCArjQE32yM5+xD7HEmm9sxNNzWkAefpQMEPizlsOI4EpaH1SLLG8Zp9scMHzqtoM= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7827.namprd04.prod.outlook.com (2603:10b6:303:139::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19; Thu, 24 Jun 2021 04:30: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.4242.023; Thu, 24 Jun 2021 04:30:57 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel , Bin Meng , Xiang W Subject: [PATCH v3 5/6] lib: utils/timer: Add FDT based ACLINT MTIMER driver Date: Thu, 24 Jun 2021 10:00:18 +0530 Message-Id: <20210624043019.498627-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210624043019.498627-1-anup.patel@wdc.com> References: <20210624043019.498627-1-anup.patel@wdc.com> X-Originating-IP: [122.171.200.190] X-ClientProxiedBy: MAXPR01CA0104.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::22) 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.200.190) by MAXPR01CA0104.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.19 via Frontend Transport; Thu, 24 Jun 2021 04:30:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65eaa8dd-acb4-4f72-5fc9-08d936c8dcb2 X-MS-TrafficTypeDiagnostic: CO6PR04MB7827: 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: Mm6slocV7FO95QzEmlCt4W/3VQgpAs4dyvgZtLcQrr6qI9qbXzws1MCy/UPRItDsn/buiSx3ydzPkBUTv8G2iiRgOB8A7hFvl5ZA9OyMSv6SfYi7jvZZ0oP//OJucnXw5V6qmY9E4MsyrIwWLEDXL8mDqZJbDixMMy0IlU12A4SDSGvvRv3eaWQyGXlfLiqMyGhmYYWRZQS1SqneOwFdcBOF4WjofebgBXBIoeS8duFRF4e9VpZ3eTkZjkva4B6QMYbBv8DeKjSaam095peoR1E8nKQxMzfdzbk6cCqmfGAJoVOCO7SbXc8Gv65LOCKXhCaRptGV0NKINXljS9fZLoSp9Xxq1F2XQKt+9DtQ4hJJvm9eB0yJvan1vOMvewfpXGXNQLwBrEVNcJgRynhbL72IDkpGK22jyiS5S94x70liR+OfkiQNV0sDmAkKqdWIfdJztIkDXa5c6ZKLvXGo2VktIYpuNvq2xYUg8aVdRngoWSmNkJdQnEQ2422xwFBoMxVJXHvTlWwODCFSdIGRKOJztKtbdRLecAzDtWm/rtbcTwqBz6lq8bkkUWcnu7kakBHTNtsOwVprmLwy5SjchhhZJ30yxFC8ktWso1UQRRf5aG+BQ4BoM8vB9pvkktXfkuty1ehO2vs5vhKU998RDI958YQ8/2GoLIA0hsMU+y+v+GabFUGwhf3wUd5uFRun X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(346002)(39860400002)(136003)(396003)(956004)(38350700002)(86362001)(8886007)(55016002)(6666004)(54906003)(110136005)(8676002)(44832011)(1076003)(7696005)(316002)(6636002)(2616005)(4326008)(52116002)(36756003)(5660300002)(2906002)(8936002)(478600001)(26005)(66556008)(66476007)(186003)(16526019)(66946007)(83380400001)(38100700002)(525324003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZJWHFlApCYf1WdmOLa6zoWQY+dqEPpdiv6NCvtL6F1xTZga30BoP540PPOsjgmyqMpniC3DCulUsxgWAeKldhMAhHc3w3rmVfzY95xlMWhm3tWusKgwsUOABaM+sYOdPOvrb3cgFcDTCOIJk+PVkjMAj6p1cG6Lh5uCLrdCGNg2jvRlv620lIY/+6sOWFXdIfDZYsGh8g2bfkn9JEz87a2uCgqPo8ZcDFDIsA6iMYeJyyE7YEOlMN1mFtCyZBv+8ehKTHc1UweX/vtn/S4mvQIlSSeCszmKt2ALEcyDECFECxGJtKTgzUCMxSjEpUXV3qdXGFjgmRyYEt+YGB/42SyMceYEur78pJUaJq3Tr363EnVvPrxMV5AjmF4dVtZ75rCUO1F+HPL/pJkUh0W8M6SywKL35JC48rzTN56jigBldsukDLTYmuoul9jgI5t52+42a4ZYM7QqHypr9UQlbsDOHc6sokab4DpUbtteRDFGLtqK2IRO7pwdHFPJpIyqy/7QUkW4DDIVwJTSY02o+vxY8tGeVqs5F6HUqF10//fr48HVjYQ3NnEac887+OcF8RJ3EEBMnhhbF1vxjjrUMgvwJXFJMA6QJrrfD2p+aVfltlpsm+9kJ5ABKqDOi8QSMux7fTcp0N+dzIMibpDHnqAXIYsX3q4nxA86f8++DpDYYyNsCJDNnCczenuRkqDleVJEu47JZXyGOt1NYgnVmmn0ikIu47EpBq4B6bruNLXP234cB8DD1/q8Ux4qpPXUCdfIxHR9mbHYoD0y2YgbqraTN1D4yQgDtJxhfr+lbugAe/YpvrhdGKF5v523MXfFaFRwswEc62KrOLj3LOjMg0DJVCC2tsKOE+xQiTT9m3cBARfGA8LJC9XUr+IdNheCtvWRLdFWtR4OZtLKjSBKitaXVRrlc6LQFIN4phoRjCD34ObcMPa5XUVsttvK4keotrrvxuVeO5/fCDm826bPFqnX7jl+bminC4HWITj/fqDSD3ksA2h2xMXrKT8acOjgabzimKX5UYb1C8988phntRVAUja4UEYBAsjyolvbW7hvuqDOy8fyIslSNftblHANzJrXrKGJrMDFXvK+RUmq95aFcQ2RcjM+SkAAhf9LfCEsgBAEI2Q7zhFVpXsr1pncLPpBtUlV28yC4IpI17hnU3sTrLiNjCs5zeieDjJfdUwkoJDCL6MVcGnqq7i//VpVJ28uGA0Fp5WNtDtIhWhx9mv6LDa/zMLzozDNGiuLFQjojqkZ8XIzYz3YVtIU9r6ctoOUaa+pW67ZP4Dms+AM979hEG1/dEBoEoO/YpA9+unoQnNNXL5Gyae+ML2uyf4ya X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65eaa8dd-acb4-4f72-5fc9-08d936c8dcb2 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2021 04:30:57.5255 (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: 8Y6KL81RAvrgcoZQPQKjIBltSEVwkHLZE0OahCESfPicrlGMAkWoWzl3ax0tEZts8APbkzS8dNG46CiD2czI0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7827 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210623_213100_514426_E714B286 X-CRM114-Status: GOOD ( 22.33 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: We add a new FDT based ACLINT MTIMER driver which works for both CLINT device and standalone ACLINT MTIMER device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/timer/fdt_timer.c | 4 +- lib/utils/timer/fdt_timer_clint.c [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We add a new FDT based ACLINT MTIMER driver which works for both CLINT device and standalone ACLINT MTIMER device. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-by: Xiang W --- lib/utils/timer/fdt_timer.c | 4 +- lib/utils/timer/fdt_timer_clint.c | 57 ----------------------- lib/utils/timer/fdt_timer_mtimer.c | 74 ++++++++++++++++++++++++++++++ lib/utils/timer/objects.mk | 2 +- 4 files changed, 77 insertions(+), 60 deletions(-) delete mode 100644 lib/utils/timer/fdt_timer_clint.c create mode 100644 lib/utils/timer/fdt_timer_mtimer.c diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index 1fad42c..148c05e 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -12,10 +12,10 @@ #include #include -extern struct fdt_timer fdt_timer_clint; +extern struct fdt_timer fdt_timer_mtimer; static struct fdt_timer *timer_drivers[] = { - &fdt_timer_clint + &fdt_timer_mtimer }; static struct fdt_timer dummy = { diff --git a/lib/utils/timer/fdt_timer_clint.c b/lib/utils/timer/fdt_timer_clint.c deleted file mode 100644 index 63d6586..0000000 --- a/lib/utils/timer/fdt_timer_clint.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2020 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#include -#include -#include -#include -#include - -#define CLINT_TIMER_MAX_NR 16 - -static unsigned long clint_timer_count = 0; -static struct clint_data clint_timer[CLINT_TIMER_MAX_NR]; - -static int timer_clint_cold_init(void *fdt, int nodeoff, - const struct fdt_match *match) -{ - int rc; - unsigned long ctsize; - struct clint_data *ct, *ctmaster = NULL; - - if (CLINT_TIMER_MAX_NR <= clint_timer_count) - return SBI_ENOSPC; - ct = &clint_timer[clint_timer_count++]; - if (1 < clint_timer_count) - ctmaster = &clint_timer[0]; - - rc = fdt_parse_aclint_node(fdt, nodeoff, true, &ct->addr, &ctsize, - &ct->first_hartid, &ct->hart_count); - if (rc) - return rc; - - ct->has_64bit_mmio = true; - if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) - ct->has_64bit_mmio = false; - - return clint_cold_timer_init(ct, ctmaster); -} - -static const struct fdt_match timer_clint_match[] = { - { .compatible = "riscv,clint0" }, - { .compatible = "sifive,clint0" }, - { }, -}; - -struct fdt_timer fdt_timer_clint = { - .match_table = timer_clint_match, - .cold_init = timer_clint_cold_init, - .warm_init = clint_warm_timer_init, - .exit = NULL, -}; diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c new file mode 100644 index 0000000..4907428 --- /dev/null +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include + +#define MTIMER_MAX_NR 16 + +static unsigned long mtimer_count = 0; +static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR]; + +static int timer_mtimer_cold_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + int rc; + unsigned long offset; + struct aclint_mtimer_data *mt, *mtmaster = NULL; + + if (MTIMER_MAX_NR <= mtimer_count) + return SBI_ENOSPC; + mt = &mtimer[mtimer_count]; + if (0 < mtimer_count) + mtmaster = &mtimer[0]; + + rc = fdt_parse_aclint_node(fdt, nodeoff, true, &mt->addr, &mt->size, + &mt->first_hartid, &mt->hart_count); + if (rc) + return rc; + mt->has_64bit_mmio = true; + + if (match->data) { + /* Adjust MTIMER address and size for CLINT device */ + offset = *((unsigned long *)match->data); + mt->addr += offset; + if ((mt->size - offset) < ACLINT_MTIMER_SIZE) + return SBI_EINVAL; + mt->size -= offset; + /* Parse additional CLINT properties */ + if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit-mmio", &rc)) + mt->has_64bit_mmio = false; + } + + rc = aclint_mtimer_cold_init(mt, mtmaster); + if (rc) + return rc; + + mtimer_count++; + return 0; +} + +static unsigned long clint_offset = CLINT_MTIMER_OFFSET; + +static const struct fdt_match timer_mtimer_match[] = { + { .compatible = "riscv,clint0", .data = &clint_offset }, + { .compatible = "sifive,clint0", .data = &clint_offset }, + { .compatible = "riscv,aclint-mtimer" }, + { }, +}; + +struct fdt_timer fdt_timer_mtimer = { + .match_table = timer_mtimer_match, + .cold_init = timer_mtimer_cold_init, + .warm_init = aclint_mtimer_warm_init, + .exit = NULL, +}; diff --git a/lib/utils/timer/objects.mk b/lib/utils/timer/objects.mk index 1d8b1e5..12cffcf 100644 --- a/lib/utils/timer/objects.mk +++ b/lib/utils/timer/objects.mk @@ -9,4 +9,4 @@ libsbiutils-objs-y += timer/aclint_mtimer.o libsbiutils-objs-y += timer/fdt_timer.o -libsbiutils-objs-y += timer/fdt_timer_clint.o +libsbiutils-objs-y += timer/fdt_timer_mtimer.o