Message ID | 20230303133647.845095-18-sunilvl@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp412941wrd; Fri, 3 Mar 2023 05:40:27 -0800 (PST) X-Google-Smtp-Source: AK7set9e/aIXX/m+Tnjdwrm0gi+Jb31XJkMSEfU0jGbzlshD7VTxmudbvO5hzRFdZQZeKv1PIdV6 X-Received: by 2002:aa7:9ae9:0:b0:5a8:a973:450a with SMTP id y9-20020aa79ae9000000b005a8a973450amr1933500pfp.2.1677850827343; Fri, 03 Mar 2023 05:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677850827; cv=none; d=google.com; s=arc-20160816; b=eHiWXbTVz+Cgjay3ifFY15WzJp1EQqnAdvUjtteMOIPsz8cvICkTpOiRZ1bHqMhdw4 w20SUL6vksAHB4jdXpinfL29xxghmxzuGKC+qEB2O9bP2VGw+KLRsvhv3hodfR7524xY JUGSQk6+gjzzUxzAC481q3b/M9nbnEr30QZVLr2U9zgZ4Nx/OITGSBCRM7rpgAMIBwiC 8WcAhXufWTXSNxYsvd2phRecSV7+gIOhGz+UYHefohjJuMTdKqN5fjyHTLzHQELZh4Y6 ewcNUXOZw5ylczJOJgJJam3NdkEUiLpojVPH/EdxZqdLMeEqw+hhtO+6jBL98JQC90wR oYvg== 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=VUObxxi7Z2aUmCgcrqeWxF5lW/0L9jWTmCmlO9qrT1Q=; b=csl3i6O9L9zmTqdKrRCjclXxPqk+U9BgPGFqayl73+QENYd56Trg04BsM7m9Tx7MMT eCtGhvn6Er3fstbmsl6gnta24LJKzrgikAOb1bPj+wgEzlie5CoQHfyZ/9L6JhB7A9wD yFKvH+u1H15Dw9Os14nUEl9qBoFDb9NyHLzmnpMmfmSg/jfJRGNkUqthjN/LnMTpQiO3 49tDiY4j8eLNS1/jOEjWUuaF0SntzDVwAYBUnAISX9IAnGVKuQqb9mNxfz9vSkgAk1iF Obg6j1Oyjw6NDB4s9/L3M5rRfwxgwhNos67F4luAXpLbjHqHjJtdwdH48cCfy24gi6l6 Bp6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=h9zxegf8; 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 w68-20020a623047000000b005a8f197c6aasi2161235pfw.88.2023.03.03.05.40.13; Fri, 03 Mar 2023 05:40:27 -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=h9zxegf8; 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 S231398AbjCCNjs (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Fri, 3 Mar 2023 08:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjCCNjI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 08:39:08 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCA315F6C5 for <linux-kernel@vger.kernel.org>; Fri, 3 Mar 2023 05:38:22 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id q31-20020a17090a17a200b0023750b69614so2259231pja.5 for <linux-kernel@vger.kernel.org>; Fri, 03 Mar 2023 05:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1677850697; 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=VUObxxi7Z2aUmCgcrqeWxF5lW/0L9jWTmCmlO9qrT1Q=; b=h9zxegf87/P6gRuaxexokAH8RlgQHTW9aNEdi0Cc5LWaIyJtjQufDamIzXWLLGiZF3 USifV6YhmXfljWtfCtKoVzDSaMAlIMQl8P8W9iYkW9P1yN2X8mEbmYGh8JZAoaZt2kTe 6LrgQhXh/gipg4ttInSYviVS133KQF2VIbLtkmOl8ztATlVtPeHdNKbw+uVMmcYZMdWZ 5wMIv3VXRo46RR68LWy/VuxQFPl/DB83K6saS8aEZgnky6OIH2/ZZHTA1GVb9Z0Tz7AB uHHajGWlsqLl7rPfxfnmyX69OHuMKHkv8cWtHqUv5ZTl8j8X2nXZ8H6CiBIv6v5bjJQY 21VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677850697; 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=VUObxxi7Z2aUmCgcrqeWxF5lW/0L9jWTmCmlO9qrT1Q=; b=GfI8b+zc63ZmAz7Ly5cuEamkHj9x7MXzmCGmrHLMjf6lfEtt03u8/UYUH5xUe/zyJ8 iwF9hHj4/HqVOtUqr0gBQyTp4I5zQtaFKR/0YQfuSz5+k/w5L1ISbYx+aXQxPvN5i7kf mfDLjL+foqVwosDz2i4g0HqWa1T+hgfAqFHdctx64beT89895AoEdabUtPpcV3DqPQjL pfj2OzCDWpvufZgYtWd0tpvE+u2lIE9nYHtyScFc9jBOvKe5H3YIPn29Lmv3FVjCa8fK 5Wa7QmsYn4ecomvxXGNy8LF8Kkib2gfQ6fGFfH/hGC+zxmNLghazccqAkW0sCqyc8uNE J5KQ== X-Gm-Message-State: AO0yUKXkYEtlCvtKrI1B3OIILUilMGLf885zgjFis2SJ9XX1CQBs/nny YxYwfu3Do0jnhDRz8lhHEqO0SQ== X-Received: by 2002:a17:903:1c1:b0:19e:72c5:34df with SMTP id e1-20020a17090301c100b0019e72c534dfmr2360125plh.52.1677850697136; Fri, 03 Mar 2023 05:38:17 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id m9-20020a170902768900b0019ac5d3ee9dsm1533125pll.157.2023.03.03.05.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 05:38:16 -0800 (PST) From: Sunil V L <sunilvl@ventanamicro.com> To: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, "Rafael J . Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <maz@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Jonathan Corbet <corbet@lwn.net>, Anup Patel <apatel@ventanamicro.com>, Andrew Jones <ajones@ventanamicro.com>, Atish Patra <atishp@rivosinc.com>, 'Conor Dooley ' <conor.dooley@microchip.com>, Sunil V L <sunilvl@ventanamicro.com>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com> Subject: [PATCH V3 17/20] RISC-V: time.c: Add ACPI support for time_init() Date: Fri, 3 Mar 2023 19:06:44 +0530 Message-Id: <20230303133647.845095-18-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303133647.845095-1-sunilvl@ventanamicro.com> References: <20230303133647.845095-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759354109091521616?= X-GMAIL-MSGID: =?utf-8?q?1759354109091521616?= |
Series |
Add basic ACPI support for RISC-V
|
|
Commit Message
Sunil V L
March 3, 2023, 1:36 p.m. UTC
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 <sunilvl@ventanamicro.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> --- arch/riscv/kernel/time.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
Comments
On Fri, Mar 03, 2023 at 07:06:44PM +0530, Sunil V L wrote: > 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 <sunilvl@ventanamicro.com> > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > --- > arch/riscv/kernel/time.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c > index babaf3b48ba8..2c29543549c3 100644 > --- a/arch/riscv/kernel/time.c > +++ b/arch/riscv/kernel/time.c > @@ -4,6 +4,7 @@ > * Copyright (C) 2017 SiFive > */ > > +#include <linux/acpi.h> > #include <linux/of_clk.h> > #include <linux/clockchips.h> > #include <linux/clocksource.h> > @@ -18,17 +19,27 @@ 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"); I appreciate that it was like this before, but a newline here (and in the corresponding spot below) would be nice. That's a minor nit though, so: Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. > + 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(); > -- > 2.34.1 >
On Mon, Mar 06, 2023 at 09:09:11PM +0000, Conor Dooley wrote: > On Fri, Mar 03, 2023 at 07:06:44PM +0530, Sunil V L wrote: > > 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 <sunilvl@ventanamicro.com> > > Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > --- > > arch/riscv/kernel/time.c | 23 +++++++++++++++++------ > > 1 file changed, 17 insertions(+), 6 deletions(-) > > > > diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c > > index babaf3b48ba8..2c29543549c3 100644 > > --- a/arch/riscv/kernel/time.c > > +++ b/arch/riscv/kernel/time.c > > @@ -4,6 +4,7 @@ > > * Copyright (C) 2017 SiFive > > */ > > > > +#include <linux/acpi.h> > > #include <linux/of_clk.h> > > #include <linux/clockchips.h> > > #include <linux/clocksource.h> > > @@ -18,17 +19,27 @@ 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"); > > I appreciate that it was like this before, but a newline here (and in > the corresponding spot below) would be nice. Sure!. Will update in next revision. Thanks, Sunil
diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c index babaf3b48ba8..2c29543549c3 100644 --- a/arch/riscv/kernel/time.c +++ b/arch/riscv/kernel/time.c @@ -4,6 +4,7 @@ * Copyright (C) 2017 SiFive */ +#include <linux/acpi.h> #include <linux/of_clk.h> #include <linux/clockchips.h> #include <linux/clocksource.h> @@ -18,17 +19,27 @@ 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();