diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-01-27 10:04:54 -0500 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-02-06 11:57:25 -0500 |
commit | b90fcfcb1378ddab1ee58ec7caaedbba2a8eb7c6 (patch) | |
tree | 436db602ee6a0af7e02baaad94aa04a44a033a75 | |
parent | 2aad40d911eeb7dcac91c669f2762a28134f0eb1 (diff) |
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: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/remoteproc/qcom_common.c | 50 | ||||
-rw-r--r-- | drivers/remoteproc/qcom_common.h | 15 | ||||
-rw-r--r-- | drivers/remoteproc/qcom_wcnss.c | 28 |
3 files changed, 67 insertions, 26 deletions
diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index bd400336e209..bb90481215c6 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c | |||
@@ -19,10 +19,13 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/remoteproc.h> | 21 | #include <linux/remoteproc.h> |
22 | #include <linux/rpmsg/qcom_smd.h> | ||
22 | 23 | ||
23 | #include "remoteproc_internal.h" | 24 | #include "remoteproc_internal.h" |
24 | #include "qcom_common.h" | 25 | #include "qcom_common.h" |
25 | 26 | ||
27 | #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev) | ||
28 | |||
26 | /** | 29 | /** |
27 | * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc | 30 | * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc |
28 | * @rproc: remoteproc handle | 31 | * @rproc: remoteproc handle |
@@ -42,5 +45,52 @@ struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, | |||
42 | } | 45 | } |
43 | EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table); | 46 | EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table); |
44 | 47 | ||
48 | static int smd_subdev_probe(struct rproc_subdev *subdev) | ||
49 | { | ||
50 | struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); | ||
51 | |||
52 | smd->edge = qcom_smd_register_edge(smd->dev, smd->node); | ||
53 | |||
54 | return IS_ERR(smd->edge) ? PTR_ERR(smd->edge) : 0; | ||
55 | } | ||
56 | |||
57 | static void smd_subdev_remove(struct rproc_subdev *subdev) | ||
58 | { | ||
59 | struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); | ||
60 | |||
61 | qcom_smd_unregister_edge(smd->edge); | ||
62 | smd->edge = NULL; | ||
63 | } | ||
64 | |||
65 | /** | ||
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 | ||
69 | */ | ||
70 | void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) | ||
71 | { | ||
72 | struct device *dev = &rproc->dev; | ||
73 | |||
74 | smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge"); | ||
75 | if (!smd->node) | ||
76 | return; | ||
77 | |||
78 | smd->dev = dev; | ||
79 | rproc_add_subdev(rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove); | ||
80 | } | ||
81 | EXPORT_SYMBOL_GPL(qcom_add_smd_subdev); | ||
82 | |||
83 | /** | ||
84 | * qcom_remove_smd_subdev() - remove the smd subdevice from rproc | ||
85 | * @rproc: rproc handle | ||
86 | * @smd: the SMD subdevice to remove | ||
87 | */ | ||
88 | void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd) | ||
89 | { | ||
90 | rproc_remove_subdev(rproc, &smd->subdev); | ||
91 | of_node_put(smd->node); | ||
92 | } | ||
93 | EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev); | ||
94 | |||
45 | MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver"); | 95 | MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver"); |
46 | MODULE_LICENSE("GPL v2"); | 96 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index caecf27c4ffa..db5c826d5cd4 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h | |||
@@ -1,11 +1,22 @@ | |||
1 | #ifndef __RPROC_QCOM_COMMON_H__ | 1 | #ifndef __RPROC_QCOM_COMMON_H__ |
2 | #define __RPROC_QCOM_COMMON_H__ | 2 | #define __RPROC_QCOM_COMMON_H__ |
3 | 3 | ||
4 | struct resource_table; | 4 | #include <linux/remoteproc.h> |
5 | struct rproc; | 5 | #include "remoteproc_internal.h" |
6 | |||
7 | struct qcom_rproc_subdev { | ||
8 | struct rproc_subdev subdev; | ||
9 | |||
10 | struct device *dev; | ||
11 | struct device_node *node; | ||
12 | struct qcom_smd_edge *edge; | ||
13 | }; | ||
6 | 14 | ||
7 | struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, | 15 | struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, |
8 | const struct firmware *fw, | 16 | const struct firmware *fw, |
9 | int *tablesz); | 17 | int *tablesz); |
10 | 18 | ||
19 | void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); | ||
20 | void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); | ||
21 | |||
11 | #endif | 22 | #endif |
diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index 781211c144c6..c7686393d505 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c | |||
@@ -97,9 +97,7 @@ struct qcom_wcnss { | |||
97 | void *mem_region; | 97 | void *mem_region; |
98 | size_t mem_size; | 98 | size_t mem_size; |
99 | 99 | ||
100 | struct device_node *smd_node; | 100 | struct qcom_rproc_subdev smd_subdev; |
101 | struct qcom_smd_edge *smd_edge; | ||
102 | struct rproc_subdev smd_subdev; | ||
103 | }; | 101 | }; |
104 | 102 | ||
105 | static const struct wcnss_data riva_data = { | 103 | static const struct wcnss_data riva_data = { |
@@ -376,23 +374,6 @@ static irqreturn_t wcnss_stop_ack_interrupt(int irq, void *dev) | |||
376 | return IRQ_HANDLED; | 374 | return IRQ_HANDLED; |
377 | } | 375 | } |
378 | 376 | ||
379 | static int wcnss_smd_probe(struct rproc_subdev *subdev) | ||
380 | { | ||
381 | struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev); | ||
382 | |||
383 | wcnss->smd_edge = qcom_smd_register_edge(wcnss->dev, wcnss->smd_node); | ||
384 | |||
385 | return IS_ERR(wcnss->smd_edge) ? PTR_ERR(wcnss->smd_edge) : 0; | ||
386 | } | ||
387 | |||
388 | static void wcnss_smd_remove(struct rproc_subdev *subdev) | ||
389 | { | ||
390 | struct qcom_wcnss *wcnss = container_of(subdev, struct qcom_wcnss, smd_subdev); | ||
391 | |||
392 | qcom_smd_unregister_edge(wcnss->smd_edge); | ||
393 | wcnss->smd_edge = NULL; | ||
394 | } | ||
395 | |||
396 | static int wcnss_init_regulators(struct qcom_wcnss *wcnss, | 377 | static int wcnss_init_regulators(struct qcom_wcnss *wcnss, |
397 | const struct wcnss_vreg_info *info, | 378 | const struct wcnss_vreg_info *info, |
398 | int num_vregs) | 379 | int num_vregs) |
@@ -575,9 +556,7 @@ static int wcnss_probe(struct platform_device *pdev) | |||
575 | } | 556 | } |
576 | } | 557 | } |
577 | 558 | ||
578 | wcnss->smd_node = of_get_child_by_name(pdev->dev.of_node, "smd-edge"); | 559 | qcom_add_smd_subdev(rproc, &wcnss->smd_subdev); |
579 | if (wcnss->smd_node) | ||
580 | rproc_add_subdev(rproc, &wcnss->smd_subdev, wcnss_smd_probe, wcnss_smd_remove); | ||
581 | 560 | ||
582 | ret = rproc_add(rproc); | 561 | ret = rproc_add(rproc); |
583 | if (ret) | 562 | if (ret) |
@@ -597,9 +576,10 @@ static int wcnss_remove(struct platform_device *pdev) | |||
597 | 576 | ||
598 | of_platform_depopulate(&pdev->dev); | 577 | of_platform_depopulate(&pdev->dev); |
599 | 578 | ||
600 | of_node_put(wcnss->smd_node); | ||
601 | qcom_smem_state_put(wcnss->state); | 579 | qcom_smem_state_put(wcnss->state); |
602 | rproc_del(wcnss->rproc); | 580 | rproc_del(wcnss->rproc); |
581 | |||
582 | qcom_remove_smd_subdev(wcnss->rproc, &wcnss->smd_subdev); | ||
603 | rproc_free(wcnss->rproc); | 583 | rproc_free(wcnss->rproc); |
604 | 584 | ||
605 | return 0; | 585 | return 0; |