Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2001 |
| 4 | * Denis Peter, MPL AG Switzerland |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | 1af3eed | 2023-01-17 10:47:43 -0700 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_SCSI |
| 8 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 9 | #include <common.h> |
Simon Glass | 655306c | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 10 | #include <blk.h> |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 11 | #include <bootdev.h> |
Simon Glass | 1ea9789 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 12 | #include <bootstage.h> |
Simon Glass | 5bf96dc | 2016-05-01 11:36:24 -0600 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | 07dc93c | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 14 | #include <env.h> |
Stefan Roese | c52ee3e | 2021-04-07 09:12:36 +0200 | [diff] [blame] | 15 | #include <libata.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 16 | #include <log.h> |
Marek Vasut | 60b20b4 | 2023-08-07 02:26:12 +0200 | [diff] [blame] | 17 | #include <memalign.h> |
Simon Glass | 655306c | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 18 | #include <part.h> |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 19 | #include <pci.h> |
| 20 | #include <scsi.h> |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 21 | #include <dm/device-internal.h> |
| 22 | #include <dm/uclass-internal.h> |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 23 | |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 24 | static struct scsi_cmd tempccb; /* temporary scsi command buffer */ |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 25 | |
Marek Vasut | 60b20b4 | 2023-08-07 02:26:12 +0200 | [diff] [blame] | 26 | DEFINE_CACHE_ALIGN_BUFFER(u8, tempbuff, 512); /* temporary data buffer */ |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 27 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 28 | /* almost the maximum amount of the scsi_ext command.. */ |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 29 | #define SCSI_MAX_BLK 0xFFFF |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 30 | #define SCSI_LBA48_READ 0xFFFFFFF |
| 31 | |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 32 | static void scsi_print_error(struct scsi_cmd *pccb) |
Simon Glass | 1674098 | 2017-06-14 21:28:23 -0600 | [diff] [blame] | 33 | { |
| 34 | /* Dummy function that could print an error for debugging */ |
| 35 | } |
| 36 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 37 | #ifdef CONFIG_SYS_64BIT_LBA |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 38 | void scsi_setup_read16(struct scsi_cmd *pccb, lbaint_t start, |
| 39 | unsigned long blocks) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 40 | { |
| 41 | pccb->cmd[0] = SCSI_READ16; |
| 42 | pccb->cmd[1] = pccb->lun << 5; |
| 43 | pccb->cmd[2] = (unsigned char)(start >> 56) & 0xff; |
| 44 | pccb->cmd[3] = (unsigned char)(start >> 48) & 0xff; |
| 45 | pccb->cmd[4] = (unsigned char)(start >> 40) & 0xff; |
| 46 | pccb->cmd[5] = (unsigned char)(start >> 32) & 0xff; |
| 47 | pccb->cmd[6] = (unsigned char)(start >> 24) & 0xff; |
| 48 | pccb->cmd[7] = (unsigned char)(start >> 16) & 0xff; |
| 49 | pccb->cmd[8] = (unsigned char)(start >> 8) & 0xff; |
| 50 | pccb->cmd[9] = (unsigned char)start & 0xff; |
| 51 | pccb->cmd[10] = 0; |
| 52 | pccb->cmd[11] = (unsigned char)(blocks >> 24) & 0xff; |
| 53 | pccb->cmd[12] = (unsigned char)(blocks >> 16) & 0xff; |
| 54 | pccb->cmd[13] = (unsigned char)(blocks >> 8) & 0xff; |
| 55 | pccb->cmd[14] = (unsigned char)blocks & 0xff; |
| 56 | pccb->cmd[15] = 0; |
| 57 | pccb->cmdlen = 16; |
| 58 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 59 | debug("scsi_setup_read16: cmd: %02X %02X startblk %02X%02X%02X%02X%02X%02X%02X%02X blccnt %02X%02X%02X%02X\n", |
| 60 | pccb->cmd[0], pccb->cmd[1], |
| 61 | pccb->cmd[2], pccb->cmd[3], pccb->cmd[4], pccb->cmd[5], |
| 62 | pccb->cmd[6], pccb->cmd[7], pccb->cmd[8], pccb->cmd[9], |
| 63 | pccb->cmd[11], pccb->cmd[12], pccb->cmd[13], pccb->cmd[14]); |
| 64 | } |
| 65 | #endif |
| 66 | |
Faiz Abbas | 76a6fa6 | 2019-10-15 18:24:32 +0530 | [diff] [blame] | 67 | static void scsi_setup_inquiry(struct scsi_cmd *pccb) |
| 68 | { |
| 69 | pccb->cmd[0] = SCSI_INQUIRY; |
| 70 | pccb->cmd[1] = pccb->lun << 5; |
| 71 | pccb->cmd[2] = 0; |
| 72 | pccb->cmd[3] = 0; |
| 73 | if (pccb->datalen > 255) |
| 74 | pccb->cmd[4] = 255; |
| 75 | else |
| 76 | pccb->cmd[4] = (unsigned char)pccb->datalen; |
| 77 | pccb->cmd[5] = 0; |
| 78 | pccb->cmdlen = 6; |
| 79 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 80 | } |
| 81 | |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 82 | static void scsi_setup_read_ext(struct scsi_cmd *pccb, lbaint_t start, |
Michal Simek | 9ec32f3 | 2016-11-30 11:53:43 +0100 | [diff] [blame] | 83 | unsigned short blocks) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 84 | { |
| 85 | pccb->cmd[0] = SCSI_READ10; |
| 86 | pccb->cmd[1] = pccb->lun << 5; |
| 87 | pccb->cmd[2] = (unsigned char)(start >> 24) & 0xff; |
| 88 | pccb->cmd[3] = (unsigned char)(start >> 16) & 0xff; |
| 89 | pccb->cmd[4] = (unsigned char)(start >> 8) & 0xff; |
| 90 | pccb->cmd[5] = (unsigned char)start & 0xff; |
| 91 | pccb->cmd[6] = 0; |
| 92 | pccb->cmd[7] = (unsigned char)(blocks >> 8) & 0xff; |
| 93 | pccb->cmd[8] = (unsigned char)blocks & 0xff; |
| 94 | pccb->cmd[6] = 0; |
| 95 | pccb->cmdlen = 10; |
| 96 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 97 | debug("scsi_setup_read_ext: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n", |
| 98 | pccb->cmd[0], pccb->cmd[1], |
| 99 | pccb->cmd[2], pccb->cmd[3], pccb->cmd[4], pccb->cmd[5], |
| 100 | pccb->cmd[7], pccb->cmd[8]); |
| 101 | } |
| 102 | |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 103 | static void scsi_setup_write_ext(struct scsi_cmd *pccb, lbaint_t start, |
Michal Simek | 9ec32f3 | 2016-11-30 11:53:43 +0100 | [diff] [blame] | 104 | unsigned short blocks) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 105 | { |
| 106 | pccb->cmd[0] = SCSI_WRITE10; |
| 107 | pccb->cmd[1] = pccb->lun << 5; |
| 108 | pccb->cmd[2] = (unsigned char)(start >> 24) & 0xff; |
| 109 | pccb->cmd[3] = (unsigned char)(start >> 16) & 0xff; |
| 110 | pccb->cmd[4] = (unsigned char)(start >> 8) & 0xff; |
| 111 | pccb->cmd[5] = (unsigned char)start & 0xff; |
| 112 | pccb->cmd[6] = 0; |
| 113 | pccb->cmd[7] = ((unsigned char)(blocks >> 8)) & 0xff; |
| 114 | pccb->cmd[8] = (unsigned char)blocks & 0xff; |
| 115 | pccb->cmd[9] = 0; |
| 116 | pccb->cmdlen = 10; |
| 117 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 118 | debug("%s: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n", |
| 119 | __func__, |
| 120 | pccb->cmd[0], pccb->cmd[1], |
| 121 | pccb->cmd[2], pccb->cmd[3], pccb->cmd[4], pccb->cmd[5], |
| 122 | pccb->cmd[7], pccb->cmd[8]); |
| 123 | } |
| 124 | |
Simon Glass | 5bf96dc | 2016-05-01 11:36:24 -0600 | [diff] [blame] | 125 | static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 126 | void *buffer) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 127 | { |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 128 | struct blk_desc *block_dev = dev_get_uclass_plat(dev); |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 129 | struct udevice *bdev = dev->parent; |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 130 | struct scsi_plat *uc_plat = dev_get_uclass_plat(bdev); |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 131 | lbaint_t start, blks, max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 132 | uintptr_t buf_addr; |
| 133 | unsigned short smallblks = 0; |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 134 | struct scsi_cmd *pccb = (struct scsi_cmd *)&tempccb; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 135 | |
| 136 | /* Setup device */ |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 137 | pccb->target = block_dev->target; |
| 138 | pccb->lun = block_dev->lun; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 139 | buf_addr = (unsigned long)buffer; |
| 140 | start = blknr; |
| 141 | blks = blkcnt; |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 142 | if (uc_plat->max_bytes_per_req) |
| 143 | max_blks = uc_plat->max_bytes_per_req / block_dev->blksz; |
| 144 | else |
| 145 | max_blks = SCSI_MAX_BLK; |
| 146 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 147 | debug("\nscsi_read: dev %d startblk " LBAF |
| 148 | ", blccnt " LBAF " buffer %lx\n", |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 149 | block_dev->devnum, start, blks, (unsigned long)buffer); |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 150 | do { |
| 151 | pccb->pdata = (unsigned char *)buf_addr; |
Faiz Abbas | 2094809 | 2019-10-15 18:24:35 +0530 | [diff] [blame] | 152 | pccb->dma_dir = DMA_FROM_DEVICE; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 153 | #ifdef CONFIG_SYS_64BIT_LBA |
| 154 | if (start > SCSI_LBA48_READ) { |
| 155 | unsigned long blocks; |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 156 | blocks = min_t(lbaint_t, blks, max_blks); |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 157 | pccb->datalen = block_dev->blksz * blocks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 158 | scsi_setup_read16(pccb, start, blocks); |
| 159 | start += blocks; |
| 160 | blks -= blocks; |
| 161 | } else |
| 162 | #endif |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 163 | if (blks > max_blks) { |
| 164 | pccb->datalen = block_dev->blksz * max_blks; |
| 165 | smallblks = max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 166 | scsi_setup_read_ext(pccb, start, smallblks); |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 167 | start += max_blks; |
| 168 | blks -= max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 169 | } else { |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 170 | pccb->datalen = block_dev->blksz * blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 171 | smallblks = (unsigned short)blks; |
| 172 | scsi_setup_read_ext(pccb, start, smallblks); |
| 173 | start += blks; |
| 174 | blks = 0; |
| 175 | } |
| 176 | debug("scsi_read_ext: startblk " LBAF |
Masahiro Yamada | c7570a3 | 2018-08-06 20:47:40 +0900 | [diff] [blame] | 177 | ", blccnt %x buffer %lX\n", |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 178 | start, smallblks, buf_addr); |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 179 | if (scsi_exec(bdev, pccb)) { |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 180 | scsi_print_error(pccb); |
| 181 | blkcnt -= blks; |
| 182 | break; |
| 183 | } |
| 184 | buf_addr += pccb->datalen; |
| 185 | } while (blks != 0); |
| 186 | debug("scsi_read_ext: end startblk " LBAF |
Masahiro Yamada | c7570a3 | 2018-08-06 20:47:40 +0900 | [diff] [blame] | 187 | ", blccnt %x buffer %lX\n", start, smallblks, buf_addr); |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 188 | return blkcnt; |
| 189 | } |
| 190 | |
| 191 | /******************************************************************************* |
| 192 | * scsi_write |
| 193 | */ |
| 194 | |
Simon Glass | 5bf96dc | 2016-05-01 11:36:24 -0600 | [diff] [blame] | 195 | static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 196 | const void *buffer) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 197 | { |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 198 | struct blk_desc *block_dev = dev_get_uclass_plat(dev); |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 199 | struct udevice *bdev = dev->parent; |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 200 | struct scsi_plat *uc_plat = dev_get_uclass_plat(bdev); |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 201 | lbaint_t start, blks, max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 202 | uintptr_t buf_addr; |
| 203 | unsigned short smallblks; |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 204 | struct scsi_cmd *pccb = (struct scsi_cmd *)&tempccb; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 205 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 206 | /* Setup device */ |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 207 | pccb->target = block_dev->target; |
| 208 | pccb->lun = block_dev->lun; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 209 | buf_addr = (unsigned long)buffer; |
| 210 | start = blknr; |
| 211 | blks = blkcnt; |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 212 | if (uc_plat->max_bytes_per_req) |
| 213 | max_blks = uc_plat->max_bytes_per_req / block_dev->blksz; |
| 214 | else |
| 215 | max_blks = SCSI_MAX_BLK; |
| 216 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 217 | debug("\n%s: dev %d startblk " LBAF ", blccnt " LBAF " buffer %lx\n", |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 218 | __func__, block_dev->devnum, start, blks, (unsigned long)buffer); |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 219 | do { |
| 220 | pccb->pdata = (unsigned char *)buf_addr; |
Faiz Abbas | 2094809 | 2019-10-15 18:24:35 +0530 | [diff] [blame] | 221 | pccb->dma_dir = DMA_TO_DEVICE; |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 222 | if (blks > max_blks) { |
| 223 | pccb->datalen = block_dev->blksz * max_blks; |
| 224 | smallblks = max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 225 | scsi_setup_write_ext(pccb, start, smallblks); |
Faiz Abbas | b26c614 | 2019-10-15 18:24:33 +0530 | [diff] [blame] | 226 | start += max_blks; |
| 227 | blks -= max_blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 228 | } else { |
Michal Simek | de6840a | 2016-11-18 16:22:42 +0100 | [diff] [blame] | 229 | pccb->datalen = block_dev->blksz * blks; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 230 | smallblks = (unsigned short)blks; |
| 231 | scsi_setup_write_ext(pccb, start, smallblks); |
| 232 | start += blks; |
| 233 | blks = 0; |
| 234 | } |
Masahiro Yamada | c7570a3 | 2018-08-06 20:47:40 +0900 | [diff] [blame] | 235 | debug("%s: startblk " LBAF ", blccnt %x buffer %lx\n", |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 236 | __func__, start, smallblks, buf_addr); |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 237 | if (scsi_exec(bdev, pccb)) { |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 238 | scsi_print_error(pccb); |
| 239 | blkcnt -= blks; |
| 240 | break; |
| 241 | } |
| 242 | buf_addr += pccb->datalen; |
| 243 | } while (blks != 0); |
Masahiro Yamada | c7570a3 | 2018-08-06 20:47:40 +0900 | [diff] [blame] | 244 | debug("%s: end startblk " LBAF ", blccnt %x buffer %lX\n", |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 245 | __func__, start, smallblks, buf_addr); |
| 246 | return blkcnt; |
| 247 | } |
Marek Vasut | b980e21 | 2023-08-14 01:50:00 +0200 | [diff] [blame] | 248 | |
| 249 | #if IS_ENABLED(CONFIG_BOUNCE_BUFFER) |
| 250 | static int scsi_buffer_aligned(struct udevice *dev, struct bounce_buffer *state) |
| 251 | { |
| 252 | struct scsi_ops *ops = scsi_get_ops(dev->parent); |
| 253 | |
| 254 | if (ops->buffer_aligned) |
| 255 | return ops->buffer_aligned(dev->parent, state); |
| 256 | |
| 257 | return 1; |
| 258 | } |
| 259 | #endif /* CONFIG_BOUNCE_BUFFER */ |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 260 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 261 | /* copy src to dest, skipping leading and trailing blanks |
| 262 | * and null terminate the string |
| 263 | */ |
Michal Simek | 9ec32f3 | 2016-11-30 11:53:43 +0100 | [diff] [blame] | 264 | static void scsi_ident_cpy(unsigned char *dest, unsigned char *src, |
| 265 | unsigned int len) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 266 | { |
| 267 | int start, end; |
| 268 | |
| 269 | start = 0; |
| 270 | while (start < len) { |
| 271 | if (src[start] != ' ') |
| 272 | break; |
| 273 | start++; |
| 274 | } |
| 275 | end = len-1; |
| 276 | while (end > start) { |
| 277 | if (src[end] != ' ') |
| 278 | break; |
| 279 | end--; |
| 280 | } |
| 281 | for (; start <= end; start++) |
| 282 | *dest ++= src[start]; |
| 283 | *dest = '\0'; |
| 284 | } |
| 285 | |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 286 | static int scsi_read_capacity(struct udevice *dev, struct scsi_cmd *pccb, |
| 287 | lbaint_t *capacity, unsigned long *blksz) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 288 | { |
| 289 | *capacity = 0; |
| 290 | |
| 291 | memset(pccb->cmd, '\0', sizeof(pccb->cmd)); |
| 292 | pccb->cmd[0] = SCSI_RD_CAPAC10; |
| 293 | pccb->cmd[1] = pccb->lun << 5; |
| 294 | pccb->cmdlen = 10; |
Nikita Yushchenko | ef793ee | 2023-11-13 11:51:02 +0600 | [diff] [blame] | 295 | pccb->dma_dir = DMA_FROM_DEVICE; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 296 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 297 | |
| 298 | pccb->datalen = 8; |
Simon Glass | a140e86 | 2017-06-14 21:28:44 -0600 | [diff] [blame] | 299 | if (scsi_exec(dev, pccb)) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 300 | return 1; |
| 301 | |
| 302 | *capacity = ((lbaint_t)pccb->pdata[0] << 24) | |
| 303 | ((lbaint_t)pccb->pdata[1] << 16) | |
| 304 | ((lbaint_t)pccb->pdata[2] << 8) | |
| 305 | ((lbaint_t)pccb->pdata[3]); |
| 306 | |
| 307 | if (*capacity != 0xffffffff) { |
| 308 | /* Read capacity (10) was sufficient for this drive. */ |
| 309 | *blksz = ((unsigned long)pccb->pdata[4] << 24) | |
| 310 | ((unsigned long)pccb->pdata[5] << 16) | |
| 311 | ((unsigned long)pccb->pdata[6] << 8) | |
| 312 | ((unsigned long)pccb->pdata[7]); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | /* Read capacity (10) was insufficient. Use read capacity (16). */ |
| 317 | memset(pccb->cmd, '\0', sizeof(pccb->cmd)); |
| 318 | pccb->cmd[0] = SCSI_RD_CAPAC16; |
| 319 | pccb->cmd[1] = 0x10; |
| 320 | pccb->cmdlen = 16; |
| 321 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 322 | |
| 323 | pccb->datalen = 16; |
Faiz Abbas | 2094809 | 2019-10-15 18:24:35 +0530 | [diff] [blame] | 324 | pccb->dma_dir = DMA_FROM_DEVICE; |
Simon Glass | a140e86 | 2017-06-14 21:28:44 -0600 | [diff] [blame] | 325 | if (scsi_exec(dev, pccb)) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 326 | return 1; |
| 327 | |
| 328 | *capacity = ((uint64_t)pccb->pdata[0] << 56) | |
| 329 | ((uint64_t)pccb->pdata[1] << 48) | |
| 330 | ((uint64_t)pccb->pdata[2] << 40) | |
| 331 | ((uint64_t)pccb->pdata[3] << 32) | |
| 332 | ((uint64_t)pccb->pdata[4] << 24) | |
| 333 | ((uint64_t)pccb->pdata[5] << 16) | |
| 334 | ((uint64_t)pccb->pdata[6] << 8) | |
| 335 | ((uint64_t)pccb->pdata[7]); |
| 336 | |
| 337 | *blksz = ((uint64_t)pccb->pdata[8] << 56) | |
| 338 | ((uint64_t)pccb->pdata[9] << 48) | |
| 339 | ((uint64_t)pccb->pdata[10] << 40) | |
| 340 | ((uint64_t)pccb->pdata[11] << 32) | |
| 341 | ((uint64_t)pccb->pdata[12] << 24) | |
| 342 | ((uint64_t)pccb->pdata[13] << 16) | |
| 343 | ((uint64_t)pccb->pdata[14] << 8) | |
| 344 | ((uint64_t)pccb->pdata[15]); |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | |
| 350 | /* |
| 351 | * Some setup (fill-in) routines |
| 352 | */ |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 353 | static void scsi_setup_test_unit_ready(struct scsi_cmd *pccb) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 354 | { |
| 355 | pccb->cmd[0] = SCSI_TST_U_RDY; |
| 356 | pccb->cmd[1] = pccb->lun << 5; |
| 357 | pccb->cmd[2] = 0; |
| 358 | pccb->cmd[3] = 0; |
| 359 | pccb->cmd[4] = 0; |
| 360 | pccb->cmd[5] = 0; |
| 361 | pccb->cmdlen = 6; |
| 362 | pccb->msgout[0] = SCSI_IDENTIFY; /* NOT USED */ |
| 363 | } |
| 364 | |
Michal Simek | 6241b52 | 2016-11-30 12:50:58 +0100 | [diff] [blame] | 365 | /** |
| 366 | * scsi_init_dev_desc_priv - initialize only SCSI specific blk_desc properties |
| 367 | * |
| 368 | * @dev_desc: Block device description pointer |
| 369 | */ |
| 370 | static void scsi_init_dev_desc_priv(struct blk_desc *dev_desc) |
Michal Simek | ac0a18d1 | 2016-11-18 15:27:00 +0100 | [diff] [blame] | 371 | { |
Tom Rini | 0154cfe | 2023-11-08 14:28:11 -0500 | [diff] [blame] | 372 | memset(dev_desc, 0, sizeof(struct blk_desc)); |
Michal Simek | ac0a18d1 | 2016-11-18 15:27:00 +0100 | [diff] [blame] | 373 | dev_desc->target = 0xff; |
| 374 | dev_desc->lun = 0xff; |
Michal Simek | ac0a18d1 | 2016-11-18 15:27:00 +0100 | [diff] [blame] | 375 | dev_desc->log2blksz = |
| 376 | LOG2_INVALID(typeof(dev_desc->log2blksz)); |
| 377 | dev_desc->type = DEV_TYPE_UNKNOWN; |
Johan Jonker | 10a986c | 2023-10-18 16:01:10 +0200 | [diff] [blame] | 378 | #if IS_ENABLED(CONFIG_BOUNCE_BUFFER) |
| 379 | dev_desc->bb = true; |
| 380 | #endif /* CONFIG_BOUNCE_BUFFER */ |
Michal Simek | ac0a18d1 | 2016-11-18 15:27:00 +0100 | [diff] [blame] | 381 | } |
| 382 | |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 383 | /** |
| 384 | * scsi_detect_dev - Detect scsi device |
| 385 | * |
Michal Simek | 4091749 | 2016-11-18 16:14:24 +0100 | [diff] [blame] | 386 | * @target: target id |
Jean-Jacques Hiblot | 0c447f0 | 2017-04-07 13:42:06 +0200 | [diff] [blame] | 387 | * @lun: target lun |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 388 | * @dev_desc: block device description |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 389 | * |
| 390 | * The scsi_detect_dev detects and fills a dev_desc structure when the device is |
Jean-Jacques Hiblot | 0c447f0 | 2017-04-07 13:42:06 +0200 | [diff] [blame] | 391 | * detected. |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 392 | * |
| 393 | * Return: 0 on success, error value otherwise |
| 394 | */ |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 395 | static int scsi_detect_dev(struct udevice *dev, int target, int lun, |
| 396 | struct blk_desc *dev_desc) |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 397 | { |
| 398 | unsigned char perq, modi; |
| 399 | lbaint_t capacity; |
| 400 | unsigned long blksz; |
Simon Glass | 5fb559d | 2017-06-14 21:28:30 -0600 | [diff] [blame] | 401 | struct scsi_cmd *pccb = (struct scsi_cmd *)&tempccb; |
Faiz Abbas | 3645a48 | 2019-10-15 18:24:34 +0530 | [diff] [blame] | 402 | int count, err; |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 403 | |
Michal Simek | 4091749 | 2016-11-18 16:14:24 +0100 | [diff] [blame] | 404 | pccb->target = target; |
Jean-Jacques Hiblot | 0c447f0 | 2017-04-07 13:42:06 +0200 | [diff] [blame] | 405 | pccb->lun = lun; |
Marek Vasut | 60b20b4 | 2023-08-07 02:26:12 +0200 | [diff] [blame] | 406 | pccb->pdata = tempbuff; |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 407 | pccb->datalen = 512; |
Faiz Abbas | 2094809 | 2019-10-15 18:24:35 +0530 | [diff] [blame] | 408 | pccb->dma_dir = DMA_FROM_DEVICE; |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 409 | scsi_setup_inquiry(pccb); |
Simon Glass | a140e86 | 2017-06-14 21:28:44 -0600 | [diff] [blame] | 410 | if (scsi_exec(dev, pccb)) { |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 411 | if (pccb->contr_stat == SCSI_SEL_TIME_OUT) { |
| 412 | /* |
| 413 | * selection timeout => assuming no |
| 414 | * device present |
| 415 | */ |
| 416 | debug("Selection timeout ID %d\n", |
| 417 | pccb->target); |
| 418 | return -ETIMEDOUT; |
| 419 | } |
| 420 | scsi_print_error(pccb); |
| 421 | return -ENODEV; |
| 422 | } |
| 423 | perq = tempbuff[0]; |
| 424 | modi = tempbuff[1]; |
| 425 | if ((perq & 0x1f) == 0x1f) |
| 426 | return -ENODEV; /* skip unknown devices */ |
| 427 | if ((modi & 0x80) == 0x80) /* drive is removable */ |
| 428 | dev_desc->removable = true; |
| 429 | /* get info for this device */ |
| 430 | scsi_ident_cpy((unsigned char *)dev_desc->vendor, |
| 431 | &tempbuff[8], 8); |
| 432 | scsi_ident_cpy((unsigned char *)dev_desc->product, |
| 433 | &tempbuff[16], 16); |
| 434 | scsi_ident_cpy((unsigned char *)dev_desc->revision, |
| 435 | &tempbuff[32], 4); |
| 436 | dev_desc->target = pccb->target; |
| 437 | dev_desc->lun = pccb->lun; |
| 438 | |
Faiz Abbas | 3645a48 | 2019-10-15 18:24:34 +0530 | [diff] [blame] | 439 | for (count = 0; count < 3; count++) { |
| 440 | pccb->datalen = 0; |
Nikita Yushchenko | ef793ee | 2023-11-13 11:51:02 +0600 | [diff] [blame] | 441 | pccb->dma_dir = DMA_NONE; |
Faiz Abbas | 3645a48 | 2019-10-15 18:24:34 +0530 | [diff] [blame] | 442 | scsi_setup_test_unit_ready(pccb); |
| 443 | err = scsi_exec(dev, pccb); |
| 444 | if (!err) |
| 445 | break; |
| 446 | } |
| 447 | if (err) { |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 448 | if (dev_desc->removable) { |
| 449 | dev_desc->type = perq; |
| 450 | goto removable; |
| 451 | } |
| 452 | scsi_print_error(pccb); |
| 453 | return -EINVAL; |
| 454 | } |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 455 | if (scsi_read_capacity(dev, pccb, &capacity, &blksz)) { |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 456 | scsi_print_error(pccb); |
| 457 | return -EINVAL; |
| 458 | } |
| 459 | dev_desc->lba = capacity; |
| 460 | dev_desc->blksz = blksz; |
| 461 | dev_desc->log2blksz = LOG2(dev_desc->blksz); |
| 462 | dev_desc->type = perq; |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 463 | removable: |
| 464 | return 0; |
| 465 | } |
| 466 | |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 467 | /* |
| 468 | * (re)-scan the scsi bus and reports scsi device info |
| 469 | * to the user if mode = 1 |
| 470 | */ |
Simon Glass | 4822873 | 2017-06-14 21:28:41 -0600 | [diff] [blame] | 471 | static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 472 | { |
| 473 | int ret; |
| 474 | struct udevice *bdev; |
| 475 | struct blk_desc bd; |
| 476 | struct blk_desc *bdesc; |
Simon Glass | 1af3eed | 2023-01-17 10:47:43 -0700 | [diff] [blame] | 477 | char str[10], *name; |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 478 | |
| 479 | /* |
| 480 | * detect the scsi driver to get information about its geometry (block |
| 481 | * size, number of blocks) and other parameters (ids, type, ...) |
| 482 | */ |
| 483 | scsi_init_dev_desc_priv(&bd); |
Simon Glass | 11b2b62 | 2017-06-14 21:28:40 -0600 | [diff] [blame] | 484 | if (scsi_detect_dev(dev, id, lun, &bd)) |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 485 | return -ENODEV; |
| 486 | |
| 487 | /* |
| 488 | * Create only one block device and do detection |
| 489 | * to make sure that there won't be a lot of |
| 490 | * block devices created |
| 491 | */ |
| 492 | snprintf(str, sizeof(str), "id%dlun%d", id, lun); |
Simon Glass | 1af3eed | 2023-01-17 10:47:43 -0700 | [diff] [blame] | 493 | name = strdup(str); |
| 494 | if (!name) |
| 495 | return log_msg_ret("nam", -ENOMEM); |
| 496 | ret = blk_create_devicef(dev, "scsi_blk", name, UCLASS_SCSI, -1, |
Simon Glass | dbfa32c | 2022-08-11 19:34:59 -0600 | [diff] [blame] | 497 | bd.blksz, bd.lba, &bdev); |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 498 | if (ret) { |
| 499 | debug("Can't create device\n"); |
| 500 | return ret; |
| 501 | } |
Simon Glass | 1af3eed | 2023-01-17 10:47:43 -0700 | [diff] [blame] | 502 | device_set_name_alloced(bdev); |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 503 | |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 504 | bdesc = dev_get_uclass_plat(bdev); |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 505 | bdesc->target = id; |
| 506 | bdesc->lun = lun; |
| 507 | bdesc->removable = bd.removable; |
| 508 | bdesc->type = bd.type; |
Johan Jonker | 10a986c | 2023-10-18 16:01:10 +0200 | [diff] [blame] | 509 | bdesc->bb = bd.bb; |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 510 | memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor)); |
| 511 | memcpy(&bdesc->product, &bd.product, sizeof(bd.product)); |
| 512 | memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision)); |
Stefan Roese | c52ee3e | 2021-04-07 09:12:36 +0200 | [diff] [blame] | 513 | if (IS_ENABLED(CONFIG_SYS_BIG_ENDIAN)) { |
| 514 | ata_swap_buf_le16((u16 *)&bdesc->vendor, sizeof(bd.vendor) / 2); |
| 515 | ata_swap_buf_le16((u16 *)&bdesc->product, sizeof(bd.product) / 2); |
| 516 | ata_swap_buf_le16((u16 *)&bdesc->revision, sizeof(bd.revision) / 2); |
| 517 | } |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 518 | |
AKASHI Takahiro | 368c3d5 | 2022-03-08 20:36:39 +0900 | [diff] [blame] | 519 | ret = blk_probe_or_unbind(bdev); |
| 520 | if (ret < 0) |
| 521 | /* TODO: undo create */ |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 522 | return log_msg_ret("pro", ret); |
| 523 | |
Simon Glass | b1d581d | 2023-07-30 11:15:14 -0600 | [diff] [blame] | 524 | ret = bootdev_setup_for_sibling_blk(bdev, "scsi_bootdev"); |
Simon Glass | 9985e9c | 2023-01-17 10:47:45 -0700 | [diff] [blame] | 525 | if (ret) |
| 526 | return log_msg_ret("bd", ret); |
AKASHI Takahiro | 368c3d5 | 2022-03-08 20:36:39 +0900 | [diff] [blame] | 527 | |
Simon Glass | 4822873 | 2017-06-14 21:28:41 -0600 | [diff] [blame] | 528 | if (verbose) { |
Heinrich Schuchardt | c5382b7 | 2019-02-05 18:06:24 +0100 | [diff] [blame] | 529 | printf(" Device %d: ", bdesc->devnum); |
Jean-Jacques Hiblot | cdf96eb | 2017-04-24 11:51:26 +0200 | [diff] [blame] | 530 | dev_print(bdesc); |
| 531 | } |
| 532 | return 0; |
| 533 | } |
| 534 | |
Simon Glass | 600d001 | 2017-06-14 21:28:45 -0600 | [diff] [blame] | 535 | int scsi_scan_dev(struct udevice *dev, bool verbose) |
| 536 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 537 | struct scsi_plat *uc_plat; /* scsi controller plat */ |
Simon Glass | 600d001 | 2017-06-14 21:28:45 -0600 | [diff] [blame] | 538 | int ret; |
| 539 | int i; |
| 540 | int lun; |
| 541 | |
| 542 | /* probe SCSI controller driver */ |
| 543 | ret = device_probe(dev); |
| 544 | if (ret) |
| 545 | return ret; |
| 546 | |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 547 | /* Get controller plat */ |
| 548 | uc_plat = dev_get_uclass_plat(dev); |
Simon Glass | 600d001 | 2017-06-14 21:28:45 -0600 | [diff] [blame] | 549 | |
| 550 | for (i = 0; i < uc_plat->max_id; i++) |
| 551 | for (lun = 0; lun < uc_plat->max_lun; lun++) |
| 552 | do_scsi_scan_one(dev, i, lun, verbose); |
| 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | |
Simon Glass | 4822873 | 2017-06-14 21:28:41 -0600 | [diff] [blame] | 557 | int scsi_scan(bool verbose) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 558 | { |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 559 | struct uclass *uc; |
| 560 | struct udevice *dev; /* SCSI controller */ |
Michal Simek | ebbde65 | 2016-11-18 15:42:13 +0100 | [diff] [blame] | 561 | int ret; |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 562 | |
Simon Glass | 4822873 | 2017-06-14 21:28:41 -0600 | [diff] [blame] | 563 | if (verbose) |
Simon Glass | c8e89ab | 2016-05-01 11:36:09 -0600 | [diff] [blame] | 564 | printf("scanning bus for devices...\n"); |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 565 | |
| 566 | ret = uclass_get(UCLASS_SCSI, &uc); |
| 567 | if (ret) |
| 568 | return ret; |
| 569 | |
Simon Glass | 01ed80a | 2023-01-17 10:47:44 -0700 | [diff] [blame] | 570 | /* remove all children of the SCSI devices */ |
| 571 | uclass_foreach_dev(dev, uc) { |
| 572 | log_debug("unbind %s\n", dev->name); |
| 573 | ret = device_chld_remove(dev, NULL, DM_REMOVE_NORMAL); |
| 574 | if (!ret) |
| 575 | ret = device_chld_unbind(dev, NULL); |
| 576 | if (ret) { |
| 577 | if (verbose) |
| 578 | printf("unable to unbind devices (%dE)\n", ret); |
| 579 | return log_msg_ret("unb", ret); |
| 580 | } |
| 581 | } |
| 582 | |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 583 | uclass_foreach_dev(dev, uc) { |
Simon Glass | 600d001 | 2017-06-14 21:28:45 -0600 | [diff] [blame] | 584 | ret = scsi_scan_dev(dev, verbose); |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 585 | if (ret) |
| 586 | return ret; |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | return 0; |
| 590 | } |
Michal Simek | c886f35 | 2016-09-08 15:06:45 +0200 | [diff] [blame] | 591 | |
Simon Glass | 5bf96dc | 2016-05-01 11:36:24 -0600 | [diff] [blame] | 592 | static const struct blk_ops scsi_blk_ops = { |
| 593 | .read = scsi_read, |
| 594 | .write = scsi_write, |
Marek Vasut | b980e21 | 2023-08-14 01:50:00 +0200 | [diff] [blame] | 595 | #if IS_ENABLED(CONFIG_BOUNCE_BUFFER) |
| 596 | .buffer_aligned = scsi_buffer_aligned, |
| 597 | #endif /* CONFIG_BOUNCE_BUFFER */ |
Simon Glass | 5bf96dc | 2016-05-01 11:36:24 -0600 | [diff] [blame] | 598 | }; |
| 599 | |
| 600 | U_BOOT_DRIVER(scsi_blk) = { |
| 601 | .name = "scsi_blk", |
| 602 | .id = UCLASS_BLK, |
| 603 | .ops = &scsi_blk_ops, |
| 604 | }; |