|
@@ -19,10 +19,13 @@
|
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/module.h>
|
|
|
#include <linux/remoteproc.h>
|
|
|
+#include <linux/rpmsg/qcom_smd.h>
|
|
|
|
|
|
#include "remoteproc_internal.h"
|
|
|
#include "qcom_common.h"
|
|
|
|
|
|
+#define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
|
|
|
+
|
|
|
/**
|
|
|
* qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc
|
|
|
* @rproc: remoteproc handle
|
|
@@ -42,5 +45,52 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc,
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table);
|
|
|
|
|
|
+static int smd_subdev_probe(struct rproc_subdev *subdev)
|
|
|
+{
|
|
|
+ struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
|
|
|
+
|
|
|
+ smd->edge = qcom_smd_register_edge(smd->dev, smd->node);
|
|
|
+
|
|
|
+ return IS_ERR(smd->edge) ? PTR_ERR(smd->edge) : 0;
|
|
|
+}
|
|
|
+
|
|
|
+static void smd_subdev_remove(struct rproc_subdev *subdev)
|
|
|
+{
|
|
|
+ struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
|
|
|
+
|
|
|
+ qcom_smd_unregister_edge(smd->edge);
|
|
|
+ smd->edge = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * qcom_add_smd_subdev() - try to add a SMD subdevice to rproc
|
|
|
+ * @rproc: rproc handle to parent the subdevice
|
|
|
+ * @smd: reference to a Qualcomm subdev context
|
|
|
+ */
|
|
|
+void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
|
|
|
+{
|
|
|
+ struct device *dev = &rproc->dev;
|
|
|
+
|
|
|
+ smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge");
|
|
|
+ if (!smd->node)
|
|
|
+ return;
|
|
|
+
|
|
|
+ smd->dev = dev;
|
|
|
+ rproc_add_subdev(rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(qcom_add_smd_subdev);
|
|
|
+
|
|
|
+/**
|
|
|
+ * qcom_remove_smd_subdev() - remove the smd subdevice from rproc
|
|
|
+ * @rproc: rproc handle
|
|
|
+ * @smd: the SMD subdevice to remove
|
|
|
+ */
|
|
|
+void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
|
|
|
+{
|
|
|
+ rproc_remove_subdev(rproc, &smd->subdev);
|
|
|
+ of_node_put(smd->node);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev);
|
|
|
+
|
|
|
MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
|
|
|
MODULE_LICENSE("GPL v2");
|