Received: by 10.223.176.46 with SMTP id f43csp4174807wra; Tue, 23 Jan 2018 05:33:52 -0800 (PST) X-Google-Smtp-Source: AH8x226du80PBrAWyeKz0ifIjfRpVjQXbBH0PJH5JvFGn1USRWK+6MutSKVgJwwNJHJsohVdoTUX X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr2877322plb.81.1516714432655; Tue, 23 Jan 2018 05:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516714432; cv=none; d=google.com; s=arc-20160816; b=Uvqr+2PBJ5fojeeJyvABN9CHLPvM8TnfLcjKUphaDyE1CENWCTVhGY1vjEL8iUfCJT A+ogYj93DzVw+2Y8wlOKyqbHsce25uK8IMXdZxnNV7XzbZ7WnEsTQjCJpKacwa28VI/h 1hZ8vMb30OGsWiRD9g2uUaOmrcGGCw9h+1UNyuzTtxJ/ZqarC4fzUG/14tt9iyVEvEdI bHabb/xWs77OObnhzijge2mIzMv1EYwoUlnNsiUKJRtrma6a5QiAxEJO7azPgtwBUEnQ 8Pe6syoZ1rEJLdfdo1WWTK/t9YumEfIsyNd8oJIg+AewkscILYglzVY4qF6qbyvu7icR F0Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=EwauOC4IBMk7/GQYSBF7nz1ewIE9CCt05dygphptWKU=; b=FibBaGLflYEEMpz3Jngc97WShbD7ooeP2g3Luy6Qi+LNQs9BDGyBVauNUVWPH/RLAO uPlTnA/c8nAL1Wl5jTjQjoRncg+j3SpGgJ9dDnuobuateDGhw8li0R5MrMWKd115cylg zibAngZYL4GqLssEL83Z7iK6JXhwTxuMJJCKbQhbOUInF+qv6gdVipQyYoxdfm4DXADa VbVura6by8PTRT7jMi7uCedujJ/F8Exke7aGn3oHYRKzQTsWqzGX3iX3M7qrswlknQKx zJ9a8RSdjhgYWbRriylu8N9HkkVcEGCU+Sz8Axf6CaiPM7KBfXaw5NJpM7E/LmAXujxI Q5MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBNFiH0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24-v6si4698232plo.608.2018.01.23.05.33.38; Tue, 23 Jan 2018 05:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBNFiH0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751921AbeAWNcl (ORCPT + 99 others); Tue, 23 Jan 2018 08:32:41 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:42403 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbeAWNcj (ORCPT ); Tue, 23 Jan 2018 08:32:39 -0500 Received: by mail-wr0-f194.google.com with SMTP id e41so568346wre.9 for ; Tue, 23 Jan 2018 05:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=EwauOC4IBMk7/GQYSBF7nz1ewIE9CCt05dygphptWKU=; b=gBNFiH0YaIpeVBxw/+l6j7uY1371NHXT6tycAh15PuOD/LuNfr2dKbihB9/gDHltGa kSE2rk9dcRP3QMf3yGP8PQ9OWVWRm2e6jRdHacXHViwl0XoNq8T3/C/rZ4cI9YC3P/IG 2Lg5S8FpBos0EkPopAK4TlzUqPd2tsvxeL3rs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=EwauOC4IBMk7/GQYSBF7nz1ewIE9CCt05dygphptWKU=; b=S2bcig7iDX+zgg6r+19kQWn/BntnQHQjV8RTRumoD/cJs7zkw0UlvacprmN+yiNMlk xw2z13DAnU6MzOS0pGFgW+Uj1lamdHWuCojz5AZMuwvrbhAUbH94bpmW5bkqUGAJxXqb G42v/rh4pggVfoD1EH/Ug28rWDQjO6MTJRtQZ2xuw9k8Zc+F0Cf/HN/s4AQw7RraSN9o OEDKF0cjUodIpl2E0AY8PK+1LMh+dAnLlCqH4yapsuVeBHhwNbCo+j8QW5PvXC/gLJ2j JiHdh0jhVoZZB8p/ZoBkn3LqU/tQB79I6VYQ+T0iGhft3wvZxLSs/0FXbiYyppZDtRZX nP4g== X-Gm-Message-State: AKwxytfPZGPsTgAHykmHbsqD5Rmz7isMDjz6fOTsYYsOHbPMu9qPptbO XH4Fp0Pxt0G+v5Q6GH9bn5kTeA== X-Received: by 10.223.136.150 with SMTP id f22mr2274008wrf.246.1516714357722; Tue, 23 Jan 2018 05:32:37 -0800 (PST) Received: from dell ([2.27.167.60]) by smtp.gmail.com with ESMTPSA id e67sm4500742wmd.7.2018.01.23.05.32.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 05:32:36 -0800 (PST) Date: Tue, 23 Jan 2018 13:32:34 +0000 From: Lee Jones To: Fabrice Gasnier Cc: thierry.reding@gmail.com, robh+dt@kernel.org, alexandre.torgue@st.com, benjamin.gaignard@linaro.org, mark.rutland@arm.com, linux@armlinux.org.uk, mcoquelin.stm32@gmail.com, benjamin.gaignard@st.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: Re: [PATCH 4/8] mfd: stm32-timers: add support for dmas Message-ID: <20180123133234.xmep76cgdremnj47@dell> References: <1516106631-18722-1-git-send-email-fabrice.gasnier@st.com> <1516106631-18722-5-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516106631-18722-5-git-send-email-fabrice.gasnier@st.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > 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 > +#include > #include > > #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