
From: Simon Glass <sjg@chromium.org> Newer SCSI controllers handle the LUN in a different place from the SCSI command. Detect this and adjust the command accordingly. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/scsi/scsi.c | 6 +++++- include/blk.h | 1 + include/scsi.h | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index df2d9666ec4..89c94f52d1d 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -41,7 +41,7 @@ static void scsi_setup_cmd(const struct blk_desc *desc, struct scsi_cmd *pccb, uint cmd) { pccb->cmd[0] = cmd; - pccb->cmd[1] = pccb->lun << 5; + pccb->cmd[1] = desc->no_lun ? 0 : pccb->lun << 5; } static void scsi_setup_read16(const struct blk_desc *desc, @@ -485,6 +485,9 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun, return -ENODEV; /* skip unknown devices */ if (resp->flags & SCSIRF_FLAGS_REMOVABLE) /* drive is removable */ desc->removable = true; + if (resp->eflags & EFLAGS_TPGS_MASK) + desc->no_lun = true; + /* get info for this device */ scsi_ident_cpy(desc->vendor, resp->vendor, sizeof(resp->vendor)); scsi_ident_cpy(desc->product, resp->product, sizeof(resp->product)); @@ -566,6 +569,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) bdesc->removable = bd.removable; bdesc->type = bd.type; bdesc->bb = bd.bb; + bdesc->no_lun = bd.no_lun; memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor)); memcpy(&bdesc->product, &bd.product, sizeof(bd.product)); memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision)); diff --git a/include/blk.h b/include/blk.h index 488d04cf32a..84c19ca887d 100644 --- a/include/blk.h +++ b/include/blk.h @@ -69,6 +69,7 @@ struct blk_desc { bool lba48; unsigned char atapi; /* Use ATAPI protocol */ unsigned char bb; /* Use bounce buffer */ + bool no_lun; /* Don't put LUN in the message */ lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ int log2blksz; /* for convenience: log2(blksz) */ diff --git a/include/scsi.h b/include/scsi.h index da4f1ed08b7..d746b0f2fcf 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -205,6 +205,8 @@ enum scsi_resp_t { SCSIRF_TYPE_UNKNOWN = 0x1f, SCSIRF_FLAGS_REMOVABLE = BIT(8), + + EFLAGS_TPGS_MASK = 0x30, /* LUN is sent in the transport layer */ }; /** @@ -215,7 +217,8 @@ enum scsi_resp_t { * @version; command version * @data_format; data format * @additional_len; additional data length - * @spare[3]; spare bytes + * @eflags: extra flags + * @spare[2]; spare bytes * @vendor[8]; vendor information * @product[16]; production information * @revision[4]; revision information @@ -226,7 +229,8 @@ struct scsi_inquiry_resp { u8 version; u8 data_format; u8 additional_len; - u8 spare[3]; + u8 eflags; + u8 spare[2]; char vendor[8]; char product[16]; char revision[4]; -- 2.43.0