]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
rtc: pcf8563: save battery power
authorJan Kardell <jan.kardell@telliq.com>
Wed, 10 Dec 2014 23:53:43 +0000 (15:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:15 +0000 (17:41 -0800)
According to Haoyu hym8563 datasheet this saves som power.  Might be
importat to battery life.  And maybe it works for the NXP part as well.

Signed-off-by: Jan Kardell <jan.kardell@telliq.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Vincent Donnefort <vdonnefort@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-pcf8563.c

index ce6a11bc0fd79e9bbe99c49caee6eefebdb6df02..1e14f609db34cca31be1d5b0e3eb652e99f17692 100644 (file)
 
 #define PCF8563_REG_CLKO       0x0D /* clock out */
 #define PCF8563_REG_TMRC       0x0E /* timer control */
+#define PCF8563_TMRC_ENABLE    BIT(7)
+#define PCF8563_TMRC_4096      0
+#define PCF8563_TMRC_64                1
+#define PCF8563_TMRC_1         2
+#define PCF8563_TMRC_1_60      3
+#define PCF8563_TMRC_MASK      3
+
 #define PCF8563_REG_TMR                0x0F /* timer */
 
 #define PCF8563_SC_LV          0x80 /* low voltage */
@@ -406,6 +413,7 @@ static int pcf8563_probe(struct i2c_client *client,
 {
        struct pcf8563 *pcf8563;
        int err;
+       unsigned char buf;
 
        dev_dbg(&client->dev, "%s\n", __func__);
 
@@ -423,6 +431,14 @@ static int pcf8563_probe(struct i2c_client *client,
        pcf8563->client = client;
        device_set_wakeup_capable(&client->dev, 1);
 
+       /* Set timer to lowest frequency to save power (ref Haoyu datasheet) */
+       buf = PCF8563_TMRC_1_60;
+       err = pcf8563_write_block_data(client, PCF8563_REG_TMRC, 1, &buf);
+       if (err < 0) {
+               dev_err(&client->dev, "%s: write error\n", __func__);
+               return err;
+       }
+
        pcf8563->rtc = devm_rtc_device_register(&client->dev,
                                pcf8563_driver.driver.name,
                                &pcf8563_rtc_ops, THIS_MODULE);