Skip to contentSkip to conversation

mtd: spi: Add MSCC SPI flash driver

PATCH New Horatiu Vultur 2 participants 6 messages Jan 16, 2019 – Jan 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 46a5044..69968c5 100644
@@ -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
index 00f8558..4ddb3ce 100644
@@ -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
index 0c2392f..536f0a1 100644
@@ -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
#2 lore raw

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_erase and spi_flash_std_probe to sf_internal.h to be able to reuse them.

Quoted 8 lines
---
 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
#3 lore raw

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_erase and spi_flash_std_probe to sf_internal.h to be able to reuse them.

Quoted 8 lines
---
 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
#4 lore raw

PATCH 2/3 mtd: spi: add MSCC SPI flash driver

In reply to Horatiu Vultur

The 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
index 3fa5d3e..a2b100e 100644
@@ -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
index 76d5a1d..0f8db82 100644
@@ -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
index b4c7e1c..3ae1860 100644
@@ -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
#5 lore raw

PATCH 3/3 mips: mscc: use MSCC SPI flash driver for Luton

In reply to Horatiu Vultur

Update 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
index 951d8da..55cf609 100644
@@ -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
index bf638b2..fe1d332 100644
@@ -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
index 7154e97..9e3efa1 100644
@@ -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