linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Howard <phil@pimoroni.co.uk>
To: linux-rtc@vger.kernel.org
Subject: rtc: rv3028: Add backup switchover mode support
Date: Wed, 10 Apr 2019 11:26:58 +0100	[thread overview]
Message-ID: <CAGk-eV5UPsJGvmovyz5maEHuEDN3374hzxSptsXxghu3KRO6QQ@mail.gmail.com> (raw)

Adds support for the backup switchover mode register in the rv3028
RTC. This allows the clock to automatically switch over to a backup
power supply when the main power supply is lost.

From 7ee04005288f0543debe46ed918b77374ad63adf Mon Sep 17 00:00:00 2001
From: Phil Howard <phil@gadgetoid.com>
Date: Fri, 29 Mar 2019 10:53:14 +0000
Subject: [PATCH 1/3] rtc: rv3028: Add backup switchover mode support

Signed-off-by: Phil Howard <phil@pimoroni.com>
---
 drivers/rtc/rtc-rv3028.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/rtc/rtc-rv3028.c b/drivers/rtc/rtc-rv3028.c
index d04c2d4816555..b69d8e6408aae 100644
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -74,6 +74,7 @@

 #define RV3028_BACKUP_TCE        BIT(5)
 #define RV3028_BACKUP_TCR_MASK        GENMASK(1,0)
+#define RV3028_BACKUP_BSM_MASK        0x0C

 #define OFFSET_STEP_PPT            953674

@@ -601,6 +602,7 @@ static int rv3028_probe(struct i2c_client *client)
     struct rv3028_data *rv3028;
     int ret, status;
     u32 ohms;
+    u8 bsm;
     struct nvmem_config nvmem_cfg = {
         .name = "rv3028_nvram",
         .word_size = 1,
@@ -671,6 +673,21 @@ static int rv3028_probe(struct i2c_client *client)
     if (ret)
         return ret;

+    /* setup backup switchover mode */
+    if (!device_property_read_u8(&client->dev, "backup-switchover-mode",
+                     &bsm))  {
+        if (bsm <= 3) {
+            ret = regmap_update_bits(rv3028->regmap, RV3028_BACKUP,
+                RV3028_BACKUP_BSM_MASK,
+                (bsm & 0x03) << 2);
+
+            if (ret)
+                return ret;
+        } else {
+            dev_warn(&client->dev, "invalid backup switchover mode value\n");
+        }
+    }
+
     /* setup trickle charger */
     if (!device_property_read_u32(&client->dev, "trickle-resistor-ohms",
                       &ohms)) {

From ae9228b10d864368b934839156b6d9fa58fb5724 Mon Sep 17 00:00:00 2001
From: Phil Howard <phil@gadgetoid.com>
Date: Fri, 29 Mar 2019 10:57:07 +0000
Subject: [PATCH 2/3] dt-bindings: rv3028 backup switchover support

Signed-off-by: Phil Howard <phil@pimoroni.com>
---
 Documentation/devicetree/bindings/rtc/rtc.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/rtc/rtc.txt
b/Documentation/devicetree/bindings/rtc/rtc.txt
index 3e6a215e7304b..33fcad8754ec2 100644
--- a/Documentation/devicetree/bindings/rtc/rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc.txt
@@ -26,6 +26,7 @@ below.
 - trickle-diode-disable :   Do not use internal trickle charger diode Should be
                             given if internal trickle charger diode should be
                             disabled
+- backup-switchover-mode :  Configure RTC backup power supply switch behaviour
 - wakeup-source :           Enables wake up of host system on alarm
 - quartz-load-femtofarads : The capacitive load of the quartz(x-tal),
                             expressed in femto Farad (fF).



-- 
--
Philip Howard
Maker, Pimoroni Ltd.

phil@pimoroni.com
http://pimoroni.com
@pimoroni

             reply	other threads:[~2019-04-10 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10 10:26 Phil Howard [this message]
2019-06-17 13:45 ` rtc: rv3028: Add backup switchover mode support Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGk-eV5UPsJGvmovyz5maEHuEDN3374hzxSptsXxghu3KRO6QQ@mail.gmail.com \
    --to=phil@pimoroni.co.uk \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).