From: Maxime Coquelin <mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: M'boumba Cedric Madianga
<cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
pawel.moll-5wv7dgnIgG8@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/4] dmaengine: Add STM32 DMA driver
Date: Mon, 12 Oct 2015 22:09:53 +0200 [thread overview]
Message-ID: <561C1391.2000802@gmail.com> (raw)
In-Reply-To: <1444317612-818-3-git-send-email-cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Hi Cedric,
On 10/08/2015 05:20 PM, M'boumba Cedric Madianga wrote:
> This patch adds support for the STM32 DMA controller.
>
> Signed-off-by: M'boumba Cedric Madianga <cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/dma/Kconfig | 12 +
> drivers/dma/Makefile | 1 +
> drivers/dma/stm32-dma.c | 1193 +++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 1206 insertions(+)
> create mode 100644 drivers/dma/stm32-dma.c
>
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 5c931d4..4c6b37b 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -431,6 +431,18 @@ config STE_DMA40
> help
> Support for ST-Ericsson DMA40 controller
>
> +config STM32_DMA
> + tristate "STMicroelectronics STM32 dma support"
s/dma/DMA/ ?
> diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
> new file mode 100644
> index 0000000..9814ca5
> --- /dev/null
> +++ b/drivers/dma/stm32-dma.c
> @@ -0,0 +1,1193 @@
> +#define STM32_DMA_LISR 0x0000 /* DMA Low Int Status Reg */
> +#define STM32_DMA_HISR 0x0004 /* DMA High Int Status Reg */
> +#define STM32_DMA_LIFCR 0x0008 /* DMA Low Int Flag Clear Reg */
> +#define STM32_DMA_HIFCR 0x000C /* DMA High Int Flag Clear Reg */
We usually use lower case for numerical values.
> +static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,
> + enum dma_transfer_direction direction,
> + enum dma_slave_buswidth *buswidth)
> +{
> + enum dma_slave_buswidth src_addr_width, dst_addr_width;
> + u32 src_bus_width, dst_bus_width, src_burst_size, dst_burst_size;
> + u32 src_maxburst, dst_maxburst;
> + dma_addr_t src_addr, dst_addr;
> +
> + src_addr_width = chan->dma_sconfig.src_addr_width;
> + dst_addr_width = chan->dma_sconfig.dst_addr_width;
> + src_maxburst = chan->dma_sconfig.src_maxburst;
> + dst_maxburst = chan->dma_sconfig.dst_maxburst;
> + src_addr = chan->dma_sconfig.src_addr;
> + dst_addr = chan->dma_sconfig.dst_addr;
> +
> + switch (direction) {
> + case DMA_MEM_TO_DEV:
> + dst_bus_width = stm32_get_dma_width(chan, dst_addr_width);
> + if (dst_bus_width < 0)
> + return -EINVAL;
dst_bus_width is a u32, so cannot be negative.
Also, you should propagate de error returned by stm32_get_dma_width().
The comment also applies below:
> + dst_burst_size = stm32_get_dma_burst(chan, dst_maxburst);
> + if (dst_burst_size < 0)
> + return -EINVAL;
> + if (!src_addr_width)
> + src_addr_width = dst_addr_width;
> + src_bus_width = stm32_get_dma_width(chan, src_addr_width);
> + if (src_bus_width < 0)
> + return -EINVAL;
> + src_burst_size = stm32_get_dma_burst(chan, src_maxburst);
> + if (src_burst_size < 0)
> + return -EINVAL;
> +
> + chan->chan_reg.dma_scr |= (chan->chan_reg.dma_scr &
> + ~(STM32_DMA_SCR_DIR_MASK | STM32_DMA_SCR_PSIZE_MASK |
> + STM32_DMA_SCR_MSIZE_MASK | STM32_DMA_SCR_PBURST_MASK |
> + STM32_DMA_SCR_MBURST_MASK)) |
> + STM32_DMA_SCR_DIR(STM32_DMA_MEM_TO_DEV) |
> + STM32_DMA_SCR_PSIZE(dst_bus_width) |
> + STM32_DMA_SCR_MSIZE(src_bus_width) |
> + STM32_DMA_SCR_PBURST(dst_burst_size) |
> + STM32_DMA_SCR_MBURST(src_burst_size);
> +
> + chan->chan_reg.dma_spar = chan->dma_sconfig.dst_addr;
> + *buswidth = dst_addr_width;
> + return 0;
> +
> + case DMA_DEV_TO_MEM:
> + src_bus_width = stm32_get_dma_width(chan, src_addr_width);
> + if (src_bus_width < 0)
> + return -EINVAL;
> + src_burst_size = stm32_get_dma_burst(chan, src_maxburst);
> + if (src_burst_size < 0)
> + return -EINVAL;
> + if (!dst_addr_width)
> + dst_addr_width = src_addr_width;
> + dst_bus_width = stm32_get_dma_width(chan, dst_addr_width);
> + if (dst_bus_width < 0)
> + return -EINVAL;
> + dst_burst_size = stm32_get_dma_burst(chan, dst_maxburst);
> + if (dst_burst_size < 0)
> + return -EINVAL;
> +
> + chan->chan_reg.dma_scr |= (chan->chan_reg.dma_scr &
> + ~(STM32_DMA_SCR_DIR_MASK | STM32_DMA_SCR_PSIZE_MASK |
> + STM32_DMA_SCR_MSIZE_MASK | STM32_DMA_SCR_PBURST_MASK |
> + STM32_DMA_SCR_MBURST_MASK)) |
> + STM32_DMA_SCR_DIR(STM32_DMA_DEV_TO_MEM) |
> + STM32_DMA_SCR_PSIZE(src_bus_width) |
> + STM32_DMA_SCR_MSIZE(dst_bus_width) |
> + STM32_DMA_SCR_PBURST(src_burst_size) |
> + STM32_DMA_SCR_MBURST(dst_burst_size);
> + chan->chan_reg.dma_spar = chan->dma_sconfig.src_addr;
> + *buswidth = chan->dma_sconfig.src_addr_width;
> + return 0;
> +
> + default:
> + dev_err(chan2dev(chan), "Dma direction is not supported\n");
> + return -EINVAL;
> + }
> +
> + return -EINVAL;
> +}
Thanks,
Maxime
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-10-12 20:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 15:20 [PATCH 0/4] Add support for STM32 DMA M'boumba Cedric Madianga
2015-10-08 15:20 ` [PATCH 1/4] dt-bindings: Document the STM32 DMA bindings M'boumba Cedric Madianga
2015-10-08 15:43 ` Arnd Bergmann
2015-10-08 16:01 ` M'boumba Cedric Madianga
[not found] ` <CAOAejn0y+6uFbho3iv37xh6=zKevnp_6MxOEw4e9Oc4U2x_csQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-08 19:26 ` Arnd Bergmann
2015-10-08 20:25 ` M'boumba Cedric Madianga
[not found] ` <CAOAejn0x68GaEEfTZbsi5VSJt+Um-bV2Mcmc2pxUwh5QjD=ZYw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-08 20:40 ` Arnd Bergmann
2015-10-12 19:16 ` Maxime Coquelin
2015-10-08 15:20 ` [PATCH 2/4] dmaengine: Add STM32 DMA driver M'boumba Cedric Madianga
[not found] ` <1444317612-818-3-git-send-email-cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-12 20:09 ` Maxime Coquelin [this message]
2015-10-13 11:25 ` M'boumba Cedric Madianga
[not found] ` <CAOAejn2rX2f7YM-JYeJv98JbPwg1Uir_30abVg1XSTKNjUHVSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-13 11:50 ` M'boumba Cedric Madianga
2015-10-08 15:20 ` [PATCH 3/4] ARM: dts: Add STM32 DMA support for STM32F429 MCU M'boumba Cedric Madianga
2015-10-08 15:20 ` [PATCH 4/4] ARM: configs: Add STM32 DMA support in STM32 defconfig M'boumba Cedric Madianga
2015-10-12 20:11 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561C1391.2000802@gmail.com \
--to=mcoquelin.stm32-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).