Skip to content

Commit a3ec7fd

Browse files
committed
firehose: Add slot flag
For SoCs that support multiple UFS devices, firehose allows the slot property. This adds a flag to set the slot parameter. Signed-off-by: Jacob Creedon <[email protected]>
1 parent 661ca1c commit a3ec7fd

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

firehose.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
417417
xml_setpropf(node, "num_partition_sectors", "%d", program->num_sectors);
418418
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
419419
xml_setpropf(node, "start_sector", "%s", program->start_sector);
420+
if (qdl->slot != UINT_MAX) {
421+
xml_setpropf(node, "slot", "%u", qdl->slot);
422+
}
420423
if (program->is_nand) {
421424
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
422425
}
@@ -495,6 +498,9 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
495498
xml_setpropf(node, "num_partition_sectors", "%d", num_sectors);
496499
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
497500
xml_setpropf(node, "start_sector", "%s", program->start_sector);
501+
if (qdl->slot != UINT_MAX) {
502+
xml_setpropf(node, "slot", "%u", qdl->slot);
503+
}
498504
if (program->filename)
499505
xml_setpropf(node, "filename", "%s", program->filename);
500506

@@ -652,6 +658,9 @@ static int firehose_issue_read(struct qdl_device *qdl, struct read_op *read_op,
652658
xml_setpropf(node, "num_partition_sectors", "%d", read_op->num_sectors);
653659
xml_setpropf(node, "physical_partition_number", "%d", read_op->partition);
654660
xml_setpropf(node, "start_sector", "%s", read_op->start_sector);
661+
if (qdl->slot != UINT_MAX) {
662+
xml_setpropf(node, "slot", "%u", qdl->slot);
663+
}
655664
if (read_op->filename)
656665
xml_setpropf(node, "filename", "%s", read_op->filename);
657666

@@ -770,6 +779,9 @@ static int firehose_apply_patch(struct qdl_device *qdl, struct patch *patch)
770779
xml_setpropf(node, "size_in_bytes", "%d", patch->size_in_bytes);
771780
xml_setpropf(node, "start_sector", "%s", patch->start_sector);
772781
xml_setpropf(node, "value", "%s", patch->value);
782+
if (qdl->slot != UINT_MAX) {
783+
xml_setpropf(node, "slot", "%u", qdl->slot);
784+
}
773785

774786
ret = firehose_write(qdl, doc);
775787
if (ret < 0)
@@ -826,6 +838,9 @@ int firehose_apply_ufs_common(struct qdl_device *qdl, struct ufs_common *ufs)
826838
xml_setpropf(node_to_send, "bInitActiveICCLevel", "%d", ufs->bInitActiveICCLevel);
827839
xml_setpropf(node_to_send, "wPeriodicRTCUpdate", "%d", ufs->wPeriodicRTCUpdate);
828840
xml_setpropf(node_to_send, "bConfigDescrLock", "%d", ufs->bConfigDescrLock);
841+
if (qdl->slot != UINT_MAX) {
842+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
843+
}
829844

830845
if (ufs->wb) {
831846
xml_setpropf(node_to_send, "bWriteBoosterBufferPreserveUserSpaceEn",
@@ -858,6 +873,9 @@ int firehose_apply_ufs_body(struct qdl_device *qdl, struct ufs_body *ufs)
858873
xml_setpropf(node_to_send, "bLogicalBlockSize", "%d", ufs->bLogicalBlockSize);
859874
xml_setpropf(node_to_send, "bProvisioningType", "%d", ufs->bProvisioningType);
860875
xml_setpropf(node_to_send, "wContextCapabilities", "%d", ufs->wContextCapabilities);
876+
if (qdl->slot != UINT_MAX) {
877+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
878+
}
861879
if (ufs->desc)
862880
xml_setpropf(node_to_send, "desc", "%s", ufs->desc);
863881

@@ -878,6 +896,9 @@ int firehose_apply_ufs_epilogue(struct qdl_device *qdl, struct ufs_epilogue *ufs
878896

879897
xml_setpropf(node_to_send, "LUNtoGrow", "%d", ufs->LUNtoGrow);
880898
xml_setpropf(node_to_send, "commit", "%d", commit);
899+
if (qdl->slot != UINT_MAX) {
900+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
901+
}
881902

882903
ret = firehose_send_single_tag(qdl, node_to_send);
883904
if (ret)

qdl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ static void print_usage(FILE *out)
431431
fprintf(out, " -S, --serial=T\t\t\tSelect target by serial number T (e.g. <0AA94EFD>)\n");
432432
fprintf(out, " -u, --out-chunk-size=T\t\tOverride chunk size for transaction with T\n");
433433
fprintf(out, " -t, --create-digests=T\t\tGenerate table of digests in the T folder\n");
434+
fprintf(out, " -T, --slot=T\t\t\tSet slot number T for multiple storage devices\n");
434435
fprintf(out, " -D, --vip-table-path=T\t\tUse digest tables in the T folder for VIP\n");
435436
fprintf(out, " -h, --help\t\t\tPrint this usage info\n");
436437
fprintf(out, " <program-xml>\txml file containing <program> or <erase> directives\n");
@@ -459,6 +460,7 @@ int main(int argc, char **argv)
459460
bool allow_fusing = false;
460461
bool allow_missing = false;
461462
long out_chunk_size = 0;
463+
unsigned int slot = UINT_MAX;
462464
struct qdl_device *qdl = NULL;
463465
enum QDL_DEVICE_TYPE qdl_dev_type = QDL_DEVICE_USB;
464466

@@ -475,11 +477,12 @@ int main(int argc, char **argv)
475477
{"allow-fusing", no_argument, 0, 'c'},
476478
{"dry-run", no_argument, 0, 'n'},
477479
{"create-digests", required_argument, 0, 't'},
480+
{"slot", required_argument, 0, 'T'},
478481
{"help", no_argument, 0, 'h'},
479482
{0, 0, 0, 0}
480483
};
481484

482-
while ((opt = getopt_long(argc, argv, "dvi:lu:S:D:s:fcnt:h", options, NULL)) != -1) {
485+
while ((opt = getopt_long(argc, argv, "dvi:lu:S:D:s:fcnt:T:h", options, NULL)) != -1) {
483486
switch (opt) {
484487
case 'd':
485488
qdl_debug = true;
@@ -519,6 +522,9 @@ int main(int argc, char **argv)
519522
case 'D':
520523
vip_table_path = optarg;
521524
break;
525+
case 'T':
526+
slot = (unsigned int)strtoul(optarg, NULL, 10);
527+
break;
522528
case 'h':
523529
print_usage(stdout);
524530
return 0;
@@ -540,6 +546,8 @@ int main(int argc, char **argv)
540546
goto out_cleanup;
541547
}
542548

549+
qdl->slot = slot;
550+
543551
if (vip_table_path) {
544552
if (vip_generate_dir)
545553
errx(1, "VIP mode and VIP table generation can't be enabled together\n");

qdl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct qdl_device {
5656
size_t max_payload_size;
5757
size_t sector_size;
5858
enum qdl_storage_type storage_type;
59+
unsigned int slot;
5960

6061
int (*open)(struct qdl_device *qdl, const char *serial);
6162
int (*read)(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);

0 commit comments

Comments
 (0)