Re: [PATCH v2 2/2] DW DMAC: add multi-block property to device tree
From: Andy Shevchenko
Date: Fri Nov 18 2016 - 12:45:14 EST
On Fri, 2016-11-18 at 19:53 +0300, Eugeniy Paltsev wrote:
> Several versions of DW DMAC have multi block transfers hardware
> support. Hardware support of multi block transfers is disabled
> by default if we use DT to configure DMAC and software emulation
> of multi block transfers used instead.
> Add multi-block property, so it is possible to enable hardware
> multi block transfers (if present) via DT.
>
> Switch from per device is_nollp variable to multi_block array
> to be able enable/disable multi block transfers separately per
> channel.
>
> Update DT documentation.
>
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@xxxxxxxxxxxx>
> ---
> ÂDocumentation/devicetree/bindings/dma/snps-dma.txt | 2 ++
> Âdrivers/dma/dw/core.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 2 +-
> Âdrivers/dma/dw/platform.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 5 +++++
> Âinclude/linux/platform_data/dma-dw.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 4 ++--
> Â4 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/dma/snps-dma.txt
> b/Documentation/devicetree/bindings/dma/snps-dma.txt
> index 0f55832..03d6d6d 100644
> --- a/Documentation/devicetree/bindings/dma/snps-dma.txt
> +++ b/Documentation/devicetree/bindings/dma/snps-dma.txt
> @@ -27,6 +27,8 @@ Optional properties:
> ÂÂÂthat services interrupts for this device
> Â- is_private: The device channels should be marked as private and not
> for by the
> ÂÂÂgeneral purpose DMA channel allocator. False if not passed.
> +- multi-block: Multi block transfers supported by hardware per AHB
> master.
> +ÂÂ0 (default): not supported, 1: supported.
Since default is "not supported" you have to update users accordingly.
(Check platform data and existing DTS).
Â
> ÂExample:
> Â
> diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
> index c2c0a61..f2a3d06 100644
> --- a/drivers/dma/dw/core.c
> +++ b/drivers/dma/dw/core.c
> @@ -1569,7 +1569,7 @@ int dw_dma_probe(struct dw_dma_chip *chip)
> Â (dwc_params >> DWC_PARAMS_MBLK_EN &
> 0x1) == 0;
> Â } else {
> Â dwc->block_size = pdata->block_size;
> - dwc->nollp = pdata->is_nollp;
> + dwc->nollp = pdata->multi_block[i];
This inverts the default logic.
> Â }
> Â }
> Â
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index aa7a5c1..b262fd3 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -152,6 +152,11 @@ dw_dma_parse_dt(struct platform_device *pdev)
> Â pdata->data_width[tmp] = BIT(arr[tmp] &
> 0x07);
> Â }
> Â
> + if (!of_property_read_u32_array(np, "multi-block", arr,
> nr_masters)) {
> + for (tmp = 0; tmp < nr_masters; tmp++)
> + pdata->multi_block[tmp] = arr[tmp];
> + }
> +
> Â return pdata;
> Â}
> Â#else
> diff --git a/include/linux/platform_data/dma-dw.h
> b/include/linux/platform_data/dma-dw.h
> index 5f0e11e..0773bb4 100644
> --- a/include/linux/platform_data/dma-dw.h
> +++ b/include/linux/platform_data/dma-dw.h
> @@ -40,19 +40,18 @@ struct dw_dma_slave {
> Â * @is_private: The device channels should be marked as private and
> not for
> Â * by the general purpose DMA channel allocator.
> Â * @is_memcpy: The device channels do support memory-to-memory
> transfers.
> - * @is_nollp: The device channels does not support multi block
> transfers.
> Â * @chan_allocation_order: Allocate channels starting from 0 or 7
> Â * @chan_priority: Set channel priority increasing from 0 to 7 or 7
> to 0.
> Â * @block_size: Maximum block size supported by the controller
> Â * @nr_masters: Number of AHB masters supported by the controller
> Â * @data_width: Maximum data width supported by hardware per AHB
> master
> Â * (in bytes, power of 2)
> + * @multi_block: Multi block transfers supported by hardware per AHB
> master.
> Â */
> Âstruct dw_dma_platform_data {
> Â unsigned int nr_channels;
> Â bool is_private;
> Â bool is_memcpy;
> - bool is_nollp;
> Â#define CHAN_ALLOCATION_ASCENDING 0 /* zero to seven */
> Â#define CHAN_ALLOCATION_DESCENDING 1 /* seven to zero
> */
> Â unsigned char chan_allocation_order;
> @@ -62,6 +61,7 @@ struct dw_dma_platform_data {
> Â unsigned int block_size;
> Â unsigned char nr_masters;
> Â unsigned char data_width[DW_DMA_MAX_NR_MASTERS];
> + unsigned char multi_block[DW_DMA_MAX_NR_MASTERS];
> Â};
> Â
> Â#endif /* _PLATFORM_DATA_DMA_DW_H */
--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy