linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode
@ 2021-05-18  8:46 Hager Stefan
  2021-05-24  4:52 ` Nobuhiro Iwamatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Hager Stefan @ 2021-05-18  8:46 UTC (permalink / raw)
  To: Alexandre Belloni, Alessandro Zummo; +Cc: linux-rtc

When the Micro Crystal RV3032 rtc is used with a primary coin-cell for power backup, the backup switching mode LSM (level switching mode) should be used according to the technical support from the manufacturer of this device.

Currently there is no way to set this mode by the driver.

Thererfore, i suggest to introduce an additional parameter for the devicetree to enable this backup switchover mode
and to extend the probe function to look for that parameter and activate the LSM.

Is this an appropriate solution? Does it need improvements?

Signed-off-by: Stefan Hager <s.hager@abatec.at>

---
diff --git a/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml b/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
index a2c55303810d..b948e19e358b 100644
--- a/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
+++ b/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
@@ -37,6 +37,10 @@ properties:
       - 3000
       - 4400
 
+  backup-switchover-mode-level:
+    description:
+      Use level switching mode for backup switchover mode
+
 required:
   - compatible
   - reg
diff --git a/drivers/rtc/rtc-rv3032.c b/drivers/rtc/rtc-rv3032.c
index d63102d5cb1e..a28a3e0172d0 100644
--- a/drivers/rtc/rtc-rv3032.c
+++ b/drivers/rtc/rtc-rv3032.c
@@ -881,6 +881,12 @@ static int rv3032_probe(struct i2c_client *client)
        if (ret)
                return ret;
 
+       if (device_property_read_bool(&client->dev, "backup-switchover-mode-level")) {
+               ret = regmap_update_bits(rv3032->regmap, RV3032_PMU, RV3032_PMU_BSM, (RV3032_PMU_BSM_LSM) << 4);
+               if (ret)
+                       return ret;
+       }
+
        rv3032_trickle_charger_setup(&client->dev, rv3032);
 
        rv3032->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode
  2021-05-18  8:46 [RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode Hager Stefan
@ 2021-05-24  4:52 ` Nobuhiro Iwamatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Nobuhiro Iwamatsu @ 2021-05-24  4:52 UTC (permalink / raw)
  To: Hager Stefan; +Cc: Alexandre Belloni, Alessandro Zummo, linux-rtc

Hi,

2021年5月18日(火) 17:46 Hager Stefan <s.hager@abatec.at>:
>
> When the Micro Crystal RV3032 rtc is used with a primary coin-cell for power backup, the backup switching mode LSM (level switching mode) should be used according to the technical support from the manufacturer of this device.
>
> Currently there is no way to set this mode by the driver.
>
> Thererfore, i suggest to introduce an additional parameter for the devicetree to enable this backup switchover mode
> and to extend the probe function to look for that parameter and activate the LSM.
>
> Is this an appropriate solution? Does it need improvements?
>
> Signed-off-by: Stefan Hager <s.hager@abatec.at>
>
> ---
> diff --git a/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml b/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
> index a2c55303810d..b948e19e358b 100644
> --- a/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
> +++ b/Documentation/devicetree/bindings/rtc/microcrystal,rv3032.yaml
> @@ -37,6 +37,10 @@ properties:
>        - 3000
>        - 4400
>
> +  backup-switchover-mode-level:
> +    description:
> +      Use level switching mode for backup switchover mode

Please add 'type: boolean'.

> +
>  required:
>    - compatible
>    - reg
> diff --git a/drivers/rtc/rtc-rv3032.c b/drivers/rtc/rtc-rv3032.c
> index d63102d5cb1e..a28a3e0172d0 100644
> --- a/drivers/rtc/rtc-rv3032.c
> +++ b/drivers/rtc/rtc-rv3032.c
> @@ -881,6 +881,12 @@ static int rv3032_probe(struct i2c_client *client)
>         if (ret)
>                 return ret;
>
> +       if (device_property_read_bool(&client->dev, "backup-switchover-mode-level")) {
> +               ret = regmap_update_bits(rv3032->regmap, RV3032_PMU, RV3032_PMU_BSM, (RV3032_PMU_BSM_LSM) << 4);
> +               if (ret)
> +                       return ret;
> +       }
> +
>         rv3032_trickle_charger_setup(&client->dev, rv3032);
>
>         rv3032->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
>

Best regards,
  Nobuhiro
-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org}
   GPG ID: 40AD1FA6

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-24  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  8:46 [RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode Hager Stefan
2021-05-24  4:52 ` Nobuhiro Iwamatsu

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).