[U-Boot] [PATCH v2 04/11] scsi: Add dma direction member to command structure
Faiz Abbas
faiz_abbas at ti.com
Tue Oct 15 12:54:35 UTC 2019
Some SCSI devices like UFS use DMA for executing scsi commands and hence
need to know the direction of transfer of the dma. Add a dma_dir element
to the command structure to facilitate this.
Signed-off-by: Faiz Abbas <faiz_abbas at ti.com>
---
drivers/scsi/scsi.c | 4 ++++
include/scsi.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1256e22a52..58ee44053a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -168,6 +168,7 @@ static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
block_dev->devnum, start, blks, (unsigned long)buffer);
do {
pccb->pdata = (unsigned char *)buf_addr;
+ pccb->dma_dir = DMA_FROM_DEVICE;
#ifdef CONFIG_SYS_64BIT_LBA
if (start > SCSI_LBA48_READ) {
unsigned long blocks;
@@ -236,6 +237,7 @@ static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
__func__, block_dev->devnum, start, blks, (unsigned long)buffer);
do {
pccb->pdata = (unsigned char *)buf_addr;
+ pccb->dma_dir = DMA_TO_DEVICE;
if (blks > max_blks) {
pccb->datalen = block_dev->blksz * max_blks;
smallblks = max_blks;
@@ -383,6 +385,7 @@ static int scsi_read_capacity(struct udevice *dev, struct scsi_cmd *pccb,
pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */
pccb->datalen = 16;
+ pccb->dma_dir = DMA_FROM_DEVICE;
if (scsi_exec(dev, pccb))
return 1;
@@ -485,6 +488,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun,
pccb->lun = lun;
pccb->pdata = (unsigned char *)&tempbuff;
pccb->datalen = 512;
+ pccb->dma_dir = DMA_FROM_DEVICE;
scsi_setup_inquiry(pccb);
if (scsi_exec(dev, pccb)) {
if (pccb->contr_stat == SCSI_SEL_TIME_OUT) {
diff --git a/include/scsi.h b/include/scsi.h
index 963abe2b13..61da958bf6 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -6,6 +6,8 @@
#ifndef _SCSI_H
#define _SCSI_H
+#include <linux/dma-direction.h>
+
struct scsi_cmd {
unsigned char cmd[16]; /* command */
/* for request sense */
@@ -26,6 +28,7 @@ struct scsi_cmd {
unsigned long trans_bytes; /* tranfered bytes */
unsigned int priv;
+ enum dma_data_direction dma_dir;
};
/*-----------------------------------------------------------
--
2.19.2
More information about the U-Boot
mailing list