rewrite mtk-quadspi spi-nor driver with spi-mem
Subsystems (5)
v3 cover rewrite mtk-quadspi spi-nor driver with spi-mem
This patchset adds a spi-mem driver for Mediatek SPI-NOR controller, which already has limited support by mtk-quadspi. This new driver can make use of full quadspi capability of this controller.
1st new commit makes spi-max-frequency optional to match current binding doc and make this new driver compatible with old driver dt bindings.
Change since v2:
revert binding example replacement and add a dummy irq binding
Changes since v1:
two new commits.
Chuanhong Guo (4):
spi: make spi-max-frequency optional
spi: add support for mediatek spi-nor controller
dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor
mtd: spi-nor: remove mtk-quadspi driver
.../mtk-quadspi.txt => spi/spi-mtk-nor.txt} | 15 +-
drivers/mtd/spi-nor/Kconfig | 8 -
drivers/mtd/spi-nor/Makefile | 1 -
drivers/mtd/spi-nor/mtk-quadspi.c | 565 --------------
drivers/spi/Kconfig | 10 +
drivers/spi/Makefile | 1 +
drivers/spi/spi-mtk-nor.c | 689 ++++++++++++++++++
drivers/spi/spi.c | 9 +-
8 files changed, 708 insertions(+), 590 deletions(-)
rename Documentation/devicetree/bindings/{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} (75%)
delete mode 100644 drivers/mtd/spi-nor/mtk-quadspi.c
create mode 100644 drivers/spi/spi-mtk-nor.cSignature · 1 line
2.24.1
PATCH v3 1/4 spi: make spi-max-frequency optional
We only need a spi-max-frequency when we specifically request a spi frequency lower than the max speed of spi host.
This property is already documented as optional property and current host drivers are implemented to operate at highest speed possible when spi->max_speed_hz is 0.
This patch makes spi-max-frequency an optional property so that we could just omit it to use max controller speed.
---
Change since v2:
none
Change since v1:
new patch
drivers/spi/spi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/spi/spi.c +2 -7
@@ -1951,13 +1951,8 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, spi->mode |=SPI_CS_HIGH ;/* Device speed */ - rc =of_property_read_u32 (nc,"spi-max-frequency" , &value); -if (rc) { -dev_err (&ctlr->dev, -"%pOF has no valid 'spi-max-frequency' property (%d)\n" , nc, rc); -return rc; - } - spi->max_speed_hz = value; +if (!of_property_read_u32 (nc,"spi-max-frequency" , &value)) + spi->max_speed_hz = value;return 0 ; }
Signature · 1 line
2.24.1
PATCH v3 2/4 spi: add support for mediatek spi-nor controller
In reply to Chuanhong GuoThis is a driver for mtk spi-nor controller using spi-mem interface. The same controller already has limited support provided by mtk-quadspi driver under spi-nor framework and this new driver is a replacement for the old one.
Comparing to the old driver, this driver has following advantages:
1. It can handle any full-duplex spi transfer up to 6 bytes, and this is implemented using generic spi interface.
2. It take account into command opcode properly. The reading routine in this controller can only use 0x03 or 0x0b as opcode on 1-1-1 transfers, but old driver doesn't implement this properly. This driver checks supported opcode explicitly and use (1) to perform unmatched operations.
3. It properly handles SFDP reading. Old driver can't read SFDP due to the bug mentioned in (2).
4. It can do 1-2-2 and 1-4-4 fast reading on spi-nor. These two ops requires parsing SFDP, which isn't possible in old driver. And the old driver is only flagged to support 1-1-2 mode.
5. It takes advantage of the DMA feature in this controller for long reads and supports IRQ on DMA requests to free cpu cycles from polling status registers on long DMA reading. It achieves up to 17.5MB/s reading speed (1-4-4 mode) which is way faster than the old one. IRQ is implemented as optional to maintain backward compatibility.
---
Change since v2:
none
Change since v1:
none
drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-mtk-nor.c | 689 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 700 insertions(+) create mode 100644 drivers/spi/spi-mtk-nor.c
drivers/spi/Kconfig +10 -0
@@ -450,6 +450,16 @@ config SPI_MT7621 help This selects a driver for the MediaTek MT7621 SPI Controller. +config SPI_MTK_NOR + tristate "MediaTek SPI NOR controller" + depends on ARCH_MEDIATEK || COMPILE_TEST + help + This enables support for SPI NOR controller found on MediaTek + ARM SoCs. This is a controller specifically for SPI-NOR flash. + It can perform generic SPI transfers up to 6 bytes via generic + SPI interface as well as several SPI-NOR specific instructions + via SPI MEM interface. + config SPI_NPCM_FIU tristate "Nuvoton NPCM FLASH Interface Unit" depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_SPI_MPC52xx_PSC) += spi-mpc52xx-psc.o obj-$(CONFIG_SPI_MPC52xx) += spi-mpc52xx.o obj-$(CONFIG_SPI_MT65XX) += spi-mt65xx.o obj-$(CONFIG_SPI_MT7621) += spi-mt7621.o +obj-$(CONFIG_SPI_MTK_NOR) += spi-mtk-nor.o obj-$(CONFIG_SPI_MXIC) += spi-mxic.o obj-$(CONFIG_SPI_MXS) += spi-mxs.o obj-$(CONFIG_SPI_NPCM_FIU) += spi-npcm-fiu.o
drivers/spi/spi-mtk-nor.c new file +689 -0
689 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v3 3/4 dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor
In reply to Chuanhong Guospi-mtk-nor is a driver to replace mtk-quadspi and they have almost the same device-tree bindings. Reuse this binding documentation and convert it for new driver:
1. "Mediatek SoCs" -> "Mediatek ARM SoCs" because MTK MIPS SoCs use different controllers.
2. document "interrupts" as a required property because it's available on all SoCs with this controller and new driver takes advantages of it. It's implemented as optional only to maintain backward compatibility.
3. add a dummy interrupt binding in example.
---
Change since v2:
revert binding example replacement and add a dummy irq binding
Change since v1:
none
.../{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
rename Documentation/devicetree/bindings/{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} (75%)Documentation/devicetree/bindings/spi/spi-mtk-nor.txt renamed from Documentation/devicetree/bindings/mtd/mtk-quadspi.txt +6 -9
@@ -1,4 +1,4 @@ -* Serial NOR flash controller for MediaTek SoCs +* Serial NOR flash controller for MediaTek ARM SoCs Required properties: - compatible: For mt8173, compatible should be "mediatek,mt8173-nor",
@@ -13,6 +13,7 @@ Required properties: "mediatek,mt7629-nor", "mediatek,mt8173-nor" "mediatek,mt8173-nor" - reg: physical base address and length of the controller's register +- interrupts: Interrupt number used by the controller. - 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,
@@ -22,20 +23,16 @@ Required properties: - #address-cells: should be <1> - #size-cells: should be <0> -The SPI flash must be a child of the nor_flash node and must have a -compatible property. Also see jedec,spi-nor.txt. - -Required properties: -- compatible: May include a device-specific string consisting of the manufacturer - and name of the chip. Must also include "jedec,spi-nor" for any - SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). -- reg : Chip-Select number +There should be only one spi slave device following generic spi bindings. +It's not recommended to use this controller for devices other than SPI NOR +flash due to limited transfer capability of this controller. Example: nor_flash: spi@1100d000 { compatible = "mediatek,mt8173-nor"; reg = <0 0x1100d000 0 0xe0>; + interrupts = <&spi_flash_irq>; clocks = <&pericfg CLK_PERI_SPI>, <&topckgen CLK_TOP_SPINFI_IFR_SEL>; clock-names = "spi", "sf";
Signature · 1 line
2.24.1
Mark Brown
maintainerApplied "dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor" to the spi tree
The patch
dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
efe72129f32cac0dee5a221399813b620e310b32Mon Sep 17 00:00:00 2001
From: Chuanhong Guo <[email protected]>
Date: Fri, 6 Mar 2020 16:50:51 +0800
Subject: [PATCH] dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor
spi-mtk-nor is a driver to replace mtk-quadspi and they have almost the same device-tree bindings. Reuse this binding documentation and convert it for new driver:
1. "Mediatek SoCs" -> "Mediatek ARM SoCs" because MTK MIPS SoCs use different controllers.
2. document "interrupts" as a required property because it's available on all SoCs with this controller and new driver takes advantages of it. It's implemented as optional only to maintain backward compatibility.
3. add a dummy interrupt binding in example.
---
.../{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
rename Documentation/devicetree/bindings/{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} (75%)Documentation/devicetree/bindings/spi/spi-mtk-nor.txt renamed from Documentation/devicetree/bindings/mtd/mtk-quadspi.txt +6 -9
@@ -1,4 +1,4 @@ -* Serial NOR flash controller for MediaTek SoCs +* Serial NOR flash controller for MediaTek ARM SoCs Required properties: - compatible: For mt8173, compatible should be "mediatek,mt8173-nor",
@@ -13,6 +13,7 @@ Required properties: "mediatek,mt7629-nor", "mediatek,mt8173-nor" "mediatek,mt8173-nor" - reg: physical base address and length of the controller's register +- interrupts: Interrupt number used by the controller. - 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,
@@ -22,20 +23,16 @@ Required properties: - #address-cells: should be <1> - #size-cells: should be <0> -The SPI flash must be a child of the nor_flash node and must have a -compatible property. Also see jedec,spi-nor.txt. - -Required properties: -- compatible: May include a device-specific string consisting of the manufacturer - and name of the chip. Must also include "jedec,spi-nor" for any - SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). -- reg : Chip-Select number +There should be only one spi slave device following generic spi bindings. +It's not recommended to use this controller for devices other than SPI NOR +flash due to limited transfer capability of this controller. Example: nor_flash: spi@1100d000 { compatible = "mediatek,mt8173-nor"; reg = <0 0x1100d000 0 0xe0>; + interrupts = <&spi_flash_irq>; clocks = <&pericfg CLK_PERI_SPI>, <&topckgen CLK_TOP_SPINFI_IFR_SEL>; clock-names = "spi", "sf";
Signature · 1 line
2.20.1
PATCH v3 4/4 mtd: spi-nor: remove mtk-quadspi driver
In reply to Chuanhong GuoThis driver is superseded by the new spi-mtk-nor driver.
---
Change since v2:
none
Change since v1:
new patch
drivers/mtd/spi-nor/Kconfig | 8 - drivers/mtd/spi-nor/Makefile | 1 - drivers/mtd/spi-nor/mtk-quadspi.c | 565 ------------------------------ 3 files changed, 574 deletions(-) delete mode 100644 drivers/mtd/spi-nor/mtk-quadspi.c
drivers/mtd/spi-nor/Kconfig +0 -8
@@ -52,14 +52,6 @@ config SPI_HISI_SFC help This enables support for HiSilicon FMC SPI-NOR flash controller. -config SPI_MTK_QUADSPI - tristate "MediaTek Quad SPI controller" - depends on HAS_IOMEM - help - This enables support for the Quad SPI controller in master mode. - This controller does not support generic SPI. It only supports - SPI NOR. - config SPI_NXP_SPIFI tristate "NXP SPI Flash Interface (SPIFI)" depends on OF && (ARCH_LPC18XX || COMPILE_TEST)
drivers/mtd/spi-nor/Makefile +0 -1
@@ -3,7 +3,6 @@ obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o obj-$(CONFIG_SPI_ASPEED_SMC) += aspeed-smc.o obj-$(CONFIG_SPI_CADENCE_QUADSPI) += cadence-quadspi.o obj-$(CONFIG_SPI_HISI_SFC) += hisi-sfc.o -obj-$(CONFIG_SPI_MTK_QUADSPI) += mtk-quadspi.o obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o obj-$(CONFIG_SPI_INTEL_SPI) += intel-spi.o obj-$(CONFIG_SPI_INTEL_SPI_PCI) += intel-spi-pci.o
drivers/mtd/spi-nor/mtk-quadspi.c deleted +0 -565
565 lines not on this page · raw message
Signature · 1 line
2.24.1
Mark Brown
maintainerRe: [PATCH v3 4/4] mtd: spi-nor: remove mtk-quadspi driver
Quoted 3 lines · Chuanhong Guo
This driver is superseded by the new spi-mtk-nor driver.
Signed-off-by Chuanhong Guo <[email protected]>
Is this move OK from a MTD point of view - should I apply this when the rest goes in? The patch was in prior versions too and is obviously straightforward.
[email protected]
Acked-byRe: [PATCH v3 4/4] mtd: spi-nor: remove mtk-quadspi driver
Hi, Mark,
Quoted 7 lines · EET Mark Brown
Quoted 3 lines
This driver is superseded by the new spi-mtk-nor driver.
Signed-off-by Chuanhong Guo <[email protected]>Is this move OK from a MTD point of view - should I apply this when the rest goes in? The patch was in prior versions too and is obviously straightforward.
If you find the rest of the patches ok, this can go through the spi tree, feel free to add my
There will be a conflict with the following patch https://
patchwork.ozlabs.org/patch/1247791/, but nothing that we can't handle. I'll try to allocate time for reviewing the remaining patches in this set in the following days.
Cheers,
ta
Re: [PATCH v3 4/4] mtd: spi-nor: remove mtk-quadspi driver
Quoted 11 lines · On Tuesday, March 10, 2020 9:41:26 AM EET…
Hi, Mark,
Quoted 7 lines · EET Mark Brown
Quoted 3 lines
This driver is superseded by the new spi-mtk-nor driver.
Signed-off-by Chuanhong Guo <[email protected]>Is this move OK from a MTD point of view - should I apply this when the rest goes in? The patch was in prior versions too and is obviously straightforward.
Quoted 6 lines
If you find the rest of the patches ok, this can go through the spi tree, feel free to add my
Acked-by Tudor Ambarus <[email protected]>There will be a conflict with the following patch https://
patchwork.ozlabs.org/patch/1247791/, but nothing that we can't handle.
You can also create an immutable tag that I can merge in my spi-nor/next branch, so that Linus doesn't have to deal with the conflict.
ta
Mark Brown
maintainerRe: [PATCH v3 4/4] mtd: spi-nor: remove mtk-quadspi driver
Quoted 2 lines · On Tue, Mar 10, 2020 at 09:11:29AM +0000…
You can also create an immutable tag that I can merge in my spi-nor/next branch, so that Linus doesn't have to deal with the conflict.
The following changes since commit bb6d3fb354c5ee8d6bde2d576eb7220ea09862b9:
Linux 5.6-rc1 (2020-02-09 16:08:48 -0800)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git tags/mtk-mtd-spi-move
for you to fetch changes up to e11e8473bcec748c3820636f11b986f611c9309b:
mtd: spi-nor: remove mtk-quadspi driver (2020-03-11 19:56:08 +0000)
----------------------------------------------------------------
spi: Rewrite mtk-quadspi spi-nor driver with spi-mem
This patchset from Chuanhong Guo <[email protected]> adds a spi-mem driver for Mediatek SPI-NOR controller, which already has limited
support by mtk-quadspi. This new driver can make use of full quadspi
capability of this controller.
----------------------------------------------------------------
Chuanhong Guo (4):
spi: make spi-max-frequency optional
spi: add support for mediatek spi-nor controller
dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor
mtd: spi-nor: remove mtk-quadspi driver
.../{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} | 15 +-
drivers/mtd/spi-nor/Kconfig | 8 -
drivers/mtd/spi-nor/Makefile | 1 -
drivers/mtd/spi-nor/mtk-quadspi.c | 565 -----------------
drivers/spi/Kconfig | 10 +
drivers/spi/Makefile | 1 +
drivers/spi/spi-mtk-nor.c | 689 +++++++++++++++++++++
drivers/spi/spi.c | 9 +-
8 files changed, 708 insertions(+), 590 deletions(-)
rename Documentation/devicetree/bindings/{mtd/mtk-quadspi.txt => spi/spi-mtk-nor.txt} (75%)
delete mode 100644 drivers/mtd/spi-nor/mtk-quadspi.c
create mode 100644 drivers/spi/spi-mtk-nor.cPatchwork summary for: spi-devel-general
In reply to Chuanhong GuoThe following patches were marked "accepted", because they were applied to broonie/spi.git (refs/heads/for-next):
Hello:
The following patches were marked "accepted", because they were applied to broonie/spi.git (refs/heads/for-next):
Series: rewrite mtk-quadspi spi-nor driver with spi-mem
Submitter: Chuanhong Guo <[email protected]>
Patchwork: https://patchwork.kernel.org/project/spi-devel-general/list/?series=252289
Patches: [v3,1/4] spi: make spi-max-frequency optional
[v3,2/4] spi: add support for mediatek spi-nor controller [v3,3/4] dt-bindings: convert mtk-quadspi binding doc for spi-mtk-nor [v3,4/4] mtd: spi-nor: remove mtk-quadspi driver
Total patches: 4
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/pwbot