Blob Blame History Raw
From: Biwen Li <biwen.li@nxp.com>
Date: Wed, 2 Dec 2020 11:18:39 +0800
Subject: rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)

Git-commit: 2843d565dd78fd9117b9a18567cf68ac37a5dd1e
Patch-mainline: v5.12-rc1
References: bsc#1185233

Properly set flag WD_CD for rtc chips(pcf2129, pca2129)

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201202031840.15582-1-biwen.li@oss.nxp.com
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
 drivers/rtc/rtc-pcf2127.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -564,7 +564,7 @@ static const struct attribute_group pcf2
 };
 
 static int pcf2127_probe(struct device *dev, struct regmap *regmap,
-			 int alarm_irq, const char *name, bool has_nvmem)
+			 int alarm_irq, const char *name, bool is_pcf2127)
 {
 	struct pcf2127 *pcf2127;
 	int ret = 0;
@@ -606,7 +606,7 @@ static int pcf2127_probe(struct device *
 		pcf2127->rtc->ops = &pcf2127_rtc_alrm_ops;
 	}
 
-	if (has_nvmem) {
+	if (is_pcf2127) {
 		struct nvmem_config nvmem_cfg = {
 			.priv = pcf2127,
 			.reg_read = pcf2127_nvmem_read,
@@ -641,6 +641,10 @@ static int pcf2127_probe(struct device *
 	 * Watchdog timer enabled and reset pin /RST activated when timed out.
 	 * Select 1Hz clock source for watchdog timer.
 	 * Note: Countdown timer disabled and not available.
+	 * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD
+	 * of register watchdg_tim_ctl. The bit[6] is labeled
+	 * as T. Bits labeled as T must always be written with
+	 * logic 0.
 	 */
 	ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
 				 PCF2127_BIT_WD_CTL_CD1 |
@@ -648,7 +652,7 @@ static int pcf2127_probe(struct device *
 				 PCF2127_BIT_WD_CTL_TF1 |
 				 PCF2127_BIT_WD_CTL_TF0,
 				 PCF2127_BIT_WD_CTL_CD1 |
-				 PCF2127_BIT_WD_CTL_CD0 |
+				 (is_pcf2127 ? PCF2127_BIT_WD_CTL_CD0 : 0) |
 				 PCF2127_BIT_WD_CTL_TF1);
 	if (ret) {
 		dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__);