aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>2020-02-11 16:25:36 -0300
committerChuanhong Guo <gch981213@gmail.com>2020-04-14 10:47:23 +0800
commitb3f984233078fcafd236bba4f94a938ab05ebfa2 (patch)
treebee86a2e9ad4730840f5f1faa4155c3774ca8016 /target/linux
parenta5a90a94cee96667b217fbaeb563c1fc4f4b7dba (diff)
downloadupstream-b3f984233078fcafd236bba4f94a938ab05ebfa2.tar.gz
upstream-b3f984233078fcafd236bba4f94a938ab05ebfa2.tar.bz2
upstream-b3f984233078fcafd236bba4f94a938ab05ebfa2.zip
ath79: add read support using spi-mem
Reimplements read optimization on top of spi-mem. Similar to what 461-spi-ath79-add-fast-flash-read.patch used to do with the dropped flash read interface. It accelerate only fast-read op reading flash directly from memory mapped region. 'm25p,fast-read' must be set in order to use the new spi-mem. It improved read speed up to 3x on old devices (tplink,tl-wr2543-v1) while no speed improvement was noticed on newer devices like (tplink,archer-c7-v2). Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/ath79/patches-4.19/410-spi-ath79-Implement-the-spi_mem-interface.patch70
-rw-r--r--target/linux/ath79/patches-5.4/410-spi-ath79-Implement-the-spi_mem-interface.patch70
2 files changed, 140 insertions, 0 deletions
diff --git a/target/linux/ath79/patches-4.19/410-spi-ath79-Implement-the-spi_mem-interface.patch b/target/linux/ath79/patches-4.19/410-spi-ath79-Implement-the-spi_mem-interface.patch
new file mode 100644
index 0000000000..9546f32a27
--- /dev/null
+++ b/target/linux/ath79/patches-4.19/410-spi-ath79-Implement-the-spi_mem-interface.patch
@@ -0,0 +1,70 @@
+From 8d8cdb4a6ccee5b62cc0dc64651c3946364514dc Mon Sep 17 00:00:00 2001
+From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
+Date: Mon, 10 Feb 2020 16:11:27 -0300
+Subject: [PATCH] spi: ath79: Implement the spi_mem interface
+
+Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
+---
+ drivers/spi/spi-ath79.c | 35 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 35 insertions(+)
+
+Index: linux-4.19.106/drivers/spi/spi-ath79.c
+===================================================================
+--- linux-4.19.106.orig/drivers/spi/spi-ath79.c
++++ linux-4.19.106/drivers/spi/spi-ath79.c
+@@ -19,6 +19,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/io.h>
+ #include <linux/spi/spi.h>
++#include <linux/spi/spi-mem.h>
+ #include <linux/spi/spi_bitbang.h>
+ #include <linux/bitops.h>
+ #include <linux/gpio.h>
+@@ -203,6 +204,39 @@ static u32 ath79_spi_txrx_mode0(struct s
+ return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS);
+ }
+
++static int ath79_exec_mem_op(struct spi_mem *mem,
++ const struct spi_mem_op *op)
++{
++ struct ath79_spi *sp = ath79_spidev_to_sp(mem->spi);
++
++ /* Ensures that reading is performed on device connected
++ to hardware cs0 */
++ if (mem->spi->chip_select || gpio_is_valid(mem->spi->cs_gpio))
++ return -ENOTSUPP;
++
++ /* Only use for fast-read op. */
++ if (op->cmd.opcode != 0x0b || op->data.dir != SPI_MEM_DATA_IN ||
++ op->addr.nbytes != 3 || op->dummy.nbytes != 1)
++ return -ENOTSUPP;
++
++ /* disable GPIO mode */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
++
++ memcpy_fromio(op->data.buf.in, sp->base + op->addr.val, op->data.nbytes);
++
++ /* enable GPIO mode */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
++
++ /* restore IOC register */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
++
++ return 0;
++}
++
++static const struct spi_controller_mem_ops ath79_mem_ops = {
++ .exec_op = ath79_exec_mem_op,
++};
++
+ static int ath79_spi_probe(struct platform_device *pdev)
+ {
+ struct spi_master *master;
+@@ -237,6 +271,7 @@ static int ath79_spi_probe(struct platfo
+ ret = PTR_ERR(sp->base);
+ goto err_put_master;
+ }
++ master->mem_ops = &ath79_mem_ops;
+
+ sp->clk = devm_clk_get(&pdev->dev, "ahb");
+ if (IS_ERR(sp->clk)) {
diff --git a/target/linux/ath79/patches-5.4/410-spi-ath79-Implement-the-spi_mem-interface.patch b/target/linux/ath79/patches-5.4/410-spi-ath79-Implement-the-spi_mem-interface.patch
new file mode 100644
index 0000000000..81a328f8f6
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/410-spi-ath79-Implement-the-spi_mem-interface.patch
@@ -0,0 +1,70 @@
+From 8d8cdb4a6ccee5b62cc0dc64651c3946364514dc Mon Sep 17 00:00:00 2001
+From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
+Date: Mon, 10 Feb 2020 16:11:27 -0300
+Subject: [PATCH] spi: ath79: Implement the spi_mem interface
+
+Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
+---
+ drivers/spi/spi-ath79.c | 35 +++++++++++++++++++++++++++++++++++
+ 1 file changed, 35 insertions(+)
+
+Index: linux-5.4.22/drivers/spi/spi-ath79.c
+===================================================================
+--- linux-5.4.22.orig/drivers/spi/spi-ath79.c
++++ linux-5.4.22/drivers/spi/spi-ath79.c
+@@ -15,6 +15,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/io.h>
+ #include <linux/spi/spi.h>
++#include <linux/spi/spi-mem.h>
+ #include <linux/spi/spi_bitbang.h>
+ #include <linux/bitops.h>
+ #include <linux/clk.h>
+@@ -133,6 +134,39 @@ static u32 ath79_spi_txrx_mode0(struct s
+ return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS);
+ }
+
++static int ath79_exec_mem_op(struct spi_mem *mem,
++ const struct spi_mem_op *op)
++{
++ struct ath79_spi *sp = ath79_spidev_to_sp(mem->spi);
++
++ /* Ensures that reading is performed on device connected
++ to hardware cs0 */
++ if (mem->spi->chip_select || mem->spi->cs_gpiod)
++ return -ENOTSUPP;
++
++ /* Only use for fast-read op. */
++ if (op->cmd.opcode != 0x0b || op->data.dir != SPI_MEM_DATA_IN ||
++ op->addr.nbytes != 3 || op->dummy.nbytes != 1)
++ return -ENOTSUPP;
++
++ /* disable GPIO mode */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
++
++ memcpy_fromio(op->data.buf.in, sp->base + op->addr.val, op->data.nbytes);
++
++ /* enable GPIO mode */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
++
++ /* restore IOC register */
++ ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
++
++ return 0;
++}
++
++static const struct spi_controller_mem_ops ath79_mem_ops = {
++ .exec_op = ath79_exec_mem_op,
++};
++
+ static int ath79_spi_probe(struct platform_device *pdev)
+ {
+ struct spi_master *master;
+@@ -163,6 +197,7 @@ static int ath79_spi_probe(struct platfo
+ ret = PTR_ERR(sp->base);
+ goto err_put_master;
+ }
++ master->mem_ops = &ath79_mem_ops;
+
+ sp->clk = devm_clk_get(&pdev->dev, "ahb");
+ if (IS_ERR(sp->clk)) {