From 535556b2aa64966970ff75a8307549506a1a168a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:24 -0600 Subject: dm: scsi: Add support for driver-model block devices Add driver-model block-device support to the SCSI implementation. Signed-off-by: Simon Glass --- common/scsi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'common/scsi.c') diff --git a/common/scsi.c b/common/scsi.c index 5b6531f01b..8ac28dd416 100644 --- a/common/scsi.c +++ b/common/scsi.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -149,9 +150,17 @@ void scsi_setup_inquiry(ccb *pccb) pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ } +#ifdef CONFIG_BLK +static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer) +#else static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) +#endif { +#ifdef CONFIG_BLK + struct blk_desc *block_dev = dev_get_uclass_platdata(dev); +#endif int device = block_dev->devnum; lbaint_t start, blks; uintptr_t buf_addr; @@ -216,9 +225,17 @@ static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr, /* Almost the maximum amount of the scsi_ext command.. */ #define SCSI_MAX_WRITE_BLK 0xFFFF +#ifdef CONFIG_BLK +static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + const void *buffer) +#else static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) +#endif { +#ifdef CONFIG_BLK + struct blk_desc *block_dev = dev_get_uclass_platdata(dev); +#endif int device = block_dev->devnum; lbaint_t start, blks; uintptr_t buf_addr; @@ -469,8 +486,10 @@ void scsi_scan(int mode) scsi_dev_desc[i].if_type = IF_TYPE_SCSI; scsi_dev_desc[i].devnum = i; scsi_dev_desc[i].part_type = PART_TYPE_UNKNOWN; +#ifndef CONFIG_BLK scsi_dev_desc[i].block_read = scsi_read; scsi_dev_desc[i].block_write = scsi_write; +#endif } scsi_max_devs = 0; for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) { @@ -552,9 +571,22 @@ removable: #endif } +#ifdef CONFIG_BLK +static const struct blk_ops scsi_blk_ops = { + .read = scsi_read, + .write = scsi_write, +}; + +U_BOOT_DRIVER(scsi_blk) = { + .name = "scsi_blk", + .id = UCLASS_BLK, + .ops = &scsi_blk_ops, +}; +#else U_BOOT_LEGACY_BLK(scsi) = { .if_typename = "sata", .if_type = IF_TYPE_SCSI, .max_devs = CONFIG_SYS_SCSI_MAX_DEVICE, .desc = scsi_dev_desc, }; +#endif -- cgit v1.2.1