All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07 ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, Chuanhong Guo

This patchset adds support for optional memory-mapped flash reading.

BTW: This controller is a ridiculous one which only supports very limited
spi-nor instructions. I can't rework the driver into a spi-mem one because
MTK didn't provide register description in their datasheet and even if they
do provide the documentation, the resulted driver will still be ridiculous
because it'll need to check every supported instructions in support_op and
do execution in one-by-one case in exec_op.

Chuanhong Guo (2):
  mtd: mtk-quadspi: add support for memory-mapped flash reading
  dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read

 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 drivers/mtd/spi-nor/mtk-quadspi.c             | 11 ++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 0/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07 ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

This patchset adds support for optional memory-mapped flash reading.

BTW: This controller is a ridiculous one which only supports very limited
spi-nor instructions. I can't rework the driver into a spi-mem one because
MTK didn't provide register description in their datasheet and even if they
do provide the documentation, the resulted driver will still be ridiculous
because it'll need to check every supported instructions in support_op and
do execution in one-by-one case in exec_op.

Chuanhong Guo (2):
  mtd: mtk-quadspi: add support for memory-mapped flash reading
  dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read

 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 drivers/mtd/spi-nor/mtk-quadspi.c             | 11 ++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

-- 
2.21.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 0/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07 ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

This patchset adds support for optional memory-mapped flash reading.

BTW: This controller is a ridiculous one which only supports very limited
spi-nor instructions. I can't rework the driver into a spi-mem one because
MTK didn't provide register description in their datasheet and even if they
do provide the documentation, the resulted driver will still be ridiculous
because it'll need to check every supported instructions in support_op and
do execution in one-by-one case in exec_op.

Chuanhong Guo (2):
  mtd: mtk-quadspi: add support for memory-mapped flash reading
  dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read

 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 drivers/mtd/spi-nor/mtk-quadspi.c             | 11 ++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

-- 
2.21.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 0/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07 ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

This patchset adds support for optional memory-mapped flash reading.

BTW: This controller is a ridiculous one which only supports very limited
spi-nor instructions. I can't rework the driver into a spi-mem one because
MTK didn't provide register description in their datasheet and even if they
do provide the documentation, the resulted driver will still be ridiculous
because it'll need to check every supported instructions in support_op and
do execution in one-by-one case in exec_op.

Chuanhong Guo (2):
  mtd: mtk-quadspi: add support for memory-mapped flash reading
  dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read

 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 drivers/mtd/spi-nor/mtk-quadspi.c             | 11 ++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-06 14:07 ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-06 14:07   ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, Chuanhong Guo

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@gmail.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


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

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@gmail.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


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

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@gmail.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


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

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@gmail.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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
  2019-11-06 14:07 ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-06 14:07   ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, Chuanhong Guo

update register descriptions and add an example binding using it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
index a12e3b5c495d..4860f6e96f5a 100644
--- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
@@ -12,7 +12,10 @@ Required properties:
 		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt8173-nor"
-- reg: 		  physical base address and length of the controller's register
+- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
+		  physical address and length. The first entry is the address and length
+		  of the controller register set. The optional second entry is the address
+		  and length of the area where the nor flash is mapped to.
 - clocks: 	  the phandle of the clocks needed by the nor controller
 - clock-names: 	  the names of the clocks
 		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
@@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
 	};
 };
 
+nor_flash: spi@11014000 {
+	compatible = "mediatek,mt7629-nor",
+		     "mediatek,mt8173-nor";
+	reg = <0x11014000 0xe0>,
+	      <0x30000000 0x10000000>;
+	clocks = <&pericfg CLK_PERI_FLASH_PD>,
+		 <&topckgen CLK_TOP_FLASH_SEL>;
+	clock-names = "spi", "sf";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+	};
+};
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

update register descriptions and add an example binding using it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
index a12e3b5c495d..4860f6e96f5a 100644
--- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
@@ -12,7 +12,10 @@ Required properties:
 		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt8173-nor"
-- reg: 		  physical base address and length of the controller's register
+- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
+		  physical address and length. The first entry is the address and length
+		  of the controller register set. The optional second entry is the address
+		  and length of the area where the nor flash is mapped to.
 - clocks: 	  the phandle of the clocks needed by the nor controller
 - clock-names: 	  the names of the clocks
 		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
@@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
 	};
 };
 
