Commit b90fcfcb authored by Bjorn Andersson's avatar Bjorn Andersson

remoteproc: qcom: wcnss: Make SMD handling common

Move the SMD edge handling to the Qualcomm common file to make it
reusable for other Qualcomm remoteproc drivers.
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 2aad40d9
...@@ -19,10 +19,13 @@ ...@@ -19,10 +19,13 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/remoteproc.h> #include <linux/remoteproc.h>
#include <linux/rpmsg/qcom_smd.h>
#include "remoteproc_internal.h" #include "remoteproc_internal.h"
#include "qcom_common.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 * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc
* @rproc: remoteproc handle * @rproc: remoteproc handle
...@@ -42,5 +45,52 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, ...@@ -42,5 +45,52 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc,
} }
EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table); 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_DESCRIPTION("Qualcomm Remoteproc helper driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
#ifndef __RPROC_QCOM_COMMON_H__ #ifndef __RPROC_QCOM_COMMON_H__
#define __RPROC_QCOM_COMMON_H__ #define __RPROC_QCOM_COMMON_H__
struct resource_table; #include <linux/remoteproc.h>
struct rproc; #include "remoteproc_internal.h"
struct qcom_rproc_subdev {
struct rproc_subdev subdev;
struct device *dev;
struct device_node *node;
struct qcom_smd_edge *edge;
};
struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc,
const struct firmware *fw, const struct firmware *fw,
int *tablesz); int *tablesz);
void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd);
void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd);
#endif #endif
...@@ -97,9 +97,7 @@ struct qcom_wcnss { ...@@ -97,9 +97,7 @@ struct qcom_wcnss {
void *mem_region; void *mem_region;
size_t mem_size; size_t mem_size;
struct device_node *smd_node; struct qcom_rproc_subdev smd_subdev;
struct qcom_smd_edge *smd_edge;
struct rproc_subdev smd_subdev;
}; };
static const struct wcnss_data riva_data = { static const struct wcnss_data riva_data = {
...@@ -376,23 +374,6 @@ static irqreturn_t wcnss_stop_ack_interrupt(int irq, void *dev) ...@@ -376,23 +374,6 @@ static irqreturn_t wcnss_stop_ack_interrupt(int irq, void *dev)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int wcnss_smd_probe(struct rproc_subdev *subdev)
{
struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev);
wcnss->smd_edge = qcom_smd_register_edge(wcnss->dev, wcnss->smd_node);
return IS_ERR(wcnss->smd_edge) ? PTR_ERR(wcnss->smd_edge) : 0;
}
static void wcnss_smd_remove(struct rproc_subdev *subdev)
{
struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev);
qcom_smd_unregister_edge(wcnss->smd_edge);
wcnss->smd_edge = NULL;
}
static int wcnss_init_regulators(struct qcom_wcnss *wcnss, static int wcnss_init_regulators(struct qcom_wcnss *wcnss,
const struct wcnss_vreg_info *info, const struct wcnss_vreg_info *info,
int num_vregs) int num_vregs)
...@@ -575,9 +556,7 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -575,9 +556,7 @@ static int wcnss_probe(struct platform_device *pdev)
} }
} }
wcnss->smd_node = of_get_child_by_name(pdev->dev.of_node, "smd-edge"); qcom_add_smd_subdev(rproc, &wcnss->smd_subdev);
if (wcnss->smd_node)
rproc_add_subdev(rproc, &wcnss->smd_subdev, wcnss_smd_probe, wcnss_smd_remove);
ret = rproc_add(rproc); ret = rproc_add(rproc);
if (ret) if (ret)
...@@ -597,9 +576,10 @@ static int wcnss_remove(struct platform_device *pdev) ...@@ -597,9 +576,10 @@ static int wcnss_remove(struct platform_device *pdev)
of_platform_depopulate(&pdev->dev); of_platform_depopulate(&pdev->dev);
of_node_put(wcnss->smd_node);
qcom_smem_state_put(wcnss->state); qcom_smem_state_put(wcnss->state);
rproc_del(wcnss->rproc); rproc_del(wcnss->rproc);
qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev);
rproc_free(wcnss->rproc); rproc_free(wcnss->rproc);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment