Skip to content

Commit ce6acb2

Browse files
glneomathieupoirier
authored andcommitted
remoteproc: k3: Factor out TI-SCI processor control OF get function
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 <[email protected]> Tested-by: Wadim Egorov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 9fedb82 commit ce6acb2

File tree

3 files changed

+28
-54
lines changed

3 files changed

+28
-54
lines changed

drivers/remoteproc/ti_k3_dsp_remoteproc.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -610,32 +610,6 @@ static void k3_dsp_release_tsp(void *data)
610610
ti_sci_proc_release(tsp);
611611
}
612612

613-
static
614-
struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev,
615-
const struct ti_sci_handle *sci)
616-
{
617-
struct ti_sci_proc *tsp;
618-
u32 temp[2];
619-
int ret;
620-
621-
ret = of_property_read_u32_array(dev->of_node, "ti,sci-proc-ids",
622-
temp, 2);
623-
if (ret < 0)
624-
return ERR_PTR(ret);
625-
626-
tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
627-
if (!tsp)
628-
return ERR_PTR(-ENOMEM);
629-
630-
tsp->dev = dev;
631-
tsp->sci = sci;
632-
tsp->ops = &sci->ops.proc_ops;
633-
tsp->proc_id = temp[0];
634-
tsp->host_id = temp[1];
635-
636-
return tsp;
637-
}
638-
639613
static int k3_dsp_rproc_probe(struct platform_device *pdev)
640614
{
641615
struct device *dev = &pdev->dev;
@@ -689,7 +663,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
689663
return dev_err_probe(dev, PTR_ERR(kproc->reset),
690664
"failed to get reset\n");
691665

692-
kproc->tsp = k3_dsp_rproc_of_get_tsp(dev, kproc->ti_sci);
666+
kproc->tsp = ti_sci_proc_of_get_tsp(dev, kproc->ti_sci);
693667
if (IS_ERR(kproc->tsp))
694668
return dev_err_probe(dev, PTR_ERR(kproc->tsp),
695669
"failed to construct ti-sci proc control\n");

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,32 +1509,6 @@ static int k3_r5_core_of_get_sram_memories(struct platform_device *pdev,
15091509
return 0;
15101510
}
15111511

1512-
static
1513-
struct ti_sci_proc *k3_r5_core_of_get_tsp(struct device *dev,
1514-
const struct ti_sci_handle *sci)
1515-
{
1516-
struct ti_sci_proc *tsp;
1517-
u32 temp[2];
1518-
int ret;
1519-
1520-
ret = of_property_read_u32_array(dev_of_node(dev), "ti,sci-proc-ids",
1521-
temp, 2);
1522-
if (ret < 0)
1523-
return ERR_PTR(ret);
1524-
1525-
tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
1526-
if (!tsp)
1527-
return ERR_PTR(-ENOMEM);
1528-
1529-
tsp->dev = dev;
1530-
tsp->sci = sci;
1531-
tsp->ops = &sci->ops.proc_ops;
1532-
tsp->proc_id = temp[0];
1533-
tsp->host_id = temp[1];
1534-
1535-
return tsp;
1536-
}
1537-
15381512
static int k3_r5_core_of_init(struct platform_device *pdev)
15391513
{
15401514
struct device *dev = &pdev->dev;
@@ -1609,7 +1583,7 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
16091583
goto err;
16101584
}
16111585

1612-
core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
1586+
core->tsp = ti_sci_proc_of_get_tsp(dev, core->ti_sci);
16131587
if (IS_ERR(core->tsp)) {
16141588
ret = PTR_ERR(core->tsp);
16151589
dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",

drivers/remoteproc/ti_sci_proc.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ struct ti_sci_proc {
2828
u8 host_id;
2929
};
3030

31+
static inline
32+
struct ti_sci_proc *ti_sci_proc_of_get_tsp(struct device *dev,
33+
const struct ti_sci_handle *sci)
34+
{
35+
struct ti_sci_proc *tsp;
36+
u32 temp[2];
37+
int ret;
38+
39+
ret = of_property_read_u32_array(dev_of_node(dev), "ti,sci-proc-ids",
40+
temp, 2);
41+
if (ret < 0)
42+
return ERR_PTR(ret);
43+
44+
tsp = devm_kzalloc(dev, sizeof(*tsp), GFP_KERNEL);
45+
if (!tsp)
46+
return ERR_PTR(-ENOMEM);
47+
48+
tsp->dev = dev;
49+
tsp->sci = sci;
50+
tsp->ops = &sci->ops.proc_ops;
51+
tsp->proc_id = temp[0];
52+
tsp->host_id = temp[1];
53+
54+
return tsp;
55+
}
56+
3157
static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
3258
{
3359
int ret;

0 commit comments

Comments
 (0)