+nor_flash: spi@11014000 {
+	compatible = "mediatek,mt7629-nor",
+		     "mediatek,mt8173-nor";
+	reg = <0x11014000 0xe0>,
+	      <0x30000000 0x10000000>;
+	clocks = <&pericfg CLK_PERI_FLASH_PD>,
+		 <&topckgen CLK_TOP_FLASH_SEL>;
+	clock-names = "spi", "sf";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+	};
+};
-- 
2.21.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

update register descriptions and add an example binding using it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
index a12e3b5c495d..4860f6e96f5a 100644
--- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
@@ -12,7 +12,10 @@ Required properties:
 		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt8173-nor"
-- reg: 		  physical base address and length of the controller's register
+- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
+		  physical address and length. The first entry is the address and length
+		  of the controller register set. The optional second entry is the address
+		  and length of the area where the nor flash is mapped to.
 - clocks: 	  the phandle of the clocks needed by the nor controller
 - clock-names: 	  the names of the clocks
 		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
@@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
 	};
 };
 
+nor_flash: spi@11014000 {
+	compatible = "mediatek,mt7629-nor",
+		     "mediatek,mt8173-nor";
+	reg = <0x11014000 0xe0>,
+	      <0x30000000 0x10000000>;
+	clocks = <&pericfg CLK_PERI_FLASH_PD>,
+		 <&topckgen CLK_TOP_FLASH_SEL>;
+	clock-names = "spi", "sf";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+	};
+};
-- 
2.21.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-06 14:07   ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-06 14:07 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Chuanhong Guo, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

update register descriptions and add an example binding using it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
 .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
index a12e3b5c495d..4860f6e96f5a 100644
--- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
@@ -12,7 +12,10 @@ Required properties:
 		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
 		  "mediatek,mt8173-nor"
-- reg: 		  physical base address and length of the controller's register
+- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
+		  physical address and length. The first entry is the address and length
+		  of the controller register set. The optional second entry is the address
+		  and length of the area where the nor flash is mapped to.
 - clocks: 	  the phandle of the clocks needed by the nor controller
 - clock-names: 	  the names of the clocks
 		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
@@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
 	};
 };
 
+nor_flash: spi@11014000 {
+	compatible = "mediatek,mt7629-nor",
+		     "mediatek,mt8173-nor";
+	reg = <0x11014000 0xe0>,
+	      <0x30000000 0x10000000>;
+	clocks = <&pericfg CLK_PERI_FLASH_PD>,
+		 <&topckgen CLK_TOP_FLASH_SEL>;
+	clock-names = "spi", "sf";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+	};
+};
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
  2019-11-06 14:07   ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-07  1:09     ` Rob Herring
  -1 siblings, 0 replies; 48+ messages in thread
From: Rob Herring @ 2019-11-07  1:09 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: linux-mtd, David Woodhouse, Brian Norris, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Mark Rutland,
	Matthias Brugger, Tudor Ambarus, devicetree, linux-arm-kernel,
	linux-mediatek, linux-kernel

On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> update register descriptions and add an example binding using it.
> 
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> ---
>  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> index a12e3b5c495d..4860f6e96f5a 100644
> --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> @@ -12,7 +12,10 @@ Required properties:
>  		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt8173-nor"
> -- reg: 		  physical base address and length of the controller's register
> +- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
> +		  physical address and length. The first entry is the address and length
> +		  of the controller register set. The optional second entry is the address
> +		  and length of the area where the nor flash is mapped to.

All the compatibles support 2 entries? If not, which ones?

>  - clocks: 	  the phandle of the clocks needed by the nor controller
>  - clock-names: 	  the names of the clocks
>  		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
> @@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
>  	};
>  };
>  
> +nor_flash: spi@11014000 {
> +	compatible = "mediatek,mt7629-nor",
> +		     "mediatek,mt8173-nor";
> +	reg = <0x11014000 0xe0>,
> +	      <0x30000000 0x10000000>;
> +	clocks = <&pericfg CLK_PERI_FLASH_PD>,
> +		 <&topckgen CLK_TOP_FLASH_SEL>;
> +	clock-names = "spi", "sf";
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	flash@0 {
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +	};
> +};
> -- 
> 2.21.0
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  1:09     ` Rob Herring
  0 siblings, 0 replies; 48+ messages in thread
From: Rob Herring @ 2019-11-07  1:09 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> update register descriptions and add an example binding using it.
> 
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> ---
>  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> index a12e3b5c495d..4860f6e96f5a 100644
> --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> @@ -12,7 +12,10 @@ Required properties:
>  		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt8173-nor"
> -- reg: 		  physical base address and length of the controller's register
> +- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
> +		  physical address and length. The first entry is the address and length
> +		  of the controller register set. The optional second entry is the address
> +		  and length of the area where the nor flash is mapped to.

All the compatibles support 2 entries? If not, which ones?

>  - clocks: 	  the phandle of the clocks needed by the nor controller
>  - clock-names: 	  the names of the clocks
>  		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
> @@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
>  	};
>  };
>  
> +nor_flash: spi@11014000 {
> +	compatible = "mediatek,mt7629-nor",
> +		     "mediatek,mt8173-nor";
> +	reg = <0x11014000 0xe0>,
> +	      <0x30000000 0x10000000>;
> +	clocks = <&pericfg CLK_PERI_FLASH_PD>,
> +		 <&topckgen CLK_TOP_FLASH_SEL>;
> +	clock-names = "spi", "sf";
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	flash@0 {
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +	};
> +};
> -- 
> 2.21.0
> 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  1:09     ` Rob Herring
  0 siblings, 0 replies; 48+ messages in thread
From: Rob Herring @ 2019-11-07  1:09 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> update register descriptions and add an example binding using it.
> 
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> ---
>  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> index a12e3b5c495d..4860f6e96f5a 100644
> --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> @@ -12,7 +12,10 @@ Required properties:
>  		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt8173-nor"
> -- reg: 		  physical base address and length of the controller's register
> +- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
> +		  physical address and length. The first entry is the address and length
> +		  of the controller register set. The optional second entry is the address
> +		  and length of the area where the nor flash is mapped to.

All the compatibles support 2 entries? If not, which ones?

>  - clocks: 	  the phandle of the clocks needed by the nor controller
>  - clock-names: 	  the names of the clocks
>  		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
> @@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
>  	};
>  };
>  
> +nor_flash: spi@11014000 {
> +	compatible = "mediatek,mt7629-nor",
> +		     "mediatek,mt8173-nor";
> +	reg = <0x11014000 0xe0>,
> +	      <0x30000000 0x10000000>;
> +	clocks = <&pericfg CLK_PERI_FLASH_PD>,
> +		 <&topckgen CLK_TOP_FLASH_SEL>;
> +	clock-names = "spi", "sf";
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	flash@0 {
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +	};
> +};
> -- 
> 2.21.0
> 

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  1:09     ` Rob Herring
  0 siblings, 0 replies; 48+ messages in thread
From: Rob Herring @ 2019-11-07  1:09 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> update register descriptions and add an example binding using it.
> 
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> ---
>  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> index a12e3b5c495d..4860f6e96f5a 100644
> --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> @@ -12,7 +12,10 @@ Required properties:
>  		  "mediatek,mt7623-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt7629-nor", "mediatek,mt8173-nor"
>  		  "mediatek,mt8173-nor"
> -- reg: 		  physical base address and length of the controller's register
> +- reg: 		  Contains one or two entries, each of which is a tuple consisting of a
> +		  physical address and length. The first entry is the address and length
> +		  of the controller register set. The optional second entry is the address
> +		  and length of the area where the nor flash is mapped to.

All the compatibles support 2 entries? If not, which ones?

