mtd: spi: Add MSCC SPI flash driver
Subsystems (2)
cover mtd: spi: Add MSCC SPI flash driver
This patch series adds MSCC SPI flash driver. The VCore III SoCs can access directly the flash through memory, this direct mapping is working only for read functions. The other operations are going through SPI driver.
This improves the read performace by a factor of 4.75.
This patch series is based on u-boot-mips/next.
Horatiu Vultur (3):
mtd: spi: export functions to sf_internal.h
mtd: spi: add MSCC SPI flash driver
mips: mscc: use MSCC SPI flash driver for Luton
MAINTAINERS | 1 + arch/mips/dts/luton_pcb090.dts | 3 +- arch/mips/dts/luton_pcb091.dts | 3 +- configs/mscc_luton_defconfig | 1 + drivers/mtd/spi/Kconfig | 8 +++++ drivers/mtd/spi/Makefile | 1 + drivers/mtd/spi/sf_internal.h | 8 +++++ drivers/mtd/spi/sf_mscc_flash.c | 76 +++++++++++++++++++++++++++++++++++++++++ drivers/mtd/spi/sf_probe.c | 8 ++--- drivers/mtd/spi/spi_flash.c | 4 +-- 10 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 drivers/mtd/spi/sf_mscc_flash.c
Signature · 1 line
2.7.4
PATCH 1/3 mtd: spi: export functions to sf_internal.h
Expose the following functions: clean_bar, write_bar, spi_flash_std_write, spi_flash_std_erase and spi_flash_std_probe to sf_internal.h to be able to reuse them.
--- drivers/mtd/spi/sf_internal.h | 8 ++++++++ drivers/mtd/spi/sf_probe.c | 8 ++++---- drivers/mtd/spi/spi_flash.c | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-)
drivers/mtd/spi/sf_internal.h +8 -0
@@ -224,6 +224,14 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,int spi_flash_cmd_read_ops (struct spi_flash *flash,u32 offset,size_t len,void *data); +int clean_bar (struct spi_flash *flash); +int write_bar (struct spi_flash *flash,u32 offset); + +int spi_flash_std_write (struct udevice *dev,u32 offset,size_t len, +const void *buf); +int spi_flash_std_erase (struct udevice *dev,u32 offset,size_t len); +int spi_flash_std_probe (struct udevice *dev); +#ifdef CONFIG_SPI_FLASH_MTD int spi_flash_mtd_register (struct spi_flash *flash);void spi_flash_mtd_unregister (void );
drivers/mtd/spi/sf_probe.c +4 -4
@@ -100,8 +100,8 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,return log_ret (spi_flash_cmd_read_ops (flash, offset, len, buf)); } -static int spi_flash_std_write (struct udevice *dev,u32 offset,size_t len, -const void *buf) +int spi_flash_std_write (struct udevice *dev,u32 offset,size_t len, +const void *buf) {struct spi_flash *flash =dev_get_uclass_priv (dev);
@@ -117,7 +117,7 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,return spi_flash_cmd_write_ops (flash, offset, len, buf); } -static int spi_flash_std_erase (struct udevice *dev,u32 offset,size_t len) +int spi_flash_std_erase (struct udevice *dev,u32 offset,size_t len) {struct spi_flash *flash =dev_get_uclass_priv (dev);
@@ -131,7 +131,7 @@ static int spi_flash_std_get_sw_write_prot(struct udevice *dev)return spi_flash_cmd_get_sw_write_prot (flash); } -static int spi_flash_std_probe (struct udevice *dev) +int spi_flash_std_probe (struct udevice *dev) {struct spi_slave *slave =dev_get_parent_priv (dev);struct dm_spi_slave_platdata *plat =dev_get_parent_platdata (dev);
drivers/mtd/spi/spi_flash.c +2 -2
@@ -133,7 +133,7 @@ int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash)* Otherwise, the BA24 bit may be left set and then after reset, the * ROM would read/write/erase SPL from 16 MiB * bank_sel address. */ -static int clean_bar (struct spi_flash *flash) +int clean_bar (struct spi_flash *flash) {u8 cmd, bank_sel =0 ;
@@ -145,7 +145,7 @@ static int clean_bar(struct spi_flash *flash)return spi_flash_write_common (flash, &cmd,1 , &bank_sel,1 ); } -static int write_bar (struct spi_flash *flash,u32 offset) +int write_bar (struct spi_flash *flash,u32 offset) {u8 cmd, bank_sel;int ret;
Signature · 1 line
2.7.4
PATCH 1/3 mtd: spi: export functions to sf_internal.h
Am 16.01.19 um 13:07 schrieb Horatiu Vultur:
Quoted 4 lines
Expose the following functions:
clean_bar,write_bar,spi_flash_std_write,spi_flash_std_eraseandspi_flash_std_probetosf_internal.hto be able to reuse them.
Quoted 8 lines
Cc Jagan Teki <[email protected]>Signed-off-by Horatiu Vultur <[email protected]>--- drivers/mtd/spi/sf_internal.h | 8 ++++++++ drivers/mtd/spi/sf_probe.c | 8 ++++---- drivers/mtd/spi/spi_flash.c | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-)
maybe you should wait with this series as there is on-going work to import spi-nor from Linux [1]
[1] https://lists.denx.de/pipermail/u-boot/2018-December/350565.html
Signature · 1 line
- Daniel
PATCH 1/3 mtd: spi: export functions to sf_internal.h
Hi Daniel,
Quoted 16 lines · Daniel Schwierzeck
Am 16.01.19 um 13:07 schrieb Horatiu Vultur:
Quoted 4 lines
Expose the following functions:
clean_bar,write_bar,spi_flash_std_write,spi_flash_std_eraseandspi_flash_std_probetosf_internal.hto be able to reuse them.Quoted 8 lines
Cc Jagan Teki <[email protected]>Signed-off-by Horatiu Vultur <[email protected]>--- drivers/mtd/spi/sf_internal.h | 8 ++++++++ drivers/mtd/spi/sf_probe.c | 8 ++++---- drivers/mtd/spi/spi_flash.c | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-)
Quoted 5 lines
maybe you should wait with this series as there is on-going work to import spi-nor from Linux [1]
[1] https://lists.denx.de/pipermail/u-boot/2018-December/350565.html
That is perfectly fine for me, I will submit another patch after the spi-nor series is accepted. Thank you.
Quoted 2 lines
Signature · 1 line
- Daniel
Signature · 1 line
/Horatiu
PATCH 2/3 mtd: spi: add MSCC SPI flash driver
In reply to Horatiu VulturThe VCore III SoCs can directly access flash through memory. The SPI controller takes care of changing a memory access to a flash access. Therefore the flash can be accessed using memcpy functions.
The direct mapping is supported only by the read functions. All the other access are going through the SPI driver.
Using this driver improves the read throughput by a factor of 4.75.
--- MAINTAINERS | 1 + drivers/mtd/spi/Kconfig | 8 +++++ drivers/mtd/spi/Makefile | 1 + drivers/mtd/spi/sf_mscc_flash.c | 76 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 drivers/mtd/spi/sf_mscc_flash.c
MAINTAINERS +1 -0
@@ -527,6 +527,7 @@ F: board/mscc/ F: configs/mscc* F: drivers/gpio/mscc_sgpio.c F: drivers/spi/mscc_bb_spi.c +F: drivers/mtd/spi/sf_mscc_flash.c F: include/configs/vcoreiii.h F: drivers/pinctrl/mscc/
drivers/mtd/spi/Kconfig +8 -0
@@ -34,6 +34,14 @@ config SPI_FLASH If unsure, say N +config MSCC_SPI_FLASH + bool "MSCC SPI Flash driver" + depends on SPI_FLASH + help + Enable MSCC SPI flash driver. This driver uses direct mapping + during read operations, regular SPI transfer otherwise. It is + using CONFIG_SPI_FLASH_BAR to access high end of +16MB flash. + config SPI_FLASH_BAR bool "SPI flash Bank/Extended address register support" depends on SPI_FLASH
drivers/mtd/spi/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o endif obj-$(CONFIG_SPI_FLASH) += sf_probe.o spi_flash.o spi_flash_ids.o sf.o +obj-$(CONFIG_MSCC_SPI_FLASH) += sf_mscc_flash.o obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o
drivers/mtd/spi/sf_mscc_flash.c new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/3 mips: mscc: use MSCC SPI flash driver for Luton
In reply to Horatiu VulturUpdate Luton DT and defconfig to use the new MSCC SPI flash driver.
--- arch/mips/dts/luton_pcb090.dts | 3 ++- arch/mips/dts/luton_pcb091.dts | 3 ++- configs/mscc_luton_defconfig | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
arch/mips/dts/luton_pcb090.dts +2 -1
@@ -48,7 +48,8 @@ &spi0 { status = "okay"; spi-flash at 0 { - compatible = "spi-flash"; + compatible = "mscc,luton-spi-flash", "spi-flash"; + memory-map = <0x40000000 0x2000000>; spi-max-frequency = <18000000>; /* input clock */ reg = <0>; /* CS0 */ spi-cs-high;
arch/mips/dts/luton_pcb091.dts +2 -1
@@ -54,7 +54,8 @@ &spi0 { status = "okay"; spi-flash at 0 { - compatible = "spi-flash"; + compatible = "mscc,luton-spi-flash", "spi-flash"; + memory-map = <0x40000000 0x2000000>; spi-max-frequency = <18000000>; /* input clock */ reg = <0>; /* CS0 */ spi-cs-high;
configs/mscc_luton_defconfig +1 -0
@@ -69,3 +69,4 @@ CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_MSCC_BB_SPI=y CONFIG_LZMA=y +CONFIG_MSCC_SPI_FLASH=y
Signature · 1 line
2.7.4