From f5fb78a2748af0d532110cc4f03912b6b30f8761 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 11 Oct 2015 07:26:27 -0400 Subject: common/usb_storage.c: Clean up usb_storage_probe() We have the protocol and subclass variables which are used only in disabled debug code. This code dates back to the initial git import and seemingly dead code so remove it. This was detected by Coverity (CID 131117) Signed-off-by: Tom Rini diff --git a/common/usb_storage.c b/common/usb_storage.c index 0ccaeb4..4fa6538 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -1177,25 +1177,9 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, struct usb_endpoint_descriptor *ep_desc; unsigned int flags = 0; - int protocol = 0; - int subclass = 0; - /* let's examine the device now */ iface = &dev->config.if_desc[ifnum]; -#if 0 - /* this is the place to patch some storage devices */ - debug("iVendor %X iProduct %X\n", dev->descriptor.idVendor, - dev->descriptor.idProduct); - - if ((dev->descriptor.idVendor) == 0x066b && - (dev->descriptor.idProduct) == 0x0103) { - debug("patched for E-USB\n"); - protocol = US_PR_CB; - subclass = US_SC_UFI; /* an assumption */ - } -#endif - if (dev->descriptor.bDeviceClass != 0 || iface->desc.bInterfaceClass != USB_CLASS_MASS_STORAGE || iface->desc.bInterfaceSubClass < US_SC_MIN || @@ -1215,17 +1199,8 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, ss->ifnum = ifnum; ss->pusb_dev = dev; ss->attention_done = 0; - - /* If the device has subclass and protocol, then use that. Otherwise, - * take data from the specific interface. - */ - if (subclass) { - ss->subclass = subclass; - ss->protocol = protocol; - } else { - ss->subclass = iface->desc.bInterfaceSubClass; - ss->protocol = iface->desc.bInterfaceProtocol; - } + ss->subclass = iface->desc.bInterfaceSubClass; + ss->protocol = iface->desc.bInterfaceProtocol; /* set the handler pointers based on the protocol */ debug("Transport: "); -- cgit v0.10.2 From b748b24fb504b4da630c6464d6704ae7758f3732 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 20 Oct 2015 18:39:29 +0200 Subject: ohci: Add missing cache-flush for hcca area We need to cache-flush the hcca area after the initial memset, otherwise on the first hc_interrupt we might see an old $random value as done_head and try to interpret that as the address for a completed td (followed by chaos). Signed-off-by: Hans de Goede diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 9bde2b2..ccbfc02 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -2205,6 +2205,7 @@ int ohci_register(struct udevice *dev, struct ohci_regs *regs) if (!ohci->hcca) return -ENOMEM; memset(ohci->hcca, 0, sizeof(struct ohci_hcca)); + flush_dcache_hcca(ohci->hcca); if (hc_reset(ohci) < 0) return -EIO; -- cgit v0.10.2 From 30e3ea4c79dd35e97d04546bd39e2468c8ba63ef Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Tue, 20 Oct 2015 15:22:00 +0530 Subject: dfu: dfu_sf: Pass duplicate devstr to parse_dev parse_dev() alters the string pointed by devstr parameter. Due to this subsequent parsing of sf entities will fail, as string pointed by devstr is no longer valid sf dev arguments. Fix this by passing pointer to the copy of the string to parse_dev instead of pointer to the actual devstr. Signed-off-by: Vignesh R Reviewed-by: Tom Rini diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index 7646c6b..9702eee 100644 --- a/drivers/dfu/dfu_sf.c +++ b/drivers/dfu/dfu_sf.c @@ -115,8 +115,10 @@ static struct spi_flash *parse_dev(char *devstr) int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s) { char *st; + char *devstr_bkup = strdup(devstr); - dfu->data.sf.dev = parse_dev(devstr); + dfu->data.sf.dev = parse_dev(devstr_bkup); + free(devstr_bkup); if (!dfu->data.sf.dev) return -ENODEV; -- cgit v0.10.2 From 5486d067a8a0e44e777b8195b2ecb47f2500f235 Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Tue, 20 Oct 2015 15:22:01 +0530 Subject: ARM: dra7xx_evm: Add DFU support for qspi flash This adds support to update firmware on qspi flash using DFU. On device: => setenv dfu_alt_info ${dfu_alt_info_qspi} => dfu 0 sf 0:0 On host: $ sudo dfu-util -l $ sudo dfu-util -D MLO -a MLO $ sudo dfu-util -D u-boot.img -a u-boot.img Signed-off-by: Vignesh R Reviewed-by: Tom Rini diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index 6e32de8..cb9544b 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -82,11 +82,24 @@ "fdt ram 0x80f80000 0x80000;" \ "ramdisk ram 0x81000000 0x4000000\0" +#define DFU_ALT_INFO_QSPI \ + "dfu_alt_info_qspi=" \ + "MLO raw 0x0 0x010000;" \ + "MLO.backup1 raw 0x010000 0x010000;" \ + "MLO.backup2 raw 0x020000 0x010000;" \ + "MLO.backup3 raw 0x030000 0x010000;" \ + "u-boot.img raw 0x040000 0x0100000;" \ + "u-boot-spl-os raw 0x140000 0x080000;" \ + "u-boot-env raw 0x1C0000 0x010000;" \ + "u-boot-env.backup raw 0x1D0000 0x010000;" \ + "kernel raw 0x1E0000 0x800000\0" + #define DFUARGS \ "dfu_bufsiz=0x10000\0" \ DFU_ALT_INFO_MMC \ DFU_ALT_INFO_EMMC \ - DFU_ALT_INFO_RAM + DFU_ALT_INFO_RAM \ + DFU_ALT_INFO_QSPI /* Fastboot */ #define CONFIG_USB_FUNCTION_FASTBOOT @@ -207,6 +220,7 @@ #define CONFIG_DFU_MMC #define CONFIG_DFU_RAM +#define CONFIG_DFU_SF /* SATA */ #define CONFIG_BOARD_LATE_INIT -- cgit v0.10.2 From 01c94c4a6ee73210096c1e363977ef0568675187 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 30 Oct 2015 16:24:06 +0100 Subject: usb: dwc3: Fix warnings on 64-bit builds Change aritmentics to use 64bit types to be compatible with 64bit builds. Signed-off-by: Michal Simek diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index ab3c94e..0ae3de5 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -281,7 +281,7 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) return 0; err1: - dma_unmap_single((void *)dwc->scratch_addr, dwc->nr_scratch * + dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); err0: @@ -296,7 +296,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc) if (!dwc->nr_scratch) return; - dma_unmap_single((void *)dwc->scratch_addr, dwc->nr_scratch * + dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); kfree(dwc->scratchbuf); } @@ -629,7 +629,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; - dwc->regs = (int *)(dwc3_dev->base + DWC3_GLOBALS_REGS_START); + dwc->regs = (void *)(uintptr_t)(dwc3_dev->base + + DWC3_GLOBALS_REGS_START); /* default to highest possible threshold */ lpm_nyet_threshold = 0xff; diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index aba614f..12b133f 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -81,8 +81,8 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, trb->ctrl |= (DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_LST); - dwc3_flush_cache((int)buf_dma, len); - dwc3_flush_cache((int)trb, sizeof(*trb)); + dwc3_flush_cache((long)buf_dma, len); + dwc3_flush_cache((long)trb, sizeof(*trb)); if (chain) return 0; @@ -790,7 +790,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, if (!r) return; - dwc3_flush_cache((int)trb, sizeof(*trb)); + dwc3_flush_cache((long)trb, sizeof(*trb)); status = DWC3_TRB_SIZE_TRBSTS(trb->size); if (status == DWC3_TRBSTS_SETUP_PENDING) { @@ -821,7 +821,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, ur->actual += transferred; trb++; - dwc3_flush_cache((int)trb, sizeof(*trb)); + dwc3_flush_cache((long)trb, sizeof(*trb)); length = trb->size & DWC3_TRB_SIZE_MASK; ep0->free_slot = 0; @@ -831,7 +831,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, maxp); transferred = min_t(u32, ur->length - transferred, transfer_size - length); - dwc3_flush_cache((int)dwc->ep0_bounce, DWC3_EP0_BOUNCE_SIZE); + dwc3_flush_cache((long)dwc->ep0_bounce, DWC3_EP0_BOUNCE_SIZE); memcpy(buf, dwc->ep0_bounce, transferred); } else { transferred = ur->length - length; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f3d649a..8ff949d 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -244,7 +244,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, list_del(&req->list); req->trb = NULL; - dwc3_flush_cache((int)req->request.dma, req->request.length); + dwc3_flush_cache((long)req->request.dma, req->request.length); if (req->request.status == -EINPROGRESS) req->request.status = status; @@ -771,8 +771,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, trb->ctrl |= DWC3_TRB_CTRL_HWO; - dwc3_flush_cache((int)dma, length); - dwc3_flush_cache((int)trb, sizeof(*trb)); + dwc3_flush_cache((long)dma, length); + dwc3_flush_cache((long)trb, sizeof(*trb)); } /* @@ -1769,7 +1769,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, slot %= DWC3_TRB_NUM; trb = &dep->trb_pool[slot]; - dwc3_flush_cache((int)trb, sizeof(*trb)); + dwc3_flush_cache((long)trb, sizeof(*trb)); __dwc3_cleanup_done_trbs(dwc, dep, req, trb, event, status); dwc3_gadget_giveback(dep, req, status); @@ -2670,7 +2670,7 @@ void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc) for (i = 0; i < dwc->num_event_buffers; i++) { evt = dwc->ev_buffs[i]; - dwc3_flush_cache((int)evt->buf, evt->length); + dwc3_flush_cache((long)evt->buf, evt->length); } dwc3_thread_interrupt(0, dwc); diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index 5042a24..0d9fa22 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -23,7 +23,7 @@ #define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE static inline u32 dwc3_readl(void __iomem *base, u32 offset) { - u32 offs = offset - DWC3_GLOBALS_REGS_START; + unsigned long offs = offset - DWC3_GLOBALS_REGS_START; u32 value; /* @@ -38,7 +38,7 @@ static inline u32 dwc3_readl(void __iomem *base, u32 offset) static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) { - u32 offs = offset - DWC3_GLOBALS_REGS_START; + unsigned long offs = offset - DWC3_GLOBALS_REGS_START; /* * We requested the mem region starting from the Globals address -- cgit v0.10.2 From 32191755d75a28a88ca980c89c1fa15db4920510 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 30 Oct 2015 16:19:43 +0100 Subject: usb: lthor: Specify correct parameter for sizeof type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch removes this warning: CC drivers/usb/gadget/f_thor.o drivers/usb/gadget/f_thor.c: In function ‘thor_tx_data’: drivers/usb/gadget/f_thor.c:572:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=] debug("%s: dev->in_req->length:%d to_cpy:%d\n", __func__, ^ Signed-off-by: Michal Simek diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c index ff1481b..9ed0ce3 100644 --- a/drivers/usb/gadget/f_thor.c +++ b/drivers/usb/gadget/f_thor.c @@ -569,7 +569,7 @@ static void thor_tx_data(unsigned char *data, int len) dev->in_req->length = len; - debug("%s: dev->in_req->length:%d to_cpy:%d\n", __func__, + debug("%s: dev->in_req->length:%d to_cpy:%zd\n", __func__, dev->in_req->length, sizeof(data)); status = usb_ep_queue(dev->in_ep, dev->in_req, 0); -- cgit v0.10.2 From f6fcebf5c181365a3c9ebc672d88121d54359eed Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 30 Oct 2015 16:21:30 +0100 Subject: usb: udc: Fix warnings on 64-bit builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cast u32 bit value to 64bit before recasting to 64bit pointer to avoid pointer from integer cast size mismatch warnings. Warning log: +../drivers/usb/gadget/udc/udc-core.c: In function ‘usb_gadget_unmap_request’: +../drivers/usb/gadget/udc/udc-core.c:68:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Signed-off-by: Michal Simek diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 875e998..326757b 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -65,7 +65,7 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget, if (req->length == 0) return; - dma_unmap_single((void *)req->dma, req->length, + dma_unmap_single((void *)(uintptr_t)req->dma, req->length, is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); } EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); -- cgit v0.10.2