From patchwork Thu Feb 16 18:20:39 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: 58199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp457483wrn; Thu, 16 Feb 2023 10:24:25 -0800 (PST) X-Google-Smtp-Source: AK7set8zzi5nH8jQ1Bn9GwezQKrpwNqGrUfoKnFjGwj/vtrP1TbU3Lt+kZ/CeElk5l/e+lc+muM7 X-Received: by 2002:a05:6a00:2388:b0:594:1f1c:3d2f with SMTP id f8-20020a056a00238800b005941f1c3d2fmr3473193pfc.4.1676571865036; Thu, 16 Feb 2023 10:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676571865; cv=none; d=google.com; s=arc-20160816; b=XCpRxMRVWfFkYeOBohtZ4LXeNMiVIuhsewSwBF6xNhuJgD+iTbbVVyK7+5qU85Gju9 P/Ggw07PShNmdjLkjNCrgWnxAasQPEfBBpuSGLpislQyOXXL9iYZsLauQLfyVDcK8paw ZFwZaR2xlSFICGhTtLtfACWW5y73wG5JGUwJRhMfoSefSBo4WhB2acC8wgrCzU+9xgS9 drhqGCiolmtdW6XQsVZm1A2eHARdYbeevLVVeYlJ4jaFVoNZLJfrkionhNKu2gm4P2Xn 2YKSFHoEq1ZmSNAmRwuFrBEvdAlt/Wt20Om+ujZDL7cF5gpwpFHE9fzFCGFjMUKlUYV4 xIXg== 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=JjXwYmjlb4qLXAQKk4p+crKVMVgfMLiURDuGCOAQBXo=; b=Tkh2dMY0mPG0Q2y1eZmUhpDxC5MESgTnLPEUrASlJFVhoog1YWaLqOM4JLkmnmrKwE GLcOHNT7wDTMsI4aoTk9bWNVPC0bZztOsusQbBtHvr7A4iAvas/WY20958cHi9egK1hP UG81oZCMiSFqr3WxwaeiUhvyodbALymoseVc1Q6QV80vm4uBcJ2GQvras8NK9fXoY8eF EvQjYXPHS6j30ZrBHdE5Rh34leINwiDp+yrmKSxG0jqAWPi047HYb/vT6cTJqGj7RkF3 Xq9hUuBxSBtA2R7mesRW6Ta3w8jWEW9nZKOeVrm9n+tItkEORovOIsIQPyT8SW0Q3adB SmLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=V1EWcSn7; 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 204-20020a6216d5000000b005a8e0855ae6si2102432pfw.179.2023.02.16.10.24.10; Thu, 16 Feb 2023 10:24:25 -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=V1EWcSn7; 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 S229640AbjBPSXj (ORCPT + 99 others); Thu, 16 Feb 2023 13:23:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbjBPSWz (ORCPT ); Thu, 16 Feb 2023 13:22:55 -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 917B046144 for ; Thu, 16 Feb 2023 10:22:18 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id o8so2909097pls.11 for ; Thu, 16 Feb 2023 10:22:18 -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=JjXwYmjlb4qLXAQKk4p+crKVMVgfMLiURDuGCOAQBXo=; b=V1EWcSn7s/zB5yoo0RZlAv/kS8CPk7pGWmyW8MmvfWwyIqESMo1MjwuqWg/GrXiycT IRlhq2vH4TRPjqX7MhEUvuxf2HAMFxTno3nTwzqLN7Hys2vkxT4VnLIRWoCjpgFE0OGJ eZNi5pce+I9VZkznd7sJnnhv14NvLcNNVkclgh3iyop6uIXFFD2lUYXuJWfNeZ2TEHfF lCb0ifNzr28mTfFrREt2B20mnaE0wHeFTC18v0zervqlQypET2v2Y6LCXohFYiPAjlyX CjBcMaogRlRp7aF3LrWJxWmuaT3vZhVsKyUcOAkehGm6q4i6NVgluPC6KGFe+nedMJnn 9I5w== 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=JjXwYmjlb4qLXAQKk4p+crKVMVgfMLiURDuGCOAQBXo=; b=uccisDOoFWE/LGhzBppwr2cJJVSPLLqrOA3tqCYCA0y/p5IwC1QYf+e36nx1PM7tmQ e9Wox3Pq8+F3RyG7hswfFJLEt1Oq5mD6Etz23TK36sAqozIvrxkdHtd7UQ9gLiVZdvUQ bsuZe1L7j+P4mRRygwqu3FtT+526Y9spzdG3qPnnXQFyT1ld6fCeBZb4fZdSub/vYIvw UwILcfJb8s4kYPjagIXPgH83SrXCnf7UjvOwXNbNe24INZli9+9NJ1znzH4ba5y2847g 1aXHg02D1TwGb0RLUqs4JCurWjOoZNlAdGKtbpbu9OOSIffYQkmsWu/vw5p+BuZA9TCW ex+Q== X-Gm-Message-State: AO0yUKWft0OQQRSbStPYZ61HpnF5qavS9dPz47kn/4Nxd406/iX3ZjyT BV/pdG0RodMXtgihHl5O/AeSig== X-Received: by 2002:a17:90b:3852:b0:234:7ccf:3c7c with SMTP id nl18-20020a17090b385200b002347ccf3c7cmr3048070pjb.9.1676571733991; Thu, 16 Feb 2023 10:22:13 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id n21-20020a637215000000b004dff15fc121sm1517574pgc.36.2023.02.16.10.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 10:22:13 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Albert Ou , Paul Walmsley , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Jonathan Corbet Cc: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Conor Dooley , Andrew Jones , Anup Patel , Atish Patra , Sunil V L , "Rafael J . Wysocki" Subject: [PATCH V2 17/21] RISC-V: time.c: Add ACPI support for time_init() Date: Thu, 16 Feb 2023 23:50:39 +0530 Message-Id: <20230216182043.1946553-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216182043.1946553-1-sunilvl@ventanamicro.com> References: <20230216182043.1946553-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?1758013019513835245?= X-GMAIL-MSGID: =?utf-8?q?1758013019513835245?= 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 --- 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();