linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
To: "Heiko Stübner" <heiko@sntech.de>,
	"Michael Riesch" <michael.riesch@wolfvision.net>,
	"Quentin Schulz" <foss+kernel@0leil.net>
Cc: linus.walleij@linaro.org, linux-gpio@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/1] pinctrl: rockchip: add support for per-pinmux io-domain dependency
Date: Thu, 11 Aug 2022 12:21:40 +0200	[thread overview]
Message-ID: <c7946a7e-d823-d43d-a595-00e8f10829e8@theobroma-systems.com> (raw)
In-Reply-To: <3152231.AJdgDx1Vlc@diego>

Hi Heiko,

On 8/11/22 11:26, Heiko Stübner wrote:
[...]
>>>> In order to make this dependency transparent to the consumer of those
>>>> pins and not add Rockchip-specific code to third party drivers (a camera
>>>> driver in our case), it is hooked into the pinctrl driver which is
>>>> Rockchip-specific obviously.
>>>
>>> This approach seems reasonable. But just for my understanding: Does this
>>> mean we need to edit e.g. rk3568-pinctrl.dtsi, iterate over all entries,
>>> and add rockchip,iodomains = <&corresponding_io_domain>;?
>>>
>>
>> That would have been my hope yes, but it is not possible for one of the
>> boards we have based on PX30.
>>
>> All pinmux listed in the px30.dtsi today belong to an IO domain. This
>> includes the I2C pins for the bus on which the PMIC is.
>> Adding the rockchip,io-domains on each pinctrl will create the following
>> circular dependency:
>> pinctrl depends on the io-domain device which depends on
>> regulators from a PMIC on i2c which requires the i2c bus pins to be
>> muxed from the pinctrl
>>
>> Since the PMIC powering the IO domains can virtually be on any I2C bus,
>> we cannot add it to the main SoC.dtsi, it'll need to be added per board
>> sadly.
> 
> though you could also add the main props to the dtsi and use a per-board
> /delete-property/ to free up the pmic-i2c, same result but less duplicate
> dt additions and less clutter.
> 

That is also a possibility, yes. However, this means that it'll make the 
bring-up of a new board slightly more complex since it'll just not boot 
until you have this /delete-property/ in your board dts. Remember that 
the current implementation basically forbids *all* pinmux (well the ones 
with rockchip,io-domains.. but that would be all of them in most cases) 
to be used until io-domains is probed, which very likely involves boot 
media such as eMMC which require some pinmux to be done. (I had this 
issue on my device already, so not hypothetical).