>  - clocks: 	  the phandle of the clocks needed by the nor controller
>  - clock-names: 	  the names of the clocks
>  		  the clocks should be named "spi" and "sf". "spi" is used for spi bus,
> @@ -48,3 +51,19 @@ nor_flash: spi@1100d000 {
>  	};
>  };
>  
> +nor_flash: spi@11014000 {
> +	compatible = "mediatek,mt7629-nor",
> +		     "mediatek,mt8173-nor";
> +	reg = <0x11014000 0xe0>,
> +	      <0x30000000 0x10000000>;
> +	clocks = <&pericfg CLK_PERI_FLASH_PD>,
> +		 <&topckgen CLK_TOP_FLASH_SEL>;
> +	clock-names = "spi", "sf";
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	flash@0 {
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +	};
> +};
> -- 
> 2.21.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-06 14:07   ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-07  6:06     ` Vignesh Raghavendra
  -1 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07  6:06 UTC (permalink / raw)
  To: Chuanhong Guo, linux-mtd
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Rob Herring, Mark Rutland, Matthias Brugger, Tudor Ambarus,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel

Hi,

On 06/11/19 7:37 PM, Chuanhong Guo wrote:
> 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@gmail.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;
> +	}
> +

Don't you need to check if access is still within valid memory mapped
window?

>  	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);

There is a single API now: devm_platform_ioremap_resource().

> +	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);
> 

-- 
Regards
Vignesh

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  6:06     ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07  6:06 UTC (permalink / raw)
  To: Chuanhong Guo, linux-mtd
  Cc: Mark Rutland, devicetree, Tudor Ambarus, Richard Weinberger,
	linux-kernel, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi,

On 06/11/19 7:37 PM, Chuanhong Guo wrote:
> 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@gmail.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;
> +	}
> +

Don't you need to check if access is still within valid memory mapped
window?

>  	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);

There is a single API now: devm_platform_ioremap_resource().

> +	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);
> 

-- 
Regards
Vignesh

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  6:06     ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07  6:06 UTC (permalink / raw)
  To: Chuanhong Guo, linux-mtd
  Cc: Mark Rutland, devicetree, Tudor Ambarus, Richard Weinberger,
	linux-kernel, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi,

On 06/11/19 7:37 PM, Chuanhong Guo wrote:
> 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@gmail.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;
> +	}
> +

Don't you need to check if access is still within valid memory mapped
window?

>  	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);

There is a single API now: devm_platform_ioremap_resource().

> +	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);
> 

-- 
Regards
Vignesh

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  6:06     ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07  6:06 UTC (permalink / raw)
  To: Chuanhong Guo, linux-mtd
  Cc: Mark Rutland, devicetree, Tudor Ambarus, Richard Weinberger,
	linux-kernel, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi,

On 06/11/19 7:37 PM, Chuanhong Guo wrote:
> 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@gmail.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;
> +	}
> +

Don't you need to check if access is still within valid memory mapped
window?

>  	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);

There is a single API now: devm_platform_ioremap_resource().

> +	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);
> 

-- 
Regards
Vignesh

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
  2019-11-07  1:09     ` Rob Herring
  (?)
  (?)
@ 2019-11-07  9:25       ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-mtd, David Woodhouse, Brian Norris, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Mark Rutland,
	Matthias Brugger, Tudor Ambarus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, linux-mediatek, open list

Hi!

On Thu, Nov 7, 2019 at 9:09 AM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> > update register descriptions and add an example binding using it.
> >
> > Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> > ---
> >  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > index a12e3b5c495d..4860f6e96f5a 100644
> > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > @@ -12,7 +12,10 @@ Required properties:
> >                 "mediatek,mt7623-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt7629-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt8173-nor"
> > -- reg:                 physical base address and length of the controller's register
> > +- reg:                 Contains one or two entries, each of which is a tuple consisting of a
> > +               physical address and length. The first entry is the address and length
> > +               of the controller register set. The optional second entry is the address
> > +               and length of the area where the nor flash is mapped to.
>
> All the compatibles support 2 entries? If not, which ones?

It should be. I implemented it as an optional feature only because I
don't know the mapped address space for all these chips and can't
update every device trees.

Regards,
Chuanhong Guo

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  9:25       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, linux-mtd, Miquel Raynal, Matthias Brugger,
	linux-mediatek, Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:09 AM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> > update register descriptions and add an example binding using it.
> >
> > Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> > ---
> >  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > index a12e3b5c495d..4860f6e96f5a 100644
> > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > @@ -12,7 +12,10 @@ Required properties:
> >                 "mediatek,mt7623-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt7629-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt8173-nor"
> > -- reg:                 physical base address and length of the controller's register
> > +- reg:                 Contains one or two entries, each of which is a tuple consisting of a
> > +               physical address and length. The first entry is the address and length
> > +               of the controller register set. The optional second entry is the address
> > +               and length of the area where the nor flash is mapped to.
>
> All the compatibles support 2 entries? If not, which ones?

It should be. I implemented it as an optional feature only because I
don't know the mapped address space for all these chips and can't
update every device trees.

