summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Panizzo <alberto@amarulasolutions.com>2018-07-12 13:05:49 +0200
committerMarek Vasut <marex@denx.de>2018-08-08 22:22:08 +0200
commit92c7edae5eb2235bcfd19823cc00177d2463bd60 (patch)
tree39de7db1cac62f3c09cb0a818c25e02cf305f9c1
parent4f6dc4c893de44e8d91008516c835e06b450e310 (diff)
downloadu-boot-92c7edae5eb2235bcfd19823cc00177d2463bd60.tar.gz
u-boot-92c7edae5eb2235bcfd19823cc00177d2463bd60.tar.bz2
u-boot-92c7edae5eb2235bcfd19823cc00177d2463bd60.zip
usb: rockchip: on K_FW_LBA_WRITE_10 remove magic block size of 512 bytes
As well as in K_FW_LBA_READ_10 and K_FW_LBA_ERASE_10 take device's block size from f_rkusb->desc->blksz instead of the fixed 512 bytes. Keep original behaviour of retry probing assigned block device on every host request to manage late SDCard plugs. Signed-off-by: Alberto Panizzo <alberto@amarulasolutions.com>
-rw-r--r--drivers/usb/gadget/f_rockusb.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c
index 574d610580..e81eb164b0 100644
--- a/drivers/usb/gadget/f_rockusb.c
+++ b/drivers/usb/gadget/f_rockusb.c
@@ -490,19 +490,6 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
unsigned int buffer_size = req->actual;
transfer_size = f_rkusb->dl_size - f_rkusb->dl_bytes;
- if (!f_rkusb->desc) {
- char *type = f_rkusb->dev_type;
- int index = f_rkusb->dev_index;
-
- f_rkusb->desc = blk_get_dev(type, index);
- if (!f_rkusb->desc ||
- f_rkusb->desc->type == DEV_TYPE_UNKNOWN) {
- puts("invalid mmc device\n");
- rockusb_tx_write_csw(f_rkusb->tag, 0, CSW_FAIL,
- USB_BULK_CS_WRAP_LEN);
- return;
- }
- }
if (req->status != 0) {
printf("Bad status: %d\n", req->status);
@@ -516,7 +503,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
memcpy((void *)f_rkusb->buf, buffer, transfer_size);
f_rkusb->dl_bytes += transfer_size;
- int blks = 0, blkcnt = transfer_size / 512;
+ int blks = 0, blkcnt = transfer_size / f_rkusb->desc->blksz;
debug("dl %x bytes, %x blks, write lba %x, dl_size:%x, dl_bytes:%x, ",
transfer_size, blkcnt, f_rkusb->lba, f_rkusb->dl_size,
@@ -547,8 +534,8 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
else
f_rkusb->buf = f_rkusb->buf_head;
- debug("remain %x bytes, %x sectors\n", req->length,
- req->length / 512);
+ debug("remain %x bytes, %lx sectors\n", req->length,
+ req->length / f_rkusb->desc->blksz);
}
req->actual = 0;
@@ -676,10 +663,26 @@ static void cb_write_lba(struct usb_ep *ep, struct usb_request *req)
memcpy((char *)cbw, req->buf, USB_BULK_CB_WRAP_LEN);
sector_count = (int)get_unaligned_be16(&cbw->CDB[7]);
+ f_rkusb->tag = cbw->tag;
+
+ if (!f_rkusb->desc) {
+ char *type = f_rkusb->dev_type;
+ int index = f_rkusb->dev_index;
+
+ f_rkusb->desc = blk_get_dev(type, index);
+ if (!f_rkusb->desc ||
+ f_rkusb->desc->type == DEV_TYPE_UNKNOWN) {
+ printf("invalid device \"%s\", %d\n", type, index);
+ rockusb_tx_write_csw(f_rkusb->tag, 0, CSW_FAIL,
+ USB_BULK_CS_WRAP_LEN);
+ return;
+ }
+ }
+
f_rkusb->lba = get_unaligned_be32(&cbw->CDB[2]);
- f_rkusb->dl_size = sector_count * 512;
+ f_rkusb->dl_size = sector_count * f_rkusb->desc->blksz;
f_rkusb->dl_bytes = 0;
- f_rkusb->tag = cbw->tag;
+
debug("require write %x bytes, %x sectors to lba %x\n",
f_rkusb->dl_size, sector_count, f_rkusb->lba);