From patchwork Mon May 8 11:52:34 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: 91098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2115072vqo; Mon, 8 May 2023 05:27:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WrrtyRH0GJogNkVAekTHVBvhoVovYqbvC1Zw3QpB0TNzWp8EKrtyE0MQdp0MfuvIf3O7j X-Received: by 2002:a05:6a00:13a8:b0:63d:6744:8cae with SMTP id t40-20020a056a0013a800b0063d67448caemr12890728pfg.2.1683548821374; Mon, 08 May 2023 05:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683548821; cv=none; d=google.com; s=arc-20160816; b=bxlYbPdTO7kOa38LYJUNjl75U+MuaNA9/DZeM/pLFPL/iNhpYeO0t/MlGniYZVDpcB qKLA0H+20eFJcJ4WG+4GIWv6GG75Wvl6kQOmRJZxh+Ll2kCBpwNpifGYHw8Ek1Q0b1iE CCzQD71d24pS/l2RxezC/uWHtlRrHCuTmOiAMdcSN4Q7V6RQQjGwQ4j7vDIhX8efuWV5 /K+S88xpfZGz4rrvB74WFm4PzeAAPv5OhL4lXq1yN+7Qy+Nvo6JZtd9y/WP1T3hjd1Le dMjzSSYRpbhvyx40TvUMuBC2xiONxJr0FpCVWHbocUmyaD7WCZpcNf1YGeNaBHKr2q3J G5gQ== 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=NiWakDDoAYtkpri/wlqw5mSrl39oz1AGu2hxJSYIVojwzyBeGU5alxBCx4gaZbj7/w 79sZ5izOwzo9TG6+vIIVdZEDZ/7yHTeaUosC0nU1o9tGYgKUlFwDtdI3+YwUzn4GTf51 rPGpMl4Bdj7h79K4AYxmSQsCA5b1WlXaxBbBLjrU6W+MM7z8uw7PqFhoKzjUd01xjSC5 GVLHXzQG4eEA8oDLVYiCs+2kzMaf3ReImImG+Y6HkPvfr1vxrq2aK/MGsGqGFvw/a5yL /gulKBLiw6zE8Q+hHc5nWFJdzL6601Y4gmKctZTjVMvpFD/N5/V8CH8EMCyVpE1XjsJO PREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dPMbOuJs; 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 n12-20020aa7984c000000b006464f29ed9dsi1428950pfq.385.2023.05.08.05.26.46; Mon, 08 May 2023 05:27:01 -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=dPMbOuJs; 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 S233986AbjEHL6J (ORCPT + 99 others); Mon, 8 May 2023 07:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233552AbjEHL5X (ORCPT ); Mon, 8 May 2023 07:57:23 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8EF441A9 for ; Mon, 8 May 2023 04:55:25 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-64115e652eeso33927760b3a.0 for ; Mon, 08 May 2023 04:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1683546924; x=1686138924; 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=dPMbOuJszGZR9AahCXbvkNUwii+U9QMTSbyX/g4rgl2Q6FpYBFAPcbDw395JVWTi3S E6urCy+MpwA2mwwR1jCyAvffT1l31W8/LPIcJGeeFTD5aLYHDEquT54qiJ2PiGwewAK/ 7/al2D5PTVEakeiZsNEdWqALf2XkQL0K7k9aFb+4iJxePbBgZXZVkfp8vW4aBTIcs+SD +bz/l9nW3Yjj7WFv+zwFHYEfdt26tbRHLOQXJbw4w/Xh1zaR7Z1ODfJ0Z4leFb0BXw7C UqtjGgxhDIEAThPM+W99EdZymdIczjmy/IDVSEpiG7tDS91x79zJImn26Sq77ax+bOHo zOIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683546924; x=1686138924; 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=YiNIif53dqf71uzIgpon4qDFVdLu3rbXq0EySSqlv/BDLo41dvBmbc6eFwDXizUqOC KQSlIVSW8T2uctgHWxIXzMxvJK4je3MpvRuNYUngO/PTVSRPOffd0zNaVhuRq+nuVh1q oy/nLLh8GciXGUW714DsuQi86tuH7LNWEsI3VhR6IahA7lm6nuXI32qXkFB2q9LBq63m 7+3jTcq+cQhEkFQVHKTlZOjq4L4T64AH8HTsWXZp8MrndennUmgaoOEccF073pN+FeqY TZrlV5RPJ3DE6bhD5S49aJBIAhMzmPDIHj/1PbTs9Xtl+wGa2AG70ISk1d82yYPbx0Ca g/Xw== X-Gm-Message-State: AC+VfDz2xQhIgAg35DFF2VZwgXjahVqhS5HNspvBE+wocSreQDXcCWeQ eZllius7CTGVwuMftG8PP/aBuQ== X-Received: by 2002:a17:902:e550:b0:1a6:e564:6044 with SMTP id n16-20020a170902e55000b001a6e5646044mr12627890plf.7.1683546924015; Mon, 08 May 2023 04:55:24 -0700 (PDT) Received: from sunil-laptop.. ([106.51.189.144]) by smtp.gmail.com with ESMTPSA id w9-20020a170902904900b001aaed524541sm7015149plz.227.2023.05.08.04.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 04:55:23 -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 , "Rafael J . Wysocki" , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , "David S . Miller" , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , Sunil V L , "Rafael J . Wysocki" , Andrew Jones , Conor Dooley Subject: [PATCH V5 18/21] RISC-V: time.c: Add ACPI support for time_init() Date: Mon, 8 May 2023 17:22:34 +0530 Message-Id: <20230508115237.216337-19-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508115237.216337-1-sunilvl@ventanamicro.com> References: <20230508115237.216337-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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?1765328888662982043?= X-GMAIL-MSGID: =?utf-8?q?1765328888662982043?= 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();