]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
remoteproc: k3: Factor out TI-SCI processor control OF get function
authorAndrew Davis <afd@ti.com>
Fri, 2 Aug 2024 15:21:02 +0000 (10:21 -0500)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 21 Aug 2024 17:21:02 +0000 (11:21 -0600)
Building the TSP structure is common for users of the TI-SCI processor
control interface. Factor out this function and put it with the rest
of the TI-SCI processor control functions.

Signed-off-by: Andrew Davis <afd@ti.com>
Tested-by: Wadim Egorov <w.egorov@phytec.de>
Link: https://lore.kernel.org/r/20240802152109.137243-3-afd@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/ti_k3_dsp_remoteproc.c
drivers/remoteproc/ti_k3_r5_remoteproc.c
drivers/remoteproc/ti_sci_proc.h

index 9009367e2891a2f6117a6b6a7925f1e244b9a3fc..8be3f631c1920608c9548e8b9146787f4bda14c7 100644 (file)
@@ -610,32 +610,6 @@ static void k3_dsp_release_tsp(void *data)
        ti_sci_proc_release(tsp);
 }
 
-static
-struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev,
-                                           const struct ti_sci_handle *sci)
-{
-       struct ti_sci_proc *tsp;
-       u32 temp[2];
-       int ret;
-
-       ret = of_property_read_u32_array(dev->of_node, "ti,sci-proc-ids",
-                                        temp, 2);
-       if (ret < 0)
-               return ERR_PTR(ret);
-
-       tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
-       if (!tsp)
-               return ERR_PTR(-ENOMEM);
-
-       tsp->dev = dev;
-       tsp->sci = sci;
-       tsp->ops = &sci->ops.proc_ops;
-       tsp->proc_id = temp[0];
-       tsp->host_id = temp[1];
-
-       return tsp;
-}
-
 static int k3_dsp_rproc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -689,7 +663,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
                return dev_err_probe(dev, PTR_ERR(kproc->reset),
                                     "failed to get reset\n");
 
-       kproc->tsp = k3_dsp_rproc_of_get_tsp(dev, kproc->ti_sci);
+       kproc->tsp = ti_sci_proc_of_get_tsp(dev, kproc->ti_sci);
        if (IS_ERR(kproc->tsp))
                return dev_err_probe(dev, PTR_ERR(kproc->tsp),
                                     "failed to construct ti-sci proc control\n");
index 8a63a9360c0f2b04926bf5169546e6015b294f76..0a9fe53dd40d1e121a78c773f2f92dbacdfd0dc6 100644 (file)
@@ -1509,32 +1509,6 @@ static int k3_r5_core_of_get_sram_memories(struct platform_device *pdev,
        return 0;
 }
 
-static
-struct ti_sci_proc *k3_r5_core_of_get_tsp(struct device *dev,
-                                         const struct ti_sci_handle *sci)
-{
-       struct ti_sci_proc *tsp;
-       u32 temp[2];
-       int ret;
-
-       ret = of_property_read_u32_array(dev_of_node(dev), "ti,sci-proc-ids",
-                                        temp, 2);
-       if (ret < 0)
-               return ERR_PTR(ret);
-
-       tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
-       if (!tsp)
-               return ERR_PTR(-ENOMEM);
-
-       tsp->dev = dev;
-       tsp->sci = sci;
-       tsp->ops = &sci->ops.proc_ops;
-       tsp->proc_id = temp[0];
-       tsp->host_id = temp[1];
-
-       return tsp;
-}
-
 static int k3_r5_core_of_init(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -1609,7 +1583,7 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
                goto err;
        }
 
-       core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
+       core->tsp = ti_sci_proc_of_get_tsp(dev, core->ti_sci);
        if (IS_ERR(core->tsp)) {
                ret = PTR_ERR(core->tsp);
                dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
index 778558abcdcc53cf02b503e2cce2146c464a9470..f3911ce75252ec534d7918b9b17193c2b63aa13e 100644 (file)
@@ -28,6 +28,32 @@ struct ti_sci_proc {
        u8 host_id;
 };
 
+static inline
+struct ti_sci_proc *ti_sci_proc_of_get_tsp(struct device *dev,
+                                          const struct ti_sci_handle *sci)
+{
+       struct ti_sci_proc *tsp;
+       u32 temp[2];
+       int ret;
+
+       ret = of_property_read_u32_array(dev_of_node(dev), "ti,sci-proc-ids",
+                                        temp, 2);
+       if (ret < 0)
+               return ERR_PTR(ret);
+
+       tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
+       if (!tsp)
+               return ERR_PTR(-ENOMEM);
+
+       tsp->dev = dev;
+       tsp->sci = sci;
+       tsp->ops = &sci->ops.proc_ops;
+       tsp->proc_id = temp[0];
+       tsp->host_id = temp[1];
+
+       return tsp;
+}
+
 static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
 {
        int ret;