rtc: ds1307: Enable battery backup on RX8130
PATCH 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.
--- drivers/rtc/rtc-ds1307.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/rtc/rtc-ds1307.c +7 -0
@@ -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 0x0f +#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, chip->offset +RX8130_REG_CONTROL1 , +RX8130_REG_CONTROL1_INIEN ); +break ;default :break ; }
Signature · 1 line
2.20.1
Quoted 26 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.
Signed-off-by Marek Vasut <[email protected]>Cc Arnaud Ebalard <[email protected]>Cc Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-ds1307.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/rtc/rtc-ds1307.c +2
-0@@ -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 0x0f +#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);
drivers/rtc/rtc-ds1307.c static int ds1307_probe(struct i2c_client *client, · line 1762
Quoted 10 lines
drivers/rtc/rtc-ds1307.c +5
-0}break ; +case rx_8130: +/* make sure that the backup battery is enabled */ +regmap_write (ds1307->regmap, chip->offset +RX8130_REG_CONTROL1 , +RX8130_REG_CONTROL1_INIEN ); +break ;default :break ; }
Bump ?
Hi Marek,
Quoted 15 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.
Signed-off-by Marek Vasut <[email protected]>Cc Arnaud Ebalard <[email protected]>Cc Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-ds1307.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/rtc/rtc-ds1307.c +0
-0
drivers/rtc/rtc-ds1307.c enum ds_type { · line 124
Quoted 4 lines
drivers/rtc/rtc-ds1307.c +1
-0@@ -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 0x0f
I think it is surprising that RX8130_REG_CONTROL0 is defined absolute and RX8130_REG_CONTROL1 must be used with chip offset. Having this defined consistently would be nice.
drivers/rtc/rtc-ds1307.c static int ds1307_probe(struct i2c_client *client, · line 1759
Quoted 13 lines
drivers/rtc/rtc-ds1307.c +6
-0+#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, chip->offset +RX8130_REG_CONTROL1 , +RX8130_REG_CONTROL1_INIEN ); +break ;
Quick note: if a rechargeable battery or supercap is used the CHGEN bit must be set also.
Regards,
Bastian
Quoted 5 lines
drivers/rtc/rtc-ds1307.c +0
-0default :break ; }
Signature · 5 lines
Pengutronix e.K. Industrial Linux Solutions http://www.pengutronix.de/ Peiner Str. 6-8, 31137 Hildesheim, Germany Amtsgericht Hildesheim, HRA 2686
Quoted 1 line · Bastian Krause
Hi Marek,
Hi,
Quoted 11 lines · Marek Vasut
Quoted 10 lines
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.
Signed-off-by Marek Vasut <[email protected]>Cc Arnaud Ebalard <[email protected]>Cc Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-ds1307.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 13 lines
drivers/rtc/rtc-ds1307.c enum ds_type { · line 124
Quoted 9 lines
drivers/rtc/rtc-ds1307.c +1
-0@@ -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 0x0fI think it is surprising that
RX8130_REG_CONTROL0is defined absolute andRX8130_REG_CONTROL1must be used with chip offset. Having this defined consistently would be nice.
It's because this old patch was rebased from before the regmap changes were even in.
Quoted 16 lines
drivers/rtc/rtc-ds1307.c static int ds1307_probe(struct i2c_client *client, · line 1759
Quoted 13 lines
drivers/rtc/rtc-ds1307.c +6
-0+#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, chip->offset +RX8130_REG_CONTROL1 , +RX8130_REG_CONTROL1_INIEN ); +break ;Quick note: if a rechargeable battery or supercap is used the CHGEN bit must be set also.
By rechargable battery, you mean coin cell one ?
Signature · 6 lines
Best regards, Marek Vasut DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-56 Email: [email protected]
Quoted 46 lines · Marek Vasut
Quoted 11 lines · Bastian Krause
Quoted 10 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.
Signed-off-by Marek Vasut <[email protected]>Cc Arnaud Ebalard <[email protected]>Cc Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-ds1307.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 13 lines
drivers/rtc/rtc-ds1307.c enum ds_type { · line 124
Quoted 9 lines
drivers/rtc/rtc-ds1307.c +1
-0@@ -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 0x0fI think it is surprising that
RX8130_REG_CONTROL0is defined absolute andRX8130_REG_CONTROL1must be used with chip offset. Having this defined consistently would be nice.It's because this old patch was rebased from before the regmap changes were even in.
Quoted 16 lines
drivers/rtc/rtc-ds1307.c static int ds1307_probe(struct i2c_client *client, · line 1759
Quoted 13 lines
drivers/rtc/rtc-ds1307.c +6
-0+#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, chip->offset +RX8130_REG_CONTROL1 , +RX8130_REG_CONTROL1_INIEN ); +break ;Quick note: if a rechargeable battery or supercap is used the CHGEN bit must be set also.
Quoted 1 line
By rechargable battery, you mean coin cell one ?
Yes, some rechargeable lithium coin/button cell. Or in my case a ELNA 0.2F 3.3V supercap.
Regards,
Bastian
Signature · 5 lines
Pengutronix e.K. Industrial Linux Solutions http://www.pengutronix.de/ Peiner Str. 6-8, 31137 Hildesheim, Germany Amtsgericht Hildesheim, HRA 2686