Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: shawn.lin@rock-chips.com, linux-rockchip@lists.infradead.org,
	devicetree@vger.kernel.org, FUKAUMI Naoki <naoki@radxa.com>,
	Marco Schirrmeister <mschirrmeister@gmail.com>,
	John Clark <inindev@gmail.com>, Tianling Shen <cnsztl@gmail.com>,
	Detlev Casanova <detlev.casanova@collabora.com>
Subject: Re: [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled
Date: Wed, 14 Jan 2026 09:34:47 +0800	[thread overview]
Message-ID: <1d37cfd0-9f7d-4d76-89ed-798c0a74e737@rock-chips.com> (raw)
In-Reply-To: <1906413.BzM5BlMlMQ@diego>

在 2026/01/14 星期三 1:43, Heiko Stübner 写道:
> Hi Shawn,
> 
> Am Dienstag, 13. Januar 2026, 02:18:24 Mitteleuropäische Normalzeit schrieb Shawn Lin:
>> Currently, only the first matched node will be handled. This leads
>> to jtag switching broken for RK3576, as rk3576-sys-grf is found before
>> rk3576-ioc-grf. Change the code to scan all the possible nodes to fix
>> the problem.
>>
>> Fixes: e1aaecacfa13 ("soc: rockchip: grf: Add rk3576 default GRF values")
>> Cc: Detlev Casanova <detlev.casanova@collabora.com>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>>
>> Changes in v2:
>> - use for_each_matching_node_and_match(Heiko)
>>
>>   drivers/soc/rockchip/grf.c | 54 +++++++++++++++++++++++-----------------------
>>   1 file changed, 27 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
>> index 8974d1c..9b36390 100644
>> --- a/drivers/soc/rockchip/grf.c
>> +++ b/drivers/soc/rockchip/grf.c
>> @@ -217,34 +217,34 @@ static int __init rockchip_grf_init(void)
>>   	struct regmap *grf;
>>   	int ret, i;
>>   
>> -	np = of_find_matching_node_and_match(NULL, rockchip_grf_dt_match,
>> -					     &match);
>> -	if (!np)
>> -		return -ENODEV;
>> -	if (!match || !match->data) {
>> -		pr_err("%s: missing grf data\n", __func__);
>> +	for_each_matching_node_and_match(np, rockchip_grf_dt_match, &match) {
>> +		if (!of_device_is_available(np))
>> +			continue;
>> +		if (!match || !match->data) {
>> +			pr_err("%s: missing grf data\n", __func__);
>> +			of_node_put(np);
>> +			return -EINVAL;
>> +		}
>> +
>> +		grf_info = match->data;
>> +
>> +		grf = syscon_node_to_regmap(np);
>>   		of_node_put(np);
> 
> This of_node_put can go away I think.
> 
> for_each_matching_node_and_match iterates over the nodes via
> 	of_find_matching_node_and_match(dn, matches, match)   [0]
> 
> and of_find_matching_node_and_match() will of_node_put() the from node [1]
> 
> 

Oops, will fix.

Thanks.

> Heiko
> 
> [0] https://elixir.bootlin.com/linux/v6.18.4/source/include/linux/of.h#L1469
> [1] https://elixir.bootlin.com/linux/v6.18.4/source/drivers/of/base.c#L1147
> 
>> -		return -EINVAL;
>> -	}
>> -
>> -	grf_info = match->data;
>> -
>> -	grf = syscon_node_to_regmap(np);
>> -	of_node_put(np);
>> -	if (IS_ERR(grf)) {
>> -		pr_err("%s: could not get grf syscon\n", __func__);
>> -		return PTR_ERR(grf);
>> -	}
>> -
>> -	for (i = 0; i < grf_info->num_values; i++) {
>> -		const struct rockchip_grf_value *val = &grf_info->values[i];
>> -
>> -		pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__,
>> -			val->desc, val->reg, val->val);
>> -		ret = regmap_write(grf, val->reg, val->val);
>> -		if (ret < 0)
>> -			pr_err("%s: write to %#6x failed with %d\n",
>> -			       __func__, val->reg, ret);
>> +		if (IS_ERR(grf)) {
>> +			pr_err("%s: could not get grf syscon\n", __func__);
>> +			return PTR_ERR(grf);
>> +		}
>> +
>> +		for (i = 0; i < grf_info->num_values; i++) {
>> +			const struct rockchip_grf_value *val = &grf_info->values[i];
>> +
>> +			pr_debug("%s: adjusting %s in %#6x to %#10x\n", __func__,
>> +				val->desc, val->reg, val->val);
>> +			ret = regmap_write(grf, val->reg, val->val);
>> +			if (ret < 0)
>> +				pr_err("%s: write to %#6x failed with %d\n",
>> +					__func__, val->reg, ret);
>> +		}
>>   	}
>>   
>>   	return 0;
>>
> 
> 
> 
> 
> 
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2026-01-14  1:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13  1:18 [PATCH v2 0/3] Fix sd card support for RK3576 Shawn Lin
2026-01-13  1:18 ` [PATCH v2 1/3] soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition Shawn Lin
2026-01-13  1:18 ` [PATCH v2 2/3] soc: rockchip: grf: Support multiple grf to be handled Shawn Lin
2026-01-13 17:43   ` Heiko Stübner
2026-01-14  1:34     ` Shawn Lin [this message]
2026-01-13  1:18 ` [PATCH v2 3/3] arm64: dts: rockchip: Add cd-gpios for sdmmc of RK3576 EVB1 Shawn Lin
2026-01-13 20:35 ` [PATCH v2 0/3] Fix sd card support for RK3576 Marco Schirrmeister
2026-01-14  2:01   ` Shawn Lin

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=1d37cfd0-9f7d-4d76-89ed-798c0a74e737@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=cnsztl@gmail.com \
    --cc=detlev.casanova@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=inindev@gmail.com \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mschirrmeister@gmail.com \
    --cc=naoki@radxa.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