mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Dhruva Gole <d-gole@ti.com>, Nishanth Menon <nm@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tero Kristo <kristo@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>, Bryan Brattlof <bb@ti.com>
Subject: Re: [PATCH v6 6/6] cpufreq: ti-cpufreq: Update efuse/rev offsets in AM62 family
Date: Wed, 25 Sep 2024 11:12:52 -0500	[thread overview]
Message-ID: <809b9eaa-a539-4309-95a3-c9fc9c39288b@ti.com> (raw)
In-Reply-To: <20240925-ti-cpufreq-fixes-v5-v6-6-46f41a903e01@ti.com>

On 9/25/24 9:54 AM, Dhruva Gole wrote:
> With the Silicon revision being taken directly from socinfo, there's no
> longer any need for reading any SOC register for revision from this driver.
> Hence, we do not require any rev_offset for AM62 family of devices.
> The efuse offset should be 0x0 for AM625 as well, as the syscon
> register being used from DT refers to the efuse_offset directly.
> 
> However, to maintain the backward compatibility with old devicetree, also
> add condition to handle the case where we have the wrong offset and add
> the older efuse_offset value there such that we don't end up reading the
> wrong register offset.
> 
> Signed-off-by: Dhruva Gole <d-gole@ti.com>
> ---
>   drivers/cpufreq/ti-cpufreq.c | 23 +++++++++++++++++------
>   1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
> index ba621ce1cdda694c98867422dbb7f10c0df2afef..8a97b95b4c44a76b12cab76ddc0f9a5b8ae73f84 100644
> --- a/drivers/cpufreq/ti-cpufreq.c
> +++ b/drivers/cpufreq/ti-cpufreq.c
> @@ -313,10 +313,9 @@ static const struct soc_device_attribute k3_cpufreq_soc[] = {
>   
>   static struct ti_cpufreq_soc_data am625_soc_data = {
>   	.efuse_xlate = am625_efuse_xlate,
> -	.efuse_offset = 0x0018,
> +	.efuse_offset = 0x0,
>   	.efuse_mask = 0x07c0,
>   	.efuse_shift = 0x6,
> -	.rev_offset = 0x0014,
>   	.multi_regulator = false,
>   };
>   
> @@ -325,7 +324,6 @@ static struct ti_cpufreq_soc_data am62a7_soc_data = {
>   	.efuse_offset = 0x0,
>   	.efuse_mask = 0x07c0,
>   	.efuse_shift = 0x6,
> -	.rev_offset = 0x0014,
>   	.multi_regulator = false,
>   };
>   
> @@ -334,7 +332,6 @@ static struct ti_cpufreq_soc_data am62p5_soc_data = {
>   	.efuse_offset = 0x0,
>   	.efuse_mask = 0x07c0,
>   	.efuse_shift = 0x6,
> -	.rev_offset = 0x0014,
>   	.multi_regulator = false,
>   };
>   
> @@ -349,11 +346,25 @@ static int ti_cpufreq_get_efuse(struct ti_cpufreq_data *opp_data,
>   				u32 *efuse_value)
>   {
>   	struct device *dev = opp_data->cpu_dev;
> +	struct device_node *np = opp_data->opp_node;
>   	u32 efuse;
>   	int ret;
>   
> -	ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset,
> -			  &efuse);
> +	/*
> +	 * The following check is used as a way to check if this is an older devicetree

"check is used as a way to check" sound redundant, maybe just:

This checks for old AM625 Devicetrees where the syscon was a phandle
to the wkup_conf parent, this required a hard-coded offset to
the efuse register.

> +	 * being used where the entire wkup_conf node was marked as "syscon",
> +	 * "simple-mfd".
> +	 * Since this bug only affects AM625, make sure it enters this condition
> +	 * only for that SoC.
> +	 */
> +	if (of_device_is_compatible(np, "simple-mfd") &&
> +	    of_device_is_compatible(np, "ti,am625")) {

Kinda hacky, but keeping backwards compat often is hacky..

Does `of_device_is_compatible(np, "ti,am625")` actually work here? I'm assuming you
tested with an old DT to make sure this path ever got taken. Maybe put a warning
here that an old DT is in use and the user should update at some point.

Andrew

> +		ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset + 0x0018,
> +				  &efuse);
> +	} else {
> +		ret = regmap_read(opp_data->syscon, opp_data->soc_data->efuse_offset,
> +				  &efuse);
> +	}
>   	if (opp_data->soc_data->quirks & TI_QUIRK_SYSCON_MAY_BE_MISSING && ret == -EIO) {
>   		/* not a syscon register! */
>   		void __iomem *regs = ioremap(OMAP3_SYSCON_BASE +
> 

      reply	other threads:[~2024-09-25 16:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:54 [PATCH v6 0/6] ti: k3-am62{a,p}x-sk: add opp frequencies Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 1/6] arm64: dts: ti: k3-am62a: " Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 2/6] arm64: dts: ti: k3-am62a7-sk: add 1.4ghz opp entry Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 3/6] arm64: dts: ti: k3-am62p: add opp frequencies Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 4/6] arm64: dts: ti: k3-am62p5-sk: add 1.4ghz opp entry Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 5/6] arm64: dts: ti: k3-am62: use opp_efuse_table for opp-table syscon Dhruva Gole
2024-09-25 14:54 ` [PATCH v6 6/6] cpufreq: ti-cpufreq: Update efuse/rev offsets in AM62 family Dhruva Gole
2024-09-25 16:12   ` Andrew Davis [this message]

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=809b9eaa-a539-4309-95a3-c9fc9c39288b@ti.com \
    --to=afd@ti.com \
    --cc=bb@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=d-gole@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kristo@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=viresh.kumar@linaro.org \
    /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

all inboxes | Powered by JetHome®