Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3707146imu; Mon, 28 Jan 2019 09:22:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IamsS4O1q5WDkkgetob2SgYtFDvi1ESMcJ1d7/i2geeKSeA5NAgZZR2rTZzGXemWpdH2B+e X-Received: by 2002:a17:902:9687:: with SMTP id n7mr1157832plp.94.1548696146335; Mon, 28 Jan 2019 09:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696146; cv=none; d=google.com; s=arc-20160816; b=xd/neungDWAdTY+hPvdUOH+vVCq0aDmNpRidMuq+TZnPrGgi2cbtoDcUSkTNFp5h9X 6cYPsapnlxqXVAKMmIlwFCjJ9yWC89bA/obbboBK8hRtjPzbfURNF+2Pqfw5+ajpMKTq 924YoALbaPvNfqtZzSzHky8yAKccR5EOvviLT+JK3xmAnkHSMbogGt7dKKAMrgxc1DPC XydCHZH7EPk8o6HVodcD8Zx8liQDfmOgBKHN0GEjE62X99TU3tZfPC3j8GGEdAQCZNpv goYLJsVv7bTaaI/0V1ZrgZ31oSRdXBhgbX4YgspfZ5O1Thk9qwtI7O8zC61GvN0W6cfK Ue2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-signature; bh=ecV0FVs8pf7wdJfAacDQzQaog4WDhg7OxsMhlavdhgo=; b=uD9/Ty2yJ+sTfqt75jHtx2zZkR0/esy4OfAVZheNzqBNTXGOUwf07naFNwIQBs3NIo /Q6DDBRgADPi06wXKj4DbXRcnrCjXjAEnzFXPuRVXnE9VjW9wvu8FxSI1JByY1apjUeU ndbveWN/Ooijdb7JLn/xzzwIfJftYcqDje/60PnRtuehXesZGv/qojk4T4eFGMSmFpq7 O8LFaabx4ALDxK2JUoAMBl8L/IKLv1ayJwYM8/ozl3Gb3nSvps6h1T3aU9ZiddmJxoGF yC3N9bHdL3oCEZ4IypovbxrkItlVxf7lWug8OyEQkgxBy8MnszMeVO/IDF1ZA/FCJS6Q Getg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akkea.ca header.s=mail header.b=lTJ+XIUV; dkim=pass header.i=@akkea.ca header.s=mail header.b=Q38CLUPc; 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 h70si32259318pge.221.2019.01.28.09.22.11; Mon, 28 Jan 2019 09:22:26 -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=@akkea.ca header.s=mail header.b=lTJ+XIUV; dkim=pass header.i=@akkea.ca header.s=mail header.b=Q38CLUPc; 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 S1731617AbfA1RUJ (ORCPT + 99 others); Mon, 28 Jan 2019 12:20:09 -0500 Received: from node.akkea.ca ([192.155.83.177]:48248 "EHLO node.akkea.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731049AbfA1QEg (ORCPT ); Mon, 28 Jan 2019 11:04:36 -0500 Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 2881E4E2051; Mon, 28 Jan 2019 16:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1548691476; bh=ecV0FVs8pf7wdJfAacDQzQaog4WDhg7OxsMhlavdhgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lTJ+XIUVtTk4URuf4yUWWjGUu6oJYao6apmwhCZlqZCO9bmK/kU3ZVYhfTKzqNlDo EmZtICPbHgeRA8bpS043UjNJzK9FSrEylyNSxoOW/bl2u29wQiPR7EP3spWpE5ggfE xlOZY13ZkqcFdYtx8XBvmoaX3BHbn7cCL3gS4eIc= X-Virus-Scanned: Debian amavisd-new at mail.akkea.ca Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yBjyiNuthFzc; Mon, 28 Jan 2019 16:04:35 +0000 (UTC) Received: from localhost.localdomain (198-48-167-13.cpe.pppoe.ca [198.48.167.13]) by node.akkea.ca (Postfix) with ESMTPSA id 1EB5C4E2050; Mon, 28 Jan 2019 16:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1548691475; bh=ecV0FVs8pf7wdJfAacDQzQaog4WDhg7OxsMhlavdhgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Q38CLUPcP7VsYjz2Y7Ew1otNBIBpfmXBeDb3RfFgOObN9oiwpnXbCCztMVGIvFOYD AEUoDE1bupPv9s9hmD5sHhGnYd4dJhWdJTn6clxHuTB7xwO3X3g6HTINxxNvwA/L21 XeYENDHeXyIqWjVUrMlQKBc/PXsm9PM8UjVcE9lg= From: "Angus Ainslie (Purism)" To: angus@akkea.ca 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, Lucas Stach , Daniel Baluta Subject: [PATCH v6 1/3] dmaengine: imx-sdma: add clock ratio 1:1 check Date: Mon, 28 Jan 2019 09:03:21 -0700 Message-Id: <20190128160323.28170-2-angus@akkea.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128160323.28170-1-angus@akkea.ca> References: <20190120023150.17138-1-angus@akkea.ca> <20190128160323.28170-1-angus@akkea.ca> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) Reviewed-by: Lucas Stach --- drivers/dma/imx-sdma.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 0b3a67ff8e82..757fad2fbfae 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,11 @@ 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); + reg = readl(sdma->regs + SDMA_H_CONFIG); + if ((reg & SDMA_H_CONFIG_CSM) == 0) { + reg |= SDMA_H_CONFIG_CSM; + writel_relaxed(reg, sdma->regs + SDMA_H_CONFIG); + } return ret; } @@ -1840,6 +1845,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 +1888,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); -- 2.17.1