Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp80765pxu; Tue, 6 Oct 2020 00:55:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1tTj+pNxlF4SCw+2d4RUgpZPhP6FCJOJXvEWuqWlIkPeT9tFHlp8hZPoKzXVNPf+Qk+Bg X-Received: by 2002:a17:907:2115:: with SMTP id qn21mr3828481ejb.278.1601970953191; Tue, 06 Oct 2020 00:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601970953; cv=none; d=google.com; s=arc-20160816; b=a7/+3BqNBYD2mDEsCULjCkTXaJ/LEk9EGq4o3CRjurzB+hmwH8gjtf+cmpCYKHQHRs COm8sKQ/CutEqwAy+ixpsNf4tQ9QNxsJtIFxCdQEsNMkebmEoj/YrAwUV7jbHFpPh0MN pcOCmWMyIsK18dDjPsuPLdqs1sayMjRWCllh/E5ndGUAn+nborM7AlFD8VCu6vwrn6oL w5ge8oL815fPDyWitU5J10yqmhEB6KMDZHtJPU8HVuXxZs3OaFFow8DvMbWLR2sCCJgF 8x7rErQsxcLMM1CSiJ78FCl9Qjst7j8S1mDSYlm/EO6Z0jUTxXO/ndglH8yOPEqgdpIm u0Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+6PvurjL54TX+y1/PrJh4kuSmSzUHQBfsfDBvhGtO0Q=; b=VoK0f8eylWb0wOuy0xNd8bfuogSrlkfg2gxnPvsGEcV9lAEBpbcDFqrgKOF7PlITVN LfACkD7/WKF8bE6saZjZYblMqgCEU2C1U13IgzUZPtKTDNPqUWnYUwl4TsmssOB+esIM zkBWPpY39JoiDObsMBYwKFm/dkneoWU+S+Wr3szOLKUSDxBdTaOUjTbHXaMLeoDQSTFp iaIrLg19mBRwqSfJLAkbhtjKwzf3NRAkSryIuqKz6DTmz+HdeP8JWz60z+rAOKYYQGPY AH3kluZxjUnjDaCqCkEX0MCZe3lIuU/055uAR2D7hkYItoTDmzYwJYdte/JjhY6IMC96 3iqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LNtpACrZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si1808964edw.38.2020.10.06.00.55.31; Tue, 06 Oct 2020 00:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LNtpACrZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727292AbgJFHy0 (ORCPT + 99 others); Tue, 6 Oct 2020 03:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727254AbgJFHyV (ORCPT ); Tue, 6 Oct 2020 03:54:21 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E4EFC061755 for ; Tue, 6 Oct 2020 00:54:21 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id p11so816531pld.5 for ; Tue, 06 Oct 2020 00:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+6PvurjL54TX+y1/PrJh4kuSmSzUHQBfsfDBvhGtO0Q=; b=LNtpACrZ8QtTYX8EgAopthIK0bClQe8ZiTLpReJ07bZ9/zLcTwKlzsxX4ZdoDUdy3x 9dghrilIND6vA+NcOkkScrBu4EmutgVlpYaoJB9MCFAWVyFUG4egXCit/P1JaK2wDWR1 KntfDGXd3Vb4HlbctW0At8LyBY5dCh/oQ+SJA= 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=+6PvurjL54TX+y1/PrJh4kuSmSzUHQBfsfDBvhGtO0Q=; b=rpSlC0UDiNQitg3sXXq0vfbc3ckCgKIgXYKMBlREbHt95g5XBjUJnCTt7HljM+JRRS j3I7IkU5NRnJmutyx+f2LThr84uOb4AsWtcRVpDEbVoNCMOLahxDSDvDSmK/+Y0JIPnd wb9MUz7tJ3nA/V69RprwVfySD3DDqmRbSiFlcE7yGhSBdjCGVjmAODPqHRv+3FuuT0Q3 Kr1PpbysMW9p6AjTaoSnaHjn8KTU+IXfSeaiBMGoKw4ijXTA36aqSctRuX5Btss8rQa+ fXSSvA8L0fuWVTSarMa8dD/qCpdvZ4X+jrxRX8GNnmOn++aiiglK34dp5Un394viEvWL UGdQ== X-Gm-Message-State: AOAM5326HItRhmGkjY7HubsKfewUtuRsf86zc376hwOnZUosrz9fOmnN h3h1dSKAWtaSCjWYXfWNJ8yQHA== X-Received: by 2002:a17:902:6ac1:b029:d3:b3bd:b66e with SMTP id i1-20020a1709026ac1b02900d3b3bdb66emr2180366plt.21.1601970860839; Tue, 06 Oct 2020 00:54:20 -0700 (PDT) Received: from ikjn-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:a8fc]) by smtp.gmail.com with ESMTPSA id r6sm2545147pfq.11.2020.10.06.00.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 00:54:20 -0700 (PDT) From: Ikjoon Jang To: Rob Herring , Mark Brown , devicetree@vger.kernel.org, linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org Cc: Ikjoon Jang , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v5 3/4] spi: spi-mtk-nor: support 36bit dma addressing Date: Tue, 6 Oct 2020 15:54:04 +0800 Message-Id: <20201006155010.v5.3.Id1cb208392928afc7ceed4de06924243c7858cd0@changeid> X-Mailer: git-send-email 2.28.0.806.g8561365e88-goog In-Reply-To: <20201006075405.11658-1-ikjn@chromium.org> References: <20201006075405.11658-1-ikjn@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch enables 36bit dma address support to spi-mtk-nor. Currently this is enabled only for mt8192-nor. Signed-off-by: Ikjoon Jang --- drivers/spi/spi-mtk-nor.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c index c11bed28b952..e46d5c93d742 100644 --- a/drivers/spi/spi-mtk-nor.c +++ b/drivers/spi/spi-mtk-nor.c @@ -79,6 +79,8 @@ #define MTK_NOR_REG_DMA_FADR 0x71c #define MTK_NOR_REG_DMA_DADR 0x720 #define MTK_NOR_REG_DMA_END_DADR 0x724 +#define MTK_NOR_REG_DMA_DADR_HB 0x738 +#define MTK_NOR_REG_DMA_END_DADR_HB 0x73c #define MTK_NOR_PRG_MAX_SIZE 6 // Reading DMA src/dst addresses have to be 16-byte aligned @@ -103,6 +105,7 @@ struct mtk_nor { unsigned int spi_freq; bool wbuf_en; bool has_irq; + bool high_dma; struct completion op_done; }; @@ -343,6 +346,13 @@ static int mtk_nor_dma_exec(struct mtk_nor *sp, u32 from, unsigned int length, writel(dma_addr, sp->base + MTK_NOR_REG_DMA_DADR); writel(dma_addr + length, sp->base + MTK_NOR_REG_DMA_END_DADR); + if (sp->high_dma) { + writel(upper_32_bits(dma_addr), + sp->base + MTK_NOR_REG_DMA_DADR_HB); + writel(upper_32_bits(dma_addr + length), + sp->base + MTK_NOR_REG_DMA_END_DADR_HB); + } + if (sp->has_irq) { reinit_completion(&sp->op_done); mtk_nor_rmw(sp, MTK_NOR_REG_IRQ_EN, MTK_NOR_IRQ_DMA, 0); @@ -731,7 +741,8 @@ static const struct spi_controller_mem_ops mtk_nor_mem_ops = { }; static const struct of_device_id mtk_nor_match[] = { - { .compatible = "mediatek,mt8173-nor" }, + { .compatible = "mediatek,mt8192-nor", .data = (void *)36 }, + { .compatible = "mediatek,mt8173-nor", .data = (void *)32 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mtk_nor_match); @@ -743,6 +754,7 @@ static int mtk_nor_probe(struct platform_device *pdev) void __iomem *base; struct clk *spi_clk, *ctlr_clk; int ret, irq; + unsigned long dma_bits; base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -756,6 +768,12 @@ static int mtk_nor_probe(struct platform_device *pdev) if (IS_ERR(ctlr_clk)) return PTR_ERR(ctlr_clk); + dma_bits = (unsigned long)of_device_get_match_data(&pdev->dev); + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(dma_bits))) { + dev_err(&pdev->dev, "failed to set dma mask(%lu)\n", dma_bits); + return -EINVAL; + } + ctlr = spi_alloc_master(&pdev->dev, sizeof(*sp)); if (!ctlr) { dev_err(&pdev->dev, "failed to allocate spi controller\n"); @@ -781,6 +799,7 @@ static int mtk_nor_probe(struct platform_device *pdev) sp->dev = &pdev->dev; sp->spi_clk = spi_clk; sp->ctlr_clk = ctlr_clk; + sp->high_dma = (dma_bits > 32); sp->buffer = dmam_alloc_coherent(&pdev->dev, MTK_NOR_BOUNCE_BUF_SIZE + MTK_NOR_DMA_ALIGN, &sp->buffer_dma, GFP_KERNEL); -- 2.28.0.806.g8561365e88-goog