From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
Cc: thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
alexandre.torgue-qxv4g6HH51o@public.gmane.org,
benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org,
mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
benjamin.gaignard-qxv4g6HH51o@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 4/8] mfd: stm32-timers: add support for dmas
Date: Tue, 23 Jan 2018 13:32:34 +0000 [thread overview]
Message-ID: <20180123133234.xmep76cgdremnj47@dell> (raw)
In-Reply-To: <1516106631-18722-5-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
On Tue, 16 Jan 2018, Fabrice Gasnier wrote:
> STM32 Timers can support up to 7 dma requests:
> 4 channels, update, compare and trigger.
> Optionally request part, or all dmas from stm32-timers MFD core.
> Also, keep reference of device's bus address to allow child drivers to
> transfer data from/to device by using dma.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
> ---
> drivers/mfd/stm32-timers.c | 37 ++++++++++++++++++++++++++++++++++++-
> include/linux/mfd/stm32-timers.h | 14 ++++++++++++++
> 2 files changed, 50 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
> index a6675a4..372b51e 100644
> --- a/drivers/mfd/stm32-timers.c
> +++ b/drivers/mfd/stm32-timers.c
> @@ -29,6 +29,23 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
> regmap_write(ddata->regmap, TIM_ARR, 0x0);
> }
>
> +static void stm32_timers_dma_probe(struct device *dev,
> + struct stm32_timers *ddata)
> +{
> + int i;
> + char name[4];
> +
> + for (i = STM32_TIMERS_DMA_CH1; i <= STM32_TIMERS_DMA_CH4; i++) {
> + snprintf(name, ARRAY_SIZE(name), "ch%1d", i + 1);
> + ddata->dmas[i] = dma_request_slave_channel(dev, name);
And if any of them fail?
> + }
> + ddata->dmas[STM32_TIMERS_DMA_UP] = dma_request_slave_channel(dev, "up");
> + ddata->dmas[STM32_TIMERS_DMA_TRIG] =
> + dma_request_slave_channel(dev, "trig");
> + ddata->dmas[STM32_TIMERS_DMA_COM] =
> + dma_request_slave_channel(dev, "com");
Can you format these in the same why. This hurts my eyes.
> +}
> +
> static int stm32_timers_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -44,6 +61,7 @@ static int stm32_timers_probe(struct platform_device *pdev)
> mmio = devm_ioremap_resource(dev, res);
> if (IS_ERR(mmio))
> return PTR_ERR(mmio);
> + ddata->phys_base = res->start;
What do you use this for?
> ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio,
> &stm32_timers_regmap_cfg);
> @@ -56,9 +74,25 @@ static int stm32_timers_probe(struct platform_device *pdev)
>
> stm32_timers_get_arr_size(ddata);
>
> + stm32_timers_dma_probe(dev, ddata);
> +
Surely this can fail?
> platform_set_drvdata(pdev, ddata);
>
> - return devm_of_platform_populate(&pdev->dev);
> + return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
> +}
> +
> +static int stm32_timers_remove(struct platform_device *pdev)
> +{
> + struct stm32_timers *ddata = platform_get_drvdata(pdev);
> + int i;
> +
> + of_platform_depopulate(&pdev->dev);
> +
> + for (i = 0; i < STM32_TIMERS_MAX_DMAS; i++)
> + if (ddata->dmas[i])
> + dma_release_channel(ddata->dmas[i]);
> +
> + return 0;
> }
>
> static const struct of_device_id stm32_timers_of_match[] = {
> @@ -69,6 +103,7 @@ static int stm32_timers_probe(struct platform_device *pdev)
>
> static struct platform_driver stm32_timers_driver = {
> .probe = stm32_timers_probe,
> + .remove = stm32_timers_remove,
> .driver = {
> .name = "stm32-timers",
> .of_match_table = stm32_timers_of_match,
> diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h
> index ce7346e..2b4ffb9 100644
> --- a/include/linux/mfd/stm32-timers.h
> +++ b/include/linux/mfd/stm32-timers.h
> @@ -10,6 +10,7 @@
> #define _LINUX_STM32_GPTIMER_H_
>
> #include <linux/clk.h>
> +#include <linux/dmaengine.h>
> #include <linux/regmap.h>
>
> #define TIM_CR1 0x00 /* Control Register 1 */
> @@ -67,9 +68,22 @@
> #define TIM_BDTR_BKF_SHIFT 16
> #define TIM_BDTR_BK2F_SHIFT 20
>
> +enum stm32_timers_dmas {
> + STM32_TIMERS_DMA_CH1,
> + STM32_TIMERS_DMA_CH2,
> + STM32_TIMERS_DMA_CH3,
> + STM32_TIMERS_DMA_CH4,
> + STM32_TIMERS_DMA_UP,
> + STM32_TIMERS_DMA_TRIG,
> + STM32_TIMERS_DMA_COM,
> + STM32_TIMERS_MAX_DMAS,
> +};
> +
> struct stm32_timers {
> struct clk *clk;
> struct regmap *regmap;
> + phys_addr_t phys_base;
> u32 max_arr;
> + struct dma_chan *dmas[STM32_TIMERS_MAX_DMAS];
> };
> #endif
--
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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:[~2018-01-23 13:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 12:43 [PATCH 0/8] Add support for PWM input capture on STM32 Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 1/8] pwm: stm32: fix, remove unused struct device Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 2/8] pwm: stm32: protect common prescaler for all channels Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 3/8] dt-bindings: mfd: stm32-timers: add support for dmas Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 4/8] " Fabrice Gasnier
[not found] ` <1516106631-18722-5-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2018-01-23 13:32 ` Lee Jones [this message]
2018-01-23 13:57 ` Fabrice Gasnier
[not found] ` <e611b40f-bd37-aa2d-afd9-997b86d55441-qxv4g6HH51o@public.gmane.org>
2018-01-23 15:30 ` Lee Jones
2018-01-23 15:52 ` Fabrice Gasnier
[not found] ` <ee021839-3298-d01b-8890-619aca0399a7-qxv4g6HH51o@public.gmane.org>
2018-01-23 16:41 ` Lee Jones
2018-01-24 8:40 ` Fabrice Gasnier
2018-01-24 14:56 ` Lee Jones
2018-01-24 15:30 ` Fabrice Gasnier
2018-01-24 15:43 ` cas
2018-01-16 12:43 ` [PATCH 5/8] pwm: stm32: add capture support Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 6/8] pwm: stm32: improve capture by tuning counter prescaler Fabrice Gasnier
[not found] ` <1516106631-18722-1-git-send-email-fabrice.gasnier-qxv4g6HH51o@public.gmane.org>
2018-01-16 12:43 ` [PATCH 7/8] pwm: stm32: use input prescaler to improve period capture Fabrice Gasnier
2018-01-16 12:43 ` [PATCH 8/8] ARM: dts: stm32: Enable pwm3 input capture on stm32f429i-eval Fabrice Gasnier
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=20180123133234.xmep76cgdremnj47@dell \
--to=lee.jones-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=alexandre.torgue-qxv4g6HH51o@public.gmane.org \
--cc=benjamin.gaignard-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=benjamin.gaignard-qxv4g6HH51o@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=fabrice.gasnier-qxv4g6HH51o@public.gmane.org \
--cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mcoquelin.stm32-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@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