Skip to contentSkip to conversation

Add spi-mem driver for MediaTek MT7629 SoC

PATCH New Weijie Gao 3 participants 10 messages Jul 22, 2019 – Aug 8, 2019

Subsystems (3)
lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

v5 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.

- Changes since v4:
Add WATCHDOG_RESET() to the exec_op() of mtk_snfi_spi driver. Remove the patch that adds WATCHDOG_RESET() to spi-nor driver.

Weijie Gao (5):
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/spi/Kconfig          |  15 +-
 drivers/spi/Makefile         |   2 +-
 drivers/spi/mtk_qspi.c       | 359 -----------------------------------
 drivers/spi/mtk_snfi_spi.c   | 318 +++++++++++++++++++++++++++++++
 8 files changed, 352 insertions(+), 378 deletions(-)
 delete mode 100644 drivers/spi/mtk_qspi.c
 create mode 100644 drivers/spi/mtk_snfi_spi.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v5 1/5 spi: remove obsolete mtk_qspi driver

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.

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
index cc174dd036..5854675094 100644
@@ -158,14 +158,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
index ab84122f08..eb34922a78 100644
@@ -37,7 +37,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.17.1
#2 lore raw

PATCH v5 1/5 spi: remove obsolete mtk_qspi driver

Quoted 10 lines · Weijie Gao

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.

Remove this driver, and a new driver will be added later.

---

Squash with obsolete changes together and

Applied to u-boot-spi/master

author
#3 lore raw

PATCH v5 2/5 spi: add spi-mem driver for MediaTek MT7629 SoC

In reply to Weijie Gao

This 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.
Changes since v4: Add WATCHDOG_RESET() to exec_op().

---
 drivers/spi/Kconfig        |   9 ++
 drivers/spi/Makefile       |   1 +
 drivers/spi/mtk_snfi_spi.c | 318 +++++++++++++++++++++++++++++++++++++
 3 files changed, 328 insertions(+)
 create mode 100644 drivers/spi/mtk_snfi_spi.c
drivers/spi/Kconfig +9 -0
index 5854675094..ad9beba8a9 100644
@@ -158,6 +158,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
index eb34922a78..4b545c40fc 100644
@@ -37,6 +37,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 +318 -0

318 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v5 3/5 arm: dts: change MT7629 to use spi-mem rather than qspi

In reply to Weijie Gao

The 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
index 4612218a1e..25f1344817 100644
@@ -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
index c87115e0fe..135ac8ecfa 100644
@@ -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.17.1
#6 lore raw

PATCH v5 3/5 arm: dts: change MT7629 to use spi-mem rather than qspi

Quoted 9 lines · Weijie Gao

The 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
---

#7 lore raw

PATCH v5 3/5 arm: dts: change MT7629 to use spi-mem rather than qspi

In reply to Weijie Gao
Quoted 5 lines · Weijie Gao

The original mtk_qspi driver has been removed. We change MT7629 to use newly added mtk-spimem driver.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190807/678b68bd/attachment.sig>
author
#8 lore raw

PATCH v5 4/5 configs: mt7629_rfb: change MTK_QSPI to MTK_SNFI_SPI

In reply to Weijie Gao

This 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
index 0dceafdaa6..d8efba6620 100644
@@ -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.17.1
author
#9 lore raw

PATCH v5 5/5 MAINTAINERS: change spi driver entry

In reply to Weijie Gao

Change 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
index bc67c49965..e836f5050d 100644
@@ -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.17.1