From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH] clk: clk-gpio: add support for sleeping GPIOs in gpio-gate-clk
Date: Wed, 13 Feb 2019 09:14:22 -0800 [thread overview]
Message-ID: <155007806256.115909.10137511038361789251@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20190211135818.10518-1-thomas.petazzoni@bootlin.com>
Quoting Thomas Petazzoni (2019-02-11 05:58:18)
> The current implementation of gpio-gate-clk enables/disables the clock
> using the GPIO in the ->enable() and ->disable() clock callbacks. This
> requires the GPIO to be configurable in atomic contexts. While it is
> the case for most memory-mapped GPIO controllers, it is not the case
> for GPIO expanders on I2C or SPI.
>
> This commit extends the gpio-gate-clk to check whether the GPIO calls
> require sleeping or not. If sleeping is not required, the current
> implementation based on ->enable()/->disable() is kept. However, if
> sleeping is needed, we instead implement the logic in the ->prepare()
> and ->unprepare() hooks. Thanks to this, a gate clock connected to a
> GPIO on a GPIO expander can be controlled with the existing driver.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Sounds like a good idea!
> diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
> index 6a43ce420492..f5d481713c7d 100644
> --- a/drivers/clk/clk-gpio.c
> +++ b/drivers/clk/clk-gpio.c
> @@ -61,6 +61,35 @@ const struct clk_ops clk_gpio_gate_ops = {
> };
> EXPORT_SYMBOL_GPL(clk_gpio_gate_ops);
>
> +static int clk_sleeping_gpio_gate_prepare(struct clk_hw *hw)
> +{
> + struct clk_gpio *clk = to_clk_gpio(hw);
> +
> + gpiod_set_value_cansleep(clk->gpiod, 1);
> +
> + return 0;
> +}
> +
> +static void clk_sleeping_gpio_gate_unprepare(struct clk_hw *hw)
> +{
> + struct clk_gpio *clk = to_clk_gpio(hw);
> +
> + gpiod_set_value_cansleep(clk->gpiod, 0);
> +}
> +
> +static int clk_sleeping_gpio_gate_is_prepared(struct clk_hw *hw)
> +{
> + struct clk_gpio *clk = to_clk_gpio(hw);
> +
> + return gpiod_get_value_cansleep(clk->gpiod);
> +}
> +
> +const struct clk_ops clk_sleeping_gpio_gate_ops = {
static?
> + .prepare = clk_sleeping_gpio_gate_prepare,
> + .unprepare = clk_sleeping_gpio_gate_unprepare,
> + .is_prepared = clk_sleeping_gpio_gate_is_prepared,
> +};
> +
> /**
> * DOC: basic clock multiplexer which can be controlled with a gpio output
> * Traits of this clock:
next prev parent reply other threads:[~2019-02-13 17:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 13:58 [PATCH] clk: clk-gpio: add support for sleeping GPIOs in gpio-gate-clk Thomas Petazzoni
2019-02-13 17:14 ` Stephen Boyd [this message]
2019-02-21 22:05 ` Stephen Boyd
2019-02-22 8:37 ` Thomas Petazzoni
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=155007806256.115909.10137511038361789251@swboyd.mtv.corp.google.com \
--to=sboyd@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=thomas.petazzoni@bootlin.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).