1 // SPDX-License-Identifier: GPL-2.0-only
4 #include <linux/module.h>
6 #include <linux/of_platform.h>
7 #include <linux/platform_device.h>
8 #include <linux/rpmsg/qcom_smd.h>
10 static int rpm_proc_probe(struct platform_device *pdev)
12 struct qcom_smd_edge *edge = NULL;
13 struct device *dev = &pdev->dev;
14 struct device_node *edge_node;
17 edge_node = of_get_child_by_name(dev->of_node, "smd-edge");
19 edge = qcom_smd_register_edge(dev, edge_node);
20 of_node_put(edge_node);
22 return dev_err_probe(dev, PTR_ERR(edge),
23 "Failed to register smd-edge\n");
26 ret = devm_of_platform_populate(dev);
28 dev_err(dev, "Failed to populate child devices: %d\n", ret);
32 platform_set_drvdata(pdev, edge);
36 qcom_smd_unregister_edge(edge);
40 static void rpm_proc_remove(struct platform_device *pdev)
42 struct qcom_smd_edge *edge = platform_get_drvdata(pdev);
45 qcom_smd_unregister_edge(edge);
48 static const struct of_device_id rpm_proc_of_match[] = {
49 { .compatible = "qcom,rpm-proc", },
52 MODULE_DEVICE_TABLE(of, rpm_proc_of_match);
54 static struct platform_driver rpm_proc_driver = {
55 .probe = rpm_proc_probe,
56 .remove = rpm_proc_remove,
58 .name = "qcom-rpm-proc",
59 .of_match_table = rpm_proc_of_match,
63 static int __init rpm_proc_init(void)
65 return platform_driver_register(&rpm_proc_driver);
67 arch_initcall(rpm_proc_init);
69 static void __exit rpm_proc_exit(void)
71 platform_driver_unregister(&rpm_proc_driver);
73 module_exit(rpm_proc_exit);
75 MODULE_DESCRIPTION("Qualcomm RPM processor/subsystem driver");
77 MODULE_LICENSE("GPL");