Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1024737pxk; Fri, 18 Sep 2020 01:35:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi39PrVpGirImlOvv2YNNkwMJXBE2jfAUYlSgkM3/Pi+LiX/1L1U6Tg25RIUFs4js8z9VP X-Received: by 2002:a17:906:9718:: with SMTP id k24mr32618284ejx.365.1600418105414; Fri, 18 Sep 2020 01:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600418105; cv=none; d=google.com; s=arc-20160816; b=GlhANxmtgDlZpnVmba+oErUFSwUOIk4vx2LYxeRCWkt2zSDHs6wOc+PT6zbiEzmgQV tGCpHae7joF1e81qgIciqPFdYfJu0lFT3X/ny5r/IrTa0Z5VnpK4a0vSWDs/IxlK4jQC IJb2D5FI+kHiAOEHU80Ij9111ONH7Ds0MjKL8jQMra1l0S1hhKr3HT4CubL6f591Hw3m smMA9ksm+s+nXr/8HecVSPhWzeHnaQ3ap34fE0fryt/57zKGS32uCe49qCFNeUMJ7CgO mIj2GVvL2Y1CqB2j8jHu2hU3r7TEFR4F72OnqbYwwI7fmrKTy45Jp+lX/yUoYiNavXo0 Fdcg== 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=V6QA5rlwQIgAumyCtY/vC8OZHPGW9fkvmobEZ61e3iw=; b=Kd8D71PChl1DmEPibQlyzwhDGv2dp0usSMLBCB3w9eSJQQUSUYBbLZ3wsabPBbEAqB tiwiHTELg7uURRxhuB/9Z4KYGGYP7JkQlZ5CgEo7D5Q1V2HaN2UmKFrpHtfb0d2M/mmb NUmCBNJIWpeYF5qp+54TJFmzQoDYY4Rc7oQY9SREiJQlt8HnLCN/es6fMU76pwx8UPXv YPg/B/fwm9IRYm7Qkt4z8VuA889ojPiNCIhZnG9PkQ6Dzi+7vxFcznXQst+bAHpFtKkO oLKygg8C/OL5PUT/43iOryo8+0nHQpiJB31MhtcGSkIy1eQFxpRkKTyw+1nPIo0+4f6P Mhig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RLCsRbGE; 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 v10si1755522ejx.195.2020.09.18.01.34.41; Fri, 18 Sep 2020 01:35:05 -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=RLCsRbGE; 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 S1726752AbgIRIbo (ORCPT + 99 others); Fri, 18 Sep 2020 04:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbgIRIbn (ORCPT ); Fri, 18 Sep 2020 04:31:43 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5057CC06178C for ; Fri, 18 Sep 2020 01:31:41 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id md22so3992676pjb.0 for ; Fri, 18 Sep 2020 01:31:41 -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=V6QA5rlwQIgAumyCtY/vC8OZHPGW9fkvmobEZ61e3iw=; b=RLCsRbGEIvBCMUuhsoukaG9neeZlgVgZbHJD1ivveD5GumnlluwtLd2WdZ/jIC/XVi OVDwap9KXfLe1ucenLJ2xRDya+7cBCILx/fCyOEwcmdCfmTxCKCmDmCrU93XhmBaJmfn QGkSidPS6H6/ySwK04ULnFvBcvusmSA0Vbsog= 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=V6QA5rlwQIgAumyCtY/vC8OZHPGW9fkvmobEZ61e3iw=; b=PkqQ0J+Wh68/UBcBT9g6hhtyOGMhyZ/OX8L7gLn3Tbp6uDJM10XAmz/LILwEELhaSj h+IHXKHKRjF+pxBhpq0tTwpv51uHZ3BxzKvHK8vimd59S8EiRa5wEYroIYCaVtVowxGJ tQh0fcFZ36V6HFpeCEhXY7pFsTr8Hmamy4Jv95bHE/eA6/Q2AikJO549+tf6UnvPmAxg G7wz/YHefrYrRD8o2UBTpAmtPihFfIrzQRhRdKEvYvEOlg+8YdtsDLelrpDoTKzzitYM eXi7OOyP2yWDxhjt5RxDDdzOun1W4t9xj/Mm1hfH5svp6YfCLk0KV0RZ9+B8RVVrPm/c oIEA== X-Gm-Message-State: AOAM533CDJbugHVtj+uJ7I9ABHUgLOySfap0NuFNChy7QYKJAwtzPcRl /KHPCBxPUcDZVRaxrjhZyXCE3A== X-Received: by 2002:a17:90b:1642:: with SMTP id il2mr11671416pjb.93.1600417900741; Fri, 18 Sep 2020 01:31:40 -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 g206sm2193172pfb.178.2020.09.18.01.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 01:31:40 -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 v2 4/5] spi: spi-mtk-nor: support 36bit dma addressing to mediatek Date: Fri, 18 Sep 2020 16:31:22 +0800 Message-Id: <20200918162834.v2.4.Id1cb208392928afc7ceed4de06924243c7858cd0@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200918083124.3921207-1-ikjn@chromium.org> References: <20200918083124.3921207-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 36bit dma addressing is enabled only for mt8192-nor. Signed-off-by: Ikjoon Jang --- (no changes since v1) drivers/spi/spi-mtk-nor.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c index e14798a6e7d0..99dd5dca744e 100644 --- a/drivers/spi/spi-mtk-nor.c +++ b/drivers/spi/spi-mtk-nor.c @@ -78,6 +78,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 @@ -102,6 +104,7 @@ struct mtk_nor { unsigned int spi_freq; bool wbuf_en; bool has_irq; + bool high_dma; struct completion op_done; }; @@ -291,6 +294,11 @@ static int read_dma(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(dma_addr >> 32, sp->base + MTK_NOR_REG_DMA_DADR_HB); + writel((dma_addr + length) >> 32, 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); @@ -594,7 +602,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); @@ -607,6 +616,7 @@ static int mtk_nor_probe(struct platform_device *pdev) u8 *buffer; struct clk *spi_clk, *ctlr_clk; int ret, irq; + unsigned long dma_bits; base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -623,6 +633,13 @@ static int mtk_nor_probe(struct platform_device *pdev) buffer = devm_kmalloc(&pdev->dev, MTK_NOR_BOUNCE_BUF_SIZE + MTK_NOR_DMA_ALIGN, GFP_KERNEL); + + 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; + } + if (!buffer) return -ENOMEM; -- 2.28.0.681.g6f77f65b4e-goog