]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
serial: qcom-geni: Enable PM runtime for serial driver
authorPraveen Talari <praveen.talari@oss.qualcomm.com>
Mon, 10 Nov 2025 10:10:42 +0000 (15:40 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Nov 2025 12:12:47 +0000 (13:12 +0100)
The GENI serial driver currently handles power resource management
through calls to the statically defined geni_serial_resources_on() and
geni_serial_resources_off() functions. This approach reduces modularity
and limits support for platforms with diverse power management
mechanisms, including resource managed by firmware.

Improve modularity and enable better integration with platform-specific
power management, introduce support for runtime PM. Use
pm_runtime_resume_and_get() and pm_runtime_put_sync() within the
qcom_geni_serial_pm() callback to control resource power state
transitions based on UART power state changes.

Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
Link: https://patch.msgid.link/20251110101043.2108414-4-praveen.talari@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/qcom_geni_serial.c

index 8058b839b26ce91c7f132c6710e16439a3f50414..9c820302047c7963873ccbe0d0e64d5c3859fc21 100644 (file)
@@ -1650,10 +1650,10 @@ static void qcom_geni_serial_pm(struct uart_port *uport,
                old_state = UART_PM_STATE_OFF;
 
        if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
-               geni_serial_resources_on(uport);
+               pm_runtime_resume_and_get(uport->dev);
        else if (new_state == UART_PM_STATE_OFF &&
                 old_state == UART_PM_STATE_ON)
-               geni_serial_resources_off(uport);
+               pm_runtime_put_sync(uport->dev);
 
 }
 
@@ -1815,6 +1815,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
+       devm_pm_runtime_enable(port->se.dev);
+
        ret = uart_add_one_port(drv, uport);
        if (ret)
                return ret;
@@ -1846,6 +1848,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
        uart_remove_one_port(drv, &port->uport);
 }
 
+static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
+{
+       struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+       struct uart_port *uport = &port->uport;
+
+       return geni_serial_resources_off(uport);
+}
+
+static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
+{
+       struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
+       struct uart_port *uport = &port->uport;
+
+       return geni_serial_resources_on(uport);
+}
+
 static int qcom_geni_serial_suspend(struct device *dev)
 {
        struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
@@ -1889,6 +1907,8 @@ static const struct qcom_geni_device_data qcom_geni_uart_data = {
 };
 
 static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
+       SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
+                          qcom_geni_serial_runtime_resume, NULL)
        SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
 };