Skip to content

Commit 8ddfa81

Browse files
stephan-ghandersson
authored andcommitted
soc: qcom: Add RPM processor/subsystem driver
Add a simple driver for the qcom,rpm-proc compatible that registers the "smd-edge" and populates other children defined in the device tree. Note that the DT schema belongs to the remoteproc subsystem while this driver is added inside soc/qcom. I argue that the RPM *is* a remoteproc, but as an implementation detail in Linux it can currently not benefit from anything provided by the remoteproc subsystem. The RPM firmware is usually already loaded and started by earlier components in the boot chain and is not meant to be ever restarted. To avoid breaking existing kernel configurations the driver is always built when smd-rpm.c is also built. They belong closely together anyway. To avoid build errors CONFIG_RPMSG_QCOM_SMD must be also built-in if rpm-proc is. Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Link: https://lore.kernel.org/r/20230531-rpm-rproc-v3-9-a07dcdefd918@gerhold.net Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 181563b commit 8ddfa81

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

drivers/soc/qcom/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ config QCOM_SMD_RPM
191191
tristate "Qualcomm Resource Power Manager (RPM) over SMD"
192192
depends on ARCH_QCOM || COMPILE_TEST
193193
depends on RPMSG
194+
depends on RPMSG_QCOM_SMD || RPMSG_QCOM_SMD=n
194195
help
195196
If you say yes to this option, support will be included for the
196197
Resource Power Manager system found in the Qualcomm 8974 based

drivers/soc/qcom/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o
1818
obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o
1919
qcom_rpmh-y += rpmh-rsc.o
2020
qcom_rpmh-y += rpmh.o
21-
obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o
21+
obj-$(CONFIG_QCOM_SMD_RPM) += rpm-proc.o smd-rpm.o
2222
obj-$(CONFIG_QCOM_SMEM) += smem.o
2323
obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
2424
obj-$(CONFIG_QCOM_SMP2P) += smp2p.o

drivers/soc/qcom/rpm-proc.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright (c) 2021-2023, Stephan Gerhold <stephan@gerhold.net> */
3+
4+
#include <linux/module.h>
5+
#include <linux/of.h>
6+
#include <linux/of_platform.h>
7+
#include <linux/platform_device.h>
8+
#include <linux/rpmsg/qcom_smd.h>
9+
10+
static int rpm_proc_probe(struct platform_device *pdev)
11+
{
12+
struct qcom_smd_edge *edge = NULL;
13+
struct device *dev = &pdev->dev;
14+
struct device_node *edge_node;
15+
int ret;
16+
17+
edge_node = of_get_child_by_name(dev->of_node, "smd-edge");
18+
if (edge_node) {
19+
edge = qcom_smd_register_edge(dev, edge_node);
20+
of_node_put(edge_node);
21+
if (IS_ERR(edge))
22+
return dev_err_probe(dev, PTR_ERR(edge),
23+
"Failed to register smd-edge\n");
24+
}
25+
26+
ret = devm_of_platform_populate(dev);
27+
if (ret) {
28+
dev_err(dev, "Failed to populate child devices: %d\n", ret);
29+
goto err;
30+
}
31+
32+
platform_set_drvdata(pdev, edge);
33+
return 0;
34+
err:
35+
if (edge)
36+
qcom_smd_unregister_edge(edge);
37+
return ret;
38+
}
39+
40+
static void rpm_proc_remove(struct platform_device *pdev)
41+
{
42+
struct qcom_smd_edge *edge = platform_get_drvdata(pdev);
43+
44+
if (edge)
45+
qcom_smd_unregister_edge(edge);
46+
}
47+
48+
static const struct of_device_id rpm_proc_of_match[] = {
49+
{ .compatible = "qcom,rpm-proc", },
50+
{ /* sentinel */ }
51+
};
52+
MODULE_DEVICE_TABLE(of, rpm_proc_of_match);
53+
54+
static struct platform_driver rpm_proc_driver = {
55+
.probe = rpm_proc_probe,
56+
.remove_new = rpm_proc_remove,
57+
.driver = {
58+
.name = "qcom-rpm-proc",
59+
.of_match_table = rpm_proc_of_match,
60+
},
61+
};
62+
63+
static int __init rpm_proc_init(void)
64+
{
65+
return platform_driver_register(&rpm_proc_driver);
66+
}
67+
arch_initcall(rpm_proc_init);
68+
69+
static void __exit rpm_proc_exit(void)
70+
{
71+
platform_driver_unregister(&rpm_proc_driver);
72+
}
73+
module_exit(rpm_proc_exit);
74+
75+
MODULE_DESCRIPTION("Qualcomm RPM processor/subsystem driver");
76+
MODULE_AUTHOR("Stephan Gerhold <stephan@gerhold.net>");
77+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)