arm64: zynqmp: Handle MMC seq number based on boot device
authorMichal Simek <michal.simek@xilinx.com>
Wed, 19 May 2021 13:16:19 +0000 (15:16 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 23 Jun 2021 07:48:35 +0000 (09:48 +0200)
K26 has EMMC and SD and default 0 is not working when system is booting out
of SD which is controller 1. Add controller autodetection via
mmc_get_env_dev(). The same code is used for distro_boot selection done in
board_late_init(). bootseq variable can't be reused because this is called
so late.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
board/xilinx/zynqmp/zynqmp.c
configs/xilinx_zynqmp_virt_defconfig

index d3c6826..208eade 100644 (file)
@@ -720,6 +720,41 @@ int checkboard(void)
        return 0;
 }
 
+int mmc_get_env_dev(void)
+{
+       struct udevice *dev;
+       int bootseq = 0;
+
+       switch (zynqmp_get_bootmode()) {
+       case EMMC_MODE:
+       case SD_MODE:
+               if (uclass_get_device_by_name(UCLASS_MMC,
+                                             "mmc@ff160000", &dev) &&
+                   uclass_get_device_by_name(UCLASS_MMC,
+                                             "sdhci@ff160000", &dev)) {
+                       return -1;
+               }
+               bootseq = dev_seq(dev);
+               break;
+       case SD1_LSHFT_MODE:
+       case SD_MODE1:
+               if (uclass_get_device_by_name(UCLASS_MMC,
+                                             "mmc@ff170000", &dev) &&
+                   uclass_get_device_by_name(UCLASS_MMC,
+                                             "sdhci@ff170000", &dev)) {
+                       return -1;
+               }
+               bootseq = dev_seq(dev);
+               break;
+       default:
+               break;
+       }
+
+       debug("bootseq %d\n", bootseq);
+
+       return bootseq;
+}
+
 enum env_location env_get_location(enum env_operation op, int prio)
 {
        u32 bootmode = zynqmp_get_bootmode();
index 997a2a7..5f250c0 100644 (file)
@@ -76,6 +76,7 @@ CONFIG_ENV_IS_IN_FAT=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_ENV_FAT_DEVICE_AND_PART=":auto"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y