Skip to contentSkip to conversation

rtc: ds1307: Enable battery backup on RX8130

PATCH In review Marek Vasut 3 participants 8 messages Sep 5, 2019 – Dec 16, 2019 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rtc: ds1307: Enable battery backup on RX8130

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>

---
V2: Drop the custom offset, let regmap handle that

---
 drivers/rtc/rtc-ds1307.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/rtc/rtc-ds1307.c +7 -0
index 1f7e8aefc1eb..f2d1e59478c2 100644
@@ -121,6 +121,8 @@ enum ds_type {
 #define RX8130_REG_FLAG_AF		BIT(3)
 #define RX8130_REG_CONTROL0		0x1e
 #define RX8130_REG_CONTROL0_AIE		BIT(3)
+#define RX8130_REG_CONTROL1		0x1f
+#define RX8130_REG_CONTROL1_INIEN	BIT(4)
 
 #define MCP794XX_REG_CONTROL		0x07
 #	define MCP794XX_BIT_ALM0_EN	0x10
@@ -1750,6 +1752,11 @@ static int ds1307_probe(struct i2c_client *client,
 				     DS1307_REG_HOUR << 4 | 0x08, hour);
 		}
 		break;
+	case rx_8130:
+		/* make sure that the backup battery is enabled */
+		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1,
+			     RX8130_REG_CONTROL1_INIEN);
+		break;
 	default:
 		break;
 	}
Signature · 1 line
2.23.0.rc1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>

Regards,
Bastian

Quoted 32 lines

---
V2: Drop the custom offset, let regmap handle that

---
 drivers/rtc/rtc-ds1307.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/rtc/rtc-ds1307.c +7 -0
index 1f7e8aefc1eb..f2d1e59478c2 100644
@@ -121,6 +121,8 @@ enum ds_type {
 #define RX8130_REG_FLAG_AF		BIT(3)
 #define RX8130_REG_CONTROL0		0x1e
 #define RX8130_REG_CONTROL0_AIE		BIT(3)
+#define RX8130_REG_CONTROL1		0x1f
+#define RX8130_REG_CONTROL1_INIEN	BIT(4)
 
 #define MCP794XX_REG_CONTROL		0x07
 #	define MCP794XX_BIT_ALM0_EN	0x10
@@ -1750,6 +1752,11 @@ static int ds1307_probe(struct i2c_client *client,
 				     DS1307_REG_HOUR << 4 | 0x08, hour);
 		}
 		break;
+	case rx_8130:
+		/* make sure that the backup battery is enabled */
+		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1,
+			     RX8130_REG_CONTROL1_INIEN);
+		break;
 	default:
 		break;
 	}
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#2 lore raw
Quoted 11 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>

I recall there was some comment about setting BIT(5) as well, RX8130_REG_CONTROL1_CHGEN , can you check that ?

Quoted 35 lines
Quoted 33 lines

---
V2: Drop the custom offset, let regmap handle that

---
 drivers/rtc/rtc-ds1307.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/rtc/rtc-ds1307.c +7 -0
index 1f7e8aefc1eb..f2d1e59478c2 100644
@@ -121,6 +121,8 @@ enum ds_type {
 #define RX8130_REG_FLAG_AF		BIT(3)
 #define RX8130_REG_CONTROL0		0x1e
 #define RX8130_REG_CONTROL0_AIE		BIT(3)
+#define RX8130_REG_CONTROL1		0x1f
+#define RX8130_REG_CONTROL1_INIEN	BIT(4)
 
 #define MCP794XX_REG_CONTROL		0x07
 #	define MCP794XX_BIT_ALM0_EN	0x10
@@ -1750,6 +1752,11 @@ static int ds1307_probe(struct i2c_client *client,
 				     DS1307_REG_HOUR << 4 | 0x08, hour);
 		}
 		break;
+	case rx_8130:
+		/* make sure that the backup battery is enabled */
+		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1,
+			     RX8130_REG_CONTROL1_INIEN);
+		break;
 	default:
 		break;
 	}
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>
Quoted 5 lines
Quoted 2 lines

I recall there was some comment about setting BIT(5) as well, RX8130_REG_CONTROL1_CHGEN , can you check that ?

