Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1820837ybi; Sat, 25 May 2019 09:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX+Z3faUqie2vCb0z1Lu3o8VPG1pqqROae0N4ma8MGV4owV85AscGSp/owSOaJTMaDR/Rz X-Received: by 2002:a63:d949:: with SMTP id e9mr25202670pgj.437.1558802473725; Sat, 25 May 2019 09:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558802473; cv=none; d=google.com; s=arc-20160816; b=ZuDaZ9WfzGMs77AZ5gtzjXcF0WzuDs58S50m6+KHMUbrdLiZIzclcfp+YyUSz9fLJ/ 6mZOz7Ezt2VOqx+ZYBKCu93JRAvhINWUOjz+UmyCVM1OBYBvbX88kGzL/TxX9FK1uXAr /b7RfvcDeMOSNDCuZGqh4x9Vfe/wKt69hnqgmq2eImZHHnSO1Ra1mgZOfsTSOXlEThKn 3vQi95gxA8obNoqpNV1g2lZ3VSuS5jUcnKwBO8cTFgJa2VBLE357Q6YdMwf/nW5yfKQD shujZNsoWdbpQC3W2aMDeIC8NVQTGM1uIjdn0iQb232xYxskx0Aqda/u9eRSSPQpcwou 7T8Q== 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:message-id:date:subject:cc:to:from :dkim-signature; bh=07+2U0H+IBjlhuGrjcqPkQ09B1GGgjfSq3SMD7jPmPk=; b=mFoGslCjlPCe01jhXF5W0JxYab2dc2lT423dveYFt9jxw9n2eDrHmtyy/Y6D6r5w7R Y1Jn0e9EhBdYy9W8TVedQKFnDSCQsyMFtIGJXFbsZr8hZVS8bnhf88gyaISd7yShsWKu ONP8bLPxv9OAZ7jNWGH4E4RcAV8AWh0kN346j7/y1Jzx5gg1brLHvOXbuAP96MfM9/Rf miLRLHDB80OWuPMW5PK3cXAlXhMWcgJj7Mfz3oFrYNfwLv8ZV3fJ4OiuZytsoOtSw7mQ 7l/yfiiO0+EDyDC0RnH3zV/3iGbEryTOcVwkansNSfzJIIXMQiSkjKRMIdnqlsPfy6QD 6TGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=klPyfvEI; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 101si9181141plb.31.2019.05.25.09.40.58; Sat, 25 May 2019 09:41:13 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=klPyfvEI; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727354AbfEYQig (ORCPT + 99 others); Sat, 25 May 2019 12:38:36 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43912 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727320AbfEYQie (ORCPT ); Sat, 25 May 2019 12:38:34 -0400 Received: by mail-wr1-f67.google.com with SMTP id l17so4424847wrm.10; Sat, 25 May 2019 09:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=07+2U0H+IBjlhuGrjcqPkQ09B1GGgjfSq3SMD7jPmPk=; b=klPyfvEI/cinBZjUx/j9WztCqHYARfQARCJH1q6MDnkpugFwTZS3mXWJOPhY2kGm9X xvh8y4d29cRIP/haRLAjSm/wPDvhHSowZ9b+BTaxE25Wj94v3Hbhj8NY4kMrQgFFqArj Sdim6YOIeNCEs+B8n78T0DnM3lLO72mOaiTq79RuFx0s/A3FKGT0JMJkoUXlNDNHZkN6 Cz2lzFORDCEjpKz2uQtW61g0f9z1ljIwrqsZZJGWZVQLIxTSlcUFdn3VmkCWavKq473z KIUSwRdjoE66O0i8n7CjJFSoIXC4TKqNnsPlYOj9J9errHJfOr344EHHAnZHXAF3vdEm k+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=07+2U0H+IBjlhuGrjcqPkQ09B1GGgjfSq3SMD7jPmPk=; b=QzXbfqDaFTU/mtUIipL8eAiqrRBX3PrhgWIKILYtM6gf9bwKXAFFLlvOnqZe50lfRf BYmbRH9KiIbg8YtTjrie8JfwgJnHYRRvn/QVC8vM81c523GKOOIocu9Qx1DotjVYfVe+ 7EsQiMFeZz7MfoQYuNggj9R3JGD+vyDeAHTp9Yek0sEcfLzJUJgqJEZwlAhORq2lfzqx a+jnJvximtwut+3wlHDShiQm4XoR2duhR9ef5WN1hJlnb+js90I4/A0MWfhTM+ILpfy2 9OeNauxnaIW957s5fgU8ChE6mAtfzXvy2nUVJY6MclufS6R/cYq5NxtFm4GrQLziYRi4 1g9g== X-Gm-Message-State: APjAAAUl7QAyT1YCoqeC9D+OL6PHXKDJiNKepvF+GlMh7L1e42C88V9t VTbVAyug9mIX33GZQF0W9Hk= X-Received: by 2002:adf:db89:: with SMTP id u9mr30158479wri.294.1558802311115; Sat, 25 May 2019 09:38:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id f65sm9306498wmg.45.2019.05.25.09.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 May 2019 09:38:30 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= To: Vinod Koul , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Dan Williams Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jernej Skrabec , =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Subject: [PATCH v2 5/7] dmaengine: sun6i: Add support for H6 DMA Date: Sat, 25 May 2019 18:38:17 +0200 Message-Id: <20190525163819.21055-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190525163819.21055-1-peron.clem@gmail.com> References: <20190525163819.21055-1-peron.clem@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jernej Skrabec H6 DMA has more than 32 supported DRQs, which means that configuration register is slightly rearranged. It also needs additional clock to be enabled. Add support for it. Signed-off-by: Jernej Skrabec Signed-off-by: Clément Péron --- drivers/dma/sun6i-dma.c | 44 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index f5cb5e89bf7b..8d44ddae926a 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -69,14 +69,19 @@ #define DMA_CHAN_CUR_CFG 0x0c #define DMA_CHAN_MAX_DRQ_A31 0x1f +#define DMA_CHAN_MAX_DRQ_H6 0x3f #define DMA_CHAN_CFG_SRC_DRQ_A31(x) ((x) & DMA_CHAN_MAX_DRQ_A31) +#define DMA_CHAN_CFG_SRC_DRQ_H6(x) ((x) & DMA_CHAN_MAX_DRQ_H6) #define DMA_CHAN_CFG_SRC_MODE_A31(x) (((x) & 0x1) << 5) +#define DMA_CHAN_CFG_SRC_MODE_H6(x) (((x) & 0x1) << 8) #define DMA_CHAN_CFG_SRC_BURST_A31(x) (((x) & 0x3) << 7) #define DMA_CHAN_CFG_SRC_BURST_H3(x) (((x) & 0x3) << 6) #define DMA_CHAN_CFG_SRC_WIDTH(x) (((x) & 0x3) << 9) #define DMA_CHAN_CFG_DST_DRQ_A31(x) (DMA_CHAN_CFG_SRC_DRQ_A31(x) << 16) +#define DMA_CHAN_CFG_DST_DRQ_H6(x) (DMA_CHAN_CFG_SRC_DRQ_H6(x) << 16) #define DMA_CHAN_CFG_DST_MODE_A31(x) (DMA_CHAN_CFG_SRC_MODE_A31(x) << 16) +#define DMA_CHAN_CFG_DST_MODE_H6(x) (DMA_CHAN_CFG_SRC_MODE_H6(x) << 16) #define DMA_CHAN_CFG_DST_BURST_A31(x) (DMA_CHAN_CFG_SRC_BURST_A31(x) << 16) #define DMA_CHAN_CFG_DST_BURST_H3(x) (DMA_CHAN_CFG_SRC_BURST_H3(x) << 16) #define DMA_CHAN_CFG_DST_WIDTH(x) (DMA_CHAN_CFG_SRC_WIDTH(x) << 16) @@ -319,12 +324,24 @@ static void sun6i_set_drq_a31(u32 *p_cfg, s8 src_drq, s8 dst_drq) DMA_CHAN_CFG_DST_DRQ_A31(dst_drq); } +static void sun6i_set_drq_h6(u32 *p_cfg, s8 src_drq, s8 dst_drq) +{ + *p_cfg |= DMA_CHAN_CFG_SRC_DRQ_H6(src_drq) | + DMA_CHAN_CFG_DST_DRQ_H6(dst_drq); +} + static void sun6i_set_mode_a31(u32 *p_cfg, s8 src_mode, s8 dst_mode) { *p_cfg |= DMA_CHAN_CFG_SRC_MODE_A31(src_mode) | DMA_CHAN_CFG_DST_MODE_A31(dst_mode); } +static void sun6i_set_mode_h6(u32 *p_cfg, s8 src_mode, s8 dst_mode) +{ + *p_cfg |= DMA_CHAN_CFG_SRC_MODE_H6(src_mode) | + DMA_CHAN_CFG_DST_MODE_H6(dst_mode); +} + static size_t sun6i_get_chan_size(struct sun6i_pchan *pchan) { struct sun6i_desc *txd = pchan->desc; @@ -1160,6 +1177,28 @@ static struct sun6i_dma_config sun50i_a64_dma_cfg = { BIT(DMA_SLAVE_BUSWIDTH_8_BYTES), }; +/* + * The H6 binding uses the number of dma channels from the + * device tree node. + */ +static struct sun6i_dma_config sun50i_h6_dma_cfg = { + .clock_autogate_enable = sun6i_enable_clock_autogate_h3, + .set_burst_length = sun6i_set_burst_length_h3, + .set_drq = sun6i_set_drq_h6, + .set_mode = sun6i_set_mode_h6, + .src_burst_lengths = BIT(1) | BIT(4) | BIT(8) | BIT(16), + .dst_burst_lengths = BIT(1) | BIT(4) | BIT(8) | BIT(16), + .src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | + BIT(DMA_SLAVE_BUSWIDTH_8_BYTES), + .dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | + BIT(DMA_SLAVE_BUSWIDTH_8_BYTES), + .has_mbus_clk = true, +}; + /* * The V3s have only 8 physical channels, a maximum DRQ port id of 23, * and a total of 24 usable source and destination endpoints. @@ -1190,6 +1229,7 @@ static const struct of_device_id sun6i_dma_match[] = { { .compatible = "allwinner,sun8i-h3-dma", .data = &sun8i_h3_dma_cfg }, { .compatible = "allwinner,sun8i-v3s-dma", .data = &sun8i_v3s_dma_cfg }, { .compatible = "allwinner,sun50i-a64-dma", .data = &sun50i_a64_dma_cfg }, + { .compatible = "allwinner,sun50i-h6-dma", .data = &sun50i_h6_dma_cfg }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun6i_dma_match); @@ -1288,8 +1328,8 @@ static int sun6i_dma_probe(struct platform_device *pdev) ret = of_property_read_u32(np, "dma-requests", &sdc->max_request); if (ret && !sdc->max_request) { dev_info(&pdev->dev, "Missing dma-requests, using %u.\n", - DMA_CHAN_MAX_DRQ_A31); - sdc->max_request = DMA_CHAN_MAX_DRQ_A31; + DMA_CHAN_MAX_DRQ_H6); + sdc->max_request = DMA_CHAN_MAX_DRQ_H6; } /* -- 2.20.1