summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configs/qcom_qcs9100_defconfig2
-rw-r--r--drivers/scsi/scsi-uclass.c8
-rw-r--r--env/Kconfig30
-rw-r--r--env/scsi.c28
-rw-r--r--include/scsi.h5
5 files changed, 60 insertions, 13 deletions
diff --git a/configs/qcom_qcs9100_defconfig b/configs/qcom_qcs9100_defconfig
index 371448b8b1b..082106157bb 100644
--- a/configs/qcom_qcs9100_defconfig
+++ b/configs/qcom_qcs9100_defconfig
@@ -11,6 +11,6 @@ CONFIG_REMAKE_ELF=y
CONFIG_FASTBOOT_BUF_ADDR=0xdb300000
CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs9100-ride-r3"
CONFIG_ENV_IS_IN_SCSI=y
-CONFIG_SCSI_ENV_PART_UUID="71cb9cd0-acf1-b6cb-ad91-be9572fe11a9"
+CONFIG_ENV_SCSI_PART_UUID="71cb9cd0-acf1-b6cb-ad91-be9572fe11a9"
# CONFIG_ENV_IS_DEFAULT is not set
# CONFIG_ENV_IS_NOWHERE is not set
diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index 3eb6069649f..39b4c7476d4 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -29,15 +29,9 @@ int scsi_get_blk_by_uuid(const char *uuid,
struct blk_desc **blk_desc_ptr,
struct disk_partition *part_info_ptr)
{
- static int is_scsi_scanned;
struct blk_desc *blk;
int i, ret;
- if (!is_scsi_scanned) {
- scsi_scan(false /* no verbose */);
- is_scsi_scanned = 1;
- }
-
for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
ret = blk_get_desc(UCLASS_SCSI, i, &blk);
if (ret)
@@ -50,7 +44,7 @@ int scsi_get_blk_by_uuid(const char *uuid,
}
}
- return -1;
+ return -ENODEV;
}
int scsi_bus_reset(struct udevice *dev)
diff --git a/env/Kconfig b/env/Kconfig
index 532adf884da..7abd82ab6f3 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -294,6 +294,23 @@ config ENV_IS_IN_SCSI
Define this if you have an SCSI device which you want to use for the
environment.
+ - CONFIG_ENV_SIZE:
+
+ The size of the partition where the environment is stored in bytes. Must
+ be a multiple of the partition block size.
+
+ - CONFIG_ENV_SCSI_HW_PARTITION:
+
+ Specifies which SCSI partition the environment is stored in. If not
+ set, defaults to partition 0, the user area. Common values might be
+ 1 (first SCSI boot partition), 2 (second SCSI boot partition). Ignored
+ if CONFIG_ENV_SCSI_PART_UUID is set to non-empty string.
+
+ - CONFIG_ENV_SCSI_PART_UUID:
+
+ UUID of the SCSI partition where the environment is stored.
+
+
config ENV_RANGE
hex "Length of the region in which the environment can be written"
depends on ENV_IS_IN_NAND
@@ -763,7 +780,18 @@ config ENV_MMC_USE_DT
The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND
are not used as fallback.
-config SCSI_ENV_PART_UUID
+config ENV_SCSI_HW_PARTITION
+ string "SCSI hardware partition number"
+ depends on ENV_IS_IN_SCSI
+ default 0
+ help
+ SCSI hardware partition device number on the platform where the
+ environment is stored. Note that this is not related to any software
+ defined partition table but instead if we are in the user area, which is
+ partition 0 or the first boot partition, which is 1 or some other defined
+ partition.
+
+config ENV_SCSI_PART_UUID
string "SCSI partition UUID for saving environment"
depends on ENV_IS_IN_SCSI
help
diff --git a/env/scsi.c b/env/scsi.c
index e56891a9899..91a6c430302 100644
--- a/env/scsi.c
+++ b/env/scsi.c
@@ -33,10 +33,22 @@ static struct env_scsi_info env_part;
static inline struct env_scsi_info *env_scsi_get_part(void)
{
+ static bool is_scsi_scanned;
struct env_scsi_info *ep = &env_part;
- if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
- return NULL;
+ if (!is_scsi_scanned) {
+ scsi_scan(false /* no verbose */);
+ is_scsi_scanned = true;
+ }
+
+ if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0') {
+ if (blk_get_device_part_str("scsi", CONFIG_ENV_SCSI_HW_PARTITION,
+ &ep->blk, &ep->part, true))
+ return NULL;
+ } else {
+ if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
+ return NULL;
+ }
ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
@@ -83,12 +95,20 @@ static int env_scsi_load(void)
int ret;
if (!ep) {
- env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
+ if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
+ env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found", 0);
+ else
+ env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition not found", 0);
+
return -ENOENT;
}
if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
- env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
+ if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
+ env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed", 0);
+ else
+ env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition read failed", 0);
+
return -EIO;
}
diff --git a/include/scsi.h b/include/scsi.h
index 8d6c5116419..2520a8b8fe6 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -340,6 +340,7 @@ int scsi_bus_reset(struct udevice *dev);
* scsi_scan() - Scan all SCSI controllers for available devices
*
* @vebose: true to show information about each device found
+ * Return: 0 if OK, -ve on error
*/
int scsi_scan(bool verbose);
@@ -348,15 +349,19 @@ int scsi_scan(bool verbose);
*
* @dev: SCSI bus
* @verbose: true to show information about each device found
+ * Return: 0 if OK, -ve on error
*/
int scsi_scan_dev(struct udevice *dev, bool verbose);
/**
* scsi_get_blk_by_uuid() - Provides SCSI partition information.
*
+ * scsi_scan() must have been called before calling this function.
+ *
* @uuid: UUID of the partition for fetching its info
* @blk_desc_ptr: Provides the blk descriptor
* @part_info_ptr: Provides partition info
+ * Return: 0 if OK, -ve on error
*/
int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
struct disk_partition *part_info_ptr);