lede/target/linux/bcm27xx/patches-6.12/950-0339-rtc-rv3028-Add-backup-switchover-mode-support.patch
=?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= d81c03f05e bcm27xx: add 6.12 patches from RPi repo
These patches were generated from:
https://github.com/raspberrypi/linux/commits/rpi-6.12.y
With the following command:
git format-patch -N v6.12.27..HEAD
(HEAD -> 8d3206ee456a5ecdf9ddbfd8e5e231e4f0cd716e)

Exceptions:
- (def)configs patches
- github workflows patches
- applied & reverted patches
- readme patches
- wireless patches

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-06-20 17:01:06 +08:00

59 lines
1.8 KiB
Diff

From a771bffa599190ec01475c7d63e458f29ad1e905 Mon Sep 17 00:00:00 2001
From: Phil Howard <phil@gadgetoid.com>
Date: Fri, 29 Mar 2019 10:53:14 +0000
Subject: [PATCH] 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;
}