From patchwork Thu Apr 22 11:20: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: 1469166 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=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.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=desiato.20200630 header.b=luZldd/k; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=q0BcexB+; 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=KYnd5DPy; dkim=neutral header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=R/PuN32D; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4FQw3G5hdNz9sTD for ; Thu, 22 Apr 2021 21:21:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=r7tR6yV2cn3LR0X5XXYN7DcNifI9n8AHtzMiDDnIoIA=; b=luZldd/kj5PijetJ+ipbgv3s7 yvx6NmjBy2wqvBECB8LEri8uYJfMtbi+AmmZAisZNZ7diOeHnhhV8mPLQxEwWllGnZ5QS2HMYe/Xi /PyTI7LOOMFnrvzNOHL7rlycOq5vs9wyszY58orhgVPtyAhdtCsHBvqjaonvHWfsgkUPIRea8Qa0J ocFowa413Xx4AKuBGXptvsCLuVzN1ld8i+3NLAeMpr6oFNT7eISe6a3nob/VBrbvu/bybh5Hd3fEr KI+bI+RCGytSSAexC2rwgLvFD6N9BJ30q38vlO4PD06bANH8Pi+XtDLD6zWoFhRSHCQgDgZ2u3pvv kdTH3nOHw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOP-00GZna-8a; Thu, 22 Apr 2021 11:21:09 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXON-00GZn3-1h for opensbi@desiato.infradead.org; Thu, 22 Apr 2021 11:21:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=q0BcexB+VPxpXoBsB6CYKQhtP4 FQ2OiCDgdwryKxHYY7DJeX6qeumjhL3kdmW7u1Ln1E5fV82+GDDahlIvzOjcd+YYYE21SPIw9We61 mpkHhphvguFF7QlYpaTCB9XDwAtROcofb9rrDUkh/Y2ityVKPLDtzcnM+DqW7YLMwiS7BEj5JVcdQ SdwWSgtFlAtdgmDExpQyvIze43hh+tVq4niqSNbUerA1egAEGiFGAZKaXg4zSOlqSlO7FCRCyYPtu jW6kbrHrQZRV4fK/5ILWEA96xmN65WNfIxOAy6gHFvFJpeB3aDl3QNFNUBRBhHNtxrR0LAo/y5VUX a10rZRCg==; Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZXOJ-00Dbxc-4M for opensbi@lists.infradead.org; Thu, 22 Apr 2021 11:21:05 +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=1619090463; x=1650626463; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=zFZR//HUeyYQlIFXdEgPhoRnYLhzYor5rl2LO7Ac+6I=; b=KYnd5DPyB3/t0X4o/v1e8nZVtHBhRdFNjuOW8pylepOa9u8L9ZwAmHKI J28WTdvoh4WFrDoCXwhGtbj4p/Ov6T+rnBTTgVW/b7em+fHn+rb8Kfqnv p6/Ke61ypbce3UQ2dcCeq1sMGc8b3nDAYK5o5zfq4JI2xirA5G38Mf61Z f8U6ovdIvuiKljJ0GD4c7Fiq3DcGAmuOT3njBbgHTvlhl0AqkvZzYFkcO 1KrG7u9NeVQBhS+zRok/F7oUMsgyTKzCyg6T9PNKe0H6xmSX7GPds2cGL WUi1p52MkX3AaEbZf/h2rBeIwJcTWCiCFtyEonW75BBLTZwSmypIUfgXC w==; IronPort-SDR: 6dDg5Jx/tBdY54hQs7GXiJhBInPgsLU/gBFEp3eDUGxbS4EJPGjUSUgtmQvQZkDNw72ZcOi1/s m7YBIgVQ2lHQ5YvwPFSsSsrKfCoyPm7jM6eGgmIUHxC8XJ9odAiOByV6P6tkMm390sLRj7gLur UcV5bQsUMia05YPfemzwb5x/EEU7C6nHKAifioCF/zcLv9HGN+KFdniFChXA1m25v62G3RRKiB P7aTyARqWgS3E6wDtw5OmZ6ib+9RCWycu7CGiyyYX/wfLy9Mj0b7Ou+TaXH9M7MonMQnHSPVLc fkE= X-IronPort-AV: E=Sophos;i="5.82,242,1613404800"; d="scan'208";a="165188485" Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.174]) by ob1.hgst.iphmx.com with ESMTP; 22 Apr 2021 19:21:02 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jSwSSazM05CMMOyZo1L6SOgwy5fXTa2G3kAcWbBqdahl3fwdmADk2Ufb8uSSmBrq7GnAp5A5QdWO9RgjzN41RnavcwmcsOjKQhLb3z6l9Qd4Yb2tZ0/Ek9rCE9nCHsW9xBnwejTm1PtDdAH0DuFuoBTEeAeMzdTVPW7vbVhqPt2mgPnwSQw4IY3guvS8t2kHaIYxKh6onPoLWzCYk6Ovsi5Zg5+5Y2eQt3qXEXnH/tRmyFZv8jzYmEafDAqM+T+m/858rpDdwetgpGUSfNQcbFguKWWb0VP+tQPNwhQNu+XQGd3WrrYUE10j28qZ5arO9pRoIuxigb20kGuX6S4jrg== 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=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=H4RqAhQjFvOPaFQNLqEY9UbHqd5MHat6J2Z9tD8q4ekzEzLhqMEQJaKrF5go/FZOtLVkumEJyANb13/kijkZ5/415l3y7Vl5X3S8BERKtf7Omj3GLmvmauYp3sszivJdbnCq3Dmr9j5iE5hZXcyLIlMdDzN1eIkujdDeAsEygoErnFZ3aEnXFEUKsXs9X/GZeIstn8WHMxSlBVDgQbEj+FgUHfvoqjlLzsskRQGfGWCdMfT2xKTY7RHmmH4xz0+aY1dFIx28LpnQTzDaGPMsLpGue2JifVWXZZSQdIYDEQBoTfaCz0pOia+GA+YibpnckdcnWrHu5u/dziB73mxmYA== 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=TSGphSF0vpljoH8cKZ4Dyo5iS7rKLks5kbjQQ+MBBfs=; b=R/PuN32DrD/L/DgQn1b/DTExpKoHCBkRnOmEZp1VI/seoi5RCLdwYtJfFmov4Zevo/3f8gE89xa6ajK0sYkbjOeegyMKX3rubhjHe3aLhkD9qDz5ksm0V3HQ2SE4UlQ7ilp3x9T5TxJMzYmXUR/B7Tj6IUTJIClR8JiNHyAPkFc= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5755.namprd04.prod.outlook.com (2603:10b6:5:162::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 22 Apr 2021 11:21:00 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::8159:3e4e:d870:bd18%3]) with mapi id 15.20.4042.024; Thu, 22 Apr 2021 11:21:00 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Cc: Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 3/7] lib: sbi: Simplify timer platform operations Date: Thu, 22 Apr 2021 16:50:19 +0530 Message-Id: <20210422112023.670521-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422112023.670521-1-anup.patel@wdc.com> References: <20210422112023.670521-1-anup.patel@wdc.com> X-Originating-IP: [122.171.42.203] X-ClientProxiedBy: MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.42.203) by MA1PR0101CA0024.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:21::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Thu, 22 Apr 2021 11:20:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0beae7f1-6aa6-4d01-4ea7-08d90580b546 X-MS-TrafficTypeDiagnostic: DM6PR04MB5755: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:296; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q4RT3Hes5CG1zRI5dSaoJuI4Lstc51JUhcjJe3p0NvZ7pQg4hc4OQ530IqgCy+vkZ8VSig2u4oXS2EHFbyJbFKn2klqSZgTPCn99E8r1RoYukNKdvj/trLzeu2L8rtQne+caYyEjxL2ZG5wbKYCc6h+Zh0Uqb1M0PIFFw4COzlzey9q4XEhjwpIOTTQ/Hm3GK5CKBuqpSFHCqMN5BbSMskaqnCQnx+0oL+m2NwKB8kifIVEFXDeoCsCAod52lQ7lS9fCT4kaBA9BMY7jEgwk6C7PPBrrqwKfC9tKDbSRJiDubKEIHQAkdpd1jCYk/bmldh+KmqFi8BVe1+OFDFsVkRns3rufW/+1qdUmjZPf7Lz297nNmWeuOyYQEfcAHTF0FvYhb1C2m+DW0HqlVGghaVAaLt+FUW+5GEjd8sZ9mj+Oz470ARDgF84fbjT5eGWMbCRAb/JMjnAWixyuS2sERYSGDjnXOeF/0NI/fae7r68B1YNKZEexV/JXshM3k2epF8HeXdF8eELROicL6oEvjEjLDarbWUX/lUmmnNFA9oIrFrMOocvdCCWLfcxPeJGtC1ZwggYHp3KPKAQT6BjZKauP5rWcfUqUtuHnxpB2CSkbIpD0Tq/OovcDHni3TpN1YJ/W8DXbVfJp3lTurfSXog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(55016002)(4326008)(110136005)(86362001)(478600001)(66946007)(6636002)(5660300002)(66556008)(66476007)(38350700002)(1076003)(2906002)(6666004)(26005)(44832011)(8886007)(956004)(30864003)(38100700002)(83380400001)(186003)(2616005)(16526019)(36756003)(52116002)(7696005)(8676002)(54906003)(8936002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pOVFsIHWyf8KQPSYDR6PyfKjiWE83KlKkwNSB/Di/I3cvJtsiDkG7PdqGonBhQ4mWvNa8pJwiwAVHZ0fL5ePlZ2bspngHI9z1GflbAjz0LWvoXWViUwtLx7y9piKcDg8EGrxwcnaDUrV68mGJ9tEotnNfzemGWwUnILBxTtqh6YCewA+07sJ1gJZ/WB3xS+j2JDe+3Rx2I0VTlFmVKRDFYNdheVOywkjdVpNSheThW0vvkpwyro88wBSv7zdDI0ZjNcxGnuuM4WAp0vIIXrxX9TREiytEhIxLJBU5Rr1wOYCAvDojd6+VHFOumMsatEaYq4aZWKBc1Ww5yBSijARfvRprVEb2uFCpzuTMBe5n7UgNujmJqT7Y9YE9fwgQkDa666X6F2nDXtbJsi9VoTPACY7sQVr3C6CDyX52lYVhagLBw6X4SDUL63HUhBACgUnU0DK1jPMzhZyBR5azg9KmE5zrkqMrP7vVDQpx3Ev0x/YwwVbd/RQJPePRqN+iNvV7VXxyAV223+5egYXdooI8AqZI0TLty/gIkznfdShpQTvhmRiJ3p3+PeG7VZ7kIKBjVutAZSufMUGp2mF/Q/8yHUWkqUGIj6y4elN/s4KuG6CaAhTDofoUKVz+TU5OJzNRGozRL6lEHeuk/4bRDhcwa585aCR0TH6A2Yfe5+vqv0umSRrFrY48SVMw88V/iWSR8l7bai6/3e9BBN8UYK+6lS6bmUx6uSaiIdyeenTju/PRQuid4TIPth1Knpoa+w5IdfrG7rzIO5mOCyWjHgAY5f2GFA83TfFly1zIZ78gBsctenYcKxWK+javqzOC6QeU2Q++b25ppwXgHak0uP3EN8Q5+UULNwsBPh4WYEEMLWSKDJQUmuPFGvxak97p/V3Ej9fkK9j5491Z8L7d/iWcfltKsYgOtnBszVmmwI6nEWHc46fZ1TbbWg/UpLHqW1SGL+q1iBUIg9zvmBXLqP+uSxAYAE7R5NYuaU3yduBbgS7sgr4Hfbo54pCkg45hh3K7jBWZceoCIMY1ym+Qa9p+kadqmGG+kY7KHexqsdL8Ok+QAIxnVC6NBAfzYP4F35L8D93KLzg9Hkz6QugVdFvxuHZbjKcf79qMKfoF3GNEgX10esAN4JK14sseKcUTGJ/GQDlsABsjUrvM3P5/cr0yrspvoSrQYw8Leeb3ZrIJF3iUbD2V21IT1vjGGIlz2QBFu7pOLvKkkiHRd8FdM3gBBRZ6GO/MzEOEWQeXm2wcIaDYsR1QBxPDHogxgxNF6x/cnnJfu7QlALdU8SXHZqq5K7UwA4EDXxt1mplozIw/oYPSMTxadjNLXgI0Y70f1OL X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0beae7f1-6aa6-4d01-4ea7-08d90580b546 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2021 11:21:00.7450 (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: uUILs0QEqXigSntLnD7j74KKOOKN1LYYGLBeiseZf5PNCUK7xkXo/tilN8dKzPQG8c8AhcErtfgEsgDljBE1ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5755 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210422_042103_305478_44528016 X-CRM114-Status: GOOD ( 17.59 ) 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: Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device [...] 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 Instead of having timer_value(), timer_event_start(), and timer_event_stop() callbacks in platform operations, it will be much simpler for timer driver to directly register these operations as device to the sbi_timer implementation. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis --- include/sbi/sbi_platform.h | 58 ++--------------------------- include/sbi/sbi_timer.h | 21 +++++++++++ include/sbi_utils/sys/clint.h | 6 --- include/sbi_utils/timer/fdt_timer.h | 9 ----- lib/sbi/sbi_platform.c | 3 -- lib/sbi/sbi_timer.c | 55 +++++++++++++++++---------- lib/utils/sys/clint.c | 22 +++++++++-- lib/utils/timer/fdt_timer.c | 31 --------------- lib/utils/timer/fdt_timer_clint.c | 3 -- platform/andes/ae350/platform.c | 3 -- platform/andes/ae350/plmt.c | 16 ++++++-- platform/andes/ae350/plmt.h | 6 --- platform/fpga/ariane/platform.c | 3 -- platform/fpga/openpiton/platform.c | 3 -- platform/generic/platform.c | 3 -- platform/kendryte/k210/platform.c | 5 +-- platform/nuclei/ux600/platform.c | 3 -- platform/sifive/fu540/platform.c | 3 -- platform/template/platform.c | 30 --------------- platform/thead/c910/platform.c | 1 - 20 files changed, 92 insertions(+), 192 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 0d18ef2..a2084c1 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -51,14 +51,12 @@ struct sbi_trap_regs; /** Possible feature flags of a platform */ enum sbi_platform_features { - /** Platform has timer value */ - SBI_PLATFORM_HAS_TIMER_VALUE = (1 << 0), /** Platform has HART hotplug support */ - SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1), + SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 0), /** Platform has fault delegation support */ - SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 2), + SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1), /** Platform has custom secondary hart booting support */ - SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 3), + SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 2), /** Last index of Platform features*/ SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_HART_SECONDARY_BOOT, @@ -66,7 +64,7 @@ enum sbi_platform_features { /** Default feature set for a platform */ #define SBI_PLATFORM_DEFAULT_FEATURES \ - (SBI_PLATFORM_HAS_TIMER_VALUE | SBI_PLATFORM_HAS_MFAULTS_DELEGATION) + (SBI_PLATFORM_HAS_MFAULTS_DELEGATION) /** Platform functions */ struct sbi_platform_operations { @@ -115,12 +113,6 @@ struct sbi_platform_operations { /** Get tlb flush limit value **/ u64 (*get_tlbr_flush_limit)(void); - /** Get platform timer value */ - u64 (*timer_value)(void); - /** Start platform timer event for current HART */ - void (*timer_event_start)(u64 next_event); - /** Stop platform timer event for current HART */ - void (*timer_event_stop)(void); /** Initialize platform timer for current HART */ int (*timer_init)(bool cold_boot); /** Exit platform timer for current HART */ @@ -210,9 +202,6 @@ struct sbi_platform { #define sbi_platform_ops(__p) \ ((const struct sbi_platform_operations *)(__p)->platform_ops_addr) -/** Check whether the platform supports timer value */ -#define sbi_platform_has_timer_value(__p) \ - ((__p)->features & SBI_PLATFORM_HAS_TIMER_VALUE) /** Check whether the platform supports HART hotplug */ #define sbi_platform_has_hart_hotplug(__p) \ ((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG) @@ -586,45 +575,6 @@ static inline void sbi_platform_ipi_exit(const struct sbi_platform *plat) sbi_platform_ops(plat)->ipi_exit(); } -/** - * Get platform timer value - * - * @param plat pointer to struct sbi_platform - * - * @return 64-bit timer value - */ -static inline u64 sbi_platform_timer_value(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->timer_value) - return sbi_platform_ops(plat)->timer_value(); - return 0; -} - -/** - * Start platform timer event for current HART - * - * @param plat pointer to struct struct sbi_platform - * @param next_event timer value when timer event will happen - */ -static inline void -sbi_platform_timer_event_start(const struct sbi_platform *plat, u64 next_event) -{ - if (plat && sbi_platform_ops(plat)->timer_event_start) - sbi_platform_ops(plat)->timer_event_start(next_event); -} - -/** - * Stop platform timer event for current HART - * - * @param plat pointer to struct sbi_platform - */ -static inline void -sbi_platform_timer_event_stop(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->timer_event_stop) - sbi_platform_ops(plat)->timer_event_stop(); -} - /** * Initialize the platform timer for current HART * diff --git a/include/sbi/sbi_timer.h b/include/sbi/sbi_timer.h index 87bbdbf..1ba6da0 100644 --- a/include/sbi/sbi_timer.h +++ b/include/sbi/sbi_timer.h @@ -12,6 +12,21 @@ #include +/** Timer hardware device */ +struct sbi_timer_device { + /** Name of the timer operations */ + char name[32]; + + /** Get free-running timer value */ + u64 (*timer_value)(void); + + /** Start timer event for current HART */ + void (*timer_event_start)(u64 next_event); + + /** Stop timer event for current HART */ + void (*timer_event_stop)(void); +}; + struct sbi_scratch; /** Get timer value for current HART */ @@ -35,6 +50,12 @@ void sbi_timer_event_start(u64 next_event); /** Process timer event for current HART */ void sbi_timer_process(void); +/** Get current timer device */ +const struct sbi_timer_device *sbi_timer_get_device(void); + +/** Register timer device */ +void sbi_timer_set_device(const struct sbi_timer_device *dev); + /* Initialize timer */ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot); diff --git a/include/sbi_utils/sys/clint.h b/include/sbi_utils/sys/clint.h index b07cf62..e102196 100644 --- a/include/sbi_utils/sys/clint.h +++ b/include/sbi_utils/sys/clint.h @@ -37,12 +37,6 @@ int clint_warm_ipi_init(void); int clint_cold_ipi_init(struct clint_data *clint); -u64 clint_timer_value(void); - -void clint_timer_event_stop(void); - -void clint_timer_event_start(u64 next_event); - int clint_warm_timer_init(void); int clint_cold_timer_init(struct clint_data *clint, diff --git a/include/sbi_utils/timer/fdt_timer.h b/include/sbi_utils/timer/fdt_timer.h index 770a0f3..36202a4 100644 --- a/include/sbi_utils/timer/fdt_timer.h +++ b/include/sbi_utils/timer/fdt_timer.h @@ -17,17 +17,8 @@ struct fdt_timer { int (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match); int (*warm_init)(void); void (*exit)(void); - u64 (*value)(void); - void (*event_stop)(void); - void (*event_start)(u64 next_event); }; -u64 fdt_timer_value(void); - -void fdt_timer_event_stop(void); - -void fdt_timer_event_start(u64 next_event); - void fdt_timer_exit(void); int fdt_timer_init(bool cold_boot); diff --git a/lib/sbi/sbi_platform.c b/lib/sbi/sbi_platform.c index 568d956..e78119a 100644 --- a/lib/sbi/sbi_platform.c +++ b/lib/sbi/sbi_platform.c @@ -19,9 +19,6 @@ static inline char *sbi_platform_feature_id2string(unsigned long feature) return NULL; switch (feature) { - case SBI_PLATFORM_HAS_TIMER_VALUE: - fstr = "timer"; - break; case SBI_PLATFORM_HAS_HART_HOTPLUG: fstr = "hotplug"; break; diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c index b571b17..63e8ea9 100644 --- a/lib/sbi/sbi_timer.c +++ b/lib/sbi/sbi_timer.c @@ -16,10 +16,11 @@ #include static unsigned long time_delta_off; -static u64 (*get_time_val)(const struct sbi_platform *plat); +static u64 (*get_time_val)(void); +static const struct sbi_timer_device *timer_dev = NULL; #if __riscv_xlen == 32 -static u64 get_ticks(const struct sbi_platform *plat) +static u64 get_ticks(void) { u32 lo, hi, tmp; __asm__ __volatile__("1:\n" @@ -31,7 +32,7 @@ static u64 get_ticks(const struct sbi_platform *plat) return ((u64)hi << 32) | lo; } #else -static u64 get_ticks(const struct sbi_platform *plat) +static u64 get_ticks(void) { unsigned long n; @@ -40,9 +41,16 @@ static u64 get_ticks(const struct sbi_platform *plat) } #endif +static u64 get_platform_ticks(void) +{ + return timer_dev->timer_value(); +} + u64 sbi_timer_value(void) { - return get_time_val(sbi_platform_thishart_ptr()); + if (get_time_val) + return get_time_val(); + return 0; } u64 sbi_timer_virt_value(void) @@ -80,7 +88,8 @@ void sbi_timer_set_delta_upper(ulong delta_upper) void sbi_timer_event_start(u64 next_event) { - sbi_platform_timer_event_start(sbi_platform_thishart_ptr(), next_event); + if (timer_dev && timer_dev->timer_event_start) + timer_dev->timer_event_start(next_event); csr_clear(CSR_MIP, MIP_STIP); csr_set(CSR_MIE, MIP_MTIP); } @@ -91,17 +100,34 @@ void sbi_timer_process(void) csr_set(CSR_MIP, MIP_STIP); } +const struct sbi_timer_device *sbi_timer_get_device(void) +{ + return timer_dev; +} + +void sbi_timer_set_device(const struct sbi_timer_device *dev) +{ + if (!dev || timer_dev) + return; + + timer_dev = dev; + if (!get_time_val && timer_dev->timer_value) + get_time_val = get_platform_ticks; +} + int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) { u64 *time_delta; const struct sbi_platform *plat = sbi_platform_ptr(scratch); - int ret; if (cold_boot) { time_delta_off = sbi_scratch_alloc_offset(sizeof(*time_delta), "TIME_DELTA"); if (!time_delta_off) return SBI_ENOMEM; + + if (sbi_hart_has_feature(scratch, SBI_HART_HAS_TIME)) + get_time_val = get_ticks; } else { if (!time_delta_off) return SBI_ENOMEM; @@ -110,24 +136,13 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) time_delta = sbi_scratch_offset_ptr(scratch, time_delta_off); *time_delta = 0; - ret = sbi_platform_timer_init(plat, cold_boot); - if (ret) - return ret; - - if (sbi_hart_has_feature(scratch, SBI_HART_HAS_TIME)) - get_time_val = get_ticks; - else if (sbi_platform_has_timer_value(plat)) - get_time_val = sbi_platform_timer_value; - else - /* There is no method to provide timer value */ - return SBI_ENODEV; - - return 0; + return sbi_platform_timer_init(plat, cold_boot); } void sbi_timer_exit(struct sbi_scratch *scratch) { - sbi_platform_timer_event_stop(sbi_platform_ptr(scratch)); + if (timer_dev && timer_dev->timer_event_stop) + timer_dev->timer_event_stop(); csr_clear(CSR_MIP, MIP_STIP); csr_clear(CSR_MIE, MIP_MTIP); diff --git a/lib/utils/sys/clint.c b/lib/utils/sys/clint.c index 80e04fb..4b1963a 100644 --- a/lib/utils/sys/clint.c +++ b/lib/utils/sys/clint.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define CLINT_IPI_OFF 0 @@ -118,7 +119,7 @@ static void clint_time_wr32(u64 value, volatile u64 *addr) writel_relaxed(value >> 32, (void *)(addr) + 0x04); } -u64 clint_timer_value(void) +static u64 clint_timer_value(void) { struct clint_data *clint = clint_timer_hartid2data[current_hartid()]; @@ -126,7 +127,7 @@ u64 clint_timer_value(void) return clint->time_rd(clint->time_val) + clint->time_delta; } -void clint_timer_event_stop(void) +static void clint_timer_event_stop(void) { u32 target_hart = current_hartid(); struct clint_data *clint = clint_timer_hartid2data[target_hart]; @@ -136,7 +137,7 @@ void clint_timer_event_stop(void) &clint->time_cmp[target_hart - clint->first_hartid]); } -void clint_timer_event_start(u64 next_event) +static void clint_timer_event_start(u64 next_event) { u32 target_hart = current_hartid(); struct clint_data *clint = clint_timer_hartid2data[target_hart]; @@ -146,6 +147,13 @@ void clint_timer_event_start(u64 next_event) &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; @@ -224,5 +232,11 @@ int clint_cold_timer_init(struct clint_data *clint, sbi_domain_memregion_init(clint->addr + CLINT_TIME_CMP_OFF, CLINT_TIME_CMP_SIZE, SBI_DOMAIN_MEMREGION_MMIO, ®); - return sbi_domain_root_add_memregion(®); + rc = sbi_domain_root_add_memregion(®); + if (rc) + return rc; + + sbi_timer_set_device(&clint_timer); + + return 0; } diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index d1d0e0c..92198cd 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -17,46 +17,15 @@ static struct fdt_timer *timer_drivers[] = { &fdt_timer_clint }; -static u64 dummy_value(void) -{ - return 0; -} - -static void dummy_event_stop(void) -{ -} - -static void dummy_event_start(u64 next_event) -{ -} - static struct fdt_timer dummy = { .match_table = NULL, .cold_init = NULL, .warm_init = NULL, .exit = NULL, - .value = dummy_value, - .event_stop = dummy_event_stop, - .event_start = dummy_event_start }; static struct fdt_timer *current_driver = &dummy; -u64 fdt_timer_value(void) -{ - return current_driver->value(); -} - -void fdt_timer_event_stop(void) -{ - current_driver->event_stop(); -} - -void fdt_timer_event_start(u64 next_event) -{ - current_driver->event_start(next_event); -} - void fdt_timer_exit(void) { if (current_driver->exit) diff --git a/lib/utils/timer/fdt_timer_clint.c b/lib/utils/timer/fdt_timer_clint.c index 6ba6c7b..0352e53 100644 --- a/lib/utils/timer/fdt_timer_clint.c +++ b/lib/utils/timer/fdt_timer_clint.c @@ -47,7 +47,4 @@ struct fdt_timer fdt_timer_clint = { .cold_init = timer_clint_cold_init, .warm_init = clint_warm_timer_init, .exit = NULL, - .value = clint_timer_value, - .event_stop = clint_timer_event_stop, - .event_start = clint_timer_event_start, }; diff --git a/platform/andes/ae350/platform.c b/platform/andes/ae350/platform.c index 338159d..17a4e48 100644 --- a/platform/andes/ae350/platform.c +++ b/platform/andes/ae350/platform.c @@ -172,9 +172,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = plicsw_ipi_clear, .timer_init = ae350_timer_init, - .timer_value = plmt_timer_value, - .timer_event_start = plmt_timer_event_start, - .timer_event_stop = plmt_timer_event_stop, .vendor_ext_provider = ae350_vendor_ext_provider }; diff --git a/platform/andes/ae350/plmt.c b/platform/andes/ae350/plmt.c index 3848e15..54dcb94 100644 --- a/platform/andes/ae350/plmt.c +++ b/platform/andes/ae350/plmt.c @@ -10,13 +10,14 @@ #include #include +#include static u32 plmt_time_hart_count; static volatile void *plmt_time_base; static volatile u64 *plmt_time_val; static volatile u64 *plmt_time_cmp; -u64 plmt_timer_value(void) +static u64 plmt_timer_value(void) { #if __riscv_xlen == 64 return readq_relaxed(plmt_time_val); @@ -32,7 +33,7 @@ u64 plmt_timer_value(void) #endif } -void plmt_timer_event_stop(void) +static void plmt_timer_event_stop(void) { u32 target_hart = current_hartid(); @@ -48,7 +49,7 @@ void plmt_timer_event_stop(void) #endif } -void plmt_timer_event_start(u64 next_event) +static void plmt_timer_event_start(u64 next_event) { u32 target_hart = current_hartid(); @@ -68,6 +69,13 @@ void plmt_timer_event_start(u64 next_event) } +static struct sbi_timer_device plmt_timer = { + .name = "ae350_plmt", + .timer_value = plmt_timer_value, + .timer_event_start = plmt_timer_event_start, + .timer_event_stop = plmt_timer_event_stop +}; + int plmt_warm_timer_init(void) { u32 target_hart = current_hartid(); @@ -93,5 +101,7 @@ int plmt_cold_timer_init(unsigned long base, u32 hart_count) plmt_time_val = (u64 *)(plmt_time_base); plmt_time_cmp = (u64 *)(plmt_time_base + 0x8); + sbi_timer_set_device(&plmt_timer); + return 0; } diff --git a/platform/andes/ae350/plmt.h b/platform/andes/ae350/plmt.h index 129fcf8..db093e0 100644 --- a/platform/andes/ae350/plmt.h +++ b/platform/andes/ae350/plmt.h @@ -10,12 +10,6 @@ #ifndef _AE350_PLMT_H_ #define _AE350_PLMT_H_ -u64 plmt_timer_value(void); - -void plmt_timer_event_stop(void); - -void plmt_timer_event_start(u64 next_event); - int plmt_warm_timer_init(void); int plmt_cold_timer_init(unsigned long base, u32 hart_count); diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 4f32c42..73c8b9c 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -159,9 +159,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .timer_init = ariane_timer_init, - .timer_value = clint_timer_value, - .timer_event_start = clint_timer_event_start, - .timer_event_stop = clint_timer_event_stop, }; const struct sbi_platform platform = { diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 77403c9..4d876c9 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -185,9 +185,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .timer_init = openpiton_timer_init, - .timer_value = clint_timer_value, - .timer_event_start = clint_timer_event_start, - .timer_event_stop = clint_timer_event_stop, }; const struct sbi_platform platform = { diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 445cbcf..cf18a1b 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -218,9 +218,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_init = fdt_ipi_init, .ipi_exit = fdt_ipi_exit, .get_tlbr_flush_limit = generic_tlbr_flush_limit, - .timer_value = fdt_timer_value, - .timer_event_stop = fdt_timer_event_stop, - .timer_event_start = fdt_timer_event_start, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, .system_reset_check = generic_system_reset_check, diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 495d214..c8fd45e 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -160,16 +160,13 @@ const struct sbi_platform_operations platform_ops = { .system_reset = k210_system_reset, .timer_init = k210_timer_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, }; const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01), .name = "Kendryte K210", - .features = SBI_PLATFORM_HAS_TIMER_VALUE, + .features = 0, .hart_count = K210_HART_COUNT, .hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE, .platform_ops_addr = (unsigned long)&platform_ops diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 4f4f884..86130c8 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -207,9 +207,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = clint_ipi_send, .ipi_clear = clint_ipi_clear, .ipi_init = ux600_ipi_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, .timer_init = ux600_timer_init, .system_reset_check = ux600_system_reset_check, .system_reset = ux600_system_reset diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index 82f6f75..78de30d 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -162,9 +162,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = clint_ipi_clear, .ipi_init = fu540_ipi_init, .get_tlbr_flush_limit = fu540_get_tlbr_flush_limit, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, .timer_init = fu540_timer_init, }; diff --git a/platform/template/platform.c b/platform/template/platform.c index fbbac30..1691652 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -133,33 +133,6 @@ static int platform_timer_init(bool cold_boot) return clint_warm_timer_init(); } -/* - * Get platform timer value. - */ -static u64 platform_timer_value(void) -{ - /* Example if the generic CLINT driver is used */ - return clint_timer_value(); -} - -/* - * Start platform timer event for current HART. - */ -static void platform_timer_event_start(u64 next_event) -{ - /* Example if the generic CLINT driver is used */ - clint_timer_event_start(next_event); -} - -/* - * Stop platform timer event for current HART. - */ -static void platform_timer_event_stop(void) -{ - /* Example if the generic CLINT driver is used */ - clint_timer_event_stop(); -} - /* * Check reset type and reason supported by the platform. */ @@ -186,9 +159,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_send = platform_ipi_send, .ipi_clear = platform_ipi_clear, .ipi_init = platform_ipi_init, - .timer_value = platform_timer_value, - .timer_event_stop = platform_timer_event_stop, - .timer_event_start = platform_timer_event_start, .timer_init = platform_timer_init, .system_reset_check = platform_system_reset_check, .system_reset = platform_system_reset diff --git a/platform/thead/c910/platform.c b/platform/thead/c910/platform.c index dfa484a..989ef90 100644 --- a/platform/thead/c910/platform.c +++ b/platform/thead/c910/platform.c @@ -137,7 +137,6 @@ const struct sbi_platform_operations platform_ops = { .ipi_clear = clint_ipi_clear, .timer_init = c910_timer_init, - .timer_event_start = clint_timer_event_start, .system_reset_check = c910_system_reset_check, .system_reset = c910_system_reset,