Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Andrew Davis and committed by
Mathieu Poirier
ce6acb22 9fedb829

+28 -54
+1 -27
drivers/remoteproc/ti_k3_dsp_remoteproc.c
··· 610 610 ti_sci_proc_release(tsp); 611 611 } 612 612 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 - 639 613 static int k3_dsp_rproc_probe(struct platform_device *pdev) 640 614 { 641 615 struct device *dev = &pdev->dev; ··· 663 689 return dev_err_probe(dev, PTR_ERR(kproc->reset), 664 690 "failed to get reset\n"); 665 691 666 - kproc->tsp = k3_dsp_rproc_of_get_tsp(dev, kproc->ti_sci); 692 + kproc->tsp = ti_sci_proc_of_get_tsp(dev, kproc->ti_sci); 667 693 if (IS_ERR(kproc->tsp)) 668 694 return dev_err_probe(dev, PTR_ERR(kproc->tsp), 669 695 "failed to construct ti-sci proc control\n");
+1 -27
drivers/remoteproc/ti_k3_r5_remoteproc.c
··· 1509 1509 return 0; 1510 1510 } 1511 1511 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 - 1538 1512 static int k3_r5_core_of_init(struct platform_device *pdev) 1539 1513 { 1540 1514 struct device *dev = &pdev->dev; ··· 1583 1609 goto err; 1584 1610 } 1585 1611 1586 - core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci); 1612 + core->tsp = ti_sci_proc_of_get_tsp(dev, core->ti_sci); 1587 1613 if (IS_ERR(core->tsp)) { 1588 1614 ret = PTR_ERR(core->tsp); 1589 1615 dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
+26
drivers/remoteproc/ti_sci_proc.h
··· 28 28 u8 host_id; 29 29 }; 30 30 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 + 31 57 static inline int ti_sci_proc_request(struct ti_sci_proc *tsp) 32 58 { 33 59 int ret;