msm8916-openwrt/target/linux/bcm27xx/patches-6.6/950-0496-rtc-rv3028-Add-backup-switchover-mode-support.patch
Álvaro Fernández Rojas 8c405cdccc bcm27xx: add 6.6 kernel patches
The patches were generated from the RPi repo with the following command:
git format-patch v6.6.34..rpi-6.1.y

Some patches needed rebasing and, as usual, the applied and reverted, wireless
drivers, Github workflows, READMEs and defconfigs patches were removed.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2024-06-18 18:52:49 +02:00

59 lines
1.8 KiB
Diff

From 9113b57d7b8ef97bd25d3b8482cfd870d70f0545 Mon Sep 17 00:00:00 2001
From: Phil Howard <phil@gadgetoid.com>
Date: Fri, 29 Mar 2019 10:53:14 +0000
Subject: [PATCH 0496/1085] rtc: rv3028: Add backup switchover mode support
Signed-off-by: Phil Howard <phil@pimoroni.com>
---
drivers/rtc/rtc-rv3028.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
--- a/drivers/rtc/rtc-rv3028.c
+++ b/drivers/rtc/rtc-rv3028.c
@@ -858,16 +858,17 @@ static const struct regmap_config regmap
static u8 rv3028_set_trickle_charger(struct rv3028_data *rv3028,
struct i2c_client *client)
{
- int ret, val_old, val;
+ int ret, val_old, val, val_mask;
u32 ohms, chargeable;
+ u32 bsm;
ret = regmap_read(rv3028->regmap, RV3028_BACKUP, &val_old);
if (ret < 0)
return ret;
/* mask out only trickle charger bits */
- val_old = val_old & (RV3028_BACKUP_TCE | RV3028_BACKUP_TCR_MASK);
- val = val_old;
+ val_mask = RV3028_BACKUP_TCE | RV3028_BACKUP_TCR_MASK;
+ val = val_old & val_mask;
/* setup trickle charger */
if (!device_property_read_u32(&client->dev, "trickle-resistor-ohms",
@@ -902,10 +903,21 @@ static u8 rv3028_set_trickle_charger(str
}
}
+ /* setup backup switchover mode */
+ if (!device_property_read_u32(&client->dev,
+ "backup-switchover-mode",
+ &bsm)) {
+ if (bsm <= 3) {
+ val_mask |= RV3028_BACKUP_BSM;
+ val |= (u8)(bsm << 2);
+ } else {
+ dev_warn(&client->dev, "invalid backup switchover mode value\n");
+ }
+ }
+
/* only update EEPROM if changes are necessary */
- if (val_old != val) {
- ret = rv3028_update_cfg(rv3028, RV3028_BACKUP, RV3028_BACKUP_TCE |
- RV3028_BACKUP_TCR_MASK, val);
+ if ((val_old & val_mask) != val) {
+ ret = rv3028_update_cfg(rv3028, RV3028_BACKUP, val_mask, val);
if (ret)
return ret;
}