rtc: rv3028: Add backup switchover mode support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
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@xxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxx>
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@xxxxxxxxxxxx>
---
 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@xxxxxxxxxxxx
http://pimoroni.com
@pimoroni



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux