Merge branch 'master' of git://git.denx.de/u-boot-usb
This commit is contained in:
commit
bdf1ea11c8
@ -1440,10 +1440,8 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
|
||||
" Request Sense returned %02X %02X %02X\n",
|
||||
pccb->sense_buf[2], pccb->sense_buf[12],
|
||||
pccb->sense_buf[13]);
|
||||
if (dev_desc->removable == 1) {
|
||||
if (dev_desc->removable == 1)
|
||||
dev_desc->type = perq;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
pccb->pdata = (unsigned char *)cap;
|
||||
|
@ -122,6 +122,8 @@ static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
|
||||
if (!evt->buf)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
dwc3_flush_cache((uintptr_t)evt->buf, evt->length);
|
||||
|
||||
return evt;
|
||||
}
|
||||
|
||||
|
@ -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((long)buf_dma, len);
|
||||
dwc3_flush_cache((long)trb, sizeof(*trb));
|
||||
dwc3_flush_cache((uintptr_t)buf_dma, len);
|
||||
dwc3_flush_cache((uintptr_t)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((long)trb, sizeof(*trb));
|
||||
dwc3_flush_cache((uintptr_t)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((long)trb, sizeof(*trb));
|
||||
dwc3_flush_cache((uintptr_t)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((long)dwc->ep0_bounce, DWC3_EP0_BOUNCE_SIZE);
|
||||
dwc3_flush_cache((uintptr_t)dwc->ep0_bounce, DWC3_EP0_BOUNCE_SIZE);
|
||||
memcpy(buf, dwc->ep0_bounce, transferred);
|
||||
} else {
|
||||
transferred = ur->length - length;
|
||||
|
@ -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((long)req->request.dma, req->request.length);
|
||||
dwc3_flush_cache((uintptr_t)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((long)dma, length);
|
||||
dwc3_flush_cache((long)trb, sizeof(*trb));
|
||||
dwc3_flush_cache((uintptr_t)dma, length);
|
||||
dwc3_flush_cache((uintptr_t)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((long)trb, sizeof(*trb));
|
||||
dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
|
||||
__dwc3_cleanup_done_trbs(dwc, dep, req, trb, event, status);
|
||||
dwc3_gadget_giveback(dep, req, status);
|
||||
|
||||
@ -2668,11 +2668,12 @@ void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc)
|
||||
int i;
|
||||
struct dwc3_event_buffer *evt;
|
||||
|
||||
dwc3_thread_interrupt(0, dwc);
|
||||
|
||||
/* Clean + Invalidate the buffers after touching them */
|
||||
for (i = 0; i < dwc->num_event_buffers; i++) {
|
||||
evt = dwc->ev_buffs[i];
|
||||
dwc3_flush_cache((long)evt->buf, evt->length);
|
||||
dwc3_flush_cache((uintptr_t)evt->buf, evt->length);
|
||||
}
|
||||
|
||||
dwc3_thread_interrupt(0, dwc);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
|
||||
writel(value, base + offs);
|
||||
}
|
||||
|
||||
static inline void dwc3_flush_cache(int addr, int length)
|
||||
static inline void dwc3_flush_cache(uintptr_t addr, int length)
|
||||
{
|
||||
flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
#define STRING_USBDOWN 2
|
||||
/* Index of String serial */
|
||||
#define STRING_SERIAL 3
|
||||
#define MAX_STRING_SERIAL 32
|
||||
#define MAX_STRING_SERIAL 256
|
||||
/* Number of supported configurations */
|
||||
#define CONFIGURATION_NUMBER 1
|
||||
|
||||
@ -62,8 +62,8 @@ static struct usb_device_descriptor device_desc = {
|
||||
|
||||
.idVendor = __constant_cpu_to_le16(CONFIG_G_DNL_VENDOR_NUM),
|
||||
.idProduct = __constant_cpu_to_le16(CONFIG_G_DNL_PRODUCT_NUM),
|
||||
.iProduct = STRING_PRODUCT,
|
||||
.iSerialNumber = STRING_SERIAL,
|
||||
/* .iProduct = DYNAMIC */
|
||||
/* .iSerialNumber = DYNAMIC */
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
@ -224,12 +224,14 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
|
||||
g_dnl_string_defs[1].id = id;
|
||||
device_desc.iProduct = id;
|
||||
|
||||
id = usb_string_id(cdev);
|
||||
if (id < 0)
|
||||
return id;
|
||||
if (strlen(g_dnl_serial)) {
|
||||
id = usb_string_id(cdev);
|
||||
if (id < 0)
|
||||
return id;
|
||||
|
||||
g_dnl_string_defs[2].id = id;
|
||||
device_desc.iSerialNumber = id;
|
||||
g_dnl_string_defs[2].id = id;
|
||||
device_desc.iSerialNumber = id;
|
||||
}
|
||||
|
||||
g_dnl_bind_fixup(&device_desc, cdev->driver->name);
|
||||
ret = g_dnl_config_register(cdev);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <usbroothubdes.h>
|
||||
#include <wait_bit.h>
|
||||
#include <asm/io.h>
|
||||
#include <power/regulator.h>
|
||||
|
||||
#include "dwc2.h"
|
||||
|
||||
@ -159,6 +160,33 @@ static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
|
||||
mdelay(100);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
|
||||
static int dwc_vbus_supply_init(struct udevice *dev)
|
||||
{
|
||||
struct udevice *vbus_supply;
|
||||
int ret;
|
||||
|
||||
ret = device_get_supply_regulator(dev, "vbus-supply", &vbus_supply);
|
||||
if (ret) {
|
||||
debug("%s: No vbus supply\n", dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = regulator_set_enable(vbus_supply, true);
|
||||
if (ret) {
|
||||
error("Error enabling vbus supply\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int dwc_vbus_supply_init(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This function initializes the DWC_otg controller registers for
|
||||
* host mode.
|
||||
@ -167,10 +195,12 @@ static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
|
||||
* request queues. Host channels are reset to ensure that they are ready for
|
||||
* performing transfers.
|
||||
*
|
||||
* @param dev USB Device (NULL if driver model is not being used)
|
||||
* @param regs Programming view of DWC_otg controller
|
||||
*
|
||||
*/
|
||||
static void dwc_otg_core_host_init(struct dwc2_core_regs *regs)
|
||||
static void dwc_otg_core_host_init(struct udevice *dev,
|
||||
struct dwc2_core_regs *regs)
|
||||
{
|
||||
uint32_t nptxfifosize = 0;
|
||||
uint32_t ptxfifosize = 0;
|
||||
@ -248,6 +278,9 @@ static void dwc_otg_core_host_init(struct dwc2_core_regs *regs)
|
||||
writel(hprt0, ®s->hprt0);
|
||||
}
|
||||
}
|
||||
|
||||
if (dev)
|
||||
dwc_vbus_supply_init(dev);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -784,12 +817,19 @@ static int transfer_chunk(struct dwc2_hc_regs *hc_regs, void *aligned_buffer,
|
||||
(*pid << DWC2_HCTSIZ_PID_OFFSET),
|
||||
&hc_regs->hctsiz);
|
||||
|
||||
if (!in && xfer_len) {
|
||||
memcpy(aligned_buffer, buffer, xfer_len);
|
||||
|
||||
flush_dcache_range((unsigned long)aligned_buffer,
|
||||
(unsigned long)aligned_buffer +
|
||||
roundup(xfer_len, ARCH_DMA_MINALIGN));
|
||||
if (xfer_len) {
|
||||
if (in) {
|
||||
invalidate_dcache_range(
|
||||
(uintptr_t)aligned_buffer,
|
||||
(uintptr_t)aligned_buffer +
|
||||
roundup(xfer_len, ARCH_DMA_MINALIGN));
|
||||
} else {
|
||||
memcpy(aligned_buffer, buffer, xfer_len);
|
||||
flush_dcache_range(
|
||||
(uintptr_t)aligned_buffer,
|
||||
(uintptr_t)aligned_buffer +
|
||||
roundup(xfer_len, ARCH_DMA_MINALIGN));
|
||||
}
|
||||
}
|
||||
|
||||
writel(phys_to_bus((unsigned long)aligned_buffer), &hc_regs->hcdma);
|
||||
@ -1048,7 +1088,7 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
static int dwc2_init_common(struct dwc2_priv *priv)
|
||||
static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
|
||||
{
|
||||
struct dwc2_core_regs *regs = priv->regs;
|
||||
uint32_t snpsid;
|
||||
@ -1070,7 +1110,7 @@ static int dwc2_init_common(struct dwc2_priv *priv)
|
||||
#endif
|
||||
|
||||
dwc_otg_core_init(priv);
|
||||
dwc_otg_core_host_init(regs);
|
||||
dwc_otg_core_host_init(dev, regs);
|
||||
|
||||
clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA |
|
||||
DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |
|
||||
@ -1143,7 +1183,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
|
||||
if (board_usb_init(index, USB_INIT_HOST))
|
||||
return -1;
|
||||
|
||||
return dwc2_init_common(priv);
|
||||
return dwc2_init_common(NULL, priv);
|
||||
}
|
||||
|
||||
int usb_lowlevel_stop(int index)
|
||||
@ -1214,7 +1254,7 @@ static int dwc2_usb_probe(struct udevice *dev)
|
||||
|
||||
bus_priv->desc_before_addr = true;
|
||||
|
||||
return dwc2_init_common(priv);
|
||||
return dwc2_init_common(dev, priv);
|
||||
}
|
||||
|
||||
static int dwc2_usb_remove(struct udevice *dev)
|
||||
|
Loading…
Reference in New Issue
Block a user