From patchwork Mon Jan 30 18:22:19 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: 50413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2332127wrn; Mon, 30 Jan 2023 10:29:23 -0800 (PST) X-Google-Smtp-Source: AK7set8gKT9NebU94t4dt42mIpBFPh3M0GIkw5vlXMzP7sb8rwLfrXqn1sPPLoZchgS9u/FMfqX3 X-Received: by 2002:a17:906:db07:b0:881:9531:35a0 with SMTP id xj7-20020a170906db0700b00881953135a0mr14780342ejb.73.1675103363451; Mon, 30 Jan 2023 10:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675103363; cv=none; d=google.com; s=arc-20160816; b=Fr7In3FQjTa3385YJJmPYTn8WLP3jkequPamHE5fWqLOQOg56Iu98wh5iiJsFOBj9G kFYxpKH1+echTjsWsTC/FFDNlFveO5UuCH5S43onAZUmKo11FYqDttr1ngJ0bTzEu/4Z C+Tk0VOT4UdvqVJAaR8hlRKIUsARTnA/tpsfWoxFwb4Xd9s5Za1AOXYQrwie7x+9qp0Q LH1HsVjunrZFD+nJl4lRIz3msmL7Xm0+HkWsjSz1vAiTY9+bkAU3WW7bs8Epg6ohtEgJ Dr9hKUr8ycsGfYL7AZZSXKv5x1hFFacKum7EYMxUW4YH8IKg35Ey16lM1hALiBATbiuI 2soA== 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=HjibFpTqTShjczIJbVTkz5RGTuyNmy3y1G35vLo3EEc=; b=F5gAzWkiyr1jrIHQg9/R1I05Rq65B4n+zqYTLCNdKYk8YRgX7p0+w9kMaDtKwLwVdL uQbGych2HOVGpl27z6gix1RDP44R13+6/FHNJuuJcZgmi09fiYBqX8ZUjEh/p2DN+10/ kBadmFRPOcYWOEtp6FE3qTvVmPcCiy7wPlXCrkg5/NfgypwdWbbl727tEBLN46QSWno/ HXjkMLV0u6F7IHevr+kyHS5FL2gQ1qV4/fsraofbKPT3m7wKWAy1+UE5/FbW6oIEccfj dXR46NNHV+wng+ED+x1GiucXksLA9nwyvswLU9L3yNIvxJfbYhTFAV8knKciMsdQnVKo YTAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=JIG4KdNI; 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 9-20020a170906018900b00883ec4c63dfsi8581775ejb.146.2023.01.30.10.29.00; Mon, 30 Jan 2023 10:29:23 -0800 (PST) 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=JIG4KdNI; 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 S238207AbjA3SZ4 (ORCPT + 99 others); Mon, 30 Jan 2023 13:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238317AbjA3SZK (ORCPT ); Mon, 30 Jan 2023 13:25:10 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF8246D45 for ; Mon, 30 Jan 2023 10:23:59 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id p24so12520572plw.11 for ; Mon, 30 Jan 2023 10:23:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=HjibFpTqTShjczIJbVTkz5RGTuyNmy3y1G35vLo3EEc=; b=JIG4KdNIJo8a8e5DcMOlWOMk+SMYfFyg3Sc1+T9cyo/r6KA/knBlxhzkv6TiGdCEFh QjO2PFJXsESo+8PMKJwelpLyT4Vo86Khy7c6Z7o6X6a33TuC+f+kT9LsGwllBf2XqEK5 IEDoGCJNFCrY9/SkFjrWHgpKsYV1CNUXGhJ9Yn8evGLV6bv8sgnDZ0PIaPdedoyRjbLR ap7ZG6XW24t+kvvZedK4Buw158HCC84yxTP3DRLno7tqS/f+CTP6IZBNL1IIp28NwGhD sUunUcy8sZSCp8pqwKkOULMjeoXPWWA/ga6VwWeMZvqz37Xp18dsvJX+07/zKlwpRN5R uRrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=HjibFpTqTShjczIJbVTkz5RGTuyNmy3y1G35vLo3EEc=; b=b7WEYfnYDeudT0DFTWM0Xu88K62V6ZUtyQw57NuOgpTdjttEd72VdkgNJQgLcjJzTB 5JPy9bPaQvFrPD5dhOF/2YO2JlQlE8CV+YAneJkg6EDXvEtD6MYFkykZ2kFmBSZbUkZT IaI2x+kfjfb/UuPFAoxGjWNSXrWQYUQUBOZzqB4zFMtLP3B4RNqqGoIPj7rHrHxHqtvN b6Ft/v338P3IEmog1YCkIY1/oKQCQA/fCjmGWrdO/nqtCAE1/G2YzY6QYv9gS4ViRcER gGstBrCV5S5886lYHI/dhTt9Bl10JIciyMKEssd38Mh88nz+/4J3jY/g5LupvElcNPeY Rb6A== X-Gm-Message-State: AFqh2kqsk5CLfd7oguPt0KH1u7dH8fjk/fq42KKudoohUuFtvxJyS6vA 09/WQAhxP6Td/2IvsYKEM/KWtg== X-Received: by 2002:a05:6a20:c706:b0:b6:c018:7fd8 with SMTP id hi6-20020a056a20c70600b000b6c0187fd8mr52692395pzb.11.1675103036632; Mon, 30 Jan 2023 10:23:56 -0800 (PST) Received: from kerodipc.Dlink ([49.206.9.96]) by smtp.gmail.com with ESMTPSA id j193-20020a638bca000000b00478162d9923sm7000291pge.13.2023.01.30.10.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 10:23:56 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Jonathan Corbet Cc: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Anup Patel , Andrew Jones , Atish Patra , Sunil V L Subject: [PATCH 18/24] RISC-V: ACPI: time.c: Add ACPI support for time_init() Date: Mon, 30 Jan 2023 23:52:19 +0530 Message-Id: <20230130182225.2471414-19-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230130182225.2471414-1-sunilvl@ventanamicro.com> References: <20230130182225.2471414-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 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?1756473184169064035?= X-GMAIL-MSGID: =?utf-8?q?1756473184169064035?= 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 --- 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 1cf21db4fcc7..e49b897fc657 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; + } 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); + if (acpi_disabled) + of_clk_init(NULL); + timer_probe(); tick_setup_hrtimer_broadcast();