# \[PATCH\] rtc: pcf8563: Do not disable clk out by default

- From: Volodymyr Bendiuga \<hidden\>
- Date: 2016-12-09 15:03:49 
- List: linux-devicetree
- Page: https://ratatoskr.run/linux-devicetree/2016/12/8131983
- Thread: https://ratatoskr.run/linux-devicetree/2016/12/8131983/t.md

```text
From: Mattias Walström <redacted>

Commit a39a6405d5f949bc651694028a disables CLKOUT of
the rtc after power-up to improve power consumption.
This is very useful, but some designs do require to
have the rtc on all the time, otherwise devices will
be bricked. Therefore this patch is a compromise that
works for both cases, where the default case is when
CLKOUT is on. If one wants to disable the CLKOUT,
clkout-allow-disable can be added to devicetree's rtc node.

Signed-off-by: Volodymyr Bendiuga <redacted>
---
 Documentation/devicetree/bindings/rtc/pcf8563.txt |  1 +
 drivers/rtc/rtc-pcf8563.c                         | 11 +++--------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/pcf8563.txt b/Documentation/devicetree/bindings/rtc/pcf8563.txt
index 086c998..0b06a36 100644
--- a/Documentation/devicetree/bindings/rtc/pcf8563.txt
+++ b/Documentation/devicetree/bindings/rtc/pcf8563.txt
@@ -7,6 +7,7 @@ see: Documentation/devicetree/bindings/i2c/trivial-admin-guide/devices.rst
 
 Optional property:
 - #clock-cells: Should be 0.
+- clkout-allow-disable: Allow the CLKOUT to be disabled if not used.
 - clock-output-names:
   overwrite the default clock name "pcf8563-clkout"
 
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 1227cea..1489ee9 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -519,18 +519,13 @@ static struct clk *pcf8563_clkout_register_clk(struct pcf8563 *pcf8563)
 	struct device_node *node = client->dev.of_node;
 	struct clk *clk;
 	struct clk_init_data init;
-	int ret;
-	unsigned char buf;
-
-	/* disable the clkout output */
-	buf = 0;
-	ret = pcf8563_write_block_data(client, PCF8563_REG_CLKO, 1, &buf);
-	if (ret < 0)
-		return ERR_PTR(ret);
 
 	init.name = "pcf8563-clkout";
 	init.ops = &pcf8563_clkout_ops;
+
+	/* disable the clkout output only if it is allowed in devicetree */
 	init.flags = 0;
+	init.flags |= !of_property_read_bool(node, "clkout-allow-disable") ? CLK_IGNORE_UNUSED : 0;
 	init.parent_names = NULL;
 	init.num_parents = 0;
 	pcf8563->clkout_hw.init = &init;
-- 
2.7.4

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
```
