From: Jyri Sarha <jsarha@ti.com>
To: Michael Allwright <michael.allwright@upb.de>,
<linux-clk@vger.kernel.org>
Subject: Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
Date: Tue, 11 Aug 2015 10:24:57 +0300 [thread overview]
Message-ID: <55C9A349.8080807@ti.com> (raw)
In-Reply-To: <CALcgO_49YPGoCOv23Vz9vbnq9+AN3WqvYyg9_TtvsQcz8ia2Hw@mail.gmail.com>
On 08/10/15 17:50, Michael Allwright wrote:
> From 19512587a6799c3cb96dc3f95d989b7c778a6f8c Mon Sep 17 00:00:00 2001
> From: Michael Allwright <allsey87@gmail.com>
> Date: Mon, 10 Aug 2015 16:44:05 +0200
> Subject: [PATCH] clk-gpio-gate: use prepare/unprepare ops to control clock
> enabling via gpiod_set_value_cansleep. This allows for GPIO expanders on I2C
> and SPI buses
>
Hi,
I sounds a bit weird if a clock gets turned on already at the prepare
state, but I can see that this is the simples solution to your problem.
Anyway, at least this should not be the default behavior. If this is
really widely needed then adding a flag to device tree binding for
changing the behavior would sound more feasible, but then again I am no
common clock framework expert. Better to turn to CCF maintainers for that.
BTW, if you propose some clk-gpio-gate changes to mainline, you should
know that the clk-gpio-gate.c was replaced with clk-gpio.c in
linux-next. The new file contains both gpio-gate and gpio-mux
functionality. I think this is the patch set was applied:
http://www.spinics.net/lists/linux-clk/msg01280.html
Best regards,
Jyri
> ---
> drivers/clk/clk-gpio-gate.c | 31 ++++++++++++++++++++++++-------
> 1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/clk/clk-gpio-gate.c b/drivers/clk/clk-gpio-gate.c
> index a71cabe..432edd9 100644
> --- a/drivers/clk/clk-gpio-gate.c
> +++ b/drivers/clk/clk-gpio-gate.c
> @@ -22,8 +22,8 @@
> * DOC: basic gpio gated clock which can be enabled and disabled
> * with gpio output
> * Traits of this clock:
> - * prepare - clk_(un)prepare only ensures parent is (un)prepared
> - * enable - clk_enable and clk_disable are functional & control gpio
> + * prepare - clk_(un)prepare ensures parent is (un)prepared and control gpio
> + * enable - clk_enable and clk_disable only ensures parent is enabled/disabled
> * rate - inherits rate from parent. No clk_set_rate support
> * parent - fixed parent. No clk_set_parent support
> */
> @@ -32,28 +32,45 @@
>
> static int clk_gpio_gate_enable(struct clk_hw *hw)
> {
> + return 0;
> +}
> +
> +static void clk_gpio_gate_disable(struct clk_hw *hw)
> +{
> +}
> +
> +static int clk_gpio_gate_is_enabled(struct clk_hw *hw)
> +{
> + return 0;
> +}
> +
> +static int clk_gpio_gate_prepare(struct clk_hw *hw)
> +{
> struct clk_gpio *clk = to_clk_gpio(hw);
>
> - gpiod_set_value(clk->gpiod, 1);
> + gpiod_set_value_cansleep(clk->gpiod, 1);
>
> return 0;
> }
>
> -static void clk_gpio_gate_disable(struct clk_hw *hw)
> +static void clk_gpio_gate_unprepare(struct clk_hw *hw)
> {
> struct clk_gpio *clk = to_clk_gpio(hw);
>
> - gpiod_set_value(clk->gpiod, 0);
> + gpiod_set_value_cansleep(clk->gpiod, 0);
> }
>
> -static int clk_gpio_gate_is_enabled(struct clk_hw *hw)
> +static int clk_gpio_gate_is_prepared(struct clk_hw *hw)
> {
> struct clk_gpio *clk = to_clk_gpio(hw);
>
> - return gpiod_get_value(clk->gpiod);
> + return gpiod_get_value_cansleep(clk->gpiod);
> }
>
> const struct clk_ops clk_gpio_gate_ops = {
> + .prepare = clk_gpio_gate_prepare,
> + .unprepare = clk_gpio_gate_unprepare,
> + .is_prepared = clk_gpio_gate_is_prepared,
> .enable = clk_gpio_gate_enable,
> .disable = clk_gpio_gate_disable,
> .is_enabled = clk_gpio_gate_is_enabled,
>
next prev parent reply other threads:[~2015-08-11 7:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 14:50 [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work Michael Allwright
2015-08-11 7:24 ` Jyri Sarha [this message]
2015-08-11 7:54 ` Michael Allwright
2015-08-11 8:03 ` Jyri Sarha
2015-08-12 12:20 ` Linus Walleij
2015-08-12 12:23 ` Linus Walleij
2015-08-12 14:54 ` Michael Allwright
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=55C9A349.8080807@ti.com \
--to=jsarha@ti.com \
--cc=linux-clk@vger.kernel.org \
--cc=michael.allwright@upb.de \
/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).