Regards,
Chuanhong Guo

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  9:25       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, linux-mtd, Miquel Raynal, Matthias Brugger,
	linux-mediatek, Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:09 AM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> > update register descriptions and add an example binding using it.
> >
> > Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> > ---
> >  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > index a12e3b5c495d..4860f6e96f5a 100644
> > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > @@ -12,7 +12,10 @@ Required properties:
> >                 "mediatek,mt7623-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt7629-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt8173-nor"
> > -- reg:                 physical base address and length of the controller's register
> > +- reg:                 Contains one or two entries, each of which is a tuple consisting of a
> > +               physical address and length. The first entry is the address and length
> > +               of the controller register set. The optional second entry is the address
> > +               and length of the area where the nor flash is mapped to.
>
> All the compatibles support 2 entries? If not, which ones?

It should be. I implemented it as an optional feature only because I
don't know the mapped address space for all these chips and can't
update every device trees.

Regards,
Chuanhong Guo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-07  9:25       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, linux-mtd, Miquel Raynal, Matthias Brugger,
	linux-mediatek, Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:09 AM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Nov 06, 2019 at 10:07:48PM +0800, Chuanhong Guo wrote:
> > update register descriptions and add an example binding using it.
> >
> > Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
> > ---
> >  .../devicetree/bindings/mtd/mtk-quadspi.txt   | 21 ++++++++++++++++++-
> >  1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > index a12e3b5c495d..4860f6e96f5a 100644
> > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt
> > @@ -12,7 +12,10 @@ Required properties:
> >                 "mediatek,mt7623-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt7629-nor", "mediatek,mt8173-nor"
> >                 "mediatek,mt8173-nor"
> > -- reg:                 physical base address and length of the controller's register
> > +- reg:                 Contains one or two entries, each of which is a tuple consisting of a
> > +               physical address and length. The first entry is the address and length
> > +               of the controller register set. The optional second entry is the address
> > +               and length of the area where the nor flash is mapped to.
>
> All the compatibles support 2 entries? If not, which ones?

It should be. I implemented it as an optional feature only because I
don't know the mapped address space for all these chips and can't
update every device trees.

Regards,
Chuanhong Guo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-07  6:06     ` Vignesh Raghavendra
  (?)
  (?)
@ 2019-11-07  9:31       ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:31 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: linux-mtd, David Woodhouse, Brian Norris, Miquel Raynal,
	Richard Weinberger, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, linux-mediatek, open list

Hi!

On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
> > @@ -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;
> > +     }
> > +
>
> Don't you need to check if access is still within valid memory mapped
> window?

The mapped area is 256MB and I don't quite believe there will be such
a big NOR flash.
I'll add a check here in the next version.

>
> >       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);
>
> There is a single API now: devm_platform_ioremap_resource().

Cool. I'll change it.
Should I add another patch to change the same mapping operation right
above this piece of code?

Regards,
Chuanhong Guo

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  9:31       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:31 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
> > @@ -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;
> > +     }
> > +
>
> Don't you need to check if access is still within valid memory mapped
> window?

The mapped area is 256MB and I don't quite believe there will be such
a big NOR flash.
I'll add a check here in the next version.

>
> >       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);
>
> There is a single API now: devm_platform_ioremap_resource().

Cool. I'll change it.
Should I add another patch to change the same mapping operation right
above this piece of code?

Regards,
Chuanhong Guo

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  9:31       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:31 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
> > @@ -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;
> > +     }
> > +
>
> Don't you need to check if access is still within valid memory mapped
> window?

The mapped area is 256MB and I don't quite believe there will be such
a big NOR flash.
I'll add a check here in the next version.

>
> >       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);
>
> There is a single API now: devm_platform_ioremap_resource().

Cool. I'll change it.
Should I add another patch to change the same mapping operation right
above this piece of code?

Regards,
Chuanhong Guo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07  9:31       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07  9:31 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
> > @@ -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;
> > +     }
> > +
>
> Don't you need to check if access is still within valid memory mapped
> window?

The mapped area is 256MB and I don't quite believe there will be such
a big NOR flash.
I'll add a check here in the next version.

>
> >       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);
>
> There is a single API now: devm_platform_ioremap_resource().

Cool. I'll change it.
Should I add another patch to change the same mapping operation right
above this piece of code?

Regards,
Chuanhong Guo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-07  9:31       ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-07 12:25         ` Vignesh Raghavendra
  -1 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07 12:25 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: linux-mtd, David Woodhouse, Brian Norris, Miquel Raynal,
	Richard Weinberger, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, linux-mediatek, open list



