Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 10 | #include <malloc.h> |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 11 | #include <os.h> |
| 12 | #include <scsi.h> |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 13 | #include <scsi_emul.h> |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 14 | #include <usb.h> |
| 15 | |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 16 | /* |
| 17 | * This driver emulates a flash stick using the UFI command specification and |
| 18 | * the BBB (bulk/bulk/bulk) protocol. It supports only a single logical unit |
| 19 | * number (LUN 0). |
| 20 | */ |
| 21 | |
| 22 | enum { |
| 23 | SANDBOX_FLASH_EP_OUT = 1, /* endpoints */ |
| 24 | SANDBOX_FLASH_EP_IN = 2, |
| 25 | SANDBOX_FLASH_BLOCK_LEN = 512, |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 26 | SANDBOX_FLASH_BUF_SIZE = 512, |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 27 | }; |
| 28 | |
Simon Glass | 31d7816 | 2015-11-08 23:47:53 -0700 | [diff] [blame] | 29 | enum { |
| 30 | STRINGID_MANUFACTURER = 1, |
| 31 | STRINGID_PRODUCT, |
| 32 | STRINGID_SERIAL, |
| 33 | |
| 34 | STRINGID_COUNT, |
| 35 | }; |
| 36 | |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 37 | /** |
| 38 | * struct sandbox_flash_priv - private state for this driver |
| 39 | * |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 40 | * @eminfo: emulator state |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 41 | * @error: true if there is an error condition |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 42 | * @tag: Tag value from last command |
| 43 | * @fd: File descriptor of backing file |
| 44 | * @file_size: Size of file in bytes |
| 45 | * @status_buff: Data buffer for outgoing status |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 46 | */ |
| 47 | struct sandbox_flash_priv { |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 48 | struct scsi_emul_info eminfo; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 49 | bool error; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 50 | u32 tag; |
| 51 | int fd; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 52 | struct umass_bbb_csw status; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | struct sandbox_flash_plat { |
| 56 | const char *pathname; |
Simon Glass | 31d7816 | 2015-11-08 23:47:53 -0700 | [diff] [blame] | 57 | struct usb_string flash_strings[STRINGID_COUNT]; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 58 | }; |
| 59 | |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 60 | static struct usb_device_descriptor flash_device_desc = { |
| 61 | .bLength = sizeof(flash_device_desc), |
| 62 | .bDescriptorType = USB_DT_DEVICE, |
| 63 | |
| 64 | .bcdUSB = __constant_cpu_to_le16(0x0200), |
| 65 | |
| 66 | .bDeviceClass = 0, |
| 67 | .bDeviceSubClass = 0, |
| 68 | .bDeviceProtocol = 0, |
| 69 | |
| 70 | .idVendor = __constant_cpu_to_le16(0x1234), |
| 71 | .idProduct = __constant_cpu_to_le16(0x5678), |
| 72 | .iManufacturer = STRINGID_MANUFACTURER, |
| 73 | .iProduct = STRINGID_PRODUCT, |
| 74 | .iSerialNumber = STRINGID_SERIAL, |
| 75 | .bNumConfigurations = 1, |
| 76 | }; |
| 77 | |
| 78 | static struct usb_config_descriptor flash_config0 = { |
| 79 | .bLength = sizeof(flash_config0), |
| 80 | .bDescriptorType = USB_DT_CONFIG, |
| 81 | |
| 82 | /* wTotalLength is set up by usb-emul-uclass */ |
| 83 | .bNumInterfaces = 1, |
| 84 | .bConfigurationValue = 0, |
| 85 | .iConfiguration = 0, |
| 86 | .bmAttributes = 1 << 7, |
| 87 | .bMaxPower = 50, |
| 88 | }; |
| 89 | |
| 90 | static struct usb_interface_descriptor flash_interface0 = { |
| 91 | .bLength = sizeof(flash_interface0), |
| 92 | .bDescriptorType = USB_DT_INTERFACE, |
| 93 | |
| 94 | .bInterfaceNumber = 0, |
| 95 | .bAlternateSetting = 0, |
| 96 | .bNumEndpoints = 2, |
| 97 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, |
| 98 | .bInterfaceSubClass = US_SC_UFI, |
| 99 | .bInterfaceProtocol = US_PR_BULK, |
| 100 | .iInterface = 0, |
| 101 | }; |
| 102 | |
| 103 | static struct usb_endpoint_descriptor flash_endpoint0_out = { |
| 104 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 105 | .bDescriptorType = USB_DT_ENDPOINT, |
| 106 | |
| 107 | .bEndpointAddress = SANDBOX_FLASH_EP_OUT, |
| 108 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 109 | .wMaxPacketSize = __constant_cpu_to_le16(1024), |
| 110 | .bInterval = 0, |
| 111 | }; |
| 112 | |
| 113 | static struct usb_endpoint_descriptor flash_endpoint1_in = { |
| 114 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 115 | .bDescriptorType = USB_DT_ENDPOINT, |
| 116 | |
| 117 | .bEndpointAddress = SANDBOX_FLASH_EP_IN | USB_ENDPOINT_DIR_MASK, |
| 118 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
| 119 | .wMaxPacketSize = __constant_cpu_to_le16(1024), |
| 120 | .bInterval = 0, |
| 121 | }; |
| 122 | |
| 123 | static void *flash_desc_list[] = { |
| 124 | &flash_device_desc, |
| 125 | &flash_config0, |
| 126 | &flash_interface0, |
| 127 | &flash_endpoint0_out, |
| 128 | &flash_endpoint1_in, |
| 129 | NULL, |
| 130 | }; |
| 131 | |
| 132 | static int sandbox_flash_control(struct udevice *dev, struct usb_device *udev, |
| 133 | unsigned long pipe, void *buff, int len, |
| 134 | struct devrequest *setup) |
| 135 | { |
| 136 | struct sandbox_flash_priv *priv = dev_get_priv(dev); |
| 137 | |
| 138 | if (pipe == usb_rcvctrlpipe(udev, 0)) { |
| 139 | switch (setup->request) { |
| 140 | case US_BBB_RESET: |
| 141 | priv->error = false; |
| 142 | return 0; |
| 143 | case US_BBB_GET_MAX_LUN: |
| 144 | *(char *)buff = '\0'; |
| 145 | return 1; |
| 146 | default: |
| 147 | debug("request=%x\n", setup->request); |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 | debug("pipe=%lx\n", pipe); |
| 152 | |
| 153 | return -EIO; |
| 154 | } |
| 155 | |
| 156 | static void setup_fail_response(struct sandbox_flash_priv *priv) |
| 157 | { |
| 158 | struct umass_bbb_csw *csw = &priv->status; |
| 159 | |
| 160 | csw->dCSWSignature = CSWSIGNATURE; |
| 161 | csw->dCSWTag = priv->tag; |
| 162 | csw->dCSWDataResidue = 0; |
| 163 | csw->bCSWStatus = CSWSTATUS_FAILED; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /** |
| 167 | * setup_response() - set up a response to send back to the host |
| 168 | * |
| 169 | * @priv: Sandbox flash private data |
| 170 | * @resp: Response to send, or NULL if none |
| 171 | * @size: Size of response |
| 172 | */ |
Simon Glass | 8cfdea7 | 2022-09-21 16:21:41 +0200 | [diff] [blame] | 173 | static void setup_response(struct sandbox_flash_priv *priv) |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 174 | { |
| 175 | struct umass_bbb_csw *csw = &priv->status; |
| 176 | |
| 177 | csw->dCSWSignature = CSWSIGNATURE; |
| 178 | csw->dCSWTag = priv->tag; |
| 179 | csw->dCSWDataResidue = 0; |
| 180 | csw->bCSWStatus = CSWSTATUS_GOOD; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 181 | } |
| 182 | |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 183 | static int handle_ufi_command(struct sandbox_flash_priv *priv, const void *buff, |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 184 | int len) |
| 185 | { |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 186 | struct scsi_emul_info *info = &priv->eminfo; |
Simon Glass | a4eff9f | 2017-06-14 21:28:29 -0600 | [diff] [blame] | 187 | const struct scsi_cmd *req = buff; |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 188 | int ret; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 189 | |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 190 | ret = sb_scsi_emul_command(info, req, len); |
| 191 | if (!ret) { |
Simon Glass | 8cfdea7 | 2022-09-21 16:21:41 +0200 | [diff] [blame] | 192 | setup_response(priv); |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 193 | } else if (ret == SCSI_EMUL_DO_READ && priv->fd != -1) { |
| 194 | os_lseek(priv->fd, info->seek_block * info->block_size, |
| 195 | OS_SEEK_SET); |
Simon Glass | 8cfdea7 | 2022-09-21 16:21:41 +0200 | [diff] [blame] | 196 | setup_response(priv); |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 197 | } else { |
| 198 | setup_fail_response(priv); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 199 | } |
| 200 | |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev, |
| 205 | unsigned long pipe, void *buff, int len) |
| 206 | { |
| 207 | struct sandbox_flash_priv *priv = dev_get_priv(dev); |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 208 | struct scsi_emul_info *info = &priv->eminfo; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 209 | int ep = usb_pipeendpoint(pipe); |
| 210 | struct umass_bbb_cbw *cbw = buff; |
| 211 | |
| 212 | debug("%s: dev=%s, pipe=%lx, ep=%x, len=%x, phase=%d\n", __func__, |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 213 | dev->name, pipe, ep, len, info->phase); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 214 | switch (ep) { |
| 215 | case SANDBOX_FLASH_EP_OUT: |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 216 | switch (info->phase) { |
Simon Glass | e6e05ad | 2022-09-21 16:21:35 +0200 | [diff] [blame] | 217 | case SCSIPH_START: |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 218 | info->alloc_len = 0; |
| 219 | info->read_len = 0; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 220 | if (priv->error || len != UMASS_BBB_CBW_SIZE || |
| 221 | cbw->dCBWSignature != CBWSIGNATURE) |
| 222 | goto err; |
| 223 | if ((cbw->bCBWFlags & CBWFLAGS_SBZ) || |
| 224 | cbw->bCBWLUN != 0) |
| 225 | goto err; |
| 226 | if (cbw->bCDBLength < 1 || cbw->bCDBLength >= 0x10) |
| 227 | goto err; |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 228 | info->transfer_len = cbw->dCBWDataTransferLength; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 229 | priv->tag = cbw->dCBWTag; |
Simon Glass | 4d3b00d | 2022-09-21 16:21:45 +0200 | [diff] [blame^] | 230 | return handle_ufi_command(priv, cbw->CBWCDB, |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 231 | cbw->bCDBLength); |
Simon Glass | e6e05ad | 2022-09-21 16:21:35 +0200 | [diff] [blame] | 232 | case SCSIPH_DATA: |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 233 | debug("data out\n"); |
| 234 | break; |
| 235 | default: |
| 236 | break; |
| 237 | } |
| 238 | case SANDBOX_FLASH_EP_IN: |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 239 | switch (info->phase) { |
Simon Glass | e6e05ad | 2022-09-21 16:21:35 +0200 | [diff] [blame] | 240 | case SCSIPH_DATA: |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 241 | debug("data in, len=%x, alloc_len=%x, info->read_len=%x\n", |
| 242 | len, info->alloc_len, info->read_len); |
| 243 | if (info->read_len) { |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 244 | ulong bytes_read; |
| 245 | |
Sean Anderson | 0383185 | 2022-03-23 18:24:38 -0400 | [diff] [blame] | 246 | if (priv->fd == -1) |
| 247 | return -EIO; |
| 248 | |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 249 | bytes_read = os_read(priv->fd, buff, len); |
| 250 | if (bytes_read != len) |
| 251 | return -EIO; |
Simon Glass | d0962c9 | 2022-09-21 16:21:39 +0200 | [diff] [blame] | 252 | info->read_len -= len / info->block_size; |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 253 | if (!info->read_len) |
| 254 | info->phase = SCSIPH_STATUS; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 255 | } else { |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 256 | if (info->alloc_len && len > info->alloc_len) |
| 257 | len = info->alloc_len; |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 258 | if (len > SANDBOX_FLASH_BUF_SIZE) |
| 259 | len = SANDBOX_FLASH_BUF_SIZE; |
| 260 | memcpy(buff, info->buff, len); |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 261 | info->phase = SCSIPH_STATUS; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 262 | } |
| 263 | return len; |
Simon Glass | e6e05ad | 2022-09-21 16:21:35 +0200 | [diff] [blame] | 264 | case SCSIPH_STATUS: |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 265 | debug("status in, len=%x\n", len); |
| 266 | if (len > sizeof(priv->status)) |
| 267 | len = sizeof(priv->status); |
| 268 | memcpy(buff, &priv->status, len); |
Simon Glass | 4c92a4d | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 269 | info->phase = SCSIPH_START; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 270 | return len; |
| 271 | default: |
| 272 | break; |
| 273 | } |
| 274 | } |
| 275 | err: |
| 276 | priv->error = true; |
| 277 | debug("%s: Detected transfer error\n", __func__); |
| 278 | return 0; |
| 279 | } |
| 280 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 281 | static int sandbox_flash_of_to_plat(struct udevice *dev) |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 282 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 283 | struct sandbox_flash_plat *plat = dev_get_plat(dev); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 284 | |
Simon Glass | 82bf00e | 2017-05-18 20:09:39 -0600 | [diff] [blame] | 285 | plat->pathname = dev_read_string(dev, "sandbox,filepath"); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 286 | |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | static int sandbox_flash_bind(struct udevice *dev) |
| 291 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 292 | struct sandbox_flash_plat *plat = dev_get_plat(dev); |
Simon Glass | 31d7816 | 2015-11-08 23:47:53 -0700 | [diff] [blame] | 293 | struct usb_string *fs; |
| 294 | |
| 295 | fs = plat->flash_strings; |
| 296 | fs[0].id = STRINGID_MANUFACTURER; |
| 297 | fs[0].s = "sandbox"; |
| 298 | fs[1].id = STRINGID_PRODUCT; |
| 299 | fs[1].s = "flash"; |
| 300 | fs[2].id = STRINGID_SERIAL; |
| 301 | fs[2].s = dev->name; |
| 302 | |
Bin Meng | d502cf1 | 2017-10-01 06:19:36 -0700 | [diff] [blame] | 303 | return usb_emul_setup_device(dev, plat->flash_strings, flash_desc_list); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | static int sandbox_flash_probe(struct udevice *dev) |
| 307 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 308 | struct sandbox_flash_plat *plat = dev_get_plat(dev); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 309 | struct sandbox_flash_priv *priv = dev_get_priv(dev); |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 310 | struct scsi_emul_info *info = &priv->eminfo; |
| 311 | int ret; |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 312 | |
| 313 | priv->fd = os_open(plat->pathname, OS_O_RDONLY); |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 314 | if (priv->fd != -1) { |
Simon Glass | 4313c3e | 2022-09-21 16:21:40 +0200 | [diff] [blame] | 315 | ret = os_get_filesize(plat->pathname, &info->file_size); |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 316 | if (ret) |
| 317 | return log_msg_ret("sz", ret); |
| 318 | } |
| 319 | info->buff = malloc(SANDBOX_FLASH_BUF_SIZE); |
| 320 | if (!info->buff) |
| 321 | return log_ret(-ENOMEM); |
Simon Glass | 37884f0 | 2022-09-21 16:21:38 +0200 | [diff] [blame] | 322 | info->vendor = plat->flash_strings[STRINGID_MANUFACTURER - 1].s; |
| 323 | info->product = plat->flash_strings[STRINGID_PRODUCT - 1].s; |
Simon Glass | d0962c9 | 2022-09-21 16:21:39 +0200 | [diff] [blame] | 324 | info->block_size = SANDBOX_FLASH_BLOCK_LEN; |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 325 | |
| 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | static int sandbox_flash_remove(struct udevice *dev) |
| 330 | { |
| 331 | struct sandbox_flash_priv *priv = dev_get_priv(dev); |
| 332 | struct scsi_emul_info *info = &priv->eminfo; |
| 333 | |
| 334 | free(info->buff); |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 335 | |
| 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | static const struct dm_usb_ops sandbox_usb_flash_ops = { |
| 340 | .control = sandbox_flash_control, |
| 341 | .bulk = sandbox_flash_bulk, |
| 342 | }; |
| 343 | |
| 344 | static const struct udevice_id sandbox_usb_flash_ids[] = { |
| 345 | { .compatible = "sandbox,usb-flash" }, |
| 346 | { } |
| 347 | }; |
| 348 | |
| 349 | U_BOOT_DRIVER(usb_sandbox_flash) = { |
| 350 | .name = "usb_sandbox_flash", |
| 351 | .id = UCLASS_USB_EMUL, |
| 352 | .of_match = sandbox_usb_flash_ids, |
| 353 | .bind = sandbox_flash_bind, |
| 354 | .probe = sandbox_flash_probe, |
Simon Glass | 293c43f | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 355 | .remove = sandbox_flash_remove, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 356 | .of_to_plat = sandbox_flash_of_to_plat, |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 357 | .ops = &sandbox_usb_flash_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 358 | .priv_auto = sizeof(struct sandbox_flash_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 359 | .plat_auto = sizeof(struct sandbox_flash_plat), |
Simon Glass | b144644 | 2015-03-25 12:22:39 -0600 | [diff] [blame] | 360 | }; |