1 /* 2 * Copyright 2017 Rockchip Electronics Co., Ltd 3 * Frank Wang <frank.wang@rock-chips.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <asm/io.h> 9 #include <asm/arch/boot_mode.h> 10 #include <asm/arch/chip_info.h> 11 #include <write_keybox.h> 12 #include <linux/mtd/mtd.h> 13 14 #ifdef CONFIG_ROCKCHIP_VENDOR_PARTITION 15 #include <asm/arch/vendor.h> 16 #endif 17 18 #include <rockusb.h> 19 20 #define ROCKUSB_INTERFACE_CLASS 0xff 21 #define ROCKUSB_INTERFACE_SUB_CLASS 0x06 22 #define ROCKUSB_INTERFACE_PROTOCOL 0x05 23 24 #define ROCKCHIP_FLASH_BLOCK_SIZE 1024 25 #define ROCKCHIP_FLASH_PAGE_SIZE 4 26 27 static struct usb_interface_descriptor rkusb_intf_desc = { 28 .bLength = USB_DT_INTERFACE_SIZE, 29 .bDescriptorType = USB_DT_INTERFACE, 30 .bInterfaceNumber = 0x00, 31 .bAlternateSetting = 0x00, 32 .bNumEndpoints = 0x02, 33 .bInterfaceClass = ROCKUSB_INTERFACE_CLASS, 34 .bInterfaceSubClass = ROCKUSB_INTERFACE_SUB_CLASS, 35 .bInterfaceProtocol = ROCKUSB_INTERFACE_PROTOCOL, 36 }; 37 38 static struct usb_descriptor_header *rkusb_fs_function[] = { 39 (struct usb_descriptor_header *)&rkusb_intf_desc, 40 (struct usb_descriptor_header *)&fsg_fs_bulk_in_desc, 41 (struct usb_descriptor_header *)&fsg_fs_bulk_out_desc, 42 NULL, 43 }; 44 45 static struct usb_descriptor_header *rkusb_hs_function[] = { 46 (struct usb_descriptor_header *)&rkusb_intf_desc, 47 (struct usb_descriptor_header *)&fsg_hs_bulk_in_desc, 48 (struct usb_descriptor_header *)&fsg_hs_bulk_out_desc, 49 NULL, 50 }; 51 52 static struct usb_descriptor_header *rkusb_ss_function[] = { 53 (struct usb_descriptor_header *)&rkusb_intf_desc, 54 (struct usb_descriptor_header *)&fsg_ss_bulk_in_desc, 55 (struct usb_descriptor_header *)&fsg_ss_bulk_in_comp_desc, 56 (struct usb_descriptor_header *)&fsg_ss_bulk_out_desc, 57 (struct usb_descriptor_header *)&fsg_ss_bulk_out_comp_desc, 58 NULL, 59 }; 60 61 struct rk_flash_info { 62 u32 flash_size; 63 u16 block_size; 64 u8 page_size; 65 u8 ecc_bits; 66 u8 access_time; 67 u8 manufacturer; 68 u8 flash_mask; 69 } __packed; 70 71 static int rkusb_rst_code; /* The subcode in reset command (0xFF) */ 72 73 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) 74 { 75 if (IS_RKUSB_UMS_DNL(name)) { 76 /* Fix to Rockchip's VID and PID */ 77 dev->idVendor = __constant_cpu_to_le16(0x2207); 78 dev->idProduct = __constant_cpu_to_le16(CONFIG_ROCKUSB_G_DNL_PID); 79 80 /* Enumerate as a loader device */ 81 #if defined(CONFIG_SUPPORT_USBPLUG) 82 dev->bcdUSB = cpu_to_le16(0x0200); 83 #else 84 dev->bcdUSB = cpu_to_le16(0x0201); 85 #endif 86 } else if (!strncmp(name, "usb_dnl_fastboot", 16)) { 87 /* Fix to Google's VID and PID */ 88 dev->idVendor = __constant_cpu_to_le16(0x18d1); 89 dev->idProduct = __constant_cpu_to_le16(0xd00d); 90 } 91 92 return 0; 93 } 94 95 __maybe_unused 96 static inline void dump_cbw(struct fsg_bulk_cb_wrap *cbw) 97 { 98 assert(!cbw); 99 100 debug("%s:\n", __func__); 101 debug("Signature %x\n", cbw->Signature); 102 debug("Tag %x\n", cbw->Tag); 103 debug("DataTransferLength %x\n", cbw->DataTransferLength); 104 debug("Flags %x\n", cbw->Flags); 105 debug("LUN %x\n", cbw->Lun); 106 debug("Length %x\n", cbw->Length); 107 debug("OptionCode %x\n", cbw->CDB[0]); 108 debug("SubCode %x\n", cbw->CDB[1]); 109 debug("SectorAddr %x\n", get_unaligned_be32(&cbw->CDB[2])); 110 debug("BlkSectors %x\n\n", get_unaligned_be16(&cbw->CDB[7])); 111 } 112 113 static int rkusb_check_lun(struct fsg_common *common) 114 { 115 struct fsg_lun *curlun; 116 117 /* Check the LUN */ 118 if (common->lun >= 0 && common->lun < common->nluns) { 119 curlun = &common->luns[common->lun]; 120 if (common->cmnd[0] != SC_REQUEST_SENSE) { 121 curlun->sense_data = SS_NO_SENSE; 122 curlun->info_valid = 0; 123 } 124 } else { 125 curlun = NULL; 126 common->bad_lun_okay = 0; 127 128 /* 129 * INQUIRY and REQUEST SENSE commands are explicitly allowed 130 * to use unsupported LUNs; all others may not. 131 */ 132 if (common->cmnd[0] != SC_INQUIRY && 133 common->cmnd[0] != SC_REQUEST_SENSE) { 134 debug("unsupported LUN %d\n", common->lun); 135 return -EINVAL; 136 } 137 } 138 139 return 0; 140 } 141 142 static void __do_reset(struct usb_ep *ep, struct usb_request *req) 143 { 144 u32 boot_flag = BOOT_NORMAL; 145 146 if (rkusb_rst_code == 0x03) 147 boot_flag = BOOT_BROM_DOWNLOAD; 148 149 rkusb_rst_code = 0; /* restore to default */ 150 writel(boot_flag, (void *)CONFIG_ROCKCHIP_BOOT_MODE_REG); 151 152 do_reset(NULL, 0, 0, NULL); 153 } 154 155 static int rkusb_do_reset(struct fsg_common *common, 156 struct fsg_buffhd *bh) 157 { 158 common->data_size_from_cmnd = common->cmnd[4]; 159 common->residue = 0; 160 bh->inreq->complete = __do_reset; 161 bh->state = BUF_STATE_EMPTY; 162 163 rkusb_rst_code = !common->cmnd[1] ? 0xff : common->cmnd[1]; 164 return 0; 165 } 166 167 static int rkusb_do_test_unit_ready(struct fsg_common *common, 168 struct fsg_buffhd *bh) 169 { 170 common->residue = 0x06 << 24; /* Max block xfer support from host */ 171 common->data_dir = DATA_DIR_NONE; 172 bh->state = BUF_STATE_EMPTY; 173 174 return 0; 175 } 176 177 static int rkusb_do_read_flash_id(struct fsg_common *common, 178 struct fsg_buffhd *bh) 179 { 180 u8 *buf = (u8 *)bh->buf; 181 u32 len = 5; 182 enum if_type type = ums[common->lun].block_dev.if_type; 183 184 if (type == IF_TYPE_MMC) 185 memcpy((void *)&buf[0], "EMMC ", 5); 186 else if (type == IF_TYPE_RKNAND) 187 memcpy((void *)&buf[0], "NAND ", 5); 188 else 189 memcpy((void *)&buf[0], "UNKN ", 5); /* unknown */ 190 191 /* Set data xfer size */ 192 common->residue = common->data_size_from_cmnd = len; 193 common->data_size = len; 194 195 return len; 196 } 197 198 static int rkusb_do_test_bad_block(struct fsg_common *common, 199 struct fsg_buffhd *bh) 200 { 201 u8 *buf = (u8 *)bh->buf; 202 u32 len = 64; 203 204 memset((void *)&buf[0], 0, len); 205 206 /* Set data xfer size */ 207 common->residue = common->data_size_from_cmnd = len; 208 common->data_size = len; 209 210 return len; 211 } 212 213 static int rkusb_do_read_flash_info(struct fsg_common *common, 214 struct fsg_buffhd *bh) 215 { 216 struct blk_desc *desc = &ums[common->lun].block_dev; 217 u8 *buf = (u8 *)bh->buf; 218 u32 len = sizeof(struct rk_flash_info); 219 struct rk_flash_info finfo = { 220 .block_size = ROCKCHIP_FLASH_BLOCK_SIZE, 221 .ecc_bits = 0, 222 .page_size = ROCKCHIP_FLASH_PAGE_SIZE, 223 .access_time = 40, 224 .manufacturer = 0, 225 .flash_mask = 0 226 }; 227 228 finfo.flash_size = (u32)desc->lba; 229 230 if (desc->if_type == IF_TYPE_MTD && 231 (desc->devnum == BLK_MTD_NAND || 232 desc->devnum == BLK_MTD_SPI_NAND)) { 233 struct mtd_info *mtd = (struct mtd_info *)desc->bdev->priv; 234 235 if (mtd) { 236 finfo.block_size = mtd->erasesize >> 9; 237 finfo.page_size = mtd->writesize >> 9; 238 } 239 } 240 241 debug("Flash info: block_size= %x page_size= %x\n", finfo.block_size, 242 finfo.page_size); 243 244 if (finfo.flash_size) 245 finfo.flash_mask = 1; 246 247 memset((void *)&buf[0], 0, len); 248 memcpy((void *)&buf[0], (void *)&finfo, len); 249 250 /* Set data xfer size */ 251 common->residue = common->data_size_from_cmnd = len; 252 /* legacy upgrade_tool does not set correct transfer size */ 253 common->data_size = len; 254 255 return len; 256 } 257 258 static int rkusb_do_get_chip_info(struct fsg_common *common, 259 struct fsg_buffhd *bh) 260 { 261 u8 *buf = (u8 *)bh->buf; 262 u32 len = common->data_size; 263 u32 chip_info[4]; 264 265 memset((void *)chip_info, 0, sizeof(chip_info)); 266 rockchip_rockusb_get_chip_info(chip_info); 267 268 memset((void *)&buf[0], 0, len); 269 memcpy((void *)&buf[0], (void *)chip_info, len); 270 271 /* Set data xfer size */ 272 common->residue = common->data_size_from_cmnd = len; 273 274 return len; 275 } 276 277 static int rkusb_do_lba_erase(struct fsg_common *common, 278 struct fsg_buffhd *bh) 279 { 280 struct fsg_lun *curlun = &common->luns[common->lun]; 281 u32 lba, amount; 282 loff_t file_offset; 283 int rc; 284 285 lba = get_unaligned_be32(&common->cmnd[2]); 286 if (lba >= curlun->num_sectors) { 287 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 288 rc = -EINVAL; 289 goto out; 290 } 291 292 file_offset = ((loff_t) lba) << 9; 293 amount = get_unaligned_be16(&common->cmnd[7]) << 9; 294 if (unlikely(amount == 0)) { 295 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; 296 rc = -EIO; 297 goto out; 298 } 299 300 /* Perform the erase */ 301 rc = ums[common->lun].erase_sector(&ums[common->lun], 302 file_offset / SECTOR_SIZE, 303 amount / SECTOR_SIZE); 304 if (!rc) { 305 curlun->sense_data = SS_MEDIUM_NOT_PRESENT; 306 rc = -EIO; 307 } 308 309 out: 310 common->data_dir = DATA_DIR_NONE; 311 bh->state = BUF_STATE_EMPTY; 312 313 return rc; 314 } 315 316 static int rkusb_do_erase_force(struct fsg_common *common, 317 struct fsg_buffhd *bh) 318 { 319 struct blk_desc *desc = &ums[common->lun].block_dev; 320 struct fsg_lun *curlun = &common->luns[common->lun]; 321 u16 block_size = ROCKCHIP_FLASH_BLOCK_SIZE; 322 u32 lba, amount; 323 loff_t file_offset; 324 int rc; 325 326 lba = get_unaligned_be32(&common->cmnd[2]); 327 if (lba >= curlun->num_sectors) { 328 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 329 rc = -EINVAL; 330 goto out; 331 } 332 333 if (desc->if_type == IF_TYPE_MTD && 334 (desc->devnum == BLK_MTD_NAND || 335 desc->devnum == BLK_MTD_SPI_NAND)) { 336 struct mtd_info *mtd = (struct mtd_info *)desc->bdev->priv; 337 338 if (mtd) 339 block_size = mtd->erasesize >> 9; 340 } 341 342 file_offset = ((loff_t)lba) * block_size; 343 amount = get_unaligned_be16(&common->cmnd[7]) * block_size; 344 345 debug("%s lba= %x, nsec= %x\n", __func__, lba, 346 (u32)get_unaligned_be16(&common->cmnd[7])); 347 348 if (unlikely(amount == 0)) { 349 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; 350 rc = -EIO; 351 goto out; 352 } 353 354 /* Perform the erase */ 355 rc = ums[common->lun].erase_sector(&ums[common->lun], 356 file_offset, 357 amount); 358 if (!rc) { 359 curlun->sense_data = SS_MEDIUM_NOT_PRESENT; 360 rc = -EIO; 361 } 362 363 out: 364 common->data_dir = DATA_DIR_NONE; 365 bh->state = BUF_STATE_EMPTY; 366 367 return rc; 368 } 369 370 #ifdef CONFIG_ROCKCHIP_VENDOR_PARTITION 371 static int rkusb_do_vs_write(struct fsg_common *common) 372 { 373 struct fsg_lun *curlun = &common->luns[common->lun]; 374 u16 type = get_unaligned_be16(&common->cmnd[4]); 375 struct vendor_item *vhead; 376 struct fsg_buffhd *bh; 377 void *data; 378 int rc; 379 380 if (common->data_size >= (u32)65536) { 381 /* _MUST_ small than 64K */ 382 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 383 return -EINVAL; 384 } 385 386 common->residue = common->data_size; 387 common->usb_amount_left = common->data_size; 388 389 /* Carry out the file writes */ 390 if (unlikely(common->data_size == 0)) 391 return -EIO; /* No data to write */ 392 393 for (;;) { 394 if (common->usb_amount_left > 0) { 395 /* Wait for the next buffer to become available */ 396 bh = common->next_buffhd_to_fill; 397 if (bh->state != BUF_STATE_EMPTY) 398 goto wait; 399 400 /* Request the next buffer */ 401 common->usb_amount_left -= common->data_size; 402 bh->outreq->length = common->data_size; 403 bh->bulk_out_intended_length = common->data_size; 404 bh->outreq->short_not_ok = 1; 405 406 START_TRANSFER_OR(common, bulk_out, bh->outreq, 407 &bh->outreq_busy, &bh->state) 408 /* 409 * Don't know what to do if 410 * common->fsg is NULL 411 */ 412 return -EIO; 413 common->next_buffhd_to_fill = bh->next; 414 } else { 415 /* Then, wait for the data to become available */ 416 bh = common->next_buffhd_to_drain; 417 if (bh->state != BUF_STATE_FULL) 418 goto wait; 419 420 common->next_buffhd_to_drain = bh->next; 421 bh->state = BUF_STATE_EMPTY; 422 423 /* Did something go wrong with the transfer? */ 424 if (bh->outreq->status != 0) { 425 curlun->sense_data = SS_COMMUNICATION_FAILURE; 426 curlun->info_valid = 1; 427 break; 428 } 429 430 /* Perform the write */ 431 vhead = (struct vendor_item *)bh->buf; 432 data = bh->buf + sizeof(struct vendor_item); 433 434 if (!type) { 435 /* Vendor storage */ 436 rc = vendor_storage_write(vhead->id, 437 (char __user *)data, 438 vhead->size); 439 if (rc < 0) { 440 curlun->sense_data = SS_WRITE_ERROR; 441 return -EIO; 442 } 443 } else { 444 /* RPMB */ 445 rc = 446 write_keybox_to_secure_storage((u8 *)data, 447 vhead->size); 448 if (rc < 0) { 449 curlun->sense_data = SS_WRITE_ERROR; 450 return -EIO; 451 } 452 } 453 454 common->residue -= common->data_size; 455 456 /* Did the host decide to stop early? */ 457 if (bh->outreq->actual != bh->outreq->length) 458 common->short_packet_received = 1; 459 break; /* Command done */ 460 } 461 wait: 462 /* Wait for something to happen */ 463 rc = sleep_thread(common); 464 if (rc) 465 return rc; 466 } 467 468 return -EIO; /* No default reply */ 469 } 470 471 static int rkusb_do_vs_read(struct fsg_common *common) 472 { 473 struct fsg_lun *curlun = &common->luns[common->lun]; 474 u16 type = get_unaligned_be16(&common->cmnd[4]); 475 struct vendor_item *vhead; 476 struct fsg_buffhd *bh; 477 void *data; 478 int rc; 479 480 if (common->data_size >= (u32)65536) { 481 /* _MUST_ small than 64K */ 482 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 483 return -EINVAL; 484 } 485 486 common->residue = common->data_size; 487 common->usb_amount_left = common->data_size; 488 489 /* Carry out the file reads */ 490 if (unlikely(common->data_size == 0)) 491 return -EIO; /* No default reply */ 492 493 for (;;) { 494 /* Wait for the next buffer to become available */ 495 bh = common->next_buffhd_to_fill; 496 while (bh->state != BUF_STATE_EMPTY) { 497 rc = sleep_thread(common); 498 if (rc) 499 return rc; 500 } 501 502 memset(bh->buf, 0, FSG_BUFLEN); 503 vhead = (struct vendor_item *)bh->buf; 504 data = bh->buf + sizeof(struct vendor_item); 505 vhead->id = get_unaligned_be16(&common->cmnd[2]); 506 507 if (!type) { 508 /* Vendor storage */ 509 rc = vendor_storage_read(vhead->id, 510 (char __user *)data, 511 common->data_size); 512 if (!rc) { 513 curlun->sense_data = SS_UNRECOVERED_READ_ERROR; 514 return -EIO; 515 } 516 vhead->size = rc; 517 } else { 518 /* RPMB */ 519 rc = 520 read_raw_data_from_secure_storage((u8 *)data, 521 common->data_size); 522 if (!rc) { 523 curlun->sense_data = SS_UNRECOVERED_READ_ERROR; 524 return -EIO; 525 } 526 vhead->size = rc; 527 } 528 529 common->residue -= common->data_size; 530 bh->inreq->length = common->data_size; 531 bh->state = BUF_STATE_FULL; 532 533 break; /* No more left to read */ 534 } 535 536 return -EIO; /* No default reply */ 537 } 538 #endif 539 540 static int rkusb_do_read_capacity(struct fsg_common *common, 541 struct fsg_buffhd *bh) 542 { 543 u8 *buf = (u8 *)bh->buf; 544 u32 len = common->data_size; 545 enum if_type type = ums[common->lun].block_dev.if_type; 546 int devnum = ums[common->lun].block_dev.devnum; 547 548 /* 549 * bit[0]: Direct LBA, 0: Disabled; 550 * bit[1]: Vendor Storage API, 0: Disabed (default); 551 * bit[2]: First 4M Access, 0: Disabled; 552 * bit[3]: Read LBA On, 0: Disabed (default); 553 * bit[4]: New Vendor Storage API, 0: Disabed; 554 * bit[5:63}: Reserved. 555 */ 556 memset((void *)&buf[0], 0, len); 557 if (type == IF_TYPE_MMC || type == IF_TYPE_SD) 558 buf[0] = BIT(0) | BIT(2) | BIT(4); 559 else 560 buf[0] = BIT(0) | BIT(4); 561 562 if (type == IF_TYPE_MTD && 563 (devnum == BLK_MTD_NAND || 564 devnum == BLK_MTD_SPI_NAND)) 565 buf[0] |= (1 << 6); 566 567 #if defined(CONFIG_ROCKCHIP_RK3568) 568 buf[1] = BIT(0); 569 #endif 570 /* Set data xfer size */ 571 common->residue = len; 572 common->data_size_from_cmnd = len; 573 574 return len; 575 } 576 577 static void rkusb_fixup_cbwcb(struct fsg_common *common, 578 struct fsg_buffhd *bh) 579 { 580 struct usb_request *req = bh->outreq; 581 struct fsg_bulk_cb_wrap *cbw = req->buf; 582 583 /* FIXME cbw.DataTransferLength was not set by Upgrade Tool */ 584 common->data_size = le32_to_cpu(cbw->DataTransferLength); 585 if (common->data_size == 0) { 586 common->data_size = 587 get_unaligned_be16(&common->cmnd[7]) << 9; 588 printf("Trasfer Length NOT set, please use new version tool\n"); 589 debug("%s %d, cmnd1 %x\n", __func__, 590 get_unaligned_be16(&common->cmnd[7]), 591 get_unaligned_be16(&common->cmnd[1])); 592 } 593 if (cbw->Flags & USB_BULK_IN_FLAG) 594 common->data_dir = DATA_DIR_TO_HOST; 595 else 596 common->data_dir = DATA_DIR_FROM_HOST; 597 598 /* Not support */ 599 common->cmnd[1] = 0; 600 } 601 602 static int rkusb_cmd_process(struct fsg_common *common, 603 struct fsg_buffhd *bh, int *reply) 604 { 605 struct usb_request *req = bh->outreq; 606 struct fsg_bulk_cb_wrap *cbw = req->buf; 607 int rc; 608 609 dump_cbw(cbw); 610 611 if (rkusb_check_lun(common)) { 612 *reply = -EINVAL; 613 return RKUSB_RC_ERROR; 614 } 615 616 switch (common->cmnd[0]) { 617 case RKUSB_TEST_UNIT_READY: 618 *reply = rkusb_do_test_unit_ready(common, bh); 619 rc = RKUSB_RC_FINISHED; 620 break; 621 622 case RKUSB_READ_FLASH_ID: 623 *reply = rkusb_do_read_flash_id(common, bh); 624 rc = RKUSB_RC_FINISHED; 625 break; 626 627 case RKUSB_TEST_BAD_BLOCK: 628 *reply = rkusb_do_test_bad_block(common, bh); 629 rc = RKUSB_RC_FINISHED; 630 break; 631 632 case RKUSB_ERASE_10_FORCE: 633 *reply = rkusb_do_erase_force(common, bh); 634 rc = RKUSB_RC_FINISHED; 635 break; 636 637 case RKUSB_LBA_READ_10: 638 rkusb_fixup_cbwcb(common, bh); 639 common->cmnd[0] = SC_READ_10; 640 common->cmnd[1] = 0; /* Not support */ 641 rc = RKUSB_RC_CONTINUE; 642 break; 643 644 case RKUSB_LBA_WRITE_10: 645 rkusb_fixup_cbwcb(common, bh); 646 common->cmnd[0] = SC_WRITE_10; 647 common->cmnd[1] = 0; /* Not support */ 648 rc = RKUSB_RC_CONTINUE; 649 break; 650 651 case RKUSB_READ_FLASH_INFO: 652 *reply = rkusb_do_read_flash_info(common, bh); 653 rc = RKUSB_RC_FINISHED; 654 break; 655 656 case RKUSB_GET_CHIP_VER: 657 *reply = rkusb_do_get_chip_info(common, bh); 658 rc = RKUSB_RC_FINISHED; 659 break; 660 661 case RKUSB_LBA_ERASE: 662 *reply = rkusb_do_lba_erase(common, bh); 663 rc = RKUSB_RC_FINISHED; 664 break; 665 666 #ifdef CONFIG_ROCKCHIP_VENDOR_PARTITION 667 case RKUSB_VS_WRITE: 668 *reply = rkusb_do_vs_write(common); 669 rc = RKUSB_RC_FINISHED; 670 break; 671 672 case RKUSB_VS_READ: 673 *reply = rkusb_do_vs_read(common); 674 rc = RKUSB_RC_FINISHED; 675 break; 676 #endif 677 678 case RKUSB_READ_CAPACITY: 679 *reply = rkusb_do_read_capacity(common, bh); 680 rc = RKUSB_RC_FINISHED; 681 break; 682 683 case RKUSB_RESET: 684 *reply = rkusb_do_reset(common, bh); 685 rc = RKUSB_RC_FINISHED; 686 break; 687 688 case RKUSB_READ_10: 689 case RKUSB_WRITE_10: 690 printf("CMD Not support, pls use new version Tool\n"); 691 case RKUSB_SET_DEVICE_ID: 692 case RKUSB_ERASE_10: 693 case RKUSB_WRITE_SPARE: 694 case RKUSB_READ_SPARE: 695 case RKUSB_GET_VERSION: 696 case RKUSB_ERASE_SYS_DISK: 697 case RKUSB_SDRAM_READ_10: 698 case RKUSB_SDRAM_WRITE_10: 699 case RKUSB_SDRAM_EXECUTE: 700 case RKUSB_LOW_FORMAT: 701 case RKUSB_SET_RESET_FLAG: 702 case RKUSB_SPI_READ_10: 703 case RKUSB_SPI_WRITE_10: 704 case RKUSB_SESSION: 705 /* Fall through */ 706 default: 707 rc = RKUSB_RC_UNKNOWN_CMND; 708 break; 709 } 710 711 return rc; 712 } 713 714 DECLARE_GADGET_BIND_CALLBACK(rkusb_ums_dnl, fsg_add); 715