From: Philipp Zabel <p.zabel@pengutronix.de>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Sean Anderson <sean.anderson@seco.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Banajit Goswami <bgoswami@quicinc.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Subject: Re: [PATCH 2/4] reset: add GPIO-based reset controller
Date: Fri, 05 Jan 2024 15:31:19 +0100 [thread overview]
Message-ID: <c15f1a71b01f7d3985ee8d3b42b6e1ae0dddd235.camel@pengutronix.de> (raw)
In-Reply-To: <d2d17b94-6f29-423d-a7e0-e24513a8e59f@linaro.org>
On Do, 2024-01-04 at 20:08 +0100, Krzysztof Kozlowski wrote:
> On 04/01/2024 17:30, Sean Anderson wrote:
> > On 1/4/24 11:08, Krzysztof Kozlowski wrote:
> > > On 04/01/2024 17:04, Sean Anderson wrote:
> > > > On 1/4/24 03:57, Krzysztof Kozlowski wrote:
> > > > > The driver (reset consumer) knows when it is safe or not. You must
> > > > > implement proper reset handling in your driver.
> > > >
> > > > The driver has no idea whether it is safe or not. It just calls
> > > > reset_assert/deassert at the appropriate time, and the reset
> > > > framework/controller is supposed to coordinate things so e.g. the device
> > > > doesn't get reset multiple times as multiple drivers all probe.
> > >
> > > Sorry, then I don't get what you refer to. The driver calls deassert
> > > when it is safe for it to do it, so the driver *knows*. Now, you claim
> > > that driver does not know that... core also does not know, so no one knows.
> >
> > Yes! That is the problem with this design. Someone has to coordinate the
> > reset, and it can't be the driver. But the core also doesn't have enough
> > information. So no one can do it.
>
> The point is that the driver coordinates.
Currently the reset controller API supports two types of shared resets.
I hope distinguishing the two types and illustrating them helps the
discussion:
1) For devices that just require the reset to be deasserted while they
are active, and don't care otherwise, there is the clk-like behavior
described in [1].
requested reset signal via reset_control_deassert/assert():
device A: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
device B: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
actual reset signal to both devices:
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
In this scenario, there should be no delays in the reset controller
driver. reset_control_deassert() may return as soon as the physical
reset signal is deasserted [2]. Any post-deassert delays required by
the devices are handled in the device drivers, and they can be
different for each device. The devices have to be able to cope with a
(much) longer post-deassert delay than expected (e.g. device B in this
case). It is assumed that the reset signal is initially asserted.
The reset-gpio patchset supports this.
2) The second type is for devices that require a single reset pulse for
initialization, at any time before they become active. This is
described in [3].
requested reset signal via reset_control_reset/rearm():
device A: ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽
device B: ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽
actual reset signal to both devices:
⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽
Here the reset controller needs to know the delay between assertion and
deassertion - either baked into the hardware or as a delay call in the
.reset callback.
This is not supported by the reset-gpio patchset. It could be
implemented via a delay property in the device tree that would have to
be the same for all devices sharing the reset line, and by adding the
.reset callback to the reset controller driver. The only issue is that
the initial state of the reset line should be deasserted, and at
reset_control_get() time, when the reset-gpio controller is
instantiated, it is not yet known which type the driver will use.
Sharing a reset line between devices of different type is not
supported. Unfortunately, this will only fail at
reset_control_deassert() / reset_control_reset() time when the second
device tries to use the reset control in a different way than the
first.
[1] https://docs.kernel.org/driver-api/reset.html#assertion-and-deassertion
[2] https://docs.kernel.org/driver-api/reset.html#c.reset_control_deassert
[3] https://docs.kernel.org/driver-api/reset.html#triggering
> > For example, say we want to share a reset GPIO between two devices. Each
> > device has the following constraints:
> >
> > device post-assert delay post-deassert delay
> > ====== ================= ===================
> > A 500us 1ms
> > B 1ms 300us
>
> And now imagine that these values are incompatible between them, so
> using 1ms on device A is wrong - too long.
>
> This is just not doable. You invented some imaginary case to prove that
> hardware is broken.
>
> Now, if we are back to realistic cases - use just the longest reset time.
Right. This all only works if no device has an upper bound to the
allowed delays on the shared reset line.
I interpret the post-assert delay to be the desired length of the reset
pulse between the rising edge and the falling edge in case 2) above,
since in case 1) a post-assert delay is not useful.
The post-deassert delays are not supposed to be handled by the reset
controller drivers at all, except where they are needed to reach the
deasserted state on the reset line. Reset drivers that do have post-
deassert delays in the .deassert callback might be bending the rules a
bit for convenience.
regards
Philipp
next prev parent reply other threads:[~2024-01-05 14:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-22 15:01 [PATCH 0/4] reset: gpio: ASoC: shared GPIO resets Krzysztof Kozlowski
2023-12-22 15:01 ` [PATCH 1/4] reset: instantiate reset GPIO controller for shared reset-gpios Krzysztof Kozlowski
2023-12-22 17:31 ` Bartosz Golaszewski
2023-12-27 12:35 ` Krzysztof Kozlowski
2023-12-27 19:13 ` Bartosz Golaszewski
2023-12-22 15:01 ` [PATCH 2/4] reset: add GPIO-based reset controller Krzysztof Kozlowski
2023-12-22 15:08 ` Krzysztof Kozlowski
2023-12-28 16:05 ` Sean Anderson
2024-01-04 8:57 ` Krzysztof Kozlowski
2024-01-04 16:04 ` Sean Anderson
2024-01-04 16:08 ` Krzysztof Kozlowski
2024-01-04 16:30 ` Sean Anderson
2024-01-04 19:08 ` Krzysztof Kozlowski
2024-01-05 14:31 ` Philipp Zabel [this message]
2024-01-09 9:41 ` Krzysztof Kozlowski
2024-01-09 15:51 ` Sean Anderson
2024-01-05 14:33 ` Mark Brown
2024-01-06 15:32 ` Krzysztof Kozlowski
2024-01-04 16:11 ` Krzysztof Kozlowski
2023-12-22 15:01 ` [PATCH 3/4] ASoC: dt-bindings: qcom,wsa8840: Add reset-gpios for shared line Krzysztof Kozlowski
2023-12-22 15:16 ` Krzysztof Kozlowski
2023-12-22 16:18 ` Rob Herring
2023-12-22 15:01 ` [PATCH 4/4] ASoC: codecs: wsa884x: Allow sharing reset GPIO Krzysztof Kozlowski
2023-12-22 15:22 ` Krzysztof Kozlowski
2023-12-22 15:09 ` [PATCH 0/4] reset: gpio: ASoC: shared GPIO resets Krzysztof Kozlowski
2023-12-22 15:18 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2024-02-29 17:26 [PATCH 2/4] reset: add GPIO-based reset controller Tim Harvey
2024-02-29 17:45 ` Krzysztof Kozlowski
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=c15f1a71b01f7d3985ee8d3b42b6e1ae0dddd235.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=alsa-devel@alsa-project.org \
--cc=andersson@kernel.org \
--cc=bgoswami@quicinc.com \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=sean.anderson@seco.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).