From patchwork Tue Apr 4 18:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 79343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp83254vqo; Tue, 4 Apr 2023 11:34:16 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2XlSLd9TdA66Z4wsBFj51+jYJztL16nn/usG2VtmP6x7wTQIqRfzjpYy4Y65hWHueJ52h X-Received: by 2002:a05:6a20:2a08:b0:da:35d1:c46f with SMTP id e8-20020a056a202a0800b000da35d1c46fmr2844086pzh.43.1680633256165; Tue, 04 Apr 2023 11:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680633256; cv=none; d=google.com; s=arc-20160816; b=mRTvKedKPuFvw/cNCnK8cIeoYQyALk011CseQz0upLHbPqqoLbQ8LRlUL+PDDwHwJR iBQ1zOFJOFAMOSjvm8dUY2xs4x144FMpt3jSvZUqtXTMwXHUFUV64GS3Yy0LiwknIkvo OZTj3U3fFCcFHwKx3Xg7nMFMBuzgl+y7ejPkTtyT6wWD25utzPpV1RM+CvfuKd12jaN6 tZmTeu+M9bXG+iulQ7ihNAjDWZrLljyoI7Z10hTFAg7RdcNE9uxpSiBgP8Q9pDB+Id2y rA8i13cn2cNMQnjUiNvYqEXk9fMIaqOTDDequndxlIEBta9YGQ/yXri2ibpOMtBvO1p0 rnFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yRIRI8aArNgE1fextAvbnFu2fBTu5X0gP4d56RcrLtU=; b=wvqQJVmwBHdPyZ3TSD5oD3CJ+Qh3ZbXulpDPr7+kdTC4dydSUleztNpxWSn9RaeuiD aZHxVGoYt7EoArxZxHRcotqj35km0XyeDNlD3l9Csy983WGQU6wglh5Qoy0YmoiXlDR/ yai2FrcsESuuAgdadrJEMUf9wlqH+fD0rzkkdnc+7vEsnhiSxIctMyryLDcfOLctDc6z DVdzQKvqdyo2hR2+QVgr4rHyMNfXp/e52n/lRNhEviVwQOSaP+RDbSwp75PKrNF8K9X5 RsX7FGBw5FoiYrmFFZqRgGB8pfahNzgKsiVSghbVkwlx9FxqWkrESXp87icyJztWH7wH uppw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="kR+s/3Cy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020aa79542000000b005a910206938si11266192pfq.29.2023.04.04.11.34.03; Tue, 04 Apr 2023 11:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="kR+s/3Cy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236422AbjDDSZc (ORCPT + 99 others); Tue, 4 Apr 2023 14:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236091AbjDDSYn (ORCPT ); Tue, 4 Apr 2023 14:24:43 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0312719BC for ; Tue, 4 Apr 2023 11:22:57 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id z11so22063479pfh.4 for ; Tue, 04 Apr 2023 11:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680632574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yRIRI8aArNgE1fextAvbnFu2fBTu5X0gP4d56RcrLtU=; b=kR+s/3CyZbFI3Sunvs1k3V1ES1X4ydgZ00TjDVbTDpPayRRqJtNYWC1pnZKPyJ1E4m uVVFYGIBA545X9dY08nwaA59HRbUjd9EYHx2Cy1PiWpDV6St/RbMsaxMzv2ebXETqB3T IWyqlqUMUTxX/L/1EVEePoaOEv+J+wDut/+8wE/WfaBlVWjmx+jUJwp27J7GJSoKBFYi Gs/bQbROeeHt3oLkMAredzEYiNhvbVD4063BbvtSGO8KYmfh9mHElnJ91hKauVeqAuJu SvE1YFOFHhbkcFvYrBZqMJlKsUQmNhxYUfL6WtnalKsTb9fumEdV3JkpckGcefrlOkdm vcYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680632574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yRIRI8aArNgE1fextAvbnFu2fBTu5X0gP4d56RcrLtU=; b=3EZaUUetANvg/sZh2V8TWM1clP+qXjpwvzyrk0JVz7oIRw1Lx6E+Euqfp9zwBYJSwZ RtoOTT+aHCPxRuoOBz4vyKjOrdtI1+ScaLW4tIe5IsCWXpeFKC+fieQjEhPGmcOtg5hH iaEB5KEJpIM3nVjP2zuIEJmylahpzGeBU6ujG2dXVDv0FbYclrWw1EK5Kuw98rVqnN0s oNyb4jL1cjd7Mk+sLKz1Au2IwQFdvzJGSJL4HOmZq7SYn1DU1TKSBdrVQR1FMs0NWtm+ YHUHKPaNcv4Gl7EoR6tFG7qkwL8HZJWc7rq827jvXZYLT3WHYvJmH9E00P9bGKPAfpoR Fbeg== X-Gm-Message-State: AAQBX9cHNtfB3BSCTkLuMStCzBpo737Fr+aHpUb+NcQujlb5SVW48yQ6 FlGfTJVYpaenG2Ba/45DDu1Gpw== X-Received: by 2002:aa7:9568:0:b0:628:4c9:a07 with SMTP id x8-20020aa79568000000b0062804c90a07mr3040510pfq.29.1680632574272; Tue, 04 Apr 2023 11:22:54 -0700 (PDT) Received: from localhost.localdomain ([106.51.184.50]) by smtp.gmail.com with ESMTPSA id o12-20020a056a001bcc00b0062dcf5c01f9sm9018524pfw.36.2023.04.04.11.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 11:22:53 -0700 (PDT) From: Sunil V L To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-crypto@vger.kernel.org, platform-driver-x86@vger.kernel.org, llvm@lists.linux.dev Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , "Rafael J . Wysocki" , "David S . Miller" , Sunil V L , "Rafael J . Wysocki" , Andrew Jones , Conor Dooley Subject: [PATCH V4 18/23] RISC-V: time.c: Add ACPI support for time_init() Date: Tue, 4 Apr 2023 23:50:32 +0530 Message-Id: <20230404182037.863533-19-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230404182037.863533-1-sunilvl@ventanamicro.com> References: <20230404182037.863533-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762271697401596835?= X-GMAIL-MSGID: =?utf-8?q?1762271697401596835?= On ACPI based platforms, timer related information is available in RHCT. Add ACPI based probe support to the timer initialization. Signed-off-by: Sunil V L Acked-by: Rafael J. Wysocki Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley --- arch/riscv/kernel/time.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c index babaf3b48ba8..23641e82a9df 100644 --- a/arch/riscv/kernel/time.c +++ b/arch/riscv/kernel/time.c @@ -4,6 +4,7 @@ * Copyright (C) 2017 SiFive */ +#include #include #include #include @@ -18,17 +19,29 @@ EXPORT_SYMBOL_GPL(riscv_timebase); void __init time_init(void) { struct device_node *cpu; + struct acpi_table_rhct *rhct; + acpi_status status; u32 prop; - cpu = of_find_node_by_path("/cpus"); - if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) - panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); - of_node_put(cpu); - riscv_timebase = prop; + if (acpi_disabled) { + cpu = of_find_node_by_path("/cpus"); + if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) + panic("RISC-V system with no 'timebase-frequency' in DTS\n"); + + of_node_put(cpu); + riscv_timebase = prop; + of_clk_init(NULL); + } else { + status = acpi_get_table(ACPI_SIG_RHCT, 0, (struct acpi_table_header **)&rhct); + if (ACPI_FAILURE(status)) + panic("RISC-V ACPI system with no RHCT table\n"); + + riscv_timebase = rhct->time_base_freq; + acpi_put_table((struct acpi_table_header *)rhct); + } lpj_fine = riscv_timebase / HZ; - of_clk_init(NULL); timer_probe(); tick_setup_hrtimer_broadcast();