On 07/11/19 3:01 PM, Chuanhong Guo wrote:
> Hi!
> 
> On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
>>> @@ -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;
>>> +     }
>>> +
>>
>> Don't you need to check if access is still within valid memory mapped
>> window?
> 
> The mapped area is 256MB and I don't quite believe there will be such
> a big NOR flash.
> I'll add a check here in the next version.
>


There are 256MB (2GiB) NORs out there in market already. So, pretty
soon, 256MB window won't be big enough :)

>>
>>>       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);
>>
>> There is a single API now: devm_platform_ioremap_resource().
> 
> Cool. I'll change it.
> Should I add another patch to change the same mapping operation right
> above this piece of code?
> 

That would be nice to do too, please send a separate patch.

-- 
Regards
Vignesh

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 12:25         ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07 12:25 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel



On 07/11/19 3:01 PM, Chuanhong Guo wrote:
> Hi!
> 
> On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
>>> @@ -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;
>>> +     }
>>> +
>>
>> Don't you need to check if access is still within valid memory mapped
>> window?
> 
> The mapped area is 256MB and I don't quite believe there will be such
> a big NOR flash.
> I'll add a check here in the next version.
>


There are 256MB (2GiB) NORs out there in market already. So, pretty
soon, 256MB window won't be big enough :)

>>
>>>       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);
>>
>> There is a single API now: devm_platform_ioremap_resource().
> 
> Cool. I'll change it.
> Should I add another patch to change the same mapping operation right
> above this piece of code?
> 

That would be nice to do too, please send a separate patch.

-- 
Regards
Vignesh

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 12:25         ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07 12:25 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel



On 07/11/19 3:01 PM, Chuanhong Guo wrote:
> Hi!
> 
> On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
>>> @@ -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;
>>> +     }
>>> +
>>
>> Don't you need to check if access is still within valid memory mapped
>> window?
> 
> The mapped area is 256MB and I don't quite believe there will be such
> a big NOR flash.
> I'll add a check here in the next version.
>


There are 256MB (2GiB) NORs out there in market already. So, pretty
soon, 256MB window won't be big enough :)

>>
>>>       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);
>>
>> There is a single API now: devm_platform_ioremap_resource().
> 
> Cool. I'll change it.
> Should I add another patch to change the same mapping operation right
> above this piece of code?
> 

That would be nice to do too, please send a separate patch.

-- 
Regards
Vignesh

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 12:25         ` Vignesh Raghavendra
  0 siblings, 0 replies; 48+ messages in thread
From: Vignesh Raghavendra @ 2019-11-07 12:25 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Tudor Ambarus, Richard Weinberger, open list, Rob Herring,
	linux-mtd, Miquel Raynal, Matthias Brugger, linux-mediatek,
	Brian Norris, David Woodhouse, linux-arm-kernel



On 07/11/19 3:01 PM, Chuanhong Guo wrote:
> Hi!
> 
> On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
>>> @@ -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;
>>> +     }
>>> +
>>
>> Don't you need to check if access is still within valid memory mapped
>> window?
> 
> The mapped area is 256MB and I don't quite believe there will be such
> a big NOR flash.
> I'll add a check here in the next version.
>


There are 256MB (2GiB) NORs out there in market already. So, pretty
soon, 256MB window won't be big enough :)

>>
>>>       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);
>>
>> There is a single API now: devm_platform_ioremap_resource().
> 
> Cool. I'll change it.
> Should I add another patch to change the same mapping operation right
> above this piece of code?
> 

That would be nice to do too, please send a separate patch.

-- 
Regards
Vignesh

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-06 14:07   ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-07 13:23     ` Yingjoe Chen
  -1 siblings, 0 replies; 48+ messages in thread
From: Yingjoe Chen @ 2019-11-07 13:23 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: linux-mtd, Mark Rutland, devicetree, Vignesh Raghavendra,
	Tudor Ambarus, Richard Weinberger, linux-kernel, Rob Herring,
	linux-mediatek, Miquel Raynal, Matthias Brugger, Brian Norris,
	David Woodhouse, linux-arm-kernel

On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> 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

This may not be true for all MTK SoC. Which one are you testing?

Joe.C





^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 13:23     ` Yingjoe Chen
  0 siblings, 0 replies; 48+ messages in thread
From: Yingjoe Chen @ 2019-11-07 13:23 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Rob Herring, linux-mtd,
	Miquel Raynal, Matthias Brugger, linux-mediatek, Brian Norris,
	David Woodhouse, linux-arm-kernel

On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> 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

This may not be true for all MTK SoC. Which one are you testing?

Joe.C





______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 13:23     ` Yingjoe Chen
  0 siblings, 0 replies; 48+ messages in thread
From: Yingjoe Chen @ 2019-11-07 13:23 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Rob Herring, linux-mtd,
	Miquel Raynal, Matthias Brugger, linux-mediatek, Brian Norris,
	David Woodhouse, linux-arm-kernel

On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> 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

This may not be true for all MTK SoC. Which one are you testing?

Joe.C





_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 13:23     ` Yingjoe Chen
  0 siblings, 0 replies; 48+ messages in thread
From: Yingjoe Chen @ 2019-11-07 13:23 UTC (permalink / raw)
  To: Chuanhong Guo
  Cc: Mark Rutland, devicetree, Vignesh Raghavendra, Tudor Ambarus,
	Richard Weinberger, linux-kernel, Rob Herring, linux-mtd,
	Miquel Raynal, Matthias Brugger, linux-mediatek, Brian Norris,
	David Woodhouse, linux-arm-kernel

On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> 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

This may not be true for all MTK SoC. Which one are you testing?

Joe.C





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-07 13:23     ` Yingjoe Chen
  (?)
  (?)
@ 2019-11-07 15:34       ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07 15:34 UTC (permalink / raw)
  To: Yingjoe Chen
  Cc: linux-mtd, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:23 PM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> > 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
>
> This may not be true for all MTK SoC. Which one are you testing?
>

I tested it on MT7629.
There should be a 5x reading speed increment under DMA or direct read
mode than PIO mode because PIO mode needs 30 or 36 clocks for every
single byte of data while DMA or direct read only needs 24 or 30
clocks for initial command/address/dummy and every byte of data after
that only need 8 clocks.

Regards,
Chuanhong Guo

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 15:34       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07 15:34 UTC (permalink / raw)
  To: Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:23 PM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> > 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
>
> This may not be true for all MTK SoC. Which one are you testing?
>

I tested it on MT7629.
There should be a 5x reading speed increment under DMA or direct read
mode than PIO mode because PIO mode needs 30 or 36 clocks for every
single byte of data while DMA or direct read only needs 24 or 30
clocks for initial command/address/dummy and every byte of data after
that only need 8 clocks.

Regards,
Chuanhong Guo

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 15:34       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07 15:34 UTC (permalink / raw)
  To: Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:23 PM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> > 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
>
> This may not be true for all MTK SoC. Which one are you testing?
>

I tested it on MT7629.
There should be a 5x reading speed increment under DMA or direct read
mode than PIO mode because PIO mode needs 30 or 36 clocks for every
single byte of data while DMA or direct read only needs 24 or 30
clocks for initial command/address/dummy and every byte of data after
that only need 8 clocks.

Regards,
Chuanhong Guo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-07 15:34       ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-07 15:34 UTC (permalink / raw)
  To: Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mtd, Miquel Raynal,
	Matthias Brugger, linux-mediatek, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Thu, Nov 7, 2019 at 9:23 PM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Wed, 2019-11-06 at 22:07 +0800, Chuanhong Guo wrote:
> > 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
>
> This may not be true for all MTK SoC. Which one are you testing?
>

I tested it on MT7629.
There should be a 5x reading speed increment under DMA or direct read
mode than PIO mode because PIO mode needs 30 or 36 clocks for every
single byte of data while DMA or direct read only needs 24 or 30
clocks for initial command/address/dummy and every byte of data after
that only need 8 clocks.

Regards,
Chuanhong Guo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
  2019-11-06 14:07   ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-08  3:51     ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:51 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, linux-mediatek, open list

Hi!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> update register descriptions and add an example binding using it.
>
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-08  3:51     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:51 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> update register descriptions and add an example binding using it.
>
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-08  3:51     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:51 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> update register descriptions and add an example binding using it.
>
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read
@ 2019-11-08  3:51     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:51 UTC (permalink / raw)
  To: linux-mtd
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> update register descriptions and add an example binding using it.
>
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
  2019-11-06 14:07   ` Chuanhong Guo
  (?)
  (?)
@ 2019-11-08  3:52     ` Chuanhong Guo
  -1 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:52 UTC (permalink / raw)
  To: linux-mtd, Yingjoe Chen
  Cc: David Woodhouse, Brian Norris, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Rob Herring, Mark Rutland, Matthias Brugger,
	Tudor Ambarus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, linux-mediatek, open list

Hi all!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> 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@gmail.com>
> ---
>  drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-08  3:52     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:52 UTC (permalink / raw)
  To: linux-mtd, Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi all!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> 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@gmail.com>
> ---
>  drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-08  3:52     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:52 UTC (permalink / raw)
  To: linux-mtd, Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi all!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> 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@gmail.com>
> ---
>  drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading
@ 2019-11-08  3:52     ` Chuanhong Guo
  0 siblings, 0 replies; 48+ messages in thread
From: Chuanhong Guo @ 2019-11-08  3:52 UTC (permalink / raw)
  To: linux-mtd, Yingjoe Chen
  Cc: Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	open list, Rob Herring, linux-mediatek, Miquel Raynal,
	Matthias Brugger, Brian Norris, David Woodhouse,
	linux-arm-kernel

Hi all!

On Wed, Nov 6, 2019 at 10:08 PM Chuanhong Guo <gch981213@gmail.com> wrote:
>
> 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@gmail.com>
> ---
>  drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

I'll abandon this patchset and implement DMA reading instead.

Regards,
Chuanhong Guo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2019-11-08  3:52 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 14:07 [PATCH 0/2] mtd: mtk-quadspi: add support for memory-mapped flash reading Chuanhong Guo
2019-11-06 14:07 ` Chuanhong Guo
2019-11-06 14:07 ` Chuanhong Guo
2019-11-06 14:07 ` Chuanhong Guo
2019-11-06 14:07 ` [PATCH 1/2] " Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-07  6:06   ` Vignesh Raghavendra
2019-11-07  6:06     ` Vignesh Raghavendra
2019-11-07  6:06     ` Vignesh Raghavendra
2019-11-07  6:06     ` Vignesh Raghavendra
2019-11-07  9:31     ` Chuanhong Guo
2019-11-07  9:31       ` Chuanhong Guo
2019-11-07  9:31       ` Chuanhong Guo
2019-11-07  9:31       ` Chuanhong Guo
2019-11-07 12:25       ` Vignesh Raghavendra
2019-11-07 12:25         ` Vignesh Raghavendra
2019-11-07 12:25         ` Vignesh Raghavendra
2019-11-07 12:25         ` Vignesh Raghavendra
2019-11-07 13:23   ` Yingjoe Chen
2019-11-07 13:23     ` Yingjoe Chen
2019-11-07 13:23     ` Yingjoe Chen
2019-11-07 13:23     ` Yingjoe Chen
2019-11-07 15:34     ` Chuanhong Guo
2019-11-07 15:34       ` Chuanhong Guo
2019-11-07 15:34       ` Chuanhong Guo
2019-11-07 15:34       ` Chuanhong Guo
2019-11-08  3:52   ` Chuanhong Guo
2019-11-08  3:52     ` Chuanhong Guo
2019-11-08  3:52     ` Chuanhong Guo
2019-11-08  3:52     ` Chuanhong Guo
2019-11-06 14:07 ` [PATCH 2/2] dt-bindings: mtd: mtk-quadspi: update bindings for mmap flash read Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-06 14:07   ` Chuanhong Guo
2019-11-07  1:09   ` Rob Herring
2019-11-07  1:09     ` Rob Herring
2019-11-07  1:09     ` Rob Herring
2019-11-07  1:09     ` Rob Herring
2019-11-07  9:25     ` Chuanhong Guo
2019-11-07  9:25       ` Chuanhong Guo
2019-11-07  9:25       ` Chuanhong Guo
2019-11-07  9:25       ` Chuanhong Guo
2019-11-08  3:51   ` Chuanhong Guo
2019-11-08  3:51     ` Chuanhong Guo
2019-11-08  3:51     ` Chuanhong Guo
2019-11-08  3:51     ` Chuanhong Guo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.