linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).