MLK-22293-5 env: Update SATA env location driver to use SCSI
authorYe Li <ye.li@nxp.com>
Tue, 23 Jul 2019 01:23:05 +0000 (18:23 -0700)
committerYe Li <ye.li@nxp.com>
Fri, 26 Jul 2019 02:47:16 +0000 (19:47 -0700)
When DM SCSI is enabled with AHCI, use SCSI device to replace SATA
device to access the peripheral.

Signed-off-by: Ye Li <ye.li@nxp.com>
env/sata.c

index 556ded5..7febbfd 100644 (file)
@@ -14,6 +14,9 @@
 #include <memalign.h>
 #include <sata.h>
 #include <search.h>
+#ifdef CONFIG_DM_SCSI
+#include <scsi.h>
+#endif
 
 #if defined(CONFIG_ENV_SIZE_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND)
 #error ENV REDUND not supported
@@ -48,12 +51,19 @@ static int env_sata_save(void)
        struct blk_desc *sata = NULL;
        int env_sata, ret;
 
+#ifndef CONFIG_DM_SCSI
        if (sata_initialize())
                return 1;
 
        env_sata = sata_get_env_dev();
 
        sata = sata_get_dev(env_sata);
+#else
+       scsi_scan(false);
+       env_sata = sata_get_env_dev();
+
+       sata = blk_get_dev("scsi", env_sata);
+#endif
        if (sata == NULL) {
                printf("Unknown SATA(%d) device for environment!\n",
                       env_sata);
@@ -94,12 +104,20 @@ static int env_sata_load(void)
        struct blk_desc *sata = NULL;
        int env_sata;
 
+#ifndef CONFIG_DM_SCSI
        if (sata_initialize())
                return -EIO;
 
        env_sata = sata_get_env_dev();
 
        sata = sata_get_dev(env_sata);
+#else
+       scsi_scan(false);
+       env_sata = sata_get_env_dev();
+
+       sata = blk_get_dev("scsi", env_sata);
+#endif
+
        if (sata == NULL) {
                printf("Unknown SATA(%d) device for environment!\n", env_sata);
                return -EIO;