Received: by 10.223.176.46 with SMTP id f43csp4307985wra; Tue, 23 Jan 2018 07:31:27 -0800 (PST) X-Google-Smtp-Source: AH8x224neEBl3NizhTQHZwswUZ689xywio8S5SpzxETdgHEnXOUG8+eEHLgqAcQkX2I6cdfWtPwC X-Received: by 10.36.36.66 with SMTP id f63mr4202751ita.41.1516721487419; Tue, 23 Jan 2018 07:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516721487; cv=none; d=google.com; s=arc-20160816; b=S9jOD+t5Hx1H3Cw7BZJ9IigRnBc/zlB8cY72Ehf6XUHMyKFsCDPluV8Ny/4sn036kB 3jxmyUA8FK4MogymU3z8/fjaKzzLm9uoyrtqPPB48q7CAiVIYVxURyT+PfyjHQSFJ+XM QjBqfqCNshtQYZcY2laOVywwOzkO+whYrPAKgpEqWVFn7XYTGOJcuW2eq0TyW9XQhJZh Bocw6t5n6rdLFi2JXhAAHtuB6ktqmjj5yeoGhUaizzFU89U8Z+CNcraAcU5uVYFDJjIc LbAXOsrVy1JzjNBOchlkwklbFRKWhQ1NvrO1re7ba00HJH36zsxsaqHKYjlkLtxbF0wj wVvw== 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=nrxCRS146jkPYvVeQzGtHLDqqgC4kkbszyLOUwh4SVs=; b=Pkq5RShbMnPA0E13JPysT7WFDX4LsrJCcW9TXptbDcVHU94edcC1Lh1pvRMWKzZLcK QlyLk81+fZgemvbqRRNyblNPXnqDTA+VddmZQcnB7gwkWHxC4GscEFeaCsDo0QewdDm1 h/DWe+2QuqrsrkzODzjo4WPa0/Mj5YIZYksjxOoAo5b4Bq10M2QKyBnSSHIP4gbS6wT9 hLRmDAmONaZt4wDiyZ6AxdLOvTAod5CliTev2eVThyA/VciRhMqYdAjS/LZihFAcHxdS nExkeTFdlRbFT4QsoC07OZVco0IBEoKpdmJMGrOniI1sqwJQTKa+tZwdG9SPvNqLDOM4 nqgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e2gLaotG; 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 e136si8670416ite.167.2018.01.23.07.31.13; Tue, 23 Jan 2018 07:31:27 -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=e2gLaotG; 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 S1751379AbeAWPam (ORCPT + 99 others); Tue, 23 Jan 2018 10:30:42 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40635 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbeAWPaj (ORCPT ); Tue, 23 Jan 2018 10:30:39 -0500 Received: by mail-wm0-f67.google.com with SMTP id v123so2673629wmd.5 for ; Tue, 23 Jan 2018 07:30:39 -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=nrxCRS146jkPYvVeQzGtHLDqqgC4kkbszyLOUwh4SVs=; b=e2gLaotG+fDUG69dkABj8q6dFKm4J9mlrB02W8BzQkmUMU/RyTDHRpaDH4aiAEUYwr V4d7Me4nE4kaZc97CRybNbA1r68qxfmtSXAmxHmimFkzlyGGmFhShEB+6ahvqXlr5Z4O mdaNCtsM2W8Fke/0lH2Zv1rlVtkU7ZBit6d5s= 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=nrxCRS146jkPYvVeQzGtHLDqqgC4kkbszyLOUwh4SVs=; b=lB5ZoVSKogjPKJBCV7d3ajCgXZuaD+qod4xjfAqK1FMeVJZTve8IpLUBQWqEbdvSZS Fuxdj6eKA3RR1o8+AFnKfAhTttAdvyglhLrmCHDWCX0vpsz/S0mWdVGvD7v/igRDMYSS yGPbn3JZmHOjne2qANulT2mcC88SaNiu9ayysH2lnduRWAB7YCJanSkGwzqw13r4cQKo PNdzPfpzyANO6WvJvFSTbezQ4qfkpyRVhHYxlLFjU6OYiX6xeEPVNThs8b3msuBMoY7x c30d+vczWZzTICiDCMlupgKrypvQHHJihacg4gsVZmK/WYPCDNww7HI0ZH5RGUTc4fyw PKVQ== X-Gm-Message-State: AKwxytdbrfwgoM+7aFR+iTo24u/ujoJfIKoPIyt+p+WArIDc539HsXwV ZvzlcebHEQGDbOcku5bdgX9NLg== X-Received: by 10.28.10.206 with SMTP id 197mr2119531wmk.61.1516721438309; Tue, 23 Jan 2018 07:30:38 -0800 (PST) Received: from dell ([2.27.167.60]) by smtp.gmail.com with ESMTPSA id g64sm8753807wmf.20.2018.01.23.07.30.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 07:30:37 -0800 (PST) Date: Tue, 23 Jan 2018 15:30:35 +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: <20180123153035.2rvhspe2m5ej57op@dell> References: <1516106631-18722-1-git-send-email-fabrice.gasnier@st.com> <1516106631-18722-5-git-send-email-fabrice.gasnier@st.com> <20180123133234.xmep76cgdremnj47@dell> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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, 23 Jan 2018, Fabrice Gasnier wrote: > On 01/23/2018 02:32 PM, Lee Jones wrote: > > 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? > > Hi Lee, > > If some of these fails, reference will be NULL. It is checked in child > driver (pwm for instance) at runtime. Support is being added as an > option: pwm capture will simply be unavailable in this case (fail with > error). Can you place a simple one-line comment in here please. Or else someone will come along and add error handling for you. > >> + } > >> + 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. > > I use enum values and try to match as possible with reference manual for > "up", "trig" & "com" names. > Would have some suggestion to beautify this? I just mean, can you push the first dma_request_slave_channel() call on to the next line, so each of the calls are formatted in the same manner please? > >> +} > >> + > >> 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? > > This is used in in child driver (pwm) for capture data transfer by dma. Might be worth being clear about that. Perhaps pass in 'dma_base' (phys_base + offset) instead? -- Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog