]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
xilinx: versal-net: Handle spi seq number based on boot device
authorVenkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Fri, 14 Jun 2024 12:48:11 +0000 (18:18 +0530)
committerMichal Simek <michal.simek@amd.com>
Mon, 5 Aug 2024 14:10:36 +0000 (16:10 +0200)
Versal NET boards has QSPI and OSPI and default bus set to 0
is not working when system is booting out of OSPI which is
controller 1, as fixed aliases are set for all the boards
i.e., QSPI to 0 and OSPI to 1. Add controller autodetection
via spi_get_env_dev().

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Link: https://lore.kernel.org/r/20240614124811.22945-3-venkatesh.abbarapu@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
board/xilinx/versal-net/board.c

index 88e10fa7a7fae1a132fb944358a3273a597e74e0..1d67e3f31859bd9385febd08643e580398a2d9d7 100644 (file)
@@ -193,6 +193,51 @@ static u8 versal_net_get_bootmode(void)
        return bootmode;
 }
 
+int spi_get_env_dev(void)
+{
+       struct udevice *dev;
+       const char *mode = NULL;
+       int bootseq = -1;
+
+       switch (versal_net_get_bootmode()) {
+       case QSPI_MODE_24BIT:
+               puts("QSPI_MODE_24\n");
+               if (uclass_get_device_by_name(UCLASS_SPI,
+                                             "spi@f1030000", &dev)) {
+                       debug("QSPI driver for QSPI device is not present\n");
+                       break;
+               }
+               mode = "xspi";
+               bootseq = dev_seq(dev);
+               break;
+       case QSPI_MODE_32BIT:
+               puts("QSPI_MODE_32\n");
+               if (uclass_get_device_by_name(UCLASS_SPI,
+                                             "spi@f1030000", &dev)) {
+                       debug("QSPI driver for QSPI device is not present\n");
+                       break;
+               }
+               mode = "xspi";
+               bootseq = dev_seq(dev);
+               break;
+       case OSPI_MODE:
+               puts("OSPI_MODE\n");
+               if (uclass_get_device_by_name(UCLASS_SPI,
+                                             "spi@f1010000", &dev)) {
+                       debug("OSPI driver for OSPI device is not present\n");
+                       break;
+               }
+               mode = "xspi";
+               bootseq = dev_seq(dev);
+               break;
+       default:
+               break;
+       }
+
+       debug("bootseq %d\n", bootseq);
+       return bootseq;
+}
+
 static int boot_targets_setup(void)
 {
        u8 bootmode;