2 * Qualcomm Peripheral Image Loader helpers
4 * Copyright (C) 2016 Linaro Ltd
5 * Copyright (C) 2015 Sony Mobile Communications Inc
6 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/firmware.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/remoteproc.h>
22 #include <linux/rpmsg/qcom_smd.h>
24 #include "remoteproc_internal.h"
25 #include "qcom_common.h"
27 #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
30 * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc
31 * @rproc: remoteproc handle
32 * @fw: firmware header
33 * @tablesz: outgoing size of the table
35 * Returns a dummy table.
37 struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc,
38 const struct firmware *fw,
41 static struct resource_table table = { .ver = 1, };
43 *tablesz = sizeof(table);
46 EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table);
48 static int smd_subdev_probe(struct rproc_subdev *subdev)
50 struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
52 smd->edge = qcom_smd_register_edge(smd->dev, smd->node);
54 return IS_ERR(smd->edge) ? PTR_ERR(smd->edge) : 0;
57 static void smd_subdev_remove(struct rproc_subdev *subdev)
59 struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
61 qcom_smd_unregister_edge(smd->edge);
66 * qcom_add_smd_subdev() - try to add a SMD subdevice to rproc
67 * @rproc: rproc handle to parent the subdevice
68 * @smd: reference to a Qualcomm subdev context
70 void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
72 struct device *dev = &rproc->dev;
74 smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge");
79 rproc_add_subdev(rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove);
81 EXPORT_SYMBOL_GPL(qcom_add_smd_subdev);
84 * qcom_remove_smd_subdev() - remove the smd subdevice from rproc
85 * @rproc: rproc handle
86 * @smd: the SMD subdevice to remove
88 void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
90 rproc_remove_subdev(rproc, &smd->subdev);
91 of_node_put(smd->node);
93 EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev);
95 MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
96 MODULE_LICENSE("GPL v2");