Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp260148imu; Fri, 25 Jan 2019 01:43:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7YbQo163jpK2ITajuo+2pMtmLDJ/2FVq06a583V0vhQkga/yG1zPAGzAH2lTT5ypJpFbZN X-Received: by 2002:a63:89c2:: with SMTP id v185mr8628946pgd.97.1548409439757; Fri, 25 Jan 2019 01:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548409439; cv=none; d=google.com; s=arc-20160816; b=fx4Qk//jWL3KodIynW+l+ezRr7dlwljKUniIosIRXviy5nGP3yy5NAy34YhNnhKkrA hyZoJlPRQaa1Etw2NuGXy+XEZnpfS46Ev3YK1haf6auPqp5a4zlqKuxyE3fkj3TOquZL 9CXCiNgOGKuXci+IpbAIGkJ5XMLjIXh7xzVrC97L5Wupe9mV7a2tAeRNgd9Rc55tk5iP 9d3xzsB/HKRlffa5Yelq082jD+XU5CPre+w6cRuTp7pIsV5QE68qg6q9X495HmuE7QDO eb0syrgXpv55QmBdcdBhgSNGblWPLWpaMRZL/B8TdivUGjn6HKLR6ZgTDyT/C7g8dNXd NPiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=BEe+6RLPRmCQDA1ePvfoDasIyZXVGlXJX4z0vsuuVLE=; b=wL6YXHFqT9lPwLsgZju8mV0Fi7G8Q+7DGHI2a3n5+P8RVwJGLA94wIDLVyUdq/ZfsL Pz6aNMi2K/OZQNWgKfTshw090EmiEhvLI5yTId/hvEbZi2S20QiE3M7i38PCQ8E/Q2eZ d5G9Vg4mtKxLVuU5q4Di0f0N0j1Tt5TITGguZjiFvjZHBhb/pmP4kQd4aagZsQLB+HYz IuX/0z2PeF8H/PlZ6Ml0lqKhzLhfmMWQ3RGACIW8qsrXiw/GzMgF5a/p8p2qw8FVea9G BNBGpA1dFDpcwAR+wp4e9HDaeTmrFvQ7H1NKDoiP06J7hcRGlsM4kd11c8GH6FyEtKy0 LByg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g83si25906484pfb.278.2019.01.25.01.43.43; Fri, 25 Jan 2019 01:43:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728973AbfAYJmw (ORCPT + 99 others); Fri, 25 Jan 2019 04:42:52 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58099 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbfAYJmw (ORCPT ); Fri, 25 Jan 2019 04:42:52 -0500 Received: from kresse.hi.pengutronix.de ([2001:67c:670:100:1d::2a]) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1gmy0c-0002bH-MG; Fri, 25 Jan 2019 10:42:46 +0100 Message-ID: <1548409366.28802.39.camel@pengutronix.de> Subject: Re: [PATCH v4 1/5] dmaengine: imx-sdma: add clock ratio 1:1 check From: Lucas Stach To: "Angus Ainslie (Purism)" Cc: angus.ainslie@puri.sm, Vinod Koul , dmaengine@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Baluta Date: Fri, 25 Jan 2019 10:42:46 +0100 In-Reply-To: <20190125025528.15645-2-angus@akkea.ca> References: <20190120023150.17138-1-angus@akkea.ca> <20190125025528.15645-1-angus@akkea.ca> <20190125025528.15645-2-angus@akkea.ca> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::2a X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Donnerstag, den 24.01.2019, 19:55 -0700 schrieb Angus Ainslie (Purism): > On i.mx8 mscale B0 chip, AHB/SDMA clock ratio 2:1 can't be supportted, > since SDMA clock ratio has to be increased to 250Mhz, AHB can't reach > to 500Mhz, so use 1:1 instead. > > > Based on NXP commit MLK-16841-1 by Robin Gong > > > Signed-off-by: Angus Ainslie (Purism) > --- >  drivers/dma/imx-sdma.c | 21 +++++++++++++++++---- >  1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > index 0b3a67ff8e82..5e5ef0b5a973 100644 > --- a/drivers/dma/imx-sdma.c > +++ b/drivers/dma/imx-sdma.c > @@ -440,6 +440,8 @@ struct sdma_engine { > > >   unsigned int irq; > > >   dma_addr_t bd0_phys; > > >   struct sdma_buffer_descriptor *bd0; > > + /* clock ratio for AHB:SDMA core. 1:1 is 1, 2:1 is 0*/ > > > + bool clk_ratio; >  }; >   >  static int sdma_config_write(struct dma_chan *chan, > @@ -662,8 +664,14 @@ static int sdma_run_channel0(struct sdma_engine *sdma) > >   dev_err(sdma->dev, "Timeout waiting for CH0 ready\n"); >   > >   /* Set bits of CONFIG register with dynamic context switching */ > > - if (readl(sdma->regs + SDMA_H_CONFIG) == 0) > > - writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG); > + if ((readl(sdma->regs + SDMA_H_CONFIG) & ~SDMA_H_CONFIG_ACR) == 0) { The intention of this code was probably to set the CSM bit if they weren't set before, so masking out individual bits from the register and risking to skip this when one of the other bits was set doesn't seem right. I guess the whole block can be simplified to: reg = readl(sdma->regs + SDMA_H_CONFIG); if ((reg & SDMA_H_CONFIG_CSM) != SDMA_H_CONFIG_CSM) reg |= SDMA_H_CONFIG_CSM; writel_relaxed(reg, sdma->regs + SDMA_H_CONFIG); Regards, Lucas > + reg = SDMA_H_CONFIG_CSM; > + > > + if (sdma->clk_ratio) > > + reg |= SDMA_H_CONFIG_ACR; > + > > + writel_relaxed(reg, sdma->regs + SDMA_H_CONFIG); > > + } >   > >   return ret; >  } > @@ -1840,6 +1848,9 @@ static int sdma_init(struct sdma_engine *sdma) > >   if (ret) > >   goto disable_clk_ipg; >   > > + if (clk_get_rate(sdma->clk_ahb) == clk_get_rate(sdma->clk_ipg)) > > + sdma->clk_ratio = 1; > + > >   /* Be sure SDMA has not started yet */ > >   writel_relaxed(0, sdma->regs + SDMA_H_C0PTR); >   > @@ -1880,8 +1891,10 @@ static int sdma_init(struct sdma_engine *sdma) > >   writel_relaxed(0x4050, sdma->regs + SDMA_CHN0ADDR); >   > >   /* Set bits of CONFIG register but with static context switching */ > > - /* FIXME: Check whether to set ACR bit depending on clock ratios */ > > - writel_relaxed(0, sdma->regs + SDMA_H_CONFIG); > > + if (sdma->clk_ratio) > > + writel_relaxed(SDMA_H_CONFIG_ACR, sdma->regs + SDMA_H_CONFIG); > > + else > > + writel_relaxed(0, sdma->regs + SDMA_H_CONFIG); >   > >   writel_relaxed(ccb_phys, sdma->regs + SDMA_H_C0PTR); >