[...]
>>>> @@ -2684,6 +2693,16 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
>>>>    	if (!size || size % 4)
>>>>    		return dev_err_probe(dev, -EINVAL, "wrong pins number or pins and configs should be by 4\n");
>>>>    
>>>> +	node = of_parse_phandle(np, "rockchip,io-domains", 0);
>>>> +	if (node) {
>>>> +		grp->io_domain = of_find_device_by_node(node);
>>>> +		of_node_put(node);
>>>> +		if (!grp->io_domain) {
>>>> +			dev_err(info->dev, "couldn't find IO domain device\n");
>>>> +			return -ENODEV;
>>>
>>> Again just for my understanding: The property is optional in order to
>>> provide compatibility with older device trees, right?
>>>
>>
>> Of course (at least that's the intent). If it is omitted,
>> of_parse_phandle will return NULL and we'll not be executing this part
>> of the code. However, if one phandle is provided and the device does not
>> actually exist (IIUC, the phandle points to a DT-valid node but the
>> device pointed at by the phandle is either disabled or its driver is not
>> built). That being said, I don't know how this would work with an IO
>> domain driver built as a module. That would be a pretty dumb thing to do
>> though.
> 
> I think this should work even with io-domain "disabled" or as module
> when slightly modified.
> 
> I.e. for disabled nodes, no kernel-device should be created
> (grp->io_domain will be NULL) and for a module the device itself is created
> when the dt is parsed (of_populate...) and will just not have probed yet.
> 
> Together with the comment farther above of having the io-domain link always
> present we should get rid of the error condition though :-) .
> 

It is not possible to have a rockchip,io-domains entry for all pinctrl, 
because at least a few needs to be removed, the ones related to the 
regulators used by the io-domain devices. But I guess you were talking 
about the check on grp->io_domain pointer?

> 
> 
> Hmm, while going through this one thought was, do we want more verbosity
> in the dt for this?
> 
> I.e. with the current approach we'll have
> 
> &io_domains {
> 	status = "okay";
> 
> 	audio-supply = <&pp1800_audio>;
> 	bt656-supply = <&pp1800_ap_io>;
> 	gpio1830-supply = <&pp3000_ap>;
> 	sdmmc-supply = <&ppvar_sd_card_io>;
> };
> 
> and pinctrl entries linking to the core <&io_domains> node. This might bite
> us down the road again in some form.
> 
> Something like doing an optional updated binding like:
> 
> &io_domains {
> 	status = "okay";
> 
> 	audio-domain {
> 		domain-supply = <&pp1800_audio>;
> 	};
> 	bt656-domain {
> 		domain-supply = <&pp1800_ap_io>;
> 	};
> 	gpio1830-domain {
> 		domain-supply = <&pp3000_ap>;
> 	};
> 	sdmmc-domain {
> 		domain-supply = <&ppvar_sd_card_io>;
> 	};
> };
> 
>         pcie {
>                 pcie_ep_gpio: pci-ep-gpio {
>                         rockchip,pins =
>                                 <4 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
>                         rockchip,io-domains = <&gpio1830_domain>;
>                 };
>         };
> 
> 
> I.e. linking the pin-set to a definition of its actual io-domain, instead
> of only the general io-domain node. Somewhat similar to power-domains.
> 

I like this (well, not the "modifying existing bindings" part though). 
This could allow io-domain driver to be more of a bus kind and "probe" 
each subnode individually, allowing to break out of circular 
dependencies. E.g., I could have some supplies provided by fixed 
non-controllable always-on regulators, and some by some controllable 
PMIC. Though this wouldn't have helped for our design since the PMIC is 
providing the power to the IO domains pins of the i2c bus on which the 
PMIC is (so whatever we do, the HW representation will always include a 
theoretical circular loop). This would maybe allow us to mitigate the 
issue I talked about earlier with the need of removing some 
rockchip,io-domains to break this circular dependency.

> The code itself could be the same as now (except needing to get the parent
> of the linked node for the io-domains), but would leave us the option of
> modifying code behaviour without touching the binding if needed down the
> road.
> 

Would I need to support forward compatibility of the DT? i.e. having 
rockchip,io-domains DT property work with the io_domains phandle AND 
sdmmc_domain phandle?

Cheers,
Quentin

  reply	other threads:[~2022-08-11 10:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02  9:52 [RFC PATCH 0/1] Making Rockchip IO domains dependency from other devices explicit Quentin Schulz
2022-08-02  9:52 ` [RFC PATCH 1/1] pinctrl: rockchip: add support for per-pinmux io-domain dependency Quentin Schulz
2022-08-11  7:52   ` Michael Riesch
2022-08-11  8:45     ` Quentin Schulz
2022-08-11  9:26       ` Heiko Stübner
2022-08-11 10:21         ` Quentin Schulz [this message]
2023-02-15 10:23   ` Sascha Hauer
2023-02-21 12:14     ` Quentin Schulz
2023-02-22 12:05       ` Sascha Hauer
2022-08-22  8:38 ` [RFC PATCH 0/1] Making Rockchip IO domains dependency from other devices explicit Linus Walleij
2022-08-22 23:43   ` Heiko Stübner

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=c7946a7e-d823-d43d-a595-00e8f10829e8@theobroma-systems.com \
    --to=quentin.schulz@theobroma-systems.com \
    --cc=foss+kernel@0leil.net \
    --cc=heiko@sntech.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=michael.riesch@wolfvision.net \
    /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;
as well as URLs for NNTP newsgroup(s).