Skip to contentSkip to conversation

spi flash env and driver model

U-Boot New Chris Packham 3 participants 6 messages Aug 7, 2017 – Aug 28, 2017 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi,

I'm looking at a problem on the db-88f6820-amc board (which has it's env on spi flash). Somewhere in the init sequence we get a crash.

git bisect leads me to commit 8fee8845e7 ("enf_sf: reuse setup_flash_device instead of open coding it") but I don't think that's actually the problem. The real problem seems to be the way setup_spi_device() relies on the speed to come from the device-tree. Even when I specify a speed for the spi-flash in the device tree it doesn't seem to stick. The only thing that seems to work is restoring the CONFIG_ENV_SPI_MAX_HZ in the DM_SPI_FLASH case.

I can submit that as a patch but it seems contrary to the intentions of commit 96907c0fe5 ("dm: spi: Read default speed and mode values from DT").

Does anyone have any thoughts as to where to go with this?

Thanks,
Chris

#1 lore raw
Quoted 13 lines · Chris Packham

Hi,

I'm looking at a problem on the db-88f6820-amc board (which has it's env on spi flash). Somewhere in the init sequence we get a crash.

git bisect leads me to commit 8fee8845e7 ("enf_sf: reuse setup_flash_device instead of open coding it") but I don't think that's actually the problem. The real problem seems to be the way setup_spi_device() relies on the speed to come from the device-tree. Even when I specify a speed for the spi-flash in the device tree it doesn't seem to stick. The only thing that seems to work is restoring the CONFIG_ENV_SPI_MAX_HZ in the DM_SPI_FLASH case.

Quoted 5 lines

I can submit that as a patch but it seems contrary to the intentions of commit 96907c0fe5 ("dm: spi: Read default speed and mode values from DT").

Does anyone have any thoughts as to where to go with this?

So now I've actually been able to see the failure with an ICD attached the problem is a divide by 0 in mvebu_spi_set_speed() because the speed is being passed down as 0. Moving up the stack this appears to be coming from the parent_platdata looked up by spi_get_bus_and_cs(). So it looks like the spi-max-frequency property hasn't been parsed up from the device tree prior to this call.

#2 lore raw

PATCH 1/1 spi: add "jedec,spi-nor" to spi_flash_std_ids

"jedec,spi-nor" is used by Linux for many boards with spi flash. In fact according to the binding documentation this must be included for any SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). Make device trees more portable between Linux an U-Boot by supporting "jedec,spi-nor" in addition to the U-Boot specific "spi-flash".

---
This fixes my issues with the spi speed selection on db-88f6820-amc. I didn't find anything in the commit message from the initial implementation saying that "jedec,spi-nor" was omitted intentionally so I've settled on this instead of updating armada-385-amc.dts.

If there is a good reason not to make this change I'm happy to submit a patch that just updates armada-385-amc.dts.

 drivers/mtd/spi/sf_probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
index 7b296378d2be..1953ec3cb748 100644
@@ -164,6 +164,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {
 
 static const struct udevice_id spi_flash_std_ids[] = {
 	{ .compatible = "spi-flash" },
+	{ .compatible = "jedec,spi-nor" },
 	{ }
 };
 
Signature · 1 line
2.13.0
maintainer
#3 lore raw

PATCH 1/1 spi: add "jedec,spi-nor" to spi_flash_std_ids

Quoted 8 lines · Chris Packham

"jedec,spi-nor" is used by Linux for many boards with spi flash. In fact according to the binding documentation this must be included for any SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). Make device trees more portable between Linux an U-Boot by supporting "jedec,spi-nor" in addition to the U-Boot specific "spi-flash".

---

+1

Use of U-Boot specific compatible "spi-flash" has caused quite a bit of confusions and also problems while syncing U-Boot and kernel DTs. IMO, its better if we could probe JEDEC SPI NOR flashes based on generic "jedec,spi-nor" compatible as well like Linux.

Quoted 23 lines

This fixes my issues with the spi speed selection on db-88f6820-amc. I didn't find anything in the commit message from the initial implementation saying that "jedec,spi-nor" was omitted intentionally so I've settled on this instead of updating armada-385-amc.dts.

If there is a good reason not to make this change I'm happy to submit a patch that just updates armada-385-amc.dts.>

 drivers/mtd/spi/sf_probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +1 -0
index 7b296378d2be..1953ec3cb748 100644
@@ -164,6 +164,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {
 
 static const struct udevice_id spi_flash_std_ids[] = {
 	{ .compatible = "spi-flash" },
+	{ .compatible = "jedec,spi-nor" },
 	{ }
 };
 
Signature · 2 lines
Regards
Vignesh
#4 lore raw

PATCH 1/1 spi: add "jedec,spi-nor" to spi_flash_std_ids

+Jagan at gmail not sure what your primary u-boot address is

Quoted 46 lines · Vignesh R
Quoted 8 lines · Chris Packham

"jedec,spi-nor" is used by Linux for many boards with spi flash. In fact according to the binding documentation this must be included for any SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). Make device trees more portable between Linux an U-Boot by supporting "jedec,spi-nor" in addition to the U-Boot specific "spi-flash".

---

+1

Use of U-Boot specific compatible "spi-flash" has caused quite a bit of confusions and also problems while syncing U-Boot and kernel DTs. IMO, its better if we could probe JEDEC SPI NOR flashes based on generic "jedec,spi-nor" compatible as well like Linux.

Quoted 16 lines

This fixes my issues with the spi speed selection on db-88f6820-amc. I didn't find anything in the commit message from the initial implementation saying that "jedec,spi-nor" was omitted intentionally so I've settled on this instead of updating armada-385-amc.dts.

If there is a good reason not to make this change I'm happy to submit a patch that just updates armada-385-amc.dts.>

 drivers/mtd/spi/sf_probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi/sf_probe.c +0 -0
index 7b296378d2be..1953ec3cb748 100644

drivers/mtd/spi/sf_probe.c static const struct dm_spi_flash_ops spi_flash_std_ops = { · line 170

Quoted 7 lines
drivers/mtd/spi/sf_probe.c +1 -0
@@ -164,6 +164,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {
 
 static const struct udevice_id spi_flash_std_ids[] = {
      { .compatible = "spi-flash" },
+     { .compatible = "jedec,spi-nor" },
      { }
 };
 

--
Regards
Vignesh

#5 lore raw

PATCH 1/1 spi: add "jedec,spi-nor" to spi_flash_std_ids

In reply to Chris Packham
Quoted 7 lines · Chris Packham

"jedec,spi-nor" is used by Linux for many boards with spi flash. In fact according to the binding documentation this must be included for any SPI NOR flash that can be identified by the JEDEC READ ID opcode (0x9F). Make device trees more portable between Linux an U-Boot by supporting "jedec,spi-nor" in addition to the U-Boot specific "spi-flash".

Quoted 8 lines

---
This fixes my issues with the spi speed selection on db-88f6820-amc. I didn't find anything in the commit message from the initial implementation saying that "jedec,spi-nor" was omitted intentionally so I've settled on this instead of updating armada-385-amc.dts.

If there is a good reason not to make this change I'm happy to submit a patch that just updates armada-385-amc.dts.

At this point try to use spi-flash in dts since we're in WIP for spi-nor support once ie in-place then only we have sync the compatible of what Linux is using.

thanks!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.