Skip to contentSkip to conversation

riscv: sifive/fu540: Enable SPI-NOR support

PATCH Superseded Jagan Teki 4 participants 29 messages Oct 16, 2019 – Apr 18, 2020 1 message not in the archive

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

v2 cover riscv: sifive/fu540: Enable SPI-NOR support

This is v2 patchset, enable SPI-NOR flash on SiFive hifive-unleashed-a00 board, here is v1 [1].

Changes for v2:
- use latest sifive commit from linux-next
- fix typos in commit message
- rebased on master

patch 0001 - 02: support devicetree

patch 0003: add is25wp256 chip

patch 0004 - 05: enable spi-nor flash

All tested in Sifive fuse540 hifive-unleashed-a00 board.

[1] https://patchwork.ozlabs.org/cover/1168959/

Any inputs?
Jagan.

Jagan Teki (5):
riscv: dts: Add hifive-unleashed-a00 dts from Linux
sifive: fu540: Enable OF_SEPARATE
mtd: spi-nor: ids: Add is25wp256 chip
riscv: dts: hifive-unleashed-a00: Add -u-boot.dtsi
sifive: fu540: Enable spi-nor flash support

 arch/riscv/dts/Makefile                       |   1 +
 arch/riscv/dts/fu540-c000.dtsi                | 251 ++++++++++++++++++
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  11 +
 arch/riscv/dts/hifive-unleashed-a00.dts       |  96 +++++++
 board/sifive/fu540/Kconfig                    |   3 +
 configs/sifive_fu540_defconfig                |   3 +-
 doc/board/sifive/fu540.rst                    |  21 +-
 drivers/mtd/spi/spi-nor-ids.c                 |   2 +
 8 files changed, 386 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/dts/fu540-c000.dtsi
 create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
 create mode 100644 arch/riscv/dts/hifive-unleashed-a00.dts
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#1 lore raw

PATCH v2 1/5 riscv: dts: Add hifive-unleashed-a00 dts from Linux

Sync the hifive-unleashed-a00 dts from Linux with
below commit details:

commit <2993c9b04e616df0848b655d7202a707a70fc876> ("riscv: dts: HiFive
Unleashed: add default chosen/stdout-path")

Idea is to periodically sync the dts from Linux instead of tweaking internal changes one after another, so better not add any intermediate changes in between. This would help to maintain the dts files easy and meaningful since we are reusing device tree files from Linux.

---
 arch/riscv/dts/Makefile                 |   1 +
 arch/riscv/dts/fu540-c000.dtsi          | 251 ++++++++++++++++++++++++
 arch/riscv/dts/hifive-unleashed-a00.dts |  96 +++++++++
 3 files changed, 348 insertions(+)
 create mode 100644 arch/riscv/dts/fu540-c000.dtsi
 create mode 100644 arch/riscv/dts/hifive-unleashed-a00.dts
arch/riscv/dts/Makefile +1 -0
index f9cd606a9a..4f30e6936f 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 dtb-$(CONFIG_TARGET_AX25_AE350) += ae350_32.dtb ae350_64.dtb
+dtb-$(CONFIG_TARGET_SIFIVE_FU540) += hifive-unleashed-a00.dtb
 
 targets += $(dtb-y)
 
arch/riscv/dts/fu540-c000.dtsi new file +251 -0

251 lines not on this page · raw message

arch/riscv/dts/hifive-unleashed-a00.dts new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#2 lore raw

PATCH v2 2/5 sifive: fu540: Enable OF_SEPARATE

In reply to Jagan Teki

Use dts support from U-Boot via OF_SEPARATE instead of depending from opensbi.

This would help to make the necessary changes in drivers and devicetrees in uboot tree itself. this feature would also be helpful to not pass dtb during opensbi builds.

---
 configs/sifive_fu540_defconfig | 3 ++-
 doc/board/sifive/fu540.rst     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
configs/sifive_fu540_defconfig +2 -1
index 48865e5f11..979d0a0418 100644
@@ -6,6 +6,7 @@ CONFIG_RISCV_SMODE=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_MISC_INIT_R=y
+CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
-CONFIG_OF_PRIOR_STAGE=y
+CONFIG_OF_SEPARATE=y
doc/board/sifive/fu540.rst +1 -1
index 7807f5b2c1..91b94ee06f 100644
@@ -58,7 +58,7 @@ firmware. We need to compile OpenSBI with below command:
 
 .. code-block:: none
 
-    make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot.bin> FW_PAYLOAD_FDT_PATH=<path to hifive-unleashed-a00.dtb from Linux>
+    make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot-dtb.bin>
 
 (Note: Prefer hifive-unleashed-a00.dtb from Linux-5.3 or higher)
 (Note: Linux-5.2 is also fine but it does not have ethernet DT node)
Signature · 1 line
2.18.0.321.gffc6fa0e3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH v2 2/5 sifive: fu540: Enable OF_SEPARATE

Hi Jagan

Please check the following typos.
Or if you don't mind. I can fix it directly on the patches. :)

Quoted 11 lines

From: Jagan Teki [mailto:jagan at amarulasolutions.com]
Sent: Wednesday, October 16, 2019 10:58 PM
To: Rick Jian-Zhi Chen(陳建志); Paul Walmsley; Palmer Dabbelt; Anup Patel; Atish Patra; Bin Meng
Cc: u-boot at lists.denx.de; linux-amarula at amarulasolutions.com; Jagan Teki
Subject: [PATCH v2 2/5] sifive: fu540: Enable OF_SEPARATE

Use dts support from U-Boot via OF_SEPARATE instead of depending from opensbi.

This would help to make the necessary changes in drivers and devicetrees in

device trees

Quoted 1 line

uboot tree itself. this feature would also be helpful to not pass dtb during

U-Boot . This feature ...

opensbi builds.

Quoted 28 lines
---
 configs/sifive_fu540_defconfig | 3 ++-
 doc/board/sifive/fu540.rst     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
configs/sifive_fu540_defconfig +2 -1
index 48865e5f11..979d0a0418 100644
@@ -6,6 +6,7 @@ CONFIG_RISCV_SMODE=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_MISC_INIT_R=y
+CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
-CONFIG_OF_PRIOR_STAGE=y
+CONFIG_OF_SEPARATE=y
doc/board/sifive/fu540.rst index renamed from doc/board/sifive/fu540.rst +0 -0

7807f5b2c1..91b94ee06f 100644

doc/board/sifive/fu540.rst +0 -0
@@ -58,7 +58,7 @@ firmware. We need to compile OpenSBI with below

command:

.. code-block:: none

Quoted 7 lines

- make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot.bin>
FW_PAYLOAD_FDT_PATH=<path to hifive-unleashed-a00.dtb from Linux>
+ make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to
u-boot-dtb.bin>

(Note: Prefer hifive-unleashed-a00.dtb from Linux-5.3 or higher) (Note: Linux-5.2 is also fine but it does not have ethernet DT node)

Thanks
Rick

author
#5 lore raw

PATCH v2 3/5 mtd: spi-nor: ids: Add is25wp256 chip

In reply to Jagan Teki

Add is25wp256, chip to spi-nor id table.

Tested on SiFive FU540 board.

---
 drivers/mtd/spi/spi-nor-ids.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi/spi-nor-ids.c +2 -0
index 6996c0a286..04db986561 100644
@@ -128,6 +128,8 @@ const struct flash_info spi_nor_ids[] = {
 			SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ INFO("is25wp128",  0x9d7018, 0, 64 * 1024, 256,
 			SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+	{ INFO("is25wp256",  0x9d7019, 0, 64 * 1024, 512,
+			SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX	/* MACRONIX */
 	/* Macronix */
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#7 lore raw

PATCH v2 4/5 riscv: dts: hifive-unleashed-a00: Add -u-boot.dtsi

In reply to Jagan Teki

Add u-boot specific dts file for hifive-unleashed-a00, this would help to add u-boot specific properties and other node changes without touching the base dts(i) files which are easy to sync from Linux.

Added spi2 alias for qspi2 as an initial u-boot specific property change.

spi probing in current dm model is very much rely on aliases numbering. even though the qspi2 can't comes under any associated spi nor flash it would require to specify the same to make proper binding happen for other spi slaves.

---
 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi new file +10 -0
new file mode 100644
index 0000000000..25ec8265a5
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Jagan Teki <[email protected]>
+ */
+
+/ {
+	aliases {
+		spi2 = &qspi2;
+	};
+};
Signature · 1 line
2.18.0.321.gffc6fa0e3
#8 lore raw

PATCH v2 4/5 riscv: dts: hifive-unleashed-a00: Add -u-boot.dtsi

Quoted 2 lines · Jagan Teki

Add u-boot specific dts file for hifive-unleashed-a00, this

nits: U-Boot

Quoted 1 line

would help to add u-boot specific properties and other node

ditto

Quoted 8 lines

changes without touching the base dts(i) files which are easy to sync from Linux.

Added spi2 alias for qspi2 as an initial u-boot specific property change.

spi probing in current dm model is very much rely on aliases numbering. even though the qspi2 can't comes under any associated

nits: even -> Even, comes -> come

Quoted 9 lines

spi nor flash it would require to specify the same to make proper binding happen for other spi slaves.

---
 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Other than above,

Regards,
Bin

author
#9 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

In reply to Jagan Teki

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
index 25ec8265a5..d7a64134db 100644
@@ -5,6 +5,7 @@
 
 / {
 	aliases {
+		spi0 = &qspi0;
 		spi2 = &qspi2;
 	};
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply CMD_FS_GENERIC
 	imply CMD_NET
 	imply CMD_PING
+	imply CMD_SF
 	imply CLK_SIFIVE
 	imply CLK_SIFIVE_FU540_PRCI
 	imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply SIFIVE_SERIAL
 	imply SPI
 	imply SPI_SIFIVE
+	imply SPI_FLASH
+	imply SPI_FLASH_ISSI
 	imply MMC
 	imply MMC_SPI
 	imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +19 -0
index 91b94ee06f..2e70cad02e 100644
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2
+   SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
+   => sf erase 0x1000000 0x100000
+   SF: 1048576 bytes @ 0x1000000 Erased: OK
+   => mw.b 0xc0000000 0xaa 0x100000
+   => sf write 0xc0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Written: OK
+   => sf read 0xf0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Read: OK
+   => cmp.b 0xf0000000 0xc0000000 0x100000
+   Total of 1048576 byte(s) were the same
Signature · 1 line
2.18.0.321.gffc6fa0e3
#10 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 54 lines · Jagan Teki

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
index 25ec8265a5..d7a64134db 100644
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

doc/board/sifive/fu540.rst load uImage.

Quoted 13 lines
doc/board/sifive/fu540.rst +12 -1
+   SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
+   => sf erase 0x1000000 0x100000
+   SF: 1048576 bytes @ 0x1000000 Erased: OK
+   => mw.b 0xc0000000 0xaa 0x100000
+   => sf write 0xc0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Written: OK
+   => sf read 0xf0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Read: OK
+   => cmp.b 0xf0000000 0xc0000000 0x100000
+   Total of 1048576 byte(s) were the same
--

Regards,
Bin

#11 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 59 lines · Bin Meng

Hi Jagan,

Quoted 55 lines · Jagan Teki

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
index 25ec8265a5..d7a64134db 100644
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644
@@ -366,3 +366,22 @@ load uImage.
 
Quoted 11 lines

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 9 lines
doc/board/sifive/fu540.rst +7 -0
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

So we still need figure out why CS number 0 cannot work on SiFive.

Quoted 14 lines
Quoted 4 lines
doc/board/sifive/fu540.rst +3 -0
+   SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
+   => sf erase 0x1000000 0x100000
+   SF: 1048576 bytes @ 0x1000000 Erased: OK

doc/board/sifive/fu540.rst load uImage.

Quoted 10 lines
doc/board/sifive/fu540.rst +9 -1
+   => mw.b 0xc0000000 0xaa 0x100000
+   => sf write 0xc0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Written: OK
+   => sf read 0xf0000000 0x1000000 0x100000
+   device 0 offset 0x1000000, size 0x100000
+   SF: 1048576 bytes @ 0x1000000 Read: OK
+   => cmp.b 0xf0000000 0xc0000000 0x100000
+   Total of 1048576 byte(s) were the same
--

Regards,
Bin

author
#12 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Bin,

Quoted 121 lines · Bin Meng

Hi Jagan,

Quoted 59 lines · Bin Meng

Hi Jagan,

Quoted 55 lines · Jagan Teki

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
index 25ec8265a5..d7a64134db 100644
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644
@@ -366,3 +366,22 @@ load uImage.
 
Quoted 11 lines

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 9 lines
doc/board/sifive/fu540.rst +7 -0
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at CS0. One more point is that flash seems available in different CS, not sure whether the hardware wired this logic or it has flash really on those CS's.

=> sf probe 0:0
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:1
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:1 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:3
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:3 (error -2)
=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:5
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:5 (error -2)
=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:7
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:7 (error -2)
=> sf probe 0:8
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:9
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:9 (error -2)

#13 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 125 lines · Jagan Teki

Hi Bin,

Quoted 121 lines · Bin Meng

Hi Jagan,

Quoted 59 lines · Bin Meng

Hi Jagan,

Quoted 55 lines · Jagan Teki

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
index 25ec8265a5..d7a64134db 100644
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644
@@ -366,3 +366,22 @@ load uImage.
 
Quoted 11 lines

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 9 lines
doc/board/sifive/fu540.rst +7 -0
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 21 lines

CS0. One more point is that flash seems available in different CS, not sure whether the hardware wired this logic or it has flash really on those CS's.

=> sf probe 0:0
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:1
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:1 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:3
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:3 (error -2)
=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:5
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:5 (error -2)
=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB

Quoted 8 lines

=> sf probe 0:7
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:7 (error -2)
=> sf probe 0:8
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:9
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:9 (error -2)

Regards,
Bin

#14 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks & BR,
Sagar Kadam

Quoted 41 lines
Quoted 6 lines

CS0. One more point is that flash seems available in different CS, not sure whether the hardware wired this logic or it has flash really on those CS's.

=> sf probe 0:0
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 5 lines

=> sf probe 0:1
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:1 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 5 lines

=> sf probe 0:3
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:3 (error -2)
=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 5 lines

=> sf probe 0:5
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:5 (error -2)
=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 5 lines

=> sf probe 0:7
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:7 (error -2)
=> sf probe 0:8
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 3 lines

=> sf probe 0:9
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:9 (error -2)

Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#15 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Segar Kadam,

Quoted 157 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 8 lines

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too.

The strange thing is that the 'sf probe' only fails at CS 0, but succeeds at CS 2/4/6/8/...

Is this strange behavior caused by the default reg_proto set to 1_1_1 in spi_nor_scan()?

Quoted 5 lines

Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Maybe Jagan can comment this.

Regards,
Bin

#16 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 176 lines · Bin Meng

Hi Segar Kadam,

Quoted 157 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 8 lines

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too.

The strange thing is that the 'sf probe' only fails at CS 0, but succeeds at CS 2/4/6/8/...

Is this strange behavior caused by the default reg_proto set to 1_1_1 in spi_nor_scan()?

Quoted 7 lines
Quoted 5 lines

Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Maybe Jagan can comment this.

Could you please also take a look at this issue that Sagar reported?

Regards,
Bin

author
#17 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

In reply to Bin Meng

Hi Bin,

Quoted 176 lines · Bin Meng

Hi Segar Kadam,

Quoted 157 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 8 lines

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too.

The strange thing is that the 'sf probe' only fails at CS 0, but succeeds at CS 2/4/6/8/...

Is this strange behavior caused by the default reg_proto set to 1_1_1 in spi_nor_scan()?

Quoted 7 lines
Quoted 5 lines

Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Maybe Jagan can comment this.

Looks like there are several issues to make this flash to work, one with a probe and others are handling cs between transfer and flash bfpt fixes.

probe failed with cs 0 (or even with other cs numbers) because of improper bitlen, spi-nor sending fast read (mean single wire) initially but the driver checks the bitlen based on slave->mode (which is from dts) ie is quad.

Default behaviour:

=> sf probe 0:0
sifive_spi_prep_transfer: QUAD
sifive_spi_prep_transfer: QUAD
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:1
Invalid cs 1 (err=-22)
Invalid cs 1 (err=-22)
Invalid chip select 0:1 (err=-22)
Failed to initialize SPI flash at 0:1 (error -22)
=> sf probe 0:2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)

With , update the cr bits based on bitlen instead of slave->mode:

=> sf probe
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:1
Invalid cs 1 (err=-22)
Invalid cs 1 (err=-22)
Invalid chip select 0:1 (err=-22)
Failed to initialize SPI flash at 0:1 (error -22)

Jagan.

#18 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 188 lines · Jagan Teki

Hi Bin,

Quoted 176 lines · Bin Meng

Hi Segar Kadam,

Quoted 157 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 8 lines

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too.

The strange thing is that the 'sf probe' only fails at CS 0, but succeeds at CS 2/4/6/8/...

Is this strange behavior caused by the default reg_proto set to 1_1_1 in spi_nor_scan()?

Quoted 7 lines
Quoted 5 lines

Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Maybe Jagan can comment this.

Quoted 9 lines

Looks like there are several issues to make this flash to work, one with a probe and others are handling cs between transfer and flash bfpt fixes.

probe failed with cs 0 (or even with other cs numbers) because of improper bitlen, spi-nor sending fast read (mean single wire) initially but the driver checks the bitlen based on slave->mode (which is from dts) ie is quad.

Thank you for looking into this. Could you please work with Sagar to come up with a new version patch that fix all these issues?

Quoted 20 lines

Default behaviour:

=> sf probe 0:0
sifive_spi_prep_transfer: QUAD
sifive_spi_prep_transfer: QUAD
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:1
Invalid cs 1 (err=-22)
Invalid cs 1 (err=-22)
Invalid chip select 0:1 (err=-22)
Failed to initialize SPI flash at 0:1 (error -22)
=> sf probe 0:2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)

With , update the cr bits based on bitlen instead of slave->mode:

Quoted 12 lines

=> sf probe
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
sifive_spi_prep_transfer: SINGLE
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB => sf probe 0:1
Invalid cs 1 (err=-22)
Invalid cs 1 (err=-22)
Invalid chip select 0:1 (err=-22)
Failed to initialize SPI flash at 0:1 (error -22)

Regards,
Bin

author
#19 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

In reply to Sagar Kadam

Hi Sagar,

Quoted 157 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 144 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 8 lines · Jagan Teki

Hi Bin,

Quoted 4 lines · Bin Meng

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 16 lines · <[email protected]> wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
Quoted 37 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
@@ -5,6 +5,7 @@
 
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
board/sifive/fu540/Kconfig +3 -0
index 5d65080429..c5a1bca03c 100644
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
doc/board/sifive/fu540.rst +0 -0
index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Quoted 12 lines

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on this. IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device tree set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by spi_mem_exec_op and prepare spi transfer's in controller based on max of t->rx_nbits, t->tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

[1] https://patchwork.ozlabs.org/patch/1228554/

Jagan.

#20 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hello Jagan,

Quoted 197 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 9 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 5 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 6 lines
Quoted 6 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:

Hi Bin,

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng <[email protected]>

Quoted 17 lines · wrote:
Quoted 17 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 3 files changed, 23 insertions(+)
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +1 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
board/sifive/fu540/Kconfig +2 -0
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
(quoted diff) +0 -0

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 40 lines
Quoted 40 lines

MiB

Quoted 38 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

Quoted 8 lines
Quoted 4 lines

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device

tree

Quoted 4 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 9 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as
done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

BR,
Sagar Kadam

Quoted 3 lines

[1] https://patchwork.ozlabs.org/patch/1228554/

Jagan.

author
#21 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Sagar,

Quoted 211 lines · Sagar Kadam

Hello Jagan,

Quoted 197 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 9 lines · Sagar Kadam

Hello Jagan/Bin,

Quoted 5 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing List

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 6 lines
Quoted 6 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:

Hi Bin,

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng <[email protected]>

Quoted 17 lines · wrote:
Quoted 17 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 3 files changed, 23 insertions(+)
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +1 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply SIFIVE_SERIAL
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
board/sifive/fu540/Kconfig +2 -0
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
(quoted diff) +0 -0

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

With this patch series, we got crazy duplicated flash devices created, see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 40 lines
Quoted 40 lines

MiB

Quoted 38 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line

So we still need figure out why CS number 0 cannot work on SiFive.

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

Quoted 8 lines
Quoted 4 lines

I vaguely remember someone from SiFive posted a patch that forced the SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further parses slave mode and accordingly sets the hwcaps fields. Now since the device

tree

Quoted 4 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this creates a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe to detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 9 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as
done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

Good to know that it is working in case of cs0 as well.

Quoted 7 lines
Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

"flash operations are working only for fast read, that means 2-wire."

Any idea if flash triggers a opcode of quad (4-wire) does sifive cr format proto aspected to assign SIFIVE_SPI_FMT_PROTO_QUAD? What exactly is the relation between flash command operations vs driver cr format proto bits? or how do we assign cr format proto bits based on flash operations, is it based on opcode transfer bits or any other logic?

Jagan.

#22 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hello Jagan,

Quoted 249 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 9 lines · Sagar Kadam

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>;

linux-

Quoted 5 lines
Quoted 5 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin

Meng

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 4 lines
Quoted 4 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 1 line
Quoted 1 line

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Hi Bin,

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 38 lines
Quoted 38 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 3 files changed, 23 insertions(+)
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 4 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +0 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 8 lines
board/sifive/fu540/Kconfig +1 -0
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
board/sifive/fu540/Kconfig +2 -0
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
(quoted diff) +0 -0

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

With this patch series, we got crazy duplicated flash devices

created,

Quoted 51 lines
Quoted 51 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 35 lines
Quoted 35 lines

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 1 line

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 1 line
Quoted 1 line
Quoted 1 line

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 2 lines
Quoted 2 lines

tree

Quoted 1 line

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 18 lines
Quoted 11 lines
Quoted 1 line

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as
done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Quoted 5 lines
Quoted 2 lines

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

Thanks for sharing your input/observations

Quoted 5 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 5 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

Quoted 8 lines

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O mode, I do see corresponding opcode during Read operations (opcode observed here is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

Quoted 7 lines

Any idea if flash triggers a opcode of quad (4-wire) does sifive cr format proto aspected to assign SIFIVE_SPI_FMT_PROTO_QUAD? What exactly is the relation between flash command operations vs driver cr format proto bits? or how do we assign cr format proto bits based on flash operations, is it based on opcode transfer bits or any other logic?

IIUC, as in linux spi-nor framework in consideration here uses spi_mem operations and set's tx/rx nbits for addr, cmd, dummy and data.
For u-boot SPI driver similarly during prepare transfer we need to parse this information And set the proto field within the driver respectively.
So if we move to spi_mem_exec_op mechanism instead of xfer's will it be useful, as it does have tx/rx nbits information as per the addr/cmd/dummy and data transfers. Please let me know your views here.

BR,
Sagar Kadam

Quoted 1 line

Jagan.

author
#23 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Quoted 279 lines · Sagar Kadam

Hello Jagan,

Quoted 249 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 9 lines · Sagar Kadam

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>;

linux-

Quoted 5 lines
Quoted 5 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin

Meng

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 4 lines
Quoted 4 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 1 line
Quoted 1 line

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Hi Bin,

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 38 lines
Quoted 38 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 3 files changed, 23 insertions(+)
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 4 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +0 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 8 lines
board/sifive/fu540/Kconfig +1 -0
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
board/sifive/fu540/Kconfig +2 -0
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
(quoted diff) +0 -0

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

With this patch series, we got crazy duplicated flash devices

created,

Quoted 51 lines
Quoted 51 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 35 lines
Quoted 35 lines

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 1 line

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 1 line
Quoted 1 line
Quoted 1 line

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 2 lines
Quoted 2 lines

tree

Quoted 1 line

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 18 lines
Quoted 11 lines
Quoted 1 line

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as
done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Quoted 5 lines
Quoted 2 lines

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

Thanks for sharing your input/observations

Quoted 5 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 11 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 8 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O mode, I do see corresponding opcode during Read operations (opcode observed here is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

So, the transfer itself triggers several read types based on the tx/rx length type.

Quoted 8 lines
Quoted 8 lines

Any idea if flash triggers a opcode of quad (4-wire) does sifive cr format proto aspected to assign SIFIVE_SPI_FMT_PROTO_QUAD? What exactly is the relation between flash command operations vs driver cr format proto bits? or how do we assign cr format proto bits based on flash operations, is it based on opcode transfer bits or any other logic?

Quoted 6 lines

IIUC, as in linux spi-nor framework in consideration here uses spi_mem operations and set's tx/rx nbits for addr, cmd, dummy and data.
For u-boot SPI driver similarly during prepare transfer we need to parse this information And set the proto field within the driver respectively.
So if we move to spi_mem_exec_op mechanism instead of xfer's will it be useful, as it does have tx/rx nbits information as per the addr/cmd/dummy and data transfers.

Vignesh, any insight this. Look like the controller expecting to set the SPI mode based on the transfer or xfer length of particular transaction from flash.

Jagan.

author
#24 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

In reply to Sagar Kadam

Hi Sagar,

Quoted 279 lines · Sagar Kadam

Hello Jagan,

Quoted 249 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 9 lines · Sagar Kadam

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>;

linux-

Quoted 5 lines
Quoted 5 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin

Meng

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 4 lines
Quoted 4 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 1 line
Quoted 1 line

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Hi Bin,

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 38 lines
Quoted 38 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference.

Tested on SiFive FU540 board.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 3 files changed, 23 insertions(+)
(quoted diff) +0 -0

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 25ec8265a5..d7a64134db 100644

arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 4 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +0 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 8 lines
board/sifive/fu540/Kconfig +1 -0
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION
@@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
board/sifive/fu540/Kconfig +2 -0
        imply SIFIVE_SERIAL
        imply SPI
        imply SPI_SIFIVE
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD
(quoted diff) +0 -0

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

With this patch series, we got crazy duplicated flash devices

created,

Quoted 51 lines
Quoted 51 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 35 lines
Quoted 35 lines

MiB

Quoted 34 lines
Quoted 34 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=129736

the CS number check was added to the SPI flash hence we got:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff
Failed to initialize SPI flash at 0:0 (error -2)
=> sf probe 2
Invalid cs 2 (err=-22)
Invalid cs 2 (err=-22)
Invalid chip select 0:2 (err=-22)
Failed to initialize SPI flash at 0:2 (error -22)
=> sf probe 4
Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22)
Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you mentioned.

Sorry, I had not been closely looking into this thread.
Yes, the initial patch posted was to add support for is25wp256 device.
https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 1 line

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 1 line
Quoted 1 line
Quoted 1 line

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 2 lines
Quoted 2 lines

tree

Quoted 1 line

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 18 lines
Quoted 11 lines
Quoted 1 line

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as
done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which seems reasonable).

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Quoted 5 lines
Quoted 2 lines

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

Thanks for sharing your input/observations

Quoted 5 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 11 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 8 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O mode, I do see corresponding opcode during Read operations (opcode observed here is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

I did manage to get the tx or rx bits logic related to u-boot via buswidth. I can see it is working with quad read and quad write is not working. Seems like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Jagan.

#25 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hello Jagan,

Quoted 329 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Friday, April 17, 2020 1:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 19 lines · Sagar Kadam

Hello Jagan,

Quoted 16 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

On Sun, Apr 5, 2020 at 12:29 AM Sagar Kadam

<[email protected]>

Quoted 181 lines
Quoted 181 lines
Quoted 9 lines · wrote:

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>;

linux-

Quoted 6 lines
Quoted 6 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin

Meng

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 5 lines
Quoted 5 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 2 lines
Quoted 2 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hi Bin,

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng
<[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor
flash, So enable the same and add test result log
for future reference.

Tested on SiFive FU540 board.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jagan Teki
<[email protected]>

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 3 files changed, 23 insertions(+)

diff --git
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 25ec8265a5..d7a64134db 100644
---
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dts +++ i

(quoted diff) +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
(quoted diff) +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 4 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +0 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
board/sifive/fu540/Kconfig +1 -0
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION @@ -40,6 +41,8 @@ config

BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

imply SIFIVE_SERIAL
imply SPI
imply SPI_SIFIVE

board/sifive/fu540/Kconfig +2 -0
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD diff --git

a/doc/board/sifive/fu540.rst

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

With this patch series, we got crazy duplicated flash devices

created,

Quoted 34 lines
Quoted 34 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 16 lines
Quoted 16 lines

MiB

Quoted 15 lines
Quoted 15 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=1
29736

the CS number check was added to the SPI flash hence we

got:

Quoted 18 lines
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 2 Invalid cs 2 (err=-22) Invalid cs 2 (err=-22) Invalid chip select 0:2 (err=-22) Failed to initialize SPI flash at 0:2 (error -22) => sf probe 4 Invalid cs 4 (err=-22) Invalid cs 4 (err=-22) Invalid chip select 0:4 (err=-22) Failed to initialize SPI flash at 0:4 (error -22)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you

mentioned.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Sorry, I had not been closely looking into this thread. Yes, the initial patch posted was to add support for is25wp256

device.

Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 3 lines
Quoted 3 lines

tree

Quoted 2 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which

seems reasonable).

Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Quoted 5 lines
Quoted 2 lines

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

Thanks for sharing your input/observations

Quoted 8 lines
Quoted 5 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to

SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 12 lines
Quoted 12 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 6 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O

mode, I do see

Quoted 3 lines

corresponding opcode during Read operations (opcode observed here
is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

Quoted 6 lines

I did manage to get the tx or rx bits logic related to u-boot via buswidth. I can see it is working with quad read and quad write is not working. Seems like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Yes, It looks that in linux the write protocol is set to SPI mode and it uses 0x12 for PAGE PROGRAM operation.
For is25wp256 flash device the SFDP table has NPH Field as 0x01 (number of parameter headers) i.e just has two parameter table's and the optional 4-byte address function specific table is not populated. Page Program capabilities of hardware are present in this table along with other information. Now since the spi_nor_parse_sfdp function doesn't get the 4BAIT table it setup's spi_nor with single Page program setting (i.e the page program opcode used for writing flash is 0x12)

So in case of linux adding the following code into xxxx_post_bfpt_fixup hooks updates the flash hwcaps and enable's flash write in QUAD mode

static int
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,
@@ -2256,6 +2267,15 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,

        if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
                BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
                nor->addr_width = 4;

+
+ if (params->hwcaps.mask != SNOR_HWCAPS_PP_1_1_4) {
+ struct spi_nor_pp_command *params_pp = params->page_programs;
+
+ params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+ spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_1_1_4],
+ SPINOR_OP_PP_1_1_4,
+ SNOR_PROTO_1_1_4);
+ }

I tried these changes in linux, and did observe that flash write's happened in quad mode.

Thanks & BR,
Sagar Kadam

Quoted 1 line

Jagan.

author
#26 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Sagar,

Quoted 367 lines · Sagar Kadam

Hello Jagan,

Quoted 329 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Friday, April 17, 2020 1:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 19 lines · Sagar Kadam

Hello Jagan,

Quoted 16 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

On Sun, Apr 5, 2020 at 12:29 AM Sagar Kadam

<[email protected]>

Quoted 181 lines
Quoted 181 lines
Quoted 9 lines · wrote:

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>;

linux-

Quoted 6 lines
Quoted 6 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin

Meng

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 5 lines
Quoted 5 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 2 lines
Quoted 2 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hi Bin,

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng
<[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor
flash, So enable the same and add test result log
for future reference.

Tested on SiFive FU540 board.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jagan Teki
<[email protected]>

---
 .../dts/hifive-unleashed-a00-u-boot.dtsi      |  1 +
 board/sifive/fu540/Kconfig                    |  3 +++
 doc/board/sifive/fu540.rst                    | 19

+++++++++++++++++++

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 3 files changed, 23 insertions(+)

diff --git
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 25ec8265a5..d7a64134db 100644
---
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dts +++ i

(quoted diff) +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
(quoted diff) +1 -0
 / {
        aliases {
+               spi0 = &qspi0;
                spi2 = &qspi2;
        };
 };
(quoted diff) +0 -0

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

board/sifive/fu540/Kconfig config BOARD_SPECIFIC_OPTIONS #

Quoted 4 lines

index 5d65080429..c5a1bca03c 100644

board/sifive/fu540/Kconfig +0 -0
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
board/sifive/fu540/Kconfig +1 -0
        imply CMD_FS_GENERIC
        imply CMD_NET
        imply CMD_PING
+       imply CMD_SF
        imply CLK_SIFIVE
        imply CLK_SIFIVE_FU540_PRCI
        imply DOS_PARTITION @@ -40,6 +41,8 @@ config

BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

imply SIFIVE_SERIAL
imply SPI
imply SPI_SIFIVE

board/sifive/fu540/Kconfig +2 -0
+       imply SPI_FLASH
+       imply SPI_FLASH_ISSI
        imply MMC
        imply MMC_SPI
        imply MMC_BROKEN_CD diff --git

a/doc/board/sifive/fu540.rst

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 4 lines

index 91b94ee06f..2e70cad02e 100644

doc/board/sifive/fu540.rst load uImage. · line 375

Quoted 10 lines
doc/board/sifive/fu540.rst +7 -0
@@ -366,3 +366,22 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+   => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

With this patch series, we got crazy duplicated flash devices

created,

Quoted 34 lines
Quoted 34 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 16 lines
Quoted 16 lines

MiB

Quoted 15 lines
Quoted 15 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--
clock-controller at 10000000
 serial        0  [ + ]   serial_sifive         |   |-- serial at 10010000
 serial        1  [   ]   serial_sifive         |   |-- serial at 10011000
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:2
 spi_flash     2  [ + ]   spi_flash_std         |   |   |-- spi_flash at 0:4
 spi_flash     3  [ + ]   spi_flash_std         |   |   `-- spi_flash at 0:6
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=1
29736

the CS number check was added to the SPI flash hence we

got:

Quoted 18 lines
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 2 Invalid cs 2 (err=-22) Invalid cs 2 (err=-22) Invalid chip select 0:2 (err=-22) Failed to initialize SPI flash at 0:2 (error -22) => sf probe 4 Invalid cs 4 (err=-22) Invalid cs 4 (err=-22) Invalid chip select 0:4 (err=-22) Failed to initialize SPI flash at 0:4 (error -22)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

SPI controller to work under single wire mode. Maybe someone from SiFive could help explain the weird behavior as you

mentioned.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Sorry, I had not been closely looking into this thread. Yes, the initial patch posted was to add support for is25wp256

device.

Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 3 lines
Quoted 3 lines

tree

Quoted 2 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

a conflict due to which reg_read fails and so the sf probe fails too. Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer bitlen(which

seems reasonable).

Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Quoted 5 lines
Quoted 2 lines

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Here are my observations.

Thanks for sharing your input/observations

Quoted 8 lines
Quoted 5 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto value to single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to

SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 12 lines
Quoted 12 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 6 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O

mode, I do see

Quoted 3 lines

corresponding opcode during Read operations (opcode observed here
is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

Quoted 6 lines

I did manage to get the tx or rx bits logic related to u-boot via buswidth. I can see it is working with quad read and quad write is not working. Seems like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Yes, It looks that in linux the write protocol is set to SPI mode and it uses 0x12 for PAGE PROGRAM operation.
For is25wp256 flash device the SFDP table has NPH Field as 0x01 (number of parameter headers) i.e just has two parameter table's and the optional 4-byte address function specific table is not populated. Page Program capabilities of hardware are present in this table along with other information. Now since the spi_nor_parse_sfdp function doesn't get the 4BAIT table it setup's spi_nor with single Page program setting (i.e the page program opcode used for writing flash is 0x12)

So in case of linux adding the following code into xxxx_post_bfpt_fixup hooks updates the flash hwcaps and enable's flash write in QUAD mode

static int
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,

(quoted diff) +9 -0
@@ -2256,6 +2267,15 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,
        if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
                BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
                nor->addr_width = 4;
+
+       if (params->hwcaps.mask != SNOR_HWCAPS_PP_1_1_4) {
+               struct spi_nor_pp_command *params_pp = params->page_programs;
+
+               params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+               spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_1_1_4],
+                                         SPINOR_OP_PP_1_1_4,
+                                         SNOR_PROTO_1_1_4);
+       }
 
Quoted 1 line

I tried these changes in linux, and did observe that flash write's happened in quad mode.

Thanks for the update, what about the SPI direction field incase of TX QUAD, is the direction needed to set for all TX transactions or only for QUAD?

Jagan.

#27 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hello Jagan,

Quoted 411 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 18, 2020 1:11 AM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 14 lines · Sagar Kadam

Hello Jagan,

Quoted 11 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Friday, April 17, 2020 1:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 28 lines
Quoted 28 lines

sender and know the content is safe

Hi Sagar,

Quoted 19 lines · Sagar Kadam

Hello Jagan,

Quoted 16 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

On Sun, Apr 5, 2020 at 12:29 AM Sagar Kadam

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt
<[email protected]>; U-Boot Mailing List <u-

boot at lists.denx.de>;

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

linux-

Quoted 6 lines
Quoted 6 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of

Bin

Quoted 72 lines
Quoted 72 lines
Quoted 72 lines
Quoted 72 lines

Meng

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 5 lines
Quoted 5 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 2 lines
Quoted 2 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hi Bin,

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng
<[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor
flash, So enable the same and add test result log
for future reference.

Tested on SiFive FU540 board.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jagan Teki
<[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Tested-by: Bin Meng <[email protected]>
---
.../dts/hifive-unleashed-a00-u-boot.dtsi | 1 +
board/sifive/fu540/Kconfig | 3 +++
doc/board/sifive/fu540.rst | 19

+++++++++++++++++++

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

3 files changed, 23 insertions(+)

diff --git
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 25ec8265a5..d7a64134db 100644
---
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
+++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dts
+++ i
@@ -5,6 +5,7 @@

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

/ {
aliases {
+ spi0 = &qspi0;
spi2 = &qspi2;
};
};
diff --git a/board/sifive/fu540/Kconfig

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 5d65080429..c5a1bca03c 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS

#

Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

imply CMD_FS_GENERIC
imply CMD_NET
imply CMD_PING
+ imply CMD_SF
imply CLK_SIFIVE
imply CLK_SIFIVE_FU540_PRCI
imply DOS_PARTITION @@ -40,6 +41,8 @@ config
BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

imply SIFIVE_SERIAL
imply SPI
imply SPI_SIFIVE
+ imply SPI_FLASH
+ imply SPI_FLASH_ISSI
imply MMC
imply MMC_SPI
imply MMC_BROKEN_CD diff --git
a/doc/board/sifive/fu540.rst

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 14 lines

index 91b94ee06f..2e70cad02e 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -366,3 +366,22 @@ load uImage.

Please press Enter to activate this console.
/ #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+ => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

With this patch series, we got crazy duplicated flash devices

created,

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 1 line
Quoted 1 line

MiB

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--

clock-controller at 10000000
serial 0 [ + ] serial_sifive | |--

serial at 10010000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

serial 1 [ ] serial_sifive | |--

serial at 10011000

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |--

spi_flash at 0:2

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 2 [ + ] spi_flash_std | | |--

spi_flash at 0:4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 3 [ + ] spi_flash_std | | `--

spi_flash at 0:6

Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=1
29736

the CS number check was added to the SPI flash hence we

got:

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 2 Invalid cs 2 (err=-22) Invalid cs 2 (err=-22) Invalid chip select 0:2 (err=-22) Failed to initialize SPI flash at 0:2 (error -22) => sf probe 4 Invalid cs 4 (err=-22) Invalid cs 4 (err=-22) Invalid chip select 0:4 (err=-22) Failed to initialize SPI flash at 0:4 (error -22)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

SPI controller to work under single wire mode. Maybe

someone

Quoted 13 lines
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

from SiFive could help explain the weird behavior as you

mentioned.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Sorry, I had not been closely looking into this thread. Yes, the initial patch posted was to add support for is25wp256

device.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 3 lines
Quoted 3 lines

tree

Quoted 2 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 1 line
Quoted 1 line
Quoted 1 line

a conflict due to which reg_read fails and so the sf probe fails

too.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer

bitlen(which

Quoted 12 lines
Quoted 12 lines

seems reasonable).

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Here are my observations.

Thanks for sharing your input/observations

Quoted 2 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto

value to

Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines

single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to

SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 12 lines
Quoted 12 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O

mode, I do see

Quoted 1 line

corresponding opcode during Read operations (opcode observed

here

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

I did manage to get the tx or rx bits logic related to u-boot via buswidth.

I

Quoted 1 line
Quoted 1 line

can see it is working with quad read and quad write is not working.

Seems

Quoted 6 lines
Quoted 4 lines

like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Yes, It looks that in linux the write protocol is set to SPI mode and it uses

0x12 for

Quoted 2 lines

PAGE PROGRAM operation.
For is25wp256 flash device the SFDP table has NPH Field as 0x01 (number

of parameter headers) i.e

Quoted 1 line

just has two parameter table's and the optional 4-byte address function

specific table is not populated.

Quoted 1 line

Page Program capabilities of hardware are present in this table along with

other information. Now since

Quoted 1 line

the spi_nor_parse_sfdp function doesn't get the 4BAIT table it setup's

spi_nor with single Page

Quoted 1 line

program setting (i.e the page program opcode used for writing flash is

0x12)

Quoted 2 lines

So in case of linux adding the following code into xxxx_post_bfpt_fixup

hooks updates the flash hwcaps and

Review is25lp256_post_bfpt_fixups(struct spi_nor

Quoted 6 lines

enable's flash write in QUAD mode

static int
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,

(quoted diff) +0 -0
@@ -2256,6 +2267,15 @@ is25lp256_post_bfpt_fixups(struct spi_nor

*nor,

Review is25lp256_post_bfpt_fixups(struct spi_nor · line 2267

Quoted 1 line
(quoted diff) +0 -0
        if ((bfpt->dwords[BFPT_DWORD(1)] &

BFPT_DWORD1_ADDRESS_BYTES_MASK) ==

Quoted 14 lines
(quoted diff) +9 -0
                BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
                nor->addr_width = 4;
+
+       if (params->hwcaps.mask != SNOR_HWCAPS_PP_1_1_4) {
+               struct spi_nor_pp_command *params_pp = params-
 page_programs;
+
+               params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+               spi_nor_set_pp_settings(&params-
 page_programs[SNOR_CMD_PP_1_1_4],
+                                         SPINOR_OP_PP_1_1_4,
+                                         SNOR_PROTO_1_1_4);
+       }
 
Quoted 7 lines
Quoted 1 line

I tried these changes in linux, and did observe that flash write's happened

in quad mode.

Thanks for the update, what about the SPI direction field incase of TX QUAD, is the direction needed to set for all TX transactions or only for QUAD?

For our case i.e QUAD TX we need to set the TX direction bit and clear it during read.

BR,
Sagar Kadam

Quoted 1 line

Jagan.

author
#28 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Sagar,

Quoted 417 lines · Sagar Kadam

Hello Jagan,

Quoted 414 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 18, 2020 1:11 AM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 14 lines · Sagar Kadam

Hello Jagan,

Quoted 11 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Friday, April 17, 2020 1:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 28 lines
Quoted 28 lines

sender and know the content is safe

Hi Sagar,

Quoted 19 lines · Sagar Kadam

Hello Jagan,

Quoted 16 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt <[email protected]>; U-Boot Mailing List <[email protected]>; linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

On Sun, Apr 5, 2020 at 12:29 AM Sagar Kadam

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt
<[email protected]>; U-Boot Mailing List <u-

boot at lists.denx.de>;

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

linux-

Quoted 6 lines
Quoted 6 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of

Bin

Quoted 72 lines
Quoted 72 lines
Quoted 72 lines
Quoted 72 lines

Meng

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 5 lines
Quoted 5 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 2 lines
Quoted 2 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hi Bin,

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng
<[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor
flash, So enable the same and add test result log
for future reference.

Tested on SiFive FU540 board.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jagan Teki
<[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Tested-by: Bin Meng <[email protected]>
---
.../dts/hifive-unleashed-a00-u-boot.dtsi | 1 +
board/sifive/fu540/Kconfig | 3 +++
doc/board/sifive/fu540.rst | 19

+++++++++++++++++++

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

3 files changed, 23 insertions(+)

diff --git
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 25ec8265a5..d7a64134db 100644
---
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
+++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dts
+++ i
@@ -5,6 +5,7 @@

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

/ {
aliases {
+ spi0 = &qspi0;
spi2 = &qspi2;
};
};
diff --git a/board/sifive/fu540/Kconfig

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 5d65080429..c5a1bca03c 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS

#

Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines

dummy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

imply CMD_FS_GENERIC
imply CMD_NET
imply CMD_PING
+ imply CMD_SF
imply CLK_SIFIVE
imply CLK_SIFIVE_FU540_PRCI
imply DOS_PARTITION @@ -40,6 +41,8 @@ config
BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

imply SIFIVE_SERIAL
imply SPI
imply SPI_SIFIVE
+ imply SPI_FLASH
+ imply SPI_FLASH_ISSI
imply MMC
imply MMC_SPI
imply MMC_BROKEN_CD diff --git
a/doc/board/sifive/fu540.rst

b/doc/board/sifive/fu540.rst

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

index 91b94ee06f..2e70cad02e 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -366,3 +366,22 @@ load uImage.

Please press Enter to activate this console.
/ #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+ => sf probe 0:2

The cs number can't be 2. It should be zero.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

With this patch series, we got crazy duplicated flash devices

created,

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 4 lines
Quoted 4 lines

MiB

Quoted 3 lines
Quoted 3 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB,

total 32

Quoted 1 line
Quoted 1 line

MiB

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------

 root          0  [ + ]   root_driver           root_driver
 simple_bus    0  [ + ]   generic_simple_bus    |-- soc
 clk           0  [ + ]   sifive-fu540-prci     |   |--

clock-controller at 10000000
serial 0 [ + ] serial_sifive | |--

serial at 10010000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

serial 1 [ ] serial_sifive | |--

serial at 10011000

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
 spi           0  [ + ]   sifive_spi            |   |-- spi at 10040000
 spi_flash     0  [   ]   spi_flash_std         |   |   |-- flash at 0
 spi_flash     1  [ + ]   spi_flash_std         |   |   |--

spi_flash at 0:2

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 2 [ + ] spi_flash_std | | |--

spi_flash at 0:4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 3 [ + ] spi_flash_std | | `--

spi_flash at 0:6

Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

With my patch series below
http://patchwork.ozlabs.org/project/uboot/list/?series=1
29736

the CS number check was added to the SPI flash hence we

got:

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to initialize SPI flash at 0:0 (error -2) => sf probe 2 Invalid cs 2 (err=-22) Invalid cs 2 (err=-22) Invalid chip select 0:2 (err=-22) Failed to initialize SPI flash at 0:2 (error -22) => sf probe 4 Invalid cs 4 (err=-22) Invalid cs 4 (err=-22) Invalid chip select 0:4 (err=-22) Failed to initialize SPI flash at 0:4 (error -22)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So we still need figure out why CS number 0 cannot work on

SiFive.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

The existing quad wire that driver pushing for flash seems not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch that forced

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

SPI controller to work under single wire mode. Maybe

someone

Quoted 13 lines
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

from SiFive could help explain the weird behavior as you

mentioned.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Sorry, I had not been closely looking into this thread. Yes, the initial patch posted was to add support for is25wp256

device.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

slave mode and accordingly sets the hwcaps fields. Now since the

device

Quoted 3 lines
Quoted 3 lines

tree

Quoted 2 lines

set's the slave mode to 4 bit mode based on the tx-bus-width, this

creates

Quoted 1 line
Quoted 1 line
Quoted 1 line

a conflict due to which reg_read fails and so the sf probe fails

too.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Now forcing the SPI-controller in single wire mode helped the sf probe

to

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver private structure so-that the same can be used while setting cr. One of your patch doing the same [1] but with every transfer

bitlen(which

Quoted 12 lines
Quoted 12 lines

seems reasonable).

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Here are my observations.

Thanks for sharing your input/observations

Quoted 2 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto

value to

Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines

single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the Linux probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to

SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 12 lines
Quoted 12 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations working with quad or does it revert back to default commands like fast read and page program? could you please check?

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

"flash operations are working only for fast read, that means 2-wire."

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD I/O

mode, I do see

Quoted 1 line

corresponding opcode during Read operations (opcode observed

here

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

I did manage to get the tx or rx bits logic related to u-boot via buswidth.

I

Quoted 1 line
Quoted 1 line

can see it is working with quad read and quad write is not working.

Seems

Quoted 6 lines
Quoted 4 lines

like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Yes, It looks that in linux the write protocol is set to SPI mode and it uses

0x12 for

Quoted 2 lines

PAGE PROGRAM operation.
For is25wp256 flash device the SFDP table has NPH Field as 0x01 (number

of parameter headers) i.e

Quoted 1 line

just has two parameter table's and the optional 4-byte address function

specific table is not populated.

Quoted 1 line

Page Program capabilities of hardware are present in this table along with

other information. Now since

Quoted 1 line

the spi_nor_parse_sfdp function doesn't get the 4BAIT table it setup's

spi_nor with single Page

Quoted 1 line

program setting (i.e the page program opcode used for writing flash is

0x12)

Quoted 2 lines

So in case of linux adding the following code into xxxx_post_bfpt_fixup

hooks updates the flash hwcaps and

Review is25lp256_post_bfpt_fixups(struct spi_nor

Quoted 6 lines

enable's flash write in QUAD mode

static int
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,

(quoted diff) +0 -0
@@ -2256,6 +2267,15 @@ is25lp256_post_bfpt_fixups(struct spi_nor

*nor,

Review is25lp256_post_bfpt_fixups(struct spi_nor · line 2267

Quoted 1 line
(quoted diff) +0 -0
        if ((bfpt->dwords[BFPT_DWORD(1)] &

BFPT_DWORD1_ADDRESS_BYTES_MASK) ==

Quoted 14 lines
(quoted diff) +9 -0
                BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
                nor->addr_width = 4;
+
+       if (params->hwcaps.mask != SNOR_HWCAPS_PP_1_1_4) {
+               struct spi_nor_pp_command *params_pp = params-
 page_programs;
+
+               params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+               spi_nor_set_pp_settings(&params-
 page_programs[SNOR_CMD_PP_1_1_4],
+                                         SPINOR_OP_PP_1_1_4,
+                                         SNOR_PROTO_1_1_4);
+       }
 
Quoted 1 line

I tried these changes in linux, and did observe that flash write's happened

in quad mode.

Quoted 6 lines
Quoted 4 lines

Thanks for the update, what about the SPI direction field incase of TX QUAD, is the direction needed to set for all TX transactions or only for QUAD?

For our case i.e QUAD TX we need to set the TX direction bit and clear it during read.

Yes, I'm trying to do exactly the same. Can you try to check the attached file (sorry it has prints, hope you can comment). It worked with QPP and I can see quad read exception after reading 8K. Unhandled exception: Load access fault
EPC: 00000000fffac14a TVAL: 0000000000002000

Let me know if you find any? by the way are you online in #u-boot?

Jagan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spi-sifive.c
Type: text/x-csrc
Size: 15755 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200418/d0cffee4/attachment.c>

#29 lore raw

PATCH v2 5/5 sifive: fu540: Enable spi-nor flash support

Hi Jagan,

Quoted 481 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 18, 2020 4:12 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

Quoted 14 lines · Sagar Kadam

Hello Jagan,

Quoted 11 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 18, 2020 1:11 AM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Fri, Apr 17, 2020 at 11:50 PM Sagar Kadam

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hello Jagan,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Friday, April 17, 2020 1:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; linux-amarula <linux-
amarula at amarulasolutions.com>; palmer at dabbelt.com
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

support

[External Email] Do not click links or attachments unless you

recognize

Quoted 6 lines
Quoted 6 lines

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Tue, Apr 7, 2020 at 9:48 PM Sagar Kadam

<[email protected]>

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines · wrote:

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Monday, April 6, 2020 9:30 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt
<[email protected]>; U-Boot Mailing List <u-

boot at lists.denx.de>;

Quoted 35 lines
Quoted 35 lines
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
Quoted 10 lines

linux- amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Sagar,

On Sun, Apr 5, 2020 at 12:29 AM Sagar Kadam

<[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Hello Jagan,

Quoted 6 lines

-----Original Message-----
From: Jagan Teki <[email protected]>
Sent: Saturday, April 4, 2020 11:45 PM
To: Sagar Kadam <[email protected]>
Cc: Bin Meng <[email protected]>; Palmer Dabbelt
<[email protected]>; U-Boot Mailing List <u-

boot at lists.denx.de>;

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

linux-

Quoted 6 lines
Quoted 6 lines

amarula <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor flash support

[External Email] Do not click links or attachments unless you recognize

the

Quoted 5 lines
Quoted 5 lines

sender and know the content is safe

Hi Sagar,

On Mon, Nov 18, 2019 at 2:29 AM Sagar Kadam

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:

Hello Jagan/Bin,

Quoted 2 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf

Of

Quoted 55 lines
Quoted 55 lines

Bin

Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines

Meng

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Sent: Monday, November 11, 2019 8:02 PM
To: Jagan Teki <[email protected]>
Cc: Palmer Dabbelt ( Sifive) <[email protected]>; U-Boot Mailing

List

Quoted 5 lines
Quoted 5 lines

<u-

Quoted 1 line
Quoted 1 line

boot at lists.denx.de>; linux-amarula <linux-

amarula at amarulasolutions.com>

Quoted 2 lines
Quoted 2 lines

Subject: Re: [U-Boot] [PATCH v2 5/5] sifive: fu540: Enable spi-nor

flash

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

support

Hi Jagan,

On Sat, Nov 9, 2019 at 7:57 PM Jagan Teki

<[email protected]>

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines · wrote:

Hi Bin,

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, Oct 29, 2019 at 3:50 PM Bin Meng
<[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jagan,

On Tue, Oct 29, 2019 at 5:38 PM Bin Meng

<[email protected]>

Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines · wrote:
Quoted 4 lines

Hi Jagan,

On Wed, Oct 16, 2019 at 10:58 PM Jagan Teki

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines

HiFive Unleashed A00 support is25wp256 spi-nor
flash, So enable the same and add test result log
for future reference.

Tested on SiFive FU540 board.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jagan Teki
<[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Tested-by: Bin Meng <[email protected]>
---
.../dts/hifive-unleashed-a00-u-boot.dtsi | 1 +
board/sifive/fu540/Kconfig | 3 +++
doc/board/sifive/fu540.rst | 19

+++++++++++++++++++

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

3 files changed, 23 insertions(+)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

diff --git
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi

Quoted 4 lines
Quoted 4 lines

index 25ec8265a5..d7a64134db 100644
---
a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
+++ b/arch/riscv/dts/hifive-unleashed-a00-u-

boot.dts

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+++ i
@@ -5,6 +5,7 @@

/ {
aliases {
+ spi0 = &qspi0;
spi2 = &qspi2;
};
};
diff --git a/board/sifive/fu540/Kconfig

b/board/sifive/fu540/Kconfig

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

index 5d65080429..c5a1bca03c 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -26,6 +26,7 @@ config

BOARD_SPECIFIC_OPTIONS

Quoted 9 lines
Quoted 9 lines

#

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

dummy

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

imply CMD_FS_GENERIC
imply CMD_NET
imply CMD_PING
+ imply CMD_SF
imply CLK_SIFIVE
imply CLK_SIFIVE_FU540_PRCI
imply DOS_PARTITION @@ -40,6 +41,8 @@

config

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

BOARD_SPECIFIC_OPTIONS #

dummy

Quoted 29 lines
Quoted 29 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

imply SIFIVE_SERIAL
imply SPI
imply SPI_SIFIVE
+ imply SPI_FLASH
+ imply SPI_FLASH_ISSI
imply MMC
imply MMC_SPI
imply MMC_BROKEN_CD diff --git
a/doc/board/sifive/fu540.rst

b/doc/board/sifive/fu540.rst

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

index 91b94ee06f..2e70cad02e 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -366,3 +366,22 @@ load uImage.

Please press Enter to activate this console.
/ #
+
+Sample spi nor flash test
+-------------------------
+
+.. code-block:: none
+
+ => sf probe 0:2

The cs number can't be 2. It should be zero.

With this patch series, we got crazy duplicated flash
devices

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

created,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

see below:

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to
initialize SPI flash at 0:0 (error -2) => sf probe 0:2
SF: Detected is25wp256 with page size 256 Bytes,

erase

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:4
SF: Detected is25wp256 with page size 256 Bytes,

erase

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

size 4 KiB,

total 32

Quoted 3 lines
Quoted 3 lines

MiB

Quoted 2 lines
Quoted 2 lines

=> sf probe 0:6
SF: Detected is25wp256 with page size 256 Bytes,

erase

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

size 4 KiB,

total 32

Quoted 9 lines
Quoted 9 lines

MiB

Quoted 8 lines
Quoted 8 lines

=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driver root_driver
simple_bus 0 [ + ] generic_simple_bus |-- soc
clk 0 [ + ] sifive-fu540-prci | |--
clock-controller at 10000000
serial 0 [ + ] serial_sifive | |--

Quoted 4 lines
Quoted 4 lines

serial at 10010000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

serial 1 [ ] serial_sifive | |--

serial at 10011000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi 0 [ + ] sifive_spi | |--

spi at 10040000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 0 [ ] spi_flash_std | | |--

flash at 0

Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 1 [ + ] spi_flash_std | | |--

spi_flash at 0:2

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 2 [ + ] spi_flash_std | | |--

spi_flash at 0:4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

spi_flash 3 [ + ] spi_flash_std | | `--

spi_flash at 0:6

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

With my patch series below

http://patchwork.ozlabs.org/project/uboot/list/?series=1

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

29736

the CS number check was added to the SPI flash hence

we

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

got:

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

=> sf probe
unrecognized JEDEC id bytes: ff, ff, ff Failed to
initialize SPI flash at 0:0 (error -2) => sf probe 2
Invalid cs 2 (err=-22) Invalid cs 2 (err=-22) Invalid
chip select 0:2 (err=-22) Failed to initialize SPI flash
at 0:2 (error -22) => sf probe 4 Invalid cs 4 (err=-22)
Invalid cs 4 (err=-22) Invalid chip select 0:4 (err=-22)
Failed to initialize SPI flash at 0:4 (error -22)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

So we still need figure out why CS number 0 cannot

work

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

on

SiFive.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The existing quad wire that driver pushing for flash

seems

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

not detecting flash at CS 0 so making cr to single wire detecting flash at

I vaguely remember someone from SiFive posted a patch

that

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

forced

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

SPI controller to work under single wire mode. Maybe

someone

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

from SiFive could help explain the weird behavior as you

mentioned.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Sorry, I had not been closely looking into this thread. Yes, the initial patch posted was to add support for

is25wp256

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

device.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

https://patchwork.ozlabs.org/patch/1146523/
but it seems it was bricking the board, and later couldn't follow-up on

this.

Quoted 2 lines

IIUC, spi_nor_scan has default reg_proto set to 1_1_1, and further

parses

Quoted 1 line
Quoted 1 line
Quoted 1 line

slave mode and accordingly sets the hwcaps fields. Now

since

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

the

device

Quoted 2 lines
Quoted 2 lines

tree

Quoted 1 line

set's the slave mode to 4 bit mode based on the tx-bus-

width,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

this

creates

Quoted 1 line
Quoted 1 line
Quoted 1 line

a conflict due to which reg_read fails and so the sf probe

fails

Quoted 2 lines
Quoted 2 lines

too.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Now forcing the SPI-controller in single wire mode helped

the

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

sf probe

to

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

detect the flash. Alternatively I think if we use bitlen passed by

spi_mem_exec_op

Quoted 3 lines

and prepare spi transfer's in controller based on max of t->rx_nbits, t- tx_nbits as done in linux driver this should work. Any thoughts on this?

Thanks for the explanation. Infact I found how to handle this via set_mode where I can preserve the mode into driver

private

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

structure so-that the same can be used while setting cr. One

of

Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

your patch doing the same [1] but with every transfer

bitlen(which

Quoted 12 lines
Quoted 12 lines

seems reasonable).

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line

Good to know that it is working in case of cs0 as well.

Quoted 5 lines

With this I can detect the flash at cs 0 but still flash still requires bfpt fixes to make it work. I would like to poke your series and do the changes accordingly (by keeping your respective authorship), will that be fine?

Yes, please feel free to do so and also let me know if there is something which I can be of help here.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Here are my observations.

Thanks for sharing your input/observations

Quoted 2 lines

1. flash probe:
Probe happened to cs0 only when we enabled cs format propto

value to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

single (SIFIVE_SPI_FMT_PROTO_SINGLE). I did check it on the

Linux

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

probe as well, same behaviour.

Yes, this matches with our understanding above, since reg read's during spi_nor_scan is 1-bit mode, and if cs proto value is set to

SIFIVE_SPI_FMT_PROTO_SINGLE It works.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

2. flash operations:
Driver always assign single to format proto (say if we enable cr format proto value based on bitlen) and it can't assign it ot dual and quad even though the tx/rx-bus-width is 4 or 1

flash operations are not working with quad, I did check the quad enable bit, it is already enabled (RDSR is 0x40 BIT[6] is 1 that means quad enabled by default). Is Linux flash operations

working

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

with quad or does it revert back to default commands like fast

read

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

and page program? could you please check?

"flash operations are working only for fast read, that means 2-

wire."

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

I checked in linux-5.6.0-rc7 flash operations for issi devices:
- quad enable bit is set via issi_set_default_init.
- post spi_nor_init, the read protocol is set to FAST_READ_QUAD

I/O

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

mode, I do see

Quoted 1 line

corresponding opcode during Read operations (opcode observed

here

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

is 0xec)
- The page program is set and uses the SPI mode (opcode 12h).

I did manage to get the tx or rx bits logic related to u-boot via

buswidth.

Quoted 9 lines
Quoted 9 lines

I

Quoted 1 line
Quoted 1 line

can see it is working with quad read and quad write is not working.

Seems

Quoted 6 lines
Quoted 4 lines

like Quad write is also not working even for Linux any idea, why [2]?

[2] https://paste.ubuntu.com/p/nhZzQkkG33/

Yes, It looks that in linux the write protocol is set to SPI mode and it

uses

Quoted 3 lines
Quoted 3 lines

0x12 for

Quoted 2 lines

PAGE PROGRAM operation.
For is25wp256 flash device the SFDP table has NPH Field as 0x01

(number

Quoted 2 lines
Quoted 2 lines

of parameter headers) i.e

Quoted 1 line

just has two parameter table's and the optional 4-byte address

function

Quoted 2 lines
Quoted 2 lines

specific table is not populated.

Quoted 1 line

Page Program capabilities of hardware are present in this table along

with

Quoted 7 lines
Quoted 7 lines

other information. Now since

Quoted 1 line

the spi_nor_parse_sfdp function doesn't get the 4BAIT table it setup's

spi_nor with single Page

Quoted 1 line

program setting (i.e the page program opcode used for writing flash is

0x12)

Quoted 2 lines

So in case of linux adding the following code into

xxxx_post_bfpt_fixup

Quoted 24 lines
Quoted 24 lines

hooks updates the flash hwcaps and

Review is25lp256_post_bfpt_fixups(struct spi_nor

Quoted 6 lines

enable's flash write in QUAD mode

static int
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,

(quoted diff) +0 -0
@@ -2256,6 +2267,15 @@ is25lp256_post_bfpt_fixups(struct spi_nor

*nor,

Review is25lp256_post_bfpt_fixups(struct spi_nor · line 2267

Quoted 1 line
(quoted diff) +0 -0
        if ((bfpt->dwords[BFPT_DWORD(1)] &

BFPT_DWORD1_ADDRESS_BYTES_MASK) ==

Quoted 14 lines
(quoted diff) +9 -0
                BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
                nor->addr_width = 4;
+
+       if (params->hwcaps.mask != SNOR_HWCAPS_PP_1_1_4) {
+               struct spi_nor_pp_command *params_pp = params-
 page_programs;
+
+               params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4;
+               spi_nor_set_pp_settings(&params-
 page_programs[SNOR_CMD_PP_1_1_4],
+                                         SPINOR_OP_PP_1_1_4,
+                                         SNOR_PROTO_1_1_4);
+       }
 
Quoted 1 line
Quoted 1 line
Quoted 1 line

I tried these changes in linux, and did observe that flash write's

happened

Quoted 7 lines
Quoted 6 lines

in quad mode.

Thanks for the update, what about the SPI direction field incase of TX QUAD, is the direction needed to set for all TX transactions or only for QUAD?

For our case i.e QUAD TX we need to set the TX direction bit and clear it

during

Quoted 1 line

read.

Quoted 8 lines

Yes, I'm trying to do exactly the same. Can you try to check the attached file (sorry it has prints, hope you can comment). It worked with QPP and I can see quad read exception after reading 8K. Unhandled exception: Load access fault
EPC: 00000000fffac14a TVAL: 0000000000002000

Let me know if you find any? by the way are you online in #u-boot?

Thanks, I will check your file. And yes, I will ping you on #u-boot channel.

Quoted 1 line

Jagan.