Add spi-mem driver for MediaTek MT7629 SoC
Subsystems (4)
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the mtk_qspi is no longer compatible with the new spi-nor driver.
This patch series add a new spi-mem driver to replace the mtk_qspi driver, with one patch to fix watchdog not feeding during spi operation.
Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsolete mtk_qspi driver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs: mt7629_rfb: change MTK_QSPI to MTK_SNFI_SPI
MAINTAINERS: change spi driver entry
MAINTAINERS | 2 +- arch/arm/dts/mt7629-rfb.dts | 18 +- arch/arm/dts/mt7629.dtsi | 14 +- configs/mt7629_rfb_defconfig | 2 +- drivers/mtd/spi/spi-nor-core.c | 13 ++ drivers/mtd/spi/spi-nor-tiny.c | 3 + drivers/spi/Kconfig | 15 +- drivers/spi/Makefile | 2 +- drivers/spi/mtk_qspi.c | 359 --------------------------------- drivers/spi/mtk_snfi_spi.c | 315 +++++++++++++++++++++++++++++ 10 files changed, 365 insertions(+), 378 deletions(-) delete mode 100644 drivers/spi/mtk_qspi.c create mode 100644 drivers/spi/mtk_snfi_spi.c
Signature · 1 line
2.18.0
PATCH v4 1/6 mtd: spi-nor: add watchdog reset to flash operation loops
This patch adds WATCHDOG_RESET() to loops for read/write/erase to avoid watchdog not being feeded in a long period.
--- drivers/mtd/spi/spi-nor-core.c | 13 +++++++++++++ drivers/mtd/spi/spi-nor-tiny.c | 3 +++ 2 files changed, 16 insertions(+)
drivers/mtd/spi/spi-nor-core.c +13 -0
@@ -10,6 +10,7 @@*/ #include <common.h> +#include <watchdog.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/log2.h>
@@ -103,6 +104,8 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, op.addr.val += op.data.nbytes; remaining -= op.data.nbytes; op.data.buf.in += op.data.nbytes; + +WATCHDOG_RESET (); }return len;
@@ -571,6 +574,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) ret =spi_nor_wait_till_ready (nor);if (ret) goto erase_err; + +WATCHDOG_RESET (); } erase_err:
@@ -963,6 +968,9 @@ static int sst_write_byteprogram(struct spi_nor *nor, loff_t to, size_t len,if (ret) goto sst_write_err; to++; + +if (actual %0x100 ==0 ) +WATCHDOG_RESET (); } sst_write_err:
@@ -1014,6 +1022,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, goto sst_write_err; to +=2 ; nor->sst_write_second = true; + +if (actual %0x100 ==0 ) +WATCHDOG_RESET (); } nor->sst_write_second = false;
@@ -1094,6 +1105,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, goto write_err; *retlen += written; i += written; + +WATCHDOG_RESET (); } write_err:
drivers/mtd/spi/spi-nor-tiny.c +3 -0
@@ -10,6 +10,7 @@*/ #include <common.h> +#include <watchdog.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/log2.h>
@@ -103,6 +104,8 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, op.addr.val += op.data.nbytes; remaining -= op.data.nbytes; op.data.buf.in += op.data.nbytes; + +WATCHDOG_RESET (); }return len;
Signature · 1 line
2.18.0
PATCH v4 1/6 mtd: spi-nor: add watchdog reset to flash operation loops
+ Vignesh
Quoted 24 lines · Weijie Gao
This patch adds
WATCHDOG_RESET()to loops for read/write/erase to avoid watchdog not being feeded in a long period.Cc Vignesh Raghavendra <[email protected]>Signed-off-by Weijie Gao <[email protected]>--- drivers/mtd/spi/spi-nor-core.c | 13 +++++++++++++ drivers/mtd/spi/spi-nor-tiny.c | 3 +++ 2 files changed, 16 insertions(+)drivers/mtd/spi/spi-nor-core.c +1
-0@@ -10,6 +10,7 @@*/ #include <common.h> +#include <watchdog.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/log2.h>
drivers/mtd/spi/spi-nor-core.c static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, · line 109
Quoted 6 lines
drivers/mtd/spi/spi-nor-core.c +2
-0@@ -103,6 +104,8 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, op.addr.val += op.data.nbytes; remaining -= op.data.nbytes; op.data.buf.in += op.data.nbytes; + +WATCHDOG_RESET (); }
Not sure, but it would require better testing.
PATCH v4 2/6 spi: remove obsolete mtk_qspi driver
In reply to Weijie GaoSince u-boot has added the spi-mem framework and replaced the spi-nor framework, the mtk_qspi is no longer compatible with the new spi-nor driver.
Remove this driver, and a new driver will be added later.
---
Changes since v1: none
--- drivers/spi/Kconfig | 8 - drivers/spi/Makefile | 1 - drivers/spi/mtk_qspi.c | 359 ----------------------------------------- 3 files changed, 368 deletions(-) delete mode 100644 drivers/spi/mtk_qspi.c
drivers/spi/Kconfig +0 -8
@@ -150,14 +150,6 @@ config MT7621_SPI the SPI NOR flash on platforms embedding this Ralink / MediaTek SPI core, like MT7621/7628/7688. -config MTK_QSPI - bool "Mediatek QSPI driver" - imply SPI_FLASH_BAR - help - Enable the Mediatek QSPI driver. This driver can be - used to access the SPI NOR flash on platforms embedding this - Mediatek QSPI IP core. - config MVEBU_A3700_SPI bool "Marvell Armada 3700 SPI driver" select CLK_ARMADA_3720
drivers/spi/Makefile +0 -1
@@ -36,7 +36,6 @@ obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o -obj-$(CONFIG_MTK_QSPI) += mtk_qspi.o obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o obj-$(CONFIG_MSCC_BB_SPI) += mscc_bb_spi.o obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
drivers/spi/mtk_qspi.c deleted +0 -359
359 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v4 3/6 spi: add spi-mem driver for MediaTek MT7629 SoC
In reply to Weijie GaoThis patch adds spi-mem driver for MediaTek MT7629 SoC to access SPI-NOR and SPI-NAND flashes.
---
Changes since v1: rename mtk_spimem to spi_snfi_spi. change pinctrl name. Changes since v2: remove udevice in mtk_snfi_priv.
Changes since v3: remove check for chipselect.
--- drivers/spi/Kconfig | 9 ++ drivers/spi/Makefile | 1 + drivers/spi/mtk_snfi_spi.c | 315 +++++++++++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 drivers/spi/mtk_snfi_spi.c
drivers/spi/Kconfig +9 -0
@@ -150,6 +150,15 @@ config MT7621_SPI the SPI NOR flash on platforms embedding this Ralink / MediaTek SPI core, like MT7621/7628/7688. +config MTK_SNFI_SPI + bool "Mediatek SPI memory controller driver" + depends on SPI_MEM + help + Enable the Mediatek SPI memory controller driver. This driver is + originally based on the MediaTek SNFI IP core. It can only be + used to access SPI memory devices like SPI-NOR or SPI-NAND on + platforms embedding this IP core, like MT7622/M7629. + config MVEBU_A3700_SPI bool "Marvell Armada 3700 SPI driver" select CLK_ARMADA_3720
drivers/spi/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o +obj-$(CONFIG_MTK_SNFI_SPI) += mtk_snfi_spi.o obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o obj-$(CONFIG_MSCC_BB_SPI) += mscc_bb_spi.o obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
drivers/spi/mtk_snfi_spi.c new file +315 -0
315 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v4 4/6 arm: dts: change MT7629 to use spi-mem rather than qspi
In reply to Weijie GaoThe original mtk_qspi driver has been removed. We change MT7629 to use newly added mtk-spimem driver.
---
Changes since v1: rename node spimem to snfi. change pinctrl name and order. Changes since v2: none
--- arch/arm/dts/mt7629-rfb.dts | 18 +++++++++++++----- arch/arm/dts/mt7629.dtsi | 14 ++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-)
arch/arm/dts/mt7629-rfb.dts +13 -5
@@ -13,7 +13,7 @@ compatible = "mediatek,mt7629-rfb", "mediatek,mt7629"; aliases { - spi0 = &qspi; + spi0 = &snfi; }; chosen {
@@ -34,7 +34,14 @@ }; &pinctrl { - qspi_pins: qspi-pins { + snfi_pins: snfi-pins { + mux { + function = "flash"; + groups = "snfi"; + }; + }; + + snor_pins: snor-pins { mux { function = "flash"; groups = "spi_nor";
@@ -56,9 +63,10 @@ }; }; -&qspi { - pinctrl-names = "default"; - pinctrl-0 = <&qspi_pins>; +&snfi { + pinctrl-names = "default", "snfi"; + pinctrl-0 = <&snor_pins>; + pinctrl-1 = <&snfi_pins>; status = "okay"; spi-flash at 0{
arch/arm/dts/mt7629.dtsi +10 -4
@@ -215,10 +215,16 @@ status = "disabled"; }; - qspi: qspi at 11014000 { - compatible = "mediatek,mt7629-qspi"; - reg = <0x11014000 0xe0>, <0x30000000 0x10000000>; - reg-names = "reg_base", "mem_base"; + snfi: snfi at 1100d000 { + compatible = "mediatek,mtk-snfi-spi"; + reg = <0x1100d000 0x2000>; + clocks = <&pericfg CLK_PERI_NFI_PD>, + <&pericfg CLK_PERI_SNFI_PD>; + clock-names = "nfi_clk", "pad_clk"; + assigned-clocks = <&topckgen CLK_TOP_AXI_SEL>, + <&topckgen CLK_TOP_NFI_INFRA_SEL>; + assigned-clock-parents = <&topckgen CLK_TOP_SYSPLL1_D2>, + <&topckgen CLK_TOP_UNIVPLL2_D8>; status = "disabled"; #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.18.0
PATCH v4 5/6 configs: mt7629_rfb: change MTK_QSPI to MTK_SNFI_SPI
In reply to Weijie GaoThis patch replaces MTK_QSPI with MTK_SNFI_SPI to ensure mtk_snfi_spi driver is built by default.
---
Changes since v1: none
--- configs/mt7629_rfb_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/mt7629_rfb_defconfig +1 -1
@@ -63,7 +63,7 @@ CONFIG_DM_SERIAL=y CONFIG_MTK_SERIAL=y CONFIG_SPI=y CONFIG_DM_SPI=y -CONFIG_MTK_QSPI=y +CONFIG_MTK_SNFI_SPI=y CONFIG_SYSRESET=y CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_WATCHDOG=y
Signature · 1 line
2.18.0
PATCH v4 6/6 MAINTAINERS: change spi driver entry
In reply to Weijie GaoChange mtk_qspi.c to mtk_snfi_spi.c
---
Changes since v1: rename mtk_spimem.c to spi_snfi_spi.c Changes since v2: none
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -205,7 +205,7 @@ F: drivers/mmc/mtk-sd.c F: drivers/pinctrl/mediatek/ F: drivers/power/domain/mtk-power-domain.c F: drivers/ram/mediatek/ -F: drivers/spi/mtk_qspi.c +F: drivers/spi/mtk_snfi_spi.c F: drivers/timer/mtk_timer.c F: drivers/watchdog/mtk_wdt.c F: drivers/net/mtk_eth.c
Signature · 1 line
2.18.0
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
In reply to Weijie GaoQuoted 7 lines · Weijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the
mtk_qspiis no longer compatible with the new spi-nor driver.This patch series add a new spi-mem driver to replace the
mtk_qspidriver, with one patch to fix watchdog not feeding during spi operation.
Quoted 7 lines
Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsoletemtk_qspidriver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs:mt7629_rfb: changeMTK_QSPItoMTK_SNFI_SPI
MAINTAINERS: change spi driver entry
What is v4 change log? I wouldn't find it on individual patches?
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
Quoted 16 lines · Jagan Teki
Quoted 7 lines · Weijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the
mtk_qspiis no longer compatible with the new spi-nor driver.This patch series add a new spi-mem driver to replace the
mtk_qspidriver, with one patch to fix watchdog not feeding during spi operation.Quoted 7 lines
Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsoletemtk_qspidriver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs:mt7629_rfb: changeMTK_QSPItoMTK_SNFI_SPI
MAINTAINERS: change spi driver entry
Quoted 1 line
What is v4 change log? I wouldn't find it on individual patches?
Oh, I forgot to write this to cover letter. But I have written change log to "spi: add spi-mem driver for MediaTek MT7629 SoC". There is only one change in this patch: remove chip select checking. I think this should be implemented in spi-uclass.
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
Quoted 18 lines · Weijie Gao
Quoted 16 lines · Jagan Teki
Quoted 14 lines · Weijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the
mtk_qspiis no longer compatible with the new spi-nor driver.This patch series add a new spi-mem driver to replace the
mtk_qspidriver, with one patch to fix watchdog not feeding during spi operation.Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsoletemtk_qspidriver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs:mt7629_rfb: changeMTK_QSPItoMTK_SNFI_SPI
MAINTAINERS: change spi driver entry
Quoted 6 lines
Quoted 1 line
What is v4 change log? I wouldn't find it on individual patches?
Oh, I forgot to write this to cover letter. But I have written change log to "spi: add spi-mem driver for MediaTek MT7629 SoC". There is only one change in this patch: remove chip select checking. I think this should be implemented in spi-uclass.
Okay, np. except 0001 rest look fine for me.
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
Quoted 21 lines · Jagan Teki
Quoted 20 lines · Weijie Gao
Quoted 17 lines · Jagan Teki
Quoted 7 lines · Weijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the
mtk_qspiis no longer compatible with the new spi-nor driver.This patch series add a new spi-mem driver to replace the
mtk_qspidriver, with one patch to fix watchdog not feeding during spi operation.Quoted 7 lines
Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsoletemtk_qspidriver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs:mt7629_rfb: changeMTK_QSPItoMTK_SNFI_SPI
MAINTAINERS: change spi driver entryWhat is v4 change log? I wouldn't find it on individual patches?
Quoted 8 lines
Quoted 4 lines
Oh, I forgot to write this to cover letter. But I have written change log to "spi: add spi-mem driver for MediaTek MT7629 SoC". There is only one change in this patch: remove chip select checking. I think this should be implemented in spi-uclass.
Okay, np. except 0001 rest look fine for me.
Reviewed-by Jagan Teki <[email protected]>
I have tested another solution. I just move WATCHDOG_RESET() into the mtk_snfi_exec_op() so there is no need to modify the spi-nor driver. I think this is better for mt7629.
v4 cover Add spi-mem driver for MediaTek MT7629 SoC
Quoted 28 lines · Weijie Gao
Quoted 26 lines · Jagan Teki
Quoted 24 lines · Weijie Gao
Quoted 16 lines · Jagan Teki
Quoted 7 lines · Weijie Gao
Since u-boot has added the spi-mem framework and replaced the spi-nor framework, the
mtk_qspiis no longer compatible with the new spi-nor driver.This patch series add a new spi-mem driver to replace the
mtk_qspidriver, with one patch to fix watchdog not feeding during spi operation.Quoted 7 lines
Weijie Gao (6):
mtd: spi-nor: add watchdog reset to flash operation loops
spi: remove obsoletemtk_qspidriver
spi: add spi-mem driver for MediaTek MT7629 SoC
arm: dts: change MT7629 to use spi-mem rather than qspi
configs:mt7629_rfb: changeMTK_QSPItoMTK_SNFI_SPI
MAINTAINERS: change spi driver entryQuoted 1 line
What is v4 change log? I wouldn't find it on individual patches?
Oh, I forgot to write this to cover letter. But I have written change log to "spi: add spi-mem driver for MediaTek MT7629 SoC". There is only one change in this patch: remove chip select checking. I think this should be implemented in spi-uclass.
Quoted 8 lines
Quoted 3 lines
Okay, np. except 0001 rest look fine for me.
Reviewed-by Jagan Teki <[email protected]>I have tested another solution. I just move
WATCHDOG_RESET()into themtk_snfi_exec_op()so there is no need to modify the spi-nor driver. I think this is better for mt7629.
Sounds good.