From: Sumit Gupta <sumitg@nvidia.com>
To: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>,
rafael@kernel.org, viresh.kumar@linaro.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, treding@nvidia.com,
jonathanh@nvidia.com, linux-pm@vger.kernel.org,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Cc: bbasu@nvidia.com
Subject: Re: [PATCH 8/9] cpufreq: tegra194: Add support for Tegra264
Date: Tue, 17 Nov 2026 15:48:17 +0530 [thread overview]
Message-ID: <ad63fdd0-86d9-4b8b-89ac-7fc3bba6d8dd@nvidia.com> (raw)
In-Reply-To: <4f680a92-c69c-459b-acc1-c877e88cc265@oss.qualcomm.com>
On 13/11/26 11:57, Zhongqiu Han wrote:
> External email: Use caution opening links or attachments
>
>
> On 11/5/2026 2:15 AM, Sumit Gupta wrote:
>> Add cpufreq support for Tegra264. It requests and reads the CPU
>> frequency differently from earlier SoCs.
>>
>> To request a frequency, the driver writes NDIV to a core_freq_req
>> register in the CCPLEX register space. Two clusters share a
>> cluster-clock unit and its register, so they always run at the same
>> frequency. The driver exposes each pair as one performance domain and
>> one cpufreq policy. Each CPU's "performance-domains" property gives the
>> domain index, which selects the register. If the CCPLEX node declares
>> "#performance-domain-cells", probe fails if any CPU lacks the property.
>>
>> To read the frequency, the driver samples the per-CPU 64-bit AMU
>> counters through system registers. The AMU constant counter is the
>> reference. It ticks at the system counter rate, so the driver takes the
>> reference rate from CNTFRQ instead of the fixed 408 MHz clock.
>>
>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>> ---
>> drivers/cpufreq/Kconfig.arm | 4 +-
>> drivers/cpufreq/tegra194-cpufreq.c | 147 ++++++++++++++++++++++++++++-
>> 2 files changed, 144 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
>> index a441668f9e0c..a5482b12be57 100644
>> --- a/drivers/cpufreq/Kconfig.arm
>> +++ b/drivers/cpufreq/Kconfig.arm
>> @@ -248,9 +248,9 @@ config ARM_TEGRA186_CPUFREQ
>>
>> config ARM_TEGRA194_CPUFREQ
>> tristate "Tegra194 CPUFreq support"
>> - depends on ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC
>> + depends on ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC ||
>> ARCH_TEGRA_264_SOC
>> depends on TEGRA_BPMP
>> - default ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC
>> + default ARCH_TEGRA_194_SOC || ARCH_TEGRA_234_SOC ||
>> ARCH_TEGRA_264_SOC
>> help
>> This adds CPU frequency driver support for Tegra194 SOCs.
>>
>> diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/
>> tegra194-cpufreq.c
>> index 1328aa0a1bd1..0767a6fd6bdc 100644
>> --- a/drivers/cpufreq/tegra194-cpufreq.c
>> +++ b/drivers/cpufreq/tegra194-cpufreq.c
>> @@ -14,7 +14,9 @@
>> #include <linux/slab.h>
>> #include <linux/units.h>
>>
>> +#include <asm/arch_timer.h>
>> #include <asm/cputype.h>
>> +#include <asm/sysreg.h>
>>
>> #include <soc/tegra/bpmp.h>
>> #include <soc/tegra/bpmp-abi.h>
>> @@ -36,6 +38,18 @@
>> (data->regs + (MMCRAB_CLUSTER_BASE(cl) + data-
>> >soc->actmon_cntr_base))
>> #define CORE_ACTMON_CNTR_REG(data, cl, cpu)
>> (CLUSTER_ACTMON_BASE(data, cl) + CORE_OFFSET(cpu))
>>
>> +/*
>> + * Tegra264 requests a frequency by writing the NDIV to a core_freq_req
>> + * register in the CCPLEX register space.
>> + *
>> + * Two clusters that share a cluster-clock unit form a performance
>> domain.
>> + * Each domain has one core_freq_req register. The registers are grouped
>> + * in blocks, two domains per block.
>> + */
>> +#define T264_CORE_FREQ_REQ_BLOCK_SIZE 0x400000
>> +#define T264_CORE_FREQ_REQ_BLOCK_DOMAIN0_OFFSET 0x40000
>> +#define T264_CORE_FREQ_REQ_BLOCK_DOMAIN1_OFFSET 0x50000
>> +
>> /* cpufreq transisition latency */
>> #define TEGRA_CPUFREQ_TRANSITION_LATENCY (300 * 1000) /* unit in
>> nanoseconds */
>>
>> @@ -70,6 +84,8 @@ struct tegra_cpufreq_ops {
>> struct tegra_cpufreq_soc {
>> struct tegra_cpufreq_ops *ops;
>> u64 cnt_mask;
>> + /* AMU's constant counter ticks at the system counter rate. */
>> + bool ref_clk_from_cntfrq;
>> int maxcpus_per_cluster;
>> unsigned int num_clusters;
>> bool needs_mmio;
>> @@ -79,8 +95,10 @@ struct tegra_cpufreq_soc {
>>
>> struct tegra194_cpufreq_data {
>> void __iomem *regs;
>> + resource_size_t regs_size;
>> struct cpufreq_frequency_table **bpmp_luts;
>> const struct tegra_cpufreq_soc *soc;
>> + u32 ref_clk_mhz;
>> bool icc_dram_bw_scaling;
>> struct tegra_cpu_data *cpu_data;
>> enum cpuhp_state cpuhp_state;
>> @@ -240,6 +258,78 @@ static const struct tegra_cpufreq_soc
>> tegra238_cpufreq_soc = {
>> .refclk_delta_min = 16000,
>> };
>>
>> +static void __iomem *tegra264_core_freq_req_reg(struct
>> tegra194_cpufreq_data *data,
>> + u32 clkid)
>> +{
>> + u64 offset = (u64)(clkid / 2) * T264_CORE_FREQ_REQ_BLOCK_SIZE;
>> +
>> + offset += (clkid % 2) ? T264_CORE_FREQ_REQ_BLOCK_DOMAIN1_OFFSET :
>> + T264_CORE_FREQ_REQ_BLOCK_DOMAIN0_OFFSET;
>> +
>> + /*
>> + * clkid comes from the device tree. Reject an index whose 32-bit
>> + * register does not fit in the mapped region.
>> + */
>> + if (offset + sizeof(u32) > data->regs_size)
>> + return NULL;
>> +
>> + return data->regs + offset;
>> +}
>> +
>> +static int tegra264_get_cpu_ndiv(u32 cpu, u32 cpuid, u32 clusterid,
>> u64 *ndiv)
>> +{
>> + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data();
>> + u32 clkid = data->cpu_data[cpu].clkid;
>> + void __iomem *reg;
>> +
>> + reg = tegra264_core_freq_req_reg(data, clkid);
>> + if (!reg)
>> + return -EINVAL;
>> +
>> + *ndiv = readl(reg) & NDIV_MASK;
>> +
>> + return 0;
>> +}
>> +
>> +static void tegra264_set_cpu_ndiv(struct cpufreq_policy *policy, u64
>> ndiv)
>> +{
>> + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data();
>> + u32 clkid = data->cpu_data[policy->cpu].clkid;
>> + void __iomem *reg;
>> +
>> + reg = tegra264_core_freq_req_reg(data, clkid);
>> + if (reg)
>> + writel(ndiv, reg);
>> +}
>> +
>> +/*
>> + * The AMU counters are per-CPU system registers, so this must run on
>> the CPU
>> + * it samples. tegra194_calculate_speed() queues it there with
>> queue_work_on().
>> + */
>> +static void tegra264_sample_counters(struct tegra194_cpufreq_data *data,
>> + struct tegra_cpu_ctr *c)
>> +{
>> + c->coreclk_cnt = read_sysreg_s(SYS_AMEVCNTR0_CORE_EL0);
>> + c->refclk_cnt = read_sysreg_s(SYS_AMEVCNTR0_CONST_EL0);
>
>
> AMU is optional, so arm64 core reads these counters only with
> CONFIG_ARM64_AMU_EXTN and a per-CPU check (arch/arm64/kernel/
> topology.c). Is AMU always enabled on Tegra264, or should this be gated
> the same way?
>
>
> --
> Thx and BRs,
> Zhongqiu Han
>
AMU is always enabled on Tegra264.
cpu_has_amu_feat() is not exported, so it can't be used.
In v2, I will change the driver to check for CONFIG_ARM64_AMU_EXTN
and the AMU field of ID_AA64PFR0_EL1. All Tegra264 CPUs are identical,
so a system wide check should be enough.
static bool tegra_cpufreq_amu_present(void)
{
u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);
return IS_ENABLED(CONFIG_ARM64_AMU_EXTN) &&
cpuid_feature_extract_unsigned_field(pfr0,
ID_AA64PFR0_EL1_AMU_SHIFT);
}
Thanks,
Sumit
next prev parent reply other threads:[~2026-11-17 10:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 18:15 [PATCH 0/9] cpufreq: tegra194: add Tegra264 support Sumit Gupta
2026-11-04 18:15 ` [PATCH 1/9] cpufreq: tegra194: move MPIDR read to CPU hotplug callback Sumit Gupta
2026-11-13 6:27 ` Zhongqiu Han
2026-11-17 9:53 ` Sumit Gupta
2026-11-04 18:15 ` [PATCH 2/9] cpufreq: tegra194: remove duplicate counter sampling loops Sumit Gupta
2026-11-04 18:15 ` [PATCH 3/9] cpufreq: tegra194: add tegra_counter_delta helper Sumit Gupta
2026-11-04 18:15 ` [PATCH 4/9] cpufreq: tegra194: add per-SoC counter mask Sumit Gupta
2026-11-04 18:15 ` [PATCH 5/9] cpufreq: tegra194: split MMIO mapping from ACTMON offset Sumit Gupta
2026-11-04 18:15 ` [PATCH 6/9] dt-bindings: arm: nvidia: Document the Tegra264 CCPLEX cluster Sumit Gupta
2026-11-04 18:15 ` [PATCH 7/9] cpufreq: tegra194: derive frequency domain from device tree Sumit Gupta
2026-11-04 18:15 ` [PATCH 8/9] cpufreq: tegra194: Add support for Tegra264 Sumit Gupta
2026-11-13 6:27 ` Zhongqiu Han
2026-11-17 10:18 ` Sumit Gupta [this message]
2026-11-04 18:15 ` [PATCH 9/9] arm64: tegra: Add CCPLEX cluster node " Sumit Gupta
2026-11-13 6:26 ` [PATCH 0/9] cpufreq: tegra194: add Tegra264 support Zhongqiu Han
2026-11-17 9:51 ` Sumit Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad63fdd0-86d9-4b8b-89ac-7fc3bba6d8dd@nvidia.com \
--to=sumitg@nvidia.com \
--cc=bbasu@nvidia.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jonathanh@nvidia.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=treding@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhongqiu.han@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox