diff mbox series

[RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode

Message ID AM8P190MB09806335DF5E7967BB8EA9E4F52C9@AM8P190MB0980.EURP190.PROD.OUTLOOK.COM
State New
Headers show
Series [RFC] rtc: rv3032: Add devicetree parameter to enable level switching mode | expand

Commit Message

Hager Stefan May 18, 2021, 8:46 a.m. UTC
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>

---

Comments

Nobuhiro Iwamatsu May 24, 2021, 4:52 a.m. UTC | #1
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
diff mbox series

Patch

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;