Skip to content

Commit 10904d7

Browse files
ptalari27gregkh
authored andcommitted
serial: qcom-geni: Enable PM runtime for serial driver
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>
1 parent 29e8a0c commit 10904d7

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

drivers/tty/serial/qcom_geni_serial.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,10 +1650,10 @@ static void qcom_geni_serial_pm(struct uart_port *uport,
16501650
old_state = UART_PM_STATE_OFF;
16511651

16521652
if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
1653-
geni_serial_resources_on(uport);
1653+
pm_runtime_resume_and_get(uport->dev);
16541654
else if (new_state == UART_PM_STATE_OFF &&
16551655
old_state == UART_PM_STATE_ON)
1656-
geni_serial_resources_off(uport);
1656+
pm_runtime_put_sync(uport->dev);
16571657

16581658
}
16591659

@@ -1815,6 +1815,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
18151815
if (ret)
18161816
return ret;
18171817

1818+
devm_pm_runtime_enable(port->se.dev);
1819+
18181820
ret = uart_add_one_port(drv, uport);
18191821
if (ret)
18201822
return ret;
@@ -1846,6 +1848,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
18461848
uart_remove_one_port(drv, &port->uport);
18471849
}
18481850

1851+
static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
1852+
{
1853+
struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1854+
struct uart_port *uport = &port->uport;
1855+
1856+
return geni_serial_resources_off(uport);
1857+
}
1858+
1859+
static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
1860+
{
1861+
struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1862+
struct uart_port *uport = &port->uport;
1863+
1864+
return geni_serial_resources_on(uport);
1865+
}
1866+
18491867
static int qcom_geni_serial_suspend(struct device *dev)
18501868
{
18511869
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 = {
18891907
};
18901908

18911909
static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
1910+
SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
1911+
qcom_geni_serial_runtime_resume, NULL)
18921912
SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
18931913
};
18941914

0 commit comments

Comments
 (0)