Skip to contentSkip to conversation

serial: 8250: omap: Add am62 wakeup support

PATCH In review Markus Schneider-Pargmann 3 participants 8 messages Aug 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover serial: 8250: omap: Add am62 wakeup support

Hi,

v2
--

In Version 2 I removed the Partial-IO specific patches as these can't be tested due to power issues in Partial-IO on am62-lp-sk and similar boards.

I added a patch to add DT 'wakeup-source' support.

Series
------

To support wakeup from several low power modes on am62, don't always enable device wakeup. Instead only set it to wakeup capable. A devicetree property 'wakeup-source' can be used to enable wakeup. The user is also able to control if wakeup is enabled through sysfs.

Base
----
v6.11-rc1

Tests
-----
I tested these patches on am62-lp-sk.

Previous versions
-----------------
v1: https://lore.kernel.org/lkml/[email protected]/

Changes in v2
-------------
- Remove Partial-IO patches
- Replace device_init_wakeup with device_set_wakeup_capable in omap8250_remove as well

Best,
Markus

Markus Schneider-Pargmann (5):
dt-bindings: serial: 8250_omap: Add wakeup-source property
serial: 8250: omap: Remove unused wakeups_enabled
serial: 8250: omap: Cleanup on error in request_irq
serial: 8250: omap: Set wakeup capable, do not enable
serial: 8250: omap: Parse DT wakeup-source proerty

 .../devicetree/bindings/serial/8250_omap.yaml          |  1 +
 drivers/tty/serial/8250/8250_omap.c                    | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 1/5 dt-bindings: serial: 8250_omap: Add wakeup-source property

Add the wakeup-source to enable this device as a wakeup source if defined in DT.

---
 Documentation/devicetree/bindings/serial/8250_omap.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/serial/8250_omap.yaml +1 -0
index 6a7be42da523..4b78de6b46a2 100644
@@ -76,6 +76,7 @@ properties:
   clock-frequency: true
   current-speed: true
   overrun-throttle-ms: true
+  wakeup-source: true
 
 required:
   - compatible
Signature · 1 line
2.45.2
#3 lore raw

PATCH v2 2/5 serial: 8250: omap: Remove unused wakeups_enabled

In reply to Markus Schneider-Pargmann

This field seems to be unused for quite some time already. Remove it.

---
 drivers/tty/serial/8250/8250_omap.c | 1 -
 1 file changed, 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +0 -1
index 1af9aed99c65..02d4f3073696 100644
@@ -144,7 +144,6 @@ struct omap8250_priv {
 	atomic_t active;
 	bool is_suspending;
 	int wakeirq;
-	int wakeups_enabled;
 	u32 latency;
 	u32 calc_latency;
 	struct pm_qos_request pm_qos_request;
Signature · 1 line
2.45.2
#4 lore raw

PATCH v2 3/5 serial: 8250: omap: Cleanup on error in request_irq

In reply to Markus Schneider-Pargmann

If devm_request_irq fails, the code does not cleanup many things that were setup before. Instead of directly returning ret we should jump to err.

Fixes fef4f600319e ("serial: 8250: omap: Fix life cycle issues for interrupt handlers")
---
 drivers/tty/serial/8250/8250_omap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +1 -1
index 02d4f3073696..01d430de9c64 100644
@@ -1587,7 +1587,7 @@ static int omap8250_probe(struct platform_device *pdev)
 	ret = devm_request_irq(&pdev->dev, up.port.irq, omap8250_irq, 0,
 			       dev_name(&pdev->dev), priv);
 	if (ret < 0)
-		return ret;
+		goto err;
 
 	priv->wakeirq = irq_of_parse_and_map(np, 1);
 
Signature · 1 line
2.45.2
#5 lore raw

PATCH v2 4/5 serial: 8250: omap: Set wakeup capable, do not enable

In reply to Markus Schneider-Pargmann

The driver sets wakeup enable by default. But not all UARTs are meant to be wakeup enabled. Change the default to be wakeup capable but not enabled. The user can enable wakeup when needed.

---
 drivers/tty/serial/8250/8250_omap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +2 -2
index 01d430de9c64..7a6dfd40af9e 100644
@@ -1529,7 +1529,7 @@ static int omap8250_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	device_init_wakeup(&pdev->dev, true);
+	device_set_wakeup_capable(&pdev->dev, true);
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_use_autosuspend(&pdev->dev);
 
@@ -1628,7 +1628,7 @@ static void omap8250_remove(struct platform_device *pdev)
 	flush_work(&priv->qos_work);
 	pm_runtime_disable(&pdev->dev);
 	cpu_latency_qos_remove_request(&priv->pm_qos_request);
-	device_init_wakeup(&pdev->dev, false);
+	device_set_wakeup_capable(&pdev->dev, false);
 }
 
 static int omap8250_prepare(struct device *dev)
Signature · 1 line
2.45.2
#6 lore raw

PATCH v2 5/5 serial: 8250: omap: Parse DT wakeup-source proerty

In reply to Markus Schneider-Pargmann

If the wakeup-source property is present, enable wakeup from this device.

---
 drivers/tty/serial/8250/8250_omap.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_omap.c +3 -0
index 7a6dfd40af9e..ccb83c05be20 100644
@@ -1530,6 +1530,9 @@ static int omap8250_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, priv);
 
 	device_set_wakeup_capable(&pdev->dev, true);
+	if (of_property_read_bool(np, "wakeup-source"))
+		device_set_wakeup_enable(&pdev->dev, true);
+
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_use_autosuspend(&pdev->dev);
 
Signature · 1 line
2.45.2
Reviewed-by Tested-by on the v2 series
#7 lore raw
In reply to Markus Schneider-Pargmann
Quoted 9 lines · Markus Schneider-Pargmann

v2
--

In Version 2 I removed the Partial-IO specific patches as these can't be tested due to power issues in Partial-IO on am62-lp-sk and similar boards.

I added a patch to add DT 'wakeup-source' support.

Quoted 7 lines

Series
------

To support wakeup from several low power modes on am62, don't always enable device wakeup. Instead only set it to wakeup capable. A devicetree property 'wakeup-source' can be used to enable wakeup. The user is also able to control if wakeup is enabled through sysfs.

For my low-power constraints series[1], it's also important to not have the UART wakeups unconditionally enabled, so I like the defaults proposed in this series. Thanks!

I tested on k3-am62a7-sk along with my constraints changes and all is well.

Kevin

[1] https://lore.kernel.org/all/20240805-lpm-v6-10-constraints-pmdomain-v1-0-d186b68ded4c@baylibre.com/