linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ashish Kumar <Ashish.Kumar@nxp.com>
To: broonie@kernel.org, boris.brezillon@collabora.com,
	frieder.schrempf@kontron.de
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ashish Kumar <Ashish.Kumar@nxp.com>,
	Kuldeep Singh <kuldeep.singh@nxp.com>,
	Ashish Kumar <Ashish.kumar@nxp.com>
Subject: [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size
Date: Thu, 16 Apr 2020 14:03:04 +0530	[thread overview]
Message-ID: <1587025984-5696-1-git-send-email-Ashish.Kumar@nxp.com> (raw)

Reduce devm_ioremap size to (4 * AHB_BUFER_SIZE) rather than mapping
complete QSPI-Memmory as driver is now independent of flash size.
Flash of any size can be accessed.

Issue was reported on platform where devm_ioremap failure is observed
with size > 256M.
Error log on LS1021ATWR :
 fsl-quadspi 1550000.spi: ioremap failed for resource [mem 0x40000000-0x7fffffff]
 fsl-quadspi 1550000.spi: Freescale QuadSPI probe failed
 fsl-quadspi: probe of 1550000.spi failed with error -12

This change was also suggested previously:
https://patchwork.kernel.org/patch/10508753/#22166385

Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com>
Signed-off-by: Ashish Kumar <Ashish.kumar@nxp.com>
---
 drivers/spi/spi-fsl-qspi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 63c9f7e..a41ce81 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -859,14 +859,15 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 					"QuadSPI-memory");
-	q->ahb_addr = devm_ioremap_resource(dev, res);
+	q->memmap_phy = res->start;
+	/* Since there are 4 CS max MAP required is 4 time ahb_buf_size */
+	q->ahb_addr = devm_ioremap(dev, q->memmap_phy,
+				   (q->devtype_data->ahb_buf_size * 4));
 	if (IS_ERR(q->ahb_addr)) {
 		ret = PTR_ERR(q->ahb_addr);
 		goto err_put_ctrl;
 	}
 
-	q->memmap_phy = res->start;
-
 	/* find the clocks */
 	q->clk_en = devm_clk_get(dev, "qspi_en");
 	if (IS_ERR(q->clk_en)) {
@@ -939,6 +940,9 @@ static int fsl_qspi_remove(struct platform_device *pdev)
 
 	mutex_destroy(&q->lock);
 
+	if (q->ahb_addr)
+		devm_iounmap(q->dev, q->ahb_addr);
+
 	return 0;
 }
 
-- 
2.7.4


             reply	other threads:[~2020-04-16  8:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16  8:33 Ashish Kumar [this message]
2020-04-16  9:36 ` [PATCH] spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size Schrempf Frieder
2020-04-16 10:39   ` [EXT] " Ashish Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1587025984-5696-1-git-send-email-Ashish.Kumar@nxp.com \
    --to=ashish.kumar@nxp.com \
    --cc=boris.brezillon@collabora.com \
    --cc=broonie@kernel.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=kuldeep.singh@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).