* [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
@ 2020-12-02 3:18 Biwen Li
2020-12-02 3:18 ` [v2 2/2] rtc: pcf2127: clear these flags TSF1, TSF2 before enabling interrupt generation Biwen Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Biwen Li @ 2020-12-02 3:18 UTC (permalink / raw)
To: leoyang.li, alexandre.belloni, anson.huang, aisheng.dong
Cc: linux-kernel, jiafei.pan, linux-rtc, Biwen Li
From: Biwen Li <biwen.li@nxp.com>
Properly set flag WD_CD for rtc chips(pcf2129, pca2129)
Signed-off-by: Biwen Li <biwen.li@nxp.com>
---
Change in v2:
- set flag WD_CD according to compatible
drivers/rtc/rtc-pcf2127.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 03c9cb6b0b6e..a5418b657c50 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -620,6 +620,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
* 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 |
@@ -627,7 +631,8 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
PCF2127_BIT_WD_CTL_TF1 |
PCF2127_BIT_WD_CTL_TF0,
PCF2127_BIT_WD_CTL_CD1 |
- PCF2127_BIT_WD_CTL_CD0 |
+ (device_property_match_string(dev, "compatible", "nxp,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__);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [v2 2/2] rtc: pcf2127: clear these flags TSF1, TSF2 before enabling interrupt generation
2020-12-02 3:18 [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
@ 2020-12-02 3:18 ` Biwen Li
2020-12-23 7:06 ` [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
2021-02-13 21:40 ` (subset) " Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Biwen Li @ 2020-12-02 3:18 UTC (permalink / raw)
To: leoyang.li, alexandre.belloni, anson.huang, aisheng.dong
Cc: linux-kernel, jiafei.pan, linux-rtc, Biwen Li
From: Biwen Li <biwen.li@nxp.com>
Clear these flags TSF1, TSF2 before enabling interrupt generation
Signed-off-by: Biwen Li <biwen.li@nxp.com>
---
Change in v2:
- clear flag TSF2
drivers/rtc/rtc-pcf2127.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index a5418b657c50..7e3fc70ac5f9 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -659,7 +659,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
/*
* Enable timestamp function and store timestamp of first trigger
- * event until TSF1 and TFS2 interrupt flags are cleared.
+ * event until TSF1 and TSF2 interrupt flags are cleared.
*/
ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_TS_CTRL,
PCF2127_BIT_TS_CTRL_TSOFF |
@@ -671,6 +671,31 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
return ret;
}
+ /*
+ * Clear TSF1 field of ctrl1 register and TSF2
+ * field of ctrl2 register to clear interrupt
+ * before enabling interrupt generation when
+ * timestamp flag set. Unless the flag TSF1 won't
+ * be cleared and get the interrupt storm.
+ */
+ ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
+ PCF2127_BIT_CTRL1_TSF1,
+ 0);
+ if (ret) {
+ dev_err(dev, "%s: control and status register 1 (ctrl1) failed, ret = 0x%x\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL2,
+ PCF2127_BIT_CTRL2_TSF2,
+ 0);
+ if (ret) {
+ dev_err(dev, "%s: control and status register 2 (ctrl2) failed, ret = 0x%x\n",
+ __func__, ret);
+ return ret;
+ }
+
/*
* Enable interrupt generation when TSF1 or TSF2 timestamp flags
* are set. Interrupt signal is an open-drain output and can be
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
2020-12-02 3:18 [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
2020-12-02 3:18 ` [v2 2/2] rtc: pcf2127: clear these flags TSF1, TSF2 before enabling interrupt generation Biwen Li
@ 2020-12-23 7:06 ` Biwen Li
2021-02-13 21:40 ` (subset) " Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Biwen Li @ 2020-12-23 7:06 UTC (permalink / raw)
To: Biwen Li (OSS), Leo Li, alexandre.belloni, Anson Huang, Aisheng Dong
Cc: linux-kernel, Jiafei Pan, linux-rtc
Hi Alexandre,
Any comments?
Regards,
Biwen Li
> -----Original Message-----
> From: Biwen Li <biwen.li@oss.nxp.com>
> Sent: 2020年12月2日 11:19
> To: Leo Li <leoyang.li@nxp.com>; alexandre.belloni@bootlin.com; Anson
> Huang <anson.huang@nxp.com>; Aisheng Dong <aisheng.dong@nxp.com>
> Cc: linux-kernel@vger.kernel.org; Jiafei Pan <jiafei.pan@nxp.com>;
> linux-rtc@vger.kernel.org; Biwen Li <biwen.li@nxp.com>
> Subject: [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129,
> pca2129)
>
> From: Biwen Li <biwen.li@nxp.com>
>
> Properly set flag WD_CD for rtc chips(pcf2129, pca2129)
>
> Signed-off-by: Biwen Li <biwen.li@nxp.com>
> ---
> Change in v2:
> - set flag WD_CD according to compatible
>
> drivers/rtc/rtc-pcf2127.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c index
> 03c9cb6b0b6e..a5418b657c50 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -620,6 +620,10 @@ static int pcf2127_probe(struct device *dev, struct
> regmap *regmap,
> * 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 |
> @@ -627,7 +631,8 @@ static int pcf2127_probe(struct device *dev, struct
> regmap *regmap,
> PCF2127_BIT_WD_CTL_TF1 |
> PCF2127_BIT_WD_CTL_TF0,
> PCF2127_BIT_WD_CTL_CD1 |
> - PCF2127_BIT_WD_CTL_CD0 |
> + (device_property_match_string(dev, "compatible",
> "nxp,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__);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: (subset) [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
2020-12-02 3:18 [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
2020-12-02 3:18 ` [v2 2/2] rtc: pcf2127: clear these flags TSF1, TSF2 before enabling interrupt generation Biwen Li
2020-12-23 7:06 ` [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
@ 2021-02-13 21:40 ` Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2021-02-13 21:40 UTC (permalink / raw)
To: aisheng.dong, leoyang.li, anson.huang, Biwen Li
Cc: Alexandre Belloni, linux-kernel, linux-rtc, jiafei.pan, Biwen Li
On Wed, 2 Dec 2020 11:18:39 +0800, Biwen Li wrote:
> Properly set flag WD_CD for rtc chips(pcf2129, pca2129)
Applied, thanks!
[1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129)
commit: 2843d565dd78fd9117b9a18567cf68ac37a5dd1e
Finally, I did revert back to your first version, after renaming has_nvmem.
Best regards,
--
Alexandre Belloni <alexandre.belloni@bootlin.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-13 21:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 3:18 [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
2020-12-02 3:18 ` [v2 2/2] rtc: pcf2127: clear these flags TSF1, TSF2 before enabling interrupt generation Biwen Li
2020-12-23 7:06 ` [v2 1/2] rtc: pcf2127: properly set flag WD_CD for rtc chips(pcf2129, pca2129) Biwen Li
2021-02-13 21:40 ` (subset) " Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).