Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3594452pxk; Tue, 29 Sep 2020 00:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeKsKMPBdKCNIvdfCUY4bvz4TDX8AGwHnqoXRDKvUbia1p6VNPi96okUUuwyZsTTi2pLzZ X-Received: by 2002:a17:906:9491:: with SMTP id t17mr2629213ejx.253.1601365228785; Tue, 29 Sep 2020 00:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601365228; cv=none; d=google.com; s=arc-20160816; b=kOD5Z6zCf4KeQBWBgJKyXedDu5vayqNLQz8V/QzB9O/CJIjUa7/23bfrGB4RMTYjU7 rCEnPKT1jH0Cr7f2ExY0oAPBHitF+YrztDuEJEOHKQOpJ8x+tJ/gkpRvbAOXsB0Tk2+Q jc7Hylq54Ds/F/l+2depVXDs2UU5s48kDNHqSTQ4Q+oJEI6lMMl5RyhaZiWs1+ZueiG6 PFmbGTezAOMox5H5tChf0KPKIQ7xrJYfL02n6vWrBn4l2YAKaMJTdHfqogKEpzewNqNP lRVKrmOyVrjqYlCUXzBODSwnINc5YICn+uqmibniYptJVWOTmN+eFXpCTbj8lBODuQg6 iEhw== 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=+Kh1cgPE0z6ZaYTa5OCqa2rDxMEmjbF1J+zo1XE6Dzc=; b=JyEzav1V2ENhuJW1sh9AYU9dwUiQvxZglmHxPxGG5bNKfCBNtXDL7SsNkgtayQAl0k TXT0wD4jTyWHSXkAyinvrTXi5YogVGkuPTQIMuY6emxjFuamd+iH6UHjevke8cMw1I56 z3c0h4nWqRfgCdQ5bxqcOTz1yg/wFdGNzdS1mJRIok0cNRG9aYavlI9PMTTOdGTQGsZh MoOrcLu3qWSne8zT89bVBfhGkh2sDcxE0A8nEZ/eSqEv0ThB8LQgL/24qQzPHbMTaSDU JHek+6IjPhleWan0VZQ9rcioha/7oiG/lHRBZSbp7eZuoP2yb6vzGOpJDAI51u0tQpxT MpcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QNnAm1um; 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 a13si2106366ejf.427.2020.09.29.00.40.05; Tue, 29 Sep 2020 00:40:28 -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=QNnAm1um; 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 S1727630AbgI2Hit (ORCPT + 99 others); Tue, 29 Sep 2020 03:38:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727620AbgI2Hir (ORCPT ); Tue, 29 Sep 2020 03:38:47 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C95C0613D1 for ; Tue, 29 Sep 2020 00:38:47 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o25so3180776pgm.0 for ; Tue, 29 Sep 2020 00:38:47 -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=+Kh1cgPE0z6ZaYTa5OCqa2rDxMEmjbF1J+zo1XE6Dzc=; b=QNnAm1umIqZw/2DLvd2wp3irYnYcyua/7QVqZM1qQ0IAu261zfNJya2qYqYVA9mpbd e6AJPlCGYWmh5BcSJBgbVx0pEf0KcBKlavOi25/linNkqEh14DI+RBfRo9/Ek05pBI8f xYWjZTx8PO8JSbr8OU4nD8Ji4AJsHWxsEVcIw= 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=+Kh1cgPE0z6ZaYTa5OCqa2rDxMEmjbF1J+zo1XE6Dzc=; b=nvEhRAPCICpBV0WdAXnZ75bCGuOOqdnjktJ/5ZP8JcT7bDejojCFb5kfdjgavaFsVA RvbpJUUSu/P1MS/cadeDs9LqFEwUD0qeZyFbdLf86gALxcLawS2tAGHF+Oy/g/opFnRu X5mNYFXmyfaNjMg72u66QN//YWNjhKp3xTscaBc7JHffAZHUVHVUwcxdAGr1s19GoX5o 48IaLf6lxAFP8TZHinHB980U4iL1BKHTvLJHgE9V/vbpou8wo4feLNMEoE4fr4aEizRQ ZTjyFR4vXoBNearbxqlxDykuWMaWaALdbD5eFKrJdkIgy52dUFVsBKTReOQk3xNqsTiV 3S8A== X-Gm-Message-State: AOAM533THSJieIbyNSNzSfF/iulI+uSGLs39wW1m5Mu72bLFUZ34aUxa VORTk89OwRICDb1WlZpqffKsvQ== X-Received: by 2002:a17:902:9349:b029:d0:cb2d:f26c with SMTP id g9-20020a1709029349b02900d0cb2df26cmr3263756plp.5.1601365127053; Tue, 29 Sep 2020 00:38:47 -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 e13sm3737317pjy.38.2020.09.29.00.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 00:38:46 -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 v4 3/4] spi: spi-mtk-nor: support 36bit dma addressing Date: Tue, 29 Sep 2020 15:37:54 +0800 Message-Id: <20200929153320.v4.3.Id1cb208392928afc7ceed4de06924243c7858cd0@changeid> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog In-Reply-To: <20200929073755.3741416-1-ikjn@chromium.org> References: <20200929073755.3741416-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 --- Changes in v4: - Fix 0-day ci warning from shifting 32bit value - Fix missing initialization of internal flags, 'high_dma' 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 cfb9a2450962..eac613b3930d 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; }; @@ -278,6 +281,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); @@ -589,7 +599,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); @@ -601,6 +612,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)) @@ -614,6 +626,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"); @@ -639,6 +657,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.709.gb0816b6eb0-goog