Skip to content

Commit 1afa706

Browse files
Praveen Talarigregkh
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. Reviewed-by: Bryan O'Donoghue <[email protected]> Signed-off-by: Praveen Talari <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5893e62 commit 1afa706

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/tty/serial/qcom_geni_serial.c

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

17151715
if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF)
1716-
geni_serial_resources_on(uport);
1716+
pm_runtime_resume_and_get(uport->dev);
17171717
else if (new_state == UART_PM_STATE_OFF &&
17181718
old_state == UART_PM_STATE_ON)
1719-
geni_serial_resources_off(uport);
1719+
pm_runtime_put_sync(uport->dev);
17201720

17211721
}
17221722

@@ -1878,6 +1878,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
18781878
if (ret)
18791879
return ret;
18801880

1881+
devm_pm_runtime_enable(port->se.dev);
1882+
18811883
ret = uart_add_one_port(drv, uport);
18821884
if (ret)
18831885
return ret;
@@ -1909,6 +1911,22 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
19091911
uart_remove_one_port(drv, &port->uport);
19101912
}
19111913

1914+
static int __maybe_unused qcom_geni_serial_runtime_suspend(struct device *dev)
1915+
{
1916+
struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1917+
struct uart_port *uport = &port->uport;
1918+
1919+
return geni_serial_resources_off(uport);
1920+
}
1921+
1922+
static int __maybe_unused qcom_geni_serial_runtime_resume(struct device *dev)
1923+
{
1924+
struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
1925+
struct uart_port *uport = &port->uport;
1926+
1927+
return geni_serial_resources_on(uport);
1928+
}
1929+
19121930
static int qcom_geni_serial_suspend(struct device *dev)
19131931
{
19141932
struct qcom_geni_serial_port *port = dev_get_drvdata(dev);
@@ -1952,6 +1970,8 @@ static const struct qcom_geni_device_data qcom_geni_uart_data = {
19521970
};
19531971

19541972
static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
1973+
SET_RUNTIME_PM_OPS(qcom_geni_serial_runtime_suspend,
1974+
qcom_geni_serial_runtime_resume, NULL)
19551975
SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_suspend, qcom_geni_serial_resume)
19561976
};
19571977

0 commit comments

Comments
 (0)