* [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
@ 2015-08-10 14:50 Michael Allwright
2015-08-11 7:24 ` Jyri Sarha
2015-08-12 12:20 ` Linus Walleij
0 siblings, 2 replies; 7+ messages in thread
From: Michael Allwright @ 2015-08-10 14:50 UTC (permalink / raw)
To: Jyri Sarha, linux-clk
>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
---
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,
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
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
2015-08-11 7:54 ` Michael Allwright
2015-08-12 12:20 ` Linus Walleij
1 sibling, 1 reply; 7+ messages in thread
From: Jyri Sarha @ 2015-08-11 7:24 UTC (permalink / raw)
To: Michael Allwright, linux-clk
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,
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
2015-08-11 7:24 ` Jyri Sarha
@ 2015-08-11 7:54 ` Michael Allwright
2015-08-11 8:03 ` Jyri Sarha
0 siblings, 1 reply; 7+ messages in thread
From: Michael Allwright @ 2015-08-11 7:54 UTC (permalink / raw)
To: Jyri Sarha; +Cc: linux-clk
On 11 August 2015 at 09:24, Jyri Sarha <jsarha@ti.com> wrote:
> 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
Thanks for the reply Jyri, if you have a look over on slide #18 of
http://elinux.org/images/b/b8/Elc2013_Clement.pdf - I think this use
case has been considered and that actually doing the enable work in
prepare could be an acceptable solution. How do/should we get in
contact with the CCF maintainers?
Cheers,
Michael
>> ---
>> 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,
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
2015-08-11 7:54 ` Michael Allwright
@ 2015-08-11 8:03 ` Jyri Sarha
0 siblings, 0 replies; 7+ messages in thread
From: Jyri Sarha @ 2015-08-11 8:03 UTC (permalink / raw)
To: Michael Allwright; +Cc: linux-clk
On 08/11/15 10:54, Michael Allwright wrote:
> On 11 August 2015 at 09:24, Jyri Sarha <jsarha@ti.com> wrote:
>> 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
>
> Thanks for the reply Jyri, if you have a look over on slide #18 of
> http://elinux.org/images/b/b8/Elc2013_Clement.pdf - I think this use
> case has been considered and that actually doing the enable work in
> prepare could be an acceptable solution. How do/should we get in
> contact with the CCF maintainers?
>
> Cheers,
>
> Michael
>
Checking from MAINTAINERS file in linux git:
COMMON CLK FRAMEWORK
M: Michael Turquette <mturquette@baylibre.com>
M: Stephen Boyd <sboyd@codeaurora.org>
L: linux-clk@vger.kernel.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git
S: Maintained
F: drivers/clk/
X: drivers/clk/clkdev.c
F: include/linux/clk-pr*
F: include/linux/clk/
Cheers,
Jyri
>>> ---$ grep -A 3 "COMMON CLK FRAMEWORK" MAINTAINERS
COMMON CLK FRAMEWORK
M: Michael Turquette <mturquette@baylibre.com>
M: Stephen Boyd <sboyd@codeaurora.org>
L: linux-clk@vger.kernel.org
>>> 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,
>>>
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
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
@ 2015-08-12 12:20 ` Linus Walleij
2015-08-12 12:23 ` Linus Walleij
1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2015-08-12 12:20 UTC (permalink / raw)
To: Michael Allwright; +Cc: Jyri Sarha, linux-clk
On Mon, Aug 10, 2015 at 4:50 PM, Michael Allwright
<michael.allwright@upb.de> 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
Wut, the whole commit message in subject?
Did you forget to add a newline XD
> 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);
> }
Naaaaaahh that is a too boring solution.
I would prefer it to be smart like this, keep the original function
names then in clk_register_gpio_gate():
const struct clk_ops clk_gpio_fastpath_gate_ops = {
.enable = clk_gpio_gate_enable,
.disable = clk_gpio_gate_disable,
.is_enabled = clk_gpio_gate_is_enabled,
};
const struct clk_ops clk_gpio_sleep_gate_ops = {
.prepare = clk_gpio_gate_enable,
.unprepare = clk_gpio_gate_disable,
.is_enabled = clk_gpio_gate_is_enabled,
};
....
if (gpiod_cansleep(clk_gpio->gpiod))
init.ops = &clk_gpio_sleep_gate_ops;
else
init.ops = &clk_gpio_fastpath_gate_ops;
If you think it's confusing to have functions ending with
_enbable and _disable in the .prepare/.unprepare callbacks,
rename them ungate/gate or something.
Extra bonus if you can make an additional cleanup patch that rids the
need to have GPIO numbers in this driver and just get GPIO
descriptors directly from DT or whatever instead.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
2015-08-12 12:20 ` Linus Walleij
@ 2015-08-12 12:23 ` Linus Walleij
2015-08-12 14:54 ` Michael Allwright
0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2015-08-12 12:23 UTC (permalink / raw)
To: Michael Allwright; +Cc: Jyri Sarha, linux-clk
On Wed, Aug 12, 2015 at 2:20 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> I would prefer it to be smart like this, keep the original function
> names then in clk_register_gpio_gate():
>
> const struct clk_ops clk_gpio_fastpath_gate_ops = {
> .enable = clk_gpio_gate_enable,
> .disable = clk_gpio_gate_disable,
> .is_enabled = clk_gpio_gate_is_enabled,
> };
>
> const struct clk_ops clk_gpio_sleep_gate_ops = {
> .prepare = clk_gpio_gate_enable,
> .unprepare = clk_gpio_gate_disable,
> .is_enabled = clk_gpio_gate_is_enabled,
> };
>
> ....
> if (gpiod_cansleep(clk_gpio->gpiod))
> init.ops = &clk_gpio_sleep_gate_ops;
> else
> init.ops = &clk_gpio_fastpath_gate_ops;
>
> If you think it's confusing to have functions ending with
> _enbable and _disable in the .prepare/.unprepare callbacks,
> rename them ungate/gate or something.
Or well, since you use the *_cansleep() versions in the
prepare/unprepare calls, maybe you need a double set
of functions anyway. Mea culpa.
But certainly it should register different callbacks
depending on whether the pin may actually sleep
or not, since we have this knowledge inside the GPIO
library.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC] clk-gpio-gate: use prepare/unprepare to do the GPIO work
2015-08-12 12:23 ` Linus Walleij
@ 2015-08-12 14:54 ` Michael Allwright
0 siblings, 0 replies; 7+ messages in thread
From: Michael Allwright @ 2015-08-12 14:54 UTC (permalink / raw)
To: Linus Walleij; +Cc: Jyri Sarha, linux-clk
On 12 August 2015 at 14:23, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Aug 12, 2015 at 2:20 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>
>> I would prefer it to be smart like this, keep the original function
>> names then in clk_register_gpio_gate():
>>
>> const struct clk_ops clk_gpio_fastpath_gate_ops = {
>> .enable = clk_gpio_gate_enable,
>> .disable = clk_gpio_gate_disable,
>> .is_enabled = clk_gpio_gate_is_enabled,
>> };
>>
>> const struct clk_ops clk_gpio_sleep_gate_ops = {
>> .prepare = clk_gpio_gate_enable,
>> .unprepare = clk_gpio_gate_disable,
>> .is_enabled = clk_gpio_gate_is_enabled,
>> };
>>
>> ....
>> if (gpiod_cansleep(clk_gpio->gpiod))
>> init.ops = &clk_gpio_sleep_gate_ops;
>> else
>> init.ops = &clk_gpio_fastpath_gate_ops;
>>
>> If you think it's confusing to have functions ending with
>> _enbable and _disable in the .prepare/.unprepare callbacks,
>> rename them ungate/gate or something.
>
> Or well, since you use the *_cansleep() versions in the
> prepare/unprepare calls, maybe you need a double set
> of functions anyway. Mea culpa.
>
> But certainly it should register different callbacks
> depending on whether the pin may actually sleep
> or not, since we have this knowledge inside the GPIO
> library.
>
> Yours,
> Linus Walleij
That's a nice clean solution - I like it. I was considering using the
can sleep function of the GPIO subsystem to do this on the fly, but
didn't consider using two structs like that.
I need to take a look over at that has been done in linux-next with
clk-gpio and see if this selecting between gpio_set_value and
gpio_set_value_cansleep can be generalised to the gpio mux clock that
has been implemented...
Cheers,
Michael Allwright
PhD Student
Paderborn Institute for Advanced Studies in Computer Science and Engineering
University of Paderborn
Office-number 02-10
Zukunftsmeile 1
33102 Paderborn
Germany
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-12 14:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).