diff options
Diffstat (limited to 'drivers/clk/clk-gpio.c')
-rw-r--r-- | drivers/clk/clk-gpio.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c index 25eed3e0251f..c2f07f0d077c 100644 --- a/drivers/clk/clk-gpio.c +++ b/drivers/clk/clk-gpio.c | |||
@@ -58,6 +58,35 @@ const struct clk_ops clk_gpio_gate_ops = { | |||
58 | }; | 58 | }; |
59 | EXPORT_SYMBOL_GPL(clk_gpio_gate_ops); | 59 | EXPORT_SYMBOL_GPL(clk_gpio_gate_ops); |
60 | 60 | ||
61 | static int clk_sleeping_gpio_gate_prepare(struct clk_hw *hw) | ||
62 | { | ||
63 | struct clk_gpio *clk = to_clk_gpio(hw); | ||
64 | |||
65 | gpiod_set_value_cansleep(clk->gpiod, 1); | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static void clk_sleeping_gpio_gate_unprepare(struct clk_hw *hw) | ||
71 | { | ||
72 | struct clk_gpio *clk = to_clk_gpio(hw); | ||
73 | |||
74 | gpiod_set_value_cansleep(clk->gpiod, 0); | ||
75 | } | ||
76 | |||
77 | static int clk_sleeping_gpio_gate_is_prepared(struct clk_hw *hw) | ||
78 | { | ||
79 | struct clk_gpio *clk = to_clk_gpio(hw); | ||
80 | |||
81 | return gpiod_get_value_cansleep(clk->gpiod); | ||
82 | } | ||
83 | |||
84 | static const struct clk_ops clk_sleeping_gpio_gate_ops = { | ||
85 | .prepare = clk_sleeping_gpio_gate_prepare, | ||
86 | .unprepare = clk_sleeping_gpio_gate_unprepare, | ||
87 | .is_prepared = clk_sleeping_gpio_gate_is_prepared, | ||
88 | }; | ||
89 | |||
61 | /** | 90 | /** |
62 | * DOC: basic clock multiplexer which can be controlled with a gpio output | 91 | * DOC: basic clock multiplexer which can be controlled with a gpio output |
63 | * Traits of this clock: | 92 | * Traits of this clock: |
@@ -144,10 +173,16 @@ struct clk_hw *clk_hw_register_gpio_gate(struct device *dev, const char *name, | |||
144 | const char *parent_name, struct gpio_desc *gpiod, | 173 | const char *parent_name, struct gpio_desc *gpiod, |
145 | unsigned long flags) | 174 | unsigned long flags) |
146 | { | 175 | { |
176 | const struct clk_ops *ops; | ||
177 | |||
178 | if (gpiod_cansleep(gpiod)) | ||
179 | ops = &clk_sleeping_gpio_gate_ops; | ||
180 | else | ||
181 | ops = &clk_gpio_gate_ops; | ||
182 | |||
147 | return clk_register_gpio(dev, name, | 183 | return clk_register_gpio(dev, name, |
148 | (parent_name ? &parent_name : NULL), | 184 | (parent_name ? &parent_name : NULL), |
149 | (parent_name ? 1 : 0), gpiod, flags, | 185 | (parent_name ? 1 : 0), gpiod, flags, ops); |
150 | &clk_gpio_gate_ops); | ||
151 | } | 186 | } |
152 | EXPORT_SYMBOL_GPL(clk_hw_register_gpio_gate); | 187 | EXPORT_SYMBOL_GPL(clk_hw_register_gpio_gate); |
153 | 188 | ||