Skip to contentSkip to conversation

dt-bindings: rtc: add wakeup-source for FlexTimer

PATCH In review Ran Wang 2 participants 4 messages May 29, 2020

Subsystems (2)
lore
Share & tools
lore

Ran Wang

author
#0 lore raw

PATCH 1/2 dt-bindings: rtc: add wakeup-source for FlexTimer

---
 Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt +2 -0
index fffac74..d7c482c 100644
@@ -20,6 +20,7 @@ Required properties:
 Optional properties:
 - big-endian: If the host controller is big-endian mode, specify this property.
   The default endian mode is little-endian.
+- wakeup-source: Enable it as a wakeup source
 
 Example:
 rcpm: rcpm@1e34040 {
@@ -32,5 +33,6 @@ ftm_alarm0: timer@2800000 {
 	compatible = "fsl,ls1088a-ftm-alarm";
 	reg = <0x0 0x2800000 0x0 0x10000>;
 	fsl,rcpm-wakeup = <&rcpm 0x0 0x0 0x0 0x0 0x4000 0x0>;
+	wakeup-source;
 	interrupts = <0 44 4>;
 };
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 rtc: fsl-ftm-alarm: fix freeze(s2idle) doesnot wake

Use dev_pm_set_wake_irq() instead of flag IRQF_NO_SUSPEND to enable wakeup system feature for both freeze(s2idle) and mem(deep).

Use property 'wakeup-source' to control this feature.

---
 drivers/rtc/rtc-fsl-ftm-alarm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/rtc/rtc-fsl-ftm-alarm.c +10 -2
index 756af62..c6945d84 100644
@@ -21,6 +21,7 @@
 #include <linux/rtc.h>
 #include <linux/time.h>
 #include <linux/acpi.h>
+#include <linux/pm_wakeirq.h>
 
 #define FTM_SC_CLK(c)		((c) << FTM_SC_CLK_MASK_SHIFT)
 
@@ -41,6 +42,7 @@ struct ftm_rtc {
 	struct rtc_device *rtc_dev;
 	void __iomem *base;
 	bool big_endian;
+	bool wakeup;
 	u32 alarm_freq;
 };
 
@@ -267,6 +269,9 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 		return PTR_ERR(rtc->base);
 	}
 
+	rtc->wakeup =
+		device_property_read_bool(&pdev->dev, "wakeup-source");
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "can't get irq number\n");
@@ -274,7 +279,7 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_irq(&pdev->dev, irq, ftm_rtc_alarm_interrupt,
-			       IRQF_NO_SUSPEND, dev_name(&pdev->dev), rtc);
+			       0, dev_name(&pdev->dev), rtc);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to request irq\n");
 		return ret;
@@ -286,7 +291,10 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 	rtc->alarm_freq = (u32)FIXED_FREQ_CLK / (u32)MAX_FREQ_DIV;
 	rtc->rtc_dev->ops = &ftm_rtc_ops;
 
-	device_init_wakeup(&pdev->dev, true);
+	device_init_wakeup(&pdev->dev, rtc->wakeup);
+	ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+	if (ret)
+		dev_err(&pdev->dev, "irq wake enable failed.\n");
 
 	ret = rtc_register_device(rtc->rtc_dev);
 	if (ret) {
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] rtc: fsl-ftm-alarm: fix freeze(s2idle) doesnot wake

Quoted 50 lines · Ran Wang

Use dev_pm_set_wake_irq() instead of flag IRQF_NO_SUSPEND to enable wakeup system feature for both freeze(s2idle) and mem(deep).

Use property 'wakeup-source' to control this feature.

---
 drivers/rtc/rtc-fsl-ftm-alarm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/rtc/rtc-fsl-ftm-alarm.c +6 -1
index 756af62..c6945d84 100644
@@ -21,6 +21,7 @@
 #include <linux/rtc.h>
 #include <linux/time.h>
 #include <linux/acpi.h>
+#include <linux/pm_wakeirq.h>
 
 #define FTM_SC_CLK(c)		((c) << FTM_SC_CLK_MASK_SHIFT)
 
@@ -41,6 +42,7 @@ struct ftm_rtc {
 	struct rtc_device *rtc_dev;
 	void __iomem *base;
 	bool big_endian;
+	bool wakeup;
 	u32 alarm_freq;
 };
 
@@ -267,6 +269,9 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 		return PTR_ERR(rtc->base);
 	}
 
+	rtc->wakeup =
+		device_property_read_bool(&pdev->dev, "wakeup-source");
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "can't get irq number\n");
@@ -274,7 +279,7 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_request_irq(&pdev->dev, irq, ftm_rtc_alarm_interrupt,
-			       IRQF_NO_SUSPEND, dev_name(&pdev->dev), rtc);
+			       0, dev_name(&pdev->dev), rtc);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to request irq\n");
 		return ret;

drivers/rtc/rtc-fsl-ftm-alarm.c static int ftm_rtc_probe(struct platform_device *pdev) · line 294

Quoted 5 lines
drivers/rtc/rtc-fsl-ftm-alarm.c +1 -1
@@ -286,7 +291,10 @@ static int ftm_rtc_probe(struct platform_device *pdev)
 	rtc->alarm_freq = (u32)FIXED_FREQ_CLK / (u32)MAX_FREQ_DIV;
 	rtc->rtc_dev->ops = &ftm_rtc_ops;
 
-	device_init_wakeup(&pdev->dev, true);
+	device_init_wakeup(&pdev->dev, rtc->wakeup);

As long as you have an irq, you should be able to wakeup, do you really need the wakeup-source property?

Usually, wakeup-source is used when the RTC interrupt line is not connected directly to the SoC but is still able to wake it up.

In your case, is it to cover the case of the flex timers that can't wake the CPU? If so, then please be more explicit in your commit message.

Quoted 9 lines
drivers/rtc/rtc-fsl-ftm-alarm.c +3 -0
+	ret = dev_pm_set_wake_irq(&pdev->dev, irq);
+	if (ret)
+		dev_err(&pdev->dev, "irq wake enable failed.\n");
 
 	ret = rtc_register_device(rtc->rtc_dev);
 	if (ret) {
Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
In reply to Ran Wang
Quoted 10 lines · Ran Wang
---
 Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt +0 -0
index fffac74..d7c482c 100644

Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt Required properties: · line 24

Quoted 5 lines
Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt +1 -0
@@ -20,6 +20,7 @@ Required properties:
 Optional properties:
 - big-endian: If the host controller is big-endian mode, specify this property.
   The default endian mode is little-endian.
+- wakeup-source: Enable it as a wakeup source
 

This is already covered by Documentation/devicetree/bindings/rtc/rtc.yaml

Quoted 12 lines
Documentation/devicetree/bindings/rtc/rtc-fsl-ftm-alarm.txt +1 -0
 Example:
 rcpm: rcpm@1e34040 {
@@ -32,5 +33,6 @@ ftm_alarm0: timer@2800000 {
 	compatible = "fsl,ls1088a-ftm-alarm";
 	reg = <0x0 0x2800000 0x0 0x10000>;
 	fsl,rcpm-wakeup = <&rcpm 0x0 0x0 0x0 0x0 0x4000 0x0>;
+	wakeup-source;
 	interrupts = <0 44 4>;
 };
Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com