[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191106140748.13100-2-gch981213@gmail.com>
Date: Wed, 6 Nov 2019 22:07:47 +0800
From: Chuanhong Guo <gch981213@...il.com>
To: linux-mtd@...ts.infradead.org
Cc: David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
Tudor Ambarus <tudor.ambarus@...rochip.com>,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
Chuanhong Guo <gch981213@...il.com>
Subject: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
PIO reading mode on this controller is ridiculously inefficient
(one cmd+addr+dummy sequence reads only one byte)
This patch adds support for reading from memory-mapped flash area
which increases reading speed from 1MB/s to 5.6MB/s
Signed-off-by: Chuanhong Guo <gch981213@...il.com>
---
drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c
index 34db01ab6cab..ba8b3be39896 100644
--- a/drivers/mtd/spi-nor/mtk-quadspi.c
+++ b/drivers/mtd/spi-nor/mtk-quadspi.c
@@ -106,6 +106,7 @@ struct mtk_nor {
struct spi_nor nor;
struct device *dev;
void __iomem *base; /* nor flash base address */
+ void __iomem *flash_base;
struct clk *spi_clk;
struct clk *nor_clk;
};
@@ -272,6 +273,11 @@ static ssize_t mtk_nor_read(struct spi_nor *nor, loff_t from, size_t length,
mtk_nor_set_read_mode(mtk_nor);
mtk_nor_set_addr(mtk_nor, addr);
+ if (mtk_nor->flash_base) {
+ memcpy_fromio(buffer, mtk_nor->flash_base + from, length);
+ return length;
+ }
+
for (i = 0; i < length; i++) {
ret = mtk_nor_execute_cmd(mtk_nor, MTK_NOR_PIO_READ_CMD);
if (ret < 0)
@@ -475,6 +481,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev)
if (IS_ERR(mtk_nor->base))
return PTR_ERR(mtk_nor->base);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ mtk_nor->flash_base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(mtk_nor->flash_base))
+ mtk_nor->flash_base = NULL;
+
mtk_nor->spi_clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(mtk_nor->spi_clk))
return PTR_ERR(mtk_nor->spi_clk);
--
2.21.0
Powered by blists - more mailing lists