RX8130_REG_CONTROL1_CHGEN decides whether the battery or the supercap should be charged or not. I think this patch is okay as is. I'll send a follow-up patch which will set RX8130_REG_CONTROL1_CHGEN depending on a new dt-binding "epson,backup-battery-chargeable" once this one is applied.

Regards,
Bastian

Quoted 38 lines
Quoted 36 lines
Quoted 34 lines

---
V2: Drop the custom offset, let regmap handle that

---
 drivers/rtc/rtc-ds1307.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/rtc/rtc-ds1307.c +7 -0
index 1f7e8aefc1eb..f2d1e59478c2 100644
@@ -121,6 +121,8 @@ enum ds_type {
 #define RX8130_REG_FLAG_AF		BIT(3)
 #define RX8130_REG_CONTROL0		0x1e
 #define RX8130_REG_CONTROL0_AIE		BIT(3)
+#define RX8130_REG_CONTROL1		0x1f
+#define RX8130_REG_CONTROL1_INIEN	BIT(4)
 
 #define MCP794XX_REG_CONTROL		0x07
 #	define MCP794XX_BIT_ALM0_EN	0x10
@@ -1750,6 +1752,11 @@ static int ds1307_probe(struct i2c_client *client,
 				     DS1307_REG_HOUR << 4 | 0x08, hour);
 		}
 		break;
+	case rx_8130:
+		/* make sure that the backup battery is enabled */
+		regmap_write(ds1307->regmap, RX8130_REG_CONTROL1,
+			     RX8130_REG_CONTROL1_INIEN);
+		break;
 	default:
 		break;
 	}
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw
Quoted 15 lines · Bastian Krause
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>
Quoted 7 lines
Quoted 2 lines

I recall there was some comment about setting BIT(5) as well, RX8130_REG_CONTROL1_CHGEN , can you check that ?

RX8130_REG_CONTROL1_CHGEN decides whether the battery or the supercap should be charged or not. I think this patch is okay as is. I'll send a follow-up patch which will set RX8130_REG_CONTROL1_CHGEN depending on a new dt-binding "epson,backup-battery-chargeable" once this one is applied.

Even better, thanks.

#5 lore raw
In reply to Bastian Krause
Quoted 15 lines · Bastian Krause
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>
Quoted 8 lines
Quoted 2 lines

I recall there was some comment about setting BIT(5) as well, RX8130_REG_CONTROL1_CHGEN , can you check that ?

RX8130_REG_CONTROL1_CHGEN decides whether the battery or the supercap should be charged or not. I think this patch is okay as is. I'll send a follow-up patch which will set RX8130_REG_CONTROL1_CHGEN depending on a new dt-binding "epson,backup-battery-chargeable" once this one is applied.

You need to have a generic RTC property, either reuse trickle-diode-disable (I know the name is a bit unfortunate but that is waht we have) or have a new property stating that the auxiliary voltage is chargeable. using battery in the name is probably not wise because this may as well be a supercap.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw
Quoted 25 lines · Alexandre Belloni
Quoted 15 lines · Bastian Krause
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>
Quoted 8 lines
Quoted 2 lines

I recall there was some comment about setting BIT(5) as well, RX8130_REG_CONTROL1_CHGEN , can you check that ?

RX8130_REG_CONTROL1_CHGEN decides whether the battery or the supercap should be charged or not. I think this patch is okay as is. I'll send a follow-up patch which will set RX8130_REG_CONTROL1_CHGEN depending on a new dt-binding "epson,backup-battery-chargeable" once this one is applied.

Quoted 5 lines

You need to have a generic RTC property, either reuse trickle-diode-disable (I know the name is a bit unfortunate but that is waht we have) or have a new property stating that the auxiliary voltage is chargeable. using battery in the name is probably not wise because this may as well be a supercap.

Alright, thanks for the suggestion. I will incorporate into the patch.

Regards,
Bastian

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#7 lore raw
In reply to Bastian Krause
Quoted 10 lines · Bastian Krause
Quoted 7 lines · Marek Vasut

The battery backup can be disabled on this RTC, e.g. if populated right out of production. Force the battery backup bit on to enable it.

Cc Arnaud Ebalard <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Bastian Krause <[email protected]>

Gentle ping.

Regards,
Bastian

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |