mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
rtc: rs5c372: support eco mode on R2223x
The R2223x can run in an eco mode that lowers its current consumption from the backup supply. Follow the ricoh,eco-mode property from the device tree: enable the mode when the property is set, turn it off when it is not set, as the bit is in CTRL2 register, which is backed by the same supply and keeps its contents across a reset, and no other path in the driver touches it. Signed-off-by: Heiko Schocher <hs@nabladev.com> Link: https://patch.msgid.link/20260825071927.4090460-4-hs@nabladev.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
df8a0f6db2
commit
95e83d98e1
|
|
@ -52,6 +52,7 @@
|
|||
#define RS5C_REG_CTRL2 15
|
||||
# define RS5C372_CTRL2_24 (1 << 5)
|
||||
# define RS5C_CTRL2_XSTP (1 << 4) /* only if !R2x2x */
|
||||
# define R2223x_CTRL2_ECO (1 << 7) /* only if R2223x */
|
||||
# define R2x2x_CTRL2_VDET (1 << 6) /* only if R2x2x */
|
||||
# define R2x2x_CTRL2_XSTP (1 << 5) /* only if R2x2x */
|
||||
# define R2x2x_CTRL2_PON (1 << 4) /* only if R2x2x */
|
||||
|
|
@ -807,6 +808,24 @@ static int rs5c_oscillator_setup(struct rs5c372 *rs5c372)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rs5c372_set_eco_mode(struct rs5c372 *rs5c372, bool eco)
|
||||
{
|
||||
struct i2c_client *client = rs5c372->client;
|
||||
int ctrl2;
|
||||
|
||||
ctrl2 = i2c_smbus_read_byte_data(client, RS5C_ADDR(RS5C_REG_CTRL2));
|
||||
if (ctrl2 < 0)
|
||||
return ctrl2;
|
||||
|
||||
if (eco)
|
||||
ctrl2 |= R2223x_CTRL2_ECO;
|
||||
else
|
||||
ctrl2 &= ~R2223x_CTRL2_ECO;
|
||||
|
||||
return i2c_smbus_write_byte_data(client, RS5C_ADDR(RS5C_REG_CTRL2),
|
||||
ctrl2);
|
||||
}
|
||||
|
||||
static int rs5c372_probe(struct i2c_client *client)
|
||||
{
|
||||
int err = 0;
|
||||
|
|
@ -903,6 +922,15 @@ static int rs5c372_probe(struct i2c_client *client)
|
|||
rs5c372->time24 ? "24hr" : "am/pm"
|
||||
);
|
||||
|
||||
if (rs5c372->type == rtc_r2223x) {
|
||||
bool eco = device_property_read_bool(&client->dev,
|
||||
"ricoh,eco-mode");
|
||||
|
||||
err = rs5c372_set_eco_mode(rs5c372, eco);
|
||||
if (err < 0)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* REVISIT use client->irq to register alarm irq ... */
|
||||
rs5c372->rtc = devm_rtc_device_register(&client->dev,
|
||||
rs5c372_driver.driver.name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user