[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241204053211.6gdogcpi4g3eavw5@vireshk-i7>
Date: Wed, 4 Dec 2024 11:02:11 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, linux-pm@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
upstream@...oha.com
Subject: Re: [PATCH v5 2/2] cpufreq: airoha: Add EN7581 CPUFreq SMCCC driver
On 03-12-24, 17:31, Christian Marangi wrote:
> diff --git a/drivers/cpufreq/airoha-cpufreq.c b/drivers/cpufreq/airoha-cpufreq.c
> +struct airoha_cpufreq_priv {
> + struct clk_hw hw;
> + struct generic_pm_domain pd;
> +
> + int opp_token;
> + struct dev_pm_domain_list *pd_list;
> + struct platform_device *cpufreq_dt;
> +};
> +
> +static long airoha_cpufreq_clk_round(struct clk_hw *hw, unsigned long rate,
> + unsigned long *parent_rate)
> +{
> + return rate;
> +}
> +
> +static unsigned long airoha_cpufreq_clk_get(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + const struct arm_smccc_1_2_regs args = {
> + .a0 = AIROHA_SIP_AVS_HANDLE,
> + .a1 = AIROHA_AVS_OP_GET_FREQ,
> + };
> + struct arm_smccc_1_2_regs res;
> +
> + arm_smccc_1_2_smc(&args, &res);
> +
> + /* SMCCC returns freq in MHz */
> + return (int)(res.a0 * 1000 * 1000);
Why casting to "int" when we can return ulong ?
> +}
> +
> +/* Airoha CPU clk SMCC is always enabled */
> +static int airoha_cpufreq_clk_is_enabled(struct clk_hw *hw)
> +{
> + return true;
> +}
> +
> +static const struct clk_ops airoha_cpufreq_clk_ops = {
> + .recalc_rate = airoha_cpufreq_clk_get,
> + .is_enabled = airoha_cpufreq_clk_is_enabled,
> + .round_rate = airoha_cpufreq_clk_round,
> +};
> +
> +static const char * const airoha_cpufreq_clk_names[] = { "cpu", NULL };
> +
> +/* NOP function to disable OPP from setting clock */
> +static int airoha_cpufreq_config_clks_nop(struct device *dev,
> + struct opp_table *opp_table,
> + struct dev_pm_opp *opp,
> + void *data, bool scaling_down)
> +{
> + return 0;
> +}
I wonder whats better here. Provide this helper or provide a dummy clk-set-rate
at the provider itself ?
--
viresh
Powered by blists - more mailing lists