U-CLASS SPI Bus and Devices
I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP FlexSPI controller. U-Boot started correctly from the flash device but using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This error message is emitted by spi_get_bus_and_cs() in drivers/spi/spi-uclass.c. I traced the issue to uclass_get_device_by_seq() in drivers/core/uclass.c.
The function first searches the device list for a device that already claimed the sequence number (dev->seq). If not found it would look if a device requested that sequence number (dev->seq_req). That would always fail for my device. The bus had not been probed yet and hence dev->seq was -1 and the device also had dev->req_seq set to -1.
The board is using a device tree hence it would only make sense to set the requested sequence number via the device tree. However, there is no such thing and even if there was it might not be specified.
Consequently, the device was never probed although the driver was correctly set up via device tree.
I worked around it by simply setting dev->req_seq of the first device that had it set to -1 to the sequence number the search function was looking for (see patch below). It solved my problem but I don't know if that is the right way of addressing it. I could not find any other solution for this particular problem anywhere.
Rudi
I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP FlexSPI controller. U-Boot started correctly from the flash device but using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This error message is emitted by spi_get_bus_and_cs() in drivers/spi/spi-uclass.c. I traced the issue to uclass_get_device_by_seq() in drivers/core/uclass.c.
The function first searches the device list for a device that already claimed the sequence number (dev->seq). If not found it would look if a device requested that sequence number (dev->seq_req). That would always fail for my device. The bus had not been probed yet and hence dev->seq was -1 and the device also had dev->req_seq set to -1.
The board is using a device tree hence it would only make sense to set the requested sequence number via the device tree. However, there is no such thing and even if there was it might not be specified.
Consequently, the device was never probed although the driver was correctly set up via device tree.
I worked around it by simply setting dev->req_seq of the first device that had it set to -1 to the sequence number the search function was looking for (see patch below). It solved my problem but I don't know if that is the right way of addressing it. I could not find any other solution for this particular problem anywhere.
Rudi
Hi Rudolf,
Quoted 21 lines · Rudolf J Streif
I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP FlexSPI controller. U-Boot started correctly from the flash device but using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This error message is emitted by
spi_get_bus_and_cs()indrivers/spi/spi-uclass.c. I traced the issue touclass_get_device_by_seq()indrivers/core/uclass.c.The function first searches the device list for a device that already claimed the sequence number (
dev->seq). If not found it would look if a device requested that sequence number (dev->seq_req). That would always fail for my device. The bus had not been probed yet and hencedev->seqwas -1 and the device also haddev->req_seqset to -1.The board is using a device tree hence it would only make sense to set the requested sequence number via the device tree. However, there is no such thing and even if there was it might not be specified.
Consequently, the device was never probed although the driver was correctly set up via device tree.
Quoted 7 lines
I worked around it by simply setting
dev->req_seqof the first device that had it set to -1 to the sequence number the search function was looking for (see patch below). It solved my problem but I don't know if that is the right way of addressing it. I could not find any other solution for this particular problem anywhere.Rudi
You can put the SPI flash in the device tree with an alias pointing to it.. That is the intended way with driver model.
Regards,
SImon
Quoted 38 lines
From
0f05ab964fcc7d29d8d467e663d7daa72328cf66Mon Sep 17 00:00:00 2001
From: Rudolf J Streif <[email protected]>
Date: Tue, 17 Mar 2020 17:13:07 -0700
Subject: [PATCH] Fix issue with SPI device sequence numberIf the requested sequence number for a SPI device was -1 (any) then the device would never be probed. This fix simply assigns the sequence number asked for at probing to the device if it has not been probed yet and the requested sequence number is -1.
Signed-off-by Rudolf J Streif <[email protected]>--- drivers/core/uclass.c | 2 ++ 1 file changed, 2 insertions(+)drivers/core/uclass.c +2
-0@@ -310,6 +310,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, uclass_foreach_dev(dev, uc) {debug (" - %d %d '%s'\n" , dev->req_seq, dev->seq, dev->name); +if (find_req_seq && dev->req_seq ==-1 ) + dev->req_seq = seq_or_req_seq; if ((find_req_seq ? dev->req_seq : dev->seq) ==seq_or_req_seq) { *devp = dev;--
2.23.0
Hi Simon,
Thanks for your response.
Quoted 29 lines · Simon Glass
Hi Rudolf,
Quoted 26 lines · Rudolf J Streif
I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP FlexSPI controller. U-Boot started correctly from the flash device but using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This error message is emitted by
spi_get_bus_and_cs()indrivers/spi/spi-uclass.c. I traced the issue touclass_get_device_by_seq()indrivers/core/uclass.c.The function first searches the device list for a device that already claimed the sequence number (
dev->seq). If not found it would look if a device requested that sequence number (dev->seq_req). That would always fail for my device. The bus had not been probed yet and hencedev->seqwas -1 and the device also haddev->req_seqset to -1.The board is using a device tree hence it would only make sense to set the requested sequence number via the device tree. However, there is no such thing and even if there was it might not be specified.
Consequently, the device was never probed although the driver was correctly set up via device tree.
I worked around it by simply setting
dev->req_seqof the first device that had it set to -1 to the sequence number the search function was looking for (see patch below). It solved my problem but I don't know if that is the right way of addressing it. I could not find any other solution for this particular problem anywhere.
Quoted 3 lines
Quoted 1 line
Rudi
You can put the SPI flash in the device tree with an alias pointing to it.. That is the intended way with driver model.
The board I am using the the FSL/NXP LX2160A-RDB. The dts arch/arm/dts/fsl-lx2160a-rdb.dts defines:
?/ {
??????? model = "NXP Layerscape LX2160ARDB Board"; ??????? compatible = "fsl,lx2160ardb", "fsl,lx2160a";
??????? aliases {
??????????????? spi0 = &fspi;
??????? };
};
I am I missing something?
Regards,
Rudi
Quoted 43 lines
Regards,
SImonQuoted 37 lines
From
0f05ab964fcc7d29d8d467e663d7daa72328cf66Mon Sep 17 00:00:00 2001
From: Rudolf J Streif <[email protected]>
Date: Tue, 17 Mar 2020 17:13:07 -0700
Subject: [PATCH] Fix issue with SPI device sequence numberIf the requested sequence number for a SPI device was -1 (any) then the device would never be probed. This fix simply assigns the sequence number asked for at probing to the device if it has not been probed yet and the requested sequence number is -1.
Signed-off-by Rudolf J Streif <[email protected]>--- drivers/core/uclass.c | 2 ++ 1 file changed, 2 insertions(+)drivers/core/uclass.c +2
-0@@ -310,6 +310,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, uclass_foreach_dev(dev, uc) {debug (" - %d %d '%s'\n" , dev->req_seq, dev->seq, dev->name); +if (find_req_seq && dev->req_seq ==-1 ) + dev->req_seq = seq_or_req_seq; if ((find_req_seq ? dev->req_seq : dev->seq) ==seq_or_req_seq) { *devp = dev;--
2.23.0
Signature · 13 lines
----- Rudolf J Streif CEO/CTO ibeeto +1.855.442.3386 x700 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200512/f65221d7/attachment.sig>
Hi Rudolf,
Quoted 51 lines · Rudolf J Streif
Hi Simon,
Thanks for your response.
Quoted 29 lines · Simon Glass
Hi Rudolf,
Quoted 26 lines · Rudolf J Streif
I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP FlexSPI controller. U-Boot started correctly from the flash device but using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This error message is emitted by
spi_get_bus_and_cs()indrivers/spi/spi-uclass.c. I traced the issue touclass_get_device_by_seq()indrivers/core/uclass.c.The function first searches the device list for a device that already claimed the sequence number (
dev->seq). If not found it would look if a device requested that sequence number (dev->seq_req). That would always fail for my device. The bus had not been probed yet and hencedev->seqwas -1 and the device also haddev->req_seqset to -1.The board is using a device tree hence it would only make sense to set the requested sequence number via the device tree. However, there is no such thing and even if there was it might not be specified.
Consequently, the device was never probed although the driver was correctly set up via device tree.
I worked around it by simply setting
dev->req_seqof the first device that had it set to -1 to the sequence number the search function was looking for (see patch below). It solved my problem but I don't know if that is the right way of addressing it. I could not find any other solution for this particular problem anywhere.Quoted 3 lines
Quoted 1 line
Rudi
You can put the SPI flash in the device tree with an alias pointing to it.. That is the intended way with driver model.
The board I am using the the FSL/NXP LX2160A-RDB. The dts
arch/arm/dts/fsl-lx2160a-rdb.dtsdefines:/ { model = "NXP Layerscape LX2160ARDB Board"; compatible = "fsl,lx2160ardb", "fsl,lx2160a"; aliases { spi0 = &fspi; }; };
Quoted 1 line
I am I missing something?
That's SPI. I mean actually SPI flash, which would be a subnode of that,
Regards,
SImon