Re: [PATCH v3 16/20] soc: ti: k3-ringacc: add AM64 DMA rings support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 08/12/2020 11.04, Peter Ujfalusi wrote:
> From: Grygorii Strashko <grygorii.strashko@xxxxxx>
> 
> The DMAs in AM64 have built in rings compared to AM654/J721e/J7200 where a
> separate and generic ringacc is used.
> 
> The ring SW interface is similar to ringacc with some major architectural
> differences, like
> 
> They are part of the DMA (BCDMA or PKTDMA).
> 
> They are dual mode rings are modeled as pair of Rings objects which has
> common configuration and memory buffer, but separate real-time control
> register sets for each direction mem2dev (forward) and dev2mem (reverse).
> 
> The ringacc driver must be initialized for DMA rings use with
> k3_ringacc_dmarings_init() as it is not an independent device as ringacc
> is.
> 
> AM64 rings must be requested only using k3_ringacc_request_rings_pair(),
> and forward ring must always be initialized/configured. After this any
> other Ringacc APIs can be used without any callers changes.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@xxxxxx>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@xxxxxx>
> ---
>  drivers/soc/ti/k3-ringacc.c       | 325 +++++++++++++++++++++++++++++-
>  include/linux/soc/ti/k3-ringacc.h |  17 ++
>  2 files changed, 335 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
> index 119164abcb41..c88c305ba367 100644
> --- a/drivers/soc/ti/k3-ringacc.c
> +++ b/drivers/soc/ti/k3-ringacc.c

...

> +struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
> +					    struct k3_ringacc_init_data *data)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct k3_ringacc *ringacc;
> +	void __iomem *base_rt;
> +	struct resource *res;
> +	int i;
> +
> +	ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
> +	if (!ringacc)
> +		return ERR_PTR(-ENOMEM);
> +
> +	ringacc->dev = dev;
> +	ringacc->dma_rings = true;
> +	ringacc->num_rings = data->num_rings;
> +	ringacc->tisci = data->tisci;
> +	ringacc->tisci_dev_id = data->tisci_dev_id;
> +
> +	mutex_init(&ringacc->req_lock);
> +
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ringrt");
> +	base_rt = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(base_rt))
> +		return base_rt;

this must have been:
	return ERR_CAST(base_rt);

> +
> +	ringacc->rings = devm_kzalloc(dev,
> +				      sizeof(*ringacc->rings) *
> +				      ringacc->num_rings * 2,
> +				      GFP_KERNEL);
> +	ringacc->rings_inuse = devm_kcalloc(dev,
> +					    BITS_TO_LONGS(ringacc->num_rings),
> +					    sizeof(unsigned long), GFP_KERNEL);
> +
> +	if (!ringacc->rings || !ringacc->rings_inuse)
> +		return ERR_PTR(-ENOMEM);
> +
> +	for (i = 0; i < ringacc->num_rings; i++) {
> +		struct k3_ring *ring = &ringacc->rings[i];
> +
> +		ring->rt = base_rt + K3_DMARING_RT_REGS_STEP * i;
> +		ring->parent = ringacc;
> +		ring->ring_id = i;
> +		ring->proxy_id = K3_RINGACC_PROXY_NOT_USED;
> +
> +		ring = &ringacc->rings[ringacc->num_rings + i];
> +		ring->rt = base_rt + K3_DMARING_RT_REGS_STEP * i +
> +			   K3_DMARING_RT_REGS_REVERSE_OFS;
> +		ring->parent = ringacc;
> +		ring->ring_id = i;
> +		ring->proxy_id = K3_RINGACC_PROXY_NOT_USED;
> +		ring->flags = K3_RING_FLAG_REVERSE;
> +	}
> +
> +	ringacc->tisci_ring_ops = &ringacc->tisci->ops.rm_ring_ops;
> +
> +	dev_info(dev, "Number of rings: %u\n", ringacc->num_rings);
> +
> +	return ringacc;
> +}

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux